react-native-unistyles 3.0.0-alpha.21 → 3.0.0-alpha.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. package/cxx/hybridObjects/HybridStyleSheet.cpp +1 -1
  2. package/cxx/hybridObjects/HybridStyleSheet.h +1 -1
  3. package/lib/commonjs/web/convert/boxShadow.js +13 -13
  4. package/lib/commonjs/web/convert/boxShadow.js.map +1 -1
  5. package/lib/commonjs/web/convert/index.js +9 -11
  6. package/lib/commonjs/web/convert/index.js.map +1 -1
  7. package/lib/commonjs/web/convert/pseudo.js.map +1 -0
  8. package/lib/commonjs/web/convert/style.js +11 -7
  9. package/lib/commonjs/web/convert/style.js.map +1 -1
  10. package/lib/commonjs/web/convert/textShadow.js +12 -12
  11. package/lib/commonjs/web/convert/textShadow.js.map +1 -1
  12. package/lib/commonjs/web/convert/transform.js +5 -5
  13. package/lib/commonjs/web/convert/transform.js.map +1 -1
  14. package/lib/commonjs/web/{listener/listener.js → listener.js} +2 -2
  15. package/lib/commonjs/web/listener.js.map +1 -0
  16. package/lib/commonjs/web/mq.js.map +1 -1
  17. package/lib/commonjs/web/registry.js +159 -21
  18. package/lib/commonjs/web/registry.js.map +1 -1
  19. package/lib/commonjs/web/shadowRegistry.js +50 -48
  20. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  21. package/lib/commonjs/web/state.js +8 -16
  22. package/lib/commonjs/web/state.js.map +1 -1
  23. package/lib/commonjs/web/{utils.js → utils/common.js} +9 -47
  24. package/lib/commonjs/web/utils/common.js.map +1 -0
  25. package/lib/commonjs/web/utils/index.js +28 -0
  26. package/lib/commonjs/web/utils/index.js.map +1 -0
  27. package/lib/commonjs/web/utils/unistyle.js +82 -0
  28. package/lib/commonjs/web/utils/unistyle.js.map +1 -0
  29. package/lib/module/web/convert/boxShadow.js +13 -13
  30. package/lib/module/web/convert/boxShadow.js.map +1 -1
  31. package/lib/module/web/convert/index.js +7 -9
  32. package/lib/module/web/convert/index.js.map +1 -1
  33. package/lib/module/web/convert/pseudo.js.map +1 -0
  34. package/lib/module/web/convert/style.js +11 -7
  35. package/lib/module/web/convert/style.js.map +1 -1
  36. package/lib/module/web/convert/textShadow.js +12 -12
  37. package/lib/module/web/convert/textShadow.js.map +1 -1
  38. package/lib/module/web/convert/transform.js +5 -5
  39. package/lib/module/web/convert/transform.js.map +1 -1
  40. package/lib/module/web/{listener/listener.js → listener.js} +2 -2
  41. package/lib/module/web/listener.js.map +1 -0
  42. package/lib/module/web/mq.js.map +1 -1
  43. package/lib/module/web/registry.js +160 -22
  44. package/lib/module/web/registry.js.map +1 -1
  45. package/lib/module/web/shadowRegistry.js +51 -49
  46. package/lib/module/web/shadowRegistry.js.map +1 -1
  47. package/lib/module/web/state.js +8 -16
  48. package/lib/module/web/state.js.map +1 -1
  49. package/lib/module/web/{utils.js → utils/common.js} +7 -39
  50. package/lib/module/web/utils/common.js.map +1 -0
  51. package/lib/module/web/utils/index.js +5 -0
  52. package/lib/module/web/utils/index.js.map +1 -0
  53. package/lib/module/web/utils/unistyle.js +69 -0
  54. package/lib/module/web/utils/unistyle.js.map +1 -0
  55. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +1 -1
  56. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  57. package/lib/typescript/src/types/stylesheet.d.ts +1 -1
  58. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  59. package/lib/typescript/src/web/convert/boxShadow.d.ts +7 -2
  60. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -1
  61. package/lib/typescript/src/web/convert/index.d.ts +1 -2
  62. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  63. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -0
  64. package/lib/typescript/src/web/convert/style.d.ts +1 -2
  65. package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
  66. package/lib/typescript/src/web/convert/textShadow.d.ts +7 -2
  67. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -1
  68. package/lib/typescript/src/web/convert/transform.d.ts +1 -2
  69. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -1
  70. package/lib/typescript/src/web/{listener/listener.d.ts → listener.d.ts} +1 -1
  71. package/lib/typescript/src/web/listener.d.ts.map +1 -0
  72. package/lib/typescript/src/web/mq.d.ts +6 -2
  73. package/lib/typescript/src/web/mq.d.ts.map +1 -1
  74. package/lib/typescript/src/web/registry.d.ts +21 -8
  75. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  76. package/lib/typescript/src/web/shadowRegistry.d.ts +3 -4
  77. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  78. package/lib/typescript/src/web/state.d.ts +2 -2
  79. package/lib/typescript/src/web/state.d.ts.map +1 -1
  80. package/lib/typescript/src/web/{utils.d.ts → utils/common.d.ts} +2 -20
  81. package/lib/typescript/src/web/utils/common.d.ts.map +1 -0
  82. package/lib/typescript/src/web/utils/index.d.ts +3 -0
  83. package/lib/typescript/src/web/utils/index.d.ts.map +1 -0
  84. package/lib/typescript/src/web/utils/unistyle.d.ts +20 -0
  85. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -0
  86. package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
  87. package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency_.hpp +8 -8
  88. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +22 -22
  89. package/nitrogen/generated/android/c++/JOrientation.hpp +1 -1
  90. package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +1 -1
  91. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +2 -2
  92. package/nitrogen/generated/android/{UnistylesOnLoad.cpp → unistylesOnLoad.cpp} +2 -2
  93. package/nitrogen/generated/android/{UnistylesOnLoad.hpp → unistylesOnLoad.hpp} +1 -1
  94. package/nitrogen/generated/ios/Unistyles+autolinking.rb +5 -3
  95. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +25 -0
  96. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +32 -32
  97. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -29
  98. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +0 -12
  99. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +134 -110
  100. package/nitrogen/generated/shared/c++/ColorScheme.hpp +2 -2
  101. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  102. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
  103. package/nitrogen/generated/shared/c++/Orientation.hpp +2 -2
  104. package/package.json +4 -15
  105. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +1 -1
  106. package/src/types/stylesheet.ts +1 -1
  107. package/src/web/convert/boxShadow.ts +14 -15
  108. package/src/web/convert/index.ts +6 -13
  109. package/src/web/convert/style.ts +61 -10
  110. package/src/web/convert/textShadow.ts +13 -14
  111. package/src/web/convert/transform.ts +7 -8
  112. package/src/web/{listener/listener.ts → listener.ts} +2 -2
  113. package/src/web/mq.ts +1 -3
  114. package/src/web/registry.ts +202 -23
  115. package/src/web/shadowRegistry.ts +49 -49
  116. package/src/web/state.ts +13 -23
  117. package/src/web/{utils.ts → utils/common.ts} +6 -68
  118. package/src/web/utils/index.ts +2 -0
  119. package/src/web/utils/unistyle.ts +104 -0
  120. package/lib/commonjs/web/convert/breakpoint.js +0 -25
  121. package/lib/commonjs/web/convert/breakpoint.js.map +0 -1
  122. package/lib/commonjs/web/createUnistylesComponent.js +0 -61
  123. package/lib/commonjs/web/createUnistylesComponent.js.map +0 -1
  124. package/lib/commonjs/web/listener/index.js +0 -20
  125. package/lib/commonjs/web/listener/index.js.map +0 -1
  126. package/lib/commonjs/web/listener/listenToDependencies.js +0 -38
  127. package/lib/commonjs/web/listener/listenToDependencies.js.map +0 -1
  128. package/lib/commonjs/web/listener/listener.js.map +0 -1
  129. package/lib/commonjs/web/pseudo.js.map +0 -1
  130. package/lib/commonjs/web/utils.js.map +0 -1
  131. package/lib/module/web/convert/breakpoint.js +0 -20
  132. package/lib/module/web/convert/breakpoint.js.map +0 -1
  133. package/lib/module/web/createUnistylesComponent.js +0 -54
  134. package/lib/module/web/createUnistylesComponent.js.map +0 -1
  135. package/lib/module/web/listener/index.js +0 -5
  136. package/lib/module/web/listener/index.js.map +0 -1
  137. package/lib/module/web/listener/listenToDependencies.js +0 -33
  138. package/lib/module/web/listener/listenToDependencies.js.map +0 -1
  139. package/lib/module/web/listener/listener.js.map +0 -1
  140. package/lib/module/web/pseudo.js.map +0 -1
  141. package/lib/module/web/utils.js.map +0 -1
  142. package/lib/typescript/src/web/convert/breakpoint.d.ts +0 -3
  143. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +0 -1
  144. package/lib/typescript/src/web/createUnistylesComponent.d.ts +0 -3
  145. package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +0 -1
  146. package/lib/typescript/src/web/listener/index.d.ts +0 -3
  147. package/lib/typescript/src/web/listener/index.d.ts.map +0 -1
  148. package/lib/typescript/src/web/listener/listenToDependencies.d.ts +0 -12
  149. package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +0 -1
  150. package/lib/typescript/src/web/listener/listener.d.ts.map +0 -1
  151. package/lib/typescript/src/web/pseudo.d.ts.map +0 -1
  152. package/lib/typescript/src/web/utils.d.ts.map +0 -1
  153. package/src/web/convert/breakpoint.ts +0 -21
  154. package/src/web/createUnistylesComponent.tsx +0 -54
  155. package/src/web/listener/index.ts +0 -2
  156. package/src/web/listener/listenToDependencies.ts +0 -45
  157. /package/lib/commonjs/web/{pseudo.js → convert/pseudo.js} +0 -0
  158. /package/lib/module/web/{pseudo.js → convert/pseudo.js} +0 -0
  159. /package/lib/typescript/src/web/{pseudo.d.ts → convert/pseudo.d.ts} +0 -0
  160. /package/nitrogen/generated/android/{UnistylesOnLoad.kt → unistylesO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B,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAKnE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,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,2 +0,0 @@
1
- export { UnistylesListener } from './listener'
2
- export { listenToDependencies } from './listenToDependencies'
@@ -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