@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
@@ -15,7 +15,6 @@ export const SnapshotOperation = {
15
15
  nodesRefInsertBefore: 5,
16
16
  nodesRefRemoveChild: 6,
17
17
  DEV_ONLY_AddSnapshot: 100,
18
- DEV_ONLY_RegisterWorklet: 101,
19
18
  DEV_ONLY_SetSnapshotEntryName: 102,
20
19
  };
21
20
  export const SnapshotOperationParams = /* @__PURE__ */ {
@@ -60,10 +59,6 @@ export const SnapshotOperationParams = /* @__PURE__ */ {
60
59
  'snapshotCreator', /* string */
61
60
  ],
62
61
  },
63
- [SnapshotOperation.DEV_ONLY_RegisterWorklet]: {
64
- name: 'DEV_ONLY_RegisterWorklet',
65
- params: ['hash', /* string */ 'fnStr' /* string */],
66
- },
67
62
  [SnapshotOperation.DEV_ONLY_SetSnapshotEntryName]: {
68
63
  name: 'DEV_ONLY_SetSnapshotEntryName',
69
64
  params: ['uniqID', /* string */ 'entryName' /* string */],
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotPatch.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/snapshotPatch.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;GAIG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IACf,aAAa,EAAE,CAAC;IAChB,oBAAoB,EAAE,CAAC;IACvB,mBAAmB,EAAE,CAAC;IAEtB,oBAAoB,EAAE,GAAG;IACzB,wBAAwB,EAAE,GAAG;IAC7B,6BAA6B,EAAE,GAAG;CAC1B,CAAC;AAEX,MAAM,CAAC,MAAM,uBAAuB,GAAuD,eAAe,CAAC;IACzG,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE;QACjC,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC;KACjD;IACD,CAAC,iBAAiB,CAAC,YAAY,CAAC,EAAE;QAChC,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE;YACN,UAAU;YACV,YAAY,CAAC,SAAS;YACtB,YAAY,CAAC,UAAU;YACvB,wBAAwB,CAAC,WAAW,EAAE,wBAAwB;SAC/D;KACF;IACD,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAA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AAM,CAAC,IAAI,qBAAgD,CAAC;AAE5D,MAAM,UAAU,uBAAuB;IACrC,IAAI,qBAAqB,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,qBAAqB,CAAC;QACnC,qBAAqB,GAAG,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,qBAAqB,GAAG,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,qBAAqB,GAAG,SAAS,CAAC;AACpC,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 * Defines the core patch operations for the snapshot system.\n * The patch operations are designed to be serializable and minimal, allowing\n * efficient transmission between threads and application to element tree.\n */\n\nexport const SnapshotOperation = {\n CreateElement: 0,\n InsertBefore: 1,\n RemoveChild: 2,\n SetAttribute: 3,\n SetAttributes: 4,\n nodesRefInsertBefore: 5,\n nodesRefRemoveChild: 6,\n\n DEV_ONLY_AddSnapshot: 100,\n DEV_ONLY_RegisterWorklet: 101,\n DEV_ONLY_SetSnapshotEntryName: 102,\n} as const;\n\nexport const SnapshotOperationParams: Record<number, { name: string; params: string[] }> = /* @__PURE__ */ {\n [SnapshotOperation.CreateElement]: {\n name: 'CreateElement',\n params: ['type', /* string */ 'id' /* number */],\n },\n [SnapshotOperation.InsertBefore]: {\n name: 'InsertBefore',\n params: [\n 'parentId',\n /* number */ 'childId',\n /* number */ 'beforeId',\n /* number | undefined */ 'slotIndex', /* number | undefined */\n ],\n },\n [SnapshotOperation.RemoveChild]: { name: 'RemoveChild', params: ['parentId', /* number */ 'childId' /* number */] },\n [SnapshotOperation.SetAttribute]: {\n name: 'SetAttribute',\n params: ['id', /* number */ 'dynamicPartIndex', /* number */ 'value' /* any */],\n },\n [SnapshotOperation.SetAttributes]: { name: 'SetAttributes', params: ['id', /* number */ 'values' /* any */] },\n [SnapshotOperation.nodesRefInsertBefore]: {\n name: 'nodesRefInsertBefore',\n params: [\n 'identifier', /* string — CSS selector */\n 'childId', /* number */\n 'beforeId', /* number | undefined */\n ],\n },\n [SnapshotOperation.nodesRefRemoveChild]: {\n name: 'nodesRefRemoveChild',\n params: [\n 'identifier', /* string — CSS selector */\n 'childId', /* number */\n ],\n },\n [SnapshotOperation.DEV_ONLY_AddSnapshot]: {\n name: 'DEV_ONLY_AddSnapshot',\n params: [\n 'uniqID', /* string */\n 'snapshotCreator', /* string */\n ],\n },\n [SnapshotOperation.DEV_ONLY_RegisterWorklet]: {\n name: 'DEV_ONLY_RegisterWorklet',\n params: ['hash', /* string */ 'fnStr' /* string */],\n },\n [SnapshotOperation.DEV_ONLY_SetSnapshotEntryName]: {\n name: 'DEV_ONLY_SetSnapshotEntryName',\n params: ['uniqID', /* string */ 'entryName' /* string */],\n },\n} as const;\n\nexport type SnapshotPatch = unknown[];\n\nexport let __globalSnapshotPatch: SnapshotPatch | undefined;\n\nexport function takeGlobalSnapshotPatch(): SnapshotPatch | undefined {\n if (__globalSnapshotPatch) {\n const list = __globalSnapshotPatch;\n __globalSnapshotPatch = [];\n return list;\n } else {\n return undefined;\n }\n}\n\nexport function initGlobalSnapshotPatch(): void {\n __globalSnapshotPatch = [];\n}\n\nexport function deinitGlobalSnapshotPatch(): void {\n __globalSnapshotPatch = undefined;\n}\n"]}
1
+ {"version":3,"file":"snapshotPatch.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/snapshotPatch.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;GAIG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IACf,aAAa,EAAE,CA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AqB;QAC3B,MAAM,EAAE;YACN,YAAY,EAAE,2BAA2B;YACzC,SAAS,EAAE,YAAY;SACxB;KACF;IACD,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,EAAE;QACxC,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE;YACN,QAAQ,EAAE,YAAY;YACtB,iBAAiB,EAAE,YAAY;SAChC;KACF;IACD,CAAC,iBAAiB,CAAC,6BAA6B,CAAC,EAAE;QACjD,IAAI,EAAE,+BAA+B;QACrC,MAAM,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC;KAC1D;CACO,CAAC;AAIX,MAAM,CAAC,IAAI,qBAAgD,CAAC;AAE5D,MAAM,UAAU,uBAAuB;IACrC,IAAI,qBAAqB,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,qBAAqB,CAAC;QACnC,qBAAqB,GAAG,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,qBAAqB,GAAG,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,qBAAqB,GAAG,SAAS,CAAC;AACpC,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 * Defines the core patch operations for the snapshot system.\n * The patch operations are designed to be serializable and minimal, allowing\n * efficient transmission between threads and application to element tree.\n */\n\nexport const SnapshotOperation = {\n CreateElement: 0,\n InsertBefore: 1,\n RemoveChild: 2,\n SetAttribute: 3,\n SetAttributes: 4,\n nodesRefInsertBefore: 5,\n nodesRefRemoveChild: 6,\n\n DEV_ONLY_AddSnapshot: 100,\n DEV_ONLY_SetSnapshotEntryName: 102,\n} as const;\n\nexport const SnapshotOperationParams: Record<number, { name: string; params: string[] }> = /* @__PURE__ */ {\n [SnapshotOperation.CreateElement]: {\n name: 'CreateElement',\n params: ['type', /* string */ 'id' /* number */],\n },\n [SnapshotOperation.InsertBefore]: {\n name: 'InsertBefore',\n params: [\n 'parentId',\n /* number */ 'childId',\n /* number */ 'beforeId',\n /* number | undefined */ 'slotIndex', /* number | undefined */\n ],\n },\n [SnapshotOperation.RemoveChild]: { name: 'RemoveChild', params: ['parentId', /* number */ 'childId' /* number */] },\n [SnapshotOperation.SetAttribute]: {\n name: 'SetAttribute',\n params: ['id', /* number */ 'dynamicPartIndex', /* number */ 'value' /* any */],\n },\n [SnapshotOperation.SetAttributes]: { name: 'SetAttributes', params: ['id', /* number */ 'values' /* any */] },\n [SnapshotOperation.nodesRefInsertBefore]: {\n name: 'nodesRefInsertBefore',\n params: [\n 'identifier', /* string — CSS selector */\n 'childId', /* number */\n 'beforeId', /* number | undefined */\n ],\n },\n [SnapshotOperation.nodesRefRemoveChild]: {\n name: 'nodesRefRemoveChild',\n params: [\n 'identifier', /* string — CSS selector */\n 'childId', /* number */\n ],\n },\n [SnapshotOperation.DEV_ONLY_AddSnapshot]: {\n name: 'DEV_ONLY_AddSnapshot',\n params: [\n 'uniqID', /* string */\n 'snapshotCreator', /* string */\n ],\n },\n [SnapshotOperation.DEV_ONLY_SetSnapshotEntryName]: {\n name: 'DEV_ONLY_SetSnapshotEntryName',\n params: ['uniqID', /* string */ 'entryName' /* string */],\n },\n} as const;\n\nexport type SnapshotPatch = unknown[];\n\nexport let __globalSnapshotPatch: SnapshotPatch | undefined;\n\nexport function takeGlobalSnapshotPatch(): SnapshotPatch | undefined {\n if (__globalSnapshotPatch) {\n const list = __globalSnapshotPatch;\n __globalSnapshotPatch = [];\n return list;\n } else {\n return undefined;\n }\n}\n\nexport function initGlobalSnapshotPatch(): void {\n __globalSnapshotPatch = [];\n}\n\nexport function deinitGlobalSnapshotPatch(): void {\n __globalSnapshotPatch = undefined;\n}\n"]}
@@ -160,16 +160,6 @@ export function snapshotPatchApply(snapshotPatch, commitId, isHydration) {
160
160
  }
