react-native-unistyles 2.0.0-alpha.6 → 2.0.0-alpha.8
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/{types/cxx.js → common.js} +6 -6
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/{Unistyles.js → core/Unistyles.js} +2 -7
- package/lib/commonjs/core/Unistyles.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -0
- package/lib/commonjs/{UnistylesRuntime.js → core/UnistylesRuntime.js} +5 -5
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
- package/lib/commonjs/core/index.js +13 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/hooks/index.js +10 -3
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/{useInitialTheme.js → hooks/useInitialTheme.js} +2 -2
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +54 -0
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
- package/lib/commonjs/index.js +15 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/common.js +2 -0
- package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
- package/lib/commonjs/types/index.js +4 -4
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/mq.js +6 -0
- package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
- package/lib/commonjs/types/unistyles.js +6 -0
- package/lib/commonjs/types/unistyles.js.map +1 -0
- package/lib/commonjs/useStyles.js +7 -4
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +18 -20
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +14 -34
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +89 -0
- package/lib/commonjs/utils/mq.js.map +1 -0
- package/lib/commonjs/utils/mqParser.js +86 -0
- package/lib/commonjs/utils/mqParser.js.map +1 -0
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/{types/cxx.js → common.js} +6 -6
- package/lib/module/common.js.map +1 -0
- package/lib/module/core/UnistyleRegistry.js.map +1 -0
- package/lib/module/{Unistyles.js → core/Unistyles.js} +1 -6
- package/lib/module/core/Unistyles.js.map +1 -0
- package/lib/module/core/UnistylesModule.js.map +1 -0
- package/lib/module/{UnistylesRuntime.js → core/UnistylesRuntime.js} +1 -1
- package/lib/module/core/UnistylesRuntime.js.map +1 -0
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/hooks/index.js +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/{useInitialTheme.js → hooks/useInitialTheme.js} +1 -1
- package/lib/module/hooks/useInitialTheme.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +47 -0
- package/lib/module/hooks/useUnistyles.js.map +1 -0
- package/lib/module/index.js +7 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/mq.js +2 -0
- package/lib/module/types/mq.js.map +1 -0
- package/lib/module/types/unistyles.js +2 -0
- package/lib/module/types/unistyles.js.map +1 -0
- package/lib/module/useStyles.js +6 -3
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +14 -16
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +83 -0
- package/lib/module/utils/mq.js.map +1 -0
- package/lib/module/utils/mqParser.js +79 -0
- package/lib/module/utils/mqParser.js.map +1 -0
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +17 -0
- package/lib/typescript/src/common.d.ts.map +1 -0
- package/lib/typescript/src/{UnistyleRegistry.d.ts → core/UnistyleRegistry.d.ts} +2 -2
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/{Unistyles.d.ts → core/Unistyles.d.ts} +0 -3
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/{UnistylesRuntime.d.ts → core/UnistylesRuntime.d.ts} +6 -6
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +2 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +2 -1
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
- package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -9
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +5 -9
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +3 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +9 -4
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +5 -4
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/mq.d.ts +3 -0
- package/lib/typescript/src/types/mq.d.ts.map +1 -0
- package/lib/typescript/src/types/{cxx.d.ts → unistyles.d.ts} +4 -22
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +8 -6
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -2
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +21 -0
- package/lib/typescript/src/utils/mq.d.ts.map +1 -0
- package/lib/typescript/src/utils/mqParser.d.ts +3 -0
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +18 -0
- package/src/{UnistyleRegistry.ts → core/UnistyleRegistry.ts} +2 -2
- package/src/{Unistyles.ts → core/Unistyles.ts} +2 -9
- package/src/{UnistylesRuntime.ts → core/UnistylesRuntime.ts} +3 -3
- package/src/core/index.ts +1 -0
- package/src/hooks/index.ts +2 -1
- package/src/{useInitialTheme.ts → hooks/useInitialTheme.ts} +2 -2
- package/src/hooks/useUnistyles.ts +55 -0
- package/src/index.ts +10 -7
- package/src/types/breakpoints.ts +6 -11
- package/src/types/common.ts +2 -0
- package/src/types/core.ts +10 -4
- package/src/types/index.ts +5 -9
- package/src/types/mq.ts +3 -0
- package/src/types/{cxx.ts → unistyles.ts} +3 -24
- package/src/useStyles.ts +15 -8
- package/src/utils/breakpoints.ts +13 -12
- package/src/utils/index.ts +2 -8
- package/src/utils/mq.ts +106 -0
- package/src/utils/mqParser.ts +99 -0
- package/src/utils/styles.ts +2 -2
- package/lib/commonjs/UnistyleRegistry.js.map +0 -1
- package/lib/commonjs/Unistyles.js.map +0 -1
- package/lib/commonjs/UnistylesEngine.js +0 -26
- package/lib/commonjs/UnistylesEngine.js.map +0 -1
- package/lib/commonjs/UnistylesModule.js.map +0 -1
- package/lib/commonjs/UnistylesRuntime.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.js +0 -10
- package/lib/commonjs/hooks/useDimensions.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.web.js +0 -34
- package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
- package/lib/commonjs/types/cxx.js.map +0 -1
- package/lib/commonjs/types/mediaQueries.js +0 -2
- package/lib/commonjs/useInitialTheme.js.map +0 -1
- package/lib/commonjs/useUnistyles.js +0 -51
- package/lib/commonjs/useUnistyles.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.js +0 -98
- package/lib/commonjs/utils/mediaQueries.js.map +0 -1
- package/lib/module/UnistyleRegistry.js.map +0 -1
- package/lib/module/Unistyles.js.map +0 -1
- package/lib/module/UnistylesEngine.js +0 -19
- package/lib/module/UnistylesEngine.js.map +0 -1
- package/lib/module/UnistylesModule.js.map +0 -1
- package/lib/module/UnistylesRuntime.js.map +0 -1
- package/lib/module/hooks/useDimensions.js +0 -3
- package/lib/module/hooks/useDimensions.js.map +0 -1
- package/lib/module/hooks/useDimensions.web.js +0 -27
- package/lib/module/hooks/useDimensions.web.js.map +0 -1
- package/lib/module/types/cxx.js.map +0 -1
- package/lib/module/types/mediaQueries.js +0 -2
- package/lib/module/useInitialTheme.js.map +0 -1
- package/lib/module/useUnistyles.js +0 -44
- package/lib/module/useUnistyles.js.map +0 -1
- package/lib/module/utils/mediaQueries.js +0 -85
- package/lib/module/utils/mediaQueries.js.map +0 -1
- package/lib/typescript/src/UnistyleRegistry.d.ts.map +0 -1
- package/lib/typescript/src/Unistyles.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesEngine.d.ts +0 -11
- package/lib/typescript/src/UnistylesEngine.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesModule.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesRuntime.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
- package/lib/typescript/src/types/cxx.d.ts.map +0 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +0 -10
- package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/useInitialTheme.d.ts +0 -3
- package/lib/typescript/src/useInitialTheme.d.ts.map +0 -1
- package/lib/typescript/src/useUnistyles.d.ts +0 -11
- package/lib/typescript/src/useUnistyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +0 -11
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
- package/src/UnistylesEngine.ts +0 -24
- package/src/hooks/useDimensions.ts +0 -4
- package/src/hooks/useDimensions.web.ts +0 -34
- package/src/types/mediaQueries.ts +0 -15
- package/src/useUnistyles.ts +0 -54
- package/src/utils/mediaQueries.ts +0 -152
- /package/lib/commonjs/{UnistyleRegistry.js → core/UnistyleRegistry.js} +0 -0
- /package/lib/commonjs/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
- /package/lib/module/{UnistyleRegistry.js → core/UnistyleRegistry.js} +0 -0
- /package/lib/module/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
- /package/lib/typescript/src/{UnistylesModule.d.ts → core/UnistylesModule.d.ts} +0 -0
- /package/src/{UnistylesModule.ts → core/UnistylesModule.ts} +0 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
import type { NestedKeys, Optional, ScreenSize } from '../types'
|
2
|
+
|
3
|
+
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
4
|
+
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/g
|
5
|
+
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/g
|
6
|
+
|
7
|
+
type ParsedMqDimension = {
|
8
|
+
from: number,
|
9
|
+
to: number
|
10
|
+
}
|
11
|
+
|
12
|
+
type UnistylesParsedMq = {
|
13
|
+
width?: ParsedMqDimension,
|
14
|
+
height?: ParsedMqDimension
|
15
|
+
}
|
16
|
+
|
17
|
+
const parseMq = (mq: string): UnistylesParsedMq => {
|
18
|
+
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
|
19
|
+
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
|
20
|
+
|
21
|
+
return {
|
22
|
+
width: width ? {
|
23
|
+
from: Number(fromW),
|
24
|
+
to: Number(toW)
|
25
|
+
} : undefined,
|
26
|
+
height: height ? {
|
27
|
+
from: Number(fromH),
|
28
|
+
to: Number(toH)
|
29
|
+
} : undefined
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
|
34
|
+
|
35
|
+
const isValidMq = (parsedMq: UnistylesParsedMq) => {
|
36
|
+
const { width, height } = parsedMq
|
37
|
+
|
38
|
+
if (width && height) {
|
39
|
+
return width.from <= width.to && height.from <= height.to
|
40
|
+
}
|
41
|
+
|
42
|
+
if (width) {
|
43
|
+
return width.from <= width.to
|
44
|
+
}
|
45
|
+
|
46
|
+
if (height) {
|
47
|
+
return height.from <= height.to
|
48
|
+
}
|
49
|
+
|
50
|
+
return false
|
51
|
+
}
|
52
|
+
|
53
|
+
const isWithinTheWidthAndHeight = (parsedMq: UnistylesParsedMq, screenSize: ScreenSize): boolean => {
|
54
|
+
const { width, height } = parsedMq
|
55
|
+
|
56
|
+
if (width && height) {
|
57
|
+
return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height)
|
58
|
+
}
|
59
|
+
|
60
|
+
if (width) {
|
61
|
+
return isWithinTheWidth(width, screenSize.width)
|
62
|
+
}
|
63
|
+
|
64
|
+
if (height) {
|
65
|
+
return isWithinTheHeight(height, screenSize.height)
|
66
|
+
}
|
67
|
+
|
68
|
+
return false
|
69
|
+
}
|
70
|
+
|
71
|
+
const isWithinTheWidth = (width: UnistylesParsedMq['width'], screenWidth: number): boolean => {
|
72
|
+
const { from, to } = width as ParsedMqDimension
|
73
|
+
|
74
|
+
return screenWidth >= from && screenWidth <= to
|
75
|
+
}
|
76
|
+
|
77
|
+
const isWithinTheHeight = (height: UnistylesParsedMq['height'], screenHeight: number): boolean => {
|
78
|
+
const { from, to } = height as ParsedMqDimension
|
79
|
+
|
80
|
+
return screenHeight >= from && screenHeight <= to
|
81
|
+
}
|
82
|
+
|
83
|
+
export const getKeyForUnistylesMediaQuery = (mediaQueries: NestedKeys, screenSize: ScreenSize) => {
|
84
|
+
const mq = mediaQueries.find(([key]) => {
|
85
|
+
if (!isUnistylesMq(key as string)) {
|
86
|
+
return false
|
87
|
+
}
|
88
|
+
|
89
|
+
const parsedMq = parseMq(key as string)
|
90
|
+
|
91
|
+
if (!isValidMq(parsedMq)) {
|
92
|
+
return false
|
93
|
+
}
|
94
|
+
|
95
|
+
return isWithinTheWidthAndHeight(parsedMq, screenSize)
|
96
|
+
})
|
97
|
+
|
98
|
+
return mq?.at(0) as Optional<string>
|
99
|
+
}
|
package/src/utils/styles.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { CustomNamedStyles,
|
1
|
+
import type { CustomNamedStyles, ScreenSize, MediaQuery } from '../types'
|
2
2
|
import { getValueForBreakpoint } from './breakpoints'
|
3
3
|
import { normalizeStyles } from './normalizeStyles'
|
4
4
|
import type { UnistylesBreakpoints } from '../global'
|
@@ -60,7 +60,7 @@ export const parseStyle = <T>(
|
|
60
60
|
|
61
61
|
return [
|
62
62
|
key,
|
63
|
-
getValueForBreakpoint(value as Record<keyof UnistylesBreakpoints |
|
63
|
+
getValueForBreakpoint(value as Record<keyof UnistylesBreakpoints | MediaQuery, string | number | undefined>)
|
64
64
|
]
|
65
65
|
})
|
66
66
|
)
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","dangerouslyUnregister","unregister","exports"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":";;;;;;AAGO,MAAMA,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BAAA,GAAAA,gBAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistylesEngine","_UnistyleRegistry","_types","Unistyles","constructor","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","UnistyleRegistry","_runtime","UnistylesRuntime","_engine","UnistylesBuiltInEngine","registry","runtime","engine","unistyles","exports"],"sourceRoot":"../../src","sources":["Unistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,CAAC;EAMZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGC,gCAAe,EAAEC,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACF,WAAW,EAAE;MACd,MAAM,IAAIG,KAAK,CAACC,qBAAc,CAACC,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACJ,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACN,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;IAClE,IAAI,CAACI,OAAO,GAAG,IAAIC,uCAAsB,CAAC,IAAI,CAACL,SAAS,EAAE,IAAI,CAACE,QAAQ,CAAC;EAC5E;EAEA,IAAWI,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACN,SAAS;EACzB;EAEA,IAAWO,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACL,QAAQ;EACxB;EAEA,IAAWM,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACJ,OAAO;EACvB;AACJ;AAEO,MAAMK,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIpB,SAAS,CAAC,CAAC"}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.UnistylesBuiltInEngine = void 0;
|
7
|
-
var _utils = require("./utils");
|
8
|
-
class UnistylesBuiltInEngine {
|
9
|
-
constructor(registry, runtime) {
|
10
|
-
this.registry = registry;
|
11
|
-
this.runtime = runtime;
|
12
|
-
this.registry = registry;
|
13
|
-
this.runtime = runtime;
|
14
|
-
}
|
15
|
-
isMediaQuery = key => {
|
16
|
-
const regex = /(:w|:h)/;
|
17
|
-
return key.length > 0 && regex.test(key);
|
18
|
-
};
|
19
|
-
didMatchMediaQuery = keys => (0, _utils.getKeyForCustomMediaQuery)(keys, this.runtime.screen, this.registry.breakpoints);
|
20
|
-
|
21
|
-
// UnistylesEngine.parseStyleSheet
|
22
|
-
// UnistylesEngine.parseStyle
|
23
|
-
// UnistylesEngine.proxify
|
24
|
-
}
|
25
|
-
exports.UnistylesBuiltInEngine = UnistylesBuiltInEngine;
|
26
|
-
//# sourceMappingURL=UnistylesEngine.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_utils","require","UnistylesBuiltInEngine","constructor","registry","runtime","isMediaQuery","key","regex","length","test","didMatchMediaQuery","keys","getKeyForCustomMediaQuery","screen","breakpoints","exports"],"sourceRoot":"../../src","sources":["UnistylesEngine.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,sBAAsB,CAA4B;EAC3DC,WAAWA,CAASC,QAA0B,EAAUC,OAAyB,EAAE;IAAA,KAA/DD,QAA0B,GAA1BA,QAA0B;IAAA,KAAUC,OAAyB,GAAzBA,OAAyB;IAC7E,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;EAEOC,YAAY,GAAIC,GAAW,IAAK;IACnC,MAAMC,KAAK,GAAG,SAAS;IAEvB,OAAOD,GAAG,CAACE,MAAM,GAAG,CAAC,IAAID,KAAK,CAACE,IAAI,CAACH,GAAG,CAAC;EAC5C,CAAC;EAEMI,kBAAkB,GAAIC,IAAgB,IACzC,IAAAC,gCAAyB,EAACD,IAAI,EAAE,IAAI,CAACP,OAAO,CAACS,MAAM,EAAE,IAAI,CAACV,QAAQ,CAACW,WAAW,CAAC;;EAEnF;EACA;EACA;AACJ;AAACC,OAAA,CAAAd,sBAAA,GAAAA,sBAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","UnistylesModule","exports","NativeModules","Unistyles"],"sourceRoot":"../../src","sources":["UnistylesModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,0BAAa,EAAEC,SAAkC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_types","require","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes","exports"],"sourceRoot":"../../src","sources":["UnistylesRuntime.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,QAA0B,EAAE;IAAA,KAAtED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,QAA0B,GAA1BA,QAA0B;EAAG;EAE3F,IAAWC,WAAWA,CAAA,EA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AO,CAAC,EAAE;MACzB,MAAM,IAAIJ,KAAK,CAACC,qBAAc,CAACM,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAAC3B,QAAQ,CAAC4B,MAAM,CAACJ,OAAO,CAAC;EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC/B,eAAe,CAACgC,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOZ,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACjB,QAAQ,CAAC4B,MAAM;AACpF;AAACI,OAAA,CAAAnC,gBAAA,GAAAA,gBAAA"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.useDimensions = void 0;
|
7
|
-
var _reactNative = require("react-native");
|
8
|
-
const useDimensions = () => (0, _reactNative.useWindowDimensions)();
|
9
|
-
exports.useDimensions = useDimensions;
|
10
|
-
//# sourceMappingURL=useDimensions.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","useDimensions","useWindowDimensions","exports"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGO,MAAMC,aAAa,GAAGA,CAAA,KAAkB,IAAAC,gCAAmB,EAAC,CAAC;AAAAC,OAAA,CAAAF,aAAA,GAAAA,aAAA"}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.useDimensions = void 0;
|
7
|
-
var _react = require("react");
|
8
|
-
const useDimensions = () => {
|
9
|
-
const timerRef = (0, _react.useRef)();
|
10
|
-
const [screenSize, setScreenSize] = (0, _react.useState)({});
|
11
|
-
(0, _react.useLayoutEffect)(() => {
|
12
|
-
setScreenSize({
|
13
|
-
width: window.innerWidth,
|
14
|
-
height: window.innerHeight
|
15
|
-
});
|
16
|
-
}, []);
|
17
|
-
(0, _react.useEffect)(() => {
|
18
|
-
const handleResize = () => {
|
19
|
-
clearTimeout(timerRef.current);
|
20
|
-
timerRef.current = setTimeout(() => setScreenSize({
|
21
|
-
width: window.innerWidth,
|
22
|
-
height: window.innerHeight
|
23
|
-
}), 100);
|
24
|
-
};
|
25
|
-
window.addEventListener('resize', handleResize);
|
26
|
-
return () => {
|
27
|
-
window.removeEventListener('resize', handleResize);
|
28
|
-
clearTimeout(timerRef.current);
|
29
|
-
};
|
30
|
-
}, []);
|
31
|
-
return screenSize;
|
32
|
-
};
|
33
|
-
exports.useDimensions = useDimensions;
|
34
|
-
//# sourceMappingURL=useDimensions.web.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_react","require","useDimensions","timerRef","useRef","screenSize","setScreenSize","useState","useLayoutEffect","width","window","innerWidth","height","innerHeight","useEffect","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener","exports"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAG,IAAAC,aAAM,EAAgC,CAAC;EACxD,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAAa,CAAC,CAAe,CAAC;EAE1E,IAAAC,sBAAe,EAAC,MAAM;IAClBF,aAAa,CAAC;MACVG,KAAK,EAAEC,MAAM,CAACC,UAAU;MACxBC,MAAM,EAAEF,MAAM,CAACG;IACnB,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACb,QAAQ,CAACc,OAAO,CAAC;MAE9Bd,QAAQ,CAACc,OAAO,GAAGC,UAAU,CAAC,MAAMZ,aAAa,CAAC;QAC9CG,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACS,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTL,MAAM,CAACU,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACb,QAAQ,CAACc,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOZ,UAAU;AACrB,CAAC;AAAAgB,OAAA,CAAAnB,aAAA,GAAAA,aAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","exports","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":";;;;;;IAYYA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAyBjBE,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAuBtBC,cAAc,GAAAF,OAAA,CAAAE,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_Unistyles","useInitialTheme","forName","useMemo","unistyles","runtime","setTheme","exports"],"sourceRoot":"../../src","sources":["useInitialTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGO,MAAME,eAAe,GAAIC,OAA8B,IAAK;EAC/D,IAAAC,cAAO,EAAC,MAAMC,oBAAS,CAACC,OAAO,CAACC,QAAQ,CAACJ,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1D,CAAC;AAAAK,OAAA,CAAAN,eAAA,GAAAA,eAAA"}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.useUnistyles = void 0;
|
7
|
-
var _reactNative = require("react-native");
|
8
|
-
var _react = require("react");
|
9
|
-
var _types = require("./types");
|
10
|
-
var _Unistyles = require("./Unistyles");
|
11
|
-
const unistylesEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Unistyles);
|
12
|
-
const useUnistyles = () => {
|
13
|
-
const [orientation, setOrientation] = (0, _react.useState)(_Unistyles.unistyles.runtime.orientation);
|
14
|
-
const [theme, setTheme] = (0, _react.useState)(_Unistyles.unistyles.runtime.getTheme(_Unistyles.unistyles.runtime.themeName));
|
15
|
-
const [breakpoint, setBreakpoint] = (0, _react.useState)(_Unistyles.unistyles.runtime.breakpoint);
|
16
|
-
const [screenSize, setScreenSize] = (0, _react.useState)({
|
17
|
-
width: _Unistyles.unistyles.runtime.screen.width,
|
18
|
-
height: _Unistyles.unistyles.runtime.screen.height
|
19
|
-
});
|
20
|
-
(0, _react.useEffect)(() => {
|
21
|
-
const subscription = unistylesEvents.addListener('onChange', event => {
|
22
|
-
switch (event.type) {
|
23
|
-
case _types.CxxUnistylesEventTypes.Theme:
|
24
|
-
{
|
25
|
-
const themeEvent = event;
|
26
|
-
setTheme(_Unistyles.unistyles.runtime.getTheme(themeEvent.payload.themeName));
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
case _types.CxxUnistylesEventTypes.Layout:
|
30
|
-
{
|
31
|
-
const layoutEvent = event;
|
32
|
-
setBreakpoint(layoutEvent.payload.breakpoint);
|
33
|
-
setOrientation(layoutEvent.payload.orientation);
|
34
|
-
setScreenSize(layoutEvent.payload.screen);
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
default:
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
});
|
41
|
-
return subscription.remove;
|
42
|
-
}, []);
|
43
|
-
return {
|
44
|
-
theme,
|
45
|
-
orientation,
|
46
|
-
breakpoint,
|
47
|
-
screenSize
|
48
|
-
};
|
49
|
-
};
|
50
|
-
exports.useUnistyles = useUnistyles;
|
51
|
-
//# sourceMappingURL=useUnistyles.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_types","_Unistyles","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","orientation","setOrientation","useState","unistyles","runtime","theme","setTheme","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","screen","height","useEffect","subscription","addListener","event","type","CxxUnistylesEventTypes","Theme","themeEvent","payload","Layout","layoutEvent","remove","exports"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAAoBC,oBAAS,CAACC,OAAO,CAACJ,WAAW,CAAC;EAChG,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAJ,eAAQ,EAACC,oBAAS,CAACC,OAAO,CAACG,QAAQ,CAACJ,oBAAS,CAACC,OAAO,CAACI,SAAS,CAAC,CAAC;EAC3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-
});
|
6
|
-
exports.isWithinTheWidthAndHeight = exports.isWithinTheWidth = exports.isWithinTheHeight = exports.isWithinBreakpoint = exports.isMediaQuery = exports.getKeyForCustomMediaQuery = exports.extractValues = void 0;
|
7
|
-
const parseLhs = (lhs, breakpoints, hasRhs) => {
|
8
|
-
const matches = lhs.match(/([([])|([^[\]()]+)|([\])])/g);
|
9
|
-
if (!hasRhs) {
|
10
|
-
const [openBracket, value, closeBracket] = matches;
|
11
|
-
const spacelessValue = value?.trim();
|
12
|
-
const parsedNumber = Number(spacelessValue);
|
13
|
-
const parsedValue = isNaN(parsedNumber) ? breakpoints[spacelessValue] : parsedNumber;
|
14
|
-
return [Number(openBracket === '('), closeBracket === ')' ? parsedValue - 1 : parsedValue];
|
15
|
-
}
|
16
|
-
const [openBracket, value] = matches;
|
17
|
-
if (!value) {
|
18
|
-
return [Number(openBracket === '(')];
|
19
|
-
}
|
20
|
-
const spacelessValue = value?.trim();
|
21
|
-
const parsedNumber = Number(spacelessValue);
|
22
|
-
const parsedValue = isNaN(parsedNumber) ? breakpoints[spacelessValue] : parsedNumber;
|
23
|
-
return openBracket === '(' ? [parsedValue - 1] : [parsedValue];
|
24
|
-
};
|
25
|
-
const parseRhs = (rhs, breakpoints) => {
|
26
|
-
const matches = rhs.match(/([([])|([^[\]()]+)|([\])])/g);
|
27
|
-
const [value, closeBrackets] = matches;
|
28
|
-
const spacelessValue = value.trim();
|
29
|
-
const parsedNumber = Number(spacelessValue);
|
30
|
-
const parsedValue = isNaN(parsedNumber) ? breakpoints[spacelessValue] : parsedNumber;
|
31
|
-
return [closeBrackets === ')' ? parsedValue - 1 : parsedValue];
|
32
|
-
};
|
33
|
-
const extractValues = (pattern, breakpoints) => {
|
34
|
-
const [lhs, rhs] = pattern.replace(/(:w|:h)/g, '').split(',');
|
35
|
-
if (!rhs) {
|
36
|
-
return parseLhs(lhs, breakpoints, false);
|
37
|
-
}
|
38
|
-
const [parsedLhs] = parseLhs(lhs, breakpoints, true);
|
39
|
-
if (parsedLhs === undefined || isNaN(parsedLhs)) {
|
40
|
-
return [];
|
41
|
-
}
|
42
|
-
const [parsedRhs] = parseRhs(rhs, breakpoints);
|
43
|
-
if (parsedRhs === undefined || isNaN(parsedRhs)) {
|
44
|
-
return [];
|
45
|
-
}
|
46
|
-
return [parsedLhs, parsedRhs];
|
47
|
-
};
|
48
|
-
exports.extractValues = extractValues;
|
49
|
-
const isWithinBreakpoint = (query, screenSize, breakpoints) => {
|
50
|
-
const hasWidthBreakpoint = query.includes(':w');
|
51
|
-
const hasHeightBreakpoint = query.includes(':h');
|
52
|
-
if (hasWidthBreakpoint && hasHeightBreakpoint) {
|
53
|
-
return isWithinTheWidthAndHeight(query, screenSize, breakpoints);
|
54
|
-
}
|
55
|
-
if (hasWidthBreakpoint) {
|
56
|
-
return isWithinTheWidth(query, screenSize.width, breakpoints);
|
57
|
-
}
|
58
|
-
if (hasHeightBreakpoint) {
|
59
|
-
return isWithinTheHeight(query, screenSize.height, breakpoints);
|
60
|
-
}
|
61
|
-
return false;
|
62
|
-
};
|
63
|
-
exports.isWithinBreakpoint = isWithinBreakpoint;
|
64
|
-
const isWithinTheWidth = (query, width, breakpoints) => {
|
65
|
-
const [minWidth, maxWidth] = extractValues(query, breakpoints);
|
66
|
-
if (maxWidth && width >= minWidth && width <= maxWidth) {
|
67
|
-
return true;
|
68
|
-
}
|
69
|
-
return !maxWidth && width >= minWidth;
|
70
|
-
};
|
71
|
-
exports.isWithinTheWidth = isWithinTheWidth;
|
72
|
-
const isWithinTheHeight = (query, height, breakpoints) => {
|
73
|
-
const [minHeight, maxHeight] = extractValues(query, breakpoints);
|
74
|
-
if (maxHeight && height >= minHeight && height <= maxHeight) {
|
75
|
-
return true;
|
76
|
-
}
|
77
|
-
return !maxHeight && height >= minHeight;
|
78
|
-
};
|
79
|
-
exports.isWithinTheHeight = isWithinTheHeight;
|
80
|
-
const isWithinTheWidthAndHeight = (query, screenSize, breakpoints) => {
|
81
|
-
const result = query.split(':').filter(Boolean).map(q => isWithinBreakpoint(`:${q}`, screenSize, breakpoints)).filter(Boolean);
|
82
|
-
return result.length === 2;
|
83
|
-
};
|
84
|
-
exports.isWithinTheWidthAndHeight = isWithinTheWidthAndHeight;
|
85
|
-
const isMediaQuery = query => {
|
86
|
-
const regex = /(:w|:h)/;
|
87
|
-
return query.length > 0 && regex.test(query);
|
88
|
-
};
|
89
|
-
exports.isMediaQuery = isMediaQuery;
|
90
|
-
const getKeyForCustomMediaQuery = (mediaQueries, screenSize, breakpoints) => {
|
91
|
-
const [matchedQuery] = mediaQueries.flatMap(_ref => {
|
92
|
-
let [key] = _ref;
|
93
|
-
return isWithinBreakpoint(key, screenSize, breakpoints) ? key : undefined;
|
94
|
-
}).filter(Boolean);
|
95
|
-
return matchedQuery;
|
96
|
-
};
|
97
|
-
exports.getKeyForCustomMediaQuery = getKeyForCustomMediaQuery;
|
98
|
-
//# sourceMappingURL=mediaQueries.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["parseLhs","lhs","breakpoints","hasRhs","matches","match","openBracket","value","closeBracket","spacelessValue","trim","parsedNumber","Number","parsedValue","isNaN","parseRhs","rhs","closeBrackets","extractValues","pattern","replace","split","parsedLhs","undefined","parsedRhs","exports","isWithinBreakpoint","query","screenSize","hasWidthBreakpoint","includes","hasHeightBreakpoint","isWithinTheWidthAndHeight","isWithinTheWidth","width","isWithinTheHeight","height","minWidth","maxWidth","minHeight","maxHeight","result","filter","Boolean","map","q","length","isMediaQuery","regex","test","getKeyForCustomMediaQuery","mediaQueries","matchedQuery","flatMap","_ref","key"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.ts"],"mappings":";;;;;;AAIA,MAAMA,QAAQ,GAAGA,CAACC,GAAW,EAAEC,WAAiC,EAAEC,MAAe,KAAK;EAClF,MAAMC,OAAO,GAAGH,GAAG,CAACI,KAAK,CAAC,6BAA6B,CAAC;EAExD,IAAI,CAACF,MAAM,EAAE;IACT,MAAM,CAACG,WAAW,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CAAE,EAAC,EAAEjB,UAAU,EAAE1B,WAAW,CAAC,CAAC,CAC9DwC,MAAM,CAACC,OAAO,CAAC;EAEpB,OAAOF,MAAM,CAACK,MAAM,KAAK,CAAC;AAC9B,CAAC;AAAArB,OAAA,CAAAO,yBAAA,GAAAA,yBAAA;AAEM,MAAMe,YAAY,GAAIpB,KAAa,IAAc;EACpD,MAAMqB,KAAK,GAAG,SAAS;EAEvB,OAAOrB,KAAK,CAACmB,MAAM,GAAG,CAAC,IAAIE,KAAK,CAACC,IAAI,CAACtB,KAAK,CAAC;AAChD,CAAC;AAAAF,OAAA,CAAAsB,YAAA,GAAAA,YAAA;AAEM,MAAMG,yBAAyB,GAAGA,CACrCC,YAA6F,EAC7FvB,UAAsB,EACtB1B,WAAiC,KACZ;EACrB,MAAM,CAACkD,YAAY,CAAC,GAAGD,YAAY,CAC9BE,OAAO,CAACC,IAAA;IAAA,IAAC,CAACC,GAAG,CAAC,GAAAD,IAAA;IAAA,OAAK5B,kBAAkB,CAAC6B,GAAG,EAAE3B,UAAU,EAAE1B,WAAW,CAAC,GAAGqD,GAAG,GAAGhC,SAAS;EAAA,EAAC,CACtFmB,MAAM,CAACC,OAAO,CAAC;EAEpB,OAAOS,YAAY;AACvB,CAAC;AAAA3B,OAAA,CAAAyB,yBAAA,GAAAA,yBAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","dangerouslyUnregister","unregister"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO,IAAI;EACf,CAAC;EAEME,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACG,eAAe,CAACK,cAAc,CAACR,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMQ,SAAS,GAAIZ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACa,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACd,MAAM,CAACa,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;EAEME,qBAAqB,GAAGA,CAAA,KAAM;IACjC,IAAI,CAACf,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAACC,UAAU,GAAG,EAAE;IACpB,IAAI,CAACC,MAAM,GAAG,CAAC,CAAoB;IACnC,IAAI,CAACC,WAAW,GAAG,CAAC,CAAyB;IAC7C,IAAI,CAACC,qBAAqB,GAAG,EAAE;IAE/B,IAAI,CAACE,eAAe,CAACU,UAAU,CAAC,CAAC;EACrC,CAAC;AACL"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistylesBuiltInEngine","UnistyleRegistry","UnistylesError","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","_runtime","_engine","registry","runtime","engine","unistyles"],"sourceRoot":"../../src","sources":["Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,sBAAsB,QAAQ,mBAAmB;AAC1D,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,SAAS,CAAC;EAMZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGP,eAAe,EAAEQ,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACL,cAAc,CAACM,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIX,gBAAgB,CAAC,IAAI,CAACQ,OAAO,CAAC;IACnD,IAAI,CAACI,QAAQ,GAAG,IAAId,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;IAClE,IAAI,CAACE,OAAO,GAAG,IAAId,sBAAsB,CAAC,IAAI,CAACY,SAAS,EAAE,IAAI,CAACC,QAAQ,CAAC;EAC5E;EAEA,IAAWE,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACH,SAAS;EACzB;EAEA,IAAWI,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACH,QAAQ;EACxB;EAEA,IAAWI,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACH,OAAO;EACvB;AACJ;AAEA,OAAO,MAAMI,SAAS,GAAG,IAAIf,SAAS,CAAC,CAAC"}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { getKeyForCustomMediaQuery } from './utils';
|
2
|
-
export class UnistylesBuiltInEngine {
|
3
|
-
constructor(registry, runtime) {
|
4
|
-
this.registry = registry;
|
5
|
-
this.runtime = runtime;
|
6
|
-
this.registry = registry;
|
7
|
-
this.runtime = runtime;
|
8
|
-
}
|
9
|
-
isMediaQuery = key => {
|
10
|
-
const regex = /(:w|:h)/;
|
11
|
-
return key.length > 0 && regex.test(key);
|
12
|
-
};
|
13
|
-
didMatchMediaQuery = keys => getKeyForCustomMediaQuery(keys, this.runtime.screen, this.registry.breakpoints);
|
14
|
-
|
15
|
-
// UnistylesEngine.parseStyleSheet
|
16
|
-
// UnistylesEngine.parseStyle
|
17
|
-
// UnistylesEngine.proxify
|
18
|
-
}
|
19
|
-
//# sourceMappingURL=UnistylesEngine.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["getKeyForCustomMediaQuery","UnistylesBuiltInEngine","constructor","registry","runtime","isMediaQuery","key","regex","length","test","didMatchMediaQuery","keys","screen","breakpoints"],"sourceRoot":"../../src","sources":["UnistylesEngine.ts"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,SAAS;AAGnD,OAAO,MAAMC,sBAAsB,CAA4B;EAC3DC,WAAWA,CAASC,QAA0B,EAAUC,OAAyB,EAAE;IAAA,KAA/DD,QAA0B,GAA1BA,QAA0B;IAAA,KAAUC,OAAyB,GAAzBA,OAAyB;IAC7E,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;EAEOC,YAAY,GAAIC,GAAW,IAAK;IACnC,MAAMC,KAAK,GAAG,SAAS;IAEvB,OAAOD,GAAG,CAACE,MAAM,GAAG,CAAC,IAAID,KAAK,CAACE,IAAI,CAACH,GAAG,CAAC;EAC5C,CAAC;EAEMI,kBAAkB,GAAIC,IAAgB,IACzCX,yBAAyB,CAACW,IAAI,EAAE,IAAI,CAACP,OAAO,CAACQ,MAAM,EAAE,IAAI,CAACT,QAAQ,CAACU,WAAW,CAAC;;EAEnF;EACA;EACA;AACJ"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../src","sources":["UnistylesModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../src","sources":["UnistylesRuntime.ts"],"mappings":"AAEA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,SAAS;AAG3D,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,QAA0B,EAAE;IAAA,KAAtED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,QAA0B,GAA1BA,QAA0B;EAAG;EAE3F,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,QAAQ,CAACI,qBAAqB;EAC9C;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACN,eAAe,CAACM,SAAS;EACzC;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACP,eAAe,CAACO,UAAU;EAC1C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACT,eAAe,CAACU,WAAW;MACvCC,MAAM,EAAE,IAAI,CAACX,eAAe,CAACY;IACjC,CAAC;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CAAA,KAAkBD,mBAAmB,CAAC,CAAC"}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
2
|
-
export const useDimensions = () => {
|
3
|
-
const timerRef = useRef();
|
4
|
-
const [screenSize, setScreenSize] = useState({});
|
5
|
-
useLayoutEffect(() => {
|
6
|
-
setScreenSize({
|
7
|
-
width: window.innerWidth,
|
8
|
-
height: window.innerHeight
|
9
|
-
});
|
10
|
-
}, []);
|
11
|
-
useEffect(() => {
|
12
|
-
const handleResize = () => {
|
13
|
-
clearTimeout(timerRef.current);
|
14
|
-
timerRef.current = setTimeout(() => setScreenSize({
|
15
|
-
width: window.innerWidth,
|
16
|
-
height: window.innerHeight
|
17
|
-
}), 100);
|
18
|
-
};
|
19
|
-
window.addEventListener('resize', handleResize);
|
20
|
-
return () => {
|
21
|
-
window.removeEventListener('resize', handleResize);
|
22
|
-
clearTimeout(timerRef.current);
|
23
|
-
};
|
24
|
-
}, []);
|
25
|
-
return screenSize;
|
26
|
-
};
|
27
|
-
//# sourceMappingURL=useDimensions.web.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useRef","useState","useDimensions","timerRef","screenSize","setScreenSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAGpE,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAGH,MAAM,CAAgC,CAAC;EACxD,MAAM,CAACI,UAAU,EAAEC,aAAa,CAAC,GAAGJ,QAAQ,CAAa,CAAC,CAAe,CAAC;EAE1EF,eAAe,CAAC,MAAM;IAClBM,aAAa,CAAC;MACVC,KAAK,EAAEC,MAAM,CAACC,UAAU;MACxBC,MAAM,EAAEF,MAAM,CAACG;IACnB,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAENZ,SAAS,CAAC,MAAM;IACZ,MAAMa,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;MAE9BV,QAAQ,CAACU,OAAO,GAAGC,UAAU,CAAC,MAAMT,aAAa,CAAC;QAC9CC,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTJ,MAAM,CAACS,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOT,UAAU;AACrB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":"AAYA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAyB7B,WAAYC,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAuBlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useMemo","unistyles","useInitialTheme","forName","runtime","setTheme"],"sourceRoot":"../../src","sources":["useInitialTheme.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,SAAS,QAAQ,aAAa;AAGvC,OAAO,MAAMC,eAAe,GAAIC,OAA8B,IAAK;EAC/DH,OAAO,CAAC,MAAMC,SAAS,CAACG,OAAO,CAACC,QAAQ,CAACF,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1D,CAAC"}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import { NativeEventEmitter, NativeModules } from 'react-native';
|
2
|
-
import { useEffect, useState } from 'react';
|
3
|
-
import { CxxUnistylesEventTypes } from './types';
|
4
|
-
import { unistyles } from './Unistyles';
|
5
|
-
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
|
6
|
-
export const useUnistyles = () => {
|
7
|
-
const [orientation, setOrientation] = useState(unistyles.runtime.orientation);
|
8
|
-
const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.themeName));
|
9
|
-
const [breakpoint, setBreakpoint] = useState(unistyles.runtime.breakpoint);
|
10
|
-
const [screenSize, setScreenSize] = useState({
|
11
|
-
width: unistyles.runtime.screen.width,
|
12
|
-
height: unistyles.runtime.screen.height
|
13
|
-
});
|
14
|
-
useEffect(() => {
|
15
|
-
const subscription = unistylesEvents.addListener('onChange', event => {
|
16
|
-
switch (event.type) {
|
17
|
-
case CxxUnistylesEventTypes.Theme:
|
18
|
-
{
|
19
|
-
const themeEvent = event;
|
20
|
-
setTheme(unistyles.runtime.getTheme(themeEvent.payload.themeName));
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
case CxxUnistylesEventTypes.Layout:
|
24
|
-
{
|
25
|
-
const layoutEvent = event;
|
26
|
-
setBreakpoint(layoutEvent.payload.breakpoint);
|
27
|
-
setOrientation(layoutEvent.payload.orientation);
|
28
|
-
setScreenSize(layoutEvent.payload.screen);
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
default:
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
});
|
35
|
-
return subscription.remove;
|
36
|
-
}, []);
|
37
|
-
return {
|
38
|
-
theme,
|
39
|
-
orientation,
|
40
|
-
breakpoint,
|
41
|
-
screenSize
|
42
|
-
};
|
43
|
-
};
|
44
|
-
//# sourceMappingURL=useUnistyles.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","CxxUnistylesEventTypes","unistyles","unistylesEvents","Unistyles","useUnistyles","orientation","setOrientation","runtime","theme","setTheme","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","screen","height","subscription","addListener","event","type","Theme","themeEvent","payload","Layout","layoutEvent","remove"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,sBAAsB,QAA2B,SAAS;AACnE,SAASC,SAAS,QAAQ,aAAa;AAEvC,MAAMC,eAAe,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;AAEvE,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGP,QAAQ,CAAoBE,SAAS,CAACM,OAAO,CAACF,WAAW,CAAC;EAChG,MAAM,CAACG,KAAK,EAAEC,QAAQ,CAAC,GAAGV,QAAQ,CAACE,SAAS,CAACM,OAAO,CAACG,QAAQ,CAACT,SAAS,CAACM,OAAO,CAACI,SAAS,CAAC,CAAC;EAC3F,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGd,QAAQ,CAACE,SAAS,CAACM,OAAO,CAACK,UAAU,CAAC;EAC1E,MAAM,CAACE,UAAU,EAAEC,aAAa,CAAC,GAAGhB,QAAQ,CAAC;IACzCiB,KAAK,EAAEf,SAAS,CAACM,OAAO,CAACU,MAAM,CAACD,KAAK;IACrCE,MAAM,EAAEjB,SAAS,CAACM,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