rnwind 0.0.3 → 0.0.5

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 (134) hide show
  1. package/lib/cjs/core/normalize-classname.cjs +25 -0
  2. package/lib/cjs/core/normalize-classname.cjs.map +1 -0
  3. package/lib/cjs/core/normalize-classname.d.ts +10 -0
  4. package/lib/cjs/core/style-builder/build-style.cjs +258 -58
  5. package/lib/cjs/core/style-builder/build-style.cjs.map +1 -1
  6. package/lib/cjs/core/style-builder/build-style.d.ts +6 -1
  7. package/lib/cjs/core/style-builder/union-builder.cjs +37 -3
  8. package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -1
  9. package/lib/cjs/core/style-builder/union-builder.d.ts +21 -1
  10. package/lib/cjs/metro/css-imports.cjs +81 -0
  11. package/lib/cjs/metro/css-imports.cjs.map +1 -0
  12. package/lib/cjs/metro/css-imports.d.ts +8 -0
  13. package/lib/cjs/metro/dts.cjs +7 -16
  14. package/lib/cjs/metro/dts.cjs.map +1 -1
  15. package/lib/cjs/metro/dts.d.ts +2 -4
  16. package/lib/cjs/metro/state.cjs +38 -86
  17. package/lib/cjs/metro/state.cjs.map +1 -1
  18. package/lib/cjs/metro/state.d.ts +8 -25
  19. package/lib/cjs/metro/transformer.cjs +193 -34
  20. package/lib/cjs/metro/transformer.cjs.map +1 -1
  21. package/lib/cjs/metro/with-config.cjs +2 -2
  22. package/lib/cjs/metro/with-config.cjs.map +1 -1
  23. package/lib/cjs/metro/with-config.d.ts +11 -26
  24. package/lib/cjs/metro/wrap-imports.cjs +273 -0
  25. package/lib/cjs/metro/wrap-imports.cjs.map +1 -0
  26. package/lib/cjs/metro/wrap-imports.d.ts +26 -0
  27. package/lib/cjs/runtime/components/rnwind-provider.cjs +0 -17
  28. package/lib/cjs/runtime/components/rnwind-provider.cjs.map +1 -1
  29. package/lib/cjs/runtime/components/rnwind-provider.d.ts +0 -14
  30. package/lib/cjs/runtime/hooks/use-css.cjs +16 -10
  31. package/lib/cjs/runtime/hooks/use-css.cjs.map +1 -1
  32. package/lib/cjs/runtime/hooks/use-css.d.ts +15 -9
  33. package/lib/cjs/runtime/index.cjs +11 -13
  34. package/lib/cjs/runtime/index.cjs.map +1 -1
  35. package/lib/cjs/runtime/index.d.ts +4 -9
  36. package/lib/cjs/runtime/lookup-css.cjs +10 -0
  37. package/lib/cjs/runtime/lookup-css.cjs.map +1 -1
  38. package/lib/cjs/runtime/lookup-css.d.ts +7 -0
  39. package/lib/cjs/runtime/resolve.cjs +348 -0
  40. package/lib/cjs/runtime/resolve.cjs.map +1 -0
  41. package/lib/cjs/runtime/resolve.d.ts +61 -0
  42. package/lib/cjs/runtime/wrap.cjs +254 -0
  43. package/lib/cjs/runtime/wrap.cjs.map +1 -0
  44. package/lib/cjs/runtime/wrap.d.ts +37 -0
  45. package/lib/cjs/testing/index.cjs +81 -50
  46. package/lib/cjs/testing/index.cjs.map +1 -1
  47. package/lib/esm/core/normalize-classname.d.ts +10 -0
  48. package/lib/esm/core/normalize-classname.mjs +23 -0
  49. package/lib/esm/core/normalize-classname.mjs.map +1 -0
  50. package/lib/esm/core/style-builder/build-style.d.ts +6 -1
  51. package/lib/esm/core/style-builder/build-style.mjs +258 -58
  52. package/lib/esm/core/style-builder/build-style.mjs.map +1 -1
  53. package/lib/esm/core/style-builder/union-builder.d.ts +21 -1
  54. package/lib/esm/core/style-builder/union-builder.mjs +37 -3
  55. package/lib/esm/core/style-builder/union-builder.mjs.map +1 -1
  56. package/lib/esm/metro/css-imports.d.ts +8 -0
  57. package/lib/esm/metro/css-imports.mjs +79 -0
  58. package/lib/esm/metro/css-imports.mjs.map +1 -0
  59. package/lib/esm/metro/dts.d.ts +2 -4
  60. package/lib/esm/metro/dts.mjs +7 -16
  61. package/lib/esm/metro/dts.mjs.map +1 -1
  62. package/lib/esm/metro/state.d.ts +8 -25
  63. package/lib/esm/metro/state.mjs +39 -85
  64. package/lib/esm/metro/state.mjs.map +1 -1
  65. package/lib/esm/metro/transformer.mjs +194 -35
  66. package/lib/esm/metro/transformer.mjs.map +1 -1
  67. package/lib/esm/metro/with-config.d.ts +11 -26
  68. package/lib/esm/metro/with-config.mjs +2 -2
  69. package/lib/esm/metro/with-config.mjs.map +1 -1
  70. package/lib/esm/metro/wrap-imports.d.ts +26 -0
  71. package/lib/esm/metro/wrap-imports.mjs +250 -0
  72. package/lib/esm/metro/wrap-imports.mjs.map +1 -0
  73. package/lib/esm/runtime/components/rnwind-provider.d.ts +0 -14
  74. package/lib/esm/runtime/components/rnwind-provider.mjs +1 -17
  75. package/lib/esm/runtime/components/rnwind-provider.mjs.map +1 -1
  76. package/lib/esm/runtime/hooks/use-css.d.ts +15 -9
  77. package/lib/esm/runtime/hooks/use-css.mjs +16 -10
  78. package/lib/esm/runtime/hooks/use-css.mjs.map +1 -1
  79. package/lib/esm/runtime/index.d.ts +4 -9
  80. package/lib/esm/runtime/index.mjs +4 -4
  81. package/lib/esm/runtime/index.mjs.map +1 -1
  82. package/lib/esm/runtime/lookup-css.d.ts +7 -0
  83. package/lib/esm/runtime/lookup-css.mjs +10 -1
  84. package/lib/esm/runtime/lookup-css.mjs.map +1 -1
  85. package/lib/esm/runtime/resolve.d.ts +61 -0
  86. package/lib/esm/runtime/resolve.mjs +341 -0
  87. package/lib/esm/runtime/resolve.mjs.map +1 -0
  88. package/lib/esm/runtime/wrap.d.ts +37 -0
  89. package/lib/esm/runtime/wrap.mjs +251 -0
  90. package/lib/esm/runtime/wrap.mjs.map +1 -0
  91. package/lib/esm/testing/index.mjs +84 -53
  92. package/lib/esm/testing/index.mjs.map +1 -1
  93. package/package.json +2 -1
  94. package/src/core/normalize-classname.ts +19 -0
  95. package/src/core/style-builder/build-style.ts +286 -55
  96. package/src/core/style-builder/union-builder.ts +36 -3
  97. package/src/metro/css-imports.ts +75 -0
  98. package/src/metro/dts.ts +7 -19
  99. package/src/metro/state.ts +38 -83
  100. package/src/metro/transformer.ts +190 -34
  101. package/src/metro/with-config.ts +13 -28
  102. package/src/metro/wrap-imports.ts +260 -0
  103. package/src/runtime/components/rnwind-provider.tsx +0 -17
  104. package/src/runtime/hooks/use-css.ts +17 -11
  105. package/src/runtime/index.ts +3 -26
  106. package/src/runtime/lookup-css.ts +10 -0
  107. package/src/runtime/resolve.ts +381 -0
  108. package/src/runtime/wrap.tsx +267 -0
  109. package/src/testing/index.ts +106 -56
  110. package/lib/cjs/core/parser/text-truncate.cjs +0 -78
  111. package/lib/cjs/core/parser/text-truncate.cjs.map +0 -1
  112. package/lib/cjs/metro/transform-ast.cjs +0 -1472
  113. package/lib/cjs/metro/transform-ast.cjs.map +0 -1
  114. package/lib/cjs/metro/transform-ast.d.ts +0 -88
  115. package/lib/cjs/runtime/haptics.cjs +0 -113
  116. package/lib/cjs/runtime/haptics.cjs.map +0 -1
  117. package/lib/cjs/runtime/haptics.d.ts +0 -48
  118. package/lib/cjs/runtime/interactive-box.cjs +0 -35
  119. package/lib/cjs/runtime/interactive-box.cjs.map +0 -1
  120. package/lib/cjs/runtime/interactive-box.d.ts +0 -40
  121. package/lib/esm/core/parser/text-truncate.mjs +0 -75
  122. package/lib/esm/core/parser/text-truncate.mjs.map +0 -1
  123. package/lib/esm/metro/transform-ast.d.ts +0 -88
  124. package/lib/esm/metro/transform-ast.mjs +0 -1451
  125. package/lib/esm/metro/transform-ast.mjs.map +0 -1
  126. package/lib/esm/runtime/haptics.d.ts +0 -48
  127. package/lib/esm/runtime/haptics.mjs +0 -110
  128. package/lib/esm/runtime/haptics.mjs.map +0 -1
  129. package/lib/esm/runtime/interactive-box.d.ts +0 -40
  130. package/lib/esm/runtime/interactive-box.mjs +0 -33
  131. package/lib/esm/runtime/interactive-box.mjs.map +0 -1
  132. package/src/metro/transform-ast.ts +0 -1729
  133. package/src/runtime/haptics.ts +0 -120
  134. package/src/runtime/interactive-box.tsx +0 -57