161
161
  break;
162
162
  }
163
- // case SnapshotOperation.DEV_ONLY_RegisterWorklet: {
164
- // // HMR-related
165
- // if (__DEV__) {
166
- // const hash: string = snapshotPatch[++i];
167
- // const fnStr: string = snapshotPatch[++i];
168
- // const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);
169
- // registerWorklet('main-thread', hash, fn);
170
- // }
171
- // break;
172
- // }
173
163
  }
174
164
  }
175
165
  }
@@ -1 +1 @@
1
- {"version":3,"file":"snapshotPatchApply.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/snapshotPatchApply.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;;;;;;GASG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE3G;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAA4B,EAAE,QAAgB,EAAE,WAAoB;IACrG,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAChC,QAAQ,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;YACzB,KAAK,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC;gBACrC,MAAM,IAAI,GAAG,aAAa,CAAC,EAAE,CAAC,CAAW,CAAC;gBAC1C,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC,CAAW,CAAC;gBACxC,IAAI,gBAAgB,CAAC,IAAI,EAAE,EAAE,CA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BAAkB,CAAC,MAAM,CAAC,GAAG,QAAQ,CACnC,MAAM,CAAC,OAAO,CAAC,4BAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CACxE,CAAC;wBACJ,CAAC;wBAAC,OAAO,CAAC,EAAE,CAAC;4BACX,OAAO,CAAC,IAAI,CAAC,wDAAwD,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;wBACpF,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,MAAM;YACR,CAAC;YACC,qDAAqD;YACrD,mBAAmB;YACnB,mBAAmB;YACnB,+CAA+C;YAC/C,gDAAgD;YAChD,6EAA6E;YAC7E,gDAAgD;YAChD,MAAM;YACN,WAAW;YACX,IAAI;QACR,CAAC;IACH,CAAC;AACH,CAAC;AAED,qBAAqB;AACrB;;GAEG;AACH,SAAS,QAAQ,CAAI,IAAY;IAC/B,IAAI,OAAO,EAAE,CAAC;QACZ,2EAA2E;QAC3E,qEAAqE;QACrE,oEAAoE;QACpE,sDAAsD;QACtD,OAAO,IAAI,CAAC,UAAU,IAAI,KAAK,CAAM,CAAC;IACxC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;AAC1E,CAAC;AACD,oBAAoB","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 * Implements the patch application logic for the snapshot system.\n * This module is responsible for interpreting and executing patch operations\n * that were generated in the background thread, applying them to the DOM\n * in the main thread.\n *\n * The module handles various operations like element creation, insertion,\n * removal, and attribute updates, ensuring they are applied in the correct\n * order and with proper error handling.\n */\n\nimport { sendCtxNotFoundEventToBackground } from './error.js';\nimport { applyNodesRefInsertBefore, applyNodesRefRemoveChild } from './nodesRefApply.js';\nimport type { SnapshotPatch } from './snapshotPatch.js';\nimport { SnapshotOperation } from './snapshotPatch.js';\nimport { SnapshotInstance, snapshotCreatorMap, snapshotInstanceManager } from '../../snapshot/snapshot.js';\n\n/**\n * Applies a patch of snapshot operations to the main thread.\n * This is the counterpart to the patch generation in the background thread.\n * Each operation in the patch is processed sequentially to update the DOM.\n */\nexport function snapshotPatchApply(snapshotPatch: SnapshotPatch, commitId: number, isHydration: boolean): void {\n const length = snapshotPatch.length;\n for (let i = 0; i < length; ++i) {\n switch (snapshotPatch[i]) {\n case SnapshotOperation.CreateElement: {\n const type = snapshotPatch[++i] as string;\n const id = snapshotPatch[++i] as number;\n new SnapshotInstance(type, id);\n break;\n }\n case SnapshotOperation.InsertBefore: {\n const parentId = snapshotPatch[++i] as number;\n const childId = snapshotPatch[++i] as number;\n const beforeId = snapshotPatch[++i] as number | undefined;\n const __slotIndex = snapshotPatch[++i] as number;\n const parent = snapshotInstanceManager.values.get(parentId);\n const child = snapshotInstanceManager.values.get(childId);\n const existingNode = snapshotInstanceManager.values.get(beforeId!);\n if (!parent || !child) {\n sendCtxNotFoundEventToBackground(parent ? childId : parentId, {\n operation: 'InsertBefore',\n commitId,\n isHydration,\n parent: parentId,\n child: childId,\n missingNode: parent ? 2 : (child ? 1 : 3),\n });\n } else {\n child.__slotIndex = __slotIndex;\n parent.insertBefore(child, existingNode);\n }\n break;\n }\n case SnapshotOperation.RemoveChild: {\n const parentId = snapshotPatch[++i] as number;\n const childId = snapshotPatch[++i] as number;\n const parent = snapshotInstanceManager.values.get(parentId);\n const child = snapshotInstanceManager.values.get(childId);\n if (!parent || !child) {\n sendCtxNotFoundEventToBackground(parent ? childId : parentId, {\n operation: 'RemoveChild',\n commitId,\n isHydration,\n parent: parentId,\n child: childId,\n missingNode: parent ? 2 : (child ? 1 : 3),\n });\n } else {\n parent.removeChild(child);\n }\n break;\n }\n case SnapshotOperation.nodesRefInsertBefore: {\n const identifier = snapshotPatch[++i] as string;\n const childId = snapshotPatch[++i] as number;\n const beforeId = snapshotPatch[++i] as number | undefined;\n const child = snapshotInstanceManager.values.get(childId);\n if (child) {\n applyNodesRefInsertBefore(identifier, child, beforeId);\n } else {\n sendCtxNotFoundEventToBackground(childId, {\n operation: 'nodesRefInsertBefore',\n commitId,\n isHydration,\n });\n }\n break;\n }\n case SnapshotOperation.nodesRefRemoveChild: {\n const identifier = snapshotPatch[++i] as string;\n const childId = snapshotPatch[++i] as number;\n const child = snapshotInstanceManager.values.get(childId);\n if (child) {\n applyNodesRefRemoveChild(identifier, child);\n } else {\n sendCtxNotFoundEventToBackground(childId, {\n operation: 'nodesRefRemoveChild',\n commitId,\n isHydration,\n });\n }\n break;\n }\n case SnapshotOperation.SetAttribute: {\n const id = snapshotPatch[++i] as number;\n const dynamicPartIndex = snapshotPatch[++i] as number;\n const value = snapshotPatch[++i];\n const si = snapshotInstanceManager.values.get(id);\n if (si) {\n si.setAttribute(dynamicPartIndex, value);\n } else {\n sendCtxNotFoundEventToBackground(id, { operation: 'SetAttribute', commitId, isHydration });\n }\n break;\n }\n case SnapshotOperation.SetAttributes: {\n const id = snapshotPatch[++i] as number;\n const values = snapshotPatch[++i];\n const si = snapshotInstanceManager.values.get(id);\n if (si) {\n si.setAttribute('values', values);\n } else {\n sendCtxNotFoundEventToBackground(id, { operation: 'SetAttributes', commitId, isHydration });\n }\n break;\n }\n case SnapshotOperation.DEV_ONLY_AddSnapshot: {\n if (__DEV__) {\n const uniqID = snapshotPatch[++i] as string;\n const snapshotCreator = snapshotPatch[++i] as string;\n\n // HMR-related\n // Update the evaluated snapshots from JS.\n snapshotCreatorMap[uniqID] = evaluate<(uniqId: string) => string>(snapshotCreator);\n }\n break;\n }\n case SnapshotOperation.DEV_ONLY_SetSnapshotEntryName: {\n if (__DEV__) {\n const uniqID = snapshotPatch[++i] as string;\n const entryName = snapshotPatch[++i] as string;\n\n // HMR-related\n // Update the evaluated snapshot entryName from JS.\n const source = snapshotCreatorMap[uniqID]?.toString();\n if (source?.includes('globDynamicComponentEntry')) {\n try {\n snapshotCreatorMap[uniqID] = evaluate<(uniqId: string) => string>(\n source.replace(/globDynamicComponentEntry/g, JSON.stringify(entryName)),\n );\n } catch (e) {\n console.warn(`[ReactLynx] failed to rewrite snapshot entryName for ${uniqID}`, e);\n }\n }\n }\n break;\n }\n // case SnapshotOperation.DEV_ONLY_RegisterWorklet: {\n // // HMR-related\n // if (__DEV__) {\n // const hash: string = snapshotPatch[++i];\n // const fnStr: string = snapshotPatch[++i];\n // const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);\n // registerWorklet('main-thread', hash, fn);\n // }\n // break;\n // }\n }\n }\n}\n\n/* v8 ignore start */\n/**\n * Deserializes a stringified snapshot creator for HMR.\n */\nfunction evaluate<T>(code: string): T {\n if (__DEV__) {\n // Creators receive the runtime as a call argument (see `SnapshotCreator`).\n // Direct `eval` is kept for the legacy `__runtime__ || require(...)`\n // fallback, which resolves `__webpack_require__` from this scope on\n // runtimes that call creators with a single argument.\n return eval(`(() => ${code})()`) as T;\n }\n throw new Error('unreachable: evaluate is not supported in production');\n}\n/* v8 ignore stop */\n"]}
1
+ {"version":3,"file":"snapshotPatchApply.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/snapshotPatchApply.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;;;;;;GASG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE3G;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAA4B,EAAE,QAAgB,EAAE,WAAoB;IACrG,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,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EAAE,CAAC,CAAW,CAAC;oBAC5C,MAAM,SAAS,GAAG,aAAa,CAAC,EAAE,CAAC,CAAW,CAAC;oBAE/C,cAAc;oBACd,mDAAmD;oBACnD,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;oBACtD,IAAI,MAAM,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EAAE,CAAC;wBAClD,IAAI,CAAC;4BACH,kBAAkB,CAAC,MAAM,CAAC,GAAG,QAAQ,CACnC,MAAM,CAAC,OAAO,CAAC,4BAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CACxE,CAAC;wBACJ,CAAC;wBAAC,OAAO,CAAC,EAAE,CAAC;4BACX,OAAO,CAAC,IAAI,CAAC,wDAAwD,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;wBACpF,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,qBAAqB;AACrB;;GAEG;AACH,SAAS,QAAQ,CAAI,IAAY;IAC/B,IAAI,OAAO,EAAE,CAAC;QACZ,2EAA2E;QAC3E,qEAAqE;QACrE,oEAAoE;QACpE,sDAAsD;QACtD,OAAO,IAAI,CAAC,UAAU,IAAI,KAAK,CAAM,CAAC;IACxC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;AAC1E,CAAC;AACD,oBAAoB","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 * Implements the patch application logic for the snapshot system.\n * This module is responsible for interpreting and executing patch operations\n * that were generated in the background thread, applying them to the DOM\n * in the main thread.\n *\n * The module handles various operations like element creation, insertion,\n * removal, and attribute updates, ensuring they are applied in the correct\n * order and with proper error handling.\n */\n\nimport { sendCtxNotFoundEventToBackground } from './error.js';\nimport { applyNodesRefInsertBefore, applyNodesRefRemoveChild } from './nodesRefApply.js';\nimport type { SnapshotPatch } from './snapshotPatch.js';\nimport { SnapshotOperation } from './snapshotPatch.js';\nimport { SnapshotInstance, snapshotCreatorMap, snapshotInstanceManager } from '../../snapshot/snapshot.js';\n\n/**\n * Applies a patch of snapshot operations to the main thread.\n * This is the counterpart to the patch generation in the background thread.\n * Each operation in the patch is processed sequentially to update the DOM.\n */\nexport function snapshotPatchApply(snapshotPatch: SnapshotPatch, commitId: number, isHydration: boolean): void {\n const length = snapshotPatch.length;\n for (let i = 0; i < length; ++i) {\n switch (snapshotPatch[i]) {\n case SnapshotOperation.CreateElement: {\n const type = snapshotPatch[++i] as string;\n const id = snapshotPatch[++i] as number;\n new SnapshotInstance(type, id);\n break;\n }\n case SnapshotOperation.InsertBefore: {\n const parentId = snapshotPatch[++i] as number;\n const childId = snapshotPatch[++i] as number;\n const beforeId = snapshotPatch[++i] as number | undefined;\n const __slotIndex = snapshotPatch[++i] as number;\n const parent = snapshotInstanceManager.values.get(parentId);\n const child = snapshotInstanceManager.values.get(childId);\n const existingNode = snapshotInstanceManager.values.get(beforeId!);\n if (!parent || !child) {\n sendCtxNotFoundEventToBackground(parent ? childId : parentId, {\n operation: 'InsertBefore',\n commitId,\n isHydration,\n parent: parentId,\n child: childId,\n missingNode: parent ? 2 : (child ? 1 : 3),\n });\n } else {\n child.__slotIndex = __slotIndex;\n parent.insertBefore(child, existingNode);\n }\n break;\n }\n case SnapshotOperation.RemoveChild: {\n const parentId = snapshotPatch[++i] as number;\n const childId = snapshotPatch[++i] as number;\n const parent = snapshotInstanceManager.values.get(parentId);\n const child = snapshotInstanceManager.values.get(childId);\n if (!parent || !child) {\n sendCtxNotFoundEventToBackground(parent ? childId : parentId, {\n operation: 'RemoveChild',\n commitId,\n isHydration,\n parent: parentId,\n child: childId,\n missingNode: parent ? 2 : (child ? 1 : 3),\n });\n } else {\n parent.removeChild(child);\n }\n break;\n }\n case SnapshotOperation.nodesRefInsertBefore: {\n const identifier = snapshotPatch[++i] as string;\n const childId = snapshotPatch[++i] as number;\n const beforeId = snapshotPatch[++i] as number | undefined;\n const child = snapshotInstanceManager.values.get(childId);\n if (child) {\n applyNodesRefInsertBefore(identifier, child, beforeId);\n } else {\n sendCtxNotFoundEventToBackground(childId, {\n operation: 'nodesRefInsertBefore',\n commitId,\n isHydration,\n });\n }\n break;\n }\n case SnapshotOperation.nodesRefRemoveChild: {\n const identifier = snapshotPatch[++i] as string;\n const childId = snapshotPatch[++i] as number;\n const child = snapshotInstanceManager.values.get(childId);\n if (child) {\n applyNodesRefRemoveChild(identifier, child);\n } else {\n sendCtxNotFoundEventToBackground(childId, {\n operation: 'nodesRefRemoveChild',\n commitId,\n isHydration,\n });\n }\n break;\n }\n case SnapshotOperation.SetAttribute: {\n const id = snapshotPatch[++i] as number;\n const dynamicPartIndex = snapshotPatch[++i] as number;\n const value = snapshotPatch[++i];\n const si = snapshotInstanceManager.values.get(id);\n if (si) {\n si.setAttribute(dynamicPartIndex, value);\n } else {\n sendCtxNotFoundEventToBackground(id, { operation: 'SetAttribute', commitId, isHydration });\n }\n break;\n }\n case SnapshotOperation.SetAttributes: {\n const id = snapshotPatch[++i] as number;\n const values = snapshotPatch[++i];\n const si = snapshotInstanceManager.values.get(id);\n if (si) {\n si.setAttribute('values', values);\n } else {\n sendCtxNotFoundEventToBackground(id, { operation: 'SetAttributes', commitId, isHydration });\n }\n break;\n }\n case SnapshotOperation.DEV_ONLY_AddSnapshot: {\n if (__DEV__) {\n const uniqID = snapshotPatch[++i] as string;\n const snapshotCreator = snapshotPatch[++i] as string;\n\n // HMR-related\n // Update the evaluated snapshots from JS.\n snapshotCreatorMap[uniqID] = evaluate<(uniqId: string) => string>(snapshotCreator);\n }\n break;\n }\n case SnapshotOperation.DEV_ONLY_SetSnapshotEntryName: {\n if (__DEV__) {\n const uniqID = snapshotPatch[++i] as string;\n const entryName = snapshotPatch[++i] as string;\n\n // HMR-related\n // Update the evaluated snapshot entryName from JS.\n const source = snapshotCreatorMap[uniqID]?.toString();\n if (source?.includes('globDynamicComponentEntry')) {\n try {\n snapshotCreatorMap[uniqID] = evaluate<(uniqId: string) => string>(\n source.replace(/globDynamicComponentEntry/g, JSON.stringify(entryName)),\n );\n } catch (e) {\n console.warn(`[ReactLynx] failed to rewrite snapshot entryName for ${uniqID}`, e);\n }\n }\n }\n break;\n }\n }\n }\n}\n\n/* v8 ignore start */\n/**\n * Deserializes a stringified snapshot creator for HMR.\n */\nfunction evaluate<T>(code: string): T {\n if (__DEV__) {\n // Creators receive the runtime as a call argument (see `SnapshotCreator`).\n // Direct `eval` is kept for the legacy `__runtime__ || require(...)`\n // fallback, which resolves `__webpack_require__` from this scope on\n // runtimes that call creators with a single argument.\n return eval(`(() => ${code})()`) as T;\n }\n throw new Error('unreachable: evaluate is not supported in production');\n}\n/* v8 ignore stop */\n"]}
@@ -24,65 +24,70 @@ function updateMainThread({ data, patchOptions }) {
24
24
  });
