react-native-unistyles 3.0.0-alpha.19 → 3.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/cxx/common/Constants.h +1 -0
  2. package/cxx/common/Helpers.h +7 -7
  3. package/cxx/core/HostStyle.cpp +1 -1
  4. package/cxx/core/HostStyle.h +1 -0
  5. package/cxx/core/StyleSheet.h +0 -1
  6. package/cxx/core/UnistyleWrapper.h +77 -9
  7. package/cxx/core/UnistylesRegistry.cpp +14 -13
  8. package/cxx/core/UnistylesRegistry.h +3 -2
  9. package/cxx/hybridObjects/HybridShadowRegistry.cpp +4 -5
  10. package/cxx/parser/Parser.cpp +10 -2
  11. package/lib/commonjs/specs/ShadowRegistry/index.js +3 -35
  12. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  13. package/lib/commonjs/web/createUnistylesComponent.js +2 -2
  14. package/lib/commonjs/web/createUnistylesComponent.js.map +1 -1
  15. package/lib/commonjs/web/listener/listenToDependencies.js +2 -3
  16. package/lib/commonjs/web/listener/listenToDependencies.js.map +1 -1
  17. package/lib/commonjs/web/registry.js +22 -0
  18. package/lib/commonjs/web/registry.js.map +1 -1
  19. package/lib/commonjs/web/shadowRegistry.js +1 -2
  20. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  21. package/lib/module/specs/ShadowRegistry/index.js +3 -35
  22. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  23. package/lib/module/web/createUnistylesComponent.js +2 -2
  24. package/lib/module/web/createUnistylesComponent.js.map +1 -1
  25. package/lib/module/web/listener/listenToDependencies.js +2 -3
  26. package/lib/module/web/listener/listenToDependencies.js.map +1 -1
  27. package/lib/module/web/registry.js +22 -0
  28. package/lib/module/web/registry.js.map +1 -1
  29. package/lib/module/web/shadowRegistry.js +1 -2
  30. package/lib/module/web/shadowRegistry.js.map +1 -1
  31. package/lib/typescript/example/App.d.ts.map +1 -1
  32. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +1 -1
  33. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  34. package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -1
  35. package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -1
  36. package/lib/typescript/src/web/registry.d.ts +3 -0
  37. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  38. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/plugin/__tests__/dependencies.spec.js +5 -5
  41. package/plugin/__tests__/ref.spec.js +119 -41
  42. package/plugin/__tests__/stylesheet.spec.js +9 -9
  43. package/plugin/index.js +12 -1
  44. package/plugin/ref.js +20 -31
  45. package/plugin/style.js +33 -6
  46. package/src/specs/ShadowRegistry/index.ts +4 -38
  47. package/src/web/createUnistylesComponent.tsx +2 -4
  48. package/src/web/listener/listenToDependencies.ts +2 -7
  49. package/src/web/registry.ts +32 -0
  50. package/src/web/shadowRegistry.ts +1 -4
