react-native-unistyles 3.0.0-beta.5 → 3.0.0-beta.6
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 +14 -2
- package/android/src/main/cxx/NativeUnistylesModule.cpp +1 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +1 -2
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +4 -0
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +2 -1
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +0 -4
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +6 -6
- package/components/native/Animated/package.json +5 -0
- package/components/native/NativeText/package.json +5 -0
- package/components/native/NativeView/package.json +5 -0
- package/cxx/core/Unistyle.h +4 -0
- package/cxx/core/UnistylesRegistry.cpp +24 -3
- package/cxx/core/UnistylesRegistry.h +3 -0
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +7 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +27 -2
- package/cxx/parser/Parser.cpp +9 -3
- package/ios/NativePlatform+ios.swift +16 -4
- package/ios/UnistylesModuleOnLoad.h +4 -4
- package/ios/UnistylesModuleOnLoad.mm +4 -8
- package/lib/commonjs/components/native/Animated.js +23 -0
- package/lib/commonjs/components/native/Animated.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +3 -1
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/NativeText.js +13 -0
- package/lib/commonjs/components/native/NativeText.js.map +1 -0
- package/lib/commonjs/components/native/NativeText.native.js +18 -0
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
- package/lib/commonjs/components/native/NativeView.js +9 -0
- package/lib/commonjs/components/native/NativeView.js.map +1 -0
- package/lib/commonjs/components/native/NativeView.native.js +20 -0
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
- package/lib/commonjs/components/native/Pressable.native.js +16 -3
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +26 -22
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +37 -23
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +34 -30
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +1 -3
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js +3 -1
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/utils.js +16 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +5 -1
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/native/Animated.js +19 -0
- package/lib/module/components/native/Animated.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +3 -1
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/NativeText.js +4 -0
- package/lib/module/components/native/NativeText.js.map +1 -0
- package/lib/module/components/native/NativeText.native.js +15 -0
- package/lib/module/components/native/NativeText.native.js.map +1 -0
- package/lib/module/components/native/NativeView.js +5 -0
- package/lib/module/components/native/NativeView.js.map +1 -0
- package/lib/module/components/native/NativeView.native.js +17 -0
- package/lib/module/components/native/NativeView.native.js.map +1 -0
- package/lib/module/components/native/Pressable.native.js +17 -4
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +26 -22
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +38 -24
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +35 -31
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/getClassname.js +2 -4
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js +3 -1
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/utils.js +14 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +5 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -3
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts +39 -0
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
- package/lib/typescript/src/components/native/FlatList.d.ts +1 -3
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts +1 -3
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -8
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts +1 -2
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -3
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
- package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
- package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
- package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
- package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -3
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts +1 -3
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SectionList.d.ts +1 -3
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Switch.d.ts +1 -3
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Text.d.ts +1 -3
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TextInput.d.ts +1 -3
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -3
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -3
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
- package/lib/typescript/src/components/native/View.d.ts +1 -3
- package/lib/typescript/src/components/native/View.d.ts.map +1 -1
- package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -3
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -7
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts +1 -2
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts +2 -2
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -0
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +1 -0
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/package.json +11 -9
- package/plugin/consts.js +63 -0
- package/plugin/exotic.js +54 -0
- package/plugin/index.d.ts +84 -36
- package/plugin/index.js +27 -33
- package/plugin/stylesheet.js +12 -1
- package/plugin/variants.js +1 -1
- package/src/components/native/Animated.tsx +17 -0
- package/src/components/native/ImageBackground.tsx +4 -1
- package/src/components/native/NativeText.native.tsx +12 -0
- package/src/components/native/NativeText.tsx +1 -0
- package/src/components/native/NativeView.native.tsx +13 -0
- package/src/components/native/NativeView.tsx +3 -0
- package/src/components/native/Pressable.native.tsx +22 -4
- package/src/core/createUnistylesElement.native.tsx +42 -27
- package/src/core/createUnistylesElement.tsx +34 -29
- package/src/core/createUnistylesImageBackground.tsx +39 -34
- package/src/core/getClassname.ts +5 -4
- package/src/server/getServerUnistyles.tsx +2 -1
- package/src/specs/StyleSheet/index.ts +2 -1
- package/src/utils.ts +17 -0
- package/src/web/utils/unistyle.ts +7 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Switch.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Switch.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,KAAuC,CAAA"}
|
@@ -1,4 +1,2 @@
|
|
1
|
-
export declare const Text:
|
2
|
-
style?: import("../../types").UnistylesValues | Array<import("../../types").UnistylesValues>;
|
3
|
-
} & import("react").RefAttributes<unknown>>;
|
1
|
+
export declare const Text: any;
|
4
2
|
//# sourceMappingURL=Text.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Text.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Text.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI,KAAqC,CAAA"}
|
@@ -1,4 +1,2 @@
|
|
1
|
-
export declare const TextInput:
|
2
|
-
style?: import("../../types").UnistylesValues | Array<import("../../types").UnistylesValues>;
|
3
|
-
} & import("react").RefAttributes<unknown>>;
|
1
|
+
export declare const TextInput: any;
|
4
2
|
//# sourceMappingURL=TextInput.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/TextInput.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/TextInput.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,KAA0C,CAAA"}
|
@@ -1,4 +1,2 @@
|
|
1
|
-
export declare const TouchableHighlight:
|
2
|
-
style?: import("../../types").UnistylesValues | Array<import("../../types").UnistylesValues>;
|
3
|
-
} & import("react").RefAttributes<unknown>>;
|
1
|
+
export declare const TouchableHighlight: any;
|
4
2
|
//# sourceMappingURL=TouchableHighlight.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TouchableHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/TouchableHighlight.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB
|
1
|
+
{"version":3,"file":"TouchableHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/TouchableHighlight.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,KAAmD,CAAA"}
|
@@ -1,4 +1,2 @@
|
|
1
|
-
export declare const TouchableOpacity:
|
2
|
-
style?: import("../../types").UnistylesValues | Array<import("../../types").UnistylesValues>;
|
3
|
-
} & import("react").RefAttributes<unknown>>;
|
1
|
+
export declare const TouchableOpacity: any;
|
4
2
|
//# sourceMappingURL=TouchableOpacity.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TouchableOpacity.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/TouchableOpacity.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB
|
1
|
+
{"version":3,"file":"TouchableOpacity.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/TouchableOpacity.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,KAAiD,CAAA"}
|
@@ -1,4 +1,2 @@
|
|
1
|
-
export declare const View:
|
2
|
-
style?: import("../../types").UnistylesValues | Array<import("../../types").UnistylesValues>;
|
3
|
-
} & import("react").RefAttributes<unknown>>;
|
1
|
+
export declare const View: any;
|
4
2
|
//# sourceMappingURL=View.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"View.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/View.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI
|
1
|
+
{"version":3,"file":"View.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/View.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI,KAAqC,CAAA"}
|
@@ -1,4 +1,2 @@
|
|
1
|
-
export declare const VirtualizedList:
|
2
|
-
style?: import("../../types").UnistylesValues | Array<import("../../types").UnistylesValues>;
|
3
|
-
} & import("react").RefAttributes<unknown>>;
|
1
|
+
export declare const VirtualizedList: any;
|
4
2
|
//# sourceMappingURL=VirtualizedList.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"VirtualizedList.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/VirtualizedList.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe
|
1
|
+
{"version":3,"file":"VirtualizedList.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/VirtualizedList.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,KAAgD,CAAA"}
|
@@ -1,8 +1,2 @@
|
|
1
|
-
|
2
|
-
import type { UnistylesValues } from '../types';
|
3
|
-
type ComponentProps = {
|
4
|
-
style?: UnistylesValues | Array<UnistylesValues>;
|
5
|
-
};
|
6
|
-
export declare const createUnistylesElement: (Component: any) => React.ForwardRefExoticComponent<ComponentProps & React.RefAttributes<unknown>>;
|
7
|
-
export {};
|
1
|
+
export declare const createUnistylesElement: (Component: any) => any;
|
8
2
|
//# sourceMappingURL=createUnistylesElement.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createUnistylesElement.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"createUnistylesElement.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.tsx"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,cAAe,GAAG,QAmCpD,CAAA"}
|
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
export declare const createUnistylesElement: (Component: any) => React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
1
|
+
export declare const createUnistylesElement: (Component: any) => any;
|
3
2
|
//# sourceMappingURL=createUnistylesElement.native.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sBAAsB,cAAe,GAAG,QA+BpD,CAAA"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
export declare const createUnistylesImageBackground: (Component: typeof ImageBackground) => React.ForwardRefExoticComponent<ImageBackgroundProps & React.RefAttributes<ImageBackground>>;
|
1
|
+
import type { ImageBackground } from 'react-native';
|
2
|
+
export declare const createUnistylesImageBackground: (Component: typeof ImageBackground) => any;
|
4
3
|
//# sourceMappingURL=createUnistylesImageBackground.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createUnistylesImageBackground.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesImageBackground.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"createUnistylesImageBackground.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesImageBackground.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,eAAe,EAAwB,MAAM,cAAc,CAAA;AAMhF,eAAO,MAAM,8BAA8B,cAAe,OAAO,eAAe,QA0C/E,CAAA"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { UnistylesValues } from '../types';
|
2
2
|
export declare const getClassName: (unistyle: UnistylesValues | undefined | Array<UnistylesValues>) => {
|
3
3
|
$$css: boolean;
|
4
|
-
hash:
|
5
|
-
injectedClassName:
|
4
|
+
hash: string;
|
5
|
+
injectedClassName: string;
|
6
6
|
} | undefined;
|
7
7
|
//# sourceMappingURL=getClassname.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getClassname.d.ts","sourceRoot":"","sources":["../../../../src/core/getClassname.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,
|
1
|
+
{"version":3,"file":"getClassname.d.ts","sourceRoot":"","sources":["../../../../src/core/getClassname.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG/C,eAAO,MAAM,YAAY,aAAc,eAAe,GAAG,SAAS,GAAG,KAAK,CAAC,eAAe,CAAC;;;;aAU1F,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getServerUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/server/getServerUnistyles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAkC,KAAK,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEtF,eAAO,MAAM,kBAAkB,0BAAiC,uBAAuB,
|
1
|
+
{"version":3,"file":"getServerUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/server/getServerUnistyles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAkC,KAAK,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEtF,eAAO,MAAM,kBAAkB,0BAAiC,uBAAuB,sBActF,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/specs/StyleSheet/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAkC,MAAM,cAAc,CAAA;AAC3E,OAAO,KAAK,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,KAAK,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACjG,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAE5D,KAAK,sBAAsB,GAAG;IAC1B,YAAY,EAAE,CAAC,MAAM,MAAM,eAAe,CAAC,GAAG,MAAM,eAAe,CAAA;CACtE,GAAG;IACA,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,iBAAiB,GAAG,sBAAsB,GAAG;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/specs/StyleSheet/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAkC,MAAM,cAAc,CAAA;AAC3E,OAAO,KAAK,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,KAAK,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACjG,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAE5D,KAAK,sBAAsB,GAAG;IAC1B,YAAY,EAAE,CAAC,MAAM,MAAM,eAAe,CAAC,GAAG,MAAM,eAAe,CAAA;CACtE,GAAG;IACA,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,KAAK,iBAAiB,GAAG,sBAAsB,GAAG;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAC9C,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,oBAAoB,CAAA;CACrC,CAAA;AAED,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAChE,kBAAkB,EAAE,OAAO,oBAAoB,CAAC,kBAAkB,CAAC;IACnE,YAAY,EAAE,OAAO,oBAAoB,CAAC,YAAY,CAAC;IACvD,OAAO,EAAE,OAAO,oBAAoB,CAAC,OAAO,CAAC;IAC7C,OAAO,EAAE,OAAO,oBAAoB,CAAC,OAAO,CAAC;IAG7C,IAAI,IAAI,IAAI,CAAC;IACb,MAAM,EAAE,yBAAyB,CAAC;IAClC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE;QACP,YAAY,EAAE,OAAO,YAAY,CAAA;KACpC,CAAA;CACJ;AAeD,KAAK,cAAc,GAAG,WAAW,GAAG,mBAAmB,GAAG,MAAM,CAAA;AAEhE,eAAO,MAAM,UAAU,EAAgC,IAAI,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAA"}
|
@@ -1,3 +1,4 @@
|
|
1
1
|
export declare const isDefined: <T>(value: T) => value is NonNullable<T>;
|
2
2
|
export declare const deepMergeObjects: <T extends Record<PropertyKey, any>>(...sources: Array<T>) => T;
|
3
|
+
export declare const copyComponentProperties: (Component: any, UnistylesComponent: any) => any;
|
3
4
|
//# sourceMappingURL=utils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,CAAC,KAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAA0C,CAAA;AAExG,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,MAuBxF,CAAA"}
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,CAAC,KAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAA0C,CAAA;AAExG,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,MAuBxF,CAAA;AAED,eAAO,MAAM,uBAAuB,cAAe,GAAG,sBAAsB,GAAG,QAe9E,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAMpG,eAAO,MAAM,aAAa,WAAY,WAAW,qBAQhD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;CAC/D,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAanE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG;;
|
1
|
+
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAMpG,eAAO,MAAM,aAAa,WAAY,WAAW,qBAQhD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;CAC/D,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAanE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG;;aAkBzC,CAAA;AAED,eAAO,MAAM,kBAAkB,WAAY,eAAe,OAUzD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA;AAErF,eAAO,MAAM,aAAa,UAAW,MAAM,kBAAkB,KAAK,CAAC,MAAM,CAAC,WA6BzE,CAAA;AAED,eAAO,MAAM,2BAA2B,UAAW,GAAG,yBAQrD,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-beta.
|
3
|
+
"version": "3.0.0-beta.6",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -11,15 +11,15 @@
|
|
11
11
|
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
|
12
12
|
"release": "release-it"
|
13
13
|
},
|
14
|
-
"main": "lib/commonjs/index",
|
15
|
-
"module": "lib/module/index",
|
14
|
+
"main": "lib/commonjs/index.js",
|
15
|
+
"module": "lib/module/index.js",
|
16
16
|
"types": "lib/typescript/src/index.d.ts",
|
17
17
|
"source": "src/index",
|
18
18
|
"exports": {
|
19
19
|
".": {
|
20
20
|
"types": "./lib/typescript/src/index.d.ts",
|
21
|
-
"module": "./lib/module/index",
|
22
|
-
"default": "./lib/commonjs/index",
|
21
|
+
"module": "./lib/module/index.js",
|
22
|
+
"default": "./lib/commonjs/index.js",
|
23
23
|
"react-native": "./src/index"
|
24
24
|
},
|
25
25
|
"./components/native/*": {
|
@@ -34,8 +34,8 @@
|
|
34
34
|
"./package.json": "./package.json",
|
35
35
|
"./server": {
|
36
36
|
"types": "./lib/typescript/src/server/index.d.ts",
|
37
|
-
"module": "./lib/module/server/index",
|
38
|
-
"default": "./lib/commonjs/server/index",
|
37
|
+
"module": "./lib/module/server/index.js",
|
38
|
+
"default": "./lib/commonjs/server/index.js",
|
39
39
|
"react-native": "./src/server"
|
40
40
|
}
|
41
41
|
},
|
@@ -82,9 +82,11 @@
|
|
82
82
|
},
|
83
83
|
"devDependencies": {
|
84
84
|
"@babel/plugin-syntax-jsx": "7.25.9",
|
85
|
+
"@babel/preset-flow": "7.25.9",
|
86
|
+
"@babel/preset-typescript": "7.26.0",
|
85
87
|
"@biomejs/biome": "1.9.4",
|
86
88
|
"@commitlint/config-conventional": "19.6.0",
|
87
|
-
"@react-native/normalize-colors": "0.
|
89
|
+
"@react-native/normalize-colors": "0.77.0",
|
88
90
|
"@release-it/conventional-changelog": "8.0.2",
|
89
91
|
"@types/jest": "29.5.14",
|
90
92
|
"@types/react": "18.3.12",
|
@@ -96,7 +98,7 @@
|
|
96
98
|
"metro-react-native-babel-preset": "0.77.0",
|
97
99
|
"nitro-codegen": "0.21.0",
|
98
100
|
"react": "18.3.1",
|
99
|
-
"react-native": "0.
|
101
|
+
"react-native": "0.77.0",
|
100
102
|
"react-native-builder-bob": "0.33.1",
|
101
103
|
"react-native-nitro-modules": "0.21.0",
|
102
104
|
"react-native-web": "0.19.13",
|
package/plugin/consts.js
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
const REACT_NATIVE_COMPONENT_NAMES = [
|
2
|
+
'ActivityIndicator',
|
3
|
+
'View',
|
4
|
+
'Text',
|
5
|
+
'Image',
|
6
|
+
'ImageBackground',
|
7
|
+
'KeyboardAvoidingView',
|
8
|
+
'Pressable',
|
9
|
+
'ScrollView',
|
10
|
+
'FlatList',
|
11
|
+
'SectionList',
|
12
|
+
'Switch',
|
13
|
+
'TextInput',
|
14
|
+
'RefreshControl',
|
15
|
+
'TouchableHighlight',
|
16
|
+
'TouchableOpacity',
|
17
|
+
'VirtualizedList',
|
18
|
+
'Animated'
|
19
|
+
// Modal - there is no exposed native handle
|
20
|
+
// TouchableWithoutFeedback - can't accept a ref
|
21
|
+
]
|
22
|
+
|
23
|
+
// auto replace RN imports to Unistyles imports under these paths
|
24
|
+
// our implementation simply borrows 'ref' to register it in ShadowRegistry
|
25
|
+
// so we won't affect anyone's implementation
|
26
|
+
const REPLACE_WITH_UNISTYLES_PATHS = [
|
27
|
+
'react-native-reanimated/src/component',
|
28
|
+
'react-native-gesture-handler/src/components'
|
29
|
+
]
|
30
|
+
|
31
|
+
// this is more powerful API as it allows to convert unmatched imports to Unistyles
|
32
|
+
// { path: string, imports: Array<{ name: string, isDefault: boolean, path: string, mapTo: string }> }
|
33
|
+
// path => node_modules path
|
34
|
+
// imports:
|
35
|
+
// name? <- target import name if isDefault is false
|
36
|
+
// isDefault <- is the import default?
|
37
|
+
// path <- path to the target import
|
38
|
+
// mapTo <- name of the Unistyles component
|
39
|
+
const REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = []
|
40
|
+
|
41
|
+
// this list will additionally detect React Native direct imports
|
42
|
+
const NATIVE_COMPONENTS_PATHS = {
|
43
|
+
imports: [
|
44
|
+
{
|
45
|
+
name: 'NativeText',
|
46
|
+
isDefault: false,
|
47
|
+
path: 'react-native/Libraries/Text/TextNativeComponent',
|
48
|
+
mapTo: 'NativeText'
|
49
|
+
},
|
50
|
+
{
|
51
|
+
isDefault: true,
|
52
|
+
path: 'react-native/Libraries/Components/View/ViewNativeComponent',
|
53
|
+
mapTo: 'NativeView'
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
|
58
|
+
module.exports = {
|
59
|
+
NATIVE_COMPONENTS_PATHS,
|
60
|
+
REACT_NATIVE_COMPONENT_NAMES,
|
61
|
+
REPLACE_WITH_UNISTYLES_PATHS,
|
62
|
+
REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
|
63
|
+
}
|
package/plugin/exotic.js
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
function handleExoticImport(t, path, state, exoticImport) {
|
2
|
+
const specifiers = path.node.specifiers
|
3
|
+
const source = path.node.source
|
4
|
+
|
5
|
+
if (path.node.importKind !== 'value') {
|
6
|
+
return
|
7
|
+
}
|
8
|
+
|
9
|
+
specifiers.forEach(specifier => {
|
10
|
+
for (const rule of exoticImport.imports) {
|
11
|
+
const hasMatchingImportType = (!rule.isDefault && t.isImportSpecifier(specifier)) || (rule.isDefault && t.isImportDefaultSpecifier(specifier))
|
12
|
+
const hasMatchingImportName = rule.isDefault || (!rule.isDefault && rule.name === specifier.local.name)
|
13
|
+
const hasMatchingPath = rule.path === source.value
|
14
|
+
|
15
|
+
if (!hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
|
16
|
+
continue
|
17
|
+
}
|
18
|
+
|
19
|
+
if (t.isImportDefaultSpecifier(specifier)) {
|
20
|
+
const newImport = t.importDeclaration(
|
21
|
+
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
|
22
|
+
t.stringLiteral(state.opts.isLocal
|
23
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
24
|
+
: `react-native-unistyles/components/native/${rule.mapTo}`
|
25
|
+
)
|
26
|
+
)
|
27
|
+
|
28
|
+
path.replaceWith(newImport)
|
29
|
+
} else {
|
30
|
+
const newImport = t.importDeclaration(
|
31
|
+
[t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
|
32
|
+
t.stringLiteral(state.opts.isLocal
|
33
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
34
|
+
: `react-native-unistyles/components/native/${rule.mapTo}`
|
35
|
+
)
|
36
|
+
)
|
37
|
+
|
38
|
+
path.node.specifiers = specifiers.filter(s => s !== specifier)
|
39
|
+
|
40
|
+
if (path.node.specifiers.length === 0) {
|
41
|
+
path.replaceWith(newImport)
|
42
|
+
} else {
|
43
|
+
path.insertBefore(newImport)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
return
|
48
|
+
}
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
module.exports = {
|
53
|
+
handleExoticImport
|
54
|
+
}
|
package/plugin/index.d.ts
CHANGED
@@ -1,41 +1,89 @@
|
|
1
|
+
type RemapImport = {
|
2
|
+
name?: string,
|
3
|
+
isDefault: boolean,
|
4
|
+
path: string,
|
5
|
+
mapTo: string
|
6
|
+
}
|
7
|
+
|
8
|
+
type RemapConfig = {
|
9
|
+
path: string,
|
10
|
+
imports: Array<RemapImport>
|
11
|
+
}
|
12
|
+
|
1
13
|
export interface UnistylesPluginOptions {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
14
|
+
/**
|
15
|
+
* Example: "src" or "apps/mobile"
|
16
|
+
* Add this option if some of your components don't have `react-native-unistyles` import.
|
17
|
+
* Babel plugin will automatically process all files under this root.
|
18
|
+
*/
|
19
|
+
autoProcessRoot?: string,
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Example: ['@codemask/styles']
|
23
|
+
* Enable this option if you want to process only files containing specific imports.
|
24
|
+
*/
|
25
|
+
autoProcessImports?: Array<string>,
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Example: [{
|
29
|
+
* path: "node_modules/custom-library/components",
|
30
|
+
* imports: [
|
31
|
+
* {
|
32
|
+
* name: "NativeText",
|
33
|
+
* isDefault: false,
|
34
|
+
* path: "react-native/Libraries/Text/TextNativeComponent",
|
35
|
+
* mapTo: "NativeText"
|
36
|
+
* },
|
37
|
+
* {
|
38
|
+
* isDefault: true,
|
39
|
+
* path: "react-native/Libraries/Components/View/ViewNativeComponent",
|
40
|
+
* mapTo: "NativeView"
|
41
|
+
* }
|
42
|
+
* ]
|
43
|
+
* }]
|
44
|
+
*
|
45
|
+
* Will map:
|
46
|
+
* import { NativeText } from "react-native/Libraries/Text/TextNativeComponent"
|
47
|
+
* to Unistyles "NativeText"
|
48
|
+
*
|
49
|
+
* import View from "react-native/Libraries/Components/View/ViewNativeComponent"
|
50
|
+
* to Unistyles "NativeView"
|
51
|
+
*
|
52
|
+
* This is the most powerful way of remapping imports. If 3rd party library uses imports different from `react-native` we can remap them to `react-native-unistyles` factories.
|
53
|
+
* Internally we do that for raw RCTView and RCTText components.
|
54
|
+
*
|
55
|
+
* path -> must be within node_modules folder
|
56
|
+
* imports.name is Optional if library used export default
|
57
|
+
* imports.mapTo - name of the component from react-native-unistyles/src/components/native
|
58
|
+
*/
|
59
|
+
autoRemapImports?: Array<RemapConfig>,
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Example: ['external-library/components']
|
63
|
+
* Enable this option to process some 3rd party components under `node_modules`.
|
64
|
+
* Under these paths we will replace `react-native` imports with `react-native-unistyles` factories that will borrow components refs [read more](https://www.unistyl.es/v3/other/babel-plugin#3-component-factory-borrowing-ref).
|
65
|
+
*
|
66
|
+
* Defaults to:
|
67
|
+
*
|
68
|
+
* ```ts
|
69
|
+
* ['react-native-reanimated/src/component', 'react-native-gesture-handler/src/components']
|
70
|
+
* ```
|
71
|
+
*/
|
72
|
+
autoProcessPaths?: Array<string>,
|
73
|
+
|
74
|
+
/**
|
75
|
+
* In order to list detected dependencies by the Babel plugin you can enable the `debug` flag.
|
76
|
+
* It will `console.log` name of the file and component with Unistyles dependencies.
|
77
|
+
*/
|
78
|
+
debug?: boolean,
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Only applicable for Unistyles monorepo for
|
82
|
+
* path resolution, don't use it!
|
83
|
+
*/
|
84
|
+
isLocal?: boolean
|
37
85
|
}
|
38
86
|
|
39
87
|
export interface UnistylesPluginPass {
|
40
|
-
|
88
|
+
opts: UnistylesPluginOptions
|
41
89
|
}
|
package/plugin/index.js
CHANGED
@@ -1,36 +1,9 @@
|
|
1
1
|
const { addUnistylesImport, isInsideNodeModules } = require('./import')
|
2
2
|
const { hasStringRef } = require('./ref')
|
3
|
-
const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles, isKindOfStyleSheet } = require('./stylesheet')
|
3
|
+
const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles, isKindOfStyleSheet, addThemeDependencyToMemberExpression } = require('./stylesheet')
|
4
4
|
const { extractVariants } = require('./variants')
|
5
|
-
|
6
|
-
const
|
7
|
-
'ActivityIndicator',
|
8
|
-
'View',
|
9
|
-
'Text',
|
10
|
-
'Image',
|
11
|
-
'ImageBackground',
|
12
|
-
'KeyboardAvoidingView',
|
13
|
-
'Pressable',
|
14
|
-
'ScrollView',
|
15
|
-
'FlatList',
|
16
|
-
'SectionList',
|
17
|
-
'Switch',
|
18
|
-
'TextInput',
|
19
|
-
'RefreshControl',
|
20
|
-
'TouchableHighlight',
|
21
|
-
'TouchableOpacity',
|
22
|
-
'VirtualizedList',
|
23
|
-
// Modal - there is no exposed native handle
|
24
|
-
// TouchableWithoutFeedback - can't accept a ref
|
25
|
-
]
|
26
|
-
|
27
|
-
// auto replace RN imports to Unistyles imports under these paths
|
28
|
-
// our implementation simply borrows 'ref' to register it in ShadowRegistry
|
29
|
-
// so we won't affect anyone's implementation
|
30
|
-
const REPLACE_WITH_UNISTYLES_PATHS = [
|
31
|
-
'react-native-reanimated/src/component',
|
32
|
-
'react-native-gesture-handler/src/components'
|
33
|
-
]
|
5
|
+
const { REACT_NATIVE_COMPONENT_NAMES, REPLACE_WITH_UNISTYLES_PATHS, REPLACE_WITH_UNISTYLES_EXOTIC_PATHS, NATIVE_COMPONENTS_PATHS } = require('./consts')
|
6
|
+
const { handleExoticImport } = require('./exotic')
|
34
7
|
|
35
8
|
module.exports = function ({ types: t }) {
|
36
9
|
return {
|
@@ -48,14 +21,16 @@ module.exports = function ({ types: t }) {
|
|
48
21
|
state.file.styleSheetLocalName = ''
|
49
22
|
state.file.tagNumber = 0
|
50
23
|
state.reactNativeImports = {}
|
51
|
-
state.file.forceProcessing =
|
24
|
+
state.file.forceProcessing = state.opts.autoProcessRoot
|
25
|
+
? state.filename.includes(`${state.file.opts.root}/${state.opts.autoProcessRoot}/`)
|
26
|
+
: false
|
52
27
|
},
|
53
28
|
exit(path, state) {
|
54
29
|
if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
|
55
30
|
return
|
56
31
|
}
|
57
32
|
|
58
|
-
if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles) {
|
33
|
+
if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
|
59
34
|
addUnistylesImport(t, path, state)
|
60
35
|
}
|
61
36
|
}
|
@@ -105,6 +80,14 @@ module.exports = function ({ types: t }) {
|
|
105
80
|
},
|
106
81
|
/** @param {import('./index').UnistylesPluginPass} state */
|
107
82
|
ImportDeclaration(path, state) {
|
83
|
+
const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
|
84
|
+
.concat(state.opts.autoRemapImports ?? [])
|
85
|
+
.find(exotic => state.filename.includes(exotic.path))
|
86
|
+
|
87
|
+
if (exoticImport) {
|
88
|
+
return handleExoticImport(t, path, state, exoticImport)
|
89
|
+
}
|
90
|
+
|
108
91
|
if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
|
109
92
|
return
|
110
93
|
}
|
@@ -121,12 +104,16 @@ module.exports = function ({ types: t }) {
|
|
121
104
|
|
122
105
|
if (importSource === 'react-native') {
|
123
106
|
path.node.specifiers.forEach(specifier => {
|
124
|
-
if (specifier.imported &&
|
107
|
+
if (specifier.imported && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
|
125
108
|
state.reactNativeImports[specifier.local.name] = specifier.imported.name
|
126
109
|
}
|
127
110
|
})
|
128
111
|
}
|
129
112
|
|
113
|
+
if (importSource.includes('react-native/Libraries')) {
|
114
|
+
handleExoticImport(t, path, state, NATIVE_COMPONENTS_PATHS)
|
115
|
+
}
|
116
|
+
|
130
117
|
if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
|
131
118
|
state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource)
|
132
119
|
}
|
@@ -196,6 +183,13 @@ module.exports = function ({ types: t }) {
|
|
196
183
|
if (t.isObjectProperty(property)) {
|
197
184
|
const propertyValues = getUnistyles(t, property)
|
198
185
|
|
186
|
+
// maybe user used inlined theme? ({ container: theme.components.container })
|
187
|
+
if (propertyValues.length === 0 && t.isMemberExpression(property.value)) {
|
188
|
+
if (property.value.object.object.name === themeLocalName) {
|
189
|
+
addThemeDependencyToMemberExpression(t, property)
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
199
193
|
propertyValues.forEach(propertyValue => {
|
200
194
|
analyzeDependencies(t, state, property.key.name, propertyValue, themeLocalName, miniRuntimeLocalName)
|
201
195
|
})
|
package/plugin/stylesheet.js
CHANGED
@@ -219,10 +219,21 @@ function getUnistyles(t, property) {
|
|
219
219
|
return []
|
220
220
|
}
|
221
221
|
|
222
|
+
function addThemeDependencyToMemberExpression(t, path) {
|
223
|
+
path.value = t.objectExpression([
|
224
|
+
t.spreadElement(path.value),
|
225
|
+
t.objectProperty(
|
226
|
+
t.identifier('uni__dependencies'),
|
227
|
+
t.arrayExpression([t.numericLiteral(UnistyleDependency.Theme)])
|
228
|
+
)
|
229
|
+
])
|
230
|
+
}
|
231
|
+
|
222
232
|
module.exports = {
|
223
233
|
isUnistylesStyleSheet,
|
224
234
|
analyzeDependencies,
|
225
235
|
addStyleSheetTag,
|
226
236
|
getUnistyles,
|
227
|
-
isKindOfStyleSheet
|
237
|
+
isKindOfStyleSheet,
|
238
|
+
addThemeDependencyToMemberExpression
|
228
239
|
}
|
package/plugin/variants.js
CHANGED
@@ -15,7 +15,7 @@ function extractVariants(t, path, state) {
|
|
15
15
|
return (
|
16
16
|
t.isIdentifier(variant.expression.callee.object, { name: calleeName }) &&
|
17
17
|
t.isIdentifier(variant.expression.callee.property, { name: 'useVariants' }) &&
|
18
|
-
|
18
|
+
variant.expression.arguments.length === 1
|
19
19
|
)
|
20
20
|
})
|
21
21
|
|