@lynx-js/react 0.129.3 → 0.129.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +10 -2
  4. package/refresh/.turbo/turbo-build.log +3 -3
  5. package/refresh/dist/index.js +113 -20
  6. package/refresh/rslib.config.ts +13 -3
  7. package/refresh/src/index.ts +100 -0
  8. package/refresh/src/self.ts +38 -0
  9. package/runtime/__test__/{snapshot → core}/attribute-name.test.ts +1 -1
  10. package/runtime/__test__/core/background-function.test.ts +37 -0
  11. package/runtime/__test__/{shared → core}/component-stack.test.ts +4 -4
  12. package/runtime/__test__/core/lynx/env.test.ts +146 -0
  13. package/runtime/__test__/core/ref.test.ts +218 -1
  14. package/runtime/__test__/core/sync-effect-flush.test.ts +58 -0
  15. package/runtime/__test__/element-template/debug/alog.test.ts +20 -12
  16. package/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsx +15 -34
  17. package/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txt +2 -0
  18. package/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txt +1 -0
  19. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txt +6 -1
  20. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txt +1 -0
  21. package/runtime/__test__/element-template/fixtures/background/hydrate/{coverage.move-before-child → children.reconciles-raw-text-slots}/case.tsx +1 -1
  22. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txt +1 -0
  23. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txt +1 -0
  24. package/runtime/__test__/element-template/fixtures/background/hydrate/root-key-mismatch-reconciles/output.txt +1 -0
  25. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt +1 -0
  26. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt +1 -0
  27. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt +1 -0
  28. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +1 -0
  29. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt +1 -0
  30. package/runtime/__test__/element-template/fixtures/background/instance/ops/emits-bundle-url-in-create-template/output.txt +1 -0
  31. package/runtime/__test__/element-template/fixtures/list/mts/index.tsx +185 -0
  32. package/runtime/__test__/element-template/fixtures/page/render-page/native-log.txt +1 -0
  33. package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/case.tsx +2 -0
  34. package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/ops.txt +1 -0
  35. package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/ops.txt +1 -0
  36. package/runtime/__test__/element-template/fixtures/render/child-siblings/papi.txt +10 -5
  37. package/runtime/__test__/element-template/fixtures/render/component/papi.txt +6 -3
  38. package/runtime/__test__/element-template/fixtures/render/component-slot-content/papi.txt +6 -3
  39. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/papi.txt +2 -1
  40. package/runtime/__test__/element-template/fixtures/render/direct-native/appends-root-text-via-append-element/native-log.txt +1 -0
  41. package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/native-log.txt +2 -0
  42. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-template-children-in-the-same-slot/native-log.txt +3 -0
  43. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/native-log.txt +3 -0
  44. package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/native-log.txt +3 -0
  45. package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/native-log.txt +3 -0
  46. package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/native-log.txt +1 -0
  47. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/papi.txt +14 -7
  48. package/runtime/__test__/element-template/fixtures/render/mixed-children/papi.txt +8 -4
  49. package/runtime/__test__/element-template/fixtures/render/multiple-text/papi.txt +38 -19
  50. package/runtime/__test__/element-template/fixtures/render/nested-templates/papi.txt +6 -3
  51. package/runtime/__test__/element-template/fixtures/render/react-example/papi.txt +6 -3
  52. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/papi.txt +6 -3
  53. package/runtime/__test__/element-template/fixtures/render/template-dedupe/papi.txt +10 -5
  54. package/runtime/__test__/element-template/imports/suspense-lazy.test.ts +47 -4
  55. package/runtime/__test__/element-template/lynx/performance.test.ts +1 -0
  56. package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +1 -0
  57. package/runtime/__test__/element-template/native/index.test.ts +9 -9
  58. package/runtime/__test__/element-template/native/mts-destroy.test.ts +65 -17
  59. package/runtime/__test__/element-template/native/reload.test.ts +19 -12
  60. package/runtime/__test__/element-template/runtime/background/adapter/background-adapter.et.test.tsx +0 -32
  61. package/runtime/__test__/element-template/runtime/background/commit-context.test.ts +0 -14
  62. package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +10 -0
  63. package/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +22 -0
  64. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +197 -252
  65. package/runtime/__test__/element-template/runtime/background/instance.test.ts +277 -126
  66. package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +1 -1
  67. package/runtime/__test__/element-template/runtime/background/passive-update-depth.test.tsx +496 -0
  68. package/runtime/__test__/element-template/runtime/background/render/preact.test.tsx +16 -22
  69. package/runtime/__test__/element-template/runtime/background/root-render.test.tsx +5 -3
  70. package/runtime/__test__/element-template/runtime/background/suspense.test.tsx +2 -0
  71. package/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx +1 -0
  72. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +1 -0
  73. package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +4 -5
  74. package/runtime/__test__/element-template/runtime/list/list-mts-compiled.test.ts +525 -0
  75. package/runtime/__test__/element-template/runtime/page/compiled-fixtures.test.tsx +2 -0
  76. package/runtime/__test__/element-template/runtime/page/root-instance.test.ts +2 -14
  77. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +425 -1032
  78. package/runtime/__test__/element-template/runtime/patch/patch-listener-alog.test.ts +1 -0
  79. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +1 -0
  80. package/runtime/__test__/element-template/runtime/prop-adapters/event.test.ts +0 -20
  81. package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +2 -1
  82. package/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts +1 -0
  83. package/runtime/__test__/element-template/runtime/prop-adapters/ref.test.ts +65 -0
  84. package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +12 -4
  85. package/runtime/__test__/element-template/runtime/render/render-components.test.jsx +2 -5
  86. package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +56 -121
  87. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +18 -17
  88. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +5 -4
  89. package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +2 -0
  90. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +1 -60
  91. package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +65 -89
  92. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +8 -6
  93. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +34 -6
  94. package/runtime/__test__/element-template/test-utils/debug/updateRunner.test.tsx +20 -12
  95. package/runtime/__test__/element-template/test-utils/debug/updateRunner.ts +2 -28
  96. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.test.ts +14 -5
  97. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.ts +1 -57
  98. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +29 -13
  99. package/runtime/__test__/element-template/vitest.config.ts +2 -1
  100. package/runtime/__test__/guardrails/snapshot-containment.test.ts +98 -77
  101. package/runtime/__test__/snapshot/debug/passive-update-depth.test.jsx +549 -0
  102. package/runtime/__test__/snapshot/debug/profile.test.jsx +147 -26
  103. package/runtime/__test__/snapshot/debug/react-hooks-profile.test.jsx +3 -3
  104. package/runtime/__test__/snapshot/lifecycle/reload-background-function.test.jsx +138 -1
  105. package/runtime/__test__/snapshot/lifecycle/reload-delayed-background.test.jsx +55 -1
  106. package/runtime/__test__/snapshot/lifecycle/transfer.mts.test.jsx +286 -0
  107. package/runtime/__test__/snapshot/lifecycle/transfer.test.jsx +415 -0
  108. package/runtime/__test__/snapshot/list.test.jsx +109 -0
  109. package/runtime/__test__/snapshot/lynx/suspense.test.jsx +48 -0
  110. package/runtime/__test__/snapshot/lynxQueueMicrotask.test.jsx +2 -2
  111. package/runtime/__test__/snapshot/ref.test.jsx +124 -1
  112. package/runtime/__test__/snapshot/utils/envManager.ts +7 -0
  113. package/runtime/__test__/snapshot/utils/globals.js +1 -0
  114. package/runtime/__test__/worklet-runtime/delayWorkletEvent.test.js +43 -11
  115. package/runtime/__test__/worklet-runtime/hydrate.test.js +1 -0
  116. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +24 -16
  117. package/runtime/__test__/worklet-runtime/lifecycle.test.js +297 -0
  118. package/runtime/__test__/worklet-runtime/profile.test.js +12 -6
  119. package/runtime/__test__/worklet-runtime/runOnBackground.test.js +188 -0
  120. package/runtime/__test__/worklet-runtime/workletRef.test.js +16 -0
  121. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +53 -1
  122. package/runtime/lazy/element-template-internal.js +1 -0
  123. package/runtime/lazy/internal.js +1 -0
  124. package/runtime/lib/core/attribute-name.js.map +1 -0
  125. package/runtime/lib/core/background-function/run-on-background.js +7 -7
  126. package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
  127. package/runtime/lib/core/compat/componentIs.d.ts +1 -0
  128. package/runtime/lib/core/compat/componentIs.js +20 -0
  129. package/runtime/lib/core/compat/componentIs.js.map +1 -0
  130. package/runtime/lib/{shared → core}/component-stack.js +1 -1
  131. package/runtime/lib/core/component-stack.js.map +1 -0
  132. package/runtime/lib/core/deep-equal.d.ts +1 -0
  133. package/runtime/lib/core/deep-equal.js +31 -0
  134. package/runtime/lib/core/deep-equal.js.map +1 -0
  135. package/runtime/lib/core/hooks/mainThreadImpl.js +1 -1
  136. package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -1
  137. package/runtime/lib/core/lynx/env.d.ts +1 -0
  138. package/runtime/lib/{element-template → core}/lynx/env.js +3 -2
  139. package/runtime/lib/core/lynx/env.js.map +1 -0
  140. package/runtime/lib/core/lynx-page-data.js +1 -1
  141. package/runtime/lib/core/lynx-page-data.js.map +1 -1
  142. package/runtime/lib/core/mts-capability.js +1 -1
  143. package/runtime/lib/core/mts-capability.js.map +1 -1
  144. package/runtime/lib/core/performance.js +2 -1
  145. package/runtime/lib/core/performance.js.map +1 -1
  146. package/runtime/lib/core/ref.d.ts +1 -2
  147. package/runtime/lib/core/ref.js +60 -9
  148. package/runtime/lib/core/ref.js.map +1 -1
  149. package/runtime/lib/core/sync-effect-flush.d.ts +9 -0
  150. package/runtime/lib/core/sync-effect-flush.js +31 -0
  151. package/runtime/lib/core/sync-effect-flush.js.map +1 -0
  152. package/runtime/lib/core/thread-function-call/main-thread.d.ts +1 -0
  153. package/runtime/lib/core/thread-function-call/main-thread.js +5 -2
  154. package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
  155. package/runtime/lib/element-template/background/attr-slots.d.ts +1 -0
  156. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  157. package/runtime/lib/element-template/background/commit-event.d.ts +6 -0
  158. package/runtime/lib/element-template/background/commit-event.js +36 -0
  159. package/runtime/lib/element-template/background/commit-event.js.map +1 -0
  160. package/runtime/lib/element-template/background/commit-hook.js +4 -24
  161. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  162. package/runtime/lib/element-template/background/destroy.js +2 -2
  163. package/runtime/lib/element-template/background/destroy.js.map +1 -1
  164. package/runtime/lib/element-template/background/hydrate.js +174 -87
  165. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  166. package/runtime/lib/element-template/background/hydration-listener.js +5 -25
  167. package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
  168. package/runtime/lib/element-template/background/instance.d.ts +7 -10
  169. package/runtime/lib/element-template/background/instance.js +65 -58
  170. package/runtime/lib/element-template/background/instance.js.map +1 -1
  171. package/runtime/lib/element-template/{runtime/template → background}/main-thread-function.js +4 -4
  172. package/runtime/lib/element-template/background/main-thread-function.js.map +1 -0
  173. package/runtime/lib/element-template/background/render-scope.js +2 -1
  174. package/runtime/lib/element-template/background/render-scope.js.map +1 -1
  175. package/runtime/lib/element-template/debug/alog.d.ts +1 -10
  176. package/runtime/lib/element-template/debug/alog.js +1 -16
  177. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  178. package/runtime/lib/element-template/debug/profile.js +1 -1
  179. package/runtime/lib/element-template/debug/profile.js.map +1 -1
  180. package/runtime/lib/element-template/index.d.ts +1 -1
  181. package/runtime/lib/element-template/index.js +1 -1
  182. package/runtime/lib/element-template/index.js.map +1 -1
  183. package/runtime/lib/element-template/internal.js +3 -0
  184. package/runtime/lib/element-template/internal.js.map +1 -1
  185. package/runtime/lib/element-template/native/index.js +4 -4
  186. package/runtime/lib/element-template/native/index.js.map +1 -1
  187. package/runtime/lib/element-template/native/mts-destroy.d.ts +2 -1
  188. package/runtime/lib/element-template/native/mts-destroy.js +15 -4
  189. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
  190. package/runtime/lib/element-template/native/patch-listener.js +4 -8
  191. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  192. package/runtime/lib/element-template/native/reload-main-thread.js +2 -6
  193. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  194. package/runtime/lib/element-template/prop-adapters/ref.d.ts +2 -1
  195. package/runtime/lib/element-template/prop-adapters/ref.js +4 -4
  196. package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -1
  197. package/runtime/lib/element-template/prop-adapters/spread.js +1 -1
  198. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  199. package/runtime/lib/element-template/protocol/opcodes.d.ts +0 -2
  200. package/runtime/lib/element-template/protocol/opcodes.js +0 -2
  201. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
  202. package/runtime/lib/element-template/protocol/types.d.ts +8 -30
  203. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  204. package/runtime/lib/element-template/runtime/list/list.d.ts +14 -54
  205. package/runtime/lib/element-template/runtime/list/list.js +82 -546
  206. package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
  207. package/runtime/lib/element-template/runtime/list/platform-info.d.ts +2 -0
  208. package/runtime/lib/element-template/runtime/list/platform-info.js +26 -0
  209. package/runtime/lib/element-template/runtime/list/platform-info.js.map +1 -0
  210. package/runtime/lib/element-template/runtime/patch.js +44 -128
  211. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  212. package/runtime/lib/element-template/runtime/render/create-rendered-host.d.ts +1 -1
  213. package/runtime/lib/element-template/runtime/render/create-rendered-host.js +24 -21
  214. package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -1
  215. package/runtime/lib/element-template/runtime/render/render-components.d.ts +1 -1
  216. package/runtime/lib/element-template/runtime/render/render-components.js +3 -6
  217. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
  218. package/runtime/lib/element-template/runtime/render/render-direct.js +21 -20
  219. package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -1
  220. package/runtime/lib/element-template/runtime/render/render-main-thread.js +0 -13
  221. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  222. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +8 -0
  223. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
  224. package/runtime/lib/element-template/runtime/template/handle.d.ts +3 -3
  225. package/runtime/lib/element-template/runtime/template/handle.js +3 -3
  226. package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
  227. package/runtime/lib/element-template/runtime/template/main-thread-background-function.d.ts +1 -0
  228. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -8
  229. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
  230. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +2 -1
  231. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +44 -28
  232. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  233. package/runtime/lib/element-template/runtime/template/typed-attributes.d.ts +2 -0
  234. package/runtime/lib/element-template/runtime/template/typed-attributes.js +8 -1
  235. package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
  236. package/runtime/lib/internal.d.ts +1 -0
  237. package/runtime/lib/internal.js +5 -10
  238. package/runtime/lib/internal.js.map +1 -1
  239. package/runtime/lib/lynx-api.js +6 -1
  240. package/runtime/lib/lynx-api.js.map +1 -1
  241. package/runtime/lib/lynx.js +4 -4
  242. package/runtime/lib/lynx.js.map +1 -1
  243. package/runtime/lib/root.d.ts +5 -1
  244. package/runtime/lib/root.js +12 -1
  245. package/runtime/lib/root.js.map +1 -1
  246. package/runtime/lib/shared/microtask.d.ts +1 -0
  247. package/runtime/lib/shared/microtask.js +28 -0
  248. package/runtime/lib/shared/microtask.js.map +1 -0
  249. package/runtime/lib/shared/utils.d.ts +8 -0
  250. package/runtime/lib/shared/utils.js +27 -0
  251. package/runtime/lib/shared/utils.js.map +1 -0
  252. package/runtime/lib/{worklet-runtime/utils → shared}/version.d.ts +1 -0
  253. package/runtime/lib/{worklet-runtime/utils → shared}/version.js +4 -2
  254. package/runtime/lib/shared/version.js.map +1 -0
  255. package/runtime/lib/snapshot/alog/render.js +1 -1
  256. package/runtime/lib/snapshot/alog/render.js.map +1 -1
  257. package/runtime/lib/snapshot/debug/profileHooks.js +28 -63
  258. package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
  259. package/runtime/lib/snapshot/lifecycle/destroy.js +2 -2
  260. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  261. package/runtime/lib/snapshot/lifecycle/isRendering.js +2 -1
  262. package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
  263. package/runtime/lib/snapshot/lifecycle/patch/commit.d.ts +7 -2
  264. package/runtime/lib/snapshot/lifecycle/patch/commit.js +11 -6
  265. package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
  266. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.d.ts +5 -0
  267. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +1 -1
  268. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  269. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +1 -1
  270. package/runtime/lib/snapshot/lifecycle/ref/delay.js +2 -2
  271. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  272. package/runtime/lib/snapshot/lifecycle/reload.js +3 -3
  273. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  274. package/runtime/lib/snapshot/list/list.js +12 -3
  275. package/runtime/lib/snapshot/list/list.js.map +1 -1
  276. package/runtime/lib/snapshot/lynx/env.js +2 -32
  277. package/runtime/lib/snapshot/lynx/env.js.map +1 -1
  278. package/runtime/lib/snapshot/lynx/tt.d.ts +3 -1
  279. package/runtime/lib/snapshot/lynx/tt.js +7 -3
  280. package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
  281. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +1 -1
  282. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  283. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
  284. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  285. package/runtime/lib/snapshot/snapshot/platformInfo.js +1 -1
  286. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
  287. package/runtime/lib/snapshot/snapshot/ref.d.ts +1 -0
  288. package/runtime/lib/snapshot/snapshot/ref.js +2 -2
  289. package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
  290. package/runtime/lib/snapshot/snapshot/snapshot.js +1 -1
  291. package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
  292. package/runtime/lib/snapshot/snapshot/spread.js +3 -2
  293. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
  294. package/runtime/lib/snapshot/transfer.d.ts +21 -0
  295. package/runtime/lib/snapshot/transfer.js +486 -0
  296. package/runtime/lib/snapshot/transfer.js.map +1 -0
  297. package/runtime/lib/snapshot/worklet/functionality.js +1 -1
  298. package/runtime/lib/snapshot/worklet/functionality.js.map +1 -1
  299. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  300. package/runtime/lib/worklet-runtime/api/element.js +1 -1
  301. package/runtime/lib/worklet-runtime/api/element.js.map +1 -1
  302. package/runtime/lib/worklet-runtime/api/lynxApi.js +1 -1
  303. package/runtime/lib/worklet-runtime/api/lynxApi.js.map +1 -1
  304. package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +3 -2
  305. package/runtime/lib/worklet-runtime/bindings/bindings.js +11 -1
  306. package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
  307. package/runtime/lib/worklet-runtime/bindings/lifecycle.d.ts +19 -0
  308. package/runtime/lib/worklet-runtime/bindings/lifecycle.js +49 -0
  309. package/runtime/lib/worklet-runtime/bindings/lifecycle.js.map +1 -0
  310. package/runtime/lib/worklet-runtime/bindings/observers.js +9 -1
  311. package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
  312. package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -0
  313. package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
  314. package/runtime/lib/worklet-runtime/delayWorkletEvent.d.ts +3 -5
  315. package/runtime/lib/worklet-runtime/delayWorkletEvent.js +49 -43
  316. package/runtime/lib/worklet-runtime/delayWorkletEvent.js.map +1 -1
  317. package/runtime/lib/worklet-runtime/global.d.ts +1 -2
  318. package/runtime/lib/worklet-runtime/global.js.map +1 -1
  319. package/runtime/lib/worklet-runtime/hydrate.js +2 -32
  320. package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
  321. package/runtime/lib/worklet-runtime/run-on-background/index.d.ts +28 -0
  322. package/runtime/lib/worklet-runtime/run-on-background/index.js +103 -0
  323. package/runtime/lib/worklet-runtime/run-on-background/index.js.map +1 -0
  324. package/runtime/lib/worklet-runtime/{jsFunctionLifecycle.d.ts → run-on-background/lifecycle.d.ts} +2 -2
  325. package/runtime/lib/worklet-runtime/{jsFunctionLifecycle.js → run-on-background/lifecycle.js} +12 -9
  326. package/runtime/lib/worklet-runtime/run-on-background/lifecycle.js.map +1 -0
  327. package/runtime/lib/worklet-runtime/utils/profile.js +1 -3
  328. package/runtime/lib/worklet-runtime/utils/profile.js.map +1 -1
  329. package/runtime/lib/worklet-runtime/workletRef.js +51 -54
  330. package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
  331. package/runtime/lib/worklet-runtime/workletRuntime.js +5 -6
  332. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  333. package/runtime/src/core/background-function/run-on-background.ts +7 -7
  334. package/runtime/src/core/compat/componentIs.ts +32 -0
  335. package/runtime/src/{shared → core}/component-stack.ts +1 -1
  336. package/runtime/src/core/deep-equal.ts +33 -0
  337. package/runtime/src/core/hooks/mainThreadImpl.ts +1 -1
  338. package/runtime/src/{element-template → core}/lynx/env.ts +6 -4
  339. package/runtime/src/core/lynx-page-data.ts +1 -1
  340. package/runtime/src/core/mts-capability.ts +1 -1
  341. package/runtime/src/core/performance.ts +2 -1
  342. package/runtime/src/core/ref.ts +92 -15
  343. package/runtime/src/core/sync-effect-flush.ts +30 -0
  344. package/runtime/src/core/thread-function-call/main-thread.ts +6 -2
  345. package/runtime/src/element-template/background/attr-slots.ts +2 -2
  346. package/runtime/src/element-template/background/commit-event.ts +52 -0
  347. package/runtime/src/element-template/background/commit-hook.ts +5 -32
  348. package/runtime/src/element-template/background/destroy.ts +2 -2
  349. package/runtime/src/element-template/background/hydrate.ts +234 -122
  350. package/runtime/src/element-template/background/hydration-listener.ts +7 -32
  351. package/runtime/src/element-template/background/instance.ts +82 -82
  352. package/runtime/src/element-template/{runtime/template → background}/main-thread-function.ts +4 -7
  353. package/runtime/src/element-template/background/render-scope.ts +2 -1
  354. package/runtime/src/element-template/debug/alog.ts +2 -30
  355. package/runtime/src/element-template/debug/profile.ts +1 -1
  356. package/runtime/src/element-template/index.ts +1 -1
  357. package/runtime/src/element-template/internal.ts +4 -0
  358. package/runtime/src/element-template/native/index.ts +4 -4
  359. package/runtime/src/element-template/native/mts-destroy.ts +21 -4
  360. package/runtime/src/element-template/native/patch-listener.ts +6 -7
  361. package/runtime/src/element-template/native/reload-main-thread.ts +2 -6
  362. package/runtime/src/element-template/prop-adapters/ref.ts +12 -5
  363. package/runtime/src/element-template/prop-adapters/spread.ts +1 -1
  364. package/runtime/src/element-template/protocol/opcodes.ts +0 -2
  365. package/runtime/src/element-template/protocol/types.ts +10 -38
  366. package/runtime/src/element-template/runtime/list/list.ts +115 -744
  367. package/runtime/src/element-template/runtime/list/platform-info.ts +31 -0
  368. package/runtime/src/element-template/runtime/patch.ts +78 -197
  369. package/runtime/src/element-template/runtime/render/create-rendered-host.ts +27 -31
  370. package/runtime/src/element-template/runtime/render/render-components.ts +2 -5
  371. package/runtime/src/element-template/runtime/render/render-direct.ts +19 -18
  372. package/runtime/src/element-template/runtime/render/render-main-thread.ts +0 -14
  373. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +9 -0
  374. package/runtime/src/element-template/runtime/template/handle.ts +5 -2
  375. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +9 -8
  376. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +44 -30
  377. package/runtime/src/element-template/runtime/template/typed-attributes.ts +17 -1
  378. package/runtime/src/element-template/types.d.ts +6 -22
  379. package/runtime/src/internal.ts +6 -13
  380. package/runtime/src/lynx-api.ts +6 -1
  381. package/runtime/src/lynx.ts +4 -4
  382. package/runtime/src/root.ts +17 -1
  383. package/runtime/src/shared/microtask.ts +26 -0
  384. package/runtime/src/shared/utils.ts +37 -0
  385. package/runtime/src/{worklet-runtime/utils → shared}/version.ts +6 -4
  386. package/runtime/src/snapshot/alog/render.ts +1 -1
  387. package/runtime/src/snapshot/debug/profileHooks.ts +31 -92
  388. package/runtime/src/snapshot/lifecycle/destroy.ts +2 -2
  389. package/runtime/src/snapshot/lifecycle/isRendering.ts +2 -1
  390. package/runtime/src/snapshot/lifecycle/patch/commit.ts +28 -7
  391. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +1 -1
  392. package/runtime/src/snapshot/lifecycle/ref/delay.ts +5 -2
  393. package/runtime/src/snapshot/lifecycle/reload.ts +3 -4
  394. package/runtime/src/snapshot/list/list.ts +12 -3
  395. package/runtime/src/snapshot/lynx/env.ts +3 -43
  396. package/runtime/src/snapshot/lynx/tt.ts +8 -3
  397. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +1 -1
  398. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
  399. package/runtime/src/snapshot/snapshot/platformInfo.ts +1 -1
  400. package/runtime/src/snapshot/snapshot/ref.ts +7 -4
  401. package/runtime/src/snapshot/snapshot/snapshot.ts +1 -1
  402. package/runtime/src/snapshot/snapshot/spread.ts +3 -2
  403. package/runtime/src/snapshot/transfer.ts +535 -0
  404. package/runtime/src/snapshot/worklet/functionality.ts +1 -1
  405. package/runtime/src/worklet-runtime/api/element.ts +1 -1
  406. package/runtime/src/worklet-runtime/api/lynxApi.ts +1 -1
  407. package/runtime/src/worklet-runtime/bindings/bindings.ts +12 -0
  408. package/runtime/src/worklet-runtime/bindings/lifecycle.ts +51 -0
  409. package/runtime/src/worklet-runtime/bindings/observers.ts +9 -1
  410. package/runtime/src/worklet-runtime/bindings/types.ts +1 -0
  411. package/runtime/src/worklet-runtime/delayWorkletEvent.ts +57 -54
  412. package/runtime/src/worklet-runtime/global.ts +1 -2
  413. package/runtime/src/worklet-runtime/hydrate.ts +2 -35
  414. package/runtime/src/worklet-runtime/run-on-background/index.ts +145 -0
  415. package/runtime/src/worklet-runtime/{jsFunctionLifecycle.ts → run-on-background/lifecycle.ts} +11 -9
  416. package/runtime/src/worklet-runtime/utils/profile.ts +1 -3
  417. package/runtime/src/worklet-runtime/workletRef.ts +63 -62
  418. package/runtime/src/worklet-runtime/workletRuntime.ts +10 -10
  419. package/runtime/types/internal-preact.d.ts +2 -0
  420. package/runtime/vitest.config.ts +0 -1
  421. package/testing-library/.turbo/turbo-build.log +11 -11
  422. package/testing-library/dist/pure.js +7 -4
  423. package/testing-library/dist/setupFiles/common/runtime-setup.js +3 -1
  424. package/testing-library/dist/setupFiles/inner/rstest.js +1 -1
  425. package/testing-library/dist/setupFiles/inner/vitest.js +1 -1
  426. package/testing-library/src/__tests__/events.test.jsx +1 -1
  427. package/testing-library/src/__tests__/list.test.jsx +52 -0
  428. package/testing-library/src/__tests__/worklet.test.jsx +81 -0
  429. package/testing-library/src/fire-event.ts +1 -1
  430. package/testing-library/src/pure.jsx +5 -2
  431. package/testing-library/src/setupFiles/common/runtime-setup.js +2 -0
  432. package/transform/.turbo/turbo-build$colon$wasm.log +45 -44
  433. package/transform/__test__/fixture.spec.js +1 -1
  434. package/transform/cjs/browser.cjs +11 -0
  435. package/transform/crates/swc_plugin_compat/lib.rs +20 -2
  436. package/transform/crates/swc_plugin_compat/napi.rs +7 -0
  437. package/transform/crates/swc_plugin_dynamic_import/lib.rs +15 -4
  438. package/transform/crates/swc_plugin_element_template/attr_name.rs +0 -3
  439. package/transform/crates/swc_plugin_element_template/extractor.rs +0 -8
  440. package/transform/crates/swc_plugin_element_template/lib.rs +12 -1
  441. package/transform/crates/swc_plugin_element_template/tests/element_template.rs +19 -45
  442. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +35 -19
  443. package/transform/crates/swc_plugin_worklet/lib.rs +11 -7
  444. package/transform/dist/wasm.cjs +1 -1
  445. package/transform/rspack-napi/lib/index.js +1 -4
  446. package/transform/rspack-napi/lib/index.js.map +1 -1
  447. package/transform/rspack-napi/src/index.ts +1 -4
  448. package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
  449. package/transform/src/lib.rs +394 -27
  450. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +415 -107
  451. package/transform/swc-plugin-reactlynx/src/lib.rs +99 -22
  452. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  453. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +29 -339
  454. package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
  455. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txt +0 -10
  456. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsx +0 -5
  457. package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/case.ts +0 -11
  458. package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/output.txt +0 -1
  459. package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/case.ts +0 -23
  460. package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/output.txt +0 -6
  461. package/runtime/__test__/element-template/lynx/env.test.ts +0 -242
  462. package/runtime/__test__/element-template/runtime/page/authored-page.test.ts +0 -35
  463. package/runtime/__test__/element-template/runtime/patch/update-fixture-helper.test.tsx +0 -40
  464. package/runtime/__test__/snapshot/lynx-data-processors.test.ts +0 -3
  465. package/runtime/lib/element-template/lynx/env.d.ts +0 -1
  466. package/runtime/lib/element-template/lynx/env.js.map +0 -1
  467. package/runtime/lib/element-template/runtime/template/main-thread-function.js.map +0 -1
  468. package/runtime/lib/shared/attribute-name.js.map +0 -1
  469. package/runtime/lib/shared/component-stack.js.map +0 -1
  470. package/runtime/lib/snapshot/alog/index.d.ts +0 -1
  471. package/runtime/lib/snapshot/alog/index.js +0 -8
  472. package/runtime/lib/snapshot/alog/index.js.map +0 -1
  473. package/runtime/lib/snapshot/compat/componentIs.d.ts +0 -4
  474. package/runtime/lib/snapshot/compat/componentIs.js +0 -20
  475. package/runtime/lib/snapshot/compat/componentIs.js.map +0 -1
  476. package/runtime/lib/utils.d.ts +0 -19
  477. package/runtime/lib/utils.js +0 -119
  478. package/runtime/lib/utils.js.map +0 -1
  479. package/runtime/lib/worklet-runtime/delayRunOnBackground.d.ts +0 -13
  480. package/runtime/lib/worklet-runtime/delayRunOnBackground.js +0 -29
  481. package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +0 -1
  482. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +0 -1
  483. package/runtime/lib/worklet-runtime/utils/version.js.map +0 -1
  484. package/runtime/src/snapshot/alog/index.ts +0 -8
  485. package/runtime/src/snapshot/compat/componentIs.ts +0 -30
  486. package/runtime/src/utils.ts +0 -134
  487. package/runtime/src/worklet-runtime/delayRunOnBackground.ts +0 -53
  488. /package/runtime/__test__/element-template/fixtures/background/hydrate/{coverage.raw-text-key-branches → children.reconciles-raw-text-slots}/output.txt +0 -0
  489. /package/runtime/__test__/element-template/runtime/{template → background}/main-thread-function.test.ts +0 -0
  490. /package/runtime/lib/{shared → core}/attribute-name.d.ts +0 -0
  491. /package/runtime/lib/{shared → core}/attribute-name.js +0 -0
  492. /package/runtime/lib/{shared → core}/component-stack.d.ts +0 -0
  493. /package/runtime/lib/element-template/{runtime/template → background}/main-thread-function.d.ts +0 -0
  494. /package/runtime/src/{shared → core}/attribute-name.ts +0 -0
