react-native-unistyles 3.0.0-alpha.4 → 3.0.0-alpha.40
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/Unistyles.podspec +1 -1
- package/android/CMakeLists.txt +19 -45
- package/android/build.gradle +6 -5
- package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
- package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
- package/android/src/main/cxx/cpp-adapter.cpp +8 -86
- package/android/src/main/java/com/unistyles/Equatable.kt +61 -0
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +285 -0
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +152 -0
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +59 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +51 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
- package/cxx/NativePlatform.h +11 -0
- package/cxx/common/Constants.h +3 -0
- package/cxx/common/Helpers.h +140 -5
- package/cxx/core/HostStyle.cpp +10 -6
- package/cxx/core/HostStyle.h +4 -0
- package/cxx/core/StyleSheet.h +0 -2
- package/cxx/core/StyleSheetRegistry.cpp +9 -17
- package/cxx/core/StyleSheetRegistry.h +3 -4
- package/cxx/core/Unistyle.h +8 -11
- package/cxx/core/UnistyleData.h +23 -0
- package/cxx/core/UnistyleWrapper.h +108 -13
- package/cxx/core/UnistylesCommitHook.cpp +14 -15
- package/cxx/core/UnistylesCommitHook.h +6 -11
- package/cxx/core/UnistylesCommitShadowNode.h +13 -0
- package/cxx/core/UnistylesMountHook.cpp +28 -0
- package/cxx/core/UnistylesMountHook.h +27 -0
- package/cxx/core/UnistylesRegistry.cpp +119 -83
- package/cxx/core/UnistylesRegistry.h +16 -14
- package/cxx/core/UnistylesState.cpp +29 -8
- package/cxx/core/UnistylesState.h +5 -2
- package/cxx/hybridObjects/HybridNavigationBar.cpp +0 -4
- package/cxx/hybridObjects/HybridNavigationBar.h +3 -4
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +16 -11
- package/cxx/hybridObjects/HybridStatusBar.cpp +0 -4
- package/cxx/hybridObjects/HybridStatusBar.h +3 -4
- package/cxx/hybridObjects/HybridStyleSheet.cpp +154 -23
- package/cxx/hybridObjects/HybridStyleSheet.h +27 -5
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +96 -14
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +19 -3
- package/cxx/parser/Parser.cpp +226 -175
- package/cxx/parser/Parser.h +11 -15
- package/cxx/shadowTree/ShadowLeafUpdate.h +2 -1
- package/cxx/shadowTree/ShadowTrafficController.h +71 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +23 -18
- package/cxx/shadowTree/ShadowTreeManager.h +3 -2
- package/ios/Equatable.swift +2 -1
- package/ios/NativePlatform+ios.swift +21 -7
- package/ios/NativePlatform+keyboard.swift +83 -0
- package/ios/NativePlatformListener+ios.swift +37 -24
- package/ios/Unistyles.h +1 -0
- package/ios/UnistylesModuleOnLoad.h +8 -2
- package/ios/UnistylesModuleOnLoad.mm +9 -1
- package/lib/commonjs/components/Display.js +18 -0
- package/lib/commonjs/components/Display.js.map +1 -0
- package/lib/commonjs/components/Hide.js +18 -0
- package/lib/commonjs/components/Hide.js.map +1 -0
- package/lib/commonjs/components/index.js +20 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/components/useMedia.js +59 -0
- package/lib/commonjs/components/useMedia.js.map +1 -0
- package/lib/commonjs/components/useMedia.web.js +43 -0
- package/lib/commonjs/components/useMedia.web.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +79 -0
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.native.js +82 -0
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -0
- package/lib/commonjs/core/index.js +13 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/index.js +21 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mq.js +25 -12
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/NavigtionBar/index.js +0 -15
- package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +10 -6
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js +0 -5
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +1 -0
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -3
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.js +7 -0
- package/lib/commonjs/specs/index.js.map +1 -1
- package/lib/commonjs/specs/index.web.js +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/utils.js +26 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/convert/index.js +79 -0
- package/lib/commonjs/web/convert/index.js.map +1 -0
- package/lib/commonjs/web/convert/module.d.js +2 -0
- package/lib/commonjs/web/convert/module.d.js.map +1 -0
- package/lib/commonjs/web/convert/object/boxShadow.js +59 -0
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/object/filter.js +42 -0
- package/lib/commonjs/web/convert/object/filter.js.map +1 -0
- package/lib/commonjs/web/convert/object/index.js +39 -0
- package/lib/commonjs/web/convert/object/index.js.map +1 -0
- package/lib/commonjs/web/convert/object/objectStyle.js +56 -0
- package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
- package/lib/commonjs/web/convert/object/transform.js +27 -0
- package/lib/commonjs/web/convert/object/transform.js.map +1 -0
- package/lib/commonjs/web/convert/pseudo.js +10 -0
- package/lib/commonjs/web/convert/pseudo.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/boxShadow.js +62 -0
- package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/index.js +28 -0
- package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/textShadow.js +59 -0
- package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/style.js +93 -0
- package/lib/commonjs/web/convert/style.js.map +1 -0
- package/lib/commonjs/web/convert/types.js +9 -0
- package/lib/commonjs/web/convert/types.js.map +1 -0
- package/lib/commonjs/web/convert/utils.js +59 -0
- package/lib/commonjs/web/convert/utils.js.map +1 -0
- package/lib/commonjs/web/create.js +49 -0
- package/lib/commonjs/web/create.js.map +1 -0
- package/lib/commonjs/web/index.js +60 -0
- package/lib/commonjs/web/index.js.map +1 -0
- package/lib/commonjs/web/listener.js +61 -0
- package/lib/commonjs/web/listener.js.map +1 -0
- package/lib/commonjs/web/mock.js +27 -0
- package/lib/commonjs/web/mock.js.map +1 -0
- package/lib/commonjs/web/registry.js +172 -0
- package/lib/commonjs/web/registry.js.map +1 -0
- package/lib/commonjs/web/runtime.js +173 -0
- package/lib/commonjs/web/runtime.js.map +1 -0
- package/lib/commonjs/web/shadowRegistry.js +142 -0
- package/lib/commonjs/web/shadowRegistry.js.map +1 -0
- package/lib/commonjs/web/state.js +73 -0
- package/lib/commonjs/web/state.js.map +1 -0
- package/lib/commonjs/web/utils/common.js +39 -0
- package/lib/commonjs/web/utils/common.js.map +1 -0
- package/lib/commonjs/web/utils/index.js +28 -0
- package/lib/commonjs/web/utils/index.js.map +1 -0
- package/lib/commonjs/web/utils/unistyle.js +85 -0
- package/lib/commonjs/web/utils/unistyle.js.map +1 -0
- package/lib/commonjs/web/variants/getVariants.js +39 -0
- package/lib/commonjs/web/variants/getVariants.js.map +1 -0
- package/lib/commonjs/web/variants/index.js +28 -0
- package/lib/commonjs/web/variants/index.js.map +1 -0
- package/lib/commonjs/web/variants/useVariants.js +59 -0
- package/lib/commonjs/web/variants/useVariants.js.map +1 -0
- package/lib/module/components/Display.js +13 -0
- package/lib/module/components/Display.js.map +1 -0
- package/lib/module/components/Hide.js +13 -0
- package/lib/module/components/Hide.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/components/useMedia.js +54 -0
- package/lib/module/components/useMedia.js.map +1 -0
- package/lib/module/components/useMedia.web.js +38 -0
- package/lib/module/components/useMedia.web.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +72 -0
- package/lib/module/core/createUnistylesComponent.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.native.js +75 -0
- package/lib/module/core/createUnistylesComponent.native.js.map +1 -0
- package/lib/module/core/index.js +4 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/index.js +2 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/mq.js +21 -11
- package/lib/module/mq.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/NavigtionBar/index.js +0 -10
- package/lib/module/specs/NavigtionBar/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +10 -6
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js +1 -6
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +1 -0
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js +1 -3
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.js +2 -1
- package/lib/module/specs/index.js.map +1 -1
- package/lib/module/specs/index.web.js +1 -1
- package/lib/module/specs/index.web.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/utils.js +21 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/convert/index.js +74 -0
- package/lib/module/web/convert/index.js.map +1 -0
- package/lib/module/web/convert/module.d.js +2 -0
- package/lib/module/web/convert/module.d.js.map +1 -0
- package/lib/module/web/convert/object/boxShadow.js +54 -0
- package/lib/module/web/convert/object/boxShadow.js.map +1 -0
- package/lib/module/web/convert/object/filter.js +37 -0
- package/lib/module/web/convert/object/filter.js.map +1 -0
- package/lib/module/web/convert/object/index.js +6 -0
- package/lib/module/web/convert/object/index.js.map +1 -0
- package/lib/module/web/convert/object/objectStyle.js +51 -0
- package/lib/module/web/convert/object/objectStyle.js.map +1 -0
- package/lib/module/web/convert/object/transform.js +22 -0
- package/lib/module/web/convert/object/transform.js.map +1 -0
- package/lib/module/web/convert/pseudo.js +5 -0
- package/lib/module/web/convert/pseudo.js.map +1 -0
- package/lib/module/web/convert/shadow/boxShadow.js +57 -0
- package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/module/web/convert/shadow/index.js +5 -0
- package/lib/module/web/convert/shadow/index.js.map +1 -0
- package/lib/module/web/convert/shadow/textShadow.js +54 -0
- package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/module/web/convert/style.js +88 -0
- package/lib/module/web/convert/style.js.map +1 -0
- package/lib/module/web/convert/types.js +5 -0
- package/lib/module/web/convert/types.js.map +1 -0
- package/lib/module/web/convert/utils.js +45 -0
- package/lib/module/web/convert/utils.js.map +1 -0
- package/lib/module/web/create.js +44 -0
- package/lib/module/web/create.js.map +1 -0
- package/lib/module/web/index.js +26 -0
- package/lib/module/web/index.js.map +1 -0
- package/lib/module/web/listener.js +57 -0
- package/lib/module/web/listener.js.map +1 -0
- package/lib/module/web/mock.js +23 -0
- package/lib/module/web/mock.js.map +1 -0
- package/lib/module/web/registry.js +168 -0
- package/lib/module/web/registry.js.map +1 -0
- package/lib/module/web/runtime.js +169 -0
- package/lib/module/web/runtime.js.map +1 -0
- package/lib/module/web/shadowRegistry.js +138 -0
- package/lib/module/web/shadowRegistry.js.map +1 -0
- package/lib/module/web/state.js +69 -0
- package/lib/module/web/state.js.map +1 -0
- package/lib/module/web/utils/common.js +28 -0
- package/lib/module/web/utils/common.js.map +1 -0
- package/lib/module/web/utils/index.js +5 -0
- package/lib/module/web/utils/index.js.map +1 -0
- package/lib/module/web/utils/unistyle.js +72 -0
- package/lib/module/web/utils/unistyle.js.map +1 -0
- package/lib/module/web/variants/getVariants.js +34 -0
- package/lib/module/web/variants/getVariants.js.map +1 -0
- package/lib/module/web/variants/index.js +5 -0
- package/lib/module/web/variants/index.js.map +1 -0
- package/lib/module/web/variants/useVariants.js +54 -0
- package/lib/module/web/variants/useVariants.js.map +1 -0
- package/lib/typescript/src/components/Display.d.ts +7 -0
- package/lib/typescript/src/components/Display.d.ts.map +1 -0
- package/lib/typescript/src/components/Hide.d.ts +7 -0
- package/lib/typescript/src/components/Hide.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/components/useMedia.d.ts +6 -0
- package/lib/typescript/src/components/useMedia.d.ts.map +1 -0
- package/lib/typescript/src/components/useMedia.web.d.ts +6 -0
- package/lib/typescript/src/components/useMedia.web.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +8 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +8 -0
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +2 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts +8 -0
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +7 -5
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/index.d.ts +1 -10
- package/lib/typescript/src/specs/NavigtionBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +4 -4
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +3 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts +2 -4
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +3 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +3 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +3 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.d.ts +4 -2
- package/lib/typescript/src/specs/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.web.d.ts +1 -1
- package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +11 -11
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +1 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +6 -4
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +4 -1
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +2 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/index.d.ts +3 -0
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
- package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/pseudo.d.ts +6 -0
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts +8 -0
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts +8 -0
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/style.d.ts +2 -0
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/types.d.ts +8 -2
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/utils.d.ts +12 -0
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/create.d.ts +1443 -0
- package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +1459 -0
- package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
- package/lib/typescript/{web/listener → src/web}/listener.d.ts +5 -2
- package/lib/typescript/src/web/listener.d.ts.map +1 -0
- package/lib/typescript/src/web/mock.d.ts +5 -0
- package/lib/typescript/src/web/mock.d.ts.map +1 -0
- package/lib/typescript/src/web/registry.d.ts +24 -0
- package/lib/typescript/src/web/registry.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/runtime.d.ts +11 -10
- package/lib/typescript/src/web/runtime.d.ts.map +1 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
- package/lib/typescript/src/web/state.d.ts +18 -0
- package/lib/typescript/src/web/state.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/common.d.ts +8 -0
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/index.d.ts +3 -0
- package/lib/typescript/src/web/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts +20 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/index.d.ts +3 -0
- package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +57 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +69 -0
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +35 -34
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +15 -6
- package/nitrogen/generated/android/c++/JOrientation.hpp +1 -1
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +4 -1
- package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +9 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/{Func_void_std__vector_UnistyleDependency_.kt → Func_void_UnistylesNativeMiniRuntime.kt} +6 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +25 -13
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +3 -1
- package/nitrogen/generated/android/unistyles+autolinking.cmake +13 -1
- package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
- package/nitrogen/generated/android/{UnistylesOnLoad.cpp → unistylesOnLoad.cpp} +6 -4
- package/nitrogen/generated/android/{UnistylesOnLoad.hpp → unistylesOnLoad.hpp} +1 -1
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +6 -4
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +25 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +73 -38
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -29
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +8 -8
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +4 -16
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +156 -115
- package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
- package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +16 -5
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.cpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +6 -3
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +5 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +2 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +10 -4
- package/nitrogen/generated/shared/c++/Orientation.hpp +2 -2
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +10 -9
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +9 -8
- package/package.json +20 -30
- package/plugin/common.js +31 -3
- package/plugin/index.js +107 -18
- package/plugin/ref.js +129 -13
- package/plugin/style.js +189 -22
- package/plugin/stylesheet.js +53 -3
- package/plugin/variants.js +33 -0
- package/src/components/Display.tsx +12 -0
- package/src/components/Hide.tsx +12 -0
- package/src/components/index.ts +2 -0
- package/src/components/useMedia.ts +64 -0
- package/src/components/useMedia.web.ts +47 -0
- package/src/core/createUnistylesComponent.native.tsx +83 -0
- package/src/core/createUnistylesComponent.tsx +84 -0
- package/src/core/index.ts +1 -0
- package/src/index.ts +3 -12
- package/src/mq.ts +27 -9
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +7 -5
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.ts +0 -1
- package/src/specs/NavigtionBar/index.ts +1 -25
- package/src/specs/ShadowRegistry/index.ts +16 -10
- package/src/specs/ShadowRegistry/types.ts +4 -1
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.ts +0 -1
- package/src/specs/StatusBar/index.ts +2 -12
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +4 -1
- package/src/specs/StyleSheet/index.ts +6 -1
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
- package/src/specs/UnistylesRuntime/index.ts +5 -4
- package/src/specs/index.ts +6 -2
- package/src/specs/index.web.ts +1 -1
- package/src/types/breakpoints.ts +25 -13
- package/src/types/common.ts +1 -0
- package/src/types/index.ts +1 -1
- package/src/types/stylesheet.ts +7 -5
- package/src/types/variants.ts +7 -1
- package/src/utils.ts +22 -0
- package/{web → src/web}/convert/index.ts +25 -25
- package/src/web/convert/object/boxShadow.ts +55 -0
- package/src/web/convert/object/filter.ts +39 -0
- package/src/web/convert/object/index.ts +3 -0
- package/src/web/convert/object/objectStyle.ts +69 -0
- package/src/web/convert/object/transform.ts +24 -0
- package/src/web/convert/pseudo.ts +137 -0
- package/src/web/convert/shadow/boxShadow.ts +50 -0
- package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
- package/src/web/convert/shadow/index.ts +2 -0
- package/src/web/convert/shadow/textShadow.ts +48 -0
- package/{web → src/web}/convert/style.ts +61 -10
- package/{web → src/web}/convert/types.ts +9 -2
- package/{web → src/web}/convert/utils.ts +11 -5
- package/src/web/create.ts +48 -0
- package/{web → src/web}/index.ts +4 -3
- package/src/web/listener.ts +63 -0
- package/{web → src/web}/mock.ts +3 -14
- package/src/web/registry.ts +215 -0
- package/{web → src/web}/runtime.ts +32 -21
- package/src/web/shadowRegistry.ts +145 -0
- package/src/web/state.ts +94 -0
- package/src/web/utils/common.ts +45 -0
- package/src/web/utils/index.ts +2 -0
- package/src/web/utils/unistyle.ts +108 -0
- package/src/web/variants/getVariants.ts +42 -0
- package/src/web/variants/index.ts +2 -0
- package/src/web/variants/useVariants.ts +65 -0
- package/android/src/main/cxx/helpers.cpp +0 -105
- package/android/src/main/cxx/helpers.h +0 -16
- package/android/src/main/cxx/platform.cpp +0 -170
- package/android/src/main/cxx/platform.h +0 -20
- package/lib/typescript/example/App.d.ts +0 -4
- package/lib/typescript/example/App.d.ts.map +0 -1
- package/lib/typescript/example/unistyles.d.ts +0 -63
- package/lib/typescript/example/unistyles.d.ts.map +0 -1
- package/lib/typescript/expo-example/App.d.ts +0 -4
- package/lib/typescript/expo-example/App.d.ts.map +0 -1
- package/lib/typescript/expo-example/unistyles.d.ts +0 -63
- package/lib/typescript/expo-example/unistyles.d.ts.map +0 -1
- package/lib/typescript/web/convert/boxShadow.d.ts +0 -3
- package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/breakpoint.d.ts +0 -3
- package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
- package/lib/typescript/web/convert/index.d.ts +0 -4
- package/lib/typescript/web/convert/index.d.ts.map +0 -1
- package/lib/typescript/web/convert/shadow.d.ts +0 -2
- package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/style.d.ts +0 -3
- package/lib/typescript/web/convert/style.d.ts.map +0 -1
- package/lib/typescript/web/convert/textShadow.d.ts +0 -3
- package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/transform.d.ts +0 -5
- package/lib/typescript/web/convert/transform.d.ts.map +0 -1
- package/lib/typescript/web/convert/types.d.ts.map +0 -1
- package/lib/typescript/web/convert/utils.d.ts +0 -8
- package/lib/typescript/web/convert/utils.d.ts.map +0 -1
- package/lib/typescript/web/create.d.ts +0 -2449
- package/lib/typescript/web/index.d.ts +0 -2464
- package/lib/typescript/web/listener/index.d.ts +0 -2
- package/lib/typescript/web/listener/index.d.ts.map +0 -1
- package/lib/typescript/web/listener/listener.d.ts.map +0 -1
- package/lib/typescript/web/mock.d.ts +0 -14
- package/lib/typescript/web/mock.d.ts.map +0 -1
- package/lib/typescript/web/mq.d.ts +0 -4
- package/lib/typescript/web/mq.d.ts.map +0 -1
- package/lib/typescript/web/pseudo.d.ts +0 -4
- package/lib/typescript/web/pseudo.d.ts.map +0 -1
- package/lib/typescript/web/registry.d.ts +0 -12
- package/lib/typescript/web/registry.d.ts.map +0 -1
- package/lib/typescript/web/runtime.d.ts.map +0 -1
- package/lib/typescript/web/state.d.ts +0 -24
- package/lib/typescript/web/state.d.ts.map +0 -1
- package/lib/typescript/web/useVariants.d.ts +0 -3
- package/lib/typescript/web/useVariants.d.ts.map +0 -1
- package/lib/typescript/web/utils.d.ts +0 -18
- package/lib/typescript/web/utils.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency_.hpp +0 -60
- package/plugin/__tests__/dependencies.spec.js +0 -360
- package/plugin/__tests__/ref.spec.js +0 -991
- package/plugin/__tests__/stylesheet.spec.js +0 -396
- package/web/convert/boxShadow.ts +0 -72
- package/web/convert/breakpoint.ts +0 -21
- package/web/convert/shadow.ts +0 -68
- package/web/convert/textShadow.ts +0 -69
- package/web/convert/transform.ts +0 -89
- package/web/create.ts +0 -102
- package/web/listener/index.ts +0 -1
- package/web/listener/listener.ts +0 -33
- package/web/mq.ts +0 -19
- package/web/pseudo.ts +0 -11
- package/web/registry.ts +0 -41
- package/web/state.ts +0 -148
- package/web/useVariants.ts +0 -99
- package/web/utils.ts +0 -95
- /package/nitrogen/generated/android/{UnistylesOnLoad.kt → unistylesOnLoad.kt} +0 -0
- /package/{web → src/web}/convert/module.d.ts +0 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getTextShadowStyle = void 0;
|
7
|
+
var _utils = require("../../../utils");
|
8
|
+
var _types = require("../types");
|
9
|
+
var _utils2 = require("../utils");
|
10
|
+
var _getShadowBreakpoints = require("./getShadowBreakpoints");
|
11
|
+
const createTextShadowValue = style => {
|
12
|
+
const {
|
13
|
+
textShadowColor,
|
14
|
+
textShadowOffset,
|
15
|
+
textShadowRadius
|
16
|
+
} = style;
|
17
|
+
const offsetX = (0, _utils2.normalizeNumericValue)(textShadowOffset?.width ?? 0);
|
18
|
+
const offsetY = (0, _utils2.normalizeNumericValue)(textShadowOffset?.height ?? 0);
|
19
|
+
const radius = (0, _utils2.normalizeNumericValue)(textShadowRadius ?? 0);
|
20
|
+
const color = (0, _utils2.normalizeColor)(textShadowColor ?? '#000000');
|
21
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
22
|
+
};
|
23
|
+
const getTextShadowStyle = styles => {
|
24
|
+
const breakpoints = (0, _getShadowBreakpoints.getShadowBreakpoints)(_types.TEXT_SHADOW_STYLES, styles);
|
25
|
+
|
26
|
+
// If no breakpoints were used return styles without media queries
|
27
|
+
if (breakpoints.length === 0) {
|
28
|
+
return {
|
29
|
+
textShadow: createTextShadowValue(styles)
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
// Create textShadow for each breakpoint
|
34
|
+
const breakpointStyles = breakpoints.map(breakpoint => {
|
35
|
+
const color = (0, _utils2.extractShadowValue)('textShadowColor', breakpoint, styles);
|
36
|
+
const {
|
37
|
+
width,
|
38
|
+
height
|
39
|
+
} = (0, _utils2.extractShadowValue)('textShadowOffset', breakpoint, styles);
|
40
|
+
const radius = (0, _utils2.extractShadowValue)('textShadowRadius', breakpoint, styles);
|
41
|
+
return {
|
42
|
+
[breakpoint]: {
|
43
|
+
textShadow: createTextShadowValue({
|
44
|
+
textShadowColor: color,
|
45
|
+
textShadowOffset: {
|
46
|
+
width,
|
47
|
+
height
|
48
|
+
},
|
49
|
+
textShadowRadius: radius
|
50
|
+
})
|
51
|
+
}
|
52
|
+
};
|
53
|
+
});
|
54
|
+
|
55
|
+
// Merge all breakpoints styles into one
|
56
|
+
return (0, _utils.deepMergeObjects)(...breakpointStyles);
|
57
|
+
};
|
58
|
+
exports.getTextShadowStyle = getTextShadowStyle;
|
59
|
+
//# sourceMappingURL=textShadow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_utils","require","_types","_utils2","_getShadowBreakpoints","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","normalizeNumericValue","width","offsetY","height","radius","color","normalizeColor","getTextShadowStyle","styles","breakpoints","getShadowBreakpoints","TEXT_SHADOW_STYLES","length","textShadow","breakpointStyles","map","breakpoint","extractShadowValue","deepMergeObjects","exports"],"sourceRoot":"../../../../../src","sources":["web/convert/shadow/textShadow.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AAEA,MAAMI,qBAAqB,GAAIC,KAAiB,IAAK;EACjD,MAAM;IAAEC,eAAe;IAAEC,gBAAgB;IAAEC;EAAiB,CAAC,GAAGH,KAAK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EACA,OAAO,IAAAc,uBAAgB,EAAC,GAAGJ,gBAAgB,CAAC;AAChD,CAAC;AAAAK,OAAA,CAAAZ,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getStyle = void 0;
|
7
|
+
var _utils = require("../utils");
|
8
|
+
const SKIP_STYLES = ['borderCurve', 'elevation', 'textAlignVertical', 'includeFontPadding', 'overlayColor', 'tintColor'];
|
9
|
+
const CSS_NUMBER_KEYS = ['animationIterationCount', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'boxFlex', 'boxFlexGroup', 'boxOrdinalGroup', 'columnCount', 'columns', 'counterIncrement', 'counterReset', 'flex', 'flexGrow', 'flexPositive', 'flexShrink', 'flexNegative', 'flexOrder', 'fontWeight', 'gridArea', 'gridColumn', 'gridColumnEnd', 'gridColumnSpan', 'gridColumnStart', 'gridRow', 'gridRowEnd', 'gridRowSpan', 'gridRowStart', 'line-clamp', 'line-height', 'opacity', 'order', 'orphans', 'tabSize', 'widows', 'zIndex', 'zoom', 'fillOpacity', 'floodOpacity', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth'];
|
10
|
+
const convertMap = {
|
11
|
+
marginHorizontal: value => ({
|
12
|
+
marginInline: value
|
13
|
+
}),
|
14
|
+
marginVertical: value => ({
|
15
|
+
marginBlock: value
|
16
|
+
}),
|
17
|
+
paddingHorizontal: value => ({
|
18
|
+
paddingInline: value
|
19
|
+
}),
|
20
|
+
paddingVertical: value => ({
|
21
|
+
paddingBlock: value
|
22
|
+
}),
|
23
|
+
writingDirection: value => ({
|
24
|
+
direction: value
|
25
|
+
}),
|
26
|
+
borderBottomEndRadius: value => ({
|
27
|
+
borderBottomRightRadius: value
|
28
|
+
}),
|
29
|
+
borderBottomStartRadius: value => ({
|
30
|
+
borderBottomLeftRadius: value
|
31
|
+
}),
|
32
|
+
borderEndColor: value => ({
|
33
|
+
borderInlineEndColor: value
|
34
|
+
}),
|
35
|
+
borderStartColor: value => ({
|
36
|
+
borderInlineStartColor: value
|
37
|
+
}),
|
38
|
+
borderTopEndRadius: value => ({
|
39
|
+
borderTopRightRadius: value
|
40
|
+
}),
|
41
|
+
borderTopStartRadius: value => ({
|
42
|
+
borderTopLeftRadius: value
|
43
|
+
}),
|
44
|
+
borderEndWidth: value => ({
|
45
|
+
borderInlineEndWidth: value
|
46
|
+
}),
|
47
|
+
borderStartWidth: value => ({
|
48
|
+
borderInlineStartWidth: value
|
49
|
+
}),
|
50
|
+
end: value => ({
|
51
|
+
right: value
|
52
|
+
}),
|
53
|
+
start: value => ({
|
54
|
+
left: value
|
55
|
+
}),
|
56
|
+
marginEnd: value => ({
|
57
|
+
marginRight: value
|
58
|
+
}),
|
59
|
+
marginStart: value => ({
|
60
|
+
marginLeft: value
|
61
|
+
}),
|
62
|
+
paddingEnd: value => ({
|
63
|
+
paddingRight: value
|
64
|
+
}),
|
65
|
+
paddingStart: value => ({
|
66
|
+
paddingLeft: value
|
67
|
+
}),
|
68
|
+
transformMatrix: value => ({
|
69
|
+
transform: `matrix(${value.join(', ')})`
|
70
|
+
}),
|
71
|
+
resizeMode: value => ({
|
72
|
+
backgroundSize: value
|
73
|
+
})
|
74
|
+
};
|
75
|
+
const convertNumber = (key, value) => {
|
76
|
+
if (typeof value === 'number') {
|
77
|
+
return CSS_NUMBER_KEYS.includes(key, value) ? value : `${value}px`;
|
78
|
+
}
|
79
|
+
return value;
|
80
|
+
};
|
81
|
+
const getStyle = (key, value) => {
|
82
|
+
if (SKIP_STYLES.includes(key)) {
|
83
|
+
return {};
|
84
|
+
}
|
85
|
+
if ((0, _utils.keyInObject)(convertMap, key)) {
|
86
|
+
return convertMap[key]?.(convertNumber(key, value)) ?? {};
|
87
|
+
}
|
88
|
+
return {
|
89
|
+
[key]: convertNumber(key, value)
|
90
|
+
};
|
91
|
+
};
|
92
|
+
exports.getStyle = getStyle;
|
93
|
+
//# sourceMappingURL=style.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_utils","require","SKIP_STYLES","CSS_NUMBER_KEYS","convertMap","marginHorizontal","value","marginInline","marginVertical","marginBlock","paddingHorizontal","paddingInline","paddingVertical","paddingBlock","writingDirection","direction","borderBottomEndRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomLeftRadius","borderEndColor","borderInlineEndColor","borderStartColor","borderInlineStartColor","borderTopEndRadius","borderTopRightRadius","borderTopStartRadius","borderTopLeftRadius","borderEndWidth","borderInlineEndWidth","borderStartWidth","borderInlineStartWidth","end","right","start","left","marginEnd","marginRight","marginStart","marginLeft","paddingEnd","paddingRight","paddingStart","paddingLeft","transformMatrix","transform","join","resizeMode","backgroundSize","convertNumber","key","includes","getStyle","keyInObject","exports"],"sourceRoot":"../../../../src","sources":["web/convert/style.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,WAAW,GAAG,CAChB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,WAAW,CACd;AAED,MAAMC,eAAe,GAAG,CACpB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,MAAM,EACN,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,OAAO,EACP,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,aAAa,EACb,c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List":[]}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.TEXT_SHADOW_STYLES = exports.BOX_SHADOW_STYLES = void 0;
|
7
|
+
const TEXT_SHADOW_STYLES = exports.TEXT_SHADOW_STYLES = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
|
8
|
+
const BOX_SHADOW_STYLES = exports.BOX_SHADOW_STYLES = ['shadowColor', 'shadowRadius', 'shadowOpacity', 'shadowOffset'];
|
9
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["TEXT_SHADOW_STYLES","exports","BOX_SHADOW_STYLES"],"sourceRoot":"../../../../src","sources":["web/convert/types.ts"],"mappings":";;;;;;AAKO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,CAAU;AAI/F,MAAME,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,CAAC,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAU","ignoreList":[]}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.normalizeNumericValue = exports.normalizeColor = exports.isTransform = exports.isTextShadow = exports.isShadow = exports.isFilter = exports.isBoxShadow = exports.extractShadowValue = void 0;
|
7
|
+
var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
|
8
|
+
var _types = require("./types");
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
10
|
+
// based on react-native-web normalizer
|
11
|
+
// https://github.com/necolas/react-native-web
|
12
|
+
|
13
|
+
const isTransform = (key, value) => key === 'transform' && Array.isArray(value);
|
14
|
+
exports.isTransform = isTransform;
|
15
|
+
const isTextShadow = key => _types.TEXT_SHADOW_STYLES.includes(key);
|
16
|
+
exports.isTextShadow = isTextShadow;
|
17
|
+
const isShadow = key => _types.BOX_SHADOW_STYLES.includes(key);
|
18
|
+
exports.isShadow = isShadow;
|
19
|
+
const isFilter = (key, value) => key === 'filter' && Array.isArray(value);
|
20
|
+
exports.isFilter = isFilter;
|
21
|
+
const isBoxShadow = (key, value) => key === 'boxShadow' && Array.isArray(value);
|
22
|
+
exports.isBoxShadow = isBoxShadow;
|
23
|
+
const normalizeNumericValue = value => value && typeof value === 'number' ? `${value}px` : value;
|
24
|
+
exports.normalizeNumericValue = normalizeNumericValue;
|
25
|
+
const normalizeColor = (color, opacity = 1) => {
|
26
|
+
// If the opacity is 1 there's no need to normalize the color
|
27
|
+
if (opacity === 1) {
|
28
|
+
return color;
|
29
|
+
}
|
30
|
+
const integer = (0, _normalizeColors.default)(color);
|
31
|
+
|
32
|
+
// If the color is an unknown format, the return value is null
|
33
|
+
if (integer === null) {
|
34
|
+
return color;
|
35
|
+
}
|
36
|
+
const hex = integer.toString(16).padStart(8, '0');
|
37
|
+
if (hex.length === 8) {
|
38
|
+
const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
|
39
|
+
return `rgba(${r},${g},${b},${a / 255 * opacity})`;
|
40
|
+
}
|
41
|
+
return color;
|
42
|
+
};
|
43
|
+
exports.normalizeColor = normalizeColor;
|
44
|
+
const extractShadowValue = (key, breakpoint, styles) => {
|
45
|
+
const value = styles[key];
|
46
|
+
if (key === 'textShadowOffset' || key === 'shadowOffset') {
|
47
|
+
const {
|
48
|
+
width,
|
49
|
+
height
|
50
|
+
} = value;
|
51
|
+
return {
|
52
|
+
width: typeof width === 'object' ? width[breakpoint] : width,
|
53
|
+
height: typeof height === 'object' ? height[breakpoint] : height
|
54
|
+
};
|
55
|
+
}
|
56
|
+
return typeof value === 'object' ? value[breakpoint] : value;
|
57
|
+
};
|
58
|
+
exports.extractShadowValue = extractShadowValue;
|
59
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizeColors","_interopRequireDefault","require","_types","e","__esModule","default","isTransform","key","value","Array","isArray","exports","isTextShadow","TEXT_SHADOW_STYLES","includes","isShadow","BOX_SHADOW_STYLES","isFilter","isBoxShadow","normalizeNumericValue","normalizeColor","color","opacity","integer","normalizeColors","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","extractShadowValue","breakpoint","styles","width","height"],"sourceRoot":"../../../../src","sources":["web/convert/utils.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAiH,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAHjH;AACA;;AAMO,MAAMG,WAAW,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAAsCD,GAAG,KAAK,WAAW,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAAAG,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAE7H,MAAMM,YAAY,GAAIL,GAAW,IAAKM,yBAAkB,CAACC,QAAQ,CAACP,GAAwC,CAAC;AAAAI,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAE3G,MAAMG,QAAQ,GAAIR,GAAW,IAAKS,wBAAiB,CAACF,QAAQ,CAACP,GAAuC,CAAC;AAAAI,OAAA,CAAAI,QAAA,GAAAA,QAAA;AAErG,MAAME,QAAQ,GAAGA,CAACV,GAAW,EAAEC,KAAU,KAA8BD,GAAG,KAAK,QAAQ,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAAAG,OAAA,CAAAM,QAAA,GAAAA,QAAA;AAE/G,MAAMC,WAAW,GAAGA,CAACX,GAAW,E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AS,EAAEkC,UAAkB,EAAEC,MAAW,KAAsB;EAC3H,MAAMlC,KAAK,GAAGkC,MAAM,CAACnC,GAAG,CAAC;EAEzB,IAAIA,GAAG,KAAK,kBAAkB,IAAIA,GAAG,KAAK,cAAc,EAAE;IACtD,MAAM;MAAEoC,KAAK;MAAEC;IAAO,CAAC,GAAGpC,KAAK;IAE/B,OAAO;MACHmC,KAAK,EAAE,OAAOA,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAACF,UAAU,CAAC,GAAGE,KAAK;MAC5DC,MAAM,EAAE,OAAOA,MAAM,KAAK,QAAQ,GAAGA,MAAM,CAACH,UAAU,CAAC,GAAGG;IAC9D,CAAC;EACL;EAEA,OAAO,OAAOpC,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAACiC,UAAU,CAAC,GAAGjC,KAAK;AAChE,CAAC;AAAAG,OAAA,CAAA6B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.create = void 0;
|
7
|
+
var _utils = require("./utils");
|
8
|
+
var _utils2 = require("../utils");
|
9
|
+
var _runtime = require("./runtime");
|
10
|
+
var _variants = require("./variants");
|
11
|
+
const create = stylesheet => {
|
12
|
+
const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
|
13
|
+
const selectedVariants = new Map();
|
14
|
+
const copyVariants = () => Object.fromEntries(selectedVariants.entries());
|
15
|
+
const addSecrets = (value, key, args) => (0, _utils.assignSecrets)(value, {
|
16
|
+
__uni__key: key,
|
17
|
+
__uni__refs: new Set(),
|
18
|
+
__uni__stylesheet: stylesheet,
|
19
|
+
__uni__args: args,
|
20
|
+
__uni__variants: copyVariants()
|
21
|
+
});
|
22
|
+
const styles = (0, _utils.reduceObject)(computedStylesheet, (value, _key) => {
|
23
|
+
const key = String(_key);
|
24
|
+
if (typeof value === 'function') {
|
25
|
+
const dynamicStyle = (...args) => {
|
26
|
+
const result = value(...args);
|
27
|
+
const variants = Object.fromEntries((0, _variants.getVariants)({
|
28
|
+
[key]: result
|
29
|
+
}, copyVariants()));
|
30
|
+
const resultWithVariants = (0, _utils2.deepMergeObjects)(result, variants[key] ?? {});
|
31
|
+
|
32
|
+
// Add secrets to result of dynamic styles function
|
33
|
+
return addSecrets((0, _utils.getStyles)(resultWithVariants), key, args);
|
34
|
+
};
|
35
|
+
|
36
|
+
// Add secrets to dynamic styles function
|
37
|
+
return addSecrets(dynamicStyle, key);
|
38
|
+
}
|
39
|
+
|
40
|
+
// Add secrets to static styles
|
41
|
+
return addSecrets((0, _utils.getStyles)(value), key);
|
42
|
+
});
|
43
|
+
|
44
|
+
// Inject useVariants hook to styles
|
45
|
+
(0, _variants.createUseVariants)(styles, newVariants => Object.entries(newVariants).forEach(([key, value]) => selectedVariants.set(key, value)));
|
46
|
+
return styles;
|
47
|
+
};
|
48
|
+
exports.create = create;
|
49
|
+
//# sourceMappingURL=create.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_utils","require","_utils2","_runtime","_variants","create","stylesheet","computedStylesheet","UnistylesRuntime","theme","miniRuntime","selectedVariants","Map","copyVariants","Object","fromEntries","entries","addSecrets","value","key","args","assignSecrets","__uni__key","__uni__refs","Set","__uni__stylesheet","__uni__args","__uni__variants","styles","reduceObject","_key","String","dynamicStyle","result","variants","getVariants","resultWithVariants","deepMergeObjects","getStyles","createUseVariants","newVariants","forEach","set","exports"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEO,MAAMI,MAAM,GAAIC,UAAiD,IAAK;EACzE,MA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,IAAI,CAAC;MAC/D,CAAC;;MAED;MACA,OAAOH,UAAU,CAACe,YAAY,EAAEb,GAAG,CAAC;IACxC;;IAEA;IACA,OAAOF,UAAU,CAAC,IAAAqB,gBAAS,EAACpB,KAAK,CAAC,EAAEC,GAAG,CAAC;EAC5C,CAAC,CAAsC;;EAEvC;EACA,IAAAoB,2BAAiB,EAACX,MAAM,EAAEY,WAAW,IAAI1B,MAAM,CAACE,OAAO,CAACwB,WAAW,CAAC,CAACC,OAAO,CAAC,CAAC,CAACtB,GAAG,EAAED,KAAK,CAAC,KAAKP,gBAAgB,CAAC+B,GAAG,CAACvB,GAAG,EAAED,KAAK,CAAC,CAAC,CAAC;EAEjI,OAAOU,MAAM;AACjB,CAAC;AAAAe,OAAA,CAAAtC,MAAA,GAAAA,MAAA","ignoreList":[]}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
var _exportNames = {
|
7
|
+
StyleSheet: true,
|
8
|
+
getSSRUnistyles: true,
|
9
|
+
UnistylesRuntime: true,
|
10
|
+
UnistylesShadowRegistry: true
|
11
|
+
};
|
12
|
+
exports.StyleSheet = void 0;
|
13
|
+
Object.defineProperty(exports, "UnistylesRuntime", {
|
14
|
+
enumerable: true,
|
15
|
+
get: function () {
|
16
|
+
return _runtime.UnistylesRuntime;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports, "UnistylesShadowRegistry", {
|
20
|
+
enumerable: true,
|
21
|
+
get: function () {
|
22
|
+
return _shadowRegistry.UnistylesShadowRegistry;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
exports.getSSRUnistyles = void 0;
|
26
|
+
var _create = require("./create");
|
27
|
+
var _state = require("./state");
|
28
|
+
var _utils = require("../utils");
|
29
|
+
var _runtime = require("./runtime");
|
30
|
+
var _shadowRegistry = require("./shadowRegistry");
|
31
|
+
var _mock = require("./mock");
|
32
|
+
Object.keys(_mock).forEach(function (key) {
|
33
|
+
if (key === "default" || key === "__esModule") return;
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
35
|
+
if (key in exports && exports[key] === _mock[key]) return;
|
36
|
+
Object.defineProperty(exports, key, {
|
37
|
+
enumerable: true,
|
38
|
+
get: function () {
|
39
|
+
return _mock[key];
|
40
|
+
}
|
41
|
+
});
|
42
|
+
});
|
43
|
+
const StyleSheet = exports.StyleSheet = {
|
44
|
+
configure: _state.UnistylesState.init,
|
45
|
+
create: _create.create,
|
46
|
+
absoluteFill: {
|
47
|
+
position: 'absolute',
|
48
|
+
left: 0,
|
49
|
+
top: 0,
|
50
|
+
right: 0,
|
51
|
+
bottom: 0
|
52
|
+
},
|
53
|
+
compose: (a, b) => (0, _utils.deepMergeObjects)(a, b),
|
54
|
+
flatten: (...styles) => (0, _utils.deepMergeObjects)(...styles),
|
55
|
+
hairlineWidth: 1
|
56
|
+
};
|
57
|
+
// TODO: Work on SSR
|
58
|
+
const getSSRUnistyles = () => [];
|
59
|
+
exports.getSSRUnistyles = getSSRUnistyles;
|
60
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_create","require","_state","_utils","_runtime","_shadowRegistry","_mock","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","StyleSheet","configure","UnistylesState","init","create","absoluteFill","position","left","top","right","bottom","compose","a","b","deepMergeObjects","flatten","styles","hairlineWidth","getSSRUnistyles"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAiBA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAjBO,MAAMS,UAAU,GAAAJ,OAAA,CAAAI,UAAA,GAAG;EACtBC,SAAS,EAAEC,qBAAc,CAACC,IAAI;EAC9BC,MAAM,EAANA,cAAM;EACNC,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAK,IAAAC,uBAAgB,EAACF,CAAC,EAAEC,CAAC,CAAC;EACzDE,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAK,IAAAF,uBAAgB,EAAC,GAAGE,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAMD;AACO,MAAMC,eAAe,GAAGA,CAAA,KAAM,EAAE;AAAAtB,OAAA,CAAAsB,eAAA,GAAAA,eAAA","ignoreList":[]}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesListener = void 0;
|
7
|
+
var _NativePlatform = require("../specs/NativePlatform");
|
8
|
+
var _runtime = require("./runtime");
|
9
|
+
class UnistylesListenerBuilder {
|
10
|
+
isInitialized = false;
|
11
|
+
listeners = Array.from({
|
12
|
+
length: Object.keys(_NativePlatform.UnistyleDependency).length / 2
|
13
|
+
}, () => new Set());
|
14
|
+
stylesheetListeners = Array.from({
|
15
|
+
length: Object.keys(_NativePlatform.UnistyleDependency).length / 2
|
16
|
+
}, () => new Set());
|
17
|
+
emitChange = dependency => {
|
18
|
+
this.stylesheetListeners[dependency]?.forEach(listener => listener());
|
19
|
+
this.listeners[dependency]?.forEach(listener => listener());
|
20
|
+
};
|
21
|
+
initListeners = () => {
|
22
|
+
if (this.isInitialized) {
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
this.isInitialized = true;
|
26
|
+
_runtime.UnistylesRuntime.darkMedia?.addEventListener('change', event => {
|
27
|
+
if (!event.matches) {
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
this.emitChange(_NativePlatform.UnistyleDependency.ColorScheme);
|
31
|
+
if (_runtime.UnistylesRuntime.hasAdaptiveThemes) {
|
32
|
+
this.emitChange(_NativePlatform.UnistyleDependency.Theme);
|
33
|
+
}
|
34
|
+
});
|
35
|
+
_runtime.UnistylesRuntime.lightMedia?.addEventListener('change', event => {
|
36
|
+
if (!event.matches) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
this.emitChange(_NativePlatform.UnistyleDependency.ColorScheme);
|
40
|
+
if (_runtime.UnistylesRuntime.hasAdaptiveThemes) {
|
41
|
+
this.emitChange(_NativePlatform.UnistyleDependency.Theme);
|
42
|
+
}
|
43
|
+
});
|
44
|
+
window.addEventListener('orientationchange', () => this.emitChange(_NativePlatform.UnistyleDependency.Orientation));
|
45
|
+
window.addEventListener('resize', () => this.emitChange(_NativePlatform.UnistyleDependency.Dimensions));
|
46
|
+
};
|
47
|
+
addListeners = (dependencies, listener) => {
|
48
|
+
dependencies.forEach(dependency => this.listeners[dependency]?.add(listener));
|
49
|
+
return () => {
|
50
|
+
dependencies.forEach(dependency => this.listeners[dependency]?.delete(listener));
|
51
|
+
};
|
52
|
+
};
|
53
|
+
addStylesheetListeners = (dependencies, listener) => {
|
54
|
+
dependencies.forEach(dependency => this.stylesheetListeners[dependency]?.add(listener));
|
55
|
+
return () => {
|
56
|
+
dependencies.forEach(dependency => this.stylesheetListeners[dependency]?.delete(listener));
|
57
|
+
};
|
58
|
+
};
|
59
|
+
}
|
60
|
+
const UnistylesListener = exports.UnistylesListener = new UnistylesListenerBuilder();
|
61
|
+
//# sourceMappingURL=listener.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","stylesheetListeners","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","event","matches","ColorScheme","hasAdaptiveThemes","Theme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","addStylesheetListeners","UnistylesListener","exports"],"sourceRoot":"../../../src","sources":["web/listener.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,kCAAkB,CAAC,CAACH,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAII,GAAG,CAAe,CAAC,CAAC;EAC7GC,mBAAmB,GAAGP,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,kCAAkB,CAAC,CAACH,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAII,GAAG,CAAe,CAAC,CAAC;EAE/HE,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACF,mBAAmB,CAACE,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;IACrE,IAAI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AAChB,QAAQ,CAAC,CAAC;IAE7E,OAAO,MAAM;MACTe,YAAY,CAAChB,OAAO,CAACD,UAAU,IAAI,IAAI,CAACV,SAAS,CAACU,UAAU,CAAC,EAAEmB,MAAM,CAACjB,QAAQ,CAAC,CAAC;IACpF,CAAC;EACL,CAAC;EAEDkB,sBAAsB,GAAGA,CAACH,YAAuC,EAAEf,QAAsB,KAAK;IAC1Fe,YAAY,CAAChB,OAAO,CAACD,UAAU,IAAI,IAAI,CAACF,mBAAmB,CAACE,UAAU,CAAC,EAAEkB,GAAG,CAAChB,QAAQ,CAAC,CAAC;IAEvF,OAAO,MAAM;MACTe,YAAY,CAAChB,OAAO,CAACD,UAAU,IAAI,IAAI,CAACF,mBAAmB,CAACE,UAAU,CAAC,EAAEmB,MAAM,CAACjB,QAAQ,CAAC,CAAC;IAC9F,CAAC;EACL,CAAC;AACL;AAEO,MAAMmB,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAIjC,wBAAwB,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.StatusBar = exports.NavigationBar = void 0;
|
7
|
+
const StatusBar = exports.StatusBar = {
|
8
|
+
width: 0,
|
9
|
+
height: 0,
|
10
|
+
setStyle: () => {},
|
11
|
+
setHidden: () => {},
|
12
|
+
equals: () => true,
|
13
|
+
toString: () => 'StatusBar',
|
14
|
+
__type: 'web',
|
15
|
+
name: 'StatusBar'
|
16
|
+
};
|
17
|
+
const NavigationBar = exports.NavigationBar = {
|
18
|
+
width: 0,
|
19
|
+
height: 0,
|
20
|
+
setHidden: () => {},
|
21
|
+
equals: () => true,
|
22
|
+
dispose: () => {},
|
23
|
+
toString: () => 'NavigationBar',
|
24
|
+
__type: 'web',
|
25
|
+
name: 'NavigationBar'
|
26
|
+
};
|
27
|
+
//# sourceMappingURL=mock.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["StatusBar","exports","width","height","setStyle","setHidden","equals","toString","__type","name","NavigationBar","dispose"],"sourceRoot":"../../../src","sources":["web/mock.ts"],"mappings":";;;;;;AAGO,MAAMA,SAAwB,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACpCE,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClBC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,MAAM,EAAEA,CAAA,KAAM,IAAI;EAClBC,QAAQ,EAAEA,CAAA,KAAM,WAAW;EAC3BC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE;AACV,CAAC;AAEM,MAAMC,aAAgC,GAAAT,OAAA,CAAAS,aAAA,GAAG;EAC5CR,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTE,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,MAAM,EAAEA,CAAA,KAAM,IAAI;EAClBK,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBJ,QAAQ,EAAEA,CAAA,KAAM,eAAe;EAC/BC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE;AACV,CAAC","ignoreList":[]}
|
@@ -0,0 +1,172 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesRegistry = void 0;
|
7
|
+
var _runtime = require("./runtime");
|
8
|
+
var _utils = require("./utils");
|
9
|
+
var _listener = require("./listener");
|
10
|
+
var _convert = require("./convert");
|
11
|
+
class UnistylesRegistryBuilder {
|
12
|
+
stylesheets = new Map();
|
13
|
+
stylesCounter = new Map();
|
14
|
+
#styleTag = null;
|
15
|
+
disposeListenersMap = new Map();
|
16
|
+
dependenciesMap = new Map();
|
17
|
+
get styleTag() {
|
18
|
+
const tag = this.#styleTag;
|
19
|
+
if (!tag) {
|
20
|
+
const newTag = document.createElement('style');
|
21
|
+
newTag.id = 'unistyles-web';
|
22
|
+
this.#styleTag = newTag;
|
23
|
+
document.head.appendChild(newTag);
|
24
|
+
return newTag;
|
25
|
+
}
|
26
|
+
return tag;
|
27
|
+
}
|
28
|
+
getComputedStylesheet = stylesheet => {
|
29
|
+
if (typeof stylesheet !== 'function') {
|
30
|
+
return stylesheet;
|
31
|
+
}
|
32
|
+
const computedStylesheet = this.stylesheets.get(stylesheet);
|
33
|
+
if (computedStylesheet) {
|
34
|
+
return computedStylesheet;
|
35
|
+
}
|
36
|
+
const createdStylesheet = stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime);
|
37
|
+
const dependencies = Object.values(createdStylesheet).flatMap(value => (0, _utils.extractUnistyleDependencies)(value));
|
38
|
+
this.addDependenciesToStylesheet(stylesheet, dependencies);
|
39
|
+
this.stylesheets.set(stylesheet, createdStylesheet);
|
40
|
+
return createdStylesheet;
|
41
|
+
};
|
42
|
+
addDependenciesToStylesheet = (stylesheet, dependencies) => {
|
43
|
+
this.disposeListenersMap.get(stylesheet)?.();
|
44
|
+
const dependenciesMap = this.dependenciesMap.get(stylesheet) ?? new Set(dependencies);
|
45
|
+
dependencies.forEach(dependency => dependenciesMap.add(dependency));
|
46
|
+
const dispose = _listener.UnistylesListener.addStylesheetListeners(Array.from(dependenciesMap), () => {
|
47
|
+
const newComputedStylesheet = stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime);
|
48
|
+
this.stylesheets.set(stylesheet, newComputedStylesheet);
|
49
|
+
});
|
50
|
+
this.dependenciesMap.set(stylesheet, dependenciesMap);
|
51
|
+
this.disposeListenersMap.set(stylesheet, dispose);
|
52
|
+
};
|
53
|
+
add = value => {
|
54
|
+
const hash = (0, _utils.generateHash)(value);
|
55
|
+
const existingCounter = this.stylesCounter.get(hash);
|
56
|
+
if (!existingCounter || existingCounter.size === 0) {
|
57
|
+
const counter = new Set();
|
58
|
+
counter.add(value);
|
59
|
+
this.stylesCounter.set(hash, counter);
|
60
|
+
this.applyStyles(hash, (0, _convert.convertUnistyles)(value));
|
61
|
+
return {
|
62
|
+
hash,
|
63
|
+
existingHash: false
|
64
|
+
};
|
65
|
+
}
|
66
|
+
existingCounter.add(value);
|
67
|
+
return {
|
68
|
+
hash,
|
69
|
+
existingHash: true
|
70
|
+
};
|
71
|
+
};
|
72
|
+
applyStyles = (hash, styles) => {
|
73
|
+
Object.entries(styles).forEach(([key, value]) => {
|
74
|
+
if (!this.styleTag.sheet) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
if (typeof value === 'object' && !key.startsWith('_')) {
|
78
|
+
const mediaQuery = (0, _utils.getMediaQuery)(key);
|
79
|
+
const cssRules = Array.from(this.styleTag.sheet.cssRules);
|
80
|
+
let queryRule = cssRules.find(rule => {
|
81
|
+
if (!(rule instanceof CSSMediaRule)) {
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
return rule.media.item(0)?.includes(mediaQuery);
|
85
|
+
}) ?? null;
|
86
|
+
if (!queryRule) {
|
87
|
+
const mediaQueryValue = (0, _utils.extractMediaQueryValue)(mediaQuery);
|
88
|
+
const ruleIndex = mediaQueryValue ? cssRules.reduce((acc, rule, ruleIndex) => {
|
89
|
+
if (!(rule instanceof CSSMediaRule)) {
|
90
|
+
return acc;
|
91
|
+
}
|
92
|
+
const ruleMediaQueryValue = (0, _utils.extractMediaQueryValue)(rule.conditionText);
|
93
|
+
if (ruleMediaQueryValue === undefined) {
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
return ruleMediaQueryValue > mediaQueryValue ? ruleIndex : acc;
|
97
|
+
}, cssRules.length) : undefined;
|
98
|
+
queryRule = this.styleTag.sheet.cssRules.item(this.styleTag.sheet.insertRule(`@media ${mediaQuery} {.${hash} {}}`, ruleIndex));
|
99
|
+
}
|
100
|
+
if (queryRule instanceof CSSMediaRule) {
|
101
|
+
Object.entries(value).forEach(([mqKey, mqValue]) => {
|
102
|
+
this.applyRule({
|
103
|
+
hash,
|
104
|
+
key: mqKey,
|
105
|
+
value: mqValue,
|
106
|
+
sheet: queryRule
|
107
|
+
});
|
108
|
+
});
|
109
|
+
}
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
|
113
|
+
// Pseudo
|
114
|
+
if (typeof value === 'object') {
|
115
|
+
Object.entries(value).forEach(([pseudoKey, pseudoValue]) => {
|
116
|
+
this.applyRule({
|
117
|
+
hash: `${hash}${key.replace('_', ':')}`,
|
118
|
+
key: pseudoKey,
|
119
|
+
value: pseudoValue,
|
120
|
+
sheet: this.styleTag.sheet
|
121
|
+
});
|
122
|
+
});
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
this.applyRule({
|
126
|
+
hash,
|
127
|
+
key,
|
128
|
+
value,
|
129
|
+
sheet: this.styleTag.sheet
|
130
|
+
});
|
131
|
+
});
|
132
|
+
};
|
133
|
+
applyRule = ({
|
134
|
+
hash,
|
135
|
+
key,
|
136
|
+
value,
|
137
|
+
sheet
|
138
|
+
}) => {
|
139
|
+
let rule = Array.from(sheet.cssRules).find(rule => {
|
140
|
+
if (!(rule instanceof CSSStyleRule)) {
|
141
|
+
return false;
|
142
|
+
}
|
143
|
+
|
144
|
+
// In unistyles pseudos are prefixed with ':' but in css some of them are prefixed with '::'
|
145
|
+
return rule.selectorText.replace('::', ':').includes(hash);
|
146
|
+
}) ?? null;
|
147
|
+
if (!rule) {
|
148
|
+
rule = sheet.cssRules.item(sheet.insertRule(`.${hash} {}`));
|
149
|
+
}
|
150
|
+
if (!(rule instanceof CSSStyleRule) || !(0, _utils.keyInObject)(rule.style, key)) {
|
151
|
+
return;
|
152
|
+
}
|
153
|
+
rule.style[key] = value;
|
154
|
+
};
|
155
|
+
remove = value => {
|
156
|
+
const hash = (0, _utils.generateHash)(value);
|
157
|
+
const existingStyles = this.stylesCounter.get(hash);
|
158
|
+
if (!existingStyles) {
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
existingStyles.delete(value);
|
162
|
+
if (existingStyles.size === 0) {
|
163
|
+
const ruleIndex = Array.from(this.styleTag.sheet?.cssRules ?? []).findIndex(rule => rule.cssText.includes(`.${hash}`));
|
164
|
+
if (ruleIndex === -1) {
|
165
|
+
return;
|
166
|
+
}
|
167
|
+
this.styleTag.sheet?.deleteRule(ruleIndex);
|
168
|
+
}
|
169
|
+
};
|
170
|
+
}
|
171
|
+
const UnistylesRegistry = exports.UnistylesRegistry = new UnistylesRegistryBuilder();
|
172
|
+
//# sourceMappingURL=registry.js.map
|