@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,349 @@
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 { prepareAttributeSlots as prepareRawAttributeSlots } from './attr-slots.js';
5
+ import { globalCommitContext, markRemovedSubtreeForCurrentCommit } from './commit-context.js';
6
+ import { isElementTemplateHydrated } from './commit-hook.js';
7
+ import { backgroundElementTemplateInstanceManager } from './manager.js';
8
+ import { isDirectOrDeepEqual } from '../../utils.js';
9
+ import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
10
+ function pushOp(...items) {
11
+ globalCommitContext.ops.push(...items);
12
+ }
13
+ export const BUILTIN_RAW_TEXT_TEMPLATE_KEY = '_et_builtin_raw_text';
14
+ function isBuiltinRawTextTemplateKey(type) {
15
+ return type === BUILTIN_RAW_TEXT_TEMPLATE_KEY;
16
+ }
17
+ function stringifyRawTextValue(value) {
18
+ if (typeof value === 'string') {
19
+ return value;
20
+ }
21
+ if (typeof value === 'number' || typeof value === 'boolean') {
22
+ return String(value);
23
+ }
24
+ return '';
25
+ }
26
+ function syncElementSlotChildren(parent, slotId, children) {
27
+ if (!parent || slotId < 0) {
28
+ return;
29
+ }
30
+ parent.elementSlots[slotId] = [...children];
31
+ }
32
+ export class BackgroundElementTemplateInstance {
33
+ instanceId = 0; // Assigned by manager
34
+ type;
35
+ parent = null;
36
+ firstChild = null;
37
+ lastChild = null;
38
+ nextSibling = null;
39
+ previousSibling = null;
40
+ // Shadow State for Hydration
41
+ attributeSlots;
42
+ elementSlots = [];
43
+ rawAttributeSlots;
44
+ hasEmittedCreate = false;
45
+ get parentNode() {
46
+ return this.parent;
47
+ }
48
+ get childNodes() {
49
+ const nodes = [];
50
+ let child = this.firstChild;
51
+ while (child) {
52
+ nodes.push(child);
53
+ child = child.nextSibling;
54
+ }
55
+ return nodes;
56
+ }
57
+ nodeType;
58
+ constructor(type, initialAttributeSlots) {
59
+ this.type = type;
60
+ this.nodeType = isBuiltinRawTextTemplateKey(type) ? 3 : 1;
61
+ backgroundElementTemplateInstanceManager.register(this);
62
+ if (initialAttributeSlots) {
63
+ const preparedSlots = prepareRawAttributeSlots(this.type, this.instanceId, initialAttributeSlots);
64
+ this.attributeSlots = preparedSlots;
65
+ if (preparedSlots !== initialAttributeSlots) {
66
+ this.rawAttributeSlots = initialAttributeSlots;
67
+ }
68
+ }
69
+ else {
70
+ this.attributeSlots = [];
71
+ }
72
+ }
73
+ emitCreate() {
74
+ if (this.hasEmittedCreate) {
75
+ return;
76
+ }
77
+ if (this.instanceId === 0 && __DEV__) {
78
+ lynx.reportError(new Error('ElementTemplate patch has illegal handleId 0.'));
79
+ return;
80
+ }
81
+ pushOp(ElementTemplateUpdateOps.createTemplate, this.instanceId, this.type, null, this.attributeSlots, this.elementSlots.map((children) => children.map((child) => child.instanceId)));
82
+ this.hasEmittedCreate = true;
83
+ }
84
+ isPendingCreate() {
85
+ return this.instanceId > 0 && !this.hasEmittedCreate;
86
+ }
87
+ canEmitPatch() {
88
+ // Background tree construction is local until hydrate binds it to main-thread
89
+ // instances. Only hydrated and already-created owners can emit update ops.
90
+ return isElementTemplateHydrated() && !this.isPendingCreate();
91
+ }
92
+ // DOM API for Preact
93
+ appendChild(child) {
94
+ this.insertBefore(child, null);
95
+ }
96
+ insertBefore(child, beforeChild, silent) {
97
+ if (beforeChild === child) {
98
+ throw new Error('Cannot insert a node before itself');
99
+ }
100
+ if (beforeChild && beforeChild.parent !== this) {
101
+ throw new Error('Reference node is not a child of this parent');
102
+ }
103
+ if (child.parent) {
104
+ child.parent.removeChild(child, true);
105
+ }
106
+ child.parent = this;
107
+ if (beforeChild) {
108
+ child.nextSibling = beforeChild;
109
+ child.previousSibling = beforeChild.previousSibling;
110
+ if (beforeChild.previousSibling) {
111
+ beforeChild.previousSibling.nextSibling = child;
112
+ }
113
+ else {
114
+ this.firstChild = child;
115
+ }
116
+ beforeChild.previousSibling = child;
117
+ }
118
+ else {
119
+ if (this.lastChild) {
120
+ this.lastChild.nextSibling = child;
121
+ child.previousSibling = this.lastChild;
122
+ }
123
+ else {
124
+ this.firstChild = child;
125
+ }
126
+ this.lastChild = child;
127
+ child.nextSibling = null;
128
+ }
129
+ if (child instanceof BackgroundElementTemplateSlot) {
130
+ syncElementSlotChildren(this, child.partId, collectChildren(child));
131
+ }
132
+ if (this instanceof BackgroundElementTemplateSlot) {
133
+ const slotId = this.partId;
134
+ const parent = this.parent;
135
+ if (parent) {
136
+ syncElementSlotChildren(parent, slotId, collectChildren(this));
137
+ }
138
+ if (silent) {
139
+ return;
140
+ }
141
+ if (slotId !== -1 && parent) {
142
+ if (!parent.canEmitPatch()) {
143
+ return;
144
+ }
145
+ const beforeId = beforeChild ? beforeChild.instanceId : 0;
146
+ emitCreateRecursive(child);
147
+ pushOp(ElementTemplateUpdateOps.insertNode, parent.instanceId, slotId, child.instanceId, beforeId);
148
+ }
149
+ return;
150
+ }
151
+ if (silent) {
152
+ return;
153
+ }
154
+ }
155
+ removeChild(child, silent) {
156
+ if (child.parent !== this) {
157
+ throw new Error('Node is not a child of this parent');
158
+ }
159
+ if (child.previousSibling) {
160
+ child.previousSibling.nextSibling = child.nextSibling;
161
+ }
162
+ else {
163
+ this.firstChild = child.nextSibling;
164
+ }
165
+ if (child.nextSibling) {
166
+ child.nextSibling.previousSibling = child.previousSibling;
167
+ }
168
+ else {
169
+ this.lastChild = child.previousSibling;
170
+ }
171
+ child.parent = null;
172
+ child.nextSibling = null;
173
+ child.previousSibling = null;
174
+ if (child instanceof BackgroundElementTemplateSlot && child.partId >= 0) {
175
+ this.elementSlots[child.partId] = [];
176
+ }
177
+ if (this instanceof BackgroundElementTemplateSlot) {
178
+ const slotId = this.partId;
179
+ const parent = this.parent;
180
+ if (parent) {
181
+ syncElementSlotChildren(parent, slotId, collectChildren(this));
182
+ }
183
+ if (silent) {
184
+ return;
185
+ }
186
+ if (slotId !== -1 && parent) {
187
+ if (!parent.canEmitPatch()) {
188
+ if (child.isPendingCreate()) {
189
+ // A never-created subtree has no main-thread registry entry, so it
190
+ // can be released from the background manager without delayed cleanup.
191
+ child.tearDown();
192
+ }
193
+ return;
194
+ }
195
+ pushOp(ElementTemplateUpdateOps.removeNode, parent.instanceId, slotId, child.instanceId, collectElementTemplateSubtreeHandleIds(child));
196
+ // The removed JS object graph may outlive the detach until GC, so keep
197
+ // it pending and tear it down on the Snapshot-aligned delayed boundary.
198
+ markRemovedSubtreeForCurrentCommit(child);
199
+ }
200
+ return;
201
+ }
202
+ if (silent) {
203
+ return;
204
+ }
205
+ }
206
+ tearDown() {
207
+ // Recursively tear down children first
208
+ let child = this.firstChild;
209
+ while (child) {
210
+ const next = child.nextSibling;
211
+ child.tearDown();
212
+ child = next;
213
+ }
214
+ // Clear references
215
+ this.parent = null;
216
+ this.firstChild = null;
217
+ this.lastChild = null;
218
+ this.previousSibling = null;
219
+ this.nextSibling = null;
220
+ this.attributeSlots = [];
221
+ this.rawAttributeSlots = undefined;
222
+ this.elementSlots = [];
223
+ // Remove from manager
224
+ if (this.instanceId) {
225
+ backgroundElementTemplateInstanceManager.values.delete(this.instanceId);
226
+ }
227
+ }
228
+ getRawAttributeSlot(attrSlotIndex) {
229
+ return this.rawAttributeSlots?.[attrSlotIndex] ?? this.attributeSlots[attrSlotIndex];
230
+ }
231
+ markCreateEmittedForHydration() {
232
+ // Hydration binds this object to a template that already exists on the main
233
+ // thread; future updates must treat it as created without emitting create.
234
+ this.hasEmittedCreate = true;
235
+ }
236
+ prepareAttributeSlotsForNative() {
237
+ if (!this.rawAttributeSlots) {
238
+ return;
239
+ }
240
+ this.attributeSlots = prepareRawAttributeSlots(this.type, this.instanceId, this.rawAttributeSlots);
241
+ }
242
+ setAttribute(key, value) {
243
+ if (isBuiltinRawTextTemplateKey(this.type) && (key === '0' || key === 'data')) {
244
+ this.text = String(value);
245
+ }
246
+ else if (key === 'attributeSlots' && Array.isArray(value)) {
247
+ const previousSlots = this.attributeSlots;
248
+ const isHydrated = isElementTemplateHydrated();
249
+ const canEmitPatch = isHydrated && !this.isPendingCreate();
250
+ const nextSlots = prepareRawAttributeSlots(this.type, this.instanceId, value);
251
+ this.rawAttributeSlots = nextSlots === value ? undefined : value;
252
+ const maxLength = Math.max(previousSlots.length, nextSlots.length);
253
+ this.attributeSlots = nextSlots;
254
+ for (let slotIndex = 0; slotIndex < maxLength; slotIndex += 1) {
255
+ const previousValue = previousSlots[slotIndex];
256
+ const nextValue = nextSlots[slotIndex];
257
+ if (isDirectOrDeepEqual(previousValue, nextValue)) {
258
+ continue;
259
+ }
260
+ if (!canEmitPatch) {
261
+ continue;
262
+ }
263
+ pushOp(ElementTemplateUpdateOps.setAttribute, this.instanceId, slotIndex, nextValue ?? null);
264
+ }
265
+ }
266
+ else if (key === 'id' && this instanceof BackgroundElementTemplateSlot) {
267
+ const previousPartId = this.partId;
268
+ this.partId = Number(value);
269
+ if (this.parent && previousPartId >= 0 && previousPartId !== this.partId) {
270
+ this.parent.elementSlots[previousPartId] = [];
271
+ }
272
+ syncElementSlotChildren(this.parent, this.partId, collectChildren(this));
273
+ }
274
+ else {
275
+ return;
276
+ }
277
+ }
278
+ get text() {
279
+ return stringifyRawTextValue(this.attributeSlots[0]);
280
+ }
281
+ set text(value) {
282
+ if (!isBuiltinRawTextTemplateKey(this.type)) {
283
+ return;
284
+ }
285
+ const text = String(value);
286
+ if (this.attributeSlots[0] === text) {
287
+ return;
288
+ }
289
+ this.rawAttributeSlots = undefined;
290
+ this.attributeSlots = [text];
291
+ if (!this.canEmitPatch()) {
292
+ return;
293
+ }
294
+ pushOp(ElementTemplateUpdateOps.setAttribute, this.instanceId, 0, text);
295
+ }
296
+ get data() {
297
+ return this.text;
298
+ }
299
+ set data(value) {
300
+ this.text = value;
301
+ }
302
+ }
303
+ export class BackgroundElementTemplateSlot extends BackgroundElementTemplateInstance {
304
+ partId = -1;
305
+ constructor() {
306
+ super('slot');
307
+ }
308
+ }
309
+ export function collectElementTemplateSubtreeHandleIds(root) {
310
+ const handles = [];
311
+ collectElementTemplateSubtreeHandleIdsImpl(root, handles);
312
+ return handles;
313
+ }
314
+ function collectElementTemplateSubtreeHandleIdsImpl(instance, handles) {
315
+ if (!(instance instanceof BackgroundElementTemplateSlot) && instance.instanceId !== 0) {
316
+ handles.push(instance.instanceId);
317
+ }
318
+ let child = instance.firstChild;
319
+ while (child) {
320
+ collectElementTemplateSubtreeHandleIdsImpl(child, handles);
321
+ child = child.nextSibling;
322
+ }
323
+ }
324
+ function emitCreateRecursive(instance) {
325
+ if (!isElementTemplateHydrated()
326
+ || instance.instanceId < 0
327
+ || instance instanceof BackgroundElementTemplateSlot) {
328
+ return;
329
+ }
330
+ for (const slotChildren of instance.elementSlots) {
331
+ if (!slotChildren) {
332
+ continue;
333
+ }
334
+ for (const child of slotChildren) {
335
+ emitCreateRecursive(child);
336
+ }
337
+ }
338
+ instance.emitCreate();
339
+ }
340
+ function collectChildren(slot) {
341
+ const res = [];
342
+ let child = slot.firstChild;
343
+ while (child) {
344
+ res.push(child);
345
+ child = child.nextSibling;
346
+ }
347
+ return res;
348
+ }
349
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../src/element-template/background/instance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,qBAAqB,IAAI,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,SAAS,MAAM,CAAC,GAAG,KAAyC;IAC1D,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,sBAAsB,CAAC;AAEpE,SAAS,2BAA2B,CAAC,IAAY;IAC/C,OAAO,IAAI,KAAK,6BAA6B,CAAC;AAChD,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAoC;IACjE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAgD,EAChD,MAAc,EACd,QAA6C;IAE7C,IAAI,CAAC,MAAM,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IAC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AAC;QACD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;YACjC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,QAAQ,CAAC,UAAU,EAAE,CAAC;AACxB,CAAC;AAED,SAAS,eAAe,CAAC,IAAmC;IAC1D,MAAM,GAAG,GAAwC,EAAE,CAAC;IACpD,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC;IAC5B,OAAO,KAAK,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { BackgroundElementTemplateInstance } from './instance.js';
2
+ export declare const backgroundElementTemplateInstanceManager: {
3
+ nextId: number;
4
+ values: Map<number, BackgroundElementTemplateInstance>;
5
+ register(instance: BackgroundElementTemplateInstance): void;
6
+ updateId(oldId: number, newId: number): void;
7
+ get(id: number): BackgroundElementTemplateInstance | undefined;
8
+ getRawAttributeValueByEventValue(eventValue: string): unknown;
9
+ clear(): void;
10
+ };
@@ -0,0 +1,60 @@
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
+ export const backgroundElementTemplateInstanceManager = {
5
+ nextId: 0,
6
+ values: new Map(),
7
+ register(instance) {
8
+ instance.instanceId = this.nextId += 1;
9
+ this.values.set(instance.instanceId, instance);
10
+ },
11
+ updateId(oldId, newId) {
12
+ if (!Number.isInteger(newId) || newId === 0) {
13
+ throw new Error(`ElementTemplate handleId must be a non-zero integer, got ${String(newId)}.`);
14
+ }
15
+ const instance = this.values.get(oldId);
16
+ if (!instance) {
17
+ throw new Error(`ElementTemplate instance ${oldId} is not registered.`);
18
+ }
19
+ const existing = this.values.get(newId);
20
+ if (existing && existing !== instance) {
21
+ throw new Error(`ElementTemplate handleId ${newId} is already bound.`);
22
+ }
23
+ if (oldId === newId) {
24
+ return;
25
+ }
26
+ this.values.delete(oldId);
27
+ instance.instanceId = newId;
28
+ this.values.set(newId, instance);
29
+ // DevTools event emission can be added here later
30
+ // if (__DEV__) { ... }
31
+ },
32
+ get(id) {
33
+ return this.values.get(id);
34
+ },
35
+ getRawAttributeValueByEventValue(eventValue) {
36
+ const parts = eventValue?.split(':');
37
+ if (!parts || (parts.length !== 2 && parts.length !== 3)) {
38
+ throw new Error('Invalid ElementTemplate event value: ' + eventValue);
39
+ }
40
+ const instance = this.values.get(Number(parts[0]));
41
+ if (!instance) {
42
+ return null;
43
+ }
44
+ const value = instance.getRawAttributeSlot(Number(parts[1]));
45
+ const spreadKey = parts[2];
46
+ if (!spreadKey) {
47
+ return value;
48
+ }
49
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) {
50
+ return undefined;
51
+ }
52
+ return value[spreadKey];
53
+ },
54
+ clear() {
55
+ // Note: nextId is NOT reset to prevent ID collisions with potentially surviving instances
56
+ // or when the clear is partial/soft reset in some scenarios.
57
+ this.values.clear();
58
+ },
59
+ };
60
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/element-template/background/manager.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,MAAM,CAAC,MAAM,wCAAwC,GAQjD;IACF,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,IAAI,GAAG,EAA6C;IAE5D,QAAQ,CAAC,QAA2C;QAClD,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,QAAQ,CAAC,KAAa,EAAE,KAAa;QACnC,IAAI,CAAC,MAAM,CAA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AC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxE,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAQ,KAAiC,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;IAED,KAAK;QACH,0FAA0F;QAC1F,6DAA6D;QAC7D,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * The default root exported by `@lynx-js/react` for you to render a JSX
4
+ * @public
5
+ */
6
+ export interface Root {
7
+ /**
8
+ * Use this API to pass in your JSX to render
9
+ *
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import { root } from "@lynx-js/react"
14
+ *
15
+ * function App() {
16
+ * // Your app
17
+ * return <view>...</view>
18
+ * }
19
+ *
20
+ * root.render(<App/>);
21
+ * ```
22
+ *
23
+ * @public
24
+ */
25
+ render: (jsx: ReactNode) => void;
26
+ }
27
+ /**
28
+ * The default and only root of ReactLynx for you to render JSX
29
+ * @example
30
+ * ```ts
31
+ * import { root } from "@lynx-js/react"
32
+ * ```
33
+ *
34
+ * @public
35
+ */
36
+ export declare const root: Root;
@@ -0,0 +1,33 @@
1
+ import { render } from 'preact';
2
+ // import { factory, withInitDataInState } from '../../compat/initData.js';
3
+ import { profileEnd, profileStart } from '../debug/profile.js';
4
+ // import { useLynxGlobalEventListener } from '../../core/hooks/useLynxGlobalEventListener.js';
5
+ import { __root } from '../runtime/page/root-instance.js';
6
+ /**
7
+ * The default and only root of ReactLynx for you to render JSX
8
+ * @example
9
+ * ```ts
10
+ * import { root } from "@lynx-js/react"
11
+ * ```
12
+ *
13
+ * @public
14
+ */
15
+ export const root = {
16
+ render: (jsx) => {
17
+ __root.__jsx = jsx;
18
+ if (__BACKGROUND__) {
19
+ if (__PROFILE__) {
20
+ profileStart('ReactLynx::renderBackground');
21
+ }
22
+ render(jsx, __root);
23
+ if (__PROFILE__) {
24
+ profileEnd();
25
+ }
26
+ }
27
+ },
28
+ /* v8 ignore next 3 */
29
+ // registerDataProcessors: (dataProcessorDefinition: DataProcessorDefinition): void => {
30
+ // lynx.registerDataProcessors(dataProcessorDefinition);
31
+ // },
32
+ };
33
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.js","sourceRoot":"","sources":["../../../src/element-template/client/root.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,+FAA+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAkC1D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,MAAM,EAAE,CAAC,GAAc,EAAQ,EAAE;QAC/B,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;QACnB,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,WAAW,EAAE,CAAC;gBAChB,YAAY,CAAC,6BAA6B,CAAC,CAAC;YAC9C,CAAC;YACD,MAAM,CAAC,GAAqB,EAAE,MAAkC,CAAC,CAAC;YAClE,IAAI,WAAW,EAAE,CAAC;gBAChB,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,sBAAsB;IACtB,wFAAwF;IACxF,0DAA0D;IAC1D,KAAK;CACN,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { BackgroundElementTemplateInstance } from '../background/instance.js';
2
+ import type { ElementTemplateUpdateCommandStream } from '../protocol/types.js';
3
+ export type FormattedElementTemplateUpdateCommand = {
4
+ op: 'createTemplate';
5
+ handleId: number;
6
+ templateKey: string;
7
+ bundleUrl: string | null | undefined;
8
+ attributeSlots: unknown;
9
+ elementSlots: unknown;
10
+ } | {
11
+ op: 'setAttribute';
12
+ targetId: number;
13
+ attrSlotIndex: number;
14
+ value: unknown;
15
+ } | {
16
+ op: 'insertNode';
17
+ targetId: number;
18
+ elementSlotIndex: number;
19
+ childId: number;
20
+ referenceId: number;
21
+ } | {
22
+ op: 'removeNode';
23
+ targetId: number;
24
+ elementSlotIndex: number;
25
+ childId: number;
26
+ removedSubtreeHandleIds: number[];
27
+ } | {
28
+ op: 'unknown';
29
+ opcode: unknown;
30
+ index: number;
31
+ remaining: unknown[];
32
+ };
33
+ export declare function formatElementTemplateUpdateCommands(stream: ElementTemplateUpdateCommandStream | undefined): FormattedElementTemplateUpdateCommand[];
34
+ export declare function printElementTemplateTreeToString(root: BackgroundElementTemplateInstance | null | undefined): string;
@@ -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 { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
5
+ export function formatElementTemplateUpdateCommands(stream) {
6
+ if (!Array.isArray(stream)) {
7
+ return [];
8
+ }
9
+ const result = [];
10
+ for (let index = 0; index < stream.length;) {
11
+ const opIndex = index;
12
+ const op = stream[index++];
13
+ switch (op) {
14
+ case ElementTemplateUpdateOps.createTemplate:
15
+ result.push({
16
+ op: 'createTemplate',
17
+ handleId: stream[index++],
18
+ templateKey: stream[index++],
19
+ bundleUrl: stream[index++],
20
+ attributeSlots: stream[index++],
21
+ elementSlots: stream[index++],
22
+ });
23
+ break;
24
+ case ElementTemplateUpdateOps.setAttribute:
25
+ result.push({
26
+ op: 'setAttribute',
27
+ targetId: stream[index++],
28
+ attrSlotIndex: stream[index++],
29
+ value: stream[index++],
30
+ });
31
+ break;
32
+ case ElementTemplateUpdateOps.insertNode:
33
+ result.push({
34
+ op: 'insertNode',
35
+ targetId: stream[index++],
36
+ elementSlotIndex: stream[index++],
37
+ childId: stream[index++],
38
+ referenceId: stream[index++],
39
+ });
40
+ break;
41
+ case ElementTemplateUpdateOps.removeNode:
42
+ result.push({
43
+ op: 'removeNode',
44
+ targetId: stream[index++],
45
+ elementSlotIndex: stream[index++],
46
+ childId: stream[index++],
47
+ removedSubtreeHandleIds: stream[index++],
48
+ });
49
+ break;
50
+ default:
51
+ result.push({
52
+ op: 'unknown',
53
+ opcode: op,
54
+ index: opIndex,
55
+ remaining: stream.slice(index),
56
+ });
57
+ index = stream.length;
58
+ break;
59
+ }
60
+ }
61
+ return result;
62
+ }
63
+ export function printElementTemplateTreeToString(root) {
64
+ if (!root) {
65
+ return '<empty>';
66
+ }
67
+ const lines = [];
68
+ appendInstance(lines, root, 0);
69
+ return lines.join('\n');
70
+ }
71
+ function appendInstance(lines, instance, depth) {
72
+ const indent = ' '.repeat(depth);
73
+ const type = instance.type ?? '<unknown>';
74
+ const instanceId = instance.instanceId ?? '<unknown>';
75
+ lines.push(`${indent}${type}#${instanceId}`);
76
+ if (Array.isArray(instance.attributeSlots) && instance.attributeSlots.length > 0) {
77
+ lines.push(`${indent} attributeSlots: ${JSON.stringify(instance.attributeSlots)}`);
78
+ }
79
+ const elementSlots = Array.isArray(instance.elementSlots) ? instance.elementSlots : [];
80
+ for (let slotIndex = 0; slotIndex < elementSlots.length; slotIndex += 1) {
81
+ const children = elementSlots[slotIndex];
82
+ if (!children || children.length === 0) {
83
+ continue;
84
+ }
85
+ lines.push(`${indent} elementSlots[${slotIndex}]: [${children.map(child => child.instanceId).join(', ')}]`);
86
+ }
87
+ let child = instance.firstChild;
88
+ while (child) {
89
+ appendInstance(lines, child, depth + 1);
90
+ child = child.nextSibling;
91
+ }
92
+ }
93
+ //# sourceMappingURL=alog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alog.js","sourceRoot":"","sources":["../../../src/element-template/debug/alog.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAwClE,MAAM,UAAU,mCAAmC,CACjD,MAAsD;IAEtD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;QAC3C,MAAM,OAAO,GAAG,KAAK,CAAC;QACtB,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,CAA4B,CAAC;QAEtD,QAAQ,EAAE,EAAE,CAAC;YACX,KAAK,wBAAwB,CAAC,cAAc;gBAC1C,MAAM,CAAC,IAAI,CAAC;oBACV,EAAE,EAAE,gBAAgB;oBACpB,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,CAAW;oBACnC,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,CAAW;oBACtC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,CAA8B;oBACvD,cAAc,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;oBAC/B,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;iBAC9B,CAAC,CAAC;gBACH,MAAM;YAER,KAAK,wBAAwB,CAAC,YAAY;gBACxC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