@lynx-js/react 0.128.0 → 0.129.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 (334) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +3 -4
  4. package/refresh/.turbo/turbo-build.log +1 -1
  5. package/runtime/__test__/core/entry-re-eval.test.ts +161 -0
  6. package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
  7. package/runtime/__test__/core/reload-scoped-dual-thread-communication.test.ts +129 -0
  8. package/runtime/__test__/core/thread-function-call.test.ts +1 -0
  9. package/runtime/__test__/element-template/fixtures/background/render/_shared.tsx +2 -0
  10. package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
  11. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
  12. package/runtime/__test__/element-template/native/index.test.ts +8 -0
  13. package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
  14. package/runtime/__test__/element-template/native/main-thread-ref-init-value.test.ts +100 -0
  15. package/runtime/__test__/element-template/native/mts-destroy.test.ts +83 -0
  16. package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +104 -0
  17. package/runtime/__test__/element-template/native/reload.test.ts +79 -1
  18. package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +104 -47
  19. package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +7 -1
  20. package/runtime/__test__/element-template/runtime/background/re-eval-reload.test.ts +69 -0
  21. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
  22. package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +31 -5
  23. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +214 -10
  24. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
  25. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
  26. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
  27. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
  28. package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +2 -0
  29. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
  30. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +121 -26
  31. package/runtime/__test__/element-template/runtime/template/main-thread-function.test.ts +89 -2
  32. package/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts +5 -0
  33. package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
  34. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
  35. package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
  36. package/runtime/__test__/shared/component-stack.test.ts +211 -0
  37. package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
  38. package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
  39. package/runtime/__test__/snapshot/lifecycle/re-eval-reload.test.jsx +114 -0
  40. package/runtime/__test__/snapshot/lifecycle/reload-background-function.test.jsx +169 -0
  41. package/runtime/__test__/snapshot/lifecycle/reload-delayed-background.test.jsx +63 -0
  42. package/runtime/__test__/snapshot/lifecycle/reload-delayed-main-thread.test.jsx +103 -0
  43. package/runtime/__test__/snapshot/lifecycle.test.jsx +61 -1
  44. package/runtime/__test__/snapshot/lynx/lazy-effect-scheduling.test.jsx +105 -0
  45. package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
  46. package/runtime/__test__/snapshot/preact.test.jsx +0 -3
  47. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
  48. package/runtime/__test__/snapshot/ssr.test.jsx +2 -2
  49. package/runtime/__test__/snapshot/worklet/runOnBackground.test.js +6 -11
  50. package/runtime/__test__/snapshot/worklet/runOnMainThread.test.jsx +1 -1
  51. package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +24 -1
  52. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +27 -1
  53. package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
  54. package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +46 -0
  55. package/runtime/__test__/worklet-runtime/runOnMainThread.test.js +3 -3
  56. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
  57. package/runtime/lazy/element-template-internal.js +0 -1
  58. package/runtime/lazy/internal.js +1 -1
  59. package/runtime/lazy/jsx-dev-runtime.js +1 -1
  60. package/runtime/lazy/jsx-runtime.js +1 -1
  61. package/runtime/lazy/legacy-react-runtime.js +1 -1
  62. package/runtime/lazy/react-lepus.js +1 -1
  63. package/runtime/lazy/react.js +1 -1
  64. package/runtime/lib/core/background-function/exec-map.d.ts +2 -0
  65. package/runtime/lib/core/background-function/exec-map.js +7 -0
  66. package/runtime/lib/core/background-function/exec-map.js.map +1 -1
  67. package/runtime/lib/core/background-function/run-on-background.js +15 -16
  68. package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
  69. package/runtime/lib/core/capture-main-thread-object.js +2 -1
  70. package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
  71. package/runtime/lib/core/card-lifetime.d.ts +5 -0
  72. package/runtime/lib/core/card-lifetime.js +17 -0
  73. package/runtime/lib/core/card-lifetime.js.map +1 -0
  74. package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
  75. package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
  76. package/runtime/lib/core/entry-reload.d.ts +7 -0
  77. package/runtime/lib/core/entry-reload.js +49 -0
  78. package/runtime/lib/core/entry-reload.js.map +1 -0
  79. package/runtime/lib/core/lynx/lazy-bundle.js +5 -2
  80. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  81. package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
  82. package/runtime/lib/core/lynx-data-processors.js +3 -0
  83. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  84. package/runtime/lib/core/main-thread-ref-id.js +4 -4
  85. package/runtime/lib/core/main-thread-ref-id.js.map +1 -1
  86. package/runtime/lib/core/reload-scoped-event.d.ts +5 -0
  87. package/runtime/lib/core/reload-scoped-event.js +26 -0
  88. package/runtime/lib/core/reload-scoped-event.js.map +1 -0
  89. package/runtime/lib/core/reload-version.js +4 -3
  90. package/runtime/lib/core/reload-version.js.map +1 -1
  91. package/runtime/lib/core/runtime-destroy.d.ts +2 -0
  92. package/runtime/lib/core/runtime-destroy.js +10 -1
  93. package/runtime/lib/core/runtime-destroy.js.map +1 -1
  94. package/runtime/lib/core/thread-function-call/main-thread.js +5 -4
  95. package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
  96. package/runtime/lib/core/thread-function-call/return-value.js +6 -5
  97. package/runtime/lib/core/thread-function-call/return-value.js.map +1 -1
  98. package/runtime/lib/document.js +0 -5
  99. package/runtime/lib/document.js.map +1 -1
  100. package/runtime/lib/element-template/background/commit-hook.js +24 -22
  101. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  102. package/runtime/lib/element-template/background/hydration-listener.js +2 -6
  103. package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
  104. package/runtime/lib/element-template/client/root.d.ts +1 -1
  105. package/runtime/lib/element-template/client/root.js.map +1 -1
  106. package/runtime/lib/element-template/index.d.ts +2 -2
  107. package/runtime/lib/element-template/index.js.map +1 -1
  108. package/runtime/lib/element-template/internal.d.ts +1 -1
  109. package/runtime/lib/element-template/internal.js +0 -13
  110. package/runtime/lib/element-template/internal.js.map +1 -1
  111. package/runtime/lib/element-template/lynx/env.js.map +1 -1
  112. package/runtime/lib/element-template/main-thread-ref-init-value.d.ts +3 -0
  113. package/runtime/lib/element-template/main-thread-ref-init-value.js +38 -0
  114. package/runtime/lib/element-template/main-thread-ref-init-value.js.map +1 -0
  115. package/runtime/lib/element-template/native/flush.d.ts +1 -0
  116. package/runtime/lib/element-template/native/flush.js +9 -0
  117. package/runtime/lib/element-template/native/flush.js.map +1 -0
  118. package/runtime/lib/element-template/native/index.js +2 -0
  119. package/runtime/lib/element-template/native/index.js.map +1 -1
  120. package/runtime/lib/element-template/native/main-thread-api.js +3 -7
  121. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
  122. package/runtime/lib/element-template/native/mts-destroy.js +10 -2
  123. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
  124. package/runtime/lib/element-template/native/patch-listener.js +58 -54
  125. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  126. package/runtime/lib/element-template/native/reload-background.d.ts +1 -1
  127. package/runtime/lib/element-template/native/reload-background.js +12 -1
  128. package/runtime/lib/element-template/native/reload-background.js.map +1 -1
  129. package/runtime/lib/element-template/native/reload-main-thread.d.ts +6 -0
  130. package/runtime/lib/element-template/native/reload-main-thread.js +20 -3
  131. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  132. package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +2 -1
  133. package/runtime/lib/element-template/protocol/lifecycle-constant.js +1 -0
  134. package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -1
  135. package/runtime/lib/element-template/protocol/types.d.ts +0 -2
  136. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  137. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
  138. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
  139. package/runtime/lib/element-template/runtime/patch.js +4 -0
  140. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  141. package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
  142. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
  143. package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
  144. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  145. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
  146. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
  147. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +1 -0
  148. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +41 -21
  149. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  150. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +1 -1
  151. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  152. package/runtime/lib/internal.d.ts +1 -1
  153. package/runtime/lib/internal.js +1 -1
  154. package/runtime/lib/internal.js.map +1 -1
  155. package/runtime/lib/lynx-api.d.ts +2 -125
  156. package/runtime/lib/lynx-api.js.map +1 -1
  157. package/runtime/lib/shared/component-stack.d.ts +0 -4
  158. package/runtime/lib/shared/component-stack.js +21 -5
  159. package/runtime/lib/shared/component-stack.js.map +1 -1
  160. package/runtime/lib/shared/index-map.d.ts +4 -1
  161. package/runtime/lib/shared/index-map.js +5 -2
  162. package/runtime/lib/shared/index-map.js.map +1 -1
  163. package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
  164. package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
  165. package/runtime/lib/snapshot/lifecycle/destroy.js +6 -0
  166. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  167. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.d.ts +6 -2
  168. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js +21 -18
  169. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -1
  170. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
  171. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
  172. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
  173. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
  174. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  175. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
  176. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  177. package/runtime/lib/snapshot/lifecycle/reload.d.ts +9 -2
  178. package/runtime/lib/snapshot/lifecycle/reload.js +29 -8
  179. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  180. package/runtime/lib/snapshot/list/list.js +3 -2
  181. package/runtime/lib/snapshot/list/list.js.map +1 -1
  182. package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
  183. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  184. package/runtime/lib/snapshot/lynx/calledByNative.js +14 -11
  185. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  186. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
  187. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  188. package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
  189. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  190. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
  191. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  192. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
  193. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  194. package/runtime/lib/snapshot/snapshot/list.js +2 -1
  195. package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
  196. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.d.ts +4 -2
  197. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js +11 -11
  198. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -1
  199. package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +1 -0
  200. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +6 -1
  201. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
  202. package/runtime/lib/snapshot/worklet/ctx.d.ts +1 -1
  203. package/runtime/lib/snapshot/worklet/ctx.js +6 -1
  204. package/runtime/lib/snapshot/worklet/ctx.js.map +1 -1
  205. package/runtime/lib/snapshot/worklet/ref/updateInitValue.js +6 -0
  206. package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
  207. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  208. package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
  209. package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
  210. package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
  211. package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
  212. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
  213. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
  214. package/runtime/lib/worklet-runtime/delayRunOnBackground.js +3 -1
  215. package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +1 -1
  216. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
  217. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +8 -1
  218. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  219. package/runtime/lib/worklet-runtime/listeners.js +2 -2
  220. package/runtime/lib/worklet-runtime/listeners.js.map +1 -1
  221. package/runtime/lib/worklet-runtime/mainThreadObject.js +3 -1
  222. package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -1
  223. package/runtime/lib/worklet-runtime/runOnMainThread.js +4 -3
  224. package/runtime/lib/worklet-runtime/runOnMainThread.js.map +1 -1
  225. package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
  226. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  227. package/runtime/package.json +2 -3
  228. package/runtime/src/core/background-function/exec-map.ts +9 -0
  229. package/runtime/src/core/background-function/run-on-background.ts +14 -16
  230. package/runtime/src/core/capture-main-thread-object.ts +2 -1
  231. package/runtime/src/core/card-lifetime.ts +18 -0
  232. package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
  233. package/runtime/src/core/entry-reload.ts +63 -0
  234. package/runtime/src/core/lynx/lazy-bundle.ts +5 -2
  235. package/runtime/src/core/lynx-data-processors.ts +124 -1
  236. package/runtime/src/core/main-thread-ref-id.ts +5 -4
  237. package/runtime/src/core/reload-scoped-event.ts +35 -0
  238. package/runtime/src/core/reload-version.ts +5 -3
  239. package/runtime/src/core/runtime-destroy.ts +12 -1
  240. package/runtime/src/core/thread-function-call/main-thread.ts +4 -4
  241. package/runtime/src/core/thread-function-call/return-value.ts +6 -5
  242. package/runtime/src/document.ts +0 -6
  243. package/runtime/src/element-template/background/commit-hook.ts +32 -23
  244. package/runtime/src/element-template/background/hydration-listener.ts +2 -6
  245. package/runtime/src/element-template/client/root.ts +1 -3
  246. package/runtime/src/element-template/index.ts +2 -2
  247. package/runtime/src/element-template/internal.ts +0 -20
  248. package/runtime/src/element-template/lynx/env.ts +1 -1
  249. package/runtime/src/element-template/main-thread-ref-init-value.ts +44 -0
  250. package/runtime/src/element-template/native/flush.ts +10 -0
  251. package/runtime/src/element-template/native/index.ts +2 -0
  252. package/runtime/src/element-template/native/main-thread-api.ts +3 -6
  253. package/runtime/src/element-template/native/mts-destroy.ts +10 -2
  254. package/runtime/src/element-template/native/patch-listener.ts +62 -62
  255. package/runtime/src/element-template/native/reload-background.ts +13 -1
  256. package/runtime/src/element-template/native/reload-main-thread.ts +32 -3
  257. package/runtime/src/element-template/protocol/lifecycle-constant.ts +1 -0
  258. package/runtime/src/element-template/protocol/types.ts +0 -15
  259. package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
  260. package/runtime/src/element-template/runtime/patch.ts +5 -0
  261. package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
  262. package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
  263. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
  264. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +51 -21
  265. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +2 -2
  266. package/runtime/src/element-template/types.d.ts +6 -0
  267. package/runtime/src/internal.ts +1 -1
  268. package/runtime/src/lynx-api.ts +2 -124
  269. package/runtime/src/shared/component-stack.ts +22 -5
  270. package/runtime/src/shared/index-map.ts +3 -2
  271. package/runtime/src/snapshot/lifecycle/destroy.ts +7 -0
  272. package/runtime/src/snapshot/lifecycle/event/firstScreenSync.ts +26 -19
  273. package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
  274. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
  275. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
  276. package/runtime/src/snapshot/lifecycle/reload.ts +47 -11
  277. package/runtime/src/snapshot/list/list.ts +9 -2
  278. package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
  279. package/runtime/src/snapshot/lynx/calledByNative.ts +14 -13
  280. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
  281. package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
  282. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
  283. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
  284. package/runtime/src/snapshot/snapshot/list.ts +5 -1
  285. package/runtime/src/snapshot/snapshot/snapshotInstanceManager.ts +19 -12
  286. package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +10 -1
  287. package/runtime/src/snapshot/worklet/ctx.ts +10 -1
  288. package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +6 -0
  289. package/runtime/src/worklet-runtime/README.md +33 -0
  290. package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
  291. package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
  292. package/runtime/src/worklet-runtime/delayRunOnBackground.ts +3 -1
  293. package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +8 -1
  294. package/runtime/src/worklet-runtime/listeners.ts +4 -7
  295. package/runtime/src/worklet-runtime/mainThreadObject.ts +2 -1
  296. package/runtime/src/worklet-runtime/runOnMainThread.ts +4 -3
  297. package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
  298. package/runtime/types/types.d.ts +3 -1
  299. package/runtime/vitest.config.ts +0 -2
  300. package/testing-library/.turbo/turbo-build.log +7 -7
  301. package/testing-library/src/__tests__/act.test.jsx +0 -7
  302. package/testing-library/src/__tests__/alog.test.jsx +12 -54
  303. package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
  304. package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
  305. package/testing-library/src/__tests__/worklet.test.jsx +59 -5
  306. package/transform/.turbo/turbo-build$colon$wasm.log +63 -136
  307. package/transform/__test__/defines.spec.js +137 -0
  308. package/transform/__test__/object-methods.spec.js +79 -0
  309. package/transform/crates/swc_plugin_worklet/definition_imports.rs +97 -0
  310. package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
  311. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +56 -48
  312. package/transform/crates/swc_plugin_worklet/lib.rs +400 -595
  313. package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
  314. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +6 -1
  315. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -1
  316. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +9 -0
  317. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +12 -1
  318. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +1 -1
  319. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +1 -1
  320. package/transform/dist/wasm.cjs +1 -1
  321. package/transform/index.d.ts +3 -1
  322. package/transform/package.json +0 -1
  323. package/transform/src/lib.rs +173 -12
  324. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +105 -32
  325. package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
  326. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  327. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +193 -194
  328. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
  329. package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
  330. package/runtime/lib/snapshot/worklet/hmr.js +0 -28
  331. package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
  332. package/runtime/src/snapshot/worklet/hmr.ts +0 -34
  333. /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
  334. /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
