UNPKG

2.35 kBJavaScriptView Raw
1Object.defineProperty(exports, "__esModule", {
2 value: true
3});
4var styleInterface = void 0;
5var styleTheme = void 0;
6
7function registerTheme(theme) {
8 styleTheme = theme;
9}
10
11function registerInterface(interfaceToRegister) {
12 styleInterface = interfaceToRegister;
13}
14
15function create(makeFromTheme, createWithDirection) {
16 var styles = createWithDirection(makeFromTheme(styleTheme));
17 return function () {
18 return styles;
19 };
20}
21
22function createLTR(makeFromTheme) {
23 return create(makeFromTheme, styleInterface.createLTR || styleInterface.create);
24}
25
26function createRTL(makeFromTheme) {
27 return create(makeFromTheme, styleInterface.createRTL || styleInterface.create);
28}
29
30function get() {
31 return styleTheme;
32}
33
34function resolve() {
35 if (process.env.NODE_ENV !== 'production' && typeof performance !== 'undefined' && performance.mark !== undefined) {
36 performance.mark('react-with-styles.resolve.start');
37 }
38
39 for (var _len = arguments.length, styles = Array(_len), _key = 0; _key < _len; _key++) {
40 styles[_key] = arguments[_key];
41 }
42
43 var result = styleInterface.resolve(styles);
44
45 if (process.env.NODE_ENV !== 'production' && typeof performance !== 'undefined' && performance.mark !== undefined) {
46 performance.mark('react-with-styles.resolve.end');
47
48 performance.measure('\uD83D\uDC69\u200D\uD83C\uDFA8 [resolve]', 'react-with-styles.resolve.start', 'react-with-styles.resolve.end');
49 }
50
51 return result;
52}
53
54function resolveLTR() {
55 for (var _len2 = arguments.length, styles = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
56 styles[_key2] = arguments[_key2];
57 }
58
59 if (styleInterface.resolveLTR) {
60 return styleInterface.resolveLTR(styles);
61 }
62
63 return resolve(styles);
64}
65
66function resolveRTL() {
67 for (var _len3 = arguments.length, styles = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
68 styles[_key3] = arguments[_key3];
69 }
70
71 if (styleInterface.resolveRTL) {
72 return styleInterface.resolveRTL(styles);
73 }
74
75 return resolve(styles);
76}
77
78function flush() {
79 if (styleInterface.flush) {
80 styleInterface.flush();
81 }
82}
83
84exports['default'] = {
85 registerTheme: registerTheme,
86 registerInterface: registerInterface,
87 create: createLTR,
88 createLTR: createLTR,
89 createRTL: createRTL,
90 get: get,
91 resolve: resolveLTR,
92 resolveLTR: resolveLTR,
93 resolveRTL: resolveRTL,
94 flush: flush
95};
\No newline at end of file