react-native-gtkx 0.2.0-alpha.1 → 0.3.0-alpha.1

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 (400) hide show
  1. package/README.md +14 -2
  2. package/dist/adw/widgets.generated.d.ts +4 -4
  3. package/dist/adw/widgets.generated.js +51 -51
  4. package/dist/adw/widgets.generated.js.map +1 -1
  5. package/dist/aliases/index.d.ts +84 -0
  6. package/dist/aliases/index.js +208 -0
  7. package/dist/aliases/index.js.map +1 -0
  8. package/dist/animated/create-animated.d.ts +2 -0
  9. package/dist/animated/create-animated.js +2 -0
  10. package/dist/animated/create-animated.js.map +1 -1
  11. package/dist/animated/index.d.ts +4 -0
  12. package/dist/animated/index.js +6 -0
  13. package/dist/animated/index.js.map +1 -1
  14. package/dist/animated/types.d.ts +1 -0
  15. package/dist/animated/types.js.map +1 -1
  16. package/dist/animated/value-animation.js +17 -4
  17. package/dist/animated/value-animation.js.map +1 -1
  18. package/dist/animated/value-xy.d.ts +41 -0
  19. package/dist/animated/value-xy.js +90 -0
  20. package/dist/animated/value-xy.js.map +1 -0
  21. package/dist/animated/value.d.ts +9 -0
  22. package/dist/animated/value.js +30 -2
  23. package/dist/animated/value.js.map +1 -1
  24. package/dist/apis/host.gtkx.js +9 -12
  25. package/dist/apis/host.gtkx.js.map +1 -1
  26. package/dist/apis/index.d.ts +4 -2
  27. package/dist/apis/index.js +2 -0
  28. package/dist/apis/index.js.map +1 -1
  29. package/dist/apis/keyboard.d.ts +60 -0
  30. package/dist/apis/keyboard.js +63 -0
  31. package/dist/apis/keyboard.js.map +1 -0
  32. package/dist/apis/log-box.d.ts +15 -0
  33. package/dist/apis/log-box.js +46 -0
  34. package/dist/apis/log-box.js.map +1 -0
  35. package/dist/apis/platform.d.ts +18 -1
  36. package/dist/apis/platform.js.map +1 -1
  37. package/dist/common/icon.d.ts +23 -0
  38. package/dist/common/icon.js +14 -0
  39. package/dist/common/icon.js.map +1 -0
  40. package/dist/common/index.d.ts +1 -0
  41. package/dist/common/index.js +25 -0
  42. package/dist/common/index.js.map +1 -1
  43. package/dist/common/widget.d.ts +1 -22
  44. package/dist/common/widget.js +75 -8
  45. package/dist/common/widget.js.map +1 -1
  46. package/dist/components/animated.d.ts +73 -7
  47. package/dist/components/animated.js +560 -45
  48. package/dist/components/animated.js.map +1 -1
  49. package/dist/components/app-registry.d.ts +26 -0
  50. package/dist/components/app-registry.js.map +1 -1
  51. package/dist/components/driven-size.d.ts +27 -0
  52. package/dist/components/driven-size.js +85 -0
  53. package/dist/components/driven-size.js.map +1 -0
  54. package/dist/components/find-node-handle.d.ts +11 -0
  55. package/dist/components/find-node-handle.js +53 -0
  56. package/dist/components/find-node-handle.js.map +1 -0
  57. package/dist/components/flat-list.d.ts +3 -2
  58. package/dist/components/flat-list.js.map +1 -1
  59. package/dist/components/frame-scheduler.d.ts +16 -0
  60. package/dist/components/frame-scheduler.js +37 -0
  61. package/dist/components/frame-scheduler.js.map +1 -0
  62. package/dist/components/host-node.d.ts +7 -0
  63. package/dist/components/host-node.js +26 -1
  64. package/dist/components/host-node.js.map +1 -1
  65. package/dist/components/image.d.ts +6 -1
  66. package/dist/components/image.js +15 -4
  67. package/dist/components/image.js.map +1 -1
  68. package/dist/components/index.d.ts +11 -5
  69. package/dist/components/index.js +7 -4
  70. package/dist/components/index.js.map +1 -1
  71. package/dist/components/measure.d.ts +63 -0
  72. package/dist/components/measure.js +150 -0
  73. package/dist/components/measure.js.map +1 -0
  74. package/dist/components/modal.d.ts +1 -1
  75. package/dist/components/press-event.d.ts +28 -0
  76. package/dist/components/press-event.js +46 -0
  77. package/dist/components/press-event.js.map +1 -0
  78. package/dist/components/pressable.d.ts +63 -7
  79. package/dist/components/pressable.js +165 -12
  80. package/dist/components/pressable.js.map +1 -1
  81. package/dist/components/rect-store.d.ts +58 -0
  82. package/dist/components/rect-store.js +124 -3
  83. package/dist/components/rect-store.js.map +1 -1
  84. package/dist/components/root.js +6 -1
  85. package/dist/components/root.js.map +1 -1
  86. package/dist/components/scroll-phase.d.ts +35 -0
  87. package/dist/components/scroll-phase.js +26 -0
  88. package/dist/components/scroll-phase.js.map +1 -0
  89. package/dist/components/scroll-view.d.ts +43 -3
  90. package/dist/components/scroll-view.js +386 -45
  91. package/dist/components/scroll-view.js.map +1 -1
  92. package/dist/components/text-input.js +9 -25
  93. package/dist/components/text-input.js.map +1 -1
  94. package/dist/components/text.d.ts +6 -2
  95. package/dist/components/text.js +68 -9
  96. package/dist/components/text.js.map +1 -1
  97. package/dist/components/use-focus.d.ts +27 -0
  98. package/dist/components/use-focus.js +116 -0
  99. package/dist/components/use-focus.js.map +1 -0
  100. package/dist/components/use-layout-child.d.ts +13 -1
  101. package/dist/components/use-layout-child.js +205 -19
  102. package/dist/components/use-layout-child.js.map +1 -1
  103. package/dist/components/view.d.ts +12 -4
  104. package/dist/components/view.js +25 -14
  105. package/dist/components/view.js.map +1 -1
  106. package/dist/components/virtualized-list.d.ts +45 -5
  107. package/dist/components/virtualized-list.js +90 -24
  108. package/dist/components/virtualized-list.js.map +1 -1
  109. package/dist/components/wheel-scroll-session.d.ts +7 -0
  110. package/dist/components/wheel-scroll-session.js +53 -0
  111. package/dist/components/wheel-scroll-session.js.map +1 -0
  112. package/dist/components/widget-retention.d.ts +35 -0
  113. package/dist/components/widget-retention.js +169 -0
  114. package/dist/components/widget-retention.js.map +1 -0
  115. package/dist/contracts.d.ts +23 -3
  116. package/dist/contracts.js.map +1 -1
  117. package/dist/dnd/context.d.ts +69 -0
  118. package/dist/dnd/context.js +149 -0
  119. package/dist/dnd/context.js.map +1 -0
  120. package/dist/dnd/draggable.d.ts +59 -0
  121. package/dist/dnd/draggable.js +149 -0
  122. package/dist/dnd/draggable.js.map +1 -0
  123. package/dist/dnd/droppable.d.ts +24 -0
  124. package/dist/dnd/droppable.js +74 -0
  125. package/dist/dnd/droppable.js.map +1 -0
  126. package/dist/dnd/gtk-controllers.d.ts +39 -0
  127. package/dist/dnd/gtk-controllers.js +110 -0
  128. package/dist/dnd/gtk-controllers.js.map +1 -0
  129. package/dist/dnd/index.d.ts +6 -0
  130. package/dist/dnd/index.js +31 -0
  131. package/dist/dnd/index.js.map +1 -0
  132. package/dist/dnd/order.d.ts +7 -0
  133. package/dist/dnd/order.js +20 -0
  134. package/dist/dnd/order.js.map +1 -0
  135. package/dist/dnd/payload.d.ts +14 -0
  136. package/dist/dnd/payload.js +41 -0
  137. package/dist/dnd/payload.js.map +1 -0
  138. package/dist/dnd/sortable.d.ts +49 -0
  139. package/dist/dnd/sortable.js +307 -0
  140. package/dist/dnd/sortable.js.map +1 -0
  141. package/dist/dnd/types.d.ts +290 -0
  142. package/dist/dnd/types.js +25 -0
  143. package/dist/dnd/types.js.map +1 -0
  144. package/dist/gesture-handler-compat/builder.d.ts +251 -0
  145. package/dist/gesture-handler-compat/builder.js +513 -0
  146. package/dist/gesture-handler-compat/builder.js.map +1 -0
  147. package/dist/gesture-handler-compat/composition.d.ts +23 -0
  148. package/dist/gesture-handler-compat/composition.js +111 -0
  149. package/dist/gesture-handler-compat/composition.js.map +1 -0
  150. package/dist/gesture-handler-compat/deciders.d.ts +3 -0
  151. package/dist/gesture-handler-compat/deciders.js +47 -0
  152. package/dist/gesture-handler-compat/deciders.js.map +1 -0
  153. package/dist/gesture-handler-compat/detector-runtime.d.ts +44 -0
  154. package/dist/gesture-handler-compat/detector-runtime.js +374 -0
  155. package/dist/gesture-handler-compat/detector-runtime.js.map +1 -0
  156. package/dist/gesture-handler-compat/detector.d.ts +22 -0
  157. package/dist/gesture-handler-compat/detector.js +104 -0
  158. package/dist/gesture-handler-compat/detector.js.map +1 -0
  159. package/dist/gesture-handler-compat/fling.d.ts +24 -0
  160. package/dist/gesture-handler-compat/fling.js +123 -0
  161. package/dist/gesture-handler-compat/fling.js.map +1 -0
  162. package/dist/gesture-handler-compat/force-touch.d.ts +13 -0
  163. package/dist/gesture-handler-compat/force-touch.js +40 -0
  164. package/dist/gesture-handler-compat/force-touch.js.map +1 -0
  165. package/dist/gesture-handler-compat/hooks.d.ts +157 -0
  166. package/dist/gesture-handler-compat/hooks.js +268 -0
  167. package/dist/gesture-handler-compat/hooks.js.map +1 -0
  168. package/dist/gesture-handler-compat/hover.d.ts +2 -0
  169. package/dist/gesture-handler-compat/hover.js +22 -0
  170. package/dist/gesture-handler-compat/hover.js.map +1 -0
  171. package/dist/gesture-handler-compat/index.d.ts +98 -0
  172. package/dist/gesture-handler-compat/index.js +255 -0
  173. package/dist/gesture-handler-compat/index.js.map +1 -0
  174. package/dist/gesture-handler-compat/long-press.d.ts +6 -0
  175. package/dist/gesture-handler-compat/long-press.js +21 -0
  176. package/dist/gesture-handler-compat/long-press.js.map +1 -0
  177. package/dist/gesture-handler-compat/manual.d.ts +2 -0
  178. package/dist/gesture-handler-compat/manual.js +18 -0
  179. package/dist/gesture-handler-compat/manual.js.map +1 -0
  180. package/dist/gesture-handler-compat/native.d.ts +7 -0
  181. package/dist/gesture-handler-compat/native.js +34 -0
  182. package/dist/gesture-handler-compat/native.js.map +1 -0
  183. package/dist/gesture-handler-compat/orchestrator.d.ts +77 -0
  184. package/dist/gesture-handler-compat/orchestrator.js +284 -0
  185. package/dist/gesture-handler-compat/orchestrator.js.map +1 -0
  186. package/dist/gesture-handler-compat/pan.d.ts +23 -0
  187. package/dist/gesture-handler-compat/pan.js +116 -0
  188. package/dist/gesture-handler-compat/pan.js.map +1 -0
  189. package/dist/gesture-handler-compat/recognizer.d.ts +268 -0
  190. package/dist/gesture-handler-compat/recognizer.js +1056 -0
  191. package/dist/gesture-handler-compat/recognizer.js.map +1 -0
  192. package/dist/gesture-handler-compat/relations.d.ts +43 -0
  193. package/dist/gesture-handler-compat/relations.js +128 -0
  194. package/dist/gesture-handler-compat/relations.js.map +1 -0
  195. package/dist/gesture-handler-compat/tap.d.ts +6 -0
  196. package/dist/gesture-handler-compat/tap.js +29 -0
  197. package/dist/gesture-handler-compat/tap.js.map +1 -0
  198. package/dist/gesture-handler-compat/touchpad.d.ts +41 -0
  199. package/dist/gesture-handler-compat/touchpad.js +64 -0
  200. package/dist/gesture-handler-compat/touchpad.js.map +1 -0
  201. package/dist/gesture-handler-compat/types.d.ts +441 -0
  202. package/dist/gesture-handler-compat/types.js +167 -0
  203. package/dist/gesture-handler-compat/types.js.map +1 -0
  204. package/dist/gtk/controllers.d.ts +39 -0
  205. package/dist/gtk/controllers.js +92 -0
  206. package/dist/gtk/controllers.js.map +1 -0
  207. package/dist/gtk/index.d.ts +3 -1
  208. package/dist/gtk/index.js +14 -1
  209. package/dist/gtk/index.js.map +1 -1
  210. package/dist/gtk/widgets.generated.d.ts +14 -14
  211. package/dist/gtk/widgets.generated.js +101 -102
  212. package/dist/gtk/widgets.generated.js.map +1 -1
  213. package/dist/gtk/window-actions.d.ts +77 -0
  214. package/dist/gtk/window-actions.js +193 -0
  215. package/dist/gtk/window-actions.js.map +1 -0
  216. package/dist/gtkx/bridge/geometry.d.ts +15 -0
  217. package/dist/gtkx/bridge/geometry.js +40 -0
  218. package/dist/gtkx/bridge/geometry.js.map +1 -0
  219. package/dist/gtkx/bridge/index.d.ts +7 -3
  220. package/dist/gtkx/bridge/index.js +12 -4
  221. package/dist/gtkx/bridge/index.js.map +1 -1
  222. package/dist/gtkx/bridge/slot-portal.d.ts +12 -0
  223. package/dist/gtkx/bridge/slot-portal.js +17 -0
  224. package/dist/gtkx/bridge/slot-portal.js.map +1 -0
  225. package/dist/gtkx/bridge/svg-node.js +10 -54
  226. package/dist/gtkx/bridge/svg-node.js.map +1 -1
  227. package/dist/gtkx/bridge/use-signal.js +2 -2
  228. package/dist/gtkx/bridge/use-signal.js.map +1 -1
  229. package/dist/gtkx/bridge/view-box.d.ts +56 -0
  230. package/dist/gtkx/bridge/view-box.js +394 -9
  231. package/dist/gtkx/bridge/view-box.js.map +1 -1
  232. package/dist/gtkx/bridge/widget-css.d.ts +17 -0
  233. package/dist/gtkx/bridge/widget-css.js +72 -0
  234. package/dist/gtkx/bridge/widget-css.js.map +1 -0
  235. package/dist/index.d.ts +3 -3
  236. package/dist/index.js +2 -2
  237. package/dist/index.js.map +1 -1
  238. package/dist/layout/driven-size.d.ts +12 -0
  239. package/dist/layout/driven-size.js +70 -0
  240. package/dist/layout/driven-size.js.map +1 -0
  241. package/dist/layout/engine.d.ts +17 -1
  242. package/dist/layout/engine.js +3 -20
  243. package/dist/layout/engine.js.map +1 -1
  244. package/dist/layout/node.d.ts +13 -0
  245. package/dist/layout/node.js +14 -0
  246. package/dist/layout/node.js.map +1 -1
  247. package/dist/layout/yoga.d.ts +3 -2
  248. package/dist/layout/yoga.js +5 -2
  249. package/dist/layout/yoga.js.map +1 -1
  250. package/dist/mcp/data/generated.d.ts +310 -91
  251. package/dist/mcp/data/generated.js +365 -90
  252. package/dist/mcp/data/generated.js.map +1 -1
  253. package/dist/mcp/server.js +1 -1
  254. package/dist/mcp/server.js.map +1 -1
  255. package/dist/metro/index.d.ts +10 -0
  256. package/dist/metro/index.js +21 -12
  257. package/dist/metro/index.js.map +1 -1
  258. package/dist/navigation/sidebar.d.ts +47 -1
  259. package/dist/navigation/sidebar.js +77 -3
  260. package/dist/navigation/sidebar.js.map +1 -1
  261. package/dist/reanimated-compat/animated-ref.d.ts +32 -0
  262. package/dist/reanimated-compat/animated-ref.js +57 -0
  263. package/dist/reanimated-compat/animated-ref.js.map +1 -0
  264. package/dist/reanimated-compat/animation.d.ts +177 -0
  265. package/dist/reanimated-compat/animation.js +540 -0
  266. package/dist/reanimated-compat/animation.js.map +1 -0
  267. package/dist/reanimated-compat/color.d.ts +28 -0
  268. package/dist/reanimated-compat/color.js +249 -0
  269. package/dist/reanimated-compat/color.js.map +1 -0
  270. package/dist/reanimated-compat/decay.d.ts +39 -0
  271. package/dist/reanimated-compat/decay.js +96 -0
  272. package/dist/reanimated-compat/decay.js.map +1 -0
  273. package/dist/reanimated-compat/easing.d.ts +30 -0
  274. package/dist/reanimated-compat/easing.js +76 -0
  275. package/dist/reanimated-compat/easing.js.map +1 -0
  276. package/dist/reanimated-compat/hooks.d.ts +14 -0
  277. package/dist/reanimated-compat/hooks.js +217 -0
  278. package/dist/reanimated-compat/hooks.js.map +1 -0
  279. package/dist/reanimated-compat/index.d.ts +258 -0
  280. package/dist/reanimated-compat/index.js +464 -0
  281. package/dist/reanimated-compat/index.js.map +1 -0
  282. package/dist/reanimated-compat/interpolation.d.ts +18 -0
  283. package/dist/reanimated-compat/interpolation.js +122 -0
  284. package/dist/reanimated-compat/interpolation.js.map +1 -0
  285. package/dist/reanimated-compat/layout-animation-config.d.ts +43 -0
  286. package/dist/reanimated-compat/layout-animation-config.js +78 -0
  287. package/dist/reanimated-compat/layout-animation-config.js.map +1 -0
  288. package/dist/reanimated-compat/layout-animation-presets.d.ts +117 -0
  289. package/dist/reanimated-compat/layout-animation-presets.js +498 -0
  290. package/dist/reanimated-compat/layout-animation-presets.js.map +1 -0
  291. package/dist/reanimated-compat/layout-animation-runtime.d.ts +21 -0
  292. package/dist/reanimated-compat/layout-animation-runtime.js +311 -0
  293. package/dist/reanimated-compat/layout-animation-runtime.js.map +1 -0
  294. package/dist/reanimated-compat/layout-animation-view.d.ts +27 -0
  295. package/dist/reanimated-compat/layout-animation-view.js +266 -0
  296. package/dist/reanimated-compat/layout-animation-view.js.map +1 -0
  297. package/dist/reanimated-compat/layout-animation.d.ts +171 -0
  298. package/dist/reanimated-compat/layout-animation.js +469 -0
  299. package/dist/reanimated-compat/layout-animation.js.map +1 -0
  300. package/dist/reanimated-compat/layout-transitions.d.ts +83 -0
  301. package/dist/reanimated-compat/layout-transitions.js +350 -0
  302. package/dist/reanimated-compat/layout-transitions.js.map +1 -0
  303. package/dist/reanimated-compat/mutable.d.ts +29 -0
  304. package/dist/reanimated-compat/mutable.js +139 -0
  305. package/dist/reanimated-compat/mutable.js.map +1 -0
  306. package/dist/reanimated-compat/props.d.ts +18 -0
  307. package/dist/reanimated-compat/props.js +111 -0
  308. package/dist/reanimated-compat/props.js.map +1 -0
  309. package/dist/reanimated-compat/scroll-handler.d.ts +119 -0
  310. package/dist/reanimated-compat/scroll-handler.js +274 -0
  311. package/dist/reanimated-compat/scroll-handler.js.map +1 -0
  312. package/dist/reanimated-compat/scroll-offset.d.ts +12 -0
  313. package/dist/reanimated-compat/scroll-offset.js +104 -0
  314. package/dist/reanimated-compat/scroll-offset.js.map +1 -0
  315. package/dist/reanimated-compat/style.d.ts +90 -0
  316. package/dist/reanimated-compat/style.js +452 -0
  317. package/dist/reanimated-compat/style.js.map +1 -0
  318. package/dist/reanimated-compat/test-timers.d.ts +28 -0
  319. package/dist/reanimated-compat/test-timers.js +136 -0
  320. package/dist/reanimated-compat/test-timers.js.map +1 -0
  321. package/dist/reanimated-compat/threads.d.ts +13 -0
  322. package/dist/reanimated-compat/threads.js +41 -0
  323. package/dist/reanimated-compat/threads.js.map +1 -0
  324. package/dist/reanimated-compat/tracking.d.ts +41 -0
  325. package/dist/reanimated-compat/tracking.js +106 -0
  326. package/dist/reanimated-compat/tracking.js.map +1 -0
  327. package/dist/reanimated-compat/updater-animations.d.ts +36 -0
  328. package/dist/reanimated-compat/updater-animations.js +273 -0
  329. package/dist/reanimated-compat/updater-animations.js.map +1 -0
  330. package/dist/responder/system.d.ts +100 -0
  331. package/dist/responder/system.js +304 -0
  332. package/dist/responder/system.js.map +1 -0
  333. package/dist/responder/touch-history.d.ts +10 -0
  334. package/dist/responder/touch-history.js +78 -0
  335. package/dist/responder/touch-history.js.map +1 -0
  336. package/dist/responder/types.d.ts +63 -0
  337. package/dist/responder/types.js +29 -0
  338. package/dist/responder/types.js.map +1 -0
  339. package/dist/responder/use-responder.d.ts +23 -0
  340. package/dist/responder/use-responder.js +317 -0
  341. package/dist/responder/use-responder.js.map +1 -0
  342. package/dist/runner/host-dev.js +4 -2
  343. package/dist/runner/host-dev.js.map +1 -1
  344. package/dist/runner/host.js +6 -2
  345. package/dist/runner/host.js.map +1 -1
  346. package/dist/runner/index.js +3 -3
  347. package/dist/runner/index.js.map +1 -1
  348. package/dist/sea/gtkx-config-module.js +2 -2
  349. package/dist/sea/gtkx-config-module.js.map +1 -1
  350. package/dist/style/absolute-insets.d.ts +26 -0
  351. package/dist/style/absolute-insets.js +113 -0
  352. package/dist/style/absolute-insets.js.map +1 -0
  353. package/dist/style/animated-size.d.ts +25 -0
  354. package/dist/style/animated-size.js +225 -0
  355. package/dist/style/animated-size.js.map +1 -0
  356. package/dist/style/box-shadow.d.ts +7 -0
  357. package/dist/style/box-shadow.js +197 -0
  358. package/dist/style/box-shadow.js.map +1 -0
  359. package/dist/style/colors.d.ts +17 -0
  360. package/dist/style/colors.js +25 -6
  361. package/dist/style/colors.js.map +1 -1
  362. package/dist/style/imperative-css.d.ts +21 -0
  363. package/dist/style/imperative-css.js +63 -0
  364. package/dist/style/imperative-css.js.map +1 -0
  365. package/dist/style/index.d.ts +4 -1
  366. package/dist/style/index.js +4 -1
  367. package/dist/style/index.js.map +1 -1
  368. package/dist/style/split-style.d.ts +5 -2
  369. package/dist/style/split-style.js +36 -3
  370. package/dist/style/split-style.js.map +1 -1
  371. package/dist/style/text-decoration.d.ts +15 -0
  372. package/dist/style/text-decoration.js +26 -0
  373. package/dist/style/text-decoration.js.map +1 -0
  374. package/dist/style/visual-css.js +37 -1
  375. package/dist/style/visual-css.js.map +1 -1
  376. package/dist/svg/gradient-geometry.js +2 -5
  377. package/dist/svg/gradient-geometry.js.map +1 -1
  378. package/dist/testing/index.js.map +1 -1
  379. package/dist/unsupported-export.d.ts +8 -0
  380. package/dist/unsupported-export.js +66 -0
  381. package/dist/unsupported-export.js.map +1 -0
  382. package/dist/vendor/react-native/pan-responder.d.ts +102 -0
  383. package/dist/vendor/react-native/pan-responder.js +196 -0
  384. package/dist/vendor/react-native/pan-responder.js.map +1 -0
  385. package/dist/vendor/react-native/touch-history-math.d.ts +18 -0
  386. package/dist/vendor/react-native/touch-history-math.js +102 -0
  387. package/dist/vendor/react-native/touch-history-math.js.map +1 -0
  388. package/dist/vite/index.d.ts +21 -8
  389. package/dist/vite/index.js +127 -82
  390. package/dist/vite/index.js.map +1 -1
  391. package/dist/vitest/index.d.ts +2 -2
  392. package/dist/vitest/index.js.map +1 -1
  393. package/dist/worklets-compat/index.d.ts +4 -0
  394. package/dist/worklets-compat/index.js +28 -0
  395. package/dist/worklets-compat/index.js.map +1 -0
  396. package/dist/worklets-compat/surface.d.ts +110 -0
  397. package/dist/worklets-compat/surface.js +153 -0
  398. package/dist/worklets-compat/surface.js.map +1 -0
  399. package/package.json +25 -9
  400. package/types.d.ts +9 -0
