react-native-unistyles 3.0.0-alpha.21 → 3.0.0-alpha.23
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/core/UnistylesRegistry.cpp +26 -0
- package/cxx/core/UnistylesRegistry.h +1 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +11 -5
- package/cxx/hybridObjects/HybridStyleSheet.h +1 -1
- package/cxx/parser/Parser.cpp +27 -1
- package/cxx/parser/Parser.h +1 -1
- package/lib/commonjs/web/convert/boxShadow.js +13 -13
- package/lib/commonjs/web/convert/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +9 -11
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/pseudo.js.map +1 -0
- package/lib/commonjs/web/convert/style.js +11 -7
- package/lib/commonjs/web/convert/style.js.map +1 -1
- package/lib/commonjs/web/convert/textShadow.js +12 -12
- package/lib/commonjs/web/convert/textShadow.js.map +1 -1
- package/lib/commonjs/web/convert/transform.js +5 -5
- package/lib/commonjs/web/convert/transform.js.map +1 -1
- package/lib/commonjs/web/{listener/listener.js → listener.js} +2 -2
- package/lib/commonjs/web/listener.js.map +1 -0
- package/lib/commonjs/web/mq.js.map +1 -1
- package/lib/commonjs/web/registry.js +159 -21
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +50 -48
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +8 -16
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/{utils.js → utils/common.js} +9 -47
- package/lib/commonjs/web/utils/common.js.map +1 -0
- package/lib/commonjs/web/utils/index.js +28 -0
- package/lib/commonjs/web/utils/index.js.map +1 -0
- package/lib/commonjs/web/utils/unistyle.js +82 -0
- package/lib/commonjs/web/utils/unistyle.js.map +1 -0
- package/lib/module/web/convert/boxShadow.js +13 -13
- package/lib/module/web/convert/boxShadow.js.map +1 -1
- package/lib/module/web/convert/index.js +7 -9
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/pseudo.js.map +1 -0
- package/lib/module/web/convert/style.js +11 -7
- package/lib/module/web/convert/style.js.map +1 -1
- package/lib/module/web/convert/textShadow.js +12 -12
- package/lib/module/web/convert/textShadow.js.map +1 -1
- package/lib/module/web/convert/transform.js +5 -5
- package/lib/module/web/convert/transform.js.map +1 -1
- package/lib/module/web/{listener/listener.js → listener.js} +2 -2
- package/lib/module/web/listener.js.map +1 -0
- package/lib/module/web/mq.js.map +1 -1
- package/lib/module/web/registry.js +160 -22
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +51 -49
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +8 -16
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/{utils.js → utils/common.js} +7 -39
- package/lib/module/web/utils/common.js.map +1 -0
- package/lib/module/web/utils/index.js +5 -0
- package/lib/module/web/utils/index.js.map +1 -0
- package/lib/module/web/utils/unistyle.js +69 -0
- package/lib/module/web/utils/unistyle.js.map +1 -0
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts +7 -2
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts +1 -2
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/style.d.ts +1 -2
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/textShadow.d.ts +7 -2
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/transform.d.ts +1 -2
- package/lib/typescript/src/web/convert/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/{listener/listener.d.ts → listener.d.ts} +1 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -0
- package/lib/typescript/src/web/mq.d.ts +6 -2
- package/lib/typescript/src/web/mq.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +21 -8
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +3 -4
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts +2 -2
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/{utils.d.ts → utils/common.d.ts} +2 -20
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/index.d.ts +3 -0
- package/lib/typescript/src/web/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts +20 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency_.hpp +8 -8
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +22 -22
- package/nitrogen/generated/android/c++/JOrientation.hpp +1 -1
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +2 -2
- package/nitrogen/generated/android/{UnistylesOnLoad.cpp → unistylesOnLoad.cpp} +2 -2
- package/nitrogen/generated/android/{UnistylesOnLoad.hpp → unistylesOnLoad.hpp} +1 -1
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +5 -3
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +25 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +32 -32
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -29
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +0 -12
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +134 -110
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +2 -2
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/Orientation.hpp +2 -2
- package/package.json +4 -15
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +1 -1
- package/src/types/stylesheet.ts +1 -1
- package/src/web/convert/boxShadow.ts +14 -15
- package/src/web/convert/index.ts +6 -13
- package/src/web/convert/style.ts +61 -10
- package/src/web/convert/textShadow.ts +13 -14
- package/src/web/convert/transform.ts +7 -8
- package/src/web/{listener/listener.ts → listener.ts} +2 -2
- package/src/web/mq.ts +1 -3
- package/src/web/registry.ts +202 -23
- package/src/web/shadowRegistry.ts +49 -49
- package/src/web/state.ts +13 -23
- package/src/web/{utils.ts → utils/common.ts} +6 -68
- package/src/web/utils/index.ts +2 -0
- package/src/web/utils/unistyle.ts +104 -0
- package/lib/commonjs/web/convert/breakpoint.js +0 -25
- package/lib/commonjs/web/convert/breakpoint.js.map +0 -1
- package/lib/commonjs/web/createUnistylesComponent.js +0 -61
- package/lib/commonjs/web/createUnistylesComponent.js.map +0 -1
- package/lib/commonjs/web/listener/index.js +0 -20
- package/lib/commonjs/web/listener/index.js.map +0 -1
- package/lib/commonjs/web/listener/listenToDependencies.js +0 -38
- package/lib/commonjs/web/listener/listenToDependencies.js.map +0 -1
- package/lib/commonjs/web/listener/listener.js.map +0 -1
- package/lib/commonjs/web/pseudo.js.map +0 -1
- package/lib/commonjs/web/utils.js.map +0 -1
- package/lib/module/web/convert/breakpoint.js +0 -20
- package/lib/module/web/convert/breakpoint.js.map +0 -1
- package/lib/module/web/createUnistylesComponent.js +0 -54
- package/lib/module/web/createUnistylesComponent.js.map +0 -1
- package/lib/module/web/listener/index.js +0 -5
- package/lib/module/web/listener/index.js.map +0 -1
- package/lib/module/web/listener/listenToDependencies.js +0 -33
- package/lib/module/web/listener/listenToDependencies.js.map +0 -1
- package/lib/module/web/listener/listener.js.map +0 -1
- package/lib/module/web/pseudo.js.map +0 -1
- package/lib/module/web/utils.js.map +0 -1
- package/lib/typescript/src/web/convert/breakpoint.d.ts +0 -3
- package/lib/typescript/src/web/convert/breakpoint.d.ts.map +0 -1
- package/lib/typescript/src/web/createUnistylesComponent.d.ts +0 -3
- package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +0 -1
- package/lib/typescript/src/web/listener/index.d.ts +0 -3
- package/lib/typescript/src/web/listener/index.d.ts.map +0 -1
- package/lib/typescript/src/web/listener/listenToDependencies.d.ts +0 -12
- package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +0 -1
- package/lib/typescript/src/web/listener/listener.d.ts.map +0 -1
- package/lib/typescript/src/web/pseudo.d.ts.map +0 -1
- package/lib/typescript/src/web/utils.d.ts.map +0 -1
- package/src/web/convert/breakpoint.ts +0 -21
- package/src/web/createUnistylesComponent.tsx +0 -54
- package/src/web/listener/index.ts +0 -2
- package/src/web/listener/listenToDependencies.ts +0 -45
- /package/lib/commonjs/web/{pseudo.js → convert/pseudo.js} +0 -0
- /package/lib/module/web/{pseudo.js → convert/pseudo.js} +0 -0
- /package/lib/typescript/src/web/{pseudo.d.ts → convert/pseudo.d.ts} +0 -0
- /package/nitrogen/generated/android/{UnistylesOnLoad.kt → unistylesOnLoad.kt} +0 -0
- /package/src/web/{pseudo.ts → convert/pseudo.ts} +0 -0
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/web/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe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GAAG,sBAUzC,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,eAAe,OAUhD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,IAAI,EAAE,UAAU,EAAE,MAAM;eAIrC,IAAI,aAAa,UAAU;eAS3B,IAAI,aAAa,UAAU,SAAS,MAAM;kBAMvC,IAAI,aAAa,UAAU;wBASrB,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI;CAQpF,CAAA;AAED,eAAO,MAAM,uBAAuB,WAAY,GAAG;;CAQlD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA"}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { MediaQuery } from 'typestyle/lib/types'
|
2
|
-
import { UnistylesState } from '../state'
|
3
|
-
import { keyInObject } from '../utils'
|
4
|
-
import { isUnistylesMq, parseMq } from '../mq'
|
5
|
-
import { Orientation } from '../../specs/types'
|
6
|
-
|
7
|
-
export const convertBreakpoint = (breakpoint: string): MediaQuery => {
|
8
|
-
if (Object.values(Orientation).includes(breakpoint as Orientation)) {
|
9
|
-
return {
|
10
|
-
orientation: breakpoint as Orientation
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
if (isUnistylesMq(breakpoint)) {
|
15
|
-
return parseMq(breakpoint)
|
16
|
-
}
|
17
|
-
|
18
|
-
return {
|
19
|
-
minWidth: UnistylesState.breakpoints && keyInObject(UnistylesState.breakpoints, breakpoint) ? UnistylesState.breakpoints[breakpoint] : undefined,
|
20
|
-
}
|
21
|
-
}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
2
|
-
import { extractHiddenProperties, extractSecrets } from './utils'
|
3
|
-
import { getVariants } from './variants'
|
4
|
-
import { UnistylesListener } from './listener'
|
5
|
-
import { UnistylesRegistry } from './registry'
|
6
|
-
|
7
|
-
const getStyles = (value: Record<string, any>) => {
|
8
|
-
const secrets = extractSecrets(value)
|
9
|
-
|
10
|
-
if (secrets.length === 0) {
|
11
|
-
return undefined
|
12
|
-
}
|
13
|
-
|
14
|
-
return secrets.reduce((acc, { __uni__stylesheet, __uni__key, __uni__args = [], __uni__variants }) => {
|
15
|
-
const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet)
|
16
|
-
const style = newComputedStylesheet[__uni__key]
|
17
|
-
const resultHidden = typeof style === 'function'
|
18
|
-
? style(...__uni__args)
|
19
|
-
: style
|
20
|
-
const result = extractHiddenProperties(resultHidden)
|
21
|
-
const { variants } = Object.fromEntries(getVariants({ variants: result }, __uni__variants ))
|
22
|
-
const resultWithVariants = {
|
23
|
-
...result,
|
24
|
-
...variants
|
25
|
-
}
|
26
|
-
|
27
|
-
return {
|
28
|
-
...acc,
|
29
|
-
...resultWithVariants
|
30
|
-
}
|
31
|
-
}, {} as Record<string, any>)
|
32
|
-
}
|
33
|
-
|
34
|
-
export const createUnistylesComponent = <TProps extends object>(Component: React.ComponentType<TProps>) => (props: TProps) => {
|
35
|
-
const passedStyles = (props as TProps & { style: Record<string, any> }).style ?? {}
|
36
|
-
const [style, setStyle] = useState(getStyles(passedStyles))
|
37
|
-
|
38
|
-
useEffect(() => {
|
39
|
-
const newStyles = getStyles(passedStyles)
|
40
|
-
const dependencies = newStyles?.['uni__dependencies'] ?? []
|
41
|
-
const dispose = UnistylesListener.addListeners(dependencies, () => setStyle(getStyles(passedStyles)))
|
42
|
-
|
43
|
-
setStyle(newStyles)
|
44
|
-
|
45
|
-
return dispose
|
46
|
-
}, [passedStyles])
|
47
|
-
|
48
|
-
return (
|
49
|
-
<Component
|
50
|
-
{...props}
|
51
|
-
style={style}
|
52
|
-
/>
|
53
|
-
)
|
54
|
-
}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
import type { TypeStyle } from 'typestyle'
|
2
|
-
import type { StyleSheet, StyleSheetWithSuperPowers } from '../../types/stylesheet'
|
3
|
-
import type { UnistyleDependency } from '../../specs/NativePlatform'
|
4
|
-
import { UnistylesListener } from './listener'
|
5
|
-
import { keyInObject } from '../utils'
|
6
|
-
import { UnistylesRegistry } from '../registry'
|
7
|
-
|
8
|
-
type ListenToDependenciesProps = {
|
9
|
-
key: PropertyKey,
|
10
|
-
unistyles: TypeStyle,
|
11
|
-
className: string,
|
12
|
-
stylesheet: StyleSheetWithSuperPowers<StyleSheet>
|
13
|
-
args?: Array<any>
|
14
|
-
}
|
15
|
-
|
16
|
-
export const listenToDependencies = ({ key, className, unistyles, args = [], stylesheet }: ListenToDependenciesProps) => {
|
17
|
-
const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(stylesheet)
|
18
|
-
const _value = keyInObject(newComputedStylesheet, key) ? newComputedStylesheet[key] : undefined
|
19
|
-
|
20
|
-
if (!_value) {
|
21
|
-
return
|
22
|
-
}
|
23
|
-
|
24
|
-
const value = typeof _value === 'function' ? _value(...args) : _value
|
25
|
-
const dependencies = ('uni__dependencies' in value ? value['uni__dependencies'] : []) as Array<UnistyleDependency>
|
26
|
-
|
27
|
-
if (dependencies.length === 0) {
|
28
|
-
return
|
29
|
-
}
|
30
|
-
|
31
|
-
return UnistylesListener.addListeners(dependencies, () => {
|
32
|
-
const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(stylesheet)
|
33
|
-
|
34
|
-
if (!keyInObject(newComputedStylesheet, key)) {
|
35
|
-
return
|
36
|
-
}
|
37
|
-
|
38
|
-
const value = newComputedStylesheet[key]!
|
39
|
-
const result = typeof value === 'function'
|
40
|
-
? value(...args)
|
41
|
-
: value
|
42
|
-
|
43
|
-
UnistylesRegistry.updateStyles(unistyles, result, className)
|
44
|
-
})
|
45
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|