@@ -0,0 +1,250 @@
1
+ import * as t from '@babel/types';
2
+
3
+ /**
4
+ * Build-time import rewrite. For every `import { View } from
5
+ * 'react-native'` (and the other configured modules) it aliases the
6
+ * original export and binds a `wrap()`-ed component in its place:
7
+ *
8
+ * ```
9
+ * import { View, StyleSheet } from 'react-native'
10
+ * ⇩
11
+ * import { View as _rnw0, StyleSheet } from 'react-native'
12
+ * import { wrap as _rnwWrap } from 'rnwind'
13
+ * const View = _rnwWrap(_rnw0)
14
+ * ```
15
+ *
16
+ * Now `<View className="…">` resolves className → style at render via the
17
+ * wrapper — no matter how className arrived (literal, `{...rest}` spread,
18
+ * forwarded through custom layers). Non-component exports (`StyleSheet`)
19
+ * are left untouched.
20
+ */
21
+ /** Local binding the injected `wrap` import is aliased to. */
22
+ const WRAP_LOCAL = '_rnwWrap';
23
+ /** Local binding the injected `wrapNamespace` import is aliased to. */
24
+ const WRAP_NS_LOCAL = '_rnwWrapNs';
25
+ /** Module the wrapper is imported from. */
26
+ const RUNTIME_MODULE = 'rnwind';
27
+ /**
28
+ * Wrap-modules whose DEFAULT export is a component NAMESPACE accessed via
29
+ * member expressions (`Animated.View`), not a single component. Their
30
+ * default import is bound through `wrapNamespace` (a Proxy that wraps each
31
+ * accessed component member) instead of `wrap`. Every other default import
32
+ * is treated as a plain component.
33
+ */
34
+ const NAMESPACE_DEFAULT_MODULES = new Set(['react-native-reanimated']);
35
+ /**
36
+ * react-native mixes styleable components with utilities (`StyleSheet`,
37
+ * `Platform`, …). Only these named exports are wrapped; everything else
38
+ * passes through. Other ecosystem modules export components only and use
39
+ * the `'all'` policy instead.
40
+ */
41
+ const REACT_NATIVE_COMPONENTS = new Set([
42
+ 'View',
43
+ 'Text',
44
+ 'TextInput',
45
+ 'Pressable',
46
+ 'ScrollView',
47
+ 'Image',
48
+ 'ImageBackground',
49
+ 'FlatList',
50
+ 'SectionList',
51
+ 'VirtualizedList',
52
+ 'KeyboardAvoidingView',
53
+ 'SafeAreaView',
54
+ 'Modal',
55
+ 'Switch',
56
+ 'RefreshControl',
57
+ 'ActivityIndicator',
58
+ 'TouchableOpacity',
59
+ 'TouchableHighlight',
60
+ 'TouchableWithoutFeedback',
61
+ 'TouchableNativeFeedback',
62
+ 'Button',
63
+ 'StatusBar',
64
+ ]);
65
+ /**
66
+ * Named exports that LOOK like components (PascalCase) under an `'all'`
67
+ * policy but aren't — React contexts, gesture-handler enums/namespaces,
68
+ * etc. Wrapping these would turn `Gesture.Pan()` / `State.ACTIVE` /
69
+ * `<XContext.Provider>` into a `wrap()`-ed component and break them.
70
+ * Names ending in `Context` are excluded separately.
71
+ */
72
+ const NON_COMPONENT_EXPORTS = new Set([
73
+ 'Gesture',
74
+ 'GestureObjects',
75
+ 'State',
76
+ 'Directions',
77
+ 'Extrapolation',
78
+ 'Extrapolate',
79
+ 'Easing',
80
+ 'ReduceMotion',
81
+ 'KeyframeRegistry',
82
+ ]);
83
+ /**
84
+ * Default module → wrap policy. react-native is allow-listed (mixed
85
+ * exports); the rest are component-only packages → `'all'`. Only modules
86
+ * the project has installed are ever hit (you can't import from a missing
87
+ * package), so listing optional peers is free.
88
+ */
89
+ const DEFAULT_WRAP_MODULES = new Map([
90
+ ['react-native', REACT_NATIVE_COMPONENTS],
91
+ ['react-native-reanimated', 'all'],
92
+ ['react-native-svg', 'all'],
93
+ ['react-native-gesture-handler', 'all'],
94
+ ['react-native-safe-area-context', 'all'],
95
+ ['expo-linear-gradient', 'all'],
96
+ ['expo-image', 'all'],
97
+ ['expo-blur', 'all'],
98
+ ['expo-symbols', 'all'],
99
+ ['@shopify/flash-list', 'all'],
100
+ ['@shopify/react-native-skia', 'all'],
101
+ ['lottie-react-native', 'all'],
102
+ ]);
103
+ /**
104
+ * Whether a named import from a wrap-module should be wrapped.
105
+ *
106
+ * Explicit allow-lists (react-native) match by exact name. The `'all'`
107
+ * policy wraps only component-style names — PascalCase, not a React
108
+ * context (`*Context`), and not a known non-component export. This is
109
+ * what stops `useSafeAreaInsets` (a hook) from being wrapped into a
110
+ * component and crashing when called.
111
+ * @param policy The module's wrap policy.
112
+ * @param importedName The exported name being imported.
113
+ * @returns True when the name is a component to wrap.
114
+ */
115
+ function shouldWrap(policy, importedName) {
116
+ if (policy !== 'all')
117
+ return policy.has(importedName);
118
+ if (!/^[A-Z]/.test(importedName))
119
+ return false;
120
+ if (importedName.endsWith('Context'))
121
+ return false;
122
+ return !NON_COMPONENT_EXPORTS.has(importedName);
123
+ }
124
+ /**
125
+ * Merge user-supplied wrap modules onto the defaults — a bare module name
126
+ * adopts the `'all'` policy.
127
+ * @param extra User module specifiers (or undefined).
128
+ * @returns Effective module → policy map.
129
+ */
130
+ function buildWrapModules(extra) {
131
+ if (!extra || extra.length === 0)
132
+ return DEFAULT_WRAP_MODULES;
133
+ const merged = new Map(DEFAULT_WRAP_MODULES);
134
+ for (const moduleName of extra)
135
+ if (!merged.has(moduleName))
136
+ merged.set(moduleName, 'all');
137
+ return merged;
138
+ }
139
+ /**
140
+ * The `imported` name of an import specifier (`import { a as b }` → `'a'`).
141
+ * @param specifier Named import specifier.
142
+ * @returns The exported name.
143
+ */
144
+ function importedNameOf(specifier) {
145
+ return t.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value;
146
+ }
147
+ /**
148
+ * Build `const Local = <wrapper>(alias)` and rebind the specifier's local
149
+ * to `alias` in place.
150
+ * @param specifier The import specifier to rebind.
151
+ * @param alias The `_rnwN` alias to bind the original import to.
152
+ * @param wrapper The runtime helper local (`_rnwWrap` / `_rnwWrapNs`).
153
+ * @returns The wrap declaration.
154
+ */
155
+ function makeWrapDecl(specifier, alias, wrapper) {
156
+ const { name: localName } = specifier.local;
157
+ specifier.local = t.identifier(alias);
158
+ return t.variableDeclaration('const', [
159
+ t.variableDeclarator(t.identifier(localName), t.callExpression(t.identifier(wrapper), [t.identifier(alias)])),
160
+ ]);
161
+ }
162
+ /**
163
+ * Rewrite one import declaration's wrappable specifiers, aliasing each to
164
+ * `_rnw<N>` in place:
165
+ * - named (`{ View }`) → `const View = wrap(_rnwN)` (per policy),
166
+ * - namespace (`* as Animated`) → `const Animated = wrapNamespace(_rnwN)`,
167
+ * - default → `wrapNamespace` for {@link NAMESPACE_DEFAULT_MODULES}
168
+ * (reanimated's `Animated`), else `wrap` (a plain default component).
169
+ * @param node Import declaration to inspect.
170
+ * @param policy The module's wrap policy.
171
+ * @param counter Next alias index (caller-threaded for uniqueness).
172
+ * @returns New wrap declarations, advanced counter, and whether any
173
+ * binding used `wrapNamespace`.
174
+ */
175
+ function wrapSpecifiers(node, policy, counter) {
176
+ const decls = [];
177
+ const moduleName = node.source.value;
178
+ let next = counter;
179
+ let usesNamespace = false;
180
+ for (const specifier of node.specifiers) {
181
+ if (t.isImportSpecifier(specifier)) {
182
+ if (!shouldWrap(policy, importedNameOf(specifier)))
183
+ continue;
184
+ decls.push(makeWrapDecl(specifier, `_rnw${next}`, WRAP_LOCAL));
185
+ next += 1;
186
+ continue;
187
+ }
188
+ const isNamespace = t.isImportNamespaceSpecifier(specifier) || NAMESPACE_DEFAULT_MODULES.has(moduleName);
189
+ const wrapper = isNamespace ? WRAP_NS_LOCAL : WRAP_LOCAL;
190
+ decls.push(makeWrapDecl(specifier, `_rnw${next}`, wrapper));
191
+ next += 1;
192
+ if (isNamespace)
193
+ usesNamespace = true;
194
+ }
195
+ return { decls, counter: next, usesNamespace };
196
+ }
197
+ /**
198
+ * Insert the `wrap` import at the top and the `const X = wrap(_rnwN)`
199
+ * declarations AFTER every import. The consts reference the aliased
200
+ * binding `_rnwN`, and in Metro's real transform (CommonJS interop + the
201
+ * reanimated worklets plugin) a const placed above its source import
202
+ * evaluates before the binding initialises → `ReferenceError: _rnw0
203
+ * doesn't exist`. ESM-only hoisting would mask this; the bundle does not.
204
+ * @param ast Parsed Babel file (mutated).
205
+ * @param wrapDecls The wrap declarations to place.
206
+ * @param usesNamespace Whether any binding used `wrapNamespace`.
207
+ */
208
+ function placeWrapDecls(ast, wrapDecls, usesNamespace) {
209
+ const specifiers = [t.importSpecifier(t.identifier(WRAP_LOCAL), t.identifier('wrap'))];
210
+ if (usesNamespace)
211
+ specifiers.push(t.importSpecifier(t.identifier(WRAP_NS_LOCAL), t.identifier('wrapNamespace')));
212
+ ast.program.body.unshift(t.importDeclaration(specifiers, t.stringLiteral(RUNTIME_MODULE)));
213
+ let afterImports = 0;
214
+ for (let index = 0; index < ast.program.body.length; index += 1) {
215
+ if (t.isImportDeclaration(ast.program.body[index]))
216
+ afterImports = index + 1;
217
+ }
218
+ ast.program.body.splice(afterImports, 0, ...wrapDecls);
219
+ }
220
+ /**
221
+ * Rewrite component imports from the configured wrap-modules into
222
+ * `wrap()`-ed bindings, in place. Injects the `wrap` import once when any
223
+ * binding was rewritten.
224
+ * @param ast Parsed Babel file (mutated).
225
+ * @param modules Effective module → policy map.
226
+ * @returns True when at least one import was wrapped.
227
+ */
228
+ function rewriteWrapImports(ast, modules) {
229
+ const wrapDecls = [];
230
+ let counter = 0;
231
+ let usesNamespace = false;
232
+ for (const node of ast.program.body) {
233
+ if (!t.isImportDeclaration(node))
234
+ continue;
235
+ const policy = modules.get(node.source.value);
236
+ if (!policy)
237
+ continue;
238
+ const { decls, counter: nextCounter, usesNamespace: ns } = wrapSpecifiers(node, policy, counter);
239
+ counter = nextCounter;
240
+ usesNamespace = usesNamespace || ns;
241
+ wrapDecls.push(...decls);
242
+ }
243
+ if (wrapDecls.length === 0)
244
+ return false;
245
+ placeWrapDecls(ast, wrapDecls, usesNamespace);
246
+ return true;
247
+ }
248
+
249
+ export { DEFAULT_WRAP_MODULES, buildWrapModules, rewriteWrapImports };
250
+ //# sourceMappingURL=wrap-imports.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-imports.mjs","sources":["../../../../src/metro/wrap-imports.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport type { File } from '@babel/types'\n\n/**\n * Build-time import rewrite. For every `import { View } from\n * 'react-native'` (and the other configured modules) it aliases the\n * original export and binds a `wrap()`-ed component in its place:\n *\n * ```\n * import { View, StyleSheet } from 'react-native'\n * ⇩\n * import { View as _rnw0, StyleSheet } from 'react-native'\n * import { wrap as _rnwWrap } from 'rnwind'\n * const View = _rnwWrap(_rnw0)\n * ```\n *\n * Now `<View className=\"…\">` resolves className → style at render via the\n * wrapper — no matter how className arrived (literal, `{...rest}` spread,\n * forwarded through custom layers). Non-component exports (`StyleSheet`)\n * are left untouched.\n */\n\n/** Local binding the injected `wrap` import is aliased to. */\nconst WRAP_LOCAL = '_rnwWrap'\n/** Local binding the injected `wrapNamespace` import is aliased to. */\nconst WRAP_NS_LOCAL = '_rnwWrapNs'\n/** Module the wrapper is imported from. */\nconst RUNTIME_MODULE = 'rnwind'\n\n/**\n * Wrap-modules whose DEFAULT export is a component NAMESPACE accessed via\n * member expressions (`Animated.View`), not a single component. Their\n * default import is bound through `wrapNamespace` (a Proxy that wraps each\n * accessed component member) instead of `wrap`. Every other default import\n * is treated as a plain component.\n */\nconst NAMESPACE_DEFAULT_MODULES: ReadonlySet<string> = new Set(['react-native-reanimated'])\n\n/**\n * react-native mixes styleable components with utilities (`StyleSheet`,\n * `Platform`, …). Only these named exports are wrapped; everything else\n * passes through. Other ecosystem modules export components only and use\n * the `'all'` policy instead.\n */\nconst REACT_NATIVE_COMPONENTS: ReadonlySet<string> = new Set([\n 'View',\n 'Text',\n 'TextInput',\n 'Pressable',\n 'ScrollView',\n 'Image',\n 'ImageBackground',\n 'FlatList',\n 'SectionList',\n 'VirtualizedList',\n 'KeyboardAvoidingView',\n 'SafeAreaView',\n 'Modal',\n 'Switch',\n 'RefreshControl',\n 'ActivityIndicator',\n 'TouchableOpacity',\n 'TouchableHighlight',\n 'TouchableWithoutFeedback',\n 'TouchableNativeFeedback',\n 'Button',\n 'StatusBar',\n])\n\n/**\n * Named exports that LOOK like components (PascalCase) under an `'all'`\n * policy but aren't — React contexts, gesture-handler enums/namespaces,\n * etc. Wrapping these would turn `Gesture.Pan()` / `State.ACTIVE` /\n * `<XContext.Provider>` into a `wrap()`-ed component and break them.\n * Names ending in `Context` are excluded separately.\n */\nconst NON_COMPONENT_EXPORTS: ReadonlySet<string> = new Set([\n 'Gesture',\n 'GestureObjects',\n 'State',\n 'Directions',\n 'Extrapolation',\n 'Extrapolate',\n 'Easing',\n 'ReduceMotion',\n 'KeyframeRegistry',\n])\n\n/** Per-module policy: an explicit allow-list, or `'all'` named exports. */\nexport type WrapPolicy = 'all' | ReadonlySet<string>\n\n/**\n * Default module → wrap policy. react-native is allow-listed (mixed\n * exports); the rest are component-only packages → `'all'`. Only modules\n * the project has installed are ever hit (you can't import from a missing\n * package), so listing optional peers is free.\n */\nexport const DEFAULT_WRAP_MODULES: ReadonlyMap<string, WrapPolicy> = new Map<string, WrapPolicy>([\n ['react-native', REACT_NATIVE_COMPONENTS],\n ['react-native-reanimated', 'all'],\n ['react-native-svg', 'all'],\n ['react-native-gesture-handler', 'all'],\n ['react-native-safe-area-context', 'all'],\n ['expo-linear-gradient', 'all'],\n ['expo-image', 'all'],\n ['expo-blur', 'all'],\n ['expo-symbols', 'all'],\n ['@shopify/flash-list', 'all'],\n ['@shopify/react-native-skia', 'all'],\n ['lottie-react-native', 'all'],\n])\n\n/**\n * Whether a named import from a wrap-module should be wrapped.\n *\n * Explicit allow-lists (react-native) match by exact name. The `'all'`\n * policy wraps only component-style names — PascalCase, not a React\n * context (`*Context`), and not a known non-component export. This is\n * what stops `useSafeAreaInsets` (a hook) from being wrapped into a\n * component and crashing when called.\n * @param policy The module's wrap policy.\n * @param importedName The exported name being imported.\n * @returns True when the name is a component to wrap.\n */\nfunction shouldWrap(policy: WrapPolicy, importedName: string): boolean {\n if (policy !== 'all') return policy.has(importedName)\n if (!/^[A-Z]/.test(importedName)) return false\n if (importedName.endsWith('Context')) return false\n return !NON_COMPONENT_EXPORTS.has(importedName)\n}\n\n/**\n * Merge user-supplied wrap modules onto the defaults — a bare module name\n * adopts the `'all'` policy.\n * @param extra User module specifiers (or undefined).\n * @returns Effective module → policy map.\n */\nexport function buildWrapModules(extra?: readonly string[]): ReadonlyMap<string, WrapPolicy> {\n if (!extra || extra.length === 0) return DEFAULT_WRAP_MODULES\n const merged = new Map<string, WrapPolicy>(DEFAULT_WRAP_MODULES)\n for (const moduleName of extra) if (!merged.has(moduleName)) merged.set(moduleName, 'all')\n return merged\n}\n\n/**\n * The `imported` name of an import specifier (`import { a as b }` → `'a'`).\n * @param specifier Named import specifier.\n * @returns The exported name.\n */\nfunction importedNameOf(specifier: t.ImportSpecifier): string {\n return t.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value\n}\n\n/**\n * Build `const Local = <wrapper>(alias)` and rebind the specifier's local\n * to `alias` in place.\n * @param specifier The import specifier to rebind.\n * @param alias The `_rnwN` alias to bind the original import to.\n * @param wrapper The runtime helper local (`_rnwWrap` / `_rnwWrapNs`).\n * @returns The wrap declaration.\n */\nfunction makeWrapDecl(\n specifier: t.ImportSpecifier | t.ImportDefaultSpecifier | t.ImportNamespaceSpecifier,\n alias: string,\n wrapper: string,\n): t.VariableDeclaration {\n const { name: localName } = specifier.local\n specifier.local = t.identifier(alias)\n return t.variableDeclaration('const', [\n t.variableDeclarator(t.identifier(localName), t.callExpression(t.identifier(wrapper), [t.identifier(alias)])),\n ])\n}\n\n/**\n * Rewrite one import declaration's wrappable specifiers, aliasing each to\n * `_rnw<N>` in place:\n * - named (`{ View }`) → `const View = wrap(_rnwN)` (per policy),\n * - namespace (`* as Animated`) → `const Animated = wrapNamespace(_rnwN)`,\n * - default → `wrapNamespace` for {@link NAMESPACE_DEFAULT_MODULES}\n * (reanimated's `Animated`), else `wrap` (a plain default component).\n * @param node Import declaration to inspect.\n * @param policy The module's wrap policy.\n * @param counter Next alias index (caller-threaded for uniqueness).\n * @returns New wrap declarations, advanced counter, and whether any\n * binding used `wrapNamespace`.\n */\nfunction wrapSpecifiers(\n node: t.ImportDeclaration,\n policy: WrapPolicy,\n counter: number,\n): { decls: t.VariableDeclaration[]; counter: number; usesNamespace: boolean } {\n const decls: t.VariableDeclaration[] = []\n const moduleName = node.source.value\n let next = counter\n let usesNamespace = false\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier)) {\n if (!shouldWrap(policy, importedNameOf(specifier))) continue\n decls.push(makeWrapDecl(specifier, `_rnw${next}`, WRAP_LOCAL))\n next += 1\n continue\n }\n const isNamespace = t.isImportNamespaceSpecifier(specifier) || NAMESPACE_DEFAULT_MODULES.has(moduleName)\n const wrapper = isNamespace ? WRAP_NS_LOCAL : WRAP_LOCAL\n decls.push(makeWrapDecl(specifier, `_rnw${next}`, wrapper))\n next += 1\n if (isNamespace) usesNamespace = true\n }\n return { decls, counter: next, usesNamespace }\n}\n\n/**\n * Insert the `wrap` import at the top and the `const X = wrap(_rnwN)`\n * declarations AFTER every import. The consts reference the aliased\n * binding `_rnwN`, and in Metro's real transform (CommonJS interop + the\n * reanimated worklets plugin) a const placed above its source import\n * evaluates before the binding initialises → `ReferenceError: _rnw0\n * doesn't exist`. ESM-only hoisting would mask this; the bundle does not.\n * @param ast Parsed Babel file (mutated).\n * @param wrapDecls The wrap declarations to place.\n * @param usesNamespace Whether any binding used `wrapNamespace`.\n */\nfunction placeWrapDecls(ast: File, wrapDecls: readonly t.VariableDeclaration[], usesNamespace: boolean): void {\n const specifiers = [t.importSpecifier(t.identifier(WRAP_LOCAL), t.identifier('wrap'))]\n if (usesNamespace) specifiers.push(t.importSpecifier(t.identifier(WRAP_NS_LOCAL), t.identifier('wrapNamespace')))\n ast.program.body.unshift(t.importDeclaration(specifiers, t.stringLiteral(RUNTIME_MODULE)))\n let afterImports = 0\n for (let index = 0; index < ast.program.body.length; index += 1) {\n if (t.isImportDeclaration(ast.program.body[index])) afterImports = index + 1\n }\n ast.program.body.splice(afterImports, 0, ...wrapDecls)\n}\n\n/**\n * Rewrite component imports from the configured wrap-modules into\n * `wrap()`-ed bindings, in place. Injects the `wrap` import once when any\n * binding was rewritten.\n * @param ast Parsed Babel file (mutated).\n * @param modules Effective module → policy map.\n * @returns True when at least one import was wrapped.\n */\nexport function rewriteWrapImports(ast: File, modules: ReadonlyMap<string, WrapPolicy>): boolean {\n const wrapDecls: t.VariableDeclaration[] = []\n let counter = 0\n let usesNamespace = false\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue\n const policy = modules.get(node.source.value)\n if (!policy) continue\n const { decls, counter: nextCounter, usesNamespace: ns } = wrapSpecifiers(node, policy, counter)\n counter = nextCounter\n usesNamespace = usesNamespace || ns\n wrapDecls.push(...decls)\n }\n\n if (wrapDecls.length === 0) return false\n placeWrapDecls(ast, wrapDecls, usesNamespace)\n return true\n}\n"],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;;;;;AAiBG;AAEH;AACA,MAAM,UAAU,GAAG,UAAU;AAC7B;AACA,MAAM,aAAa,GAAG,YAAY;AAClC;AACA,MAAM,cAAc,GAAG,QAAQ;AAE/B;;;;;;AAMG;AACH,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC,CAAC,yBAAyB,CAAC,CAAC;AAE3F;;;;;AAKG;AACH,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAC3D,MAAM;IACN,MAAM;IACN,WAAW;IACX,WAAW;IACX,YAAY;IACZ,OAAO;IACP,iBAAiB;IACjB,UAAU;IACV,aAAa;IACb,iBAAiB;IACjB,sBAAsB;IACtB,cAAc;IACd,OAAO;IACP,QAAQ;IACR,gBAAgB;IAChB,mBAAmB;IACnB,kBAAkB;IAClB,oBAAoB;IACpB,0BAA0B;IAC1B,yBAAyB;IACzB,QAAQ;IACR,WAAW;AACZ,CAAA,CAAC;AAEF;;;;;;AAMG;AACH,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,SAAS;IACT,gBAAgB;IAChB,OAAO;IACP,YAAY;IACZ,eAAe;IACf,aAAa;IACb,QAAQ;IACR,cAAc;IACd,kBAAkB;AACnB,CAAA,CAAC;AAKF;;;;;AAKG;AACI,MAAM,oBAAoB,GAAoC,IAAI,GAAG,CAAqB;IAC/F,CAAC,cAAc,EAAE,uBAAuB,CAAC;IACzC,CAAC,yBAAyB,EAAE,K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AI,CAAC,KAAK,CAAC,CAAC;AAAE,YAAA,YAAY,GAAG,KAAK,GAAG,CAAC;IAC9E;AACA,IAAA,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC;AACxD;AAEA;;;;;;;AAOG;AACG,SAAU,kBAAkB,CAAC,GAAS,EAAE,OAAwC,EAAA;IACpF,MAAM,SAAS,GAA4B,EAAE;IAC7C,IAAI,OAAO,GAAG,CAAC;IACf,IAAI,aAAa,GAAG,KAAK;IAEzB,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;AACnC,QAAA,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAAE;AAClC,QAAA,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;AAC7C,QAAA,IAAI,CAAC,MAAM;YAAE;QACb,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,EAAE,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;QAChG,OAAO,GAAG,WAAW;AACrB,QAAA,aAAa,GAAG,aAAa,IAAI,EAAE;AACnC,QAAA,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC1B;AAEA,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;AACxC,IAAA,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC;AAC7C,IAAA,OAAO,IAAI;AACb;;;;"}
@@ -55,20 +55,6 @@ export type RnwindProviderProps = Readonly<{
55
55
  * @returns Active rnwind state under the nearest {@link RnwindProvider}.
56
56
  */
57
57
  export declare function useRnwind(): RnwindState;
58
- /**
59
- * Internal context hook the babel transformer injects at the top of
60
- * every rewritten component as `const _t = useR_()`. Same body as the
61
- * public {@link useRnwind} — exposed under a `use*`-prefixed name so
62
- * react-refresh's babel plugin (which only tracks call-sites whose
63
- * identifier matches `^use[A-Z]`) folds it into each component's
64
- * fast-refresh signature. Without that prefix the signature stayed
65
- * stable across transformer changes; HMR then preserved fiber state
66
- * while the rendered hook list shifted, surfacing as "change in the
67
- * order of Hooks" runtime errors. Trailing underscore keeps it
68
- * visually distinct from the user-facing `useRnwind`.
69
- * @returns Active rnwind state.
70
- */
71
- export declare function useR_(): RnwindState;
72
58
  /**
73
59
  * Provider for rnwind's full runtime state. fontScale + windowWidth
74
60
  * come from `useWindowDimensions()` so they react to OS-level
@@ -44,22 +44,6 @@ const RnwindContext = createContext(DEFAULT_STATE);
44
44
  function useRnwind() {
45
45
  return useContext(RnwindContext);
46
46
  }
47
- /**
48
- * Internal context hook the babel transformer injects at the top of
49
- * every rewritten component as `const _t = useR_()`. Same body as the
50
- * public {@link useRnwind} — exposed under a `use*`-prefixed name so
51
- * react-refresh's babel plugin (which only tracks call-sites whose
52
- * identifier matches `^use[A-Z]`) folds it into each component's
53
- * fast-refresh signature. Without that prefix the signature stayed
54
- * stable across transformer changes; HMR then preserved fiber state
55
- * while the rendered hook list shifted, surfacing as "change in the
56
- * order of Hooks" runtime errors. Trailing underscore keeps it
57
- * visually distinct from the user-facing `useRnwind`.
58
- * @returns Active rnwind state.
59
- */
60
- function useR_() {
61
- return useContext(RnwindContext);
62
- }
63
47
  /**
64
48
  * Provider for rnwind's full runtime state. fontScale + windowWidth
65
49
  * come from `useWindowDimensions()` so they react to OS-level
@@ -90,5 +74,5 @@ function RnwindProvider({ scheme, tables, insets, onHaptics, children }) {
90
74
  return jsx(RnwindContext.Provider, { value: value, children: children });
91
75
  }
92
76
 
93
- export { RnwindProvider, useR_, useRnwind };
77
+ export { RnwindProvider, useRnwind };
94
78
  //# sourceMappingURL=rnwind-provider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rnwind-provider.mjs","sources":["../../../../../src/runtime/components/rnwind-provider.tsx"],"sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { useWindowDimensions } from 'react-native'\nimport type { ThemeTables } from '../../core/types'\nimport type { Scheme } from '../types'\nimport type { OnHaptics } from '../../core/parser/haptics'\nimport { activeBreakpointFor, BASE_BREAKPOINT, loadScheme } from '../lookup-css'\n\n/**\n * Per-render safe-area insets snapshot. Bridge from any source\n * (`useSafeAreaInsets()`, expo-router insets, a manually computed\n * value) into the {@link RnwindProvider} — rnwind stays\n * library-agnostic.\n */\nexport type Insets = Readonly<{\n top: number\n right: number\n bottom: number\n left: number\n}>\n\n/**\n * Single value carried by the rnwind context. Every piece of runtime\n * state rnwind needs — scheme, theme tables, insets, font scale,\n * window width, active responsive breakpoint, optional haptic\n * dispatcher — lives on this one bag. Consumers read it via\n * {@link useRnwind} and either destructure or forward straight to\n * `lookupCss` / `useCss`.\n *\n * `activeBreakpoint` is the highest-threshold registered breakpoint\n * whose min-width is `<= windowWidth`, or `'base'` when below the\n * smallest one (mobile-first tier) or when no breakpoints are\n * registered yet (tests, bundles without rnwind-transformed sources).\n * Always a string — never null. Reactive: it updates with\n * `useWindowDimensions().width`, so consumers can branch on it\n * without a separate hook.\n */\nexport type RnwindState = Readonly<{\n scheme: Scheme\n tables: ThemeTables\n insets: Insets\n onHaptics: OnHaptics | undefined\n fontScale: number\n windowWidth: number\n activeBreakpoint: string\n}>\n\n/** Props accepted by {@link RnwindProvider}. */\nexport type RnwindProviderProps = Readonly<{\n scheme: Scheme\n tables?: ThemeTables\n insets?: Partial<Insets>\n onHaptics?: OnHaptics\n children?: ReactNode\n}>\n\nconst EMPTY_TABLES: ThemeTables = {}\nconst ZERO_INSETS: Insets = { top: 0, right: 0, bottom: 0, left: 0 }\nconst DEFAULT_STATE: RnwindState = {\n scheme: 'light' as Scheme,\n tables: EMPTY_TABLES,\n insets: ZERO_INSETS,\n onHaptics: undefined,\n fontScale: 1,\n windowWidth: 0,\n activeBreakpoint: BASE_BREAKPOINT,\n}\n\n/**\n * Normalise a `Partial<Insets>` into a complete {@link Insets}, returning\n * the shared {@link ZERO_INSETS} reference when nothing is supplied so\n * downstream memoisation stays stable.\n * @param partial Caller-supplied insets (or undefined).\n * @returns Complete insets record.\n */\nfunction normaliseInsets(partial: Partial<Insets> | undefined): Insets {\n if (!partial) return ZERO_INSETS\n const top = partial.top ?? 0\n const right = partial.right ?? 0\n const bottom = partial.bottom ?? 0\n const left = partial.left ?? 0\n if (top === 0 && right === 0 && bottom === 0 && left === 0) return ZERO_INSETS\n return { top, right, bottom, left }\n}\n\n/** Single internal context the runtime reads from. */\nconst RnwindContext = createContext<RnwindState>(DEFAULT_STATE)\n\n/**\n * Read rnwind's full runtime state — scheme, theme tables, insets,\n * fontScale, windowWidth, onHaptics — in one go. Pass the returned\n * value straight to `lookupCss` / `useCss`, or destructure what you\n * need.\n * @returns Active rnwind state under the nearest {@link RnwindProvider}.\n */\nexport function useRnwind(): RnwindState {\n return useContext(RnwindContext)\n}\n\n/**\n * Internal context hook the babel transformer injects at the top of\n * every rewritten component as `const _t = useR_()`. Same body as the\n * public {@link useRnwind} — exposed under a `use*`-prefixed name so\n * react-refresh's babel plugin (which only tracks call-sites whose\n * identifier matches `^use[A-Z]`) folds it into each component's\n * fast-refresh signature. Without that prefix the signature stayed\n * stable across transformer changes; HMR then preserved fiber state\n * while the rendered hook list shifted, surfacing as \"change in the\n * order of Hooks\" runtime errors. Trailing underscore keeps it\n * visually distinct from the user-facing `useRnwind`.\n * @returns Active rnwind state.\n */\nexport function useR_(): RnwindState {\n return useContext(RnwindContext)\n}\n\n/**\n * Provider for rnwind's full runtime state. fontScale + windowWidth\n * come from `useWindowDimensions()` so they react to OS-level\n * orientation / accessibility-text-size changes automatically.\n * @param props Provider props.\n * @param props.scheme Active scheme name.\n * @param props.tables Optional pre-resolved token tables.\n * @param props.insets Optional safe-area insets.\n * @param props.onHaptics Optional haptic dispatcher.\n * @param props.children React subtree.\n * @returns Provider element.\n */\nexport function RnwindProvider({ scheme, tables, insets, onHaptics, children }: RnwindProviderProps): ReactNode {\n const normalized = normaliseInsets(insets)\n const { fontScale, width } = useWindowDimensions()\n const value = useMemo<RnwindState>(() => {\n loadScheme(scheme)\n return {\n scheme,\n tables: tables ?? EMPTY_TABLES,\n insets: normalized,\n onHaptics,\n fontScale,\n windowWidth: width,\n activeBreakpoint: activeBreakpointFor(width),\n }\n }, [scheme, tables, normalized, onHaptics, fontScale, width])\n return <RnwindContext.Provider value={value}>{children}</RnwindContext.Provider>\n}\n"],"names":["_jsx"],"mappings":";;;;;AAuDA,MAAM,YAAY,GAAgB,EAAE;AACpC,MAAM,WAAW,GAAW,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;AACpE,MAAM,aAAa,GAAgB;AACjC,IAAA,MAAM,EAAE,OAAiB;AACzB,IAAA,MAAM,EAAE,YAAY;AACpB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,gBAAgB,EAAE,eAAe;CAClC;AAED;;;;;;AAMG;AACH,SAAS,eAAe,CAAC,OAAoC,EAAA;AAC3D,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,WAAW;AAChC,IAAA,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;AAC5B,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC;AAChC,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;AAClC,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC;AAC9B,IAAA,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,WAAW;IAC9E,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;AACrC;AAEA;AACA,MAAM,aAAa,GAAG,aAAa,CAAc,aAAa,CAAC;AAE/D;;;;;;AAMG;SACa,SAAS,GAAA;AACvB,IAAA,OAAO,UAAU,CAAC,aAAa,CAAC;AAClC;AAEA;;;;;;;;;;;;AAYG;SACa,KAAK,GAAA;AACnB,IAAA,OAAO,UAAU,CAAC,aAAa,CAAC;AAClC;AAEA;;;;;;;;;;;AAWG;AACG,SAAU,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAuB,EAAA;AACjG,IAAA,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,mBAAmB,EAAE;AAClD,IAAA,MAAM,KAAK,GAAG,OAAO,CAAc,MAAK;QACtC,UAAU,CAAC,MAAM,CAAC;QAClB,OAAO;YACL,MAAM;YACN,MAAM,EAAE,MAAM,IAAI,YAAY;AAC9B,YAAA,MAAM,EAAE,UAAU;YAClB,SAAS;YACT,SAAS;AACT,YAAA,WAAW,EAAE,KAAK;AAClB,YAAA,gBAAgB,EAAE,mBAAmB,CAAC,KAAK,CAAC;SAC7C;AACH,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAOA,GAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAA0B;AAClF;;;;"}
1
+ {"version":3,"file":"rnwind-provider.mjs","sources":["../../../../../src/runtime/components/rnwind-provider.tsx"],"sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { useWindowDimensions } from 'react-native'\nimport type { ThemeTables } from '../../core/types'\nimport type { Scheme } from '../types'\nimport type { OnHaptics } from '../../core/parser/haptics'\nimport { activeBreakpointFor, BASE_BREAKPOINT, loadScheme } from '../lookup-css'\n\n/**\n * Per-render safe-area insets snapshot. Bridge from any source\n * (`useSafeAreaInsets()`, expo-router insets, a manually computed\n * value) into the {@link RnwindProvider} — rnwind stays\n * library-agnostic.\n */\nexport type Insets = Readonly<{\n top: number\n right: number\n bottom: number\n left: number\n}>\n\n/**\n * Single value carried by the rnwind context. Every piece of runtime\n * state rnwind needs — scheme, theme tables, insets, font scale,\n * window width, active responsive breakpoint, optional haptic\n * dispatcher — lives on this one bag. Consumers read it via\n * {@link useRnwind} and either destructure or forward straight to\n * `lookupCss` / `useCss`.\n *\n * `activeBreakpoint` is the highest-threshold registered breakpoint\n * whose min-width is `<= windowWidth`, or `'base'` when below the\n * smallest one (mobile-first tier) or when no breakpoints are\n * registered yet (tests, bundles without rnwind-transformed sources).\n * Always a string — never null. Reactive: it updates with\n * `useWindowDimensions().width`, so consumers can branch on it\n * without a separate hook.\n */\nexport type RnwindState = Readonly<{\n scheme: Scheme\n tables: ThemeTables\n insets: Insets\n onHaptics: OnHaptics | undefined\n fontScale: number\n windowWidth: number\n activeBreakpoint: string\n}>\n\n/** Props accepted by {@link RnwindProvider}. */\nexport type RnwindProviderProps = Readonly<{\n scheme: Scheme\n tables?: ThemeTables\n insets?: Partial<Insets>\n onHaptics?: OnHaptics\n children?: ReactNode\n}>\n\nconst EMPTY_TABLES: ThemeTables = {}\nconst ZERO_INSETS: Insets = { top: 0, right: 0, bottom: 0, left: 0 }\nconst DEFAULT_STATE: RnwindState = {\n scheme: 'light' as Scheme,\n tables: EMPTY_TABLES,\n insets: ZERO_INSETS,\n onHaptics: undefined,\n fontScale: 1,\n windowWidth: 0,\n activeBreakpoint: BASE_BREAKPOINT,\n}\n\n/**\n * Normalise a `Partial<Insets>` into a complete {@link Insets}, returning\n * the shared {@link ZERO_INSETS} reference when nothing is supplied so\n * downstream memoisation stays stable.\n * @param partial Caller-supplied insets (or undefined).\n * @returns Complete insets record.\n */\nfunction normaliseInsets(partial: Partial<Insets> | undefined): Insets {\n if (!partial) return ZERO_INSETS\n const top = partial.top ?? 0\n const right = partial.right ?? 0\n const bottom = partial.bottom ?? 0\n const left = partial.left ?? 0\n if (top === 0 && right === 0 && bottom === 0 && left === 0) return ZERO_INSETS\n return { top, right, bottom, left }\n}\n\n/** Single internal context the runtime reads from. */\nconst RnwindContext = createContext<RnwindState>(DEFAULT_STATE)\n\n/**\n * Read rnwind's full runtime state — scheme, theme tables, insets,\n * fontScale, windowWidth, onHaptics — in one go. Pass the returned\n * value straight to `lookupCss` / `useCss`, or destructure what you\n * need.\n * @returns Active rnwind state under the nearest {@link RnwindProvider}.\n */\nexport function useRnwind(): RnwindState {\n return useContext(RnwindContext)\n}\n\n/**\n * Provider for rnwind's full runtime state. fontScale + windowWidth\n * come from `useWindowDimensions()` so they react to OS-level\n * orientation / accessibility-text-size changes automatically.\n * @param props Provider props.\n * @param props.scheme Active scheme name.\n * @param props.tables Optional pre-resolved token tables.\n * @param props.insets Optional safe-area insets.\n * @param props.onHaptics Optional haptic dispatcher.\n * @param props.children React subtree.\n * @returns Provider element.\n */\nexport function RnwindProvider({ scheme, tables, insets, onHaptics, children }: RnwindProviderProps): ReactNode {\n const normalized = normaliseInsets(insets)\n const { fontScale, width } = useWindowDimensions()\n const value = useMemo<RnwindState>(() => {\n loadScheme(scheme)\n return {\n scheme,\n tables: tables ?? EMPTY_TABLES,\n insets: normalized,\n onHaptics,\n fontScale,\n windowWidth: width,\n activeBreakpoint: activeBreakpointFor(width),\n }\n }, [scheme, tables, normalized, onHaptics, fontScale, width])\n return <RnwindContext.Provider value={value}>{children}</RnwindContext.Provider>\n}\n"],"names":["_jsx"],"mappings":";;;;;AAuDA,MAAM,YAAY,GAAgB,EAAE;AACpC,MAAM,WAAW,GAAW,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EA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Ac,MAAK;QACtC,UAAU,CAAC,MAAM,CAAC;QAClB,OAAO;YACL,MAAM;YACN,MAAM,EAAE,MAAM,IAAI,YAAY;AAC9B,YAAA,MAAM,EAAE,UAAU;YAClB,SAAS;YACT,SAAS;AACT,YAAA,WAAW,EAAE,KAAK;AAClB,YAAA,gBAAgB,EAAE,mBAAmB,CAAC,KAAK,CAAC;SAC7C;AACH,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAOA,GAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAA0B;AAClF;;;;"}
@@ -1,11 +1,17 @@
1
1
  /**
2
- * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use
3
- * inside any component that wants the resolved style array without
4
- * threading the rnwind context manually. JSX-heavy components should
5
- * still call `useRnwind()` once and pass it to `lookupCss(...)` per
6
- * element so React only does a single context read per render.
7
- * @param className Raw className string or transformer-hoisted atom-name array.
8
- * @param userStyle Optional caller-supplied style appended last.
9
- * @returns Frozen style array for React Native's `style` prop.
2
+ * Resolve a className to a React Native `style` value against the active
3
+ * rnwind context (scheme, insets, fontScale, breakpoint). Molecule-fast:
4
+ * a literal className the scanner saw returns a pre-merged object by
5
+ * reference; anything else falls back to per-atom resolution. The escape
6
+ * hatch for custom components that hold a `className` prop:
7
+ *
8
+ * ```tsx
9
+ * function Card({ className, style, ...rest }) {
10
+ * return <RNView style={useCss(className, style)} {...rest} />
11
+ * }
12
+ * ```
13
+ * @param className Raw className string.
14
+ * @param userStyle Optional caller-supplied style appended last (wins).
15
+ * @returns RN `style` value (a single object or an array).
10
16
  */
