@lynx-js/react 0.129.0 → 0.129.2

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 (282) hide show
  1. package/CHANGELOG.md +24 -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/globalProps.test.ts +27 -6
  6. package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
  7. package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
  8. package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
  9. package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
  10. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
  11. package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
  12. package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
  13. package/runtime/__test__/element-template/native/mts-destroy.test.ts +88 -0
  14. package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
  15. package/runtime/__test__/element-template/native/reload.test.ts +118 -2
  16. package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
  17. package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
  18. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
  19. package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
  20. package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
  21. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
  22. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +212 -7
  23. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
  24. package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
  25. package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
  26. package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
  27. package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
  28. package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
  29. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
  30. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
  31. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
  32. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
  33. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +309 -26
  34. package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
  35. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
  36. package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
  37. package/runtime/__test__/shared/component-stack.test.ts +211 -0
  38. package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
  39. package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
  40. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
  41. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
  42. package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
  43. package/runtime/__test__/snapshot/preact.test.jsx +0 -3
  44. package/runtime/__test__/snapshot/ref.test.jsx +30 -0
  45. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
  46. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
  47. package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
  48. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
  49. package/runtime/lazy/element-template-internal.js +1 -1
  50. package/runtime/lazy/internal.js +1 -1
  51. package/runtime/lazy/jsx-dev-runtime.js +1 -1
  52. package/runtime/lazy/jsx-runtime.js +1 -1
  53. package/runtime/lazy/legacy-react-runtime.js +1 -1
  54. package/runtime/lazy/react-lepus.js +1 -1
  55. package/runtime/lazy/react.js +1 -1
  56. package/runtime/lib/core/capture-main-thread-object.js +2 -1
  57. package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
  58. package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
  59. package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
  60. package/runtime/lib/core/globalProps.js +1 -1
  61. package/runtime/lib/core/globalProps.js.map +1 -1
  62. package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
  63. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  64. package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
  65. package/runtime/lib/core/lynx-data-processors.js +3 -0
  66. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  67. package/runtime/lib/core/runtime-destroy.js +1 -1
  68. package/runtime/lib/core/runtime-destroy.js.map +1 -1
  69. package/runtime/lib/document.js +0 -5
  70. package/runtime/lib/document.js.map +1 -1
  71. package/runtime/lib/element-template/background/attr-slots.js +5 -2
  72. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  73. package/runtime/lib/element-template/background/commit-hook.js +11 -12
  74. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  75. package/runtime/lib/element-template/background/destroy.js +16 -11
  76. package/runtime/lib/element-template/background/destroy.js.map +1 -1
  77. package/runtime/lib/element-template/background/hydrate.js +23 -0
  78. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  79. package/runtime/lib/element-template/client/root.d.ts +1 -1
  80. package/runtime/lib/element-template/client/root.js.map +1 -1
  81. package/runtime/lib/element-template/debug/alog.d.ts +1 -1
  82. package/runtime/lib/element-template/debug/alog.js +4 -1
  83. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  84. package/runtime/lib/element-template/index.d.ts +2 -2
  85. package/runtime/lib/element-template/index.js.map +1 -1
  86. package/runtime/lib/element-template/internal.d.ts +2 -2
  87. package/runtime/lib/element-template/internal.js +1 -14
  88. package/runtime/lib/element-template/internal.js.map +1 -1
  89. package/runtime/lib/element-template/lynx/env.js.map +1 -1
  90. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
  91. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
  92. package/runtime/lib/element-template/native/flush.d.ts +1 -0
  93. package/runtime/lib/element-template/native/flush.js +9 -0
  94. package/runtime/lib/element-template/native/flush.js.map +1 -0
  95. package/runtime/lib/element-template/native/main-thread-api.js +3 -7
  96. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
  97. package/runtime/lib/element-template/native/mts-destroy.js +8 -2
  98. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
  99. package/runtime/lib/element-template/native/patch-listener.js +57 -50
  100. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  101. package/runtime/lib/element-template/native/reload-background.js +1 -1
  102. package/runtime/lib/element-template/native/reload-background.js.map +1 -1
  103. package/runtime/lib/element-template/native/reload-main-thread.js +35 -10
  104. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  105. package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
  106. package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
  107. package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
  108. package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
  109. package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
  110. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  111. package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
  112. package/runtime/lib/element-template/protocol/opcodes.js +1 -0
  113. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
  114. package/runtime/lib/element-template/protocol/types.d.ts +7 -1
  115. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  116. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
  117. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
  118. package/runtime/lib/element-template/runtime/patch.js +31 -2
  119. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  120. package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
  121. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
  122. package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
  123. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  124. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
  125. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
  126. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
  127. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
  128. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
  129. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -1
  130. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +380 -50
  131. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  132. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +3 -2
  133. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
  134. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  135. package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
  136. package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
  137. package/runtime/lib/internal.d.ts +1 -1
  138. package/runtime/lib/internal.js +1 -1
  139. package/runtime/lib/internal.js.map +1 -1
  140. package/runtime/lib/lynx-api.d.ts +2 -125
  141. package/runtime/lib/lynx-api.js.map +1 -1
  142. package/runtime/lib/shared/component-stack.d.ts +0 -4
  143. package/runtime/lib/shared/component-stack.js +21 -5
  144. package/runtime/lib/shared/component-stack.js.map +1 -1
  145. package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
  146. package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
  147. package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
  148. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  149. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
  150. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
  151. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
  152. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
  153. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  154. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
  155. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  156. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
  157. package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
  158. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  159. package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
  160. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  161. package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
  162. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  163. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
  164. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  165. package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
  166. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  167. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
  168. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  169. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
  170. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  171. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  172. package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
  173. package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
  174. package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
  175. package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
  176. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
  177. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
  178. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
  179. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
  180. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  181. package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
  182. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  183. package/runtime/package.json +2 -3
  184. package/runtime/src/core/capture-main-thread-object.ts +2 -1
  185. package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
  186. package/runtime/src/core/globalProps.ts +1 -1
  187. package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
  188. package/runtime/src/core/lynx-data-processors.ts +124 -1
  189. package/runtime/src/core/runtime-destroy.ts +1 -1
  190. package/runtime/src/document.ts +0 -6
  191. package/runtime/src/element-template/background/attr-slots.ts +5 -1
  192. package/runtime/src/element-template/background/commit-hook.ts +18 -12
  193. package/runtime/src/element-template/background/destroy.ts +16 -13
  194. package/runtime/src/element-template/background/hydrate.ts +23 -0
  195. package/runtime/src/element-template/client/root.ts +1 -3
  196. package/runtime/src/element-template/debug/alog.ts +5 -2
  197. package/runtime/src/element-template/index.ts +2 -2
  198. package/runtime/src/element-template/internal.ts +1 -20
  199. package/runtime/src/element-template/lynx/env.ts +1 -1
  200. package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
  201. package/runtime/src/element-template/native/flush.ts +10 -0
  202. package/runtime/src/element-template/native/main-thread-api.ts +3 -6
  203. package/runtime/src/element-template/native/mts-destroy.ts +7 -2
  204. package/runtime/src/element-template/native/patch-listener.ts +62 -57
  205. package/runtime/src/element-template/native/reload-background.ts +1 -1
  206. package/runtime/src/element-template/native/reload-main-thread.ts +32 -11
  207. package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
  208. package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
  209. package/runtime/src/element-template/protocol/opcodes.ts +1 -0
  210. package/runtime/src/element-template/protocol/types.ts +8 -13
  211. package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
  212. package/runtime/src/element-template/runtime/patch.ts +38 -0
  213. package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
  214. package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
  215. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
  216. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
  217. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +456 -50
  218. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +14 -4
  219. package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
  220. package/runtime/src/element-template/types.d.ts +6 -0
  221. package/runtime/src/internal.ts +1 -1
  222. package/runtime/src/lynx-api.ts +2 -124
  223. package/runtime/src/shared/component-stack.ts +22 -5
  224. package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
  225. package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
  226. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
  227. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
  228. package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
  229. package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
  230. package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
  231. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
  232. package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
  233. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
  234. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
  235. package/runtime/src/worklet-runtime/README.md +30 -10
  236. package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
  237. package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
  238. package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
  239. package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
  240. package/runtime/types/types.d.ts +2 -1
  241. package/runtime/vitest.config.ts +0 -2
  242. package/testing-library/.turbo/turbo-build.log +7 -7
  243. package/testing-library/src/__tests__/act.test.jsx +0 -7
  244. package/testing-library/src/__tests__/alog.test.jsx +12 -54
  245. package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
  246. package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
  247. package/testing-library/src/__tests__/worklet.test.jsx +49 -0
  248. package/transform/.turbo/turbo-build$colon$wasm.log +133 -297
  249. package/transform/__test__/defines.spec.js +30 -0
  250. package/transform/__test__/fixture.spec.js +11 -11
  251. package/transform/__test__/main-thread-object-compat.spec.js +111 -0
  252. package/transform/__test__/object-methods.spec.js +79 -0
  253. package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
  254. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
  255. package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
  256. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +63 -57
  257. package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
  258. package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
  259. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
  260. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
  261. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +11 -6
  262. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +12 -6
  263. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +14 -5
  264. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +17 -6
  265. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
  266. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
  267. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
  268. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
  269. package/transform/dist/wasm.cjs +1 -1
  270. package/transform/package.json +0 -1
  271. package/transform/src/lib.rs +1 -1
  272. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +167 -69
  273. package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
  274. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  275. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +226 -132
  276. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
  277. package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
  278. package/runtime/lib/snapshot/worklet/hmr.js +0 -28
  279. package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
  280. package/runtime/src/snapshot/worklet/hmr.ts +0 -34
  281. /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
  282. /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
