react-native-unistyles 3.0.0-nightly-20250425 → 3.0.0-nightly-20250428
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 +1 -1
- package/lib/commonjs/core/getClassname.js +4 -2
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js +5 -3
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js +5 -3
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +4 -2
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +4 -2
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js +4 -2
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/create.js +6 -4
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/index.js +7 -12
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/services.js +7 -2
- package/lib/commonjs/web/services.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js +5 -3
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +5 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/core/getClassname.js +2 -2
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.js +3 -3
- package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js +3 -3
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/hydrateServerUnistyles.js +2 -2
- package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/module/server/resetServerUnistyles.js +2 -2
- package/lib/module/server/resetServerUnistyles.js.map +1 -1
- package/lib/module/web/convert/object/filter.js +2 -2
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/create.js +4 -4
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/index.js +4 -10
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/services.js +7 -1
- package/lib/module/web/services.js.map +1 -1
- package/lib/module/web/utils/createUnistylesRef.js +3 -3
- package/lib/module/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +3 -3
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts +0 -1
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/resetServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +0 -5
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/services.d.ts +6 -1
- package/lib/typescript/src/web/services.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/getClassname.ts +2 -2
- package/src/core/useProxifiedUnistyles/listener.ts +3 -3
- package/src/server/getServerUnistyles.tsx +3 -3
- package/src/server/hydrateServerUnistyles.ts +3 -2
- package/src/server/resetServerUnistyles.ts +4 -3
- package/src/web/convert/object/filter.ts +2 -2
- package/src/web/create.ts +4 -4
- package/src/web/index.ts +4 -16
- package/src/web/services.ts +14 -1
- package/src/web/utils/createUnistylesRef.ts +3 -3
- package/src/web/utils/unistyle.ts +4 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["unistyles","error","isServer","hydrateServerUnistyles","services","registry","css","hydrate","window","__UNISTYLES_STATE__","document","querySelector","remove"],"sourceRoot":"../../../src","sources":["server/hydrateServerUnistyles.ts"],"mappings":";;AAAA,OAAO,KAAKA,SAAS,MAAM,iBAAiB;AAC5C,SAASC,KAAK,EAAEC,QAAQ,QAAQ,cAAc;AAS9C,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACxC,IAAID,QAAQ,CAAC,CAAC,EAAE;IACZ,MAAMD,KAAK,CAAC,qDAAqD,CAAC;EACtE;EAEAD,SAAS,CAACI,QAAQ,CAACC,QAAQ,CAACC,GAAG,CAACC,OAAO,CAACC,MAAM,CAACC,mBAAmB,CAAC;EACnEC,QAAQ,CAACC,aAAa,CAAC,mBAAmB,CAAC,EAAEC,MAAM,CAAC,CAAC;AACzD,CAAC","ignoreList":[]}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import
|
3
|
+
import * as unistyles from '../web/services';
|
4
4
|
import { error, isServer } from '../web/utils';
|
5
5
|
export const resetServerUnistyles = () => {
|
6
6
|
if (!isServer()) {
|
7
7
|
throw error('Server styles should only be reset on the server');
|
8
8
|
}
|
9
|
-
|
9
|
+
unistyles.services.registry.reset();
|
10
10
|
};
|
11
11
|
//# sourceMappingURL=resetServerUnistyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["unistyles","error","isServer","resetServerUnistyles","services","registry","reset"],"sourceRoot":"../../../src","sources":["server/resetServerUnistyles.ts"],"mappings":";;AAAA,OAAO,KAAKA,SAAS,MAAM,iBAAiB;AAC5C,SAASC,KAAK,EAAEC,QAAQ,QAAQ,cAAc;AAE9C,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACtC,IAAI,CAACD,QAAQ,CAAC,CAAC,EAAE;IACb,MAAMD,KAAK,CAAC,kDAAkD,CAAC;EACnE;EAEAD,SAAS,CAACI,QAAQ,CAACC,QAAQ,CAACC,KAAK,CAAC,CAAC;AACvC,CAAC","ignoreList":[]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
import { isUnistylesMq } from '../../../mq';
|
4
|
-
import
|
4
|
+
import * as unistyles from '../../services';
|
5
5
|
import { hyphenate } from '../../utils';
|
6
6
|
import { normalizeColor, normalizeNumericValue } from '../utils';
|
7
7
|
import { getObjectStyle } from './objectStyle';
|
@@ -21,7 +21,7 @@ export const getFilterStyle = filters => {
|
|
21
21
|
if (typeof dropShadowValue !== 'object') {
|
22
22
|
return [];
|
23
23
|
}
|
24
|
-
const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(
|
24
|
+
const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(unistyles.services.runtime.breakpoints).includes(key) || isUnistylesMq(key));
|
25
25
|
const breakpointsDropShadow = Object.fromEntries(breakpoints.map(breakpoint => [breakpoint, getDropShadowStyle(dropShadowValue[breakpoint])]));
|
26
26
|
if (breakpoints.length === 0) {
|
27
27
|
return [{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isUnistylesMq","
|
1
|
+
{"version":3,"names":["isUnistylesMq","unistyles","hyphenate","normalizeColor","normalizeNumericValue","getObjectStyle","getDropShadowStyle","dropShadow","offsetX","offsetY","standardDeviation","color","String","getFilterStyle","filters","restFilters","filter","Object","keys","dropShadowValue","find","breakpoints","key","services","runtime","includes","breakpointsDropShadow","fromEntries","map","breakpoint","length","value"],"sourceRoot":"../../../../../src","sources":["web/convert/object/filter.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAC3C,SAASC,SAAS,QAAQ,aAAa;AAEvC,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,UAAU;AAChE,SAASC,cAAc,QAAQ,eAAe;AAE9C,MAAMC,kBAAkB,GAAIC,UAA2B,IAAK;EACxD,MAAM;IAAEC,OAAO,GAAG,CAAC;IAAEC,OAAO,GAAG,CAAC;IAAEC,iBAAiB,GAAG,CAAC;IAAEC,KAAK,GAAG;EAAO,CAAC,GAAGJ,UAAU;EAEtF,OAAO,GAAGJ,cAAc,CAACS,MAAM,CAACD,KAAK,CAAC,CAAC,IAAIP,qBAAqB,CAACI,OAAO,CAAC,IAAIJ,qBAAqB,CAACK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AG,EAAES,KAAK,KAAK,GAAG7B,SAAS,CAACoB,GAAG,CAAC,IAAIlB,qBAAqB,CAAC2B,KAAwB,CAAC,GAAG,CAAC;AAC7J,CAAC","ignoreList":[]}
|
package/lib/module/web/create.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import
|
3
|
+
import * as unistyles from './services';
|
4
4
|
import { assignSecrets, error, isServer, removeInlineStyles } from './utils';
|
5
5
|
export const create = (stylesheet, id) => {
|
6
6
|
if (!id) {
|
@@ -8,11 +8,11 @@ export const create = (stylesheet, id) => {
|
|
8
8
|
}
|
9
9
|
|
10
10
|
// For SSR
|
11
|
-
if (!
|
11
|
+
if (!unistyles.services.state.isInitialized && !isServer()) {
|
12
12
|
const config = window?.__UNISTYLES_STATE__?.config;
|
13
|
-
config &&
|
13
|
+
config && unistyles.services.state.init(config);
|
14
14
|
}
|
15
|
-
const computedStylesheet =
|
15
|
+
const computedStylesheet = unistyles.services.registry.getComputedStylesheet(stylesheet);
|
16
16
|
const addSecrets = (value, key, args = undefined, variants = {}) => assignSecrets(value, {
|
17
17
|
__uni__key: key,
|
18
18
|
__uni__stylesheet: stylesheet,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["unistyles","assignSecrets","error","isServer","removeInlineStyles","create","stylesheet","id","services","state","isInitialized","config","window","__UNISTYLES_STATE__","init","computedStylesheet","registry","getComputedStylesheet","addSecrets","value","key","args","undefined","variants","__uni__key","__uni__stylesheet","__uni__args","__uni_variants","createStyleSheetStyles","stylesEntries","Object","entries","map","result","fromEntries","concat","useVariants"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;AACA,OAAO,KAAKA,SAAS,MAAM,YAAY;AACvC,SAASC,aAAa,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,kBAAkB,QAAQ,SAAS;AAI5E,OAAO,MAAMC,MAAM,GAAGA,CAACC,UAAiD,EAAEC,EAAW,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EC,GAAG,EAAEE,SAAS,EAAEC,QAAQ,CAAC,CAAC;IACjF,CAAC,CAAC;IAEF,OAAOO,MAAM,CAACI,WAAW,CAACL,aAAa,CAACM,MAAM,CAAC,CAACC,WAAW,CAAC,CAAC,CAAC;EAClE,CAAC;EAED,MAAMA,WAAW,GAAG,CAAC,aAAa,EAAGb,QAAkB,IAAK;IACxD,OAAOK,sBAAsB,CAACL,QAAQ,CAAC;EAC3C,CAAC,CAAC;EAEF,OAAOK,sBAAsB,CAAC,CAAC;AACnC,CAAC","ignoreList":[]}
|
package/lib/module/web/index.js
CHANGED
@@ -2,15 +2,9 @@
|
|
2
2
|
|
3
3
|
import { deepMergeObjects } from '../utils';
|
4
4
|
import { create } from './create';
|
5
|
-
import
|
6
|
-
import { isServer } from './utils';
|
7
|
-
if (isServer() && !globalThis.__unistyles__) {
|
8
|
-
// @ts-ignore
|
9
|
-
globalThis.__unistyles__ = new UnistylesServices();
|
10
|
-
}
|
11
|
-
export const UnistylesWeb = isServer() ? globalThis.__unistyles__ : new UnistylesServices();
|
5
|
+
import * as unistyles from './services';
|
12
6
|
export const StyleSheet = {
|
13
|
-
configure:
|
7
|
+
configure: unistyles.services.state.init,
|
14
8
|
create: create,
|
15
9
|
absoluteFill: {
|
16
10
|
position: 'absolute',
|
@@ -30,7 +24,7 @@ export const StyleSheet = {
|
|
30
24
|
flatten: (...styles) => deepMergeObjects(...styles),
|
31
25
|
hairlineWidth: 1
|
32
26
|
};
|
33
|
-
export const UnistylesRuntime =
|
34
|
-
export const UnistylesShadowRegistry =
|
27
|
+
export const UnistylesRuntime = unistyles.services.runtime;
|
28
|
+
export const UnistylesShadowRegistry = unistyles.services.shadowRegistry;
|
35
29
|
export * from './mock';
|
36
30
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["deepMergeObjects","create","
|
1
|
+
{"version":3,"names":["deepMergeObjects","create","unistyles","StyleSheet","configure","services","state","init","absoluteFill","position","left","top","right","bottom","absoluteFillObject","compose","a","b","flatten","styles","hairlineWidth","UnistylesRuntime","runtime","UnistylesShadowRegistry","shadowRegistry"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;AAGA,SAASA,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,MAAM,QAAQ,UAAU;AACjC,OAAO,KAAKC,SAAS,MAAM,YAAY;AAEvC,OAAO,MAAMC,UAAU,GAAG;EACtBC,SAAS,EAAEF,SAAS,CAACG,QAAQ,CAACC,KAAK,CAACC,IAAI;EACxCN,MAAM,EAAEA,MAAM;EACdO,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,kBAAkB,EAAE;IAChBL,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDE,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAKjB,gBAAgB,CAACgB,CAAC,EAAEC,CAAC,CAAC;EACzDC,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAKnB,gBAAgB,CAAC,GAAGmB,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAuC;AAEvC,OAAO,MAAMC,gBAAgB,GAAGnB,SAAS,CAACG,QAAQ,CAACiB,OAAmD;AACtG,OAAO,MAAMC,uBAAuB,GAAGrB,SAAS,CAACG,QAAQ,CAACmB,cAAiE;AAE3H,cAAc,QAAQ","ignoreList":[]}
|
@@ -5,7 +5,8 @@ import { UnistylesRegistry } from './registry';
|
|
5
5
|
import { UnistylesRuntime } from './runtime';
|
6
6
|
import { UnistylesShadowRegistry } from './shadowRegistry';
|
7
7
|
import { UnistylesState } from './state';
|
8
|
-
|
8
|
+
import { isServer } from './utils';
|
9
|
+
class UnistylesServices {
|
9
10
|
services = {};
|
10
11
|
constructor() {
|
11
12
|
this.runtime = new UnistylesRuntime(this.services);
|
@@ -20,4 +21,9 @@ export class UnistylesServices {
|
|
20
21
|
this.services.listener = this.listener;
|
21
22
|
}
|
22
23
|
}
|
24
|
+
if (isServer() && !globalThis.__unistyles__) {
|
25
|
+
// @ts-ignore
|
26
|
+
globalThis.__unistyles__ = new UnistylesServices();
|
27
|
+
}
|
28
|
+
export const services = isServer() ? globalThis.__unistyles__ : new UnistylesServices();
|
23
29
|
//# sourceMappingURL=services.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistylesListener","UnistylesRegistry","UnistylesRuntime","UnistylesShadowRegistry","UnistylesState","UnistylesServices","services","constructor","runtime","registry","shadowRegistry","state","listener"],"sourceRoot":"../../../src","sources":["web/services.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,SAASC,cAAc,QAAQ,SAAS;
|
1
|
+
{"version":3,"names":["UnistylesListener","UnistylesRegistry","UnistylesRuntime","UnistylesShadowRegistry","UnistylesState","isServer","UnistylesServices","services","constructor","runtime","registry","shadowRegistry","state","listener","globalThis","__unistyles__"],"sourceRoot":"../../../src","sources":["web/services.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,QAAQ,QAAQ,SAAS;AAElC,MAAMC,iBAAiB,CAAC;EAOZC,QAAQ,GAAG,CAAC,CAAC;EAErBC,WAAWA,CAAA,EAAG;IACV,IAAI,CAACC,OAAO,GAAG,IAAIP,gBAAgB,CAAC,IAAI,CAACK,QAAQ,CAAC;IAClD,IAAI,CAACG,QAAQ,GAAG,IAAIT,iBAAiB,CAAC,IAAI,CAACM,QAAQ,CAAC;IACpD,IAAI,CAACI,cAAc,GAAG,IAAIR,uBAAuB,CAAC,IAAI,CAACI,QAAQ,CAAC;IAChE,IAAI,CAACK,KAAK,GAAG,IAAIR,cAAc,CAAC,IAAI,CAACG,QAAQ,CAAC;IAC9C,IAAI,CAACM,QAAQ,GAAG,IAAIb,iBAAiB,CAAC,IAAI,CAACO,QAAQ,CAAC;IACpD,IAAI,CAACA,QAAQ,CAACE,OAAO,GAAG,IAAI,CAACA,OAAO;IACpC,IAAI,CAACF,QAAQ,CAACG,QAAQ,GAAG,IAAI,CAACA,QAAQ;IACtC,IAAI,CAACH,QAAQ,CAACI,cAAc,GAAG,IAAI,CAACA,cAAc;IAClD,IAAI,CAACJ,QAAQ,CAACK,KAAK,GAAG,IAAI,CAACA,KAAK;IAChC,IAAI,CAACL,QAAQ,CAACM,QAAQ,GAAG,IAAI,CAACA,QAAQ;EAC1C;AACJ;AAOA,IAAIR,QAAQ,CAAC,CAAC,IAAI,CAACS,UAAU,CAACC,aAAa,EAAE;EACzC;EACAD,UAAU,CAACC,aAAa,GAAG,IAAIT,iBAAiB,CAAC,CAAC;AACtD;AAEA,OAAO,MAAMC,QAAQ,GAAGF,QAAQ,CAAC,CAAC,GAAGS,UAAU,CAACC,aAAa,GAAG,IAAIT,iBAAiB,CAAC,CAAC","ignoreList":[]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import
|
3
|
+
import * as unistyles from '../services';
|
4
4
|
import { isServer } from './common';
|
5
5
|
export const createUnistylesRef = (styles, forwardedRef) => {
|
6
6
|
const storedRef = {
|
@@ -9,10 +9,10 @@ export const createUnistylesRef = (styles, forwardedRef) => {
|
|
9
9
|
const [classNames] = styles ?? [];
|
10
10
|
return isServer() ? undefined : ref => {
|
11
11
|
if (!ref) {
|
12
|
-
|
12
|
+
unistyles.services.shadowRegistry.remove(storedRef, classNames?.hash);
|
13
13
|
}
|
14
14
|
storedRef.current = ref;
|
15
|
-
|
15
|
+
unistyles.services.shadowRegistry.add(ref, classNames?.hash);
|
16
16
|
if (typeof forwardedRef === 'function') {
|
17
17
|
return forwardedRef(ref);
|
18
18
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["unistyles","isServer","createUnistylesRef","styles","forwardedRef","storedRef","current","classNames","undefined","ref","services","shadowRegistry","remove","hash","add"],"sourceRoot":"../../../../src","sources":["web/utils/createUnistylesRef.ts"],"mappings":";;AAEA,OAAO,KAAKA,SAAS,MAAM,aAAa;AACxC,SAASC,QAAQ,QAAQ,UAAU;AASnC,OAAO,MAAMC,kBAAkB,GAAGA,CAAIC,MAAe,EAAEC,YAAoC,KAAK;EAC5F,MAAMC,SAAS,GAAG;IAAEC,OAAO,EAAE;EAAoB,CAAC;EAClD,MAAM,CAACC,UAAU,CAAC,GAAGJ,MAAM,IAAI,EAAE;EAEjC,OAAOF,QAAQ,CAAC,CAAC,GAAGO,SAAS,GAAIC,GAAgB,IAAK;IAClD,IAAI,CAACA,GAAG,EAAE;MACNT,SAAS,CAACU,QAAQ,CAACC,cAAc,CAACC,MAAM,CAACP,SAAS,EAAEE,UAAU,EAAEM,IAAI,CAAC;IACzE;IAEAR,SAAS,CAACC,OAAO,GAAGG,GAAG;IACvBT,SAAS,CAACU,QAAQ,CAACC,cAAc,CAACG,GAAG,CAACL,GAAG,EAAEF,UAAU,EAAEM,IAAI,CAAC;IAE5D,IAAI,OAAOT,YAAY,KAAK,UAAU,EAAE;MACpC,OAAOA,YAAY,CAACK,GAAG,CAAC;IAC5B;IAEA,IAAIL,YAAY,EAAE;MACdA,YAAY,CAACE,OAAO,GAAGG,GAAG;IAC9B;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import { Animated } from 'react-native';
|
4
4
|
import { isUnistylesMq, parseMq } from '../../mq';
|
5
5
|
import { ColorScheme, Orientation } from '../../specs/types';
|
6
|
-
import
|
6
|
+
import * as unistyles from '../services';
|
7
7
|
import { keyInObject, reduceObject } from './common';
|
8
8
|
export const schemeToTheme = scheme => {
|
9
9
|
switch (scheme) {
|
@@ -60,8 +60,8 @@ export const getMediaQuery = (query, allBreakpoints) => {
|
|
60
60
|
const queries = [minWidth ? `(min-width: ${minWidth}px)` : undefined, maxWidth ? `(max-width: ${maxWidth}px)` : undefined, minHeight ? `(min-height: ${minHeight}px)` : undefined, maxHeight ? `(max-height: ${maxHeight}px)` : undefined].filter(Boolean).join(' and ');
|
61
61
|
return `@media ${queries}`;
|
62
62
|
}
|
63
|
-
const breakpointValue =
|
64
|
-
const nextBreakpoint = allBreakpoints.filter(b => b in
|
63
|
+
const breakpointValue = unistyles.services.runtime.breakpoints[query] ?? 0;
|
64
|
+
const nextBreakpoint = allBreakpoints.filter(b => b in unistyles.services.runtime.breakpoints).map(b => unistyles.services.runtime.breakpoints[b]).sort((a, b) => a - b).find(b => b > breakpointValue);
|
65
65
|
const queries = [`(min-width: ${breakpointValue}px)`, nextBreakpoint ? `(max-width: ${nextBreakpoint - 1}px)` : undefined].filter(Boolean).join(' and ');
|
66
66
|
return `@media ${queries}`;
|
67
67
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Animated","isUnistylesMq","parseMq","ColorScheme","Orientation","
|
1
|
+
{"version":3,"names":["Animated","isUnistylesMq","parseMq","ColorScheme","Orientation","unistyles","keyInObject","reduceObject","schemeToTheme","scheme","Dark","Light","assignSecrets","object","secrets","secretsId","Math","random","toString","slice","Object","defineProperties","secret","value","enumerable","configurable","extractSecrets","undefined","entries","find","key","startsWith","getOwnPropertyDescriptors","removeInlineStyles","values","returnValue","getMediaQuery","query","allBreakpoints","includes","minWidth","maxWidth","minHeight","maxHeight","queries","filter","Boolean","join","breakpointValue","services","runtime","breakpoints","nextBreakpoint","b","map","sort","a","extractUnistyleDependencies","dependencies","uni__dependencies","Array","isArray","checkForProp","prop","some","nestedValue","_web","checkForAnimated","objectValues","Node","length","keys"],"sourceRoot":"../../../../src","sources":["web/utils/unistyle.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,aAAa,EAAEC,OAAO,QAAQ,UAAU;AAEjD,SAASC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AAE5D,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,SAASC,WAAW,EAAEC,YAAY,QAAQ,UAAU;AAEpD,OAAO,MAAMC,aAAa,GAAIC,MAAmB,IAAK;EAClD,QAAQA,MAAM;IACV,KAAKN,WAAW,CAACO,IAAI;MACjB,OAAO,MAAM;IACjB,KAAKP,WAAW,CAACQ,KAAK;IACtB;MACI,OAAO,OAAO;EACtB;AACJ,CAAC;AASD,OAAO,MAAMC,aAAa,GAAGA,CAAIC,MAAS,EAAEC,OAAwB,KAAK;EACrE,MAAMC,SAAS,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC;;EAErD;EACAN,MAAM,CAAC,aAAaE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC;EACrC;EACAK,MAAM,CAACC,gBAAgB,CAACR,MAAM,CAAC,aAAaE,SAAS,EAAE,CAAC,EAAER,YAAY,CAACO,OAAO,EAAEQ,MAAM,KAAK;IACvFC,KAAK,EAAED,MAAM;IACbE,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE;EAClB,CAAC,CAAC,CAAC,CAAC;EAEJ,OAAOZ,MAAM;AACjB,CAAC;AAED,OAAO,MAAMa,cAAc,GAAIb,MAAW,IAAK;EAC3C,IAAI,CAACA,MAAM,EAAE;IACT,OAAOc,SAAS;EACpB;EAEA,MAAM,GAAGb,OAAO,CAAC,GAAGM,MAAM,CAACQ,OAAO,CAACf,MAAM,CAAC,CAACgB,IAAI,CAAC,CAAC,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AAEF,IAAI,CAAC,CAAC;EACrE;EAEA,IAAI,OAAOxC,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;IAC7C,OAAOjB,WAAW,CAACiB,KAAK,EAAEwC,IAAI,CAAC,GACzB,IAAI,GACJzD,WAAW,CAACiB,KAAK,EAAE,MAAM,CAAC,GACtBuC,YAAY,CAACvC,KAAK,CAAC2C,IAAI,EAAEH,IAAI,CAAC,GAC9B,KAAK;EACnB;EAEA,OAAO,KAAK;AAChB,CAAC;AAED,OAAO,MAAMI,gBAAgB,GAAI5C,KAAU,IAAc;EACrD,IAAIqC,KAAK,CAACC,OAAO,CAACtC,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACyC,IAAI,CAACG,gBAAgB,CAAC;EACvC;EAEA,IAAI,OAAO5C,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;IAC7C,MAAM6C,YAAY,GAAGhD,MAAM,CAACc,MAAM,CAACX,KAAK,CAAC;IACzC,MAAMT,OAAO,GAAGY,cAAc,CAACH,KAAK,CAAC;;IAErC;IACA,OAAOA,KAAK,YAAYvB,QAAQ,CAACqE,IAAI,IACjCD,YAAY,CAACE,MAAM,GAAG,CAAC,IAAIF,YAAY,CAACJ,IAAI,CAACG,gBAAgB,CAAC,IAC9DrD,OAAO,IAAIM,MAAM,CAACmD,IAAI,CAACzD,OAAO,CAAC,CAACwD,MAAM,KAAK,CAAC;EACpD;EAEA,OAAO,KAAK;AAChB,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"hydrateServerUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/server/hydrateServerUnistyles.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"hydrateServerUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/server/hydrateServerUnistyles.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QAEZ,mBAAmB,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;KAC7E;CACJ;AAED,eAAO,MAAM,sBAAsB,YAOlC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resetServerUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/server/resetServerUnistyles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,
|
1
|
+
{"version":3,"file":"resetServerUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/server/resetServerUnistyles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,YAMhC,CAAA"}
|
@@ -1,11 +1,6 @@
|
|
1
1
|
import type { UnistylesShadowRegistry as NativeUnistylesShadowRegistry } from '../specs/ShadowRegistry';
|
2
2
|
import type { StyleSheet as NativeStyleSheet } from '../specs/StyleSheet';
|
3
3
|
import type { Runtime as NativeUnistylesRuntime } from '../specs/UnistylesRuntime';
|
4
|
-
import { UnistylesServices } from './services';
|
5
|
-
declare global {
|
6
|
-
var __unistyles__: UnistylesServices;
|
7
|
-
}
|
8
|
-
export declare const UnistylesWeb: UnistylesServices;
|
9
4
|
export declare const StyleSheet: typeof NativeStyleSheet;
|
10
5
|
export declare const UnistylesRuntime: typeof NativeUnistylesRuntime;
|
11
6
|
export declare const UnistylesShadowRegistry: typeof NativeUnistylesShadowRegistry;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,IAAI,6BAA6B,EAAE,MAAM,yBAAyB,CAAA;AACvG,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,IAAI,6BAA6B,EAAE,MAAM,yBAAyB,CAAA;AACvG,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAKlF,eAAO,MAAM,UAAU,EAoBP,OAAO,gBAAgB,CAAA;AAEvC,eAAO,MAAM,gBAAgB,EAA4C,OAAO,sBAAsB,CAAA;AACtG,eAAO,MAAM,uBAAuB,EAAmD,OAAO,6BAA6B,CAAA;AAE3H,cAAc,QAAQ,CAAA"}
|
@@ -3,7 +3,7 @@ import { UnistylesRegistry } from './registry';
|
|
3
3
|
import { UnistylesRuntime } from './runtime';
|
4
4
|
import { UnistylesShadowRegistry } from './shadowRegistry';
|
5
5
|
import { UnistylesState } from './state';
|
6
|
-
|
6
|
+
declare class UnistylesServices {
|
7
7
|
runtime: UnistylesRuntime;
|
8
8
|
registry: UnistylesRegistry;
|
9
9
|
shadowRegistry: UnistylesShadowRegistry;
|
@@ -12,4 +12,9 @@ export declare class UnistylesServices {
|
|
12
12
|
private services;
|
13
13
|
constructor();
|
14
14
|
}
|
15
|
+
declare global {
|
16
|
+
var __unistyles__: UnistylesServices;
|
17
|
+
}
|
18
|
+
export declare const services: UnistylesServices;
|
19
|
+
export {};
|
15
20
|
//# sourceMappingURL=services.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/web/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/web/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGxC,cAAM,iBAAiB;IACnB,OAAO,EAAE,gBAAgB,CAAA;IACzB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,cAAc,EAAE,uBAAuB,CAAA;IACvC,KAAK,EAAE,cAAc,CAAA;IACrB,QAAQ,EAAE,iBAAiB,CAAA;IAE3B,OAAO,CAAC,QAAQ,CAA0B;;CAc7C;AAED,OAAO,CAAC,MAAM,CAAC;IAEX,IAAI,aAAa,EAAE,iBAAiB,CAAA;CACvC;AAOD,eAAO,MAAM,QAAQ,mBAAkE,CAAA"}
|
package/package.json
CHANGED
package/src/core/getClassname.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { UnistylesValues } from '../types'
|
2
|
-
import
|
2
|
+
import * as unistyles from '../web/services'
|
3
3
|
import { checkForAnimated } from '../web/utils'
|
4
4
|
|
5
5
|
export const getClassName = (unistyle: UnistylesValues | undefined | Array<UnistylesValues>, forChild?: boolean) => {
|
@@ -11,7 +11,7 @@ export const getClassName = (unistyle: UnistylesValues | undefined | Array<Unist
|
|
11
11
|
const animatedStyles = flattenedStyles.filter(checkForAnimated)
|
12
12
|
const regularStyles = flattenedStyles.filter(style => !checkForAnimated(style))
|
13
13
|
|
14
|
-
const { hash, injectedClassName } =
|
14
|
+
const { hash, injectedClassName } = unistyles.services.shadowRegistry.addStyles(
|
15
15
|
regularStyles,
|
16
16
|
forChild
|
17
17
|
)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { UnistyleDependency } from '../../specs'
|
2
|
-
import
|
2
|
+
import * as unistyles from '../../web/services'
|
3
3
|
import type { ListenerProps } from './types'
|
4
4
|
|
5
5
|
export const listener = ({ dependencies, updateTheme, updateRuntime }: ListenerProps) => {
|
6
|
-
const disposeTheme =
|
7
|
-
const disposeRuntime =
|
6
|
+
const disposeTheme = unistyles.services.listener.addListeners(dependencies.filter(dependency => dependency === UnistyleDependency.Theme), updateTheme)
|
7
|
+
const disposeRuntime = unistyles.services.listener.addListeners(dependencies.filter(dependency => dependency !== UnistyleDependency.Theme), updateRuntime)
|
8
8
|
|
9
9
|
return () => {
|
10
10
|
disposeTheme()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { StyleSheet } from 'react-native'
|
3
|
-
import
|
3
|
+
import * as unistyles from '../web/services'
|
4
4
|
import { error, isServer } from '../web/utils'
|
5
5
|
import { serialize } from './serialize'
|
6
6
|
import { DefaultServerUnistylesSettings, type ServerUnistylesSettings } from './types'
|
@@ -12,8 +12,8 @@ export const getServerUnistyles = ({ includeRNWStyles = true }: ServerUnistylesS
|
|
12
12
|
|
13
13
|
// @ts-ignore
|
14
14
|
const rnwStyle: string | null = includeRNWStyles ? (StyleSheet?.getSheet().textContent ?? '') : null
|
15
|
-
const css =
|
16
|
-
const state =
|
15
|
+
const css = unistyles.services.registry.css.getStyles()
|
16
|
+
const state = unistyles.services.registry.css.getState()
|
17
17
|
|
18
18
|
return (
|
19
19
|
<>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import * as unistyles from '../web/services'
|
2
2
|
import { error, isServer } from '../web/utils'
|
3
3
|
|
4
4
|
declare global {
|
@@ -12,6 +12,7 @@ export const hydrateServerUnistyles = () => {
|
|
12
12
|
if (isServer()) {
|
13
13
|
throw error('Server styles should only be hydrated on the client')
|
14
14
|
}
|
15
|
-
|
15
|
+
|
16
|
+
unistyles.services.registry.css.hydrate(window.__UNISTYLES_STATE__)
|
16
17
|
document.querySelector('#unistyles-script')?.remove()
|
17
18
|
}
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import
|
1
|
+
import * as unistyles from '../web/services'
|
2
2
|
import { error, isServer } from '../web/utils'
|
3
3
|
|
4
4
|
export const resetServerUnistyles = () => {
|
5
5
|
if (!isServer()) {
|
6
6
|
throw error('Server styles should only be reset on the server')
|
7
7
|
}
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
unistyles.services.registry.reset()
|
10
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { DropShadowValue } from 'react-native'
|
2
2
|
import { isUnistylesMq } from '../../../mq'
|
3
|
-
import
|
3
|
+
import * as unistyles from '../../services'
|
4
4
|
import { hyphenate } from '../../utils'
|
5
5
|
import type { Filters } from '../types'
|
6
6
|
import { normalizeColor, normalizeNumericValue } from '../utils'
|
@@ -21,7 +21,7 @@ export const getFilterStyle = (filters: Array<Filters>) => {
|
|
21
21
|
return []
|
22
22
|
}
|
23
23
|
|
24
|
-
const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(
|
24
|
+
const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(unistyles.services.runtime.breakpoints).includes(key) || isUnistylesMq(key))
|
25
25
|
const breakpointsDropShadow = Object.fromEntries(breakpoints.map(breakpoint => [breakpoint, getDropShadowStyle(dropShadowValue[breakpoint])]))
|
26
26
|
|
27
27
|
if (breakpoints.length === 0) {
|
package/src/web/create.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet'
|
2
|
-
import
|
2
|
+
import * as unistyles from './services'
|
3
3
|
import { assignSecrets, error, isServer, removeInlineStyles } from './utils'
|
4
4
|
|
5
5
|
type Variants = Record<string, string | boolean | undefined>
|
@@ -10,13 +10,13 @@ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, id?: s
|
|
10
10
|
}
|
11
11
|
|
12
12
|
// For SSR
|
13
|
-
if (!
|
13
|
+
if (!unistyles.services.state.isInitialized && !isServer()) {
|
14
14
|
const config = window?.__UNISTYLES_STATE__?.config
|
15
15
|
|
16
|
-
config &&
|
16
|
+
config && unistyles.services.state.init(config)
|
17
17
|
}
|
18
18
|
|
19
|
-
const computedStylesheet =
|
19
|
+
const computedStylesheet = unistyles.services.registry.getComputedStylesheet(stylesheet)
|
20
20
|
const addSecrets = (value: any, key: string, args = undefined as Array<any> | undefined, variants = {} as Variants) => assignSecrets(value, {
|
21
21
|
__uni__key: key,
|
22
22
|
__uni__stylesheet: stylesheet,
|
package/src/web/index.ts
CHANGED
@@ -3,22 +3,10 @@ import type { StyleSheet as NativeStyleSheet } from '../specs/StyleSheet'
|
|
3
3
|
import type { Runtime as NativeUnistylesRuntime } from '../specs/UnistylesRuntime'
|
4
4
|
import { deepMergeObjects } from '../utils'
|
5
5
|
import { create } from './create'
|
6
|
-
import
|
7
|
-
import { isServer } from './utils'
|
6
|
+
import * as unistyles from './services'
|
8
7
|
|
9
|
-
declare global {
|
10
|
-
// @ts-ignore
|
11
|
-
var __unistyles__: UnistylesServices
|
12
|
-
}
|
13
|
-
|
14
|
-
if (isServer() && !globalThis.__unistyles__) {
|
15
|
-
// @ts-ignore
|
16
|
-
globalThis.__unistyles__ = new UnistylesServices()
|
17
|
-
}
|
18
|
-
|
19
|
-
export const UnistylesWeb = isServer() ? globalThis.__unistyles__ : new UnistylesServices()
|
20
8
|
export const StyleSheet = {
|
21
|
-
configure:
|
9
|
+
configure: unistyles.services.state.init,
|
22
10
|
create: create,
|
23
11
|
absoluteFill: {
|
24
12
|
position: 'absolute',
|
@@ -39,8 +27,8 @@ export const StyleSheet = {
|
|
39
27
|
hairlineWidth: 1
|
40
28
|
} as unknown as typeof NativeStyleSheet
|
41
29
|
|
42
|
-
export const UnistylesRuntime =
|
43
|
-
export const UnistylesShadowRegistry =
|
30
|
+
export const UnistylesRuntime = unistyles.services.runtime as unknown as typeof NativeUnistylesRuntime
|
31
|
+
export const UnistylesShadowRegistry = unistyles.services.shadowRegistry as unknown as typeof NativeUnistylesShadowRegistry
|
44
32
|
|
45
33
|
export * from './mock'
|
46
34
|
|
package/src/web/services.ts
CHANGED
@@ -3,8 +3,9 @@ import { UnistylesRegistry } from './registry'
|
|
3
3
|
import { UnistylesRuntime } from './runtime'
|
4
4
|
import { UnistylesShadowRegistry } from './shadowRegistry'
|
5
5
|
import { UnistylesState } from './state'
|
6
|
+
import { isServer } from './utils'
|
6
7
|
|
7
|
-
|
8
|
+
class UnistylesServices {
|
8
9
|
runtime: UnistylesRuntime
|
9
10
|
registry: UnistylesRegistry
|
10
11
|
shadowRegistry: UnistylesShadowRegistry
|
@@ -26,3 +27,15 @@ export class UnistylesServices {
|
|
26
27
|
this.services.listener = this.listener
|
27
28
|
}
|
28
29
|
}
|
30
|
+
|
31
|
+
declare global {
|
32
|
+
// @ts-ignore
|
33
|
+
var __unistyles__: UnistylesServices
|
34
|
+
}
|
35
|
+
|
36
|
+
if (isServer() && !globalThis.__unistyles__) {
|
37
|
+
// @ts-ignore
|
38
|
+
globalThis.__unistyles__ = new UnistylesServices()
|
39
|
+
}
|
40
|
+
|
41
|
+
export const services = isServer() ? globalThis.__unistyles__ : new UnistylesServices()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type React from 'react'
|
2
2
|
import type { Nullable, UnistylesValues } from '../../types'
|
3
|
-
import
|
3
|
+
import * as unistyles from '../services'
|
4
4
|
import { isServer } from './common'
|
5
5
|
|
6
6
|
type Styles = readonly [
|
@@ -16,11 +16,11 @@ export const createUnistylesRef = <T>(styles?: Styles, forwardedRef?: React.Forw
|
|
16
16
|
|
17
17
|
return isServer() ? undefined : (ref: Nullable<T>) => {
|
18
18
|
if (!ref) {
|
19
|
-
|
19
|
+
unistyles.services.shadowRegistry.remove(storedRef, classNames?.hash)
|
20
20
|
}
|
21
21
|
|
22
22
|
storedRef.current = ref
|
23
|
-
|
23
|
+
unistyles.services.shadowRegistry.add(ref, classNames?.hash)
|
24
24
|
|
25
25
|
if (typeof forwardedRef === 'function') {
|
26
26
|
return forwardedRef(ref)
|
@@ -4,7 +4,7 @@ import { isUnistylesMq, parseMq } from '../../mq'
|
|
4
4
|
import type { UnistyleDependency } from '../../specs/NativePlatform'
|
5
5
|
import { ColorScheme, Orientation } from '../../specs/types'
|
6
6
|
import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
|
7
|
-
import
|
7
|
+
import * as unistyles from '../services'
|
8
8
|
import { keyInObject, reduceObject } from './common'
|
9
9
|
|
10
10
|
export const schemeToTheme = (scheme: ColorScheme) => {
|
@@ -82,10 +82,10 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
|
|
82
82
|
return `@media ${queries}`
|
83
83
|
}
|
84
84
|
|
85
|
-
const breakpointValue =
|
85
|
+
const breakpointValue = unistyles.services.runtime.breakpoints[query as keyof UnistylesBreakpoints] ?? 0
|
86
86
|
const nextBreakpoint = allBreakpoints
|
87
|
-
.filter((b): b is keyof UnistylesBreakpoints => b in
|
88
|
-
.map(b =>
|
87
|
+
.filter((b): b is keyof UnistylesBreakpoints => b in unistyles.services.runtime.breakpoints)
|
88
|
+
.map(b => unistyles.services.runtime.breakpoints[b] as number)
|
89
89
|
.sort((a, b) => a - b)
|
90
90
|
.find(b => b > breakpointValue)
|
91
91
|
const queries = [
|