@@ -44,7 +44,7 @@ pluginTester({
44
44
  style={[styles.container]}
45
45
  ref={ref => {
46
46
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
47
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
47
+ return () => UnistylesShadowRegistry.remove(ref)
48
48
  }}
49
49
  >
50
50
  <Text>Hello world</Text>
@@ -93,7 +93,7 @@ pluginTester({
93
93
  style={[styles.container]}
94
94
  ref={ref => {
95
95
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
96
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
96
+ return () => UnistylesShadowRegistry.remove(ref)
97
97
  }}
98
98
  >
99
99
  <Text>Hello world</Text>
@@ -143,7 +143,7 @@ pluginTester({
143
143
  style={[styles.container]}
144
144
  ref={ref => {
145
145
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
146
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
146
+ return () => UnistylesShadowRegistry.remove(ref)
147
147
  }}
148
148
  >
149
149
  <Text>Hello world</Text>
@@ -194,7 +194,7 @@ pluginTester({
194
194
  style={[styles.container]}
195
195
  ref={ref => {
196
196
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
197
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
197
+ return () => UnistylesShadowRegistry.remove(ref)
198
198
  }}
199
199
  >
200
200
  <Text>Hello world</Text>
@@ -246,7 +246,7 @@ pluginTester({
246
246
  style={[styles.container]}
247
247
  ref={ref => {
248
248
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
249
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
249
+ return () => UnistylesShadowRegistry.remove(ref)
250
250
  }}
251
251
  >
252
252
  <Text>Hello world</Text>
@@ -299,7 +299,7 @@ pluginTester({
299
299
  style={[styles.container]}
300
300
  ref={ref => {
301
301
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
302
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
302
+ return () => UnistylesShadowRegistry.remove(ref)
303
303
  }}
304
304
  >
305
305
  <Text>Hello world</Text>
@@ -353,7 +353,7 @@ pluginTester({
353
353
  style={[styles.container]}
354
354
  ref={ref => {
355
355
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
356
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
356
+ return () => UnistylesShadowRegistry.remove(ref)
357
357
  }}
358
358
  >
359
359
  <Text>Hello world</Text>
@@ -409,7 +409,7 @@ pluginTester({
409
409
  style={[styles.container]}
410
410
  ref={ref => {
411
411
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
412
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
412
+ return () => UnistylesShadowRegistry.remove(ref)
413
413
  }}
414
414
  >
415
415
  <Text>Hello world</Text>
@@ -473,7 +473,7 @@ pluginTester({
473
473
  style={[styles.container]}
474
474
  ref={ref => {
475
475
  UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
476
- return () => UnistylesShadowRegistry.remove(ref, styles.container)
476
+ return () => UnistylesShadowRegistry.remove(ref)
477
477
  }}
478
478
  >
479
479
  <Text>Hello world</Text>
package/plugin/index.js CHANGED
@@ -34,6 +34,7 @@ module.exports = function ({ types: t }) {
34
34
  state.file.hasUnistylesImport = false
35
35
  state.file.styleSheetLocalName = ''
36
36
  state.file.tagNumber = 0
37
+ state.file.isClassComponent = false
37
38
  state.reactNativeImports = {}
38
39
  },
39
40
  exit(path, state) {
@@ -58,6 +59,7 @@ module.exports = function ({ types: t }) {
58
59
 
59
60
  if (componentName) {
60
61
  state.file.hasVariants = false
62
+ state.file.isClassComponent = true
61
63
  }
62
64
  },
63
65
  VariableDeclaration(path, state) {
@@ -95,11 +97,20 @@ module.exports = function ({ types: t }) {
95
97
  }
96
98
  },
97
99
  JSXElement(path, state) {
100
+ if (state.file.isClassComponent) {
101
+ return
102
+ }
103
+
98
104
  const openingElement = path.node.openingElement
99
105
  const openingElementName = openingElement.name.name
100
106
  const isReactNativeComponent = Boolean(state.reactNativeImports[openingElementName])
107
+ const isAnimatedComponent = (
108
+ !isReactNativeComponent &&
109
+ openingElement.name.object &&
110
+ openingElement.name.object.name === 'Animated'
111
+ )
101
112
 
102
- if (!isReactNativeComponent) {
113
+ if (!isReactNativeComponent && !isAnimatedComponent) {
103
114
  return
104
115
  }
105
116
 
package/plugin/ref.js CHANGED
@@ -14,6 +14,17 @@ function hasStringRef(t, path) {
14
14
  )
15
15
  }
16
16
 
17
+ function memberExpressionFromArray(t, identifiers) {
18
+ // possible for inline styles
19
+ if (identifiers.length === 0) {
20
+ return undefined
21
+ }
22
+
23
+ const [base, ...members] = identifiers
24
+
25
+ return members.reduce((object, property) => t.memberExpression(object, t.identifier(property)), t.identifier(base))
26
+ }
27
+
17
28
  function addRef(t, path, metadata, state) {
18
29
  const hasVariants = state.file.hasVariants
19
30
 
@@ -25,9 +36,7 @@ function addRef(t, path, metadata, state) {
25
36
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
26
37
  [
27
38
  t.identifier('ref'),
28
- metadata.styleProp
29
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
30
- : t.identifier(metadata.styleObj),
39
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
31
40
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
32
41
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
33
42
  ]
@@ -37,12 +46,7 @@ function addRef(t, path, metadata, state) {
37
46
  t.arrowFunctionExpression([],
38
47
  t.callExpression(
39
48
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
40
- [
41
- t.identifier('ref'),
42
- metadata.styleProp
43
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
44
- : t.identifier(metadata.styleObj)
45
- ]
49
+ [t.identifier('ref')]
46
50
  )
47
51
  )
48
52
  )
@@ -81,9 +85,7 @@ function overrideRef(t, path, refProp, metadata, state) {
81
85
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
82
86
  [
83
87
  t.identifier(uniqueRefName),
84
- metadata.styleProp
85
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
86
- : t.identifier(metadata.styleObj),
88
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
87
89
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
88
90
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
89
91
  ]
@@ -94,10 +96,7 @@ function overrideRef(t, path, refProp, metadata, state) {
94
96
  t.callExpression(
95
97
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
96
98
  [
97
- t.identifier(uniqueRefName),
98
- metadata.styleProp
99
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
100
- : t.identifier(metadata.styleObj)
99
+ t.identifier(uniqueRefName)
101
100
  ]
102
101
  )
103
102
  )
@@ -131,9 +130,7 @@ function overrideRef(t, path, refProp, metadata, state) {
131
130
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
132
131
  [
133
132
  t.identifier(userRefName),
134
- metadata.styleProp
135
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
136
- : t.identifier(metadata.styleObj),
133
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
137
134
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
138
135
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
139
136
  ]
@@ -151,10 +148,7 @@ function overrideRef(t, path, refProp, metadata, state) {
151
148
  t.callExpression(
152
149
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
153
150
  [
154
- t.identifier(userRefName),
155
- metadata.styleProp
156
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
157
- : t.identifier(metadata.styleObj)
151
+ t.identifier(userRefName)
158
152
  ]
159
153
  )
160
154
  )
@@ -198,9 +192,7 @@ function overrideRef(t, path, refProp, metadata, state) {
198
192
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
199
193
  [
200
194
  t.identifier(uniqueRefName),
201
- metadata.styleProp
202
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
203
- : t.identifier(metadata.styleObj),
195
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
204
196
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
205
197
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
206
198
  ]
@@ -217,14 +209,11 @@ function overrideRef(t, path, refProp, metadata, state) {
217
209
  t.callExpression(
218
210
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
219
211
  [
220
- t.identifier(uniqueRefName),
221
- metadata.styleProp
222
- ? t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))
223
- : t.identifier(metadata.styleObj)
212
+ t.identifier(uniqueRefName)
224
213
  ]
225
214
  )
226
215
  )
227
- ]))
216
+ ].filter(Boolean)))
228
217
  )
229
218
  ])
230
219
  )
package/plugin/style.js CHANGED
@@ -1,10 +1,14 @@
1
1
  function getStyleMetadata(t, node, dynamicFunction = null) {
2
2
  // {styles.container}
3
3
  if (t.isMemberExpression(node)) {
4
+ const members = t.isMemberExpression(node.object)
5
+ ? [node.object.object.name, node.object.property.name, node.property.name]
6
+ : [node.object.name, node.property.name]
7
+
4
8
  return [
5
9
  {
6
- styleObj: node.object.name,
7
- styleProp: node.property.name,
10
+ members: members.filter(Boolean),
11
+ inlineStyle: undefined,
8
12
  dynamicFunction
9
13
  }
10
14
  ]
@@ -22,7 +26,31 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
22
26
 
23
27
  // {{ ...styles.container }}
24
28
  if (t.isObjectExpression(node)) {
25
- return node.properties.flatMap(prop => getStyleMetadata(t, prop.argument))
29
+ const inlineStyles = []
30
+
31
+ const partialResult = node
32
+ .properties
33
+ .flatMap(prop => {
34
+ // handle inline styles
35
+ if (t.isObjectProperty(prop)) {
36
+ inlineStyles.push(prop)
37
+
38
+ return null
39
+ }
40
+
41
+ return getStyleMetadata(t, prop.argument)
42
+ })
43
+ .filter(Boolean)
44
+
45
+ if (inlineStyles.length > 0) {
46
+ return partialResult.concat([{
47
+ members: [],
48
+ inlineStyle: t.objectExpression(inlineStyles),
49
+ dynamicFunction: undefined
50
+ }])
51
+ }
52
+
53
+ return partialResult
26
54
  }
27
55
 
28
56
  // {styles.container(arg1, arg2)}
@@ -30,11 +58,10 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
30
58
  return getStyleMetadata(t, node.callee, node)
31
59
  }
32
60
 
33
- // {styles}
34
61
  if (t.isIdentifier(node)) {
35
62
  return [{
36
- styleObj: node.name,
37
- styleProp: undefined,
63
+ members: [node.name],
64
+ inlineStyle: undefined,
38
65
  dynamicFunction: undefined
39
66
  }]
40
67
  }
@@ -8,7 +8,7 @@ interface ShadowRegistry extends UnistylesShadowRegistrySpec {
8
8
  remove(handle?: ViewHandle, style?: Unistyle): void,
9
9
  // JSI
10
10
  link(node: ShadowNode, style?: Unistyle, variants?: Record<string, string | boolean>, args?: Array<any>): void,
11
- unlink(node: ShadowNode, style: Unistyle): void
11
+ unlink(node: ShadowNode): void
12
12
  }
13
13
 
14
14
  const HybridShadowRegistry = NitroModules.createHybridObject<ShadowRegistry>('UnistylesShadowRegistry')
@@ -32,49 +32,15 @@ HybridShadowRegistry.add = (handle, style, variants, args) => {
32
32
  return
33
33
  }
34
34
 
35
- // at this point unistyle can be only object or dynamic function
36
- if (typeof style !== 'object' && typeof style !== 'function') {
37
- return
38
- }
39
-
40
- if (!style.__unid) {
41
- console.warn(`Unistyles: Style is not bound!
42
-
43
- Potential reasons:
44
- a) You created a new Expo or React Native project that references StyleSheet from React Native
45
- b) You used the spread operator on a Unistyle style outside of a JSX component
46
- c) You're mixing StyleSheet styles from React Native with Unistyles
47
-
48
- a) For new projects
49
- If you're using a freshly generated project, replace StyleSheet imports from React Native with Unistyles:
50
-
51
- - import { StyleSheet } from 'react-native'
52
- + import { StyleSheet } from 'react-native-unistyles'
53
-
54
- b) Merging styles
55
- If you need to merge styles, do it within the style prop of your JSX component:
56
-
57
- style={{...styles.container, ...styles.otherProp}}
58
- or
59
- style={[styles.container, styles.otherProp]}
60
-
61
- Copying a Unistyle style outside of a JSX element will remove its internal C++ state, leading to unexpected behavior.
62
-
63
- c) Mixing styles
64
- If you're mixing React Native and Unistyle StyleSheet styles, move your static styles into Unistyles to avoid conflicts.\n`)
65
-
66
- return
67
- }
68
-
69
35
  HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? [])
70
36
  }
71
37
 
72
- HybridShadowRegistry.remove = (handle, style) => {
73
- if (!handle || !style?.__unid) {
38
+ HybridShadowRegistry.remove = handle => {
39
+ if (!handle) {
74
40
  return
75
41
  }
76
42
 
77
- HybridShadowRegistry.unlink(findShadowNodeForHandle(handle), style)
43
+ HybridShadowRegistry.unlink(findShadowNodeForHandle(handle))
78
44
  }
79
45
 
80
46
  type PrivateMethods =
@@ -1,8 +1,8 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { extractHiddenProperties, extractSecrets } from './utils'
3
- import { UnistylesRuntime } from './runtime'
4
3
  import { getVariants } from './variants'
5
4
  import { UnistylesListener } from './listener'
5
+ import { UnistylesRegistry } from './registry'
6
6
 
7
7
  const getStyles = (value: Record<string, any>) => {
8
8
  const secrets = extractSecrets(value)
@@ -12,9 +12,7 @@ const getStyles = (value: Record<string, any>) => {
12
12
  }
13
13
 
14
14
  return secrets.reduce((acc, { __uni__stylesheet, __uni__key, __uni__args = [], __uni__variants }) => {
15
- const newComputedStylesheet = typeof __uni__stylesheet === 'function'
16
- ? __uni__stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime)
17
- : __uni__stylesheet
15
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet)
18
16
  const style = newComputedStylesheet[__uni__key]
19
17
  const resultHidden = typeof style === 'function'
20
18
  ? style(...__uni__args)
@@ -2,7 +2,6 @@ import type { TypeStyle } from 'typestyle'
2
2
  import type { StyleSheet, StyleSheetWithSuperPowers } from '../../types/stylesheet'
3
3
  import type { UnistyleDependency } from '../../specs/NativePlatform'
4
4
  import { UnistylesListener } from './listener'
5
- import { UnistylesRuntime } from '../runtime'
6
5
  import { keyInObject } from '../utils'
7
6
  import { UnistylesRegistry } from '../registry'
8
7
 
@@ -15,9 +14,7 @@ type ListenToDependenciesProps = {
15
14
  }
16
15
 
17
16
  export const listenToDependencies = ({ key, className, unistyles, args = [], stylesheet }: ListenToDependenciesProps) => {
18
- const newComputedStylesheet = typeof stylesheet === 'function'
19
- ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime)
20
- : stylesheet
17
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(stylesheet)
21
18
  const _value = keyInObject(newComputedStylesheet, key) ? newComputedStylesheet[key] : undefined
22
19
 
23
20
  if (!_value) {
@@ -32,9 +29,7 @@ export const listenToDependencies = ({ key, className, unistyles, args = [], sty
32
29
  }
33
30
 
34
31
  return UnistylesListener.addListeners(dependencies, () => {
35
- const newComputedStylesheet = typeof stylesheet === 'function'
36
- ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime)
37
- : stylesheet
32
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(stylesheet)
38
33
 
39
34
  if (!keyInObject(newComputedStylesheet, key)) {
40
35
  return
@@ -1,8 +1,40 @@
1
1
  import { createTypeStyle, TypeStyle } from 'typestyle'
2
2
  import type { UnistylesValues } from '../types'
3
3
  import { convertToTypeStyle } from './convert'
4
+ import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet'
5
+ import { UnistylesRuntime } from './runtime'
6
+ import { keyInObject } from './utils'
7
+ import { UnistylesListener } from './listener'
4
8
 
5
9
  class UnistylesRegistryBuilder {
10
+ private stylesheets = new Map<StyleSheetWithSuperPowers<StyleSheet>, StyleSheet>()
11
+
12
+ getComputedStylesheet = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => {
13
+ if (typeof stylesheet !== 'function') {
14
+ return stylesheet
15
+ }
16
+
17
+ const computedStylesheet = this.stylesheets.get(stylesheet)
18
+
19
+ if (computedStylesheet) {
20
+ return computedStylesheet
21
+ }
22
+
23
+ const createdStylesheet = stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime)
24
+ // @ts-expect-error uni__dependencies is hidden
25
+ const dependencies = Object.values(createdStylesheet).flatMap(value => keyInObject(value, 'uni__dependencies') ? value.uni__dependencies : [])
26
+
27
+ UnistylesListener.addListeners(dependencies, () => {
28
+ const newComputedStylesheet = stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime)
29
+
30
+ this.stylesheets.set(stylesheet, newComputedStylesheet)
31
+ })
32
+
33
+ this.stylesheets.set(stylesheet, createdStylesheet)
34
+
35
+ return createdStylesheet
36
+ }
37
+
6
38
  createStyles = (stylesheet: UnistylesValues, key: string) => {
7
39
  const unistyles = createTypeStyle()
8
40
  const typestyleStylesheet = convertToTypeStyle(stylesheet)
@@ -1,7 +1,6 @@
1
1
  import type { UnistylesValues } from '../types'
2
2
  import { listenToDependencies } from './listener'
3
3
  import { UnistylesRegistry } from './registry'
4
- import { UnistylesRuntime } from './runtime'
5
4
  import { createDoubleMap, extractHiddenProperties, extractSecrets, isInDocument } from './utils'
6
5
  import { getVariants } from './variants'
7
6
 
@@ -64,9 +63,7 @@ class UnistylesShadowRegistryBuilder {
64
63
 
65
64
  extractSecrets(_style).forEach(secret => {
66
65
  const { __uni__key, __uni__stylesheet, __uni__refs, __uni__variants, __uni__args = [] } = secret
67
- const newComputedStylesheet = typeof __uni__stylesheet === 'function'
68
- ? __uni__stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime)
69
- : __uni__stylesheet
66
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet)
70
67
  const style = newComputedStylesheet[__uni__key]
71
68
  const args = _args ?? __uni__args
72
69
  const resultHidden = typeof style === 'function'