25
25
  }
26
26
  setPipeline(patchOptions.pipelineOptions);
27
- markTiming('mtsRenderStart');
28
- markTiming('parseChangesStart');
29
- const parsedData = JSON.parse(data);
30
- const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;
31
- if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
32
- console.alog?.('[ReactLynxDebug] BTS -> MTS updateMainThread:\n' + JSON.stringify({
33
- data: {
34
- ...parsedData,
35
- patchList: parsedData.patchList.map(patch => ({
36
- ...patch,
37
- snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),
38
- })),
39
- },
40
- patchOptions,
41
- }, null, 2));
42
- }
43
- markTiming('parseChangesEnd');
44
- markTiming('patchChangesStart');
45
- if (patchOptions.isHydration) {
46
- setMainThreadHydrating(true);
47
- }
48
27
  try {
49
- for (const { snapshotPatch, id } of patchList) {
50
- __pendingListUpdates.clearAttachedLists();
51
- if (snapshotPatch) {
52
- snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
53
- }
54
- __pendingListUpdates.flush();
55
- // console.debug('********** Lepus updatePatch:');
56
- // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
28
+ markTiming('mtsRenderStart');
29
+ markTiming('parseChangesStart');
30
+ const parsedData = JSON.parse(data);
31
+ const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;
32
+ if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
33
+ console.alog?.('[ReactLynxDebug] BTS -> MTS updateMainThread:\n' + JSON.stringify({
34
+ data: {
35
+ ...parsedData,
36
+ patchList: parsedData.patchList.map(patch => ({
37
+ ...patch,
38
+ snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),
39
+ })),
40
+ },
41
+ patchOptions,
42
+ }, null, 2));
57
43
  }