@@ -1,89 +1,16 @@
1
1
  $ node ./scripts/build_wasm.js
2
2
  Blocking waiting for file lock on package cache
3
3
  Blocking waiting for file lock on package cache
4
- Blocking waiting for file lock on package cache
5
4
  Downloading crates ...
6
- Downloaded bitflags v1.3.2
7
- Downloaded block-buffer v0.12.1
8
- Downloaded arrayvec v0.7.8
9
- Downloaded browserslist-rs v0.20.0
10
- Downloaded napi-sys v2.4.0
11
- Downloaded crypto-common v0.2.2
12
- Downloaded ctor v0.1.26
13
5
  Downloaded napi-build v2.3.2
14
- Downloaded path-clean v1.0.1
15
- Downloaded pathdiff v0.2.3
16
- Downloaded radix_fmt v1.0.0
17
6
  Downloaded convert_case v0.6.0
18
- Downloaded fixedbitset v0.5.7
19
- Downloaded foldhash v0.1.5
20
- Downloaded foldhash v0.2.0
21
- Downloaded hybrid-array v0.4.13
22
- Downloaded lru v0.18.4
23
- Downloaded precomputed-map v0.2.0
24
- Downloaded preset_env_base v9.0.0
25
- Downloaded browserslist-data v0.2.0
26
- Downloaded const-oid v0.10.2
27
- Downloaded cpufeatures v0.3.0
28
- Downloaded crossbeam-utils v0.8.22
29
- Downloaded dashmap v6.2.1
30
- Downloaded digest v0.11.3
31
- Downloaded getrandom v0.3.4
32
- Downloaded globset v0.4.19
33
- Downloaded iana-time-zone v0.1.65
7
+ Downloaded napi-sys v2.4.0
8
+ Downloaded ctor v0.1.26
9
+ Downloaded bitflags v1.3.2
10
+ Downloaded napi-derive-backend v1.0.40
34
11
  Downloaded napi v2.10.4
