@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # @lynx-js/react
2
2
 
3
+ ## 0.121.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Disable vnode reuse of different slot index in preact's diff, fixing a bug that `__RemoveElement` was called with mismatched parent and child element. ([#2664](https://github.com/lynx-family/lynx-stack/pull/2664))
8
+
9
+ - Fix list update indices when existing items are updated after inserting siblings before them. ([#2518](https://github.com/lynx-family/lynx-stack/pull/2518))
10
+
11
+ ## 0.121.0
12
+
13
+ ### Minor Changes
14
+
15
+ - Support `React.createElement(type, props, children)` API. ([#2360](https://github.com/lynx-family/lynx-stack/pull/2360))
16
+
17
+ ```jsx
18
+ React.createElement('view', { style }, <text>hello</text>);
19
+ // equivalent to
20
+ <view style={style}>
21
+ <text>hello</text>
22
+ </view>;
23
+
24
+ React.createElement(MyComponent, { style }, <view />);
25
+ // equivalent to
26
+ <MyComponent style={style}>
27
+ <view />
28
+ </MyComponent>;
29
+ ```
30
+
31
+ ### Patch Changes
32
+
33
+ - Clear transient snapshot child props when removed snapshot subtrees are detached, preventing compiled `$*` child references from retaining deleted list holder or list item subtrees after removal. ([#2590](https://github.com/lynx-family/lynx-stack/pull/2590))
34
+
35
+ - Add `createPortal` for rendering a subtree into a different ReactLynx element identified by a `NodesRef`. ([#2543](https://github.com/lynx-family/lynx-stack/pull/2543))
36
+
37
+ ```tsx
38
+ function App() {
39
+ const [host, setHost] = useState(null);
40
+ return (
41
+ <view>
42
+ <view ref={setHost} />
43
+ {host && createPortal(<text>hi</text>, host)}
44
+ </view>
45
+ );
46
+ }
47
+ ```
48
+
49
+ - Default `fireEvent` to `bubbles: true` for the TouchEvent family in testing-library to match Lynx runtime semantics, and stop reassigning the read-only `Event.prototype` accessors which threw `TypeError` in strict mode. ([#2532](https://github.com/lynx-family/lynx-stack/pull/2532))
50
+
51
+ - Set `bundle-url` on lazy bundle border elements. ([#2537](https://github.com/lynx-family/lynx-stack/pull/2537))
52
+
53
+ - Stop warning when `runWorklet` receives an invalid or missing main-thread function object. Invalid worklet contexts are still ignored, but nullish handler values no longer produce noisy `MainThreadFunction: Invalid function object` console output. ([#2586](https://github.com/lynx-family/lynx-stack/pull/2586))
54
+
55
+ - Retain main-thread worklet context references before offscreen snapshot elements are materialized, so event, ref, gesture, and spread callbacks stay alive until the DOM update path can attach them. ([#2592](https://github.com/lynx-family/lynx-stack/pull/2592))
56
+
57
+ - Update the @lynx-js/tasm dependency to 0.0.39 and align React template attribute descriptors with it. ([#2643](https://github.com/lynx-family/lynx-stack/pull/2643))
58
+
59
+ - Avoid retaining transformed nested worklet contexts after worklet transformation. ([#2591](https://github.com/lynx-family/lynx-stack/pull/2591))
60
+
61
+ Nested worklets transformed by the worklet runtime now keep their context recovery metadata through a weak reference, preventing cached transformed worklet functions from keeping list-item worklet contexts alive.
62
+
3
63
  ## 0.120.0
4
64
 
5
65
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react",
3
- "version": "0.120.0",
3
+ "version": "0.121.1",
4
4
  "description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,6 +37,22 @@
37
37
  "types": "./runtime/lib/document.d.ts",
38
38
  "default": "./runtime/lib/document.js"
39
39
  },
40
+ "./element-template": {
41
+ "types": "./runtime/lib/element-template/index.d.ts",
42
+ "default": "./runtime/lib/element-template/index.js"
43
+ },
44
+ "./element-template/internal": {
45
+ "types": "./runtime/lib/element-template/internal.d.ts",
46
+ "default": "./runtime/lib/element-template/internal.js"
47
+ },
48
+ "./element-template/jsx-runtime": {
49
+ "types": "./runtime/lib/element-template/jsx-runtime/index.d.ts",
50
+ "default": "./runtime/lib/element-template/jsx-runtime/index.js"
51
+ },
52
+ "./element-template/jsx-dev-runtime": {
53
+ "types": "./runtime/lib/element-template/jsx-dev-runtime/index.d.ts",
54
+ "default": "./runtime/lib/element-template/jsx-dev-runtime/index.js"
55
+ },
40
56
  "./jsx-runtime": {
41
57
  "types": "./runtime/jsx-runtime/index.d.ts",
42
58
  "lazy": "./runtime/lazy/jsx-runtime.js",
@@ -56,12 +72,12 @@
56
72
  "default": "./runtime/lepus/jsx-runtime/index.js"
57
73
  },
58
74
  "./hooks": {
59
- "types": "./runtime/lib/snapshot/hooks/react.d.ts",
60
- "default": "./runtime/lib/snapshot/hooks/react.js"
75
+ "types": "./runtime/lib/core/hooks/react.d.ts",
76
+ "default": "./runtime/lib/core/hooks/react.js"
61
77
  },
62
78
  "./lepus/hooks": {
63
- "types": "./runtime/lib/snapshot/hooks/react.d.ts",
64
- "default": "./runtime/lib/snapshot/hooks/mainThread.js"
79
+ "types": "./runtime/lib/core/hooks/react.d.ts",
80
+ "default": "./runtime/lib/core/hooks/mainThread.js"
65
81
  },
66
82
  "./lepus": {
67
83
  "types": "./runtime/lepus/index.d.ts",
@@ -132,10 +148,10 @@
132
148
  "./runtime/lazy/import.d.ts"
133
149
  ],
134
150
  "hooks": [
135
- "./runtime/lib/snapshot/hooks/react.d.ts"
151
+ "./runtime/lib/core/hooks/react.d.ts"
136
152
  ],
137
153
  "lepus/hooks": [
138
- "./runtime/lib/snapshot/hooks/react.d.ts"
154
+ "./runtime/lib/core/hooks/react.d.ts"
139
155
  ],
140
156
  "internal": [
141
157
  "./runtime/lib/internal.d.ts"
@@ -143,6 +159,18 @@
143
159
  "internal/document": [
144
160
  "./runtime/lib/document.d.ts"
145
161
  ],
162
+ "element-template": [
163
+ "./runtime/lib/element-template/index.d.ts"
164
+ ],
165
+ "element-template/internal": [
166
+ "./runtime/lib/element-template/internal.d.ts"
167
+ ],
168
+ "element-template/jsx-runtime": [
169
+ "./runtime/lib/element-template/jsx-runtime/index.d.ts"
170
+ ],
171
+ "element-template/jsx-dev-runtime": [
172
+ "./runtime/lib/element-template/jsx-dev-runtime/index.d.ts"
173
+ ],
146
174
  "jsx-runtime": [
147
175
  "./runtime/jsx-runtime/index.d.ts"
148
176
  ],
@@ -192,7 +220,7 @@
192
220
  "README.zh.md"
193
221
  ],
194
222
  "dependencies": {
195
- "preact": "npm:@lynx-js/internal-preact@10.29.1-20260424024911-12b794f"
223
+ "preact": "npm:@lynx-js/internal-preact@10.29.1-20260519060144-e6da44c"
196
224
  },
197
225
  "devDependencies": {
198
226
  "@lynx-js/types": "3.7.0",
@@ -18,6 +18,7 @@ export const {
18
18
  cloneElement,
19
19
  createContext,
20
20
  createElement,
21
+ createPortal,
21
22
  createRef,
22
23
  forwardRef,
23
24
  isValidElement,
@@ -16,6 +16,7 @@ export const {
16
16
  PureComponent,
17
17
  Suspense,
18
18
  cloneElement,
19
+ createPortal,
19
20
  createContext,
20
21
  createElement,
21
22
  createRef,
@@ -0,0 +1,8 @@
1
+ export interface GlobalCommitContext<Ops = unknown[]> {
2
+ ops: Ops;
3
+ flushOptions: FlushOptions;
4
+ flowIds?: number[];
5
+ }
6
+ export declare const globalCommitContext: GlobalCommitContext;
7
+ export declare function resetGlobalCommitContext(): void;
8
+ export declare function takeGlobalFlushOptions(): FlushOptions;
@@ -0,0 +1,18 @@
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
+ export const globalCommitContext = {
5
+ ops: [],
6
+ flushOptions: {},
7
+ };
8
+ export function resetGlobalCommitContext() {
9
+ globalCommitContext.ops = [];
10
+ globalCommitContext.flushOptions = {};
11
+ delete globalCommitContext.flowIds;
12
+ }
13
+ export function takeGlobalFlushOptions() {
14
+ const flushOptions = globalCommitContext.flushOptions;
15
+ globalCommitContext.flushOptions = {};
16
+ return flushOptions;
17
+ }
18
+ //# sourceMappingURL=commit-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-context.js","sourceRoot":"","sources":["../../src/core/commit-context.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAQ1D,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACtD,GAAG,EAAE,EAAE;IACP,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,CAAC,GAAG,GAAG,EAAE,CAAC;IAC7B,mBAAmB,CAAC,YAAY,GAAG,EAAE,CAAC;IACtC,OAAO,mBAAmB,CAAC,OAAO,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;IACtD,mBAAmB,CAAC,YAAY,GAAG,EAAE,CAAC;IACtC,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { VNode } from 'preact';
2
+ export interface ForceRootRenderOptions {
3
+ getRootVNode: () => unknown;
4
+ setRootVNode: (vnode: VNode) => void;
5
+ render: () => void;
6
+ }
7
+ export declare function runWithForceRootRender({ getRootVNode, setRootVNode, render }: ForceRootRenderOptions): void;
@@ -0,0 +1,40 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { options as preactOptions } from 'preact';
5
+ import { COMPONENT, DIFF2, FORCE, ORIGINAL } from '../shared/render-constants.js';
6
+ export function runWithForceRootRender({ getRootVNode, setRootVNode, render }) {
7
+ // Preact can skip root render if `_original` is unchanged; bumping it keeps
8
+ // backend force renders aligned with Preact's own rerender path.
9
+ const rootVNode = getRootVNode();
10
+ if (rootVNode) {
11
+ const newVNode = Object.assign({}, rootVNode);
12
+ if (newVNode[ORIGINAL] != null) {
13
+ newVNode[ORIGINAL] += 1;
14
+ setRootVNode(newVNode);
15
+ }
16
+ }
17
+ const oldDiff = preactOptions[DIFF2];
18
+ preactOptions[DIFF2] = (vnode, oldVNode) => {
19
+ /* v8 ignore start */
20
+ if (oldDiff) {
21
+ oldDiff(vnode, oldVNode);
22
+ }
23
+ /* v8 ignore stop */
24
+ const c = oldVNode[COMPONENT];
25
+ if (c) {
26
+ c[FORCE] = true;
27
+ }
28
+ else {
29
+ // mount phase of a new Component
30
+ // `isNew` is true, no need to set FORCE
31
+ }
32
+ };
33
+ try {
34
+ render();
35
+ }
36
+ finally {
37
+ preactOptions[DIFF2] = oldDiff;
38
+ }
39
+ }
40
+ //# sourceMappingURL=forceRootRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forceRootRender.js","sourceRoot":"","sources":["../../src/core/forceRootRender.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAQlF,MAAM,UAAU,sBAAsB,CACpC,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAA0B;IAE9D,4EAA4E;IAC5E,iEAAiE;IACjE,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAU,CAAC;QACvD,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;YAC/B,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACxB,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACrC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,KAAY,EAAE,QAAe,EAAE,EAAE;QACvD,qBAAqB;QACrB,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3B,CAAC;QACD,oBAAoB;QAEpB,MAAM,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,iCAAiC;YACjC,wCAAwC;QAC1C,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;IACX,CAAC;YAAS,CAAC;QACT,aAAa,CAAC,KAAK,CAAC,GAAG,OAAkD,CAAC;IAC5E,CAAC;AACH,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { Consumer, Provider } from 'preact';
2
+ import type { useLynxGlobalEventListener } from './hooks/useLynxGlobalEventListener.js';
3
+ type Getter<T> = {
4
+ [key in keyof T]: () => T[key];
5
+ };
6
+ interface GlobalPropsRuntimeDeps {
7
+ createContext: typeof import('preact').createContext;
8
+ useState: typeof import('preact/hooks').useState;
9
+ createElement: typeof import('preact/compat').createElement;
10
+ useLynxGlobalEventListener: typeof useLynxGlobalEventListener;
11
+ }
12
+ interface GlobalPropsApi<Data> {
13
+ Provider: Provider<Data>;
14
+ Consumer: Consumer<Data>;
15
+ use: () => Data;
16
+ useChanged: (callback: (data: Data) => void) => void;
17
+ }
18
+ /**
19
+ * The interface you can extends so that the `useGlobalProps` returning value can be customized
20
+ *
21
+ * @public
22
+ */
23
+ export interface GlobalProps {
24
+ }
25
+ export interface UpdateGlobalPropsOptions {
26
+ forceRerender?: (() => void) | undefined;
27
+ }
28
+ export declare function isGlobalPropsEventMode(): boolean;
29
+ export declare function createGlobalProps<Data = GlobalProps>(deps: GlobalPropsRuntimeDeps): Getter<GlobalPropsApi<Data>>;
30
+ export declare function updateGlobalProps(newData: Record<string, any>, { forceRerender }?: UpdateGlobalPropsOptions): void;
31
+ export {};
@@ -0,0 +1,55 @@
1
+ import { factory } from './initData.js';
2
+ export function isGlobalPropsEventMode() {
3
+ return typeof __GLOBAL_PROPS_MODE__ !== 'undefined' && __GLOBAL_PROPS_MODE__ === 'event';
4
+ }
5
+ export function createGlobalProps(deps) {
6
+ return isGlobalPropsEventMode()
7
+ ? /* @__PURE__ */ factory(deps, '__globalProps', 'onGlobalPropsChanged')
8
+ : /* @__PURE__ */ createFallbackGlobalProps(deps.useLynxGlobalEventListener);
9
+ }
10
+ export function updateGlobalProps(newData, { forceRerender } = {}) {
11
+ if (isGlobalPropsEventMode()) {
12
+ // COW keeps Provider / Consumer state readers aligned in event mode.
13
+ lynx.__globalProps = Object.assign({}, lynx.__globalProps, newData);
14
+ }
15
+ else {
16
+ Object.assign(lynx.__globalProps, newData);
17
+ if (forceRerender) {
18
+ void Promise.resolve().then(forceRerender);
19
+ }
20
+ }
21
+ lynxCoreInject.tt.GlobalEventEmitter.emit('onGlobalPropsChanged', [lynx.__globalProps]);
22
+ }
23
+ function warnGlobalPropsMode() {
24
+ if (typeof __LEPUS__ !== 'undefined' && !__LEPUS__ && typeof __DEV__ !== 'undefined' && __DEV__) {
25
+ console.warn(`No need to use this API when 'globalPropsMode' is not 'event', `
26
+ + `updates will be triggered automatically by full re-render. `
27
+ + `Please set 'globalPropsMode' to 'event' to enable optimized updates.`);
28
+ }
29
+ }
30
+ function FallbackProvider({ children }) {
31
+ warnGlobalPropsMode();
32
+ return children;
33
+ }
34
+ function FallbackConsumer({ children }) {
35
+ warnGlobalPropsMode();
36
+ return children(lynx.__globalProps);
37
+ }
38
+ function useFallbackGlobalProps() {
39
+ warnGlobalPropsMode();
40
+ return lynx.__globalProps;
41
+ }
42
+ function createFallbackGlobalProps(useListener) {
43
+ const useChanged = (callback) => {
44
+ if (typeof __LEPUS__ === 'undefined' || !__LEPUS__) {
45
+ useListener('onGlobalPropsChanged', callback);
46
+ }
47
+ };
48
+ return {
49
+ Provider: () => FallbackProvider,
50
+ Consumer: () => FallbackConsumer,
51
+ use: () => useFallbackGlobalProps,
52
+ useChanged: () => useChanged,
53
+ };
54
+ }
55
+ //# sourceMappingURL=globalProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalProps.js","sourceRoot":"","sources":["../../src/core/globalProps.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA+BxC,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,qBAAqB,KAAK,WAAW,IAAI,qBAAqB,KAAK,OAAO,CAAC;AAC3F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAA4B;IAE5B,OAAO,sBAAsB,EAAE;QAC7B,CAAC,CAAC,eAAe,CAAC,OAAO,CACvB,IAAI,EACJ,eAAe,EACf,sBAAsB,CACvB;QACD,CAAC,CAAC,eAAe,CAAC,yBAAyB,CAAO,IAAI,CAAC,0BAA0B,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,OAA4B,EAC5B,EAAE,aAAa,KAA+B,EAAE;IAEhD,IAAI,sBAAsB,EAAE,EAAE,CAAC;QAC7B,qEAAqE;QACrE,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;SA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AE,CAAC,gBAAkC;QAClD,GAAG,EAAE,GAAG,EAAE,CAAC,sBAAoC;QAC/C,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU;KAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './mainThreadImpl.js';
@@ -0,0 +1,7 @@
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 { installMainThreadHooks } from './mainThreadImpl.js';
5
+ installMainThreadHooks();
6
+ export * from './mainThreadImpl.js';
7
+ //# sourceMappingURL=mainThread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mainThread.js","sourceRoot":"","sources":["../../../src/core/hooks/mainThread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,sBAAsB,EAAE,CAAC;AAEzB,cAAc,qBAAqB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { ErrorInfo, PreactContext } from 'preact';
2
2
  import type { Dispatch, useEffect as useEffectType, useErrorBoundary as useErrorBoundaryType, useImperativeHandle as useImperativeHandleType, useLayoutEffect as useLayoutEffectType } from 'preact/hooks';
3
+ declare function installMainThreadHooks(): void;
3
4
  declare function useState<S>(initialState: S | (() => S)): [S, Dispatch<unknown>];
4
5
  declare function useReducer<S, A>(_reducer: (prevState: S, action: A) => S, initialState: S | (() => S), init?: (initialState: S) => S): [S, Dispatch<A>];
5
6
  declare function useRef<T>(initialValue?: T): {
@@ -14,4 +15,4 @@ declare function useId(): string;
14
15
  declare const useEffect: typeof useEffectType;
15
16
  declare const useLayoutEffect: typeof useLayoutEffectType;
16
17
  declare const useImperativeHandle: typeof useImperativeHandleType;
17
- export { useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
18
+ export { installMainThreadHooks, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
@@ -2,48 +2,59 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  /**
5
- * Implements hooks in main thread.
5
+ * Implements hooks in the main thread.
6
6
  * This module is modified from preact/hooks
7
7
  *
8
8
  * internal-preact/hooks/dist/hooks.mjs
9
9
  */
10
10
  import { options } from 'preact';
11
+ import { CHILDREN, COMPONENT, DIFF, DIFFED, HOOK, HOOKS, LIST, MASK, PARENT, PENDING_EFFECTS, RENDER, ROOT, VALUE, VNODE, } from '../../shared/render-constants.js';
11
12
  import { noop } from '../../utils.js';
12
- import { CHILDREN, COMPONENT, DIFF, DIFFED, HOOK, HOOKS, LIST, MASK, PARENT, PENDING_EFFECTS, RENDER, ROOT, VALUE, VNODE, } from '../renderToOpcodes/constants.js';
13
13
  let currentIndex;
14
14
  let currentComponent;
15
15
  let currentHook;
16
- const oldBeforeDiff = options[DIFF];
17
- const oldBeforeRender = options[RENDER];
18
- const oldAfterDiff = options[DIFFED];
19
- const oldRoot = options[ROOT];
20
- options[DIFF] = function (vnode) {
21
- currentComponent = null;
22
- if (oldBeforeDiff)
23
- oldBeforeDiff(vnode);
24
- };
25
- /* v8 ignore start */
26
- options[ROOT] = function (vnode, parentDom) {
27
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
28
- if (vnode && parentDom[CHILDREN] && parentDom[CHILDREN][MASK]) {
29
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
30
- vnode[MASK] = parentDom[CHILDREN][MASK];
16
+ let hooksInstalled = false;
17
+ let oldBeforeDiff;
18
+ let oldBeforeRender;
19
+ let oldAfterDiff;
20
+ let oldRoot;
21
+ function installMainThreadHooks() {
22
+ if (hooksInstalled) {
23
+ return;
31
24
  }
32
- if (oldRoot)
33
- oldRoot(vnode, parentDom);
34
- };
35
- /* v8 ignore stop */
36
- options[RENDER] = function (vnode) {
37
- if (oldBeforeRender)
38
- oldBeforeRender(vnode);
39
- currentComponent = vnode[COMPONENT];
40
- currentIndex = 0;
41
- };
42
- options[DIFFED] = function (vnode) {
43
- if (oldAfterDiff)
44
- oldAfterDiff(vnode);
45
- currentComponent = null;
46
- };
25
+ hooksInstalled = true;
26
+ oldBeforeDiff = options[DIFF];
27
+ oldBeforeRender = options[RENDER];
28
+ oldAfterDiff = options[DIFFED];
29
+ oldRoot = options[ROOT];
30
+ options[DIFF] = function (vnode) {
31
+ currentComponent = null;
32
+ if (oldBeforeDiff)
33
+ oldBeforeDiff(vnode);
34
+ };
35
+ /* v8 ignore start */
36
+ options[ROOT] = function (vnode, parentDom) {
37
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
38
+ if (vnode && parentDom[CHILDREN] && parentDom[CHILDREN][MASK]) {
39
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
40
+ vnode[MASK] = parentDom[CHILDREN][MASK];
41
+ }
42
+ if (oldRoot)
43
+ oldRoot(vnode, parentDom);
44
+ };
45
+ /* v8 ignore stop */
46
+ options[RENDER] = function (vnode) {
47
+ if (oldBeforeRender)
48
+ oldBeforeRender(vnode);
49
+ currentComponent = vnode[COMPONENT];
50
+ currentIndex = 0;
51
+ };
52
+ options[DIFFED] = function (vnode) {
53
+ if (oldAfterDiff)
54
+ oldAfterDiff(vnode);
55
+ currentComponent = null;
56
+ };
57
+ }
47
58
  function getHookState(index, type) {
48
59
  if (options[HOOK]) {
49
60
  options[HOOK](currentComponent, index, currentHook || type);
@@ -148,5 +159,5 @@ function useId() {
148
159
  const useEffect = noop;
149
160
  const useLayoutEffect = noop;
150
161
  const useImperativeHandle = noop;
151
- export { useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
152
- //# sourceMappingURL=mainThread.js.map
162
+ export { installMainThreadHooks, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
163
+ //# sourceMappingURL=mainThreadImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mainThreadImpl.js","sourceRoot":"","sources":["../../../src/core/hooks/mainThreadImpl.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAUjC,OAAO,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,eAAe,EACf,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,GACN,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,IAAI,YAAoB,CAAC;AACzB,IAAI,gBAA8C,CAAC;AACnD,IAAI,WAAmB,CAAC;AACxB,IAAI,cAAc,GAAG,KAAK,CAAC;AAC3B,IAAI,aAAiD,CAAC;AACtD,IAAI,eAAmD,CAAC;AACxD,IAAI,YAAgD,CAAC;AACrD,IAAI,OAA2D,CAAC;AAEhE,SAAS,sBAAsB;IAC7B,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IACD,cAAc,GAAG,IAAI,CAAC;IACtB,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,KAAK;QAC5B,gBAAgB,GAAG,IAAI,CAAC;QACxB,IAAI,aAAa;YAAE,aAAa,CAAC,KAAK,CAAC,CAAC;I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License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { useCallback, useContext, useDebugValue, useErrorBoundary, useId, useImperativeHandle, useMemo, useEffect as usePreactEffect, useState as usePreactState, useReducer, useRef, } from 'preact/hooks';
5
- import { isProfiling, profileEnd, profileFlowId, profileStart } from '../debug/profile.js';
5
+ import { isProfiling, profileEnd, profileFlowId, profileStart } from '../../shared/profile.js';
6
6
  // Cache profiled wrappers by the original preact setter to preserve stable
7
7
  // identity without introducing extra hooks in component render flow.
8
8
  const stateSetterTraceCache = /* @__PURE__ */ isProfiling
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/core/hooks/react.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,mBAAmB,EACnB,OAAO,EACP,SAAS,IAAI,eAAe,EAC5B,QAAQ,IAAI,cAAc,EAC1B,UAAU,EACV,MAAM,GACP,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI/F,2EAA2E;AAC3E,qEAAqE;AACrE,MAAM,qBAAqB,GAA0D,eAAe,CAAC,WAAW;IAC9G,CAAC,CAAC,IAAI,OAAO,EAAoC;IACjD,CAAC,CAAC,SAAS,CAAC;AAEd,SAAS,gBAAgB,CAAC,MAAc,EAAE,KAAyB;IACjE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IACD,OAAO;QACL,MAAM;QACN,IAAI,EAAE;YACJ,KAAK;SACN;KACF,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CACxB,MAAsB,EACtB,SAAiB,EACjB,MAAc,EACd,KAAyB;IAEzB,MAAM,WAAW,GAAG,gBAAgB,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AC,iBAAiB;IACnB,CAAC,CAAC,eAAe,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,MAAM,eAAe,GAA4D,CAAC,cAAc,IAAI,WAAW,CAAC;IAC9G,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,eAAe,CAAC;AAEpB,OAAO;AACL,SAAS;AACT,QAAQ,EACR,UAAU,EACV,MAAM,EACN,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,GACN,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `useLynxGlobalEventListener` help you `addListener` as early as possible.
2
+ * `useLynxGlobalEventListener` helps you `addListener` as early as possible.
3
3
  *
4
4
  * @example
5
5
  *
@@ -1,9 +1,9 @@
1
1
  // Copyright 2024 The Lynx Authors. All rights reserved.
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
- import { useEffect, useMemo, useRef } from 'preact/hooks';
4
+ import { useEffect, useMemo, useRef } from '@lynx-js/react/hooks';
5
5
  /**
6
- * `useLynxGlobalEventListener` help you `addListener` as early as possible.
6
+ * `useLynxGlobalEventListener` helps you `addListener` as early as possible.
7
7
  *
8
8
  * @example
9
9
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLynxGlobalEventListener.js","sourceRoot":"","sources":["../../../src/core/hooks/useLynxGlobalEventListener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAiB,EACjB,QAAW;IAEX,iBAAiB,CAAC;IAElB,MAAM,eAAe,GAAG,MAAM,EAAe,CAAC;IAE9C,OAAO,CAAC,GAAG,EAAE;QACX,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC;YAC5B,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC;YACtD,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC7E,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACxE,eAAe,CAAC,OAAO,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC;gBAC5B,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC;gBACtD,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
@@ -1,13 +1,13 @@
1
1
  import type { Consumer, Context, Provider } from 'preact';
2
2
  import type { ComponentClass } from 'react';
3
- import { useLynxGlobalEventListener } from '../hooks/useLynxGlobalEventListener.js';
3
+ import type { useLynxGlobalEventListener } from './hooks/useLynxGlobalEventListener.js';
4
4
  type Getter<T> = {
5
5
  [key in keyof T]: () => T[key];
6
6
  };
7
7
  export declare function factory<Data>({ createContext, useState, createElement, useLynxGlobalEventListener: useListener }: {
8
8
  createContext: typeof import('preact').createContext;
9
9
  useState: typeof import('preact/hooks').useState;
10
- createElement: typeof import('preact').createElement;
10
+ createElement: typeof import('preact/compat').createElement;
11
11
  useLynxGlobalEventListener: typeof useLynxGlobalEventListener;
12
12
  }, prop: '__globalProps' | '__initData', eventName: string): Getter<{
13
13
  Context: Context<Data>;
@@ -1,5 +1,4 @@
1
- import { useLynxGlobalEventListener } from '../hooks/useLynxGlobalEventListener.js';
2
- import { globalFlushOptions } from '../lifecycle/patch/commit.js';
1
+ import { globalCommitContext } from './commit-context.js';
3
2
  // for better reuse if runtime is changed
4
3
  export function factory({ createContext, useState, createElement, useLynxGlobalEventListener: useListener }, prop, eventName) {
5
4
  const Context = createContext({});
@@ -7,7 +6,7 @@ export function factory({ createContext, useState, createElement, useLynxGlobalE
7
6
  const [__, set] = useState(lynx[prop]);
8
7
  const handleChange = () => {
9
8
  if (prop === '__initData') {
10
- globalFlushOptions.triggerDataUpdated = true;
9
+ globalCommitContext.flushOptions.triggerDataUpdated = true;
11
10
  }
12
11
  set(lynx[prop]);
13
12
  };
@@ -21,7 +20,7 @@ export function factory({ createContext, useState, createElement, useLynxGlobalE
21
20
  const [__, set] = useState(lynx[prop]);
22
21
  useChanged(() => {
23
22
  if (prop === '__initData') {
24
- globalFlushOptions.triggerDataUpdated = true;
23
+ globalCommitContext.flushOptions.triggerDataUpdated = true;
25
24
  }
26
25
  set(lynx[prop]);
27
26
  });
@@ -84,7 +83,7 @@ export function withInitDataInState(App) {
84
83
  if (!__LEPUS__) {
85
84
  lynx.getJSModule('GlobalEventEmitter').addListener('onDataChanged', this.h = (...args) => {
86
85
  const [newData] = args;
87
- globalFlushOptions.triggerDataUpdated = true;
86
+ globalCommitContext.flushOptions.triggerDataUpdated = true;
88
87
  this.setState(newData);
89
88
  });
90
89
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initData.js","sourceRoot":"","sources":["../../src/core/initData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAO1D,yCAAyC;AACzC,MAAM,UAAU,OAAO,CACrB,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,0BAA0B,EAAE,WAAW,EAKhF,EACD,IAAoC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,oBAAoB,CAAC,CAAC,cAAc,CACnD,eAAe,EACf,IAAI,CAAC,CAAE,CACR,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { DataProcessorDefinition, InitData, InitDataRaw } from '../lynx-api.js';
2
+ export declare function createProcessData(dataProcessorDefinition?: DataProcessorDefinition): (data: InitDataRaw, processorName?: string) => InitData | InitDataRaw;