@lynx-js/react 0.119.0 → 0.121.0

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 (549) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/package.json +39 -11
  3. package/runtime/lazy/compat.js +1 -0
  4. package/runtime/lazy/internal.js +3 -0
  5. package/runtime/lazy/react.js +1 -0
  6. package/runtime/lib/core/hooks/mainThread.d.ts +1 -0
  7. package/runtime/lib/core/hooks/mainThread.js +7 -0
  8. package/runtime/lib/core/hooks/mainThread.js.map +1 -0
  9. package/runtime/lib/{hooks/mainThread.d.ts → core/hooks/mainThreadImpl.d.ts} +2 -1
  10. package/runtime/lib/{hooks/mainThread.js → core/hooks/mainThreadImpl.js} +46 -35
  11. package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -0
  12. package/runtime/lib/{hooks → core/hooks}/react.js +1 -1
  13. package/runtime/lib/core/hooks/react.js.map +1 -0
  14. package/runtime/lib/{hooks → core/hooks}/useLynxGlobalEventListener.d.ts +1 -1
  15. package/runtime/lib/{hooks → core/hooks}/useLynxGlobalEventListener.js +1 -1
  16. package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -0
  17. package/runtime/lib/document.d.ts +4 -4
  18. package/runtime/lib/document.js +14 -12
  19. package/runtime/lib/document.js.map +1 -1
  20. package/runtime/lib/element-template/background/attr-slots.d.ts +2 -0
  21. package/runtime/lib/element-template/background/attr-slots.js +34 -0
  22. package/runtime/lib/element-template/background/attr-slots.js.map +1 -0
  23. package/runtime/lib/element-template/background/commit-context.d.ts +13 -0
  24. package/runtime/lib/element-template/background/commit-context.js +25 -0
  25. package/runtime/lib/element-template/background/commit-context.js.map +1 -0
  26. package/runtime/lib/element-template/background/commit-hook.d.ts +7 -0
  27. package/runtime/lib/element-template/background/commit-hook.js +96 -0
  28. package/runtime/lib/element-template/background/commit-hook.js.map +1 -0
  29. package/runtime/lib/element-template/background/destroy.d.ts +1 -0
  30. package/runtime/lib/element-template/background/destroy.js +17 -0
  31. package/runtime/lib/element-template/background/destroy.js.map +1 -0
  32. package/runtime/lib/element-template/background/document.d.ts +7 -0
  33. package/runtime/lib/element-template/background/document.js +27 -0
  34. package/runtime/lib/element-template/background/document.js.map +1 -0
  35. package/runtime/lib/element-template/background/hydrate.d.ts +4 -0
  36. package/runtime/lib/element-template/background/hydrate.js +219 -0
  37. package/runtime/lib/element-template/background/hydrate.js.map +1 -0
  38. package/runtime/lib/element-template/background/hydration-listener.d.ts +2 -0
  39. package/runtime/lib/element-template/background/hydration-listener.js +93 -0
  40. package/runtime/lib/element-template/background/hydration-listener.js.map +1 -0
  41. package/runtime/lib/element-template/background/instance.d.ts +39 -0
  42. package/runtime/lib/element-template/background/instance.js +349 -0
  43. package/runtime/lib/element-template/background/instance.js.map +1 -0
  44. package/runtime/lib/element-template/background/manager.d.ts +10 -0
  45. package/runtime/lib/element-template/background/manager.js +60 -0
  46. package/runtime/lib/element-template/background/manager.js.map +1 -0
  47. package/runtime/lib/element-template/client/root.d.ts +36 -0
  48. package/runtime/lib/element-template/client/root.js +33 -0
  49. package/runtime/lib/element-template/client/root.js.map +1 -0
  50. package/runtime/lib/element-template/debug/alog.d.ts +34 -0
  51. package/runtime/lib/element-template/debug/alog.js +93 -0
  52. package/runtime/lib/element-template/debug/alog.js.map +1 -0
  53. package/runtime/lib/element-template/debug/elementPAPICall.d.ts +1 -0
  54. package/runtime/lib/element-template/debug/elementPAPICall.js +75 -0
  55. package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -0
  56. package/runtime/lib/element-template/debug/profile.d.ts +3 -0
  57. package/runtime/lib/element-template/debug/profile.js +141 -0
  58. package/runtime/lib/element-template/debug/profile.js.map +1 -0
  59. package/runtime/lib/element-template/hooks/react.d.ts +14 -0
  60. package/runtime/lib/element-template/hooks/react.js +24 -0
  61. package/runtime/lib/element-template/hooks/react.js.map +1 -0
  62. package/runtime/lib/element-template/index.d.ts +7 -0
  63. package/runtime/lib/element-template/index.js +45 -0
  64. package/runtime/lib/element-template/index.js.map +1 -0
  65. package/runtime/lib/element-template/internal.d.ts +6 -0
  66. package/runtime/lib/element-template/internal.js +44 -0
  67. package/runtime/lib/element-template/internal.js.map +1 -0
  68. package/runtime/lib/element-template/jsx-dev-runtime/index.d.ts +1 -0
  69. package/runtime/lib/element-template/jsx-dev-runtime/index.js +5 -0
  70. package/runtime/lib/element-template/jsx-dev-runtime/index.js.map +1 -0
  71. package/runtime/lib/element-template/jsx-runtime/index.d.ts +19 -0
  72. package/runtime/lib/element-template/jsx-runtime/index.js +60 -0
  73. package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -0
  74. package/runtime/lib/element-template/lynx/env.js +89 -0
  75. package/runtime/lib/element-template/lynx/env.js.map +1 -0
  76. package/runtime/lib/element-template/lynx/performance.d.ts +23 -0
  77. package/runtime/lib/element-template/lynx/performance.js +135 -0
  78. package/runtime/lib/element-template/lynx/performance.js.map +1 -0
  79. package/runtime/lib/element-template/native/callDestroyLifetimeFun.d.ts +1 -0
  80. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +8 -0
  81. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -0
  82. package/runtime/lib/element-template/native/index.d.ts +1 -0
  83. package/runtime/lib/element-template/native/index.js +53 -0
  84. package/runtime/lib/element-template/native/index.js.map +1 -0
  85. package/runtime/lib/element-template/native/main-thread-api.js +27 -0
  86. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -0
  87. package/runtime/lib/element-template/native/mts-destroy.d.ts +3 -0
  88. package/runtime/lib/element-template/native/mts-destroy.js +37 -0
  89. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -0
  90. package/runtime/lib/element-template/native/patch-listener.d.ts +2 -0
  91. package/runtime/lib/element-template/native/patch-listener.js +66 -0
  92. package/runtime/lib/element-template/native/patch-listener.js.map +1 -0
  93. package/runtime/lib/element-template/prop-adapters/event-value.d.ts +1 -0
  94. package/runtime/lib/element-template/prop-adapters/event-value.js +7 -0
  95. package/runtime/lib/element-template/prop-adapters/event-value.js.map +1 -0
  96. package/runtime/lib/element-template/prop-adapters/event.d.ts +7 -0
  97. package/runtime/lib/element-template/prop-adapters/event.js +61 -0
  98. package/runtime/lib/element-template/prop-adapters/event.js.map +1 -0
  99. package/runtime/lib/element-template/prop-adapters/spread.d.ts +5 -0
  100. package/runtime/lib/element-template/prop-adapters/spread.js +45 -0
  101. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -0
  102. package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +4 -0
  103. package/runtime/lib/element-template/protocol/lifecycle-constant.js +9 -0
  104. package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -0
  105. package/runtime/lib/element-template/protocol/opcodes.d.ts +7 -0
  106. package/runtime/lib/element-template/protocol/opcodes.js +10 -0
  107. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -0
  108. package/runtime/lib/element-template/protocol/types.d.ts +50 -0
  109. package/runtime/lib/element-template/protocol/types.js +5 -0
  110. package/runtime/lib/element-template/protocol/types.js.map +1 -0
  111. package/runtime/lib/element-template/runtime/components/slot.js +11 -0
  112. package/runtime/lib/element-template/runtime/components/slot.js.map +1 -0
  113. package/runtime/lib/element-template/runtime/page/page.d.ts +2 -0
  114. package/runtime/lib/element-template/runtime/page/page.js +8 -0
  115. package/runtime/lib/element-template/runtime/page/page.js.map +1 -0
  116. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +10 -0
  117. package/runtime/lib/element-template/runtime/page/root-instance.js +17 -0
  118. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -0
  119. package/runtime/lib/element-template/runtime/patch.d.ts +3 -0
  120. package/runtime/lib/element-template/runtime/patch.js +145 -0
  121. package/runtime/lib/element-template/runtime/patch.js.map +1 -0
  122. package/runtime/lib/element-template/runtime/render/render-main-thread.js +53 -0
  123. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -0
  124. package/runtime/lib/element-template/runtime/render/render-opcodes.d.ts +4 -0
  125. package/runtime/lib/element-template/runtime/render/render-opcodes.js +134 -0
  126. package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -0
  127. package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +14 -0
  128. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +272 -0
  129. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -0
  130. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +11 -0
  131. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +23 -0
  132. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -0
  133. package/runtime/lib/element-template/runtime/template/handle.d.ts +5 -0
  134. package/runtime/lib/element-template/runtime/template/handle.js +23 -0
  135. package/runtime/lib/element-template/runtime/template/handle.js.map +1 -0
  136. package/runtime/lib/element-template/runtime/template/registry.d.ts +13 -0
  137. package/runtime/lib/element-template/runtime/template/registry.js +46 -0
  138. package/runtime/lib/element-template/runtime/template/registry.js.map +1 -0
  139. package/runtime/lib/index.d.ts +7 -5
  140. package/runtime/lib/index.js +9 -6
  141. package/runtime/lib/index.js.map +1 -1
  142. package/runtime/lib/internal.d.ts +22 -20
  143. package/runtime/lib/internal.js +26 -23
  144. package/runtime/lib/internal.js.map +1 -1
  145. package/runtime/lib/lynx-api.d.ts +5 -5
  146. package/runtime/lib/lynx-api.js +9 -9
  147. package/runtime/lib/lynx-api.js.map +1 -1
  148. package/runtime/lib/lynx.d.ts +2 -2
  149. package/runtime/lib/lynx.js +17 -17
  150. package/runtime/lib/lynx.js.map +1 -1
  151. package/runtime/lib/root.d.ts +2 -2
  152. package/runtime/lib/root.js +2 -2
  153. package/runtime/lib/root.js.map +1 -1
  154. package/runtime/lib/{debug → shared}/component-stack.js +1 -1
  155. package/runtime/lib/shared/component-stack.js.map +1 -0
  156. package/runtime/lib/{debug → shared}/profile.js +6 -4
  157. package/runtime/lib/shared/profile.js.map +1 -0
  158. package/runtime/lib/{renderToOpcodes/constants.js → shared/render-constants.js} +1 -1
  159. package/runtime/lib/shared/render-constants.js.map +1 -0
  160. package/runtime/lib/{alog → snapshot/alog}/elementPAPICall.js +1 -1
  161. package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -0
  162. package/runtime/lib/snapshot/alog/index.js.map +1 -0
  163. package/runtime/lib/{alog → snapshot/alog}/render.js +2 -2
  164. package/runtime/lib/snapshot/alog/render.js.map +1 -0
  165. package/runtime/lib/snapshot/compat/componentIs.js.map +1 -0
  166. package/runtime/lib/{compat → snapshot/compat}/initData.d.ts +2 -2
  167. package/runtime/lib/{compat → snapshot/compat}/initData.js +1 -1
  168. package/runtime/lib/snapshot/compat/initData.js.map +1 -0
  169. package/runtime/lib/snapshot/compat/lynxComponent.js.map +1 -0
  170. package/runtime/lib/snapshot/debug/debug.js.map +1 -0
  171. package/runtime/lib/snapshot/debug/describeInvalidValue.js.map +1 -0
  172. package/runtime/lib/snapshot/debug/formatPatch.js.map +1 -0
  173. package/runtime/lib/snapshot/debug/printSnapshot.js.map +1 -0
  174. package/runtime/lib/{debug → snapshot/debug}/profileHooks.js +2 -2
  175. package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -0
  176. package/runtime/lib/{debug → snapshot/debug}/vnodeSource.js +1 -1
  177. package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -0
  178. package/runtime/lib/{gesture → snapshot/gesture}/processGesture.d.ts +2 -0
  179. package/runtime/lib/{gesture → snapshot/gesture}/processGesture.js +40 -3
  180. package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -0
  181. package/runtime/lib/snapshot/gesture/processGestureBagkround.d.ts +9 -0
  182. package/runtime/lib/snapshot/gesture/processGestureBagkround.js +80 -0
  183. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +1 -0
  184. package/runtime/lib/snapshot/gesture/types.js.map +1 -0
  185. package/runtime/lib/snapshot/index.d.ts +1 -4
  186. package/runtime/lib/snapshot/index.js +2 -5
  187. package/runtime/lib/snapshot/index.js.map +1 -1
  188. package/runtime/lib/{legacy-react-runtime → snapshot/legacy-react-runtime}/index.d.ts +2 -2
  189. package/runtime/lib/{legacy-react-runtime → snapshot/legacy-react-runtime}/index.js +2 -2
  190. package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +1 -0
  191. package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -0
  192. package/runtime/lib/{lifecycle → snapshot/lifecycle}/destroy.js +2 -2
  193. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -0
  194. package/runtime/lib/snapshot/lifecycle/event/delayEvents.js.map +1 -0
  195. package/runtime/lib/snapshot/lifecycle/event/delayLifecycleEvents.js.map +1 -0
  196. package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/jsReady.js +2 -2
  197. package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +1 -0
  198. package/runtime/lib/{lifecycle → snapshot/lifecycle}/isRendering.js +2 -2
  199. package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -0
  200. package/runtime/lib/snapshot/lifecycle/pass.js.map +1 -0
  201. package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/commit.js +3 -3
  202. package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -0
  203. package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -0
  204. package/runtime/lib/snapshot/lifecycle/patch/globalState.js.map +1 -0
  205. package/runtime/lib/snapshot/lifecycle/patch/isMainThreadHydrating.js.map +1 -0
  206. package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.d.ts +15 -0
  207. package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js +102 -0
  208. package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js.map +1 -0
  209. package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatch.d.ts +2 -0
  210. package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatch.js +27 -2
  211. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -0
  212. package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatchApply.js +28 -0
  213. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -0
  214. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -0
  215. package/runtime/lib/{lifecycle → snapshot/lifecycle}/ref/delay.d.ts +1 -0
  216. package/runtime/lib/{lifecycle → snapshot/lifecycle}/ref/delay.js +5 -3
  217. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -0
  218. package/runtime/lib/{lifecycle → snapshot/lifecycle}/reload.js +3 -3
  219. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -0
  220. package/runtime/lib/snapshot/lifecycle/render.d.ts +2 -0
  221. package/runtime/lib/{lifecycle → snapshot/lifecycle}/render.js +2 -2
  222. package/runtime/lib/snapshot/lifecycle/render.js.map +1 -0
  223. package/runtime/lib/{list → snapshot/list}/list.js +5 -2
  224. package/runtime/lib/snapshot/list/list.js.map +1 -0
  225. package/runtime/lib/{list → snapshot/list}/listUpdateInfo.js +1 -1
  226. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -0
  227. package/runtime/lib/snapshot/list/pendingListUpdates.js.map +1 -0
  228. package/runtime/lib/snapshot/lynx/calledByNative.d.ts +2 -0
  229. package/runtime/lib/{lynx → snapshot/lynx}/calledByNative.js +2 -2
  230. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -0
  231. package/runtime/lib/{lynx → snapshot/lynx}/component.js +1 -1
  232. package/runtime/lib/snapshot/lynx/component.js.map +1 -0
  233. package/runtime/lib/snapshot/lynx/dynamic-js.js.map +1 -0
  234. package/runtime/lib/snapshot/lynx/element.d.ts +6 -0
  235. package/runtime/lib/snapshot/lynx/element.js +35 -0
  236. package/runtime/lib/snapshot/lynx/element.js.map +1 -0
  237. package/runtime/lib/snapshot/lynx/env.d.ts +1 -0
  238. package/runtime/lib/{lynx → snapshot/lynx}/env.js +1 -4
  239. package/runtime/lib/snapshot/lynx/env.js.map +1 -0
  240. package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -0
  241. package/runtime/lib/snapshot/lynx/lazy-bundle.js.map +1 -0
  242. package/runtime/lib/snapshot/lynx/nodesRef.d.ts +6 -0
  243. package/runtime/lib/snapshot/lynx/nodesRef.js +31 -0
  244. package/runtime/lib/snapshot/lynx/nodesRef.js.map +1 -0
  245. package/runtime/lib/{lynx → snapshot/lynx}/performance.js +2 -2
  246. package/runtime/lib/snapshot/lynx/performance.js.map +1 -0
  247. package/runtime/lib/snapshot/lynx/portals.d.ts +9 -0
  248. package/runtime/lib/snapshot/lynx/portals.js +120 -0
  249. package/runtime/lib/snapshot/lynx/portals.js.map +1 -0
  250. package/runtime/lib/snapshot/lynx/portalsPending.d.ts +10 -0
  251. package/runtime/lib/snapshot/lynx/portalsPending.js +38 -0
  252. package/runtime/lib/snapshot/lynx/portalsPending.js.map +1 -0
  253. package/runtime/lib/{lynx → snapshot/lynx}/runWithForce.js +2 -2
  254. package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -0
  255. package/runtime/lib/{lynx → snapshot/lynx}/suspense.js +27 -17
  256. package/runtime/lib/snapshot/lynx/suspense.js.map +1 -0
  257. package/runtime/lib/{lynx → snapshot/lynx}/tt.js +3 -3
  258. package/runtime/lib/snapshot/lynx/tt.js.map +1 -0
  259. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/hydrate.js +22 -5
  260. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -0
  261. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/index.js +35 -14
  262. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -0
  263. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/opcodes.js +5 -3
  264. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -0
  265. package/runtime/lib/snapshot/{backgroundSnapshot.d.ts → snapshot/backgroundSnapshot.d.ts} +2 -1
  266. package/runtime/lib/snapshot/{backgroundSnapshot.js → snapshot/backgroundSnapshot.js} +101 -73
  267. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -0
  268. package/runtime/lib/snapshot/{constants.d.ts → snapshot/constants.d.ts} +4 -0
  269. package/runtime/lib/snapshot/{constants.js → snapshot/constants.js} +4 -0
  270. package/runtime/lib/snapshot/snapshot/constants.js.map +1 -0
  271. package/runtime/lib/snapshot/{definition.d.ts → snapshot/definition.d.ts} +2 -0
  272. package/runtime/lib/snapshot/{definition.js → snapshot/definition.js} +55 -3
  273. package/runtime/lib/snapshot/snapshot/definition.js.map +1 -0
  274. package/runtime/lib/snapshot/{dynamicPartType.d.ts → snapshot/dynamicPartType.d.ts} +14 -0
  275. package/runtime/lib/snapshot/{dynamicPartType.js → snapshot/dynamicPartType.js} +14 -0
  276. package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -0
  277. package/runtime/lib/snapshot/{event.d.ts → snapshot/event.d.ts} +1 -1
  278. package/runtime/lib/snapshot/{event.js → snapshot/event.js} +0 -4
  279. package/runtime/lib/snapshot/snapshot/event.js.map +1 -0
  280. package/runtime/lib/snapshot/{gesture.js → snapshot/gesture.js} +9 -3
  281. package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -0
  282. package/runtime/lib/snapshot/snapshot/index.d.ts +4 -0
  283. package/runtime/lib/snapshot/snapshot/index.js +8 -0
  284. package/runtime/lib/snapshot/snapshot/index.js.map +1 -0
  285. package/runtime/lib/snapshot/snapshot/list.js.map +1 -0
  286. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -0
  287. package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.d.ts +14 -0
  288. package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js +27 -0
  289. package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js.map +1 -0
  290. package/runtime/lib/snapshot/{ref.d.ts → snapshot/ref.d.ts} +1 -0
  291. package/runtime/lib/snapshot/{ref.js → snapshot/ref.js} +13 -1
  292. package/runtime/lib/snapshot/snapshot/ref.js.map +1 -0
  293. package/runtime/lib/snapshot/{snapshot.d.ts → snapshot/snapshot.d.ts} +1 -0
  294. package/runtime/lib/snapshot/{snapshot.js → snapshot/snapshot.js} +90 -11
  295. package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -0
  296. package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -0
  297. package/runtime/lib/snapshot/{spread.d.ts → snapshot/spread.d.ts} +1 -1
  298. package/runtime/lib/snapshot/{spread.js → snapshot/spread.js} +35 -4
  299. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -0
  300. package/runtime/lib/snapshot/{types.d.ts → snapshot/types.d.ts} +1 -0
  301. package/runtime/lib/snapshot/snapshot/types.js.map +1 -0
  302. package/runtime/lib/snapshot/{utils.d.ts → snapshot/utils.d.ts} +1 -3
  303. package/runtime/lib/snapshot/{utils.js → snapshot/utils.js} +5 -0
  304. package/runtime/lib/snapshot/snapshot/utils.js.map +1 -0
  305. package/runtime/lib/snapshot/{workletEvent.d.ts → snapshot/workletEvent.d.ts} +1 -1
  306. package/runtime/lib/snapshot/{workletEvent.js → snapshot/workletEvent.js} +10 -5
  307. package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -0
  308. package/runtime/lib/snapshot/{workletRef.d.ts → snapshot/workletRef.d.ts} +1 -1
  309. package/runtime/lib/snapshot/{workletRef.js → snapshot/workletRef.js} +6 -3
  310. package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -0
  311. package/runtime/lib/snapshot/worklet/call/delayedRunOnMainThreadData.js.map +1 -0
  312. package/runtime/lib/snapshot/worklet/call/execMap.js.map +1 -0
  313. package/runtime/lib/snapshot/worklet/call/functionCall.js.map +1 -0
  314. package/runtime/lib/snapshot/worklet/call/runOnBackground.js.map +1 -0
  315. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -0
  316. package/runtime/lib/snapshot/worklet/call/transformToWorklet.js.map +1 -0
  317. package/runtime/lib/snapshot/worklet/ctx.d.ts +1 -0
  318. package/runtime/lib/snapshot/worklet/ctx.js.map +1 -0
  319. package/runtime/lib/snapshot/worklet/destroy.js.map +1 -0
  320. package/runtime/lib/{worklet → snapshot/worklet}/functionality.js +1 -1
  321. package/runtime/lib/snapshot/worklet/functionality.js.map +1 -0
  322. package/runtime/lib/snapshot/worklet/hmr.js.map +1 -0
  323. package/runtime/lib/snapshot/worklet/indexMap.js.map +1 -0
  324. package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -0
  325. package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRef.js +1 -1
  326. package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +1 -0
  327. package/runtime/lib/snapshot/worklet/ref/workletRefPool.js.map +1 -0
  328. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  329. package/runtime/lib/utils.js +1 -1
  330. package/runtime/lib/utils.js.map +1 -1
  331. package/runtime/lib/worklet-runtime/bindings/observers.d.ts +1 -0
  332. package/runtime/lib/worklet-runtime/bindings/observers.js +5 -3
  333. package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
  334. package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -1
  335. package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
  336. package/runtime/lib/worklet-runtime/hydrate.js +1 -1
  337. package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
  338. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +1 -0
  339. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +5 -0
  340. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  341. package/runtime/lib/worklet-runtime/workletRuntime.js +1 -2
  342. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  343. package/runtime/worklet-runtime/dev.js +8 -4
  344. package/runtime/worklet-runtime/main.js +1 -1
  345. package/testing-library/dist/env/index.js +25 -7
  346. package/testing-library/dist/fire-event.d.ts +21 -7
  347. package/testing-library/dist/index.d.ts +2 -0
  348. package/testing-library/dist/pure.js +29 -11
  349. package/testing-library/dist/setupFiles/common/runtime-setup.js +14 -49
  350. package/testing-library/dist/type-entry/index.js +0 -0
  351. package/transform/dist/wasm.cjs +1274 -665
  352. package/transform/index.d.ts +28 -1
  353. package/types/react.docs.d.ts +9 -1
  354. package/refresh/.gitignore +0 -1
  355. package/refresh/.npmignore +0 -3
  356. package/refresh/.turbo/turbo-build.log +0 -12
  357. package/refresh/package.json +0 -20
  358. package/refresh/rslib.config.ts +0 -24
  359. package/refresh/tsconfig.json +0 -4
  360. package/refresh/turbo.json +0 -15
  361. package/runtime/lib/alog/elementPAPICall.js.map +0 -1
  362. package/runtime/lib/alog/index.js.map +0 -1
  363. package/runtime/lib/alog/render.js.map +0 -1
  364. package/runtime/lib/compat/componentIs.js.map +0 -1
  365. package/runtime/lib/compat/initData.js.map +0 -1
  366. package/runtime/lib/compat/lynxComponent.js.map +0 -1
  367. package/runtime/lib/debug/component-stack.js.map +0 -1
  368. package/runtime/lib/debug/debug.js.map +0 -1
  369. package/runtime/lib/debug/describeInvalidValue.js.map +0 -1
  370. package/runtime/lib/debug/formatPatch.js.map +0 -1
  371. package/runtime/lib/debug/printSnapshot.js.map +0 -1
  372. package/runtime/lib/debug/profile.js.map +0 -1
  373. package/runtime/lib/debug/profileHooks.js.map +0 -1
  374. package/runtime/lib/debug/vnodeSource.js.map +0 -1
  375. package/runtime/lib/gesture/processGesture.js.map +0 -1
  376. package/runtime/lib/gesture/processGestureBagkround.d.ts +0 -2
  377. package/runtime/lib/gesture/processGestureBagkround.js +0 -19
  378. package/runtime/lib/gesture/processGestureBagkround.js.map +0 -1
  379. package/runtime/lib/gesture/types.js.map +0 -1
  380. package/runtime/lib/hooks/mainThread.js.map +0 -1
  381. package/runtime/lib/hooks/react.js.map +0 -1
  382. package/runtime/lib/hooks/useLynxGlobalEventListener.js.map +0 -1
  383. package/runtime/lib/legacy-react-runtime/index.js.map +0 -1
  384. package/runtime/lib/lifecycle/constant.js.map +0 -1
  385. package/runtime/lib/lifecycle/destroy.js.map +0 -1
  386. package/runtime/lib/lifecycle/event/delayEvents.js.map +0 -1
  387. package/runtime/lib/lifecycle/event/delayLifecycleEvents.js.map +0 -1
  388. package/runtime/lib/lifecycle/event/jsReady.js.map +0 -1
  389. package/runtime/lib/lifecycle/isRendering.js.map +0 -1
  390. package/runtime/lib/lifecycle/pass.js.map +0 -1
  391. package/runtime/lib/lifecycle/patch/commit.js.map +0 -1
  392. package/runtime/lib/lifecycle/patch/error.js.map +0 -1
  393. package/runtime/lib/lifecycle/patch/globalState.js.map +0 -1
  394. package/runtime/lib/lifecycle/patch/isMainThreadHydrating.js.map +0 -1
  395. package/runtime/lib/lifecycle/patch/snapshotPatch.js.map +0 -1
  396. package/runtime/lib/lifecycle/patch/snapshotPatchApply.js.map +0 -1
  397. package/runtime/lib/lifecycle/patch/updateMainThread.js.map +0 -1
  398. package/runtime/lib/lifecycle/ref/delay.js.map +0 -1
  399. package/runtime/lib/lifecycle/reload.js.map +0 -1
  400. package/runtime/lib/lifecycle/render.js.map +0 -1
  401. package/runtime/lib/list/list.js.map +0 -1
  402. package/runtime/lib/list/listUpdateInfo.js.map +0 -1
  403. package/runtime/lib/list/pendingListUpdates.js.map +0 -1
  404. package/runtime/lib/lynx/calledByNative.js.map +0 -1
  405. package/runtime/lib/lynx/component.js.map +0 -1
  406. package/runtime/lib/lynx/dynamic-js.js.map +0 -1
  407. package/runtime/lib/lynx/env.js.map +0 -1
  408. package/runtime/lib/lynx/injectLepusMethods.js.map +0 -1
  409. package/runtime/lib/lynx/lazy-bundle.js.map +0 -1
  410. package/runtime/lib/lynx/performance.js.map +0 -1
  411. package/runtime/lib/lynx/runWithForce.js.map +0 -1
  412. package/runtime/lib/lynx/suspense.js.map +0 -1
  413. package/runtime/lib/lynx/tt.js.map +0 -1
  414. package/runtime/lib/renderToOpcodes/constants.js.map +0 -1
  415. package/runtime/lib/renderToOpcodes/hydrate.js.map +0 -1
  416. package/runtime/lib/renderToOpcodes/index.js.map +0 -1
  417. package/runtime/lib/renderToOpcodes/opcodes.js.map +0 -1
  418. package/runtime/lib/snapshot/backgroundSnapshot.js.map +0 -1
  419. package/runtime/lib/snapshot/constants.js.map +0 -1
  420. package/runtime/lib/snapshot/definition.js.map +0 -1
  421. package/runtime/lib/snapshot/dynamicPartType.js.map +0 -1
  422. package/runtime/lib/snapshot/event.js.map +0 -1
  423. package/runtime/lib/snapshot/gesture.js.map +0 -1
  424. package/runtime/lib/snapshot/list.js.map +0 -1
  425. package/runtime/lib/snapshot/platformInfo.js.map +0 -1
  426. package/runtime/lib/snapshot/ref.js.map +0 -1
  427. package/runtime/lib/snapshot/snapshot.js.map +0 -1
  428. package/runtime/lib/snapshot/snapshotInstanceHydrationMap.js.map +0 -1
  429. package/runtime/lib/snapshot/spread.js.map +0 -1
  430. package/runtime/lib/snapshot/types.js.map +0 -1
  431. package/runtime/lib/snapshot/utils.js.map +0 -1
  432. package/runtime/lib/snapshot/workletEvent.js.map +0 -1
  433. package/runtime/lib/snapshot/workletRef.js.map +0 -1
  434. package/runtime/lib/worklet/call/delayedRunOnMainThreadData.js.map +0 -1
  435. package/runtime/lib/worklet/call/execMap.js.map +0 -1
  436. package/runtime/lib/worklet/call/functionCall.js.map +0 -1
  437. package/runtime/lib/worklet/call/runOnBackground.js.map +0 -1
  438. package/runtime/lib/worklet/call/runOnMainThread.js.map +0 -1
  439. package/runtime/lib/worklet/call/transformToWorklet.js.map +0 -1
  440. package/runtime/lib/worklet/ctx.js.map +0 -1
  441. package/runtime/lib/worklet/destroy.js.map +0 -1
  442. package/runtime/lib/worklet/functionality.js.map +0 -1
  443. package/runtime/lib/worklet/hmr.js.map +0 -1
  444. package/runtime/lib/worklet/indexMap.js.map +0 -1
  445. package/runtime/lib/worklet/ref/updateInitValue.js.map +0 -1
  446. package/runtime/lib/worklet/ref/workletRef.js.map +0 -1
  447. package/runtime/lib/worklet/ref/workletRefPool.js.map +0 -1
  448. package/testing-library/README.md +0 -109
  449. /package/runtime/lib/{hooks → core/hooks}/react.d.ts +0 -0
  450. /package/runtime/lib/{lynx → element-template/lynx}/env.d.ts +0 -0
  451. /package/runtime/lib/{lynx/calledByNative.d.ts → element-template/native/main-thread-api.d.ts} +0 -0
  452. /package/runtime/lib/{lynx/component.d.ts → element-template/runtime/components/slot.d.ts} +0 -0
  453. /package/runtime/lib/{lifecycle/render.d.ts → element-template/runtime/render/render-main-thread.d.ts} +0 -0
  454. /package/runtime/lib/{debug → shared}/component-stack.d.ts +0 -0
  455. /package/runtime/lib/{debug → shared}/profile.d.ts +0 -0
  456. /package/runtime/lib/{renderToOpcodes/constants.d.ts → shared/render-constants.d.ts} +0 -0
  457. /package/runtime/lib/{alog → snapshot/alog}/elementPAPICall.d.ts +0 -0
  458. /package/runtime/lib/{alog → snapshot/alog}/index.d.ts +0 -0
  459. /package/runtime/lib/{alog → snapshot/alog}/index.js +0 -0
  460. /package/runtime/lib/{alog → snapshot/alog}/render.d.ts +0 -0
  461. /package/runtime/lib/{compat → snapshot/compat}/componentIs.d.ts +0 -0
  462. /package/runtime/lib/{compat → snapshot/compat}/componentIs.js +0 -0
  463. /package/runtime/lib/{compat → snapshot/compat}/lynxComponent.d.ts +0 -0
  464. /package/runtime/lib/{compat → snapshot/compat}/lynxComponent.js +0 -0
  465. /package/runtime/lib/{debug → snapshot/debug}/debug.d.ts +0 -0
  466. /package/runtime/lib/{debug → snapshot/debug}/debug.js +0 -0
  467. /package/runtime/lib/{debug → snapshot/debug}/describeInvalidValue.d.ts +0 -0
  468. /package/runtime/lib/{debug → snapshot/debug}/describeInvalidValue.js +0 -0
  469. /package/runtime/lib/{debug → snapshot/debug}/formatPatch.d.ts +0 -0
  470. /package/runtime/lib/{debug → snapshot/debug}/formatPatch.js +0 -0
  471. /package/runtime/lib/{debug → snapshot/debug}/printSnapshot.d.ts +0 -0
  472. /package/runtime/lib/{debug → snapshot/debug}/printSnapshot.js +0 -0
  473. /package/runtime/lib/{debug → snapshot/debug}/profileHooks.d.ts +0 -0
  474. /package/runtime/lib/{debug → snapshot/debug}/vnodeSource.d.ts +0 -0
  475. /package/runtime/lib/{gesture → snapshot/gesture}/types.d.ts +0 -0
  476. /package/runtime/lib/{gesture → snapshot/gesture}/types.js +0 -0
  477. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/constant.d.ts +0 -0
  478. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/constant.js +0 -0
  479. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/destroy.d.ts +0 -0
  480. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayEvents.d.ts +0 -0
  481. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayEvents.js +0 -0
  482. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayLifecycleEvents.d.ts +0 -0
  483. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayLifecycleEvents.js +0 -0
  484. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/jsReady.d.ts +0 -0
  485. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/isRendering.d.ts +0 -0
  486. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/pass.d.ts +0 -0
  487. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/pass.js +0 -0
  488. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/commit.d.ts +0 -0
  489. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/error.d.ts +0 -0
  490. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/error.js +0 -0
  491. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/globalState.d.ts +0 -0
  492. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/globalState.js +0 -0
  493. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/isMainThreadHydrating.d.ts +0 -0
  494. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/isMainThreadHydrating.js +0 -0
  495. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatchApply.d.ts +0 -0
  496. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/updateMainThread.d.ts +0 -0
  497. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/updateMainThread.js +0 -0
  498. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/reload.d.ts +0 -0
  499. /package/runtime/lib/{list → snapshot/list}/list.d.ts +0 -0
  500. /package/runtime/lib/{list → snapshot/list}/listUpdateInfo.d.ts +0 -0
  501. /package/runtime/lib/{list → snapshot/list}/pendingListUpdates.d.ts +0 -0
  502. /package/runtime/lib/{list → snapshot/list}/pendingListUpdates.js +0 -0
  503. /package/runtime/lib/{worklet/call/execMap.d.ts → snapshot/lynx/component.d.ts} +0 -0
  504. /package/runtime/lib/{lynx → snapshot/lynx}/dynamic-js.d.ts +0 -0
  505. /package/runtime/lib/{lynx → snapshot/lynx}/dynamic-js.js +0 -0
  506. /package/runtime/lib/{lynx → snapshot/lynx}/injectLepusMethods.d.ts +0 -0
  507. /package/runtime/lib/{lynx → snapshot/lynx}/injectLepusMethods.js +0 -0
  508. /package/runtime/lib/{lynx → snapshot/lynx}/lazy-bundle.d.ts +0 -0
  509. /package/runtime/lib/{lynx → snapshot/lynx}/lazy-bundle.js +0 -0
  510. /package/runtime/lib/{lynx → snapshot/lynx}/performance.d.ts +0 -0
  511. /package/runtime/lib/{lynx → snapshot/lynx}/runWithForce.d.ts +0 -0
  512. /package/runtime/lib/{lynx → snapshot/lynx}/suspense.d.ts +0 -0
  513. /package/runtime/lib/{lynx → snapshot/lynx}/tt.d.ts +0 -0
  514. /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/hydrate.d.ts +0 -0
  515. /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/index.d.ts +0 -0
  516. /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/opcodes.d.ts +0 -0
  517. /package/runtime/lib/snapshot/{gesture.d.ts → snapshot/gesture.d.ts} +0 -0
  518. /package/runtime/lib/snapshot/{list.d.ts → snapshot/list.d.ts} +0 -0
  519. /package/runtime/lib/snapshot/{list.js → snapshot/list.js} +0 -0
  520. /package/runtime/lib/snapshot/{platformInfo.d.ts → snapshot/platformInfo.d.ts} +0 -0
  521. /package/runtime/lib/snapshot/{platformInfo.js → snapshot/platformInfo.js} +0 -0
  522. /package/runtime/lib/snapshot/{snapshotInstanceHydrationMap.d.ts → snapshot/snapshotInstanceHydrationMap.d.ts} +0 -0
  523. /package/runtime/lib/snapshot/{snapshotInstanceHydrationMap.js → snapshot/snapshotInstanceHydrationMap.js} +0 -0
  524. /package/runtime/lib/snapshot/{types.js → snapshot/types.js} +0 -0
  525. /package/runtime/lib/{worklet → snapshot/worklet}/call/delayedRunOnMainThreadData.d.ts +0 -0
  526. /package/runtime/lib/{worklet → snapshot/worklet}/call/delayedRunOnMainThreadData.js +0 -0
  527. /package/runtime/lib/{worklet/call/transformToWorklet.d.ts → snapshot/worklet/call/execMap.d.ts} +0 -0
  528. /package/runtime/lib/{worklet → snapshot/worklet}/call/execMap.js +0 -0
  529. /package/runtime/lib/{worklet → snapshot/worklet}/call/functionCall.d.ts +0 -0
  530. /package/runtime/lib/{worklet → snapshot/worklet}/call/functionCall.js +0 -0
  531. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnBackground.d.ts +0 -0
  532. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnBackground.js +0 -0
  533. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnMainThread.d.ts +0 -0
  534. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnMainThread.js +0 -0
  535. /package/runtime/lib/{worklet/ctx.d.ts → snapshot/worklet/call/transformToWorklet.d.ts} +0 -0
  536. /package/runtime/lib/{worklet → snapshot/worklet}/call/transformToWorklet.js +0 -0
  537. /package/runtime/lib/{worklet → snapshot/worklet}/ctx.js +0 -0
  538. /package/runtime/lib/{worklet → snapshot/worklet}/destroy.d.ts +0 -0
  539. /package/runtime/lib/{worklet → snapshot/worklet}/destroy.js +0 -0
  540. /package/runtime/lib/{worklet → snapshot/worklet}/functionality.d.ts +0 -0
  541. /package/runtime/lib/{worklet → snapshot/worklet}/hmr.d.ts +0 -0
  542. /package/runtime/lib/{worklet → snapshot/worklet}/hmr.js +0 -0
  543. /package/runtime/lib/{worklet → snapshot/worklet}/indexMap.d.ts +0 -0
  544. /package/runtime/lib/{worklet → snapshot/worklet}/indexMap.js +0 -0
  545. /package/runtime/lib/{worklet → snapshot/worklet}/ref/updateInitValue.d.ts +0 -0
  546. /package/runtime/lib/{worklet → snapshot/worklet}/ref/updateInitValue.js +0 -0
  547. /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRef.d.ts +0 -0
  548. /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRefPool.d.ts +0 -0
  549. /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRefPool.js +0 -0
