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