react-native-unistyles 2.0.0-alpha.3 → 2.0.0-alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- package/ios/UnistylesHelpers.h +4 -0
- package/ios/UnistylesHelpers.mm +20 -0
- package/ios/UnistylesModule.h +1 -3
- package/ios/UnistylesModule.mm +55 -65
- package/lib/commonjs/UnistyleRegistry.js +12 -1
- package/lib/commonjs/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/UnistylesRuntime.js +5 -2
- package/lib/commonjs/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/hooks/useDimensions.web.js +7 -5
- package/lib/commonjs/hooks/useDimensions.web.js.map +1 -1
- package/lib/commonjs/index.js +2 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/cxx.js +4 -0
- package/lib/commonjs/types/cxx.js.map +1 -1
- package/lib/commonjs/useInitialTheme.js +1 -1
- package/lib/commonjs/useInitialTheme.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/module/UnistyleRegistry.js +12 -1
- package/lib/module/UnistyleRegistry.js.map +1 -1
- package/lib/module/UnistylesRuntime.js +5 -2
- package/lib/module/UnistylesRuntime.js.map +1 -1
- package/lib/module/hooks/useDimensions.web.js +8 -6
- package/lib/module/hooks/useDimensions.web.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/cxx.js +4 -0
- package/lib/module/types/cxx.js.map +1 -1
- package/lib/module/useInitialTheme.js +2 -2
- package/lib/module/useInitialTheme.js.map +1 -1
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/typescript/src/UnistyleRegistry.d.ts +2 -0
- package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/UnistylesRuntime.d.ts +4 -40
- package/lib/typescript/src/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/global.d.ts +1 -0
- package/lib/typescript/src/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/cxx.d.ts +7 -2
- package/lib/typescript/src/types/cxx.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts +3 -39
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/useUnistyles.d.ts +2 -38
- package/lib/typescript/src/useUnistyles.d.ts.map +1 -1
- package/package.json +12 -13
- package/react-native-unistyles.podspec +2 -1
- package/src/UnistyleRegistry.ts +16 -1
- package/src/UnistylesRuntime.ts +6 -2
- package/src/global.ts +3 -1
- package/src/hooks/useDimensions.web.ts +9 -6
- package/src/index.ts +2 -0
- package/src/types/cxx.ts +9 -2
- package/src/useInitialTheme.ts +2 -2
- package/src/utils/breakpoints.ts +1 -1
- package/ios/UnistylesRuntime.h +0 -48
- package/ios/UnistylesRuntime.mm +0 -228
- package/lib/typescript/examples/expo/src/App.d.ts +0 -3
- package/lib/typescript/examples/expo/src/App.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Cxx.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Cxx.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/index.d.ts +0 -2
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/index.d.ts +0 -2
- package/lib/typescript/examples/expo/src/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +0 -8
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/index.d.ts +0 -16
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +0 -40
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +0 -1
@@ -3,6 +3,7 @@ import type { UnistylesThemes, UnistylesBreakpoints } from './global';
|
|
3
3
|
export declare class UnistyleRegistry {
|
4
4
|
private unistylesBridge;
|
5
5
|
config: UnistylesConfig;
|
6
|
+
themeNames: Array<keyof UnistylesThemes>;
|
6
7
|
themes: UnistylesThemes;
|
7
8
|
breakpoints: UnistylesBreakpoints;
|
8
9
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
|
@@ -10,5 +11,6 @@ export declare class UnistyleRegistry {
|
|
10
11
|
addThemes: (themes: UnistylesThemes) => this;
|
11
12
|
addBreakpoints: (breakpoints: UnistylesBreakpoints) => this;
|
12
13
|
addConfig: (config: UnistylesConfig) => this;
|
14
|
+
dangerouslyUnregister: () => void;
|
13
15
|
}
|
14
16
|
//# sourceMappingURL=UnistyleRegistry.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../src/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAErE,qBAAa,gBAAgB;
|
1
|
+
{"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../src/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAErE,qBAAa,gBAAgB;IAOb,OAAO,CAAC,eAAe;IAN5B,MAAM,EAAE,eAAe,CAAK;IAC5B,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe,UAS1C;IAEM,cAAc,gBAAiB,oBAAoB,UAKzD;IAEM,SAAS,WAAY,eAAe,UAQ1C;IAEM,qBAAqB,aAQ3B;CACJ"}
|
@@ -8,52 +8,16 @@ export declare class UnistylesRuntime {
|
|
8
8
|
constructor(unistylesBridge: UnistylesBridge, registry: UnistyleRegistry);
|
9
9
|
get colorScheme(): import("./types").ColorSchemeName;
|
10
10
|
get hasAdaptiveThemes(): boolean;
|
11
|
-
get sortedBreakpoints(): [
|
12
|
-
get themeName():
|
13
|
-
get breakpoint():
|
11
|
+
get sortedBreakpoints(): ["default", 0 | undefined][];
|
12
|
+
get themeName(): never;
|
13
|
+
get breakpoint(): "default";
|
14
14
|
get screen(): {
|
15
15
|
width: number;
|
16
16
|
height: number;
|
17
17
|
};
|
18
18
|
get orientation(): ScreenOrientation;
|
19
19
|
setTheme: (name: keyof UnistylesThemes) => boolean;
|
20
|
-
getTheme: (forName: keyof UnistylesThemes) =>
|
21
|
-
colors: {
|
22
|
-
backgroundColor: string;
|
23
|
-
typography: string;
|
24
|
-
accent: string;
|
25
|
-
barbie: string;
|
26
|
-
oak: string;
|
27
|
-
sky: string;
|
28
|
-
fog: string;
|
29
|
-
aloes: string;
|
30
|
-
blood: string;
|
31
|
-
};
|
32
|
-
} | {
|
33
|
-
colors: {
|
34
|
-
backgroundColor: string;
|
35
|
-
typography: string;
|
36
|
-
accent: string;
|
37
|
-
barbie: string;
|
38
|
-
oak: string;
|
39
|
-
sky: string;
|
40
|
-
fog: string;
|
41
|
-
aloes: string;
|
42
|
-
blood: string;
|
43
|
-
};
|
44
|
-
} | {
|
45
|
-
colors: {
|
46
|
-
backgroundColor: string;
|
47
|
-
typography: string;
|
48
|
-
accent: string;
|
49
|
-
barbie: string;
|
50
|
-
oak: string;
|
51
|
-
sky: string;
|
52
|
-
fog: string;
|
53
|
-
aloes: string;
|
54
|
-
blood: string;
|
55
|
-
};
|
56
|
-
};
|
20
|
+
getTheme: (forName: keyof UnistylesThemes) => never;
|
57
21
|
setAdaptiveThemes: (enable: boolean) => void;
|
58
22
|
private hasTheme;
|
59
23
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../src/UnistylesRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAkB,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,QAAQ;gBAAlD,eAAe,EAAE,eAAe,EAAU,QAAQ,EAAE,gBAAgB;IAExF,IAAW,WAAW,sCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,iBAAiB,
|
1
|
+
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../src/UnistylesRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAkB,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,QAAQ;gBAAlD,eAAe,EAAE,eAAe,EAAU,QAAQ,EAAE,gBAAgB;IAExF,IAAW,WAAW,sCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,iBAAiB,iCAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,cAEpB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,sBAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,aAQ7C;IAEM,QAAQ,YAAa,MAAM,eAAe,WAUhD;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAED,OAAO,CAAC,QAAQ,CAAgE;CACnF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/global.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;CAAG;AACnC,MAAM,WAAW,oBAAoB;
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/global.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;CAAG;AACnC,MAAM,WAAW,oBAAoB;IACjC,OAAO,CAAC,EAAE,CAAC,CAAA;CACd"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDimensions.web.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"useDimensions.web.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,aAAa,QAAO,UA8BhC,CAAA"}
|
@@ -9,6 +9,7 @@ declare const UnistylesRegistry: {
|
|
9
9
|
addBreakpoints: (breakpoints: UnistylesBreakpoints) => import("./UnistyleRegistry").UnistyleRegistry;
|
10
10
|
addConfig: (config: import("./types").UnistylesConfig) => import("./UnistyleRegistry").UnistyleRegistry;
|
11
11
|
};
|
12
|
+
export declare const __dangerouslyUnregister: () => void;
|
12
13
|
export { UnistylesRuntime, UnistylesRegistry };
|
13
14
|
export { ScreenOrientation };
|
14
15
|
export type { UnistylesThemes, UnistylesBreakpoints };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,QAAA,MAAM,gBAAgB,+CAAoB,CAAA;AAC1C,QAAA,MAAM,iBAAiB;;;;CAItB,CAAA;AAED,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACpB,CAAA;AAED,OAAO,EACH,iBAAiB,EACpB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACvB,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,QAAA,MAAM,gBAAgB,+CAAoB,CAAA;AAC1C,QAAA,MAAM,iBAAiB;;;;CAItB,CAAA;AAED,eAAO,MAAM,uBAAuB,YAA2C,CAAA;AAE/E,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACpB,CAAA;AAED,OAAO,EACH,iBAAiB,EACpB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACvB,CAAA"}
|
@@ -12,7 +12,7 @@ export type UnistylesBridge = {
|
|
12
12
|
screenWidth: number;
|
13
13
|
screenHeight: number;
|
14
14
|
hasAdaptiveThemes: boolean;
|
15
|
-
|
15
|
+
themeName: keyof UnistylesThemes;
|
16
16
|
breakpoint: keyof UnistylesBreakpoints;
|
17
17
|
colorScheme: ColorSchemeName;
|
18
18
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
|
@@ -20,6 +20,7 @@ export type UnistylesBridge = {
|
|
20
20
|
useBreakpoints(breakpoints: UnistylesBreakpoints): void;
|
21
21
|
useTheme(name: keyof UnistylesThemes): void;
|
22
22
|
useAdaptiveThemes(enable: boolean): void;
|
23
|
+
unregister(): void;
|
23
24
|
};
|
24
25
|
export declare enum CxxUnistylesEventTypes {
|
25
26
|
Theme = "theme",
|
@@ -48,6 +49,10 @@ export type CxxUnistylesBreakpointEvent = {
|
|
48
49
|
export type UnistylesEvents = CxxUnistylesThemeEvent | CxxUnistylesSizeEvent | CxxUnistylesBreakpointEvent;
|
49
50
|
export declare enum UnistylesError {
|
50
51
|
RuntimeUnavailable = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE",
|
51
|
-
ThemeNotFound = "UNISTYLES_ERROR_THEME_NOT_FOUND"
|
52
|
+
ThemeNotFound = "UNISTYLES_ERROR_THEME_NOT_FOUND",
|
53
|
+
ThemeNotRegistered = "UNISTYLES_ERROR_THEME_NOT_REGISTERED",
|
54
|
+
ThemesCannotBeEmpty = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY",
|
55
|
+
BreakpointsCannotBeEmpty = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY",
|
56
|
+
BreakpointsMustStartFromZero = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO"
|
52
57
|
}
|
53
58
|
//# sourceMappingURL=cxx.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cxx.d.ts","sourceRoot":"","sources":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
2
|
import type { UnistylesThemes } from './global';
|
3
3
|
type T = UnistylesThemes[keyof UnistylesThemes];
|
4
|
-
export declare const useStyles: <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST,
|
5
|
-
theme:
|
6
|
-
|
7
|
-
backgroundColor: string;
|
8
|
-
typography: string;
|
9
|
-
accent: string;
|
10
|
-
barbie: string;
|
11
|
-
oak: string;
|
12
|
-
sky: string;
|
13
|
-
fog: string;
|
14
|
-
aloes: string;
|
15
|
-
blood: string;
|
16
|
-
};
|
17
|
-
} | {
|
18
|
-
colors: {
|
19
|
-
backgroundColor: string;
|
20
|
-
typography: string;
|
21
|
-
accent: string;
|
22
|
-
barbie: string;
|
23
|
-
oak: string;
|
24
|
-
sky: string;
|
25
|
-
fog: string;
|
26
|
-
aloes: string;
|
27
|
-
blood: string;
|
28
|
-
};
|
29
|
-
} | {
|
30
|
-
colors: {
|
31
|
-
backgroundColor: string;
|
32
|
-
typography: string;
|
33
|
-
accent: string;
|
34
|
-
barbie: string;
|
35
|
-
oak: string;
|
36
|
-
sky: string;
|
37
|
-
fog: string;
|
38
|
-
aloes: string;
|
39
|
-
blood: string;
|
40
|
-
};
|
41
|
-
};
|
42
|
-
breakpoint: "xs" | "sm" | "md" | "lg" | "xl";
|
4
|
+
export declare const useStyles: <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, never> | undefined) => {
|
5
|
+
theme: never;
|
6
|
+
breakpoint: "default";
|
43
7
|
styles: ExtractBreakpoints<RemoveKeysWithPrefix<ST>>;
|
44
8
|
};
|
45
9
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE/G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG/C,KAAK,CAAC,GAAG,eAAe,CAAC,MAAM,eAAe,CAAC,CAAA;AAE/C,eAAO,MAAM,SAAS
|
1
|
+
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE/G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG/C,KAAK,CAAC,GAAG,eAAe,CAAC,MAAM,eAAe,CAAC,CAAA;AAE/C,eAAO,MAAM,SAAS;;;;CAsCrB,CAAA"}
|
@@ -1,42 +1,6 @@
|
|
1
1
|
export declare const useUnistyles: () => {
|
2
|
-
theme:
|
3
|
-
|
4
|
-
backgroundColor: string;
|
5
|
-
typography: string;
|
6
|
-
accent: string;
|
7
|
-
barbie: string;
|
8
|
-
oak: string;
|
9
|
-
sky: string;
|
10
|
-
fog: string;
|
11
|
-
aloes: string;
|
12
|
-
blood: string;
|
13
|
-
};
|
14
|
-
} | {
|
15
|
-
colors: {
|
16
|
-
backgroundColor: string;
|
17
|
-
typography: string;
|
18
|
-
accent: string;
|
19
|
-
barbie: string;
|
20
|
-
oak: string;
|
21
|
-
sky: string;
|
22
|
-
fog: string;
|
23
|
-
aloes: string;
|
24
|
-
blood: string;
|
25
|
-
};
|
26
|
-
} | {
|
27
|
-
colors: {
|
28
|
-
backgroundColor: string;
|
29
|
-
typography: string;
|
30
|
-
accent: string;
|
31
|
-
barbie: string;
|
32
|
-
oak: string;
|
33
|
-
sky: string;
|
34
|
-
fog: string;
|
35
|
-
aloes: string;
|
36
|
-
blood: string;
|
37
|
-
};
|
38
|
-
};
|
39
|
-
breakpoint: "xs" | "sm" | "md" | "lg" | "xl";
|
2
|
+
theme: never;
|
3
|
+
breakpoint: "default";
|
40
4
|
screenSize: {
|
41
5
|
width: number;
|
42
6
|
height: number;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../src/useUnistyles.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY
|
1
|
+
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../src/useUnistyles.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;CAoDxB,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "2.0.0-alpha.
|
3
|
+
"version": "2.0.0-alpha.4",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -41,25 +41,24 @@
|
|
41
41
|
"registry": "https://registry.npmjs.org/"
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
44
|
-
"@commitlint/config-conventional": "
|
44
|
+
"@commitlint/config-conventional": "18.1.0",
|
45
45
|
"@react-native/eslint-config": "0.74.0",
|
46
46
|
"@react-native/normalize-colors": "0.74.1",
|
47
47
|
"@release-it/conventional-changelog": "7.0.2",
|
48
48
|
"@testing-library/react-hooks": "8.0.1",
|
49
|
-
"@types/jest": "29.5.
|
50
|
-
"@types/react": "18.2.
|
51
|
-
"@
|
52
|
-
"@typescript-eslint/eslint-plugin": "6.
|
53
|
-
"@typescript-eslint/
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"eslint": "8.51.0",
|
49
|
+
"@types/jest": "29.5.7",
|
50
|
+
"@types/react": "18.2.34",
|
51
|
+
"@typescript-eslint/eslint-plugin": "6.9.1",
|
52
|
+
"@typescript-eslint/eslint-plugin-tslint": "6.9.1",
|
53
|
+
"@typescript-eslint/parser": "6.9.1",
|
54
|
+
"commitlint": "18.2.0",
|
55
|
+
"concurrently": "8.2.2",
|
56
|
+
"eslint": "8.53.0",
|
58
57
|
"eslint-config-codemask": "1.1.7",
|
59
58
|
"eslint-plugin-functional": "6.0.0",
|
60
|
-
"eslint-plugin-import": "2.
|
59
|
+
"eslint-plugin-import": "2.29.0",
|
61
60
|
"eslint-plugin-jsdoc": "46.8.2",
|
62
|
-
"eslint-plugin-jsx-a11y": "6.
|
61
|
+
"eslint-plugin-jsx-a11y": "6.8.0",
|
63
62
|
"eslint-plugin-nested-if": "1.0.0",
|
64
63
|
"eslint-plugin-no-else": "0.2.2",
|
65
64
|
"eslint-plugin-no-loops": "0.3.0",
|
package/src/UnistyleRegistry.ts
CHANGED
@@ -3,6 +3,7 @@ import type { UnistylesThemes, UnistylesBreakpoints } from './global'
|
|
3
3
|
|
4
4
|
export class UnistyleRegistry {
|
5
5
|
public config: UnistylesConfig = {}
|
6
|
+
public themeNames: Array<keyof UnistylesThemes> = []
|
6
7
|
public themes: UnistylesThemes = {} as UnistylesThemes
|
7
8
|
public breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
|
8
9
|
public sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]> = []
|
@@ -11,7 +12,11 @@ export class UnistyleRegistry {
|
|
11
12
|
|
12
13
|
public addThemes = (themes: UnistylesThemes) => {
|
13
14
|
this.themes = themes
|
14
|
-
|
15
|
+
|
16
|
+
const keys = Object.keys(themes) as Array<keyof UnistylesThemes>
|
17
|
+
|
18
|
+
this.unistylesBridge.themes = keys
|
19
|
+
this.themeNames = keys
|
15
20
|
|
16
21
|
return this
|
17
22
|
}
|
@@ -32,4 +37,14 @@ export class UnistyleRegistry {
|
|
32
37
|
|
33
38
|
return this
|
34
39
|
}
|
40
|
+
|
41
|
+
public dangerouslyUnregister = () => {
|
42
|
+
this.config = {}
|
43
|
+
this.themeNames = []
|
44
|
+
this.themes = {} as UnistylesThemes
|
45
|
+
this.breakpoints = {} as UnistylesBreakpoints
|
46
|
+
this.sortedBreakpointPairs = []
|
47
|
+
|
48
|
+
this.unistylesBridge.unregister()
|
49
|
+
}
|
35
50
|
}
|
package/src/UnistylesRuntime.ts
CHANGED
@@ -19,7 +19,7 @@ export class UnistylesRuntime {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
public get themeName() {
|
22
|
-
return this.unistylesBridge.
|
22
|
+
return this.unistylesBridge.themeName
|
23
23
|
}
|
24
24
|
|
25
25
|
public get breakpoint() {
|
@@ -50,10 +50,14 @@ export class UnistylesRuntime {
|
|
50
50
|
return true
|
51
51
|
}
|
52
52
|
|
53
|
-
|
53
|
+
throw new Error(UnistylesError.ThemeNotRegistered)
|
54
54
|
}
|
55
55
|
|
56
56
|
public getTheme = (forName: keyof UnistylesThemes) => {
|
57
|
+
if (this.registry.themeNames.length === 0) {
|
58
|
+
return {} as UnistylesThemes[keyof UnistylesThemes]
|
59
|
+
}
|
60
|
+
|
57
61
|
if (!this.hasTheme(forName)) {
|
58
62
|
throw new Error(UnistylesError.ThemeNotFound)
|
59
63
|
}
|
package/src/global.ts
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
import { useEffect, useRef, useState } from 'react'
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
2
2
|
import type { ScreenSize } from '../types'
|
3
|
-
import { isServer } from '../utils'
|
4
3
|
|
5
4
|
export const useDimensions = (): ScreenSize => {
|
6
5
|
const timerRef = useRef<ReturnType<typeof setTimeout>>()
|
7
|
-
const [screenSize, setScreenSize] = useState<ScreenSize>({
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
const [screenSize, setScreenSize] = useState<ScreenSize>({} as ScreenSize)
|
7
|
+
|
8
|
+
useLayoutEffect(() => {
|
9
|
+
setScreenSize({
|
10
|
+
width: window.innerWidth,
|
11
|
+
height: window.innerHeight
|
12
|
+
})
|
13
|
+
}, [])
|
11
14
|
|
12
15
|
useEffect(() => {
|
13
16
|
const handleResize = () => {
|
package/src/index.ts
CHANGED
package/src/types/cxx.ts
CHANGED
@@ -17,7 +17,7 @@ export type UnistylesBridge = {
|
|
17
17
|
screenWidth: number,
|
18
18
|
screenHeight: number,
|
19
19
|
hasAdaptiveThemes: boolean,
|
20
|
-
|
20
|
+
themeName: keyof UnistylesThemes,
|
21
21
|
breakpoint: keyof UnistylesBreakpoints,
|
22
22
|
colorScheme: ColorSchemeName,
|
23
23
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>,
|
@@ -27,6 +27,9 @@ export type UnistylesBridge = {
|
|
27
27
|
useBreakpoints(breakpoints: UnistylesBreakpoints): void,
|
28
28
|
useTheme(name: keyof UnistylesThemes): void,
|
29
29
|
useAdaptiveThemes(enable: boolean): void,
|
30
|
+
|
31
|
+
// other
|
32
|
+
unregister(): void
|
30
33
|
}
|
31
34
|
|
32
35
|
export enum CxxUnistylesEventTypes {
|
@@ -61,5 +64,9 @@ export type UnistylesEvents = CxxUnistylesThemeEvent | CxxUnistylesSizeEvent | C
|
|
61
64
|
|
62
65
|
export enum UnistylesError {
|
63
66
|
RuntimeUnavailable = 'UNISTYLES_ERROR_RUNTIME_UNAVAILABLE',
|
64
|
-
ThemeNotFound = 'UNISTYLES_ERROR_THEME_NOT_FOUND'
|
67
|
+
ThemeNotFound = 'UNISTYLES_ERROR_THEME_NOT_FOUND',
|
68
|
+
ThemeNotRegistered = 'UNISTYLES_ERROR_THEME_NOT_REGISTERED',
|
69
|
+
ThemesCannotBeEmpty = 'UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY',
|
70
|
+
BreakpointsCannotBeEmpty = 'UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY',
|
71
|
+
BreakpointsMustStartFromZero = 'UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO',
|
65
72
|
}
|
package/src/useInitialTheme.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { useMemo } from 'react'
|
2
2
|
import { unistyles } from './Unistyles'
|
3
3
|
import type { UnistylesThemes } from './global'
|
4
4
|
|
5
5
|
export const useInitialTheme = (forName: keyof UnistylesThemes) => {
|
6
|
-
|
6
|
+
useMemo(() => unistyles.runtime.setTheme(forName), [])
|
7
7
|
}
|
package/src/utils/breakpoints.ts
CHANGED
@@ -66,7 +66,7 @@ export const sortAndValidateBreakpoints = (breakpoints: UnistylesBreakpoints): U
|
|
66
66
|
export const getBreakpointFromScreenWidth = (width: number, breakpointEntries: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>): keyof UnistylesBreakpoints & string => {
|
67
67
|
const [key] = breakpointEntries
|
68
68
|
.find(([, value], index, otherBreakpoints) => {
|
69
|
-
const minVal = value
|
69
|
+
const minVal = value as number
|
70
70
|
const maxVal = otherBreakpoints[index + 1]?.[1]
|
71
71
|
|
72
72
|
if (!maxVal) {
|
package/ios/UnistylesRuntime.h
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#import "UnistylesModule.h"
|
4
|
-
#import <jsi/jsi.h>
|
5
|
-
#import <vector>
|
6
|
-
|
7
|
-
using namespace facebook;
|
8
|
-
|
9
|
-
class JSI_EXPORT UnistylesRuntime : public jsi::HostObject {
|
10
|
-
private:
|
11
|
-
UnistylesThemeChangeEvent onThemeChange;
|
12
|
-
UnistylesBreakpointChangeEvent onBreakpointChange;
|
13
|
-
|
14
|
-
int screenWidth;
|
15
|
-
int screenHeight;
|
16
|
-
std::string colorScheme;
|
17
|
-
|
18
|
-
public:
|
19
|
-
UnistylesRuntime(
|
20
|
-
UnistylesThemeChangeEvent onThemeChange,
|
21
|
-
UnistylesBreakpointChangeEvent onBreakpointChange,
|
22
|
-
float screenWidth,
|
23
|
-
float screenHeight,
|
24
|
-
std::string colorScheme
|
25
|
-
): onThemeChange(onThemeChange),
|
26
|
-
onBreakpointChange(onBreakpointChange),
|
27
|
-
screenWidth(screenWidth),
|
28
|
-
screenHeight(screenHeight),
|
29
|
-
colorScheme(colorScheme) {}
|
30
|
-
|
31
|
-
bool hasAdaptiveThemes;
|
32
|
-
bool supportsAutomaticColorScheme;
|
33
|
-
|
34
|
-
std::string theme;
|
35
|
-
std::string breakpoint;
|
36
|
-
std::vector<std::string> themes;
|
37
|
-
std::vector<std::pair<std::string, double>> sortedBreakpointEntries;
|
38
|
-
|
39
|
-
jsi::Value get(jsi::Runtime&, const jsi::PropNameID& name) override;
|
40
|
-
void set(jsi::Runtime& runtime, const jsi::PropNameID& propNameId, const jsi::Value& value) override;
|
41
|
-
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override;
|
42
|
-
|
43
|
-
void handleScreenSizeChange(int width, int height);
|
44
|
-
void handleAppearanceChange(std::string colorScheme);
|
45
|
-
|
46
|
-
jsi::Value getThemeOrFail(jsi::Runtime&);
|
47
|
-
std::string getBreakpointFromScreenWidth(double width, const std::vector<std::pair<std::string, double>>& sortedBreakpointEntries);
|
48
|
-
};
|