@@ -0,0 +1,96 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { options } from 'preact';
5
+ import { globalCommitContext, resetGlobalCommitContext, takeRemovedSubtreesForCurrentCommit, } from './commit-context.js';
6
+ import { COMMIT } from '../../shared/render-constants.js';
7
+ import { hook } from '../../utils.js';
8
+ import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
9
+ import { profileEnd, profileStart } from '../debug/profile.js';
10
+ import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../lynx/performance.js';
11
+ import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
12
+ let installed = false;
13
+ let hasHydrated = false;
14
+ const scheduledRemovedSubtreeCleanupTimers = new Set();
15
+ export function markElementTemplateHydrated() {
16
+ hasHydrated = true;
17
+ }
18
+ export function isElementTemplateHydrated() {
19
+ return hasHydrated;
20
+ }
21
+ export function resetElementTemplateCommitState() {
22
+ hasHydrated = false;
23
+ resetGlobalCommitContext();
24
+ }
25
+ export function scheduleElementTemplateRemovedSubtreeCleanup(removedSubtrees) {
26
+ if (removedSubtrees.length === 0) {
27
+ return;
28
+ }
29
+ const timer = setTimeout(() => {
30
+ scheduledRemovedSubtreeCleanupTimers.delete(timer);
31
+ for (const root of removedSubtrees) {
32
+ root.tearDown();
33
+ }
34
+ }, 10000);
35
+ scheduledRemovedSubtreeCleanupTimers.add(timer);
36
+ }
37
+ export function cancelElementTemplateRemovedSubtreeCleanup() {
38
+ for (const timer of scheduledRemovedSubtreeCleanupTimers) {
39
+ clearTimeout(timer);
40
+ }
41
+ scheduledRemovedSubtreeCleanupTimers.clear();
42
+ }
43
+ export function installElementTemplateCommitHook() {
44
+ if (installed) {
45
+ return;
46
+ }
47
+ installed = true;
48
+ hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {
49
+ if (__BACKGROUND__ && hasHydrated && globalCommitContext.ops.length > 0) {
50
+ markTimingLegacy('updateDiffVdomEnd');
51
+ markTiming('diffVdomEnd');
52
+ if (__PROFILE__) {
53
+ profileStart('ReactLynx::commitChanges');
54
+ }
55
+ markTiming('packChangesStart');
56
+ if (globalPipelineOptions) {
57
+ globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;
58
+ }
59
+ markTiming('packChangesEnd');
60
+ if (globalPipelineOptions) {
61
+ setPipeline(undefined);
62
+ }
63
+ if (__PROFILE__) {
64
+ profileEnd();
65
+ }
66
+ if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
67
+ console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS update:\n'
68
+ + JSON.stringify({
69
+ ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),
70
+ flushOptions: globalCommitContext.flushOptions,
71
+ flowIds: globalCommitContext.flowIds,
72
+ }, null, 2));
73
+ }
74
+ const removedSubtrees = takeRemovedSubtreesForCurrentCommit();
75
+ try {
76
+ lynx.getCoreContext().dispatchEvent({
77
+ type: ElementTemplateLifecycleConstant.update,
78
+ data: {
79
+ ops: globalCommitContext.ops,
80
+ flushOptions: globalCommitContext.flushOptions,
81
+ flowIds: globalCommitContext.flowIds,
82
+ },
83
+ });
84
+ }
85
+ finally {
86
+ resetGlobalCommitContext();
87
+ // Match Snapshot's cleanup boundary: start the delayed teardown only
88
+ // after the bridge dispatch attempt, so background JS objects are not
89
+ // torn down before main-thread detach observes the same commit.
90
+ scheduleElementTemplateRemovedSubtreeCleanup(removedSubtrees);
91
+ }
92
+ }
93
+ originalCommit?.(vnode, commitQueue);
94
+ });
95
+ }
96
+ //# sourceMappingURL=commit-hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,mCAAmC,GACpC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1G,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAErF,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,MAAM,oCAAoC,GAAG,IAAI,GAAG,EAAiC,CAAC;AAEtF,MAAM,UAAU,2BAA2B;IACzC,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,yB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void;
@@ -0,0 +1,17 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { cancelElementTemplateRemovedSubtreeCleanup, resetElementTemplateCommitState } from './commit-hook.js';
5
+ import { resetElementTemplateHydrationListener } from './hydration-listener.js';
6
+ import { backgroundElementTemplateInstanceManager } from './manager.js';
7
+ import { clearEventState } from '../prop-adapters/event.js';
8
+ export function destroyElementTemplateBackgroundRuntime() {
9
+ resetElementTemplateHydrationListener();
10
+ resetElementTemplateCommitState();
11
+ // Destroy is the only place that may discard delayed removed subtrees instead
12
+ // of letting the Snapshot-aligned timer tear them down later.
13
+ cancelElementTemplateRemovedSubtreeCleanup();
14
+ clearEventState();
15
+ backgroundElementTemplateInstanceManager.clear();
16
+ }
17
+ //# sourceMappingURL=destroy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/element-template/background/destroy.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,0CAA0C,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,UAAU,uCAAuC;IACrD,qCAAqC,EAAE,CAAC;IACxC,+BAA+B,EAAE,CAAC;IAClC,8EAA8E;IAC9E,8DAA8D;IAC9D,0CAA0C,EAAE,CAAC;IAC7C,eAAe,EAAE,CAAC;IAClB,wCAAwC,CAAC,KAAK,EAAE,CAAC;AACnD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { BackgroundElementTemplateInstance } from './instance.js';
2
+ export interface BackgroundElementTemplateDocument {
3
+ createElement(type: string): BackgroundElementTemplateInstance;
4
+ createElementNS(ns: string, type: string): BackgroundElementTemplateInstance;
5
+ createTextNode(text: string): BackgroundElementTemplateInstance;
6
+ }
7
+ export declare function setupBackgroundElementTemplateDocument(): BackgroundElementTemplateDocument;
@@ -0,0 +1,27 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { options } from 'preact';
5
+ import { BUILTIN_RAW_TEXT_TEMPLATE_KEY, BackgroundElementTemplateInstance, BackgroundElementTemplateSlot, } from './instance.js';
6
+ export function setupBackgroundElementTemplateDocument() {
7
+ const doc = {
8
+ createElement(type) {
9
+ if (type === 'slot') {
10
+ return new BackgroundElementTemplateSlot();
11
+ }
12
+ return new BackgroundElementTemplateInstance(type);
13
+ },
14
+ createElementNS(_ns, type) {
15
+ if (type === 'slot') {
16
+ return new BackgroundElementTemplateSlot();
17
+ }
18
+ return new BackgroundElementTemplateInstance(type);
19
+ },
20
+ createTextNode(text) {
21
+ return new BackgroundElementTemplateInstance(BUILTIN_RAW_TEXT_TEMPLATE_KEY, [text]);
22
+ },
23
+ };
24
+ options.document = doc;
25
+ return doc;
26
+ }
27
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/element-template/background/document.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,eAAe,CAAC;AAQvB,MAAM,UAAU,sCAAsC;IACpD,MAAM,GAAG,GAAG;QACV,aAAa,CAAC,IAAY;YACxB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,6BAA6B,EAAE,CAAC;YAC7C,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,eAAe,CAAC,GAAW,EAAE,IAAY;YACvC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,6BAA6B,EAAE,CAAC;YAC7C,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,cAAc,CAAC,IAAY;YACzB,OAAO,IAAI,iCAAiC,CAAC,6BAA6B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;IAEF,OAAO,CAAC,QAAQ,GAAG,GAA0B,CAAC;IAE9C,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { BackgroundElementTemplateInstance } from './instance.js';
2
+ import type { ElementTemplateUpdateCommandStream, SerializedElementTemplate } from '../protocol/types.js';
3
+ export declare function hydrate(serialized: SerializedElementTemplate, instance: BackgroundElementTemplateInstance): ElementTemplateUpdateCommandStream;
4
+ export declare function hydrateIntoContext(serialized: SerializedElementTemplate, instance: BackgroundElementTemplateInstance): void;
@@ -0,0 +1,219 @@
1
+ // Copyright 2025 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { globalCommitContext, markRemovedSubtreeForCurrentCommit, resetGlobalCommitContext } from './commit-context.js';
5
+ import { BUILTIN_RAW_TEXT_TEMPLATE_KEY } from './instance.js';
6
+ import { backgroundElementTemplateInstanceManager } from './manager.js';
7
+ import { isDirectOrDeepEqual } from '../../utils.js';
8
+ import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
9
+ export function hydrate(serialized, instance) {
10
+ resetGlobalCommitContext();
11
+ hydrateIntoContext(serialized, instance);
12
+ return globalCommitContext.ops;
13
+ }
14
+ export function hydrateIntoContext(serialized, instance) {
15
+ hydrateInstance(serialized, instance);
16
+ }
17
+ function hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildren) {
18
+ let lastPlacedIndex = 0;
19
+ const result = {
20
+ hasChanges: false,
21
+ insertions: {},
22
+ insertionCount: 0,
23
+ removals: [],
24
+ moves: {},
25
+ };
26
+ const serializedByTemplateKey = {};
27
+ const serializedCursorByTemplateKey = {};
28
+ for (let i = 0; i < serializedChildren.length; i += 1) {
29
+ const node = serializedChildren[i];
30
+ (serializedByTemplateKey[node.templateKey] ??= []).push([node, i]);
31
+ }
32
+ for (let i = 0; i < backgroundChildren.length; i += 1) {
33
+ const backgroundChild = backgroundChildren[i];
34
+ const serializedCandidates = serializedByTemplateKey[backgroundChild.type];
35
+ const candidateCursor = serializedCursorByTemplateKey[backgroundChild.type] ?? 0;
36
+ const matchedSerialized = serializedCandidates?.[candidateCursor];
37
+ if (matchedSerialized) {
38
+ serializedCursorByTemplateKey[backgroundChild.type] = candidateCursor + 1;
39
+ const oldIndex = matchedSerialized[1];
40
+ hydrateInstance(matchedSerialized[0], backgroundChild);
41
+ if (oldIndex < lastPlacedIndex) {
42
+ result.moves[oldIndex] = { toIndex: i, instance: backgroundChild };
43
+ result.hasChanges = true;
44
+ }
45
+ else {
46
+ lastPlacedIndex = oldIndex;
47
+ }
48
+ }
49
+ else {
50
+ result.insertions[i] = backgroundChild;
51
+ result.insertionCount += 1;
52
+ result.hasChanges = true;
53
+ }
54
+ }
55
+ for (const key in serializedByTemplateKey) {
56
+ const candidates = serializedByTemplateKey[key];
57
+ const candidateCursor = serializedCursorByTemplateKey[key] ?? 0;
58
+ for (let i = candidateCursor; i < candidates.length; i += 1) {
59
+ result.removals.push(candidates[i][1]);
60
+ result.hasChanges = true;
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ function hydrateInstance(serialized, instance) {
66
+ if (serialized.templateKey !== instance.type) {
67
+ if (__DEV__) {
68
+ lynx.reportError(new Error(`ElementTemplate hydrate key mismatch: main='${serialized.templateKey}' background='${instance.type}'.`));
69
+ }
70
+ return;
71
+ }
72
+ const handleId = serialized.uid;
73
+ if (!bindHydrationHandleId(instance, handleId, serialized.templateKey)) {
74
+ return;
75
+ }
76
+ instance.prepareAttributeSlotsForNative();
77
+ hydrateAttributeSlots(handleId, serialized.attributeSlots ?? [], instance.attributeSlots);
78
+ if (serialized.templateKey === BUILTIN_RAW_TEXT_TEMPLATE_KEY) {
79
+ return;
80
+ }
81
+ const serializedElementSlots = serialized.elementSlots ?? [];
82
+ // Snapshot hydrates dynamic children through slot-filtered lists. Keeping ET
83
+ // scoped the same way means a cross-slot candidate is a source remove plus a
84
+ // target create/insert, while same-slot reorder can still stay move-like.
85
+ const slotCount = Math.max(serializedElementSlots.length, instance.elementSlots.length);
86
+ for (let slotId = 0; slotId < slotCount; slotId += 1) {
87
+ const serializedSlot = serializedElementSlots[slotId];
88
+ const backgroundSlot = instance.elementSlots[slotId];
89
+ if (!serializedSlot && !backgroundSlot) {
90
+ continue;
91
+ }
92
+ hydrateElementSlot(instance, slotId, serializedSlot ?? []);
93
+ }
94
+ }
95
+ function hydrateElementSlot(parent, slotId, serializedChildren) {
96
+ const backgroundChildren = parent.elementSlots[slotId] ?? [];
97
+ if (backgroundChildren.length === 0) {
98
+ for (const serialized of serializedChildren) {
99
+ emitSerializedSubtreeRemove(parent, slotId, serialized);
100
+ }
101
+ return;
102
+ }
103
+ const listDiff = hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildren);
104
+ if (!listDiff.hasChanges) {
105
+ return;
106
+ }
107
+ // Hydrate emits patches directly here. Replaying against serialized order
108
+ // keeps insert targets in the main-thread slot without reshaping background.
109
+ const removalIndexes = new Set(listDiff.removals);
110
+ const { insertions, moves } = listDiff;
111
+ const pendingMoves = new Map();
112
+ let serializedCursor = 0;
113
+ let currentSerializedChild = serializedChildren[serializedCursor];
114
+ let newIndex = 0;
115
+ let oldIndex = 0;
116
+ // Insertions are known before replay starts. Moves are counted only when their
117
+ // old serialized position is reached, so the cursor can keep emitting patches
118
+ // even after all serialized children have been consumed.
119
+ let pendingInsertOrMovePatchCount = listDiff.insertionCount;
120
+ while (currentSerializedChild || pendingInsertOrMovePatchCount > 0) {
121
+ let keepCurrentSerializedChild = false;
122
+ if (currentSerializedChild && removalIndexes.has(oldIndex)) {
123
+ emitSerializedSubtreeRemove(parent, slotId, currentSerializedChild);
124
+ }
125
+ else if (currentSerializedChild && moves[oldIndex] !== undefined) {
126
+ const move = moves[oldIndex];
127
+ pendingMoves.set(move.toIndex, move.instance);
128
+ pendingInsertOrMovePatchCount += 1;
129
+ }
130
+ else {
131
+ const beforeChildId = currentSerializedChild ? currentSerializedChild.uid : 0;
132
+ const movedChild = pendingMoves.get(newIndex);
133
+ if (movedChild) {
134
+ keepCurrentSerializedChild = true;
135
+ globalCommitContext.ops.push(ElementTemplateUpdateOps.insertNode, parent.instanceId, slotId, movedChild.instanceId, beforeChildId);
136
+ pendingInsertOrMovePatchCount -= 1;
137
+ }
138
+ else if (insertions[newIndex] !== undefined) {
139
+ const insertedChild = insertions[newIndex];
140
+ keepCurrentSerializedChild = true;
141
+ emitCreateSubtree(insertedChild);
142
+ globalCommitContext.ops.push(ElementTemplateUpdateOps.insertNode, parent.instanceId, slotId, insertedChild.instanceId, beforeChildId);
143
+ pendingInsertOrMovePatchCount -= 1;
144
+ }
145
+ newIndex += 1;
146
+ }
147
+ if (currentSerializedChild && !keepCurrentSerializedChild) {
148
+ currentSerializedChild = serializedChildren[++serializedCursor];
149
+ oldIndex += 1;
150
+ }
151
+ }
152
+ }
153
+ function emitSerializedSubtreeRemove(parent, slotId, serialized) {
154
+ const childId = serialized.uid;
155
+ const existing = backgroundElementTemplateInstanceManager.get(childId);
156
+ // The removed child may no longer have a live background instance in this
157
+ // slot, so serialized data is the source of truth for registry cleanup.
158
+ const removedSubtreeHandleIds = [];
159
+ collectSerializedSubtreeHandleIdsInto(serialized, removedSubtreeHandleIds);
160
+ globalCommitContext.ops.push(ElementTemplateUpdateOps.removeNode, parent.instanceId, slotId, childId, removedSubtreeHandleIds);
161
+ if (existing && !existing.parent) {
162
+ markRemovedSubtreeForCurrentCommit(existing);
163
+ }
164
+ }
165
+ function collectSerializedSubtreeHandleIdsInto(serialized, handles) {
166
+ handles.push(serialized.uid);
167
+ for (const slotChildren of serialized.elementSlots ?? []) {
168
+ if (!slotChildren) {
169
+ continue;
170
+ }
171
+ for (const child of slotChildren) {
172
+ collectSerializedSubtreeHandleIdsInto(child, handles);
173
+ }
174
+ }
175
+ }
176
+ function emitCreateSubtree(node) {
177
+ for (const slotChildren of node.elementSlots) {
178
+ /* v8 ignore start */
179
+ if (!slotChildren) {
180
+ continue;
181
+ }
182
+ /* v8 ignore stop */
183
+ for (const child of slotChildren) {
184
+ emitCreateSubtree(child);
185
+ }
186
+ }
187
+ node.prepareAttributeSlotsForNative();
188
+ node.emitCreate();
189
+ }
190
+ function bindHydrationHandleId(instance, handleId, templateKey) {
191
+ try {
192
+ backgroundElementTemplateInstanceManager.updateId(instance.instanceId, handleId);
193
+ instance.markCreateEmittedForHydration();
194
+ return true;
195
+ }
196
+ catch (error) {
197
+ if (__DEV__) {
198
+ const reason = error instanceof Error ? error.message : String(error);
199
+ lynx.reportError(new Error(`ElementTemplate hydrate received invalid uid ${handleId} for '${templateKey}': ${reason}`));
200
+ }
201
+ return false;
202
+ }
203
+ }
204
+ function hydrateAttributeSlots(handleId, beforeSlots, afterSlots) {
205
+ const slotCount = Math.max(beforeSlots.length, afterSlots.length);
206
+ for (let slotIndex = 0; slotIndex < slotCount; slotIndex += 1) {
207
+ const beforeValue = beforeSlots[slotIndex];
208
+ const afterValue = afterSlots[slotIndex];
209
+ if (isDirectOrDeepEqual(beforeValue, afterValue)) {
210
+ continue;
211
+ }
212
+ if (afterValue === undefined && beforeValue === null) {
213
+ // JSON serialization turns undefined array slots into null on the main-thread payload.
214
+ continue;
215
+ }
216
+ globalCommitContext.ops.push(ElementTemplateUpdateOps.setAttribute, handleId, slotIndex, afterValue ?? null);
217
+ }
218
+ }
219
+ //# sourceMappingURL=hydrate.js.map
@@ -0,0 +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,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAC5B,QAAgB,EAChB,WAAgC,EAChC,UAA+B;IAE/B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAClE,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QAC9D,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,CAAC;YACjD,SAAS;QACX,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACrD,uFAAuF;YACvF,SAAS;QACX,CAAC;QACD,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAC1B,wBAAwB,CAAC,YAAY,EACrC,QAAQ,EACR,SAAS,EACT,UAAU,IAAI,IAAI,CACnB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function installElementTemplateHydrationListener(): void;
2
+ export declare function resetElementTemplateHydrationListener(): void;
@@ -0,0 +1,93 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { globalCommitContext, resetGlobalCommitContext, takeRemovedSubtreesForCurrentCommit, } from './commit-context.js';
5
+ import { markElementTemplateHydrated, resetElementTemplateCommitState, scheduleElementTemplateRemovedSubtreeCleanup, } from './commit-hook.js';
6
+ import { hydrateIntoContext } from './hydrate.js';
7
+ import { BackgroundElementTemplateInstance } from './instance.js';
8
+ import { formatElementTemplateUpdateCommands, printElementTemplateTreeToString } from '../debug/alog.js';
9
+ import { profileEnd, profileStart } from '../debug/profile.js';
10
+ import { PerformanceTimingFlags, PipelineOrigins, beginPipeline, markTiming } from '../lynx/performance.js';
11
+ import { flushPendingEvents } from '../prop-adapters/event.js';
12
+ import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
13
+ import { __root } from '../runtime/page/root-instance.js';
14
+ let listener;
15
+ export function installElementTemplateHydrationListener() {
16
+ resetElementTemplateHydrationListener();
17
+ resetElementTemplateCommitState();
18
+ listener = (event) => {
19
+ const { data } = event;
20
+ if (__PROFILE__) {
21
+ profileStart('ReactLynx::hydrate');
22
+ }
23
+ beginPipeline(true, PipelineOrigins.reactLynxHydrate, PerformanceTimingFlags.reactLynxHydrate);
24
+ markTiming('hydrateParsePayloadStart');
25
+ const instances = data;
26
+ markTiming('hydrateParsePayloadEnd');
27
+ markTiming('diffVdomStart');
28
+ const root = __root;
29
+ resetGlobalCommitContext();
30
+ if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
31
+ console.alog?.('[ReactLynxDebug] ElementTemplate MTS -> BTS hydrate:\n'
32
+ + JSON.stringify({ data: instances }, null, 2));
33
+ console.alog?.('[ReactLynxDebug] BackgroundElementTemplate tree before hydration:\n'
34
+ + printElementTemplateTreeToString(root));
35
+ }
36
+ let after = root.firstChild;
37
+ for (const before of instances) {
38
+ if (!after) {
39
+ break;
40
+ }
41
+ hydrateIntoContext(before, after);
42
+ after = after.nextSibling;
43
+ }
44
+ if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
45
+ console.alog?.('[ReactLynxDebug] BackgroundElementTemplate tree after hydration:\n'
46
+ + printElementTemplateTreeToString(root));
47
+ }
48
+ if (__PROFILE__) {
49
+ profileEnd();
50
+ }
51
+ markTiming('diffVdomEnd');
52
+ markElementTemplateHydrated();
53
+ const hasHydrateUpdate = globalCommitContext.ops.length > 0;
54
+ let didDispatchHydrateUpdate = false;
55
+ if (hasHydrateUpdate) {
56
+ if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
57
+ console.alog?.('[ReactLynxDebug] ElementTemplate hydrate update commands:\n'
58
+ + JSON.stringify({
59
+ ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),
60
+ flushOptions: globalCommitContext.flushOptions,
61
+ flowIds: globalCommitContext.flowIds,
62
+ }, null, 2));
63
+ }
64
+ const removedSubtrees = takeRemovedSubtreesForCurrentCommit();
65
+ try {
66
+ lynx.getCoreContext().dispatchEvent({
67
+ type: ElementTemplateLifecycleConstant.update,
68
+ data: {
69
+ ops: globalCommitContext.ops,
70
+ flushOptions: globalCommitContext.flushOptions,
71
+ flowIds: globalCommitContext.flowIds,
72
+ },
73
+ });
74
+ didDispatchHydrateUpdate = true;
75
+ }
76
+ finally {
77
+ resetGlobalCommitContext();
78
+ scheduleElementTemplateRemovedSubtreeCleanup(removedSubtrees);
79
+ }
80
+ }
81
+ if (!hasHydrateUpdate || didDispatchHydrateUpdate) {
82
+ flushPendingEvents();
83
+ }
84
+ };
85
+ lynx.getCoreContext().addEventListener(ElementTemplateLifecycleConstant.hydrate, listener);
86
+ }
87
+ export function resetElementTemplateHydrationListener() {
88
+ if (listener) {
89
+ lynx.getCoreContext().removeEventListener(ElementTemplateLifecycleConstant.hydrate, listener);
90
+ }
91
+ listener = undefined;
92
+ }
93
+ //# sourceMappingURL=hydration-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydration-listener.js","sourceRoot":"","sources":["../../../src/element-template/background/hydration-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,mCAAmC,GACpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,4CAA4C,GAC7C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,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IAAI,EAAE;wBACJ,GAAG,EAAE,mBAAmB,CAAC,GAAG;wBAC5B,YAAY,EAAE,mBAAmB,CAAC,YAAY;wBAC9C,OAAO,EAAE,mBAAmB,CAAC,OAAO;qBACrC;iBACF,CAAC,CAAC;gBACH,wBAAwB,GAAG,IAAI,CAAC;YAClC,CAAC;oBAAS,CAAC;gBACT,wBAAwB,EAAE,CAAC;gBAC3B,4CAA4C,CAAC,eAAe,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QACD,IAAI,CAAC,gBAAgB,IAAI,wBAAwB,EAAE,CAAC;YAClD,kBAAkB,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,cAAc,EAAE,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,qCAAqC;IACnD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,EAAE,CAAC,mBAAmB,CAAC,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChG,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { SerializableValue } from '../protocol/types.js';
2
+ export declare const BUILTIN_RAW_TEXT_TEMPLATE_KEY = "_et_builtin_raw_text";
3
+ export declare class BackgroundElementTemplateInstance {
4
+ instanceId: number;
5
+ type: string;
6
+ parent: BackgroundElementTemplateInstance | null;
7
+ firstChild: BackgroundElementTemplateInstance | null;
8
+ lastChild: BackgroundElementTemplateInstance | null;
9
+ nextSibling: BackgroundElementTemplateInstance | null;
10
+ previousSibling: BackgroundElementTemplateInstance | null;
11
+ attributeSlots: SerializableValue[];
12
+ elementSlots: BackgroundElementTemplateInstance[][];
13
+ private rawAttributeSlots;
14
+ private hasEmittedCreate;
15
+ get parentNode(): BackgroundElementTemplateInstance | null;
16
+ get childNodes(): BackgroundElementTemplateInstance[];
17
+ nodeType: number;
18
+ constructor(type: string, initialAttributeSlots?: SerializableValue[]);
19
+ emitCreate(): void;
20
+ private isPendingCreate;
21
+ private canEmitPatch;
22
+ appendChild(child: BackgroundElementTemplateInstance): void;
23
+ insertBefore(child: BackgroundElementTemplateInstance, beforeChild: BackgroundElementTemplateInstance | null, silent?: boolean): void;
24
+ removeChild(child: BackgroundElementTemplateInstance, silent?: boolean): void;
25
+ tearDown(): void;
26
+ getRawAttributeSlot(attrSlotIndex: number): unknown;
27
+ markCreateEmittedForHydration(): void;
28
+ prepareAttributeSlotsForNative(): void;
29
+ setAttribute(key: string, value: unknown): void;
30
+ get text(): string;
31
+ set text(value: string);
32
+ get data(): string;
33
+ set data(value: string);
34
+ }
35
+ export declare class BackgroundElementTemplateSlot extends BackgroundElementTemplateInstance {
36
+ partId: number;
37
+ constructor();
38
+ }
39
+ export declare function collectElementTemplateSubtreeHandleIds(root: BackgroundElementTemplateInstance): number[];