react-native-unistyles 3.0.0-alpha.41 → 3.0.0-alpha.42
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -1
- package/cxx/common/Constants.h +0 -1
- package/cxx/core/UnistylesRegistry.cpp +10 -4
- package/cxx/core/UnistylesRegistry.h +1 -1
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +2 -2
- package/cxx/parser/Parser.cpp +7 -22
- package/cxx/parser/Parser.h +0 -1
- package/lib/commonjs/components/Display.js +2 -2
- package/lib/commonjs/components/Display.js.map +1 -1
- package/lib/commonjs/components/Hide.js +2 -2
- package/lib/commonjs/components/Hide.js.map +1 -1
- package/lib/commonjs/components/Pressable.js +64 -0
- package/lib/commonjs/components/Pressable.js.map +1 -0
- package/lib/commonjs/components/Pressable.web.js +97 -0
- package/lib/commonjs/components/Pressable.web.js.map +1 -0
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/core/getBoundArgs.js +18 -0
- package/lib/commonjs/core/getBoundArgs.js.map +1 -0
- package/lib/commonjs/core/getId.js +9 -0
- package/lib/commonjs/core/getId.js.map +1 -0
- package/lib/commonjs/core/index.js +14 -0
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/hooks/index.js +13 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useMedia.js.map +1 -0
- package/lib/commonjs/hooks/useMedia.web.js.map +1 -0
- package/lib/commonjs/index.js +8 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mq.js +6 -6
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +3 -4
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/commonjs/specs/index.web.js +0 -7
- package/lib/commonjs/specs/index.web.js.map +1 -1
- package/lib/commonjs/utils.js +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/types.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js +1 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/create.js +4 -1
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/index.js +7 -5
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/runtime.js +7 -7
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +23 -16
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +3 -3
- package/lib/commonjs/web/utils/common.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +2 -4
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web/variants/getVariants.js +1 -1
- package/lib/commonjs/web/variants/getVariants.js.map +1 -1
- package/lib/commonjs/web/variants/useVariants.js +1 -1
- package/lib/module/components/Display.js +1 -1
- package/lib/module/components/Display.js.map +1 -1
- package/lib/module/components/Hide.js +1 -1
- package/lib/module/components/Hide.js.map +1 -1
- package/lib/module/components/Pressable.js +58 -0
- package/lib/module/components/Pressable.js.map +1 -0
- package/lib/module/components/Pressable.web.js +91 -0
- package/lib/module/components/Pressable.web.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/core/getBoundArgs.js +13 -0
- package/lib/module/core/getBoundArgs.js.map +1 -0
- package/lib/module/core/getId.js +4 -0
- package/lib/module/core/getId.js.map +1 -0
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/hooks/index.js +4 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useMedia.js.map +1 -0
- package/lib/module/hooks/useMedia.web.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mq.js +6 -6
- package/lib/module/mq.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +3 -4
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/module/specs/index.web.js +0 -1
- package/lib/module/specs/index.web.js.map +1 -1
- package/lib/module/utils.js +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/types.js.map +1 -1
- package/lib/module/web/convert/utils.js +1 -1
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/create.js +5 -2
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/index.js +7 -3
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/runtime.js +8 -8
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +24 -17
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js +1 -1
- package/lib/module/web/utils/common.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +1 -2
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web/variants/getVariants.js +1 -1
- package/lib/module/web/variants/getVariants.js.map +1 -1
- package/lib/module/web/variants/useVariants.js +1 -1
- package/lib/typescript/src/components/Pressable.d.ts +7 -0
- package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/Pressable.web.d.ts +13 -0
- package/lib/typescript/src/components/Pressable.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +1 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/core/getBoundArgs.d.ts +2 -0
- package/lib/typescript/src/core/getBoundArgs.d.ts.map +1 -0
- package/lib/typescript/src/core/getId.d.ts +2 -0
- package/lib/typescript/src/core/getId.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 -1
- package/lib/typescript/src/hooks/index.d.ts +2 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMedia.web.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +3 -2
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.web.d.ts +0 -2
- package/lib/typescript/src/specs/index.web.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/web/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +8 -2
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts +1 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +0 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/package.json +12 -16
- package/plugin/common.js +1 -4
- package/plugin/import.js +29 -3
- package/plugin/index.js +18 -8
- package/plugin/ref.js +14 -74
- package/plugin/style.js +117 -63
- package/src/components/Display.tsx +1 -1
- package/src/components/Hide.tsx +1 -1
- package/src/components/Pressable.tsx +72 -0
- package/src/components/Pressable.web.tsx +103 -0
- package/src/components/index.ts +1 -0
- package/src/core/getBoundArgs.ts +15 -0
- package/src/core/getId.ts +1 -0
- package/src/core/index.ts +2 -0
- package/src/hooks/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/mq.ts +6 -6
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +1 -1
- package/src/specs/ShadowRegistry/index.ts +5 -6
- package/src/specs/ShadowRegistry/types.ts +2 -1
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +1 -1
- package/src/specs/StyleSheet/index.ts +3 -2
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -2
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
- package/src/specs/UnistylesRuntime/index.ts +1 -1
- package/src/specs/index.web.ts +0 -4
- package/src/types/common.ts +1 -0
- package/src/types/index.ts +1 -1
- package/src/utils.ts +1 -1
- package/src/web/convert/types.ts +1 -1
- package/src/web/convert/utils.ts +2 -2
- package/src/web/create.ts +6 -2
- package/src/web/index.ts +7 -3
- package/src/web/listener.ts +2 -0
- package/src/web/registry.ts +1 -1
- package/src/web/runtime.ts +9 -9
- package/src/web/shadowRegistry.ts +2 -2
- package/src/web/state.ts +36 -17
- package/src/web/utils/common.ts +1 -1
- package/src/web/utils/unistyle.ts +3 -9
- package/src/web/variants/getVariants.ts +1 -1
- package/src/web/variants/useVariants.ts +1 -1
- package/lib/commonjs/components/useMedia.js.map +0 -1
- package/lib/commonjs/components/useMedia.web.js.map +0 -1
- package/lib/module/components/useMedia.js.map +0 -1
- package/lib/module/components/useMedia.web.js.map +0 -1
- package/lib/typescript/src/components/useMedia.d.ts.map +0 -1
- package/lib/typescript/src/components/useMedia.web.d.ts.map +0 -1
- /package/lib/commonjs/{components → hooks}/useMedia.js +0 -0
- /package/lib/commonjs/{components → hooks}/useMedia.web.js +0 -0
- /package/lib/module/{components → hooks}/useMedia.js +0 -0
- /package/lib/module/{components → hooks}/useMedia.web.js +0 -0
- /package/lib/typescript/src/{components → hooks}/useMedia.d.ts +0 -0
- /package/lib/typescript/src/{components → hooks}/useMedia.web.d.ts +0 -0
- /package/src/{components → hooks}/useMedia.ts +0 -0
- /package/src/{components → hooks}/useMedia.web.ts +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,wBAAsB;IAE/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,YAAY;IAYpB,IAAI,WAAW,gBASd;IAED,IAAI,SAAS,cAMZ;IAED,IAAI,mBAAmB,2BAEtB;IAED,IAAI,WAAW,sCAEd;IAED,IAAI,UAAU,wDAEb;IAED,IAAI,WAAW,gBAMd;IAED,IAAI,KAAK,UAER;IAED,IAAI,UAAU,WAEb;IAED,IAAI,MAAM;;;MAYT;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,MAAM;;;;;;MAQT;IAED,IAAI,SAAS,oDAEZ;IAED,IAAI,GAAG,YAEN;IAED,IAAI,iBAAiB,YAEpB;IAED,IAAI,aAAa,2DAEhB;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,cAAe,YAAY,
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,wBAAsB;IAE/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,YAAY;IAYpB,IAAI,WAAW,gBASd;IAED,IAAI,SAAS,cAMZ;IAED,IAAI,mBAAmB,2BAEtB;IAED,IAAI,WAAW,sCAEd;IAED,IAAI,UAAU,wDAEb;IAED,IAAI,WAAW,gBAMd;IAED,IAAI,KAAK,UAER;IAED,IAAI,UAAU,WAEb;IAED,IAAI,MAAM;;;MAYT;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,MAAM;;;;;;MAQT;IAED,IAAI,SAAS,oDAEZ;IAED,IAAI,GAAG,YAEN;IAED,IAAI,iBAAiB,YAEpB;IAED,IAAI,aAAa,2DAEhB;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,cAAe,YAAY,UAYlC;IAED,iBAAiB,cAAe,OAAO,UAQtC;IAED,0BAA0B,UAAW,MAAM,UAM1C;IAED,gBAAgB,aAAW;IAE3B,WAAW,cAAe,YAAY,WAAW,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,UAQpF;IAED,QAAQ,mCAQP;CACJ;AAED,eAAO,MAAM,gBAAgB,yBAAgC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAY,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,WAAW,CAAA;
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAY,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,WAAW,CAAA;AAStE,cAAM,qBAAqB;IACvB,MAAM,qBAAoC;IAC1C,SAAS,CAAC,EAAE,YAAY,CAAA;IAExB,OAAO,CAAC,mBAAmB,CAA6B;IAExD,IAAI,UAAU,IAKkB,aAAa,GAAG,SAAS,CACxD;IAED,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC,iBAAiB,UAAQ;IAEzB,IAAI,WAAY,eAAe,UAa9B;IAED,OAAO,CAAC,UAAU,CAIjB;IAED,OAAO,CAAC,YAAY,CA6BnB;IAED,OAAO,CAAC,eAAe,CA2BtB;CACJ;AAED,eAAO,MAAM,cAAc,uBAA8B,CAAA"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
export declare const reduceObject: <TObj extends Record<string, any>, TReducer>(obj: TObj, reducer: (value: TObj[keyof TObj], key: keyof TObj) => TReducer) => { [K in keyof TObj]: TReducer; };
|
2
2
|
export declare const keyInObject: <T extends Record<string, any>>(obj: T, key: PropertyKey) => key is keyof T;
|
3
3
|
export declare const isServer: () => boolean;
|
4
|
-
export declare const
|
4
|
+
export declare const error: (message: string) => Error;
|
5
5
|
export declare const equal: <T>(a: T, b: T) => boolean;
|
6
6
|
export declare const generateHash: (value: any) => string;
|
7
7
|
export declare const hyphenate: (propertyName: string) => string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,OAC9D,IAAI,WACA,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,IAAI,KAAK,QAAQ,KACmD,GAAG,
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,OAC9D,IAAI,WACA,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,IAAI,KAAK,QAAQ,KACmD,GAAG,CAAC,IAAI,MAAM,IAAI,GAAG,QAAQ,GAAE,CAAA;AAErJ,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,WAAW,KAAG,GAAG,IAAI,MAAM,CAAe,CAAA;AAElH,eAAO,MAAM,QAAQ,eAAsC,CAAA;AAE3D,eAAO,MAAM,KAAK,YAAa,MAAM,UAAuC,CAAA;AAE5E,eAAO,MAAM,KAAK,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAqBlC,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,GAAG,WAQtC,CAAA;AAED,eAAO,MAAM,SAAS,iBAAkB,MAAM,WAAyE,CAAA"}
|
@@ -2,7 +2,6 @@ import type { UnistyleDependency } from '../../specs/NativePlatform';
|
|
2
2
|
import { ColorScheme } from '../../specs/types';
|
3
3
|
import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet';
|
4
4
|
export declare const schemeToTheme: (scheme: ColorScheme) => "light" | "dark";
|
5
|
-
export declare const hexToRGBA: (hex: string, opacity: number) => string;
|
6
5
|
export type UnistyleSecrets = {
|
7
6
|
__uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
|
8
7
|
__uni__key: string;
|
@@ -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;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,qBAQhD,CAAA;AAED,
|
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;AAKpG,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,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAKnE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,sBAUzC,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,eAAe,OAUhD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA;AAErF,eAAO,MAAM,sBAAsB,UAAW,MAAM,uBAYnD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAmB1C,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-alpha.
|
3
|
+
"version": "3.0.0-alpha.42",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"tsc": "node_modules/typescript/bin/tsc --noEmit",
|
9
9
|
"lint": "biome lint",
|
10
10
|
"prepare": "husky && bob build",
|
11
|
-
"precommit": "concurrently '
|
11
|
+
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
|
12
12
|
"release": "release-it"
|
13
13
|
},
|
14
14
|
"main": "lib/commonjs/index",
|
@@ -42,11 +42,7 @@
|
|
42
42
|
"react-native",
|
43
43
|
"ios",
|
44
44
|
"android",
|
45
|
-
"react-native-macos",
|
46
|
-
"react-native-windows",
|
47
45
|
"react-native-web",
|
48
|
-
"react-native-tvos",
|
49
|
-
"react-native-visionos",
|
50
46
|
"expo"
|
51
47
|
],
|
52
48
|
"repository": "https://github.com/jpudysz/react-native-unistyles",
|
@@ -62,26 +58,26 @@
|
|
62
58
|
"devDependencies": {
|
63
59
|
"@babel/plugin-syntax-jsx": "7.25.9",
|
64
60
|
"@biomejs/biome": "1.9.4",
|
65
|
-
"@commitlint/config-conventional": "19.
|
66
|
-
"@react-native/normalize-colors": "0.76.
|
61
|
+
"@commitlint/config-conventional": "19.6.0",
|
62
|
+
"@react-native/normalize-colors": "0.76.3",
|
67
63
|
"@release-it/conventional-changelog": "8.0.2",
|
68
|
-
"@testing-library/react-hooks": "8.0.1",
|
69
64
|
"@types/jest": "29.5.14",
|
70
65
|
"@types/react": "18.3.12",
|
71
66
|
"babel-plugin-tester": "11.0.4",
|
72
|
-
"commitlint": "19.
|
73
|
-
"concurrently": "
|
74
|
-
"husky": "9.1.
|
67
|
+
"commitlint": "19.6.0",
|
68
|
+
"concurrently": "9.1.0",
|
69
|
+
"husky": "9.1.7",
|
75
70
|
"jest": "29.7.0",
|
76
71
|
"metro-react-native-babel-preset": "0.77.0",
|
77
72
|
"nitro-codegen": "0.17.0",
|
78
73
|
"react": "18.3.1",
|
79
|
-
"react-native": "0.76.
|
80
|
-
"react-native-builder-bob": "0.
|
74
|
+
"react-native": "0.76.3",
|
75
|
+
"react-native-builder-bob": "0.33.1",
|
81
76
|
"react-native-nitro-modules": "0.17.0",
|
77
|
+
"react-native-web": "0.19.13",
|
82
78
|
"react-test-renderer": "18.3.1",
|
83
|
-
"release-it": "17.
|
84
|
-
"typescript": "5.
|
79
|
+
"release-it": "17.6.0",
|
80
|
+
"typescript": "5.7.2"
|
85
81
|
},
|
86
82
|
"peerDependencies": {
|
87
83
|
"@react-native/normalize-colors": "*",
|
package/plugin/common.js
CHANGED
@@ -138,10 +138,7 @@ function getSecondPropertyName(t, memberExpression) {
|
|
138
138
|
return []
|
139
139
|
}
|
140
140
|
|
141
|
-
const PRESSABLE_STATE_NAME = '__uni_pressable_state'
|
142
|
-
|
143
141
|
module.exports = {
|
144
142
|
getIdentifierNameFromExpression,
|
145
|
-
getSecondPropertyName
|
146
|
-
PRESSABLE_STATE_NAME
|
143
|
+
getSecondPropertyName
|
147
144
|
}
|
package/plugin/import.js
CHANGED
@@ -1,8 +1,34 @@
|
|
1
|
-
module.exports = function
|
1
|
+
module.exports = function addUnistylesImport(t, path, state) {
|
2
2
|
const newImport = t.importDeclaration(
|
3
|
-
[
|
3
|
+
[
|
4
|
+
t.importSpecifier(t.identifier('UnistylesShadowRegistry'), t.identifier('UnistylesShadowRegistry')),
|
5
|
+
...state.file.shouldIncludePressable
|
6
|
+
? [
|
7
|
+
t.importSpecifier(t.identifier('Pressable'), t.identifier('Pressable')),
|
8
|
+
t.importSpecifier(t.identifier('getBoundArgs'), t.identifier('getBoundArgs'))
|
9
|
+
]
|
10
|
+
: []
|
11
|
+
].filter(Boolean),
|
4
12
|
t.stringLiteral('react-native-unistyles')
|
5
13
|
)
|
6
14
|
|
7
|
-
|
15
|
+
if (state.file.shouldIncludePressable) {
|
16
|
+
const rnImport = path.node.body.find(node => t.isImportDeclaration(node) && node.source.value === 'react-native')
|
17
|
+
|
18
|
+
if (rnImport) {
|
19
|
+
rnImport.specifiers = rnImport.specifiers.filter(specifier => specifier.local.name !== 'Pressable')
|
20
|
+
}
|
21
|
+
|
22
|
+
const rnWebImport = path.node.body.find(node => t.isImportDeclaration(node) && node.source.value === 'react-native-web/dist/exports/Pressable')
|
23
|
+
const unistylesImport = path.node.body.find(node => t.isImportDeclaration(node) && node.source.value === 'react-native-unistyles')
|
24
|
+
const hasUniPressable = unistylesImport && unistylesImport.specifiers
|
25
|
+
? unistylesImport.specifiers.find(specifier => specifier.imported.name === 'Pressable' && specifier.local.name !== "NativePressableReactNative")
|
26
|
+
: false
|
27
|
+
|
28
|
+
if (rnWebImport && !hasUniPressable) {
|
29
|
+
rnWebImport.specifiers = []
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
path.node.body.unshift(newImport)
|
8
34
|
}
|
package/plugin/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const
|
1
|
+
const addUnistylesImport = require('./import')
|
2
2
|
const { getStyleMetadata, getStyleAttribute, styleAttributeToArray, handlePressable } = require('./style')
|
3
3
|
const { getRefProp, addRef, overrideRef, hasStringRef } = require('./ref')
|
4
4
|
const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyle } = require('./stylesheet')
|
@@ -32,6 +32,8 @@ module.exports = function ({ types: t }) {
|
|
32
32
|
enter(path, state) {
|
33
33
|
state.file.hasAnyUnistyle = false
|
34
34
|
state.file.hasUnistylesImport = false
|
35
|
+
state.file.shouldIncludePressable = false
|
36
|
+
state.file.hasVariants = false
|
35
37
|
state.file.styleSheetLocalName = ''
|
36
38
|
state.file.tagNumber = 0
|
37
39
|
state.file.isClassComponent = false
|
@@ -39,7 +41,7 @@ module.exports = function ({ types: t }) {
|
|
39
41
|
},
|
40
42
|
exit(path, state) {
|
41
43
|
if (state.file.hasAnyUnistyle) {
|
42
|
-
|
44
|
+
addUnistylesImport(t, path, state)
|
43
45
|
}
|
44
46
|
}
|
45
47
|
},
|
@@ -90,11 +92,19 @@ module.exports = function ({ types: t }) {
|
|
90
92
|
|
91
93
|
if (importSource.includes('react-native')) {
|
92
94
|
path.node.specifiers.forEach(specifier => {
|
95
|
+
if (specifier.imported && specifier.imported.name === 'Pressable' && specifier.local.name !== 'NativePressableReactNative') {
|
96
|
+
state.file.shouldIncludePressable = true
|
97
|
+
}
|
98
|
+
|
93
99
|
if (specifier.imported && reactNativeComponentNames.includes(specifier.imported.name)) {
|
94
100
|
state.reactNativeImports[specifier.local.name] = true
|
95
101
|
}
|
96
102
|
})
|
97
103
|
}
|
104
|
+
|
105
|
+
if (importSource.includes('react-native-web/dist/exports/Pressable')) {
|
106
|
+
state.file.shouldIncludePressable = true
|
107
|
+
}
|
98
108
|
},
|
99
109
|
JSXElement(path, state) {
|
100
110
|
if (state.file.isClassComponent) {
|
@@ -123,15 +133,15 @@ module.exports = function ({ types: t }) {
|
|
123
133
|
|
124
134
|
const metadata = getStyleMetadata(t, styleAttr.value.expression)
|
125
135
|
|
136
|
+
if (openingElementName === 'Pressable') {
|
137
|
+
return handlePressable(t, path, styleAttr, metadata, state)
|
138
|
+
}
|
139
|
+
|
126
140
|
// style prop is using unexpected expression
|
127
141
|
if (metadata.length === 0) {
|
128
142
|
return
|
129
143
|
}
|
130
144
|
|
131
|
-
const uniquePressableId = openingElementName === 'Pressable'
|
132
|
-
? handlePressable(t, path, styleAttr, metadata)
|
133
|
-
: undefined
|
134
|
-
|
135
145
|
styleAttributeToArray(t, path)
|
136
146
|
|
137
147
|
// to add import
|
@@ -144,8 +154,8 @@ module.exports = function ({ types: t }) {
|
|
144
154
|
}
|
145
155
|
|
146
156
|
refProp
|
147
|
-
? overrideRef(t, path, refProp, metadata, state
|
148
|
-
: addRef(t, path, metadata, state
|
157
|
+
? overrideRef(t, path, refProp, metadata, state)
|
158
|
+
: addRef(t, path, metadata, state)
|
149
159
|
},
|
150
160
|
CallExpression(path, state) {
|
151
161
|
if (isUsingVariants(t, path)) {
|
package/plugin/ref.js
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
const { PRESSABLE_STATE_NAME } = require('./common')
|
2
|
-
|
3
|
-
function generateUniqueId() {
|
4
|
-
return `${Math.random().toString(36).substring(2, 9)}`
|
5
|
-
}
|
6
|
-
|
7
1
|
function getRefProp(t, path) {
|
8
2
|
return path.node.openingElement.attributes.find(attr =>
|
9
3
|
t.isJSXAttribute(attr) &&
|
@@ -37,65 +31,16 @@ function arrayExpressionFromMetadata(t, metadata) {
|
|
37
31
|
}
|
38
32
|
|
39
33
|
function arrayFromDynamicFunctionArgs(t, metadata, path) {
|
40
|
-
const hasPressableDynamicFunction = path.node.openingElement.attributes
|
41
|
-
.find(attr => t.isJSXIdentifier(attr.name) && attr.name.name === "style" && t.isArrowFunctionExpression(attr.value.expression))
|
42
|
-
|
43
34
|
const memberExpressions = metadata
|
44
|
-
.map(meta =>
|
45
|
-
|
46
|
-
|
47
|
-
// special case for pressable
|
48
|
-
if (t.isIdentifier(arg) && arg.name === PRESSABLE_STATE_NAME) {
|
49
|
-
// replace with { pressed: false }
|
50
|
-
return t.objectExpression([
|
51
|
-
t.objectProperty(
|
52
|
-
t.identifier("pressed"),
|
53
|
-
t.booleanLiteral(false)
|
54
|
-
)
|
55
|
-
])
|
56
|
-
}
|
57
|
-
|
58
|
-
if (t.isMemberExpression(arg) && arg.object.name === PRESSABLE_STATE_NAME) {
|
59
|
-
return t.identifier('false')
|
60
|
-
}
|
61
|
-
|
62
|
-
return arg
|
63
|
-
})
|
64
|
-
|
65
|
-
return t.arrayExpression(args)
|
66
|
-
}
|
67
|
-
|
68
|
-
// typeof styles.pressable === "function" ? { pressed: false } : []
|
69
|
-
if (hasPressableDynamicFunction) {
|
70
|
-
return t.arrayExpression([
|
71
|
-
t.conditionalExpression(
|
72
|
-
t.binaryExpression(
|
73
|
-
"===",
|
74
|
-
t.unaryExpression(
|
75
|
-
"typeof",
|
76
|
-
t.identifier("styles.pressable")
|
77
|
-
),
|
78
|
-
t.stringLiteral("function")
|
79
|
-
),
|
80
|
-
t.objectExpression([
|
81
|
-
t.objectProperty(
|
82
|
-
t.identifier("pressed"),
|
83
|
-
t.booleanLiteral(false)
|
84
|
-
)
|
85
|
-
]),
|
86
|
-
t.arrayExpression([])
|
87
|
-
)
|
88
|
-
])
|
89
|
-
}
|
90
|
-
|
91
|
-
return t.arrayExpression([])
|
92
|
-
})
|
35
|
+
.map(meta => meta.dynamicFunction
|
36
|
+
? t.arrayExpression(meta.dynamicFunction.arguments)
|
37
|
+
: t.arrayExpression([]))
|
93
38
|
.filter(Boolean)
|
94
39
|
|
95
40
|
return t.arrayExpression(memberExpressions)
|
96
41
|
}
|
97
42
|
|
98
|
-
function addRef(t, path, metadata, state
|
43
|
+
function addRef(t, path, metadata, state) {
|
99
44
|
const hasVariants = state.file.hasVariants
|
100
45
|
|
101
46
|
const newRefFunction = t.arrowFunctionExpression(
|
@@ -108,9 +53,8 @@ function addRef(t, path, metadata, state, uniquePressableId) {
|
|
108
53
|
t.identifier('ref'),
|
109
54
|
arrayExpressionFromMetadata(t, metadata),
|
110
55
|
t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
|
111
|
-
arrayFromDynamicFunctionArgs(t, metadata, path)
|
112
|
-
|
113
|
-
].filter(Boolean)
|
56
|
+
arrayFromDynamicFunctionArgs(t, metadata, path)
|
57
|
+
]
|
114
58
|
)
|
115
59
|
),
|
116
60
|
t.returnStatement(
|
@@ -132,7 +76,7 @@ function addRef(t, path, metadata, state, uniquePressableId) {
|
|
132
76
|
path.node.openingElement.attributes.push(newRefProp)
|
133
77
|
}
|
134
78
|
|
135
|
-
function overrideRef(t, path, refProp, metadata, state
|
79
|
+
function overrideRef(t, path, refProp, metadata, state) {
|
136
80
|
const hasVariants = state.file.hasVariants
|
137
81
|
const uniqueRefName = path.scope.generateUidIdentifier('ref').name
|
138
82
|
const isIdentifier = t.isIdentifier(refProp.value.expression)
|
@@ -158,9 +102,8 @@ function overrideRef(t, path, refProp, metadata, state, uniquePressableId) {
|
|
158
102
|
t.identifier(uniqueRefName),
|
159
103
|
arrayExpressionFromMetadata(t, metadata),
|
160
104
|
t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
|
161
|
-
arrayFromDynamicFunctionArgs(t, metadata, path)
|
162
|
-
|
163
|
-
].filter(Boolean)
|
105
|
+
arrayFromDynamicFunctionArgs(t, metadata, path)
|
106
|
+
]
|
164
107
|
)
|
165
108
|
),
|
166
109
|
t.returnStatement(
|
@@ -204,9 +147,8 @@ function overrideRef(t, path, refProp, metadata, state, uniquePressableId) {
|
|
204
147
|
t.identifier(userRefName),
|
205
148
|
arrayExpressionFromMetadata(t, metadata),
|
206
149
|
t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
|
207
|
-
arrayFromDynamicFunctionArgs(t, metadata, path)
|
208
|
-
|
209
|
-
].filter(Boolean)
|
150
|
+
arrayFromDynamicFunctionArgs(t, metadata, path)
|
151
|
+
]
|
210
152
|
)
|
211
153
|
),
|
212
154
|
// Merged cleanup function
|
@@ -267,9 +209,8 @@ function overrideRef(t, path, refProp, metadata, state, uniquePressableId) {
|
|
267
209
|
t.identifier(uniqueRefName),
|
268
210
|
arrayExpressionFromMetadata(t, metadata),
|
269
211
|
t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
|
270
|
-
arrayFromDynamicFunctionArgs(t, metadata, path)
|
271
|
-
|
272
|
-
].filter(Boolean)
|
212
|
+
arrayFromDynamicFunctionArgs(t, metadata, path)
|
213
|
+
]
|
273
214
|
)
|
274
215
|
),
|
275
216
|
t.returnStatement(
|
@@ -300,6 +241,5 @@ module.exports = {
|
|
300
241
|
getRefProp,
|
301
242
|
addRef,
|
302
243
|
overrideRef,
|
303
|
-
hasStringRef
|
304
|
-
generateUniqueId
|
244
|
+
hasStringRef
|
305
245
|
}
|
package/plugin/style.js
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
const { PRESSABLE_STATE_NAME } = require('./common')
|
2
|
-
const { generateUniqueId } = require('./ref')
|
3
|
-
|
4
1
|
function getStyleMetadata(t, node, dynamicFunction = null) {
|
5
2
|
// {styles.container}
|
6
3
|
if (t.isMemberExpression(node)) {
|
@@ -71,7 +68,6 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
|
|
71
68
|
}]
|
72
69
|
}
|
73
70
|
|
74
|
-
// pressable
|
75
71
|
if (t.isArrowFunctionExpression(node)) {
|
76
72
|
return getStyleMetadata(t, node.body, node)
|
77
73
|
}
|
@@ -90,12 +86,6 @@ function getStyleAttribute(t, path) {
|
|
90
86
|
function styleAttributeToArray(t, path) {
|
91
87
|
const styleAttribute = getStyleAttribute(t, path)
|
92
88
|
|
93
|
-
// special case for pressable
|
94
|
-
// {state => styles.pressable(state)}
|
95
|
-
if (t.isArrowFunctionExpression(styleAttribute.value.expression)) {
|
96
|
-
return
|
97
|
-
}
|
98
|
-
|
99
89
|
// {{...style.container, ...style.container}}
|
100
90
|
if (t.isObjectExpression(styleAttribute.value.expression)) {
|
101
91
|
const properties = styleAttribute.value.expression.properties
|
@@ -127,12 +117,35 @@ function styleAttributeToArray(t, path) {
|
|
127
117
|
styleAttribute.value.expression = t.arrayExpression([styleAttribute.value.expression])
|
128
118
|
}
|
129
119
|
|
130
|
-
function handlePressable(t, path, styleAttr, metadata) {
|
131
|
-
|
120
|
+
function handlePressable(t, path, styleAttr, metadata, state) {
|
121
|
+
if (state.file.hasVariants) {
|
122
|
+
const variants = t.jsxAttribute(
|
123
|
+
t.jsxIdentifier('variants'),
|
124
|
+
t.jsxExpressionContainer(t.identifier('__uni__variants'))
|
125
|
+
)
|
126
|
+
|
127
|
+
path.node.openingElement.attributes.push(variants)
|
128
|
+
}
|
129
|
+
|
130
|
+
// add raw C++ style as prop to be bound
|
131
|
+
const props = metadata
|
132
|
+
.map(meta => meta.members)
|
133
|
+
.filter(members => members.length > 0)
|
134
|
+
.flatMap(members => t.memberExpression(...members.map(member => t.identifier(member))))
|
132
135
|
|
136
|
+
const rawStyles = t.jsxAttribute(
|
137
|
+
t.jsxIdentifier('rawStyle'),
|
138
|
+
t.jsxExpressionContainer(t.arrayExpression([
|
139
|
+
...props
|
140
|
+
]))
|
141
|
+
)
|
142
|
+
|
143
|
+
path.node.openingElement.attributes.push(rawStyles)
|
144
|
+
|
145
|
+
const styleExpression = styleAttr.value.expression
|
133
146
|
// {style.pressable}
|
134
|
-
// the worst case, we don't know if user rely on state
|
135
147
|
if (t.isMemberExpression(styleExpression)) {
|
148
|
+
// user may care about state, but didn't pass any arguments
|
136
149
|
const members = metadata.at(0).members
|
137
150
|
|
138
151
|
if (members.length === 0) {
|
@@ -143,10 +156,18 @@ function handlePressable(t, path, styleAttr, metadata) {
|
|
143
156
|
(acc, property) => t.memberExpression(acc, t.identifier(property)),
|
144
157
|
t.identifier(members[0])
|
145
158
|
)
|
159
|
+
const expression = t.callExpression(
|
160
|
+
t.identifier('getBoundArgs'),
|
161
|
+
[stylePath]
|
162
|
+
)
|
163
|
+
const bindCall = t.callExpression(
|
164
|
+
t.memberExpression(expression, t.identifier('bind')),
|
165
|
+
[t.identifier('undefined'), t.identifier("state")]
|
166
|
+
)
|
146
167
|
|
147
|
-
|
148
|
-
|
149
|
-
//
|
168
|
+
// state => typeof style.pressable === 'function'
|
169
|
+
// ? getBoundArgs(style.pressable).bind(undefined, state)
|
170
|
+
// : style.pressable
|
150
171
|
styleAttr.value.expression = t.arrowFunctionExpression(
|
151
172
|
[t.identifier("state")],
|
152
173
|
t.conditionalExpression(
|
@@ -158,81 +179,114 @@ function handlePressable(t, path, styleAttr, metadata) {
|
|
158
179
|
),
|
159
180
|
t.stringLiteral("function")
|
160
181
|
),
|
161
|
-
|
162
|
-
stylePath,
|
163
|
-
[t.identifier("state"), t.objectExpression([
|
164
|
-
t.objectProperty(
|
165
|
-
t.identifier("__uni_pressable_id"),
|
166
|
-
t.stringLiteral(uniquePressableId)
|
167
|
-
)
|
168
|
-
])]
|
169
|
-
),
|
182
|
+
bindCall,
|
170
183
|
stylePath
|
171
184
|
)
|
172
185
|
)
|
173
186
|
|
174
|
-
return
|
187
|
+
return
|
175
188
|
}
|
176
189
|
|
177
190
|
// {style.pressable(1, 2)}
|
178
191
|
if (t.isCallExpression(styleExpression)) {
|
179
192
|
// user already called dynamic function
|
180
|
-
|
181
|
-
|
182
|
-
|
193
|
+
const expression = t.callExpression(
|
194
|
+
t.identifier('getBoundArgs'),
|
195
|
+
[styleExpression.callee]
|
196
|
+
)
|
197
|
+
const bindCall = t.callExpression(
|
198
|
+
t.memberExpression(expression, t.identifier('bind')),
|
199
|
+
[t.identifier('undefined'), ...styleExpression.arguments]
|
200
|
+
)
|
183
201
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
202
|
+
path.node.openingElement.attributes = path.node.openingElement.attributes.map(attribute => {
|
203
|
+
if (attribute.name.name === "style") {
|
204
|
+
attribute.value.expression = t.arrowFunctionExpression([], bindCall)
|
205
|
+
}
|
206
|
+
|
207
|
+
return attribute
|
208
|
+
})
|
189
209
|
|
190
210
|
return
|
191
211
|
}
|
192
212
|
|
193
|
-
// {
|
194
|
-
if (t.isArrowFunctionExpression(styleExpression) && styleExpression.params.length
|
195
|
-
|
196
|
-
|
197
|
-
|
213
|
+
// {() => style.pressable(1, 2)}
|
214
|
+
if (t.isArrowFunctionExpression(styleExpression) && styleExpression.params.length === 0) {
|
215
|
+
const wrapper = t.isBlockStatement(styleExpression.body)
|
216
|
+
? styleExpression.body.body.find(node => t.isReturnStatement(node))
|
217
|
+
: styleExpression.body
|
198
218
|
|
199
|
-
if (
|
219
|
+
if (t.isMemberExpression(wrapper)) {
|
200
220
|
return
|
201
221
|
}
|
202
222
|
|
203
|
-
|
204
|
-
|
223
|
+
const pressableArgs = t.isCallExpression(wrapper)
|
224
|
+
? wrapper.arguments
|
225
|
+
: wrapper.argument.arguments
|
226
|
+
const callee = t.isCallExpression(wrapper)
|
227
|
+
? wrapper.callee
|
228
|
+
: wrapper.argument.callee
|
229
|
+
const getBoundArgsCall = t.callExpression(
|
230
|
+
t.identifier('getBoundArgs'),
|
231
|
+
[callee]
|
232
|
+
)
|
233
|
+
const bindCall = t.callExpression(
|
234
|
+
t.memberExpression(getBoundArgsCall, t.identifier('bind')),
|
235
|
+
[t.identifier('undefined'), ...pressableArgs]
|
236
|
+
)
|
237
|
+
|
238
|
+
if (t.isCallExpression(wrapper)) {
|
239
|
+
styleExpression.body = bindCall
|
205
240
|
|
206
|
-
if (!stateIdentifier || !t.isIdentifier(stateIdentifier)) {
|
207
241
|
return
|
208
242
|
}
|
209
243
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
arg.name = PRESSABLE_STATE_NAME
|
214
|
-
}
|
244
|
+
if (wrapper) {
|
245
|
+
wrapper.argument = bindCall
|
246
|
+
}
|
215
247
|
|
216
|
-
|
217
|
-
|
218
|
-
}
|
248
|
+
return
|
249
|
+
}
|
219
250
|
|
220
|
-
|
221
|
-
|
251
|
+
// {state => style.pressable(state, 1, 2)}
|
252
|
+
if (t.isArrowFunctionExpression(styleExpression) && styleExpression.params.length > 0) {
|
253
|
+
// user used state with custom args we need to getBoundArgs
|
254
|
+
// detect between arrow function with body and arrow function
|
255
|
+
const wrapper = t.isBlockStatement(styleExpression.body)
|
256
|
+
? styleExpression.body.body.find(node => t.isReturnStatement(node))
|
257
|
+
: styleExpression.body
|
222
258
|
|
223
|
-
|
259
|
+
if (t.isMemberExpression(wrapper)) {
|
260
|
+
return
|
261
|
+
}
|
224
262
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
263
|
+
const pressableArgs = t.isCallExpression(wrapper)
|
264
|
+
? wrapper.arguments
|
265
|
+
: wrapper.argument.arguments
|
266
|
+
const callee = t.isCallExpression(wrapper)
|
267
|
+
? wrapper.callee
|
268
|
+
: wrapper.argument.callee
|
231
269
|
|
232
|
-
|
233
|
-
|
270
|
+
const getBoundArgsCall = t.callExpression(
|
271
|
+
t.identifier('getBoundArgs'),
|
272
|
+
[callee]
|
273
|
+
)
|
274
|
+
const bindCall = t.callExpression(
|
275
|
+
t.memberExpression(getBoundArgsCall, t.identifier('bind')),
|
276
|
+
[t.identifier('undefined'), ...pressableArgs]
|
277
|
+
)
|
278
|
+
|
279
|
+
// arrow function
|
280
|
+
if (t.isCallExpression(wrapper)) {
|
281
|
+
styleExpression.body = bindCall
|
282
|
+
|
283
|
+
return
|
284
|
+
}
|
234
285
|
|
235
|
-
|
286
|
+
// arrow function with body
|
287
|
+
if (wrapper) {
|
288
|
+
wrapper.argument = bindCall
|
289
|
+
}
|
236
290
|
}
|
237
291
|
}
|
238
292
|
|
package/src/components/Hide.tsx
CHANGED