react-native-unistyles 3.0.0-nightly-20250520 → 3.0.0-nightly-20250527
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 +13 -9
- 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/UnistylesCommitShadowNode.h +0 -21
- package/cxx/core/UnistylesRegistry.cpp +45 -43
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +6 -1
- package/cxx/hybridObjects/HybridShadowRegistry.h +6 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +7 -16
- package/cxx/hybridObjects/HybridStyleSheet.h +2 -7
- package/cxx/parser/Parser.cpp +150 -107
- 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/ScopedTheme.js +5 -2
- 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.native.js +2 -28
- 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/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/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.map +1 -1
- package/lib/commonjs/web/create.js +1 -2
- package/lib/commonjs/web/create.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/runtime.js +9 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +2 -1
- 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/utils/createUnistylesRef.js +1 -2
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +12 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/ScopedTheme.js +4 -0
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +1 -26
- 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/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.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/runtime.js +10 -2
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +2 -1
- 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/utils/unistyle.js +10 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- 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/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/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/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.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +1 -0
- 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/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 +1 -0
- 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.map +1 -1
- package/package.json +17 -20
- package/plugin/index.d.ts +5 -4
- package/plugin/index.js +9 -1
- package/src/components/ScopedTheme.tsx +5 -0
- package/src/core/createUnistylesElement.native.tsx +1 -29
- package/src/core/createUnistylesImageBackground.tsx +7 -22
- package/src/index.ts +8 -0
- package/src/specs/ShadowRegistry/index.ts +1 -0
- package/src/web/css/state.ts +10 -8
- package/src/web/runtime.ts +15 -2
- package/src/web/shadowRegistry.ts +3 -1
- package/src/web/state.ts +7 -17
- package/src/web/utils/unistyle.ts +13 -1
- package/cxx/core/UnistylesCommitHook.cpp +0 -59
- package/cxx/core/UnistylesCommitHook.h +0 -27
- package/cxx/core/UnistylesMountHook.cpp +0 -26
- package/cxx/core/UnistylesMountHook.h +0 -24
- package/lib/module/package.json +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../src/web/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,qBAAa,iBAAiB;IAKd,OAAO,CAAC,QAAQ;IAJ5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAoG;IACrH,OAAO,CAAC,mBAAmB,CAAoG;gBAE3G,QAAQ,EAAE,iBAAiB;IAE/C,UAAU,
|
1
|
+
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../src/web/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,qBAAa,iBAAiB;IAKd,OAAO,CAAC,QAAQ;IAJ5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAoG;IACrH,OAAO,CAAC,mBAAmB,CAAoG;gBAE3G,QAAQ,EAAE,iBAAiB;IAE/C,UAAU,GAAI,YAAY,kBAAkB,UAG3C;IAED,aAAa,aAgCZ;IAED,YAAY,GAAI,cAAc,KAAK,CAAC,kBAAkB,CAAC,EAAE,UAAU,YAAY,gBAM9E;IAED,sBAAsB,GAAI,cAAc,KAAK,CAAC,kBAAkB,CAAC,EAAE,UAAU,YAAY,gBAMxF;CACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGhD,qBAAa,iBAAiB;IAQd,OAAO,CAAC,QAAQ;IAP5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+D;IAC3F,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsC;IACpE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4E;IAC5G,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;gBAEF,QAAQ,EAAE,iBAAiB;IAI/C,qBAAqB,
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACxE,OA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C3D,OAAO,CAAC,UAAU,CAAkC;gBAEhC,QAAQ,EAAE,iBAAiB;IAE/C,GAAG,
|
1
|
+
{"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAInE,qBAAa,uBAAuB;IAYpB,OAAO,CAAC,QAAQ;IAV5B,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,UAAU,CAAkC;gBAEhC,QAAQ,EAAE,iBAAiB;IAE/C,GAAG,GAAI,KAAK,GAAG,EAAE,OAAO,MAAM,UAM7B;IAED,SAAS,GAAI,WAAW,KAAK,CAAC,eAAe,CAAC,EAAE,WAAW,OAAO;;;MAoEjE;IAED,cAAc,GAAI,QAAQ,cAAc,UAEvC;IAED,cAAc,kBAAyB;IAEvC,MAAM,GAAI,KAAK,GAAG,EAAE,OAAO,MAAM,UAchC;IAED,KAAK,aAAW;CACnB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,WAAW,CAAA;AAEtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAY,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAKhD,qBAAa,cAAc;IAsBX,OAAO,CAAC,QAAQ;IArB5B,aAAa,UAAQ;IACrB,MAAM,qBAAoC;IAC1C,SAAS,qBAAoC;IAC7C,SAAS,CAAC,EAAE,YAAY,CAAA;IACxB,OAAO,UAAO;IAEd,OAAO,CAAC,mBAAmB,CAA6B;IACxD,OAAO,CAAC,OAAO,CAAsB;IAErC,IAAI,UAAU,IAKkB,aAAa,GAAG,SAAS,CACxD;IAED,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC,iBAAiB,UAAQ;gBAEL,QAAQ,EAAE,iBAAiB;IAE/C,IAAI,
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,WAAW,CAAA;AAEtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAY,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAKhD,qBAAa,cAAc;IAsBX,OAAO,CAAC,QAAQ;IArB5B,aAAa,UAAQ;IACrB,MAAM,qBAAoC;IAC1C,SAAS,qBAAoC;IAC7C,SAAS,CAAC,EAAE,YAAY,CAAA;IACxB,OAAO,UAAO;IAEd,OAAO,CAAC,mBAAmB,CAA6B;IACxD,OAAO,CAAC,OAAO,CAAsB;IAErC,IAAI,UAAU,IAKkB,aAAa,GAAG,SAAS,CACxD;IAED,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC,iBAAiB,UAAQ;gBAEL,QAAQ,EAAE,iBAAiB;IAE/C,IAAI,GAAI,QAAQ,eAAe,UAyB9B;IAED,OAAO,CAAC,UAAU,CAoBjB;IAED,OAAO,CAAC,YAAY,CA6BnB;IAED,OAAO,CAAC,eAAe,CA+BtB;IAED,SAAS,wBAAqB;CACjC"}
|
@@ -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,
|
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,EACnE,KAAK,IAAI,EACT,SAAS,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,EAAE,KAAK,CAAC,EAAE,KAAK,WAAW,KAAG,GAAG,IAAI,MAAM,CAAe,CAAA;AAElH,eAAO,MAAM,QAAQ,eAAyE,CAAA;AAE9F,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,UAAuC,CAAA;AAE5E,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,YAqBlC,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,cAAc,MAAM,WAAyE,CAAA;AAEvH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,KAAG,MASzD,CAAA;AAmBD,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,WAItC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createUnistylesRef.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/createUnistylesRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI5D,KAAK,MAAM,GAAG,SAAS;IACnB;QACI,IAAI,EAAE,MAAM,CAAA;KACf;IACD,KAAK,CAAC,eAAe,CAAC;CACzB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,
|
1
|
+
{"version":3,"file":"createUnistylesRef.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/createUnistylesRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI5D,KAAK,MAAM,GAAG,SAAS;IACnB;QACI,IAAI,EAAE,MAAM,CAAA;KACf;IACD,KAAK,CAAC,eAAe,CAAC;CACzB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,YAIjD,QAAQ,CAAC,CAAC,CAAC,sBAgBpD,CAAA"}
|
@@ -19,4 +19,5 @@ export declare const extractUnistyleDependencies: (value: any) => UnistyleDepend
|
|
19
19
|
export declare const checkForProp: (value: any, prop: string) => boolean;
|
20
20
|
export declare const checkForAnimated: (value: any) => boolean;
|
21
21
|
export declare const isGeneratedUnistyle: (value: Record<string, any>) => value is UniGeneratedStyle;
|
22
|
+
export declare const convertTheme: (key: string, value: any, prev?: string) => [string, any];
|
22
23
|
//# sourceMappingURL=unistyle.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAA;AACzF,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGpG,OAAO,EAA4C,KAAK,iBAAi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B,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,KAAK,IAAI,iBAEzE,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,EAAE,OAAO,GAAG,EAAE,aAAU,KAAG,CAAC,MAAM,EAAE,GAAG,CAU9E,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/web/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAc/C,eAAO,MAAM,WAAW,
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/web/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAc/C,eAAO,MAAM,WAAW,GAAI,QAAQ,eAAe,EAAE,kBAAkB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,2DA2BzF,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getWebProps.d.ts","sourceRoot":"","sources":["../../../../src/web-only/getWebProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAA;AAGxD,eAAO,MAAM,WAAW,GAAI,CAAC,
|
1
|
+
{"version":3,"file":"getWebProps.d.ts","sourceRoot":"","sources":["../../../../src/web-only/getWebProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAA;AAGxD,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,OAAO,SAAS,CAAC,OAAO,CAAC;;;CAYvD,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-nightly-
|
3
|
+
"version": "3.0.0-nightly-20250527",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "NODE_ENV=babel-test jest ./plugin",
|
@@ -126,37 +126,37 @@
|
|
126
126
|
"registry": "https://registry.npmjs.org/"
|
127
127
|
},
|
128
128
|
"devDependencies": {
|
129
|
-
"@babel/core": "7.
|
130
|
-
"@babel/plugin-syntax-jsx": "7.
|
131
|
-
"@babel/preset-flow": "7.
|
132
|
-
"@babel/preset-typescript": "7.
|
133
|
-
"@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",
|
134
134
|
"@biomejs/biome": "1.9.4",
|
135
135
|
"@callstack/repack": "5.1.0",
|
136
|
-
"@commitlint/config-conventional": "19.
|
137
|
-
"@react-native/normalize-colors": "0.
|
136
|
+
"@commitlint/config-conventional": "19.8.1",
|
137
|
+
"@react-native/normalize-colors": "0.79.2",
|
138
138
|
"@release-it/conventional-changelog": "8.0.2",
|
139
139
|
"@rspack/core": "1.3.10",
|
140
140
|
"@types/jest": "29.5.14",
|
141
|
-
"@types/react": "19.
|
141
|
+
"@types/react": "19.1.4",
|
142
142
|
"babel-plugin-tester": "11.0.4",
|
143
|
-
"commitlint": "19.
|
143
|
+
"commitlint": "19.8.1",
|
144
144
|
"concurrently": "9.1.2",
|
145
145
|
"dpdm": "3.14.0",
|
146
|
-
"esbuild": "0.25.
|
146
|
+
"esbuild": "0.25.4",
|
147
147
|
"husky": "9.1.7",
|
148
148
|
"jest": "29.7.0",
|
149
149
|
"metro-react-native-babel-preset": "0.77.0",
|
150
150
|
"nitro-codegen": "0.25.2",
|
151
|
-
"react": "
|
152
|
-
"react-native": "0.
|
153
|
-
"react-native-builder-bob": "0.
|
151
|
+
"react": "19.1.0",
|
152
|
+
"react-native": "0.79.2",
|
153
|
+
"react-native-builder-bob": "0.40.10",
|
154
154
|
"react-native-nitro-modules": "0.25.2",
|
155
155
|
"react-native-reanimated": "3.17.5",
|
156
|
-
"react-native-web": "0.
|
157
|
-
"react-test-renderer": "
|
156
|
+
"react-native-web": "0.20.0",
|
157
|
+
"react-test-renderer": "19.1.0",
|
158
158
|
"release-it": "17.11.0",
|
159
|
-
"typescript": "5.
|
159
|
+
"typescript": "5.8.3"
|
160
160
|
},
|
161
161
|
"peerDependencies": {
|
162
162
|
"@react-native/normalize-colors": "*",
|
@@ -234,8 +234,5 @@
|
|
234
234
|
"name": "TurboUnistyles",
|
235
235
|
"type": "modules",
|
236
236
|
"jsSrcsDir": "./src/specs/TurboUnistyles"
|
237
|
-
},
|
238
|
-
"resolutions": {
|
239
|
-
"@babel/types": "7.26.8"
|
240
237
|
}
|
241
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']
|
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
|
@@ -724,6 +725,13 @@ function index_default() {
|
|
724
725
|
visitor: {
|
725
726
|
Program: {
|
726
727
|
enter(path2, state) {
|
728
|
+
if (!state.opts.root) {
|
729
|
+
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");
|
730
|
+
}
|
731
|
+
const appRoot = toPlatformPath(import_node_path2.default.join(state.file.opts.root, state.opts.root));
|
732
|
+
if (state.file.opts.root === appRoot) {
|
733
|
+
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");
|
734
|
+
}
|
727
735
|
state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.map(toPlatformPath).concat(state.opts.autoProcessPaths ?? []).some((path3) => state.filename?.includes(path3));
|
728
736
|
state.file.hasAnyUnistyle = false;
|
729
737
|
state.file.hasUnistylesImport = false;
|
@@ -733,7 +741,7 @@ function index_default() {
|
|
733
741
|
state.file.reactNativeCommonJSName = "";
|
734
742
|
state.file.tagNumber = 0;
|
735
743
|
state.reactNativeImports = {};
|
736
|
-
state.file.forceProcessing = state.
|
744
|
+
state.file.forceProcessing = state.filename?.includes(appRoot) ?? false;
|
737
745
|
path2.traverse({
|
738
746
|
BlockStatement(blockPath) {
|
739
747
|
if (isInsideNodeModules(state)) {
|
@@ -24,6 +24,11 @@ export const ScopedTheme: React.FunctionComponent<React.PropsWithChildren<ThemeP
|
|
24
24
|
<Apply key='dispose' name={previousScopedTheme as keyof UnistylesThemes | undefined} />
|
25
25
|
]
|
26
26
|
|
27
|
+
useLayoutEffect(() => {
|
28
|
+
// this will affect only scoped styles as other styles are not yet mounted
|
29
|
+
UnistylesShadowRegistry.flush()
|
30
|
+
})
|
31
|
+
|
27
32
|
return (
|
28
33
|
<React.Fragment>
|
29
34
|
{mappedChildren}
|
@@ -1,43 +1,15 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react'
|
2
2
|
import { UnistylesShadowRegistry } from '../specs'
|
3
3
|
import { copyComponentProperties } from '../utils'
|
4
4
|
import { passForwardedRef } from './passForwardRef'
|
5
5
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
6
6
|
|
7
|
-
const getNativeRef = (Component: any, ref: any) => {
|
8
|
-
switch (Component.name) {
|
9
|
-
case 'KeyboardAvoidingView':
|
10
|
-
return ref.viewRef?.current
|
11
|
-
case 'FlatList':
|
12
|
-
return ref.getNativeScrollRef?.()
|
13
|
-
case 'VirtualizedList':
|
14
|
-
return ref.getScrollRef?.()
|
15
|
-
default:
|
16
|
-
return ref
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
7
|
export const createUnistylesElement = (Component: any) => {
|
21
8
|
const UnistylesComponent = React.forwardRef((props, forwardedRef) => {
|
22
|
-
const storedRef = useRef<unknown>(null)
|
23
|
-
|
24
|
-
useLayoutEffect(() => {
|
25
|
-
return () => {
|
26
|
-
if (storedRef.current) {
|
27
|
-
// @ts-ignore
|
28
|
-
UnistylesShadowRegistry.remove(storedRef.current)
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}, [])
|
32
|
-
|
33
9
|
return (
|
34
10
|
<Component
|
35
11
|
{...props}
|
36
12
|
ref={(ref: unknown) => {
|
37
|
-
if (ref) {
|
38
|
-
storedRef.current = getNativeRef(Component, ref)
|
39
|
-
}
|
40
|
-
|
41
13
|
// @ts-ignore we don't know the type of the component
|
42
14
|
maybeWarnAboutMultipleUnistyles(props.style, Component.displayName)
|
43
15
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import React
|
2
|
-
import type {
|
1
|
+
import React from 'react'
|
2
|
+
import type { ImageBackground, ImageBackgroundProps } from 'react-native'
|
3
3
|
import { UnistylesShadowRegistry } from '../specs'
|
4
4
|
import { copyComponentProperties } from '../utils'
|
5
5
|
import { passForwardedRef } from './passForwardRef'
|
@@ -7,17 +7,6 @@ import { maybeWarnAboutMultipleUnistyles } from './warn'
|
|
7
7
|
|
8
8
|
export const createUnistylesImageBackground = (Component: typeof ImageBackground) => {
|
9
9
|
const UnistylesImageBackground = React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => {
|
10
|
-
const storedImageRef = useRef<Image | null>(null)
|
11
|
-
|
12
|
-
useLayoutEffect(() => {
|
13
|
-
return () => {
|
14
|
-
if (storedImageRef.current) {
|
15
|
-
// @ts-ignore
|
16
|
-
UnistylesShadowRegistry.remove(storedImageRef.current)
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}, [])
|
20
|
-
|
21
10
|
// @ts-expect-error we don't know the type of the component
|
22
11
|
maybeWarnAboutMultipleUnistyles(props.style, 'ImageBackground')
|
23
12
|
// @ts-ignore we don't know the type of the component
|
@@ -37,21 +26,17 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
|
|
37
26
|
() => {
|
38
27
|
// @ts-expect-error - this is hidden from TS
|
39
28
|
UnistylesShadowRegistry.remove(ref)
|
40
|
-
|
41
|
-
if (storedImageRef.current) {
|
42
|
-
// @ts-expect-error - this is hidden from TS
|
43
|
-
UnistylesShadowRegistry.remove(storedImageRef.current)
|
44
|
-
}
|
45
29
|
}
|
46
30
|
)
|
47
31
|
}}
|
48
32
|
imageRef={ref => {
|
49
|
-
if (ref) {
|
50
|
-
storedImageRef.current = ref
|
51
|
-
}
|
52
|
-
|
53
33
|
// @ts-expect-error web types are not compatible with RN styles
|
54
34
|
UnistylesShadowRegistry.add(ref, props.imageStyle)
|
35
|
+
|
36
|
+
return () => {
|
37
|
+
// @ts-ignore this is hidden from TS
|
38
|
+
UnistylesShadowRegistry.remove(ref)
|
39
|
+
}
|
55
40
|
}}
|
56
41
|
/>
|
57
42
|
)
|
package/src/index.ts
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
const [majorReactVersions] = React.version.split('.').map(Number.parseInt)
|
4
|
+
|
5
|
+
if (majorReactVersions === undefined || majorReactVersions < 19) {
|
6
|
+
throw new Error('Unistyles 🦄: To enable full Fabric power you need to use React 19.0.0 or higher')
|
7
|
+
}
|
8
|
+
|
1
9
|
export { StyleSheet, UnistylesRuntime, StatusBar, NavigationBar } from './specs'
|
2
10
|
export { mq } from './mq'
|
3
11
|
export type { UnistylesThemes, UnistylesBreakpoints } from './global'
|
@@ -9,6 +9,7 @@ interface ShadowRegistry extends UnistylesShadowRegistrySpec {
|
|
9
9
|
// JSI
|
10
10
|
link(node: ShadowNode, styles?: Array<Unistyle>): void,
|
11
11
|
unlink(node: ShadowNode): void,
|
12
|
+
flush(): void,
|
12
13
|
setScopedTheme(themeName?: string): void,
|
13
14
|
getScopedTheme(): string | undefined
|
14
15
|
}
|
package/src/web/css/state.ts
CHANGED
@@ -32,7 +32,7 @@ export class CSSState {
|
|
32
32
|
mainMap: MapType = new Map()
|
33
33
|
mqMap: MapType = new Map()
|
34
34
|
private styleTag: HTMLStyleElement | null = null
|
35
|
-
private
|
35
|
+
private themesCSS = new Map<string, string>()
|
36
36
|
|
37
37
|
constructor(private services: UnistylesServices) {
|
38
38
|
if (isServer()) {
|
@@ -62,7 +62,10 @@ export class CSSState {
|
|
62
62
|
|
63
63
|
add = (hash: string, values: UnistylesValues) => {
|
64
64
|
convertToCSS(hash, convertUnistyles(values, this.services.runtime), this)
|
65
|
+
this.recreate()
|
66
|
+
}
|
65
67
|
|
68
|
+
recreate = () => {
|
66
69
|
if (this.styleTag) {
|
67
70
|
this.styleTag.innerText = this.getStyles()
|
68
71
|
}
|
@@ -84,10 +87,10 @@ export class CSSState {
|
|
84
87
|
Object.entries(values).forEach(([key, value]) => convertToCSS(key, value))
|
85
88
|
|
86
89
|
if (theme === 'light' || theme === 'dark') {
|
87
|
-
this.
|
90
|
+
this.themesCSS.set(`media ${theme}`, `@media (prefers-color-scheme: ${theme}){:root{${themeVars}}}`)
|
88
91
|
}
|
89
92
|
|
90
|
-
this.
|
93
|
+
this.themesCSS.set(theme, `:root.${theme}{${themeVars}}`)
|
91
94
|
}
|
92
95
|
|
93
96
|
remove = (hash: string) => {
|
@@ -97,14 +100,13 @@ export class CSSState {
|
|
97
100
|
this.mqMap.forEach(styles => {
|
98
101
|
styles.delete(hash)
|
99
102
|
})
|
100
|
-
|
101
|
-
if (this.styleTag) {
|
102
|
-
this.styleTag.innerText = this.getStyles()
|
103
|
-
}
|
103
|
+
this.recreate()
|
104
104
|
}
|
105
105
|
|
106
106
|
getStyles = () => {
|
107
|
-
let styles = this.
|
107
|
+
let styles = Array.from(this.themesCSS.entries()).reduce((acc, [, themeCss]) => {
|
108
|
+
return acc + themeCss
|
109
|
+
}, '')
|
108
110
|
|
109
111
|
const generate = (mediaQuery: string, secondLevelMap: Map<string, Map<string, string>>) => {
|
110
112
|
if (mediaQuery) {
|
package/src/web/runtime.ts
CHANGED
@@ -4,7 +4,7 @@ import { type AppTheme, type AppThemeName, ColorScheme, Orientation } from '../s
|
|
4
4
|
import { type UnistylesTheme, WebContentSizeCategory } from '../types'
|
5
5
|
import { NavigationBar, StatusBar } from './mock'
|
6
6
|
import type { UnistylesServices } from './types'
|
7
|
-
import { error, isServer, schemeToTheme } from './utils'
|
7
|
+
import { convertTheme, error, isServer, schemeToTheme } from './utils'
|
8
8
|
|
9
9
|
export class UnistylesRuntime {
|
10
10
|
lightMedia = this.getLightMedia()
|
@@ -204,7 +204,20 @@ export class UnistylesRuntime {
|
|
204
204
|
throw error(`Unistyles: You're trying to update theme "${themeName}" but it wasn't registered.`)
|
205
205
|
}
|
206
206
|
|
207
|
-
|
207
|
+
const newTheme = updater(oldTheme)
|
208
|
+
|
209
|
+
this.services.state.themes.set(themeName, newTheme)
|
210
|
+
|
211
|
+
if (this.services.state.CSSVars) {
|
212
|
+
this.services.state.cssThemes.set(
|
213
|
+
themeName,
|
214
|
+
Object.fromEntries(Object.entries(newTheme).map(([key, value]) => {
|
215
|
+
return convertTheme(key, value)
|
216
|
+
})) as UnistylesTheme
|
217
|
+
)
|
218
|
+
this.services.registry.css.addTheme(themeName, newTheme)
|
219
|
+
this.services.registry.css.recreate()
|
220
|
+
}
|
208
221
|
}
|
209
222
|
|
210
223
|
getTheme = (themeName = this.themeName, CSSVars = false) => {
|
@@ -20,7 +20,7 @@ export class UnistylesShadowRegistry {
|
|
20
20
|
constructor(private services: UnistylesServices) {}
|
21
21
|
|
22
22
|
add = (ref: any, hash?: string) => {
|
23
|
-
if (!(ref instanceof HTMLElement) || !hash) {
|
23
|
+
if (isServer() || !(ref instanceof HTMLElement) || !hash) {
|
24
24
|
return
|
25
25
|
}
|
26
26
|
|
@@ -118,4 +118,6 @@ export class UnistylesShadowRegistry {
|
|
118
118
|
this.disposeMap.delete(hash)
|
119
119
|
})
|
120
120
|
}
|
121
|
+
|
122
|
+
flush = () => {}
|
121
123
|
}
|
package/src/web/state.ts
CHANGED
@@ -5,7 +5,7 @@ import type { AppBreakpoint, AppTheme, AppThemeName } from '../specs/types'
|
|
5
5
|
import type { UnistylesTheme } from '../types'
|
6
6
|
import type { UnionToIntersection } from '../types'
|
7
7
|
import type { UnistylesServices } from './types'
|
8
|
-
import {
|
8
|
+
import { convertTheme, error, isServer, schemeToTheme } from './utils'
|
9
9
|
|
10
10
|
type UnistylesSettings = Partial<UnionToIntersection<Required<UnistylesConfig>['settings']>>
|
11
11
|
|
@@ -72,22 +72,12 @@ export class UnistylesState {
|
|
72
72
|
|
73
73
|
if (CSSVars) {
|
74
74
|
this.services.registry.css.addTheme(themeName, theme)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
return
|
79
|
-
}
|
80
|
-
|
81
|
-
if (typeof value === 'string') {
|
82
|
-
return [key, `var(${prev}-${hyphenate(key)})`]
|
83
|
-
}
|
84
|
-
|
85
|
-
return [key, value]
|
86
|
-
}
|
87
|
-
|
88
|
-
this.cssThemes.set(themeName, Object.fromEntries(Object.entries(theme).map(([key, value]) => {
|
89
|
-
return convertTheme(key, value)
|
90
|
-
})) as UnistylesTheme)
|
75
|
+
this.cssThemes.set(
|
76
|
+
themeName,
|
77
|
+
Object.fromEntries(Object.entries(theme).map(([key, value]) => {
|
78
|
+
return convertTheme(key, value)
|
79
|
+
})) as UnistylesTheme
|
80
|
+
)
|
91
81
|
}
|
92
82
|
})
|
93
83
|
}
|
@@ -6,7 +6,7 @@ import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../
|
|
6
6
|
import { isUnistylesMq, parseMq } from '../../utils'
|
7
7
|
import * as unistyles from '../services'
|
8
8
|
import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
|
9
|
-
import { keyInObject, reduceObject } from './common'
|
9
|
+
import { hyphenate, keyInObject, reduceObject } from './common'
|
10
10
|
|
11
11
|
export const schemeToTheme = (scheme: ColorScheme) => {
|
12
12
|
switch (scheme) {
|
@@ -144,3 +144,15 @@ export const checkForAnimated = (value: any): boolean => {
|
|
144
144
|
export const isGeneratedUnistyle = (value: Record<string, any>): value is UniGeneratedStyle => {
|
145
145
|
return Object.keys(value).every(key => UNI_GENERATED_KEYS.includes(key as UniGeneratedKey))
|
146
146
|
}
|
147
|
+
|
148
|
+
export const convertTheme = (key: string, value: any, prev = '-'): [string, any] => {
|
149
|
+
if (typeof value === 'object' && value !== null) {
|
150
|
+
return [key, Object.fromEntries(Object.entries(value).map(([nestedKey, nestedValue]) => convertTheme(nestedKey, nestedValue, `${prev}-${key}`)))]
|
151
|
+
}
|
152
|
+
|
153
|
+
if (typeof value === 'string') {
|
154
|
+
return [key, `var(${prev}-${hyphenate(key)})`]
|
155
|
+
}
|
156
|
+
|
157
|
+
return [key, value]
|
158
|
+
}
|
@@ -1,59 +0,0 @@
|
|
1
|
-
#include "UnistylesCommitHook.h"
|
2
|
-
|
3
|
-
using namespace margelo::nitro::unistyles;
|
4
|
-
using namespace facebook::react;
|
5
|
-
|
6
|
-
core::UnistylesCommitHook::~UnistylesCommitHook() noexcept {
|
7
|
-
_uiManager->unregisterCommitHook(*this);
|
8
|
-
}
|
9
|
-
|
10
|
-
void core::UnistylesCommitHook::commitHookWasRegistered(const UIManager &uiManager) noexcept {}
|
11
|
-
void core::UnistylesCommitHook::commitHookWasUnregistered(const UIManager &uiManager) noexcept {}
|
12
|
-
|
13
|
-
RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
|
14
|
-
const ShadowTree &shadowTree,
|
15
|
-
const RootShadowNode::Shared &oldRootShadowNode,
|
16
|
-
const RootShadowNode::Unshared &newRootShadowNode
|
17
|
-
) noexcept {
|
18
|
-
RootShadowNode::Unshared rootNode = newRootShadowNode;
|
19
|
-
auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootShadowNode);
|
20
|
-
|
21
|
-
// this is Unistyles commit, we don't need to override it
|
22
|
-
if (unistylesRootNode->hasUnistylesCommitTrait()) {
|
23
|
-
unistylesRootNode->removeUnistylesCommitTrait();
|
24
|
-
unistylesRootNode->addUnistylesMountTrait();
|
25
|
-
|
26
|
-
return newRootShadowNode;
|
27
|
-
}
|
28
|
-
|
29
|
-
auto& registry = core::UnistylesRegistry::get();
|
30
|
-
|
31
|
-
if (registry.trafficController.shouldStop()) {
|
32
|
-
registry.trafficController.resumeUnistylesTraffic();
|
33
|
-
|
34
|
-
return newRootShadowNode;
|
35
|
-
}
|
36
|
-
|
37
|
-
// this is React Native / Reanimated commit
|
38
|
-
// merge Unistyles updates before it completes
|
39
|
-
|
40
|
-
return registry.trafficController.withLock([&](){
|
41
|
-
auto& shadowLeafUpdates = registry.trafficController.getUpdates();
|
42
|
-
|
43
|
-
// oops, no updates from Unistyles yet, skip it!
|
44
|
-
if (shadowLeafUpdates.size() == 0) {
|
45
|
-
return newRootShadowNode;
|
46
|
-
}
|
47
|
-
|
48
|
-
auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(*rootNode, shadowLeafUpdates);
|
49
|
-
|
50
|
-
registry.trafficController.stopUnistylesTraffic();
|
51
|
-
|
52
|
-
// we have few updates, so merge it
|
53
|
-
return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
|
54
|
-
*rootNode,
|
55
|
-
shadowLeafUpdates,
|
56
|
-
affectedNodes
|
57
|
-
));
|
58
|
-
});
|
59
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include <react/renderer/uimanager/UIManager.h>
|
4
|
-
#include <react/renderer/uimanager/UIManagerCommitHook.h>
|
5
|
-
#include "ShadowTreeManager.h"
|
6
|
-
#include "ShadowTrafficController.h"
|
7
|
-
|
8
|
-
namespace margelo::nitro::unistyles::core {
|
9
|
-
|
10
|
-
using namespace facebook::react;
|
11
|
-
|
12
|
-
struct UnistylesCommitHook : public UIManagerCommitHook {
|
13
|
-
UnistylesCommitHook(std::shared_ptr<UIManager> uiManager) : _uiManager{uiManager} {
|
14
|
-
_uiManager->registerCommitHook(*this);
|
15
|
-
}
|
16
|
-
|
17
|
-
~UnistylesCommitHook() noexcept override;
|
18
|
-
|
19
|
-
void commitHookWasRegistered(const UIManager &uiManager) noexcept override;
|
20
|
-
void commitHookWasUnregistered(const UIManager &uiManager) noexcept override;
|
21
|
-
RootShadowNode::Unshared shadowTreeWillCommit(const ShadowTree &shadowTree, const RootShadowNode::Shared &oldRootShadowNode, const RootShadowNode::Unshared &newRootShadowNode) noexcept override;
|
22
|
-
|
23
|
-
private:
|
24
|
-
std::shared_ptr<UIManager> _uiManager;
|
25
|
-
};
|
26
|
-
|
27
|
-
}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#include "UnistylesMountHook.h"
|
2
|
-
|
3
|
-
using namespace margelo::nitro::unistyles;
|
4
|
-
using namespace facebook::react;
|
5
|
-
|
6
|
-
core::UnistylesMountHook::~UnistylesMountHook() noexcept {
|
7
|
-
_uiManager->unregisterMountHook(*this);
|
8
|
-
}
|
9
|
-
|
10
|
-
void core::UnistylesMountHook::shadowTreeDidMount(RootShadowNode::Shared const &rootShadowNode, double mountTime) noexcept {
|
11
|
-
auto rootNode = std::const_pointer_cast<RootShadowNode>(rootShadowNode);
|
12
|
-
auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(rootNode);
|
13
|
-
|
14
|
-
// if this is Unistyles commit, do nothing
|
15
|
-
if (unistylesRootNode->hasUnistylesMountTrait()) {
|
16
|
-
unistylesRootNode->removeUnistylesMountTrait();
|
17
|
-
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
|
21
|
-
// this is React Native or Reanimated commit
|
22
|
-
// one more time merge Unistyles changes
|
23
|
-
auto& registry = core::UnistylesRegistry::get();
|
24
|
-
|
25
|
-
registry.trafficController.stopUnistylesTraffic();
|
26
|
-
}
|