@@ -13,17 +13,17 @@ export function reserveElementTemplateId() {
13
13
  const id = nextId--;
14
14
  return id;
15
15
  }
16
- export function createElementTemplateWithReservedHandle(handleId, templateKey, bundleUrl, attributeSlots, childSlots, hasDynamicAttributes = true) {
16
+ export function createElementTemplateWithReservedHandle(handleId, templateKey, bundleUrl, attributeSlots, childSlots, hasDynamicAttributes = true, options, isCreatedByPatch = false) {
17
17
  // Adapter-free compiled hosts need neither dynamic state nor native slot preparation.
18
18
  const templateType = hasDynamicAttributes ? elementTemplateTypeTag(templateKey, bundleUrl) : undefined;
19
19
  const nativeAttributeSlots = templateType === undefined
20
20
  ? attributeSlots
21
21
  : prepareMainThreadDynamicAttrSlotsForNative(templateType, attributeSlots);
22
- const nativeRef = __CreateElementTemplate(templateKey, bundleUrl, nativeAttributeSlots, childSlots, handleId);
22
+ const nativeRef = __CreateElementTemplate(templateKey, bundleUrl, nativeAttributeSlots, childSlots, handleId, options);
23
23
  if (nativeRef) {
24
24
  setElementTemplateNativeRef(handleId, nativeRef);
25
25
  if (templateType !== undefined) {
26
- initializeMainThreadDynamicAttrSlots(handleId, templateType, attributeSlots);
26
+ initializeMainThreadDynamicAttrSlots(handleId, templateType, attributeSlots, isCreatedByPatch);
27
27
  }
28
28
  }
29
29
  return nativeRef;
@@ -1 +1 @@
1
- {"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/handle.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EACL,yCAAyC,EACzC,0CAA0C,EAC1C,oCAAoC,EACpC,0CAA0C,GAC3C,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5F,O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S,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,SAAgC,EAChC,cAAsB,EACtB,QAA+B,EAC/B,YAA0C,EAC1C,cAAoE;IAEpE,6BAA6B,CAAC,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACjF,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,yCAAyC,CAAC,cAAc,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,CAAC,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EAAU;IACjD,8BAA8B,CAAC,EAAE,CAAC,CAAC;IACnC,0CAA0C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n attachMainThreadDynamicAttrRefsForSubtree,\n deleteMainThreadDynamicAttrStateForSubtree,\n initializeMainThreadDynamicAttrSlots,\n prepareMainThreadDynamicAttrSlotsForNative,\n} from './main-thread-dynamic-attr-state.js';\nimport type { MainThreadDynamicAttrSubtreeHandle } from './main-thread-dynamic-attr-state.js';\nimport { deleteElementTemplateNativeRef, setElementTemplateNativeRef } from './registry.js';\nimport { elementTemplateTypeTag } from '../../protocol/template-type.js';\nimport type {\n RuntimeChildSlots,\n RuntimeOptions,\n RuntimeTypedElementAttributes,\n RuntimeTypedListOptions,\n SerializableValue,\n} from '../../protocol/types.js';\n\n// Main-thread IFR allocates ids as consecutive negative integers.\nlet nextId = -1;\n\nexport function getNextElementTemplateId(): number {\n return nextId;\n}\n\nexport function reserveElementTemplateId(): number {\n const id = nextId--;\n return id;\n}\n\nexport function createElementTemplateWithReservedHandle(\n handleId: number,\n templateKey: string,\n bundleUrl: string | null | undefined,\n attributeSlots: SerializableValue[] | null | undefined,\n childSlots: RuntimeChildSlots | null | undefined,\n hasDynamicAttributes = true,\n): ElementTemplateHandle {\n // Adapter-free compiled hosts need neither dynamic state nor native slot preparation.\n const templateType = hasDynamicAttributes ? elementTemplateTypeTag(templateKey, bundleUrl) : undefined;\n const nativeAttributeSlots = templateType === undefined\n ? attributeSlots\n : prepareMainThreadDynamicAttrSlotsForNative(templateType, attributeSlots);\n const nativeRef = __CreateElementTemplate(\n templateKey,\n bundleUrl,\n nativeAttributeSlots,\n childSlots,\n handleId,\n );\n if (nativeRef) {\n setElementTemplateNativeRef(handleId, nativeRef);\n if (templateType !== undefined) {\n initializeMainThreadDynamicAttrSlots(\n handleId,\n templateType,\n attributeSlots,\n );\n }\n }\n return nativeRef;\n}\n\nexport function createTypedElementTemplateWithReservedHandle(\n handleId: number,\n type: string,\n attributes: RuntimeTypedElementAttributes | null | undefined,\n childSlots: RuntimeChildSlots | null | undefined,\n options: RuntimeOptions | RuntimeTypedListOptions | null | undefined,\n): ElementTemplateHandle {\n const nativeRef = __CreateTypedElementTemplate(\n type,\n attributes,\n childSlots,\n handleId,\n options,\n );\n setElementTemplateNativeRef(handleId, nativeRef);\n return nativeRef;\n}\n\nexport function insertElementTemplateSubtree(\n targetRef: ElementTemplateHandle,\n childSlotIndex: number,\n childRef: ElementTemplateHandle,\n referenceRef: ElementTemplateHandle | null,\n subtreeHandles: readonly MainThreadDynamicAttrSubtreeHandle[] | null,\n): void {\n __InsertNodeToElementTemplate(targetRef, childSlotIndex, childRef, referenceRef);\n if (subtreeHandles !== null) {\n attachMainThreadDynamicAttrRefsForSubtree(subtreeHandles);\n }\n}\n\nexport function resetTemplateId(): void {\n nextId = -1;\n}\n\nexport function destroyElementTemplateId(id: number): void {\n deleteElementTemplateNativeRef(id);\n deleteMainThreadDynamicAttrStateForSubtree([id]);\n}\n"]}
1
+ {"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/handle.ts"],"names":[],"m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ACJ,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,4CAA4C,CAC1D,QAAgB,EAChB,IAAY,EACZ,UAA4D,EAC5D,UAAgD,EAChD,OAA0C;IAE1C,MAAM,SAAS,GAAG,4BAA4B,CAC5C,IAAI,EACJ,UAAU,EACV,UAAU,EACV,QAAQ,EACR,OAAO,CACR,CAAC;IACF,2BAA2B,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,SAAgC,EAChC,cAAsB,EACtB,QAA+B,EAC/B,YAA0C,EAC1C,cAAoE;IAEpE,6BAA6B,CAAC,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACjF,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,yCAAyC,CAAC,cAAc,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,CAAC,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EAAU;IACjD,8BAA8B,CAAC,EAAE,CAAC,CAAC;IACnC,0CAA0C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n attachMainThreadDynamicAttrRefsForSubtree,\n deleteMainThreadDynamicAttrStateForSubtree,\n initializeMainThreadDynamicAttrSlots,\n prepareMainThreadDynamicAttrSlotsForNative,\n} from './main-thread-dynamic-attr-state.js';\nimport type { MainThreadDynamicAttrSubtreeHandle } from './main-thread-dynamic-attr-state.js';\nimport { deleteElementTemplateNativeRef, setElementTemplateNativeRef } from './registry.js';\nimport { elementTemplateTypeTag } from '../../protocol/template-type.js';\nimport type {\n RuntimeChildSlots,\n RuntimeOptions,\n RuntimeTypedElementAttributes,\n SerializableValue,\n} from '../../protocol/types.js';\n\n// Main-thread IFR allocates ids as consecutive negative integers.\nlet nextId = -1;\n\nexport function getNextElementTemplateId(): number {\n return nextId;\n}\n\nexport function reserveElementTemplateId(): number {\n const id = nextId--;\n return id;\n}\n\nexport function createElementTemplateWithReservedHandle(\n handleId: number,\n templateKey: string,\n bundleUrl: string | null | undefined,\n attributeSlots: SerializableValue[] | null | undefined,\n childSlots: RuntimeChildSlots | null | undefined,\n hasDynamicAttributes = true,\n options?: RuntimeOptions | null,\n isCreatedByPatch = false,\n): ElementTemplateHandle {\n // Adapter-free compiled hosts need neither dynamic state nor native slot preparation.\n const templateType = hasDynamicAttributes ? elementTemplateTypeTag(templateKey, bundleUrl) : undefined;\n const nativeAttributeSlots = templateType === undefined\n ? attributeSlots\n : prepareMainThreadDynamicAttrSlotsForNative(templateType, attributeSlots);\n const nativeRef = __CreateElementTemplate(\n templateKey,\n bundleUrl,\n nativeAttributeSlots,\n childSlots,\n handleId,\n options,\n );\n if (nativeRef) {\n setElementTemplateNativeRef(handleId, nativeRef);\n if (templateType !== undefined) {\n initializeMainThreadDynamicAttrSlots(\n handleId,\n templateType,\n attributeSlots,\n isCreatedByPatch,\n );\n }\n }\n return nativeRef;\n}\n\nexport function createTypedElementTemplateWithReservedHandle(\n handleId: number,\n type: string,\n attributes: RuntimeTypedElementAttributes | null | undefined,\n childSlots: RuntimeChildSlots | null | undefined,\n options: RuntimeOptions | null | undefined,\n): ElementTemplateHandle {\n const nativeRef = __CreateTypedElementTemplate(\n type,\n attributes,\n childSlots,\n handleId,\n options,\n );\n setElementTemplateNativeRef(handleId, nativeRef);\n return nativeRef;\n}\n\nexport function insertElementTemplateSubtree(\n targetRef: ElementTemplateHandle,\n childSlotIndex: number,\n childRef: ElementTemplateHandle,\n referenceRef: ElementTemplateHandle | null,\n subtreeHandles: readonly MainThreadDynamicAttrSubtreeHandle[] | null,\n): void {\n __InsertNodeToElementTemplate(targetRef, childSlotIndex, childRef, referenceRef);\n if (subtreeHandles !== null) {\n attachMainThreadDynamicAttrRefsForSubtree(subtreeHandles);\n }\n}\n\nexport function resetTemplateId(): void {\n nextId = -1;\n}\n\nexport function destroyElementTemplateId(id: number): void {\n deleteElementTemplateNativeRef(id);\n deleteMainThreadDynamicAttrStateForSubtree([id]);\n}\n"]}
@@ -8,3 +8,4 @@ export declare function registerMainThreadBackgroundFunctionCtx(ctx: MainThreadB
8
8
  export declare function retainMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void;
9
9
  export declare function resetElementTemplateBackgroundFunctionRuntime(): void;
10
10
  export declare function resetElementTemplateMainThreadBackgroundFunctionRuntime(): void;
11
+ export declare function disposeElementTemplateMainThreadBackgroundFunctionRuntime(): void;
@@ -1,11 +1,12 @@
1
1
  // Copyright 2026 The Lynx Authors. All rights reserved.
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
- import { clearDelayedRunOnBackgroundFunctions, retainWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';
4
+ import { retainWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';
5
5
  import { createBackgroundFunctionHandle } from '../../../core/background-function/handle.js';
6
6
  import { registerBackgroundFunctionCtx, resetBackgroundFunctionRuntime, runOnBackground, } from '../../../core/background-function/run-on-background.js';
7
7
  import { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';
8
- import { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';
8
+ import { isRunOnBackgroundEnabled } from '../../../shared/version.js';
9
+ import { disposeWorkletRuntime, resetWorkletRuntimeForReload } from '../../../worklet-runtime/bindings/lifecycle.js';
9
10
  /**
10
11
  * @internal transform-generated runtime helper for background JS function handles.
11
12
  */
@@ -26,12 +27,11 @@ export function resetElementTemplateBackgroundFunctionRuntime() {
26
27
  resetFunctionCallReturnListener();
27
28
  }
28
29
  export function resetElementTemplateMainThreadBackgroundFunctionRuntime() {
29
- const manager = globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager;
30
- if (manager) {
31
- manager.dispose();
32
- globalThis.lynxWorkletImpl._jsFunctionLifecycleManager = new JsFunctionLifecycleManager();
33
- }
34
- clearDelayedRunOnBackgroundFunctions();
30
+ resetWorkletRuntimeForReload();
31
+ resetFunctionCallReturnListener();
32
+ }
33
+ export function disposeElementTemplateMainThreadBackgroundFunctionRuntime() {
34
+ disposeWorkletRuntime();
35
35
  resetFunctionCallReturnListener();
36
36
  }
37
37
  //# sourceMappingURL=main-thread-background-function.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main-thread-background-function.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/main-thread-background-function.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oCAAoC,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAEjH,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,eAAe,GAChB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAUvH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,UAAU,uCAAuC,CAAC,GAAoC;IAC1F,IAAI,MAAM,IAAI,wBAAwB,EAAE,EAAE,CAAC;QACzC,6BAA6B,CAAC,GAA4B,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,4FAA4F;AAC5F,MAAM,UAAU,qCAAqC,CAAC,GAAoC;IACxF,gBAAgB,CAAC,GAA8B,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,6CAA6C;IAC3D,8BAA8B,EAAE,CAAC;IACjC,+BAA+B,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,uDAAuD;IACrE,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,EAAE,2BAA2B,CAAC;IACxE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,UAAU,CAAC,eAAe,CAAC,2BAA2B,GAAG,IAAI,0BAA0B,EAAE,CAAC;IAC5F,CAAC;IACD,oCAAoC,EAAE,CAAC;IACvC,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { clearDelayedRunOnBackgroundFunctions, retainWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { createBackgroundFunctionHandle } from '../../../core/background-function/handle.js';\nimport {\n registerBackgroundFunctionCtx,\n resetBackgroundFunctionRuntime,\n runOnBackground,\n} from '../../../core/background-function/run-on-background.js';\nimport { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';\nimport { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';\n\ntype BackgroundFunctionCtx = Parameters<typeof registerBackgroundFunctionCtx>[0];\ntype RetainableMainThreadCtx = Parameters<typeof retainWorkletCtx>[0];\n\ninterface MainThreadBackgroundFunctionCtx {\n _wkltId: string;\n [key: string]: unknown;\n}\n\n/**\n * @internal transform-generated runtime helper for background JS function handles.\n */\nexport const transformToWorklet = createBackgroundFunctionHandle;\nexport { runOnBackground };\n\nexport function registerMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {\n if (__JS__ && isRunOnBackgroundEnabled()) {\n registerBackgroundFunctionCtx(ctx as BackgroundFunctionCtx);\n }\n}\n\n// Track the input before Native takes ownership. If Native rejects it, collection\n// must still release its already-registered background execution; slot state commits later.\nexport function retainMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {\n retainWorkletCtx(ctx as RetainableMainThreadCtx);\n}\n\nexport function resetElementTemplateBackgroundFunctionRuntime(): void {\n resetBackgroundFunctionRuntime();\n resetFunctionCallReturnListener();\n}\n\nexport function resetElementTemplateMainThreadBackgroundFunctionRuntime(): void {\n const manager = globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager;\n if (manager) {\n manager.dispose();\n globalThis.lynxWorkletImpl._jsFunctionLifecycleManager = new JsFunctionLifecycleManager();\n }\n clearDelayedRunOnBackgroundFunctions();\n resetFunctionCallReturnListener();\n}\n"]}
1
+ {"version":3,"file":"main-thread-background-function.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/main-thread-background-function.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,eAAe,GAChB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAUrH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,UAAU,uCAAuC,CAAC,GAAoC;IAC1F,IAAI,MAAM,IAAI,wBAAwB,EAAE,EAAE,CAAC;QACzC,6BAA6B,CAAC,GAA4B,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,4FAA4F;AAC5F,MAAM,UAAU,qCAAqC,CAAC,GAAoC;IACxF,gBAAgB,CAAC,GAA8B,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,6CAA6C;IAC3D,8BAA8B,EAAE,CAAC;IACjC,+BAA+B,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,uDAAuD;IACrE,4BAA4B,EAAE,CAAC;IAC/B,+BAA+B,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,yDAAyD;IACvE,qBAAqB,EAAE,CAAC;IACxB,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { retainWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { createBackgroundFunctionHandle } from '../../../core/background-function/handle.js';\nimport {\n registerBackgroundFunctionCtx,\n resetBackgroundFunctionRuntime,\n runOnBackground,\n} from '../../../core/background-function/run-on-background.js';\nimport { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';\nimport { isRunOnBackgroundEnabled } from '../../../shared/version.js';\nimport { disposeWorkletRuntime, resetWorkletRuntimeForReload } from '../../../worklet-runtime/bindings/lifecycle.js';\n\ntype BackgroundFunctionCtx = Parameters<typeof registerBackgroundFunctionCtx>[0];\ntype RetainableMainThreadCtx = Parameters<typeof retainWorkletCtx>[0];\n\ninterface MainThreadBackgroundFunctionCtx {\n _wkltId: string;\n [key: string]: unknown;\n}\n\n/**\n * @internal transform-generated runtime helper for background JS function handles.\n */\nexport const transformToWorklet = createBackgroundFunctionHandle;\nexport { runOnBackground };\n\nexport function registerMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {\n if (__JS__ && isRunOnBackgroundEnabled()) {\n registerBackgroundFunctionCtx(ctx as BackgroundFunctionCtx);\n }\n}\n\n// Track the input before Native takes ownership. If Native rejects it, collection\n// must still release its already-registered background execution; slot state commits later.\nexport function retainMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {\n retainWorkletCtx(ctx as RetainableMainThreadCtx);\n}\n\nexport function resetElementTemplateBackgroundFunctionRuntime(): void {\n resetBackgroundFunctionRuntime();\n resetFunctionCallReturnListener();\n}\n\nexport function resetElementTemplateMainThreadBackgroundFunctionRuntime(): void {\n resetWorkletRuntimeForReload();\n resetFunctionCallReturnListener();\n}\n\nexport function disposeElementTemplateMainThreadBackgroundFunctionRuntime(): void {\n disposeWorkletRuntime();\n resetFunctionCallReturnListener();\n}\n"]}
@@ -8,6 +8,7 @@ type MainThreadDynamicAttrState = {
8
8
  kind: 'mt-ref';
9
9
  value: MTRefValue;
10
10
  };
11
+ export declare function runWithEomFlushSuppressed(fn: () => void): void;
11
12
  export interface MainThreadDynamicAttrSubtreeHandle {
12
13
  uid: number;
13
14
  ref: ElementTemplateHandle;
@@ -25,6 +26,6 @@ export declare function updateSpreadAttrSlot(handleId: number, attrSlotIndex: nu
25
26
  export declare function reconcileUnhydratedSpreadMTRefSlots(): void;
26
27
  export declare function attachMainThreadDynamicAttrRefsForSubtree(handles: readonly MainThreadDynamicAttrSubtreeHandle[]): void;
27
28
  export declare function applyPendingMainThreadRefAttachments(isHydration?: boolean): void;
28
- export declare function detachMainThreadDynamicAttrRefsForSubtree(handles: readonly MainThreadDynamicAttrSubtreeHandle[]): void;
29
+ export declare function detachMainThreadDynamicAttrRefsForHandleIds(handleIds: readonly number[]): void;
29
30
  export declare function deleteMainThreadDynamicAttrStateForSubtree(handleIds: readonly number[]): void;
30
31
  export {};
@@ -1,7 +1,7 @@
1
1
  // Copyright 2026 The Lynx Authors. All rights reserved.
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
- import { hydrateWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';
4
+ import { hydrateWorkletCtx, setEomShouldFlushElementTree } from '@lynx-js/react/worklet-runtime/bindings';
5
5
  import { getMainThreadDynamicAttrSlotKinds } from './attr-slot-plan.js';
6
6
  import { retainMainThreadBackgroundFunctionCtx } from './main-thread-background-function.js';
7
7
  import { isMTEventNativeWrapper } from './main-thread-event-ctx.js';
@@ -20,6 +20,22 @@ const unhydratedSpreadMTRefSlots = new Map();
20
20
  const attachedMTRefHandles = new Map();
21
21
  const attachedMTRefsByElement = new Map();
22
22
  let pendingMTRefReconciliations = new Map();
23
+ let eomFlushSuppressionDepth = 0;
24
+ export function runWithEomFlushSuppressed(fn) {
25
+ if (eomFlushSuppressionDepth === 0) {
26
+ setEomShouldFlushElementTree(false);
27
+ }
28
+ eomFlushSuppressionDepth += 1;
29
+ try {
30
+ fn();
31
+ }
32
+ finally {
33
+ eomFlushSuppressionDepth -= 1;
34
+ if (eomFlushSuppressionDepth === 0) {
35
+ setEomShouldFlushElementTree(true);
36
+ }
37
+ }
38
+ }
23
39
  function deleteSlotState(state, handleId, attrSlotIndex) {
24
40
  const handleState = state.get(handleId);
25
41
  if (!handleState) {
@@ -84,16 +100,6 @@ function isSameMTRefSpec(prev, next, isHydration) {
84
100
  && prev._execId !== undefined
85
101
  && prev._execId === next._execId;
86
102
  }
87
- function cleanupAttachedElementsForHandle(handleId) {
88
- const attachedElements = attachedMTRefsByElement.get(handleId);
89
- if (!attachedElements) {
90
- return;
91
- }
92
- attachedMTRefsByElement.delete(handleId);
93
- for (const entry of attachedElements.values()) {
94
- cleanupMTRefValue(entry.value);
95
- }
96
- }
97
103
  function cleanupAttachedElementsForSlot(handleId, attrSlotIndex) {
98
104
  const attachedElements = attachedMTRefsByElement.get(handleId);
99
105
  if (!attachedElements) {
@@ -200,15 +206,13 @@ export function prepareMainThreadDynamicAttrSlotsForNative(templateType, attribu
200
206
  }
201
207
  export function clearMainThreadDynamicAttrState() {
202
208
  const attachedHandleIds = Array.from(attachedMTRefHandles.keys());
203
- attachedMTRefHandles.clear();
204
- unhydratedSpreadMTRefSlots.clear();
205
- pendingMTRefReconciliations.clear();
206
209
  try {
207
- for (const handleId of attachedHandleIds) {
208
- cleanupAttachedElementsForHandle(handleId);
209
- }
210
+ detachMainThreadDynamicAttrRefsForHandleIds(attachedHandleIds);
210
211
  }
211
212
  finally {
213
+ attachedMTRefHandles.clear();
214
+ unhydratedSpreadMTRefSlots.clear();
215
+ pendingMTRefReconciliations.clear();
212
216
  gestureAttrState.clear();
213
217
  mtEventAttrState.clear();
214
218
  mtRefAttrState.clear();
@@ -462,24 +466,36 @@ export function applyPendingMainThreadRefAttachments(isHydration = false) {
462
466
  }
463
467
  }
464
468
  }
465
- export function detachMainThreadDynamicAttrRefsForSubtree(handles) {
466
- for (let handleIndex = 0; handleIndex < handles.length; handleIndex += 1) {
467
- const handleId = handles[handleIndex].uid;
468
- if (!attachedMTRefHandles.has(handleId)) {
469
+ export function detachMainThreadDynamicAttrRefsForHandleIds(handleIds) {
470
+ let failure;
471
+ for (const handleId of handleIds) {
472
+ if (!attachedMTRefHandles.delete(handleId)) {
469
473
  continue;
470
474
  }
471
- attachedMTRefHandles.delete(handleId);
472
475
  pendingMTRefReconciliations.delete(handleId);
473
- cleanupAttachedElementsForHandle(handleId);
476
+ const attachedElements = attachedMTRefsByElement.get(handleId);
477
+ if (!attachedElements) {
478
+ continue;
479
+ }
480
+ attachedMTRefsByElement.delete(handleId);
481
+ for (const { value } of attachedElements.values()) {
482
+ try {
483
+ cleanupMTRefValue(value);
484
+ }
485
+ catch (error) {
486
+ // The subtree has already left its owner. Release every attached ref
487
+ // before propagating the first user error.
488
+ failure ??= { error };
489
+ }
490
+ }
491
+ }
492
+ if (failure) {
493
+ throw failure.error;
474
494
  }
475
495
  }
476
496
  export function deleteMainThreadDynamicAttrStateForSubtree(handleIds) {
477
497
  try {
478
- for (const handleId of handleIds) {
479
- if (attachedMTRefHandles.has(handleId)) {
480
- cleanupAttachedElementsForHandle(handleId);
481
- }
482
- }
498
+ detachMainThreadDynamicAttrRefsForHandleIds(handleIds);
483
499
  }
484
500
  finally {
485
501
  for (const handleId of handleIds) {
@@ -1 +1 @@
1
- {"version":3,"file":"main-thread-dynamic-attr-state.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/main-thread-dynamic-attr-state.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAG5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,qCAAqC,EAAE,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAErH,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAmBzF,MAAM,gBAAgB,GAAoD,IAAI,GAAG,EAAE,CAAC;AACpF,MAAM,gBAAgB,GAA8C,IAAI,GAAG,EAAE,CAAC;AAC9E,MAAM,cAAc,GAA8C,IAAI,GAAG,EAAE,CAAC;AAC5E,MAAM,cAAc,GAAqD,IAAI,GAAG,EAAE,CAAC;AACnF,MAAM,eAAe,GAAG,IAAI,GAAG,EAAuB,CAAC;AACvD,MAAM,eAAe,GAA0D,IAAI,GAAG,EAAE,CAAC;AACzF,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAuB,CAAC;AAClE,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAiC,CAAC;AACtE,MAAM,uBAAuB,GAAG,IAAI,GAAG,EAA+C,CAAC;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;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { hydrateWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';\nimport type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { getMainThreadDynamicAttrSlotKinds } from './attr-slot-plan.js';\nimport { retainMainThreadBackgroundFunctionCtx } from './main-thread-background-function.js';\nimport { isMTEventNativeWrapper } from './main-thread-event-ctx.js';\nimport type { MTEventCtx, MTEventNativeWrapper } from './main-thread-event-ctx.js';\nimport {\n attachMTRefValue,\n cleanupMTRefValue,\n hydrateMTRefValue,\n isMTRefNativeWrapper,\n retainMTRefValue,\n} from './main-thread-ref-ctx.js';\nimport type { MTRefNativeWrapper, MTRefValue } from './main-thread-ref-ctx.js';\nimport { isMainThreadFunction } from '../../../core/main-thread-function.js';\nimport { isMainThreadRef } from '../../../core/main-thread-ref.js';\nimport { hydrateGestureCallbacks, isGestureSlotValue, retainGestureCallbacks } from '../../prop-adapters/gesture.js';\nimport type { GestureSlotValue } from '../../prop-adapters/gesture.js';\nimport { isMainThreadEventPropKey, isSpreadRecord } from '../../prop-adapters/spread.js';\nimport type { SerializableValue } from '../../protocol/types.js';\n\ntype MainThreadDynamicAttrState =\n | { kind: 'mt-event'; nativeHeldValue: MTEventCtx }\n | { kind: 'mt-ref'; value: MTRefValue };\n\ntype MainThreadDynamicAttrStateMap<T> = Map<number, Map<number, T>>;\n\ninterface SpreadSlotDynamicState {\n events?: Map<string, MTEventCtx> | undefined;\n gesture?: GestureSlotValue | undefined;\n}\n\ninterface AttachedMTRefEntry {\n slotIndex: number;\n value: MTRefValue;\n}\n\nconst gestureAttrState: MainThreadDynamicAttrStateMap<GestureSlotValue> = new Map();\nconst mtEventAttrState: MainThreadDynamicAttrStateMap<MTEventCtx> = new Map();\nconst mtRefAttrState: MainThreadDynamicAttrStateMap<MTRefValue> = new Map();\nconst mtRefSlotSpecs: MainThreadDynamicAttrStateMap<MTRefValue | null> = new Map();\nconst spreadAttrSlots = new Map<number, Set<number>>();\nconst spreadSlotState: MainThreadDynamicAttrStateMap<SpreadSlotDynamicState> = new Map();\nconst unhydratedSpreadMTRefSlots = new Map<number, Set<number>>();\nconst attachedMTRefHandles = new Map<number, ElementTemplateHandle>();\nconst attachedMTRefsByElement = new Map<number, Map<ElementRef, AttachedMTRefEntry>>();\n\nlet pendingMTRefReconciliations = new Map<number, ElementTemplateHandle>();\n\nexport interface MainThreadDynamicAttrSubtreeHandle {\n uid: number;\n ref: ElementTemplateHandle;\n}\n\nfunction deleteSlotState<T>(\n state: MainThreadDynamicAttrStateMap<T>,\n handleId: number,\n attrSlotIndex: number,\n): void {\n const handleState = state.get(handleId);\n if (!handleState) {\n return;\n }\n handleState.delete(attrSlotIndex);\n if (handleState.size === 0) {\n state.delete(handleId);\n }\n}\n\nfunction setSlotState<T>(\n state: MainThreadDynamicAttrStateMap<T>,\n handleId: number,\n attrSlotIndex: number,\n value: T,\n): void {\n let handleState = state.get(handleId);\n if (!handleState) {\n handleState = new Map();\n state.set(handleId, handleState);\n }\n handleState.set(attrSlotIndex, value);\n}\n\nfunction registerHandleSlot(\n slotsByHandle: Map<number, Set<number>>,\n handleId: number,\n attrSlotIndex: number,\n): void {\n let slots = slotsByHandle.get(handleId);\n if (!slots) {\n slots = new Set();\n slotsByHandle.set(handleId, slots);\n }\n slots.add(attrSlotIndex);\n}\n\nfunction deleteHandleSlot(\n slotsByHandle: Map<number, Set<number>>,\n handleId: number,\n attrSlotIndex: number,\n): void {\n const slots = slotsByHandle.get(handleId);\n if (!slots) {\n return;\n }\n slots.delete(attrSlotIndex);\n if (slots.size === 0) {\n slotsByHandle.delete(handleId);\n }\n}\n\nfunction hasNonNullMTRefSpec(handleId: number): boolean {\n const specs = mtRefSlotSpecs.get(handleId);\n if (!specs) {\n return false;\n }\n for (const value of specs.values()) {\n if (value !== null) {\n return true;\n }\n }\n return false;\n}\n\nfunction isSameMTRefSpec(\n prev: MTRefValue | null | undefined,\n next: MTRefValue | null | undefined,\n isHydration: boolean,\n): boolean {\n if (prev === next) {\n return true;\n }\n if (prev == null || next == null) {\n return false;\n }\n if (isMainThreadRef(prev) && isMainThreadRef(next)) {\n return prev._wvid === next._wvid;\n }\n return !isHydration\n && isMainThreadFunction(prev)\n && isMainThreadFunction(next)\n && prev._execId !== undefined\n && prev._execId === next._execId;\n}\n\nfunction cleanupAttachedElementsForHandle(handleId: number): void {\n const attachedElements = attachedMTRefsByElement.get(handleId);\n if (!attachedElements) {\n return;\n }\n attachedMTRefsByElement.delete(handleId);\n for (const entry of attachedElements.values()) {\n cleanupMTRefValue(entry.value);\n }\n}\n\nfunction cleanupAttachedElementsForSlot(handleId: number, attrSlotIndex: number): void {\n const attachedElements = attachedMTRefsByElement.get(handleId);\n if (!attachedElements) {\n return;\n }\n const toCleanup: MTRefValue[] = [];\n for (const [element, entry] of attachedElements) {\n if (entry.slotIndex === attrSlotIndex) {\n attachedElements.delete(element);\n toCleanup.push(entry.value);\n }\n }\n if (attachedElements.size === 0) {\n attachedMTRefsByElement.delete(handleId);\n }\n for (const value of toCleanup) {\n cleanupMTRefValue(value);\n }\n}\n\nfunction setMTEventSlotState(handleId: number, attrSlotIndex: number, nativeHeldValue: MTEventCtx): void {\n setSlotState(mtEventAttrState, handleId, attrSlotIndex, nativeHeldValue);\n}\n\nfunction setDirectMTRefSlotState(\n handleId: number,\n attrSlotIndex: number,\n value: MTRefValue,\n): void {\n retainMTRefValue(value);\n setSlotState(mtRefAttrState, handleId, attrSlotIndex, value);\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, value);\n}\n\nexport function isSpreadDynamicAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n): boolean {\n return spreadAttrSlots.get(handleId)?.has(attrSlotIndex) === true;\n}\n\nexport function prepareSpreadAttrSlotForNative(\n value: unknown,\n): SerializableValue | null {\n if (!isSpreadRecord(value)) {\n return null;\n }\n const keys = Object.keys(value);\n let hasOwnMTRef = false;\n let activeMTRefWrapper: MTRefNativeWrapper | undefined;\n for (const key of keys) {\n const entry = value[key];\n if (key === 'main-thread:ref') {\n hasOwnMTRef = true;\n if (isMTRefNativeWrapper(entry)) {\n activeMTRefWrapper = entry;\n retainMTRefValue(entry.value);\n }\n } else if (key === 'main-thread:gesture') {\n if (isGestureSlotValue(entry)) {\n retainGestureCallbacks(entry);\n }\n } else if (isMainThreadEventPropKey(key) && isMTEventNativeWrapper(entry)) {\n retainMainThreadBackgroundFunctionCtx(entry.value);\n }\n }\n if (!hasOwnMTRef) {\n return value as SerializableValue;\n }\n const nativeSpread: Record<string, SerializableValue> = {};\n for (const key of keys) {\n if (key !== 'main-thread:ref') {\n nativeSpread[key] = value[key] as SerializableValue;\n }\n }\n if (activeMTRefWrapper) {\n nativeSpread['has-react-ref'] = true;\n nativeSpread['flatten'] = false;\n }\n return nativeSpread;\n}\n\nexport function prepareMainThreadDynamicAttrSlotsForNative(\n templateType: string,\n attributeSlots: readonly unknown[] | null | undefined,\n): SerializableValue[] | null | undefined {\n if (attributeSlots == null) {\n return attributeSlots;\n }\n const slotKinds = getMainThreadDynamicAttrSlotKinds(templateType);\n if (!slotKinds) {\n return attributeSlots as SerializableValue[];\n }\n let nativeSlots: SerializableValue[] | undefined;\n for (const [attrSlotIndex, kind] of slotKinds) {\n if (kind === 'gesture' && attributeSlots[attrSlotIndex] != null) {\n retainGestureCallbacks(attributeSlots[attrSlotIndex] as GestureSlotValue);\n }\n if (kind === 'mt-event' && attributeSlots[attrSlotIndex] != null) {\n retainMainThreadBackgroundFunctionCtx((attributeSlots[attrSlotIndex] as MTEventNativeWrapper).value);\n continue;\n }\n if (kind === 'spread') {\n const slotValue = attributeSlots[attrSlotIndex];\n const nativeSpread = prepareSpreadAttrSlotForNative(slotValue);\n if (nativeSpread !== slotValue) {\n nativeSlots ??= attributeSlots.slice() as SerializableValue[];\n nativeSlots[attrSlotIndex] = nativeSpread;\n }\n continue;\n }\n if (kind !== 'mt-ref') {\n continue;\n }\n nativeSlots ??= attributeSlots.slice() as SerializableValue[];\n nativeSlots[attrSlotIndex] = null;\n }\n return nativeSlots ?? attributeSlots as SerializableValue[];\n}\n\nexport function clearMainThreadDynamicAttrState(): void {\n const attachedHandleIds = Array.from(attachedMTRefHandles.keys());\n attachedMTRefHandles.clear();\n unhydratedSpreadMTRefSlots.clear();\n pendingMTRefReconciliations.clear();\n try {\n for (const handleId of attachedHandleIds) {\n cleanupAttachedElementsForHandle(handleId);\n }\n } finally {\n gestureAttrState.clear();\n mtEventAttrState.clear();\n mtRefAttrState.clear();\n mtRefSlotSpecs.clear();\n spreadAttrSlots.clear();\n spreadSlotState.clear();\n attachedMTRefsByElement.clear();\n }\n}\n\nexport function getMainThreadDynamicAttrState(\n handleId: number,\n attrSlotIndex: number,\n): MainThreadDynamicAttrState | undefined {\n const event = mtEventAttrState.get(handleId)?.get(attrSlotIndex);\n if (event) {\n return { kind: 'mt-event', nativeHeldValue: event };\n }\n const ref = mtRefAttrState.get(handleId)?.get(attrSlotIndex);\n return ref ? { kind: 'mt-ref', value: ref } : undefined;\n}\n\nfunction commitSpreadSlotState(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n isHydration: boolean,\n cleanupBeforeRefHydrate = false,\n): { prevSpec: MTRefValue | null | undefined; nextSpec: MTRefValue | null | undefined } {\n deleteHandleSlot(unhydratedSpreadMTRefSlots, handleId, attrSlotIndex);\n const prevSpread = isHydration ? spreadSlotState.get(handleId)?.get(attrSlotIndex) : undefined;\n const prevSpec = mtRefSlotSpecs.get(handleId)?.get(attrSlotIndex);\n\n let nextEvents: Map<string, MTEventCtx> | undefined;\n let nextGesture: GestureSlotValue | undefined;\n let hasOwnMTRef = false;\n let nextRefValue: MTRefValue | null = null;\n\n if (isSpreadRecord(value)) {\n for (const key of Object.keys(value)) {\n const entry = value[key];\n if (key === 'main-thread:ref') {\n hasOwnMTRef = true;\n nextRefValue = isMTRefNativeWrapper(entry) ? entry.value : null;\n } else if (key === 'main-thread:gesture') {\n if (isGestureSlotValue(entry)) {\n nextGesture = entry;\n }\n } else if (isMainThreadEventPropKey(key) && isMTEventNativeWrapper(entry)) {\n (nextEvents ??= new Map()).set(key, entry.value);\n }\n }\n }\n\n if (nextEvents || nextGesture) {\n setSlotState(spreadSlotState, handleId, attrSlotIndex, {\n events: nextEvents,\n gesture: nextGesture,\n });\n } else {\n deleteSlotState(spreadSlotState, handleId, attrSlotIndex);\n }\n\n const rawNextSpec = hasOwnMTRef ? nextRefValue : undefined;\n const nextSpec = isSameMTRefSpec(prevSpec, rawNextSpec, isHydration) ? prevSpec : rawNextSpec;\n\n if (cleanupBeforeRefHydrate && prevSpec !== nextSpec) {\n cleanupAttachedElementsForSlot(handleId, attrSlotIndex);\n }\n\n if (isHydration) {\n if (nextEvents && prevSpread?.events) {\n for (const [eventKey, nextCtx] of nextEvents) {\n const prevCtx = prevSpread.events.get(eventKey);\n if (prevCtx) {\n hydrateWorkletCtx(nextCtx as Worklet, prevCtx as Worklet);\n }\n }\n }\n if (nextGesture && prevSpread?.gesture) {\n hydrateGestureCallbacks(nextGesture, prevSpread.gesture);\n }\n if (nextRefValue !== null) {\n hydrateMTRefValue(nextRefValue, prevSpec);\n }\n }\n\n if (nextSpec === undefined) {\n deleteSlotState(mtRefSlotSpecs, handleId, attrSlotIndex);\n } else {\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, nextSpec);\n }\n\n return { prevSpec, nextSpec };\n}\n\nexport function initializeMainThreadDynamicAttrSlots(\n handleId: number,\n templateType: string,\n attributeSlots: readonly unknown[] | null | undefined,\n isCreatedByPatch = false,\n): void {\n const slotKinds = getMainThreadDynamicAttrSlotKinds(templateType);\n if (!slotKinds) {\n return;\n }\n for (const [attrSlotIndex, kind] of slotKinds) {\n const value = attributeSlots?.[attrSlotIndex];\n if (kind === 'gesture' && value != null) {\n updateGestureAttrSlot(handleId, attrSlotIndex, value);\n } else if (kind === 'mt-event' && value != null) {\n setMTEventSlotState(handleId, attrSlotIndex, (value as MTEventNativeWrapper).value);\n } else if (kind === 'mt-ref') {\n if (value == null) {\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, null);\n } else {\n setDirectMTRefSlotState(handleId, attrSlotIndex, (value as MTRefNativeWrapper).value);\n }\n } else if (kind === 'spread') {\n registerHandleSlot(spreadAttrSlots, handleId, attrSlotIndex);\n const { nextSpec } = commitSpreadSlotState(handleId, attrSlotIndex, value, false);\n if (!isCreatedByPatch && nextSpec !== undefined) {\n registerHandleSlot(unhydratedSpreadMTRefSlots, handleId, attrSlotIndex);\n }\n }\n }\n}\n\nexport function updateGestureAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n isHydration = false,\n): void {\n const previous = isHydration ? gestureAttrState.get(handleId)?.get(attrSlotIndex) : undefined;\n if (value == null) {\n deleteSlotState(gestureAttrState, handleId, attrSlotIndex);\n return;\n }\n const next = value as GestureSlotValue;\n if (previous) {\n hydrateGestureCallbacks(next, previous);\n }\n setSlotState(gestureAttrState, handleId, attrSlotIndex, next);\n}\n\nexport function updateMainThreadEventAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n isHydration = false,\n): void {\n const previousState = isHydration\n ? mtEventAttrState.get(handleId)?.get(attrSlotIndex)\n : undefined;\n if (value == null) {\n deleteSlotState(mtEventAttrState, handleId, attrSlotIndex);\n return;\n }\n const nextValue = (value as MTEventNativeWrapper).value;\n setMTEventSlotState(handleId, attrSlotIndex, nextValue);\n if (previousState) {\n hydrateWorkletCtx(\n nextValue as Worklet,\n previousState as Worklet,\n );\n }\n}\n\nexport function updateMainThreadRefAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n nativeRef: ElementTemplateHandle,\n isHydration = false,\n): void {\n const previousState = mtRefAttrState.get(handleId)?.get(attrSlotIndex);\n const isAttached = attachedMTRefHandles.has(handleId);\n if (isAttached) {\n cleanupAttachedElementsForSlot(handleId, attrSlotIndex);\n }\n if (value == null) {\n deleteSlotState(mtRefAttrState, handleId, attrSlotIndex);\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, null);\n return;\n }\n const nextValue = (value as MTRefNativeWrapper).value;\n setDirectMTRefSlotState(handleId, attrSlotIndex, nextValue);\n if (isHydration) {\n hydrateMTRefValue(nextValue, previousState);\n }\n if (isAttached) {\n pendingMTRefReconciliations.set(handleId, nativeRef);\n }\n}\n\nexport function updateSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n nativeRef: ElementTemplateHandle,\n isHydration = false,\n): void {\n const isAttached = attachedMTRefHandles.has(handleId);\n const { prevSpec, nextSpec } = commitSpreadSlotState(\n handleId,\n attrSlotIndex,\n value,\n isHydration,\n isAttached,\n );\n if (prevSpec === nextSpec) {\n return;\n }\n if (isAttached && hasNonNullMTRefSpec(handleId)) {\n pendingMTRefReconciliations.set(handleId, nativeRef);\n }\n}\n\nexport function reconcileUnhydratedSpreadMTRefSlots(): void {\n if (unhydratedSpreadMTRefSlots.size === 0) {\n return;\n }\n for (const [handleId, slotIndices] of unhydratedSpreadMTRefSlots) {\n for (const attrSlotIndex of slotIndices) {\n cleanupAttachedElementsForSlot(handleId, attrSlotIndex);\n deleteSlotState(mtRefSlotSpecs, handleId, attrSlotIndex);\n }\n const nativeRef = attachedMTRefHandles.get(handleId);\n if (nativeRef && hasNonNullMTRefSpec(handleId)) {\n pendingMTRefReconciliations.set(handleId, nativeRef);\n }\n }\n unhydratedSpreadMTRefSlots.clear();\n}\n\nexport function attachMainThreadDynamicAttrRefsForSubtree(\n handles: readonly MainThreadDynamicAttrSubtreeHandle[],\n): void {\n for (let handleIndex = 0; handleIndex < handles.length; handleIndex += 1) {\n const handle = handles[handleIndex]!;\n if (attachedMTRefHandles.has(handle.uid)) {\n continue;\n }\n attachedMTRefHandles.set(handle.uid, handle.ref);\n if (hasNonNullMTRefSpec(handle.uid)) {\n pendingMTRefReconciliations.set(handle.uid, handle.ref);\n }\n }\n}\n\n// Consume one queue snapshot, matching Snapshot's ref delivery boundary.\nexport function applyPendingMainThreadRefAttachments(isHydration = false): void {\n if (isHydration) {\n reconcileUnhydratedSpreadMTRefSlots();\n }\n if (pendingMTRefReconciliations.size === 0) {\n return;\n }\n const pending = pendingMTRefReconciliations;\n pendingMTRefReconciliations = new Map();\n\n for (const [handleId, nativeRef] of pending) {\n const specs = mtRefSlotSpecs.get(handleId);\n const desiredByElement = new Map<ElementRef, AttachedMTRefEntry | null>();\n if (specs && specs.size > 0) {\n const sortedEntries = specs.size === 1\n ? Array.from(specs.entries())\n : Array.from(specs.entries()).sort((a, b) => a[0] - b[0]);\n for (const [slotIndex, refValue] of sortedEntries) {\n const element = __GetElementByAttrSlot(nativeRef, slotIndex);\n if (!element) {\n throw new Error(\n `ElementTemplate main-thread:ref target ${handleId}:${slotIndex} could not be materialized.`,\n );\n }\n desiredByElement.set(\n element,\n refValue === null ? null : { slotIndex, value: refValue },\n );\n }\n }\n\n let attachedElements = attachedMTRefsByElement.get(handleId);\n if (attachedElements) {\n const staleValues: MTRefValue[] = [];\n for (const [element, prevEntry] of attachedElements) {\n const desired = desiredByElement.get(element) ?? null;\n if (!desired || desired.slotIndex !== prevEntry.slotIndex || desired.value !== prevEntry.value) {\n attachedElements.delete(element);\n staleValues.push(prevEntry.value);\n }\n }\n if (attachedElements.size === 0) {\n attachedMTRefsByElement.delete(handleId);\n attachedElements = undefined;\n }\n for (const staleValue of staleValues) {\n cleanupMTRefValue(staleValue);\n }\n }\n\n for (const [element, desired] of desiredByElement) {\n if (!desired) {\n continue;\n }\n if (attachedElements?.has(element)) {\n continue;\n }\n attachMTRefValue(desired.value, element);\n if (!attachedElements) {\n attachedElements = new Map();\n attachedMTRefsByElement.set(handleId, attachedElements);\n }\n attachedElements.set(element, desired);\n }\n }\n}\n\nexport function detachMainThreadDynamicAttrRefsForSubtree(\n handles: readonly MainThreadDynamicAttrSubtreeHandle[],\n): void {\n for (let handleIndex = 0; handleIndex < handles.length; handleIndex += 1) {\n const handleId = handles[handleIndex]!.uid;\n if (!attachedMTRefHandles.has(handleId)) {\n continue;\n }\n attachedMTRefHandles.delete(handleId);\n pendingMTRefReconciliations.delete(handleId);\n cleanupAttachedElementsForHandle(handleId);\n }\n}\n\nexport function deleteMainThreadDynamicAttrStateForSubtree(\n handleIds: readonly number[],\n): void {\n try {\n for (const handleId of handleIds) {\n if (attachedMTRefHandles.has(handleId)) {\n cleanupAttachedElementsForHandle(handleId);\n }\n }\n } finally {\n for (const handleId of handleIds) {\n attachedMTRefHandles.delete(handleId);\n unhydratedSpreadMTRefSlots.delete(handleId);\n pendingMTRefReconciliations.delete(handleId);\n attachedMTRefsByElement.delete(handleId);\n gestureAttrState.delete(handleId);\n mtEventAttrState.delete(handleId);\n mtRefAttrState.delete(handleId);\n mtRefSlotSpecs.delete(handleId);\n spreadAttrSlots.delete(handleId);\n spreadSlotState.delete(handleId);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"main-thread-dynamic-attr-state.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/main-thread-dynamic-attr-state.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAG1G,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,qCAAqC,EAAE,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,kBAA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D,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,OAAO,CAAC,KAAK,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0CAA0C,CACxD,SAA4B;IAE5B,IAAI,CAAC;QACH,2CAA2C,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;YAAS,CAAC;QACT,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACtC,0BAA0B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5C,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC7C,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAClC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAClC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACjC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { hydrateWorkletCtx, setEomShouldFlushElementTree } from '@lynx-js/react/worklet-runtime/bindings';\nimport type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { getMainThreadDynamicAttrSlotKinds } from './attr-slot-plan.js';\nimport { retainMainThreadBackgroundFunctionCtx } from './main-thread-background-function.js';\nimport { isMTEventNativeWrapper } from './main-thread-event-ctx.js';\nimport type { MTEventCtx, MTEventNativeWrapper } from './main-thread-event-ctx.js';\nimport {\n attachMTRefValue,\n cleanupMTRefValue,\n hydrateMTRefValue,\n isMTRefNativeWrapper,\n retainMTRefValue,\n} from './main-thread-ref-ctx.js';\nimport type { MTRefNativeWrapper, MTRefValue } from './main-thread-ref-ctx.js';\nimport { isMainThreadFunction } from '../../../core/main-thread-function.js';\nimport { isMainThreadRef } from '../../../core/main-thread-ref.js';\nimport { hydrateGestureCallbacks, isGestureSlotValue, retainGestureCallbacks } from '../../prop-adapters/gesture.js';\nimport type { GestureSlotValue } from '../../prop-adapters/gesture.js';\nimport { isMainThreadEventPropKey, isSpreadRecord } from '../../prop-adapters/spread.js';\nimport type { SerializableValue } from '../../protocol/types.js';\n\ntype MainThreadDynamicAttrState =\n | { kind: 'mt-event'; nativeHeldValue: MTEventCtx }\n | { kind: 'mt-ref'; value: MTRefValue };\n\ntype MainThreadDynamicAttrStateMap<T> = Map<number, Map<number, T>>;\n\ninterface SpreadSlotDynamicState {\n events?: Map<string, MTEventCtx> | undefined;\n gesture?: GestureSlotValue | undefined;\n}\n\ninterface AttachedMTRefEntry {\n slotIndex: number;\n value: MTRefValue;\n}\n\nconst gestureAttrState: MainThreadDynamicAttrStateMap<GestureSlotValue> = new Map();\nconst mtEventAttrState: MainThreadDynamicAttrStateMap<MTEventCtx> = new Map();\nconst mtRefAttrState: MainThreadDynamicAttrStateMap<MTRefValue> = new Map();\nconst mtRefSlotSpecs: MainThreadDynamicAttrStateMap<MTRefValue | null> = new Map();\nconst spreadAttrSlots = new Map<number, Set<number>>();\nconst spreadSlotState: MainThreadDynamicAttrStateMap<SpreadSlotDynamicState> = new Map();\nconst unhydratedSpreadMTRefSlots = new Map<number, Set<number>>();\nconst attachedMTRefHandles = new Map<number, ElementTemplateHandle>();\nconst attachedMTRefsByElement = new Map<number, Map<ElementRef, AttachedMTRefEntry>>();\n\nlet pendingMTRefReconciliations = new Map<number, ElementTemplateHandle>();\nlet eomFlushSuppressionDepth = 0;\n\nexport function runWithEomFlushSuppressed(fn: () => void): void {\n if (eomFlushSuppressionDepth === 0) {\n setEomShouldFlushElementTree(false);\n }\n eomFlushSuppressionDepth += 1;\n try {\n fn();\n } finally {\n eomFlushSuppressionDepth -= 1;\n if (eomFlushSuppressionDepth === 0) {\n setEomShouldFlushElementTree(true);\n }\n }\n}\n\nexport interface MainThreadDynamicAttrSubtreeHandle {\n uid: number;\n ref: ElementTemplateHandle;\n}\n\nfunction deleteSlotState<T>(\n state: MainThreadDynamicAttrStateMap<T>,\n handleId: number,\n attrSlotIndex: number,\n): void {\n const handleState = state.get(handleId);\n if (!handleState) {\n return;\n }\n handleState.delete(attrSlotIndex);\n if (handleState.size === 0) {\n state.delete(handleId);\n }\n}\n\nfunction setSlotState<T>(\n state: MainThreadDynamicAttrStateMap<T>,\n handleId: number,\n attrSlotIndex: number,\n value: T,\n): void {\n let handleState = state.get(handleId);\n if (!handleState) {\n handleState = new Map();\n state.set(handleId, handleState);\n }\n handleState.set(attrSlotIndex, value);\n}\n\nfunction registerHandleSlot(\n slotsByHandle: Map<number, Set<number>>,\n handleId: number,\n attrSlotIndex: number,\n): void {\n let slots = slotsByHandle.get(handleId);\n if (!slots) {\n slots = new Set();\n slotsByHandle.set(handleId, slots);\n }\n slots.add(attrSlotIndex);\n}\n\nfunction deleteHandleSlot(\n slotsByHandle: Map<number, Set<number>>,\n handleId: number,\n attrSlotIndex: number,\n): void {\n const slots = slotsByHandle.get(handleId);\n if (!slots) {\n return;\n }\n slots.delete(attrSlotIndex);\n if (slots.size === 0) {\n slotsByHandle.delete(handleId);\n }\n}\n\nfunction hasNonNullMTRefSpec(handleId: number): boolean {\n const specs = mtRefSlotSpecs.get(handleId);\n if (!specs) {\n return false;\n }\n for (const value of specs.values()) {\n if (value !== null) {\n return true;\n }\n }\n return false;\n}\n\nfunction isSameMTRefSpec(\n prev: MTRefValue | null | undefined,\n next: MTRefValue | null | undefined,\n isHydration: boolean,\n): boolean {\n if (prev === next) {\n return true;\n }\n if (prev == null || next == null) {\n return false;\n }\n if (isMainThreadRef(prev) && isMainThreadRef(next)) {\n return prev._wvid === next._wvid;\n }\n return !isHydration\n && isMainThreadFunction(prev)\n && isMainThreadFunction(next)\n && prev._execId !== undefined\n && prev._execId === next._execId;\n}\n\nfunction cleanupAttachedElementsForSlot(handleId: number, attrSlotIndex: number): void {\n const attachedElements = attachedMTRefsByElement.get(handleId);\n if (!attachedElements) {\n return;\n }\n const toCleanup: MTRefValue[] = [];\n for (const [element, entry] of attachedElements) {\n if (entry.slotIndex === attrSlotIndex) {\n attachedElements.delete(element);\n toCleanup.push(entry.value);\n }\n }\n if (attachedElements.size === 0) {\n attachedMTRefsByElement.delete(handleId);\n }\n for (const value of toCleanup) {\n cleanupMTRefValue(value);\n }\n}\n\nfunction setMTEventSlotState(handleId: number, attrSlotIndex: number, nativeHeldValue: MTEventCtx): void {\n setSlotState(mtEventAttrState, handleId, attrSlotIndex, nativeHeldValue);\n}\n\nfunction setDirectMTRefSlotState(\n handleId: number,\n attrSlotIndex: number,\n value: MTRefValue,\n): void {\n retainMTRefValue(value);\n setSlotState(mtRefAttrState, handleId, attrSlotIndex, value);\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, value);\n}\n\nexport function isSpreadDynamicAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n): boolean {\n return spreadAttrSlots.get(handleId)?.has(attrSlotIndex) === true;\n}\n\nexport function prepareSpreadAttrSlotForNative(\n value: unknown,\n): SerializableValue | null {\n if (!isSpreadRecord(value)) {\n return null;\n }\n const keys = Object.keys(value);\n let hasOwnMTRef = false;\n let activeMTRefWrapper: MTRefNativeWrapper | undefined;\n for (const key of keys) {\n const entry = value[key];\n if (key === 'main-thread:ref') {\n hasOwnMTRef = true;\n if (isMTRefNativeWrapper(entry)) {\n activeMTRefWrapper = entry;\n retainMTRefValue(entry.value);\n }\n } else if (key === 'main-thread:gesture') {\n if (isGestureSlotValue(entry)) {\n retainGestureCallbacks(entry);\n }\n } else if (isMainThreadEventPropKey(key) && isMTEventNativeWrapper(entry)) {\n retainMainThreadBackgroundFunctionCtx(entry.value);\n }\n }\n if (!hasOwnMTRef) {\n return value as SerializableValue;\n }\n const nativeSpread: Record<string, SerializableValue> = {};\n for (const key of keys) {\n if (key !== 'main-thread:ref') {\n nativeSpread[key] = value[key] as SerializableValue;\n }\n }\n if (activeMTRefWrapper) {\n nativeSpread['has-react-ref'] = true;\n nativeSpread['flatten'] = false;\n }\n return nativeSpread;\n}\n\nexport function prepareMainThreadDynamicAttrSlotsForNative(\n templateType: string,\n attributeSlots: readonly unknown[] | null | undefined,\n): SerializableValue[] | null | undefined {\n if (attributeSlots == null) {\n return attributeSlots;\n }\n const slotKinds = getMainThreadDynamicAttrSlotKinds(templateType);\n if (!slotKinds) {\n return attributeSlots as SerializableValue[];\n }\n let nativeSlots: SerializableValue[] | undefined;\n for (const [attrSlotIndex, kind] of slotKinds) {\n if (kind === 'gesture' && attributeSlots[attrSlotIndex] != null) {\n retainGestureCallbacks(attributeSlots[attrSlotIndex] as GestureSlotValue);\n }\n if (kind === 'mt-event' && attributeSlots[attrSlotIndex] != null) {\n retainMainThreadBackgroundFunctionCtx((attributeSlots[attrSlotIndex] as MTEventNativeWrapper).value);\n continue;\n }\n if (kind === 'spread') {\n const slotValue = attributeSlots[attrSlotIndex];\n const nativeSpread = prepareSpreadAttrSlotForNative(slotValue);\n if (nativeSpread !== slotValue) {\n nativeSlots ??= attributeSlots.slice() as SerializableValue[];\n nativeSlots[attrSlotIndex] = nativeSpread;\n }\n continue;\n }\n if (kind !== 'mt-ref') {\n continue;\n }\n nativeSlots ??= attributeSlots.slice() as SerializableValue[];\n nativeSlots[attrSlotIndex] = null;\n }\n return nativeSlots ?? attributeSlots as SerializableValue[];\n}\n\nexport function clearMainThreadDynamicAttrState(): void {\n const attachedHandleIds = Array.from(attachedMTRefHandles.keys());\n try {\n detachMainThreadDynamicAttrRefsForHandleIds(attachedHandleIds);\n } finally {\n attachedMTRefHandles.clear();\n unhydratedSpreadMTRefSlots.clear();\n pendingMTRefReconciliations.clear();\n gestureAttrState.clear();\n mtEventAttrState.clear();\n mtRefAttrState.clear();\n mtRefSlotSpecs.clear();\n spreadAttrSlots.clear();\n spreadSlotState.clear();\n attachedMTRefsByElement.clear();\n }\n}\n\nexport function getMainThreadDynamicAttrState(\n handleId: number,\n attrSlotIndex: number,\n): MainThreadDynamicAttrState | undefined {\n const event = mtEventAttrState.get(handleId)?.get(attrSlotIndex);\n if (event) {\n return { kind: 'mt-event', nativeHeldValue: event };\n }\n const ref = mtRefAttrState.get(handleId)?.get(attrSlotIndex);\n return ref ? { kind: 'mt-ref', value: ref } : undefined;\n}\n\nfunction commitSpreadSlotState(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n isHydration: boolean,\n cleanupBeforeRefHydrate = false,\n): { prevSpec: MTRefValue | null | undefined; nextSpec: MTRefValue | null | undefined } {\n deleteHandleSlot(unhydratedSpreadMTRefSlots, handleId, attrSlotIndex);\n const prevSpread = isHydration ? spreadSlotState.get(handleId)?.get(attrSlotIndex) : undefined;\n const prevSpec = mtRefSlotSpecs.get(handleId)?.get(attrSlotIndex);\n\n let nextEvents: Map<string, MTEventCtx> | undefined;\n let nextGesture: GestureSlotValue | undefined;\n let hasOwnMTRef = false;\n let nextRefValue: MTRefValue | null = null;\n\n if (isSpreadRecord(value)) {\n for (const key of Object.keys(value)) {\n const entry = value[key];\n if (key === 'main-thread:ref') {\n hasOwnMTRef = true;\n nextRefValue = isMTRefNativeWrapper(entry) ? entry.value : null;\n } else if (key === 'main-thread:gesture') {\n if (isGestureSlotValue(entry)) {\n nextGesture = entry;\n }\n } else if (isMainThreadEventPropKey(key) && isMTEventNativeWrapper(entry)) {\n (nextEvents ??= new Map()).set(key, entry.value);\n }\n }\n }\n\n if (nextEvents || nextGesture) {\n setSlotState(spreadSlotState, handleId, attrSlotIndex, {\n events: nextEvents,\n gesture: nextGesture,\n });\n } else {\n deleteSlotState(spreadSlotState, handleId, attrSlotIndex);\n }\n\n const rawNextSpec = hasOwnMTRef ? nextRefValue : undefined;\n const nextSpec = isSameMTRefSpec(prevSpec, rawNextSpec, isHydration) ? prevSpec : rawNextSpec;\n\n if (cleanupBeforeRefHydrate && prevSpec !== nextSpec) {\n cleanupAttachedElementsForSlot(handleId, attrSlotIndex);\n }\n\n if (isHydration) {\n if (nextEvents && prevSpread?.events) {\n for (const [eventKey, nextCtx] of nextEvents) {\n const prevCtx = prevSpread.events.get(eventKey);\n if (prevCtx) {\n hydrateWorkletCtx(nextCtx as Worklet, prevCtx as Worklet);\n }\n }\n }\n if (nextGesture && prevSpread?.gesture) {\n hydrateGestureCallbacks(nextGesture, prevSpread.gesture);\n }\n if (nextRefValue !== null) {\n hydrateMTRefValue(nextRefValue, prevSpec);\n }\n }\n\n if (nextSpec === undefined) {\n deleteSlotState(mtRefSlotSpecs, handleId, attrSlotIndex);\n } else {\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, nextSpec);\n }\n\n return { prevSpec, nextSpec };\n}\n\nexport function initializeMainThreadDynamicAttrSlots(\n handleId: number,\n templateType: string,\n attributeSlots: readonly unknown[] | null | undefined,\n isCreatedByPatch = false,\n): void {\n const slotKinds = getMainThreadDynamicAttrSlotKinds(templateType);\n if (!slotKinds) {\n return;\n }\n for (const [attrSlotIndex, kind] of slotKinds) {\n const value = attributeSlots?.[attrSlotIndex];\n if (kind === 'gesture' && value != null) {\n updateGestureAttrSlot(handleId, attrSlotIndex, value);\n } else if (kind === 'mt-event' && value != null) {\n setMTEventSlotState(handleId, attrSlotIndex, (value as MTEventNativeWrapper).value);\n } else if (kind === 'mt-ref') {\n if (value == null) {\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, null);\n } else {\n setDirectMTRefSlotState(handleId, attrSlotIndex, (value as MTRefNativeWrapper).value);\n }\n } else if (kind === 'spread') {\n registerHandleSlot(spreadAttrSlots, handleId, attrSlotIndex);\n const { nextSpec } = commitSpreadSlotState(handleId, attrSlotIndex, value, false);\n if (!isCreatedByPatch && nextSpec !== undefined) {\n registerHandleSlot(unhydratedSpreadMTRefSlots, handleId, attrSlotIndex);\n }\n }\n }\n}\n\nexport function updateGestureAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n isHydration = false,\n): void {\n const previous = isHydration ? gestureAttrState.get(handleId)?.get(attrSlotIndex) : undefined;\n if (value == null) {\n deleteSlotState(gestureAttrState, handleId, attrSlotIndex);\n return;\n }\n const next = value as GestureSlotValue;\n if (previous) {\n hydrateGestureCallbacks(next, previous);\n }\n setSlotState(gestureAttrState, handleId, attrSlotIndex, next);\n}\n\nexport function updateMainThreadEventAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n isHydration = false,\n): void {\n const previousState = isHydration\n ? mtEventAttrState.get(handleId)?.get(attrSlotIndex)\n : undefined;\n if (value == null) {\n deleteSlotState(mtEventAttrState, handleId, attrSlotIndex);\n return;\n }\n const nextValue = (value as MTEventNativeWrapper).value;\n setMTEventSlotState(handleId, attrSlotIndex, nextValue);\n if (previousState) {\n hydrateWorkletCtx(\n nextValue as Worklet,\n previousState as Worklet,\n );\n }\n}\n\nexport function updateMainThreadRefAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n nativeRef: ElementTemplateHandle,\n isHydration = false,\n): void {\n const previousState = mtRefAttrState.get(handleId)?.get(attrSlotIndex);\n const isAttached = attachedMTRefHandles.has(handleId);\n if (isAttached) {\n cleanupAttachedElementsForSlot(handleId, attrSlotIndex);\n }\n if (value == null) {\n deleteSlotState(mtRefAttrState, handleId, attrSlotIndex);\n setSlotState(mtRefSlotSpecs, handleId, attrSlotIndex, null);\n return;\n }\n const nextValue = (value as MTRefNativeWrapper).value;\n setDirectMTRefSlotState(handleId, attrSlotIndex, nextValue);\n if (isHydration) {\n hydrateMTRefValue(nextValue, previousState);\n }\n if (isAttached) {\n pendingMTRefReconciliations.set(handleId, nativeRef);\n }\n}\n\nexport function updateSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n nativeRef: ElementTemplateHandle,\n isHydration = false,\n): void {\n const isAttached = attachedMTRefHandles.has(handleId);\n const { prevSpec, nextSpec } = commitSpreadSlotState(\n handleId,\n attrSlotIndex,\n value,\n isHydration,\n isAttached,\n );\n if (prevSpec === nextSpec) {\n return;\n }\n if (isAttached && hasNonNullMTRefSpec(handleId)) {\n pendingMTRefReconciliations.set(handleId, nativeRef);\n }\n}\n\nexport function reconcileUnhydratedSpreadMTRefSlots(): void {\n if (unhydratedSpreadMTRefSlots.size === 0) {\n return;\n }\n for (const [handleId, slotIndices] of unhydratedSpreadMTRefSlots) {\n for (const attrSlotIndex of slotIndices) {\n cleanupAttachedElementsForSlot(handleId, attrSlotIndex);\n deleteSlotState(mtRefSlotSpecs, handleId, attrSlotIndex);\n }\n const nativeRef = attachedMTRefHandles.get(handleId);\n if (nativeRef && hasNonNullMTRefSpec(handleId)) {\n pendingMTRefReconciliations.set(handleId, nativeRef);\n }\n }\n unhydratedSpreadMTRefSlots.clear();\n}\n\nexport function attachMainThreadDynamicAttrRefsForSubtree(\n handles: readonly MainThreadDynamicAttrSubtreeHandle[],\n): void {\n for (let handleIndex = 0; handleIndex < handles.length; handleIndex += 1) {\n const handle = handles[handleIndex]!;\n if (attachedMTRefHandles.has(handle.uid)) {\n continue;\n }\n attachedMTRefHandles.set(handle.uid, handle.ref);\n if (hasNonNullMTRefSpec(handle.uid)) {\n pendingMTRefReconciliations.set(handle.uid, handle.ref);\n }\n }\n}\n\n// Consume one queue snapshot, matching Snapshot's ref delivery boundary.\nexport function applyPendingMainThreadRefAttachments(isHydration = false): void {\n if (isHydration) {\n reconcileUnhydratedSpreadMTRefSlots();\n }\n if (pendingMTRefReconciliations.size === 0) {\n return;\n }\n const pending = pendingMTRefReconciliations;\n pendingMTRefReconciliations = new Map();\n\n for (const [handleId, nativeRef] of pending) {\n const specs = mtRefSlotSpecs.get(handleId);\n const desiredByElement = new Map<ElementRef, AttachedMTRefEntry | null>();\n if (specs && specs.size > 0) {\n const sortedEntries = specs.size === 1\n ? Array.from(specs.entries())\n : Array.from(specs.entries()).sort((a, b) => a[0] - b[0]);\n for (const [slotIndex, refValue] of sortedEntries) {\n const element = __GetElementByAttrSlot(nativeRef, slotIndex);\n if (!element) {\n throw new Error(\n `ElementTemplate main-thread:ref target ${handleId}:${slotIndex} could not be materialized.`,\n );\n }\n desiredByElement.set(\n element,\n refValue === null ? null : { slotIndex, value: refValue },\n );\n }\n }\n\n let attachedElements = attachedMTRefsByElement.get(handleId);\n if (attachedElements) {\n const staleValues: MTRefValue[] = [];\n for (const [element, prevEntry] of attachedElements) {\n const desired = desiredByElement.get(element) ?? null;\n if (!desired || desired.slotIndex !== prevEntry.slotIndex || desired.value !== prevEntry.value) {\n attachedElements.delete(element);\n staleValues.push(prevEntry.value);\n }\n }\n if (attachedElements.size === 0) {\n attachedMTRefsByElement.delete(handleId);\n attachedElements = undefined;\n }\n for (const staleValue of staleValues) {\n cleanupMTRefValue(staleValue);\n }\n }\n\n for (const [element, desired] of desiredByElement) {\n if (!desired) {\n continue;\n }\n if (attachedElements?.has(element)) {\n continue;\n }\n attachMTRefValue(desired.value, element);\n if (!attachedElements) {\n attachedElements = new Map();\n attachedMTRefsByElement.set(handleId, attachedElements);\n }\n attachedElements.set(element, desired);\n }\n }\n}\n\nexport function detachMainThreadDynamicAttrRefsForHandleIds(\n handleIds: readonly number[],\n): void {\n let failure: { error: unknown } | undefined;\n for (const handleId of handleIds) {\n if (!attachedMTRefHandles.delete(handleId)) {\n continue;\n }\n pendingMTRefReconciliations.delete(handleId);\n const attachedElements = attachedMTRefsByElement.get(handleId);\n if (!attachedElements) {\n continue;\n }\n attachedMTRefsByElement.delete(handleId);\n for (const { value } of attachedElements.values()) {\n try {\n cleanupMTRefValue(value);\n } catch (error) {\n // The subtree has already left its owner. Release every attached ref\n // before propagating the first user error.\n failure ??= { error };\n }\n }\n }\n if (failure) {\n throw failure.error;\n }\n}\n\nexport function deleteMainThreadDynamicAttrStateForSubtree(\n handleIds: readonly number[],\n): void {\n try {\n detachMainThreadDynamicAttrRefsForHandleIds(handleIds);\n } finally {\n for (const handleId of handleIds) {\n attachedMTRefHandles.delete(handleId);\n unhydratedSpreadMTRefSlots.delete(handleId);\n pendingMTRefReconciliations.delete(handleId);\n attachedMTRefsByElement.delete(handleId);\n gestureAttrState.delete(handleId);\n mtEventAttrState.delete(handleId);\n mtRefAttrState.delete(handleId);\n mtRefSlotSpecs.delete(handleId);\n spreadAttrSlots.delete(handleId);\n spreadSlotState.delete(handleId);\n }\n }\n}\n"]}
@@ -2,4 +2,6 @@ import type { EtAttrPlan } from './attr-slot-plan.js';
2
2
  import type { RuntimeTypedElementAttributes, TypedElementAttributesCommand } from '../../protocol/types.js';
3
3
  export declare const TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX = 0;
4
4
  export declare const TYPED_ELEMENT_ATTR_PLAN: EtAttrPlan;
5
+ export declare const TYPED_LIST_ATTR_PLAN: EtAttrPlan;
5
6
  export declare function prepareTypedElementAttributes(handleId: number, attributes: RuntimeTypedElementAttributes | null | undefined): TypedElementAttributesCommand | null;
7
+ export declare function prepareTypedListAttributes(handleId: number, attributes: RuntimeTypedElementAttributes | null | undefined): TypedElementAttributesCommand | null;
@@ -1,13 +1,20 @@
1
1
  // Copyright 2026 The Lynx Authors. All rights reserved.
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
- import { adaptTypedSpreadAttrSlot } from './attr-slot-plan.js';
4
+ import { adaptSpreadAttrSlot, adaptTypedSpreadAttrSlot } from './attr-slot-plan.js';
5
5
  export const TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX = 0;
6
6
  export const TYPED_ELEMENT_ATTR_PLAN = [
7
7
  TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,
8
8
  adaptTypedSpreadAttrSlot,
9
9
  ];
10
+ export const TYPED_LIST_ATTR_PLAN = [
11
+ TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,
12
+ adaptSpreadAttrSlot,
13
+ ];
10
14
  export function prepareTypedElementAttributes(handleId, attributes) {
11
15
  return adaptTypedSpreadAttrSlot(handleId, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, attributes);
12
16
  }
17
+ export function prepareTypedListAttributes(handleId, attributes) {
18
+ return adaptSpreadAttrSlot(handleId, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, attributes);
19
+ }
13
20
  //# sourceMappingURL=typed-attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typed-attributes.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/typed-attributes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAI/D,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,mCAAmC;IACnC,wBAAwB;CACzB,CAAC;AAEF,MAAM,UAAU,6BAA6B,CAC3C,QAAgB,EAChB,UAA4D;IAE5D,OAAO,wBAAwB,CAC7B,QAAQ,EACR,mCAAmC,EACnC,UAAU,CAC6B,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { adaptTypedSpreadAttrSlot } from './attr-slot-plan.js';\nimport type { EtAttrPlan } from './attr-slot-plan.js';\nimport type { RuntimeTypedElementAttributes, TypedElementAttributesCommand } from '../../protocol/types.js';\n\nexport const TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX = 0;\n\nexport const TYPED_ELEMENT_ATTR_PLAN: EtAttrPlan = [\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n adaptTypedSpreadAttrSlot,\n];\n\nexport function prepareTypedElementAttributes(\n handleId: number,\n attributes: RuntimeTypedElementAttributes | null | undefined,\n): TypedElementAttributesCommand | null {\n return adaptTypedSpreadAttrSlot(\n handleId,\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n attributes,\n ) as TypedElementAttributesCommand | null;\n}\n"]}
1
+ {"version":3,"file":"typed-attributes.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/typed-attributes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAIpF,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,uBAAuB,GAAe;IACjD,mCAAmC;IACnC,wBAAwB;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAe;IAC9C,mCAAmC;IACnC,mBAAmB;CACpB,CAAC;AAEF,MAAM,UAAU,6BAA6B,CAC3C,QAAgB,EAChB,UAA4D;IAE5D,OAAO,wBAAwB,CAC7B,QAAQ,EACR,mCAAmC,EACnC,UAAU,CAC6B,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,QAAgB,EAChB,UAA4D;IAE5D,OAAO,mBAAmB,CACxB,QAAQ,EACR,mCAAmC,EACnC,UAAU,CAC6B,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { adaptSpreadAttrSlot, adaptTypedSpreadAttrSlot } from './attr-slot-plan.js';\nimport type { EtAttrPlan } from './attr-slot-plan.js';\nimport type { RuntimeTypedElementAttributes, TypedElementAttributesCommand } from '../../protocol/types.js';\n\nexport const TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX = 0;\n\nexport const TYPED_ELEMENT_ATTR_PLAN: EtAttrPlan = [\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n adaptTypedSpreadAttrSlot,\n];\n\nexport const TYPED_LIST_ATTR_PLAN: EtAttrPlan = [\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n adaptSpreadAttrSlot,\n];\n\nexport function prepareTypedElementAttributes(\n handleId: number,\n attributes: RuntimeTypedElementAttributes | null | undefined,\n): TypedElementAttributesCommand | null {\n return adaptTypedSpreadAttrSlot(\n handleId,\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n attributes,\n ) as TypedElementAttributesCommand | null;\n}\n\nexport function prepareTypedListAttributes(\n handleId: number,\n attributes: RuntimeTypedElementAttributes | null | undefined,\n): TypedElementAttributesCommand | null {\n return adaptSpreadAttrSlot(\n handleId,\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n attributes,\n ) as TypedElementAttributesCommand | null;\n}\n"]}
@@ -9,6 +9,7 @@ import { snapshotCreateList } from './snapshot/snapshot/list.js';
9
9
  import { SnapshotInstance, snapshotCreatorMap } from './snapshot/snapshot/snapshot.js';
10
10
  export { BITS, CHILDREN, COMPONENT, COMPONENT_DIRTY, DIFF, DOM, FLAGS, INDEX, PARENT, } from './shared/render-constants.js';
11
11
  export { __page, __pageId, __root };
12
+ export { TransferRegistry } from './snapshot/transfer.js';
12
13
  export { BackgroundSnapshotInstance, SnapshotInstance, snapshotCreateList, createSnapshot, snapshotManager, snapshotCreatorMap, };
13
14
  export declare const __DynamicPartSlot: DynamicPartType;
14
15
  export declare const __DynamicPartMultiChildren: DynamicPartType;
@@ -1,14 +1,12 @@
1
1
  // Copyright 2024 The Lynx Authors. All rights reserved.
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
- import { Suspense, createElement, lazy, cloneElement as preactCloneElement } from 'preact/compat';
4
+ import { cloneElement as preactCloneElement } from 'preact/compat';
5
5
  import './runtime-marker.js';
6
6
  import './lynx.js';
7
- import { useMemo } from './core/hooks/react.js';
8
- import { loadLazyBundle } from './core/lynx/lazy-bundle.js';
7
+ import { __ComponentIsPolyfill as componentIsPolyfill } from './core/compat/componentIs.js';
9
8
  import * as ReactLynxInternalSelf from './internal.js';
10
9
  import { __root } from './root.js';
11
- import { factory as factory2 } from './snapshot/compat/componentIs.js';
12
10
  import { BackgroundSnapshotInstance } from './snapshot/snapshot/backgroundSnapshot.js';
13
11
  import { __page, __pageId, createSnapshot, snapshotManager } from './snapshot/snapshot/definition.js';
14
12
  import { DynamicPartType } from './snapshot/snapshot/dynamicPartType.js';
@@ -17,6 +15,7 @@ import { SnapshotInstance, snapshotCreatorMap } from './snapshot/snapshot/snapsh
17
15
  import { setSnapshotCreatorRuntime } from './snapshot/snapshot/snapshotCreatorMap.js';
18
16
  export { BITS, CHILDREN, COMPONENT, COMPONENT_DIRTY, DIFF, DOM, FLAGS, INDEX, PARENT, } from './shared/render-constants.js';
19
17
  export { __page, __pageId, __root };
18
+ export { TransferRegistry } from './snapshot/transfer.js';
20
19
  export { BackgroundSnapshotInstance, SnapshotInstance, snapshotCreateList, createSnapshot, snapshotManager, snapshotCreatorMap, };
21
20
  export const __DynamicPartSlot = DynamicPartType.Slot;
22
21
  export const __DynamicPartMultiChildren = DynamicPartType.MultiChildren;
@@ -44,12 +43,8 @@ export { registerRuntimeVersion, getRuntimeVersion } from './core/lynx/runtime-v
44
43
  export { RUNTIME_BACKEND_ELEMENT_TEMPLATE, RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend, } from './core/lynx/runtime-backend.js';
45
44
  export { withInitDataInState } from './core/initData.js';
46
45
  export { wrapWithLynxComponent } from './core/compat/lynxComponent.js';
47
- /**
48
- * @internal a polyfill for <component is=? />
49
- */
50
- export const __ComponentIsPolyfill = /* @__PURE__ */ factory2(
51
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
52
- { Suspense, lazy, createElement, useMemo }, loadLazyBundle);
46
+ /** @internal Compatibility for the compiler lowering of <component is=? />. */
47
+ export const __ComponentIsPolyfill = componentIsPolyfill;
53
48
  export { loadLazyBundle } from './core/lynx/lazy-bundle.js';
54
49
  export { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';
55
50
  export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGlG,OAAO,qBAAqB,CAAC;AAC7B,OAAO,WAAW,CAAC;AAEnB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,qBAAqB,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACtG,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,eAAe,EACf,IAAI,EACJ,GAAG,EACH,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAEpC,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,k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BAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAuB,eAAe,CAAC,QAAQ;AAC/E,iEAAiE;AACjE,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAS,EACjD,cAAc,CACf,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,8BAA8B,IAAI,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE5G,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,IAAI,OAAO,EAAE,CAAC;IACZ,kEAAkE;IAClE,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,yBAAyB,CAAC,qBAAqB,CAAC,CAAC;AACnD,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { Suspense, createElement, lazy, cloneElement as preactCloneElement } from 'preact/compat';\nimport type { FC } from 'react';\n\nimport './runtime-marker.js';\nimport './lynx.js';\n\nimport { useMemo } from './core/hooks/react.js';\nimport { loadLazyBundle } from './core/lynx/lazy-bundle.js';\nimport * as ReactLynxInternalSelf from './internal.js';\nimport { __root } from './root.js';\nimport { factory as factory2 } from './snapshot/compat/componentIs.js';\nimport { BackgroundSnapshotInstance } from './snapshot/snapshot/backgroundSnapshot.js';\nimport { __page, __pageId, createSnapshot, snapshotManager } from './snapshot/snapshot/definition.js';\nimport { DynamicPartType } from './snapshot/snapshot/dynamicPartType.js';\nimport { snapshotCreateList } from './snapshot/snapshot/list.js';\nimport { SnapshotInstance, snapshotCreatorMap } from './snapshot/snapshot/snapshot.js';\nimport { setSnapshotCreatorRuntime } from './snapshot/snapshot/snapshotCreatorMap.js';\n\nexport {\n BITS,\n CHILDREN,\n COMPONENT,\n COMPONENT_DIRTY,\n DIFF,\n DOM,\n FLAGS,\n INDEX,\n PARENT,\n} from './shared/render-constants.js';\n\nexport { __page, __pageId, __root };\n\nexport {\n BackgroundSnapshotInstance,\n SnapshotInstance,\n snapshotCreateList,\n createSnapshot,\n snapshotManager,\n snapshotCreatorMap,\n};\n\nexport const __DynamicPartSlot: DynamicPartType = DynamicPartType.Slot;\nexport const __DynamicPartMultiChildren: DynamicPartType = DynamicPartType.MultiChildren;\nexport const __DynamicPartChildren: DynamicPartType = DynamicPartType.Children;\nexport const __DynamicPartListChildren: DynamicPartType = DynamicPartType.ListChildren;\nexport { __DynamicPartChildren_0, __DynamicPartSlotV2_0 } from './snapshot/snapshot/dynamicPartType.js';\n\n// v2 slot\nexport const __DynamicPartSlotV2: DynamicPartType = DynamicPartType.SlotV2;\nexport const __DynamicPartListSlotV2: DynamicPartType = DynamicPartType.ListSlotV2;\n\nexport { updateSpread } from './snapshot/snapshot/spread.js';\nexport { updateEvent } from './snapshot/snapshot/event.js';\nexport { updateRef, transformRef } from './snapshot/snapshot/ref.js';\nexport { updateWorkletEvent } from './snapshot/snapshot/workletEvent.js';\nexport { updateWorkletRef } from './snapshot/snapshot/workletRef.js';\nexport { updateGesture } from './snapshot/snapshot/gesture.js';\nexport { updateListItemPlatformInfo } from './snapshot/snapshot/platformInfo.js';\n\nexport { preactCloneElement };\n\nexport {\n options,\n // Component is not an internal API, but refresh needs it from 'react/internal'\n Component,\n process,\n} from 'preact';\nexport type { Options } from 'preact';\n\nexport { loadDynamicJS, __dynamicImport } from './core/lynx/dynamic-import.js';\n\n// Re-exported so lazy bundle shells can reach the host runtime APIs\n// via `target[sExportsReactInternal]`.\nexport { registerRuntimeVersion, getRuntimeVersion } from './core/lynx/runtime-version.js';\nexport {\n RUNTIME_BACKEND_ELEMENT_TEMPLATE,\n RUNTIME_BACKEND_SNAPSHOT,\n registerRuntimeBackend,\n} from './core/lynx/runtime-backend.js';\n\nexport { withInitDataInState } from './core/initData.js';\n\nexport { wrapWithLynxComponent } from './core/compat/lynxComponent.js';\n\n/**\n * @internal a polyfill for <component is=? />\n */\nexport const __ComponentIsPolyfill: FC<{ is: string }> = /* @__PURE__ */ factory2(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n { Suspense, lazy, createElement, useMemo } as any,\n loadLazyBundle,\n);\n\nexport { loadLazyBundle } from './core/lynx/lazy-bundle.js';\n\nexport { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';\n\nexport { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';\nexport { captureMainThreadObject } from './core/capture-main-thread-object.js';\n\nif (__DEV__) {\n // Dev snapshot creators take the runtime as a parameter (they are\n // stringified for cross-thread HMR and must not capture module bindings);\n // register this namespace as that runtime. Production creators close over\n // their own module's runtime import, so this reference is dropped there.\n setSnapshotCreatorRuntime(ReactLynxInternalSelf);\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,qBAAqB,CAAC;AAC7B,OAAO,WAAW,CAAC;AAEnB,OAAO,EAAE,qBAAqB,IAAI,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,KAAK,qBAAqB,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACtG,OAAO,EAAE,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AAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,OAAO,EACL,OAAO;AACP,+EAA+E;AAC/E,SAAS,EACT,OAAO,GACR,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAE/E,oEAAoE;AACpE,uCAAuC;AACvC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EACL,gCAAgC,EAChC,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,8BAA8B,IAAI,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE5G,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,IAAI,OAAO,EAAE,CAAC;IACZ,kEAAkE;IAClE,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,yBAAyB,CAAC,qBAAqB,CAAC,CAAC;AACnD,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { cloneElement as preactCloneElement } from 'preact/compat';\n\nimport './runtime-marker.js';\nimport './lynx.js';\n\nimport { __ComponentIsPolyfill as componentIsPolyfill } from './core/compat/componentIs.js';\nimport * as ReactLynxInternalSelf from './internal.js';\nimport { __root } from './root.js';\nimport { BackgroundSnapshotInstance } from './snapshot/snapshot/backgroundSnapshot.js';\nimport { __page, __pageId, createSnapshot, snapshotManager } from './snapshot/snapshot/definition.js';\nimport { DynamicPartType } from './snapshot/snapshot/dynamicPartType.js';\nimport { snapshotCreateList } from './snapshot/snapshot/list.js';\nimport { SnapshotInstance, snapshotCreatorMap } from './snapshot/snapshot/snapshot.js';\nimport { setSnapshotCreatorRuntime } from './snapshot/snapshot/snapshotCreatorMap.js';\n\nexport {\n BITS,\n CHILDREN,\n COMPONENT,\n COMPONENT_DIRTY,\n DIFF,\n DOM,\n FLAGS,\n INDEX,\n PARENT,\n} from './shared/render-constants.js';\n\nexport { __page, __pageId, __root };\n\nexport { TransferRegistry } from './snapshot/transfer.js';\n\nexport {\n BackgroundSnapshotInstance,\n SnapshotInstance,\n snapshotCreateList,\n createSnapshot,\n snapshotManager,\n snapshotCreatorMap,\n};\n\nexport const __DynamicPartSlot: DynamicPartType = DynamicPartType.Slot;\nexport const __DynamicPartMultiChildren: DynamicPartType = DynamicPartType.MultiChildren;\nexport const __DynamicPartChildren: DynamicPartType = DynamicPartType.Children;\nexport const __DynamicPartListChildren: DynamicPartType = DynamicPartType.ListChildren;\nexport { __DynamicPartChildren_0, __DynamicPartSlotV2_0 } from './snapshot/snapshot/dynamicPartType.js';\n\n// v2 slot\nexport const __DynamicPartSlotV2: DynamicPartType = DynamicPartType.SlotV2;\nexport const __DynamicPartListSlotV2: DynamicPartType = DynamicPartType.ListSlotV2;\n\nexport { updateSpread } from './snapshot/snapshot/spread.js';\nexport { updateEvent } from './snapshot/snapshot/event.js';\nexport { updateRef, transformRef } from './snapshot/snapshot/ref.js';\nexport { updateWorkletEvent } from './snapshot/snapshot/workletEvent.js';\nexport { updateWorkletRef } from './snapshot/snapshot/workletRef.js';\nexport { updateGesture } from './snapshot/snapshot/gesture.js';\nexport { updateListItemPlatformInfo } from './snapshot/snapshot/platformInfo.js';\n\nexport { preactCloneElement };\n\nexport {\n options,\n // Component is not an internal API, but refresh needs it from 'react/internal'\n Component,\n process,\n} from 'preact';\nexport type { Options } from 'preact';\n\nexport { loadDynamicJS, __dynamicImport } from './core/lynx/dynamic-import.js';\n\n// Re-exported so lazy bundle shells can reach the host runtime APIs\n// via `target[sExportsReactInternal]`.\nexport { registerRuntimeVersion, getRuntimeVersion } from './core/lynx/runtime-version.js';\nexport {\n RUNTIME_BACKEND_ELEMENT_TEMPLATE,\n RUNTIME_BACKEND_SNAPSHOT,\n registerRuntimeBackend,\n} from './core/lynx/runtime-backend.js';\n\nexport { withInitDataInState } from './core/initData.js';\n\nexport { wrapWithLynxComponent } from './core/compat/lynxComponent.js';\n\n/** @internal Compatibility for the compiler lowering of <component is=? />. */\nexport const __ComponentIsPolyfill = componentIsPolyfill;\n\nexport { loadLazyBundle } from './core/lynx/lazy-bundle.js';\n\nexport { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';\n\nexport { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';\nexport { captureMainThreadObject } from './core/capture-main-thread-object.js';\n\nif (__DEV__) {\n // Dev snapshot creators take the runtime as a parameter (they are\n // stringified for cross-thread HMR and must not capture module bindings);\n // register this namespace as that runtime. Production creators close over\n // their own module's runtime import, so this reference is dropped there.\n setSnapshotCreatorRuntime(ReactLynxInternalSelf);\n}\n"]}
@@ -7,7 +7,7 @@ import { useState } from 'preact/hooks';
7
7
  import { createGlobalProps } from './core/globalProps.js';
8
8
  import { useLynxGlobalEventListener } from './core/hooks/useLynxGlobalEventListener.js';
9
9
  import { factory, withInitDataInState } from './core/initData.js';
10
- import { __root } from './root.js';
10
+ import { __root, transferMode, warnRootRenderOnTransferPage } from './root.js';
11
11
  import { profileEnd, profileStart } from './shared/profile.js';
12
12
  import { LifecycleConstant } from './snapshot/lifecycle/constant.js';
13
13
  import { onFirstScreenSyncReady } from './snapshot/lifecycle/event/firstScreenSync.js';
@@ -25,6 +25,11 @@ import { flushDelayedLifecycleEvents } from './snapshot/lynx/tt.js';
25
25
  */
26
26
  export const root = {
27
27
  render: (jsx) => {
28
+ // Transfer pages render only registered components; the page root stays empty.
29
+ if (transferMode) {
30
+ warnRootRenderOnTransferPage();
31
+ return;
32
+ }
28
33
  /* v8 ignore next 2 */
29
34
  if (typeof __MAIN_THREAD__ !== 'undefined' && __MAIN_THREAD__) {
30
35
  __root.__jsx = jsx;