@@ -128,6 +128,13 @@ export type SetMainThreadEventCommand = [
128
128
  value: SerializableValue | null,
129
129
  ];
130
130
 
131
+ export type SetGestureCommand = [
132
+ typeof ElementTemplateUpdateOps.setGesture,
133
+ targetHandleId: number,
134
+ attrSlotIndex: number,
135
+ value: SerializableValue | null,
136
+ ];
137
+
131
138
  export type SetMainThreadRefCommand = [
132
139
  typeof ElementTemplateUpdateOps.setMainThreadRef,
133
140
  targetHandleId: number,
@@ -186,6 +193,7 @@ export type ElementTemplateUpdateCommand =
186
193
  | SetAttributeCommand
187
194
  | SetMainThreadEventCommand
188
195
  | SetMainThreadRefCommand
196
+ | SetGestureCommand
189
197
  | InsertNodeCommand
190
198
  | RemoveNodeCommand
191
199
  | CreateTypedElementCommand
@@ -199,20 +207,7 @@ export type ElementTemplateUpdateCommand =
199
207
  export type ElementTemplateUpdateCommandStream = ElementTemplateUpdateCommand[number][];
200
208
 
201
209
  export interface ElementTemplateFlushOptions {
202
- // triggerLayout?: boolean;
203
- // operationID?: any;
204
- // __lynx_timing_flag?: string;
205
- // nativeUpdateDataOrder?: number;
206
- // elementID?: number;
207
- // listID?: number;
208
- // listReuseNotification?: {
209
- // listElement: FiberElement;
210
- // itemKey: string;
211
- // };
212
210
  pipelineOptions?: PipelineOptions;
213
- // elementIDs?: number[];
214
- // operationIDs?: any[];
215
- // asyncFlush?: boolean;
216
211
  triggerDataUpdated?: boolean;
217
212
  emptyPatch?: boolean;
218
213
  }
@@ -7,7 +7,6 @@
7
7
  */
8
8
  let __root: {
9
9
  __jsx?: React.ReactNode;
10
- __opcodes?: any[];
11
10
  nodeType?: Element['nodeType'];
12
11
  };
13
12
 
@@ -16,6 +16,8 @@ import {
16
16
  } from './list/list.js';
17
17
  import type { ETListFlushResult, ETListUpdateItem } from './list/list.js';
18
18
  import { insertElementTemplateSubtree } from './template/handle.js';
19
+ import { retainMainThreadBackgroundFunctionCtx } from './template/main-thread-background-function.js';
20
+ import type { MTEventNativeWrapper } from './template/main-thread-event-ctx.js';
19
21
  import { elementTemplateRegistry } from './template/registry.js';
20
22
  import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from './template/typed-attributes.js';
21
23
  import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
@@ -41,11 +43,18 @@ import type {
41
43
  import {
42
44
  deleteMainThreadDynamicAttrStateForSubtree,
43
45
  initializeMainThreadDynamicAttrSlots,
46
+ isSpreadDynamicAttrSlot,
44
47
  prepareMainThreadDynamicAttrSlotsForNative,
48
+ prepareSpreadAttrSlotForNative,
49
+ reconcileUnhydratedSpreadMTRefSlots,
50
+ updateGestureAttrSlot,
45
51
  updateMainThreadEventAttrSlot,
46
52
  updateMainThreadRefAttrSlot,
53
+ updateSpreadAttrSlot,
47
54
  } from './template/main-thread-dynamic-attr-state.js';
48
55
  import type { MainThreadDynamicAttrSubtreeHandle } from './template/main-thread-dynamic-attr-state.js';
56
+ import { retainGestureCallbacks } from '../prop-adapters/gesture.js';
57
+ import type { GestureSlotValue } from '../prop-adapters/gesture.js';
49
58
 
50
59
  export type { ElementTemplateUpdateCommandStream } from '../protocol/types.js';
51
60
 
@@ -103,6 +112,7 @@ export function applyElementTemplateUpdateCommands(
103
112
  handleId,
104
113
  templateType,
105
114
  attributeSlots,
115
+ true,
106
116
  );
107
117
  }
108
118
  break;
@@ -126,10 +136,32 @@ export function applyElementTemplateUpdateCommands(
126
136
  break;
127
137
  }
128
138
  }
