react-native-unistyles 1.1.1 → 2.0.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/ios/UnistylesModule.h +10 -0
- package/ios/UnistylesModule.mm +108 -0
- package/ios/UnistylesRuntime.h +30 -0
- package/ios/UnistylesRuntime.mm +191 -0
- package/lib/commonjs/UnistyleRegistry.js +37 -0
- package/lib/commonjs/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/Unistyles.js +36 -0
- package/lib/commonjs/Unistyles.js.map +1 -0
- package/lib/commonjs/UnistylesEngine.js +22 -0
- package/lib/commonjs/UnistylesEngine.js.map +1 -0
- package/lib/commonjs/UnistylesModule.js +9 -0
- package/lib/commonjs/UnistylesModule.js.map +1 -0
- package/lib/commonjs/UnistylesRuntime.js +52 -0
- package/lib/commonjs/UnistylesRuntime.js.map +1 -0
- package/lib/commonjs/createStyleSheet.js +14 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -0
- package/lib/commonjs/global.js +2 -0
- package/lib/commonjs/global.js.map +1 -0
- package/lib/commonjs/index.js +33 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/cxx.js +23 -0
- package/lib/commonjs/types/cxx.js.map +1 -0
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/useInitialTheme.js +13 -0
- package/lib/commonjs/useInitialTheme.js.map +1 -0
- package/lib/commonjs/useStyles.js +48 -0
- package/lib/commonjs/useStyles.js.map +1 -0
- package/lib/commonjs/useUnistyles.js +59 -0
- package/lib/commonjs/useUnistyles.js.map +1 -0
- package/lib/commonjs/utils/breakpoints.js +4 -2
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/styles.js +6 -6
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/UnistyleRegistry.js +30 -0
- package/lib/module/UnistyleRegistry.js.map +1 -0
- package/lib/module/Unistyles.js +30 -0
- package/lib/module/Unistyles.js.map +1 -0
- package/lib/module/UnistylesEngine.js +15 -0
- package/lib/module/UnistylesEngine.js.map +1 -0
- package/lib/module/UnistylesModule.js +3 -0
- package/lib/module/UnistylesModule.js.map +1 -0
- package/lib/module/UnistylesRuntime.js +45 -0
- package/lib/module/UnistylesRuntime.js.map +1 -0
- package/lib/module/createStyleSheet.js +7 -0
- package/lib/module/createStyleSheet.js.map +1 -0
- package/lib/module/global.js +2 -0
- package/lib/module/global.js.map +1 -0
- package/lib/module/index.js +18 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/cxx.js +17 -0
- package/lib/module/types/cxx.js.map +1 -0
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/useInitialTheme.js +6 -0
- package/lib/module/useInitialTheme.js.map +1 -0
- package/lib/module/useStyles.js +42 -0
- package/lib/module/useStyles.js.map +1 -0
- package/lib/module/useUnistyles.js +52 -0
- package/lib/module/useUnistyles.js.map +1 -0
- package/lib/module/utils/breakpoints.js +4 -3
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/styles.js +6 -7
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/examples/expo/src/App.d.ts.map +1 -1
- package/lib/typescript/examples/expo/src/examples/Cxx.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Cxx.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts +1 -7
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -1
- package/lib/typescript/examples/expo/src/styles/index.d.ts +15 -45
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -1
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +17 -1
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -1
- package/lib/typescript/src/UnistyleRegistry.d.ts +15 -0
- package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/Unistyles.d.ts +16 -0
- package/lib/typescript/src/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesEngine.d.ts +8 -0
- package/lib/typescript/src/UnistylesEngine.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesModule.d.ts +6 -0
- package/lib/typescript/src/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesRuntime.d.ts +56 -0
- package/lib/typescript/src/UnistylesRuntime.d.ts.map +1 -0
- package/lib/typescript/src/createStyleSheet.d.ts +6 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
- package/lib/typescript/src/global.d.ts +5 -0
- package/lib/typescript/src/global.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +14 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +6 -7
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +4 -4
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/cxx.d.ts +50 -0
- package/lib/typescript/src/types/cxx.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +3 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/useInitialTheme.d.ts +3 -0
- package/lib/typescript/src/useInitialTheme.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +46 -0
- package/lib/typescript/src/useStyles.d.ts.map +1 -0
- package/lib/typescript/src/useUnistyles.d.ts +45 -0
- package/lib/typescript/src/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/breakpoints.d.ts +5 -4
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +4 -3
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +11 -8
- package/react-native-unistyles.podspec +21 -0
- package/src/UnistyleRegistry.ts +39 -0
- package/src/Unistyles.ts +41 -0
- package/src/UnistylesEngine.ts +15 -0
- package/src/UnistylesModule.ts +7 -0
- package/src/UnistylesRuntime.ts +58 -0
- package/src/createStyleSheet.ts +12 -0
- package/src/global.ts +2 -0
- package/src/index.ts +30 -2
- package/src/types/breakpoints.ts +9 -11
- package/src/types/core.ts +6 -6
- package/src/types/cxx.ts +61 -0
- package/src/types/index.ts +3 -3
- package/src/useInitialTheme.ts +7 -0
- package/src/useStyles.ts +49 -0
- package/src/useUnistyles.ts +67 -0
- package/src/utils/breakpoints.ts +16 -14
- package/src/utils/styles.ts +16 -18
- package/lib/commonjs/UnistylesTheme.js +0 -21
- package/lib/commonjs/UnistylesTheme.js.map +0 -1
- package/lib/commonjs/createUnistyles.js +0 -57
- package/lib/commonjs/createUnistyles.js.map +0 -1
- package/lib/module/UnistylesTheme.js +0 -12
- package/lib/module/UnistylesTheme.js.map +0 -1
- package/lib/module/createUnistyles.js +0 -50
- package/lib/module/createUnistyles.js.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +0 -7
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
- package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
- package/lib/typescript/src/createUnistyles.d.ts +0 -10
- package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
- package/src/UnistylesTheme.tsx +0 -17
- package/src/__tests__/createUnistyles.spec.tsx +0 -192
- package/src/createUnistyles.ts +0 -70
@@ -0,0 +1,10 @@
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
2
|
+
#import <React/RCTEventEmitter.h>
|
3
|
+
|
4
|
+
typedef void(^UnistylesEventHandler)(NSDictionary *);
|
5
|
+
|
6
|
+
@interface UnistylesModule : RCTEventEmitter<RCTBridgeModule>
|
7
|
+
|
8
|
+
@property (nonatomic, assign) void* unistylesRuntime;
|
9
|
+
|
10
|
+
@end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#import "UnistylesModule.h"
|
2
|
+
#import "UnistylesRuntime.h"
|
3
|
+
|
4
|
+
#import <React/RCTBridge+Private.h>
|
5
|
+
#import <React/RCTUtils.h>
|
6
|
+
#import <jsi/jsi.h>
|
7
|
+
|
8
|
+
@implementation UnistylesModule
|
9
|
+
|
10
|
+
BOOL hasListeners;
|
11
|
+
|
12
|
+
using namespace facebook;
|
13
|
+
|
14
|
+
RCT_EXPORT_MODULE(Unistyles)
|
15
|
+
|
16
|
+
- (instancetype)init {
|
17
|
+
if ((self = [super init])) {
|
18
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
19
|
+
selector:@selector(handleOrientationChange:)
|
20
|
+
name:UIDeviceOrientationDidChangeNotification
|
21
|
+
object:nil];
|
22
|
+
}
|
23
|
+
return self;
|
24
|
+
}
|
25
|
+
|
26
|
+
- (void)handleOrientationChange:(NSNotification *)notification {
|
27
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
28
|
+
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
|
29
|
+
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
|
30
|
+
|
31
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChangeWithWidth(screenWidth, screenHeight);
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
- (void)dealloc {
|
36
|
+
delete (UnistylesRuntime*)self.unistylesRuntime;
|
37
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
38
|
+
}
|
39
|
+
|
40
|
+
+ (BOOL)requiresMainQueueSetup
|
41
|
+
{
|
42
|
+
return YES;
|
43
|
+
}
|
44
|
+
|
45
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
46
|
+
{
|
47
|
+
NSLog(@"Installing Unistyles 🦄...");
|
48
|
+
|
49
|
+
RCTBridge* bridge = [RCTBridge currentBridge];
|
50
|
+
RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
|
51
|
+
|
52
|
+
if (cxxBridge == nil) {
|
53
|
+
return @false;
|
54
|
+
}
|
55
|
+
|
56
|
+
auto jsiRuntime = (jsi::Runtime*)cxxBridge.runtime;
|
57
|
+
|
58
|
+
if (jsiRuntime == nil) {
|
59
|
+
return @false;
|
60
|
+
}
|
61
|
+
|
62
|
+
auto& runtime = *jsiRuntime;
|
63
|
+
UnistylesModule *__weak weakSelf = self;
|
64
|
+
|
65
|
+
registerUnistylesHostObject(runtime, weakSelf);
|
66
|
+
|
67
|
+
NSLog(@"Installed Unistyles 🦄!");
|
68
|
+
|
69
|
+
return @true;
|
70
|
+
}
|
71
|
+
|
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
|
+
|
92
|
+
void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSelf) {
|
93
|
+
CGFloat initialScreenWidth = [UIScreen mainScreen].bounds.size.width;
|
94
|
+
CGFloat initialScreenHeight = [UIScreen mainScreen].bounds.size.height;
|
95
|
+
UnistylesEventHandler eventHandler = ^(NSDictionary *body) {
|
96
|
+
[weakSelf emitEvent:@"onChange" withBody:body];
|
97
|
+
};
|
98
|
+
|
99
|
+
auto unistylesRuntime = std::make_shared<UnistylesRuntime>(eventHandler, initialScreenWidth, initialScreenHeight);
|
100
|
+
|
101
|
+
weakSelf.unistylesRuntime = unistylesRuntime.get();
|
102
|
+
|
103
|
+
auto hostObject = jsi::Object::createFromHostObject(runtime, unistylesRuntime);
|
104
|
+
|
105
|
+
runtime.global().setProperty(runtime, "__UNISTYLES__", std::move(hostObject));
|
106
|
+
}
|
107
|
+
|
108
|
+
@end
|
@@ -0,0 +1,30 @@
|
|
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
|
+
UnistylesEventHandler eventHandler;
|
12
|
+
float screenWidth;
|
13
|
+
float screenHeight;
|
14
|
+
|
15
|
+
public:
|
16
|
+
UnistylesRuntime(UnistylesEventHandler handler, CGFloat screenWidth, CGFloat screenHeight)
|
17
|
+
: eventHandler(handler), screenWidth(screenWidth), screenHeight(screenHeight) {}
|
18
|
+
|
19
|
+
std::string theme;
|
20
|
+
std::string breakpoint;
|
21
|
+
std::string colorScheme;
|
22
|
+
std::vector<std::string> featureFlags;
|
23
|
+
std::vector<std::pair<std::string, double>> sortedBreakpointEntries;
|
24
|
+
|
25
|
+
jsi::Value get(jsi::Runtime&, const jsi::PropNameID& name) override;
|
26
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& rt) override;
|
27
|
+
|
28
|
+
void handleScreenSizeChangeWithWidth(CGFloat width, CGFloat height);
|
29
|
+
std::string getBreakpointFromScreenWidth(double width, const std::vector<std::pair<std::string, double>>& sortedBreakpointEntries);
|
30
|
+
};
|
@@ -0,0 +1,191 @@
|
|
1
|
+
#import "UnistylesRuntime.h"
|
2
|
+
|
3
|
+
std::vector<jsi::PropNameID> UnistylesRuntime::getPropertyNames(jsi::Runtime& rt) {
|
4
|
+
std::vector<jsi::PropNameID> properties;
|
5
|
+
|
6
|
+
// getters
|
7
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("theme")));
|
8
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("breakpoint")));
|
9
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("colorScheme")));
|
10
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("sortedBreakpointPairs")));
|
11
|
+
|
12
|
+
// setters
|
13
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useBreakpoints")));
|
14
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useTheme")));
|
15
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useColorScheme")));
|
16
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string("useFeatureFlags")));
|
17
|
+
|
18
|
+
return properties;
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
jsi::Value UnistylesRuntime::get(jsi::Runtime& runtime, const jsi::PropNameID& propNameId) {
|
23
|
+
std::string propName = propNameId.utf8(runtime);
|
24
|
+
|
25
|
+
if (propName == "theme") {
|
26
|
+
return !this->theme.empty()
|
27
|
+
? jsi::Value(jsi::String::createFromUtf8(runtime, this->theme))
|
28
|
+
: jsi::Value::undefined();
|
29
|
+
}
|
30
|
+
|
31
|
+
if (propName == "breakpoint") {
|
32
|
+
return !this->breakpoint.empty()
|
33
|
+
? jsi::Value(jsi::String::createFromUtf8(runtime, this->breakpoint))
|
34
|
+
: jsi::Value::undefined();
|
35
|
+
}
|
36
|
+
|
37
|
+
if (propName == "colorScheme") {
|
38
|
+
return !this->colorScheme.empty()
|
39
|
+
? jsi::Value(jsi::String::createFromUtf8(runtime, this->colorScheme))
|
40
|
+
: jsi::Value::undefined();
|
41
|
+
}
|
42
|
+
|
43
|
+
if (propName == "sortedBreakpointPairs") {
|
44
|
+
std::unique_ptr<jsi::Array> sortedBreakpointEntriesArray = std::make_unique<jsi::Array>(runtime, this->sortedBreakpointEntries.size());
|
45
|
+
|
46
|
+
for (size_t i = 0; i < this->sortedBreakpointEntries.size(); ++i) {
|
47
|
+
std::unique_ptr<jsi::Array> pairArray = std::make_unique<jsi::Array>(runtime, 2);
|
48
|
+
jsi::String nameValue = jsi::String::createFromUtf8(runtime, this->sortedBreakpointEntries[i].first);
|
49
|
+
|
50
|
+
pairArray->setValueAtIndex(runtime, 0, nameValue);
|
51
|
+
pairArray->setValueAtIndex(runtime, 1, jsi::Value(this->sortedBreakpointEntries[i].second));
|
52
|
+
sortedBreakpointEntriesArray->setValueAtIndex(runtime, i, *pairArray);
|
53
|
+
}
|
54
|
+
|
55
|
+
return jsi::Value(runtime, *sortedBreakpointEntriesArray);
|
56
|
+
}
|
57
|
+
|
58
|
+
if (propName == "useBreakpoints") {
|
59
|
+
return jsi::Function::createFromHostFunction(
|
60
|
+
runtime,
|
61
|
+
jsi::PropNameID::forAscii(runtime, "useBreakpoints"),
|
62
|
+
1,
|
63
|
+
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
64
|
+
jsi::Object breakpointsObj = arguments[0].asObject(runtime);
|
65
|
+
jsi::Array propertyNames = breakpointsObj.getPropertyNames(runtime);
|
66
|
+
std::vector<std::pair<std::string, double>> sortedBreakpointEntriesVec;
|
67
|
+
|
68
|
+
for (size_t i = 0; i < propertyNames.size(runtime); ++i) {
|
69
|
+
jsi::Value propNameValue = propertyNames.getValueAtIndex(runtime, i);
|
70
|
+
std::string name = propNameValue.asString(runtime).utf8(runtime);
|
71
|
+
jsi::PropNameID propNameID = jsi::PropNameID::forUtf8(runtime, name);
|
72
|
+
jsi::Value value = breakpointsObj.getProperty(runtime, propNameID);
|
73
|
+
|
74
|
+
if (value.isNumber()) {
|
75
|
+
double breakpointValue = value.asNumber();
|
76
|
+
sortedBreakpointEntriesVec.push_back(std::make_pair(name, breakpointValue));
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
std::sort(sortedBreakpointEntriesVec.begin(), sortedBreakpointEntriesVec.end(), [](const std::pair<std::string, double>& a, const std::pair<std::string, double>& b) {
|
81
|
+
return a.second < b.second;
|
82
|
+
});
|
83
|
+
|
84
|
+
this->sortedBreakpointEntries = sortedBreakpointEntriesVec;
|
85
|
+
|
86
|
+
std::string breakpoint = this->getBreakpointFromScreenWidth(this->screenWidth, sortedBreakpointEntriesVec);
|
87
|
+
|
88
|
+
this->breakpoint = breakpoint;
|
89
|
+
|
90
|
+
return jsi::Value::undefined();
|
91
|
+
}
|
92
|
+
);
|
93
|
+
}
|
94
|
+
|
95
|
+
if (propName == "useTheme") {
|
96
|
+
return jsi::Function::createFromHostFunction(runtime,
|
97
|
+
jsi::PropNameID::forAscii(runtime, "useTheme"),
|
98
|
+
1,
|
99
|
+
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
100
|
+
std::string themeName = arguments[0].asString(runtime).utf8(runtime);
|
101
|
+
NSString *currentTheme = [NSString stringWithUTF8String:themeName.c_str()];
|
102
|
+
|
103
|
+
this->theme = themeName;
|
104
|
+
|
105
|
+
NSDictionary *body = @{
|
106
|
+
@"type": @"theme",
|
107
|
+
@"payload": @{
|
108
|
+
@"currentTheme": currentTheme
|
109
|
+
}
|
110
|
+
};
|
111
|
+
this->eventHandler(body);
|
112
|
+
|
113
|
+
return jsi::Value::undefined();
|
114
|
+
}
|
115
|
+
);
|
116
|
+
}
|
117
|
+
|
118
|
+
if (propName == "useColorScheme") {
|
119
|
+
return jsi::Function::createFromHostFunction(runtime,
|
120
|
+
jsi::PropNameID::forAscii(runtime, "useColorScheme"),
|
121
|
+
1,
|
122
|
+
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
123
|
+
std::string colorScheme = arguments[0].asString(runtime).utf8(runtime);
|
124
|
+
|
125
|
+
this->colorScheme = colorScheme;
|
126
|
+
|
127
|
+
return jsi::Value::undefined();
|
128
|
+
}
|
129
|
+
);
|
130
|
+
}
|
131
|
+
|
132
|
+
if (propName == "useFeatureFlags") {
|
133
|
+
return jsi::Function::createFromHostFunction(runtime,
|
134
|
+
jsi::PropNameID::forAscii(runtime, "useFeatureFlags"),
|
135
|
+
1,
|
136
|
+
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
137
|
+
jsi::Array featureFlagsArray = arguments[0].asObject(runtime).asArray(runtime);
|
138
|
+
size_t length = featureFlagsArray.size(runtime);
|
139
|
+
std::vector<std::string> featureFlags;
|
140
|
+
featureFlags.reserve(length);
|
141
|
+
|
142
|
+
for (size_t i = 0; i < length; ++i) {
|
143
|
+
jsi::Value element = featureFlagsArray.getValueAtIndex(runtime, i);
|
144
|
+
|
145
|
+
if (element.isString()) {
|
146
|
+
std::string featureFlag = element.asString(runtime).utf8(runtime);
|
147
|
+
featureFlags.push_back(featureFlag);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
this->featureFlags = featureFlags;
|
152
|
+
|
153
|
+
return jsi::Value::undefined();
|
154
|
+
}
|
155
|
+
);
|
156
|
+
}
|
157
|
+
|
158
|
+
return jsi::Value::undefined();
|
159
|
+
}
|
160
|
+
|
161
|
+
std::string UnistylesRuntime::getBreakpointFromScreenWidth(double width, const std::vector<std::pair<std::string, double>>& sortedBreakpointEntries) {
|
162
|
+
for (size_t i = 0; i < sortedBreakpointEntries.size(); ++i) {
|
163
|
+
const auto& [key, value] = sortedBreakpointEntries[i];
|
164
|
+
const double maxVal = (i + 1 < sortedBreakpointEntries.size()) ? sortedBreakpointEntries[i + 1].second : std::numeric_limits<double>::infinity();
|
165
|
+
|
166
|
+
if (width >= value && width < maxVal) {
|
167
|
+
return key;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
return sortedBreakpointEntries.empty() ? "" : sortedBreakpointEntries.back().first;
|
172
|
+
}
|
173
|
+
|
174
|
+
void UnistylesRuntime::handleScreenSizeChangeWithWidth(CGFloat width, CGFloat height) {
|
175
|
+
std::string currentBreakpoint = this->breakpoint;
|
176
|
+
std::string nextBreakpoint = this->getBreakpointFromScreenWidth(width, this->sortedBreakpointEntries);
|
177
|
+
|
178
|
+
if (currentBreakpoint != nextBreakpoint) {
|
179
|
+
this->breakpoint = nextBreakpoint;
|
180
|
+
|
181
|
+
NSString *breakpoint = [NSString stringWithUTF8String:nextBreakpoint.c_str()];
|
182
|
+
NSDictionary *body = @{
|
183
|
+
@"type": @"breakpoint",
|
184
|
+
@"payload": @{
|
185
|
+
@"currentBreakpoint": breakpoint
|
186
|
+
}
|
187
|
+
};
|
188
|
+
|
189
|
+
this->eventHandler(body);
|
190
|
+
}
|
191
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistyleRegistry = void 0;
|
7
|
+
class UnistyleRegistry {
|
8
|
+
isClosed = false;
|
9
|
+
themes = {};
|
10
|
+
breakpoints = {};
|
11
|
+
sortedBreakpointPairs = [];
|
12
|
+
config = {};
|
13
|
+
constructor(unistylesBridge) {
|
14
|
+
this.unistylesBridge = unistylesBridge;
|
15
|
+
}
|
16
|
+
addThemes = themes => {
|
17
|
+
this.themes = themes;
|
18
|
+
return this;
|
19
|
+
};
|
20
|
+
addBreakpoints = breakpoints => {
|
21
|
+
this.unistylesBridge.useBreakpoints(breakpoints);
|
22
|
+
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
|
23
|
+
return this;
|
24
|
+
};
|
25
|
+
addConfig = config => {
|
26
|
+
this.config = config;
|
27
|
+
if (config.featureFlags && config.featureFlags.length > 0) {
|
28
|
+
this.unistylesBridge.useFeatureFlags(config.featureFlags);
|
29
|
+
}
|
30
|
+
if (config.colorScheme) {
|
31
|
+
this.unistylesBridge.useColorScheme(config.colorScheme);
|
32
|
+
}
|
33
|
+
return this;
|
34
|
+
};
|
35
|
+
}
|
36
|
+
exports.UnistyleRegistry = UnistyleRegistry;
|
37
|
+
//# sourceMappingURL=UnistyleRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistyleRegistry","isClosed","themes","breakpoints","sortedBreakpointPairs","config","constructor","unistylesBridge","addThemes","addBreakpoints","useBreakpoints","addConfig","featureFlags","length","useFeatureFlags","colorScheme","useColorScheme","exports"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":";;;;;;AAGO,MAAMA,gBAAgB,CAAC;EACnBC,QAAQ,GAAG,KAAK;EAChBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EACjHC,MAAM,GAAoB,CAAC,CAAC;EAEnCC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIN,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,OAAO,IAAI;EACf,CAAC;EAEMO,cAAc,GAAIN,WAAiC,IAAK;IAC3D,IAAI,CAACI,eAAe,CAACG,cAAc,CAACP,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACG,eAAe,CAACH,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMO,SAAS,GAAIN,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACO,YAAY,IAAIP,MAAM,CAACO,YAAY,CAACC,MAAM,GAAG,CAAC,EAAE;MACvD,IAAI,CAACN,eAAe,CAACO,eAAe,CAACT,MAAM,CAACO,YAAY,CAAC;IAC7D;IAEA,IAAIP,MAAM,CAACU,WAAW,EAAE;MACpB,IAAI,CAACR,eAAe,CAACS,cAAc,CAACX,MAAM,CAACU,WAAW,CAAC;IAC3D;IAEA,OAAO,IAAI;EACf,CAAC;AACL;AAACE,OAAA,CAAAjB,gBAAA,GAAAA,gBAAA"}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.unistyles = void 0;
|
7
|
+
var _UnistylesModule = require("./UnistylesModule");
|
8
|
+
var _UnistylesRuntime = require("./UnistylesRuntime");
|
9
|
+
var _UnistylesEngine = require("./UnistylesEngine");
|
10
|
+
var _UnistyleRegistry = require("./UnistyleRegistry");
|
11
|
+
var _types = require("./types");
|
12
|
+
class Unistyles {
|
13
|
+
constructor() {
|
14
|
+
const isInstalled = _UnistylesModule.UnistylesModule?.install() ?? false;
|
15
|
+
if (!isInstalled) {
|
16
|
+
throw new Error(_types.UnistylesError.RuntimeUnavailable);
|
17
|
+
}
|
18
|
+
|
19
|
+
// @ts-ignore
|
20
|
+
this._bridge = global.__UNISTYLES__;
|
21
|
+
this._registry = new _UnistyleRegistry.UnistyleRegistry(this._bridge);
|
22
|
+
this._runtime = new _UnistylesRuntime.UnistylesRuntime(this._bridge, this._registry);
|
23
|
+
this._engine = new _UnistylesEngine.UnistylesEngine(this._registry, this._runtime);
|
24
|
+
}
|
25
|
+
get registry() {
|
26
|
+
return this._registry;
|
27
|
+
}
|
28
|
+
get runtime() {
|
29
|
+
return this._runtime;
|
30
|
+
}
|
31
|
+
get engine() {
|
32
|
+
return this._engine;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
const unistyles = exports.unistyles = new Unistyles();
|
36
|
+
//# sourceMappingURL=Unistyles.js.map
|
@@ -0,0 +1 @@
|
|
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","UnistylesEngine","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,gCAAe,CAAC,IAAI,CAACL,SAAS,EAAE,IAAI,CAACE,QAAQ,CAAC;EACrE;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"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesEngine = void 0;
|
7
|
+
// todo implement engine
|
8
|
+
class UnistylesEngine {
|
9
|
+
// @ts-ignore
|
10
|
+
constructor(registry, runtime) {
|
11
|
+
this.registry = registry;
|
12
|
+
this.runtime = runtime;
|
13
|
+
this.registry = registry;
|
14
|
+
this.runtime = runtime;
|
15
|
+
}
|
16
|
+
|
17
|
+
// UnistylesEngine.parseStyleSheet
|
18
|
+
// UnistylesEngine.parseStyle
|
19
|
+
// UnistylesEngine.proxify
|
20
|
+
}
|
21
|
+
exports.UnistylesEngine = UnistylesEngine;
|
22
|
+
//# sourceMappingURL=UnistylesEngine.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesEngine","constructor","registry","runtime","exports"],"sourceRoot":"../../src","sources":["UnistylesEngine.ts"],"mappings":";;;;;;AAGA;AACO,MAAMA,eAAe,CAAC;EACzB;EACAC,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;;EAEA;EACA;EACA;AACJ;AAACC,OAAA,CAAAJ,eAAA,GAAAA,eAAA"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesModule = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
const UnistylesModule = exports.UnistylesModule = _reactNative.NativeModules?.Unistyles;
|
9
|
+
//# sourceMappingURL=UnistylesModule.js.map
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesRuntime = void 0;
|
7
|
+
var _types = require("./types");
|
8
|
+
class UnistylesRuntime {
|
9
|
+
constructor(unistylesBridge, registry) {
|
10
|
+
this.unistylesBridge = unistylesBridge;
|
11
|
+
this.registry = registry;
|
12
|
+
}
|
13
|
+
get colorScheme() {
|
14
|
+
return this.unistylesBridge.colorScheme;
|
15
|
+
}
|
16
|
+
get breakpoints() {
|
17
|
+
return this.registry.breakpoints;
|
18
|
+
}
|
19
|
+
get sortedBreakpoints() {
|
20
|
+
return this.registry.sortedBreakpointPairs;
|
21
|
+
}
|
22
|
+
get config() {
|
23
|
+
return this.registry.config;
|
24
|
+
}
|
25
|
+
get theme() {
|
26
|
+
return this.unistylesBridge.theme;
|
27
|
+
}
|
28
|
+
get currentBreakpoint() {
|
29
|
+
return this.unistylesBridge.breakpoint;
|
30
|
+
}
|
31
|
+
setColorScheme = scheme => {
|
32
|
+
if (scheme !== this.colorScheme) {
|
33
|
+
this.unistylesBridge.useColorScheme(scheme);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
setTheme = name => {
|
37
|
+
if (name !== this.theme && this.hasTheme(name)) {
|
38
|
+
this.unistylesBridge.useTheme(name);
|
39
|
+
return true;
|
40
|
+
}
|
41
|
+
return false;
|
42
|
+
};
|
43
|
+
hasTheme = name => name in this.registry.themes;
|
44
|
+
getTheme = forName => {
|
45
|
+
if (!this.hasTheme(forName)) {
|
46
|
+
throw new Error(_types.UnistylesError.ThemeNotFound);
|
47
|
+
}
|
48
|
+
return this.registry.themes[forName];
|
49
|
+
};
|
50
|
+
}
|
51
|
+
exports.UnistylesRuntime = UnistylesRuntime;
|
52
|
+
//# sourceMappingURL=UnistylesRuntime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_types","require","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","breakpoints","sortedBreakpoints","sortedBreakpointPairs","config","theme","currentBreakpoint","breakpoint","setColorScheme","scheme","useColorScheme","setTheme","name","hasTheme","useTheme","themes","getTheme","forName","Error","UnistylesError","ThemeNotFound","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,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,QAAQ,CAACE,WAAW;EACpC;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,QAAQ,CAACI,qBAAqB;EAC9C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACL,QAAQ,CAACK,MAAM;EAC/B;EAEA,IAAWC,KAAKA,CAAA,EAAG;IACf,OAAO,IAAI,CAACP,eAAe,CAACO,KAAK;EACrC;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACR,eAAe,CAACS,UAAU;EAC1C;EAEOC,cAAc,GAAIC,MAA4B,IAAK;IACtD,IAAIA,MAAM,KAAK,IAAI,CAACT,WAAW,EAAE;MAC7B,IAAI,CAACF,eAAe,CAACY,cAAc,CAACD,MAAM,CAAC;IAC/C;EACJ,CAAC;EAEME,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAIA,IAAI,KAAK,IAAI,CAACP,KAAK,IAAI,IAAI,CAACQ,QAAQ,CAACD,IAAI,CAAC,EAAE;MAC5C,IAAI,CAACd,eAAe,CAACgB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,OAAO,KAAK;EAChB,CAAC;EAEMC,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACb,QAAQ,CAACgB,MAAM;EAExEC,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,CAAC,IAAI,CAACJ,QAAQ,CAACI,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIC,KAAK,CAACC,qBAAc,CAACC,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAACrB,QAAQ,CAACgB,MAAM,CAACE,OAAO,CAAC;EACxC,CAAC;AACL;AAACI,OAAA,CAAAzB,gBAAA,GAAAA,gBAAA"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createStyleSheet = void 0;
|
7
|
+
const createStyleSheet = styles => {
|
8
|
+
if (typeof styles === 'function') {
|
9
|
+
return styles;
|
10
|
+
}
|
11
|
+
return styles;
|
12
|
+
};
|
13
|
+
exports.createStyleSheet = createStyleSheet;
|
14
|
+
//# sourceMappingURL=createStyleSheet.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["createStyleSheet","styles","exports"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":";;;;;;AAKO,MAAMA,gBAAgB,GAAuCC,MAA+E,IAAY;EAC3J,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM;EACjB;EAEA,OAAOA,MAAM;AACjB,CAAC;AAAAC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":""}
|
package/lib/commonjs/index.js
CHANGED
@@ -3,18 +3,45 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
Object.defineProperty(exports, "
|
6
|
+
Object.defineProperty(exports, "UnistylesColorScheme", {
|
7
7
|
enumerable: true,
|
8
8
|
get: function () {
|
9
|
-
return
|
9
|
+
return _types.UnistylesColorScheme;
|
10
10
|
}
|
11
11
|
});
|
12
|
-
|
12
|
+
exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
|
13
|
+
Object.defineProperty(exports, "createStyleSheet", {
|
13
14
|
enumerable: true,
|
14
15
|
get: function () {
|
15
|
-
return
|
16
|
+
return _createStyleSheet.createStyleSheet;
|
16
17
|
}
|
17
18
|
});
|
18
|
-
|
19
|
-
|
19
|
+
Object.defineProperty(exports, "useInitialTheme", {
|
20
|
+
enumerable: true,
|
21
|
+
get: function () {
|
22
|
+
return _useInitialTheme.useInitialTheme;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
Object.defineProperty(exports, "useStyles", {
|
26
|
+
enumerable: true,
|
27
|
+
get: function () {
|
28
|
+
return _useStyles.useStyles;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
var _Unistyles = require("./Unistyles");
|
32
|
+
var _types = require("./types");
|
33
|
+
var _useInitialTheme = require("./useInitialTheme");
|
34
|
+
var _useStyles = require("./useStyles");
|
35
|
+
var _createStyleSheet = require("./createStyleSheet");
|
36
|
+
const {
|
37
|
+
addThemes,
|
38
|
+
addBreakpoints,
|
39
|
+
addConfig
|
40
|
+
} = _Unistyles.unistyles.registry;
|
41
|
+
const UnistylesRuntime = exports.UnistylesRuntime = _Unistyles.unistyles.runtime;
|
42
|
+
const UnistylesRegistry = exports.UnistylesRegistry = {
|
43
|
+
addThemes,
|
44
|
+
addBreakpoints,
|
45
|
+
addConfig
|
46
|
+
};
|
20
47
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
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"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesError = exports.UnistylesColorScheme = exports.CxxUnistylesEventTypes = void 0;
|
7
|
+
let UnistylesColorScheme = exports.UnistylesColorScheme = /*#__PURE__*/function (UnistylesColorScheme) {
|
8
|
+
UnistylesColorScheme["System"] = "system";
|
9
|
+
UnistylesColorScheme["Manual"] = "manual";
|
10
|
+
return UnistylesColorScheme;
|
11
|
+
}({});
|
12
|
+
let CxxUnistylesEventTypes = exports.CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
|
13
|
+
CxxUnistylesEventTypes["Theme"] = "theme";
|
14
|
+
CxxUnistylesEventTypes["Size"] = "size";
|
15
|
+
CxxUnistylesEventTypes["Breakpoint"] = "breakpoint";
|
16
|
+
return CxxUnistylesEventTypes;
|
17
|
+
}({});
|
18
|
+
let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
19
|
+
UnistylesError["RuntimeUnavailable"] = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE";
|
20
|
+
UnistylesError["ThemeNotFound"] = "UNISTYLES_ERROR_THEME_NOT_FOUND";
|
21
|
+
return UnistylesError;
|
22
|
+
}({});
|
23
|
+
//# sourceMappingURL=cxx.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesColorScheme","exports","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":";;;;;;IAGYA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAAA,IAwBpBE,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;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -14,4 +14,15 @@ Object.keys(_normalizer).forEach(function (key) {
|
|
14
14
|
}
|
15
15
|
});
|
16
16
|
});
|
17
|
+
var _cxx = require("./cxx");
|
18
|
+
Object.keys(_cxx).forEach(function (key) {
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
20
|
+
if (key in exports && exports[key] === _cxx[key]) return;
|
21
|
+
Object.defineProperty(exports, key, {
|
22
|
+
enumerable: true,
|
23
|
+
get: function () {
|
24
|
+
return _cxx[key];
|
25
|
+
}
|
26
|
+
});
|
27
|
+
});
|
17
28
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
1
|
+
{"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_cxx"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,IAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,IAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,IAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,IAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|