@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
@@ -89,6 +89,7 @@ describe('BackgroundElementTemplateInstance', () => {
89
89
  null,
90
90
  [],
91
91
  [],
92
+ null,
92
93
  ElementTemplateUpdateOps.insertNode,
93
94
  0,
94
95
  0,
@@ -217,7 +218,7 @@ describe('BackgroundElementTemplateInstance', () => {
217
218
  expect(globalCommitContext.ops).toEqual([ElementTemplateUpdateOps.setAttribute, -10, 0, 'changed']);
218
219
  });
219
220
 
220
- it('emits exact list create as typed holder with logical children in command options', () => {
221
+ it('emits exact list create with logical child slots and ref candidates', () => {
221
222
  const list = new BackgroundListElementTemplateInstance();
222
223
  const item = new BackgroundElementTemplateInstance('_et_list_item');
223
224
  list.setAttribute('attributes', { id: 'feed' });
@@ -231,16 +232,22 @@ describe('BackgroundElementTemplateInstance', () => {
231
232
  list.instanceId,
232
233
  'list',
233
234
  { id: 'feed' },
235
+ [[item.instanceId]],
234
236
  null,
237
+ ElementTemplateUpdateOps.updateTypedListItem,
238
+ list.instanceId,
235
239
  {
236
- listChildren: [{
237
- __etHandleRef: item.instanceId,
238
- type: '_et_list_item',
239
- platformInfo: {},
240
- subtreeHandleIds: [],
241
- }],
240
+ __etHandleRef: item.instanceId,
241
+ type: '_et_list_item',
242
+ platformInfo: null,
243
+ subtreeHandleIds: [],
242
244
  },
243
245
  ]);
246
+
247
+ globalCommitContext.ops = [];
248
+ list.emitCreate();
249
+
250
+ expect(globalCommitContext.ops).toEqual([]);
244
251
  });
245
252
 
246
253
  it('owns empty attributes in the generic typed attribute slot', () => {
@@ -351,7 +358,7 @@ describe('BackgroundElementTemplateInstance', () => {
351
358
  ]);
352
359
  });
353
360
 
354
- it('emits logical list insertions as incremental typed list item patches', () => {
361
+ it('emits logical list insertions through the shared child slot commands', () => {
355
362
  const list = new BackgroundListElementTemplateInstance();
356
363
  const oldListId = list.instanceId;
357
364
  backgroundElementTemplateInstanceManager.updateId(oldListId, -10);
@@ -376,15 +383,13 @@ describe('BackgroundElementTemplateInstance', () => {
376
383
  null,
377
384
  [],
378
385
  [],
379
- ElementTemplateUpdateOps.insertTypedListItem,
386
+ { __listItemPlatformInfo: { 'item-key': 'b' } },
387
+ ElementTemplateUpdateOps.insertNode,
380
388
  -10,
381
- {
382
- __etHandleRef: second.instanceId,
383
- type: '_et_item_b',
384
- platformInfo: { 'item-key': 'b' },
385
- subtreeHandleIds: [],
386
- },
389
+ 0,
390
+ second.instanceId,
387
391
  -11,
392
+ null,
388
393
  ]);
389
394
  });
390
395
 
@@ -411,9 +416,183 @@ describe('BackgroundElementTemplateInstance', () => {
411
416
  __etHandleRef: -11,
412
417
  type: '_et_item_a',
413
418
  platformInfo: { 'item-key': 'a', 'estimated-height': 42 },
414
- subtreeHandleIds: [],
419
+ subtreeHandleIds: null,
420
+ },
421
+ ]);
422
+ });
423
+
424
+ it('filters list item metadata in background create commands without changing ordinary attributes', () => {
425
+ const platformInfo = {
426
+ 'reuse-identifier': '',
427
+ 'full-span': false,
428
+ 'item-key': 'a',
429
+ 'sticky-top': false,
430
+ 'sticky-bottom': true,
431
+ 'estimated-height': 0,
432
+ 'estimated-height-px': null,
433
+ 'estimated-main-axis-size-px': undefined,
434
+ recyclable: false,
435
+ };
436
+ const attributes = {
437
+ id: 'row',
438
+ className: 'row-before',
439
+ style: { height: 64 },
440
+ };
441
+ const handleTap = vi.fn();
442
+ const metadata = {
443
+ ...platformInfo,
444
+ ...attributes,
445
+ bindtap: handleTap,
446
+ __spread: true,
447
+ itemKey: 'camel-case',
448
+ };
449
+ const originalMetadata = { ...metadata };
450
+ const item = new BackgroundElementTemplateInstance('_et_item_a', [attributes]);
451
+
452
+ item.setAttribute('__listItemPlatformInfo', metadata);
453
+
454
+ expect(item.getListItemPlatformInfo()).toStrictEqual(platformInfo);
455
+ expect(item.getListItemPlatformInfo()).not.toBe(metadata);
456
+ expect(metadata).toStrictEqual(originalMetadata);
457
+ markElementTemplateHydrated();
458
+ globalCommitContext.ops = [];
459
+
460
+ item.emitCreate();
461
+
462
+ expect(globalCommitContext.ops).toStrictEqual([
463
+ ElementTemplateUpdateOps.createTemplate,
464
+ item.instanceId,
465
+ '_et_item_a',
466
+ null,
467
+ [attributes],
468
+ [],
469
+ { __listItemPlatformInfo: platformInfo },
470
+ ]);
471
+ expect(item.attributeSlots[0]).toBe(attributes);
472
+ expect(handleTap).not.toHaveBeenCalled();
473
+ });
474
+
475
+ it('ignores inherited platform info and does not rename ordinary metadata keys', () => {
476
+ const metadata = Object.assign(
477
+ Object.create({ 'item-key': 'inherited', 'reuse-identifier': 'inherited' }) as Record<string, unknown>,
478
+ { 'estimated-height': 42, itemKey: 'camel-case', className: 'row' },
479
+ );
480
+ const item = new BackgroundElementTemplateInstance('_et_item_a');
481
+
482
+ item.setAttribute('__listItemPlatformInfo', metadata);
483
+
484
+ expect(item.getListItemPlatformInfo()).toEqual({ 'estimated-height': 42 });
485
+ expect(Object.hasOwn(metadata, 'item-key')).toBe(false);
486
+ expect(metadata['item-key']).toBe('inherited');
487
+ });
488
+
489
+ it('ignores ordinary prop changes but emits filtered list item platform info updates', () => {
490
+ const list = new BackgroundListElementTemplateInstance();
491
+ backgroundElementTemplateInstanceManager.updateId(list.instanceId, -10);
492
+ list.markMaterializedByHydration();
493
+ const metadata = {
494
+ 'item-key': 'a',
495
+ 'estimated-height': 42,
496
+ className: 'row-before',
497
+ style: { height: 64 },
498
+ bindtap: vi.fn(),
499
+ };
500
+ const item = new BackgroundElementTemplateInstance('_et_item_a');
501
+ item.setAttribute('__listItemPlatformInfo', metadata);
502
+ list.appendChild(item);
503
+ backgroundElementTemplateInstanceManager.updateId(item.instanceId, -11);
504
+ item.markMaterializedByHydration();
505
+ markElementTemplateHydrated();
506
+ globalCommitContext.ops = [];
507
+ const changedProps = {
508
+ ...metadata,
509
+ id: 'next-row',
510
+ className: 'row-after',
511
+ style: { height: 80 },
512
+ bindtap: vi.fn(),
513
+ __spread: true,
514
+ };
515
+
516
+ item.setAttribute('__listItemPlatformInfo', changedProps);
517
+
518
+ expect(item.getListItemPlatformInfo()).toEqual({ 'item-key': 'a', 'estimated-height': 42 });
519
+ expect(globalCommitContext.ops).toEqual([]);
520
+
521
+ item.setAttribute('__listItemPlatformInfo', { ...changedProps, 'estimated-height': 84 });
522
+
523
+ expect(globalCommitContext.ops).toEqual([
524
+ ElementTemplateUpdateOps.updateTypedListItem,
525
+ -10,
526
+ {
527
+ __etHandleRef: -11,
528
+ type: '_et_item_a',
529
+ platformInfo: { 'item-key': 'a', 'estimated-height': 84 },
530
+ subtreeHandleIds: null,
531
+ },
532
+ ]);
533
+ });
534
+
535
+ it('copies list item metadata before comparing a reused input object', () => {
536
+ const list = new BackgroundListElementTemplateInstance();
537
+ backgroundElementTemplateInstanceManager.updateId(list.instanceId, -10);
538
+ list.markMaterializedByHydration();
539
+ const metadata = { 'item-key': 'a', className: 'row' };
540
+ const item = new BackgroundElementTemplateInstance('_et_item_a');
541
+ item.setAttribute('__listItemPlatformInfo', metadata);
542
+ list.appendChild(item);
543
+ backgroundElementTemplateInstanceManager.updateId(item.instanceId, -11);
544
+ item.markMaterializedByHydration();
545
+ markElementTemplateHydrated();
546
+ globalCommitContext.ops = [];
547
+
548
+ metadata['item-key'] = 'b';
549
+
550
+ expect(item.getListItemPlatformInfo()).toEqual({ 'item-key': 'a' });
551
+
552
+ item.setAttribute('__listItemPlatformInfo', metadata);
553
+
554
+ expect(globalCommitContext.ops).toEqual([
555
+ ElementTemplateUpdateOps.updateTypedListItem,
556
+ -10,
557
+ {
558
+ __etHandleRef: -11,
559
+ type: '_et_item_a',
560
+ platformInfo: { 'item-key': 'b' },
561
+ subtreeHandleIds: null,
562
+ },
563
+ ]);
564
+ });
565
+
566
+ it.each([null, undefined, {}, { className: 'row' }])('clears list item platform info once when set to %s', value => {
567
+ const list = new BackgroundListElementTemplateInstance();
568
+ backgroundElementTemplateInstanceManager.updateId(list.instanceId, -10);
569
+ list.markMaterializedByHydration();
570
+ const item = new BackgroundElementTemplateInstance('_et_item_a');
571
+ item.setAttribute('__listItemPlatformInfo', { 'item-key': 'a' });
572
+ list.appendChild(item);
573
+ backgroundElementTemplateInstanceManager.updateId(item.instanceId, -11);
574
+ item.markMaterializedByHydration();
575
+ markElementTemplateHydrated();
576
+ globalCommitContext.ops = [];
577
+
578
+ item.setAttribute('__listItemPlatformInfo', value);
579
+
580
+ expect(globalCommitContext.ops).toEqual([
581
+ ElementTemplateUpdateOps.updateTypedListItem,
582
+ -10,
583
+ {
584
+ __etHandleRef: -11,
585
+ type: '_et_item_a',
586
+ platformInfo: {},
587
+ subtreeHandleIds: null,
415
588
  },
416
589
  ]);
590
+
591
+ globalCommitContext.ops = [];
592
+
593
+ item.setAttribute('__listItemPlatformInfo', value);
594
+
595
+ expect(globalCommitContext.ops).toEqual([]);
417
596
  });
418
597
 
419
598
  it('does not refresh list membership when adding a subtree without MTRefs', () => {
@@ -438,6 +617,7 @@ describe('BackgroundElementTemplateInstance', () => {
438
617
  null,
439
618
  [],
440
619
  [],
620
+ null,
441
621
  ElementTemplateUpdateOps.insertNode,
442
622
  -11,
443
623
  0,
@@ -514,8 +694,9 @@ describe('BackgroundElementTemplateInstance', () => {
514
694
  flushPendingRefs();
515
695
 
516
696
  expect(globalCommitContext.ops).toEqual([
517
- ElementTemplateUpdateOps.removeTypedListItem,
697
+ ElementTemplateUpdateOps.removeNode,
518
698
  -10,
699
+ 0,
519
700
  -11,
520
701
  [-11],
521
702
  ]);
@@ -559,19 +740,17 @@ describe('BackgroundElementTemplateInstance', () => {
559
740
  newList.appendChild(item);
560
741
 
561
742
  expect(globalCommitContext.ops).toEqual([
562
- ElementTemplateUpdateOps.removeTypedListItem,
743
+ ElementTemplateUpdateOps.removeNode,
563
744
  -10,
745
+ 0,
564
746
  -11,
565
747
  [],
566
- ElementTemplateUpdateOps.insertTypedListItem,
748
+ ElementTemplateUpdateOps.insertNode,
567
749
  -20,
568
- {
569
- __etHandleRef: -11,
570
- type: '_et_item_a',
571
- platformInfo: { 'item-key': 'a' },
572
- subtreeHandleIds: [],
573
- },
574
750
  0,
751
+ -11,
752
+ 0,
753
+ null,
575
754
  ]);
576
755
  });
577
756
 
@@ -605,7 +784,7 @@ describe('BackgroundElementTemplateInstance', () => {
605
784
  {
606
785
  __etHandleRef: item.instanceId,
607
786
  type: '_et_item',
608
- platformInfo: {},
787
+ platformInfo: null,
609
788
  subtreeHandleIds: [child.instanceId],
610
789
  },
611
790
  ]);
@@ -637,13 +816,13 @@ describe('BackgroundElementTemplateInstance', () => {
637
816
  {
638
817
  __etHandleRef: item.instanceId,
639
818
  type: '_et_item',
640
- platformInfo: {},
819
+ platformInfo: null,
641
820
  subtreeHandleIds: [],
642
821
  },
643
822
  ]);
644
823
  });
645
824
 
646
- it('emits incremental list mutations instead of full children snapshots during one render', () => {
825
+ it('emits structural and platform info updates for list mutations during one render', () => {
647
826
  const list = new BackgroundListElementTemplateInstance();
648
827
  backgroundElementTemplateInstanceManager.updateId(list.instanceId, -10);
649
828
  list.markMaterializedByHydration();
@@ -670,17 +849,16 @@ describe('BackgroundElementTemplateInstance', () => {
670
849
  null,
671
850
  [],
672
851
  [],
673
- ElementTemplateUpdateOps.insertTypedListItem,
852
+ null,
853
+ ElementTemplateUpdateOps.insertNode,
674
854
  -10,
675
- {
676
- __etHandleRef: third.instanceId,
677
- type: '_et_item_c',
678
- platformInfo: {},
679
- subtreeHandleIds: [],
680
- },
855
+ 0,
856
+ third.instanceId,
681
857
  -12,
682
- ElementTemplateUpdateOps.removeTypedListItem,
858
+ null,
859
+ ElementTemplateUpdateOps.removeNode,
683
860
  -10,
861
+ 0,
684
862
  -11,
685
863
  [-11],
686
864
  ElementTemplateUpdateOps.updateTypedListItem,
@@ -689,7 +867,7 @@ describe('BackgroundElementTemplateInstance', () => {
689
867
  __etHandleRef: -12,
690
868
  type: '_et_item_b',
691
869
  platformInfo: { 'item-key': 'b', 'full-span': true },
692
- subtreeHandleIds: [],
870
+ subtreeHandleIds: null,
693
871
  },
694
872
  ]);
695
873
  });
@@ -784,17 +962,6 @@ describe('BackgroundElementTemplateInstance', () => {
784
962
  expect(parent.lastChild).toBe(child);
785
963
  });
786
964
 
787
- it('supports silent append on regular parents', () => {
788
- const parent = new BackgroundElementTemplateInstance('view');
789
- const child = new BackgroundElementTemplateInstance('text');
790
- globalCommitContext.ops = [];
791
-
792
- parent.insertBefore(child, null, true);
793
-
794
- expect(parent.firstChild).toBe(child);
795
- expect(globalCommitContext.ops).toEqual([]);
796
- });
797
-
798
965
  it('emits create with initialized attrs before inserting a post-hydration template', () => {
799
966
  const parent = new BackgroundElementTemplateInstance('view');
800
967
  parent.emitCreate();
@@ -816,6 +983,7 @@ describe('BackgroundElementTemplateInstance', () => {
816
983
  null,
817
984
  ['logo.png'],
818
985
  [],
986
+ null,
819
987
  3,
820
988
  parent.instanceId,
821
989
  0,
@@ -846,6 +1014,7 @@ describe('BackgroundElementTemplateInstance', () => {
846
1014
  null,
847
1015
  [`${child.instanceId}-0`],
848
1016
  [],
1017
+ null,
849
1018
  3,
850
1019
  parent.instanceId,
851
1020
  0,
@@ -870,7 +1039,7 @@ describe('BackgroundElementTemplateInstance', () => {
870
1039
  child.appendChild(ordinaryDescendant);
871
1040
  parent.appendChild(child);
872
1041
 
873
- expect(globalCommitContext.ops[12]).toBe(ElementTemplateUpdateOps.insertNode);
1042
+ expect(globalCommitContext.ops[14]).toBe(ElementTemplateUpdateOps.insertNode);
874
1043
  expect(globalCommitContext.ops.at(-1)).toEqual([child.instanceId]);
875
1044
  });
876
1045
 
@@ -957,32 +1126,14 @@ describe('BackgroundElementTemplateInstance', () => {
957
1126
  expect(parent.childNodes).toEqual([owner, anchor]);
958
1127
  expect(owner.firstChild).toBe(nested);
959
1128
  expect(nested.firstChild).toBe(leaf);
960
- expect(globalCommitContext.ops).toEqual(
961
- parentKind === 'list'
962
- ? [
963
- ElementTemplateUpdateOps.removeTypedListItem,
964
- parent.instanceId,
965
- owner.instanceId,
966
- [],
967
- ElementTemplateUpdateOps.insertTypedListItem,
968
- parent.instanceId,
969
- {
970
- __etHandleRef: owner.instanceId,
971
- type: '_et_owner',
972
- platformInfo: {},
973
- subtreeHandleIds: [leaf.instanceId],
974
- },
975
- anchor.instanceId,
976
- ]
977
- : [
978
- ElementTemplateUpdateOps.insertNode,
979
- parent.instanceId,
980
- 0,
981
- owner.instanceId,
982
- anchor.instanceId,
983
- [leaf.instanceId],
984
- ],
985
- );
1129
+ expect(globalCommitContext.ops).toEqual([
1130
+ ElementTemplateUpdateOps.insertNode,
1131
+ parent.instanceId,
1132
+ 0,
1133
+ owner.instanceId,
1134
+ anchor.instanceId,
1135
+ parentKind === 'list' ? null : [leaf.instanceId],
1136
+ ]);
986
1137
  });
987
1138
 
988
1139
  it('creates new descendants once when moving their materialized owner', () => {
@@ -1017,12 +1168,14 @@ describe('BackgroundElementTemplateInstance', () => {
1017
1168
  null,
1018
1169
  [`${leaf.instanceId}-0`],
1019
1170
  [],
1171
+ null,
1020
1172
  ElementTemplateUpdateOps.createTemplate,
1021
1173
  nested.instanceId,
1022
1174
  '_et_nested',
1023
1175
  null,
1024
1176
  [],
1025
1177
  [[leaf.instanceId]],
1178
+ null,
1026
1179
  ElementTemplateUpdateOps.insertNode,
1027
1180
  owner.instanceId,
1028
1181
  0,
@@ -1067,12 +1220,14 @@ describe('BackgroundElementTemplateInstance', () => {
1067
1220
  null,
1068
1221
  ['nested'],
1069
1222
  [],
1223
+ null,
1070
1224
  1,
1071
1225
  owner.instanceId,
1072
1226
  'view',
1073
1227
  null,
1074
1228
  [],
1075
1229
  [[nested.instanceId]],
1230
+ null,
1076
1231
  3,
1077
1232
  parent.instanceId,
1078
1233
  0,
@@ -1096,14 +1251,14 @@ describe('BackgroundElementTemplateInstance', () => {
1096
1251
 
1097
1252
  parent.appendChild(child);
1098
1253
 
1099
- const serializedSlots = globalCommitContext.ops[11] as unknown[];
1100
- expect(globalCommitContext.ops[6]).toBe(1);
1101
- expect(globalCommitContext.ops[7]).toBe(child.instanceId);
1254
+ const serializedSlots = globalCommitContext.ops[12] as unknown[];
1255
+ expect(globalCommitContext.ops[7]).toBe(1);
1256
+ expect(globalCommitContext.ops[8]).toBe(child.instanceId);
1102
1257
  expect(serializedSlots).toHaveLength(2);
1103
1258
  expect(0 in serializedSlots).toBe(false);
1104
1259
  expect(1 in serializedSlots).toBe(true);
1105
1260
  expect(serializedSlots[1]).toEqual([grandchild.instanceId]);
1106
- expect(globalCommitContext.ops.slice(12)).toEqual([
1261
+ expect(globalCommitContext.ops.slice(14)).toEqual([
1107
1262
  3,
1108
1263
  parent.instanceId,
1109
1264
  0,
@@ -1135,31 +1290,34 @@ describe('BackgroundElementTemplateInstance', () => {
1135
1290
  null,
1136
1291
  [],
1137
1292
  [],
1293
+ null,
1138
1294
  ElementTemplateUpdateOps.createTemplate,
1139
1295
  item.instanceId,
1140
1296
  '_et_item',
1141
1297
  null,
1142
1298
  [],
1143
1299
  [[nested.instanceId]],
1300
+ null,
1144
1301
  ElementTemplateUpdateOps.createTypedElement,
1145
1302
  list.instanceId,
1146
1303
  'list',
1147
1304
  null,
1305
+ [[item.instanceId]],
1148
1306
  null,
1307
+ ElementTemplateUpdateOps.updateTypedListItem,
1308
+ list.instanceId,
1149
1309
  {
1150
- listChildren: [{
1151
- __etHandleRef: item.instanceId,
1152
- type: '_et_item',
1153
- platformInfo: {},
1154
- subtreeHandleIds: [],
1155
- }],
1310
+ __etHandleRef: item.instanceId,
1311
+ type: '_et_item',
1312
+ platformInfo: null,
1313
+ subtreeHandleIds: [],
1156
1314
  },
1157
1315
  ElementTemplateUpdateOps.insertNode,
1158
1316
  parent.instanceId,
1159
1317
  0,
1160
1318
  list.instanceId,
1161
1319
  0,
1162
- null,
1320
+ [list.instanceId],
1163
1321
  ]);
1164
1322
  });
1165
1323
 
@@ -1270,6 +1428,7 @@ describe('BackgroundElementTemplateInstance', () => {
1270
1428
  null,
1271
1429
  [],
1272
1430
  [],
1431
+ null,
1273
1432
  ElementTemplateUpdateOps.insertNode,
1274
1433
  parent.instanceId,
1275
1434
  1,
@@ -1302,6 +1461,7 @@ describe('BackgroundElementTemplateInstance', () => {
1302
1461
  null,
1303
1462
  [],
1304
1463
  [],
1464
+ null,
1305
1465
  ElementTemplateUpdateOps.insertNode,
1306
1466
  parent.instanceId,
1307
1467
  1,
@@ -1385,12 +1545,14 @@ describe('BackgroundElementTemplateInstance', () => {
1385
1545
  null,
1386
1546
  ['inside'],
1387
1547
  [],
1548
+ null,
1388
1549
  ElementTemplateUpdateOps.createTemplate,
1389
1550
  child.instanceId,
1390
1551
  'view',
1391
1552
  null,
1392
1553
  [],
1393
1554
  [[grandchild.instanceId]],
1555
+ null,
1394
1556
  ElementTemplateUpdateOps.insertNode,
1395
1557
  parent.instanceId,
1396
1558
  0,
@@ -1425,12 +1587,14 @@ describe('BackgroundElementTemplateInstance', () => {
1425
1587
  null,
1426
1588
  ['inside'],
1427
1589
  [],
1590
+ null,
1428
1591
  ElementTemplateUpdateOps.createTemplate,
1429
1592
  -2,
1430
1593
  'view',
1431
1594
  null,
1432
1595
  [],
1433
1596
  [[-3]],
1597
+ null,
1434
1598
  ElementTemplateUpdateOps.insertNode,
1435
1599
  parent.instanceId,
1436
1600
  0,
@@ -1747,20 +1911,20 @@ describe('BackgroundElementTemplateInstance', () => {
1747
1911
  const child = new BackgroundElementTemplateInstance('text');
1748
1912
  parent.appendChild(child);
1749
1913
 
1750
- globalCommitContext.ops = [];
1914
+ markElementTemplateHydrated();
1915
+ parent.markMaterializedByHydration();
1916
+ child.markMaterializedByHydration();
1917
+
1751
1918
  parent.removeChild(child, true);
1752
1919
 
1753
1920
  expect(parent.childSlots[0]).toBeUndefined();
1921
+ expect(child.parent).toBeNull();
1754
1922
  expect(globalCommitContext.ops).toEqual([]);
1755
1923
  expect([...globalCommitContext.nonPayload.removedSubtreesAwaitingTeardown]).toEqual([]);
1924
+ expect(backgroundElementTemplateInstanceManager.get(child.instanceId)).toBe(child);
1756
1925
  });
1757
1926
  });
1758
1927
 
1759
- it('should be registered with manager upon creation', () => {
1760
- const instance = new BackgroundElementTemplateInstance('view');
1761
- expect(backgroundElementTemplateInstanceManager.get(instance.instanceId)).toBe(instance);
1762
- });
1763
-
1764
1928
  it('should tear down correctly', () => {
1765
1929
  const parent = new BackgroundElementTemplateInstance('view');
1766
1930
  const child = new BackgroundElementTemplateInstance('text');
@@ -1802,7 +1966,7 @@ describe('BackgroundElementTemplateInstance', () => {
1802
1966
  expect(ref.current).toBeNull();
1803
1967
  });
1804
1968
 
1805
- it('reports error for emitCreate with illegal handleId 0 in dev', () => {
1969
+ it('reports errors for compiled and List emitCreate with illegal handleId 0 in dev', () => {
1806
1970
  const lynxObj = globalThis.lynx as typeof lynx & { reportError?: (error: Error) => void };
1807
1971
  const oldReportError = lynxObj.reportError;
1808
1972
  const reportErrorSpy = vi.fn();
@@ -1814,6 +1978,16 @@ describe('BackgroundElementTemplateInstance', () => {
1814
1978
 
1815
1979
  expect(reportErrorSpy).toHaveBeenCalledTimes(1);
1816
1980
 
1981
+ const list = new BackgroundListElementTemplateInstance();
1982
+ list.appendChild(new BackgroundElementTemplateInstance('_et_list_item'));
1983
+ list.instanceId = 0;
1984
+ globalCommitContext.ops = [];
1985
+
1986
+ list.emitCreate();
1987
+
1988
+ expect(reportErrorSpy).toHaveBeenCalledTimes(2);
1989
+ expect(globalCommitContext.ops).toEqual([]);
1990
+
1817
1991
  lynxObj.reportError = oldReportError;
1818
1992
  });
1819
1993
 
@@ -1843,6 +2017,7 @@ describe('BackgroundElementTemplateInstance', () => {
1843
2017
  null,
1844
2018
  [null],
1845
2019
  [],
2020
+ null,
1846
2021
  ]);
1847
2022
  });
1848
2023
 
@@ -2181,6 +2356,7 @@ describe('BackgroundElementTemplateInstance', () => {
2181
2356
  null,
2182
2357
  [],
2183
2358
  [],
2359
+ null,
2184
2360
  ]);
2185
2361
  });
2186
2362
 
@@ -2198,6 +2374,7 @@ describe('BackgroundElementTemplateInstance', () => {
2198
2374
  null,
2199
2375
  [],
2200
2376
  [],
2377
+ null,
2201
2378
  ]);
2202
2379
  });
2203
2380
 
@@ -2232,6 +2409,7 @@ describe('BackgroundElementTemplateInstance', () => {
2232
2409
  null,
2233
2410
  ['deferred'],
2234
2411
  [],
2412
+ null,
2235
2413
  3,
2236
2414
  parent.instanceId,
2237
2415
  0,
@@ -2341,14 +2519,6 @@ describe('BackgroundElementTemplateInstance Shadow State', () => {
2341
2519
  expect(instance.attributeSlots).toEqual(slots);
2342
2520
  });
2343
2521
 
2344
- it('should update attributeSlots when setAttribute("attributeSlots", ...) is called', () => {
2345
- const instance = new BackgroundElementTemplateInstance('view');
2346
- const slots = [{ id: 'a' }, { class: 'foo' }] as const;
2347
- instance.setAttribute('attributeSlots', [...slots]);
2348
-
2349
- expect(instance.attributeSlots).toEqual(slots);
2350
- });
2351
-
2352
2522
  it.each([false, true])('does not serialize attributes before materialization (hydrated=%s)', (isHydrated) => {
2353
2523
  const instance = new BackgroundElementTemplateInstance('view', [{ id: 'before' }]);
2354
2524
  if (isHydrated) {
@@ -2377,6 +2547,7 @@ describe('BackgroundElementTemplateInstance Shadow State', () => {
2377
2547
  null,
2378
2548
  nextSlots,
2379
2549
  [],
2550
+ null,
2380
2551
  ElementTemplateUpdateOps.insertNode,
2381
2552
  root.instanceId,
2382
2553
  0,
@@ -2525,6 +2696,7 @@ describe('BackgroundElementTemplateInstance Shadow State', () => {
2525
2696
  null,
2526
2697
  [eventValue],
2527
2698
  [],
2699
+ null,
2528
2700
  ]);
2529
2701
  });
2530
2702
 
@@ -2653,6 +2825,7 @@ describe('BackgroundElementTemplateInstance Shadow State', () => {
2653
2825
  null,
2654
2826
  [preparedSpread],
2655
2827
  [],
2828
+ null,
2656
2829
  ]);
2657
2830
  });
2658
2831
 
@@ -2696,36 +2869,14 @@ describe('BackgroundElementTemplateInstance slot-index children', () => {
2696
2869
  expect(root.childSlots[1]).toEqual([text]);
2697
2870
  });
2698
2871
 
2699
- it('should keep childSlots in sync when slot is attached after children exist', () => {
2700
- const root = new BackgroundElementTemplateInstance('element-template-view');
2701
- const text = createTextNode('late');
2702
-
2703
- text.__slotIndex = 2;
2704
- root.appendChild(text);
2705
-
2706
- expect(root.childSlots[2]).toEqual([text]);
2707
- });
2708
-
2709
- it('should move slot children to the new slot index when partId changes', () => {
2710
- const root = new BackgroundElementTemplateInstance('element-template-view');
2711
- const text = createTextNode('move');
2712
-
2713
- text.__slotIndex = 0;
2714
- root.appendChild(text);
2715
- text.__slotIndex = 3;
2716
-
2717
- expect(root.childSlots[0]).toBeUndefined();
2718
- expect(root.childSlots[3]).toEqual([text]);
2719
- });
2720
-
2721
- it('should detach a moved child from the old slot shadow state when silent reparenting', () => {
2872
+ it('should detach a moved child from the old slot shadow state when reparenting', () => {
2722
2873
  const root = new BackgroundElementTemplateInstance('element-template-view');
2723
2874
  const text = createTextNode('move');
2724
2875
 
2725
2876
  root.appendChild(text);
2726
2877
 
2727
2878
  text.__slotIndex = 1;
2728
- root.insertBefore(text, null, true);
2879
+ root.insertBefore(text, null);
2729
2880
 
2730
2881
  expect(root.childSlots[0]).toBeUndefined();
2731
2882
  expect(root.childSlots[1]).toEqual([text]);
@@ -2739,7 +2890,7 @@ describe('BackgroundElementTemplateInstance slot-index children', () => {
2739
2890
 
2740
2891
  rootA.appendChild(text);
2741
2892
 
2742
- rootB.insertBefore(text, null, true);
2893
+ rootB.insertBefore(text, null);
2743
2894
 
2744
2895
  expect(rootA.childSlots).toEqual([]);
2745
2896
  expect(rootB.firstChild).toBe(text);