35
12
  Downloaded napi-derive v2.9.3
36
- Downloaded napi-derive-backend v1.0.40
37
- Downloaded sha1 v0.10.7
38
- Downloaded sha2 v0.11.0
39
- Downloaded st-map v0.2.4
40
- Downloaded static-map-macro v0.3.4
41
- Downloaded chrono v0.4.45
42
- Downloaded hashbrown v0.16.1
43
- Downloaded itertools v0.15.0
44
- Downloaded jsonc-parser v0.26.3
45
- Downloaded nom v8.0.0
46
- Downloaded par-iter v2.0.0
47
- Downloaded ryu-js v1.0.3
48
- Downloaded bstr v1.13.0
49
- Downloaded regress v0.11.1
50
- Downloaded swc_compiler_base v64.0.0
51
- Downloaded swc_ecma_regexp_ast v3.0.0
52
- Downloaded swc_ecma_regexp_visit v0.15.0
53
- Downloaded petgraph v0.7.1
54
- Downloaded swc v75.0.1
55
- Downloaded swc_config v6.0.0
56
- Downloaded swc_config_macro v1.0.1
57
- Downloaded swc_ecma_compat_common v45.0.0
58
- Downloaded swc_ecma_compat_es2017 v50.0.0
59
- Downloaded swc_ecma_compat_es2018 v51.0.0
60
- Downloaded swc_ecma_compat_es2019 v50.0.0
61
- Downloaded swc_ecma_compat_es2020 v53.0.0
62
- Downloaded swc_ecma_compat_es2021 v50.0.0
63
- Downloaded swc_ecma_compat_regexp v9.0.0
64
- Downloaded swc_ecma_loader v27.0.0
65
- Downloaded swc_ecma_preset_env v63.0.0
66
- Downloaded swc_ecma_regexp_common v0.0.1
67
- Downloaded swc_ecma_transformer v21.0.1
68
- Downloaded swc_ecma_compat_bugfixes v56.0.0
69
- Downloaded swc_ecma_compat_es2015 v55.0.0
70
- Downloaded swc_ecma_compat_es2016 v50.0.0
71
- Downloaded swc_ecma_hooks v1.0.0
72
- Downloaded swc_ecma_regexp v0.15.0
73
- Downloaded swc_ecma_minifier v61.0.4
74
- Downloaded swc_ecma_transforms v62.0.0
75
- Downloaded swc_ecma_transforms_macros v1.0.1
76
- Downloaded swc_ecma_compat_es2022 v53.0.0
77
- Downloaded swc_ecma_transforms_optimization v52.0.0
78
- Downloaded swc_ecma_transforms_proposal v49.0.0
79
- Downloaded swc_ecma_transforms_react v55.0.1
80
- Downloaded swc_ecma_ext_transforms v35.0.0
81
- Downloaded swc_ecma_transforms_classes v49.0.0
82
- Downloaded swc_ecma_transforms_compat v57.0.1
83
- Downloaded swc_ecma_transforms_typescript v55.0.1
84
- Downloaded swc_node_comments v27.0.0
85
13
  Downloaded version-compare v0.2.1
