react-native-unistyles 2.0.0-alpha.9 → 2.0.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +28 -0
- package/android/build.gradle +40 -0
- package/android/src/main/cxx/cpp-adapter.cpp +108 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +159 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
- package/cxx/UnistylesRuntime.cpp +55 -2
- package/cxx/UnistylesRuntime.h +15 -9
- package/ios/UnistylesModule.mm +16 -6
- package/lib/commonjs/common.js +30 -16
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +65 -3
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +1 -1
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.web.js +187 -0
- package/lib/commonjs/core/UnistylesModule.web.js.map +1 -0
- package/lib/commonjs/core/UnistylesRuntime.js +15 -16
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/createStyleSheet.js +1 -6
- package/lib/commonjs/createStyleSheet.js.map +1 -1
- package/lib/commonjs/hooks/index.js +7 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useUnistyles.js +12 -9
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +14 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugins/index.js +38 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/index.js +32 -0
- package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
- package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
- package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/commonjs/types/{mq.js → plugin.js} +1 -1
- package/lib/commonjs/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/commonjs/types/stylesheet.js +6 -0
- package/lib/commonjs/types/stylesheet.js.map +1 -0
- package/lib/commonjs/types/variants.js +2 -0
- package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/commonjs/useStyles.js +10 -20
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +13 -59
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +13 -51
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +36 -68
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js +4 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +35 -20
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js +15 -0
- package/lib/commonjs/utils/withPlugins.js.map +1 -0
- package/lib/module/common.js +28 -17
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +65 -3
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +2 -2
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/UnistylesModule.web.js +180 -0
- package/lib/module/core/UnistylesModule.web.js.map +1 -0
- package/lib/module/core/UnistylesRuntime.js +15 -16
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/createStyleSheet.js +1 -6
- package/lib/module/createStyleSheet.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useUnistyles.js +13 -10
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js +7 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugins/index.js +3 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/module/plugins/normalizer/index.js +3 -0
- package/lib/module/plugins/normalizer/index.js.map +1 -0
- package/lib/module/plugins/normalizer/module.d.js.map +1 -0
- package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
- package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/module/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/stylesheet.js.map +1 -0
- package/lib/module/types/variants.js +2 -0
- package/lib/module/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/module/useStyles.js +12 -22
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +12 -56
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +4 -6
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +35 -67
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js +3 -3
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +35 -20
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js +8 -0
- package/lib/module/utils/withPlugins.js.map +1 -0
- package/lib/typescript/src/common.d.ts +23 -12
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +45 -4
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.web.d.ts +19 -0
- package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +8 -9
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +1 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/createStyleSheet.d.ts +2 -2
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
- package/lib/typescript/src/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +51 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugins/index.d.ts +3 -0
- package/lib/typescript/src/plugins/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
- package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
- package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/types/breakpoints.d.ts +25 -12
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +6 -27
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +4 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/plugin.d.ts +7 -0
- package/lib/typescript/src/types/plugin.d.ts.map +1 -0
- package/lib/typescript/src/types/stylesheet.d.ts +40 -0
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +16 -11
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +14 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +3 -3
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +4 -6
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +15 -14
- package/lib/typescript/src/utils/mq.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts +14 -2
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +3 -4
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
- package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
- package/package.json +19 -16
- package/src/__tests__/mocks.ts +24 -0
- package/src/common.ts +30 -14
- package/src/core/UnistyleRegistry.ts +66 -4
- package/src/core/Unistyles.ts +2 -2
- package/src/core/UnistylesModule.web.ts +214 -0
- package/src/core/UnistylesRuntime.ts +18 -20
- package/src/core/index.ts +1 -0
- package/src/createStyleSheet.ts +2 -8
- package/src/global.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUnistyles.ts +12 -10
- package/src/hooks/useVariants.ts +10 -0
- package/src/index.ts +3 -1
- package/src/plugins/index.ts +2 -0
- package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
- package/src/plugins/normalizer/index.ts +2 -0
- package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
- package/src/{utils → plugins/normalizer}/normalizer.ts +3 -3
- package/src/types/breakpoints.ts +57 -25
- package/src/types/core.ts +9 -43
- package/src/types/index.ts +11 -2
- package/src/types/plugin.ts +7 -0
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +18 -13
- package/src/types/variants.ts +19 -0
- package/src/useStyles.ts +18 -25
- package/src/utils/breakpoints.ts +11 -67
- package/src/utils/index.ts +4 -6
- package/src/utils/mq.ts +31 -84
- package/src/utils/mqParser.ts +5 -5
- package/src/utils/styles.ts +44 -50
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/utils/common.js +0 -25
- package/lib/commonjs/utils/common.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.js +0 -10
- package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
- package/lib/commonjs/utils/normalizer.js.map +0 -1
- package/lib/module/types/mq.js +0 -2
- package/lib/module/utils/common.js +0 -17
- package/lib/module/utils/common.js.map +0 -1
- package/lib/module/utils/normalizeStyles.js +0 -3
- package/lib/module/utils/normalizeStyles.js.map +0 -1
- package/lib/module/utils/normalizeStyles.web.js.map +0 -1
- package/lib/module/utils/normalizer.js.map +0 -1
- package/lib/typescript/src/types/mq.d.ts +0 -3
- package/lib/typescript/src/types/mq.d.ts.map +0 -1
- package/lib/typescript/src/utils/common.d.ts +0 -12
- package/lib/typescript/src/utils/common.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
- package/src/types/mq.ts +0 -3
- package/src/utils/common.ts +0 -20
- package/src/utils/normalizeStyles.ts +0 -2
- /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
|
7
7
|
var _breakpoints = require("./breakpoints");
|
8
|
-
var
|
9
|
-
var
|
10
|
-
const proxifyFunction = (
|
11
|
-
apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList),
|
8
|
+
var _common = require("../common");
|
9
|
+
var _withPlugins = require("./withPlugins");
|
10
|
+
const proxifyFunction = (key, fn, variant) => new Proxy(fn, {
|
11
|
+
apply: (target, thisArg, argumentsList) => (0, _withPlugins.withPlugins)(key, parseStyle(target.apply(thisArg, argumentsList), variant))
|
12
12
|
});
|
13
13
|
exports.proxifyFunction = proxifyFunction;
|
14
14
|
const isPlatformColor = value => {
|
@@ -18,26 +18,41 @@ const isPlatformColor = value => {
|
|
18
18
|
return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
|
19
19
|
};
|
20
20
|
exports.isPlatformColor = isPlatformColor;
|
21
|
-
const parseStyle = (style
|
22
|
-
|
23
|
-
|
21
|
+
const parseStyle = function (style) {
|
22
|
+
let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
23
|
+
return Object.entries(style || {}).reduce((acc, _ref) => {
|
24
24
|
let [key, value] = _ref;
|
25
|
-
|
26
|
-
if (
|
27
|
-
|
25
|
+
// nested objects
|
26
|
+
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
27
|
+
acc[key] = parseStyle(value, variant);
|
28
|
+
return acc;
|
28
29
|
}
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
|
31
|
+
// transforms
|
32
|
+
if (key === 'transform' && Array.isArray(value)) {
|
33
|
+
acc[key] = value.map(value => parseStyle(value, variant));
|
34
|
+
return acc;
|
35
|
+
}
|
36
|
+
|
37
|
+
// values or platform colors
|
38
|
+
if (typeof value !== 'object' || isPlatformColor(value)) {
|
39
|
+
acc[key] = value;
|
40
|
+
return acc;
|
32
41
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
if (key === 'variants') {
|
43
|
+
return {
|
44
|
+
...acc,
|
45
|
+
...Object.keys(value).reduce((acc, key) => ({
|
46
|
+
...acc,
|
47
|
+
...parseStyle(value[key][variant[key] || 'default'] ?? {})
|
48
|
+
}), {})
|
49
|
+
};
|
37
50
|
}
|
38
|
-
return
|
39
|
-
|
40
|
-
|
51
|
+
return {
|
52
|
+
...acc,
|
53
|
+
[key]: (0, _breakpoints.getValueForBreakpoint)(value)
|
54
|
+
};
|
55
|
+
}, {});
|
41
56
|
};
|
42
57
|
exports.parseStyle = parseStyle;
|
43
58
|
//# sourceMappingURL=styles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_breakpoints","require","
|
1
|
+
{"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","arguments","length","undefined","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAK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AAOZ,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;MACrDY,GAAG,CAACxB,GAAG,CAAY,GAAGY,KAAK;MAE3B,OAAOY,GAAG;IACd;IAEA,IAAIxB,GAAG,KAAK,UAAU,EAAE;MACpB,OAAO;QACH,GAAGwB,GAAG;QACN,GAAIH,MAAM,CACLQ,IAAI,CAACjB,KAAK,CAAC,CACXW,MAAM,CAAC,CAACC,GAAG,EAAExB,GAAG,MAAM;UACnB,GAAGwB,GAAG;UACN,GAAGf,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACvF,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;IAEA,OAAO;MACH,GAAGwB,GAAG;MACN,CAACxB,GAAG,GAAG,IAAA8B,kCAAqB,EAAClB,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withPlugins = void 0;
|
7
|
+
var _core = require("../core");
|
8
|
+
const withPlugins = (key, style) => _core.unistyles.registry.plugins.reduce((acc, plugin) => {
|
9
|
+
if (plugin.onParsedStyle) {
|
10
|
+
return plugin.onParsedStyle(key, acc, _core.unistyles.runtime);
|
11
|
+
}
|
12
|
+
return acc;
|
13
|
+
}, style);
|
14
|
+
exports.withPlugins = withPlugins;
|
15
|
+
//# sourceMappingURL=withPlugins.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_core","require","withPlugins","key","style","unistyles","registry","plugins","reduce","acc","plugin","onParsedStyle","runtime","exports"],"sourceRoot":"../../../src","sources":["utils/withPlugins.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAGA,CACvBC,GAAW,EACXC,KAAc,KACbC,eAAS,CAACC,QAAQ,CAACC,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EACpD,IAAIA,MAAM,CAACC,aAAa,EAAE;IACtB,OAAOD,MAAM,CAACC,aAAa,CAACR,GAAG,EAAEM,GAAG,EAAEJ,eAAS,CAACO,OAAO,CAAC;EAC5D;EAEA,OAAOH,GAAG;AACd,CAAC,EAAEL,KAAK,CAAC;AAAAS,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
|
package/lib/module/common.js
CHANGED
@@ -1,22 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { Platform } from 'react-native';
|
2
|
+
export const warn = message => {
|
3
|
+
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
4
|
+
};
|
5
|
+
export const isWeb = Platform.OS === 'web';
|
6
|
+
export const isIOS = Platform.OS === 'ios';
|
7
|
+
export const isAndroid = Platform.OS === 'android';
|
8
|
+
export const isMobile = isIOS || isAndroid;
|
9
|
+
export const isServer = typeof window === 'undefined';
|
10
|
+
export const ScreenOrientation = {
|
11
|
+
Landscape: 'landscape',
|
12
|
+
Portrait: 'portrait'
|
13
|
+
};
|
14
|
+
export let UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
|
15
|
+
UnistylesEventType["Theme"] = "theme";
|
16
|
+
UnistylesEventType["Layout"] = "layout";
|
17
|
+
UnistylesEventType["Plugin"] = "plugin";
|
18
|
+
return UnistylesEventType;
|
5
19
|
}({});
|
6
20
|
export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
7
|
-
UnistylesError["RuntimeUnavailable"] = "
|
8
|
-
UnistylesError["ThemeNotFound"] = "
|
9
|
-
UnistylesError["ThemeNotRegistered"] = "
|
10
|
-
UnistylesError["
|
11
|
-
UnistylesError["
|
12
|
-
UnistylesError["
|
21
|
+
UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions";
|
22
|
+
UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered with UnistylesRegistry";
|
23
|
+
UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
|
24
|
+
UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
|
25
|
+
UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
|
26
|
+
UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
|
27
|
+
UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
|
28
|
+
UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
|
29
|
+
UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
|
30
|
+
UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
|
13
31
|
return UnistylesError;
|
14
32
|
}({});
|
15
|
-
|
16
|
-
// todo to string?
|
17
|
-
export let ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
|
18
|
-
ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
|
19
|
-
ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
|
20
|
-
return ScreenOrientation;
|
21
|
-
}({});
|
22
33
|
//# sourceMappingURL=common.js.map
|
package/lib/module/common.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAME,KAAK,GAAGJ,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,SAAS,GAAGP,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMG,QAAQ,GAAGF,KAAK,IAAIC,SAAS;AAC1C,OAAO,MAAME,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAEV,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAM9B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -1,5 +1,8 @@
|
|
1
|
+
import { isWeb, UnistylesError } from '../common';
|
2
|
+
import { normalizeWebStylesPlugin } from '../plugins';
|
1
3
|
export class UnistyleRegistry {
|
2
4
|
config = {};
|
5
|
+
plugins = isWeb ? [normalizeWebStylesPlugin] : [];
|
3
6
|
themeNames = [];
|
4
7
|
themes = {};
|
5
8
|
breakpoints = {};
|
@@ -12,20 +15,79 @@ export class UnistyleRegistry {
|
|
12
15
|
const keys = Object.keys(themes);
|
13
16
|
this.unistylesBridge.themes = keys;
|
14
17
|
this.themeNames = keys;
|
15
|
-
return
|
18
|
+
return {
|
19
|
+
addBreakpoints: this.addBreakpoints,
|
20
|
+
addConfig: this.addConfig
|
21
|
+
};
|
16
22
|
};
|
17
23
|
addBreakpoints = breakpoints => {
|
18
24
|
this.breakpoints = breakpoints;
|
19
25
|
this.unistylesBridge.useBreakpoints(breakpoints);
|
20
26
|
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
|
21
|
-
return
|
27
|
+
return {
|
28
|
+
addThemes: this.addThemes,
|
29
|
+
addConfig: this.addConfig
|
30
|
+
};
|
22
31
|
};
|
23
32
|
addConfig = config => {
|
24
33
|
this.config = config;
|
25
34
|
if (config.adaptiveThemes) {
|
26
35
|
this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
|
27
36
|
}
|
28
|
-
|
37
|
+
if (config.experimentalPlugins) {
|
38
|
+
config.experimentalPlugins.forEach(plugin => this.addPlugin(plugin, false));
|
39
|
+
}
|
40
|
+
if (config.initialTheme) {
|
41
|
+
this.unistylesBridge.useTheme(config.initialTheme);
|
42
|
+
}
|
43
|
+
return {
|
44
|
+
addBreakpoints: this.addBreakpoints,
|
45
|
+
addThemes: this.addThemes
|
46
|
+
};
|
47
|
+
};
|
48
|
+
getTheme = forName => {
|
49
|
+
if (this.themeNames.length === 0) {
|
50
|
+
return {};
|
51
|
+
}
|
52
|
+
if (this.hasTheme(forName)) {
|
53
|
+
return this.themes[forName];
|
54
|
+
}
|
55
|
+
if (this.unistylesBridge.themeName) {
|
56
|
+
throw new Error(UnistylesError.ThemeNotFound);
|
57
|
+
}
|
58
|
+
throw new Error(UnistylesError.ThemeNotSelected);
|
59
|
+
};
|
60
|
+
addPlugin = (() => {
|
61
|
+
var _this = this;
|
62
|
+
return function (plugin) {
|
63
|
+
let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
64
|
+
if (plugin.name.startsWith('__unistyles')) {
|
65
|
+
throw new Error(UnistylesError.InvalidPluginName);
|
66
|
+
}
|
67
|
+
if (_this.plugins.some(_ref => {
|
68
|
+
let {
|
69
|
+
name
|
70
|
+
} = _ref;
|
71
|
+
return name === plugin.name;
|
72
|
+
})) {
|
73
|
+
throw new Error(UnistylesError.DuplicatePluginName);
|
74
|
+
}
|
75
|
+
_this.plugins = [plugin].concat(_this.plugins);
|
76
|
+
_this.unistylesBridge.addPlugin(plugin.name, notify);
|
77
|
+
};
|
78
|
+
})();
|
79
|
+
removePlugin = plugin => {
|
80
|
+
if (plugin.name.startsWith('__unistyles')) {
|
81
|
+
throw new Error(UnistylesError.CantRemoveInternalPlugin);
|
82
|
+
}
|
83
|
+
this.plugins = this.plugins.filter(_ref2 => {
|
84
|
+
let {
|
85
|
+
name
|
86
|
+
} = _ref2;
|
87
|
+
return name !== plugin.name;
|
88
|
+
});
|
89
|
+
this.unistylesBridge.removePlugin(plugin.name);
|
29
90
|
};
|
91
|
+
hasTheme = name => name in this.themes;
|
30
92
|
}
|
31
93
|
//# sourceMappingURL=UnistyleRegistry.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","
|
1
|
+
{"version":3,"names":["isWeb","UnistylesError","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACjD,SAASC,wBAAwB,QAAQ,YAAY;AAErD,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BL,KAAK,GACxC,CAACE,wBAAwB,CAAC,GAC1B,E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AAC;MAC5C6B,KAAI,CAACvB,eAAe,CAACY,SAAS,CAACD,MAAM,CAACgB,IAAI,EAAEH,MAAM,CAAC;IACvD,CAAC;EAAA;EAEMU,YAAY,GAAIvB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACgB,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIR,KAAK,CAAC9B,cAAc,CAAC6C,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAACzC,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC0C,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,OAAKV,IAAI,KAAKhB,MAAM,CAACgB,IAAI;IAAA,EAAC;IACtE,IAAI,CAAC3B,eAAe,CAACkC,YAAY,CAACvB,MAAM,CAACgB,IAAI,CAAC;EAClD,CAAC;EAEMT,QAAQ,GAAIS,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAC/B,MAAM;AAC1E"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { UnistylesModule } from './UnistylesModule';
|
2
2
|
import { UnistylesRuntime } from './UnistylesRuntime';
|
3
3
|
import { UnistyleRegistry } from './UnistyleRegistry';
|
4
|
-
import { UnistylesError } from '../common';
|
4
|
+
import { UnistylesError, isWeb } from '../common';
|
5
5
|
class Unistyles {
|
6
6
|
constructor() {
|
7
7
|
const isInstalled = UnistylesModule?.install() ?? false;
|
@@ -10,7 +10,7 @@ class Unistyles {
|
|
10
10
|
}
|
11
11
|
|
12
12
|
// @ts-ignore
|
13
|
-
this._bridge = global.__UNISTYLES__;
|
13
|
+
this._bridge = (isWeb ? window : global).__UNISTYLES__;
|
14
14
|
this._registry = new UnistyleRegistry(this._bridge);
|
15
15
|
this._runtime = new UnistylesRuntime(this._bridge, this._registry);
|
16
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","_runtime","registry","runtime","unistyles"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,QAAQ,WAAW;
|
1
|
+
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","isWeb","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","window","global","__UNISTYLES__","_registry","_runtime","registry","runtime","unistyles"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,EAAEC,KAAK,QAAQ,WAAW;AAEjD,MAAMC,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGP,eAAe,EAAEQ,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACN,cAAc,CAACO,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAG,CAACP,KAAK,GAAGQ,MAAM,GAAGC,MAAM,EAAEC,aAAgC;IACzE,IAAI,CAACC,SAAS,GAAG,IAAIb,gBAAgB,CAAC,IAAI,CAACS,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIf,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACI,SAAS,CAAC;EACtE;EAEA,IAAWE,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACF,SAAS;EACzB;EAEA,IAAWG,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACF,QAAQ;EACxB;AACJ;AAEA,OAAO,MAAMG,SAAS,GAAG,IAAId,SAAS,CAAC,CAAC"}
|
@@ -0,0 +1,180 @@
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
2
|
+
import { normalizeWebStylesPlugin } from '../plugins';
|
3
|
+
export class UnistylesBridgeWeb {
|
4
|
+
#timerRef = undefined;
|
5
|
+
#hasAdaptiveThemes = false;
|
6
|
+
#supportsAutomaticColorScheme = false;
|
7
|
+
#screenWidth = window.innerWidth;
|
8
|
+
#screenHeight = window.innerHeight;
|
9
|
+
#themes = [];
|
10
|
+
#colorScheme = this.getPreferredColorScheme();
|
11
|
+
#themeName = '';
|
12
|
+
#enabledPlugins = [normalizeWebStylesPlugin.name];
|
13
|
+
#unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
|
14
|
+
#sortedBreakpointPairs = [];
|
15
|
+
#breakpoint = '';
|
16
|
+
constructor() {
|
17
|
+
this.setupListeners();
|
18
|
+
}
|
19
|
+
install() {
|
20
|
+
// @ts-ignore
|
21
|
+
window.__UNISTYLES__ = new Proxy({}, {
|
22
|
+
get: (_target, prop) => {
|
23
|
+
switch (prop) {
|
24
|
+
case 'themeName':
|
25
|
+
return this.getTheme();
|
26
|
+
case 'screenWidth':
|
27
|
+
return this.#screenWidth;
|
28
|
+
case 'screenHeight':
|
29
|
+
return this.#screenHeight;
|
30
|
+
case 'breakpoint':
|
31
|
+
return this.#breakpoint || undefined;
|
32
|
+
case 'hasAdaptiveThemes':
|
33
|
+
return this.#hasAdaptiveThemes;
|
34
|
+
case 'sortedBreakpointPairs':
|
35
|
+
return this.#sortedBreakpointPairs;
|
36
|
+
case 'enabledPlugins':
|
37
|
+
return this.#enabledPlugins;
|
38
|
+
case 'colorScheme':
|
39
|
+
return this.#colorScheme;
|
40
|
+
case 'useTheme':
|
41
|
+
return themeName => this.useTheme(themeName);
|
42
|
+
case 'useBreakpoints':
|
43
|
+
return breakpoints => this.useBreakpoints(breakpoints);
|
44
|
+
case 'useAdaptiveThemes':
|
45
|
+
return enable => this.useAdaptiveThemes(enable);
|
46
|
+
case 'addPlugin':
|
47
|
+
return (pluginName, notify) => this.addPlugin(pluginName, notify);
|
48
|
+
case 'removePlugin':
|
49
|
+
return pluginName => this.removePlugin(pluginName);
|
50
|
+
default:
|
51
|
+
return Reflect.get(this, prop);
|
52
|
+
}
|
53
|
+
},
|
54
|
+
set: (target, prop, newValue, receiver) => {
|
55
|
+
switch (prop) {
|
56
|
+
case 'themes':
|
57
|
+
{
|
58
|
+
this.#themes = newValue;
|
59
|
+
this.#supportsAutomaticColorScheme = newValue.includes('light') && newValue.includes('dark');
|
60
|
+
return true;
|
61
|
+
}
|
62
|
+
case 'themeName':
|
63
|
+
{
|
64
|
+
this.#themeName = newValue;
|
65
|
+
this.emitThemeChange();
|
66
|
+
return true;
|
67
|
+
}
|
68
|
+
default:
|
69
|
+
return Reflect.set(target, prop, newValue, receiver);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
});
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
useTheme(themeName) {
|
76
|
+
this.#themeName = themeName;
|
77
|
+
this.emitThemeChange();
|
78
|
+
}
|
79
|
+
useBreakpoints(breakpoints) {
|
80
|
+
this.#sortedBreakpointPairs = Object.entries(breakpoints).sort((_ref, _ref2) => {
|
81
|
+
let [, a] = _ref;
|
82
|
+
let [, b] = _ref2;
|
83
|
+
return (a ?? 0) - (b ?? 0);
|
84
|
+
});
|
85
|
+
this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
|
86
|
+
}
|
87
|
+
useAdaptiveThemes(enable) {
|
88
|
+
this.#hasAdaptiveThemes = enable;
|
89
|
+
if (!this.#hasAdaptiveThemes || !this.#supportsAutomaticColorScheme) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
if (this.#themeName !== this.#colorScheme) {
|
93
|
+
this.#themeName = this.#colorScheme;
|
94
|
+
this.emitThemeChange();
|
95
|
+
}
|
96
|
+
}
|
97
|
+
addPlugin(pluginName, notify) {
|
98
|
+
this.#enabledPlugins = [pluginName].concat(this.#enabledPlugins);
|
99
|
+
if (notify) {
|
100
|
+
this.emitPluginChange();
|
101
|
+
}
|
102
|
+
}
|
103
|
+
removePlugin(pluginName) {
|
104
|
+
this.#enabledPlugins = this.#enabledPlugins.filter(name => name !== pluginName);
|
105
|
+
this.emitPluginChange();
|
106
|
+
}
|
107
|
+
getTheme() {
|
108
|
+
if (this.#themes.length === 1) {
|
109
|
+
return this.#themes.at(0);
|
110
|
+
}
|
111
|
+
return this.#themeName;
|
112
|
+
}
|
113
|
+
setupListeners() {
|
114
|
+
window.addEventListener('resize', () => {
|
115
|
+
clearTimeout(this.#timerRef);
|
116
|
+
this.#timerRef = setTimeout(() => {
|
117
|
+
this.#screenWidth = window.innerWidth;
|
118
|
+
this.#screenHeight = window.innerHeight;
|
119
|
+
this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
|
120
|
+
this.emitLayoutChange();
|
121
|
+
}, 100);
|
122
|
+
});
|
123
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
124
|
+
this.#colorScheme = event.matches ? 'dark' : 'light';
|
125
|
+
if (!this.#supportsAutomaticColorScheme || !this.#hasAdaptiveThemes) {
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
if (this.#colorScheme !== this.#themeName) {
|
129
|
+
this.#themeName = this.#colorScheme;
|
130
|
+
this.emitThemeChange();
|
131
|
+
}
|
132
|
+
});
|
133
|
+
}
|
134
|
+
getBreakpointFromScreenWidth(width) {
|
135
|
+
const breakpoint = this.#sortedBreakpointPairs.find((_ref3, index, otherBreakpoints) => {
|
136
|
+
let [, value] = _ref3;
|
137
|
+
const minVal = value;
|
138
|
+
const maxVal = otherBreakpoints[index + 1]?.[1];
|
139
|
+
if (!maxVal) {
|
140
|
+
return true;
|
141
|
+
}
|
142
|
+
return width >= minVal && width < maxVal;
|
143
|
+
});
|
144
|
+
return breakpoint?.at(0);
|
145
|
+
}
|
146
|
+
getPreferredColorScheme() {
|
147
|
+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
148
|
+
return 'dark';
|
149
|
+
}
|
150
|
+
return 'light';
|
151
|
+
}
|
152
|
+
emitPluginChange() {
|
153
|
+
this.#unistylesEvents.emit('__unistylesOnChange', {
|
154
|
+
type: 'plugin'
|
155
|
+
});
|
156
|
+
}
|
157
|
+
emitThemeChange() {
|
158
|
+
this.#unistylesEvents.emit('__unistylesOnChange', {
|
159
|
+
type: 'theme',
|
160
|
+
payload: {
|
161
|
+
themeName: this.#themeName
|
162
|
+
}
|
163
|
+
});
|
164
|
+
}
|
165
|
+
emitLayoutChange() {
|
166
|
+
this.#unistylesEvents.emit('__unistylesOnChange', {
|
167
|
+
type: 'layout',
|
168
|
+
payload: {
|
169
|
+
breakpoint: this.#breakpoint,
|
170
|
+
orientation: this.#screenWidth > this.#screenHeight ? 'landscape' : 'portrait',
|
171
|
+
screen: {
|
172
|
+
width: this.#screenWidth,
|
173
|
+
height: this.#screenHeight
|
174
|
+
}
|
175
|
+
}
|
176
|
+
});
|
177
|
+
}
|
178
|
+
}
|
179
|
+
export const UnistylesModule = new UnistylesBridgeWeb();
|
180
|
+
//# sourceMappingURL=UnistylesModule.web.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","breakpoints","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","_ref","_ref2","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","_ref3","index","otherBreakpoints","value","minVal","maxVal","emit","type","payload","orientation","screen","height","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.web.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,QAAQ,YAAY;AAErD,OAAO,MAAMC,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAWC,MAAM,CAACC,UAAU;EACxC,CAACC,YAAY,GAAWF,MAAM,CAACG,WAAW;EAC1C,CAACC,MAAM,GAAiC,EAAE;EAC1C,CAACC,WAAW,GAAoB,IAAI,CAACC,uBAAuB,CAAC,CAAC;EAC9D,CAACC,SAAS,GAA0B,EAAE;EACtC,CAACC,cAAc,GAAkB,CAACf,wBAAwB,CAACgB,IAAI,CAAC;EAChE,CAACC,eAAe,GAAG,IAAInB,kBAAkB,CAACC,aAAa,CAACmB,SAAS,CAAC;EAClE,CAACC,qBAAqB,GAAgD,EAAE;EACxE,CAACC,UAAU,GAA+B,EAAE;EAE5CC,WAAWA,CAAA,EAAG;IACV,IAAI,CAACC,cAAc,CAAC,CAAC;EACzB;EAEOC,OAAOA,CAAA,EAAG;IACb;IACAhB,MAAM,CAACiB,aAAa,GAAG,IAAIC,KAAK,CAAC,CAAC,CAAC,EAAE;MACjCC,GAAG,EAAEA,CAACC,OAAO,EAAEC,IAAI,KAAK;QACpB,QAAQA,IAAI;UACR,KAAK,WAAW;YACZ,OAAO,IAAI,CAACC,QAAQ,CAAC,CAAC;UAC1B,KAAK,aAAa;YACd,OAAO,IAAI,CAAC,CAACvB,WAAW;UAC5B,KAAK,cAAc;YACf,OAAO,IAAI,CAAC,CAACG,YAAY;UAC7B,KAAK,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,EAAE,OAAO;MACbC,OAAO,EAAE;QACL9D,SAAS,EAAE,IAAI,CAAC,CAACA;MACrB;IACJ,CAAC,CAAC;EACN;EAEQgD,gBAAgBA,CAAA,EAAG;IACvB,IAAI,CAAC,CAAC7C,eAAe,CAACyD,IAAI,CAAC,qBAAqB,EAAE;MAC9CC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACLxD,UAAU,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5ByD,WAAW,EAAE,IAAI,CAAC,CAACvE,WAAW,GAAG,IAAI,CAAC,CAACG,YAAY,GAC7C,WAAW,GACX,UAAU;QAChBqE,MAAM,EAAE;UACJZ,KAAK,EAAE,IAAI,CAAC,CAAC5D,WAAW;UACxByE,MAAM,EAAE,IAAI,CAAC,CAACtE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMuE,eAAe,GAAG,IAAI/E,kBAAkB,CAAC,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ScreenOrientation, UnistylesError } from '../common';
|
2
2
|
export class UnistylesRuntime {
|
3
|
-
constructor(unistylesBridge,
|
3
|
+
constructor(unistylesBridge, unistylesRegistry) {
|
4
4
|
this.unistylesBridge = unistylesBridge;
|
5
|
-
this.
|
5
|
+
this.unistylesRegistry = unistylesRegistry;
|
6
6
|
}
|
7
7
|
get colorScheme() {
|
8
8
|
return this.unistylesBridge.colorScheme;
|
@@ -10,15 +10,15 @@ export class UnistylesRuntime {
|
|
10
10
|
get hasAdaptiveThemes() {
|
11
11
|
return this.unistylesBridge.hasAdaptiveThemes;
|
12
12
|
}
|
13
|
-
get sortedBreakpoints() {
|
14
|
-
return this.registry.sortedBreakpointPairs;
|
15
|
-
}
|
16
13
|
get themeName() {
|
17
14
|
return this.unistylesBridge.themeName;
|
18
15
|
}
|
19
16
|
get breakpoint() {
|
20
17
|
return this.unistylesBridge.breakpoint;
|
21
18
|
}
|
19
|
+
get enabledPlugins() {
|
20
|
+
return this.unistylesBridge.enabledPlugins;
|
21
|
+
}
|
22
22
|
get screen() {
|
23
23
|
return {
|
24
24
|
width: this.unistylesBridge.screenWidth,
|
@@ -36,24 +36,23 @@ export class UnistylesRuntime {
|
|
36
36
|
return ScreenOrientation.Portrait;
|
37
37
|
}
|
38
38
|
setTheme = name => {
|
39
|
-
if (this.
|
39
|
+
if (name === this.themeName) {
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
if (this.unistylesRegistry.hasTheme(name)) {
|
40
43
|
this.unistylesBridge.useTheme(name);
|
41
44
|
return true;
|
42
45
|
}
|
43
46
|
throw new Error(UnistylesError.ThemeNotRegistered);
|
44
47
|
};
|
45
|
-
getTheme = forName => {
|
46
|
-
if (this.registry.themeNames.length === 0) {
|
47
|
-
return {};
|
48
|
-
}
|
49
|
-
if (!this.hasTheme(forName)) {
|
50
|
-
throw new Error(UnistylesError.ThemeNotFound);
|
51
|
-
}
|
52
|
-
return this.registry.themes[forName];
|
53
|
-
};
|
54
48
|
setAdaptiveThemes = enable => {
|
55
49
|
this.unistylesBridge.useAdaptiveThemes(enable);
|
56
50
|
};
|
57
|
-
|
51
|
+
addPlugin = plugin => {
|
52
|
+
this.unistylesRegistry.addPlugin(plugin);
|
53
|
+
};
|
54
|
+
removePlugin = plugin => {
|
55
|
+
this.unistylesRegistry.removePlugin(plugin);
|
56
|
+
};
|
58
57
|
}
|
59
58
|
//# sourceMappingURL=UnistylesRuntime.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","
|
1
|
+
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"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AAI,CAAChB,eAAe,CAACkB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,MAAM,IAAIG,KAAK,CAACtB,cAAc,CAACuB,kBAAkB,CAAC;EACtD,CAAC;EAEMC,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAACtB,eAAe,CAACuB,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEME,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAACxB,iBAAiB,CAACuB,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;EAEMC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAACxB,iBAAiB,CAACyB,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createStyleSheet","
|
1
|
+
{"version":3,"names":["createStyleSheet","stylesheet"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useInitialTheme","useUnistyles"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,gBAAgB"}
|
1
|
+
{"version":3,"names":["useInitialTheme","useUnistyles","useVariants"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,QAAQ,eAAe"}
|