react-native-unistyles 3.0.0-alpha.13 → 3.0.0-alpha.15
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 +13 -10
- package/cxx/core/UnistylesMountHook.cpp +3 -19
- package/cxx/hybridObjects/HybridStyleSheet.cpp +4 -3
- package/cxx/hybridObjects/HybridStyleSheet.h +1 -1
- package/cxx/parser/Parser.cpp +13 -9
- package/cxx/shadowTree/ShadowTreeManager.cpp +5 -5
- 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 +15 -31
- 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 +16 -32
- 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/plugin/index.js +31 -0
- 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 +18 -32
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_listener","require","_runtime","_utils","_registry","listenToDependencies","key","className","unistyles","args","stylesheet","newComputedStylesheet","UnistylesRuntime","theme","miniRuntime","_value","keyInObject","undefined","value","dependencies","length","UnistylesListener","addListeners","result","UnistylesRegistry","updateStyles","exports"],"sourceRoot":"../../../../src","sources":["web/listener/listenToDependencies.ts"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAUO,MAAMI,oBAAoB,GAAGA,CAAC;EAAEC,GAAG;EAAEC,SAAS;EAAEC,SAAS;EAAEC,IAAI,GAAG,EAAE;EAAEC;AAAsC,CAAC,KAAK;EACrH,MA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
|
6
|
-
exports.
|
6
|
+
exports.UnistylesListener = void 0;
|
7
7
|
var _NativePlatform = require("../../specs/NativePlatform");
|
8
8
|
var _runtime = require("../runtime");
|
9
9
|
class UnistylesListenerBuilder {
|
@@ -31,6 +31,5 @@ class UnistylesListenerBuilder {
|
|
31
31
|
};
|
32
32
|
};
|
33
33
|
}
|
34
|
-
exports.UnistylesListenerBuilder = UnistylesListenerBuilder;
|
35
34
|
const UnistylesListener = exports.UnistylesListener = new UnistylesListenerBuilder();
|
36
35
|
//# sourceMappingURL=listener.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","
|
1
|
+
{"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","UnistylesListener","exports"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,kCAAkB,CAAC,CAACH,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAII,GAAG,CAAe,CAAC,CAAC;EAErHC,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;EAC/D,CAAC;EAEDC,aAAa,GAAGA,CAAA,KAAM;IAClB,IAAI,IAAI,CAACb,aAAa,EAAE;MACpB;IACJ;IAEA,IAAI,CAACA,aAAa,GAAG,IAAI;IACzBc,yBAAgB,CAACC,SAAS,EAAEC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACU,WAAW,CAAC,CAAC;IAC7GH,yBAAgB,CAACI,UAAU,EAAEF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACU,WAAW,CAAC,CAAC;IAC9GE,MAAM,CAACH,gBAAgB,CAAC,mBAAmB,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACa,WAAW,CAAC,CAAC;IACnGD,MAAM,CAACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACc,UAAU,CAAC,CAAC;EAC3F,CAAC;EAEDC,YAAY,GAAGA,CAACC,YAAuC,EAAEX,QAAsB,KAAK;IAChFW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEc,GAAG,CAACZ,QAAQ,CAAC,CAAC;IAE7E,OAAO,MAAM;MACTW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEe,MAAM,CAACb,QAAQ,CAAC,CAAC;IACpF,CAAC;EACL,CAAC;AACL;AAEO,MAAMc,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAI3B,wBAAwB,CAAC,CAAC","ignoreList":[]}
|
package/lib/commonjs/web/mock.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.StatusBar = exports.NavigationBar = void 0;
|
7
7
|
const StatusBar = exports.StatusBar = {
|
8
8
|
width: 0,
|
9
9
|
height: 0,
|
@@ -25,13 +25,4 @@ const NavigationBar = exports.NavigationBar = {
|
|
25
25
|
__type: 'web',
|
26
26
|
name: 'NavigationBar'
|
27
27
|
};
|
28
|
-
const UnistylesShadowRegistry = exports.UnistylesShadowRegistry = {
|
29
|
-
name: 'UnistylesShadowRegistry',
|
30
|
-
__type: 'web',
|
31
|
-
equals: () => true,
|
32
|
-
toString: () => 'UnistylesShadowRegistry',
|
33
|
-
dispose: () => {},
|
34
|
-
add: () => {},
|
35
|
-
remove: () => {}
|
36
|
-
};
|
37
28
|
//# sourceMappingURL=mock.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["StatusBar","exports","width","height","setStyle","setHidden","setBackgroundColor","equals","toString","__type","name","NavigationBar"
|
1
|
+
{"version":3,"names":["StatusBar","exports","width","height","setStyle","setHidden","setBackgroundColor","equals","toString","__type","name","NavigationBar"],"sourceRoot":"../../../src","sources":["web/mock.ts"],"mappings":";;;;;;AAGO,MAAMA,SAAwB,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACpCE,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClBC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC5BC,MAAM,EAAEA,CAAA,KAAM,IAAI;EAClBC,QAAQ,EAAEA,CAAA,KAAM,WAAW;EAC3BC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE;AACV,CAAC;AAEM,MAAMC,aAAgC,GAAAV,OAAA,CAAAU,aAAA,GAAG;EAC5CT,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTE,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC5BC,MAAM,EAAEA,CAAA,KAAM,IAAI;EAClBC,QAAQ,EAAEA,CAAA,KAAM,eAAe;EAC/BC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE;AACV,CAAC","ignoreList":[]}
|
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.pseudos = exports.isPseudo = void 0;
|
7
|
-
|
8
|
-
const
|
9
|
-
const isPseudo = selector => pseudos.includes(selector);
|
7
|
+
const pseudos = exports.pseudos = ['_-moz-broken', '_-moz-drag-over', '_-moz-first-node', '_-moz-handler-blocked', '_-moz-handler-crashed', '_-moz-handler-disabled', '_-moz-last-node', '_-moz-loading', '_-moz-locale-dir(ltr)', '_-moz-locale-dir(rtl)', '_-moz-only-whitespace', '_-moz-submit-invalid', '_-moz-suppressed', '_-moz-user-disabled', '_-moz-window-inactive', '_active', '_any-link', '_autofill', '_blank', '_buffering', '_checked', '_current', '_default', '_defined', '_dir(', '_disabled', '_empty', '_enabled', '_first', '_first-child', '_first-of-type', '_focus', '_focus-visible', '_focus-within', '_fullscreen', '_future', '_has(', '_host', '_host-context(', '_host(', '_hover', '_in-range', '_indeterminate', '_invalid', '_is(', '_lang(', '_last-child', '_last-of-type', '_left', '_link', '_local-link', '_modal', '_muted', '_not(', '_nth-child(', '_nth-last-child(', '_nth-last-of-type(', '_nth-of-type(', '_only-child', '_only-of-type', '_optional', '_out-of-range', '_past', '_paused', '_picture-in-picture', '_placeholder-shown', '_playing', '_popover-open', '_read-only', '_read-write', '_required', '_right', '_scope', '_seeking', '_stalled', '_state(', '_target', '_target-within', '_user-invalid', '_user-valid', '_valid', '_visited', '_volume-locked', '_where(', '_-moz-color-swatch', '_-moz-focus-inner', '_-moz-list-bullet', '_-moz-list-number', '_-moz-meter-bar', '_-moz-progress-bar', '_-moz-range-progress', '_-moz-range-thumb', '_-moz-range-track', '_-webkit-inner-spin-button', '_-webkit-meter-barDeprecated', '_-webkit-meter-even-less-good-value', '_-webkit-meter-inner-element', '_-webkit-meter-optimum-value', '_-webkit-meter-suboptimum-value', '_-webkit-progress-bar', '_-webkit-progress-inner-element', '_-webkit-progress-value', '_-webkit-scrollbar', '_-webkit-search-cancel-button', '_-webkit-search-results-button', '_-webkit-slider-runnable-track', '_-webkit-slider-thumb', '_after', '_backdrop', '_before', '_cue', '_file-selector-button', '_first-letter', '_first-line', '_grammar-error', '_highlight(', '_marker', '_part(', '_placeholder', '_selection', '_slotted(', '_spelling-error', '_target-text', '_view-transition', '_view-transition-group', '_view-transition-image-pair', '_view-transition-new', '_view-transition-old'];
|
8
|
+
const isPseudo = selector => pseudos.some(pseudo => selector.startsWith(pseudo));
|
10
9
|
exports.isPseudo = isPseudo;
|
11
10
|
//# sourceMappingURL=pseudo.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["pseudos","exports","isPseudo","selector","
|
1
|
+
{"version":3,"names":["pseudos","exports","isPseudo","selector","some","pseudo","startsWith"],"sourceRoot":"../../../src","sources":["web/pseudo.ts"],"mappings":";;;;;;AAAO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,CACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,SAAS,EACT,WAAW,EACX,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,SAAS,EACT,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,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A,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
|
@@ -6,14 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.UnistylesRegistry = void 0;
|
7
7
|
var _typestyle = require("typestyle");
|
8
8
|
var _convert = require("./convert");
|
9
|
-
var _state = require("./state");
|
10
9
|
class UnistylesRegistryBuilder {
|
11
10
|
createStyles = (stylesheet, key) => {
|
12
|
-
const
|
13
|
-
const unistyles = (0, _typestyle.createTypeStyle)(stylesTag);
|
11
|
+
const unistyles = (0, _typestyle.createTypeStyle)();
|
14
12
|
const typestyleStylesheet = (0, _convert.convertToTypeStyle)(stylesheet);
|
15
13
|
const className = unistyles.style({
|
16
|
-
$debugName:
|
14
|
+
$debugName: `${key}-${Math.random().toString(16).slice(10)}`
|
17
15
|
}, typestyleStylesheet);
|
18
16
|
if (stylesheet._web?._css) {
|
19
17
|
const customClassName = Array.isArray(stylesheet._web._css) ? stylesheet._web._css.join(' ') : stylesheet._web._css;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_typestyle","require","_convert","
|
1
|
+
{"version":3,"names":["_typestyle","require","_convert","UnistylesRegistryBuilder","createStyles","stylesheet","key","unistyles","createTypeStyle","typestyleStylesheet","convertToTypeStyle","className","style","$debugName","Math","random","toString","slice","_web","_css","customClassName","Array","isArray","join","updateStyles","reinit","cssRule","UnistylesRegistry","exports"],"sourceRoot":"../../../src","sources":["web/registry.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,wBAAwB,CAAC;EAC3BC,YAAY,GAAGA,CAACC,UAA2B,EAAEC,GAAW,KAAK;IACzD,MAAMC,SAAS,GAAG,IAAAC,0BAAe,EAAC,CAAC;IACnC,MAAMC,mBAAmB,GAAG,IAAAC,2BAAkB,EAACL,UAAU,CAAC;IAE1D,MAAMM,SAAS,GAAGJ,SAAS,CAACK,KAAK,CAAC;MAC9BC,UAAU,EAAE,GAAGP,GAAG,IAAIQ,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,EAAE,CAAC;IAC9D,CAAC,EAAER,mBAAmB,CAAC;IAEvB,IAAIJ,UAAU,CAACa,IAAI,EAAEC,IAAI,EAAE;MACvB,MAAMC,eAAe,GAAGC,KAAK,CAACC,OAAO,CAACjB,UAAU,CAACa,IAAI,CAACC,IAAI,CAAC,GACrDd,UAAU,CAACa,IAAI,CAACC,IAAI,CAACI,IAAI,CAAC,GAAG,CAAC,GAC9BlB,UAAU,CAACa,IAAI,CAACC,IAAI;MAE1B,OAAO;QACHR,SAAS,EAAE,GAAGA,SAAS,IAAIS,eAAe,EAAE;QAC5Cb;MACJ,CAAC;IACL;IAEA,OAAO;MACHI,SAAS;MACTJ;IACJ,CAAC;EACL,CAAC;EAEDiB,YAAY,GAAGA,CAACjB,SAAoB,EAAEF,UAA2B,EAAEM,SAAiB,KAAK;IACrF,MAAMF,mBAAmB,GAAG,IAAAC,2BAAkB,EAACL,UAAU,CAAC;IAE1DE,SAAS,CAACkB,MAAM,CAAC,CAAC;IAClBlB,SAAS,CAACmB,OAAO,CAAC,IAAIf,SAAS,EAAE,EAAEF,mBAAmB,CAAC;EAC3D,CAAC;AACL;AAEO,MAAMkB,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAIxB,wBAAwB,CAAC,CAAC","ignoreList":[]}
|
@@ -158,7 +158,6 @@ class UnistylesRuntimeBuilder {
|
|
158
158
|
}
|
159
159
|
_state.UnistylesState.themes.set(themeName, updater(oldTheme));
|
160
160
|
};
|
161
|
-
getSSRUnistyles = () => _state.UnistylesState.tags;
|
162
161
|
}
|
163
162
|
const UnistylesRuntime = exports.UnistylesRuntime = new UnistylesRuntimeBuilder();
|
164
163
|
//# sourceMappingURL=runtime.js.map
|
@@ -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,IAA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H,2BAAiB,CAACC,UAAU,CAACC,kCAAkB,CAACE,SAAS,CAAC;EAC9D,CAAC;EAEDC,iBAAiB,GAAIC,SAAkB,IAAK;IACxC9C,qBAAc,CAACkC,iBAAiB,GAAGY,SAAS;IAE5C,IAAI,CAACA,SAAS,EAAE;MACZ;IACJ;IAEA,IAAI,CAACR,QAAQ,CAAC,IAAAS,oBAAa,EAACR,gBAAgB,CAAC9C,WAAW,CAAC,CAAC;EAC9D,CAAC;EAEDuD,0BAA0B,GAAGA,CAACC,GAAW,EAAEC,KAAc,KAAK;IAC1D,IAAI,IAAA5D,eAAQ,EAAC,CAAC,EAAE;MACZ;IACJ;IAEAyC,QAAQ,CAACC,eAAe,CAACmB,KAAK,CAACC,eAAe,GAAGF,KAAK,GAAG,IAAAG,gBAAS,EAACJ,GAAG,EAAEC,KAAK,CAAC,GAAGD,GAAG;EACxF,CAAC;EAEDK,gBAAgB,GAAGA,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;EAC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xC,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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AW,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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,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,31 @@ 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
|
-
|
43
|
-
const className = classNameMap.get(key);
|
44
|
-
const selectedVariantStyles = selectedVariantStylesMap.get(key);
|
45
|
-
if (!unistyles || !className) {
|
29
|
+
if (!styleEntry) {
|
46
30
|
return;
|
47
31
|
}
|
48
|
-
|
49
|
-
_registry.UnistylesRegistry.updateStyles(unistyles, value, className);
|
50
|
-
}
|
32
|
+
const selectedVariantStyles = selectedVariantStylesMap.get(key);
|
51
33
|
Object.defineProperties(styleEntry, (0, _utils.reduceObject)(selectedVariantStyles ?? {}, value => ({
|
52
34
|
value,
|
53
35
|
enumerable: false,
|
54
36
|
configurable: true
|
55
37
|
})));
|
56
|
-
if (styleEntry) {
|
57
|
-
Object.keys(styleEntry ?? {}).forEach(key => {
|
58
|
-
if (!key.startsWith('variant-')) {
|
59
|
-
return;
|
60
|
-
}
|
61
38
|
|
62
|
-
|
63
|
-
|
39
|
+
// Add __uni__variants to static styles
|
40
|
+
Object.keys(styleEntry).forEach(key => {
|
41
|
+
if (!key.startsWith('__uni__secrets__')) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
const secret = (0, _utils.keyInObject)(styleEntry, key) ? styleEntry[key] : undefined;
|
45
|
+
if (!secret) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
Object.defineProperty(secret, '__uni__variants', {
|
49
|
+
value: selectedVariants
|
64
50
|
});
|
65
|
-
|
66
|
-
styleEntry[className] = className;
|
67
|
-
}
|
51
|
+
});
|
68
52
|
});
|
69
53
|
};
|
70
54
|
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","keys","startsWith","secret","keyInObject","undefined","defineProperty","exports"],"sourceRoot":"../../../../src","sources":["web/variants/useVariants.ts"],"mappings":";;;;;;AA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I,CAAC,CAAC,EAAEH,KAAK,KAAK;QACpFA,KAAK;QACLQ,UAAU,EAAE,KAAK;QACjBC,YAAY,EAAE;MAClB,CAAC,CAAC,CAAC,CAAC;;MAEJ;MACAJ,MAAM,CAACK,IAAI,CAACR,UAAU,CAAC,CAACJ,OAAO,CAACC,GAAG,IAAI;QACnC,IAAI,CAACA,GAAG,CAACY,UAAU,CAAC,kBAAkB,CAAC,EAAE;UACrC;QACJ;QAEA,MAAMC,MAAM,GAAG,IAAAC,kBAAW,EAACX,UAAU,EAAEH,GAAG,CAAC,GAAGG,UAAU,CAACH,GAAG,CAAC,GAAGe,SAAS;QAEzE,IAAI,CAACF,MAAM,EAAE;UACT;QACJ;QAEAP,MAAM,CAACU,cAAc,CAACH,MAAM,EAAE,iBAAiB,EAAE;UAC7CZ,KAAK,EAAEf;QACX,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC;EAEDoB,MAAM,CAACU,cAAc,CAACjC,MAAM,EAAE,aAAa,EAAE;IACzCkB,KAAK,EAAEhB;EACX,CAAC,CAAC;AACN,CAAC;AAAAgC,OAAA,CAAAnC,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":[]}
|