86
- Blocking waiting for file lock on package cache
87
14
  Blocking waiting for file lock on build directory
88
15
  Compiling cfg-if v1.0.4
89
16
  Compiling serde_core v1.0.229
@@ -106,11 +33,11 @@ $ node ./scripts/build_wasm.js
106
33
  Compiling itoa v1.0.18
107
34
  Compiling serde_json v1.0.151
108
35
  Compiling tinystr v0.8.3
109
- Compiling writeable v0.6.3
110
36
  Compiling litemap v0.8.2
37
+ Compiling writeable v0.6.3
111
38
  Compiling potential_utf v0.1.5
112
- Compiling icu_locale_core v2.2.0
113
39
  Compiling zerotrie v0.2.4
40
+ Compiling icu_locale_core v2.2.0
114
41
  Compiling utf8_iter v1.0.4
115
42
  Compiling icu_collections v2.2.0
116
43
  Compiling indexmap v2.14.0
@@ -120,99 +47,99 @@ $ node ./scripts/build_wasm.js
120
47
  Compiling icu_properties_data v2.2.0
121
48
  Compiling rustc-hash v2.1.3
122
49
  Compiling parking_lot_core v0.9.12
123
- Compiling icu_properties v2.2.0
124
50
  Compiling icu_normalizer v2.2.0
125
- Compiling hashbrown v0.14.5
51
+ Compiling icu_properties v2.2.0
126
52
  Compiling either v1.17.0
127
53
  Compiling scopeguard v1.2.0
128
- Compiling radium v0.7.0
129
54
  Compiling lock_api v0.4.14
130
- Compiling idna_adapter v1.2.2
55
+ Compiling radium v0.7.0
56
+ Compiling hashbrown v0.14.5
131
57
  Compiling tracing-core v0.1.36
132
- Compiling percent-encoding v2.3.2
58
+ Compiling idna_adapter v1.2.2
133
59
  Compiling tap v1.0.1
60
+ Compiling percent-encoding v2.3.2
61
+ Compiling idna v1.1.0
134
62
  Compiling wyz v0.5.1
135
63
  Compiling form_urlencoded v1.2.2
136
- Compiling idna v1.1.0
137
64
  Compiling anyhow v1.0.104
138
- Compiling pin-project-lite v0.2.17
139
65
  Compiling bytes v1.12.1