11
- export declare function useCss(className?: string | readonly string[] | null, userStyle?: unknown): readonly unknown[];
17
+ export declare function useCss(className?: string | null, userStyle?: unknown): unknown;
@@ -1,18 +1,24 @@
1
1
  import { useRnwind } from '../components/rnwind-provider.mjs';
2
- import { lookupCss } from '../lookup-css.mjs';
2
+ import { resolve } from '../resolve.mjs';
3
3
 
4
4
  /**
5
- * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use
6
- * inside any component that wants the resolved style array without
7
- * threading the rnwind context manually. JSX-heavy components should
8
- * still call `useRnwind()` once and pass it to `lookupCss(...)` per
9
- * element so React only does a single context read per render.
10
- * @param className Raw className string or transformer-hoisted atom-name array.
11
- * @param userStyle Optional caller-supplied style appended last.
12
- * @returns Frozen style array for React Native's `style` prop.
5
+ * Resolve a className to a React Native `style` value against the active
6
+ * rnwind context (scheme, insets, fontScale, breakpoint). Molecule-fast:
7
+ * a literal className the scanner saw returns a pre-merged object by
8
+ * reference; anything else falls back to per-atom resolution. The escape
9
+ * hatch for custom components that hold a `className` prop:
10
+ *
11
+ * ```tsx
12
+ * function Card({ className, style, ...rest }) {
13
+ * return <RNView style={useCss(className, style)} {...rest} />
14
+ * }
15
+ * ```
16
+ * @param className Raw className string.
17
+ * @param userStyle Optional caller-supplied style appended last (wins).
18
+ * @returns RN `style` value (a single object or an array).
13
19
  */
