react-native-unistyles 2.4.0-rc.2 → 2.5.0-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/common.js +3 -1
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +8 -4
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +7 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js +32 -0
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js +46 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js +77 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/commonjs/core/mocks/index.js +27 -0
- package/lib/commonjs/core/mocks/index.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +2 -2
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/useStyles.js +1 -1
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/module/common.js +2 -0
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +9 -5
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +8 -1
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/mocks/UnistylesMockedBridge.js +25 -0
- package/lib/module/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js +39 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js +69 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/module/core/mocks/index.js +4 -0
- package/lib/module/core/mocks/index.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +2 -2
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/useStyles.js +1 -1
- package/lib/module/useStyles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +2 -0
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts +24 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts +21 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts +41 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/index.d.ts +4 -0
- package/lib/typescript/src/core/mocks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -1
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +2 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +2 -0
- package/src/core/UnistyleRegistry.ts +11 -5
- package/src/core/Unistyles.ts +10 -1
- package/src/core/mocks/UnistylesMockedBridge.ts +26 -0
- package/src/core/mocks/UnistylesMockedRegistry.ts +47 -0
- package/src/core/mocks/UnistylesMockedRuntime.ts +92 -0
- package/src/core/mocks/index.ts +3 -0
- package/src/hooks/useUnistyles.ts +2 -2
- package/src/types/breakpoints.ts +2 -1
- package/src/types/stylesheet.ts +2 -1
- package/src/useStyles.ts +1 -1
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.h +33 -27
package/lib/commonjs/common.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.warn = exports.isWeb = exports.isServer = exports.isMobile = exports.isIOS = exports.isAndroid = exports.UnistylesEventType = exports.UnistylesError = exports.ScreenOrientation = exports.IOSContentSizeCategory = exports.AndroidContentSizeCategory = void 0;
|
6
|
+
exports.warn = exports.isWeb = exports.isTest = exports.isServer = exports.isMobile = exports.isIOS = exports.isDev = exports.isAndroid = exports.UnistylesEventType = exports.UnistylesError = exports.ScreenOrientation = exports.IOSContentSizeCategory = exports.AndroidContentSizeCategory = void 0;
|
7
7
|
var _reactNative = require("react-native");
|
8
8
|
const warn = message => {
|
9
9
|
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
@@ -14,6 +14,8 @@ const isIOS = exports.isIOS = _reactNative.Platform.OS === 'ios';
|
|
14
14
|
const isAndroid = exports.isAndroid = _reactNative.Platform.OS === 'android';
|
15
15
|
const isMobile = exports.isMobile = isIOS || isAndroid;
|
16
16
|
const isServer = exports.isServer = typeof window === 'undefined';
|
17
|
+
const isDev = exports.isDev = process.env.NODE_ENV !== 'production';
|
18
|
+
const isTest = exports.isTest = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined || typeof jest !== 'undefined';
|
17
19
|
const ScreenOrientation = exports.ScreenOrientation = {
|
18
20
|
Landscape: 'landscape',
|
19
21
|
Portrait: 'portrait'
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","warn","message","console","exports","isWeb","Platform","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAEM,MAAMI,KAAK,GAAAD,OAAA,CAAAC,KAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,SAAS,GAAAL,OAAA,CAAAK,SAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMG,QAAQ,GAAAN,OAAA,CAAAM,QAAA,GAAGF,KAAK,IAAIC,SAAS;AACnC,MAAME,QAAQ,GAAAP,OAAA,CAAAO,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;
|
1
|
+
{"version":3,"names":["_reactNative","require","warn","message","console","exports","isWeb","Platform","OS","isIOS","isAndroid","isMobile","isServer","window","isDev","process","env","NODE_ENV","isTest","JEST_WORKER_ID","undefined","jest","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAEM,MAAMI,KAAK,GAAAD,OAAA,CAAAC,KAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,SAAS,GAAAL,OAAA,CAAAK,SAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMG,QAAQ,GAAAN,OAAA,CAAAM,QAAA,GAAGF,KAAK,IAAIC,SAAS;AACnC,MAAME,QAAQ,GAAAP,OAAA,CAAAO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Ac;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -71,13 +71,17 @@ class UnistyleRegistry {
|
|
71
71
|
if (plugin.name.startsWith('__unistyles')) {
|
72
72
|
throw new Error(_common.UnistylesError.InvalidPluginName);
|
73
73
|
}
|
74
|
-
|
74
|
+
const isAlreadyRegistered = this.plugins.some(({
|
75
75
|
name
|
76
|
-
}) => name === plugin.name)
|
76
|
+
}) => name === plugin.name);
|
77
|
+
if (!isAlreadyRegistered) {
|
78
|
+
this.plugins = [plugin].concat(this.plugins);
|
79
|
+
this.unistylesBridge.addPlugin(plugin.name, notify);
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
if (!_common.isDev) {
|
77
83
|
throw new Error(_common.UnistylesError.DuplicatePluginName);
|
78
84
|
}
|
79
|
-
this.plugins = [plugin].concat(this.plugins);
|
80
|
-
this.unistylesBridge.addPlugin(plugin.name, notify);
|
81
85
|
};
|
82
86
|
removePlugin = plugin => {
|
83
87
|
if (plugin.name.startsWith('__unistyles')) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","cssMediaQueriesPlugin","concat","name","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","notify","startsWith","InvalidPluginName","some","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","updateTheme","theme","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAA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C,MAAM,IAAI,IAAI,CAACC,SAAS,CAACD,MAAM,EAAE,KAAK,CAAC,CAAC;IACnE;IAEA,IAAInB,MAAM,CAACqB,YAAY,EAAE;MACrB,IAAI,CAACZ,eAAe,CAACa,QAAQ,CAACtB,MAAM,CAACqB,YAAY,CAAC;IACtD;IAEA,IAAIrB,MAAM,CAACuB,2BAA2B,EAAE;MACpC,IAAI,CAACtB,OAAO,GAAG,CAACuB,8BAAqB,CAAC,CAACC,MAAM,CAAC,IAAI,CAACxB,OAAO,CAAC;MAC3D,IAAI,CAACQ,eAAe,CAACW,SAAS,CAACI,8BAAqB,CAACE,IAAI,EAAE,KAAK,CAAC;IACrE;IAEA,OAAO;MACHb,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCH,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMiB,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,IAAI,CAACxB,UAAU,CAACyB,MAAM,KAAK,CAAC,EAAE;MAC9B,OAAO,CAAC,CAAC;IACb;IAEA,IAAI,IAAI,CAACC,QAAQ,CAACF,OAAO,CAAC,EAAE;MACxB,OAAO,IAAI,CAACvB,MAAM,CAACuB,OAAO,CAAC;IAC/B;IAEA,IAAI,IAAI,CAACnB,eAAe,CAACsB,SAAS,EAAE;MAChC,MAAM,IAAIC,KAAK,CAACC,sBAAc,CAACC,aAAa,CAAC;IACjD;IAEA,MAAM,IAAIF,KAAK,CAACC,sBAAc,CAACE,gBAAgB,CAAC;EACpD,CAAC;EAEMf,SAAS,GAAGA,CAACD,MAAuB,EAAEiB,MAAe,GAAG,IAAI,KAAK;IACpE,IAAIjB,MAAM,CAACO,IAAI,CAACW,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIL,KAAK,CAACC,sBAAc,CAACK,iBAAiB,CAAC;IACrD;IAEA,
|
1
|
+
{"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","cssMediaQueriesPlugin","concat","name","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","notify","startsWith","InvalidPluginName","isAlreadyRegistered","some","isDev","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","updateTheme","theme","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BC,aAAK,GACxC,CAACC,iCAAwB,CAAC,GAC1B,EAAE;EACDC,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;MACHE,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCC,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMD,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACM,cAAc,CAACT,WAAW,CAAC;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AACpB,IAA2B,EAAEqB,KAA6C,KAAK;IACjG,IAAI,CAAC1C,MAAM,CAACqB,IAAI,CAAC,GAAGqB,KAAK;IAEzB,IAAI,IAAI,CAACtC,eAAe,CAACsB,SAAS,KAAKL,IAAI,EAAE;MACzC,IAAI,CAACjB,eAAe,CAACqC,WAAW,CAACpB,IAAI,CAAC;IAC1C;EACJ,CAAC;EAEMI,QAAQ,GAAIJ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACrB,MAAM;AAC1E;AAAC2C,OAAA,CAAAjD,gBAAA,GAAAA,gBAAA"}
|
@@ -8,8 +8,15 @@ var _UnistylesModule = require("./UnistylesModule");
|
|
8
8
|
var _UnistylesRuntime = require("./UnistylesRuntime");
|
9
9
|
var _UnistyleRegistry = require("./UnistyleRegistry");
|
10
10
|
var _common = require("../common");
|
11
|
+
var _mocks = require("./mocks");
|
11
12
|
class Unistyles {
|
12
13
|
constructor() {
|
14
|
+
if (_common.isTest) {
|
15
|
+
this._bridge = new _mocks.UnistylesMockedBridge();
|
16
|
+
this._registry = new _mocks.UnistylesMockedRegistry(this._bridge);
|
17
|
+
this._runtime = new _mocks.UnistylesMockedRuntime(this._bridge, this._registry);
|
18
|
+
return;
|
19
|
+
}
|
13
20
|
const isInstalled = _UnistylesModule.UnistylesModule?.install() ?? false;
|
14
21
|
if (!isInstalled) {
|
15
22
|
throw new Error(_common.UnistylesError.RuntimeUnavailable);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistyleRegistry","_common","Unistyles","constructor","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","
|
1
|
+
{"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistyleRegistry","_common","_mocks","Unistyles","constructor","isTest","_bridge","UnistylesMockedBridge","_registry","UnistylesMockedRegistry","_runtime","UnistylesMockedRuntime","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","isWeb","globalThis","global","__UNISTYLES__","UnistyleRegistry","UnistylesRuntime","registry","runtime","unistyles","exports"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,IAAIC,cAAM,EAAE;MACR,IAAI,CAACC,OAAO,GAAG,IAAIC,4BAAqB,CAAC,CAA+B;MACxE,IAAI,CAACC,SAAS,GAAG,IAAIC,8BAAuB,CAAC,IAAI,CAACH,OAAO,CAAgC;MACzF,IAAI,CAACI,QAAQ,GAAG,IAAIC,6BAAsB,CAAC,IAAI,CAACL,OAAO,EAAE,IAAI,CAACE,SAAS,CAAgC;MAEvG;IACJ;IAEA,MAAMI,WAAW,GAAGC,gCAAe,EAAEC,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACF,WAAW,EAAE;MACd,MAAM,IAAIG,KAAK,CAACC,sBAAc,CAACC,kBAAkB,CAAC;IACtD;;IAEA;IACA;IACA,IAAI,CAACX,OAAO,GAAG,CAACY,aAAK,GAAGC,UAAU,GAAGC,MAAM,EAAEC,aAAgC;IAC7E,IAAI,CAACb,SAAS,GAAG,IAAIc,kCAAgB,CAAC,IAAI,CAAChB,OAAO,CAAC;IACnD,IAAI,CAACI,QAAQ,GAAG,IAAIa,kCAAgB,CAAC,IAAI,CAACjB,OAAO,EAAE,IAAI,CAACE,SAAS,CAAC;EACtE;EAEA,IAAWgB,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAAChB,SAAS;EACzB;EAEA,IAAWiB,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACf,QAAQ;EACxB;AACJ;AAEO,MAAMgB,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIvB,SAAS,CAAC,CAAC"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesMockedBridge = void 0;
|
7
|
+
// @ts-nocheck
|
8
|
+
|
9
|
+
class UnistylesMockedBridge {
|
10
|
+
constructor() {}
|
11
|
+
screenWidth() {}
|
12
|
+
screenHeight() {}
|
13
|
+
enabledPlugins() {}
|
14
|
+
hasAdaptiveThemes() {}
|
15
|
+
themeName() {}
|
16
|
+
breakpoint() {}
|
17
|
+
colorScheme() {}
|
18
|
+
contentSizeCategory() {}
|
19
|
+
sortedBreakpointPairs() {}
|
20
|
+
insets() {}
|
21
|
+
statusBar() {}
|
22
|
+
navigationBar() {}
|
23
|
+
themes(themes) {}
|
24
|
+
useBreakpoints(breakpoints) {}
|
25
|
+
useTheme(name) {}
|
26
|
+
updateTheme(name) {}
|
27
|
+
useAdaptiveThemes(enable) {}
|
28
|
+
addPlugin(pluginName, notify) {}
|
29
|
+
removePlugin(pluginName) {}
|
30
|
+
}
|
31
|
+
exports.UnistylesMockedBridge = UnistylesMockedBridge;
|
32
|
+
//# sourceMappingURL=UnistylesMockedBridge.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesMockedBridge","constructor","screenWidth","screenHeight","enabledPlugins","hasAdaptiveThemes","themeName","breakpoint","colorScheme","contentSizeCategory","sortedBreakpointPairs","insets","statusBar","navigationBar","themes","useBreakpoints","breakpoints","useTheme","name","updateTheme","useAdaptiveThemes","enable","addPlugin","pluginName","notify","removePlugin","exports"],"sourceRoot":"../../../../src","sources":["core/mocks/UnistylesMockedBridge.ts"],"mappings":";;;;;;AAAA;;AAGO,MAAMA,qBAAqB,CAAC;EAC/BC,WAAWA,CAAA,EAAG,CAAC;EAERC,WAAWA,CAAA,EAAG,CAAC;EACfC,YAAYA,CAAA,EAAG,CAAC;EAChBC,cAAcA,CAAA,EAAG,CAAC;EAClBC,iBAAiBA,CAAA,EAAG,CAAC;EACrBC,SAASA,CAAA,EAAG,CAAC;EACbC,UAAUA,CAAA,EAAG,CAAC;EACdC,WAAWA,CAAA,EAAG,CAAC;EACfC,mBAAmBA,CAAA,EAAG,CAAC;EACvBC,qBAAqBA,CAAA,EAAG,CAAC;EACzBC,MAAMA,CAAA,EAAG,CAAC;EACVC,SAASA,CAAA,EAAG,CAAC;EACbC,aAAaA,CAAA,EAAG,CAAC;EACjBC,MAAMA,CAACA,MAAoC,EAAE,CAAC;EAC9CC,cAAcA,CAACC,WAAiC,EAAE,CAAC;EACnDC,QAAQA,CAACC,IAA2B,EAAE,CAAC;EACvCC,WAAWA,CAACD,IAA2B,EAAE,CAAC;EAC1CE,iBAAiBA,CAACC,MAAe,EAAE,CAAC;EACpCC,SAASA,CAACC,UAAkB,EAAEC,MAAe,EAAE,CAAC;EAChDC,YAAYA,CAACF,UAAkB,EAAE,CAAC;AAC7C;AAACG,OAAA,CAAA1B,qBAAA,GAAAA,qBAAA"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesMockedRegistry = void 0;
|
7
|
+
// @ts-nocheck
|
8
|
+
|
9
|
+
class UnistylesMockedRegistry {
|
10
|
+
config = {};
|
11
|
+
breakpoints = {};
|
12
|
+
sortedBreakpointPairs = [];
|
13
|
+
plugins = [];
|
14
|
+
themes = {};
|
15
|
+
themeNames = [];
|
16
|
+
constructor(unistylesBridge) {
|
17
|
+
this.unistylesBridge = unistylesBridge;
|
18
|
+
}
|
19
|
+
addThemes = themes => {
|
20
|
+
this.themes = themes;
|
21
|
+
this.themeNames = Object.keys(themes);
|
22
|
+
return this;
|
23
|
+
};
|
24
|
+
addBreakpoints = breakpoints => {
|
25
|
+
this.breakpoints = breakpoints;
|
26
|
+
this.sortedBreakpointPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
27
|
+
const [, value1] = breakpoint1;
|
28
|
+
const [, value2] = breakpoint2;
|
29
|
+
return value1 - value2;
|
30
|
+
});
|
31
|
+
return this;
|
32
|
+
};
|
33
|
+
addConfig = config => {};
|
34
|
+
getTheme = forName => {
|
35
|
+
if (this.themeNames.length === 0) {
|
36
|
+
return {};
|
37
|
+
}
|
38
|
+
return this.themes[forName];
|
39
|
+
};
|
40
|
+
addPlugin = (plugin, notify = true) => {};
|
41
|
+
removePlugin = plugin => {};
|
42
|
+
updateTheme = (name, theme) => {};
|
43
|
+
hasTheme = name => true;
|
44
|
+
}
|
45
|
+
exports.UnistylesMockedRegistry = UnistylesMockedRegistry;
|
46
|
+
//# sourceMappingURL=UnistylesMockedRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesMockedRegistry","config","breakpoints","sortedBreakpointPairs","plugins","themes","themeNames","constructor","unistylesBridge","addThemes","Object","keys","addBreakpoints","entries","sort","breakpoint1","breakpoint2","value1","value2","addConfig","getTheme","forName","length","addPlugin","plugin","notify","removePlugin","updateTheme","name","theme","hasTheme","exports"],"sourceRoot":"../../../../src","sources":["core/mocks/UnistylesMockedRegistry.ts"],"mappings":";;;;;;AAAA;;AAIO,MAAMA,uBAAuB,CAAC;EAC1BC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EACjHC,OAAO,GAA2B,EAAE;EACpCC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAEpDC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIJ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,UAAU,GAAGI,MAAM,CAACC,IAAI,CAACN,MAAM,CAAiC;IAErE,OAAO,IAAI;EACf,CAAC;EACMO,cAAc,GAAIV,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,qBAAqB,GAAGO,MAAM,CAC9BG,OAAO,CAACX,WAAW,CAAC,CACpBY,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;MAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;MAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;MAE9B,OAAOC,MAAM,GAAGC,MAAM;IAC1B,CAAC,CAA0F;IAE/F,OAAO,IAAI;EACf,CAAC;EACMC,SAAS,GAAIlB,MAAuB,IAAK,CAAC,CAAC;EAC3CmB,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,IAAI,CAACf,UAAU,CAACgB,MAAM,KAAK,CAAC,EAAE;MAC9B,OAAO,CAAC,CAAC;IACb;IAEA,OAAO,IAAI,CAACjB,MAAM,CAACgB,OAAO,CAAC;EAC/B,CAAC;EAEME,SAAS,GAAGA,CAACC,MAAuB,EAAEC,MAAe,GAAG,IAAI,KAAK,CAAC,CAAC;EACnEC,YAAY,GAAIF,MAAuB,IAAK,CAAC,CAAC;EAC9CG,WAAW,GAAGA,CAACC,IAA2B,EAAEC,KAA6C,KAAK,CAAC,CAAC;EAChGC,QAAQ,GAAIF,IAA2B,IAAK,IAAI;AAC3D;AAACG,OAAA,CAAA/B,uBAAA,GAAAA,uBAAA"}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesMockedRuntime = void 0;
|
7
|
+
var _common = require("../../common");
|
8
|
+
// @ts-nocheck
|
9
|
+
|
10
|
+
class UnistylesMockedRuntime {
|
11
|
+
constructor(unistylesBridge, unistylesRegistry) {
|
12
|
+
this.unistylesBridge = unistylesBridge;
|
13
|
+
this.unistylesRegistry = unistylesRegistry;
|
14
|
+
this.unistylesRegistry = unistylesRegistry;
|
15
|
+
}
|
16
|
+
get colorScheme() {
|
17
|
+
return 'dark';
|
18
|
+
}
|
19
|
+
get hasAdaptiveThemes() {
|
20
|
+
return true;
|
21
|
+
}
|
22
|
+
get themeName() {
|
23
|
+
return this.unistylesRegistry.themeNames.length > 0 ? this.unistylesRegistry.themeNames.at(0) : undefined;
|
24
|
+
}
|
25
|
+
get contentSizeCategory() {
|
26
|
+
return 'unspecified';
|
27
|
+
}
|
28
|
+
get breakpoint() {
|
29
|
+
if (this.unistylesRegistry.sortedBreakpointPairs.length === 0) {
|
30
|
+
return undefined;
|
31
|
+
}
|
32
|
+
const firstBreakpoint = this.unistylesRegistry.sortedBreakpointPairs.at(0);
|
33
|
+
return firstBreakpoint ? firstBreakpoint.at(0) : undefined;
|
34
|
+
}
|
35
|
+
get breakpoints() {
|
36
|
+
return this.unistylesRegistry.breakpoints;
|
37
|
+
}
|
38
|
+
get enabledPlugins() {
|
39
|
+
return this.unistylesRegistry.plugins;
|
40
|
+
}
|
41
|
+
get screen() {
|
42
|
+
return {
|
43
|
+
width: 360,
|
44
|
+
height: 800
|
45
|
+
};
|
46
|
+
}
|
47
|
+
get insets() {
|
48
|
+
return {
|
49
|
+
top: 0,
|
50
|
+
right: 0,
|
51
|
+
bottom: 0,
|
52
|
+
left: 0
|
53
|
+
};
|
54
|
+
}
|
55
|
+
get statusBar() {
|
56
|
+
return {
|
57
|
+
height: 24,
|
58
|
+
width: 800
|
59
|
+
};
|
60
|
+
}
|
61
|
+
get navigationBar() {
|
62
|
+
return {
|
63
|
+
height: 0,
|
64
|
+
width: 0
|
65
|
+
};
|
66
|
+
}
|
67
|
+
get orientation() {
|
68
|
+
return _common.ScreenOrientation.Portrait;
|
69
|
+
}
|
70
|
+
setTheme = name => true;
|
71
|
+
updateTheme = (name, theme) => {};
|
72
|
+
setAdaptiveThemes = enabled => {};
|
73
|
+
addPlugin = plugin => {};
|
74
|
+
removePlugin = plugin => {};
|
75
|
+
}
|
76
|
+
exports.UnistylesMockedRuntime = UnistylesMockedRuntime;
|
77
|
+
//# sourceMappingURL=UnistylesMockedRuntime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_common","require","UnistylesMockedRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","themeNames","length","at","undefined","contentSizeCategory","breakpoint","sortedBreakpointPairs","firstBreakpoint","breakpoints","enabledPlugins","plugins","screen","width","height","insets","top","right","bottom","left","statusBar","navigationBar","orientation","ScreenOrientation","Portrait","setTheme","name","updateTheme","theme","setAdaptiveThemes","enabled","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../../src","sources":["core/mocks/UnistylesMockedRuntime.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AADA;;AAOO,MAAMC,sBAAsB,CAAC;EAGhCC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;IAC7F,IAAI,CAACA,iBAAiB,GAAGA,iBAAuD;EACpF;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,MAAM;EACjB;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI;EACf;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACH,iBAAiB,CAACI,UAAU,CAACC,MAAM,GAAG,CAAC,GAC7C,IAAI,CAACL,iBAAiB,CAACI,UAAU,CAACE,EAAE,CAAC,CAAC,CAAC,GACvCC,SAAS;EACnB;EAEA,IAAWC,mBAAmBA,CAAA,EAAG;IAC7B,OAAO,aAAa;EACxB;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,IAAI,IAAI,CAACT,iBAAiB,CAACU,qBAAqB,CAACL,MAAM,KAAK,CAAC,EAAE;MA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use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "UnistylesMockedBridge", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _UnistylesMockedBridge.UnistylesMockedBridge;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
Object.defineProperty(exports, "UnistylesMockedRegistry", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () {
|
15
|
+
return _UnistylesMockedRegistry.UnistylesMockedRegistry;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
Object.defineProperty(exports, "UnistylesMockedRuntime", {
|
19
|
+
enumerable: true,
|
20
|
+
get: function () {
|
21
|
+
return _UnistylesMockedRuntime.UnistylesMockedRuntime;
|
22
|
+
}
|
23
|
+
});
|
24
|
+
var _UnistylesMockedBridge = require("./UnistylesMockedBridge");
|
25
|
+
var _UnistylesMockedRegistry = require("./UnistylesMockedRegistry");
|
26
|
+
var _UnistylesMockedRuntime = require("./UnistylesMockedRuntime");
|
27
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_UnistylesMockedBridge","require","_UnistylesMockedRegistry","_UnistylesMockedRuntime"],"sourceRoot":"../../../../src","sources":["core/mocks/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA"}
|
@@ -16,7 +16,7 @@ const useUnistyles = () => {
|
|
16
16
|
const [layout, setLayout] = (0, _react.useState)({
|
17
17
|
breakpoint: _core.unistyles.runtime.breakpoint,
|
18
18
|
orientation: _core.unistyles.runtime.orientation,
|
19
|
-
|
19
|
+
screen: {
|
20
20
|
width: _core.unistyles.runtime.screen.width,
|
21
21
|
height: _core.unistyles.runtime.screen.height
|
22
22
|
},
|
@@ -49,7 +49,7 @@ const useUnistyles = () => {
|
|
49
49
|
return setLayout({
|
50
50
|
breakpoint: layoutEvent.payload.breakpoint,
|
51
51
|
orientation: layoutEvent.payload.orientation,
|
52
|
-
|
52
|
+
screen: layoutEvent.payload.screen,
|
53
53
|
statusBar: layoutEvent.payload.statusBar,
|
54
54
|
insets: layoutEvent.payload.insets,
|
55
55
|
navigationBar: layoutEvent.payload.navigationBar
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_core","_common","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","plugins","setPlugins","useState","unistyles","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","contentSizeCategory","setContentSizeCategory","layout","setLayout","breakpoint","orientation","
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_core","_common","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","plugins","setPlugins","useState","unistyles","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","contentSizeCategory","setContentSizeCategory","layout","setLayout","breakpoint","orientation","screen","width","height","statusBar","navigationBar","insets","top","bottom","left","right","useEffect","subscription","addListener","event","type","UnistylesEventType","Theme","themeEvent","payload","Layout","layoutEvent","Plugin","DynamicTypeSize","dynamicTypeSizeEvent","remove","exports"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAGA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAACC,eAAS,CAACC,OAAO,CAACC,cAAc,CAAC;EACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,G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ins
|
24
24
|
} = (0, _hooks.useUnistyles)();
|
25
25
|
const variants = (0, _hooks.useVariants)(variantsMap);
|
26
|
-
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
|
26
|
+
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme, _core.unistyles.runtime) : stylesheet, [theme, stylesheet, layout]);
|
27
27
|
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, [key, value]) => {
|
28
28
|
if (typeof value === 'function') {
|
29
29
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","_common","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","key","value","proxifyFunction","StyleSheet","create","withPlugins","parseStyle","isWeb","
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","_common","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","unistyles","runtime","dynamicStyleSheet","Object","entries","reduce","acc","key","value","proxifyFunction","StyleSheet","create","withPlugins","parseStyle","isWeb","registry","config","experimentalCSSMediaQueries","useCSS","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAGA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAA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CHANGED
@@ -7,6 +7,8 @@ export const isIOS = Platform.OS === 'ios';
|
|
7
7
|
export const isAndroid = Platform.OS === 'android';
|
8
8
|
export const isMobile = isIOS || isAndroid;
|
9
9
|
export const isServer = typeof window === 'undefined';
|
10
|
+
export const isDev = process.env.NODE_ENV !== 'production';
|
11
|
+
export const isTest = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined || typeof jest !== 'undefined';
|
10
12
|
export const ScreenOrientation = {
|
11
13
|
Landscape: 'landscape',
|
12
14
|
Portrait: 'portrait'
|
package/lib/module/common.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","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;
|
1
|
+
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","isDev","process","env","NODE_ENV","isTest","JEST_WORKER_ID","undefined","jest","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.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0BAA0B;EAAA,OAA1BA,0BAA0B;AAAA;AAUtC,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAO9B,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,4 +1,4 @@
|
|
1
|
-
import { isWeb, UnistylesError } from '../common';
|
1
|
+
import { isDev, isWeb, UnistylesError } from '../common';
|
2
2
|
import { cssMediaQueriesPlugin, normalizeWebStylesPlugin } from '../plugins';
|
3
3
|
export class UnistyleRegistry {
|
4
4
|
config = {};
|
@@ -65,13 +65,17 @@ export class UnistyleRegistry {
|
|
65
65
|
if (plugin.name.startsWith('__unistyles')) {
|
66
66
|
throw new Error(UnistylesError.InvalidPluginName);
|
67
67
|
}
|
68
|
-
|
68
|
+
const isAlreadyRegistered = this.plugins.some(({
|
69
69
|
name
|
70
|
-
}) => name === plugin.name)
|
70
|
+
}) => name === plugin.name);
|
71
|
+
if (!isAlreadyRegistered) {
|
72
|
+
this.plugins = [plugin].concat(this.plugins);
|
73
|
+
this.unistylesBridge.addPlugin(plugin.name, notify);
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
if (!isDev) {
|
71
77
|
throw new Error(UnistylesError.DuplicatePluginName);
|
72
78
|
}
|
73
|
-
this.plugins = [plugin].concat(this.plugins);
|
74
|
-
this.unistylesBridge.addPlugin(plugin.name, notify);
|
75
79
|
};
|
76
80
|
removePlugin = plugin => {
|
77
81
|
if (plugin.name.startsWith('__unistyles')) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isWeb","UnistylesError","cssMediaQueriesPlugin","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","concat","name","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","notify","startsWith","InvalidPluginName","some","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","updateTheme","theme"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;
|
1
|
+
{"version":3,"names":["isDev","isWeb","UnistylesError","cssMediaQueriesPlugin","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","concat","name","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","notify","startsWith","InvalidPluginName","isAlreadyRegistered","some","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","updateTheme","theme"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACxD,SAASC,qBAAqB,EAAEC,wBAAwB,QAAQ,YAAY;AAE5E,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BN,KAAK,GACxC,CAACG,wBAAwB,CAAC,GAC1B,EAAE;EACDI,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,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tC,KAAK,EAAE;MACR,MAAM,IAAImC,KAAK,CAACjC,cAAc,CAACyC,mBAAmB,CAAC;IACvD;EACJ,CAAC;EAEMC,YAAY,GAAIrB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACM,IAAI,CAACU,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIJ,KAAK,CAACjC,cAAc,CAAC2C,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAACtC,OAAO,GAAG,IAAI,CAACA,OAAO,CAACuC,MAAM,CAAC,CAAC;MAAEjB;IAAK,CAAC,KAAKA,IAAI,KAAKN,MAAM,CAACM,IAAI,CAAC;IACtE,IAAI,CAAChB,eAAe,CAAC+B,YAAY,CAACrB,MAAM,CAACM,IAAI,CAAC;EAClD,CAAC;EAEMkB,WAAW,GAAGA,CAAClB,IAA2B,EAAEmB,KAA6C,KAAK;IACjG,IAAI,CAACvC,MAAM,CAACoB,IAAI,CAAC,GAAGmB,KAAK;IAEzB,IAAI,IAAI,CAACnC,eAAe,CAACqB,SAAS,KAAKL,IAAI,EAAE;MACzC,IAAI,CAAChB,eAAe,CAACkC,WAAW,CAAClB,IAAI,CAAC;IAC1C;EACJ,CAAC;EAEMI,QAAQ,GAAIJ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACpB,MAAM;AAC1E"}
|
@@ -1,9 +1,16 @@
|
|
1
1
|
import { UnistylesModule } from './UnistylesModule';
|
2
2
|
import { UnistylesRuntime } from './UnistylesRuntime';
|
3
3
|
import { UnistyleRegistry } from './UnistyleRegistry';
|
4
|
-
import { UnistylesError, isWeb } from '../common';
|
4
|
+
import { UnistylesError, isTest, isWeb } from '../common';
|
5
|
+
import { UnistylesMockedBridge, UnistylesMockedRegistry, UnistylesMockedRuntime } from './mocks';
|
5
6
|
class Unistyles {
|
6
7
|
constructor() {
|
8
|
+
if (isTest) {
|
9
|
+
this._bridge = new UnistylesMockedBridge();
|
10
|
+
this._registry = new UnistylesMockedRegistry(this._bridge);
|
11
|
+
this._runtime = new UnistylesMockedRuntime(this._bridge, this._registry);
|
12
|
+
return;
|
13
|
+
}
|
7
14
|
const isInstalled = UnistylesModule?.install() ?? false;
|
8
15
|
if (!isInstalled) {
|
9
16
|
throw new Error(UnistylesError.RuntimeUnavailable);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","isWeb","Unistyles","constructor","
|
1
|
+
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","isTest","isWeb","UnistylesMockedBridge","UnistylesMockedRegistry","UnistylesMockedRuntime","Unistyles","constructor","_bridge","_registry","_runtime","isInstalled","install","Error","RuntimeUnavailable","globalThis","global","__UNISTYLES__","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,MAAM,EAAEC,KAAK,QAAQ,WAAW;AACzD,SAASC,qBAAqB,EAAEC,uBAAuB,EAAEC,sBAAsB,QAAQ,SAAS;AAEhG,MAAMC,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,IAAIN,MAAM,EAAE;MACR,IAAI,CAACO,OAAO,GAAG,IAAIL,qBAAqB,CAAC,CAA+B;MACxE,IAAI,CAACM,SAAS,GAAG,IAAIL,uBAAuB,CAAC,IAAI,CAACI,OAAO,CAAgC;MACzF,IAAI,CAACE,QAAQ,GAAG,IAAIL,sBAAsB,CAAC,IAAI,CAACG,OAAO,EAAE,IAAI,CAACC,SAAS,CAAgC;MAEvG;IACJ;IAEA,MAAME,WAAW,GAAGd,eAAe,EAAEe,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACb,cAAc,CAACc,kBAAkB,CAAC;IACtD;;IAEA;IACA;IACA,IAAI,CAACN,OAAO,GAAG,CAACN,KAAK,GAAGa,UAAU,GAAGC,MAAM,EAAEC,aAAgC;IAC7E,IAAI,CAACR,SAAS,GAAG,IAAIV,gBAAgB,CAAC,IAAI,CAACS,OAAO,CAAC;IACnD,IAAI,CAACE,QAAQ,GAAG,IAAIZ,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACC,SAAS,CAAC;EACtE;EAEA,IAAWS,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACT,SAAS;EACzB;EAEA,IAAWU,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACT,QAAQ;EACxB;AACJ;AAEA,OAAO,MAAMU,SAAS,GAAG,IAAId,SAAS,CAAC,CAAC"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// @ts-nocheck
|
2
|
+
|
3
|
+
export class UnistylesMockedBridge {
|
4
|
+
constructor() {}
|
5
|
+
screenWidth() {}
|
6
|
+
screenHeight() {}
|
7
|
+
enabledPlugins() {}
|
8
|
+
hasAdaptiveThemes() {}
|
9
|
+
themeName() {}
|
10
|
+
breakpoint() {}
|
11
|
+
colorScheme() {}
|
12
|
+
contentSizeCategory() {}
|
13
|
+
sortedBreakpointPairs() {}
|
14
|
+
insets() {}
|
15
|
+
statusBar() {}
|
16
|
+
navigationBar() {}
|
17
|
+
themes(themes) {}
|
18
|
+
useBreakpoints(breakpoints) {}
|
19
|
+
useTheme(name) {}
|
20
|
+
updateTheme(name) {}
|
21
|
+
useAdaptiveThemes(enable) {}
|
22
|
+
addPlugin(pluginName, notify) {}
|
23
|
+
removePlugin(pluginName) {}
|
24
|
+
}
|
25
|
+
//# sourceMappingURL=UnistylesMockedBridge.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesMockedBridge","constructor","screenWidth","screenHeight","enabledPlugins","hasAdaptiveThemes","themeName","breakpoint","colorScheme","contentSizeCategory","sortedBreakpointPairs","insets","statusBar","navigationBar","themes","useBreakpoints","breakpoints","useTheme","name","updateTheme","useAdaptiveThemes","enable","addPlugin","pluginName","notify","removePlugin"],"sourceRoot":"../../../../src","sources":["core/mocks/UnistylesMockedBridge.ts"],"mappings":"AAAA;;AAGA,OAAO,MAAMA,qBAAqB,CAAC;EAC/BC,WAAWA,CAAA,EAAG,CAAC;EAERC,WAAWA,CAAA,EAAG,CAAC;EACfC,YAAYA,CAAA,EAAG,CAAC;EAChBC,cAAcA,CAAA,EAAG,CAAC;EAClBC,iBAAiBA,CAAA,EAAG,CAAC;EACrBC,SAASA,CAAA,EAAG,CAAC;EACbC,UAAUA,CAAA,EAAG,CAAC;EACdC,WAAWA,CAAA,EAAG,CAAC;EACfC,mBAAmBA,CAAA,EAAG,CAAC;EACvBC,qBAAqBA,CAAA,EAAG,CAAC;EACzBC,MAAMA,CAAA,EAAG,CAAC;EACVC,SAASA,CAAA,EAAG,CAAC;EACbC,aAAaA,CAAA,EAAG,CAAC;EACjBC,MAAMA,CAACA,MAAoC,EAAE,CAAC;EAC9CC,cAAcA,CAACC,WAAiC,EAAE,CAAC;EACnDC,QAAQA,CAACC,IAA2B,EAAE,CAAC;EACvCC,WAAWA,CAACD,IAA2B,EAAE,CAAC;EAC1CE,iBAAiBA,CAACC,MAAe,EAAE,CAAC;EACpCC,SAASA,CAACC,UAAkB,EAAEC,MAAe,EAAE,CAAC;EAChDC,YAAYA,CAACF,UAAkB,EAAE,CAAC;AAC7C"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// @ts-nocheck
|
2
|
+
|
3
|
+
export class UnistylesMockedRegistry {
|
4
|
+
config = {};
|
5
|
+
breakpoints = {};
|
6
|
+
sortedBreakpointPairs = [];
|
7
|
+
plugins = [];
|
8
|
+
themes = {};
|
9
|
+
themeNames = [];
|
10
|
+
constructor(unistylesBridge) {
|
11
|
+
this.unistylesBridge = unistylesBridge;
|
12
|
+
}
|
13
|
+
addThemes = themes => {
|
14
|
+
this.themes = themes;
|
15
|
+
this.themeNames = Object.keys(themes);
|
16
|
+
return this;
|
17
|
+
};
|
18
|
+
addBreakpoints = breakpoints => {
|
19
|
+
this.breakpoints = breakpoints;
|
20
|
+
this.sortedBreakpointPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
21
|
+
const [, value1] = breakpoint1;
|
22
|
+
const [, value2] = breakpoint2;
|
23
|
+
return value1 - value2;
|
24
|
+
});
|
25
|
+
return this;
|
26
|
+
};
|
27
|
+
addConfig = config => {};
|
28
|
+
getTheme = forName => {
|
29
|
+
if (this.themeNames.length === 0) {
|
30
|
+
return {};
|
31
|
+
}
|
32
|
+
return this.themes[forName];
|
33
|
+
};
|
34
|
+
addPlugin = (plugin, notify = true) => {};
|
35
|
+
removePlugin = plugin => {};
|
36
|
+
updateTheme = (name, theme) => {};
|
37
|
+
hasTheme = name => true;
|
38
|
+
}
|
39
|
+
//# sourceMappingURL=UnistylesMockedRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesMockedRegistry","config","breakpoints","sortedBreakpointPairs","plugins","themes","themeNames","constructor","unistylesBridge","addThemes","Object","keys","addBreakpoints","entries","sort","breakpoint1","breakpoint2","value1","value2","addConfig","getTheme","forName","length","addPlugin","plugin","notify","removePlugin","updateTheme","name","theme","hasTheme"],"sourceRoot":"../../../../src","sources":["core/mocks/UnistylesMockedRegistry.ts"],"mappings":"AAAA;;AAIA,OAAO,MAAMA,uBAAuB,CAAC;EAC1BC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EACjHC,OAAO,GAA2B,EAAE;EACpCC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAEpDC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIJ,MAAuB,IAAK;IAC5C,IA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