react-native-unistyles 3.0.0-alpha.13 → 3.0.0-alpha.14
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/core/UnistyleWrapper.h +1 -1
- package/cxx/core/UnistylesCommitHook.cpp +5 -2
- package/cxx/hybridObjects/HybridStyleSheet.cpp +1 -3
- package/cxx/hybridObjects/HybridStyleSheet.h +1 -1
- package/lib/commonjs/index.js +4 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +7 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +1 -1
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/create.js +25 -63
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/createUnistylesComponent.js +61 -0
- package/lib/commonjs/web/createUnistylesComponent.js.map +1 -0
- package/lib/commonjs/web/index.js +12 -3
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener/index.js +7 -0
- package/lib/commonjs/web/listener/index.js.map +1 -1
- package/lib/commonjs/web/listener/listenToDependencies.js +39 -0
- package/lib/commonjs/web/listener/listenToDependencies.js.map +1 -0
- package/lib/commonjs/web/listener/listener.js +1 -2
- package/lib/commonjs/web/listener/listener.js.map +1 -1
- package/lib/commonjs/web/mock.js +1 -10
- package/lib/commonjs/web/mock.js.map +1 -1
- package/lib/commonjs/web/pseudo.js +2 -3
- package/lib/commonjs/web/pseudo.js.map +1 -1
- package/lib/commonjs/web/registry.js +2 -4
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +0 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +120 -0
- package/lib/commonjs/web/shadowRegistry.js.map +1 -0
- package/lib/commonjs/web/state.js +0 -40
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils.js +66 -14
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/commonjs/web/variants/useVariants.js +1 -34
- package/lib/commonjs/web/variants/useVariants.js.map +1 -1
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +7 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/web/convert/index.js +1 -1
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/create.js +26 -64
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/createUnistylesComponent.js +54 -0
- package/lib/module/web/createUnistylesComponent.js.map +1 -0
- package/lib/module/web/index.js +4 -2
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/listener/index.js +1 -0
- package/lib/module/web/listener/index.js.map +1 -1
- package/lib/module/web/listener/listenToDependencies.js +34 -0
- package/lib/module/web/listener/listenToDependencies.js.map +1 -0
- package/lib/module/web/listener/listener.js +1 -1
- package/lib/module/web/listener/listener.js.map +1 -1
- package/lib/module/web/mock.js +0 -9
- package/lib/module/web/mock.js.map +1 -1
- package/lib/module/web/pseudo.js +2 -3
- package/lib/module/web/pseudo.js.map +1 -1
- package/lib/module/web/registry.js +2 -4
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +0 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +116 -0
- package/lib/module/web/shadowRegistry.js.map +1 -0
- package/lib/module/web/state.js +0 -40
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils.js +59 -12
- package/lib/module/web/utils.js.map +1 -1
- package/lib/module/web/variants/useVariants.js +1 -34
- package/lib/module/web/variants/useVariants.js.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/createUnistylesComponent.d.ts +3 -0
- package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -0
- package/lib/typescript/src/web/index.d.ts +2 -1
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener/index.d.ts +1 -0
- package/lib/typescript/src/web/listener/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener/listenToDependencies.d.ts +12 -0
- package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -0
- package/lib/typescript/src/web/listener/listener.d.ts +2 -1
- package/lib/typescript/src/web/listener/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/mock.d.ts +0 -9
- package/lib/typescript/src/web/mock.d.ts.map +1 -1
- package/lib/typescript/src/web/pseudo.d.ts +4 -2
- package/lib/typescript/src/web/pseudo.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +0 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
- package/lib/typescript/src/web/state.d.ts +0 -5
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils.d.ts +22 -7
- package/lib/typescript/src/web/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +8 -3
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +14 -2
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +4 -1
- package/package.json +3 -3
- package/src/index.ts +3 -0
- package/src/specs/ShadowRegistry/index.ts +7 -1
- package/src/web/convert/index.ts +1 -1
- package/src/web/create.ts +24 -79
- package/src/web/createUnistylesComponent.tsx +56 -0
- package/src/web/index.ts +3 -2
- package/src/web/listener/index.ts +1 -0
- package/src/web/listener/listenToDependencies.ts +50 -0
- package/src/web/listener/listener.ts +1 -1
- package/src/web/mock.ts +0 -10
- package/src/web/pseudo.ts +131 -5
- package/src/web/registry.ts +3 -5
- package/src/web/runtime.ts +0 -2
- package/src/web/shadowRegistry.ts +121 -0
- package/src/web/state.ts +0 -44
- package/src/web/utils.ts +90 -16
- package/src/web/variants/useVariants.ts +1 -37
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_NativePlatform","require","_types","_types2","_listener","_mock","_state","_utils","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","isServer","window","matchMedia","colorScheme","matches","ColorScheme","Light","Dark","Unspecified","themeName","UnistylesState","contentSizeCategory","WebContentSizeCategory","breakpoint","orientation","Orientation","Portrait","screen","type","includes","Landscape","theme","Error","themes","get","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","StatusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","NavigationBar","miniRuntime","setTheme","UnistylesRuntime","UnistylesListener","emitChange","UnistyleDependency","Theme","ThemeName","setAdaptiveThemes","isEnabled","schemeToTheme","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","hexToRGBA","setImmersiveMode","updateTheme","updater","oldTheme","set","
|
1
|
+
{"version":3,"names":["_NativePlatform","require","_types","_types2","_listener","_mock","_state","_utils","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","isServer","window","matchMedia","colorScheme","matches","ColorScheme","Light","Dark","Unspecified","themeName","UnistylesState","contentSizeCategory","WebContentSizeCategory","breakpoint","orientation","Orientation","Portrait","screen","type","includes","Landscape","theme","Error","themes","get","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","StatusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","NavigationBar","miniRuntime","setTheme","UnistylesRuntime","UnistylesListener","emitChange","UnistyleDependency","Theme","ThemeName","setAdaptiveThemes","isEnabled","schemeToTheme","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","hexToRGBA","setImmersiveMode","updateTheme","updater","oldTheme","set","exports"],"sourceRoot":"../../../src","sources":["web/runtime.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA,MAAMO,uBAAuB,CAAC;EAC1BC,UAAU,GAAG,IAAI,CAACC,aAAa,CAAC,CAAC;EACjCC,SAAS,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;EAEvBF,aAAaA,CAAA,EAA0B;IAC3C,IAAI,IAAAG,eAAQ,EAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,IAAI,CAAC,IAAI,CAACJ,UAAU,EAAE;MAClB,IAAI,CAACA,UAAU,GAAGK,MAAM,CAACC,UAAU,CAAC,+BAA+B,CAAC;IACxE;IAEA,OAAO,IAAI,CAACN,UAAU;EAC1B;EAEQG,YAAYA,CAAA,EAA0B;IAC1C,IAAI,IAAAC,eAAQ,EAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,I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A,CAAA,KAAM,CAAC,CAAC;EAE3BC,WAAW,GAAGA,CAACxD,SAAuB,EAAEyD,OAA6C,KAAK;IACtF,MAAMC,QAAQ,GAAGzD,qBAAc,CAACa,MAAM,CAACC,GAAG,CAACf,SAAS,CAAC;IAErD,IAAI,CAAC0D,QAAQ,EAAE;MACX,MAAM,IAAI7C,KAAK,CAAC,aAAab,SAAS,sBAAsB,CAAC;IACjE;IAEAC,qBAAc,CAACa,MAAM,CAAC6C,GAAG,CAAC3D,SAAS,EAAEyD,OAAO,CAACC,QAAQ,CAAC,CAAC;EAC3D,CAAC;AACL;AAEO,MAAMlB,gBAAgB,GAAAoB,OAAA,CAAApB,gBAAA,GAAG,IAAItD,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,120 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesShadowRegistry = void 0;
|
7
|
+
var _listener = require("./listener");
|
8
|
+
var _registry = require("./registry");
|
9
|
+
var _runtime = require("./runtime");
|
10
|
+
var _utils = require("./utils");
|
11
|
+
var _variants2 = require("./variants");
|
12
|
+
class UnistylesShadowRegistryBuilder {
|
13
|
+
// MOCKS
|
14
|
+
name = 'UnistylesShadowRegistry';
|
15
|
+
__type = 'web';
|
16
|
+
equals = () => true;
|
17
|
+
toString = () => 'UnistylesShadowRegistry';
|
18
|
+
dispose = () => {};
|
19
|
+
// END MOCKS
|
20
|
+
|
21
|
+
webUnistylesMap = (0, _utils.createDoubleMap)();
|
22
|
+
disposeMap = (0, _utils.createDoubleMap)();
|
23
|
+
stylesMap = (0, _utils.createDoubleMap)();
|
24
|
+
add = (ref, _style, _variants, _args) => {
|
25
|
+
// Style is not provided
|
26
|
+
if (!_style) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
30
|
+
// Array of styles
|
31
|
+
if (Array.isArray(_style)) {
|
32
|
+
_style.forEach(style => this.add(ref, style, _variants, _args));
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
|
36
|
+
// Not a unistyle
|
37
|
+
if (!Object.keys(_style).some(key => key.startsWith('__uni__'))) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
|
41
|
+
// Ref is unmounted, remove style tags from the document
|
42
|
+
if (ref === null) {
|
43
|
+
const secrets = (0, _utils.extractSecrets)(_style);
|
44
|
+
secrets.forEach(({
|
45
|
+
__uni__refs
|
46
|
+
}) => {
|
47
|
+
__uni__refs.forEach(ref => {
|
48
|
+
if ((0, _utils.isInDocument)(ref)) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
this.remove(ref, _style);
|
52
|
+
});
|
53
|
+
});
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
|
57
|
+
// Ref is not an HTMLElement
|
58
|
+
if (!(ref instanceof HTMLElement)) {
|
59
|
+
return;
|
60
|
+
}
|
61
|
+
(0, _utils.extractSecrets)(_style).forEach(secret => {
|
62
|
+
const {
|
63
|
+
__uni__key,
|
64
|
+
__uni__stylesheet,
|
65
|
+
__uni__refs,
|
66
|
+
__uni__variants,
|
67
|
+
__uni__args = []
|
68
|
+
} = secret;
|
69
|
+
const newComputedStylesheet = typeof __uni__stylesheet === 'function' ? __uni__stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : __uni__stylesheet;
|
70
|
+
const style = newComputedStylesheet[__uni__key];
|
71
|
+
const args = _args ?? __uni__args;
|
72
|
+
const resultHidden = typeof style === 'function' ? style(...args) : style;
|
73
|
+
const result = (0, _utils.extractHiddenProperties)(resultHidden);
|
74
|
+
const {
|
75
|
+
variants
|
76
|
+
} = Object.fromEntries((0, _variants2.getVariants)({
|
77
|
+
variants: result
|
78
|
+
}, _variants && Object.keys(_variants).length > 0 ? _variants : __uni__variants));
|
79
|
+
const resultWithVariants = {
|
80
|
+
...result,
|
81
|
+
...variants
|
82
|
+
};
|
83
|
+
const storedWebUnistyle = this.webUnistylesMap.get(ref, __uni__key);
|
84
|
+
const webUnistyle = storedWebUnistyle ?? _registry.UnistylesRegistry.createStyles(resultWithVariants, __uni__key);
|
85
|
+
this.webUnistylesMap.set(ref, __uni__key, webUnistyle);
|
86
|
+
this.disposeMap.get(ref, __uni__key)?.();
|
87
|
+
this.disposeMap.set(ref, __uni__key, (0, _listener.listenToDependencies)({
|
88
|
+
key: __uni__key,
|
89
|
+
stylesheet: __uni__stylesheet,
|
90
|
+
args,
|
91
|
+
className: webUnistyle.className,
|
92
|
+
unistyles: webUnistyle.unistyles
|
93
|
+
}));
|
94
|
+
if (!storedWebUnistyle) {
|
95
|
+
const styleTag = document.createElement('style');
|
96
|
+
ref.classList.add(webUnistyle.className);
|
97
|
+
webUnistyle.unistyles.setStylesTarget(styleTag);
|
98
|
+
document.head.appendChild(styleTag);
|
99
|
+
__uni__refs.add(ref);
|
100
|
+
this.stylesMap.set(ref, __uni__key, styleTag);
|
101
|
+
}
|
102
|
+
if (storedWebUnistyle) {
|
103
|
+
_registry.UnistylesRegistry.updateStyles(webUnistyle.unistyles, resultWithVariants, webUnistyle.className);
|
104
|
+
}
|
105
|
+
});
|
106
|
+
};
|
107
|
+
remove = (ref, style) => {
|
108
|
+
(0, _utils.extractSecrets)(style).forEach(({
|
109
|
+
__uni__key
|
110
|
+
}) => {
|
111
|
+
this.webUnistylesMap.delete(ref, __uni__key);
|
112
|
+
this.disposeMap.get(ref, __uni__key)?.();
|
113
|
+
this.disposeMap.delete(ref, __uni__key);
|
114
|
+
this.stylesMap.get(ref, __uni__key)?.remove();
|
115
|
+
this.stylesMap.delete(ref, __uni__key);
|
116
|
+
});
|
117
|
+
};
|
118
|
+
}
|
119
|
+
const UnistylesShadowRegistry = exports.UnistylesShadowRegistry = new UnistylesShadowRegistryBuilder();
|
120
|
+
//# sourceMappingURL=shadowRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_listener","require","_registry","_runtime","_utils","_variants2","UnistylesShadowRegistryBuilder","name","__type","equals","toString","dispose","webUnistylesMap","createDoubleMap","disposeMap","stylesMap","add","ref","_style","_variants","_args","Array","isArray","forEach","style","Object","keys","some","key","startsWith","secrets","extractSecrets","__uni__refs","isInDocument","remove","HTMLElement","secret","__uni__key","__uni__stylesheet","__uni__variants","__uni__args","newComputedStylesheet","UnistylesRuntime","theme","miniRuntime","args","resultHidden","result","extractHiddenProperties","variants","fromEntries","getVariants","length","resultWithVariants","storedWebUnistyle","get","webUnistyle","UnistylesRegistry","createStyles","set","listenToDependencies","stylesheet","className","unistyles","styleTag","document","createElement","classList","setStylesTarget","head","appendChild","updateStyles","delete","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../src","sources":["web/shadowRegistry.ts"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAMA,MAAMK,8BAA8B,CAAC;EACjC;EACAC,IAAI,GAAG,yBAAyB;EAChCC,MAAM,GAAG,KAAK;EACdC,MAAM,GAAGA,CAAA,KAAM,IAAI;EACnBC,QAAQ,GAAGA,CAAA,KAAM,yBAAyB;EAC1CC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;EAClB;;EAEiBC,eAAe,GAAG,IAAAC,sBAAe,EAAmC,CAAC;EACrEC,UAAU,GAAG,IAAAD,sBAAe,EAAgD,CAAC;EAC7EE,SAAS,GAAG,IAAAF,sBAAe,EAAwC,CAAC;EAErFG,GAAG,GAAGA,CAACC,GAAQ,EAAEC,MAA6B,EAAEC,SAA+B,EAAEC,KAAkB,KAAK;IACpG;IACA,IAAI,CAACF,MAAM,EAAE;MACT;IACJ;;IAEA;IACA,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,EAAE;MACvBA,MAAM,CAACK,OAAO,CAACC,KAAK,IAAI,IAAI,CAACR,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/CC,QAAQ,CAACI,IAAI,CAACC,WAAW,CAACN,QAAQ,CAAC;QACnChC,WAAW,CAAChB,GAAG,CAACC,GAAG,CAAC;QACpB,IAAI,CAACF,SAAS,CAAC4C,GAAG,CAAC1C,GAAG,EAAEoB,UAAU,EAAE2B,QAAQ,CAAC;MACjD;MAEA,IAAIV,iBAAiB,EAAE;QACnBG,2BAAiB,CAACc,YAAY,CAACf,WAAW,CAACO,SAAS,EAAEV,kBAAkB,EAAEG,WAAW,CAACM,SAAS,CAAC;MACpG;IACJ,CAAC,CAAC;EACN,CAAC;EAED5B,MAAM,GAAGA,CAACjB,GAAgB,EAAEO,KAAY,KAAK;IACzC,IAAAO,qBAAc,EAACP,KAAK,CAAC,CAACD,OAAO,CAAC,CAAC;MAAEc;IAAW,CAAC,KAAK;MAC9C,IAAI,CAACzB,eAAe,CAAC4D,MAAM,CAACvD,GAAG,EAAEoB,UAAU,CAAC;MAC5C,IAAI,CAACvB,UAAU,CAACyC,GAAG,CAACtC,GAAG,EAAEoB,UAAU,CAAC,GAAG,CAAC;MACxC,IAAI,CAACvB,UAAU,CAAC0D,MAAM,CAACvD,GAAG,EAAEoB,UAAU,CAAC;MACvC,IAAI,CAACtB,SAAS,CAACwC,GAAG,CAACtC,GAAG,EAAEoB,UAAU,CAAC,EAAEH,MAAM,CAAC,CAAC;MAC7C,IAAI,CAACnB,SAAS,CAACyD,MAAM,CAACvD,GAAG,EAAEoB,UAAU,CAAC;IAC1C,CAAC,CAAC;EACN,CAAC;AACL;AAEO,MAAMoC,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,IAAInE,8BAA8B,CAAC,CAAC","ignoreList":[]}
|
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.UnistylesState = void 0;
|
7
|
-
var _react = require("react");
|
8
7
|
var _runtime = require("./runtime");
|
9
8
|
var _utils = require("./utils");
|
10
9
|
var _listener = require("./listener");
|
11
10
|
var _NativePlatform = require("../specs/NativePlatform");
|
12
11
|
class UnistylesStateBuilder {
|
13
12
|
isSSR = (0, _utils.isServer)();
|
14
|
-
tags = [];
|
15
13
|
themes = new Map();
|
16
14
|
hasAdaptiveThemes = false;
|
17
15
|
init = config => {
|
@@ -78,44 +76,6 @@ class UnistylesStateBuilder {
|
|
78
76
|
});
|
79
77
|
});
|
80
78
|
};
|
81
|
-
createTag() {
|
82
|
-
if (!this.isSSR) {
|
83
|
-
const tag = document.createElement('style');
|
84
|
-
document.head.appendChild(tag);
|
85
|
-
return tag;
|
86
|
-
}
|
87
|
-
const tagRef = new Proxy(/*#__PURE__*/(0, _react.createRef)(), {
|
88
|
-
set: (target, prop, value) => {
|
89
|
-
// When ref is assigned
|
90
|
-
if ('textContent' in value) {
|
91
|
-
value.textContent = tag.textContent;
|
92
|
-
}
|
93
|
-
return Reflect.set(target, prop, value);
|
94
|
-
}
|
95
|
-
});
|
96
|
-
const tagElement = /*#__PURE__*/(0, _react.createElement)('style', {
|
97
|
-
ref: tagRef,
|
98
|
-
key: this.tags.length
|
99
|
-
}, '');
|
100
|
-
const tag = new Proxy({
|
101
|
-
textContent: ''
|
102
|
-
}, {
|
103
|
-
set: (target, prop, value) => {
|
104
|
-
if (prop !== 'textContent') {
|
105
|
-
return false;
|
106
|
-
}
|
107
|
-
|
108
|
-
// When css is updated
|
109
|
-
target.textContent = value;
|
110
|
-
if (tagRef.current) {
|
111
|
-
tagRef.current.textContent = value;
|
112
|
-
}
|
113
|
-
return true;
|
114
|
-
}
|
115
|
-
});
|
116
|
-
this.tags.push(tagElement);
|
117
|
-
return tag;
|
118
|
-
}
|
119
79
|
}
|
120
80
|
const UnistylesState = exports.UnistylesState = new UnistylesStateBuilder();
|
121
81
|
//# sourceMappingURL=state.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_runtime","require","_utils","_listener","_NativePlatform","UnistylesStateBuilder","isSSR","isServer","themes","Map","hasAdaptiveThemes","init","config","initThemes","initBreakpoints","breakpoints","initSettings","settings","UnistylesListener","initListeners","Object","entries","forEach","themeName","theme","set","adaptiveThemes","themeNames","Array","from","keys","initialTheme","length","Error","schemeToTheme","UnistylesRuntime","colorScheme","breakpointsMap","sort","a","b","breakpoint","value","mediaQuery","window","matchMedia","matches","addEventListener","event","currentBreakpoint","find","mq","emitChange","UnistyleDependency","Breakpoints","UnistylesState","exports"],"sourceRoot":"../../../src","sources":["web/state.ts"],"mappings":";;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,MAAMI,qBAAqB,CAAC;EACPC,KAAK,GAAG,IAAAC,eAAQ,EAAC,CAAC;EAEnCC,MAAM,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAM1CC,iBAAiB,GAAG,KAAK;EAEzBC,IAAI,GAAIC,MAAuB,IAAK;IAChC,IAAI,CAACC,UAAU,CAACD,MAAM,CAACJ,MAAM,CAAC;IAC9B,IAAI,CAACM,eAAe,CAACF,MAAM,CAACG,WAAW,CAAC;IACxC,IAAI,CAACC,YAAY,CAACJ,MAAM,CAACK,QAAQ,CAAC;IAElC,IAAI,IAAI,CAACX,KAAK,EAAE;MACZ;IACJ;IAEAY,2BAAiB,CAACC,aAAa,CAAC,CAAC;EACrC,CAAC;EAEON,UAAU,GAAGA,CAACL,MAAM,GAAG,CAAC,CAAoB,KAAK;IACrDY,MAAM,CAACC,OAAO,CAACb,MAAM,CAAC,CAACc,OAAO,CAAC,CAAC,CAACC,SAAS,EAAEC,KAAK,CAAC,KAAK;MACnD,IAAI,CAAChB,MAAM,CAACiB,GAAG,CAACF,SAAS,EAAEC,KAAK,CAAC;IACrC,CAAC,CAAC;EACN,CAAC;EAEOR,YAAY,GAAIC,QAAqC,IAAK;IAC9D,IAAI,CAACP,iBAAiB,GAAGO,QAAQ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,CAAC;MAC/DL,cAAc,CAACZ,GAAG,CAACgB,UAAU,EAAEE,UAAU,CAAC;MAE1C,IAAIA,UAAU,CAACG,OAAO,EAAE;QACpB,IAAI,CAACL,UAAU,GAAGA,UAA2B;MACjD;MAEAE,UAAU,CAACI,gBAAgB,CAAC,QAAQ,EAAEC,KAAK,IAAI;QAC3C,IAAI,CAACA,KAAK,CAACF,OAAO,EAAE;UAChB,MAAM,CAACG,iBAAiB,CAAC,GAAGrB,KAAK,CAACC,IAAI,CAACQ,cAAc,CAAC,CAACa,IAAI,CAAC,CAAC,GAAEC,EAAE,CAAC,KAAKA,EAAE,CAACL,OAAO,CAAC,IAAI,EAAE;UAExF,IAAIG,iBAAiB,EAAE;YACnB,IAAI,CAACR,UAAU,GAAGQ,iBAAkC;YACpD/B,2BAAiB,CAACkC,UAAU,CAACC,kCAAkB,CAACC,WAAW,CAAC;UAChE;UAEA;QACJ;QAEA,IAAI,CAACb,UAAU,GAAGA,UAA2B;QAC7CvB,2BAAiB,CAACkC,UAAU,CAACC,kCAAkB,CAACC,WAAW,CAAC;MAChE,CAAC,CAAC;IACN,CAAC,CAAC;EACV,CAAC;AACL;AAEO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,IAAIlD,qBAAqB,CAAC,CAAC","ignoreList":[]}
|
@@ -3,23 +3,10 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.warn = exports.
|
6
|
+
exports.warn = exports.schemeToTheme = exports.reduceObject = exports.keyInObject = exports.isServer = exports.isInDocument = exports.hexToRGBA = exports.getStyles = exports.extractSecrets = exports.extractHiddenProperties = exports.equal = exports.deepMergeObjects = exports.createDoubleMap = exports.assignSecrets = void 0;
|
7
7
|
var _types = require("../specs/types");
|
8
8
|
const reduceObject = (obj, reducer) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, reducer(value, key)]));
|
9
9
|
exports.reduceObject = reduceObject;
|
10
|
-
const toReactNativeClassName = (className, values) => {
|
11
|
-
const returnValue = className ? {
|
12
|
-
$$css: true,
|
13
|
-
[className]: className
|
14
|
-
} : {};
|
15
|
-
Object.defineProperties(returnValue, reduceObject(values, value => ({
|
16
|
-
value,
|
17
|
-
enumerable: false,
|
18
|
-
configurable: true
|
19
|
-
})));
|
20
|
-
return returnValue;
|
21
|
-
};
|
22
|
-
exports.toReactNativeClassName = toReactNativeClassName;
|
23
10
|
const keyInObject = (obj, key) => key in obj;
|
24
11
|
exports.keyInObject = keyInObject;
|
25
12
|
const schemeToTheme = scheme => {
|
@@ -75,4 +62,69 @@ const equal = (a, b) => {
|
|
75
62
|
return keysA.every(key => Object.is(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key));
|
76
63
|
};
|
77
64
|
exports.equal = equal;
|
65
|
+
const assignSecrets = (object, secrets) => {
|
66
|
+
// @ts-expect-error - assign secrets to object
|
67
|
+
object[`__uni__secrets__${Math.random().toString(16).slice(2)}`] = secrets;
|
68
|
+
return object;
|
69
|
+
};
|
70
|
+
exports.assignSecrets = assignSecrets;
|
71
|
+
const extractSecrets = object => {
|
72
|
+
const secrets = Object.entries(object).reduce((acc, [key, value]) => {
|
73
|
+
if (key.startsWith('__uni__secrets__')) {
|
74
|
+
acc.push(value);
|
75
|
+
}
|
76
|
+
return acc;
|
77
|
+
}, []);
|
78
|
+
return secrets;
|
79
|
+
};
|
80
|
+
exports.extractSecrets = extractSecrets;
|
81
|
+
const getStyles = values => {
|
82
|
+
const returnValue = {};
|
83
|
+
Object.defineProperties(returnValue, reduceObject(values, value => ({
|
84
|
+
value,
|
85
|
+
enumerable: false,
|
86
|
+
configurable: true
|
87
|
+
})));
|
88
|
+
return returnValue;
|
89
|
+
};
|
90
|
+
exports.getStyles = getStyles;
|
91
|
+
const createDoubleMap = () => {
|
92
|
+
const map = new Map();
|
93
|
+
return {
|
94
|
+
get: (key, secondKey) => {
|
95
|
+
const mapForKey = map.get(key);
|
96
|
+
if (!mapForKey) {
|
97
|
+
return undefined;
|
98
|
+
}
|
99
|
+
return mapForKey.get(secondKey);
|
100
|
+
},
|
101
|
+
set: (key, secondKey, value) => {
|
102
|
+
const mapForKey = map.get(key) ?? new Map();
|
103
|
+
map.set(key, mapForKey);
|
104
|
+
mapForKey.set(secondKey, value);
|
105
|
+
},
|
106
|
+
delete: (key, secondKey) => {
|
107
|
+
const mapForKey = map.get(key);
|
108
|
+
if (!mapForKey) {
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
mapForKey.delete(secondKey);
|
112
|
+
},
|
113
|
+
forEach: callback => {
|
114
|
+
map.forEach((mapForKey, key) => {
|
115
|
+
mapForKey.forEach((value, secondKey) => {
|
116
|
+
callback(key, secondKey, value);
|
117
|
+
});
|
118
|
+
});
|
119
|
+
}
|
120
|
+
};
|
121
|
+
};
|
122
|
+
exports.createDoubleMap = createDoubleMap;
|
123
|
+
const extractHiddenProperties = object => {
|
124
|
+
const hiddenProperties = Object.getOwnPropertyNames(object);
|
125
|
+
return Object.fromEntries(hiddenProperties.filter(key => !key.startsWith('__uni__')).map(key => [key, object[key]]));
|
126
|
+
};
|
127
|
+
exports.extractHiddenProperties = extractHiddenProperties;
|
128
|
+
const isInDocument = element => document.body.contains(element);
|
129
|
+
exports.isInDocument = isInDocument;
|
78
130
|
//# sourceMappingURL=utils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","reduceObject","obj","reducer","Object","fromEntries","entries","map","key","value","exports","
|
1
|
+
{"version":3,"names":["_types","require","reduceObject","obj","reducer","Object","fromEntries","entries","map","key","value","exports","keyInObject","schemeToTheme","scheme","ColorScheme","Dark","Light","hexToRGBA","hex","opacity","replace","split","x","parseInt","filter","num","isNaN","reduce","acc","color","concat","isServer","window","deepMergeObjects","sources","target","forEach","source","keys","sourceValue","targetValue","warn","message","console","equal","a","b","is","keysA","length","every","prototype","hasOwnProperty","call","assignSecrets","object","secrets","Math","random","toString","slice","extractSecrets","startsWith","push","getStyles","values","returnValue","defineProperties","enumerable","configurable","createDoubleMap","Map","get","secondKey","mapForKey","undefined","set","delete","callback","extractHiddenProperties","hiddenProperties","getOwnPropertyNames","isInDocument","element","document","body","contains"],"sourceRoot":"../../../src","sources":["web/utils.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,YAAY,GAAGA,CACxBC,GAAS,EACTC,OAA+D,KAC9DC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,GAAG,CAAC,CAACK,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK,CAACD,GAAG,EAAEL,OAAO,CAACM,KAAK,EAAsBD,GAAG,CAAC,CAAC,CAAC,CAAoC;AAAAE,OAAA,CAAAT,YAAA,GAAAA,YAAA;AAE9I,MAAMU,WAAW,GAAGA,CAAgCT,GAAM,EAAEM,GAAgB,KAAqBA,GAAG,IAAIN,GAAG;AAAAQ,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAE3G,MAAMC,aAAa,GAAIC,MAAmB,IAAmB;EAChE,QAAQA,MAAM;IACV,KAAKC,kBAAW,CAACC,IAAI;MACjB,OAAO,MAAM;IACjB,KAAKD,kBAAW,CAACE,KAAK;IACtB;MACI,OAAO,OAAO;EACtB;AACJ,CAAC;AAAAN,OAAA,CAAAE,aAAA,GAAAA,aAAA;AAEM,MAAMK,SAAS,GAAGA,CAACC,GAAW,EAAEC,OAAe,KAAKD,GAAG,CACzDE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAChBC,KAAK,CAAC,cAAc,CAAC,CACrBd,GAAG,CAACe,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC,CAC1BE,MAAM,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK,GAAGD,GAAG,GAAGC,KAAK,GAAG,EAAE,OAAO,CA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G,MAAM,CAACJ,SAAS,CAAC;IAC/B,CAAC;IACDrC,OAAO,EAAG0C,QAAmE,IAAK;MAC9EvE,GAAG,CAAC6B,OAAO,CAAC,CAACsC,SAAS,EAAElE,GAAG,KAAK;QAC5BkE,SAAS,CAACtC,OAAO,CAAC,CAAC3B,KAAK,EAAEgE,SAAS,KAAK;UACpCK,QAAQ,CAACtE,GAAG,EAAEiE,SAAS,EAAEhE,KAAK,CAAC;QACnC,CAAC,CAAC;MACN,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAAC,OAAA,CAAA4D,eAAA,GAAAA,eAAA;AAEM,MAAMS,uBAAuB,GAAIxB,MAAW,IAAK;EACpD,MAAMyB,gBAAgB,GAAG5E,MAAM,CAAC6E,mBAAmB,CAAC1B,MAAM,CAAC;EAE3D,OAAOnD,MAAM,CAACC,WAAW,CACrB2E,gBAAgB,CACXxD,MAAM,CAAChB,GAAG,IAAI,CAACA,GAAG,CAACsD,UAAU,CAAC,SAAS,CAAC,CAAC,CACzCvD,GAAG,CAACC,GAAG,IAAI,CAACA,GAAG,EAAE+C,MAAM,CAAC/C,GAAG,CAAC,CAAC,CACtC,CAAC;AACL,CAAC;AAAAE,OAAA,CAAAqE,uBAAA,GAAAA,uBAAA;AAEM,MAAMG,YAAY,GAAIC,OAAoB,IAAKC,QAAQ,CAACC,IAAI,CAACC,QAAQ,CAACH,OAAO,CAAC;AAAAzE,OAAA,CAAAwE,YAAA,GAAAA,YAAA","ignoreList":[]}
|
@@ -6,12 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.createUseVariants = void 0;
|
7
7
|
var _react = require("react");
|
8
8
|
var _utils = require("../utils");
|
9
|
-
var _registry = require("../registry");
|
10
9
|
var _getVariants = require("./getVariants");
|
11
10
|
const createUseVariants = (styles, setSelectedVariants) => {
|
12
11
|
const useVariants = selectedVariants => {
|
13
|
-
const [unistylesMap] = (0, _react.useState)(() => new Map());
|
14
|
-
const [classNameMap] = (0, _react.useState)(() => new Map());
|
15
12
|
const [selectedVariantStylesMap] = (0, _react.useState)(() => new Map());
|
16
13
|
const lastSelectedVariantsRef = (0, _react.useRef)();
|
17
14
|
// Variable that determines if variants have changed and we need to recalculate styles
|
@@ -27,44 +24,14 @@ const createUseVariants = (styles, setSelectedVariants) => {
|
|
27
24
|
});
|
28
25
|
return result;
|
29
26
|
}, [lastSelectedVariantsRef.current]);
|
30
|
-
|
31
|
-
combinedVariantStyles.forEach(([key, value]) => {
|
32
|
-
const {
|
33
|
-
className,
|
34
|
-
unistyles
|
35
|
-
} = _registry.UnistylesRegistry.createStyles(value, `variant-${key}`);
|
36
|
-
unistylesMap.set(key, unistyles);
|
37
|
-
classNameMap.set(key, className);
|
38
|
-
});
|
39
|
-
}
|
40
|
-
combinedVariantStyles.forEach(([key, value]) => {
|
27
|
+
combinedVariantStyles.forEach(([key]) => {
|
41
28
|
const styleEntry = styles[key];
|
42
|
-
const unistyles = unistylesMap.get(key);
|
43
|
-
const className = classNameMap.get(key);
|
44
29
|
const selectedVariantStyles = selectedVariantStylesMap.get(key);
|
45
|
-
if (!unistyles || !className) {
|
46
|
-
return;
|
47
|
-
}
|
48
|
-
if (variantsChanged) {
|
49
|
-
_registry.UnistylesRegistry.updateStyles(unistyles, value, className);
|
50
|
-
}
|
51
30
|
Object.defineProperties(styleEntry, (0, _utils.reduceObject)(selectedVariantStyles ?? {}, value => ({
|
52
31
|
value,
|
53
32
|
enumerable: false,
|
54
33
|
configurable: true
|
55
34
|
})));
|
56
|
-
if (styleEntry) {
|
57
|
-
Object.keys(styleEntry ?? {}).forEach(key => {
|
58
|
-
if (!key.startsWith('variant-')) {
|
59
|
-
return;
|
60
|
-
}
|
61
|
-
|
62
|
-
// @ts-expect-error - remove old variants
|
63
|
-
delete styleEntry[key];
|
64
|
-
});
|
65
|
-
// @ts-expect-error - apply variant className
|
66
|
-
styleEntry[className] = className;
|
67
|
-
}
|
68
35
|
});
|
69
36
|
};
|
70
37
|
Object.defineProperty(styles, 'useVariants', {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_utils","
|
1
|
+
{"version":3,"names":["_react","require","_utils","_getVariants","createUseVariants","styles","setSelectedVariants","useVariants","selectedVariants","selectedVariantStylesMap","useState","Map","lastSelectedVariantsRef","useRef","variantsChanged","equal","current","combinedVariantStyles","useMemo","result","getVariants","forEach","key","value","set","styleEntry","selectedVariantStyles","get","Object","defineProperties","reduceObject","enumerable","configurable","defineProperty","exports"],"sourceRoot":"../../../../src","sources":["web/variants/useVariants.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,iBAAiB,GAAGA,CAACC,MAAyC,EAAEC,mBAA4D,KAAK;EAC1I,MAAMC,WAAW,GAAIC,gBAAqC,IAAK;IAC3D,MAAM,CAACC,wBAAwB,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM,IAAIC,GAAG,CAA8B,CAAC,CAAC;IACzF,MAAMC,uBAAuB,GAAG,IAAAC,aAAM,EAAsB,CAAC;IAC7D;IACA,MAAMC,eAAe,GAAG,CAAC,IAAAC,YAAK,EAACH,uBAAuB,CAACI,OAAO,EAAER,gBAAgB,CAAC;IAEjF,IAAIM,eAAe,EAAE;MACjBF,uBAAuB,CAACI,OAAO,GAAGR,gBAAgB;MAClDF,mBAAmB,CAACE,gBAAgB,CAAC;IACzC;IAEA,MAAMS,qBAAqB,GAAG,IAAAC,cAAO,EAAC,MAAM;MACxC,MAAMC,MAAM,GAAG,IAAAC,wBAAW,EAACf,MAAM,EAAEG,gBAAgB,CAAC;MAEpDW,MAAM,CAACE,OAAO,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;QAC7Bd,wBAAwB,CAACe,GAAG,CAACF,GAAG,EAAEC,KAAK,CAAC;MAC5C,CAAC,CAAC;MAEF,OAAOJ,MAAM;IACjB,CAAC,EAAE,CAACP,uBAAuB,CAACI,OAAO,CAAC,CAAC;IAErCC,qBAAqB,CAACI,OAAO,CAAC,CAAC,CAACC,GAAG,CAAC,KAAK;MACrC,MAAMG,UAAU,GAAGpB,MAAM,CAACiB,GAAG,CAAC;MAC9B,MAAMI,qBAAqB,GAAGjB,wBAAwB,CAACkB,GAAG,CAACL,GAAG,CAAC;MAE/DM,MAAM,CAACC,gBAAgB,CAACJ,UAAU,EAAE,IAAAK,mBAAY,EAACJ,qBAAqB,IAAI,CAAC,CAAC,EAAEH,KAAK,KAAK;QACpFA,KAAK;QACLQ,UAAU,EAAE,KAAK;QACjBC,YAAY,EAAE;MAClB,CAAC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC;EACN,CAAC;EAEDJ,MAAM,CAACK,cAAc,CAAC5B,MAAM,EAAE,aAAa,EAAE;IACzCkB,KAAK,EAAEhB;EACX,CAAC,CAAC;AACN,CAAC;AAAA2B,OAAA,CAAA9B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
import React from 'react';
|
4
4
|
export * from './specs';
|
5
5
|
export { mq } from './mq';
|
6
|
+
// TODO: export Native createUnistylesComponent
|
7
|
+
// can't import it this way, it will break native build
|
8
|
+
// export { createUnistylesComponent } from './web/createUnistylesComponent'
|
9
|
+
|
6
10
|
// todo verify true min version
|
7
11
|
const minReactVersionRequiredByUnistyles = '18.3.1';
|
8
12
|
if (React.version < minReactVersionRequiredByUnistyles) {
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","mq","minReactVersionRequiredByUnistyles","version","Error"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,cAAc,SAAS;AACvB,SAASC,EAAE,QAAQ,MAAM;
|
1
|
+
{"version":3,"names":["React","mq","minReactVersionRequiredByUnistyles","version","Error"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,cAAc,SAAS;AACvB,SAASC,EAAE,QAAQ,MAAM;AAEzB;AACA;AACA;;AAEA;AACA,MAAMC,kCAAkC,GAAG,QAAQ;AAEnD,IAAIF,KAAK,CAACG,OAAO,GAAGD,kCAAkC,EAAE;EACpD,MAAM,IAAIE,KAAK,CAAC;AACpB,sDAAsDJ,KAAK,CAACG,OAAO;AACnE,4CAA4CD,kCAAkC;AAC9E,KAAK,CAAC;AACN","ignoreList":[]}
|
@@ -11,7 +11,13 @@ const findShadowNodeForHandle = handle => {
|
|
11
11
|
return node;
|
12
12
|
};
|
13
13
|
HybridShadowRegistry.add = (handle, style, variants, args) => {
|
14
|
-
|
14
|
+
// virtualized nodes can be null
|
15
|
+
if (!handle || !style) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
// at this point unistyle can be only object or dynamic function
|
20
|
+
if (typeof style !== 'object' && typeof style !== 'function') {
|
15
21
|
return;
|
16
22
|
}
|
17
23
|
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAazD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDJ,oBAAoB,CAACU,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D,IAAI,CAACV,MAAM,IAAI,
|
1
|
+
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","link","remove","__unid","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAazD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDJ,oBAAoB,CAACU,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D;EACA,IAAI,CAACV,MAAM,IAAI,CAACQ,KAAK,EAAE;IACnB;EACJ;;EAEA;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;IAC1D;EACJ;EAEAX,oBAAoB,CAACc,IAAI,CAACZ,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDb,oBAAoB,CAACe,MAAM,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEK,MAAM,EAAE;IAC3B;EACJ;EAEAhB,oBAAoB,CAACiB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQD,OAAO,MAAMO,uBAAuB,GAAGlB,oBAA4D","ignoreList":[]}
|
@@ -19,7 +19,7 @@ export const convertToTypeStyle = value => {
|
|
19
19
|
...value._web
|
20
20
|
}).flatMap(([unistylesKey, unistylesValue]) => {
|
21
21
|
// Keys to omit
|
22
|
-
if (['_css', '_web', 'variants', 'compoundVariants', 'uni__dependencies'].includes(unistylesKey)) {
|
22
|
+
if (['_css', '_web', 'variants', 'compoundVariants', 'uni__dependencies', '__unistyles-secrets__'].includes(unistylesKey) || unistylesKey.startsWith('variant-')) {
|
23
23
|
return [];
|
24
24
|
}
|
25
25
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["media","isPseudo","convertBreakpoint","getStyle","deepMergeObjects","getTransformStyle","isBoxShadow","isTextShadow","isTransform","getTextShadowStyle","getBoxShadowStyle","convertToTypeStyle","value","hasTextShadow","hasBoxShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","typestyleValues","$nest","replace","map","breakpointKey","breakpointValue"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;AAEA,SAASA,KAAK,QAAQ,WAAW;AACjC,SAASC,QAAQ,QAAQ,WAAW;AACpC,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,QAAQ,QAAQ,SAAS;AAClC,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,WAAW,EAAEC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAChE,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SAASC,iBAAiB,QAAQ,aAAa;AAE/C,OAAO,MAAMC,kBAAkB,GAAIC,KAAsB,IAAK;EAC1D;EACA,IAAIC,aAAa,GAAG,KAAK;EACzB;EACA,IAAIC,YAAY,GAAG,KAAK;EAExB,MAAMC,WAAW,GAAGC,MAAM,CAACC,OAAO,CAAC;IAC/B,GAAGL,KAAK;IACR,GAAGA,KAAK,CAACM;EACb,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,CAACC,YAAY,EAAEC,cAAc,CAAC,KAAK;IAC3C;IACA,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,EAAE;
|
1
|
+
{"version":3,"names":["media","isPseudo","convertBreakpoint","getStyle","deepMergeObjects","getTransformStyle","isBoxShadow","isTextShadow","isTransform","getTextShadowStyle","getBoxShadowStyle","convertToTypeStyle","value","hasTextShadow","hasBoxShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","startsWith","typestyleValues","$nest","replace","map","breakpointKey","breakpointValue"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;AAEA,SAASA,KAAK,QAAQ,WAAW;AACjC,SAASC,QAAQ,QAAQ,WAAW;AACpC,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,QAAQ,QAAQ,SAAS;AAClC,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,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cAAc,CAAC,EAAE;MAC3C,OAAOhB,iBAAiB,CAACgB,cAAc,CAAC;IAC5C;;IAEA;IACA,IAAI,OAAOA,cAAc,KAAK,QAAQ,IAAIA,cAAc,KAAK,IAAI,EAAE;MAC/D,OAAOL,MAAM,CAACC,OAAO,CAACI,cAAc,CAAC,CAACM,GAAG,CAAC,CAAC,CAACC,aAAa,EAAEC,eAAe,CAAC,KAAK;QAC5E,OAAO7B,KAAK,CAACE,iBAAiB,CAAC0B,aAAa,CAAC,EAAEzB,QAAQ,CAACiB,YAAY,EAAES,eAAe,CAAC,CAAC;MAC3F,CAAC,CAAC;IACN;;IAEA;IACA,OAAO1B,QAAQ,CAACiB,YAAY,EAAEC,cAAc,CAAC;EACjD,CAAC,CAA+B;EAEhC,OAAOjB,gBAAgB,CAAC,GAAGW,WAAW,CAAC;AAC3C,CAAC","ignoreList":[]}
|
package/lib/module/web/create.js
CHANGED
@@ -1,84 +1,46 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import {
|
4
|
-
import { keyInObject, reduceObject, toReactNativeClassName } from './utils';
|
3
|
+
import { assignSecrets, reduceObject, getStyles } from './utils';
|
5
4
|
import { UnistylesRuntime } from './runtime';
|
6
5
|
import { createUseVariants, getVariants } from './variants';
|
7
|
-
import { UnistylesListener } from './listener';
|
8
6
|
export const create = stylesheet => {
|
9
7
|
const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : stylesheet;
|
10
|
-
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
args
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
22
|
-
return UnistylesListener.addListeners(dependencies, () => {
|
23
|
-
const newComputedStylesheet = typeof stylesheet === 'function' ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : stylesheet;
|
24
|
-
if (!keyInObject(newComputedStylesheet, key)) {
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
const value = newComputedStylesheet[key];
|
28
|
-
const result = typeof value === 'function' ? value(...args) : value;
|
29
|
-
UnistylesRegistry.updateStyles(unistyles, result, className);
|
30
|
-
});
|
31
|
-
};
|
32
|
-
const styles = reduceObject(computedStylesheet, (value, key) => {
|
8
|
+
const selectedVariants = new Map();
|
9
|
+
const copyVariants = () => Object.fromEntries(selectedVariants.entries());
|
10
|
+
const addSecrets = (value, key, args) => assignSecrets(value, {
|
11
|
+
__uni__key: key,
|
12
|
+
__uni__refs: new Set(),
|
13
|
+
__uni__stylesheet: stylesheet,
|
14
|
+
__uni__args: args,
|
15
|
+
__uni__variants: copyVariants()
|
16
|
+
});
|
17
|
+
const styles = reduceObject(computedStylesheet, (value, _key) => {
|
18
|
+
const key = String(_key);
|
33
19
|
if (typeof value === 'function') {
|
34
|
-
const
|
35
|
-
const disposeByRef = new Map();
|
36
|
-
return (...args) => {
|
37
|
-
const [ref] = args.slice(-1);
|
20
|
+
const dynamicStyle = (...args) => {
|
38
21
|
const result = value(...args);
|
39
22
|
const variants = Object.fromEntries(getVariants({
|
40
23
|
[key]: result
|
41
|
-
},
|
24
|
+
}, copyVariants()));
|
42
25
|
const resultWithVariants = {
|
43
26
|
...result,
|
44
27
|
...variants[key]
|
45
28
|
};
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
webUnistyleByRef.set(ref, webUnistyle);
|
50
|
-
disposeByRef.get(ref)?.();
|
51
|
-
disposeByRef.set(ref, listenToDependencies({
|
52
|
-
key,
|
53
|
-
value,
|
54
|
-
unistyles: webUnistyle.unistyles,
|
55
|
-
className: webUnistyle.className,
|
56
|
-
args
|
57
|
-
}));
|
58
|
-
ref.classList.add(webUnistyle.className);
|
59
|
-
if (storedWebUnistyle) {
|
60
|
-
UnistylesRegistry.updateStyles(webUnistyle.unistyles, resultWithVariants, webUnistyle.className);
|
61
|
-
}
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
return toReactNativeClassName(null, resultWithVariants);
|
29
|
+
|
30
|
+
// Add secrets to result of dynamic styles function
|
31
|
+
return addSecrets(getStyles(resultWithVariants), key, args);
|
65
32
|
};
|
33
|
+
|
34
|
+
// Add secrets to dynamic styles function
|
35
|
+
return addSecrets(dynamicStyle, key);
|
66
36
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
} = UnistylesRegistry.createStyles(value, key);
|
71
|
-
listenToDependencies({
|
72
|
-
key,
|
73
|
-
value,
|
74
|
-
unistyles,
|
75
|
-
className
|
76
|
-
});
|
77
|
-
return toReactNativeClassName(className, value);
|
78
|
-
});
|
79
|
-
createUseVariants(styles, newVariants => {
|
80
|
-
lastlySelectedVariants = newVariants;
|
37
|
+
|
38
|
+
// Add secrets to static styles
|
39
|
+
return addSecrets(getStyles(value), key);
|
81
40
|
});
|
41
|
+
|
42
|
+
// Inject useVariants hook to styles
|
43
|
+
createUseVariants(styles, newVariants => Object.entries(newVariants).forEach(([key, value]) => selectedVariants.set(key, value)));
|
82
44
|
return styles;
|
83
45
|
};
|
84
46
|
//# sourceMappingURL=create.js.map
|