140
- Compiling funty v2.0.0
66
+ Compiling pin-project-lite v0.2.17
141
67
  Compiling uuid v1.24.0
142
68
  Compiling outref v0.5.2
143
69
  Compiling vsimd v0.8.0
70
+ Compiling funty v2.0.0
71
+ Compiling base64-simd v0.8.0
144
72
  Compiling bytes-str v0.2.8
145
- Compiling bitvec v1.1.1
146
73
  Compiling debugid v0.8.0
147
- Compiling base64-simd v0.8.0
148
74
  Compiling url v2.5.8
149
75
  Compiling tracing v0.1.44
76
+ Compiling bitvec v1.1.1
150
77
  Compiling triomphe v0.1.16
151
78
  Compiling unicode-width v0.2.2
152
- Compiling if_chain v1.0.3
153
- Compiling data-encoding v2.11.0
154
79
  Compiling new_debug_unreachable v1.0.6
80
+ Compiling data-encoding v2.11.0
155
81
  Compiling unicode-id-start v1.4.0
82
+ Compiling if_chain v1.0.3
156
83
  Compiling hstr v4.0.0
157
84
  Compiling num-integer v0.1.46
158
85
  Compiling scoped-tls v1.0.1
159
86
  Compiling better_scoped_tls v1.0.1
160
- Compiling num-bigint v0.4.8
161
87
  Compiling swc_atoms v10.0.0
88
+ Compiling num-bigint v0.4.8
162
89
  Compiling parking_lot v0.12.5
163
- Compiling swc_sourcemap v10.0.2
164
90
  Compiling swc_visit v2.0.2
165
- Compiling siphasher v0.3.11
166
91
  Compiling termcolor v1.4.1
92
+ Compiling swc_sourcemap v10.0.2
93
+ Compiling siphasher v0.3.11
167
94
  Compiling bitflags v2.13.1
168
95
  Compiling siphasher v1.0.3
96
+ Compiling phf_shared v0.11.3
169
97
  Compiling libc v0.2.189
170
98
  Compiling dragonbox_ecma v0.1.12
171
- Compiling phf_shared v0.11.3
172
99
  Compiling par-core v2.0.0
173
- Compiling num_cpus v1.17.0
174
100
  Compiling phf v0.11.3
101
+ Compiling num_cpus v1.17.0
175
102
  Compiling castaway v0.2.4
176
103
  Compiling ryu v1.0.23
177
104
  Compiling static_assertions v1.1.0
178
105
  Compiling aho-corasick v1.1.4
179
- Compiling swc_common v26.0.0
180
106
  Compiling compact_str v0.7.1
107
+ Compiling swc_common v26.0.0
181
108
  Compiling regex-syntax v0.8.11
182
109
  Compiling swc_ecma_ast v29.0.0
183
110
  Compiling regex-automata v0.4.16
184
111
  Compiling typenum v1.20.1
185
112
  Compiling swc_ecma_regexp_common v0.0.1
186
- Compiling crossbeam-utils v0.8.22
187
113
  Compiling swc_ecma_regexp_ast v3.0.0
114
+ Compiling crossbeam-utils v0.8.22
188
115
  Compiling swc_ecma_regexp_visit v0.15.0
189
- Compiling dashmap v6.2.1
190
- Compiling swc_ecma_compat_regexp v9.0.0
191
116
  Compiling swc_ecma_regexp v0.15.0
117
+ Compiling swc_ecma_compat_regexp v9.0.0
192
118
  Compiling swc_ecma_visit v29.0.0
193
119
  Compiling swc_ecma_parser v45.1.1
194
120
  Compiling regex v1.13.1
121
+ Compiling dashmap v6.2.1
195
122
  Compiling generic-array v0.14.7
196
- Compiling hashbrown v0.16.1
197
123
  Compiling bstr v1.13.0
198
- Compiling globset v0.4.19
124
+ Compiling hashbrown v0.16.1
199
125
  Compiling regress v0.11.1
200
- Compiling block-buffer v0.10.4
126
+ Compiling globset v0.4.19
201
127
  Compiling crypto-common v0.1.7
128
+ Compiling block-buffer v0.10.4
129
+ Compiling swc_config v6.0.0
202
130
  Compiling digest v0.10.7
203
131
  Compiling arrayvec v0.7.8
204
132
  Compiling thiserror v1.0.69
205
133
  Compiling owo-colors v4.3.0
206
134
  Compiling semver v1.0.28
207
- Compiling fixedbitset v0.5.7
208
135
  Compiling unicode-linebreak v0.1.5
136
+ Compiling fixedbitset v0.5.7
209
137
  Compiling base64 v0.22.1
210
- Compiling textwrap v0.16.2
211
- Compiling swc_config v6.0.0
212
138
  Compiling petgraph v0.7.1
213
- Compiling bumpalo v3.20.3
139
+ Compiling textwrap v0.16.2
214
140
  Compiling swc_ecma_utils v35.0.0
215
141
  Compiling swc_ecma_hooks v1.0.0
142
+ Compiling bumpalo v3.20.3
216
143
  Compiling thread_local v1.1.10
217
144
  Compiling unicode-width v0.1.14
218
145
  Compiling miette v7.6.0
@@ -221,36 +148,36 @@ $ node ./scripts/build_wasm.js
221
148
  Compiling swc_allocator v5.0.0
222
149
  Compiling sha1 v0.10.7
223
150
  Compiling chrono v0.4.45
224
- Compiling lazy_static v1.5.0
225
- Compiling log v0.4.33
226
151
  Compiling syn v1.0.109
152
+ Compiling lazy_static v1.5.0
227
153
  Compiling ascii v1.1.0
228
- Compiling swc_ecma_codegen v32.0.0
154
+ Compiling log v0.4.33
155
+ Compiling tracing-log v0.2.0
156
+ Compiling browserslist-data v0.2.0
229
157
  Compiling swc_ecma_transformer v21.0.1
230
158
  Compiling swc_ecma_transforms_classes v49.0.0
231
159
  Compiling swc_ecma_compat_common v45.0.0
