react-native-unistyles 3.0.0-nightly-20250329 → 3.0.0-nightly-20250409
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 +3 -3
- package/components/native/Image/package.json +1 -1
- package/cxx/core/UnistylesCommitHook.cpp +2 -2
- package/cxx/core/UnistylesRegistry.cpp +24 -20
- package/cxx/hybridObjects/HybridStyleSheet.cpp +15 -11
- package/cxx/parser/Parser.cpp +11 -8
- package/cxx/shadowTree/ShadowTrafficController.h +7 -9
- package/lib/commonjs/components/native/Image.js +26 -1
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/Image.native.js +10 -0
- package/lib/commonjs/components/native/Image.native.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +16 -28
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +7 -4
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +3 -19
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +6 -4
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +7 -5
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/passForwardRef.js +3 -5
- package/lib/commonjs/core/passForwardRef.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/server/serialize.js +1 -1
- package/lib/commonjs/server/serialize.js.map +1 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js +28 -0
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -0
- package/lib/commonjs/web/utils/index.js +11 -0
- package/lib/commonjs/web/utils/index.js.map +1 -1
- package/lib/module/components/native/Image.js +25 -2
- package/lib/module/components/native/Image.js.map +1 -1
- package/lib/module/components/native/Image.native.js +6 -0
- package/lib/module/components/native/Image.native.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +17 -29
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +7 -4
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +4 -20
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +6 -4
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +7 -5
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/passForwardRef.js +3 -5
- package/lib/module/core/passForwardRef.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/server/serialize.js +1 -1
- package/lib/module/server/serialize.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +2 -2
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/web/utils/createUnistylesRef.js +23 -0
- package/lib/module/web/utils/createUnistylesRef.js.map +1 -0
- package/lib/module/web/utils/index.js +1 -0
- package/lib/module/web/utils/index.js.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.native.d.ts +2 -0
- package/lib/typescript/src/components/native/Image.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.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/passForwardRef.d.ts +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +2 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts +8 -0
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/index.d.ts +1 -0
- package/lib/typescript/src/web/utils/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +3 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +2 -1
- package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
- package/package.json +1 -1
- package/plugin/index.js +5 -1
- package/src/components/native/Image.native.tsx +4 -0
- package/src/components/native/Image.tsx +35 -3
- package/src/components/native/ImageBackground.tsx +17 -33
- package/src/components/native/Pressable.native.tsx +12 -4
- package/src/core/createUnistylesElement.native.tsx +12 -6
- package/src/core/createUnistylesElement.tsx +6 -24
- package/src/core/createUnistylesImageBackground.tsx +16 -10
- package/src/core/passForwardRef.ts +5 -5
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +1 -0
- package/src/server/serialize.ts +1 -1
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +2 -1
- package/src/specs/ShadowRegistry/index.ts +1 -2
- package/src/web/utils/createUnistylesRef.ts +29 -0
- package/src/web/utils/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","_viewRef","viewRef","current","_nativeRef","Error","elementType","add","styles","stylesArray","Array","isArray","flat","filteredStyles","filter","style","
|
|
1
|
+
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","_viewRef","viewRef","current","_nativeRef","Error","elementType","add","styles","stylesArray","Array","isArray","flat","filteredStyles","filter","style","Object","keys","length","Boolean","link","remove","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAezD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACzED,MAAM,EAAEM,QAAQ,EAAEJ,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IAC3DD,MAAM,EAAEO,OAAO,EAAEC,OAAO,EAAEN,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACnED,MAAM,EAAES,UAAU,EAAEP,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEpE,IAAI,CAACA,IAAI,EAAE;IACP,MAAM,IAAIS,KAAK,CAAC,4EAA4EV,MAAM,EAAEE,wBAAwB,EAAES,WAAW,IAAI,SAAS,EAAE,CAAC;EAC7J;EAEA,OAAOV,IAAI;AACf,CAAC;AAEDJ,oBAAoB,CAACe,GAAG,GAAG,CAACZ,MAAM,EAAEa,MAAM,KAAK;EAC3C;EACA,IAAI,CAACb,MAAM,IAAI,CAACa,MAAM,EAAE;IACpB;EACJ;EAEA,MAAMC,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,GACnCA,MAAM,CAACI,IAAI,CAAC,CAAC,GACb,CAACJ,MAAM,CAAC;;EAEd;EACA,MAAMK,cAAc,GAAGJ,WAAW,CAC7BK,MAAM,CAACC,KAAK,IAAIA,KAAK,IAAIC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,GAAG,CAAC,CAAC,CACvDN,IAAI,CAAC,CAAC,CACNE,MAAM,CAACK,OAAO,CAAC;EAEpB,IAAIN,cAAc,CAACK,MAAM,GAAG,CAAC,EAAE;IAC3B1B,oBAAoB,CAAC4B,IAAI,CAAC1B,uBAAuB,CAACC,MAAM,CAAC,EAAEkB,cAAc,CAAC;EAC9E;AACJ,CAAC;AAEDrB,oBAAoB,CAAC6B,MAAM,GAAG1B,MAAM,IAAI;EACpC,IAAI,CAACA,MAAM,EAAE;IACT;EACJ;EAEAH,oBAAoB,CAAC8B,MAAM,CAAC5B,uBAAuB,CAACC,MAAM,CAAC,CAAC;AAChE,CAAC;AAQD,OAAO,MAAM4B,uBAAuB,GAAG/B,oBAA4D","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { UnistylesWeb } from '../index';
|
|
4
|
+
import { isServer } from './common';
|
|
5
|
+
export const createUnistylesRef = (classNames, forwardedRef) => {
|
|
6
|
+
const storedRef = {
|
|
7
|
+
current: null
|
|
8
|
+
};
|
|
9
|
+
return isServer() ? undefined : ref => {
|
|
10
|
+
if (!ref) {
|
|
11
|
+
UnistylesWeb.shadowRegistry.remove(storedRef, classNames?.hash);
|
|
12
|
+
}
|
|
13
|
+
storedRef.current = ref;
|
|
14
|
+
UnistylesWeb.shadowRegistry.add(ref, classNames?.hash);
|
|
15
|
+
if (typeof forwardedRef === 'function') {
|
|
16
|
+
return forwardedRef(ref);
|
|
17
|
+
}
|
|
18
|
+
if (forwardedRef) {
|
|
19
|
+
forwardedRef.current = ref;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=createUnistylesRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UnistylesWeb","isServer","createUnistylesRef","classNames","forwardedRef","storedRef","current","undefined","ref","shadowRegistry","remove","hash","add"],"sourceRoot":"../../../../src","sources":["web/utils/createUnistylesRef.ts"],"mappings":";;AAEA,SAASA,YAAY,QAAQ,UAAU;AACvC,SAASC,QAAQ,QAAQ,UAAU;AAMnC,OAAO,MAAMC,kBAAkB,GAAGA,CAAIC,UAAuB,EAAEC,YAAoC,KAAK;EACpG,MAAMC,SAAS,GAAG;IAAEC,OAAO,EAAE;EAAoB,CAAC;EAElD,OAAOL,QAAQ,CAAC,CAAC,GAAGM,SAAS,GAAIC,GAAgB,IAAK;IAClD,IAAI,CAACA,GAAG,EAAE;MACNR,YAAY,CAACS,cAAc,CAACC,MAAM,CAACL,SAAS,EAAEF,UAAU,EAAEQ,IAAI,CAAC;IACnE;IAEAN,SAAS,CAACC,OAAO,GAAGE,GAAG;IACvBR,YAAY,CAACS,cAAc,CAACG,GAAG,CAACJ,GAAG,EAAEL,UAAU,EAAEQ,IAAI,CAAC;IAEtD,IAAI,OAAOP,YAAY,KAAK,UAAU,EAAE;MACpC,OAAOA,YAAY,CAACI,GAAG,CAAC;IAC5B;IAEA,IAAIJ,YAAY,EAAE;MACdA,YAAY,CAACE,OAAO,GAAGE,GAAG;IAC9B;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/utils/index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/utils/index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,sBAAsB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Image.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Image.tsx"],"names":[],"mappings":"AAmCA,eAAO,MAAM,KAAK,KAAuD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.native.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Image.native.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,KAAsC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageBackground.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/ImageBackground.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageBackground.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/ImageBackground.tsx"],"names":[],"mappings":"AAyCA,eAAO,MAAM,eAAe,KAA2E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pressable.native.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Pressable.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAwBjE,eAAO,MAAM,SAAS;eAnBP,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Pressable.native.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/Pressable.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8C,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAwBjE,eAAO,MAAM,SAAS;eAnBP,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;8BAoF7C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUnistylesElement.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.tsx"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,cAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"createUnistylesElement.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.tsx"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,cAAe,GAAG,QAiBpD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sBAAsB,cAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sBAAsB,cAAe,GAAG,QA0CpD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,QAqD/E,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const passForwardedRef: <T>(
|
|
2
|
+
export declare const passForwardedRef: <T>(ref: T, forwardedRef: React.ForwardedRef<T>, onMount?: () => void, onUnmount?: () => void) => () => void;
|
|
3
3
|
//# sourceMappingURL=passForwardRef.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passForwardRef.d.ts","sourceRoot":"","sources":["../../../../src/core/passForwardRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"passForwardRef.d.ts","sourceRoot":"","sources":["../../../../src/core/passForwardRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,gBAAgB,GAAI,CAAC,OACzB,CAAC,gBACQ,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,YACzB,MAAM,IAAI,cACR,MAAM,IAAI,eAqBzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProxifiedUnistyles.d.ts","sourceRoot":"","sources":["../../../../../src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAA6C,MAAM,aAAa,CAAA;AAElG,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"useProxifiedUnistyles.d.ts","sourceRoot":"","sources":["../../../../../src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAA6C,MAAM,aAAa,CAAA;AAElG,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAyBjD,eAAO,MAAM,qBAAqB,iBAAkB,cAAc;;;uCAgEvB,KAAK,CAAC,kBAAkB,CAAC;CAcnE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativePlatform.nitro.d.ts","sourceRoot":"","sources":["../../../../../src/specs/NativePlatform/NativePlatform.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAElD,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAA;AACnD,KAAK,WAAW,GAAG,UAAU,GAAG,WAAW,CAAA;AAE3C,oBAAY,kBAAkB;IAC1B,KAAK,IAAI;IACT,SAAS,IAAI;IACb,cAAc,IAAI;IAClB,WAAW,IAAI;IACf,QAAQ,IAAI;IACZ,WAAW,IAAI;IACf,UAAU,IAAI;IACd,WAAW,IAAI;IACf,mBAAmB,IAAI;IACvB,MAAM,IAAI;IACV,UAAU,KAAK;IACf,SAAS,KAAK;IACd,SAAS,KAAK;IACd,aAAa,KAAK;IAClB,GAAG,KAAK;CACX;AAED,MAAM,WAAW,0BAA0B;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAA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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { Nullable } from '../../types';
|
|
3
|
+
type ClassNames = {
|
|
4
|
+
hash: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const createUnistylesRef: <T>(classNames?: ClassNames, forwardedRef?: React.ForwardedRef<T>) => ((ref: Nullable<T>) => void) | undefined;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=createUnistylesRef.d.ts.map
|
|
@@ -0,0 +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,MAAM,aAAa,CAAA;AAI3C,KAAK,UAAU,GAAG;IACd,IAAI,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,eAAe,UAAU,iBAAiB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,YAGzD,QAAQ,CAAC,CAAC,CAAC,sBAgBpD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA"}
|
|
@@ -56,6 +56,7 @@ namespace margelo::nitro::unistyles {
|
|
|
56
56
|
static const auto fieldSTATUSBAR = clazz->getStaticField<JUnistyleDependency>("STATUSBAR");
|
|
57
57
|
static const auto fieldNAVIGATIONBAR = clazz->getStaticField<JUnistyleDependency>("NAVIGATIONBAR");
|
|
58
58
|
static const auto fieldIME = clazz->getStaticField<JUnistyleDependency>("IME");
|
|
59
|
+
static const auto fieldRTL = clazz->getStaticField<JUnistyleDependency>("RTL");
|
|
59
60
|
|
|
60
61
|
switch (value) {
|
|
61
62
|
case UnistyleDependency::THEME:
|
|
@@ -88,6 +89,8 @@ namespace margelo::nitro::unistyles {
|
|
|
88
89
|
return clazz->getStaticFieldValue(fieldNAVIGATIONBAR);
|
|
89
90
|
case UnistyleDependency::IME:
|
|
90
91
|
return clazz->getStaticFieldValue(fieldIME);
|
|
92
|
+
case UnistyleDependency::RTL:
|
|
93
|
+
return clazz->getStaticFieldValue(fieldRTL);
|
|
91
94
|
default:
|
|
92
95
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
93
96
|
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
@@ -47,6 +47,8 @@ public extension UnistyleDependency {
|
|
|
47
47
|
self = .navigationbar
|
|
48
48
|
case "Ime":
|
|
49
49
|
self = .ime
|
|
50
|
+
case "Rtl":
|
|
51
|
+
self = .rtl
|
|
50
52
|
default:
|
|
51
53
|
return nil
|
|
52
54
|
}
|
|
@@ -87,6 +89,8 @@ public extension UnistyleDependency {
|
|
|
87
89
|
return "NavigationBar"
|
|
88
90
|
case .ime:
|
|
89
91
|
return "Ime"
|
|
92
|
+
case .rtl:
|
|
93
|
+
return "Rtl"
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
}
|
|
@@ -40,6 +40,7 @@ namespace margelo::nitro::unistyles {
|
|
|
40
40
|
STATUSBAR SWIFT_NAME(statusbar) = 12,
|
|
41
41
|
NAVIGATIONBAR SWIFT_NAME(navigationbar) = 13,
|
|
42
42
|
IME SWIFT_NAME(ime) = 14,
|
|
43
|
+
RTL SWIFT_NAME(rtl) = 15,
|
|
43
44
|
} CLOSED_ENUM;
|
|
44
45
|
|
|
45
46
|
} // namespace margelo::nitro::unistyles
|
|
@@ -70,7 +71,7 @@ namespace margelo::nitro {
|
|
|
70
71
|
return false;
|
|
71
72
|
}
|
|
72
73
|
// Check if we are within the bounds of the enum.
|
|
73
|
-
return integer >= 0 && integer <=
|
|
74
|
+
return integer >= 0 && integer <= 15;
|
|
74
75
|
}
|
|
75
76
|
};
|
|
76
77
|
|
package/package.json
CHANGED
package/plugin/index.js
CHANGED
|
@@ -197,7 +197,8 @@ var UnistyleDependency = {
|
|
|
197
197
|
FontScale: 11,
|
|
198
198
|
StatusBar: 12,
|
|
199
199
|
NavigationBar: 13,
|
|
200
|
-
Ime: 14
|
|
200
|
+
Ime: 14,
|
|
201
|
+
Rtl: 15
|
|
201
202
|
};
|
|
202
203
|
function getProperty(property) {
|
|
203
204
|
if (!property) {
|
|
@@ -280,6 +281,9 @@ function toUnistylesDependency(dependency) {
|
|
|
280
281
|
case "variants": {
|
|
281
282
|
return UnistyleDependency.Variants;
|
|
282
283
|
}
|
|
284
|
+
case "rtl": {
|
|
285
|
+
return UnistyleDependency.Rtl;
|
|
286
|
+
}
|
|
283
287
|
default:
|
|
284
288
|
return null;
|
|
285
289
|
}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import React, { type ComponentProps, forwardRef } from 'react'
|
|
2
|
+
import { type ImageStyle, Image as NativeImage, type StyleProp, type ViewStyle } from 'react-native'
|
|
3
|
+
import { getClassName } from '../../core'
|
|
4
|
+
import { maybeWarnAboutMultipleUnistyles } from '../../core/warn'
|
|
5
|
+
import type { UnistylesValues } from '../../types'
|
|
6
|
+
import { copyComponentProperties } from '../../utils'
|
|
7
|
+
import { createUnistylesRef, keyInObject } from '../../web/utils'
|
|
3
8
|
|
|
4
|
-
|
|
9
|
+
type Props = ComponentProps<typeof NativeImage> & {
|
|
10
|
+
style?: UnistylesValues
|
|
11
|
+
imageStyle?: UnistylesValues
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const UnistylesImage = forwardRef<unknown, Props>((props, forwardedRef) => {
|
|
15
|
+
const classNames = getClassName(props.style)
|
|
16
|
+
const ref = createUnistylesRef(classNames, forwardedRef)
|
|
17
|
+
const hasWidthStyle = typeof props.style === 'object' && keyInObject(props.style, 'width')
|
|
18
|
+
const hasHeightStyle = typeof props.style === 'object' && keyInObject(props.style, 'height')
|
|
19
|
+
|
|
20
|
+
maybeWarnAboutMultipleUnistyles(props.style as ViewStyle, 'Image')
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<NativeImage
|
|
24
|
+
{...props}
|
|
25
|
+
style={[
|
|
26
|
+
classNames,
|
|
27
|
+
// Clear inline width and height extracted from source
|
|
28
|
+
hasWidthStyle && { width: '' },
|
|
29
|
+
hasHeightStyle && { height: '' }
|
|
30
|
+
] as StyleProp<ImageStyle>}
|
|
31
|
+
ref={ref}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export const Image = copyComponentProperties(NativeImage, UnistylesImage)
|
|
@@ -2,10 +2,10 @@ import React from 'react'
|
|
|
2
2
|
import { forwardRef } from 'react'
|
|
3
3
|
import { type ImageStyle, ImageBackground as NativeImageBackground, type StyleProp, type ViewStyle } from 'react-native'
|
|
4
4
|
import { getClassName } from '../../core'
|
|
5
|
+
import { maybeWarnAboutMultipleUnistyles } from '../../core/warn'
|
|
5
6
|
import type { UnistylesValues } from '../../types'
|
|
6
7
|
import { copyComponentProperties } from '../../utils'
|
|
7
|
-
import {
|
|
8
|
-
import { isServer } from '../../web/utils'
|
|
8
|
+
import { createUnistylesRef, keyInObject } from '../../web/utils'
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
11
|
style?: UnistylesValues
|
|
@@ -13,44 +13,28 @@ type Props = {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const UnistylesImageBackground = forwardRef<unknown, Props>((props, forwardedRef) => {
|
|
16
|
-
let storedRef: NativeImageBackground | null = null
|
|
17
|
-
let storedImageRef: NativeImageBackground | null = null
|
|
18
16
|
const styleClassNames = getClassName(props.style)
|
|
19
17
|
const imageClassNames = getClassName(props.imageStyle)
|
|
18
|
+
const ref = createUnistylesRef(styleClassNames, forwardedRef)
|
|
19
|
+
const imageRef = createUnistylesRef(imageClassNames)
|
|
20
|
+
const hasWidthStyle = typeof props.imageStyle === 'object' && keyInObject(props.imageStyle, 'width')
|
|
21
|
+
const hasHeightStyle = typeof props.imageStyle === 'object' && keyInObject(props.imageStyle, 'height')
|
|
22
|
+
|
|
23
|
+
maybeWarnAboutMultipleUnistyles(props.style as ViewStyle, 'ImageBackground')
|
|
24
|
+
maybeWarnAboutMultipleUnistyles(props.imageStyle as ViewStyle, 'ImageBackground')
|
|
20
25
|
|
|
21
26
|
return (
|
|
22
27
|
<NativeImageBackground
|
|
23
28
|
{...props}
|
|
24
29
|
style={styleClassNames as StyleProp<ViewStyle>}
|
|
25
|
-
imageStyle={
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// @ts-expect-error hidden from TS
|
|
34
|
-
UnistylesShadowRegistry.add(ref, styleClassNames?.hash)
|
|
35
|
-
|
|
36
|
-
if (typeof forwardedRef === 'function') {
|
|
37
|
-
return forwardedRef(ref)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (forwardedRef) {
|
|
41
|
-
forwardedRef.current = ref
|
|
42
|
-
}
|
|
43
|
-
}}
|
|
44
|
-
imageRef={isServer() ? undefined : ref => {
|
|
45
|
-
if (!ref) {
|
|
46
|
-
// @ts-expect-error hidden from TS
|
|
47
|
-
UnistylesShadowRegistry.remove(storedImageRef, imageClassNames?.hash)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
storedImageRef = ref
|
|
51
|
-
// @ts-expect-error hidden from TS
|
|
52
|
-
UnistylesShadowRegistry.add(ref, imageClassNames?.hash)
|
|
53
|
-
}}
|
|
30
|
+
imageStyle={[
|
|
31
|
+
imageClassNames,
|
|
32
|
+
// Clear inline width and height extracted from source
|
|
33
|
+
hasWidthStyle && { width: '' },
|
|
34
|
+
hasHeightStyle && { height: '' }
|
|
35
|
+
] as StyleProp<ImageStyle>}
|
|
36
|
+
ref={ref}
|
|
37
|
+
imageRef={imageRef}
|
|
54
38
|
/>
|
|
55
39
|
)
|
|
56
40
|
})
|
|
@@ -50,10 +50,18 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ..
|
|
|
50
50
|
storedRef.current = ref
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
return passForwardedRef(
|
|
54
|
+
ref,
|
|
55
|
+
forwardedRef,
|
|
56
|
+
() => {
|
|
57
|
+
// @ts-expect-error - this is hidden from TS
|
|
58
|
+
UnistylesShadowRegistry.add(ref, unistyles)
|
|
59
|
+
},
|
|
60
|
+
() => {
|
|
61
|
+
// @ts-expect-error - this is hidden from TS
|
|
62
|
+
UnistylesShadowRegistry.remove(ref)
|
|
63
|
+
}
|
|
64
|
+
)
|
|
57
65
|
}}
|
|
58
66
|
style={state => {
|
|
59
67
|
const isPropStyleAFunction = typeof style === 'function'
|
|
@@ -38,15 +38,21 @@ export const createUnistylesElement = (Component: any) => {
|
|
|
38
38
|
storedRef.current = getNativeRef(Component, ref)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
passForwardedRef(props, ref, forwardedRef)
|
|
42
|
-
|
|
43
41
|
// @ts-ignore we don't know the type of the component
|
|
44
42
|
maybeWarnAboutMultipleUnistyles(props.style, Component.displayName)
|
|
45
43
|
|
|
46
|
-
return (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
return passForwardedRef(
|
|
45
|
+
ref,
|
|
46
|
+
forwardedRef,
|
|
47
|
+
() => {
|
|
48
|
+
// @ts-ignore this is hidden from TS
|
|
49
|
+
UnistylesShadowRegistry.add(ref, props.style)
|
|
50
|
+
},
|
|
51
|
+
() => {
|
|
52
|
+
// @ts-ignore this is hidden from TS
|
|
53
|
+
UnistylesShadowRegistry.remove(ref)
|
|
54
|
+
}
|
|
55
|
+
)
|
|
50
56
|
}}
|
|
51
57
|
/>
|
|
52
58
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import type { ViewStyle } from 'react-native'
|
|
2
3
|
import type { UnistylesValues } from '../types'
|
|
3
4
|
import { copyComponentProperties } from '../utils'
|
|
4
|
-
import {
|
|
5
|
-
import { isServer } from '../web/utils'
|
|
5
|
+
import { createUnistylesRef } from '../web/utils'
|
|
6
6
|
import { getClassName } from './getClassname'
|
|
7
7
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
|
8
8
|
|
|
@@ -12,34 +12,16 @@ type ComponentProps = {
|
|
|
12
12
|
|
|
13
13
|
export const createUnistylesElement = (Component: any) => {
|
|
14
14
|
const UnistylesComponent = React.forwardRef<unknown, ComponentProps>((props, forwardedRef) => {
|
|
15
|
-
let storedRef: HTMLElement | null = null
|
|
16
15
|
const classNames = getClassName(props.style)
|
|
16
|
+
const ref = createUnistylesRef(classNames, forwardedRef)
|
|
17
|
+
|
|
18
|
+
maybeWarnAboutMultipleUnistyles(props.style as ViewStyle, Component.displayName)
|
|
17
19
|
|
|
18
20
|
return (
|
|
19
21
|
<Component
|
|
20
22
|
{...props}
|
|
21
23
|
style={classNames}
|
|
22
|
-
ref={
|
|
23
|
-
// @ts-ignore we don't know the type of the component
|
|
24
|
-
maybeWarnAboutMultipleUnistyles(props.style, Component.displayName)
|
|
25
|
-
|
|
26
|
-
if (!ref) {
|
|
27
|
-
// @ts-expect-error hidden from TS
|
|
28
|
-
UnistylesShadowRegistry.remove(storedRef, classNames?.hash)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
storedRef = ref
|
|
32
|
-
// @ts-expect-error hidden from TS
|
|
33
|
-
UnistylesShadowRegistry.add(ref, classNames?.hash)
|
|
34
|
-
|
|
35
|
-
if (typeof forwardedRef === 'function') {
|
|
36
|
-
return forwardedRef(ref)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (forwardedRef) {
|
|
40
|
-
forwardedRef.current = ref
|
|
41
|
-
}
|
|
42
|
-
}}
|
|
24
|
+
ref={ref}
|
|
43
25
|
/>
|
|
44
26
|
)
|
|
45
27
|
})
|
|
@@ -27,17 +27,23 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
|
|
|
27
27
|
<Component
|
|
28
28
|
{...props}
|
|
29
29
|
ref={ref => {
|
|
30
|
-
passForwardedRef(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
return passForwardedRef(
|
|
31
|
+
ref,
|
|
32
|
+
forwardedRef,
|
|
33
|
+
() => {
|
|
34
|
+
// @ts-expect-error - this is hidden from TS
|
|
35
|
+
UnistylesShadowRegistry.add(ref, props.style)
|
|
36
|
+
},
|
|
37
|
+
() => {
|
|
38
|
+
// @ts-expect-error - this is hidden from TS
|
|
39
|
+
UnistylesShadowRegistry.remove(ref)
|
|
40
|
+
|
|
41
|
+
if (storedImageRef.current) {
|
|
42
|
+
// @ts-expect-error - this is hidden from TS
|
|
43
|
+
UnistylesShadowRegistry.remove(storedImageRef.current)
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
|
-
|
|
46
|
+
)
|
|
41
47
|
}}
|
|
42
48
|
imageRef={ref => {
|
|
43
49
|
if (ref) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { UnistylesShadowRegistry } from '../specs'
|
|
3
2
|
|
|
4
3
|
export const passForwardedRef = <T>(
|
|
5
|
-
props: any,
|
|
6
4
|
ref: T,
|
|
7
|
-
forwardedRef: React.ForwardedRef<T
|
|
5
|
+
forwardedRef: React.ForwardedRef<T>,
|
|
6
|
+
onMount?: () => void,
|
|
7
|
+
onUnmount?: () => void
|
|
8
8
|
) => {
|
|
9
9
|
const passForwardedRef = () => {
|
|
10
10
|
if (typeof forwardedRef === 'function') {
|
|
@@ -19,10 +19,10 @@ export const passForwardedRef = <T>(
|
|
|
19
19
|
}
|
|
20
20
|
const forwardedRefReturnFn = passForwardedRef()
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
UnistylesShadowRegistry.add(ref, props.style)
|
|
22
|
+
onMount?.()
|
|
24
23
|
|
|
25
24
|
return () => {
|
|
26
25
|
forwardedRefReturnFn?.()
|
|
26
|
+
onUnmount?.()
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -24,6 +24,7 @@ const RTDependencyMap = {
|
|
|
24
24
|
statusBar: UnistyleDependency.StatusBar,
|
|
25
25
|
pixelRatio: UnistyleDependency.PixelRatio,
|
|
26
26
|
themeName: UnistyleDependency.ThemeName,
|
|
27
|
+
rtl: UnistyleDependency.Rtl
|
|
27
28
|
} satisfies Partial<Record<keyof UnistylesMiniRuntime, UnistyleDependency>>
|
|
28
29
|
|
|
29
30
|
export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
package/src/server/serialize.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const serialize = (value: any): string => {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
return `{${Object.entries(value)
|
|
15
|
-
.map(([key, value]) =>
|
|
15
|
+
.map(([key, value]) => `'${key}':${serialize(value)}`)
|
|
16
16
|
.join(',')}}`
|
|
17
17
|
default:
|
|
18
18
|
return JSON.stringify(value)
|
|
@@ -40,9 +40,8 @@ HybridShadowRegistry.add = (handle, styles) => {
|
|
|
40
40
|
? styles.flat()
|
|
41
41
|
: [styles]
|
|
42
42
|
|
|
43
|
-
// filter
|
|
43
|
+
// filter styles that are undefined or with no keys
|
|
44
44
|
const filteredStyles = stylesArray
|
|
45
|
-
.filter(style => !style?.initial?.updater)
|
|
46
45
|
.filter(style => style && Object.keys(style).length > 0)
|
|
47
46
|
.flat()
|
|
48
47
|
.filter(Boolean)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { Nullable } from '../../types'
|
|
3
|
+
import { UnistylesWeb } from '../index'
|
|
4
|
+
import { isServer } from './common'
|
|
5
|
+
|
|
6
|
+
type ClassNames = {
|
|
7
|
+
hash: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const createUnistylesRef = <T>(classNames?: ClassNames, forwardedRef?: React.ForwardedRef<T>) => {
|
|
11
|
+
const storedRef = { current: null as Nullable<T> }
|
|
12
|
+
|
|
13
|
+
return isServer() ? undefined : (ref: Nullable<T>) => {
|
|
14
|
+
if (!ref) {
|
|
15
|
+
UnistylesWeb.shadowRegistry.remove(storedRef, classNames?.hash)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
storedRef.current = ref
|
|
19
|
+
UnistylesWeb.shadowRegistry.add(ref, classNames?.hash)
|
|
20
|
+
|
|
21
|
+
if (typeof forwardedRef === 'function') {
|
|
22
|
+
return forwardedRef(ref)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (forwardedRef) {
|
|
26
|
+
forwardedRef.current = ref
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/web/utils/index.ts
CHANGED