139
+ if (isSpreadDynamicAttrSlot(targetId, attrSlotIndex)) {
140
+ const nativeValue = prepareSpreadAttrSlotForNative(value);
141
+ __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, nativeValue);
142
+ updateSpreadAttrSlot(targetId, attrSlotIndex, value, nativeRef, isHydration);
143
+ break;
144
+ }
129
145
  __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);
130
146
  break;
131
147
  }
132
148
 
149
+ case ElementTemplateUpdateOps.setGesture: {
150
+ const targetId = stream[i++] as number;
151
+ const attrSlotIndex = stream[i++] as number;
152
+ const value = stream[i++] as SerializableValue | null;
153
+ const nativeRef = resolveTargetHandle(targetId, 'target');
154
+ if (!nativeRef) {
155
+ continue;
156
+ }
157
+ if (value != null) {
158
+ retainGestureCallbacks(value as unknown as GestureSlotValue);
159
+ }
160
+ __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);
161
+ updateGestureAttrSlot(targetId, attrSlotIndex, value, isHydration);
162
+ break;
163
+ }
164
+
133
165
  case ElementTemplateUpdateOps.setMainThreadEvent: {
134
166
  const targetId = stream[i++] as number;
135
167
  const attrSlotIndex = stream[i++] as number;
@@ -138,6 +170,9 @@ export function applyElementTemplateUpdateCommands(
138
170
  if (!nativeRef) {
139
171
  continue;
140
172
  }
173
+ if (value != null) {
174
+ retainMainThreadBackgroundFunctionCtx((value as unknown as MTEventNativeWrapper).value);
175
+ }
141
176
  __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);
142
177
  updateMainThreadEventAttrSlot(targetId, attrSlotIndex, value, isHydration);
143
178
  break;
@@ -323,6 +358,9 @@ export function applyElementTemplateUpdateCommands(
323
358
  }
324
359
  }