232
160
  Compiling swc_ecma_compat_es2015 v55.0.0
233
161
  Compiling swc_ecma_compat_es2022 v53.0.0
234
162
  Compiling swc_ecma_transforms_optimization v52.0.0
235
- Compiling swc_ecma_compat_es2020 v53.0.0
236
- Compiling swc_ecma_compat_es2019 v50.0.0
237
163
  Compiling swc_ecma_compat_bugfixes v56.0.0
164
+ Compiling swc_ecma_compat_es2020 v53.0.0
165
+ Compiling swc_ecma_compat_es2017 v50.0.0
238
166
  Compiling swc_ecma_compat_es2021 v50.0.0
239
- Compiling swc_ecma_compat_es2018 v51.0.0
240
167
  Compiling swc_ecma_compat_es2016 v50.0.0
241
- Compiling swc_ecma_compat_es2017 v50.0.0
242
- Compiling browserslist-data v0.2.0
168
+ Compiling swc_ecma_compat_es2018 v51.0.0
169
+ Compiling swc_ecma_compat_es2019 v50.0.0
243
170
  Compiling swc_ecma_transforms_react v55.0.1
244
- Compiling tracing-log v0.2.0
171
+ Compiling swc_ecma_codegen v32.0.0
245
172
  Compiling sharded-slab v0.1.7
246
173
  Compiling swc_error_reporters v28.0.0
247
174
  Compiling matchers v0.2.0
248
175
  Compiling itertools v0.15.0
249
176
  Compiling cargo-platform v0.1.9
250
177
  Compiling nom v8.0.0
251
- Compiling diff v0.1.13
252
178
  Compiling nu-ansi-term v0.50.3
253
179
  Compiling yansi v1.0.1
180
+ Compiling diff v0.1.13
254
181
  Compiling pretty_assertions v1.4.1
255
182
  Compiling tracing-subscriber v0.3.23
256
183
  Compiling st-map v0.2.4
@@ -260,67 +187,67 @@ $ node ./scripts/build_wasm.js
260
187
  Compiling swc_ecma_transforms_compat v57.0.1
261
188
  Compiling swc_ecma_transforms_proposal v49.0.0
262
189
  Compiling par-iter v2.0.0
190
+ Compiling difference v2.0.0
263
191
  Compiling ryu-js v1.0.3
264
192
  Compiling pathdiff v0.2.3
265
- Compiling difference v2.0.0
266
193
  Compiling radix_fmt v1.0.0
267
- Compiling testing v27.0.0
268
- Compiling swc_ecma_minifier v61.0.4
269
194
  Compiling swc_ecma_transforms v62.0.0
195
+ Compiling testing v27.0.0
270
196
  Compiling preset_env_base v9.0.0
271
197
  Compiling swc_ecma_preset_env v63.0.0
198
+ Compiling swc_ecma_minifier v61.0.4
272
199
  Compiling sha2 v0.10.9
273
200
  Compiling lru v0.18.4
274
- Compiling foldhash v0.1.5
275
- Compiling fastrand v2.5.0
201
+ Compiling precomputed-map v0.2.0
276
202
  Compiling hex v0.4.3
203
+ Compiling foldhash v0.1.5
277
204
  Compiling unicode-segmentation v1.13.3
278
205
  Compiling path-clean v1.0.1
279
- Compiling precomputed-map v0.2.0
206
+ Compiling fastrand v2.5.0
207
+ Compiling tempfile v3.27.0
280
208
  Compiling swc_ecma_loader v27.0.0
281
209
  Compiling convert_case v0.6.0
282
210
  Compiling swc_ecma_testing v27.0.0
283
- Compiling tempfile v3.27.0
284
211
  Compiling swc_ecma_ext_transforms v35.0.0
285
212
  Compiling swc_node_comments v27.0.0
286
213
  Compiling swc_transform_common v20.0.0
287
214
  Compiling jsonc-parser v0.26.3
288
- Compiling swc_core v77.1.2
289
215
  Compiling ansi_term v0.12.1
216
+ Compiling swc_core v77.1.2
290
217
  Compiling swc_ecma_transforms_testing v53.0.0
291
218
  Compiling napi-derive-backend v1.0.40
292
219
  Compiling swc_compiler_base v64.0.0
293
220
  Compiling swc v75.0.1
294
221
  Compiling ctor v0.1.26
295
- Compiling napi-sys v2.4.0
296
222
  Compiling bitflags v1.3.2
223
+ Compiling napi-sys v2.4.0
297
224
  Compiling napi v2.10.4
298
225
  Compiling napi-derive v2.9.3
299
226
  Compiling convert_case v0.11.0
300
227
  Compiling sha-1 v0.10.1
301
228
  Compiling sugar_path v1.2.1
302
- Compiling hybrid-array v0.4.13
303
229
  Compiling swc_plugins_shared v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugins_shared)
304
- Compiling block-buffer v0.12.1
230
+ Compiling hybrid-array v0.4.13
305
231
  Compiling crypto-common v0.2.2
232
+ Compiling block-buffer v0.12.1
306
233
  Compiling const-oid v0.10.2
307
- Compiling napi-build v2.3.2
308
234
  Compiling digest v0.11.3
309
- Compiling sha2 v0.11.0
310
- Compiling react-transform v0.0.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform)
235
+ Compiling napi-build v2.3.2
311
236
  Compiling getrandom v0.4.3
237
+ Compiling react-transform v0.0.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform)
238
+ Compiling sha2 v0.11.0
312
239
  Compiling swc_plugin_snapshot v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_snapshot)
313
240
  Compiling swc_plugin_define_dce v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_define_dce)
314
241
  Compiling swc_plugin_directive_dce v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_directive_dce)
315
242
  Compiling swc_plugin_element_template v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_element_template)
316
243
  Compiling swc_plugin_list v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_list)
317
- Compiling swc_plugin_css_scope v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_css_scope)
244
+ Compiling swc_plugin_inject v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_inject)
245
+ Compiling swc_plugin_compat v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_compat)
318
246
  Compiling swc_plugin_dynamic_import v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_dynamic_import)
