@lynx-js/react 0.129.0 → 0.129.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +3 -4
  4. package/refresh/.turbo/turbo-build.log +1 -1
  5. package/runtime/__test__/core/globalProps.test.ts +27 -6
  6. package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
  7. package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
  8. package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
  9. package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
  10. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
  11. package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
  12. package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
  13. package/runtime/__test__/element-template/native/mts-destroy.test.ts +88 -0
  14. package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
  15. package/runtime/__test__/element-template/native/reload.test.ts +118 -2
  16. package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
  17. package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
  18. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
  19. package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
  20. package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
  21. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
  22. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +212 -7
  23. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
  24. package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
  25. package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
  26. package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
  27. package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
  28. package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
  29. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
  30. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
  31. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
  32. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
  33. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +309 -26
  34. package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
  35. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
  36. package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
  37. package/runtime/__test__/shared/component-stack.test.ts +211 -0
  38. package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
  39. package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
  40. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
  41. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
  42. package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
  43. package/runtime/__test__/snapshot/preact.test.jsx +0 -3
  44. package/runtime/__test__/snapshot/ref.test.jsx +30 -0
  45. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
  46. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
  47. package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
  48. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
  49. package/runtime/lazy/element-template-internal.js +1 -1
  50. package/runtime/lazy/internal.js +1 -1
  51. package/runtime/lazy/jsx-dev-runtime.js +1 -1
  52. package/runtime/lazy/jsx-runtime.js +1 -1
  53. package/runtime/lazy/legacy-react-runtime.js +1 -1
  54. package/runtime/lazy/react-lepus.js +1 -1
  55. package/runtime/lazy/react.js +1 -1
  56. package/runtime/lib/core/capture-main-thread-object.js +2 -1
  57. package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
  58. package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
  59. package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
  60. package/runtime/lib/core/globalProps.js +1 -1
  61. package/runtime/lib/core/globalProps.js.map +1 -1
  62. package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
  63. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  64. package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
  65. package/runtime/lib/core/lynx-data-processors.js +3 -0
  66. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  67. package/runtime/lib/core/runtime-destroy.js +1 -1
  68. package/runtime/lib/core/runtime-destroy.js.map +1 -1
  69. package/runtime/lib/document.js +0 -5
  70. package/runtime/lib/document.js.map +1 -1
  71. package/runtime/lib/element-template/background/attr-slots.js +5 -2
  72. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  73. package/runtime/lib/element-template/background/commit-hook.js +11 -12
  74. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  75. package/runtime/lib/element-template/background/destroy.js +16 -11
  76. package/runtime/lib/element-template/background/destroy.js.map +1 -1
  77. package/runtime/lib/element-template/background/hydrate.js +23 -0
  78. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  79. package/runtime/lib/element-template/client/root.d.ts +1 -1
  80. package/runtime/lib/element-template/client/root.js.map +1 -1
  81. package/runtime/lib/element-template/debug/alog.d.ts +1 -1
  82. package/runtime/lib/element-template/debug/alog.js +4 -1
  83. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  84. package/runtime/lib/element-template/index.d.ts +2 -2
  85. package/runtime/lib/element-template/index.js.map +1 -1
  86. package/runtime/lib/element-template/internal.d.ts +2 -2
  87. package/runtime/lib/element-template/internal.js +1 -14
  88. package/runtime/lib/element-template/internal.js.map +1 -1
  89. package/runtime/lib/element-template/lynx/env.js.map +1 -1
  90. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
  91. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
  92. package/runtime/lib/element-template/native/flush.d.ts +1 -0
  93. package/runtime/lib/element-template/native/flush.js +9 -0
  94. package/runtime/lib/element-template/native/flush.js.map +1 -0
  95. package/runtime/lib/element-template/native/main-thread-api.js +3 -7
  96. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
  97. package/runtime/lib/element-template/native/mts-destroy.js +8 -2
  98. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
  99. package/runtime/lib/element-template/native/patch-listener.js +57 -50
  100. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  101. package/runtime/lib/element-template/native/reload-background.js +1 -1
  102. package/runtime/lib/element-template/native/reload-background.js.map +1 -1
  103. package/runtime/lib/element-template/native/reload-main-thread.js +35 -10
  104. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  105. package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
  106. package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
  107. package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
  108. package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
  109. package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
  110. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  111. package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
  112. package/runtime/lib/element-template/protocol/opcodes.js +1 -0
  113. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
  114. package/runtime/lib/element-template/protocol/types.d.ts +7 -1
  115. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  116. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
  117. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
  118. package/runtime/lib/element-template/runtime/patch.js +31 -2
  119. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  120. package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
  121. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
  122. package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
  123. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  124. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
  125. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
  126. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
  127. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
  128. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
  129. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -1
  130. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +380 -50
  131. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  132. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +3 -2
  133. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
  134. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  135. package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
  136. package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
  137. package/runtime/lib/internal.d.ts +1 -1
  138. package/runtime/lib/internal.js +1 -1
  139. package/runtime/lib/internal.js.map +1 -1
  140. package/runtime/lib/lynx-api.d.ts +2 -125
  141. package/runtime/lib/lynx-api.js.map +1 -1
  142. package/runtime/lib/shared/component-stack.d.ts +0 -4
  143. package/runtime/lib/shared/component-stack.js +21 -5
  144. package/runtime/lib/shared/component-stack.js.map +1 -1
  145. package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
  146. package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
  147. package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
  148. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  149. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
  150. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
  151. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
  152. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
  153. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  154. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
  155. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  156. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
  157. package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
  158. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  159. package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
  160. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  161. package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
  162. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  163. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
  164. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  165. package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
  166. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  167. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
  168. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  169. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
  170. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  171. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  172. package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
  173. package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
  174. package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
  175. package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
  176. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
  177. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
  178. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
  179. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
  180. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  181. package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
  182. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  183. package/runtime/package.json +2 -3
  184. package/runtime/src/core/capture-main-thread-object.ts +2 -1
  185. package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
  186. package/runtime/src/core/globalProps.ts +1 -1
  187. package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
  188. package/runtime/src/core/lynx-data-processors.ts +124 -1
  189. package/runtime/src/core/runtime-destroy.ts +1 -1
  190. package/runtime/src/document.ts +0 -6
  191. package/runtime/src/element-template/background/attr-slots.ts +5 -1
  192. package/runtime/src/element-template/background/commit-hook.ts +18 -12
  193. package/runtime/src/element-template/background/destroy.ts +16 -13
  194. package/runtime/src/element-template/background/hydrate.ts +23 -0
  195. package/runtime/src/element-template/client/root.ts +1 -3
  196. package/runtime/src/element-template/debug/alog.ts +5 -2
  197. package/runtime/src/element-template/index.ts +2 -2
  198. package/runtime/src/element-template/internal.ts +1 -20
  199. package/runtime/src/element-template/lynx/env.ts +1 -1
  200. package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
  201. package/runtime/src/element-template/native/flush.ts +10 -0
  202. package/runtime/src/element-template/native/main-thread-api.ts +3 -6
  203. package/runtime/src/element-template/native/mts-destroy.ts +7 -2
  204. package/runtime/src/element-template/native/patch-listener.ts +62 -57
  205. package/runtime/src/element-template/native/reload-background.ts +1 -1
  206. package/runtime/src/element-template/native/reload-main-thread.ts +32 -11
  207. package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
  208. package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
  209. package/runtime/src/element-template/protocol/opcodes.ts +1 -0
  210. package/runtime/src/element-template/protocol/types.ts +8 -13
  211. package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
  212. package/runtime/src/element-template/runtime/patch.ts +38 -0
  213. package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
  214. package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
  215. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
  216. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
  217. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +456 -50
  218. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +14 -4
  219. package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
  220. package/runtime/src/element-template/types.d.ts +6 -0
  221. package/runtime/src/internal.ts +1 -1
  222. package/runtime/src/lynx-api.ts +2 -124
  223. package/runtime/src/shared/component-stack.ts +22 -5
  224. package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
  225. package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
  226. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
  227. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
  228. package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
  229. package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
  230. package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
  231. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
  232. package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
  233. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
  234. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
  235. package/runtime/src/worklet-runtime/README.md +30 -10
  236. package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
  237. package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
  238. package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
  239. package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
  240. package/runtime/types/types.d.ts +2 -1
  241. package/runtime/vitest.config.ts +0 -2
  242. package/testing-library/.turbo/turbo-build.log +7 -7
  243. package/testing-library/src/__tests__/act.test.jsx +0 -7
  244. package/testing-library/src/__tests__/alog.test.jsx +12 -54
  245. package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
  246. package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
  247. package/testing-library/src/__tests__/worklet.test.jsx +49 -0
  248. package/transform/.turbo/turbo-build$colon$wasm.log +133 -297
  249. package/transform/__test__/defines.spec.js +30 -0
  250. package/transform/__test__/fixture.spec.js +11 -11
  251. package/transform/__test__/main-thread-object-compat.spec.js +111 -0
  252. package/transform/__test__/object-methods.spec.js +79 -0
  253. package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
  254. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
  255. package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
  256. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +63 -57
  257. package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
  258. package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
  259. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
  260. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
  261. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +11 -6
  262. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +12 -6
  263. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +14 -5
  264. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +17 -6
  265. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
  266. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
  267. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
  268. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
  269. package/transform/dist/wasm.cjs +1 -1
  270. package/transform/package.json +0 -1
  271. package/transform/src/lib.rs +1 -1
  272. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +167 -69
  273. package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
  274. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  275. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +226 -132
  276. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
  277. package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
  278. package/runtime/lib/snapshot/worklet/hmr.js +0 -28
  279. package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
  280. package/runtime/src/snapshot/worklet/hmr.ts +0 -34
  281. /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
  282. /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"backgroundSnapshot.js","sourceRoot":"","sources":["../../../src/snapshot/snapshot/backgroundSnapshot.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAU1D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC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AC,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;4BACtF,uBAAuB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC;wBACjF,CAAC;wBAED,YAAY,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,IAAI,CAAC,CAAC;wBACtE,MAAM;oBACR,CAAC;oBACD;wBACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACtB,uIAAuI;QACvI,eAAe,EAAE,CAAC;QAClB,8BAA8B,EAAE,CAAC;QACjC,OAAO,uBAAuB,EAAG,CAAC;IACpC,CAAC;YAAS,CAAC;QACT,IAAI,aAAa,EAAE,CAAC;YAClB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,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\n/**\n * Background snapshot implementation that runs in the background thread.\n *\n * This is the mirror of main thread's {@link SnapshotInstance}:\n */\n\nimport type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { createCloneSnapshot, createRuntimeSnapshot, snapshotManager } from './definition.js';\nimport type { Snapshot } from './definition.js';\nimport { DynamicPartType } from './dynamicPartType.js';\nimport { getListItemPlatformInfoFromIndexedValue } from './platformInfo.js';\nimport type { PlatformInfo } from './platformInfo.js';\nimport { reconstructInstanceTree } from './reconstructInstanceTree.js';\nimport { clearQueuedRefs, getRefFromValue, queueRefAttrUpdate } from './ref.js';\nimport type { Ref } from './ref.js';\nimport { snapshotCreatorMap } from './snapshot.js';\nimport { snapshotCreatorRuntime } from './snapshotCreatorMap.js';\nimport { hydrationMap } from './snapshotInstanceHydrationMap.js';\nimport { transformSpread } from './spread.js';\nimport type { SerializedSnapshotInstance } from './types.js';\nimport { isCloneSnapshot, isCompiledSnapshot, traverseSnapshotInstance } from './utils.js';\nimport { globalPipelineOptions } from '../../core/performance.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { isDirectOrDeepEqual } from '../../utils.js';\nimport { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';\nimport { prepareGestureForCommit } from '../gesture/processGestureBagkround.js';\nimport type { GestureKind } from '../gesture/types.js';\nimport { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';\nimport {\n SnapshotOperation,\n __globalSnapshotPatch,\n initGlobalSnapshotPatch,\n takeGlobalSnapshotPatch,\n} from '../lifecycle/patch/snapshotPatch.js';\nimport type { SnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';\nimport { clearPendingPortalInsertBefore } from '../lynx/portalsPending.js';\nimport { diffArrayAction, diffArrayLepus } from '../renderToOpcodes/hydrate.js';\nimport { onPostWorkletCtx } from '../worklet/ctx.js';\n\n/**\n * Background snapshot instance manager that manages all background snapshot instances.\n */\nexport const backgroundSnapshotInstanceManager: {\n nextId: number;\n values: Map<number, BackgroundSnapshotInstance>;\n clear(): void;\n updateId(id: number, newId: number): void;\n getValueBySign(str: string): unknown;\n} = {\n nextId: 0,\n values: /* @__PURE__ */ new Map<number, BackgroundSnapshotInstance>(),\n clear() {\n // not resetting `nextId` to prevent id collision\n this.values.clear();\n if (__DEV__) {\n clearSnapshotVNodeSource();\n }\n },\n updateId(id: number, newId: number) {\n const values = this.values;\n const si = values.get(id)!;\n // For PreactDevtools, on first hydration,\n // PreactDevtools can get the real snapshot instance id in main-thread\n if (__DEV__ && __BACKGROUND__) {\n lynx.getJSModule('GlobalEventEmitter').emit('onBackgroundSnapshotInstanceUpdateId', [\n {\n backgroundSnapshotInstance: si,\n oldId: id,\n newId,\n },\n ]);\n }\n values.delete(id);\n values.set(newId, si);\n si.__id = newId;\n if (__DEV__) {\n moveSnapshotVNodeSource(id, newId);\n }\n },\n getValueBySign(str: string): unknown {\n const res = str?.split(':');\n if (!res || (res.length != 2 && res.length != 3)) {\n throw new Error('Invalid ctx format: ' + str);\n }\n const id = Number(res[0]);\n const expIndex = Number(res[1]);\n const ctx = this.values.get(id);\n if (!ctx) {\n return null;\n }\n /**\n * 1. normal event\n * `${ctx.__id}:${expIndex}:${spreadKey}`\n * 2. defer list event\n * ${ctx.__id}:__extraProps:onRecycleComponent`\n * ${ctx.__id}:__extraProps:onComponentAtIndex`\n */\n const spreadKey = res[2];\n if (res[1] === '__extraProps') {\n if (spreadKey) {\n return ctx.__extraProps![spreadKey];\n }\n throw new Error('unreachable');\n } else {\n if (spreadKey) {\n return (ctx.__values![expIndex] as { [spreadKey]: unknown })[spreadKey];\n } else {\n return ctx.__values![expIndex];\n }\n }\n },\n};\n\nfunction prepareWorkletForCommit(worklet: Worklet): Worklet | null {\n // Copy-on-commit: do not mutate the background-side worklet ctx.\n // `_execId` is injected into the payload object that will be sent to the main thread.\n return onPostWorkletCtx({ ...(worklet as unknown as Record<string, unknown>) } as Worklet);\n}\n\nfunction prepareSpreadForCommit(\n spread: Record<string, unknown>,\n oldSpread: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n let committed: Record<string, unknown> | undefined;\n for (const key in spread) {\n const v = spread[key];\n if (key === '__lynx_timing_flag' && oldSpread?.[key] != v && globalPipelineOptions) {\n globalPipelineOptions.needTimestamps = true;\n }\n if (!v || typeof v !== 'object') {\n continue;\n }\n const valueRecord = v as Record<string, unknown>;\n let committedValue: unknown;\n if ('_wkltId' in valueRecord) {\n committedValue = prepareWorkletForCommit(v as Worklet);\n } else if ('__isGesture' in valueRecord) {\n committedValue = prepareGestureForCommit(v as GestureKind);\n } else {\n continue;\n }\n\n committed ??= { ...spread };\n committed[key] = committedValue;\n }\n return committed ?? spread;\n}\n\nexport class BackgroundSnapshotInstance {\n constructor(public type: string) {\n // Suspense uses 'div'\n if (!snapshotManager.values.has(type) && type !== 'div') {\n if (snapshotCreatorMap[type]) {\n snapshotCreatorMap[type](type, snapshotCreatorRuntime);\n } else if (isCloneSnapshot(type)) {\n createCloneSnapshot(type);\n } else if (isCompiledSnapshot(type)) {\n throw new Error('BackgroundSnapshot not found: ' + type);\n } else {\n // add runtime snapshot to backgroundSnapshotInstanceManager\n createRuntimeSnapshot(type);\n }\n }\n this.__snapshot_def = snapshotManager.values.get(type)!;\n const id = this.__id = backgroundSnapshotInstanceManager.nextId += 1;\n backgroundSnapshotInstanceManager.values.set(id, this);\n\n __globalSnapshotPatch?.push(SnapshotOperation.CreateElement, type, id);\n }\n\n __id: number;\n __values: unknown[] | undefined;\n __snapshot_def: Snapshot;\n __listItemPlatformInfo?: PlatformInfo;\n __extraProps?: Record<string, unknown> | undefined;\n __slotIndex: number = 0;\n private __listItemPlatformInfoIndex?: number;\n\n private __parent: BackgroundSnapshotInstance | null = null;\n private __firstChild: BackgroundSnapshotInstance | null = null;\n private __lastChild: BackgroundSnapshotInstance | null = null;\n private __previousSibling: BackgroundSnapshotInstance | null = null;\n private __nextSibling: BackgroundSnapshotInstance | null = null;\n private __removed_from_tree?: boolean;\n\n get parentNode(): BackgroundSnapshotInstance | null {\n return this.__parent;\n }\n\n get nextSibling(): BackgroundSnapshotInstance | null {\n return this.__nextSibling;\n }\n\n // get isConnected() {\n // return !!this.__parent;\n // }\n\n // contains(child: BackgroundSnapshotInstance): boolean {\n // return child.parentNode === this;\n // }\n\n // Preact 11's `removeNode` calls `node.remove()` instead of\n // `parentNode.removeChild(node)`.\n remove(): void {\n this.parentNode?.removeChild(this);\n }\n\n // This will be called in `lazy`/`Suspense`.\n appendChild(child: BackgroundSnapshotInstance): void {\n return this.insertBefore(child);\n }\n\n insertBefore(\n node: BackgroundSnapshotInstance,\n beforeNode?: BackgroundSnapshotInstance,\n ): void {\n if (node.__removed_from_tree) {\n node.__removed_from_tree = false;\n // This is only called by `lazy`/`Suspense` through `appendChild` so beforeNode is always undefined.\n /* v8 ignore next */\n reconstructInstanceTree([node], this.__id, beforeNode?.__id);\n } else {\n __globalSnapshotPatch?.push(\n SnapshotOperation.InsertBefore,\n this.__id,\n node.__id,\n beforeNode?.__id,\n node.__slotIndex,\n );\n }\n\n // If the node already has a parent, remove it from its current parent\n const p = node.__parent;\n if (p) {\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n p.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n p.__lastChild = node.__previousSibling;\n }\n }\n\n // If beforeNode is not provided, add the new node as the last child\n if (beforeNode) {\n // If beforeNode is provided, insert the new node before beforeNode\n if (beforeNode.__previousSibling) {\n beforeNode.__previousSibling.__nextSibling = node;\n node.__previousSibling = beforeNode.__previousSibling;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n beforeNode.__previousSibling = node;\n node.__nextSibling = beforeNode;\n node.__parent = this;\n } else {\n if (this.__lastChild) {\n this.__lastChild.__nextSibling = node;\n node.__previousSibling = this.__lastChild;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n this.__lastChild = node;\n node.__parent = this;\n node.__nextSibling = null;\n }\n }\n\n removeChild(node: BackgroundSnapshotInstance): void {\n __globalSnapshotPatch?.push(\n SnapshotOperation.RemoveChild,\n this.__id,\n node.__id,\n );\n node.__removed_from_tree = true;\n\n if (node.__parent !== this) {\n throw new Error('The node to be removed is not a child of this node.');\n }\n\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n this.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n this.__lastChild = node.__previousSibling;\n }\n\n node.__parent = null;\n node.__previousSibling = null;\n node.__nextSibling = null;\n\n traverseSnapshotInstance(node, instance => {\n if (instance.__values) {\n instance.__snapshot_def.refAndSpreadIndexes?.forEach(index => {\n const ref = getRefFromValue(instance.__values![index]);\n if (ref) {\n queueRefAttrUpdate(ref, null, instance, index);\n }\n });\n }\n });\n\n globalBackgroundSnapshotInstancesToRemove.push(node.__id);\n }\n\n tearDown(): void {\n traverseSnapshotInstance(this, v => {\n v.__parent = null;\n v.__previousSibling = null;\n v.__nextSibling = null;\n backgroundSnapshotInstanceManager.values.delete(v.__id);\n });\n }\n\n get childNodes(): BackgroundSnapshotInstance[] {\n const nodes: BackgroundSnapshotInstance[] = [];\n let node = this.__firstChild;\n while (node) {\n nodes.push(node);\n node = node.__nextSibling;\n }\n return nodes;\n }\n\n setAttribute(key: string | number, value: unknown): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::BSI::setAttribute');\n }\n if (key === 'values') {\n if (__globalSnapshotPatch) {\n const oldValues = this.__values;\n if (oldValues) {\n for (let index = 0; index < (value as unknown[]).length; index++) {\n const { needUpdate, valueToCommit } = this.setAttributeImpl(\n (value as unknown[])[index],\n oldValues[index],\n index,\n );\n if (needUpdate) {\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n index,\n valueToCommit,\n );\n }\n }\n } else {\n const patch = [];\n const length = (value as unknown[]).length;\n for (let index = 0; index < length; ++index) {\n const { valueToCommit } = this.setAttributeImpl((value as unknown[])[index], null, index);\n patch[index] = valueToCommit;\n }\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttributes,\n this.__id,\n patch,\n );\n }\n } else {\n this.__snapshot_def.refAndSpreadIndexes?.forEach((index) => {\n // In first render, this.__values is undefined.\n // In next rerenders before hydration, this.__values is not undefined.\n const oldValue: unknown = this.__values?.[index];\n const v = (value as unknown[])[index];\n queueRefAttrUpdate(getRefFromValue(oldValue), getRefFromValue(v), this, index);\n });\n }\n this.__values = value as unknown[];\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n\n if (typeof key === 'string') {\n if (key === '__listItemPlatformInfoIndex') {\n this.__listItemPlatformInfoIndex = value as number;\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n if (key === '__listItemPlatformInfo') {\n this.__listItemPlatformInfo = value as PlatformInfo;\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n (this.__extraProps ??= {})[key] = value;\n } else {\n // old path (`this.setAttribute(0, xxx)`)\n // is reserved as slow path\n (this.__values ??= [])[key] = value;\n this.syncListItemPlatformInfo();\n }\n __globalSnapshotPatch?.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n key,\n value,\n );\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n\n private syncListItemPlatformInfo(): void {\n if (this.__listItemPlatformInfoIndex === undefined || !this.__values) {\n return;\n }\n const index = this.__listItemPlatformInfoIndex;\n this.__listItemPlatformInfo = getListItemPlatformInfoFromIndexedValue(\n this.__values[index],\n this.__snapshot_def.refAndSpreadIndexes?.includes(index),\n );\n }\n\n private setAttributeImpl(newValue: unknown, oldValue: unknown, index: number): {\n needUpdate: boolean;\n valueToCommit: unknown;\n } {\n if (!newValue) {\n const oldRef = getRefFromValue(oldValue);\n if (oldRef) {\n queueRefAttrUpdate(oldRef, null, this, index);\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n\n const newType = typeof newValue;\n if (newType === 'object') {\n const newValueObj = newValue as Record<string, unknown>;\n if ('__spread' in newValueObj) {\n const oldSpread = (oldValue as { __spread?: Record<string, unknown> } | undefined)?.__spread;\n const newSpread = transformSpread(this, index, newValueObj);\n const needUpdate = !isDirectOrDeepEqual(oldSpread, newSpread);\n // use __spread to cache the transform result for next diff\n newValueObj['__spread'] = newSpread;\n queueRefAttrUpdate(\n oldSpread && ((oldValue as { ref?: Ref }).ref),\n newValueObj['ref'] as Ref,\n this,\n index,\n );\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareSpreadForCommit(newSpread, oldSpread) : newSpread,\n };\n }\n if ('__ref' in newValueObj) {\n queueRefAttrUpdate(oldValue as Ref, newValueObj as unknown as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n if ('_wkltId' in newValueObj) {\n // Worklet ctx can be stable across rerenders (e.g. memoized by the user).\n // In that case we should NOT re-register / re-send it, otherwise `_execId` churn\n // will cause unnecessary patches.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareWorkletForCommit(newValueObj as Worklet) : newValue,\n };\n }\n if ('__isGesture' in newValueObj) {\n // Gestures are large objects; if the reference is stable, avoid reprocessing and patching.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate\n ? prepareGestureForCommit(newValueObj as unknown as GestureKind)\n : newValue,\n };\n }\n if ('__ltf' in newValueObj) {\n // __lynx_timing_flag\n if (globalPipelineOptions && (oldValue as { __ltf?: unknown } | undefined)?.__ltf != newValueObj['__ltf']) {\n globalPipelineOptions.needTimestamps = true;\n return { needUpdate: true, valueToCommit: newValue };\n }\n return { needUpdate: false, valueToCommit: newValue };\n }\n return { needUpdate: !isDirectOrDeepEqual(oldValue, newValue), valueToCommit: newValue };\n }\n if (newType === 'function') {\n if ((newValue as { __ref?: unknown }).__ref) {\n queueRefAttrUpdate(oldValue as Ref, newValue as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n /* event */\n return { needUpdate: !oldValue, valueToCommit: 1 };\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n}\n\nexport function hydrate(\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n): SnapshotPatch {\n const shouldProfile = typeof __PROFILE__ !== 'undefined' && __PROFILE__;\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::hydrate');\n }\n try {\n initGlobalSnapshotPatch();\n\n const helper = (\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n ) => {\n hydrationMap.set(after.__id, before.id);\n backgroundSnapshotInstanceManager.updateId(after.__id, before.id);\n // handle value by index\n after.__values?.forEach((value: unknown, index) => {\n // render with different root would cause different values length\n const old: unknown = before.values?.[index];\n\n if (value) {\n if (typeof value === 'object') {\n if ('__spread' in value) {\n // `value.__spread` my contain event ids using snapshot ids before hydration. Remove it.\n delete value.__spread;\n const __spread = transformSpread(after, index, value);\n // Cache a clean spread for future diffs. For the patch payload, create a committed copy\n // with runtime fields (e.g. `_execId`) injected.\n (after.__values![index]! as Record<string, unknown>)['__spread'] = __spread;\n value = prepareSpreadForCommit(__spread, old as Record<string, unknown> | undefined);\n } else if ('__ref' in value) {\n // skip patch\n value = old;\n } else if ('_wkltId' in value) {\n value = prepareWorkletForCommit(value as Worklet);\n } else if ('__isGesture' in value) {\n value = prepareGestureForCommit(value as GestureKind);\n }\n } else if (typeof value === 'function') {\n if ('__ref' in value) {\n // skip patch\n value = old;\n } else {\n value = `${after.__id}:${index}:`;\n }\n }\n }\n\n if (!isDirectOrDeepEqual(value, old)) {\n if (value === undefined && old === null) {\n // This is a workaround for the case where we set an attribute to `undefined` in the main thread,\n // but the old value becomes `null` during JSON serialization.\n // In this case, we should not patch the value.\n } else {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: String(index),\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n }\n }\n }\n });\n\n // handle extraProps as attributes and set by key\n if (after.__extraProps) {\n for (const key in after.__extraProps) {\n const value = after.__extraProps[key];\n const old = before.extraProps?.[key];\n if (!isDirectOrDeepEqual(value, old)) {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: key,\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n }\n }\n }\n }\n\n const { slot } = after.__snapshot_def;\n\n const beforeChildNodes = before.children ?? [];\n const afterChildNodes = after.childNodes;\n\n if (!slot) {\n return;\n }\n\n // Hoisted out of the loop: none of this depends on the slot entry.\n const diffChildren = (\n filteredBeforeChildNodes: SerializedSnapshotInstance[],\n filteredAfterChildNodes: BackgroundSnapshotInstance[],\n isListHasItemKey: boolean,\n ) => {\n const diffResult = diffArrayLepus(\n filteredBeforeChildNodes,\n filteredAfterChildNodes,\n (a, b) => a.type === b.type,\n (a, b) => {\n helper(a, b);\n },\n isListHasItemKey,\n );\n diffArrayAction(\n filteredBeforeChildNodes,\n diffResult,\n (node, target) => {\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::reconstructInstanceTree', {\n args: {\n id: String(node.__id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.__id) ?? '',\n },\n });\n }\n try {\n reconstructInstanceTree([node], before.id, target?.id);\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n return undefined as unknown as SerializedSnapshotInstance;\n },\n node => {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::removeChild', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n }\n },\n (node, target) => {\n // changedList.push([SnapshotOperation.RemoveChild, before.id, node.id]);\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::insertBefore', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n targetId: String(target?.id ?? ''),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n }\n },\n );\n };\n\n slot.forEach(([type], index) => {\n switch (type) {\n case DynamicPartType.Slot:\n case DynamicPartType.MultiChildren: {\n // TODO: the following null assertions are not 100% safe\n const v1 = beforeChildNodes[index]!;\n const v2 = afterChildNodes[index]!;\n helper(v1, v2);\n break;\n }\n case DynamicPartType.SlotV2:\n case DynamicPartType.Children: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.SlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n // Children match pairwise by type, so the diff is empty — do what\n // `diffArrayLepus` + `diffArrayAction` would do without allocating\n // the diff structures.\n const length = filteredBeforeChildNodes.length;\n if (length === filteredAfterChildNodes.length) {\n let samePairwise = true;\n for (let i = 0; i < length; i++) {\n if (filteredBeforeChildNodes[i]!.type !== filteredAfterChildNodes[i]!.type) {\n samePairwise = false;\n break;\n }\n }\n if (samePairwise) {\n for (let i = 0; i < length; i++) {\n helper(filteredBeforeChildNodes[i]!, filteredAfterChildNodes[i]!);\n }\n break;\n }\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, false);\n break;\n }\n case DynamicPartType.ListSlotV2:\n case DynamicPartType.ListChildren: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.ListSlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, true);\n break;\n }\n default:\n throw new Error('Unexpected slot type: ' + type);\n }\n });\n };\n\n helper(before, after);\n // Hydration should not trigger ref updates. They were incorrectly triggered when using `setAttribute` to add values to the patch list.\n clearQueuedRefs();\n clearPendingPortalInsertBefore();\n return takeGlobalSnapshotPatch()!;\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"backgroundSnapshot.js","sourceRoot":"","sources":["../../../src/snapshot/snapshot/backgroundSnapshot.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAU1D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,uCAAuC,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,kBA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E,CAAC;QAClB,8BAA8B,EAAE,CAAC;QACjC,OAAO,uBAAuB,EAAG,CAAC;IACpC,CAAC;YAAS,CAAC;QACT,IAAI,aAAa,EAAE,CAAC;YAClB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,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\n/**\n * Background snapshot implementation that runs in the background thread.\n *\n * This is the mirror of main thread's {@link SnapshotInstance}:\n */\n\nimport type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { createCloneSnapshot, createRuntimeSnapshot, snapshotManager } from './definition.js';\nimport type { Snapshot } from './definition.js';\nimport { DynamicPartType } from './dynamicPartType.js';\nimport { getListItemPlatformInfoFromIndexedValue } from './platformInfo.js';\nimport type { PlatformInfo } from './platformInfo.js';\nimport { reconstructInstanceTree } from './reconstructInstanceTree.js';\nimport { clearQueuedRefs, getRefFromValue, queueRefAttrUpdate } from './ref.js';\nimport type { Ref } from './ref.js';\nimport { snapshotCreatorMap } from './snapshot.js';\nimport { snapshotCreatorRuntime } from './snapshotCreatorMap.js';\nimport { hydrationMap } from './snapshotInstanceHydrationMap.js';\nimport { transformSpread } from './spread.js';\nimport type { SerializedSnapshotInstance } from './types.js';\nimport { isCloneSnapshot, isCompiledSnapshot, traverseSnapshotInstance } from './utils.js';\nimport { globalPipelineOptions } from '../../core/performance.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { isDirectOrDeepEqual } from '../../utils.js';\nimport { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';\nimport { prepareGestureForCommit } from '../gesture/processGestureBackground.js';\nimport type { GestureKind } from '../gesture/types.js';\nimport { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';\nimport {\n SnapshotOperation,\n __globalSnapshotPatch,\n initGlobalSnapshotPatch,\n takeGlobalSnapshotPatch,\n} from '../lifecycle/patch/snapshotPatch.js';\nimport type { SnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';\nimport { clearPendingPortalInsertBefore } from '../lynx/portalsPending.js';\nimport { diffArrayAction, diffArrayLepus } from '../renderToOpcodes/hydrate.js';\nimport { onPostWorkletCtx } from '../worklet/ctx.js';\n\n/**\n * Background snapshot instance manager that manages all background snapshot instances.\n */\nexport const backgroundSnapshotInstanceManager: {\n nextId: number;\n values: Map<number, BackgroundSnapshotInstance>;\n clear(): void;\n updateId(id: number, newId: number): void;\n getValueBySign(str: string): unknown;\n} = {\n nextId: 0,\n values: /* @__PURE__ */ new Map<number, BackgroundSnapshotInstance>(),\n clear() {\n // not resetting `nextId` to prevent id collision\n this.values.clear();\n if (__DEV__) {\n clearSnapshotVNodeSource();\n }\n },\n updateId(id: number, newId: number) {\n const values = this.values;\n const si = values.get(id)!;\n // For PreactDevtools, on first hydration,\n // PreactDevtools can get the real snapshot instance id in main-thread\n if (__DEV__ && __BACKGROUND__) {\n lynx.getJSModule('GlobalEventEmitter').emit('onBackgroundSnapshotInstanceUpdateId', [\n {\n backgroundSnapshotInstance: si,\n oldId: id,\n newId,\n },\n ]);\n }\n values.delete(id);\n values.set(newId, si);\n si.__id = newId;\n if (__DEV__) {\n moveSnapshotVNodeSource(id, newId);\n }\n },\n getValueBySign(str: string): unknown {\n const res = str?.split(':');\n if (!res || (res.length != 2 && res.length != 3)) {\n throw new Error('Invalid ctx format: ' + str);\n }\n const id = Number(res[0]);\n const expIndex = Number(res[1]);\n const ctx = this.values.get(id);\n if (!ctx) {\n return null;\n }\n /**\n * 1. normal event\n * `${ctx.__id}:${expIndex}:${spreadKey}`\n * 2. defer list event\n * ${ctx.__id}:__extraProps:onRecycleComponent`\n * ${ctx.__id}:__extraProps:onComponentAtIndex`\n */\n const spreadKey = res[2];\n if (res[1] === '__extraProps') {\n if (spreadKey) {\n return ctx.__extraProps![spreadKey];\n }\n throw new Error('unreachable');\n } else {\n if (spreadKey) {\n return (ctx.__values![expIndex] as { [spreadKey]: unknown })[spreadKey];\n } else {\n return ctx.__values![expIndex];\n }\n }\n },\n};\n\nfunction prepareWorkletForCommit(worklet: Worklet): Worklet | null {\n // Copy-on-commit: do not mutate the background-side worklet ctx.\n // `_execId` is injected into the payload object that will be sent to the main thread.\n return onPostWorkletCtx({ ...(worklet as unknown as Record<string, unknown>) } as Worklet);\n}\n\nfunction prepareSpreadForCommit(\n spread: Record<string, unknown>,\n oldSpread: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n let committed: Record<string, unknown> | undefined;\n for (const key in spread) {\n const v = spread[key];\n if (key === '__lynx_timing_flag' && oldSpread?.[key] != v && globalPipelineOptions) {\n globalPipelineOptions.needTimestamps = true;\n }\n if (!v || typeof v !== 'object') {\n continue;\n }\n const valueRecord = v as Record<string, unknown>;\n let committedValue: unknown;\n if ('_wkltId' in valueRecord) {\n committedValue = prepareWorkletForCommit(v as Worklet);\n } else if ('__isGesture' in valueRecord) {\n committedValue = prepareGestureForCommit(v as GestureKind);\n } else {\n continue;\n }\n\n committed ??= { ...spread };\n committed[key] = committedValue;\n }\n return committed ?? spread;\n}\n\nexport class BackgroundSnapshotInstance {\n constructor(public type: string) {\n // Suspense uses 'div'\n if (!snapshotManager.values.has(type) && type !== 'div') {\n if (snapshotCreatorMap[type]) {\n snapshotCreatorMap[type](type, snapshotCreatorRuntime);\n } else if (isCloneSnapshot(type)) {\n createCloneSnapshot(type);\n } else if (isCompiledSnapshot(type)) {\n throw new Error('BackgroundSnapshot not found: ' + type);\n } else {\n // add runtime snapshot to backgroundSnapshotInstanceManager\n createRuntimeSnapshot(type);\n }\n }\n this.__snapshot_def = snapshotManager.values.get(type)!;\n const id = this.__id = backgroundSnapshotInstanceManager.nextId += 1;\n backgroundSnapshotInstanceManager.values.set(id, this);\n\n __globalSnapshotPatch?.push(SnapshotOperation.CreateElement, type, id);\n }\n\n __id: number;\n __values: unknown[] | undefined;\n __snapshot_def: Snapshot;\n __listItemPlatformInfo?: PlatformInfo;\n __extraProps?: Record<string, unknown> | undefined;\n __slotIndex: number = 0;\n private __listItemPlatformInfoIndex?: number;\n\n private __parent: BackgroundSnapshotInstance | null = null;\n private __firstChild: BackgroundSnapshotInstance | null = null;\n private __lastChild: BackgroundSnapshotInstance | null = null;\n private __previousSibling: BackgroundSnapshotInstance | null = null;\n private __nextSibling: BackgroundSnapshotInstance | null = null;\n private __removed_from_tree?: boolean;\n\n get parentNode(): BackgroundSnapshotInstance | null {\n return this.__parent;\n }\n\n get nextSibling(): BackgroundSnapshotInstance | null {\n return this.__nextSibling;\n }\n\n // get isConnected() {\n // return !!this.__parent;\n // }\n\n // contains(child: BackgroundSnapshotInstance): boolean {\n // return child.parentNode === this;\n // }\n\n // Preact 11's `removeNode` calls `node.remove()` instead of\n // `parentNode.removeChild(node)`.\n remove(): void {\n this.parentNode?.removeChild(this);\n }\n\n // This will be called in `lazy`/`Suspense`.\n appendChild(child: BackgroundSnapshotInstance): void {\n return this.insertBefore(child);\n }\n\n insertBefore(\n node: BackgroundSnapshotInstance,\n beforeNode?: BackgroundSnapshotInstance,\n ): void {\n if (node.__removed_from_tree) {\n node.__removed_from_tree = false;\n // This is only called by `lazy`/`Suspense` through `appendChild` so beforeNode is always undefined.\n /* v8 ignore next */\n reconstructInstanceTree([node], this.__id, beforeNode?.__id);\n } else {\n __globalSnapshotPatch?.push(\n SnapshotOperation.InsertBefore,\n this.__id,\n node.__id,\n beforeNode?.__id,\n node.__slotIndex,\n );\n }\n\n // If the node already has a parent, remove it from its current parent\n const p = node.__parent;\n if (p) {\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n p.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n p.__lastChild = node.__previousSibling;\n }\n }\n\n // If beforeNode is not provided, add the new node as the last child\n if (beforeNode) {\n // If beforeNode is provided, insert the new node before beforeNode\n if (beforeNode.__previousSibling) {\n beforeNode.__previousSibling.__nextSibling = node;\n node.__previousSibling = beforeNode.__previousSibling;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n beforeNode.__previousSibling = node;\n node.__nextSibling = beforeNode;\n node.__parent = this;\n } else {\n if (this.__lastChild) {\n this.__lastChild.__nextSibling = node;\n node.__previousSibling = this.__lastChild;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n this.__lastChild = node;\n node.__parent = this;\n node.__nextSibling = null;\n }\n }\n\n removeChild(node: BackgroundSnapshotInstance): void {\n __globalSnapshotPatch?.push(\n SnapshotOperation.RemoveChild,\n this.__id,\n node.__id,\n );\n node.__removed_from_tree = true;\n\n if (node.__parent !== this) {\n throw new Error('The node to be removed is not a child of this node.');\n }\n\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n this.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n this.__lastChild = node.__previousSibling;\n }\n\n node.__parent = null;\n node.__previousSibling = null;\n node.__nextSibling = null;\n\n traverseSnapshotInstance(node, instance => {\n if (instance.__values) {\n instance.__snapshot_def.refAndSpreadIndexes?.forEach(index => {\n const ref = getRefFromValue(instance.__values![index]);\n if (ref) {\n queueRefAttrUpdate(ref, null, instance, index);\n }\n });\n }\n });\n\n globalBackgroundSnapshotInstancesToRemove.push(node.__id);\n }\n\n tearDown(): void {\n traverseSnapshotInstance(this, v => {\n v.__parent = null;\n v.__previousSibling = null;\n v.__nextSibling = null;\n backgroundSnapshotInstanceManager.values.delete(v.__id);\n });\n }\n\n get childNodes(): BackgroundSnapshotInstance[] {\n const nodes: BackgroundSnapshotInstance[] = [];\n let node = this.__firstChild;\n while (node) {\n nodes.push(node);\n node = node.__nextSibling;\n }\n return nodes;\n }\n\n setAttribute(key: string | number, value: unknown): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::BSI::setAttribute');\n }\n if (key === 'values') {\n if (__globalSnapshotPatch) {\n const oldValues = this.__values;\n if (oldValues) {\n for (let index = 0; index < (value as unknown[]).length; index++) {\n const { needUpdate, valueToCommit } = this.setAttributeImpl(\n (value as unknown[])[index],\n oldValues[index],\n index,\n );\n if (needUpdate) {\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n index,\n valueToCommit,\n );\n }\n }\n } else {\n const patch = [];\n const length = (value as unknown[]).length;\n for (let index = 0; index < length; ++index) {\n const { valueToCommit } = this.setAttributeImpl((value as unknown[])[index], null, index);\n patch[index] = valueToCommit;\n }\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttributes,\n this.__id,\n patch,\n );\n }\n } else {\n this.__snapshot_def.refAndSpreadIndexes?.forEach((index) => {\n // In first render, this.__values is undefined.\n // In next rerenders before hydration, this.__values is not undefined.\n const oldValue: unknown = this.__values?.[index];\n const v = (value as unknown[])[index];\n queueRefAttrUpdate(getRefFromValue(oldValue), getRefFromValue(v), this, index);\n });\n }\n this.__values = value as unknown[];\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n\n if (typeof key === 'string') {\n if (key === '__listItemPlatformInfoIndex') {\n this.__listItemPlatformInfoIndex = value as number;\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n if (key === '__listItemPlatformInfo') {\n this.__listItemPlatformInfo = value as PlatformInfo;\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n (this.__extraProps ??= {})[key] = value;\n } else {\n // old path (`this.setAttribute(0, xxx)`)\n // is reserved as slow path\n (this.__values ??= [])[key] = value;\n this.syncListItemPlatformInfo();\n }\n __globalSnapshotPatch?.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n key,\n value,\n );\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n\n private syncListItemPlatformInfo(): void {\n if (this.__listItemPlatformInfoIndex === undefined || !this.__values) {\n return;\n }\n const index = this.__listItemPlatformInfoIndex;\n this.__listItemPlatformInfo = getListItemPlatformInfoFromIndexedValue(\n this.__values[index],\n this.__snapshot_def.refAndSpreadIndexes?.includes(index),\n );\n }\n\n private setAttributeImpl(newValue: unknown, oldValue: unknown, index: number): {\n needUpdate: boolean;\n valueToCommit: unknown;\n } {\n if (!newValue) {\n const oldRef = getRefFromValue(oldValue);\n if (oldRef) {\n queueRefAttrUpdate(oldRef, null, this, index);\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n\n const newType = typeof newValue;\n if (newType === 'object') {\n const newValueObj = newValue as Record<string, unknown>;\n if ('__spread' in newValueObj) {\n const oldSpread = (oldValue as { __spread?: Record<string, unknown> } | undefined)?.__spread;\n const newSpread = transformSpread(this, index, newValueObj);\n const needUpdate = !isDirectOrDeepEqual(oldSpread, newSpread);\n // use __spread to cache the transform result for next diff\n newValueObj['__spread'] = newSpread;\n queueRefAttrUpdate(\n oldSpread && ((oldValue as { ref?: Ref }).ref),\n newValueObj['ref'] as Ref,\n this,\n index,\n );\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareSpreadForCommit(newSpread, oldSpread) : newSpread,\n };\n }\n if ('__ref' in newValueObj) {\n queueRefAttrUpdate(oldValue as Ref, newValueObj as unknown as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n if ('_wkltId' in newValueObj) {\n // Worklet ctx can be stable across rerenders (e.g. memoized by the user).\n // In that case we should NOT re-register / re-send it, otherwise `_execId` churn\n // will cause unnecessary patches.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareWorkletForCommit(newValueObj as Worklet) : newValue,\n };\n }\n if ('__isGesture' in newValueObj) {\n // Gestures are large objects; if the reference is stable, avoid reprocessing and patching.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate\n ? prepareGestureForCommit(newValueObj as unknown as GestureKind)\n : newValue,\n };\n }\n if ('__ltf' in newValueObj) {\n // __lynx_timing_flag\n if (globalPipelineOptions && (oldValue as { __ltf?: unknown } | undefined)?.__ltf != newValueObj['__ltf']) {\n globalPipelineOptions.needTimestamps = true;\n return { needUpdate: true, valueToCommit: newValue };\n }\n return { needUpdate: false, valueToCommit: newValue };\n }\n return { needUpdate: !isDirectOrDeepEqual(oldValue, newValue), valueToCommit: newValue };\n }\n if (newType === 'function') {\n if ((newValue as { __ref?: unknown }).__ref) {\n queueRefAttrUpdate(oldValue as Ref, newValue as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n /* event */\n return { needUpdate: !oldValue, valueToCommit: 1 };\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n}\n\nexport function hydrate(\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n): SnapshotPatch {\n const shouldProfile = typeof __PROFILE__ !== 'undefined' && __PROFILE__;\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::hydrate');\n }\n try {\n initGlobalSnapshotPatch();\n\n const helper = (\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n ) => {\n hydrationMap.set(after.__id, before.id);\n backgroundSnapshotInstanceManager.updateId(after.__id, before.id);\n // handle value by index\n after.__values?.forEach((value: unknown, index) => {\n // render with different root would cause different values length\n const old: unknown = before.values?.[index];\n\n if (value) {\n if (typeof value === 'object') {\n if ('__spread' in value) {\n // `value.__spread` my contain event ids using snapshot ids before hydration. Remove it.\n delete value.__spread;\n const __spread = transformSpread(after, index, value);\n // Cache a clean spread for future diffs. For the patch payload, create a committed copy\n // with runtime fields (e.g. `_execId`) injected.\n (after.__values![index]! as Record<string, unknown>)['__spread'] = __spread;\n value = prepareSpreadForCommit(__spread, old as Record<string, unknown> | undefined);\n } else if ('__ref' in value) {\n // skip patch\n value = old;\n } else if ('_wkltId' in value) {\n value = prepareWorkletForCommit(value as Worklet);\n } else if ('__isGesture' in value) {\n value = prepareGestureForCommit(value as GestureKind);\n }\n } else if (typeof value === 'function') {\n if ('__ref' in value) {\n // skip patch\n value = old;\n } else {\n value = `${after.__id}:${index}:`;\n }\n }\n }\n\n if (!isDirectOrDeepEqual(value, old)) {\n if (value === undefined && old === null) {\n // This is a workaround for the case where we set an attribute to `undefined` in the main thread,\n // but the old value becomes `null` during JSON serialization.\n // In this case, we should not patch the value.\n } else {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: String(index),\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n }\n }\n }\n });\n\n // handle extraProps as attributes and set by key\n if (after.__extraProps) {\n for (const key in after.__extraProps) {\n const value = after.__extraProps[key];\n const old = before.extraProps?.[key];\n if (!isDirectOrDeepEqual(value, old)) {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: key,\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n }\n }\n }\n }\n\n const { slot } = after.__snapshot_def;\n\n const beforeChildNodes = before.children ?? [];\n const afterChildNodes = after.childNodes;\n\n if (!slot) {\n return;\n }\n\n // Hoisted out of the loop: none of this depends on the slot entry.\n const diffChildren = (\n filteredBeforeChildNodes: SerializedSnapshotInstance[],\n filteredAfterChildNodes: BackgroundSnapshotInstance[],\n isListHasItemKey: boolean,\n ) => {\n const diffResult = diffArrayLepus(\n filteredBeforeChildNodes,\n filteredAfterChildNodes,\n (a, b) => a.type === b.type,\n (a, b) => {\n helper(a, b);\n },\n isListHasItemKey,\n );\n diffArrayAction(\n filteredBeforeChildNodes,\n diffResult,\n (node, target) => {\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::reconstructInstanceTree', {\n args: {\n id: String(node.__id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.__id) ?? '',\n },\n });\n }\n try {\n reconstructInstanceTree([node], before.id, target?.id);\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n return undefined as unknown as SerializedSnapshotInstance;\n },\n node => {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::removeChild', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n }\n },\n (node, target) => {\n // changedList.push([SnapshotOperation.RemoveChild, before.id, node.id]);\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::insertBefore', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n targetId: String(target?.id ?? ''),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n }\n },\n );\n };\n\n slot.forEach(([type], index) => {\n switch (type) {\n case DynamicPartType.Slot:\n case DynamicPartType.MultiChildren: {\n // TODO: the following null assertions are not 100% safe\n const v1 = beforeChildNodes[index]!;\n const v2 = afterChildNodes[index]!;\n helper(v1, v2);\n break;\n }\n case DynamicPartType.SlotV2:\n case DynamicPartType.Children: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.SlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n // Children match pairwise by type, so the diff is empty — do what\n // `diffArrayLepus` + `diffArrayAction` would do without allocating\n // the diff structures.\n const length = filteredBeforeChildNodes.length;\n if (length === filteredAfterChildNodes.length) {\n let samePairwise = true;\n for (let i = 0; i < length; i++) {\n if (filteredBeforeChildNodes[i]!.type !== filteredAfterChildNodes[i]!.type) {\n samePairwise = false;\n break;\n }\n }\n if (samePairwise) {\n for (let i = 0; i < length; i++) {\n helper(filteredBeforeChildNodes[i]!, filteredAfterChildNodes[i]!);\n }\n break;\n }\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, false);\n break;\n }\n case DynamicPartType.ListSlotV2:\n case DynamicPartType.ListChildren: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.ListSlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, true);\n break;\n }\n default:\n throw new Error('Unexpected slot type: ' + type);\n }\n });\n };\n\n helper(before, after);\n // Hydration should not trigger ref updates. They were incorrectly triggered when using `setAttribute` to add values to the patch list.\n clearQueuedRefs();\n clearPendingPortalInsertBefore();\n return takeGlobalSnapshotPatch()!;\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n}\n"]}