@@ -4,42 +4,30 @@
4
4
  // from the root and merges it beneath the CLI config; this preset plugs in
5
5
  // there as a single plugin.
6
6
  //
7
- // Single self-contained file on purpose: vite loads the config's imported
8
- // packages with BARE Node, so this subpath (like ./metro and ./runner) must
9
- // not contain extensionless relative imports — the pure resolution helpers
10
- // live here rather than in a sibling module.
7
+ // vite loads the config's imported packages with BARE Node, so this subpath
8
+ // (like ./metro and ./runner) must not contain EXTENSIONLESS relative imports
9
+ // — the pure resolution helpers live here rather than in a sibling module,
10
+ // and the one import that does cross a file boundary spells out its `.js`.
11
11
  import { existsSync } from "node:fs";
12
12
  import { dirname, extname, isAbsolute, resolve } from "node:path";
13
+ import { applyAliases, compileAliases, DEFAULT_ALIAS_TABLE, } from "../aliases/index.js";
14
+ // Re-exported so an app configuring `aliases` never has to reach past the
15
+ // preset subpath it already imports.
16
+ export { CONFIGURABLE_ALIASES, DEFAULT_ALIASES, PLATFORM_ALIAS, } from "../aliases/index.js";
13
17
  export const DEFAULT_PLATFORMS = ["linux", "native"];
