@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,75 @@
1
+ // Copyright 2025 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { profileEnd, profileStart } from '../../shared/profile.js';
5
+ const elementTemplatePAPINameList = [
6
+ '__CreateElementTemplate',
7
+ '__SetAttributeOfElementTemplate',
8
+ '__InsertNodeToElementTemplate',
9
+ '__RemoveNodeFromElementTemplate',
10
+ '__SerializeElementTemplate',
11
+ ];
12
+ export function initElementTemplatePAPICallAlog(globalWithIndex = globalThis) {
13
+ let count = 0;
14
+ const elementTemplateMap = new Map();
15
+ for (const elementTemplatePAPIName of elementTemplatePAPINameList) {
16
+ const oldElementTemplatePAPI = globalWithIndex[elementTemplatePAPIName];
17
+ if (typeof oldElementTemplatePAPI !== 'function') {
18
+ continue;
19
+ }
20
+ const callElementTemplatePAPI = oldElementTemplatePAPI;
21
+ globalWithIndex[elementTemplatePAPIName] = (...args) => {
22
+ const shouldProfile = typeof __PROFILE__ !== 'undefined' && __PROFILE__;
23
+ if (shouldProfile) {
24
+ profileStart(`ElementTemplatePAPI: ${elementTemplatePAPIName}`, {
25
+ args: {
26
+ args: formatValue(args, elementTemplateMap),
27
+ },
28
+ });
29
+ }
30
+ let result;
31
+ try {
32
+ result = callElementTemplatePAPI(...args);
33
+ }
34
+ finally {
35
+ if (shouldProfile) {
36
+ profileEnd();
37
+ }
38
+ }
39
+ if (elementTemplatePAPIName === '__CreateElementTemplate' && result != null) {
40
+ elementTemplateMap.set(result, `${String(args[0])}#${String(args[4])}`);
41
+ }
42
+ const formattedResult = result == null ? undefined : formatValue(result, elementTemplateMap);
43
+ console.alog?.(`[ReactLynxDebug] ElementTemplate API call #${++count}: ${elementTemplatePAPIName}(${args.map(arg => formatValue(arg, elementTemplateMap)).join(', ')})${formattedResult == null ? '' : ` => ${formattedResult}`}`);
44
+ return result;
45
+ };
46
+ }
47
+ }
48
+ function formatValue(value, elementTemplateMap) {
49
+ if (elementTemplateMap.has(value)) {
50
+ return elementTemplateMap.get(value);
51
+ }
52
+ if (value === undefined) {
53
+ return 'undefined';
54
+ }
55
+ if (value === null) {
56
+ return 'null';
57
+ }
58
+ if (Array.isArray(value)) {
59
+ return '[' + value.map(item => formatValue(item, elementTemplateMap)).join(', ') + ']';
60
+ }
61
+ if (typeof value === 'function') {
62
+ return `[Function${value.name ? ` ${value.name}` : ''}]`;
63
+ }
64
+ if (typeof value === 'symbol') {
65
+ return value.toString();
66
+ }
67
+ try {
68
+ const formatted = JSON.stringify(value);
69
+ return formatted ?? Object.prototype.toString.call(value);
70
+ }
71
+ catch {
72
+ return Object.prototype.toString.call(value);
73
+ }
74
+ }
75
+ //# sourceMappingURL=elementPAPICall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elementPAPICall.js","sourceRoot":"","sources":["../../../src/element-template/debug/elementPAPICall.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,UAAU,EAAE,Y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AI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;IAC3D,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { profileEnd, profileStart } from '../../shared/profile.js';
2
+ export { profileEnd, profileStart };
3
+ export declare function initProfileHook(): void;
@@ -0,0 +1,141 @@
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 { Component, options } from 'preact';
5
+ import { profileEnd, profileStart } from '../../shared/profile.js';
6
+ import { COMMIT, COMPONENT, DIFF, DIFF2, DIFFED, DIRTY, NEXT_STATE, RENDER } from '../../shared/render-constants.js';
7
+ import { getDisplayName, hook } from '../../utils.js';
8
+ import { globalCommitContext } from '../background/commit-context.js';
9
+ let installed = false;
10
+ export { profileEnd, profileStart };
11
+ export function initProfileHook() {
12
+ if (installed) {
13
+ return;
14
+ }
15
+ // early-exit if required profiling APIs are unavailable
16
+ let p;
17
+ /* v8 ignore start */
18
+ if (!(p = lynx.performance)
19
+ || typeof p.profileStart !== 'function'
20
+ || typeof p.profileEnd !== 'function'
21
+ || typeof p.profileMark !== 'function'
22
+ || typeof p.profileFlowId !== 'function') {
23
+ return;
24
+ }
25
+ /* v8 ignore stop */
26
+ installed = true;
27
+ const profileStart = p.profileStart.bind(p);
28
+ const profileEnd = p.profileEnd.bind(p);
29
+ const profileMark = p.profileMark.bind(p);
30
+ const profileFlowId = p.profileFlowId.bind(p);
31
+ // for each setState call, we will add a profiling trace and
32
+ // attach a flowId to the component instance.
33
+ // This allows us to trace the flow of its diffing, committing and patching.
34
+ {
35
+ const sFlowID = Symbol('FLOW_ID');
36
+ if (__BACKGROUND__) {
37
+ function buildSetStateProfileMarkArgs(currentState, nextState) {
38
+ const EMPTY_OBJ = {};
39
+ currentState ??= EMPTY_OBJ;
40
+ nextState ??= EMPTY_OBJ;
41
+ return {
42
+ 'current state keys': JSON.stringify(Object.keys(currentState)),
43
+ 'next state keys': JSON.stringify(Object.keys(nextState)),
44
+ 'changed (shallow diff) state keys': JSON.stringify(
45
+ // the setState is in assign manner, we assume nextState is a superset of currentState
46
+ Object.keys(nextState).filter(key => currentState[key] !== nextState[key])),
47
+ };
48
+ }
49
+ hook(Component.prototype, 'setState', function (old, state, callback) {
50
+ old?.call(this, state, callback);
51
+ if (this[DIRTY]) {
52
+ profileMark('ReactLynx::setState', {
53
+ flowId: this[sFlowID] ??= profileFlowId(),
54
+ args: buildSetStateProfileMarkArgs(this.state, this[NEXT_STATE]),
55
+ });
56
+ }
57
+ });
58
+ }
59
+ hook(options, DIFF2, (old, vnode, oldVNode) => {
60
+ // We only add profiling trace for Component
61
+ if (typeof vnode.type === 'function') {
62
+ const profileOptions = {};
63
+ if (__BACKGROUND__) {
64
+ const c = oldVNode?.[COMPONENT];
65
+ if (c) {
66
+ const flowId = c[sFlowID];
67
+ delete c[sFlowID];
68
+ if (flowId) {
69
+ const flowIds = globalCommitContext.flowIds
70
+ ?? (globalCommitContext.flowIds = []);
71
+ flowIds.push(flowId);
72
+ profileOptions.flowId = flowId;
73
+ }
74
+ }
75
+ }
76
+ profileStart(`ReactLynx::diff::${ /* #__INLINE__ */getDisplayName(vnode.type)}`, profileOptions);
77
+ }
78
+ /* v8 ignore next */
79
+ old?.(vnode, oldVNode);
80
+ });
81
+ hook(options, DIFFED, (old, vnode) => {
82
+ if (typeof vnode.type === 'function') {
83
+ profileEnd(); // for options[DIFF]
84
+ }
85
+ old?.(vnode);
86
+ });
87
+ if (__BACKGROUND__) {
88
+ hook(options, COMMIT, (old, vnode, commitQueue) => {
89
+ const globalFlowIds = globalCommitContext.flowIds;
90
+ const commitProfileOptions = globalFlowIds && globalFlowIds.length > 0
91
+ ? { flowId: globalFlowIds[0], flowIds: [...globalFlowIds] }
92
+ : {};
93
+ profileStart('ReactLynx::commit', commitProfileOptions);
94
+ /* v8 ignore next */
95
+ old?.(vnode, commitQueue);
96
+ profileEnd();
97
+ delete globalCommitContext.flowIds;
98
+ });
99
+ }
100
+ }
101
+ // Profile the user-provided `render`.
102
+ hook(options, RENDER, (old, vnode) => {
103
+ // eslint-disable-next-line @typescript-eslint/unbound-method
104
+ const originalRender = vnode[COMPONENT].render;
105
+ vnode[COMPONENT].render = function render(props, state, context) {
106
+ profileStart(`ReactLynx::render::${ /* #__INLINE__ */getDisplayName(vnode.type)}`);
107
+ try {
108
+ return originalRender.call(this, props, state, context);
109
+ }
110
+ finally {
111
+ profileEnd();
112
+ vnode[COMPONENT].render = originalRender;
113
+ }
114
+ };
115
+ old?.(vnode);
116
+ });
117
+ if (__BACKGROUND__) {
118
+ const sPatchLength = Symbol('PATCH_LENGTH');
119
+ hook(options, DIFF, (old, vnode) => {
120
+ if (typeof vnode.type === 'function') {
121
+ vnode[sPatchLength] = globalCommitContext.ops.length;
122
+ }
123
+ old?.(vnode);
124
+ });
125
+ hook(options, DIFFED, (old, vnode) => {
126
+ if (typeof vnode.type === 'function') {
127
+ if (vnode[sPatchLength] === globalCommitContext.ops.length) {
128
+ // "NoPatch" is a conventional name in Lynx
129
+ profileMark('ReactLynx::diffFinishNoPatch', {
130
+ args: {
131
+ componentName: /* #__INLINE__ */ getDisplayName(vnode.type),
132
+ },
133
+ });
134
+ }
135
+ delete vnode[sPatchLength];
136
+ }
137
+ old?.(vnode);
138
+ });
139
+ }
140
+ }
141
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../src/element-template/debug/profile.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAK5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AACrH,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AAEpC,MAAM,UAAU,eAAe;IAC7B,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IACD,wDAAwD;IACxD,IAAI,CAAC,CAAC;IACN,qBAAqB;IACrB,IACE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;WACpB,OAAO,CAAC,CAAC,YAAY,KAAK,UAAU;WACpC,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU;WAClC,OAAO,CAAC,CAAC,WAAW,KAAK,UAAU;WACnC,OAAO,CAAC,CAAC,aAAa,KAAK,UAAU,EACxC,CAAC;QACD,OAAO;IACT,CAAC;IACD,oBAAoB;IACpB,SAAS,GAAG,IAAI,CAAC;IAEjB,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxC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;YAC5C,CAAC;QACH,CAAC,CAAC;QACF,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;QAI5C,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,KAAmB,EAAE,EAAE;YAC/C,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACrC,KAAK,CAAC,YAAY,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC;YACvD,CAAC;YACD,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,KAAmB,EAAE,EAAE;YACjD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACrC,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;oBAC3D,2CAA2C;oBAC3C,WAAW,CAAC,8BAA8B,EAAE;wBAC1C,IAAI,EAAE;4BACJ,aAAa,EAAE,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,IAAsB,CAAC;yBAC9E;qBACF,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC;YAC7B,CAAC;YACD,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import * as backgroundHooks from '../../core/hooks/react.js';
2
+ declare const useState: typeof backgroundHooks.useState;
3
+ declare const useReducer: typeof backgroundHooks.useReducer;
4
+ declare const useRef: typeof backgroundHooks.useRef;
5
+ declare const useImperativeHandle: typeof backgroundHooks.useImperativeHandle;
6
+ declare const useLayoutEffect: typeof backgroundHooks.useLayoutEffect;
7
+ declare const useEffect: typeof backgroundHooks.useEffect;
8
+ declare const useCallback: typeof backgroundHooks.useCallback;
9
+ declare const useMemo: typeof backgroundHooks.useMemo;
10
+ declare const useContext: typeof backgroundHooks.useContext;
11
+ declare const useDebugValue: typeof backgroundHooks.useDebugValue;
12
+ declare const useErrorBoundary: typeof backgroundHooks.useErrorBoundary;
13
+ declare const useId: typeof backgroundHooks.useId;
14
+ export { useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
@@ -0,0 +1,24 @@
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 * as mainThreadHooks from '../../core/hooks/mainThreadImpl.js';
5
+ import * as backgroundHooks from '../../core/hooks/react.js';
6
+ function currentHooks() {
7
+ return __MAIN_THREAD__
8
+ ? mainThreadHooks
9
+ : backgroundHooks;
10
+ }
11
+ const useState = ((...args) => currentHooks().useState(...args));
12
+ const useReducer = ((...args) => currentHooks().useReducer(...args));
13
+ const useRef = ((...args) => currentHooks().useRef(...args));
14
+ const useImperativeHandle = ((...args) => currentHooks().useImperativeHandle(...args));
15
+ const useLayoutEffect = ((...args) => currentHooks().useLayoutEffect(...args));
16
+ const useEffect = ((...args) => currentHooks().useEffect(...args));
17
+ const useCallback = ((...args) => currentHooks().useCallback(...args));
18
+ const useMemo = ((...args) => currentHooks().useMemo(...args));
19
+ const useContext = ((...args) => currentHooks().useContext(...args));
20
+ const useDebugValue = ((...args) => currentHooks().useDebugValue(...args));
21
+ const useErrorBoundary = ((...args) => currentHooks().useErrorBoundary(...args));
22
+ const useId = ((...args) => currentHooks().useId(...args));
23
+ export { useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
24
+ //# sourceMappingURL=react.js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C;AACpH,MAAM,OAAO,GACX,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CACrB,YAAY,EAAE,CAAC,OAA2C,CAAC,GAAG,IAAI,CAAC,CAAmC,CAAC;AAC5G,MAAM,UAAU,GACd,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CACrB,YAAY,EAAE,CAAC,UAA8C,CAAC,GAAG,IAAI,CAAC,CAAsC,CAAC;AAClH,MAAM,aAAa,GACjB,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CACrB,YAAY,EAAE,CAAC,aAAiD,CAAC,GAAG,IAAI,CAAC,CAAyC,CAAC;AACxH,MAAM,gBAAgB,GAAG,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CAC9C,YAAY,EAAE,CAAC,gBAAoD,CAClE,GAAG,IAAI,CACR,CAA4C,CAAC;AAChD,MAAM,KAAK,GACT,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CACrB,YAAY,EAAE,CAAC,KAAyC,CAAC,GAAG,IAAI,CAAC,CAAiC,CAAC;AAExG,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,GACT,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Children, Fragment, cloneElement, createElement, createRef, forwardRef, isValidElement, lazy, memo, useSyncExternalStore } from 'preact/compat';
2
+ import './native/index.js';
3
+ export { Component, createContext } from 'preact';
4
+ export { PureComponent } from 'preact/compat';
5
+ export * from './hooks/react.js';
6
+ export { Children, createRef, Fragment, isValidElement, memo, forwardRef, lazy, createElement, cloneElement, useSyncExternalStore, };
7
+ export * from './client/root.js';
@@ -0,0 +1,45 @@
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 { Children, Component, Fragment, PureComponent, cloneElement, createContext, createElement, createRef, forwardRef, isValidElement, lazy, memo, useSyncExternalStore, } from 'preact/compat';
5
+ import { useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, } from './hooks/react.js';
6
+ import './native/index.js';
7
+ // import './lynx/component.js';
8
+ // import { Suspense } from './lynx/suspense.js';
9
+ export { Component, createContext } from 'preact';
10
+ export { PureComponent } from 'preact/compat';
11
+ export * from './hooks/react.js';
12
+ /**
13
+ * @internal
14
+ */
15
+ export default {
16
+ // hooks
17
+ useState,
18
+ useReducer,
19
+ useEffect,
20
+ useLayoutEffect,
21
+ useRef,
22
+ useImperativeHandle,
23
+ useMemo,
24
+ useCallback,
25
+ useContext,
26
+ useDebugValue,
27
+ useSyncExternalStore,
28
+ createContext,
29
+ createRef,
30
+ Fragment,
31
+ isValidElement,
32
+ Children,
33
+ Component,
34
+ PureComponent,
35
+ memo,
36
+ forwardRef,
37
+ // Suspense,
38
+ lazy,
39
+ createElement,
40
+ };
41
+ export { Children, createRef, Fragment, isValidElement, memo, forwardRef,
42
+ // Suspense,
43
+ lazy, createElement, cloneElement, useSyncExternalStore, };
44
+ export * from './client/root.js';
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/element-template/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,gCAAgC;AAChC,iDAAiD;AAEjD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AAEjC;;GAEG;AACH,eAAe;IACb,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,SAAS;IACT,eAAe;IACf,MAAM;IACN,mBAAmB;IACnB,OAAO;IACP,WAAW;IACX,UAAU;IACV,aAAa;IACb,oBAAoB;IAEpB,aAAa;IACb,SAAS;IACT,QAAQ;IACR,cAAc;IACd,QAAQ;IACR,SAAS;IACT,aAAa;IACb,IAAI;IACJ,UAAU;IACV,YAAY;IACZ,IAAI;IACJ,aAAa;CACd,CAAC;AAEF,OAAO,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,UAAU;AACV,YAAY;AACZ,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,oBAAoB,GACrB,CAAC;AAEF,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import './native/index.js';
2
+ import { __root } from './runtime/page/root-instance.js';
3
+ export { __root };
4
+ export { options, Component, process, } from 'preact';
5
+ export type { Options } from 'preact';
6
+ export { __etAttrPlanMap, adaptEventAttrSlot, adaptSpreadAttrSlot } from './runtime/template/attr-slot-plan.js';
@@ -0,0 +1,44 @@
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 { Suspense, createElement, lazy } from 'preact/compat';
5
+ // import type { FC } from 'react';
6
+ import './native/index.js';
7
+ // import { factory as factory2 } from '../compat/componentIs.js';
8
+ // import { useMemo } from '../core/hooks/react.js';
9
+ // import { loadLazyBundle } from '../lynx/lazy-bundle.js';
10
+ import { __root } from './runtime/page/root-instance.js';
11
+ /**
12
+ * @internal kept only to fail fast when stale internal imports leak into the
13
+ * Element Template alias surface. This is not a supported ET runtime API.
14
+ */
15
+ export class SnapshotInstance {
16
+ type;
17
+ constructor(type) {
18
+ this.type = type;
19
+ throw new Error('SnapshotInstance should not be instantiated when using Element Template.');
20
+ }
21
+ }
22
+ export { __root };
23
+ export { options,
24
+ // Component is not an internal API, but refresh needs it from 'react/internal'
25
+ Component, process, } from 'preact';
26
+ // export { loadDynamicJS, __dynamicImport } from '../lynx/dynamic-js.js';
27
+ // export { withInitDataInState } from '../compat/initData.js';
28
+ // export { wrapWithLynxComponent } from '../compat/lynxComponent.js';
29
+ /**
30
+ * @internal a polyfill for <component is=? />
31
+ */
32
+ // export const __ComponentIsPolyfill: FC<{ is: string }> = /* @__PURE__ */ factory2(
33
+ // // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
34
+ // { Suspense, lazy, createElement, useMemo } as any,
35
+ // loadLazyBundle,
36
+ // );
37
+ // export { loadLazyBundle } from '../lynx/lazy-bundle.js';
38
+ // TODO: enable when worklet/runtime integration is implemented for ElementTemplate entry.
39
+ // export { transformToWorklet } from '../worklet/call/transformToWorklet.js';
40
+ // export { registerWorkletOnBackground } from '../worklet/hmr.js';
41
+ // export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
42
+ export { __etSlot } from './runtime/components/slot.js';
43
+ export { __etAttrPlanMap, adaptEventAttrSlot, adaptSpreadAttrSlot } from './runtime/template/attr-slot-plan.js';
44
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/element-template/internal.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,iEAAiE;AACjE,mCAAmC;AAEnC,OAAO,mBAAmB,CAAC;AAE3B,kEAAkE;AAClE,oDAAoD;AACpD,2DAA2D;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACR;IAAnB,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAC7B,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;IAC9F,CAAC;CACF;AAED,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,EACL,OAAO;AACP,+EAA+E;AAC/E,SAAS,EACT,OAAO,GACR,MAAM,QAAQ,CAAC;AAGhB,0EAA0E;AAE1E,+DAA+D;AAE/D,sEAAsE;AAEtE;;GAEG;AACH,qFAAqF;AACrF,sEAAsE;AACtE,uDAAuD;AACvD,oBAAoB;AACpB,KAAK;AAEL,2DAA2D;AAE3D,0FAA0F;AAC1F,8EAA8E;AAC9E,mEAAmE;AACnE,gFAAgF;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from '../jsx-runtime/index.js';
@@ -0,0 +1,5 @@
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 * from '../jsx-runtime/index.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/jsx-dev-runtime/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,19 @@
1
+ type ComponentLike = ((...args: unknown[]) => unknown) & {
2
+ defaultProps?: Record<string, unknown>;
3
+ };
4
+ interface ElementTemplateVNode {
5
+ type: string | ComponentLike;
6
+ props: Record<string, unknown> | null | undefined;
7
+ __k: null;
8
+ __: null;
9
+ __b: number;
10
+ __e: null;
11
+ __d: undefined;
12
+ __c: null;
13
+ constructor: undefined;
14
+ __i: number;
15
+ __u: number;
16
+ }
17
+ declare function createVNode(type: string | ComponentLike | null | undefined, props: Record<string, unknown> | null | undefined): ElementTemplateVNode | undefined;
18
+ export { createVNode as jsx, createVNode as jsxs, createVNode as jsxDEV };
19
+ export { Fragment } from 'preact';
@@ -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
+ import { CHILDREN, COMPONENT, DIFF, DIRTY, DOM, FLAGS, INDEX, PARENT } from '../../shared/render-constants.js';
5
+ function createVNode(type, props) {
6
+ if (typeof type === 'string') {
7
+ // ET host nodes are consumed by the opcode renderer directly, so they
8
+ // should not go through the SnapshotInstance construction path.
9
+ return {
10
+ type,
11
+ props: props ?? {},
12
+ [CHILDREN]: null,
13
+ [PARENT]: null,
14
+ [DIFF]: 0,
15
+ [DOM]: null,
16
+ [DIRTY]: void 0,
17
+ [COMPONENT]: null,
18
+ constructor: void 0,
19
+ [INDEX]: -1,
20
+ [FLAGS]: 0,
21
+ };
22
+ }
23
+ else if (typeof type === 'function') {
24
+ let normalizedProps = props;
25
+ if (normalizedProps && 'ref' in normalizedProps) {
26
+ normalizedProps = {};
27
+ for (const i in props) {
28
+ if (i !== 'ref') {
29
+ normalizedProps[i] = props[i];
30
+ }
31
+ }
32
+ }
33
+ let defaultProps;
34
+ if ((defaultProps = type.defaultProps)) {
35
+ normalizedProps ??= {};
36
+ for (const i in defaultProps) {
37
+ if (typeof normalizedProps[i] === 'undefined') {
38
+ normalizedProps[i] = defaultProps[i];
39
+ }
40
+ }
41
+ }
42
+ return {
43
+ type,
44
+ props: normalizedProps,
45
+ [CHILDREN]: null,
46
+ [PARENT]: null,
47
+ [DIFF]: 0,
48
+ [DOM]: null,
49
+ [DIRTY]: void 0,
50
+ [COMPONENT]: null,
51
+ constructor: void 0,
52
+ [INDEX]: -1,
53
+ [FLAGS]: 0,
54
+ };
55
+ }
56
+ return undefined;
57
+ }
58
+ export { createVNode as jsx, createVNode as jsxs, createVNode as jsxDEV };
59
+ export { Fragment } from 'preact';
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/jsx-runtime/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAoB/G,SAAS,WAAW,CAClB,IAA+C,EAC/C,KAAiD;IAEjD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,sEAAsE;QACtE,gEAAgE;QAChE,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,KAAK,IAAI,EAAE;YAElB,CAAC,QAAQ,CAAC,EAAE,IAAI;YAChB,CAAC,MAAM,CAAC,EAAE,IAAI;YACd,CAAC,IAAI,CAAC,EAAE,CAAC;YACT,CAAC,GAAG,CAAC,EAAE,IAAI;YACX,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;YACf,CAAC,SAAS,CAAC,EAAE,IAAI;YACjB,WAAW,EAAE,KAAK,CAAC;YACnB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACX,CAAC,KAAK,CAAC,EAAE,CAAC;SACX,CAAC;IACJ,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,KAAK,CAAC;QAE5B,IAAI,eAAe,IAAI,KAAK,IAAI,eAAe,EAAE,CAAC;YAChD,eAAe,GAAG,EAAE,CAAC;YACrB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;gBACtB,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;oBAChB,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,YAAY,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,eAAe,KAAK,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;gBAC7B,IAAI,OAAO,eAAe,CAAC,CAAC,CAAC,KAAK,WAAW,EAAE,CAAC;oBAC9C,eAAe,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,eAAe;YAEtB,CAAC,QAAQ,CAAC,EAAE,IAAI;YAChB,CAAC,MAAM,CAAC,EAAE,IAAI;YACd,CAAC,IAAI,CAAC,EAAE,CAAC;YACT,CAAC,GAAG,CAAC,EAAE,IAAI;YACX,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;YACf,CAAC,SAAS,CAAC,EAAE,IAAI;YACjB,WAAW,EAAE,KAAK,CAAC;YACnB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACX,CAAC,KAAK,CAAC,EAAE,CAAC;SACX,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,WAAW,IAAI,IAAI,EAAE,WAAW,IAAI,MAAM,EAAE,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { profileEnd, profileStart } from '../debug/profile.js';
2
+ export function setupLynxEnv() {
3
+ if (!__LEPUS__) {
4
+ let initData = {};
5
+ let updateData = {};
6
+ try {
7
+ const params = lynxCoreInject
8
+ ?.tt?._params;
9
+ if (params) {
10
+ initData = params.initData ?? {};
11
+ updateData = params.updateData ?? {};
12
+ }
13
+ }
14
+ catch { }
15
+ lynx.__initData = { ...initData, ...updateData };
16
+ lynx.registerDataProcessors = function () { };
17
+ }
18
+ if (__LEPUS__) {
19
+ lynx.__initData = {
20
+ /* available only in renderPage */
21
+ };
22
+ lynx.triggerGlobalEventFromLepus = function (eventName, params) {
23
+ __OnLifecycleEvent(['globalEventFromLepus', [eventName, params]]);
24
+ };
25
+ {
26
+ // eslint-disable-next-line unicorn/consistent-function-scoping
27
+ function __name(empty) {
28
+ return `Native${empty}Modules`;
29
+ }
30
+ // TODO(hongzhiyuan.hzy): make sure this is run before any other code (especially code access `NativeModules`)
31
+ // @ts-expect-error hack
32
+ if (typeof globalThis[__name('')] === 'undefined') {
33
+ // @ts-expect-error hack
34
+ globalThis[__name('')] = undefined;
35
+ }
36
+ }
37
+ lynx.registerDataProcessors = function (dataProcessorDefinition) {
38
+ let hasDefaultDataProcessorExecuted = false;
39
+ globalThis.processData = (data, processorName) => {
40
+ if (__PROFILE__) {
41
+ profileStart('processData');
42
+ }
43
+ let r;
44
+ try {
45
+ if (processorName) {
46
+ r = dataProcessorDefinition?.dataProcessors?.[processorName]?.(data) ?? data;
47
+ }
48
+ else {
49
+ r = dataProcessorDefinition?.defaultDataProcessor?.(data) ?? data;
50
+ }
51
+ }
52
+ catch (e) {
53
+ lynx.reportError(e);
54
+ r = {};
55
+ }
56
+ if (__PROFILE__) {
57
+ profileEnd();
58
+ }
59
+ if (hasDefaultDataProcessorExecuted === false) {
60
+ // @ts-expect-error todo: add types to i18n logic
61
+ if (globalThis.__I18N_RESOURCE_TRANSLATION__) {
62
+ r = {
63
+ ...r,
64
+ // @ts-expect-error todo: add types to i18n logic
65
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
66
+ __I18N_RESOURCE_TRANSLATION__: globalThis.__I18N_RESOURCE_TRANSLATION__,
67
+ };
68
+ }
69
+ // @ts-expect-error todo: add types to __EXTRACT_STR__
70
+ if (__EXTRACT_STR__) {
71
+ r = {
72
+ ...r,
73
+ // @ts-expect-error todo: add types to __EXTRACT_STR__
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
75
+ _EXTRACT_STR: __EXTRACT_STR_IDENT_FLAG__,
76
+ };
77
+ }
78
+ }
79
+ if (processorName) { }
80
+ else {
81
+ hasDefaultDataProcessorExecuted = true;
82
+ }
83
+ return r;
84
+ };
85
+ };
86
+ lynx.registerDataProcessors();
87
+ }
88
+ }
89
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/element-template/lynx/env.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,QAAQ,GAA4B,EAAE,CAAC;QAC3C,IAAI,UAAU,GAA4B,EAAE,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,MAAM,GAAI,cAEd;gBACA,EAAE,EAAE,EAAE,OAAO,CAAC;YAChB,IAAI,MAAM,EAAE,CAAC;gBACX,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACjC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,IAAI,CAAC,UAAU,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,UAAU,EAAE,CAAC;QACjD,IAAI,CAAC,sBAAsB,GAAG,cAAY,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG;QAChB,kCAAkC;SACnC,CAAC;QAEF,IAAI,CAAC,2BAA2B,GAAG,UACjC,SAAiB,EACjB,MAAW;YAEX,kBAAkB,CAAC,CAAC,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC;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iD;4BACjD,mEAAmE;4BACnE,6BAA6B,EAAE,UAAU,CAAC,6BAA6B;yBACxE,CAAC;oBACJ,CAAC;oBAED,sDAAsD;oBACtD,IAAI,eAAe,EAAE,CAAC;wBACpB,CAAC,GAAG;4BACF,GAAG,CAAC;4BACJ,sDAAsD;4BACtD,mEAAmE;4BACnE,YAAY,EAAE,0BAA0B;yBACzC,CAAC;oBACJ,CAAC;gBACH,CAAC;gBAED,IAAI,aAAa,EAAE,CAAC,CAAA,CAAC;qBAChB,CAAC;oBACJ,+BAA+B,GAAG,IAAI,CAAC;gBACzC,CAAC;gBAED,OAAO,CAAC,CAAC;YACX,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ declare const PerformanceTimingKeys: readonly ["updateSetStateTrigger", "updateDiffVdomStart", "updateDiffVdomEnd", "diffVdomStart", "diffVdomEnd", "packChangesStart", "packChangesEnd", "parseChangesStart", "parseChangesEnd", "patchChangesStart", "patchChangesEnd", "hydrateParsePayloadStart", "hydrateParsePayloadEnd", "mtsRenderStart", "mtsRenderEnd"];
2
+ declare const PerformanceTimingFlags: {
3
+ readonly reactLynxHydrate: "react_lynx_hydrate";
4
+ };
5
+ declare const PipelineOrigins: {
6
+ readonly reactLynxHydrate: "reactLynxHydrate";
7
+ readonly updateTriggeredByBts: "updateTriggeredByBts";
8
+ };
9
+ type PipelineOrigin = typeof PipelineOrigins[keyof typeof PipelineOrigins];
10
+ /**
11
+ * @deprecated used by old timing api(setState timing flag)
12
+ */
13
+ declare const PerfSpecificKey = "__lynx_timing_flag";
14
+ declare let globalPipelineOptions: PipelineOptions | undefined;
15
+ /**
16
+ * @deprecated used by old timing api(setState timing flag)
17
+ */
18
+ declare function markTimingLegacy(key: typeof PerformanceTimingKeys[number], timingFlag_?: string): void;
19
+ declare function beginPipeline(needTimestamps: boolean, pipelineOrigin: PipelineOrigin, timingFlag?: string): void;
20
+ declare function setPipeline(pipeline: PipelineOptions | undefined): void;
21
+ declare function markTiming(timestampKey: typeof PerformanceTimingKeys[number], force?: boolean): void;
22
+ declare function initTimingAPI(): void;
23
+ export {};