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
@@ -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,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,EAAE,uBAAuB,CAAC,CAACC,QAAQ,CAACF,YAAY,CAAC,IAAIA,YAAY,CAACG,UAAU,CAAC,UAAU,CAAC,EAAE;MAC9J,OAAO,EAAE;IACb;;IAEA;IACA,IAAItB,QAAQ,CAACmB,YAAY,CAAC,EAAE;MACxB,MAAMI,eAAe,GAAGb,kBAAkB,CAACU,cAAiC,CAAC;MAE7E,OAAO;QACHI,KAAK,EAAE;UACH,CAACL,YAAY,CAACM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,GAAGF;QACvC;MACJ,CAAC;IACL;;IAEA;IACA,IAAIjB,YAAY,CAACa,YAAY,CAAC,EAAE;MAC5B,IAAIP,aAAa,EAAE;QACf,OAAO,EAAE;MACb;MAEAA,aAAa,GAAG,IAAI;MAEpB,OAAOJ,kBAAkB,CAACG,KAAK,CAAC;IACpC;;IAEA;IACA,IAAIN,WAAW,CAACc,YAAY,CAAC,EAAE;MAC3B,IAAIN,YAAY,EAAE;QACd,OAAO,EAAE;MACb;MAEAA,YAAY,GAAG,IAAI;MAEnB,OAAOJ,iBAAiB,CAACE,KAAK,CAAC;IACnC;;IAEA;IACA,IAAIJ,WAAW,CAACY,YAAY,EAAEC,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
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["assignSecrets","reduceObject","getStyles","UnistylesRuntime","createUseVariants","getVariants","create","stylesheet","computedStylesheet","theme","miniRuntime","selectedVariants","Map","copyVariants","Object","fromEntries","entries","addSecrets","value","key","args","__uni__key","__uni__refs","Set","__uni__stylesheet","__uni__args","__uni__variants","styles","_key","String","dynamicStyle","result","variants","resultWithVariants","newVariants","forEach","set"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;AAEA,SAASA,aAAa,EAAEC,YAAY,EAAEC,SAAS,QAAQ,SAAS;AAChE,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,iBAAiB,EAAEC,WAAW,QAAQ,YAAY;AAE3D,OAAO,MAAMC,MAAM,GAAIC,UAAiD,IAAK;EACzE,MAAMC,kBAAkB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACJ,gBAAgB,CAACM,KAAK,EAAEN,gBAAgB,CAACO,WAAW,CAAC,GAChEH,UAAU;EAChB,MAAMI,gBAAgB,GAAG,IAAIC,GAAG,CAAc,CAAC;EAE/C,MAAMC,YAAY,GAAGA,CAAA,KAAMC,MAAM,CAACC,WAAW,CAACJ,gBAAgB,CAACK,OAAO,CAAC,CAAC,CAAC;EACzE,MAAMC,UAAU,GAAGA,CAACC,KAAU,EAAEC,GAAW,EAAEC,IAAiB,KAAKpB,aAAa,CAACkB,KAAK,EAAE;IACpFG,UAAU,EAAEF,GAAG;IACfG,WAAW,EAAE,IAAIC,GAAG,CAAC,CAAC;IACtBC,iBAAiB,EAAEjB,UAAU;IAC7BkB,WAAW,EAAEL,IAAI;IACjBM,eAAe,EAAEb,YAAY,CAAC;EAClC,CAAC,CAAC;EAEF,MAAMc,MAAM,GAAG1B,YAAY,CAACO,kBAAkB,EAAE,CAACU,KAAK,EAAEU,IAAI,KAAK;IAC7D,MAAMT,GAAG,GAAGU,MAAM,CAACD,IAAI,CAAC;IAExB,IAAI,OAAOV,KAAK,KAAK,UAAU,EAAE;MAC7B,MAAMY,YAAY,GAAGA,CAAC,GAAGV,IAAgB,KAAK;QAC1C,MAAMW,MAAM,GAAGb,KAAK,CAAC,GAAGE,IAAI,CAAC;QAC7B,MAAMY,QAAQ,GAAGlB,MAAM,CAACC,WAAW,CAACV,WAAW,CAAC;UAAE,CAACc,GAAG,GAAGY;QAAO,CAAC,EAAuClB,YAAY,CAAC,CAAC,CAAC,CAAC;QACxH,MAAMoB,kBAAkB,GAAG;UACvB,GAAGF,MAAM;UACT,GAAGC,QAAQ,CAACb,GAAG;QACnB,CAAC;;QAED;QACA,OAAOF,UAAU,CAACf,SAAS,CAAC+B,kBAAkB,CAAC,EAAEd,GAAG,EAAEC,IAAI,CAAC;MAC/D,CAAC;;MAED;MACA,OAAOH,UAAU,CAACa,YAAY,EAAEX,GAAG,CAAC;IACxC;;IAEA;IACA,OAAOF,UAAU,CAACf,SAAS,CAACgB,KAAK,CAAC,EAAEC,GAAG,CAAC;EAC5C,CAAC,CAAsC;;EAEvC;EACAf,iBAAiB,CAACuB,MAAM,EAAEO,WAAW,IAAIpB,MAAM,CAACE,OAAO,CAACkB,WAAW,CAAC,CAACC,OAAO,CAAC,CAAC,CAAChB,GAAG,EAAED,KAAK,CAAC,KAAKP,gBAAgB,CAACyB,GAAG,CAACjB,GAAG,EAAED,KAAK,CAAC,CAAC,CAAC;EAEjI,OAAOS,MAAM;AACjB,CAAC","ignoreList":[]}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import React, { useEffect, useState } from 'react';
|
4
|
+
import { extractHiddenProperties, extractSecrets } from './utils';
|
5
|
+
import { UnistylesRuntime } from './runtime';
|
6
|
+
import { getVariants } from './variants';
|
7
|
+
import { UnistylesListener } from './listener';
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
+
const getStyles = value => {
|
10
|
+
const secrets = extractSecrets(value);
|
11
|
+
if (secrets.length === 0) {
|
12
|
+
return undefined;
|
13
|
+
}
|
14
|
+
return secrets.reduce((acc, {
|
15
|
+
__uni__stylesheet,
|
16
|
+
__uni__key,
|
17
|
+
__uni__args = [],
|
18
|
+
__uni__variants
|
19
|
+
}) => {
|
20
|
+
const newComputedStylesheet = typeof __uni__stylesheet === 'function' ? __uni__stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : __uni__stylesheet;
|
21
|
+
const style = newComputedStylesheet[__uni__key];
|
22
|
+
const resultHidden = typeof style === 'function' ? style(...__uni__args) : style;
|
23
|
+
const result = extractHiddenProperties(resultHidden);
|
24
|
+
const {
|
25
|
+
variants
|
26
|
+
} = Object.fromEntries(getVariants({
|
27
|
+
variants: result
|
28
|
+
}, __uni__variants));
|
29
|
+
const resultWithVariants = {
|
30
|
+
...result,
|
31
|
+
...variants
|
32
|
+
};
|
33
|
+
return {
|
34
|
+
...acc,
|
35
|
+
...resultWithVariants
|
36
|
+
};
|
37
|
+
}, {});
|
38
|
+
};
|
39
|
+
export const createUnistylesComponent = Component => props => {
|
40
|
+
const passedStyles = props.style ?? {};
|
41
|
+
const [style, setStyle] = useState(getStyles(passedStyles));
|
42
|
+
useEffect(() => {
|
43
|
+
const newStyles = getStyles(passedStyles);
|
44
|
+
const dependencies = newStyles?.['uni__dependencies'] ?? [];
|
45
|
+
const dispose = UnistylesListener.addListeners(dependencies, () => setStyle(getStyles(passedStyles)));
|
46
|
+
setStyle(newStyles);
|
47
|
+
return dispose;
|
48
|
+
}, [passedStyles]);
|
49
|
+
return /*#__PURE__*/_jsx(Component, {
|
50
|
+
...props,
|
51
|
+
style: style
|
52
|
+
});
|
53
|
+
};
|
54
|
+
//# sourceMappingURL=createUnistylesComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","extractHiddenProperties","extractSecrets","UnistylesRuntime","getVariants","UnistylesListener","jsx","_jsx","getStyles","value","secrets","length","undefined","reduce","acc","__uni__stylesheet","__uni__key","__uni__args","__uni__variants","newComputedStylesheet","theme","miniRuntime","style","resultHidden","result","variants","Object","fromEntries","resultWithVariants","createUnistylesComponent","Component","props","passedStyles","setStyle","newStyles","dependencies","dispose","addListeners"],"sourceRoot":"../../../src","sources":["web/createUnistylesComponent.tsx"],"mappings":";;AAAA,OAAOA,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2BC,SAAsC,IAAMC,KAAa,IAAK;EAC1H,MAAMC,YAAY,GAAID,KAAK,CAA6CT,KAAK,IAAI,CAAC,CAAC;EACnF,MAAM,CAACA,KAAK,EAAEW,QAAQ,CAAC,GAAGjC,QAAQ,CAACQ,SAAS,CAACwB,YAAY,CAAC,CAAC;EAE3DjC,SAAS,CAAC,MAAM;IACZ,MAAMmC,SAAS,GAAG1B,SAAS,CAACwB,YAAY,CAAC;IACzC,MAAMG,YAAY,GAAGD,SAAS,GAAG,mBAAmB,CAAC,IAAI,EAAE;IAC3D,MAAME,OAAO,GAAG/B,iBAAiB,CAACgC,YAAY,CAACF,YAAY,EAAE,MAAMF,QAAQ,CAACzB,SAAS,CAACwB,YAAY,CAAC,CAAC,CAAC;IAErGC,QAAQ,CAACC,SAAS,CAAC;IAEnB,OAAOE,OAAO;EAClB,CAAC,EAAE,CAACJ,YAAY,CAAC,CAAC;EAElB,oBACIzB,IAAA,CAACuB,SAAS;IAAA,GACFC,KAAK;IACTT,KAAK,EAAEA;EAAM,CAChB,CAAC;AAEV,CAAC","ignoreList":[]}
|
package/lib/module/web/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
import { create } from './create';
|
4
|
-
import { UnistylesRuntime } from './runtime';
|
5
4
|
import { UnistylesState } from './state';
|
6
5
|
import { deepMergeObjects } from './utils';
|
7
6
|
export const StyleSheet = {
|
@@ -19,6 +18,9 @@ export const StyleSheet = {
|
|
19
18
|
hairlineWidth: 1
|
20
19
|
};
|
21
20
|
export { UnistylesRuntime } from './runtime';
|
21
|
+
export { UnistylesShadowRegistry } from './shadowRegistry';
|
22
22
|
export * from './mock';
|
23
|
-
|
23
|
+
|
24
|
+
// TODO: Work on SSR
|
25
|
+
export const getSSRUnistyles = () => [];
|
24
26
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["create","
|
1
|
+
{"version":3,"names":["create","UnistylesState","deepMergeObjects","StyleSheet","configure","init","absoluteFill","position","left","top","right","bottom","compose","a","b","flatten","styles","hairlineWidth","UnistylesRuntime","UnistylesShadowRegistry","getSSRUnistyles"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,gBAAgB,QAAQ,SAAS;AAE1C,OAAO,MAAMC,UAAU,GAAG;EACtBC,SAAS,EAAEH,cAAc,CAACI,IAAI;EAC9BL,MAAM;EACNM,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAKZ,gBAAgB,CAACW,CAAC,EAAEC,CAAC,CAAC;EACzDC,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAKd,gBAAgB,CAAC,GAAGc,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAED,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,cAAc,QAAQ;;AAEtB;AACA,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM,EAAE","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistylesListener"],"sourceRoot":"../../../../src","sources":["web/listener/index.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,YAAY","ignoreList":[]}
|
1
|
+
{"version":3,"names":["UnistylesListener","listenToDependencies"],"sourceRoot":"../../../../src","sources":["web/listener/index.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB","ignoreList":[]}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { UnistylesListener } from './listener';
|
4
|
+
import { UnistylesRuntime } from '../runtime';
|
5
|
+
import { keyInObject } from '../utils';
|
6
|
+
import { UnistylesRegistry } from '../registry';
|
7
|
+
export const listenToDependencies = ({
|
8
|
+
key,
|
9
|
+
className,
|
10
|
+
unistyles,
|
11
|
+
args = [],
|
12
|
+
stylesheet
|
13
|
+
}) => {
|
14
|
+
const newComputedStylesheet = typeof stylesheet === 'function' ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : stylesheet;
|
15
|
+
const _value = keyInObject(newComputedStylesheet, key) ? newComputedStylesheet[key] : undefined;
|
16
|
+
if (!_value) {
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
const value = typeof _value === 'function' ? _value(...args) : _value;
|
20
|
+
const dependencies = 'uni__dependencies' in value ? value['uni__dependencies'] : [];
|
21
|
+
if (dependencies.length === 0) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
return UnistylesListener.addListeners(dependencies, () => {
|
25
|
+
const newComputedStylesheet = typeof stylesheet === 'function' ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : stylesheet;
|
26
|
+
if (!keyInObject(newComputedStylesheet, key)) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
const value = newComputedStylesheet[key];
|
30
|
+
const result = typeof value === 'function' ? value(...args) : value;
|
31
|
+
UnistylesRegistry.updateStyles(unistyles, result, className);
|
32
|
+
});
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=listenToDependencies.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesListener","UnistylesRuntime","keyInObject","UnistylesRegistry","listenToDependencies","key","className","unistyles","args","stylesheet","newComputedStylesheet","theme","miniRuntime","_value","undefined","value","dependencies","length","addListeners","result","updateStyles"],"sourceRoot":"../../../../src","sources":["web/listener/listenToDependencies.ts"],"mappings":";;AAGA,SAASA,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,WA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,SAAS,CAAC;EAChE,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import { UnistyleDependency } from '../../specs/NativePlatform';
|
4
4
|
import { UnistylesRuntime } from '../runtime';
|
5
|
-
|
5
|
+
class UnistylesListenerBuilder {
|
6
6
|
isInitialized = false;
|
7
7
|
listeners = Array.from({
|
8
8
|
length: Object.keys(UnistyleDependency).length / 2
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistyleDependency","UnistylesRuntime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","Set","emitChange","dependency","forEach","listener","initListeners","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","UnistylesListener"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,
|
1
|
+
{"version":3,"names":["UnistyleDependency","UnistylesRuntime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","Set","emitChange","dependency","forEach","listener","initListeners","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","UnistylesListener"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,MAAMC,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACT,kBAAkB,CAAC,CAACO,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAIG,GAAG,CAAe,CAAC,CAAC;EAErHC,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACR,SAAS,CAACQ,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;EAC/D,CAAC;EAEDC,aAAa,GAAGA,CAAA,KAAM;IAClB,IAAI,IAAI,CAACZ,aAAa,EAAE;MACpB;IACJ;IAEA,IAAI,CAACA,aAAa,GAAG,IAAI;IACzBF,gBAAgB,CAACe,SAAS,EAAEC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACN,UAAU,CAACX,kBAAkB,CAACkB,WAAW,CAAC,CAAC;IAC7GjB,gBAAgB,CAACkB,UAAU,EAAEF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACN,UAAU,CAACX,kBAAkB,CAACkB,WAAW,CAAC,CAAC;IAC9GE,MAAM,CAACH,gBAAgB,CAAC,mBAAmB,EAAE,MAAM,IAAI,CAACN,UAAU,CAACX,kBAAkB,CAACqB,WAAW,CAAC,CAAC;IACnGD,MAAM,CAACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACN,UAAU,CAACX,kBAAkB,CAACsB,UAAU,CAAC,CAAC;EAC3F,CAAC;EAEDC,YAAY,GAAGA,CAACC,YAAuC,EAAEV,QAAsB,KAAK;IAChFU,YAAY,CAACX,OAAO,CAACD,UAAU,IAAI,IAAI,CAACR,SAAS,CAACQ,UAAU,CAAC,EAAEa,GAAG,CAACX,QAAQ,CAAC,CAAC;IAE7E,OAAO,MAAM;MACTU,YAAY,CAACX,OAAO,CAACD,UAAU,IAAI,IAAI,CAACR,SAAS,CAACQ,UAAU,CAAC,EAAEc,MAAM,CAACZ,QAAQ,CAAC,CAAC;IACpF,CAAC;EACL,CAAC;AACL;AAEA,OAAO,MAAMa,iBAAiB,GAAG,IAAIzB,wBAAwB,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/web/mock.js
CHANGED
@@ -21,13 +21,4 @@ export const NavigationBar = {
|
|
21
21
|
__type: 'web',
|
22
22
|
name: 'NavigationBar'
|
23
23
|
};
|
24
|
-
export const UnistylesShadowRegistry = {
|
25
|
-
name: 'UnistylesShadowRegistry',
|
26
|
-
__type: 'web',
|
27
|
-
equals: () => true,
|
28
|
-
toString: () => 'UnistylesShadowRegistry',
|
29
|
-
dispose: () => {},
|
30
|
-
add: () => {},
|
31
|
-
remove: () => {}
|
32
|
-
};
|
33
24
|
//# sourceMappingURL=mock.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["StatusBar","width","height","setStyle","setHidden","setBackgroundColor","equals","toString","__type","name","NavigationBar"
|
1
|
+
{"version":3,"names":["StatusBar","width","height","setStyle","setHidden","setBackgroundColor","equals","toString","__type","name","NavigationBar"],"sourceRoot":"../../../src","sources":["web/mock.ts"],"mappings":";;AAGA,OAAO,MAAMA,SAAwB,GAAG;EACpCC,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;AAED,OAAO,MAAMC,aAAgC,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":[]}
|
package/lib/module/web/pseudo.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
export const
|
5
|
-
export const isPseudo = selector => pseudos.includes(selector);
|
3
|
+
export const 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'];
|
4
|
+
export const isPseudo = selector => pseudos.some(pseudo => selector.startsWith(pseudo));
|
6
5
|
//# sourceMappingURL=pseudo.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["pseudos","isPseudo","selector","
|
1
|
+
{"version":3,"names":["pseudos","isPseudo","selector","some","pseudo","startsWith"],"sourceRoot":"../../../src","sources":["web/pseudo.ts"],"mappings":";;AAAA,OAAO,MAAMA,OAAO,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,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,EACb,eAAe,EACf,OAAO,EACP,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EACf,OAAO,EACP,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,8BAA8B,EAC9B,qCAAqC,EACrC,8BAA8B,EAC9B,8BAA8B,EAC9B,iCAAiC,EACjC,uBAAuB,EACvB,iCAAiC,EACjC,yBAAyB,EACzB,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EAChC,uBAAuB,EACvB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,MAAM,EACN,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,sBAAsB,CAChB;AAEV,OAAO,MAAMC,QAAQ,GAAIC,QAAgB,IAAKF,OAAO,CAACG,IAAI,CAACC,MAAM,IAAIF,QAAQ,CAACG,UAAU,CAACD,MAAM,CAAC,CAAC","ignoreList":[]}
|
@@ -2,14 +2,12 @@
|
|
2
2
|
|
3
3
|
import { createTypeStyle } from 'typestyle';
|
4
4
|
import { convertToTypeStyle } from './convert';
|
5
|
-
import { UnistylesState } from './state';
|
6
5
|
class UnistylesRegistryBuilder {
|
7
6
|
createStyles = (stylesheet, key) => {
|
8
|
-
const
|
9
|
-
const unistyles = createTypeStyle(stylesTag);
|
7
|
+
const unistyles = createTypeStyle();
|
10
8
|
const typestyleStylesheet = convertToTypeStyle(stylesheet);
|
11
9
|
const className = unistyles.style({
|
12
|
-
$debugName:
|
10
|
+
$debugName: `${key}-${Math.random().toString(16).slice(10)}`
|
13
11
|
}, typestyleStylesheet);
|
14
12
|
if (stylesheet._web?._css) {
|
15
13
|
const customClassName = Array.isArray(stylesheet._web._css) ? stylesheet._web._css.join(' ') : stylesheet._web._css;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createTypeStyle","convertToTypeStyle","
|
1
|
+
{"version":3,"names":["createTypeStyle","convertToTypeStyle","UnistylesRegistryBuilder","createStyles","stylesheet","key","unistyles","typestyleStylesheet","className","style","$debugName","Math","random","toString","slice","_web","_css","customClassName","Array","isArray","join","updateStyles","reinit","cssRule","UnistylesRegistry"],"sourceRoot":"../../../src","sources":["web/registry.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAmB,WAAW;AAEtD,SAASC,kBAAkB,QAAQ,WAAW;AAE9C,MAAMC,wBAAwB,CAAC;EAC3BC,YAAY,GAAGA,CAACC,UAA2B,EAAEC,GAAW,KAAK;IACzD,MAAMC,SAAS,GAAGN,eAAe,CAAC,CAAC;IACnC,MAAMO,mBAAmB,GAAGN,kBAAkB,CAACG,UAAU,CAAC;IAE1D,MAAMI,SAAS,GAAGF,SAAS,CAACG,KAAK,CAAC;MAC9BC,UAAU,EAAE,GAAGL,GAAG,IAAIM,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,EAAE,CAAC;IAC9D,CAAC,EAAEP,mBAAmB,CAAC;IAEvB,IAAIH,UAAU,CAACW,IAAI,EAAEC,IAAI,EAAE;MACvB,MAAMC,eAAe,GAAGC,KAAK,CAACC,OAAO,CAACf,UAAU,CAACW,IAAI,CAACC,IAAI,CAAC,GACrDZ,UAAU,CAACW,IAAI,CAACC,IAAI,CAACI,IAAI,CAAC,GAAG,CAAC,GAC9BhB,UAAU,CAACW,IAAI,CAACC,IAAI;MAE1B,OAAO;QACHR,SAAS,EAAE,GAAGA,SAAS,IAAIS,eAAe,EAAE;QAC5CX;MACJ,CAAC;IACL;IAEA,OAAO;MACHE,SAAS;MACTF;IACJ,CAAC;EACL,CAAC;EAEDe,YAAY,GAAGA,CAACf,SAAoB,EAAEF,UAA2B,EAAEI,SAAiB,KAAK;IACrF,MAAMD,mBAAmB,GAAGN,kBAAkB,CAACG,UAAU,CAAC;IAE1DE,SAAS,CAACgB,MAAM,CAAC,CAAC;IAClBhB,SAAS,CAACiB,OAAO,CAAC,IAAIf,SAAS,EAAE,EAAED,mBAAmB,CAAC;EAC3D,CAAC;AACL;AAEA,OAAO,MAAMiB,iBAAiB,GAAG,IAAItB,wBAAwB,CAAC,CAAC","ignoreList":[]}
|
@@ -154,7 +154,6 @@ class UnistylesRuntimeBuilder {
|
|
154
154
|
}
|
155
155
|
UnistylesState.themes.set(themeName, updater(oldTheme));
|
156
156
|
};
|
157
|
-
getSSRUnistyles = () => UnistylesState.tags;
|
158
157
|
}
|
159
158
|
export const UnistylesRuntime = new UnistylesRuntimeBuilder();
|
160
159
|
//# sourceMappingURL=runtime.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnistyleDependency","ColorScheme","Orientation","WebContentSizeCategory","UnistylesListener","NavigationBar","StatusBar","UnistylesState","hexToRGBA","isServer","schemeToTheme","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","window","matchMedia","colorScheme","matches","Light","Dark","Unspecified","themeName","contentSizeCategory","breakpoint","orientation","Portrait","screen","type","includes","Landscape","theme","Error","themes","get","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","miniRuntime","setTheme","UnistylesRuntime","emitChange","Theme","ThemeName","setAdaptiveThemes","isEnabled","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","setImmersiveMode","updateTheme","updater","oldTheme","set"
|
1
|
+
{"version":3,"names":["UnistyleDependency","ColorScheme","Orientation","WebContentSizeCategory","UnistylesListener","NavigationBar","StatusBar","UnistylesState","hexToRGBA","isServer","schemeToTheme","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","window","matchMedia","colorScheme","matches","Light","Dark","Unspecified","themeName","contentSizeCategory","breakpoint","orientation","Portrait","screen","type","includes","Landscape","theme","Error","themes","get","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","miniRuntime","setTheme","UnistylesRuntime","emitChange","Theme","ThemeName","setAdaptiveThemes","isEnabled","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","setImmersiveMode","updateTheme","updater","oldTheme","set"],"sourceRoot":"../../../src","sources":["web/runtime.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,WAAW,EAAEC,WAAW,QAA0C,gBAAgB;AAE3F,SAASC,sBAAsB,QAAQ,UAAU;AACjD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,aAAa,EAAEC,SAAS,QAAQ,QAAQ;AACjD,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,SAAS;AAE5D,MAAMC,uBAAuB,CAAC;EAC1BC,UAAU,GAAG,IAAI,CAACC,aAAa,CAAC,CAAC;EACjCC,SAAS,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;EAEvBF,aAAaA,CAAA,EAA0B;IAC3C,IAAIJ,QAAQ,CAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,IAAI,CAAC,IAAI,CAACG,UAAU,EAAE;MAClB,IAAI,CAACA,UAAU,GAAGI,MAAM,CAACC,UAAU,CAAC,+BAA+B,CAAC;IACxE;IAEA,OAAO,IAAI,CAACL,UAAU;EAC1B;EAEQG,YAAYA,CAAA,EAA0B;IAC1C,IAAIN,QAAQ,CAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,IAAI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C;EAE3BC,WAAW,GAAGA,CAAC/C,SAAuB,EAAEgD,OAA6C,KAAK;IACtF,MAAMC,QAAQ,GAAGjE,cAAc,CAAC2B,MAAM,CAACC,GAAG,CAACZ,SAAS,CAAC;IAErD,IAAI,CAACiD,QAAQ,EAAE;MACX,MAAM,IAAIvC,KAAK,CAAC,aAAaV,SAAS,sBAAsB,CAAC;IACjE;IAEAhB,cAAc,CAAC2B,MAAM,CAACuC,GAAG,CAAClD,SAAS,EAAEgD,OAAO,CAACC,QAAQ,CAAC,CAAC;EAC3D,CAAC;AACL;AAEA,OAAO,MAAMd,gBAAgB,GAAG,IAAI/C,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { listenToDependencies } from './listener';
|
4
|
+
import { UnistylesRegistry } from './registry';
|
5
|
+
import { UnistylesRuntime } from './runtime';
|
6
|
+
import { createDoubleMap, extractHiddenProperties, extractSecrets, isInDocument } from './utils';
|
7
|
+
import { getVariants } from './variants';
|
8
|
+
class UnistylesShadowRegistryBuilder {
|
9
|
+
// MOCKS
|
10
|
+
name = 'UnistylesShadowRegistry';
|
11
|
+
__type = 'web';
|
12
|
+
equals = () => true;
|
13
|
+
toString = () => 'UnistylesShadowRegistry';
|
14
|
+
dispose = () => {};
|
15
|
+
// END MOCKS
|
16
|
+
|
17
|
+
webUnistylesMap = createDoubleMap();
|
18
|
+
disposeMap = createDoubleMap();
|
19
|
+
stylesMap = createDoubleMap();
|
20
|
+
add = (ref, _style, _variants, _args) => {
|
21
|
+
// Style is not provided
|
22
|
+
if (!_style) {
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
|
26
|
+
// Array of styles
|
27
|
+
if (Array.isArray(_style)) {
|
28
|
+
_style.forEach(style => this.add(ref, style, _variants, _args));
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
|
32
|
+
// Not a unistyle
|
33
|
+
if (!Object.keys(_style).some(key => key.startsWith('__uni__'))) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
37
|
+
// Ref is unmounted, remove style tags from the document
|
38
|
+
if (ref === null) {
|
39
|
+
const secrets = extractSecrets(_style);
|
40
|
+
secrets.forEach(({
|
41
|
+
__uni__refs
|
42
|
+
}) => {
|
43
|
+
__uni__refs.forEach(ref => {
|
44
|
+
if (isInDocument(ref)) {
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
this.remove(ref, _style);
|
48
|
+
});
|
49
|
+
});
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
|
53
|
+
// Ref is not an HTMLElement
|
54
|
+
if (!(ref instanceof HTMLElement)) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
extractSecrets(_style).forEach(secret => {
|
58
|
+
const {
|
59
|
+
__uni__key,
|
60
|
+
__uni__stylesheet,
|
61
|
+
__uni__refs,
|
62
|
+
__uni__variants,
|
63
|
+
__uni__args = []
|
64
|
+
} = secret;
|
65
|
+
const newComputedStylesheet = typeof __uni__stylesheet === 'function' ? __uni__stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : __uni__stylesheet;
|
66
|
+
const style = newComputedStylesheet[__uni__key];
|
67
|
+
const args = _args ?? __uni__args;
|
68
|
+
const resultHidden = typeof style === 'function' ? style(...args) : style;
|
69
|
+
const result = extractHiddenProperties(resultHidden);
|
70
|
+
const {
|
71
|
+
variants
|
72
|
+
} = Object.fromEntries(getVariants({
|
73
|
+
variants: result
|
74
|
+
}, _variants && Object.keys(_variants).length > 0 ? _variants : __uni__variants));
|
75
|
+
const resultWithVariants = {
|
76
|
+
...result,
|
77
|
+
...variants
|
78
|
+
};
|
79
|
+
const storedWebUnistyle = this.webUnistylesMap.get(ref, __uni__key);
|
80
|
+
const webUnistyle = storedWebUnistyle ?? UnistylesRegistry.createStyles(resultWithVariants, __uni__key);
|
81
|
+
this.webUnistylesMap.set(ref, __uni__key, webUnistyle);
|
82
|
+
this.disposeMap.get(ref, __uni__key)?.();
|
83
|
+
this.disposeMap.set(ref, __uni__key, listenToDependencies({
|
84
|
+
key: __uni__key,
|
85
|
+
stylesheet: __uni__stylesheet,
|
86
|
+
args,
|
87
|
+
className: webUnistyle.className,
|
88
|
+
unistyles: webUnistyle.unistyles
|
89
|
+
}));
|
90
|
+
if (!storedWebUnistyle) {
|
91
|
+
const styleTag = document.createElement('style');
|
92
|
+
ref.classList.add(webUnistyle.className);
|
93
|
+
webUnistyle.unistyles.setStylesTarget(styleTag);
|
94
|
+
document.head.appendChild(styleTag);
|
95
|
+
__uni__refs.add(ref);
|
96
|
+
this.stylesMap.set(ref, __uni__key, styleTag);
|
97
|
+
}
|
98
|
+
if (storedWebUnistyle) {
|
99
|
+
UnistylesRegistry.updateStyles(webUnistyle.unistyles, resultWithVariants, webUnistyle.className);
|
100
|
+
}
|
101
|
+
});
|
102
|
+
};
|
103
|
+
remove = (ref, style) => {
|
104
|
+
extractSecrets(style).forEach(({
|
105
|
+
__uni__key
|
106
|
+
}) => {
|
107
|
+
this.webUnistylesMap.delete(ref, __uni__key);
|
108
|
+
this.disposeMap.get(ref, __uni__key)?.();
|
109
|
+
this.disposeMap.delete(ref, __uni__key);
|
110
|
+
this.stylesMap.get(ref, __uni__key)?.remove();
|
111
|
+
this.stylesMap.delete(ref, __uni__key);
|
112
|
+
});
|
113
|
+
};
|
114
|
+
}
|
115
|
+
export const UnistylesShadowRegistry = new UnistylesShadowRegistryBuilder();
|
116
|
+
//# sourceMappingURL=shadowRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["listenToDependencies","UnistylesRegistry","UnistylesRuntime","createDoubleMap","extractHiddenProperties","extractSecrets","isInDocument","getVariants","UnistylesShadowRegistryBuilder","name","__type","equals","toString","dispose","webUnistylesMap","disposeMap","stylesMap","add","ref","_style","_variants","_args","Array","isArray","forEach","style","Object","keys","some","key","startsWith","secrets","__uni__refs","remove","HTMLElement","secret","__uni__key","__uni__stylesheet","__uni__variants","__uni__args","newComputedStylesheet","theme","miniRuntime","args","resultHidden","result","variants","fromEntries","length","resultWithVariants","storedWebUnistyle","get","webUnistyle","createStyles","set","stylesheet","className","unistyles","styleTag","document","createElement","classList","setStylesTarget","head","appendChild","updateStyles","delete","UnistylesShadowRegistry"],"sourceRoot":"../../../src","sources":["web/shadowRegistry.ts"],"mappings":";;AACA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,eAAe,EAAEC,uBAAuB,EAAEC,cAAc,EAAEC,YAAY,QAAQ,SAAS;AAChG,SAASC,WAAW,QAAQ,YAAY;AAMxC,MAAMC,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,GAAGX,eAAe,CAAmC,CAAC;EACrEY,UAAU,GAAGZ,eAAe,CAAgD,CAAC;EAC7Ea,SAAS,GAAGb,eAAe,CAAwC,CAAC;EAErFc,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,GAAG,CAACC,GAAG,EAAEO,KAAK,EAAEL,SAAS,EAAEC,KAAK,CAAC,CAAC;MAE/D;IACJ;;IAEA;IACA,IAAI,CAACK,MAAM,CAACC,IAAI,CAACR,MAAM,CAAC,CAACS,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE;MAC7D;I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