react-native-unistyles 3.0.0-rc.3 → 3.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/android/src/main/cxx/NativeUnistylesModule.cpp +3 -7
- package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -7
- package/cxx/core/UnistyleWrapper.h +4 -1
- package/cxx/core/UnistylesCommitShadowNode.h +0 -21
- package/cxx/core/UnistylesRegistry.cpp +45 -49
- package/cxx/core/UnistylesState.cpp +10 -0
- package/cxx/core/UnistylesState.h +3 -0
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +6 -1
- package/cxx/hybridObjects/HybridShadowRegistry.h +6 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +13 -16
- package/cxx/hybridObjects/HybridStyleSheet.h +2 -7
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +8 -0
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
- package/cxx/parser/Parser.cpp +175 -110
- package/cxx/parser/Parser.h +1 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +36 -33
- package/cxx/shadowTree/ShadowTreeManager.h +0 -1
- package/ios/UnistylesModuleOnLoad.h +1 -5
- package/ios/UnistylesModuleOnLoad.mm +5 -13
- package/lib/commonjs/components/AdaptiveTheme.js +35 -0
- package/lib/commonjs/components/AdaptiveTheme.js.map +1 -0
- package/lib/commonjs/components/ApplyScopedTheme.js +19 -0
- package/lib/commonjs/components/ApplyScopedTheme.js.map +1 -0
- package/lib/commonjs/components/NamedTheme.js +31 -0
- package/lib/commonjs/components/NamedTheme.js.map +1 -0
- package/lib/commonjs/components/ScopedTheme.js +24 -20
- package/lib/commonjs/components/ScopedTheme.js.map +1 -1
- package/lib/commonjs/components/native/Image.js +1 -2
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js +1 -2
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js +1 -2
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +1 -2
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +3 -3
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +18 -31
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +6 -21
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +1 -2
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/parseBoxShadow.js +57 -0
- package/lib/commonjs/core/parseBoxShadow.js.map +1 -0
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js +1 -2
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +1 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +1 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mocks.js +5 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/reanimated/index.js +20 -0
- package/lib/commonjs/reanimated/index.js.map +1 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.js +22 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js +24 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -0
- package/lib/commonjs/reanimated/variant/index.js +17 -0
- package/lib/commonjs/reanimated/variant/index.js.map +1 -0
- package/lib/commonjs/reanimated/variant/types.js +2 -0
- package/lib/commonjs/reanimated/variant/types.js.map +1 -0
- package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js +38 -0
- package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js +66 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +39 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
- package/lib/commonjs/server/getServerUnistyles.js +1 -2
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +1 -2
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +1 -2
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +6 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +3 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/utils.js +0 -3
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/create.js +2 -3
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/core.js +6 -1
- package/lib/commonjs/web/css/core.js.map +1 -1
- package/lib/commonjs/web/css/state.js +10 -7
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -2
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js +2 -0
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/runtime.js +15 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +12 -4
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +1 -10
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/types.js +2 -0
- package/lib/commonjs/web/types.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js +1 -2
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +30 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web-only/getWebProps.js +19 -0
- package/lib/commonjs/web-only/getWebProps.js.map +1 -0
- package/lib/commonjs/web-only/index.js +13 -0
- package/lib/commonjs/web-only/index.js.map +1 -0
- package/lib/module/components/AdaptiveTheme.js +29 -0
- package/lib/module/components/AdaptiveTheme.js.map +1 -0
- package/lib/module/components/ApplyScopedTheme.js +14 -0
- package/lib/module/components/ApplyScopedTheme.js.map +1 -0
- package/lib/module/components/NamedTheme.js +25 -0
- package/lib/module/components/NamedTheme.js.map +1 -0
- package/lib/module/components/ScopedTheme.js +24 -19
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +3 -3
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +18 -30
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +5 -19
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/parseBoxShadow.js +52 -0
- package/lib/module/core/parseBoxShadow.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks.js +5 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/reanimated/index.js +5 -0
- package/lib/module/reanimated/index.js.map +1 -0
- package/lib/module/reanimated/useAnimatedTheme.js +17 -0
- package/lib/module/reanimated/useAnimatedTheme.js.map +1 -0
- package/lib/module/reanimated/useAnimatedTheme.native.js +19 -0
- package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -0
- package/lib/module/reanimated/variant/index.js +4 -0
- package/lib/module/reanimated/variant/index.js.map +1 -0
- package/lib/module/reanimated/variant/types.js +2 -0
- package/lib/module/reanimated/variant/types.js.map +1 -0
- package/lib/module/reanimated/variant/useAnimatedVariantColor.js +33 -0
- package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.js +61 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +34 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
- package/lib/module/specs/ShadowRegistry/index.js +6 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +3 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/utils.js +0 -3
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/create.js +1 -1
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/css/core.js +6 -1
- package/lib/module/web/css/core.js.map +1 -1
- package/lib/module/web/css/state.js +10 -7
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/listener.js +2 -0
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/runtime.js +16 -2
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +13 -5
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +1 -10
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/types.js +1 -1
- package/lib/module/web/types.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +27 -2
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web-only/getWebProps.js +14 -0
- package/lib/module/web-only/getWebProps.js.map +1 -0
- package/lib/module/web-only/index.js +4 -0
- package/lib/module/web-only/index.js.map +1 -0
- package/lib/typescript/plugin/src/consts.d.ts +17 -0
- package/lib/typescript/plugin/src/consts.d.ts.map +1 -0
- package/lib/typescript/repack-plugin/src/index.d.ts +18 -0
- package/lib/typescript/repack-plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/repack-plugin/src/loader.d.ts +9 -0
- package/lib/typescript/repack-plugin/src/loader.d.ts.map +1 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts +8 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/ApplyScopedTheme.d.ts +7 -0
- package/lib/typescript/src/components/ApplyScopedTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/NamedTheme.d.ts +10 -0
- package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/ScopedTheme.d.ts +4 -0
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/parseBoxShadow.d.ts +11 -0
- package/lib/typescript/src/core/parseBoxShadow.d.ts.map +1 -0
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/warn.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/index.d.ts +3 -0
- package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts +4 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts +4 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/index.d.ts +2 -0
- package/lib/typescript/src/reanimated/variant/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/types.d.ts +10 -0
- package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts +3 -0
- package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +6 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +6 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -0
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/serialize.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -0
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +2 -0
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/css/core.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts +2 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +2 -0
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +4 -2
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +6 -0
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +7 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/lib/typescript/src/web/variants.d.ts.map +1 -1
- package/lib/typescript/src/web-only/getWebProps.d.ts +7 -0
- package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -0
- package/lib/typescript/src/web-only/index.d.ts +2 -0
- package/lib/typescript/src/web-only/index.d.ts.map +1 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +1 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +2 -0
- package/package.json +57 -25
- package/plugin/index.d.ts +6 -5
- package/plugin/index.js +103 -99
- package/reanimated/package.json +6 -0
- package/repack-plugin/index.d.ts +19 -0
- package/repack-plugin/index.js +149 -0
- package/src/components/AdaptiveTheme.tsx +34 -0
- package/src/components/ApplyScopedTheme.tsx +17 -0
- package/src/components/NamedTheme.tsx +33 -0
- package/src/components/ScopedTheme.tsx +42 -22
- package/src/core/createUnistylesElement.native.tsx +21 -31
- package/src/core/createUnistylesElement.tsx +3 -3
- package/src/core/createUnistylesImageBackground.tsx +7 -22
- package/src/core/parseBoxShadow.ts +87 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +1 -0
- package/src/index.ts +8 -0
- package/src/mocks.ts +5 -2
- package/src/reanimated/index.ts +2 -0
- package/src/reanimated/useAnimatedTheme.native.ts +21 -0
- package/src/reanimated/useAnimatedTheme.ts +19 -0
- package/src/reanimated/variant/index.ts +1 -0
- package/src/reanimated/variant/types.ts +14 -0
- package/src/reanimated/variant/useAnimatedVariantColor.ts +38 -0
- package/src/reanimated/variant/useUpdateVariantColor.native.ts +38 -0
- package/src/reanimated/variant/useUpdateVariantColor.ts +81 -0
- package/src/specs/ShadowRegistry/index.ts +7 -1
- package/src/specs/StyleSheet/index.ts +5 -2
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +2 -0
- package/src/utils.ts +1 -3
- package/src/web/create.ts +1 -1
- package/src/web/css/core.ts +9 -1
- package/src/web/css/state.ts +10 -8
- package/src/web/listener.ts +2 -0
- package/src/web/runtime.ts +23 -2
- package/src/web/shadowRegistry.ts +15 -6
- package/src/web/state.ts +7 -17
- package/src/web/types.ts +12 -4
- package/src/web/utils/unistyle.ts +38 -3
- package/src/web-only/getWebProps.ts +18 -0
- package/src/web-only/index.ts +2 -0
- package/web/package.json +6 -0
- package/cxx/core/UnistylesCommitHook.cpp +0 -52
- package/cxx/core/UnistylesCommitHook.h +0 -27
- package/cxx/core/UnistylesMountHook.cpp +0 -28
- package/cxx/core/UnistylesMountHook.h +0 -24
- package/lib/module/package.json +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-rc.
|
3
|
+
"version": "3.0.0-rc.5",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "NODE_ENV=babel-test jest ./plugin",
|
@@ -9,10 +9,11 @@
|
|
9
9
|
"lint": "biome lint",
|
10
10
|
"check": "biome check --write",
|
11
11
|
"check:ci": "biome check",
|
12
|
-
"prepare": "husky && bob build && yarn plugin:build",
|
12
|
+
"prepare": "husky && bob build && yarn plugin:build && yarn repack:plugin:build",
|
13
13
|
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn check' 'yarn test' 'yarn circular:check'",
|
14
14
|
"release": "release-it",
|
15
15
|
"plugin:build": "node plugin/esbuild.js",
|
16
|
+
"repack:plugin:build": "node repack-plugin/esbuild.js",
|
16
17
|
"circular:check": "dpdm --no-warning --no-tree -T --exit-code circular:1 src/**/*.ts",
|
17
18
|
"components:build": "node build-components.js"
|
18
19
|
},
|
@@ -46,13 +47,32 @@
|
|
46
47
|
"types": "./plugin/index.d.ts",
|
47
48
|
"default": "./plugin/index.js"
|
48
49
|
},
|
50
|
+
"./repack-plugin": {
|
51
|
+
"import": "./repack-plugin/index.js",
|
52
|
+
"types": "./repack-plugin/index.d.ts",
|
53
|
+
"default": "./repack-plugin/index.js"
|
54
|
+
},
|
49
55
|
"./package.json": "./package.json",
|
50
56
|
"./server": {
|
51
57
|
"types": "./lib/typescript/src/server/index.d.ts",
|
52
58
|
"import": "./lib/module/server/index.js",
|
53
59
|
"browser": "./lib/module/server/index.js",
|
54
|
-
"react-native": "./src/server.ts",
|
60
|
+
"react-native": "./src/server/index.ts",
|
55
61
|
"default": "./lib/commonjs/server/index.js"
|
62
|
+
},
|
63
|
+
"./web": {
|
64
|
+
"types": "./lib/typescript/src/web-only/index.d.ts",
|
65
|
+
"import": "./lib/module/web-only/index.js",
|
66
|
+
"browser": "./lib/module/web-only/index.js",
|
67
|
+
"react-native": "./src/web-only/index.ts",
|
68
|
+
"default": "./lib/commonjs/web-only/index.js"
|
69
|
+
},
|
70
|
+
"./reanimated": {
|
71
|
+
"types": "./lib/typescript/src/reanimated/index.d.ts",
|
72
|
+
"import": "./lib/module/reanimated/index.js",
|
73
|
+
"browser": "./lib/module/reanimated/index.js",
|
74
|
+
"react-native": "./src/reanimated/index.ts",
|
75
|
+
"default": "./lib/commonjs/reanimated/index.js"
|
56
76
|
}
|
57
77
|
},
|
58
78
|
"files": [
|
@@ -66,8 +86,14 @@
|
|
66
86
|
"web",
|
67
87
|
"components",
|
68
88
|
"server",
|
89
|
+
"web-only",
|
90
|
+
"reanimated",
|
69
91
|
"react-native.config.js",
|
70
92
|
"Unistyles.podspec",
|
93
|
+
"repack-plugin",
|
94
|
+
"!repack-plugin/__tests__",
|
95
|
+
"!repack-plugin/src",
|
96
|
+
"!repack-plugin/esbuild.js",
|
71
97
|
"!plugin/__tests__",
|
72
98
|
"!plugin/src",
|
73
99
|
"!plugin/esbuild.js",
|
@@ -100,41 +126,50 @@
|
|
100
126
|
"registry": "https://registry.npmjs.org/"
|
101
127
|
},
|
102
128
|
"devDependencies": {
|
103
|
-
"@babel/core": "7.
|
104
|
-
"@babel/plugin-syntax-jsx": "7.
|
105
|
-
"@babel/preset-flow": "7.
|
106
|
-
"@babel/preset-typescript": "7.
|
107
|
-
"@babel/types": "7.
|
129
|
+
"@babel/core": "7.27.1",
|
130
|
+
"@babel/plugin-syntax-jsx": "7.27.1",
|
131
|
+
"@babel/preset-flow": "7.27.1",
|
132
|
+
"@babel/preset-typescript": "7.27.1",
|
133
|
+
"@babel/types": "7.27.1",
|
108
134
|
"@biomejs/biome": "1.9.4",
|
109
|
-
"@
|
110
|
-
"@
|
135
|
+
"@callstack/repack": "5.1.0",
|
136
|
+
"@commitlint/config-conventional": "19.8.1",
|
137
|
+
"@react-native/normalize-colors": "0.79.2",
|
111
138
|
"@release-it/conventional-changelog": "8.0.2",
|
139
|
+
"@rspack/core": "1.3.10",
|
112
140
|
"@types/jest": "29.5.14",
|
113
|
-
"@types/react": "19.
|
141
|
+
"@types/react": "19.1.4",
|
114
142
|
"babel-plugin-tester": "11.0.4",
|
115
|
-
"commitlint": "19.
|
143
|
+
"commitlint": "19.8.1",
|
116
144
|
"concurrently": "9.1.2",
|
117
145
|
"dpdm": "3.14.0",
|
118
|
-
"esbuild": "0.25.
|
146
|
+
"esbuild": "0.25.4",
|
119
147
|
"husky": "9.1.7",
|
120
148
|
"jest": "29.7.0",
|
121
149
|
"metro-react-native-babel-preset": "0.77.0",
|
122
|
-
"nitro-codegen": "0.
|
123
|
-
"react": "
|
124
|
-
"react-native": "0.
|
125
|
-
"react-native-builder-bob": "0.
|
126
|
-
"react-native-nitro-modules": "0.
|
127
|
-
"react-native-
|
128
|
-
"react-
|
150
|
+
"nitro-codegen": "0.26.2",
|
151
|
+
"react": "19.1.0",
|
152
|
+
"react-native": "0.79.2",
|
153
|
+
"react-native-builder-bob": "0.40.10",
|
154
|
+
"react-native-nitro-modules": "0.26.2",
|
155
|
+
"react-native-reanimated": "3.17.5",
|
156
|
+
"react-native-web": "0.20.0",
|
157
|
+
"react-test-renderer": "19.1.0",
|
129
158
|
"release-it": "17.11.0",
|
130
|
-
"typescript": "5.
|
159
|
+
"typescript": "5.8.3"
|
131
160
|
},
|
132
161
|
"peerDependencies": {
|
133
162
|
"@react-native/normalize-colors": "*",
|
134
163
|
"react": "*",
|
135
164
|
"react-native": ">=0.76.0",
|
136
165
|
"react-native-edge-to-edge": "*",
|
137
|
-
"react-native-nitro-modules": "*"
|
166
|
+
"react-native-nitro-modules": "*",
|
167
|
+
"react-native-reanimated": "*"
|
168
|
+
},
|
169
|
+
"peerDependenciesMeta": {
|
170
|
+
"react-native-reanimated": {
|
171
|
+
"optional": true
|
172
|
+
}
|
138
173
|
},
|
139
174
|
"workspaces": [
|
140
175
|
"example",
|
@@ -199,8 +234,5 @@
|
|
199
234
|
"name": "TurboUnistyles",
|
200
235
|
"type": "modules",
|
201
236
|
"jsSrcsDir": "./src/specs/TurboUnistyles"
|
202
|
-
},
|
203
|
-
"resolutions": {
|
204
|
-
"@babel/types": "7.26.8"
|
205
237
|
}
|
206
238
|
}
|
package/plugin/index.d.ts
CHANGED
@@ -37,11 +37,12 @@ export interface RemapConfig {
|
|
37
37
|
|
38
38
|
export interface UnistylesPluginOptions {
|
39
39
|
/**
|
40
|
-
*
|
41
|
-
*
|
42
|
-
*
|
40
|
+
* Required from RC.5
|
41
|
+
* Example: 'src' or 'app'
|
42
|
+
* Add root folder of your project. All files under this folder will be processed by the Babel plugin.
|
43
|
+
* If you need to process extra folders, use with `autoProcessPaths` option.
|
43
44
|
*/
|
44
|
-
|
45
|
+
root: string,
|
45
46
|
|
46
47
|
/**
|
47
48
|
* Example: ['@codemask/styles']
|
@@ -103,7 +104,7 @@ export interface UnistylesPluginOptions {
|
|
103
104
|
* Defaults to:
|
104
105
|
*
|
105
106
|
* ```ts
|
106
|
-
* ['react-native-reanimated/src/component'
|
107
|
+
* ['react-native-reanimated/src/component']
|
107
108
|
* ```
|
108
109
|
*/
|
109
110
|
autoProcessPaths?: Array<string>,
|
package/plugin/index.js
CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
33
33
|
default: () => index_default
|
34
34
|
});
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
36
|
+
var import_node_path2 = __toESM(require("node:path"));
|
36
37
|
var t6 = __toESM(require("@babel/types"));
|
37
38
|
|
38
39
|
// plugin/src/consts.ts
|
@@ -59,10 +60,7 @@ var REACT_NATIVE_COMPONENT_NAMES = [
|
|
59
60
|
];
|
60
61
|
var REPLACE_WITH_UNISTYLES_PATHS = [
|
61
62
|
"react-native-reanimated/src/component",
|
62
|
-
"react-native-reanimated/lib/module/component"
|
63
|
-
"react-native-gesture-handler/lib/module/components",
|
64
|
-
"react-native-gesture-handler/lib/commonjs/components",
|
65
|
-
"react-native-gesture-handler/src/components"
|
63
|
+
"react-native-reanimated/lib/module/component"
|
66
64
|
];
|
67
65
|
var REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = [];
|
68
66
|
var NATIVE_COMPONENTS_PATHS = {
|
@@ -83,21 +81,10 @@ var NATIVE_COMPONENTS_PATHS = {
|
|
83
81
|
|
84
82
|
// plugin/src/exotic.ts
|
85
83
|
var t = __toESM(require("@babel/types"));
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
return pathString;
|
91
|
-
};
|
92
|
-
var toPlatformPath = (pathString) => {
|
93
|
-
return isWindows ? toWinPath(pathString) : pathString;
|
94
|
-
};
|
95
|
-
|
96
|
-
// plugin/src/exotic.ts
|
97
|
-
function handleExoticImport(path, state, exoticImport) {
|
98
|
-
const specifiers = path.node.specifiers;
|
99
|
-
const source = path.node.source;
|
100
|
-
if (path.node.importKind !== "value") {
|
84
|
+
function handleExoticImport(path2, state, exoticImport) {
|
85
|
+
const specifiers = path2.node.specifiers;
|
86
|
+
const source = path2.node.source;
|
87
|
+
if (path2.node.importKind !== "value") {
|
101
88
|
return;
|
102
89
|
}
|
103
90
|
specifiers.forEach((specifier) => {
|
@@ -112,22 +99,22 @@ function handleExoticImport(path, state, exoticImport) {
|
|
112
99
|
const newImport = t.importDeclaration(
|
113
100
|
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
|
114
101
|
t.stringLiteral(
|
115
|
-
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(
|
102
|
+
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/components/native/${rule.mapTo}`) ?? "" : `react-native-unistyles/components/native/${rule.mapTo}`
|
116
103
|
)
|
117
104
|
);
|
118
|
-
|
105
|
+
path2.replaceWith(newImport);
|
119
106
|
} else {
|
120
107
|
const newImport = t.importDeclaration(
|
121
108
|
[t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
|
122
109
|
t.stringLiteral(
|
123
|
-
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(
|
110
|
+
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/components/native/${rule.mapTo}`) ?? "" : `react-native-unistyles/components/native/${rule.mapTo}`
|
124
111
|
)
|
125
112
|
);
|
126
|
-
|
127
|
-
if (
|
128
|
-
|
113
|
+
path2.node.specifiers = specifiers.filter((s) => s !== specifier);
|
114
|
+
if (path2.node.specifiers.length === 0) {
|
115
|
+
path2.replaceWith(newImport);
|
129
116
|
} else {
|
130
|
-
|
117
|
+
path2.insertBefore(newImport);
|
131
118
|
}
|
132
119
|
}
|
133
120
|
return;
|
@@ -137,12 +124,12 @@ function handleExoticImport(path, state, exoticImport) {
|
|
137
124
|
|
138
125
|
// plugin/src/import.ts
|
139
126
|
var t2 = __toESM(require("@babel/types"));
|
140
|
-
function addUnistylesImport(
|
127
|
+
function addUnistylesImport(path2, state) {
|
141
128
|
const localNames = Object.keys(state.reactNativeImports);
|
142
129
|
const names = Object.values(state.reactNativeImports);
|
143
130
|
const pairs = Object.entries(state.reactNativeImports);
|
144
131
|
const nodesToRemove = [];
|
145
|
-
|
132
|
+
path2.node.body.forEach((node) => {
|
146
133
|
if (t2.isImportDeclaration(node) && node.source.value === "react-native") {
|
147
134
|
node.specifiers = node.specifiers.filter((specifier) => !localNames.some((name) => name === specifier.local.name));
|
148
135
|
if (node.specifiers.length === 0) {
|
@@ -151,7 +138,7 @@ function addUnistylesImport(path, state) {
|
|
151
138
|
}
|
152
139
|
});
|
153
140
|
names.forEach((name) => {
|
154
|
-
const rnWebImport =
|
141
|
+
const rnWebImport = path2.node.body.find((node) => t2.isImportDeclaration(node) && node.source.value === `react-native-web/dist/exports/${name}`);
|
155
142
|
if (rnWebImport) {
|
156
143
|
rnWebImport.specifiers = [];
|
157
144
|
}
|
@@ -160,34 +147,44 @@ function addUnistylesImport(path, state) {
|
|
160
147
|
const newImport = t2.importDeclaration(
|
161
148
|
[t2.importSpecifier(t2.identifier(localName), t2.identifier(name))],
|
162
149
|
t2.stringLiteral(
|
163
|
-
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(
|
150
|
+
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/src/components/native/${name}`) ?? "" : `react-native-unistyles/components/native/${name}`
|
164
151
|
)
|
165
152
|
);
|
166
|
-
|
153
|
+
path2.node.body.unshift(newImport);
|
167
154
|
});
|
168
|
-
nodesToRemove.forEach((node) =>
|
155
|
+
nodesToRemove.forEach((node) => path2.node.body.splice(path2.node.body.indexOf(node), 1));
|
169
156
|
}
|
170
157
|
function isInsideNodeModules(state) {
|
171
158
|
return state.file.opts.filename?.includes("node_modules") && !state.file.replaceWithUnistyles;
|
172
159
|
}
|
173
|
-
function addUnistylesRequire(
|
160
|
+
function addUnistylesRequire(path2, state) {
|
174
161
|
Object.entries(state.reactNativeImports).forEach(([componentName, uniqueName]) => {
|
175
162
|
const newRequire = t2.variableDeclaration("const", [
|
176
163
|
t2.variableDeclarator(
|
177
164
|
t2.identifier(uniqueName),
|
178
165
|
t2.callExpression(t2.identifier("require"), [
|
179
|
-
t2.stringLiteral(
|
166
|
+
t2.stringLiteral(`react-native-unistyles/components/native/${componentName}`)
|
180
167
|
])
|
181
168
|
)
|
182
169
|
]);
|
183
|
-
|
170
|
+
path2.node.body.unshift(newRequire);
|
184
171
|
});
|
185
172
|
}
|
186
173
|
|
174
|
+
// plugin/src/paths.ts
|
175
|
+
var import_node_path = __toESM(require("node:path"));
|
176
|
+
var isWindows = process.platform === "win32";
|
177
|
+
var toWinPath = (pathString) => {
|
178
|
+
return import_node_path.default.normalize(pathString).replace(/\//g, "\\");
|
179
|
+
};
|
180
|
+
var toPlatformPath = (pathString) => {
|
181
|
+
return isWindows ? toWinPath(pathString) : pathString;
|
182
|
+
};
|
183
|
+
|
187
184
|
// plugin/src/ref.ts
|
188
185
|
var t3 = __toESM(require("@babel/types"));
|
189
|
-
function hasStringRef(
|
190
|
-
return
|
186
|
+
function hasStringRef(path2) {
|
187
|
+
return path2.node.openingElement.attributes.find(
|
191
188
|
(attr) => t3.isJSXAttribute(attr) && t3.isJSXIdentifier(attr.name, { name: "ref" }) && t3.isStringLiteral(attr.value)
|
192
189
|
);
|
193
190
|
}
|
@@ -324,8 +321,8 @@ function stringToUniqueId(str) {
|
|
324
321
|
const absHash = Math.abs(hash);
|
325
322
|
return absHash % 1e9;
|
326
323
|
}
|
327
|
-
function isUnistylesStyleSheet(
|
328
|
-
const { callee } =
|
324
|
+
function isUnistylesStyleSheet(path2, state) {
|
325
|
+
const { callee } = path2.node;
|
329
326
|
if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
|
330
327
|
return false;
|
331
328
|
}
|
@@ -333,38 +330,38 @@ function isUnistylesStyleSheet(path, state) {
|
|
333
330
|
const isRequire = state.file.hasUnistylesImport && callee.property.name === "create" && t4.isMemberExpression(callee.object) && t4.isIdentifier(callee.object.property) && t4.isIdentifier(callee.object.object) && callee.object.object.name === state.file.styleSheetLocalName && callee.object.property.name === "StyleSheet";
|
334
331
|
return isImport || isRequire;
|
335
332
|
}
|
336
|
-
function isUnistylesCommonJSRequire(
|
337
|
-
const isRequire = t4.isIdentifier(
|
338
|
-
if (isRequire && t4.isVariableDeclarator(
|
333
|
+
function isUnistylesCommonJSRequire(path2, state) {
|
334
|
+
const isRequire = t4.isIdentifier(path2.node.callee) && path2.node.arguments.length > 0 && t4.isStringLiteral(path2.node.arguments[0]) && path2.node.arguments[0].value === "react-native-unistyles";
|
335
|
+
if (isRequire && t4.isVariableDeclarator(path2.parent) && t4.isIdentifier(path2.parent.id)) {
|
339
336
|
state.file.hasUnistylesImport = true;
|
340
|
-
state.file.styleSheetLocalName =
|
337
|
+
state.file.styleSheetLocalName = path2.parent.id.name;
|
341
338
|
}
|
342
339
|
return isRequire;
|
343
340
|
}
|
344
|
-
function isReactNativeCommonJSRequire(
|
345
|
-
const isRequire = t4.isIdentifier(
|
346
|
-
const requireImportName =
|
341
|
+
function isReactNativeCommonJSRequire(path2, state) {
|
342
|
+
const isRequire = t4.isIdentifier(path2.node.callee) && path2.node.arguments.length > 0 && path2.node.callee.name === "require";
|
343
|
+
const requireImportName = path2.node.arguments.find((node) => t4.isStringLiteral(node));
|
347
344
|
const isReactNativeRequire = isRequire && requireImportName && (requireImportName.value === "react-native" || requireImportName.value === "react-native-web/dist/index");
|
348
|
-
if (isReactNativeRequire && t4.isVariableDeclarator(
|
349
|
-
state.file.reactNativeCommonJSName =
|
345
|
+
if (isReactNativeRequire && t4.isVariableDeclarator(path2.parent) && t4.isIdentifier(path2.parent.id)) {
|
346
|
+
state.file.reactNativeCommonJSName = path2.parent.id.name;
|
350
347
|
}
|
351
348
|
return isRequire;
|
352
349
|
}
|
353
|
-
function isKindOfStyleSheet(
|
350
|
+
function isKindOfStyleSheet(path2, state) {
|
354
351
|
if (!state.file.forceProcessing && !state.file.hasUnistylesImport) {
|
355
352
|
return false;
|
356
353
|
}
|
357
|
-
const { callee } =
|
354
|
+
const { callee } = path2.node;
|
358
355
|
return t4.isMemberExpression(callee) && t4.isIdentifier(callee.property) && callee.property.name === "create" && t4.isIdentifier(callee.object);
|
359
356
|
}
|
360
|
-
function addStyleSheetTag(
|
357
|
+
function addStyleSheetTag(path2, state) {
|
361
358
|
const str = state.filename?.replace(state.cwd, "") ?? "";
|
362
359
|
const uniqueId = stringToUniqueId(str) + ++state.file.tagNumber;
|
363
|
-
|
360
|
+
path2.node.arguments.push(t4.numericLiteral(uniqueId));
|
364
361
|
}
|
365
|
-
function getStylesDependenciesFromObject(
|
362
|
+
function getStylesDependenciesFromObject(path2) {
|
366
363
|
const detectedStylesWithVariants = /* @__PURE__ */ new Set();
|
367
|
-
const stylesheet =
|
364
|
+
const stylesheet = path2.node.arguments[0];
|
368
365
|
if (t4.isObjectExpression(stylesheet)) {
|
369
366
|
stylesheet?.properties.forEach((property) => {
|
370
367
|
if (!t4.isObjectProperty(property) || !t4.isIdentifier(property.key)) {
|
@@ -663,8 +660,8 @@ function addDependencies(state, styleName, unistyle, detectedDependencies) {
|
|
663
660
|
|
664
661
|
// plugin/src/variants.ts
|
665
662
|
var t5 = __toESM(require("@babel/types"));
|
666
|
-
function extractVariants(
|
667
|
-
const maybeVariants =
|
663
|
+
function extractVariants(path2, state) {
|
664
|
+
const maybeVariants = path2.node.body.filter((node2) => t5.isExpressionStatement(node2) && t5.isCallExpression(node2.expression) && t5.isMemberExpression(node2.expression.callee));
|
668
665
|
if (maybeVariants.length === 0) {
|
669
666
|
return;
|
670
667
|
}
|
@@ -687,7 +684,7 @@ function extractVariants(path, state) {
|
|
687
684
|
return;
|
688
685
|
}
|
689
686
|
const calleeName = callee.object.name;
|
690
|
-
const newUniqueName =
|
687
|
+
const newUniqueName = path2.scope.generateUidIdentifier(calleeName);
|
691
688
|
const shadowDeclaration = t5.variableDeclaration("const", [
|
692
689
|
t5.variableDeclarator(newUniqueName, t5.identifier(calleeName))
|
693
690
|
]);
|
@@ -698,14 +695,14 @@ function extractVariants(path, state) {
|
|
698
695
|
const finalDeclaration = t5.variableDeclaration("const", [
|
699
696
|
t5.variableDeclarator(t5.identifier(calleeName), newCallExpression)
|
700
697
|
]);
|
701
|
-
const pathIndex =
|
702
|
-
const rest =
|
698
|
+
const pathIndex = path2.node.body.findIndex((bodyPath) => bodyPath === targetVariant);
|
699
|
+
const rest = path2.node.body.slice(pathIndex + 1);
|
703
700
|
const statement = t5.blockStatement([
|
704
701
|
finalDeclaration,
|
705
702
|
...rest
|
706
703
|
]);
|
707
|
-
|
708
|
-
...
|
704
|
+
path2.node.body = [
|
705
|
+
...path2.node.body.slice(0, pathIndex),
|
709
706
|
shadowDeclaration,
|
710
707
|
statement
|
711
708
|
];
|
@@ -724,8 +721,15 @@ function index_default() {
|
|
724
721
|
name: "babel-react-native-unistyles",
|
725
722
|
visitor: {
|
726
723
|
Program: {
|
727
|
-
enter(
|
728
|
-
|
724
|
+
enter(path2, state) {
|
725
|
+
if (!state.opts.root) {
|
726
|
+
throw new Error("Unistyles \u{1F984}: Babel plugin requires `root` option to be set. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration");
|
727
|
+
}
|
728
|
+
const appRoot = toPlatformPath(import_node_path2.default.join(state.file.opts.root, state.opts.root));
|
729
|
+
if (state.file.opts.root === appRoot) {
|
730
|
+
throw new Error("Unistyles \u{1F984}: Root option can't resolve to project root as it will include node_modules folder. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration");
|
731
|
+
}
|
732
|
+
state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.map(toPlatformPath).concat(state.opts.autoProcessPaths ?? []).some((path3) => state.filename?.includes(path3));
|
729
733
|
state.file.hasAnyUnistyle = false;
|
730
734
|
state.file.hasUnistylesImport = false;
|
731
735
|
state.file.addUnistylesRequire = false;
|
@@ -734,8 +738,8 @@ function index_default() {
|
|
734
738
|
state.file.reactNativeCommonJSName = "";
|
735
739
|
state.file.tagNumber = 0;
|
736
740
|
state.reactNativeImports = {};
|
737
|
-
state.file.forceProcessing = state.
|
738
|
-
|
741
|
+
state.file.forceProcessing = state.filename?.includes(appRoot) ?? false;
|
742
|
+
path2.traverse({
|
739
743
|
BlockStatement(blockPath) {
|
740
744
|
if (isInsideNodeModules(state)) {
|
741
745
|
return;
|
@@ -744,41 +748,41 @@ function index_default() {
|
|
744
748
|
}
|
745
749
|
});
|
746
750
|
},
|
747
|
-
exit(
|
751
|
+
exit(path2, state) {
|
748
752
|
if (isInsideNodeModules(state)) {
|
749
753
|
return;
|
750
754
|
}
|
751
755
|
if (state.file.addUnistylesRequire) {
|
752
|
-
return addUnistylesRequire(
|
756
|
+
return addUnistylesRequire(path2, state);
|
753
757
|
}
|
754
758
|
if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
|
755
|
-
addUnistylesImport(
|
759
|
+
addUnistylesImport(path2, state);
|
756
760
|
}
|
757
761
|
}
|
758
762
|
},
|
759
|
-
FunctionDeclaration(
|
763
|
+
FunctionDeclaration(path2, state) {
|
760
764
|
if (isInsideNodeModules(state)) {
|
761
765
|
return;
|
762
766
|
}
|
763
|
-
const componentName =
|
767
|
+
const componentName = path2.node.id ? path2.node.id.name : null;
|
764
768
|
if (componentName) {
|
765
769
|
state.file.hasVariants = false;
|
766
770
|
}
|
767
771
|
},
|
768
|
-
ClassDeclaration(
|
772
|
+
ClassDeclaration(path2, state) {
|
769
773
|
if (isInsideNodeModules(state)) {
|
770
774
|
return;
|
771
775
|
}
|
772
|
-
const componentName =
|
776
|
+
const componentName = path2.node.id ? path2.node.id.name : null;
|
773
777
|
if (componentName) {
|
774
778
|
state.file.hasVariants = false;
|
775
779
|
}
|
776
780
|
},
|
777
|
-
VariableDeclaration(
|
781
|
+
VariableDeclaration(path2, state) {
|
778
782
|
if (isInsideNodeModules(state)) {
|
779
783
|
return;
|
780
784
|
}
|
781
|
-
|
785
|
+
path2.node.declarations.forEach((declaration) => {
|
782
786
|
if (t6.isArrowFunctionExpression(declaration.init) || t6.isFunctionExpression(declaration.init)) {
|
783
787
|
const componentName = declaration.id && t6.isIdentifier(declaration.id) ? declaration.id.name : null;
|
784
788
|
if (componentName) {
|
@@ -787,83 +791,83 @@ function index_default() {
|
|
787
791
|
}
|
788
792
|
});
|
789
793
|
},
|
790
|
-
ImportDeclaration(
|
794
|
+
ImportDeclaration(path2, state) {
|
791
795
|
const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find((exotic) => state.filename?.includes(exotic.path));
|
792
796
|
if (exoticImport) {
|
793
|
-
return handleExoticImport(
|
797
|
+
return handleExoticImport(path2, state, exoticImport);
|
794
798
|
}
|
795
799
|
if (isInsideNodeModules(state)) {
|
796
800
|
return;
|
797
801
|
}
|
798
|
-
const importSource =
|
802
|
+
const importSource = path2.node.source.value;
|
799
803
|
if (importSource.includes("react-native-unistyles")) {
|
800
804
|
state.file.hasUnistylesImport = true;
|
801
|
-
|
805
|
+
path2.node.specifiers.forEach((specifier) => {
|
802
806
|
if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && specifier.imported.name === "StyleSheet") {
|
803
807
|
state.file.styleSheetLocalName = specifier.local.name;
|
804
808
|
}
|
805
809
|
});
|
806
810
|
}
|
807
811
|
if (importSource === "react-native") {
|
808
|
-
|
812
|
+
path2.node.specifiers.forEach((specifier) => {
|
809
813
|
if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
|
810
814
|
state.reactNativeImports[specifier.local.name] = specifier.imported.name;
|
811
815
|
}
|
812
816
|
});
|
813
817
|
}
|
814
|
-
if (importSource.includes(
|
815
|
-
handleExoticImport(
|
818
|
+
if (importSource.includes("react-native/Libraries")) {
|
819
|
+
handleExoticImport(path2, state, NATIVE_COMPONENTS_PATHS);
|
816
820
|
}
|
817
821
|
if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
|
818
822
|
state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource);
|
819
823
|
}
|
820
824
|
},
|
821
|
-
JSXElement(
|
825
|
+
JSXElement(path2, state) {
|
822
826
|
if (isInsideNodeModules(state)) {
|
823
827
|
return;
|
824
828
|
}
|
825
|
-
if (hasStringRef(
|
829
|
+
if (hasStringRef(path2)) {
|
826
830
|
throw new Error("Detected string based ref which is not supported by Unistyles.");
|
827
831
|
}
|
828
832
|
},
|
829
|
-
MemberExpression(
|
833
|
+
MemberExpression(path2, state) {
|
830
834
|
if (isInsideNodeModules(state)) {
|
831
835
|
return;
|
832
836
|
}
|
833
|
-
if (!state.file.reactNativeCommonJSName || !t6.isIdentifier(
|
837
|
+
if (!state.file.reactNativeCommonJSName || !t6.isIdentifier(path2.node.object)) {
|
834
838
|
return;
|
835
839
|
}
|
836
|
-
if (
|
840
|
+
if (path2.node.object.name !== state.file.reactNativeCommonJSName || !t6.isIdentifier(path2.node.property)) {
|
837
841
|
return;
|
838
842
|
}
|
839
|
-
if (!REACT_NATIVE_COMPONENT_NAMES.includes(
|
843
|
+
if (!REACT_NATIVE_COMPONENT_NAMES.includes(path2.node.property.name)) {
|
840
844
|
return;
|
841
845
|
}
|
842
|
-
if (!state.reactNativeImports[
|
843
|
-
const uniqueId =
|
844
|
-
state.reactNativeImports[
|
846
|
+
if (!state.reactNativeImports[path2.node.property.name]) {
|
847
|
+
const uniqueId = path2.scope.generateUidIdentifier(`reactNativeUnistyles_${path2.node.property.name}`);
|
848
|
+
state.reactNativeImports[path2.node.property.name] = uniqueId.name;
|
845
849
|
state.file.addUnistylesRequire = true;
|
846
850
|
}
|
847
|
-
|
851
|
+
path2.node.object.name = state.reactNativeImports[path2.node.property.name];
|
848
852
|
},
|
849
|
-
CallExpression(
|
853
|
+
CallExpression(path2, state) {
|
850
854
|
if (isInsideNodeModules(state)) {
|
851
855
|
return;
|
852
856
|
}
|
853
|
-
if (isUnistylesCommonJSRequire(
|
857
|
+
if (isUnistylesCommonJSRequire(path2, state)) {
|
854
858
|
return;
|
855
859
|
}
|
856
|
-
if (isReactNativeCommonJSRequire(
|
860
|
+
if (isReactNativeCommonJSRequire(path2, state)) {
|
857
861
|
return;
|
858
862
|
}
|
859
|
-
if (!isUnistylesStyleSheet(
|
863
|
+
if (!isUnistylesStyleSheet(path2, state) && !isKindOfStyleSheet(path2, state)) {
|
860
864
|
return;
|
861
865
|
}
|
862
866
|
state.file.hasAnyUnistyle = true;
|
863
|
-
addStyleSheetTag(
|
864
|
-
const arg = t6.isAssignmentExpression(
|
867
|
+
addStyleSheetTag(path2, state);
|
868
|
+
const arg = t6.isAssignmentExpression(path2.node.arguments[0]) ? path2.node.arguments[0].right : path2.node.arguments[0];
|
865
869
|
if (t6.isObjectExpression(arg)) {
|
866
|
-
const detectedDependencies = getStylesDependenciesFromObject(
|
870
|
+
const detectedDependencies = getStylesDependenciesFromObject(path2);
|
867
871
|
if (detectedDependencies) {
|
868
872
|
if (t6.isObjectExpression(arg)) {
|
869
873
|
arg.properties.forEach((property) => {
|
@@ -875,7 +879,7 @@ function index_default() {
|
|
875
879
|
}
|
876
880
|
}
|
877
881
|
if (t6.isArrowFunctionExpression(arg) || t6.isFunctionExpression(arg)) {
|
878
|
-
const funcPath = t6.isAssignmentExpression(
|
882
|
+
const funcPath = t6.isAssignmentExpression(path2.node.arguments[0]) ? path2.get("arguments.0.right") : path2.get("arguments.0");
|
879
883
|
const detectedDependencies = getStylesDependenciesFromFunction(funcPath);
|
880
884
|
if (detectedDependencies) {
|
881
885
|
const body = t6.isBlockStatement(arg.body) ? arg.body.body.find((statement) => t6.isReturnStatement(statement))?.argument : arg.body;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import type {Compiler,LoaderContext,RspackPluginInstance } from '@rspack/core'
|
2
|
+
import type { UnistylesPluginOptions } from 'react-native-unistyles/plugin'
|
3
|
+
|
4
|
+
export declare const BASE_REPACK_EXCLUDE_PATHS: Array<RegExp>
|
5
|
+
interface ConstructorParams {
|
6
|
+
ruleExcludePaths?: Array<RegExp>
|
7
|
+
unistylesPluginOptions?: UnistylesPluginOptions
|
8
|
+
}
|
9
|
+
|
10
|
+
export declare class RepackUnistylePlugin implements RspackPluginInstance {
|
11
|
+
private ruleExcludePaths
|
12
|
+
private unistylesPluginOptions
|
13
|
+
constructor({ ruleExcludePaths, unistylesPluginOptions }?: ConstructorParams)
|
14
|
+
apply(compiler: Compiler): void
|
15
|
+
}
|
16
|
+
|
17
|
+
declare function unistylesLoader(this: LoaderContext<UnistylesLoaderOptions>, source: string): void;
|
18
|
+
|
19
|
+
export default unistylesLoader
|