325
360
  }
361
+ if (isHydration) {
362
+ reconcileUnhydratedSpreadMTRefSlots();
363
+ }
326
364
  flushPendingListUpdates();
327
365
  }
328
366
 
@@ -40,7 +40,7 @@ const assign = /* @__PURE__ */ Object.assign;
40
40
  // Global state for the current render pass
41
41
  export let beforeDiff: ((vnode: unknown) => void) | undefined;
42
42
  export let beforeDiff2: ((vnode: unknown, context: Record<string, unknown>) => void) | undefined;
43
- let afterDiff, renderHook, ummountHook;
43
+ let afterDiff, renderHook, unmountHook;
44
44
 
45
45
  export function renderWithHooks(
46
46
  vnode: unknown,
@@ -62,7 +62,7 @@ export function renderWithHooks(
62
62
  beforeDiff2 = options[DIFF2];
63
63
  afterDiff = options[DIFFED];
64
64
  renderHook = options[RENDER];
65
- ummountHook = options.unmount;
65
+ unmountHook = options.unmount;
66
66
 
67
67
  const parent = h(Fragment, null);
68
68
  parent[CHILDREN] = [vnode];
@@ -141,7 +141,7 @@ function renderClassComponent(vnode, context, globalContext) {
141
141
  export function cleanupVNode(vnode: unknown): void {
142
142
  if (afterDiff) afterDiff(vnode);
143
143
  vnode[PARENT] = undefined;
144
- if (ummountHook) ummountHook(vnode);
144
+ if (unmountHook) unmountHook(vnode);
145
145
  }
146
146
 
147
147
  export function renderComponentVNode(
@@ -16,6 +16,7 @@ import { flushInitialElementTemplateListUpdates } from '../list/list.js';
16
16
  import { __page } from '../page/page.js';
17
17
  import { __root } from '../page/root-instance.js';
18
18
  import { insertElementTemplateSubtree } from '../template/handle.js';
19
+ import { applyPendingMainThreadRefAttachments } from '../template/main-thread-dynamic-attr-state.js';
19
20
  import { getElementTemplateNativeRef } from '../template/registry.js';
20
21
  import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';
21
22
 
@@ -48,6 +49,7 @@ function renderMainThread(): void {
48
49
  );
49
50
  }
50
51
  flushInitialListUpdates();
52
+ applyPendingMainThreadRefAttachments();
51
53
  } finally {
52
54
  profileEnd();
53
55
  }
@@ -6,8 +6,10 @@ import { prepareMTEventCtxForNative } from './main-thread-event-ctx.js';
6
6
  import { prepareMTRefForNative } from './main-thread-ref-ctx.js';
7
7
  import { isMainThreadFunction } from '../../../core/main-thread-function.js';
8
8
  import { getEventValue } from '../../prop-adapters/event-value.js';
9
+ import { prepareGestureForNative } from '../../prop-adapters/gesture.js';
10
+ import type { GestureSlotValue } from '../../prop-adapters/gesture.js';
9
11
  import { prepareRefAttrSlot } from '../../prop-adapters/ref.js';
10
- import { prepareSpreadAttrSlot } from '../../prop-adapters/spread.js';
12
+ import { prepareSpreadAttrSlot, prepareTypedSpreadAttrSlot } from '../../prop-adapters/spread.js';
11
13
  import type { SerializableValue } from '../../protocol/types.js';
12
14
 
13
15
  export interface EtAttrAdapterContext {
@@ -31,7 +33,7 @@ export type EtAttrPlanMap = Record<
31
33
 
32
34
  export const __etAttrPlanMap = Object.create(null) as EtAttrPlanMap;
33
35
 
34
- export type MainThreadDynamicAttrKind = 'mt-event' | 'mt-ref';
36
+ export type MainThreadDynamicAttrKind = 'mt-event' | 'mt-ref' | 'gesture' | 'spread';
35
37
 
36
38
  const mainThreadDynamicAttrSlotKinds = new Map<
37
39
  string,
@@ -54,8 +56,12 @@ export function getMainThreadDynamicAttrSlotKinds(
54
56
  let kind: MainThreadDynamicAttrKind | undefined;
55
57
  if (adapter === adaptMTEventAttrSlot) {
56
58
  kind = 'mt-event';
59
+ } else if (adapter === adaptGestureAttrSlot) {
60
+ kind = 'gesture';
57
61
  } else if (adapter === adaptMTRefAttrSlot) {
58
62
  kind = 'mt-ref';
63
+ } else if (adapter === adaptSpreadAttrSlot) {
64
+ kind = 'spread';
59
65
  }
60
66
  if (kind) {
61
67
  (slotKinds ??= new Map()).set(attrPlan[planIndex] as number, kind);
@@ -72,7 +78,7 @@ export function hasMainThreadRefAttrSlot(templateType: string): boolean {
72
78
  return false;
73
79
  }
74
80
  for (const kind of slotKinds.values()) {
75
- if (kind === 'mt-ref') {
81
+ if (kind === 'mt-ref' || kind === 'spread') {
76
82
  return true;
77
83
  }
78
84
  }
@@ -135,12 +141,33 @@ export function adaptMTRefAttrSlot(
135
141
  );
136
142
  }
137
143
 
144
+ export function adaptGestureAttrSlot(
145
+ _handleId: number,
146
+ attrSlotIndex: number,
147
+ value: unknown,
148
+ context?: EtAttrAdapterContext,
149
+ ): SerializableValue | null {
150
+ return prepareGestureForNative(
151
+ value,
152
+ context?.previousPreparedSlots[attrSlotIndex] as GestureSlotValue | null | undefined,
153
+ ) as unknown as SerializableValue | null;
154
+ }
155
+
138
156
  export function adaptSpreadAttrSlot(
139
157
  handleId: number,
140
158
  attrSlotIndex: number,
141
159
  value: unknown,
160
+ context?: EtAttrAdapterContext,
161
+ ): SerializableValue | null {
162
+ return prepareSpreadAttrSlot(handleId, attrSlotIndex, value, context);
163
+ }
164
+
165
+ export function adaptTypedSpreadAttrSlot(
166
+ handleId: number,
167
+ attrSlotIndex: number,
168
+ value: unknown,
142
169
  ): SerializableValue | null {
143
- return prepareSpreadAttrSlot(handleId, attrSlotIndex, value);
170
+ return prepareTypedSpreadAttrSlot(handleId, attrSlotIndex, value);
144
171
  }
145
172
 
146
173
  export function clearEtAttrPlanMap(): void {
@@ -11,7 +11,7 @@ import {
11
11
  runOnBackground,
12
12
  } from '../../../core/background-function/run-on-background.js';
13
13
  import { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';
14
- import { isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';
14
+ import { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';
15
15
 
16
16
  type BackgroundFunctionCtx = Parameters<typeof registerBackgroundFunctionCtx>[0];
17
17
  type RetainableMainThreadCtx = Parameters<typeof retainWorkletCtx>[0];
@@ -33,6 +33,8 @@ export function registerMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroun
33
33
  }
34
34
  }
35
35
 
36
+ // Track the input before Native takes ownership. If Native rejects it, collection
37
+ // must still release its already-registered background execution; slot state commits later.
36
38
  export function retainMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {
37
39
  retainWorkletCtx(ctx as RetainableMainThreadCtx);
38
40
  }
@@ -43,6 +45,11 @@ export function resetElementTemplateBackgroundFunctionRuntime(): void {
43
45
  }
44
46
 
45
47
  export function resetElementTemplateMainThreadBackgroundFunctionRuntime(): void {
48
+ const manager = globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager;
49
+ if (manager) {
50
+ manager.dispose();
51
+ globalThis.lynxWorkletImpl._jsFunctionLifecycleManager = new JsFunctionLifecycleManager();
52
+ }
46
53
  clearDelayedRunOnBackgroundFunctions();
47
54
  resetFunctionCallReturnListener();
48
55
  }