14
18
  export const DEFAULT_EXTENSIONS = ["tsx", "ts", "jsx", "js"];
15
- const REACT_NATIVE = "react-native";
16
19
  const REACT_NATIVE_GTKX = "react-native-gtkx";
17
- const REACT_NATIVE_SVG = "react-native-svg";
18
- const REACT_NATIVE_GTKX_SVG = "react-native-gtkx/svg";
19
20
  /**
20
- * Maps `react-native` (and its subpaths) to `react-native-gtkx`, and
21
- * `react-native-svg` (and its subpaths) to the `react-native-gtkx/svg`
22
- * compat subpath (see src/svg-compat/index.ts) — same rationale, same exact-
23
- * match-or-slash-prefix guard so a lookalike package name (`react-native-
24
- * svg-icons`, the same shape of trap `react-native-web` is for the plain
25
- * `react-native` case below) is never aliased by accident. Returns null for
26
- * every other specifier, including `react-native-gtkx` itself.
21
+ * Applies the DEFAULT alias table (../aliases/index.ts) to one specifier:
22
+ * `react-native` and its subpaths onto `react-native-gtkx`, and the five
23
+ * package substitutions onto their compat subpaths. Returns null for every
24
+ * other specifier, including `react-native-gtkx` itself.
25
+ *
26
+ * Exported for tests and for apps driving vite by hand. The plugin does NOT
27
+ * call it — the plugin resolves through the table its own `aliases` option
28
+ * produced, so an app's deltas apply.
27
29
  */
28
- export const rewriteReactNativeImport = (source) => {
29
- if (source === REACT_NATIVE) {
30
- return REACT_NATIVE_GTKX;
31
- }
32
- if (source.startsWith(`${REACT_NATIVE}/`)) {
33
- return `${REACT_NATIVE_GTKX}${source.slice(REACT_NATIVE.length)}`;
34
- }
35
- if (source === REACT_NATIVE_SVG) {
36
- return REACT_NATIVE_GTKX_SVG;
37
- }
38
- if (source.startsWith(`${REACT_NATIVE_SVG}/`)) {
39
- return `${REACT_NATIVE_GTKX_SVG}${source.slice(REACT_NATIVE_SVG.length)}`;
40
- }
41
- return null;
42
- };
30
+ export const rewriteReactNativeImport = (source) => applyAliases(DEFAULT_ALIAS_TABLE, source);
43
31
  /** Splits a vite specifier into its path part and its `?query` suffix. */