14
20
  function useCss(className, userStyle) {
15
- return lookupCss(className, useRnwind(), userStyle);
21
+ return resolve(className, useRnwind(), userStyle).style;
16
22
  }
17
23
 
18
24
  export { useCss };
@@ -1 +1 @@
1
- {"version":3,"file":"use-css.mjs","sources":["../../../../../src/runtime/hooks/use-css.ts"],"sourcesContent":["import { useRnwind } from '../components/rnwind-provider'\nimport { lookupCss } from '../lookup-css'\n\n/**\n * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use\n * inside any component that wants the resolved style array without\n * threading the rnwind context manually. JSX-heavy components should\n * still call `useRnwind()` once and pass it to `lookupCss(...)` per\n * element so React only does a single context read per render.\n * @param className Raw className string or transformer-hoisted atom-name array.\n * @param userStyle Optional caller-supplied style appended last.\n * @returns Frozen style array for React Native's `style` prop.\n */\nexport function useCss(className?: string | readonly string[] | null, userStyle?: unknown): readonly unknown[] {\n return lookupCss(className, useRnwind(), userStyle)\n}\n"],"names":[],"mappings":";;;AAGA;;;;;;;;;AASG;AACG,SAAU,MAAM,CAAC,SAA6C,EAAE,SAAmB,EAAA;IACvF,OAAO,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC;AACrD;;;;"}
1
+ {"version":3,"file":"use-css.mjs","sources":["../../../../../src/runtime/hooks/use-css.ts"],"sourcesContent":["import { useRnwind } from '../components/rnwind-provider'\nimport { resolve } from '../resolve'\n\n/**\n * Resolve a className to a React Native `style` value against the active\n * rnwind context (scheme, insets, fontScale, breakpoint). Molecule-fast:\n * a literal className the scanner saw returns a pre-merged object by\n * reference; anything else falls back to per-atom resolution. The escape\n * hatch for custom components that hold a `className` prop:\n *\n * ```tsx\n * function Card({ className, style, ...rest }) {\n * return <RNView style={useCss(className, style)} {...rest} />\n * }\n * ```\n * @param className Raw className string.\n * @param userStyle Optional caller-supplied style appended last (wins).\n * @returns RN `style` value (a single object or an array).\n */\nexport function useCss(className?: string | null, userStyle?: unknown): unknown {\n return resolve(className, useRnwind(), userStyle).style\n}\n"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;AAeG;AACG,SAAU,MAAM,CAAC,SAAyB,EAAE,SAAmB,EAAA;IACnE,OAAO,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC,KAAK;AACzD;;;;"}
@@ -1,19 +1,14 @@
1
- export { lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, lookupCss as _l, } from './lookup-css';
2
- export { useR_ } from './components/rnwind-provider';
1
+ export { lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, } from './lookup-css';
3
2
  export type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css';
3
+ export { wrap, wrapNamespace } from './wrap';
4
+ export { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve';
5
+ export type { ResolvedCss } from './resolve';
4
6
  export { useCss } from './hooks/use-css';
5
7
  export { useInteract } from './hooks/use-interact';
6
8
  export type { UseInteractResult } from './hooks/use-interact';
7
9
  export { chainPress, chainFocus } from './chain-handlers';
8
- export { InteractiveBox, InteractiveBox as _ib } from './interactive-box';
9
- export type { InteractiveBoxProps, InteractiveSpec } from './interactive-box';
10
10
  export { RnwindProvider, useRnwind } from './components/rnwind-provider';
11
11
  export type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider';
12
- export { useMountHaptic, triggerHaptic, triggerHaptic as _ht, useMountHaptic as _hm } from './haptics';
13
- /** @internal */
14
- /** @internal */
15
- /** @internal */
16
- /** @internal */
17
12
  export type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics';
18
13
  export type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types';
19
14
  export type { ThemeTable, ThemeTables } from '../core/types';
@@ -1,10 +1,10 @@
1
- export { lookupCss as _l, activeBreakpointFor, getBreakpoints, lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider } from './lookup-css.mjs';
2
- export { RnwindProvider, useR_, useRnwind } from './components/rnwind-provider.mjs';
1
+ export { activeBreakpointFor, getBreakpoints, lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider } from './lookup-css.mjs';
2
+ export { wrap, wrapNamespace } from './wrap.mjs';
3
+ export { registerGradients, registerHaptics, registerMolecules, resolve } from './resolve.mjs';
3
4
  export { useCss } from './hooks/use-css.mjs';
4
5
  export { useInteract } from './hooks/use-interact.mjs';
5
6
  export { chainFocus, chainPress } from './chain-handlers.mjs';
6
- export { InteractiveBox, InteractiveBox as _ib } from './interactive-box.mjs';
7
- export { useMountHaptic as _hm, triggerHaptic as _ht, triggerHaptic, useMountHaptic } from './haptics.mjs';
7
+ export { RnwindProvider, useRnwind } from './components/rnwind-provider.mjs';
8
8
  export { useColor, useSize, useTheme, useToken } from './hooks/use-scheme.mjs';
9
9
 
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/runtime/index.ts"],"sourcesContent":["\n\n\n\nexport {\n lookupCss,\n registerAtoms,\n registerBreakpoints,\n registerSchemeLoader,\n setWindowHeightProvider,\n getBreakpoints,\n activeBreakpointFor,\n lookupCss as _l,\n} from './lookup-css'\nexport { useR_ } from './components/rnwind-provider'\nexport type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'\nexport { useCss } from './hooks/use-css'\nexport { useInteract } from './hooks/use-interact'\nexport type { UseInteractResult } from './hooks/use-interact'\nexport { chainPress, chainFocus } from './chain-handlers'\nexport { InteractiveBox, InteractiveBox as _ib } from './interactive-box'\nexport type { InteractiveBoxProps, InteractiveSpec } from './interactive-box'\nexport { RnwindProvider, useRnwind } from './components/rnwind-provider'\nexport type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'\nexport { useMountHaptic, triggerHaptic, triggerHaptic as _ht, useMountHaptic as _hm } from './haptics'\n\n// ──────────────────────────────────────────────────────────────────────\n// Internal aliases the babel transformer uses. Underscore-prefixed so\n// user code (which imports the public names above) can never collide\n// with what we inject at JSX sites — even if the user shadows\n// `lookupCss` / `useHaptics` / `InteractiveBox` with a local symbol,\n// the transformer's emitted code still references the private alias.\n// Don't import these in app code.\n// ──────────────────────────────────────────────────────────────────────\n/** @internal */\n\n/** @internal */\n\n/** @internal */\n\n/** @internal */\n\nexport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nexport type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'\nexport type { ThemeTable, ThemeTables } from '../core/types'\nexport { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'\nexport type { Scheme, RnwindConfig } from './types'\n\n/**\n * Installed rnwind version, inlined at publish time. Compare against a pinned\n * string when integrating with build tooling that may see multiple rnwind\n * copies (e.g. workspace overrides).\n */\nexport const VERSION = '0.0.1' as const\n"],"names":[],"mappings":";;;;;;;;;AAgDA;;;;AAIG;AACI,MAAM,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/runtime/index.ts"],"sourcesContent":["export {\n lookupCss,\n registerAtoms,\n registerBreakpoints,\n registerSchemeLoader,\n setWindowHeightProvider,\n getBreakpoints,\n activeBreakpointFor,\n} from './lookup-css'\nexport type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'\nexport { wrap, wrapNamespace } from './wrap'\nexport { resolve, registerMolecules, registerGradients, registerHaptics } from './resolve'\nexport type { ResolvedCss } from './resolve'\nexport { useCss } from './hooks/use-css'\nexport { useInteract } from './hooks/use-interact'\nexport type { UseInteractResult } from './hooks/use-interact'\nexport { chainPress, chainFocus } from './chain-handlers'\nexport { RnwindProvider, useRnwind } from './components/rnwind-provider'\nexport type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'\nexport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nexport type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'\nexport type { ThemeTable, ThemeTables } from '../core/types'\nexport { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'\nexport type { Scheme, RnwindConfig } from './types'\n\n/**\n * Installed rnwind version, inlined at publish time. Compare against a pinned\n * string when integrating with build tooling that may see multiple rnwind\n * copies (e.g. workspace overrides).\n */\nexport const VERSION = '0.0.1' as const\n"],"names":[],"mappings":";;;;;;;;;AAyBA;;;;AAIG;AACI,MAAM,OAAO,GAAG;;;;"}
@@ -95,6 +95,13 @@ export declare function loadScheme(scheme: string): void;
95
95
  * @param atoms Plain record keyed by atom name.
96
96
  */
97
97
  export declare function registerAtoms(scheme: string, atoms: Record<string, unknown>): void;
98
+ /**
99
+ * Current registry version — bumps on every `registerAtoms` /
100
+ * `registerBreakpoints`. The molecule resolver folds it into its cache
101
+ * key so an HMR atom reload invalidates derived results.
102
+ * @returns Monotonic version counter.
103
+ */
104
+ export declare function getStyleVersion(): number;
98
105
  /**
99
106
  * Register the responsive-breakpoint table the manifest module emits at
100
107
  * load time. Replaces the prior table — calling with `{}` clears it.
@@ -407,6 +407,15 @@ function registerAtoms(scheme, atoms) {
407
407
  cache.atoms[scheme] = atoms;
408
408
  atomVersion += 1;
409
409
  }
410
+ /**
411
+ * Current registry version — bumps on every `registerAtoms` /
412
+ * `registerBreakpoints`. The molecule resolver folds it into its cache
413
+ * key so an HMR atom reload invalidates derived results.
414
+ * @returns Monotonic version counter.
415
+ */
416
+ function getStyleVersion() {
417
+ return atomVersion;
418
+ }
410
419
  /**
411
420
  * Register the responsive-breakpoint table the manifest module emits at
412
421
  * load time. Replaces the prior table — calling with `{}` clears it.
@@ -527,5 +536,5 @@ function __resetLookupCssState() {
527
536
  atomVersion += 1;
528
537
  }
529
538
 
530
- export { BASE_BREAKPOINT, __resetLookupCssState, activeBreakpointFor, getBreakpoints, loadScheme, lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider };
539
+ export { BASE_BREAKPOINT, __resetLookupCssState, activeBreakpointFor, getBreakpoints, getStyleVersion, loadScheme, lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider };
531
540
  //# sourceMappingURL=lookup-css.mjs.map