58
- }
59
- finally {
60
- markTiming('patchChangesEnd');
61
- markTiming('mtsRenderEnd');
44
+ markTiming('parseChangesEnd');
45
+ markTiming('patchChangesStart');
62
46
  if (patchOptions.isHydration) {
63
- setMainThreadHydrating(false);
47
+ setMainThreadHydrating(true);
64
48
  }
65
- }
66
- applyRefQueue();
67
- if (delayedRunOnMainThreadData && isMtsEnabled()) {
68
- setEomShouldFlushElementTree(false);
69
- for (const data of delayedRunOnMainThreadData) {
70
- try {
71
- runRunOnMainThreadTask(data.worklet, data.params, data.resolveId);
72
- /* v8 ignore next 3 */
49
+ try {
50
+ for (const { snapshotPatch, id } of patchList) {
51
+ __pendingListUpdates.clearAttachedLists();
52
+ if (snapshotPatch) {
53
+ snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
54
+ }
55
+ __pendingListUpdates.flush();
56
+ // console.debug('********** Lepus updatePatch:');
57
+ // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
58
+ }
59
+ }
60
+ finally {
61
+ markTiming('patchChangesEnd');
62
+ markTiming('mtsRenderEnd');
63
+ if (patchOptions.isHydration) {
64
+ setMainThreadHydrating(false);
73
65
  }
74
- catch (e) {
75
- lynx.reportError(e);
66
+ }
67
+ applyRefQueue();
68
+ if (delayedRunOnMainThreadData && isMtsEnabled()) {
69
+ setEomShouldFlushElementTree(false);
70
+ for (const data of delayedRunOnMainThreadData) {
71
+ try {
72
+ runRunOnMainThreadTask(data.worklet, data.params, data.resolveId);
73
+ /* v8 ignore next 3 */
74
+ }
75
+ catch (e) {
76
+ lynx.reportError(e);
77
+ }
76
78
  }
79
+ setEomShouldFlushElementTree(true);
80
+ }
81
+ if (patchOptions.pipelineOptions) {
82
+ flushOptions.pipelineOptions = patchOptions.pipelineOptions;
83
+ }
84
+ __FlushElementTree(__page, flushOptions);
85
+ if (flowIds) {
86
+ lynx.performance.profileEnd();
77
87
  }
78
- setEomShouldFlushElementTree(true);
79
- }
80
- if (patchOptions.pipelineOptions) {
81
- flushOptions.pipelineOptions = patchOptions.pipelineOptions;
82
88
  }
83
- __FlushElementTree(__page, flushOptions);
84
- if (flowIds) {
85
- lynx.performance.profileEnd();
89
+ finally {
90
+ setPipeline(undefined);
86
91
  }
87
92
  }
88
93
  function injectUpdateMainThread() {
@@ -1 +1 @@
1
- {"version":3,"file":"updateMainThread.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/updateMainThread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAG/G,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;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AC,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;IAC9D,CAAC;IACD,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAEzC,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings';\nimport { runRunOnMainThreadTask, setEomShouldFlushElementTree } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport type { PatchList, PatchOptions } from './commit.js';\nimport { setMainThreadHydrating } from './isMainThreadHydrating.js';\nimport { snapshotPatchApply } from './snapshotPatchApply.js';\nimport { markTiming, setPipeline } from '../../../core/performance.js';\nimport { getReloadVersion } from '../../../core/reload-version.js';\nimport { prettyFormatSnapshotPatch } from '../../debug/formatPatch.js';\nimport { LifecycleConstant } from '../../lifecycle/constant.js';\nimport { __pendingListUpdates } from '../../list/pendingListUpdates.js';\nimport { __page } from '../../snapshot/definition.js';\nimport { applyRefQueue } from '../../snapshot/workletRef.js';\nimport { isMtsEnabled } from '../../worklet/functionality.js';\n\nfunction updateMainThread(\n { data, patchOptions }: {\n data: string;\n patchOptions: PatchOptions;\n },\n): void {\n if ((patchOptions.reloadVersion) < getReloadVersion()) {\n return;\n }\n\n const flowIds = patchOptions.flowIds;\n if (flowIds) {\n lynx.performance.profileStart('ReactLynx::patch', {\n flowId: flowIds[0],\n flowIds,\n });\n }\n\n setPipeline(patchOptions.pipelineOptions);\n markTiming('mtsRenderStart');\n markTiming('parseChangesStart');\n const parsedData = JSON.parse(data) as PatchList;\n const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;\n\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BTS -> MTS updateMainThread:\\n' + JSON.stringify(\n {\n data: {\n ...parsedData,\n patchList: parsedData.patchList.map(patch => ({\n ...patch,\n snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),\n })),\n },\n patchOptions,\n },\n null,\n 2,\n ),\n );\n }\n\n markTiming('parseChangesEnd');\n markTiming('patchChangesStart');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(true);\n }\n try {\n for (const { snapshotPatch, id } of patchList) {\n __pendingListUpdates.clearAttachedLists();\n if (snapshotPatch) {\n snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);\n }\n __pendingListUpdates.flush();\n // console.debug('********** Lepus updatePatch:');\n // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);\n }\n } finally {\n markTiming('patchChangesEnd');\n markTiming('mtsRenderEnd');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(false);\n }\n }\n applyRefQueue();\n if (delayedRunOnMainThreadData && isMtsEnabled()) {\n setEomShouldFlushElementTree(false);\n for (const data of delayedRunOnMainThreadData) {\n try {\n runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);\n /* v8 ignore next 3 */\n } catch (e) {\n lynx.reportError(e as Error);\n }\n }\n setEomShouldFlushElementTree(true);\n }\n if (patchOptions.pipelineOptions) {\n flushOptions.pipelineOptions = patchOptions.pipelineOptions;\n }\n __FlushElementTree(__page, flushOptions);\n\n if (flowIds) {\n lynx.performance.profileEnd();\n }\n}\n\nfunction injectUpdateMainThread(): void {\n Object.assign(globalThis, { [LifecycleConstant.patchUpdate]: updateMainThread });\n}\n\n/**\n * @internal\n */\nexport { injectUpdateMainThread };\n"]}
1
+ {"version":3,"file":"updateMainThread.js","source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,CAAC;gBAC7B,sBAAsB,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,aAAa,EAAE,CAAC;QAChB,IAAI,0BAA0B,IAAI,YAAY,EAAE,EAAE,CAAC;YACjD,4BAA4B,CAAC,KAAK,CAAC,CAAC;YACpC,KAAK,MAAM,IAAI,IAAI,0BAA0B,EAAE,CAAC;gBAC9C,IAAI,CAAC;oBACH,sBAAsB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;oBACxF,sBAAsB;gBACxB,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,IAAI,CAAC,WAAW,CAAC,CAAU,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;YACD,4BAA4B,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,YAAY,CAAC,eAAe,EAAE,CAAC;YACjC,YAAY,CAAC,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;QAC9D,CAAC;QACD,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEzC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,WAAW,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings';\nimport { runRunOnMainThreadTask, setEomShouldFlushElementTree } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport type { PatchList, PatchOptions } from './commit.js';\nimport { setMainThreadHydrating } from './isMainThreadHydrating.js';\nimport { snapshotPatchApply } from './snapshotPatchApply.js';\nimport { markTiming, setPipeline } from '../../../core/performance.js';\nimport { getReloadVersion } from '../../../core/reload-version.js';\nimport { prettyFormatSnapshotPatch } from '../../debug/formatPatch.js';\nimport { LifecycleConstant } from '../../lifecycle/constant.js';\nimport { __pendingListUpdates } from '../../list/pendingListUpdates.js';\nimport { __page } from '../../snapshot/definition.js';\nimport { applyRefQueue } from '../../snapshot/workletRef.js';\nimport { isMtsEnabled } from '../../worklet/functionality.js';\n\nfunction updateMainThread(\n { data, patchOptions }: {\n data: string;\n patchOptions: PatchOptions;\n },\n): void {\n if ((patchOptions.reloadVersion) < getReloadVersion()) {\n return;\n }\n\n const flowIds = patchOptions.flowIds;\n if (flowIds) {\n lynx.performance.profileStart('ReactLynx::patch', {\n flowId: flowIds[0],\n flowIds,\n });\n }\n\n setPipeline(patchOptions.pipelineOptions);\n try {\n markTiming('mtsRenderStart');\n markTiming('parseChangesStart');\n const parsedData = JSON.parse(data) as PatchList;\n const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;\n\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BTS -> MTS updateMainThread:\\n' + JSON.stringify(\n {\n data: {\n ...parsedData,\n patchList: parsedData.patchList.map(patch => ({\n ...patch,\n snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),\n })),\n },\n patchOptions,\n },\n null,\n 2,\n ),\n );\n }\n\n markTiming('parseChangesEnd');\n markTiming('patchChangesStart');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(true);\n }\n try {\n for (const { snapshotPatch, id } of patchList) {\n __pendingListUpdates.clearAttachedLists();\n if (snapshotPatch) {\n snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);\n }\n __pendingListUpdates.flush();\n // console.debug('********** Lepus updatePatch:');\n // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);\n }\n } finally {\n markTiming('patchChangesEnd');\n markTiming('mtsRenderEnd');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(false);\n }\n }\n applyRefQueue();\n if (delayedRunOnMainThreadData && isMtsEnabled()) {\n setEomShouldFlushElementTree(false);\n for (const data of delayedRunOnMainThreadData) {\n try {\n runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);\n /* v8 ignore next 3 */\n } catch (e) {\n lynx.reportError(e as Error);\n }\n }\n setEomShouldFlushElementTree(true);\n }\n if (patchOptions.pipelineOptions) {\n flushOptions.pipelineOptions = patchOptions.pipelineOptions;\n }\n __FlushElementTree(__page, flushOptions);\n\n if (flowIds) {\n lynx.performance.profileEnd();\n }\n } finally {\n setPipeline(undefined);\n }\n}\n\nfunction injectUpdateMainThread(): void {\n Object.assign(globalThis, { [LifecycleConstant.patchUpdate]: updateMainThread });\n}\n\n/**\n * @internal\n */\nexport { injectUpdateMainThread };\n"]}
@@ -10,6 +10,11 @@ import type { RefProxyForwardedMethods } from '../../../core/ref.js';
10
10
  declare const shouldDelayUiOps: {
11
11
  value: boolean;
12
12
  };
13
+ /**
14
+ * An array of functions that will be executed later when `runDelayedUiOps` is called.
15
+ * These functions contain UI operations that need to be delayed.
16
+ */
17
+ declare const delayedUiOps: (() => void)[];
13
18
  /**
14
19
  * Executes all delayed UI operations.
15
20
  */
@@ -64,5 +64,5 @@ class RefProxy extends SelectorRefProxy {
64
64
  /**
65
65
  * @internal
66
66
  */
67
- export { RefProxy, runDelayedUiOps, shouldDelayUiOps };
67
+ export { delayedUiOps, RefProxy, runDelayedUiOps, shouldDelayUiOps };
68
68
  //# sourceMappingURL=delay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/ref/delay.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AAC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CAAC,CAAC;QACvE,OAAO,cAAc,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACvD,CAAC;CACF;AAID;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { SelectorRefProxy } from '../../../core/ref.js';\nimport type { RefProxyForwardedMethods } from '../../../core/ref.js';\nimport { hydrationMap } from '../../snapshot/snapshotInstanceHydrationMap.js';\n\n/**\n * A flag to indicate whether UI operations should be delayed.\n * When set to true, UI operations will be queued in the `delayedUiOps` array\n * and executed later when `runDelayedUiOps` is called.\n * This is used before hydration to ensure UI operations are batched\n * and executed at the appropriate time.\n */\nconst shouldDelayUiOps = { value: true };\n\n/**\n * An array of functions that will be executed later when `runDelayedUiOps` is called.\n * These functions contain UI operations that need to be delayed.\n */\nconst delayedUiOps: (() => void)[] = [];\n\n/**\n * Runs a task either immediately or delays it based on the `shouldDelayUiOps` flag.\n * @param task - The function to execute.\n */\nfunction runOrDelay(task: () => void): void {\n if (shouldDelayUiOps.value) {\n delayedUiOps.push(task);\n } else {\n task();\n }\n}\n\n/**\n * Executes all delayed UI operations.\n */\nfunction runDelayedUiOps(): void {\n const tasks = delayedUiOps.slice();\n delayedUiOps.length = 0;\n shouldDelayUiOps.value = false;\n\n for (const task of tasks) {\n task();\n }\n}\n\n/**\n * A proxy class designed for managing and executing reference-based tasks.\n * It delays the execution of tasks until hydration is complete.\n */\nclass RefProxy extends SelectorRefProxy<RefProxy> {\n private readonly refAttr: [snapshotInstanceId: number, expIndex: number];\n\n constructor(refAttr: [snapshotInstanceId: number, expIndex: number]) {\n super();\n this.refAttr = refAttr;\n\n return this.createProxy();\n }\n\n protected createProxyTarget(): RefProxy {\n return new RefProxy(this.refAttr);\n }\n\n protected runOrDelay(task: () => void): void {\n runOrDelay(task);\n }\n\n get selector(): string {\n const realRefId = hydrationMap.get(this.refAttr[0]) ?? this.refAttr[0];\n return `[react-ref-${realRefId}-${this.refAttr[1]}]`;\n }\n}\n\ninterface RefProxy extends RefProxyForwardedMethods<RefProxy> {}\n\n/**\n * @internal\n */\nexport { RefProxy, runDelayedUiOps, shouldDelayUiOps };\n"]}
1
+ {"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/ref/delay.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAEzC;;;GAGG;AACH,MAAM,YAAY,GAAmB,EAAE,CAAC;AAExC;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAgB;IAClC,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC3B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,IAAI,EAAE,CAAC;IACT,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IACnC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IACxB,gBAAgB,CAAC,KAAK,GAAG,KAAK,CAAC;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,EAAE,CAAC;IACT,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,QAAS,SAAQ,gBAA0B;IAC9B,OAAO,CAAiD;IAEzE,YAAY,OAAuD;QACjE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAES,iBAAiB;QACzB,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAES,UAAU,CAAC,IAAgB;QACnC,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,QAAQ;QACV,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACvE,OAAO,cAAc,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACvD,CAAC;CACF;AAID;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { SelectorRefProxy } from '../../../core/ref.js';\nimport type { RefProxyForwardedMethods } from '../../../core/ref.js';\nimport { hydrationMap } from '../../snapshot/snapshotInstanceHydrationMap.js';\n\n/**\n * A flag to indicate whether UI operations should be delayed.\n * When set to true, UI operations will be queued in the `delayedUiOps` array\n * and executed later when `runDelayedUiOps` is called.\n * This is used before hydration to ensure UI operations are batched\n * and executed at the appropriate time.\n */\nconst shouldDelayUiOps = { value: true };\n\n/**\n * An array of functions that will be executed later when `runDelayedUiOps` is called.\n * These functions contain UI operations that need to be delayed.\n */\nconst delayedUiOps: (() => void)[] = [];\n\n/**\n * Runs a task either immediately or delays it based on the `shouldDelayUiOps` flag.\n * @param task - The function to execute.\n */\nfunction runOrDelay(task: () => void): void {\n if (shouldDelayUiOps.value) {\n delayedUiOps.push(task);\n } else {\n task();\n }\n}\n\n/**\n * Executes all delayed UI operations.\n */\nfunction runDelayedUiOps(): void {\n const tasks = delayedUiOps.slice();\n delayedUiOps.length = 0;\n shouldDelayUiOps.value = false;\n\n for (const task of tasks) {\n task();\n }\n}\n\n/**\n * A proxy class designed for managing and executing reference-based tasks.\n * It delays the execution of tasks until hydration is complete.\n */\nclass RefProxy extends SelectorRefProxy<RefProxy> {\n private readonly refAttr: [snapshotInstanceId: number, expIndex: number];\n\n constructor(refAttr: [snapshotInstanceId: number, expIndex: number]) {\n super();\n this.refAttr = refAttr;\n\n return this.createProxy();\n }\n\n protected createProxyTarget(): RefProxy {\n return new RefProxy(this.refAttr);\n }\n\n protected runOrDelay(task: () => void): void {\n runOrDelay(task);\n }\n\n get selector(): string {\n const realRefId = hydrationMap.get(this.refAttr[0]) ?? this.refAttr[0];\n return `[react-ref-${realRefId}-${this.refAttr[1]}]`;\n }\n}\n\ninterface RefProxy extends RefProxyForwardedMethods<RefProxy> {}\n\n/**\n * @internal\n */\nexport { delayedUiOps, RefProxy, runDelayedUiOps, shouldDelayUiOps };\n"]}
@@ -9,28 +9,13 @@ export class ListUpdateInfoRecording {
9
9
  constructor(list) {
10
10
  this.list = list;
11
11
  this.oldChildNodes = list.childNodes;
12
- // this.oldChildNodesSet = new Set(this.oldChildNodes);
13
12
  }
14
- // private __commitAndReset() {
15
- // (this.__pendingAttributes ??= []).push(this.__toAttribute());
16
- // this.oldChildNodes = this.list.childNodes;
17
- // this.oldChildNodesSet = new Set(this.oldChildNodes);
18
- // this.removeChild1.clear();
19
- // this.removeChild2.clear();
20
- // this.insertBefore.clear();
21
- // this.appendChild.length = 0;
22
- // this.platformInfoUpdate.clear();
23
- // }
24
13
  flush() {
25
14
  if (!this.list.__elements) {
26
15
  return undefined;
27
16
  }
28
17
  const elementIndex = this.list.__snapshot_def.slot[0][1];
29
18
  const listElement = this.list.__elements[elementIndex];
30
- // this.__pendingAttributes?.forEach(pendingAttribute => {
31
- // __SetAttribute(listElement, "update-list-info", pendingAttribute);
32
- // __FlushElementTree(listElement);
33
- // });
34
19
  const updateListInfo = this.__toAttribute();
35
20
  if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
36
21
  const listID = __GetElementUniqueID(listElement);
@@ -64,22 +49,15 @@ export class ListUpdateInfoRecording {
64
49
  return this.list.__id;
65
50
  }
66
51
  oldChildNodes;
67
- // private oldChildNodesSet: Set<SnapshotInstance>;
68
52
  removeChild = new Set();
69
53
  insertBefore = new Map(); // insert V before K
70
54
  appendChild = [];
71
55
  platformInfoUpdate = new Map();
72
56
  onInsertBefore(newNode, existingNode) {
73
57
  if (newNode.parentNode) {
74
- // if (!this.oldChildNodesSet.has(newNode)) {
75
- // this.__commitAndReset();
76
- // }
77
58
  this.removeChild.add(newNode);
78
59
  }
79
60
  if (existingNode) {
80
- // if (!this.oldChildNodesSet.has(existingNode)) {
81
- // this.__commitAndReset();
82
- // }
83
61
  const newChildren = this.insertBefore.get(existingNode) ?? [];
84
62
  newChildren.push(newNode);
85
63
  this.insertBefore.set(existingNode, newChildren);
@@ -89,9 +67,6 @@ export class ListUpdateInfoRecording {
89
67
  }
90
68
  }
91
69
  onRemoveChild(child) {
92
- // if (!this.oldChildNodesSet.has(child)) {
93
- // this.__commitAndReset();
94
- // }
95
70
  this.removeChild.add(child);
96
71
  }
97
72
  onSetAttribute(child, attr, _oldAttr) {
@@ -174,11 +149,6 @@ export class ListUpdateInfoRecording {
174
149
  };
175
150
  }
176
151
  toJSON() {
177
- // if (this.__pendingAttributes) {
178
- // return [...this.__pendingAttributes, this.__toAttribute()];
179
- // } else {
180
- // return [this.__toAttribute()];
181
- // }
182
152
  return [this.__toAttribute()];
183
153
  }
184
154
  }
@@ -1 +1 @@
1
- {"version":3,"file":"listUpdateInfo.js","sourceRoot":"","sources":["../../../src/snapshot/list/listUpdateInfo.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MA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,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAU,CAAC;IACzC,CAAC;CACF","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { componentAtIndexFactory, enqueueComponentFactory } from './list.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { hydrate } from '../renderToOpcodes/hydrate.js';\nimport type { SnapshotInstance } from '../snapshot/snapshot.js';\n\nexport interface ListUpdateInfo {\n flush(): number | undefined;\n getAttachedListId(): number | undefined;\n onInsertBefore(\n newNode: SnapshotInstance,\n existingNode?: SnapshotInstance,\n ): void;\n onRemoveChild(child: SnapshotInstance): void;\n onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;\n}\n\n// class ListUpdateInfoDiffing implements ListUpdateInfo {\n// private oldChildNodes: SnapshotInstance[];\n// constructor(private list: SnapshotInstance) {\n// this.oldChildNodes = list.childNodes;\n// }\n// flush(): void {\n// Object.defineProperty(SnapshotInstance.prototype, \"key\", {\n// get: function () {\n// return this.values[0][\"item-key\"];\n// },\n// });\n\n// }\n// onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance | undefined): void {}\n// onRemoveChild(child: SnapshotInstance): void {}\n// onSetAttribute(child: SnapshotInstance, attr: any): void {\n// throw new Error(\"Method not implemented.\");\n// }\n// }\n\ninterface InsertAction {\n position: number;\n type: string;\n}\n\ninterface UpdateAction {\n from: number;\n to: number;\n type: string;\n flush: boolean;\n}\n\ninterface ListOperations {\n insertAction: InsertAction[];\n removeAction: number[];\n updateAction: UpdateAction[];\n}\n\nexport class ListUpdateInfoRecording implements ListUpdateInfo {\n constructor(private list: SnapshotInstance) {\n this.oldChildNodes = list.childNodes;\n // this.oldChildNodesSet = new Set(this.oldChildNodes);\n }\n\n // private __commitAndReset() {\n // (this.__pendingAttributes ??= []).push(this.__toAttribute());\n // this.oldChildNodes = this.list.childNodes;\n // this.oldChildNodesSet = new Set(this.oldChildNodes);\n // this.removeChild1.clear();\n // this.removeChild2.clear();\n // this.insertBefore.clear();\n // this.appendChild.length = 0;\n // this.platformInfoUpdate.clear();\n // }\n\n flush(): undefined | number {\n if (!this.list.__elements) {\n return undefined;\n }\n const elementIndex = this.list.__snapshot_def.slot[0]![1];\n const listElement = this.list.__elements[elementIndex]!;\n // this.__pendingAttributes?.forEach(pendingAttribute => {\n // __SetAttribute(listElement, \"update-list-info\", pendingAttribute);\n // __FlushElementTree(listElement);\n // });\n const updateListInfo = this.__toAttribute();\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n const listID = __GetElementUniqueID(listElement);\n profileStart(`ReactLynx::listFlush::updateListInfo`, {\n args: {\n 'list id': String(listID),\n 'update list info': JSON.stringify(updateListInfo),\n },\n });\n }\n\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n const listID = __GetElementUniqueID(listElement);\n console.alog?.(\n '[ReactLynxDebug] ReactLynx::listFlush::updateListInfo:\\n'\n + JSON.stringify(\n {\n listID,\n updateListInfo,\n },\n null,\n 2,\n ),\n );\n }\n\n __SetAttribute(listElement, 'update-list-info', updateListInfo);\n const [componentAtIndex, componentAtIndexes] = componentAtIndexFactory(this.list.childNodes, hydrate);\n __UpdateListCallbacks(\n listElement,\n componentAtIndex,\n enqueueComponentFactory(),\n componentAtIndexes,\n );\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return this.list.__id;\n }\n\n getAttachedListId(): undefined | number {\n if (!this.list.__elements) {\n return undefined;\n }\n return this.list.__id;\n }\n\n private oldChildNodes: SnapshotInstance[];\n // private oldChildNodesSet: Set<SnapshotInstance>;\n private removeChild = new Set<SnapshotInstance>();\n private insertBefore = new Map<SnapshotInstance, SnapshotInstance[]>(); // insert V before K\n private appendChild = [] as SnapshotInstance[];\n private platformInfoUpdate = new Map<SnapshotInstance, any>();\n\n onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void {\n if (newNode.parentNode) {\n // if (!this.oldChildNodesSet.has(newNode)) {\n // this.__commitAndReset();\n // }\n this.removeChild.add(newNode);\n }\n if (existingNode) {\n // if (!this.oldChildNodesSet.has(existingNode)) {\n // this.__commitAndReset();\n // }\n const newChildren = this.insertBefore.get(existingNode) ?? [];\n newChildren.push(newNode);\n this.insertBefore.set(existingNode, newChildren);\n } else {\n this.appendChild.push(newNode);\n }\n }\n\n onRemoveChild(child: SnapshotInstance): void {\n // if (!this.oldChildNodesSet.has(child)) {\n // this.__commitAndReset();\n // }\n this.removeChild.add(child);\n }\n\n onSetAttribute(child: SnapshotInstance, attr: any, _oldAttr: any): void {\n this.platformInfoUpdate.set(child, attr);\n }\n\n private __toAttribute(): ListOperations {\n const { removeChild, insertBefore, appendChild, platformInfoUpdate } = this;\n\n const removals: number[] = [];\n const insertions: InsertAction[] = [];\n const updates: UpdateAction[] = [];\n\n let j = 0;\n for (let i = 0; i < this.oldChildNodes.length; i++, j++) {\n const child = this.oldChildNodes[i]!;\n const insertedBefore = insertBefore.get(child)?.length ?? 0;\n if (platformInfoUpdate.has(child)) {\n updates.push({\n ...platformInfoUpdate.get(child),\n from: +j + insertedBefore,\n to: +j + insertedBefore,\n // no flush\n flush: false,\n type: child.type,\n } as UpdateAction);\n }\n if (insertBefore.has(child)) {\n const children = insertBefore.get(child)!;\n children.forEach(c => {\n insertions.push({\n position: j,\n type: c.type,\n ...c.__listItemPlatformInfo,\n } as InsertAction);\n j++;\n });\n }\n if (removeChild.has(child)) {\n removals.push(i);\n removeChild.delete(child);\n j--;\n }\n }\n for (let i = 0; i < appendChild.length; i++) {\n const child = appendChild[i]!;\n insertions.push({\n position: j + i,\n type: child.type,\n ...child.__listItemPlatformInfo,\n } as InsertAction);\n }\n\n insertions.sort((a, b) => a.position - b.position);\n removals.sort((a, b) => a - b);\n\n if (\n SystemInfo.lynxSdkVersion === '2.14'\n || SystemInfo.lynxSdkVersion === '2.15'\n || SystemInfo.lynxSdkVersion === '2.16'\n || SystemInfo.lynxSdkVersion === '2.17'\n || SystemInfo.lynxSdkVersion === '2.18'\n ) {\n const elementIndex = this.list.__snapshot_def.slot[0]![1];\n const listElement = this.list.__elements![elementIndex]!;\n\n // `__GetAttributeByName` is available since Lynx 2.14\n if (__GetAttributeByName(listElement, 'custom-list-name') === 'list-container') {\n // `updateAction` must be full (not incremental) when Lynx version <= 2.18 and\n // when `custom-list-name` is `list-container` (available when Lynx version >= 2.14) is true,\n updates.length = 0;\n this.list.childNodes.forEach((child, index) => {\n updates.push({\n ...child.__listItemPlatformInfo,\n from: index,\n to: index,\n // no flush\n flush: false,\n type: child.type,\n } as UpdateAction);\n });\n }\n }\n\n return {\n insertAction: insertions,\n removeAction: removals,\n updateAction: updates,\n };\n }\n\n toJSON(): [ListOperations] {\n // if (this.__pendingAttributes) {\n // return [...this.__pendingAttributes, this.__toAttribute()];\n // } else {\n // return [this.__toAttribute()];\n // }\n\n return [this.__toAttribute()] as const;\n }\n}\n"]}
1
+ {"version":3,"file":"listUpdateInfo.js","sourceRoot":"","sources":["../../../src/snapshot/list/listUpdateInfo.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAgCxD,MAAM,OAAO,uBAAuB;IACd;IAApB,YAAoB,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC;IACvC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,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AAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;oBAC5C,OAAO,CAAC,IAAI,CAAC;wBACX,GAAG,KAAK,CAAC,sBAAsB;wBAC/B,IAAI,EAAE,KAAK;wBACX,EAAE,EAAE,KAAK;wBACT,WAAW;wBACX,KAAK,EAAE,KAAK;wBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;qBACD,CAAC,CAAC;gBACrB,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,YAAY,EAAE,UAAU;YACxB,YAAY,EAAE,QAAQ;YACtB,YAAY,EAAE,OAAO;SACtB,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAU,CAAC;IACzC,CAAC;CACF","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { componentAtIndexFactory, enqueueComponentFactory } from './list.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { hydrate } from '../renderToOpcodes/hydrate.js';\nimport type { SnapshotInstance } from '../snapshot/snapshot.js';\n\nexport interface ListUpdateInfo {\n flush(): number | undefined;\n getAttachedListId(): number | undefined;\n onInsertBefore(\n newNode: SnapshotInstance,\n existingNode?: SnapshotInstance,\n ): void;\n onRemoveChild(child: SnapshotInstance): void;\n onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;\n}\n\ninterface InsertAction {\n position: number;\n type: string;\n}\n\ninterface UpdateAction {\n from: number;\n to: number;\n type: string;\n flush: boolean;\n}\n\ninterface ListOperations {\n insertAction: InsertAction[];\n removeAction: number[];\n updateAction: UpdateAction[];\n}\n\nexport class ListUpdateInfoRecording implements ListUpdateInfo {\n constructor(private list: SnapshotInstance) {\n this.oldChildNodes = list.childNodes;\n }\n\n flush(): undefined | number {\n if (!this.list.__elements) {\n return undefined;\n }\n const elementIndex = this.list.__snapshot_def.slot[0]![1];\n const listElement = this.list.__elements[elementIndex]!;\n const updateListInfo = this.__toAttribute();\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n const listID = __GetElementUniqueID(listElement);\n profileStart(`ReactLynx::listFlush::updateListInfo`, {\n args: {\n 'list id': String(listID),\n 'update list info': JSON.stringify(updateListInfo),\n },\n });\n }\n\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n const listID = __GetElementUniqueID(listElement);\n console.alog?.(\n '[ReactLynxDebug] ReactLynx::listFlush::updateListInfo:\\n'\n + JSON.stringify(\n {\n listID,\n updateListInfo,\n },\n null,\n 2,\n ),\n );\n }\n\n __SetAttribute(listElement, 'update-list-info', updateListInfo);\n const [componentAtIndex, componentAtIndexes] = componentAtIndexFactory(this.list.childNodes, hydrate);\n __UpdateListCallbacks(\n listElement,\n componentAtIndex,\n enqueueComponentFactory(),\n componentAtIndexes,\n );\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return this.list.__id;\n }\n\n getAttachedListId(): undefined | number {\n if (!this.list.__elements) {\n return undefined;\n }\n return this.list.__id;\n }\n\n private oldChildNodes: SnapshotInstance[];\n private removeChild = new Set<SnapshotInstance>();\n private insertBefore = new Map<SnapshotInstance, SnapshotInstance[]>(); // insert V before K\n private appendChild = [] as SnapshotInstance[];\n private platformInfoUpdate = new Map<SnapshotInstance, any>();\n\n onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void {\n if (newNode.parentNode) {\n this.removeChild.add(newNode);\n }\n if (existingNode) {\n const newChildren = this.insertBefore.get(existingNode) ?? [];\n newChildren.push(newNode);\n this.insertBefore.set(existingNode, newChildren);\n } else {\n this.appendChild.push(newNode);\n }\n }\n\n onRemoveChild(child: SnapshotInstance): void {\n this.removeChild.add(child);\n }\n\n onSetAttribute(child: SnapshotInstance, attr: any, _oldAttr: any): void {\n this.platformInfoUpdate.set(child, attr);\n }\n\n private __toAttribute(): ListOperations {\n const { removeChild, insertBefore, appendChild, platformInfoUpdate } = this;\n\n const removals: number[] = [];\n const insertions: InsertAction[] = [];\n const updates: UpdateAction[] = [];\n\n let j = 0;\n for (let i = 0; i < this.oldChildNodes.length; i++, j++) {\n const child = this.oldChildNodes[i]!;\n const insertedBefore = insertBefore.get(child)?.length ?? 0;\n if (platformInfoUpdate.has(child)) {\n updates.push({\n ...platformInfoUpdate.get(child),\n from: +j + insertedBefore,\n to: +j + insertedBefore,\n // no flush\n flush: false,\n type: child.type,\n } as UpdateAction);\n }\n if (insertBefore.has(child)) {\n const children = insertBefore.get(child)!;\n children.forEach(c => {\n insertions.push({\n position: j,\n type: c.type,\n ...c.__listItemPlatformInfo,\n } as InsertAction);\n j++;\n });\n }\n if (removeChild.has(child)) {\n removals.push(i);\n removeChild.delete(child);\n j--;\n }\n }\n for (let i = 0; i < appendChild.length; i++) {\n const child = appendChild[i]!;\n insertions.push({\n position: j + i,\n type: child.type,\n ...child.__listItemPlatformInfo,\n } as InsertAction);\n }\n\n insertions.sort((a, b) => a.position - b.position);\n removals.sort((a, b) => a - b);\n\n if (\n SystemInfo.lynxSdkVersion === '2.14'\n || SystemInfo.lynxSdkVersion === '2.15'\n || SystemInfo.lynxSdkVersion === '2.16'\n || SystemInfo.lynxSdkVersion === '2.17'\n || SystemInfo.lynxSdkVersion === '2.18'\n ) {\n const elementIndex = this.list.__snapshot_def.slot[0]![1];\n const listElement = this.list.__elements![elementIndex]!;\n\n // `__GetAttributeByName` is available since Lynx 2.14\n if (__GetAttributeByName(listElement, 'custom-list-name') === 'list-container') {\n // `updateAction` must be full (not incremental) when Lynx version <= 2.18 and\n // when `custom-list-name` is `list-container` (available when Lynx version >= 2.14) is true,\n updates.length = 0;\n this.list.childNodes.forEach((child, index) => {\n updates.push({\n ...child.__listItemPlatformInfo,\n from: index,\n to: index,\n // no flush\n flush: false,\n type: child.type,\n } as UpdateAction);\n });\n }\n }\n\n return {\n insertAction: insertions,\n removeAction: removals,\n updateAction: updates,\n };\n }\n\n toJSON(): [ListOperations] {\n return [this.__toAttribute()] as const;\n }\n}\n"]}
@@ -110,7 +110,7 @@ function updatePage(data, options) {
110
110
  __root.__jsx = oldRoot.__jsx;
111
111
  setPipeline(options?.pipelineOptions);
112
112
  markTiming('updateDiffVdomStart');
113
- {
113
+ try {
114
114
  __pendingListUpdates.clearAttachedLists();
115
115
  renderMainThread();
116
116
  // As said by codename `firstScreenEventIdSwap`, this swap will only be used for event remap,
@@ -119,14 +119,17 @@ function updatePage(data, options) {
119
119
  // always call this before `__FlushElementTree`
120
120
  __pendingListUpdates.flush();
121
121
  applyRefQueue();
122
+ if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
123
+ onFirstScreenTreeReady();
124
+ }
125
+ flushOptions.triggerDataUpdated = true;
126
+ markTiming('updateDiffVdomEnd');
127
+ if (typeof lepusng_gc === 'function') {
128
+ lepusng_gc();
129
+ }
122
130
  }
123
- if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
124
- onFirstScreenTreeReady();
125
- }
126
- flushOptions.triggerDataUpdated = true;
127
- markTiming('updateDiffVdomEnd');
128
- if (typeof lepusng_gc === 'function') {
129
- lepusng_gc();
131
+ finally {
132
+ setPipeline(undefined);
130
133
  }
131
134
  }
132
135
  __FlushElementTree(__page, flushOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"calledByNative.js","sourceRoot":"","sources":["../../../src/snapshot/lynx/calledByNative.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,yBA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CAAC,CAAC;QACtC,UAAU,CAAC,qBAAqB,CAAC,CAAC;QAClC,CAAC;YACC,oBAAoB,CAAC,kBAAkB,EAAE,CAAC;YAC1C,gBAAgB,EAAE,CAAC;YACnB,6FAA6F;YAC7F,+DAA+D;YAC/D,OAAO,CACL,OAA2B,EAC3B,MAA0B,EAC1B,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,WAAW,EAAE,CACvD,CAAC;YAEF,+CAA+C;YAC/C,oBAAoB,CAAC,KAAK,EAAE,CAAC;YAC7B,aAAa,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,4BAA4B,KAAK,QAAQ,EAAE,CAAC;YAC9C,sBAAsB,EAAE,CAAC;QAC3B,CAAC;QAED,YAAY,CAAC,kBAAkB,GAAG,IAAI,CAAC;QACvC,UAAU,CAAC,mBAAmB,CAAC,CAAC;QAEhC,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE,CAAC;YACrC,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAU,EAAE,OAA0B;IAC/D,IAAI,OAAO,EAAE,CAAC;QACZ,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,kBAAkB,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,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.\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { markTiming, setPipeline } from '../../core/performance.js';\nimport { __root, setRoot } from '../../root.js';\nimport { LifecycleConstant } from '../lifecycle/constant.js';\nimport {\n firstScreenSync,\n onFirstScreenSyncReady,\n onFirstScreenTreeReady,\n resetFirstScreenSyncState,\n resetFirstScreenTreeReady,\n syncFirstScreen,\n} from '../lifecycle/event/firstScreenSync.js';\nimport { reloadMainThread } from '../lifecycle/reload.js';\nimport { renderMainThread } from '../lifecycle/render.js';\nimport { __pendingListUpdates } from '../list/pendingListUpdates.js';\nimport { hydrate } from '../renderToOpcodes/hydrate.js';\nimport { ssrHydrateByOpcodes } from '../renderToOpcodes/opcodes.js';\nimport { __page, setupPage } from '../snapshot/definition.js';\nimport { SnapshotInstance } from '../snapshot/snapshot.js';\nimport { applyRefQueue } from '../snapshot/workletRef.js';\n\nfunction ssrEncode() {\n const { __opcodes } = __root;\n delete __root.__opcodes;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldToJSON = SnapshotInstance.prototype.toJSON;\n SnapshotInstance.prototype.toJSON = function(this: SnapshotInstance): any {\n return [\n this.type,\n this.__id,\n this.__elements,\n ];\n };\n\n try {\n const replacer = (_key: string, value: unknown): unknown => {\n if (value && typeof value === 'object' && '_wkltId' in (value as Record<string, unknown>)) {\n return null;\n }\n return value;\n };\n return JSON.stringify({ __opcodes, __root_values: __root.__values }, replacer);\n } finally {\n SnapshotInstance.prototype.toJSON = oldToJSON;\n }\n}\n\nfunction ssrHydrate(info: string) {\n const nativePage = __GetPageElement();\n if (!nativePage) {\n throw new Error('SSR Hydration Failed! Please check if the SSR content loaded successfully!');\n }\n\n resetFirstScreenSyncState();\n setupPage(nativePage);\n const refsMap = __GetTemplateParts(nativePage);\n\n const { __opcodes, __root_values } = JSON.parse(info) as {\n __opcodes: unknown[];\n __root_values: unknown[] | undefined;\n };\n if (__root_values) {\n __root.setAttribute('values', __root_values);\n }\n ssrHydrateByOpcodes(__opcodes, __root as SnapshotInstance, refsMap);\n\n (__root as SnapshotInstance).__elements = [nativePage];\n (__root as SnapshotInstance).__element_root = nativePage;\n}\n\nfunction injectCalledByNative(): void {\n if (process.env['NODE_ENV'] !== 'test' && __FIRST_SCREEN_SYNC_TIMING__ !== 'jsReady' && __ENABLE_SSR__) {\n throw new Error('`firstScreenSyncTiming` must be `jsReady` when SSR is enabled');\n }\n\n const calledByNative: LynxCallByNative = {\n renderPage,\n updatePage,\n updateGlobalProps,\n getPageData: function() {\n return null;\n },\n removeComponents: function(): void {},\n ...(__ENABLE_SSR__ ? { ssrEncode, ssrHydrate } : {}),\n };\n\n Object.assign(globalThis, calledByNative);\n Object.assign(globalThis, {\n [LifecycleConstant.firstScreenSyncReady]: onFirstScreenSyncReady,\n });\n}\n\nfunction renderPage(data: Record<string, unknown> | undefined): void {\n lynx.__initData = data ?? {};\n\n setupPage(__CreatePage('0', 0));\n (__root as SnapshotInstance).ensureElements();\n\n renderMainThread();\n\n // always call this before `__FlushElementTree`\n // (There is an implicit `__FlushElementTree` in `renderPage`)\n __pendingListUpdates.flush();\n applyRefQueue();\n\n if (__FIRST_SCREEN_SYNC_TIMING__ === 'immediately') {\n syncFirstScreen();\n } else {\n // `jsReady` / `manual`: the tree is ready, but the sync waits for the\n // `rLynxFirstScreenSyncReady` signal.\n onFirstScreenTreeReady();\n }\n}\n\nfunction updatePage(data: Record<string, unknown> | undefined, options?: UpdatePageOption): void {\n if (options?.reloadTemplate) {\n reloadMainThread(data, options);\n return;\n }\n\n applyUpdatePageData(data, options);\n\n const flushOptions = options ?? {};\n if (!firstScreenSync.isSynced) {\n if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {\n // a `markFirstScreenSyncReady` call during the re-render below must not\n // sync the half-rendered tree; it is deferred to `onFirstScreenTreeReady`\n resetFirstScreenTreeReady();\n }\n\n const oldRoot = __root;\n setRoot(new SnapshotInstance('root'));\n __root.__jsx = oldRoot.__jsx;\n\n setPipeline(options?.pipelineOptions);\n markTiming('updateDiffVdomStart');\n {\n __pendingListUpdates.clearAttachedLists();\n renderMainThread();\n // As said by codename `firstScreenEventIdSwap`, this swap will only be used for event remap,\n // because ref & unref cause by previous render will be ignored\n hydrate(\n oldRoot as SnapshotInstance,\n __root as SnapshotInstance,\n { skipUnRef: true, swap: firstScreenSync.eventIdSwap },\n );\n\n // always call this before `__FlushElementTree`\n __pendingListUpdates.flush();\n applyRefQueue();\n }\n\n if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {\n onFirstScreenTreeReady();\n }\n\n flushOptions.triggerDataUpdated = true;\n markTiming('updateDiffVdomEnd');\n\n if (typeof lepusng_gc === 'function') {\n lepusng_gc();\n }\n }\n\n __FlushElementTree(__page, flushOptions);\n}\n\nfunction updateGlobalProps(_data: any, options?: UpdatePageOption): void {\n if (options) {\n __FlushElementTree(__page, options);\n } else {\n __FlushElementTree();\n }\n}\n\n/**\n * @internal\n */\nexport { injectCalledByNative };\n"]}
1
+ {"version":3,"file":"calledByNative.js","sourceRoot":"","sources":["../../../src/snapshot/lynx/calledByNative.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,GAChB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,E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AQ,EAAE,CAAC;gBAC9C,sBAAsB,EAAE,CAAC;YAC3B,CAAC;YAED,YAAY,CAAC,kBAAkB,GAAG,IAAI,CAAC;YACvC,UAAU,CAAC,mBAAmB,CAAC,CAAC;YAEhC,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE,CAAC;gBACrC,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,WAAW,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAU,EAAE,OAA0B;IAC/D,IAAI,OAAO,EAAE,CAAC;QACZ,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,kBAAkB,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,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.\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { markTiming, setPipeline } from '../../core/performance.js';\nimport { __root, setRoot } from '../../root.js';\nimport { LifecycleConstant } from '../lifecycle/constant.js';\nimport {\n firstScreenSync,\n onFirstScreenSyncReady,\n onFirstScreenTreeReady,\n resetFirstScreenSyncState,\n resetFirstScreenTreeReady,\n syncFirstScreen,\n} from '../lifecycle/event/firstScreenSync.js';\nimport { reloadMainThread } from '../lifecycle/reload.js';\nimport { renderMainThread } from '../lifecycle/render.js';\nimport { __pendingListUpdates } from '../list/pendingListUpdates.js';\nimport { hydrate } from '../renderToOpcodes/hydrate.js';\nimport { ssrHydrateByOpcodes } from '../renderToOpcodes/opcodes.js';\nimport { __page, setupPage } from '../snapshot/definition.js';\nimport { SnapshotInstance } from '../snapshot/snapshot.js';\nimport { applyRefQueue } from '../snapshot/workletRef.js';\n\nfunction ssrEncode() {\n const { __opcodes } = __root;\n delete __root.__opcodes;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldToJSON = SnapshotInstance.prototype.toJSON;\n SnapshotInstance.prototype.toJSON = function(this: SnapshotInstance): any {\n return [\n this.type,\n this.__id,\n this.__elements,\n ];\n };\n\n try {\n const replacer = (_key: string, value: unknown): unknown => {\n if (value && typeof value === 'object' && '_wkltId' in (value as Record<string, unknown>)) {\n return null;\n }\n return value;\n };\n return JSON.stringify({ __opcodes, __root_values: __root.__values }, replacer);\n } finally {\n SnapshotInstance.prototype.toJSON = oldToJSON;\n }\n}\n\nfunction ssrHydrate(info: string) {\n const nativePage = __GetPageElement();\n if (!nativePage) {\n throw new Error('SSR Hydration Failed! Please check if the SSR content loaded successfully!');\n }\n\n resetFirstScreenSyncState();\n setupPage(nativePage);\n const refsMap = __GetTemplateParts(nativePage);\n\n const { __opcodes, __root_values } = JSON.parse(info) as {\n __opcodes: unknown[];\n __root_values: unknown[] | undefined;\n };\n if (__root_values) {\n __root.setAttribute('values', __root_values);\n }\n ssrHydrateByOpcodes(__opcodes, __root as SnapshotInstance, refsMap);\n\n (__root as SnapshotInstance).__elements = [nativePage];\n (__root as SnapshotInstance).__element_root = nativePage;\n}\n\nfunction injectCalledByNative(): void {\n if (process.env['NODE_ENV'] !== 'test' && __FIRST_SCREEN_SYNC_TIMING__ !== 'jsReady' && __ENABLE_SSR__) {\n throw new Error('`firstScreenSyncTiming` must be `jsReady` when SSR is enabled');\n }\n\n const calledByNative: LynxCallByNative = {\n renderPage,\n updatePage,\n updateGlobalProps,\n getPageData: function() {\n return null;\n },\n removeComponents: function(): void {},\n ...(__ENABLE_SSR__ ? { ssrEncode, ssrHydrate } : {}),\n };\n\n Object.assign(globalThis, calledByNative);\n Object.assign(globalThis, {\n [LifecycleConstant.firstScreenSyncReady]: onFirstScreenSyncReady,\n });\n}\n\nfunction renderPage(data: Record<string, unknown> | undefined): void {\n lynx.__initData = data ?? {};\n\n setupPage(__CreatePage('0', 0));\n (__root as SnapshotInstance).ensureElements();\n\n renderMainThread();\n\n // always call this before `__FlushElementTree`\n // (There is an implicit `__FlushElementTree` in `renderPage`)\n __pendingListUpdates.flush();\n applyRefQueue();\n\n if (__FIRST_SCREEN_SYNC_TIMING__ === 'immediately') {\n syncFirstScreen();\n } else {\n // `jsReady` / `manual`: the tree is ready, but the sync waits for the\n // `rLynxFirstScreenSyncReady` signal.\n onFirstScreenTreeReady();\n }\n}\n\nfunction updatePage(data: Record<string, unknown> | undefined, options?: UpdatePageOption): void {\n if (options?.reloadTemplate) {\n reloadMainThread(data, options);\n return;\n }\n\n applyUpdatePageData(data, options);\n\n const flushOptions = options ?? {};\n if (!firstScreenSync.isSynced) {\n if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {\n // a `markFirstScreenSyncReady` call during the re-render below must not\n // sync the half-rendered tree; it is deferred to `onFirstScreenTreeReady`\n resetFirstScreenTreeReady();\n }\n\n const oldRoot = __root;\n setRoot(new SnapshotInstance('root'));\n __root.__jsx = oldRoot.__jsx;\n\n setPipeline(options?.pipelineOptions);\n markTiming('updateDiffVdomStart');\n try {\n __pendingListUpdates.clearAttachedLists();\n renderMainThread();\n // As said by codename `firstScreenEventIdSwap`, this swap will only be used for event remap,\n // because ref & unref cause by previous render will be ignored\n hydrate(\n oldRoot as SnapshotInstance,\n __root as SnapshotInstance,\n { skipUnRef: true, swap: firstScreenSync.eventIdSwap },\n );\n\n // always call this before `__FlushElementTree`\n __pendingListUpdates.flush();\n applyRefQueue();\n\n if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {\n onFirstScreenTreeReady();\n }\n\n flushOptions.triggerDataUpdated = true;\n markTiming('updateDiffVdomEnd');\n\n if (typeof lepusng_gc === 'function') {\n lepusng_gc();\n }\n } finally {\n setPipeline(undefined);\n }\n }\n\n __FlushElementTree(__page, flushOptions);\n}\n\nfunction updateGlobalProps(_data: any, options?: UpdatePageOption): void {\n if (options) {\n __FlushElementTree(__page, options);\n } else {\n __FlushElementTree();\n }\n}\n\n/**\n * @internal\n */\nexport { injectCalledByNative };\n"]}