44
32
  export const splitQuery = (source) => {
45
33
  const index = source.indexOf("?");
@@ -115,60 +103,117 @@ export const resolvePlatformSpecifier = (source, importer, exists, options = {})
115
103
  * and resolves Metro-style platform extensions
116
104
  * (`.linux.tsx` → `.native.tsx` → base) for extensionless imports.
117
105
  */
118
- export const reactNativeGtkx = (options = {}) => ({
119
- name: "react-native-gtkx:preset",
120
- // Before vite's own resolver and the gtkx CLI plugins: the alias must win
121
- // over node resolution and platform files must win over the base file.
122
- enforce: "pre",
123
- config: () => ({
124
- ssr: {
125
- // `gtkx dev` runs vite with ssr.external: true, which would hand
126
- // react-native-gtkx straight to node. Keep the package inside the
127
- // vite pipeline; noExternal wins over external: true.
106
+ export const reactNativeGtkx = (options = {}) => {
107
+ // Throws on an unknown key, an overlapping pattern or an attempt to remove
108
+ // the platform alias — at config load, naming what is valid.
109
+ const aliases = compileAliases(options.aliases);
110
+ return {
111
+ name: "react-native-gtkx:preset",
112
+ // Before vite's own resolver and the gtkx CLI plugins: the alias must win
113
+ // over node resolution and platform files must win over the base file.
114
+ enforce: "pre",
115
+ config: (_config, env) => ({
116
+ // `__DEV__` is part of the react-native runtime contract, not a Metro
117
+ // detail: RN's own modules branch on it and so does every library
118
+ // written against them (`@gorhom/bottom-sheet`'s logger and four of its
119
+ // components read it at module scope). The Metro path gets it from the
120
+ // app's stock RN preset; nothing supplied it on the vite path, so a
121
+ // library that reads it crashed the bundle at startup with
122
+ // "ReferenceError: __DEV__ is not defined" — found by building
123
+ // spike/core-exports rather than by reading anything.
128
124
  //
129
- // "react-native" must be listed too: with ssr.external: true vite
130
- // externalizes a bare import BEFORE the plugin pipeline whenever the
131
- // package resolves natively — and the real react-native (a Flow
132
- // codebase Node cannot parse) exists in RN monorepos. noExternal
133
- // forces the full plugin resolution, where the alias rewrites the
134
- // import to react-native-gtkx.
135
- // @react-navigation must go through the pipeline too: it imports
136
- // "react-native", and an externalized copy resolves that to the real
137
- // Flow package (SyntaxError: Unexpected token 'typeof') instead of
138
- // our alias. Only bites on the dev path — a production build inlines
139
- // everything anyway.
140
- noExternal: ["react-native-gtkx", "react-native", /^@react-navigation\//],
141
- },
142
- resolve: {
143
- // RC2-WORKAROUND(runtime-dedupe): see docs/gtkx-rc2-notes.md
144
- // The gtkx runtime and react are single-instance hosts: when the app
145
- // and react-native-gtkx resolve them from different node_modules
146
- // (file:-installed package, nested installs), two bundled copies
147
- // double-init the runtime and GLib aborts. dedupe pins every copy to
148
- // the project's own resolution.
149
- dedupe: [
150
- "@gtkx/css",
151
- "@gtkx/gi",
152
- "@gtkx/jsx",
153
- "@gtkx/native",
154
- "@gtkx/react",
155
- "@gtkx/runtime",
156
- // react-navigation is context-based: two bundled copies of core
157
- // fail with "couldn't find a navigation context".
158
- "@react-navigation/core",
159
- "@react-navigation/native",
160
- "react",
161
- ],
125
+ // vite's mode is the honest source: `gtkx dev` builds in development,
126
+ // `gtkx build` in production, which is exactly the distinction RN draws.
127
+ define: {
128
+ __DEV__: JSON.stringify(env.mode !== "production"),
129
+ },
130
+ ssr: {
131
+ // `gtkx dev` runs vite with ssr.external: true, which would hand
132
+ // react-native-gtkx straight to node. Keep the package inside the
133
+ // vite pipeline; noExternal wins over external: true.
134
+ //
135
+ // "react-native" must be listed too: with ssr.external: true vite
136
+ // externalizes a bare import BEFORE the plugin pipeline whenever the
137
+ // package resolves natively — and the real react-native (a Flow
138
+ // codebase Node cannot parse) exists in RN monorepos. noExternal
139
+ // forces the full plugin resolution, where the alias rewrites the
140
+ // import to react-native-gtkx.
141
+ // "react-native-reanimated" for the same reason as "react-native": an
142
+ // app that also ships iOS/Android keeps the real package installed, it
143
+ // resolves natively, and ssr.external: true would hand Node a codebase
144
+ // built around a Babel plugin and a worklet runtime before the alias
145
+ // ever gets a chance to rewrite the import.
146
+ // "react-native-worklets" is the same case one package over — it is
147
+ // where that worklet runtime actually lives since Reanimated 4.
148
+ //
149
+ // The rule those are instances of, stated once so the next alias does
150
+ // not have to rediscover it: EVERY package name in the alias table must
151
+ // be listed here. An alias is a resolveId hook, and a bare specifier
152
+ // that vite externalizes never reaches one — so on the dev path the
153
+ // alias silently loses to whatever is installed under the real name.
154
+ // That is not hypothetical: an app that also ships iOS and Android has
155
+ // all of them in node_modules, which is the case the alias exists to
156
+ // serve. `react-native-gesture-handler` proved it — this list once held
157
+ // three of the six names, its real package loaded, and it failed on an
158
+ // extensionless internal import Node cannot resolve (found by running
159
+ // the gallery's upstream-libraries section, which installs it).
160
+ //
161
+ // So the list is DERIVED rather than written out: it is exactly the
162
+ // table's package names, and a name can no longer go missing from one
163
+ // of the two places it has to appear.
164
+ //
165
+ // `aliases.names` includes the packages an app turned OFF with `false`,
166
+ // deliberately. Dropping an alias means the REAL package loads, and the
167
+ // real package imports `react-native` at module scope — an import that
168
+ // only reaches the platform alias if Node never gets the package first.
169
+ // Un-aliasing a package is therefore a reason to keep it inside the
170
+ // pipeline, not a reason to let it out.
171
+ noExternal: [
172
+ REACT_NATIVE_GTKX,
173
+ ...aliases.names,
174
+ // @react-navigation is not aliased, but must go through the pipeline
175
+ // too: it imports `react-native`, and an externalized copy resolves
176
+ // that to the real Flow package (SyntaxError: Unexpected token
177
+ // 'typeof') instead of our alias. Only bites on the dev path — a
178
+ // production build inlines everything anyway.
179
+ /^@react-navigation\//,
180
+ ],
181
+ },
182
+ resolve: {
183
+ // RC4-WORKAROUND(runtime-dedupe): see docs/gtkx-rc4-notes.md
184
+ // The gtkx runtime and react are single-instance hosts: when the app
185
+ // and react-native-gtkx resolve them from different node_modules
186
+ // (file:-installed package, nested installs), two bundled copies
187
+ // double-init the runtime and GLib aborts. dedupe pins every copy to
188
+ // the project's own resolution.
189
+ dedupe: [
190
+ "@gtkx/css",
191
+ "@gtkx/gi",
192
+ "@gtkx/jsx",
193
+ "@gtkx/native",
194
+ "@gtkx/react",
195
+ "@gtkx/runtime",
196
+ // react-navigation is context-based: two bundled copies of core
197
+ // fail with "couldn't find a navigation context".
198
+ "@react-navigation/core",
199
+ "@react-navigation/native",
200
+ "react",
201
+ ],
202
+ },
203
+ }),
204
+ async resolveId(source, importer) {
205
+ // The app's table, not the default one: a package dropped with `false`
206
+ // falls through to vite's own resolution and the real package loads.
207
+ const aliased = applyAliases(aliases, source);
208
+ if (aliased !== null) {
209
+ const resolved = await this.resolve(aliased, importer, {
210
+ skipSelf: true,
211
+ });
212
+ return resolved ?? aliased;
213
+ }
214
+ return resolvePlatformSpecifier(source, importer, existsSync, options);
162
215
  },
163
- }),
164
- async resolveId(source, importer) {
165
- const aliased = rewriteReactNativeImport(source);
166
- if (aliased !== null) {
167
- const resolved = await this.resolve(aliased, importer, { skipSelf: true });
168
- return resolved ?? aliased;
169
- }
170
- return resolvePlatformSpecifier(source, importer, existsSync, options);
171
- },
172
- });
216
+ };
217
+ };
173
218
  export default reactNativeGtkx;
174
219
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,4BAA4B;AAC5B,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,6CAA6C;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAgBjE,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAsB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;AAE/E,MAAM,YAAY,GAAG,cAAc,CAAA;AACnC,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AAC7C,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAC3C,MAAM,qBAAqB,GAAG,uBAAuB,CAAA;AAErD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAiB,EAAE;IACxE,IAAI,MAAM,KAAK,YAAY,EAAE,CAAC;QAC5B,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,YAAY,GAAG,CAAC,EAAE,CAAC;QAC1C,OAAO,GAAG,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAA;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,qEAAqE;YACrE,gCAAgC;YAChC,MAAM,EAAE;gBACN,WAAW;gBACX,UAAU;gBACV,WAAW;gBACX,cAAc;gBACd,aAAa;gBACb,eAAe;gBACf,gEAAgE;gBAChE,kDAAkD;gBAClD,wBAAwB;gBACxB,0BAA0B;gBAC1B,OAAO;aACR;SACF;KACF,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ;QAC9B,MAAM,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAA;QAChD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;YAC1E,OAAO,QAAQ,IAAI,OAAO,CAAA;QAC5B,CAAC;QACD,OAAO,wBAAwB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACxE,CAAC;CACF,CAAC,CAAA;AAEF,eAAe,eAAe,CAAA","sourcesContent":["// react-native-gtkx/vite — makes a gtkx project React Native compatible.\n// The gtkx CLI (dev and build) starts vite with an inline config that never\n// sets `configFile: false`, so vite picks up the project's vite.config.ts\n// from the root and merges it beneath the CLI config; this preset plugs in\n// there as a single plugin.\n//\n// Single self-contained file on purpose: vite loads the config's imported\n// packages with BARE Node, so this subpath (like ./metro and ./runner) must\n// not contain extensionless relative imports — the pure resolution helpers\n// live here rather than in a sibling module.\nimport { existsSync } from \"node:fs\"\nimport { dirname, extname, isAbsolute, resolve } from \"node:path\"\nimport type { Plugin } from \"vite\"\n\n// --- pure resolution logic (unit-tested directly) -----------------------\n\n/** Options shared by the preset factory and the pure resolver helpers. */\nexport type PlatformResolutionOptions = {\n /** Platform suffix priority, most specific first. Default: [\"linux\", \"native\"]. */\n platforms?: readonly string[]\n /** Source extensions tried for every platform suffix. Default: [\"tsx\", \"ts\", \"jsx\", \"js\"]. */\n extensions?: readonly string[]\n}\n\n/** Predicate the plugin injects as fs.existsSync; tests inject fakes. */\nexport type FileExists = (filePath: string) => boolean\n\nexport const DEFAULT_PLATFORMS: readonly string[] = [\"linux\", \"native\"]\nexport const DEFAULT_EXTENSIONS: readonly string[] = [\"tsx\", \"ts\", \"jsx\", \"js\"]\n\nconst REACT_NATIVE = \"react-native\"\nconst REACT_NATIVE_GTKX = \"react-native-gtkx\"\nconst REACT_NATIVE_SVG = \"react-native-svg\"\nconst REACT_NATIVE_GTKX_SVG = \"react-native-gtkx/svg\"\n\n/**\n * Maps `react-native` (and its subpaths) to `react-native-gtkx`, and\n * `react-native-svg` (and its subpaths) to the `react-native-gtkx/svg`\n * compat subpath (see src/svg-compat/index.ts) — same rationale, same exact-\n * match-or-slash-prefix guard so a lookalike package name (`react-native-\n * svg-icons`, the same shape of trap `react-native-web` is for the plain\n * `react-native` case below) is never aliased by accident. Returns null for\n * every other specifier, including `react-native-gtkx` itself.\n */\nexport const rewriteReactNativeImport = (source: string): string | null => {\n if (source === REACT_NATIVE) {\n return REACT_NATIVE_GTKX\n }\n if (source.startsWith(`${REACT_NATIVE}/`)) {\n return `${REACT_NATIVE_GTKX}${source.slice(REACT_NATIVE.length)}`\n }\n if (source === REACT_NATIVE_SVG) {\n return REACT_NATIVE_GTKX_SVG\n }\n if (source.startsWith(`${REACT_NATIVE_SVG}/`)) {\n return `${REACT_NATIVE_GTKX_SVG}${source.slice(REACT_NATIVE_SVG.length)}`\n }\n return null\n}\n\n/** Splits a vite specifier into its path part and its `?query` suffix. */\nexport const splitQuery = (\n source: string,\n): { specifier: string; query: string } => {\n const index = source.indexOf(\"?\")\n if (index === -1) {\n return { specifier: source, query: \"\" }\n }\n return { specifier: source.slice(0, index), query: source.slice(index) }\n}\n\nconst isRelative = (specifier: string): boolean =>\n specifier.startsWith(\"./\") || specifier.startsWith(\"../\")\n\n/**\n * Ordered platform suffixes, platform-major: every extension of the first\n * platform is tried before any extension of the next one\n * (`.linux.tsx`, `.linux.ts`, …, `.native.tsx`, …).\n */\nexport const platformSuffixes = (\n options: PlatformResolutionOptions = {},\n): string[] => {\n const platforms = options.platforms ?? DEFAULT_PLATFORMS\n const extensions = options.extensions ?? DEFAULT_EXTENSIONS\n return platforms.flatMap((platform) =>\n extensions.map((extension) => `.${platform}.${extension}`),\n )\n}\n\n/**\n * Candidate file paths for an extensionless base path, in priority order:\n * direct platform files first, then platform index files of a directory —\n * mirroring Metro, which exhausts file resolution before directory resolution.\n * The base file itself is not a candidate: when no platform file exists the\n * plugin bails out and the default resolver picks the base module.\n */\nexport const platformCandidates = (\n base: string,\n options: PlatformResolutionOptions = {},\n): string[] => {\n const suffixes = platformSuffixes(options)\n return [\n ...suffixes.map((suffix) => `${base}${suffix}`),\n ...suffixes.map((suffix) => `${base}/index${suffix}`),\n ]\n}\n\n// Source extensions Metro strips before trying platform variants: an\n// import of \"./useLinking.js\" (the TS-ESM style react-navigation and most\n// compiled RN libraries use) must still find useLinking.native.tsx /\n// useLinking.native.js — Metro resolves the BASE name platform-first, the\n// literal file is only the fallback.\nconst STRIPPABLE_EXTENSIONS = new Set([\".js\", \".jsx\", \".mjs\", \".ts\", \".tsx\"])\n\n/**\n * Metro platform-extension resolution for a single import: relative (or\n * absolute) specifiers that are extensionless — or carry a strippable\n * source extension — try platform candidates first; the first existing\n * candidate wins; the `?query` suffix is carried over. Returns null when\n * the import is out of scope or no platform file exists, handing the\n * import back to the default resolver.\n */\nexport const resolvePlatformSpecifier = (\n source: string,\n importer: string | undefined,\n exists: FileExists,\n options: PlatformResolutionOptions = {},\n): string | null => {\n if (importer === undefined || source.startsWith(\"\\0\")) {\n return null\n }\n const { specifier, query } = splitQuery(source)\n if (!isRelative(specifier) && !isAbsolute(specifier)) {\n return null\n }\n const extension = extname(specifier)\n if (extension !== \"\" && !STRIPPABLE_EXTENSIONS.has(extension)) {\n return null\n }\n const withExtension = isAbsolute(specifier)\n ? specifier\n : resolve(dirname(splitQuery(importer).specifier), specifier)\n const base =\n extension === \"\" ? withExtension : withExtension.slice(0, -extension.length)\n for (const candidate of platformCandidates(base, options)) {\n if (exists(candidate)) {\n return candidate + query\n }\n }\n return null\n}\n\n// --- the vite plugin ----------------------------------------------------\n\nexport type ReactNativeGtkxOptions = PlatformResolutionOptions\n\n/**\n * Vite plugin: aliases `react-native` (and subpaths) to `react-native-gtkx`\n * and resolves Metro-style platform extensions\n * (`.linux.tsx` → `.native.tsx` → base) for extensionless imports.\n */\nexport const reactNativeGtkx = (\n options: ReactNativeGtkxOptions = {},\n): Plugin => ({\n name: \"react-native-gtkx:preset\",\n // Before vite's own resolver and the gtkx CLI plugins: the alias must win\n // over node resolution and platform files must win over the base file.\n enforce: \"pre\",\n\n config: () => ({\n ssr: {\n // `gtkx dev` runs vite with ssr.external: true, which would hand\n // react-native-gtkx straight to node. Keep the package inside the\n // vite pipeline; noExternal wins over external: true.\n //\n // \"react-native\" must be listed too: with ssr.external: true vite\n // externalizes a bare import BEFORE the plugin pipeline whenever the\n // package resolves natively — and the real react-native (a Flow\n // codebase Node cannot parse) exists in RN monorepos. noExternal\n // forces the full plugin resolution, where the alias rewrites the\n // import to react-native-gtkx.\n // @react-navigation must go through the pipeline too: it imports\n // \"react-native\", and an externalized copy resolves that to the real\n // Flow package (SyntaxError: Unexpected token 'typeof') instead of\n // our alias. Only bites on the dev path — a production build inlines\n // everything anyway.\n noExternal: [\"react-native-gtkx\", \"react-native\", /^@react-navigation\\//],\n },\n resolve: {\n // RC2-WORKAROUND(runtime-dedupe): see docs/gtkx-rc2-notes.md\n // The gtkx runtime and react are single-instance hosts: when the app\n // and react-native-gtkx resolve them from different node_modules\n // (file:-installed package, nested installs), two bundled copies\n // double-init the runtime and GLib aborts. dedupe pins every copy to\n // the project's own resolution.\n dedupe: [\n \"@gtkx/css\",\n \"@gtkx/gi\",\n \"@gtkx/jsx\",\n \"@gtkx/native\",\n \"@gtkx/react\",\n \"@gtkx/runtime\",\n // react-navigation is context-based: two bundled copies of core\n // fail with \"couldn't find a navigation context\".\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"react\",\n ],\n },\n }),\n\n async resolveId(source, importer) {\n const aliased = rewriteReactNativeImport(source)\n if (aliased !== null) {\n const resolved = await this.resolve(aliased, importer, { skipSelf: true })\n return resolved ?? aliased\n }\n return resolvePlatformSpecifier(source, importer, existsSync, options)\n },\n})\n\nexport default reactNativeGtkx\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,4BAA4B;AAC5B,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEjE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,mBAAmB,GAEpB,MAAM,qBAAqB,CAAA;AAE5B,0EAA0E;AAC1E,qCAAqC;AACrC,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,GACf,MAAM,qBAAqB,CAAA;AAsB5B,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAsB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;AAE/E,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AAE7C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAiB,EAAE,CACxE,YAAY,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA;AAE3C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAc,EACwB,EAAE;IACxC,MAAM,K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a gtkx project React Native compatible.\n// The gtkx CLI (dev and build) starts vite with an inline config that never\n// sets `configFile: false`, so vite picks up the project's vite.config.ts\n// from the root and merges it beneath the CLI config; this preset plugs in\n// there as a single plugin.\n//\n// vite loads the config's imported packages with BARE Node, so this subpath\n// (like ./metro and ./runner) must not contain EXTENSIONLESS relative imports\n// — the pure resolution helpers live here rather than in a sibling module,\n// and the one import that does cross a file boundary spells out its `.js`.\nimport { existsSync } from \"node:fs\"\nimport { dirname, extname, isAbsolute, resolve } from \"node:path\"\nimport type { Plugin } from \"vite\"\nimport {\n applyAliases,\n compileAliases,\n DEFAULT_ALIAS_TABLE,\n type AliasOverrides,\n} from \"../aliases/index.js\"\n\n// Re-exported so an app configuring `aliases` never has to reach past the\n// preset subpath it already imports.\nexport {\n CONFIGURABLE_ALIASES,\n DEFAULT_ALIASES,\n PLATFORM_ALIAS,\n} from \"../aliases/index.js\"\nexport type {\n AliasOverride,\n AliasOverrides,\n AliasPattern,\n AliasTable,\n CompiledAlias,\n} from \"../aliases/index.js\"\n\n// --- pure resolution logic (unit-tested directly) -----------------------\n\n/** Options shared by the preset factory and the pure resolver helpers. */\nexport type PlatformResolutionOptions = {\n /** Platform suffix priority, most specific first. Default: [\"linux\", \"native\"]. */\n platforms?: readonly string[]\n /** Source extensions tried for every platform suffix. Default: [\"tsx\", \"ts\", \"jsx\", \"js\"]. */\n extensions?: readonly string[]\n}\n\n/** Predicate the plugin injects as fs.existsSync; tests inject fakes. */\nexport type FileExists = (filePath: string) => boolean\n\nexport const DEFAULT_PLATFORMS: readonly string[] = [\"linux\", \"native\"]\nexport const DEFAULT_EXTENSIONS: readonly string[] = [\"tsx\", \"ts\", \"jsx\", \"js\"]\n\nconst REACT_NATIVE_GTKX = \"react-native-gtkx\"\n\n/**\n * Applies the DEFAULT alias table (../aliases/index.ts) to one specifier:\n * `react-native` and its subpaths onto `react-native-gtkx`, and the five\n * package substitutions onto their compat subpaths. Returns null for every\n * other specifier, including `react-native-gtkx` itself.\n *\n * Exported for tests and for apps driving vite by hand. The plugin does NOT\n * call it — the plugin resolves through the table its own `aliases` option\n * produced, so an app's deltas apply.\n */\nexport const rewriteReactNativeImport = (source: string): string | null =>\n applyAliases(DEFAULT_ALIAS_TABLE, source)\n\n/** Splits a vite specifier into its path part and its `?query` suffix. */\nexport const splitQuery = (\n source: string,\n): { specifier: string; query: string } => {\n const index = source.indexOf(\"?\")\n if (index === -1) {\n return { specifier: source, query: \"\" }\n }\n return { specifier: source.slice(0, index), query: source.slice(index) }\n}\n\nconst isRelative = (specifier: string): boolean =>\n specifier.startsWith(\"./\") || specifier.startsWith(\"../\")\n\n/**\n * Ordered platform suffixes, platform-major: every extension of the first\n * platform is tried before any extension of the next one\n * (`.linux.tsx`, `.linux.ts`, …, `.native.tsx`, …).\n */\nexport const platformSuffixes = (\n options: PlatformResolutionOptions = {},\n): string[] => {\n const platforms = options.platforms ?? DEFAULT_PLATFORMS\n const extensions = options.extensions ?? DEFAULT_EXTENSIONS\n return platforms.flatMap((platform) =>\n extensions.map((extension) => `.${platform}.${extension}`),\n )\n}\n\n/**\n * Candidate file paths for an extensionless base path, in priority order:\n * direct platform files first, then platform index files of a directory —\n * mirroring Metro, which exhausts file resolution before directory resolution.\n * The base file itself is not a candidate: when no platform file exists the\n * plugin bails out and the default resolver picks the base module.\n */\nexport const platformCandidates = (\n base: string,\n options: PlatformResolutionOptions = {},\n): string[] => {\n const suffixes = platformSuffixes(options)\n return [\n ...suffixes.map((suffix) => `${base}${suffix}`),\n ...suffixes.map((suffix) => `${base}/index${suffix}`),\n ]\n}\n\n// Source extensions Metro strips before trying platform variants: an\n// import of \"./useLinking.js\" (the TS-ESM style react-navigation and most\n// compiled RN libraries use) must still find useLinking.native.tsx /\n// useLinking.native.js — Metro resolves the BASE name platform-first, the\n// literal file is only the fallback.\nconst STRIPPABLE_EXTENSIONS = new Set([\".js\", \".jsx\", \".mjs\", \".ts\", \".tsx\"])\n\n/**\n * Metro platform-extension resolution for a single import: relative (or\n * absolute) specifiers that are extensionless — or carry a strippable\n * source extension — try platform candidates first; the first existing\n * candidate wins; the `?query` suffix is carried over. Returns null when\n * the import is out of scope or no platform file exists, handing the\n * import back to the default resolver.\n */\nexport const resolvePlatformSpecifier = (\n source: string,\n importer: string | undefined,\n exists: FileExists,\n options: PlatformResolutionOptions = {},\n): string | null => {\n if (importer === undefined || source.startsWith(\"\\0\")) {\n return null\n }\n const { specifier, query } = splitQuery(source)\n if (!isRelative(specifier) && !isAbsolute(specifier)) {\n return null\n }\n const extension = extname(specifier)\n if (extension !== \"\" && !STRIPPABLE_EXTENSIONS.has(extension)) {\n return null\n }\n const withExtension = isAbsolute(specifier)\n ? specifier\n : resolve(dirname(splitQuery(importer).specifier), specifier)\n const base =\n extension === \"\" ? withExtension : withExtension.slice(0, -extension.length)\n for (const candidate of platformCandidates(base, options)) {\n if (exists(candidate)) {\n return candidate + query\n }\n }\n return null\n}\n\n// --- the vite plugin ----------------------------------------------------\n\nexport type ReactNativeGtkxOptions = PlatformResolutionOptions & {\n /**\n * Deltas over the preset's package aliases, keyed by package name — a\n * string target, a `{ pattern, replace }` rule, or `false` to drop one of\n * ours so the real package loads. Identical semantics to the Metro\n * preset's option of the same name: both compile the same table.\n * Invalid entries throw here, while the config is being read.\n */\n aliases?: AliasOverrides\n}\n\n/**\n * Vite plugin: aliases `react-native` (and subpaths) to `react-native-gtkx`\n * and resolves Metro-style platform extensions\n * (`.linux.tsx` → `.native.tsx` → base) for extensionless imports.\n */\nexport const reactNativeGtkx = (\n options: ReactNativeGtkxOptions = {},\n): Plugin => {\n // Throws on an unknown key, an overlapping pattern or an attempt to remove\n // the platform alias — at config load, naming what is valid.\n const aliases = compileAliases(options.aliases)\n return {\n name: \"react-native-gtkx:preset\",\n // Before vite's own resolver and the gtkx CLI plugins: the alias must win\n // over node resolution and platform files must win over the base file.\n enforce: \"pre\",\n\n config: (_config, env) => ({\n // `__DEV__` is part of the react-native runtime contract, not a Metro\n // detail: RN's own modules branch on it and so does every library\n // written against them (`@gorhom/bottom-sheet`'s logger and four of its\n // components read it at module scope). The Metro path gets it from the\n // app's stock RN preset; nothing supplied it on the vite path, so a\n // library that reads it crashed the bundle at startup with\n // \"ReferenceError: __DEV__ is not defined\" — found by building\n // spike/core-exports rather than by reading anything.\n //\n // vite's mode is the honest source: `gtkx dev` builds in development,\n // `gtkx build` in production, which is exactly the distinction RN draws.\n define: {\n __DEV__: JSON.stringify(env.mode !== \"production\"),\n },\n ssr: {\n // `gtkx dev` runs vite with ssr.external: true, which would hand\n // react-native-gtkx straight to node. Keep the package inside the\n // vite pipeline; noExternal wins over external: true.\n //\n // \"react-native\" must be listed too: with ssr.external: true vite\n // externalizes a bare import BEFORE the plugin pipeline whenever the\n // package resolves natively — and the real react-native (a Flow\n // codebase Node cannot parse) exists in RN monorepos. noExternal\n // forces the full plugin resolution, where the alias rewrites the\n // import to react-native-gtkx.\n // \"react-native-reanimated\" for the same reason as \"react-native\": an\n // app that also ships iOS/Android keeps the real package installed, it\n // resolves natively, and ssr.external: true would hand Node a codebase\n // built around a Babel plugin and a worklet runtime before the alias\n // ever gets a chance to rewrite the import.\n // \"react-native-worklets\" is the same case one package over — it is\n // where that worklet runtime actually lives since Reanimated 4.\n //\n // The rule those are instances of, stated once so the next alias does\n // not have to rediscover it: EVERY package name in the alias table must\n // be listed here. An alias is a resolveId hook, and a bare specifier\n // that vite externalizes never reaches one — so on the dev path the\n // alias silently loses to whatever is installed under the real name.\n // That is not hypothetical: an app that also ships iOS and Android has\n // all of them in node_modules, which is the case the alias exists to\n // serve. `react-native-gesture-handler` proved it — this list once held\n // three of the six names, its real package loaded, and it failed on an\n // extensionless internal import Node cannot resolve (found by running\n // the gallery's upstream-libraries section, which installs it).\n //\n // So the list is DERIVED rather than written out: it is exactly the\n // table's package names, and a name can no longer go missing from one\n // of the two places it has to appear.\n //\n // `aliases.names` includes the packages an app turned OFF with `false`,\n // deliberately. Dropping an alias means the REAL package loads, and the\n // real package imports `react-native` at module scope — an import that\n // only reaches the platform alias if Node never gets the package first.\n // Un-aliasing a package is therefore a reason to keep it inside the\n // pipeline, not a reason to let it out.\n noExternal: [\n REACT_NATIVE_GTKX,\n ...aliases.names,\n // @react-navigation is not aliased, but must go through the pipeline\n // too: it imports `react-native`, and an externalized copy resolves\n // that to the real Flow package (SyntaxError: Unexpected token\n // 'typeof') instead of our alias. Only bites on the dev path — a\n // production build inlines everything anyway.\n /^@react-navigation\\//,\n ],\n },\n resolve: {\n // RC4-WORKAROUND(runtime-dedupe): see docs/gtkx-rc4-notes.md\n // The gtkx runtime and react are single-instance hosts: when the app\n // and react-native-gtkx resolve them from different node_modules\n // (file:-installed package, nested installs), two bundled copies\n // double-init the runtime and GLib aborts. dedupe pins every copy to\n // the project's own resolution.\n dedupe: [\n \"@gtkx/css\",\n \"@gtkx/gi\",\n \"@gtkx/jsx\",\n \"@gtkx/native\",\n \"@gtkx/react\",\n \"@gtkx/runtime\",\n // react-navigation is context-based: two bundled copies of core\n // fail with \"couldn't find a navigation context\".\n \"@react-navigation/core\",\n \"@react-navigation/native\",\n \"react\",\n ],\n },\n }),\n\n async resolveId(source, importer) {\n // The app's table, not the default one: a package dropped with `false`\n // falls through to vite's own resolution and the real package loads.\n const aliased = applyAliases(aliases, source)\n if (aliased !== null) {\n const resolved = await this.resolve(aliased, importer, {\n skipSelf: true,\n })\n return resolved ?? aliased\n }\n return resolvePlatformSpecifier(source, importer, existsSync, options)\n },\n }\n}\n\nexport default reactNativeGtkx\n"]}
@@ -1,4 +1,4 @@
1
- import type { GtkxPluginOptions } from "@gtkx/vitest";
1
+ import type { PluginOptions as GtkxPluginOptions } from "@gtkx/vitest";
2
2
  import type { UserWorkspaceConfig } from "vitest/config";
3
3
  import { type ReactNativeGtkxOptions } from "../vite/index.js";
4
4
  /**
@@ -26,7 +26,7 @@ export type ReactNativeGtkxTestOptions = {
26
26
  /**
27
27
  * Run this project's test files serially. Default: false — window-resize
28
28
  * signal delivery races when several per-worker headless compositors run
29
- * at once (see docs/gtkx-rc2-notes.md); the suite this recipe is proven
29
+ * at once (see docs/gtkx-rc4-notes.md); the suite this recipe is proven
30
30
  * on takes seconds, so serial execution is the cheap fix. Override once a
31
31
  * suite is large enough for parallelism to matter more than that race.
32
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vitest/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAwE;AACxE,uEAAuE;AACvE,mDAAmD;AACnD,EAAE;AACF,iEAAiE;AACjE,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,qEAAqE;AACrE,0EAA0E;AAC1E,sEAAsE;AACtE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAI7C,OAAO,EAAE,eAAe,EAA+B,MAAM,kBAAkB,CAAA;AAkC/E,MAAM,eAAe,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAClD,MAAM,mBAAmB,GAAwB,CAAC,mBAAmB,CAAC,CAAA;AACtE,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAExE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,UAAsC,EAAE,EACV,EAAE;IAChC,MAAM,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAA;IACnD,MAAM,OAAO,GAAa;QACxB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACtB,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;KAClC,CAAA;IACD,OAAO;QACL,OAAO;QACP,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;YAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,eAAe;YAC3C,UAAU,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YACvD,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,MAAM,EAAE,CAAC,GAAG,mBAAmB,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;iBAChE;aACF;YACD,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,KAAK;SAClD;KACF,CAAA;AACH,CAAC,CAAA;AAED,eAAe,mBAAmB,CAAA","sourcesContent":["// react-native-gtkx/vitest — the vitest recipe this repo's own test suite\n// runs on (see vitest.config.ts's \"gtk\" project), packaged for a consumer\n// app: the @gtkx/vitest headless-compositor plugin, the react-native-gtkx\n// vite preset (react-native alias + Metro-style platform extensions), a\n// default inline-deps list for RN libraries that import \"react-native\"\n// themselves, and the React act-environment setup.\n//\n// Self-contained like ./vite, ./metro and ./runner: a consumer's\n// vitest.config.ts is loaded the same way vite.config.ts is (vite's config\n// loader bundles only the user's own relative import graph; node_modules\n// imports stay bare specifiers, resolved afterwards by plain Node ESM) — so\n// this file must not contain extensionless relative imports. The one\n// relative import below carries an explicit \".js\" extension, which a real\n// sibling file on disk resolves under plain Node without any bundler.\nimport { fileURLToPath, URL } from \"node:url\"\nimport type { GtkxPluginOptions } from \"@gtkx/vitest\"\nimport type { Plugin } from \"vite\"\nimport type { UserWorkspaceConfig } from \"vitest/config\"\nimport { reactNativeGtkx, type ReactNativeGtkxOptions } from \"../vite/index.js\"\n\n/**\n * Options accepted by {@link reactNativeGtkxTest}. Every field is optional\n * and falls back to the recipe this repo's own test suite runs on.\n */\nexport type ReactNativeGtkxTestOptions = {\n /** Vitest project name. Default: \"gtk\". */\n name?: string\n /** Test file glob(s), relative to the project root. Default: `[\"**\\/*.gtk.test.{ts,tsx}\"]`. */\n include?: string[]\n /** Headless compositor size/compositor, forwarded to @gtkx/vitest's plugin. */\n headless?: GtkxPluginOptions\n /** Metro-style platform resolution options, forwarded to the vite preset. */\n platform?: ReactNativeGtkxOptions\n /**\n * Extra `server.deps.inline` patterns, merged after the default\n * (`/@react-navigation/`). Needed for any node_modules library that\n * itself imports \"react-native\" — Vitest externalizes node_modules code\n * by default, a path the react-native alias cannot reach.\n */\n inlineDeps?: (string | RegExp)[]\n /** Extra setup files, run after the built-in React act-environment setup. */\n setupFiles?: string[]\n /**\n * Run this project's test files serially. Default: false — window-resize\n * signal delivery races when several per-worker headless compositors run\n * at once (see docs/gtkx-rc2-notes.md); the suite this recipe is proven\n * on takes seconds, so serial execution is the cheap fix. Override once a\n * suite is large enough for parallelism to matter more than that race.\n */\n fileParallelism?: boolean\n}\n\nconst DEFAULT_INCLUDE = [\"**/*.gtk.test.{ts,tsx}\"]\nconst DEFAULT_INLINE_DEPS: (string | RegExp)[] = [/@react-navigation/]\nconst SETUP_FILE = fileURLToPath(new URL(\"./setup.js\", import.meta.url))\n\n/**\n * A ready Vitest project config for react-native-gtkx component tests: the\n * headless Wayland compositor, the react-native alias and platform\n * extensions, and the React act-environment setup — the same recipe this\n * repo's own suite runs on. Use the result as a whole config\n * (`defineConfig(reactNativeGtkxTest())`) or as one entry of\n * `test.projects` alongside a portable \"unit\" project.\n *\n * Requires a headless Wayland compositor on PATH (`sway` by default —\n * `apt install sway xwayland dbus`, see docs/getting-started.md) and\n * `gtkx codegen` to have already generated the project's `@gtkx/gi`\n * bindings — a bare `vitest run` does not trigger codegen itself, unlike\n * `gtkx dev`/`gtkx build`. A missing compositor or codegen store fails with\n * a readable error (e.g. `Cannot find the \"sway\" executable on PATH`), not\n * a hang.\n */\nexport const reactNativeGtkxTest = async (\n options: ReactNativeGtkxTestOptions = {},\n): Promise<UserWorkspaceConfig> => {\n const gtkx = (await import(\"@gtkx/vitest\")).default\n const plugins: Plugin[] = [\n gtkx(options.headless),\n reactNativeGtkx(options.platform),\n ]\n return {\n plugins,\n test: {\n name: options.name ?? \"gtk\",\n include: options.include ?? DEFAULT_INCLUDE,\n setupFiles: [SETUP_FILE, ...(options.setupFiles ?? [])],\n server: {\n deps: {\n inline: [...DEFAULT_INLINE_DEPS, ...(options.inlineDeps ?? [])],\n },\n },\n fileParallelism: options.fileParallelism ?? false,\n },\n }\n}\n\nexport default reactNativeGtkxTest\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vitest/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAwE;AACxE,uEAAuE;AACvE,mDAAmD;AACnD,EAAE;AACF,iEAAiE;AACjE,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,qEAAqE;AACrE,0EAA0E;AAC1E,sEAAsE;AACtE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAI7C,OAAO,EAAE,eAAe,EAA+B,MAAM,kBAAkB,CAAA;AAkC/E,MAAM,eAAe,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAClD,MAAM,mBAAmB,GAAwB,CAAC,mBAAmB,CAAC,CAAA;AACtE,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAExE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,UAAsC,EAAE,EACV,EAAE;IAChC,MAAM,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAA;IACnD,MAAM,OAAO,GAAa;QACxB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACtB,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;KAClC,CAAA;IACD,OAAO;QACL,OAAO;QACP,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;YAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,eAAe;YAC3C,UAAU,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YACvD,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,MAAM,EAAE,CAAC,GAAG,mBAAmB,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;iBAChE;aACF;YACD,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,KAAK;SAClD;KACF,CAAA;AACH,CAAC,CAAA;AAED,eAAe,mBAAmB,CAAA","sourcesContent":["// react-native-gtkx/vitest — the vitest recipe this repo's own test suite\n// runs on (see vitest.config.ts's \"gtk\" project), packaged for a consumer\n// app: the @gtkx/vitest headless-compositor plugin, the react-native-gtkx\n// vite preset (react-native alias + Metro-style platform extensions), a\n// default inline-deps list for RN libraries that import \"react-native\"\n// themselves, and the React act-environment setup.\n//\n// Self-contained like ./vite, ./metro and ./runner: a consumer's\n// vitest.config.ts is loaded the same way vite.config.ts is (vite's config\n// loader bundles only the user's own relative import graph; node_modules\n// imports stay bare specifiers, resolved afterwards by plain Node ESM) — so\n// this file must not contain extensionless relative imports. The one\n// relative import below carries an explicit \".js\" extension, which a real\n// sibling file on disk resolves under plain Node without any bundler.\nimport { fileURLToPath, URL } from \"node:url\"\nimport type { PluginOptions as GtkxPluginOptions } from \"@gtkx/vitest\"\nimport type { Plugin } from \"vite\"\nimport type { UserWorkspaceConfig } from \"vitest/config\"\nimport { reactNativeGtkx, type ReactNativeGtkxOptions } from \"../vite/index.js\"\n\n/**\n * Options accepted by {@link reactNativeGtkxTest}. Every field is optional\n * and falls back to the recipe this repo's own test suite runs on.\n */\nexport type ReactNativeGtkxTestOptions = {\n /** Vitest project name. Default: \"gtk\". */\n name?: string\n /** Test file glob(s), relative to the project root. Default: `[\"**\\/*.gtk.test.{ts,tsx}\"]`. */\n include?: string[]\n /** Headless compositor size/compositor, forwarded to @gtkx/vitest's plugin. */\n headless?: GtkxPluginOptions\n /** Metro-style platform resolution options, forwarded to the vite preset. */\n platform?: ReactNativeGtkxOptions\n /**\n * Extra `server.deps.inline` patterns, merged after the default\n * (`/@react-navigation/`). Needed for any node_modules library that\n * itself imports \"react-native\" — Vitest externalizes node_modules code\n * by default, a path the react-native alias cannot reach.\n */\n inlineDeps?: (string | RegExp)[]\n /** Extra setup files, run after the built-in React act-environment setup. */\n setupFiles?: string[]\n /**\n * Run this project's test files serially. Default: false — window-resize\n * signal delivery races when several per-worker headless compositors run\n * at once (see docs/gtkx-rc4-notes.md); the suite this recipe is proven\n * on takes seconds, so serial execution is the cheap fix. Override once a\n * suite is large enough for parallelism to matter more than that race.\n */\n fileParallelism?: boolean\n}\n\nconst DEFAULT_INCLUDE = [\"**/*.gtk.test.{ts,tsx}\"]\nconst DEFAULT_INLINE_DEPS: (string | RegExp)[] = [/@react-navigation/]\nconst SETUP_FILE = fileURLToPath(new URL(\"./setup.js\", import.meta.url))\n\n/**\n * A ready Vitest project config for react-native-gtkx component tests: the\n * headless Wayland compositor, the react-native alias and platform\n * extensions, and the React act-environment setup — the same recipe this\n * repo's own suite runs on. Use the result as a whole config\n * (`defineConfig(reactNativeGtkxTest())`) or as one entry of\n * `test.projects` alongside a portable \"unit\" project.\n *\n * Requires a headless Wayland compositor on PATH (`sway` by default —\n * `apt install sway xwayland dbus`, see docs/getting-started.md) and\n * `gtkx codegen` to have already generated the project's `@gtkx/gi`\n * bindings — a bare `vitest run` does not trigger codegen itself, unlike\n * `gtkx dev`/`gtkx build`. A missing compositor or codegen store fails with\n * a readable error (e.g. `Cannot find the \"sway\" executable on PATH`), not\n * a hang.\n */\nexport const reactNativeGtkxTest = async (\n options: ReactNativeGtkxTestOptions = {},\n): Promise<UserWorkspaceConfig> => {\n const gtkx = (await import(\"@gtkx/vitest\")).default\n const plugins: Plugin[] = [\n gtkx(options.headless),\n reactNativeGtkx(options.platform),\n ]\n return {\n plugins,\n test: {\n name: options.name ?? \"gtk\",\n include: options.include ?? DEFAULT_INCLUDE,\n setupFiles: [SETUP_FILE, ...(options.setupFiles ?? [])],\n server: {\n deps: {\n inline: [...DEFAULT_INLINE_DEPS, ...(options.inlineDeps ?? [])],\n },\n },\n fileParallelism: options.fileParallelism ?? false,\n },\n }\n}\n\nexport default reactNativeGtkxTest\n"]}
@@ -0,0 +1,4 @@
1
+ declare const runOnUI: <A extends unknown[]>(worklet: (...args: A) => unknown) => (...args: A) => void, scheduleOnUI: <A extends unknown[]>(worklet: (...args: A) => unknown, ...args: A) => void, runOnJS: <A extends unknown[]>(fn: (...args: A) => unknown) => (...args: A) => void, scheduleOnRN: <A extends unknown[]>(fn: (...args: A) => unknown, ...args: A) => void, runOnUIAsync: <A extends unknown[], R>(worklet: (...args: A) => R, ...args: A) => Promise<R>;
2
+ export { runOnJS, runOnUI, runOnUIAsync, scheduleOnRN, scheduleOnUI };
3
+ export { callMicrotasks, createSerializable, createShareable, createSynchronizable, createWorkletRuntime, executeOnUIRuntimeSync, getDynamicFeatureFlag, getRuntimeKind, getStaticFeatureFlag, getUIRuntimeHolder, getUISchedulerHolder, isBundleModeEnabled, isRNRuntime, isSerializableRef, isShareable, isShareableRef, isSynchronizable, isUIRuntime, isWorkerRuntime, isWorkletFunction, isWorkletRuntime, makeShareable, makeShareableCloneOnUIRecursive, makeShareableCloneRecursive, registerCustomSerializable, runOnRuntime, runOnRuntimeAsync, runOnRuntimeAsyncWithId, runOnRuntimeSync, runOnRuntimeSyncWithId, RuntimeKind, runOnUISync, scheduleOnRuntime, scheduleOnRuntimeWithId, serializableMappingCache, setDynamicFeatureFlag, shareableMappingCache, toggleSlowAnimationsOnUIRuntime, UIRuntimeId, WorkletsModule, } from "./surface";
4
+ export type { SerializableRef, ShareableRef, WorkletFunction, WorkletRuntime, } from "./surface";
@@ -0,0 +1,28 @@
1
+ // react-native-gtkx/worklets — the `react-native-worklets` name, on a
2
+ // platform with one thread.
3
+ //
4
+ // Reanimated 4 moved the worklet surface into its own package, and libraries
5
+ // import it under that name rather than through Reanimated. That is not a
6
+ // detail: `react-native-reanimated-dnd` 2.0.0 pulls `scheduleOnRN` and
7
+ // `scheduleOnUI` out of it at module scope in five of its hooks
8
+ // (useDraggable, useDroppable, useSortable, useHorizontalSortable,
9
+ // useGridSortable) with no `try { require } catch` anywhere, so an unaliased
10
+ // package name fails at IMPORT rather than at use. Aliasing
11
+ // `react-native-reanimated` alone left that wall standing one package over.
12
+ //
13
+ // The surface itself already existed — this module adds the NAME. Both
14
+ // presets alias the package onto it (src/vite/index.ts, src/metro/index.ts),
15
+ // and the thread functions are the very same instance the Reanimated surface
16
+ // exports, so `scheduleOnUI` reached through either package name queues into
17
+ // one batch. Upstream has the same property for the same reason: Reanimated
18
+ // re-exports them from here.
19
+ //
20
+ // What is implemented and what refuses is decided by upstream's own
21
+ // non-native build rather than by us — see surface.ts, which is also where
22
+ // everything that needs no clock lives so unit tests can reach it without
23
+ // GTK. docs/api.md records the boundary.
24
+ import { createWorkletsSurface } from "./surface";
25
+ const { runOnUI, scheduleOnUI, runOnJS, scheduleOnRN, runOnUIAsync } = createWorkletsSurface();
26
+ export { runOnJS, runOnUI, runOnUIAsync, scheduleOnRN, scheduleOnUI };
27
+ export { callMicrotasks, createSerializable, createShareable, createSynchronizable, createWorkletRuntime, executeOnUIRuntimeSync, getDynamicFeatureFlag, getRuntimeKind, getStaticFeatureFlag, getUIRuntimeHolder, getUISchedulerHolder, isBundleModeEnabled, isRNRuntime, isSerializableRef, isShareable, isShareableRef, isSynchronizable, isUIRuntime, isWorkerRuntime, isWorkletFunction, isWorkletRuntime, makeShareable, makeShareableCloneOnUIRecursive, makeShareableCloneRecursive, registerCustomSerializable, runOnRuntime, runOnRuntimeAsync, runOnRuntimeAsyncWithId, runOnRuntimeSync, runOnRuntimeSyncWithId, RuntimeKind, runOnUISync, scheduleOnRuntime, scheduleOnRuntimeWithId, serializableMappingCache, setDynamicFeatureFlag, shareableMappingCache, toggleSlowAnimationsOnUIRuntime, UIRuntimeId, WorkletsModule, } from "./surface";
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/worklets-compat/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,4BAA4B;AAC5B,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,uEAAuE;AACvE,gEAAgE;AAChE,mEAAmE;AACnE,6EAA6E;AAC7E,4DAA4D;AAC5D,4EAA4E;AAC5E,EAAE;AACF,uEAAuE;AACvE,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,6BAA6B;AAC7B,EAAE;AACF,oEAAoE;AACpE,2EAA2E;AAC3E,0EAA0E;AAC1E,yCAAyC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAEjD,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,GAClE,qBAAqB,EAAE,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAA;AAErE,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,+BAA+B,EAC/B,2BAA2B,EAC3B,0BAA0B,EAC1B,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,WAAW,EACX,cAAc,GACf,MAAM,WAAW,CAAA","sourcesContent":["// react-native-gtkx/worklets — the `react-native-worklets` name, on a\n// platform with one thread.\n//\n// Reanimated 4 moved the worklet surface into its own package, and libraries\n// import it under that name rather than through Reanimated. That is not a\n// detail: `react-native-reanimated-dnd` 2.0.0 pulls `scheduleOnRN` and\n// `scheduleOnUI` out of it at module scope in five of its hooks\n// (useDraggable, useDroppable, useSortable, useHorizontalSortable,\n// useGridSortable) with no `try { require } catch` anywhere, so an unaliased\n// package name fails at IMPORT rather than at use. Aliasing\n// `react-native-reanimated` alone left that wall standing one package over.\n//\n// The surface itself already existed — this module adds the NAME. Both\n// presets alias the package onto it (src/vite/index.ts, src/metro/index.ts),\n// and the thread functions are the very same instance the Reanimated surface\n// exports, so `scheduleOnUI` reached through either package name queues into\n// one batch. Upstream has the same property for the same reason: Reanimated\n// re-exports them from here.\n//\n// What is implemented and what refuses is decided by upstream's own\n// non-native build rather than by us — see surface.ts, which is also where\n// everything that needs no clock lives so unit tests can reach it without\n// GTK. docs/api.md records the boundary.\nimport { createWorkletsSurface } from \"./surface\"\n\nconst { runOnUI, scheduleOnUI, runOnJS, scheduleOnRN, runOnUIAsync } =\n createWorkletsSurface()\n\nexport { runOnJS, runOnUI, runOnUIAsync, scheduleOnRN, scheduleOnUI }\n\nexport {\n callMicrotasks,\n createSerializable,\n createShareable,\n createSynchronizable,\n createWorkletRuntime,\n executeOnUIRuntimeSync,\n getDynamicFeatureFlag,\n getRuntimeKind,\n getStaticFeatureFlag,\n getUIRuntimeHolder,\n getUISchedulerHolder,\n isBundleModeEnabled,\n isRNRuntime,\n isSerializableRef,\n isShareable,\n isShareableRef,\n isSynchronizable,\n isUIRuntime,\n isWorkerRuntime,\n isWorkletFunction,\n isWorkletRuntime,\n makeShareable,\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n registerCustomSerializable,\n runOnRuntime,\n runOnRuntimeAsync,\n runOnRuntimeAsyncWithId,\n runOnRuntimeSync,\n runOnRuntimeSyncWithId,\n RuntimeKind,\n runOnUISync,\n scheduleOnRuntime,\n scheduleOnRuntimeWithId,\n serializableMappingCache,\n setDynamicFeatureFlag,\n shareableMappingCache,\n toggleSlowAnimationsOnUIRuntime,\n UIRuntimeId,\n WorkletsModule,\n} from \"./surface\"\n\nexport type {\n SerializableRef,\n ShareableRef,\n WorkletFunction,\n WorkletRuntime,\n} from \"./surface\"\n"]}
@@ -0,0 +1,110 @@
1
+ /** A function the Babel plugin processed. Never produced on this platform. */
2
+ export type WorkletFunction<Args extends unknown[] = unknown[], ReturnValue = unknown> = ((...args: Args) => ReturnValue) & {
3
+ __workletHash?: number;
4
+ };
5
+ /** Upstream's handle for a runtime that cannot exist here — see the refusals. */
6
+ export type WorkletRuntime = {
7
+ __workletRuntime: true;
8
+ };
9
+ /** Upstream's serializer handle. Identity here: nothing leaves this runtime. */
10
+ export type SerializableRef<T = unknown> = T;
11
+ /** @deprecated Upstream's former name for {@link SerializableRef}. */
12
+ export type ShareableRef<T = unknown> = SerializableRef<T>;
13
+ /**
14
+ * The thread surface. `runOnUI`/`runOnJS`/`scheduleOnUI`/`scheduleOnRN` come
15
+ * from the same `createThreads` the Reanimated surface uses — index.ts hands
16
+ * both modules the SAME instance, so a job queued through either name lands
17
+ * in the same batch, as it does upstream where one package re-exports the
18
+ * other.
19
+ */
20
+ export declare const createWorkletsSurface: () => {
21
+ runOnUIAsync: <A extends unknown[], R>(worklet: (...args: A) => R, ...args: A) => Promise<R>;
22
+ runOnUI: <A extends unknown[]>(worklet: (...args: A) => unknown) => (...args: A) => void;
23
+ scheduleOnUI: <A extends unknown[]>(worklet: (...args: A) => unknown, ...args: A) => void;
24
+ runOnJS: <A extends unknown[]>(fn: (...args: A) => unknown) => (...args: A) => void;
25
+ scheduleOnRN: <A extends unknown[]>(fn: (...args: A) => unknown, ...args: A) => void;
26
+ };
27
+ export { isWorkletFunction } from "../reanimated-compat/threads";
28
+ /**
29
+ * Upstream's runtime taxonomy. There is one runtime here and it is the React
30
+ * Native one — GTK's main loop IS the JS thread — which is exactly what
31
+ * upstream's non-native path reports too: its initializer sets
32
+ * `__RUNTIME_KIND` to `ReactNative` and never changes it.
33
+ */
34
+ export declare enum RuntimeKind {
35
+ ReactNative = 1,
36
+ UI = 2,
37
+ Worker = 3
38
+ }
39
+ export declare const getRuntimeKind: () => RuntimeKind;
40
+ export declare const isRNRuntime: () => boolean;
41
+ export declare const isUIRuntime: () => boolean;
42
+ export declare const isWorkerRuntime: () => boolean;
43
+ export declare const isWorkletRuntime: () => boolean;
44
+ /** Mirrored as data, as upstream's non-native `runtimes.ts` does. */
45
+ export declare const UIRuntimeId: number;
46
+ /**
47
+ * The serializer, which on a single-runtime path is a file of identity
48
+ * functions — a value never leaves the runtime it was made in, so there is
49
+ * nothing to clone and nothing to register.
50
+ */
51
+ export declare const createSerializable: <T>(value: T) => SerializableRef<T>;
52
+ export declare const isSerializableRef: (value: unknown) => boolean;
53
+ export declare const registerCustomSerializable: (registration: unknown) => void;
54
+ export declare const makeShareable: <T>(value: T) => T;
55
+ export declare const makeShareableCloneRecursive: <T>(value: T) => SerializableRef<T>;
56
+ export declare const makeShareableCloneOnUIRecursive: <T>(value: T) => SerializableRef<T>;
57
+ /** @deprecated Upstream's former name for {@link isSerializableRef}. */
58
+ export declare const isShareableRef: (value: unknown) => boolean;
59
+ /** The mapping cache upstream keeps for the serializer, which has nothing to map. */
60
+ export declare const serializableMappingCache: {
61
+ set(serializable: object, ref?: unknown): void;
62
+ get(key: object): unknown;
63
+ };
64
+ /** @deprecated Upstream's former name for {@link serializableMappingCache}. */
65
+ export declare const shareableMappingCache: {
66
+ set(serializable: object, ref?: unknown): void;
67
+ get(key: object): unknown;
68
+ };
69
+ /** Deprecated and a documented no-op upstream, kept callable for source parity. */
70
+ export declare const callMicrotasks: () => void;
71
+ /** Structural checks, portable exactly as upstream writes them. */
72
+ export declare const isShareable: (value: unknown) => boolean;
73
+ export declare const isSynchronizable: (value: unknown) => boolean;
74
+ /**
75
+ * Bundle mode is a Babel/Metro transform of upstream's own plugin, which this
76
+ * platform never runs — so the honest answer is upstream's non-native one.
77
+ */
78
+ export declare const isBundleModeEnabled: () => boolean;
79
+ /** A debug toggle for the UI runtime's clock, which is this platform's only clock. */
80
+ export declare const toggleSlowAnimationsOnUIRuntime: () => boolean;
81
+ /**
82
+ * Feature flags gate upstream's own native experiments. None of them exist
83
+ * here, so every flag reads false and setting one changes nothing — again
84
+ * upstream's non-native answer rather than an invention.
85
+ */
86
+ export declare const getStaticFeatureFlag: (name: string) => boolean;
87
+ export declare const getDynamicFeatureFlag: (name: string) => boolean;
88
+ export declare const setDynamicFeatureFlag: (name: string, value: boolean) => void;
89
+ export declare const createWorkletRuntime: any;
90
+ export declare const runOnRuntime: any;
91
+ export declare const runOnRuntimeAsync: any;
92
+ export declare const runOnRuntimeAsyncWithId: any;
93
+ export declare const runOnRuntimeSync: any;
94
+ export declare const runOnRuntimeSyncWithId: any;
95
+ export declare const scheduleOnRuntime: any;
96
+ export declare const scheduleOnRuntimeWithId: any;
97
+ export declare const getUIRuntimeHolder: any;
98
+ export declare const getUISchedulerHolder: any;
99
+ export declare const runOnUISync: any;
100
+ export declare const executeOnUIRuntimeSync: any;
101
+ export declare const createShareable: any;
102
+ export declare const createSynchronizable: any;
103
+ /**
104
+ * The TurboModule behind the whole package. Upstream's non-native build
105
+ * exports it as `null`, which fails as "cannot read properties of null" and
106
+ * names nothing; this refuses by name instead. The one deliberate deviation
107
+ * from the mirror rule above, and it can only ever turn a worse error into a
108
+ * better one — nothing that works against `null` works against a refusal.
109
+ */
110
+ export declare const WorkletsModule: any;