@lynx-js/react 0.120.0 → 0.121.1

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 (350) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/package.json +36 -8
  3. package/runtime/lazy/compat.js +1 -0
  4. package/runtime/lazy/react.js +1 -0
  5. package/runtime/lib/core/commit-context.d.ts +8 -0
  6. package/runtime/lib/core/commit-context.js +18 -0
  7. package/runtime/lib/core/commit-context.js.map +1 -0
  8. package/runtime/lib/core/forceRootRender.d.ts +7 -0
  9. package/runtime/lib/core/forceRootRender.js +40 -0
  10. package/runtime/lib/core/forceRootRender.js.map +1 -0
  11. package/runtime/lib/core/globalProps.d.ts +31 -0
  12. package/runtime/lib/core/globalProps.js +55 -0
  13. package/runtime/lib/core/globalProps.js.map +1 -0
  14. package/runtime/lib/core/hooks/mainThread.d.ts +1 -0
  15. package/runtime/lib/core/hooks/mainThread.js +7 -0
  16. package/runtime/lib/core/hooks/mainThread.js.map +1 -0
  17. package/runtime/lib/{snapshot/hooks/mainThread.d.ts → core/hooks/mainThreadImpl.d.ts} +2 -1
  18. package/runtime/lib/{snapshot/hooks/mainThread.js → core/hooks/mainThreadImpl.js} +45 -34
  19. package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -0
  20. package/runtime/lib/{snapshot → core}/hooks/react.js +1 -1
  21. package/runtime/lib/core/hooks/react.js.map +1 -0
  22. package/runtime/lib/{snapshot → core}/hooks/useLynxGlobalEventListener.d.ts +1 -1
  23. package/runtime/lib/{snapshot → core}/hooks/useLynxGlobalEventListener.js +2 -2
  24. package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -0
  25. package/runtime/lib/{snapshot/compat → core}/initData.d.ts +2 -2
  26. package/runtime/lib/{snapshot/compat → core}/initData.js +4 -5
  27. package/runtime/lib/core/initData.js.map +1 -0
  28. package/runtime/lib/core/lynx-data-processors.d.ts +2 -0
  29. package/runtime/lib/core/lynx-data-processors.js +53 -0
  30. package/runtime/lib/core/lynx-data-processors.js.map +1 -0
  31. package/runtime/lib/core/lynx-page-data.d.ts +1 -0
  32. package/runtime/lib/core/lynx-page-data.js +14 -0
  33. package/runtime/lib/core/lynx-page-data.js.map +1 -0
  34. package/runtime/lib/core/lynx-update-data.d.ts +11 -0
  35. package/runtime/lib/core/lynx-update-data.js +21 -0
  36. package/runtime/lib/core/lynx-update-data.js.map +1 -0
  37. package/runtime/lib/core/ref.d.ts +37 -0
  38. package/runtime/lib/core/ref.js +108 -0
  39. package/runtime/lib/core/ref.js.map +1 -0
  40. package/runtime/lib/core/reload-version.d.ts +2 -0
  41. package/runtime/lib/{snapshot/lifecycle/pass.js → core/reload-version.js} +4 -5
  42. package/runtime/lib/core/reload-version.js.map +1 -0
  43. package/runtime/lib/element-template/background/attr-slots.d.ts +7 -0
  44. package/runtime/lib/element-template/background/attr-slots.js +67 -0
  45. package/runtime/lib/element-template/background/attr-slots.js.map +1 -0
  46. package/runtime/lib/element-template/background/commit-context.d.ts +13 -0
  47. package/runtime/lib/element-template/background/commit-context.js +22 -0
  48. package/runtime/lib/element-template/background/commit-context.js.map +1 -0
  49. package/runtime/lib/element-template/background/commit-hook.d.ts +7 -0
  50. package/runtime/lib/element-template/background/commit-hook.js +121 -0
  51. package/runtime/lib/element-template/background/commit-hook.js.map +1 -0
  52. package/runtime/lib/element-template/background/destroy.d.ts +1 -0
  53. package/runtime/lib/element-template/background/destroy.js +20 -0
  54. package/runtime/lib/element-template/background/destroy.js.map +1 -0
  55. package/runtime/lib/element-template/background/document.d.ts +7 -0
  56. package/runtime/lib/element-template/background/document.js +21 -0
  57. package/runtime/lib/element-template/background/document.js.map +1 -0
  58. package/runtime/lib/element-template/background/hydrate.d.ts +4 -0
  59. package/runtime/lib/element-template/background/hydrate.js +236 -0
  60. package/runtime/lib/element-template/background/hydrate.js.map +1 -0
  61. package/runtime/lib/element-template/background/hydration-listener.d.ts +2 -0
  62. package/runtime/lib/element-template/background/hydration-listener.js +139 -0
  63. package/runtime/lib/element-template/background/hydration-listener.js.map +1 -0
  64. package/runtime/lib/element-template/background/instance.d.ts +41 -0
  65. package/runtime/lib/element-template/background/instance.js +347 -0
  66. package/runtime/lib/element-template/background/instance.js.map +1 -0
  67. package/runtime/lib/element-template/background/manager.d.ts +10 -0
  68. package/runtime/lib/element-template/background/manager.js +60 -0
  69. package/runtime/lib/element-template/background/manager.js.map +1 -0
  70. package/runtime/lib/element-template/client/root.d.ts +43 -0
  71. package/runtime/lib/element-template/client/root.js +30 -0
  72. package/runtime/lib/element-template/client/root.js.map +1 -0
  73. package/runtime/lib/element-template/debug/alog.d.ts +41 -0
  74. package/runtime/lib/element-template/debug/alog.js +103 -0
  75. package/runtime/lib/element-template/debug/alog.js.map +1 -0
  76. package/runtime/lib/element-template/debug/elementPAPICall.d.ts +1 -0
  77. package/runtime/lib/element-template/debug/elementPAPICall.js +79 -0
  78. package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -0
  79. package/runtime/lib/element-template/debug/profile.d.ts +3 -0
  80. package/runtime/lib/element-template/debug/profile.js +141 -0
  81. package/runtime/lib/element-template/debug/profile.js.map +1 -0
  82. package/runtime/lib/element-template/hydration-map.d.ts +5 -0
  83. package/runtime/lib/element-template/hydration-map.js +12 -0
  84. package/runtime/lib/element-template/hydration-map.js.map +1 -0
  85. package/runtime/lib/element-template/index.d.ts +28 -0
  86. package/runtime/lib/element-template/index.js +75 -0
  87. package/runtime/lib/element-template/index.js.map +1 -0
  88. package/runtime/lib/element-template/internal.d.ts +6 -0
  89. package/runtime/lib/element-template/internal.js +43 -0
  90. package/runtime/lib/element-template/internal.js.map +1 -0
  91. package/runtime/lib/element-template/jsx-dev-runtime/index.d.ts +1 -0
  92. package/runtime/lib/element-template/jsx-dev-runtime/index.js +5 -0
  93. package/runtime/lib/element-template/jsx-dev-runtime/index.js.map +1 -0
  94. package/runtime/lib/element-template/jsx-runtime/index.d.ts +19 -0
  95. package/runtime/lib/element-template/jsx-runtime/index.js +60 -0
  96. package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -0
  97. package/runtime/lib/element-template/lynx/env.d.ts +1 -0
  98. package/runtime/lib/element-template/lynx/env.js +46 -0
  99. package/runtime/lib/element-template/lynx/env.js.map +1 -0
  100. package/runtime/lib/element-template/lynx/performance.d.ts +23 -0
  101. package/runtime/lib/element-template/lynx/performance.js +135 -0
  102. package/runtime/lib/element-template/lynx/performance.js.map +1 -0
  103. package/runtime/lib/element-template/native/callDestroyLifetimeFun.d.ts +1 -0
  104. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +8 -0
  105. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -0
  106. package/runtime/lib/element-template/native/index.d.ts +1 -0
  107. package/runtime/lib/element-template/native/index.js +79 -0
  108. package/runtime/lib/element-template/native/index.js.map +1 -0
  109. package/runtime/lib/element-template/native/main-thread-api.d.ts +2 -0
  110. package/runtime/lib/element-template/native/main-thread-api.js +49 -0
  111. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -0
  112. package/runtime/lib/element-template/native/mts-destroy.d.ts +3 -0
  113. package/runtime/lib/element-template/native/mts-destroy.js +37 -0
  114. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -0
  115. package/runtime/lib/element-template/native/patch-listener.d.ts +2 -0
  116. package/runtime/lib/element-template/native/patch-listener.js +70 -0
  117. package/runtime/lib/element-template/native/patch-listener.js.map +1 -0
  118. package/runtime/lib/element-template/native/reload.d.ts +2 -0
  119. package/runtime/lib/element-template/native/reload.js +64 -0
  120. package/runtime/lib/element-template/native/reload.js.map +1 -0
  121. package/runtime/lib/element-template/prop-adapters/event-value.d.ts +1 -0
  122. package/runtime/lib/element-template/prop-adapters/event-value.js +7 -0
  123. package/runtime/lib/element-template/prop-adapters/event-value.js.map +1 -0
  124. package/runtime/lib/element-template/prop-adapters/event.d.ts +8 -0
  125. package/runtime/lib/element-template/prop-adapters/event.js +64 -0
  126. package/runtime/lib/element-template/prop-adapters/event.js.map +1 -0
  127. package/runtime/lib/element-template/prop-adapters/ref.d.ts +26 -0
  128. package/runtime/lib/element-template/prop-adapters/ref.js +107 -0
  129. package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -0
  130. package/runtime/lib/element-template/prop-adapters/spread.d.ts +5 -0
  131. package/runtime/lib/element-template/prop-adapters/spread.js +52 -0
  132. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -0
  133. package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +4 -0
  134. package/runtime/lib/element-template/protocol/lifecycle-constant.js +9 -0
  135. package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -0
  136. package/runtime/lib/element-template/protocol/opcodes.d.ts +8 -0
  137. package/runtime/lib/element-template/protocol/opcodes.js +11 -0
  138. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -0
  139. package/runtime/lib/element-template/protocol/types.d.ts +98 -0
  140. package/runtime/lib/element-template/protocol/types.js +5 -0
  141. package/runtime/lib/element-template/protocol/types.js.map +1 -0
  142. package/runtime/lib/element-template/runtime/page/page.d.ts +5 -0
  143. package/runtime/lib/element-template/runtime/page/page.js +20 -0
  144. package/runtime/lib/element-template/runtime/page/page.js.map +1 -0
  145. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +10 -0
  146. package/runtime/lib/element-template/runtime/page/root-instance.js +17 -0
  147. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -0
  148. package/runtime/lib/element-template/runtime/patch.d.ts +3 -0
  149. package/runtime/lib/element-template/runtime/patch.js +214 -0
  150. package/runtime/lib/element-template/runtime/patch.js.map +1 -0
  151. package/runtime/lib/element-template/runtime/render/render-main-thread.d.ts +4 -0
  152. package/runtime/lib/element-template/runtime/render/render-main-thread.js +71 -0
  153. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -0
  154. package/runtime/lib/element-template/runtime/render/render-opcodes.d.ts +4 -0
  155. package/runtime/lib/element-template/runtime/render/render-opcodes.js +134 -0
  156. package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -0
  157. package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +14 -0
  158. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +278 -0
  159. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -0
  160. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +12 -0
  161. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +27 -0
  162. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -0
  163. package/runtime/lib/element-template/runtime/template/handle.d.ts +5 -0
  164. package/runtime/lib/element-template/runtime/template/handle.js +22 -0
  165. package/runtime/lib/element-template/runtime/template/handle.js.map +1 -0
  166. package/runtime/lib/element-template/runtime/template/registry.d.ts +13 -0
  167. package/runtime/lib/element-template/runtime/template/registry.js +46 -0
  168. package/runtime/lib/element-template/runtime/template/registry.js.map +1 -0
  169. package/runtime/lib/index.d.ts +5 -3
  170. package/runtime/lib/index.js +7 -4
  171. package/runtime/lib/index.js.map +1 -1
  172. package/runtime/lib/internal.d.ts +3 -4
  173. package/runtime/lib/internal.js +4 -5
  174. package/runtime/lib/internal.js.map +1 -1
  175. package/runtime/lib/lynx-api.d.ts +4 -9
  176. package/runtime/lib/lynx-api.js +11 -48
  177. package/runtime/lib/lynx-api.js.map +1 -1
  178. package/runtime/lib/lynx.d.ts +1 -1
  179. package/runtime/lib/lynx.js +3 -3
  180. package/runtime/lib/lynx.js.map +1 -1
  181. package/runtime/lib/{snapshot/debug → shared}/component-stack.js +1 -1
  182. package/runtime/lib/shared/component-stack.js.map +1 -0
  183. package/runtime/lib/{snapshot/debug → shared}/profile.js +6 -4
  184. package/runtime/lib/shared/profile.js.map +1 -0
  185. package/runtime/lib/{snapshot/renderToOpcodes/constants.js → shared/render-constants.js} +1 -1
  186. package/runtime/lib/shared/render-constants.js.map +1 -0
  187. package/runtime/lib/snapshot/alog/elementPAPICall.js +1 -1
  188. package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -1
  189. package/runtime/lib/snapshot/alog/render.js +1 -1
  190. package/runtime/lib/snapshot/alog/render.js.map +1 -1
  191. package/runtime/lib/snapshot/debug/profileHooks.js +1 -1
  192. package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
  193. package/runtime/lib/snapshot/debug/vnodeSource.js +2 -2
  194. package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
  195. package/runtime/lib/snapshot/gesture/processGesture.d.ts +2 -0
  196. package/runtime/lib/snapshot/gesture/processGesture.js +16 -1
  197. package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -1
  198. package/runtime/lib/snapshot/legacy-react-runtime/index.d.ts +2 -2
  199. package/runtime/lib/snapshot/legacy-react-runtime/index.js +2 -2
  200. package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +1 -1
  201. package/runtime/lib/snapshot/lifecycle/destroy.js +1 -1
  202. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  203. package/runtime/lib/snapshot/lifecycle/event/jsReady.js +1 -1
  204. package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +1 -1
  205. package/runtime/lib/snapshot/lifecycle/isRendering.js +1 -1
  206. package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
  207. package/runtime/lib/snapshot/lifecycle/patch/commit.d.ts +0 -1
  208. package/runtime/lib/snapshot/lifecycle/patch/commit.js +5 -10
  209. package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
  210. package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.d.ts +15 -0
  211. package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js +102 -0
  212. package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js.map +1 -0
  213. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +2 -0
  214. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +17 -0
  215. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
  216. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +26 -0
  217. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  218. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +1 -1
  219. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  220. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +7 -13
  221. package/runtime/lib/snapshot/lifecycle/ref/delay.js +12 -31
  222. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  223. package/runtime/lib/snapshot/lifecycle/reload.js +3 -3
  224. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  225. package/runtime/lib/snapshot/lifecycle/render.js +1 -1
  226. package/runtime/lib/snapshot/lifecycle/render.js.map +1 -1
  227. package/runtime/lib/snapshot/list/list.js +5 -2
  228. package/runtime/lib/snapshot/list/list.js.map +1 -1
  229. package/runtime/lib/snapshot/list/listUpdateInfo.js +4 -3
  230. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  231. package/runtime/lib/snapshot/lynx/calledByNative.js +2 -8
  232. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  233. package/runtime/lib/snapshot/lynx/component.js +3 -3
  234. package/runtime/lib/snapshot/lynx/component.js.map +1 -1
  235. package/runtime/lib/snapshot/lynx/element.d.ts +6 -0
  236. package/runtime/lib/snapshot/lynx/element.js +35 -0
  237. package/runtime/lib/snapshot/lynx/element.js.map +1 -0
  238. package/runtime/lib/snapshot/lynx/env.js +5 -51
  239. package/runtime/lib/snapshot/lynx/env.js.map +1 -1
  240. package/runtime/lib/snapshot/lynx/nodesRef.d.ts +6 -0
  241. package/runtime/lib/snapshot/lynx/nodesRef.js +31 -0
  242. package/runtime/lib/snapshot/lynx/nodesRef.js.map +1 -0
  243. package/runtime/lib/snapshot/lynx/performance.js +1 -1
  244. package/runtime/lib/snapshot/lynx/performance.js.map +1 -1
  245. package/runtime/lib/snapshot/lynx/portals.d.ts +9 -0
  246. package/runtime/lib/snapshot/lynx/portals.js +120 -0
  247. package/runtime/lib/snapshot/lynx/portals.js.map +1 -0
  248. package/runtime/lib/snapshot/lynx/portalsPending.d.ts +10 -0
  249. package/runtime/lib/snapshot/lynx/portalsPending.js +38 -0
  250. package/runtime/lib/snapshot/lynx/portalsPending.js.map +1 -0
  251. package/runtime/lib/snapshot/lynx/runWithForce.js +9 -39
  252. package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -1
  253. package/runtime/lib/snapshot/lynx/tt.js +11 -31
  254. package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
  255. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +1 -1
  256. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  257. package/runtime/lib/snapshot/renderToOpcodes/index.js +1 -1
  258. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  259. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +1 -1
  260. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  261. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.d.ts +1 -1
  262. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +23 -24
  263. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  264. package/runtime/lib/snapshot/snapshot/constants.d.ts +4 -0
  265. package/runtime/lib/snapshot/snapshot/constants.js +4 -0
  266. package/runtime/lib/snapshot/snapshot/constants.js.map +1 -1
  267. package/runtime/lib/snapshot/snapshot/definition.d.ts +1 -0
  268. package/runtime/lib/snapshot/snapshot/definition.js +49 -1
  269. package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
  270. package/runtime/lib/snapshot/snapshot/dynamicPartType.d.ts +12 -0
  271. package/runtime/lib/snapshot/snapshot/dynamicPartType.js +12 -0
  272. package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -1
  273. package/runtime/lib/snapshot/snapshot/event.d.ts +1 -1
  274. package/runtime/lib/snapshot/snapshot/event.js +0 -4
  275. package/runtime/lib/snapshot/snapshot/event.js.map +1 -1
  276. package/runtime/lib/snapshot/snapshot/gesture.js +9 -3
  277. package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -1
  278. package/runtime/lib/snapshot/snapshot/list.js +1 -1
  279. package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
  280. package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.d.ts +14 -0
  281. package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js +27 -0
  282. package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js.map +1 -0
  283. package/runtime/lib/snapshot/snapshot/ref.d.ts +3 -5
  284. package/runtime/lib/snapshot/snapshot/ref.js +16 -59
  285. package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
  286. package/runtime/lib/snapshot/snapshot/snapshot.js +62 -3
  287. package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
  288. package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js +1 -1
  289. package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -1
  290. package/runtime/lib/snapshot/snapshot/spread.d.ts +1 -1
  291. package/runtime/lib/snapshot/snapshot/spread.js +32 -1
  292. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
  293. package/runtime/lib/snapshot/snapshot/utils.d.ts +1 -3
  294. package/runtime/lib/snapshot/snapshot/utils.js +5 -0
  295. package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
  296. package/runtime/lib/snapshot/snapshot/workletEvent.d.ts +1 -1
  297. package/runtime/lib/snapshot/snapshot/workletEvent.js +10 -5
  298. package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -1
  299. package/runtime/lib/snapshot/snapshot/workletRef.d.ts +1 -1
  300. package/runtime/lib/snapshot/snapshot/workletRef.js +6 -3
  301. package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -1
  302. package/runtime/lib/snapshot/worklet/ref/workletRef.js +1 -1
  303. package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +1 -1
  304. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  305. package/runtime/lib/utils.js +1 -1
  306. package/runtime/lib/utils.js.map +1 -1
  307. package/runtime/lib/worklet-runtime/bindings/observers.d.ts +1 -0
  308. package/runtime/lib/worklet-runtime/bindings/observers.js +5 -3
  309. package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
  310. package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -1
  311. package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
  312. package/runtime/lib/worklet-runtime/hydrate.js +1 -1
  313. package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
  314. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +1 -0
  315. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +5 -0
  316. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  317. package/runtime/lib/worklet-runtime/workletRuntime.js +2 -3
  318. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  319. package/runtime/worklet-runtime/dev.js +9 -5
  320. package/runtime/worklet-runtime/main.js +1 -1
  321. package/testing-library/dist/env/index.js +27 -15
  322. package/testing-library/dist/fire-event.d.ts +21 -7
  323. package/testing-library/dist/index.d.ts +2 -0
  324. package/testing-library/dist/plugins/index.js +12 -1
  325. package/testing-library/dist/pure.js +27 -9
  326. package/testing-library/dist/type-entry/index.js +0 -0
  327. package/transform/dist/wasm.cjs +833 -285
  328. package/transform/index.d.ts +28 -1
  329. package/types/react.docs.d.ts +9 -1
  330. package/refresh/.gitignore +0 -1
  331. package/refresh/.npmignore +0 -3
  332. package/refresh/.turbo/turbo-build.log +0 -12
  333. package/refresh/package.json +0 -20
  334. package/refresh/rslib.config.ts +0 -24
  335. package/refresh/tsconfig.json +0 -4
  336. package/refresh/turbo.json +0 -15
  337. package/runtime/lib/snapshot/compat/initData.js.map +0 -1
  338. package/runtime/lib/snapshot/debug/component-stack.js.map +0 -1
  339. package/runtime/lib/snapshot/debug/profile.js.map +0 -1
  340. package/runtime/lib/snapshot/hooks/mainThread.js.map +0 -1
  341. package/runtime/lib/snapshot/hooks/react.js.map +0 -1
  342. package/runtime/lib/snapshot/hooks/useLynxGlobalEventListener.js.map +0 -1
  343. package/runtime/lib/snapshot/lifecycle/pass.d.ts +0 -3
  344. package/runtime/lib/snapshot/lifecycle/pass.js.map +0 -1
  345. package/runtime/lib/snapshot/renderToOpcodes/constants.js.map +0 -1
  346. package/testing-library/README.md +0 -109
  347. /package/runtime/lib/{snapshot → core}/hooks/react.d.ts +0 -0
  348. /package/runtime/lib/{snapshot/debug → shared}/component-stack.d.ts +0 -0
  349. /package/runtime/lib/{snapshot/debug → shared}/profile.d.ts +0 -0
  350. /package/runtime/lib/{snapshot/renderToOpcodes/constants.d.ts → shared/render-constants.d.ts} +0 -0