319
247
  Compiling swc_plugin_shake v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_shake)
320
- Compiling swc_plugin_text v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_text)
321
248
  Compiling swc_plugin_worklet v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_worklet)
322
- Compiling swc_plugin_compat v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_compat)
323
- Compiling swc_plugin_inject v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_inject)
249
+ Compiling swc_plugin_text v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_text)
250
+ Compiling swc_plugin_css_scope v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_css_scope)
324
251
  Compiling swc_plugin_background_only v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_background_only)
325
252
  Compiling version-compare v0.2.1
326
- Finished `release` profile [optimized] target(s) in 6m 40s
253
+ Finished `release` profile [optimized] target(s) in 6m 28s
@@ -2,6 +2,8 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
+ import path from 'node:path';
6
+
5
7
  import { describe, expect, it } from 'vitest';
6
8
 
7
9
  import { transformReactLynx } from '../main.js';
@@ -175,6 +177,21 @@ describe('collected defines', () => {
175
177
  expect(result.code).not.toContain('__CreateView');
176
178
  });
177
179
 
180
+ it.each(['development', 'production'])(
181
+ 'keeps worklet implementations in main-thread definitions in %s builds',
182
+ async mode => {
183
+ const result = await transformReactLynx(source, options('JS', { mode }));
184
+
185
+ expect(result.errors).toEqual([]);
186
+ expect(result.code).not.toContain('registerWorkletOnBackground');
187
+ expect(result.code).not.toContain('console.info');
188
+ expect(result.code).toContain('_wkltId');
189
+ expect(result.definesForWorklet).toHaveLength(1);
190
+ expect(result.definesForWorklet[0].code).toContain('__registerWorklet');
191
+ expect(result.definesForWorklet[0].code).toContain('console.info');
192
+ },
193
+ );
194
+
178
195
  it('collects the same definitions the main-thread transform would emit', async () => {
179
196
  const fromBackground = await transformReactLynx(
180
197
  source,
@@ -273,6 +290,111 @@ function legacy(target, extra = {}) {
273
290
  });
274
291
  }
275
292
 
293
+ describe('worklet definition imports', () => {
294
+ const source = `
295
+ import { runOnBackground, useState } from '@lynx-js/react';
296
+ export function Repro() {
297
+ const [count, setCount] = useState(0);
298
+ const onTap = () => {
299
+ 'main thread';
300
+ runOnBackground(() => {
301
+ 'background only';
302
+ setCount(value => value + 1);
303
+ })();
304
+ };
305
+ return <view main-thread:bindtap={onTap}>{count}</view>;
306
+ }
307
+ `;
308
+
309
+ it.each(['test', 'development'])(
310
+ 'carries the runOnBackground import without unrelated component imports in %s mode',
311
+ async (mode) => {
312
+ const background = await transformReactLynx(source, options('JS', { mode }));
313
+ const mainThread = await transformReactLynx(source, options('LEPUS', { mode }));
314
+ expect(background.errors).toEqual([]);
315
+ expect(background.definesForWorklet).toEqual(mainThread.definesForWorklet);
316
+ const [definition] = background.definesForWorklet;
317
+ const dependency = definition.imports.find(item => item.imported === 'runOnBackground');
318
+ expect(dependency).toEqual({ source: '@lynx-js/react', imported: 'runOnBackground', local: dependency.local });
319
+ expect(definition.code).toContain(`${dependency.local}(_jsFn1)()`);
320
+ expect(definition.imports.some(item => item.imported === 'useState')).toBe(false);
321
+ },
322
+ );
323
+
324
+ it('resolves Windows relative imports in the Wasm transform', async () => {
325
+ const result = await transformReactLynx(
326
+ source.replace('\'@lynx-js/react\'', '\'./bridge.js\''),
327
+ options('JS', { filename: 'C:\\project\\src\\Repro.jsx' }),
328
+ );
329
+ expect(result.errors).toEqual([]);
330
+ expect(result.definesForWorklet[0].imports).toContainEqual(
331
+ expect.objectContaining({ source: 'C:/project/src/./bridge.js', imported: 'runOnBackground' }),
332
+ );
333
+ });
334
+
335
+ it('resolves relative imports from the owning module directory', async () => {
336
+ const filename = path.resolve('src/components/Repro.jsx');
337
+ const result = await transformReactLynx(
338
+ source.replace('\'@lynx-js/react\'', '\'./bridge.js\''),
339
+ options('JS', { filename }),
340
+ );
341
+ expect(result.errors).toEqual([]);
342
+ expect(result.definesForWorklet[0].imports).toContainEqual(expect.objectContaining({
343
+ source: `${path.dirname(filename)}/./bridge.js`.replaceAll('\\', '/'),
344
+ imported: 'runOnBackground',
345
+ }));
346
+ });
347
+
348
+ it('does not import bindings captured through the worklet context', async () => {
349
+ const result = await transformReactLynx(
350
+ `
351
+ import { value } from './values.js';
352
+ function worklet() { 'main thread'; return value; }
353
+ `,
354
+ options('JS'),
355
+ );
356
+ expect(result.errors).toEqual([]);
357
+ expect(result.definesForWorklet[0].imports).toHaveLength(1);
358
+ expect(result.definesForWorklet[0].code).toContain('this["_c"]');
359
+ });
360
+
361
+ it('preserves default, namespace and aliased imports and shorthand keys', async () => {
362
+ const opts = options('JS');
363
+ opts.worklet.customGlobalIdentNames = ['call', 'api', 'named'];
364
+ const result = await transformReactLynx(
365
+ `
366
+ import call, * as api from './bridge.js';
367
+ import { original as named } from './other.js';
368
+ function worklet() { 'main thread'; return [call(), api.value, { named }]; }
369
+ `,
370
+ opts,
371
+ );
372
+ expect(result.errors).toEqual([]);
373
+ const [definition] = result.definesForWorklet;
374
+ expect(definition.imports).toEqual(expect.arrayContaining([
375
+ { source: './bridge.js', imported: 'default', local: 'call' },
376
+ { source: './bridge.js', imported: '*', local: 'api', namespace: true },
377
+ { source: './other.js', imported: 'original', local: 'named' },
378
+ ]));
379
+ expect(definition.code).toContain('named');
380
+ });
381
+
382
+ it('does not carry an import shadowed by a worklet parameter', async () => {
383
+ const result = await transformReactLynx(
384
+ `
385
+ import { runOnBackground } from './bridge.js';
386
+ function worklet(runOnBackground) {
387
+ 'main thread';
388
+ runOnBackground(() => {})();
389
+ }
390
+ `,
391
+ options('JS'),
392
+ );
393
+ expect(result.errors).toEqual([]);
394
+ expect(result.definesForWorklet[0].imports).toHaveLength(1);
395
+ });
396
+ });
397
+
276
398
  describe('legacy slot codegen', () => {
277
399
  it('collects the definitions its frozen codegen emits', async () => {
278
400
  const { definesForSnapshot, definesForWorklet } = await transformReactLynx(
@@ -332,6 +454,21 @@ describe('legacy slot codegen', () => {
332
454
  `);
333
455
  });
334
456
 
457
+ it.each(['development', 'production'])(
458
+ 'keeps worklet implementations in main-thread definitions in %s builds',
459
+ async mode => {
460
+ const result = await transformReactLynx(source, { ...legacy('JS'), mode });
461
+
462
+ expect(result.errors).toEqual([]);
463
+ expect(result.code).not.toContain('registerWorkletOnBackground');
464
+ expect(result.code).not.toContain('console.info');
465
+ expect(result.code).toContain('_wkltId');
466
+ expect(result.definesForWorklet).toHaveLength(1);
467
+ expect(result.definesForWorklet[0].code).toContain('__registerWorklet');
468
+ expect(result.definesForWorklet[0].code).toContain('console.info');
469
+ },
470
+ );
471
+
335
472
  it('collects the same definitions the main-thread transform would emit', async () => {
336
473
  const fromBackground = await transformReactLynx(source, legacy('JS'));
337
474
  const fromMainThread = await transformReactLynx(source, legacy('LEPUS'));
@@ -79,4 +79,83 @@ describe('object method captures', () => {
79
79
  expect(Object.getOwnPropertyDescriptor(valueType, 'create').get.call(other)._jsFn._jsFn1)
80
80
  .toBe(other.callback);
81
81
  });
82
+
83
+ it('preserves nullish bases and guards when narrowing optional member captures', async () => {
84
+ const result = await transformReactLynx(
85
+ `
86
+ export function create(enabled, handlers) {
87
+ return () => {
88
+ 'main thread';
89
+ if (enabled && handlers?.start) handlers.start();
90
+ };
91
+ }
92
+
93
+ export function createNested(enabled, handlers) {
94
+ return () => {
95
+ 'main thread';
96
+ if (enabled && handlers?.nested?.start) handlers.nested.start();
97
+ };
98
+ }
99
+ `,
100
+ options('LEPUS'),
101
+ );
102
+ const functions = new Map();
103
+ const { create, createNested } = new Function(
104
+ '__registerWorklet',
105
+ '__captureMainThreadObject',
106
+ `${result.code.replace(/^import .*;$/gm, '').replace(/^export /gm, '')}\nreturn { create, createNested };`,
107
+ )(
108
+ (_type, id, fn) => functions.set(id, fn),
109
+ () => undefined,
110
+ );
111
+ const invoke = worklet => functions.get(worklet._wkltId).call(worklet);
112
+
113
+ const withNullDisabled = create(false, null);
114
+ expect(withNullDisabled._c.handlers).toBeNull();
115
+ expect(() => invoke(withNullDisabled)).not.toThrow();
116
+
117
+ const withUndefinedDisabled = create(false, undefined);
118
+ expect(withUndefinedDisabled._c.handlers).toBeUndefined();
119
+ expect(() => invoke(withUndefinedDisabled)).not.toThrow();
120
+
121
+ const withNullEnabled = create(true, null);
122
+ expect(withNullEnabled._c.handlers).toBeNull();
123
+ expect(() => invoke(withNullEnabled)).not.toThrow();
124
+
125
+ const withUndefinedEnabled = create(true, undefined);
126
+ expect(withUndefinedEnabled._c.handlers).toBeUndefined();
127
+ expect(() => invoke(withUndefinedEnabled)).not.toThrow();
128
+
129
+ let started = 0;
130
+ const handlers = {
131
+ start() {
132
+ started += 1;
133
+ },
134
+ extra: 'unreferenced',
135
+ };
136
+ const withHandlersDisabled = create(false, handlers);
137
+ expect(withHandlersDisabled._c.handlers).toEqual({ start: handlers.start });
138
+ expect('extra' in withHandlersDisabled._c.handlers).toBe(false);
139
+ invoke(withHandlersDisabled);
140
+ expect(started).toBe(0);
141
+
142
+ const withHandlersEnabled = create(true, handlers);
143
+ invoke(withHandlersEnabled);
144
+ expect(started).toBe(1);
145
+
146
+ const withNestedNull = createNested(true, { nested: null, extra: 1 });
147
+ expect(withNestedNull._c.handlers).toEqual({ nested: null });
148
+ expect(() => invoke(withNestedNull)).not.toThrow();
149
+
150
+ const withNestedUndefined = createNested(true, { nested: undefined, extra: 1 });
151
+ expect(withNestedUndefined._c.handlers).toEqual({ nested: undefined });
152
+ expect(() => invoke(withNestedUndefined)).not.toThrow();
153
+
154
+ const withNestedHandlers = createNested(true, { nested: handlers, extra: 1 });
155
+ expect(withNestedHandlers._c.handlers).toEqual({
156
+ nested: { start: handlers.start },
157
+ });
158
+ invoke(withNestedHandlers);
159
+ expect(started).toBe(2);
160
+ });
82
161
  });