react-native-unistyles 2.0.0-alpha.2 → 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 +2 -2
- package/ios/UnistylesModule.mm +83 -38
- package/lib/commonjs/UnistyleRegistry.js +15 -7
- package/lib/commonjs/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/UnistylesRuntime.js +29 -15
- 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 +4 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/cxx.js +9 -5
- 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/useUnistyles.js +5 -7
- package/lib/commonjs/useUnistyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/module/UnistyleRegistry.js +15 -7
- package/lib/module/UnistyleRegistry.js.map +1 -1
- package/lib/module/UnistylesRuntime.js +30 -16
- 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 +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/cxx.js +8 -4
- 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/useUnistyles.js +5 -7
- package/lib/module/useUnistyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/typescript/src/UnistyleRegistry.d.ts +3 -2
- package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/UnistylesRuntime.d.ts +14 -46
- 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 +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/cxx.d.ts +21 -13
- 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 +19 -8
- package/src/UnistylesRuntime.ts +31 -16
- package/src/global.ts +3 -1
- package/src/hooks/useDimensions.web.ts +9 -6
- package/src/index.ts +4 -2
- package/src/types/cxx.ts +25 -14
- package/src/useInitialTheme.ts +2 -2
- package/src/useUnistyles.ts +5 -6
- package/src/utils/breakpoints.ts +1 -1
- package/ios/UnistylesRuntime.h +0 -30
- package/ios/UnistylesRuntime.mm +0 -191
- 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
@@ -0,0 +1,20 @@
|
|
1
|
+
#import "UnistylesHelpers.h"
|
2
|
+
#import "UnistylesRuntime.h"
|
3
|
+
|
4
|
+
std::string getColorScheme() {
|
5
|
+
UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
|
6
|
+
|
7
|
+
switch (colorScheme) {
|
8
|
+
case UIUserInterfaceStyleLight:
|
9
|
+
return UnistylesLightScheme;
|
10
|
+
case UIUserInterfaceStyleDark:
|
11
|
+
return UnistylesDarkScheme;
|
12
|
+
case UIUserInterfaceStyleUnspecified:
|
13
|
+
default:
|
14
|
+
return UnistylesUnspecifiedScheme;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
NSString* cxxStringToNSString(std::string cxxString) {
|
19
|
+
return [NSString stringWithUTF8String:cxxString.c_str()];
|
20
|
+
}
|
package/ios/UnistylesModule.h
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
2
2
|
#import <React/RCTEventEmitter.h>
|
3
|
-
|
4
|
-
typedef void(^UnistylesEventHandler)(NSDictionary *);
|
3
|
+
#import <string>
|
5
4
|
|
6
5
|
@interface UnistylesModule : RCTEventEmitter<RCTBridgeModule>
|
7
6
|
|
7
|
+
@property (nonatomic, assign) BOOL hasListeners;
|
8
8
|
@property (nonatomic, assign) void* unistylesRuntime;
|
9
9
|
|
10
10
|
@end
|
package/ios/UnistylesModule.mm
CHANGED
@@ -1,47 +1,85 @@
|
|
1
1
|
#import "UnistylesModule.h"
|
2
|
+
#import "UnistylesHelpers.h"
|
2
3
|
#import "UnistylesRuntime.h"
|
3
4
|
|
5
|
+
#import <React/RCTAppearance.h>
|
4
6
|
#import <React/RCTBridge+Private.h>
|
5
|
-
#import <React/RCTUtils.h>
|
6
7
|
#import <jsi/jsi.h>
|
7
8
|
|
8
|
-
@implementation UnistylesModule
|
9
|
-
|
10
|
-
BOOL hasListeners;
|
11
|
-
|
12
9
|
using namespace facebook;
|
13
10
|
|
11
|
+
@implementation UnistylesModule
|
12
|
+
|
14
13
|
RCT_EXPORT_MODULE(Unistyles)
|
15
14
|
|
15
|
+
#pragma mark - Lifecycle
|
16
|
+
|
16
17
|
- (instancetype)init {
|
17
18
|
if ((self = [super init])) {
|
18
19
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
19
20
|
selector:@selector(handleOrientationChange:)
|
20
21
|
name:UIDeviceOrientationDidChangeNotification
|
21
22
|
object:nil];
|
23
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
24
|
+
selector:@selector(appearanceChanged:)
|
25
|
+
name:RCTUserInterfaceStyleDidChangeNotification
|
26
|
+
object:nil];
|
22
27
|
}
|
28
|
+
|
23
29
|
return self;
|
24
30
|
}
|
25
31
|
|
32
|
+
- (void)dealloc {
|
33
|
+
if (self.unistylesRuntime != nullptr) {
|
34
|
+
delete (UnistylesRuntime*)self.unistylesRuntime;
|
35
|
+
}
|
36
|
+
|
37
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
+ (BOOL)requiresMainQueueSetup {
|
42
|
+
return YES;
|
43
|
+
}
|
44
|
+
|
45
|
+
#pragma mark - Event handlers
|
46
|
+
|
26
47
|
- (void)handleOrientationChange:(NSNotification *)notification {
|
27
48
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
28
49
|
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
|
29
50
|
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
|
30
51
|
|
31
|
-
((UnistylesRuntime*)self.unistylesRuntime)->
|
52
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight);
|
32
53
|
});
|
33
54
|
}
|
34
55
|
|
35
|
-
- (void)
|
36
|
-
|
37
|
-
|
56
|
+
- (void)appearanceChanged:(NSNotification *)notification {
|
57
|
+
std::string colorScheme = getColorScheme();
|
58
|
+
|
59
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
|
38
60
|
}
|
39
61
|
|
40
|
-
|
41
|
-
{
|
42
|
-
|
62
|
+
#pragma mark - Event emitter
|
63
|
+
- (NSArray<NSString *> *)supportedEvents {
|
64
|
+
return @[@"onChange"];
|
65
|
+
}
|
66
|
+
|
67
|
+
- (void)startObserving {
|
68
|
+
self.hasListeners = YES;
|
69
|
+
}
|
70
|
+
|
71
|
+
- (void)stopObserving {
|
72
|
+
self.hasListeners = NO;
|
43
73
|
}
|
44
74
|
|
75
|
+
- (void)emitEvent:(NSString *)eventName withBody:(NSDictionary *)body {
|
76
|
+
if (self.hasListeners) {
|
77
|
+
[self sendEventWithName:@"onChange" body:body];
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
#pragma mark - Core
|
82
|
+
|
45
83
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
46
84
|
{
|
47
85
|
NSLog(@"Installing Unistyles 🦄...");
|
@@ -50,13 +88,13 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
|
50
88
|
RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
|
51
89
|
|
52
90
|
if (cxxBridge == nil) {
|
53
|
-
|
91
|
+
return @false;
|
54
92
|
}
|
55
93
|
|
56
94
|
auto jsiRuntime = (jsi::Runtime*)cxxBridge.runtime;
|
57
95
|
|
58
96
|
if (jsiRuntime == nil) {
|
59
|
-
|
97
|
+
return @false;
|
60
98
|
}
|
61
99
|
|
62
100
|
auto& runtime = *jsiRuntime;
|
@@ -69,40 +107,47 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
|
69
107
|
return @true;
|
70
108
|
}
|
71
109
|
|
72
|
-
- (NSArray<NSString *> *)supportedEvents {
|
73
|
-
return @[@"onChange"];
|
74
|
-
}
|
75
|
-
|
76
|
-
- (void)startObserving
|
77
|
-
{
|
78
|
-
hasListeners = YES;
|
79
|
-
}
|
80
|
-
|
81
|
-
- (void)stopObserving
|
82
|
-
{
|
83
|
-
hasListeners = NO;
|
84
|
-
}
|
85
|
-
|
86
|
-
- (void)emitEvent:(NSString *)eventName withBody:(NSDictionary *)body {
|
87
|
-
if (hasListeners) {
|
88
|
-
[self sendEventWithName:@"onChange" body:body];
|
89
|
-
}
|
90
|
-
}
|
91
110
|
|
92
111
|
void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSelf) {
|
93
112
|
CGFloat initialScreenWidth = [UIScreen mainScreen].bounds.size.width;
|
94
113
|
CGFloat initialScreenHeight = [UIScreen mainScreen].bounds.size.height;
|
95
|
-
|
114
|
+
std::string initialColorScheme = getColorScheme();
|
115
|
+
UnistylesThemeChangeEvent onThemeChange = ^(std::string theme) {
|
116
|
+
NSDictionary *body = @{
|
117
|
+
@"type": @"theme",
|
118
|
+
@"payload": @{
|
119
|
+
@"themeName": cxxStringToNSString(theme)
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
96
123
|
[weakSelf emitEvent:@"onChange" withBody:body];
|
97
124
|
};
|
98
|
-
|
99
|
-
|
100
|
-
|
125
|
+
UnistylesBreakpointChangeEvent onBreakpointChange = ^(std::string breakpoint) {
|
126
|
+
NSDictionary *body = @{
|
127
|
+
@"type": @"breakpoint",
|
128
|
+
@"payload": @{
|
129
|
+
@"breakpoint": cxxStringToNSString(breakpoint)
|
130
|
+
}
|
131
|
+
};
|
132
|
+
|
133
|
+
[weakSelf emitEvent:@"onChange" withBody:body];
|
134
|
+
};
|
135
|
+
|
136
|
+
auto unistylesRuntime = std::make_shared<UnistylesRuntime>(
|
137
|
+
onThemeChange,
|
138
|
+
onBreakpointChange,
|
139
|
+
(int)initialScreenWidth,
|
140
|
+
(int)initialScreenHeight,
|
141
|
+
initialColorScheme
|
142
|
+
);
|
143
|
+
|
101
144
|
weakSelf.unistylesRuntime = unistylesRuntime.get();
|
102
145
|
|
103
146
|
auto hostObject = jsi::Object::createFromHostObject(runtime, unistylesRuntime);
|
104
|
-
|
147
|
+
|
105
148
|
runtime.global().setProperty(runtime, "__UNISTYLES__", std::move(hostObject));
|
106
149
|
}
|
107
150
|
|
108
151
|
@end
|
152
|
+
|
153
|
+
#pragma mark - End
|
@@ -5,16 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.UnistyleRegistry = void 0;
|
7
7
|
class UnistyleRegistry {
|
8
|
-
|
8
|
+
config = {};
|
9
|
+
themeNames = [];
|
9
10
|
themes = {};
|
10
11
|
breakpoints = {};
|
11
12
|
sortedBreakpointPairs = [];
|
12
|
-
config = {};
|
13
13
|
constructor(unistylesBridge) {
|
14
14
|
this.unistylesBridge = unistylesBridge;
|
15
15
|
}
|
16
16
|
addThemes = themes => {
|
17
17
|
this.themes = themes;
|
18
|
+
const keys = Object.keys(themes);
|
19
|
+
this.unistylesBridge.themes = keys;
|
20
|
+
this.themeNames = keys;
|
18
21
|
return this;
|
19
22
|
};
|
20
23
|
addBreakpoints = breakpoints => {
|
@@ -24,14 +27,19 @@ class UnistyleRegistry {
|
|
24
27
|
};
|
25
28
|
addConfig = config => {
|
26
29
|
this.config = config;
|
27
|
-
if (config.
|
28
|
-
this.unistylesBridge.
|
29
|
-
}
|
30
|
-
if (config.colorScheme) {
|
31
|
-
this.unistylesBridge.useColorScheme(config.colorScheme);
|
30
|
+
if (config.adaptiveThemes) {
|
31
|
+
this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
|
32
32
|
}
|
33
33
|
return this;
|
34
34
|
};
|
35
|
+
dangerouslyUnregister = () => {
|
36
|
+
this.config = {};
|
37
|
+
this.themeNames = [];
|
38
|
+
this.themes = {};
|
39
|
+
this.breakpoints = {};
|
40
|
+
this.sortedBreakpointPairs = [];
|
41
|
+
this.unistylesBridge.unregister();
|
42
|
+
};
|
35
43
|
}
|
36
44
|
exports.UnistyleRegistry = UnistyleRegistry;
|
37
45
|
//# sourceMappingURL=UnistyleRegistry.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistyleRegistry","
|
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,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;AAACC,OAAA,CAAAlB,gBAAA,GAAAA,gBAAA"}
|
@@ -13,40 +13,54 @@ class UnistylesRuntime {
|
|
13
13
|
get colorScheme() {
|
14
14
|
return this.unistylesBridge.colorScheme;
|
15
15
|
}
|
16
|
-
get
|
17
|
-
return this.
|
16
|
+
get hasAdaptiveThemes() {
|
17
|
+
return this.unistylesBridge.hasAdaptiveThemes;
|
18
18
|
}
|
19
19
|
get sortedBreakpoints() {
|
20
20
|
return this.registry.sortedBreakpointPairs;
|
21
21
|
}
|
22
|
-
get
|
23
|
-
return this.
|
22
|
+
get themeName() {
|
23
|
+
return this.unistylesBridge.themeName;
|
24
24
|
}
|
25
|
-
get
|
26
|
-
return this.unistylesBridge.theme;
|
27
|
-
}
|
28
|
-
get currentBreakpoint() {
|
25
|
+
get breakpoint() {
|
29
26
|
return this.unistylesBridge.breakpoint;
|
30
27
|
}
|
31
|
-
|
32
|
-
|
33
|
-
this.unistylesBridge.
|
28
|
+
get screen() {
|
29
|
+
return {
|
30
|
+
width: this.unistylesBridge.screenWidth,
|
31
|
+
height: this.unistylesBridge.screenHeight
|
32
|
+
};
|
33
|
+
}
|
34
|
+
get orientation() {
|
35
|
+
const {
|
36
|
+
width,
|
37
|
+
height
|
38
|
+
} = this.screen;
|
39
|
+
if (width > height) {
|
40
|
+
return _types.ScreenOrientation.Landscape;
|
34
41
|
}
|
35
|
-
|
42
|
+
return _types.ScreenOrientation.Portrait;
|
43
|
+
}
|
36
44
|
setTheme = name => {
|
37
|
-
if (name !== this.
|
45
|
+
if (name !== this.themeName && this.hasTheme(name)) {
|
38
46
|
this.unistylesBridge.useTheme(name);
|
39
47
|
return true;
|
40
48
|
}
|
41
|
-
|
49
|
+
throw new Error(_types.UnistylesError.ThemeNotRegistered);
|
42
50
|
};
|
43
|
-
hasTheme = name => name in this.registry.themes;
|
44
51
|
getTheme = forName => {
|
52
|
+
if (this.registry.themeNames.length === 0) {
|
53
|
+
return {};
|
54
|
+
}
|
45
55
|
if (!this.hasTheme(forName)) {
|
46
56
|
throw new Error(_types.UnistylesError.ThemeNotFound);
|
47
57
|
}
|
48
58
|
return this.registry.themes[forName];
|
49
59
|
};
|
60
|
+
setAdaptiveThemes = enable => {
|
61
|
+
this.unistylesBridge.useAdaptiveThemes(enable);
|
62
|
+
};
|
63
|
+
hasTheme = name => name in this.registry.themes;
|
50
64
|
}
|
51
65
|
exports.UnistylesRuntime = UnistylesRuntime;
|
52
66
|
//# sourceMappingURL=UnistylesRuntime.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","
|
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,eA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E;MACvC,OAAO,CAAC,CAAC;IACb;IAEA,IAAI,CAAC,IAAI,CAACR,QAAQ,CAACM,OAAO,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"}
|
@@ -5,13 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.useDimensions = void 0;
|
7
7
|
var _react = require("react");
|
8
|
-
var _utils = require("../utils");
|
9
8
|
const useDimensions = () => {
|
10
9
|
const timerRef = (0, _react.useRef)();
|
11
|
-
const [screenSize, setScreenSize] = (0, _react.useState)({
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
const [screenSize, setScreenSize] = (0, _react.useState)({});
|
11
|
+
(0, _react.useLayoutEffect)(() => {
|
12
|
+
setScreenSize({
|
13
|
+
width: window.innerWidth,
|
14
|
+
height: window.innerHeight
|
15
|
+
});
|
16
|
+
}, []);
|
15
17
|
(0, _react.useEffect)(() => {
|
16
18
|
const handleResize = () => {
|
17
19
|
clearTimeout(timerRef.current);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","
|
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"}
|
package/lib/commonjs/index.js
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
Object.defineProperty(exports, "
|
6
|
+
Object.defineProperty(exports, "ScreenOrientation", {
|
7
7
|
enumerable: true,
|
8
8
|
get: function () {
|
9
|
-
return _types.
|
9
|
+
return _types.ScreenOrientation;
|
10
10
|
}
|
11
11
|
});
|
12
|
-
exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
|
12
|
+
exports.__dangerouslyUnregister = exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
|
13
13
|
Object.defineProperty(exports, "createStyleSheet", {
|
14
14
|
enumerable: true,
|
15
15
|
get: function () {
|
@@ -44,4 +44,5 @@ const UnistylesRegistry = exports.UnistylesRegistry = {
|
|
44
44
|
addBreakpoints,
|
45
45
|
addConfig
|
46
46
|
};
|
47
|
+
const __dangerouslyUnregister = exports.__dangerouslyUnregister = _Unistyles.unistyles.registry.dangerouslyUnregister;
|
47
48
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Unistyles","require","_types","_useInitialTheme","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,MAAM;EAAEK,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGC,oBAAS,CAACC,QAAQ;AACpE,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGF,oBAAS,CAACI,OAAO;AAC1C,MAAMC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,GAAG;EACtBR,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC"}
|
1
|
+
{"version":3,"names":["_Unistyles","require","_types","_useInitialTheme","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,MAAM;EAAEK,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGC,oBAAS,CAACC,QAAQ;AACpE,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGF,oBAAS,CAACI,OAAO;AAC1C,MAAMC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,GAAG;EACtBR,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC;AAEM,MAAMO,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAGN,oBAAS,CAACC,QAAQ,CAACM,qBAAqB"}
|
@@ -3,11 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.UnistylesError = exports.
|
7
|
-
let
|
8
|
-
|
9
|
-
|
10
|
-
return
|
6
|
+
exports.UnistylesError = exports.ScreenOrientation = exports.CxxUnistylesEventTypes = void 0;
|
7
|
+
let ScreenOrientation = exports.ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
|
8
|
+
ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
|
9
|
+
ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
|
10
|
+
return ScreenOrientation;
|
11
11
|
}({});
|
12
12
|
let CxxUnistylesEventTypes = exports.CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
|
13
13
|
CxxUnistylesEventTypes["Theme"] = "theme";
|
@@ -18,6 +18,10 @@ let CxxUnistylesEventTypes = exports.CxxUnistylesEventTypes = /*#__PURE__*/funct
|
|
18
18
|
let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
19
19
|
UnistylesError["RuntimeUnavailable"] = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE";
|
20
20
|
UnistylesError["ThemeNotFound"] = "UNISTYLES_ERROR_THEME_NOT_FOUND";
|
21
|
+
UnistylesError["ThemeNotRegistered"] = "UNISTYLES_ERROR_THEME_NOT_REGISTERED";
|
22
|
+
UnistylesError["ThemesCannotBeEmpty"] = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY";
|
23
|
+
UnistylesError["BreakpointsCannotBeEmpty"] = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY";
|
24
|
+
UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
|
21
25
|
return UnistylesError;
|
22
26
|
}({});
|
23
27
|
//# sourceMappingURL=cxx.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["ScreenOrientation","exports","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":";;;;;;IASYA,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;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IA8BtBC,cAAc,GAAAF,OAAA,CAAAE,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -7,7 +7,7 @@ exports.useInitialTheme = void 0;
|
|
7
7
|
var _react = require("react");
|
8
8
|
var _Unistyles = require("./Unistyles");
|
9
9
|
const useInitialTheme = forName => {
|
10
|
-
(0, _react.
|
10
|
+
(0, _react.useMemo)(() => _Unistyles.unistyles.runtime.setTheme(forName), []);
|
11
11
|
};
|
12
12
|
exports.useInitialTheme = useInitialTheme;
|
13
13
|
//# sourceMappingURL=useInitialTheme.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_Unistyles","useInitialTheme","forName","
|
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"}
|
@@ -10,8 +10,8 @@ var _types = require("./types");
|
|
10
10
|
var _Unistyles = require("./Unistyles");
|
11
11
|
const unistylesEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Unistyles);
|
12
12
|
const useUnistyles = () => {
|
13
|
-
const [theme, setTheme] = (0, _react.useState)(_Unistyles.unistyles.runtime.getTheme(_Unistyles.unistyles.runtime.
|
14
|
-
const [breakpoint, setBreakpoint] = (0, _react.useState)(_Unistyles.unistyles.runtime.
|
13
|
+
const [theme, setTheme] = (0, _react.useState)(_Unistyles.unistyles.runtime.getTheme(_Unistyles.unistyles.runtime.themeName));
|
14
|
+
const [breakpoint, setBreakpoint] = (0, _react.useState)(_Unistyles.unistyles.runtime.breakpoint);
|
15
15
|
const [screenSize, setScreenSize] = (0, _react.useState)({
|
16
16
|
width: 0,
|
17
17
|
height: 0
|
@@ -22,9 +22,10 @@ const useUnistyles = () => {
|
|
22
22
|
case _types.CxxUnistylesEventTypes.Theme:
|
23
23
|
{
|
24
24
|
const themeEvent = event;
|
25
|
-
setTheme(_Unistyles.unistyles.runtime.getTheme(themeEvent.payload.
|
25
|
+
setTheme(_Unistyles.unistyles.runtime.getTheme(themeEvent.payload.themeName));
|
26
26
|
return;
|
27
27
|
}
|
28
|
+
// this event is not available on mobile
|
28
29
|
case _types.CxxUnistylesEventTypes.Size:
|
29
30
|
{
|
30
31
|
const sizeEvent = event;
|
@@ -32,15 +33,12 @@ const useUnistyles = () => {
|
|
32
33
|
width: sizeEvent.payload.width,
|
33
34
|
height: sizeEvent.payload.height
|
34
35
|
});
|
35
|
-
// todo
|
36
|
-
// setBreakpoint(unistyles.runtime.currentBreakpoint)
|
37
|
-
|
38
36
|
return;
|
39
37
|
}
|
40
38
|
case _types.CxxUnistylesEventTypes.Breakpoint:
|
41
39
|
{
|
42
40
|
const breakpointEvent = event;
|
43
|
-
setBreakpoint(breakpointEvent.payload.
|
41
|
+
setBreakpoint(breakpointEvent.payload.breakpoint);
|
44
42
|
return;
|
45
43
|
}
|
46
44
|
default:
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_types","_Unistyles","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","theme","setTheme","useState","unistyles","runtime","getTheme","
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_types","_Unistyles","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","theme","setTheme","useState","unistyles","runtime","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","height","useEffect","subscription","addListener","event","type","CxxUnistylesEventTypes","Theme","themeEvent","payload","Size","sizeEvent","Breakpoint","breakpointEvent","remove","exports"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAA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ACd,UAAU,CAAC;YAEjD;UACJ;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOO,YAAY,CAACY,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACH1B,KAAK;IACLO,UAAU;IACVE;EACJ,CAAC;AACL,CAAC;AAAAkB,OAAA,CAAA5B,YAAA,GAAAA,YAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Unistyles","require","_common","_mediaQueries","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","isMediaQuery","customMediaQueryKey","getKeyForCustomMediaQuery","unifiedKey","toLowerCase","directBreakpoint","breakpointPairs","unistyles","runtime","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,eAAe,CAAC,GAAGF,gBAAgB;EAE1C,IAAIE,eAAe,KAAK,CAAC,EAAE;IACvB,IAAAC,kBAAU,EAAC,oCAAoC,CAAC;EACpD;EAEA,IAAIH,gBAAgB,CAACI,MAAM,KAAK,IAAIC,GAAG,CAACL,gBAAgB,CAAC,CAACM,IAAI,EAAE;IAC5D,IAAAH,kBAAU,EAAC,kCAAkC,CAAC;EAClD;EAEA,OAAON,iBAAiB;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAdAU,OAAA,CAAApB,0BAAA,GAAAA,0BAAA;AAeO,MAAMqB,4BAA4B,GAAGA,CAACC,KAAa,EAAEC,iBAAwG,KAA0C;EAC1M,MAAM,CAACC,GAAG,CAAC,GAAGD,iBAAiB,CAC1BE,IAAI,CAAC,CAAAC,IAAA,EAAYC,KAAK,EAAEC,gBAAgB,KAAK;IAAA,IAAvC,GAAGC,KAAK,CAAC,GAAAH,IAAA;IACZ,MAAMI,MAAM,GAAGD,
|
1
|
+
{"version":3,"names":["_Unistyles","require","_common","_mediaQueries","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","isMediaQuery","customMediaQueryKey","getKeyForCustomMediaQuery","unifiedKey","toLowerCase","directBreakpoint","breakpointPairs","unistyles","runtime","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,eAAe,CAAC,GAAGF,gBAAgB;EAE1C,IAAIE,eAAe,KAAK,CAAC,EAAE;IACvB,IAAAC,kBAAU,EAAC,oCAAoC,CAAC;EACpD;EAEA,IAAIH,gBAAgB,CAACI,MAAM,KAAK,IAAIC,GAAG,CAACL,gBAAgB,CAAC,CAACM,IAAI,EAAE;IAC5D,IAAAH,kBAAU,EAAC,kCAAkC,CAAC;EAClD;EAEA,OAAON,iBAAiB;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAdAU,OAAA,CAAApB,0BAAA,GAAAA,0BAAA;AAeO,MAAMqB,4BAA4B,GAAGA,CAACC,KAAa,EAAEC,iBAAwG,KAA0C;EAC1M,MAAM,CAACC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AOc,gBAAgB;EAC3B;;EAEA;EACA,MAAMC,eAAe,GAAGC,oBAAS,CAACC,OAAO,CAACpC,iBAAiB;EAC3D,MAAMqC,iBAAiB,GAAGH,eAAe,CACpCI,SAAS,CAACC,KAAA;IAAA,IAAC,CAACzB,GAAG,CAAC,GAAAyB,KAAA;IAAA,OAAKzB,GAAG,KAAKiB,UAAU;EAAA,EAAC;EAE7C,MAAMS,oBAAoB,GAAGN,eAAe,CACvCR,MAAM,CAAC,CAAAe,KAAA,EAAQxB,KAAK;IAAA,IAAZ,CAACH,GAAG,CAAC,GAAA2B,KAAA;IAAA,OAAYxB,KAAK,GAAGoB,iBAAiB,IAAIvB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1EuB,GAAG,CAACC,KAAA;IAAA,IAAC,CAAC7B,GAAG,CAAC,GAAA6B,KAAA;IAAA,OAAK7B,GAAG;EAAA,EAAC;EAExB,OAAOoB,eAAe,CAAC3B,MAAM,GAAG,CAAC,GAC3BY,KAAK,CAACqB,oBAAoB,CAACA,oBAAoB,CAACjC,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnGqC,SAAS;AACnB,CAAC;AAAAlC,OAAA,CAAAY,qBAAA,GAAAA,qBAAA"}
|
@@ -1,14 +1,17 @@
|
|
1
1
|
export class UnistyleRegistry {
|
2
|
-
|
2
|
+
config = {};
|
3
|
+
themeNames = [];
|
3
4
|
themes = {};
|
4
5
|
breakpoints = {};
|
5
6
|
sortedBreakpointPairs = [];
|
6
|
-
config = {};
|
7
7
|
constructor(unistylesBridge) {
|
8
8
|
this.unistylesBridge = unistylesBridge;
|
9
9
|
}
|
10
10
|
addThemes = themes => {
|
11
11
|
this.themes = themes;
|
12
|
+
const keys = Object.keys(themes);
|
13
|
+
this.unistylesBridge.themes = keys;
|
14
|
+
this.themeNames = keys;
|
12
15
|
return this;
|
13
16
|
};
|
14
17
|
addBreakpoints = breakpoints => {
|
@@ -18,13 +21,18 @@ export class UnistyleRegistry {
|
|
18
21
|
};
|
19
22
|
addConfig = config => {
|
20
23
|
this.config = config;
|
21
|
-
if (config.
|
22
|
-
this.unistylesBridge.
|
23
|
-
}
|
24
|
-
if (config.colorScheme) {
|
25
|
-
this.unistylesBridge.useColorScheme(config.colorScheme);
|
24
|
+
if (config.adaptiveThemes) {
|
25
|
+
this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
|
26
26
|
}
|
27
27
|
return this;
|
28
28
|
};
|
29
|
+
dangerouslyUnregister = () => {
|
30
|
+
this.config = {};
|
31
|
+
this.themeNames = [];
|
32
|
+
this.themes = {};
|
33
|
+
this.breakpoints = {};
|
34
|
+
this.sortedBreakpointPairs = [];
|
35
|
+
this.unistylesBridge.unregister();
|
36
|
+
};
|
29
37
|
}
|
30
38
|
//# sourceMappingURL=UnistyleRegistry.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistyleRegistry","
|
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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