@@ -0,0 +1,347 @@
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, queueRefAttributeSlotUpdates } from './attr-slots.js';
5
+ import { globalCommitContext, markRemovedSubtreeForPostDispatchTeardown } 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
+ export class BackgroundElementTemplateInstance {
27
+ instanceId = 0; // Assigned by manager
28
+ type;
29
+ parent = null;
30
+ firstChild = null;
31
+ lastChild = null;
32
+ nextSibling = null;
33
+ previousSibling = null;
34
+ __slotIndex = 0;
35
+ // Shadow State for Hydration
36
+ attributeSlots;
37
+ rawAttributeSlots;
38
+ isMaterializedOnMainThread = false;
39
+ get parentNode() {
40
+ return this.parent;
41
+ }
42
+ get childNodes() {
43
+ const nodes = [];
44
+ let child = this.firstChild;
45
+ while (child) {
46
+ nodes.push(child);
47
+ child = child.nextSibling;
48
+ }
49
+ return nodes;
50
+ }
51
+ get elementSlots() {
52
+ const elementSlots = [];
53
+ let child = this.firstChild;
54
+ while (child) {
55
+ (elementSlots[child.__slotIndex] ??= []).push(child);
56
+ child = child.nextSibling;
57
+ }
58
+ return elementSlots;
59
+ }
60
+ nodeType;
61
+ constructor(type, initialAttributeSlots) {
62
+ this.type = type;
63
+ this.nodeType = isBuiltinRawTextTemplateKey(type) ? 3 : 1;
64
+ backgroundElementTemplateInstanceManager.register(this);
65
+ if (initialAttributeSlots) {
66
+ const preparedSlots = prepareRawAttributeSlots(this.type, this.instanceId, initialAttributeSlots);
67
+ this.attributeSlots = preparedSlots;
68
+ if (preparedSlots !== initialAttributeSlots) {
69
+ this.rawAttributeSlots = initialAttributeSlots;
70
+ }
71
+ }
72
+ else {
73
+ this.attributeSlots = [];
74
+ }
75
+ }
76
+ emitCreate() {
77
+ if (this.isMaterializedOnMainThread) {
78
+ return;
79
+ }
80
+ if (this.instanceId === 0 && __DEV__) {
81
+ lynx.reportError(new Error('ElementTemplate patch has illegal handleId 0.'));
82
+ return;
83
+ }
84
+ // Walk the linked-list children once to build the slot-indexed handle list
85
+ // for the createTemplate op. Going via `this.elementSlots` would allocate
86
+ // the full `Instance[][]` intermediate just to throw it away here.
87
+ const serializedSlots = [];
88
+ let child = this.firstChild;
89
+ while (child) {
90
+ (serializedSlots[child.__slotIndex] ??= []).push(child.instanceId);
91
+ child = child.nextSibling;
92
+ }
93
+ pushOp(ElementTemplateUpdateOps.createTemplate, this.instanceId, this.type, null, this.attributeSlots, serializedSlots);
94
+ this.isMaterializedOnMainThread = true;
95
+ }
96
+ needsMainThreadCreate() {
97
+ return this.instanceId > 0 && !this.isMaterializedOnMainThread;
98
+ }
99
+ emitMainThreadCreateIfNeeded() {
100
+ if (!this.needsMainThreadCreate()) {
101
+ return;
102
+ }
103
+ // An unmaterialized subtree may receive attr updates before it is inserted;
104
+ // prepare here so ref attach happens once, at the create boundary.
105
+ this.prepareAttributeSlotsForNative();
106
+ this.emitCreate();
107
+ }
108
+ canEmitUpdatePatch() {
109
+ // Background tree construction is local until hydrate binds it to main-thread
110
+ // instances. Only hydrated and materialized owners can emit update ops.
111
+ return isElementTemplateHydrated() && !this.needsMainThreadCreate();
112
+ }
113
+ // DOM API for Preact
114
+ appendChild(child) {
115
+ this.insertBefore(child, null);
116
+ }
117
+ insertBefore(child, beforeChild, silent) {
118
+ if (beforeChild === child) {
119
+ throw new Error('Cannot insert a node before itself');
120
+ }
121
+ if (beforeChild && beforeChild.parent !== this) {
122
+ throw new Error('Reference node is not a child of this parent');
123
+ }
124
+ if (child.parent) {
125
+ child.parent.removeChild(child, true);
126
+ }
127
+ child.parent = this;
128
+ if (beforeChild) {
129
+ child.nextSibling = beforeChild;
130
+ child.previousSibling = beforeChild.previousSibling;
131
+ if (beforeChild.previousSibling) {
132
+ beforeChild.previousSibling.nextSibling = child;
133
+ }
134
+ else {
135
+ this.firstChild = child;
136
+ }
137
+ beforeChild.previousSibling = child;
138
+ }
139
+ else {
140
+ if (this.lastChild) {
141
+ this.lastChild.nextSibling = child;
142
+ child.previousSibling = this.lastChild;
143
+ }
144
+ else {
145
+ this.firstChild = child;
146
+ }
147
+ this.lastChild = child;
148
+ child.nextSibling = null;
149
+ }
150
+ if (silent || !this.canEmitUpdatePatch()) {
151
+ return;
152
+ }
153
+ const beforeId = (beforeChild && beforeChild.__slotIndex === child.__slotIndex) ? beforeChild.instanceId : 0;
154
+ emitMainThreadCreateRecursive(child);
155
+ pushOp(ElementTemplateUpdateOps.insertNode, this.instanceId, child.__slotIndex, child.instanceId, beforeId);
156
+ }
157
+ removeChild(child, silent) {
158
+ if (child.parent !== this) {
159
+ throw new Error('Node is not a child of this parent');
160
+ }
161
+ if (child.previousSibling) {
162
+ child.previousSibling.nextSibling = child.nextSibling;
163
+ }
164
+ else {
165
+ this.firstChild = child.nextSibling;
166
+ }
167
+ if (child.nextSibling) {
168
+ child.nextSibling.previousSibling = child.previousSibling;
169
+ }
170
+ else {
171
+ this.lastChild = child.previousSibling;
172
+ }
173
+ child.parent = null;
174
+ child.nextSibling = null;
175
+ child.previousSibling = null;
176
+ const slotId = child.__slotIndex;
177
+ if (silent) {
178
+ return;
179
+ }
180
+ if (this.canEmitUpdatePatch()) {
181
+ pushOp(ElementTemplateUpdateOps.removeNode, this.instanceId, slotId, child.instanceId, collectElementTemplateSubtreeHandleIds(child));
182
+ // The removed JS object graph may outlive the detach until GC, so keep
183
+ // it pending and tear it down on the Snapshot-aligned delayed boundary.
184
+ markRemovedSubtreeForPostDispatchTeardown(child);
185
+ child.queueRefCleanupForSubtree();
186
+ }
187
+ else {
188
+ // Mirrors `shouldQueueRefEffects` in `setAttribute`: pre-hydration
189
+ // commits and post-hydration materialized children publish their refs
190
+ // to user effects. Post-hydration unmaterialized children defer attach
191
+ // to `emitCreate`, which never fires for a subtree torn down before
192
+ // insert — so cleaning up there would emit a spurious detach.
193
+ const refAttachWasPublished = !isElementTemplateHydrated()
194
+ || !child.needsMainThreadCreate();
195
+ if (refAttachWasPublished) {
196
+ // Run before any tearDown below: `tearDown` clears `rawAttributeSlots`,
197
+ // which `queueRefCleanupForSubtree` walks to enqueue the detach.
198
+ child.queueRefCleanupForSubtree();
199
+ }
200
+ if (child.needsMainThreadCreate()) {
201
+ // An unmaterialized subtree has no main-thread registry entry, so it
202
+ // can be released from the background manager without delayed cleanup.
203
+ child.tearDown();
204
+ }
205
+ }
206
+ }
207
+ tearDown() {
208
+ // Recursively tear down children first
209
+ let child = this.firstChild;
210
+ while (child) {
211
+ const next = child.nextSibling;
212
+ child.tearDown();
213
+ child = next;
214
+ }
215
+ // Clear references
216
+ this.parent = null;
217
+ this.firstChild = null;
218
+ this.lastChild = null;
219
+ this.previousSibling = null;
220
+ this.nextSibling = null;
221
+ this.attributeSlots = [];
222
+ this.rawAttributeSlots = undefined;
223
+ // Remove from manager
224
+ if (this.instanceId) {
225
+ backgroundElementTemplateInstanceManager.values.delete(this.instanceId);
226
+ }
227
+ }
228
+ queueRefCleanupForSubtree() {
229
+ if (this.rawAttributeSlots) {
230
+ queueRefAttributeSlotUpdates(this.type, this.instanceId, this.rawAttributeSlots);
231
+ }
232
+ let child = this.firstChild;
233
+ while (child) {
234
+ child.queueRefCleanupForSubtree();
235
+ child = child.nextSibling;
236
+ }
237
+ }
238
+ getRawAttributeSlot(attrSlotIndex) {
239
+ return this.rawAttributeSlots?.[attrSlotIndex] ?? this.attributeSlots[attrSlotIndex];
240
+ }
241
+ markMaterializedByHydration() {
242
+ // Hydration binds this object to a template that already exists on the main
243
+ // thread; future updates must treat it as materialized without emitting create.
244
+ this.isMaterializedOnMainThread = true;
245
+ }
246
+ prepareAttributeSlotsForNative(options) {
247
+ if (!this.rawAttributeSlots) {
248
+ return;
249
+ }
250
+ this.attributeSlots = prepareRawAttributeSlots(this.type, this.instanceId, this.rawAttributeSlots, {
251
+ queueRefEffects: options?.queueRefEffects ?? true,
252
+ });
253
+ }
254
+ prepareAttributeSlotsForHydration() {
255
+ // Hydrate only rebinds the selector marker to the stable handle. The ref was
256
+ // already made visible to user effects on the pre-hydration commit path.
257
+ this.prepareAttributeSlotsForNative({
258
+ queueRefEffects: false,
259
+ });
260
+ }
261
+ setAttribute(key, value) {
262
+ if (isBuiltinRawTextTemplateKey(this.type) && (key === '0' || key === 'data')) {
263
+ this.text = String(value);
264
+ }
265
+ else if (key === 'attributeSlots' && Array.isArray(value)) {
266
+ const previousSlots = this.attributeSlots;
267
+ const previousRawSlots = this.rawAttributeSlots ?? previousSlots;
268
+ const isHydrated = isElementTemplateHydrated();
269
+ const canEmitUpdatePatch = isHydrated && !this.needsMainThreadCreate();
270
+ // Pre-hydration commits must expose refs to effects, while post-hydration
271
+ // unmaterialized nodes defer ref attach to create emission to avoid dupes.
272
+ const shouldQueueRefEffects = !isHydrated || canEmitUpdatePatch;
273
+ const nextSlots = prepareRawAttributeSlots(this.type, this.instanceId, value, {
274
+ previousRawSlots,
275
+ queueRefEffects: shouldQueueRefEffects,
276
+ });
277
+ this.rawAttributeSlots = nextSlots === value ? undefined : value;
278
+ const maxLength = Math.max(previousSlots.length, nextSlots.length);
279
+ this.attributeSlots = nextSlots;
280
+ for (let slotIndex = 0; slotIndex < maxLength; slotIndex += 1) {
281
+ const previousValue = previousSlots[slotIndex];
282
+ const nextValue = nextSlots[slotIndex];
283
+ if (isDirectOrDeepEqual(previousValue, nextValue)) {
284
+ continue;
285
+ }
286
+ if (!canEmitUpdatePatch) {
287
+ continue;
288
+ }
289
+ pushOp(ElementTemplateUpdateOps.setAttribute, this.instanceId, slotIndex, nextValue ?? null);
290
+ }
291
+ }
292
+ }
293
+ get text() {
294
+ return stringifyRawTextValue(this.attributeSlots[0]);
295
+ }
296
+ set text(value) {
297
+ if (!isBuiltinRawTextTemplateKey(this.type)) {
298
+ return;
299
+ }
300
+ const text = String(value);
301
+ if (this.attributeSlots[0] === text) {
302
+ return;
303
+ }
304
+ this.rawAttributeSlots = undefined;
305
+ this.attributeSlots = [text];
306
+ if (!this.canEmitUpdatePatch()) {
307
+ return;
308
+ }
309
+ pushOp(ElementTemplateUpdateOps.setAttribute, this.instanceId, 0, text);
310
+ }
311
+ get data() {
312
+ return this.text;
313
+ }
314
+ set data(value) {
315
+ this.text = value;
316
+ }
317
+ }
318
+ export function collectElementTemplateSubtreeHandleIds(root) {
319
+ const handles = [];
320
+ collectElementTemplateSubtreeHandleIdsImpl(root, handles);
321
+ return handles;
322
+ }
323
+ function collectElementTemplateSubtreeHandleIdsImpl(instance, handles) {
324
+ if (instance.instanceId !== 0) {
325
+ handles.push(instance.instanceId);
326
+ }
327
+ let child = instance.firstChild;
328
+ while (child) {
329
+ collectElementTemplateSubtreeHandleIdsImpl(child, handles);
330
+ child = child.nextSibling;
331
+ }
332
+ }
333
+ function emitMainThreadCreateRecursive(instance) {
334
+ if (!isElementTemplateHydrated()
335
+ || instance.instanceId < 0) {
336
+ return;
337
+ }
338
+ // Walk children in linked-list order; the slot-grouped view would just be
339
+ // discarded here since we recurse into every child regardless of slot.
340
+ let child = instance.firstChild;
341
+ while (child) {
342
+ emitMainThreadCreateRecursive(child);
343
+ child = child.nextSibling;
344
+ }
345
+ instance.emitMainThreadCreateIfNeeded();
346
+ }
347
+ //# 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,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAClH,OAAO,EAAE,mBAAmB,EAAE,yCAAyC,EAAE,MAAM,qBAAqB,CAAC;AACrG,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,2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AED,SAAS,6BAA6B,CAAC,QAA2C;IAChF,IACE,CAAC,yBAAyB,EAAE;WACzB,QAAQ,CAAC,UAAU,GAAG,CAAC,EAC1B,CAAC;QACD,OAAO;IACT,CAAC;IAED,0EAA0E;IAC1E,uEAAuE;IACvE,IAAI,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC;IAChC,OAAO,KAAK,EAAE,CAAC;QACb,6BAA6B,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,QAAQ,CAAC,4BAA4B,EAAE,CAAC;AAC1C,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,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE,CA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AAC,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,43 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DataProcessorDefinition } from '../../lynx-api.js';
3
+ /**
4
+ * The default root exported by `@lynx-js/react` for you to render a JSX
5
+ * @public
6
+ */
7
+ export interface Root {
8
+ /**
9
+ * Use this API to pass in your JSX to render
10
+ *
11
+ * @example
12
+ *
13
+ * ```ts
14
+ * import { root } from "@lynx-js/react"
15
+ *
16
+ * function App() {
17
+ * // Your app
18
+ * return <view>...</view>
19
+ * }
20
+ *
21
+ * root.render(<App/>);
22
+ * ```
23
+ *
24
+ * @public
25
+ */
26
+ render: (jsx: ReactNode) => void;
27
+ /**
28
+ * {@inheritDoc Lynx.registerDataProcessors}
29
+ * @deprecated use {@link Lynx.registerDataProcessors | lynx.registerDataProcessors} instead
30
+ * @public
31
+ */
32
+ registerDataProcessors: (dataProcessorDefinition?: DataProcessorDefinition) => void;
33
+ }
34
+ /**
35
+ * The default and only root of ReactLynx for you to render JSX
36
+ * @example
37
+ * ```ts
38
+ * import { root } from "@lynx-js/react"
39
+ * ```
40
+ *
41
+ * @public
42
+ */
43
+ export declare const root: Root;
@@ -0,0 +1,30 @@
1
+ import { render } from 'preact';
2
+ import { profileEnd, profileStart } from '../debug/profile.js';
3
+ import { __root } from '../runtime/page/root-instance.js';
4
+ /**
5
+ * The default and only root of ReactLynx for you to render JSX
6
+ * @example
7
+ * ```ts
8
+ * import { root } from "@lynx-js/react"
9
+ * ```
10
+ *
11
+ * @public
12
+ */
13
+ export const root = {
14
+ render: (jsx) => {
15
+ __root.__jsx = jsx;
16
+ if (__BACKGROUND__) {
17
+ if (__PROFILE__) {
18
+ profileStart('ReactLynx::renderBackground');
19
+ }
20
+ render(jsx, __root);
21
+ if (__PROFILE__) {
22
+ profileEnd();
23
+ }
24
+ }
25
+ },
26
+ registerDataProcessors: (dataProcessorDefinition) => {
27
+ lynx.registerDataProcessors(dataProcessorDefinition);
28
+ },
29
+ };
30
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.js","sourceRoot":"","sources":["../../../src/element-template/client/root.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,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,EAAE,CAAC,uBAAiD,EAAQ,EAAE;QAClF,IAAI,CAAC,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;IACvD,CAAC;CACF,CAAC"}
@@ -0,0 +1,41 @@
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: 'createTypedElement';
12
+ handleId: number;
13
+ type: string;
14
+ attributes: unknown;
15
+ elementSlots: unknown;
16
+ options: unknown;
17
+ } | {
18
+ op: 'setAttribute';
19
+ targetId: number;
20
+ attrSlotIndex: number;
21
+ value: unknown;
22
+ } | {
23
+ op: 'insertNode';
24
+ targetId: number;
25
+ elementSlotIndex: number;
26
+ childId: number;
27
+ referenceId: number;
28
+ } | {
29
+ op: 'removeNode';
30
+ targetId: number;
31
+ elementSlotIndex: number;
32
+ childId: number;
33
+ removedSubtreeHandleIds: number[];
34
+ } | {
35
+ op: 'unknown';
36
+ opcode: unknown;
37
+ index: number;
38
+ remaining: unknown[];
39
+ };
40
+ export declare function formatElementTemplateUpdateCommands(stream: ElementTemplateUpdateCommandStream | undefined): FormattedElementTemplateUpdateCommand[];
41
+ export declare function printElementTemplateTreeToString(root: BackgroundElementTemplateInstance | null | undefined): string;
@@ -0,0 +1,103 @@
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.createTypedElement:
33
+ result.push({
34
+ op: 'createTypedElement',
35
+ handleId: stream[index++],
36
+ type: stream[index++],
37
+ attributes: stream[index++],
38
+ elementSlots: stream[index++],
39
+ options: stream[index++],
40
+ });
41
+ break;
42
+ case ElementTemplateUpdateOps.insertNode:
43
+ result.push({
44
+ op: 'insertNode',
45
+ targetId: stream[index++],
46
+ elementSlotIndex: stream[index++],
47
+ childId: stream[index++],
48
+ referenceId: stream[index++],
49
+ });
50
+ break;
51
+ case ElementTemplateUpdateOps.removeNode:
52
+ result.push({
53
+ op: 'removeNode',
54
+ targetId: stream[index++],
55
+ elementSlotIndex: stream[index++],
56
+ childId: stream[index++],
57
+ removedSubtreeHandleIds: stream[index++],
58
+ });
59
+ break;
60
+ default:
61
+ result.push({
62
+ op: 'unknown',
63
+ opcode: op,
64
+ index: opIndex,
65
+ remaining: stream.slice(index),
66
+ });
67
+ index = stream.length;
68
+ break;
69
+ }
70
+ }
71
+ return result;
72
+ }
73
+ export function printElementTemplateTreeToString(root) {
74
+ if (!root) {
75
+ return '<empty>';
76
+ }
77
+ const lines = [];
78
+ appendInstance(lines, root, 0);
79
+ return lines.join('\n');
80
+ }
81
+ function appendInstance(lines, instance, depth) {
82
+ const indent = ' '.repeat(depth);
83
+ const type = instance.type ?? '<unknown>';
84
+ const instanceId = instance.instanceId ?? '<unknown>';
85
+ lines.push(`${indent}${type}#${instanceId}`);
86
+ if (Array.isArray(instance.attributeSlots) && instance.attributeSlots.length > 0) {
87
+ lines.push(`${indent} attributeSlots: ${JSON.stringify(instance.attributeSlots)}`);
88
+ }
89
+ const elementSlots = Array.isArray(instance.elementSlots) ? instance.elementSlots : [];
90
+ for (let slotIndex = 0; slotIndex < elementSlots.length; slotIndex += 1) {
91
+ const children = elementSlots[slotIndex];
92
+ if (!children || children.length === 0) {
93
+ continue;
94
+ }
95
+ lines.push(`${indent} elementSlots[${slotIndex}]: [${children.map(child => child.instanceId).join(', ')}]`);
96
+ }
97
+ let child = instance.firstChild;
98
+ while (child) {
99
+ appendInstance(lines, child, depth + 1);
100
+ child = child.nextSibling;
101
+ }
102
+ }
103
+ //# sourceMappingURL=alog.js.map