@lynx-js/react 0.129.0 → 0.129.2

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 (282) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +3 -4
  4. package/refresh/.turbo/turbo-build.log +1 -1
  5. package/runtime/__test__/core/globalProps.test.ts +27 -6
  6. package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
  7. package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
  8. package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
  9. package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
  10. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
  11. package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
  12. package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
  13. package/runtime/__test__/element-template/native/mts-destroy.test.ts +88 -0
  14. package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
  15. package/runtime/__test__/element-template/native/reload.test.ts +118 -2
  16. package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
  17. package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
  18. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
  19. package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
  20. package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
  21. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
  22. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +212 -7
  23. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
  24. package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
  25. package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
  26. package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
  27. package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
  28. package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
  29. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
  30. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
  31. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
  32. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
  33. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +309 -26
  34. package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
  35. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
  36. package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
  37. package/runtime/__test__/shared/component-stack.test.ts +211 -0
  38. package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
  39. package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
  40. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
  41. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
  42. package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
  43. package/runtime/__test__/snapshot/preact.test.jsx +0 -3
  44. package/runtime/__test__/snapshot/ref.test.jsx +30 -0
  45. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
  46. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
  47. package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
  48. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
  49. package/runtime/lazy/element-template-internal.js +1 -1
  50. package/runtime/lazy/internal.js +1 -1
  51. package/runtime/lazy/jsx-dev-runtime.js +1 -1
  52. package/runtime/lazy/jsx-runtime.js +1 -1
  53. package/runtime/lazy/legacy-react-runtime.js +1 -1
  54. package/runtime/lazy/react-lepus.js +1 -1
  55. package/runtime/lazy/react.js +1 -1
  56. package/runtime/lib/core/capture-main-thread-object.js +2 -1
  57. package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
  58. package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
  59. package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
  60. package/runtime/lib/core/globalProps.js +1 -1
  61. package/runtime/lib/core/globalProps.js.map +1 -1
  62. package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
  63. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  64. package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
  65. package/runtime/lib/core/lynx-data-processors.js +3 -0
  66. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  67. package/runtime/lib/core/runtime-destroy.js +1 -1
  68. package/runtime/lib/core/runtime-destroy.js.map +1 -1
  69. package/runtime/lib/document.js +0 -5
  70. package/runtime/lib/document.js.map +1 -1
  71. package/runtime/lib/element-template/background/attr-slots.js +5 -2
  72. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  73. package/runtime/lib/element-template/background/commit-hook.js +11 -12
  74. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  75. package/runtime/lib/element-template/background/destroy.js +16 -11
  76. package/runtime/lib/element-template/background/destroy.js.map +1 -1
  77. package/runtime/lib/element-template/background/hydrate.js +23 -0
  78. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  79. package/runtime/lib/element-template/client/root.d.ts +1 -1
  80. package/runtime/lib/element-template/client/root.js.map +1 -1
  81. package/runtime/lib/element-template/debug/alog.d.ts +1 -1
  82. package/runtime/lib/element-template/debug/alog.js +4 -1
  83. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  84. package/runtime/lib/element-template/index.d.ts +2 -2
  85. package/runtime/lib/element-template/index.js.map +1 -1
  86. package/runtime/lib/element-template/internal.d.ts +2 -2
  87. package/runtime/lib/element-template/internal.js +1 -14
  88. package/runtime/lib/element-template/internal.js.map +1 -1
  89. package/runtime/lib/element-template/lynx/env.js.map +1 -1
  90. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
  91. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
  92. package/runtime/lib/element-template/native/flush.d.ts +1 -0
  93. package/runtime/lib/element-template/native/flush.js +9 -0
  94. package/runtime/lib/element-template/native/flush.js.map +1 -0
  95. package/runtime/lib/element-template/native/main-thread-api.js +3 -7
  96. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
  97. package/runtime/lib/element-template/native/mts-destroy.js +8 -2
  98. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
  99. package/runtime/lib/element-template/native/patch-listener.js +57 -50
  100. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  101. package/runtime/lib/element-template/native/reload-background.js +1 -1
  102. package/runtime/lib/element-template/native/reload-background.js.map +1 -1
  103. package/runtime/lib/element-template/native/reload-main-thread.js +35 -10
  104. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  105. package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
  106. package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
  107. package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
  108. package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
  109. package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
  110. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  111. package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
  112. package/runtime/lib/element-template/protocol/opcodes.js +1 -0
  113. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
  114. package/runtime/lib/element-template/protocol/types.d.ts +7 -1
  115. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  116. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
  117. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
  118. package/runtime/lib/element-template/runtime/patch.js +31 -2
  119. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  120. package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
  121. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
  122. package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
  123. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  124. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
  125. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
  126. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
  127. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
  128. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
  129. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -1
  130. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +380 -50
  131. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  132. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +3 -2
  133. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
  134. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  135. package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
  136. package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
  137. package/runtime/lib/internal.d.ts +1 -1
  138. package/runtime/lib/internal.js +1 -1
  139. package/runtime/lib/internal.js.map +1 -1
  140. package/runtime/lib/lynx-api.d.ts +2 -125
  141. package/runtime/lib/lynx-api.js.map +1 -1
  142. package/runtime/lib/shared/component-stack.d.ts +0 -4
  143. package/runtime/lib/shared/component-stack.js +21 -5
  144. package/runtime/lib/shared/component-stack.js.map +1 -1
  145. package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
  146. package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
  147. package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
  148. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  149. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
  150. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
  151. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
  152. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
  153. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  154. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
  155. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  156. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
  157. package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
  158. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  159. package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
  160. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  161. package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
  162. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  163. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
  164. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  165. package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
  166. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  167. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
  168. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  169. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
  170. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  171. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  172. package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
  173. package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
  174. package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
  175. package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
  176. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
  177. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
  178. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
  179. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
  180. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  181. package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
  182. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  183. package/runtime/package.json +2 -3
  184. package/runtime/src/core/capture-main-thread-object.ts +2 -1
  185. package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
  186. package/runtime/src/core/globalProps.ts +1 -1
  187. package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
  188. package/runtime/src/core/lynx-data-processors.ts +124 -1
  189. package/runtime/src/core/runtime-destroy.ts +1 -1
  190. package/runtime/src/document.ts +0 -6
  191. package/runtime/src/element-template/background/attr-slots.ts +5 -1
  192. package/runtime/src/element-template/background/commit-hook.ts +18 -12
  193. package/runtime/src/element-template/background/destroy.ts +16 -13
  194. package/runtime/src/element-template/background/hydrate.ts +23 -0
  195. package/runtime/src/element-template/client/root.ts +1 -3
  196. package/runtime/src/element-template/debug/alog.ts +5 -2
  197. package/runtime/src/element-template/index.ts +2 -2
  198. package/runtime/src/element-template/internal.ts +1 -20
  199. package/runtime/src/element-template/lynx/env.ts +1 -1
  200. package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
  201. package/runtime/src/element-template/native/flush.ts +10 -0
  202. package/runtime/src/element-template/native/main-thread-api.ts +3 -6
  203. package/runtime/src/element-template/native/mts-destroy.ts +7 -2
  204. package/runtime/src/element-template/native/patch-listener.ts +62 -57
  205. package/runtime/src/element-template/native/reload-background.ts +1 -1
  206. package/runtime/src/element-template/native/reload-main-thread.ts +32 -11
  207. package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
  208. package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
  209. package/runtime/src/element-template/protocol/opcodes.ts +1 -0
  210. package/runtime/src/element-template/protocol/types.ts +8 -13
  211. package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
  212. package/runtime/src/element-template/runtime/patch.ts +38 -0
  213. package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
  214. package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
  215. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
  216. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
  217. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +456 -50
  218. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +14 -4
  219. package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
  220. package/runtime/src/element-template/types.d.ts +6 -0
  221. package/runtime/src/internal.ts +1 -1
  222. package/runtime/src/lynx-api.ts +2 -124
  223. package/runtime/src/shared/component-stack.ts +22 -5
  224. package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
  225. package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
  226. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
  227. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
  228. package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
  229. package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
  230. package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
  231. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
  232. package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
  233. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
  234. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
  235. package/runtime/src/worklet-runtime/README.md +30 -10
  236. package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
  237. package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
  238. package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
  239. package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
  240. package/runtime/types/types.d.ts +2 -1
  241. package/runtime/vitest.config.ts +0 -2
  242. package/testing-library/.turbo/turbo-build.log +7 -7
  243. package/testing-library/src/__tests__/act.test.jsx +0 -7
  244. package/testing-library/src/__tests__/alog.test.jsx +12 -54
  245. package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
  246. package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
  247. package/testing-library/src/__tests__/worklet.test.jsx +49 -0
  248. package/transform/.turbo/turbo-build$colon$wasm.log +133 -297
  249. package/transform/__test__/defines.spec.js +30 -0
  250. package/transform/__test__/fixture.spec.js +11 -11
  251. package/transform/__test__/main-thread-object-compat.spec.js +111 -0
  252. package/transform/__test__/object-methods.spec.js +79 -0
  253. package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
  254. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
  255. package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
  256. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +63 -57
  257. package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
  258. package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
  259. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
  260. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
  261. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +11 -6
  262. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +12 -6
  263. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +14 -5
  264. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +17 -6
  265. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
  266. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
  267. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
  268. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
  269. package/transform/dist/wasm.cjs +1 -1
  270. package/transform/package.json +0 -1
  271. package/transform/src/lib.rs +1 -1
  272. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +167 -69
  273. package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
  274. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  275. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +226 -132
  276. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
  277. package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
  278. package/runtime/lib/snapshot/worklet/hmr.js +0 -28
  279. package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
  280. package/runtime/src/snapshot/worklet/hmr.ts +0 -34
  281. /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
  282. /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
@@ -37,6 +37,12 @@ declare global {
37
37
  // explicit flush options. It is not an Element Template handle.
38
38
  function __FlushElementTree(element: undefined, options: FlushOptions): void;
39
39
 
40
+ // Materializes the instance on demand; parent mounting and layout may still be pending.
41
+ function __GetElementByAttrSlot(
42
+ templateInstance: ElementTemplateHandle,
43
+ attrSlotIndex: number,
44
+ ): ElementRef | null;
45
+
40
46
  function __CreateElementTemplate(
41
47
  templateKey: string,
42
48
  bundleUrl: string | null | undefined,
@@ -98,8 +98,8 @@ export const __ComponentIsPolyfill: FC<{ is: string }> = /* @__PURE__ */ factory
98
98
  export { loadLazyBundle } from './core/lynx/lazy-bundle.js';
99
99
 
100
100
  export { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';
101
- export { registerWorkletOnBackground } from './snapshot/worklet/hmr.js';
102
101
 
102
+ export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
103
103
  export { captureMainThreadObject } from './core/capture-main-thread-object.js';
104
104
 
105
105
  if (__DEV__) {
@@ -10,6 +10,7 @@ import { createGlobalProps } from './core/globalProps.js';
10
10
  import type { GlobalProps } from './core/globalProps.js';
11
11
  import { useLynxGlobalEventListener } from './core/hooks/useLynxGlobalEventListener.js';
12
12
  import { factory, withInitDataInState } from './core/initData.js';
13
+ import type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from './core/lynx-data-processors.js';
13
14
  import { __root } from './root.js';
14
15
  import { profileEnd, profileStart } from './shared/profile.js';
15
16
  import { LifecycleConstant } from './snapshot/lifecycle/constant.js';
@@ -338,132 +339,9 @@ export const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.us
338
339
  export const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void = /* @__PURE__ */ _GlobalProps
339
340
  .useChanged();
340
341
 
341
- /**
342
- * The interface you can extends so that the `defaultDataProcessor` parameter can be customized
343
- *
344
- * Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
345
- *
346
- * @public
347
- *
348
- * @group Types
349
- */
350
- export interface InitDataRaw {}
351
- /**
352
- * The interface you can extends so that the `defaultDataProcessor` returning value can be customized
353
- *
354
- * Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
355
- *
356
- * @public
357
- *
358
- * @group Types
359
- */
360
- export interface InitData {}
361
-
342
+ export type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw };
362
343
  export { withInitDataInState };
363
344
 
364
- /**
365
- * The data processors that registered with {@link Lynx.registerDataProcessors}.
366
- *
367
- * @example
368
- *
369
- * Extending `dataProcessors` interface
370
- *
371
- * ```ts
372
- * import type { DataProcessors as WellKnownDataProcessors } from '@lynx-js/react';
373
- *
374
- * declare module '@lynx-js/react' {
375
- * interface DataProcessors extends WellKnownDataProcessors {
376
- * foo(bar: string): number;
377
- * }
378
- * }
379
- * ```
380
- *
381
- * Then you can use `lynx.registerDataProcessors` with types.
382
- *
383
- * ```js
384
- * lynx.registerDataProcessors({
385
- * dataProcessors: {
386
- * foo(bar) {
387
- * return 1;
388
- * }
389
- * }
390
- * })
391
- * ```
392
- *
393
- * @public
394
- *
395
- * @group Types
396
- */
397
- export interface DataProcessors {
398
- /**
399
- * Optional processor to override screen metrics used by the app
400
- *
401
- * @param metrics - The physical screen dimensions in pixels
402
- *
403
- * @returns New screen dimensions to be used by the app
404
- *
405
- * @example
406
- *
407
- * ```ts
408
- * lynx.registerDataProcessors({
409
- * dataProcessors: {
410
- * getScreenMetricsOverride: (metrics) => {
411
- * // Force a specific aspect ratio
412
- * return {
413
- * width: metrics.width,
414
- * height: metrics.width * (16/9)
415
- * };
416
- * }
417
- * }
418
- * });
419
- * ```
420
- */
421
- getScreenMetricsOverride?(metrics: {
422
- /**
423
- * The physical pixel width of the screen
424
- */
425
- width: number;
426
- /**
427
- * The physical pixel height of the screen
428
- */
429
- height: number;
430
- }): { width: number; height: number };
431
-
432
- /**
433
- * Custom unknown data processors.
434
- *
435
- * @remarks
436
- *
437
- * You may extends the `DataProcessors` interface for better TypeScript types. See {@link DataProcessors}.
438
- */
439
- [processorName: string]: (...args: any[]) => any;
440
- }
441
-
442
- /**
443
- * Definition of DataProcessor(s)
444
- * @public
445
- *
446
- * @group Types
447
- */
448
- export interface DataProcessorDefinition {
449
- /**
450
- * You can custom input and output type of `defaultDataProcessor` by extends {@link InitDataRaw} and {@link InitData}
451
- *
452
- * Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
453
- *
454
- * @param rawInitData - initData passed from native code
455
- * @returns
456
- * @public
457
- */
458
- defaultDataProcessor?: (rawInitData: InitDataRaw) => InitData;
459
- /**
460
- * Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
461
- *
462
- * @public
463
- */
464
- dataProcessors?: DataProcessors;
465
- }
466
-
467
345
  /**
468
346
  * APIs under `lynx` global variable that added by ReactLynx.
469
347
  *
@@ -44,7 +44,7 @@ interface PatchedVNode extends VNode {
44
44
  /**
45
45
  * Get human readable name of the component/dom node
46
46
  */
47
- export function getDisplayName(vnode: PatchedVNode): string {
47
+ function getVNodeDisplayName(vnode: PatchedVNode): string {
48
48
  if (vnode.type === Fragment) {
49
49
  return 'Fragment';
50
50
  } else if (typeof vnode.type == 'function') {
@@ -81,6 +81,7 @@ const renderStack: PatchedVNode[] = [];
81
81
  * optimization. In these cases the `_owner` will be different.
82
82
  */
83
83
  let ownerStack: PatchedVNode[] = [];
84
+ let didInstallComponentStack = false;
84
85
 
85
86
  /**
86
87
  * Get the currently rendered `vnode`
@@ -108,7 +109,7 @@ export function getOwnerStack(vnode: PatchedVNode): string {
108
109
  }
109
110
 
110
111
  return stack.reduce((acc, owner) => {
111
- acc += ` in ${getDisplayName(owner)}`;
112
+ acc += ` in ${getVNodeDisplayName(owner)}`;
112
113
 
113
114
  const source = owner.__source;
114
115
  if (source) {
@@ -125,6 +126,13 @@ export function getOwnerStack(vnode: PatchedVNode): string {
125
126
  * debug messages for `this.setState` where the `vnode` is `undefined`.
126
127
  */
127
128
  export function setupComponentStack(): void {
129
+ renderStack.length = 0;
130
+ ownerStack = [];
131
+ if (didInstallComponentStack) {
132
+ return;
133
+ }
134
+ didInstallComponentStack = true;
135
+
128
136
  /* eslint-disable @typescript-eslint/unbound-method */
129
137
  const oldDiff = options[DIFF];
130
138
  const oldDiffed = options[DIFFED];
@@ -135,9 +143,15 @@ export function setupComponentStack(): void {
135
143
 
136
144
  options[DIFFED] = vnode => {
137
145
  if (isPossibleOwner(vnode)) {
138
- ownerStack.pop();
146
+ const ownerIndex = ownerStack.lastIndexOf(vnode);
147
+ if (ownerIndex !== -1) {
148
+ ownerStack.length = ownerIndex;
149
+ }
150
+ const renderIndex = renderStack.lastIndexOf(vnode);
151
+ if (renderIndex !== -1) {
152
+ renderStack.length = renderIndex;
153
+ }
139
154
  }
140
- renderStack.pop();
141
155
  if (oldDiffed) oldDiffed(vnode);
142
156
  };
143
157
 
@@ -149,7 +163,10 @@ export function setupComponentStack(): void {
149
163
  };
150
164
 
151
165
  options[ROOT] = (vnode, parent) => {
152
- ownerStack = [];
166
+ if (!(parent as { parentNode?: unknown } | null | undefined)?.parentNode) {
167
+ renderStack.length = 0;
168
+ ownerStack = [];
169
+ }
153
170
  if (oldRoot) oldRoot(vnode, parent);
154
171
  };
155
172
 
@@ -8,6 +8,7 @@ import { delayedEvents } from './event/delayEvents.js';
8
8
  import { delayedLifecycleEvents } from './event/delayLifecycleEvents.js';
9
9
  import { globalCommitTaskMap } from './patch/commit.js';
10
10
  import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js';
11
+ import { delayedUiOps } from './ref/delay.js';
11
12
  import { profileEnd, profileStart } from '../../shared/profile.js';
12
13
  import { withSyncEffectFlush } from '../../utils.js';
13
14
  import { resetSnapshotMainThreadFunctionRuntime } from '../worklet/call/runOnMainThread.js';
@@ -20,25 +21,29 @@ function destroyBackground(): void {
20
21
 
21
22
  deinitGlobalSnapshotPatch();
22
23
 
23
- withSyncEffectFlush(() => {
24
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
25
- render(null, __root as any);
26
- });
24
+ try {
25
+ withSyncEffectFlush(() => {
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
27
+ render(null, __root as any);
28
+ });
27
29
 
28
- globalCommitTaskMap.forEach(task => {
29
- task();
30
- });
31
- globalCommitTaskMap.clear();
32
- // Clear delayed events which should not be executed after destroyed.
33
- // This is important when the page is performing a reload.
34
- delayedLifecycleEvents.length = 0;
35
- if (delayedEvents) {
36
- delayedEvents.length = 0;
37
- }
38
- resetSnapshotBackgroundFunctionRuntime();
39
- resetSnapshotMainThreadFunctionRuntime();
40
- if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
41
- profileEnd();
30
+ globalCommitTaskMap.forEach(task => {
31
+ task();
32
+ });
33
+ } finally {
34
+ globalCommitTaskMap.clear();
35
+ // Clear delayed events which should not be executed after destroyed.
36
+ // This is important when the page is performing a reload.
37
+ delayedLifecycleEvents.length = 0;
38
+ if (delayedEvents) {
39
+ delayedEvents.length = 0;
40
+ }
41
+ delayedUiOps.length = 0;
42
+ resetSnapshotBackgroundFunctionRuntime();
43
+ resetSnapshotMainThreadFunctionRuntime();
44
+ if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
45
+ profileEnd();
46
+ }
42
47
  }
43
48
  }
44
49
 
@@ -18,7 +18,6 @@ export const SnapshotOperation = {
18
18
  nodesRefRemoveChild: 6,
19
19
 
20
20
  DEV_ONLY_AddSnapshot: 100,
21
- DEV_ONLY_RegisterWorklet: 101,
22
21
  DEV_ONLY_SetSnapshotEntryName: 102,
23
22
  } as const;
24
23
 
@@ -64,10 +63,6 @@ export const SnapshotOperationParams: Record<number, { name: string; params: str
64
63
  'snapshotCreator', /* string */
65
64
  ],
66
65
  },
67
- [SnapshotOperation.DEV_ONLY_RegisterWorklet]: {
68
- name: 'DEV_ONLY_RegisterWorklet',
69
- params: ['hash', /* string */ 'fnStr' /* string */],
70
- },
71
66
  [SnapshotOperation.DEV_ONLY_SetSnapshotEntryName]: {
72
67
  name: 'DEV_ONLY_SetSnapshotEntryName',
73
68
  params: ['uniqID', /* string */ 'entryName' /* string */],
@@ -161,16 +161,6 @@ export function snapshotPatchApply(snapshotPatch: SnapshotPatch, commitId: numbe
161
161
  }
162
162
  break;
163
163
  }
164
- // case SnapshotOperation.DEV_ONLY_RegisterWorklet: {
165
- // // HMR-related
166
- // if (__DEV__) {
167
- // const hash: string = snapshotPatch[++i];
168
- // const fnStr: string = snapshotPatch[++i];
169
- // const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);
170
- // registerWorklet('main-thread', hash, fn);
171
- // }
172
- // break;
173
- // }
174
164
  }
175
165
  }
176
166
  }
@@ -36,72 +36,76 @@ function updateMainThread(
36
36
  }
37
37
 
38
38
  setPipeline(patchOptions.pipelineOptions);
39
- markTiming('mtsRenderStart');
40
- markTiming('parseChangesStart');
41
- const parsedData = JSON.parse(data) as PatchList;
42
- const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;
39
+ try {
40
+ markTiming('mtsRenderStart');
41
+ markTiming('parseChangesStart');
42
+ const parsedData = JSON.parse(data) as PatchList;
43
+ const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;
43
44
 
44
- if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
45
- console.alog?.(
46
- '[ReactLynxDebug] BTS -> MTS updateMainThread:\n' + JSON.stringify(
47
- {
48
- data: {
49
- ...parsedData,
50
- patchList: parsedData.patchList.map(patch => ({
51
- ...patch,
52
- snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),
53
- })),
45
+ if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
46
+ console.alog?.(
47
+ '[ReactLynxDebug] BTS -> MTS updateMainThread:\n' + JSON.stringify(
48
+ {
49
+ data: {
50
+ ...parsedData,
51
+ patchList: parsedData.patchList.map(patch => ({
52
+ ...patch,
53
+ snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),
54
+ })),
55
+ },
56
+ patchOptions,
54
57
  },
55
- patchOptions,
56
- },
57
- null,
58
- 2,
59
- ),
60
- );
61
- }
62
-
63
- markTiming('parseChangesEnd');
64
- markTiming('patchChangesStart');
65
- if (patchOptions.isHydration) {
66
- setMainThreadHydrating(true);
67
- }
68
- try {
69
- for (const { snapshotPatch, id } of patchList) {
70
- __pendingListUpdates.clearAttachedLists();
71
- if (snapshotPatch) {
72
- snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
73
- }
74
- __pendingListUpdates.flush();
75
- // console.debug('********** Lepus updatePatch:');
76
- // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
58
+ null,
59
+ 2,
60
+ ),
61
+ );
77
62
  }
78
- } finally {
79
- markTiming('patchChangesEnd');
80
- markTiming('mtsRenderEnd');
63
+
64
+ markTiming('parseChangesEnd');
65
+ markTiming('patchChangesStart');
81
66
  if (patchOptions.isHydration) {
82
- setMainThreadHydrating(false);
67
+ setMainThreadHydrating(true);
83
68
  }
84
- }
85
- applyRefQueue();
86
- if (delayedRunOnMainThreadData && isMtsEnabled()) {
87
- setEomShouldFlushElementTree(false);
88
- for (const data of delayedRunOnMainThreadData) {
89
- try {
90
- runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
91
- /* v8 ignore next 3 */
92
- } catch (e) {
93
- lynx.reportError(e as Error);
69
+ try {
70
+ for (const { snapshotPatch, id } of patchList) {
71
+ __pendingListUpdates.clearAttachedLists();
72
+ if (snapshotPatch) {
73
+ snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
74
+ }
75
+ __pendingListUpdates.flush();
76
+ // console.debug('********** Lepus updatePatch:');
77
+ // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
78
+ }
79
+ } finally {
80
+ markTiming('patchChangesEnd');
81
+ markTiming('mtsRenderEnd');
82
+ if (patchOptions.isHydration) {
83
+ setMainThreadHydrating(false);
94
84
  }
95
85
  }
96
- setEomShouldFlushElementTree(true);
97
- }
98
- if (patchOptions.pipelineOptions) {
99
- flushOptions.pipelineOptions = patchOptions.pipelineOptions;
100
- }
101
- __FlushElementTree(__page, flushOptions);
86
+ applyRefQueue();
87
+ if (delayedRunOnMainThreadData && isMtsEnabled()) {
88
+ setEomShouldFlushElementTree(false);
89
+ for (const data of delayedRunOnMainThreadData) {
90
+ try {
91
+ runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
92
+ /* v8 ignore next 3 */
93
+ } catch (e) {
94
+ lynx.reportError(e as Error);
95
+ }
96
+ }
97
+ setEomShouldFlushElementTree(true);
98
+ }
99
+ if (patchOptions.pipelineOptions) {
100
+ flushOptions.pipelineOptions = patchOptions.pipelineOptions;
101
+ }
102
+ __FlushElementTree(__page, flushOptions);
102
103
 
103
- if (flowIds) {
104
- lynx.performance.profileEnd();
104
+ if (flowIds) {
105
+ lynx.performance.profileEnd();
106
+ }
107
+ } finally {
108
+ setPipeline(undefined);
105
109
  }
106
110
  }
107
111
 
@@ -79,4 +79,4 @@ interface RefProxy extends RefProxyForwardedMethods<RefProxy> {}
79
79
  /**
80
80
  * @internal
81
81
  */
82
- export { RefProxy, runDelayedUiOps, shouldDelayUiOps };
82
+ export { delayedUiOps, RefProxy, runDelayedUiOps, shouldDelayUiOps };
@@ -17,26 +17,6 @@ export interface ListUpdateInfo {
17
17
  onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;
18
18
  }
19
19
 
20
- // class ListUpdateInfoDiffing implements ListUpdateInfo {
21
- // private oldChildNodes: SnapshotInstance[];
22
- // constructor(private list: SnapshotInstance) {
23
- // this.oldChildNodes = list.childNodes;
24
- // }
25
- // flush(): void {
26
- // Object.defineProperty(SnapshotInstance.prototype, "key", {
27
- // get: function () {
28
- // return this.values[0]["item-key"];
29
- // },
30
- // });
31
-
32
- // }
33
- // onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance | undefined): void {}
34
- // onRemoveChild(child: SnapshotInstance): void {}
35
- // onSetAttribute(child: SnapshotInstance, attr: any): void {
36
- // throw new Error("Method not implemented.");
37
- // }
38
- // }
39
-
40
20
  interface InsertAction {
41
21
  position: number;
42
22
  type: string;
@@ -58,30 +38,14 @@ interface ListOperations {
58
38
  export class ListUpdateInfoRecording implements ListUpdateInfo {
59
39
  constructor(private list: SnapshotInstance) {
60
40
  this.oldChildNodes = list.childNodes;
61
- // this.oldChildNodesSet = new Set(this.oldChildNodes);
62
41
  }
63
42
 
64
- // private __commitAndReset() {
65
- // (this.__pendingAttributes ??= []).push(this.__toAttribute());
66
- // this.oldChildNodes = this.list.childNodes;
67
- // this.oldChildNodesSet = new Set(this.oldChildNodes);
68
- // this.removeChild1.clear();
69
- // this.removeChild2.clear();
70
- // this.insertBefore.clear();
71
- // this.appendChild.length = 0;
72
- // this.platformInfoUpdate.clear();
73
- // }
74
-
75
43
  flush(): undefined | number {
76
44
  if (!this.list.__elements) {
77
45
  return undefined;
78
46
  }
79
47
  const elementIndex = this.list.__snapshot_def.slot[0]![1];
80
48
  const listElement = this.list.__elements[elementIndex]!;
81
- // this.__pendingAttributes?.forEach(pendingAttribute => {
82
- // __SetAttribute(listElement, "update-list-info", pendingAttribute);
83
- // __FlushElementTree(listElement);
84
- // });
85
49
  const updateListInfo = this.__toAttribute();
86
50
 
87
51
  if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
@@ -132,7 +96,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
132
96
  }
133
97
 
134
98
  private oldChildNodes: SnapshotInstance[];
135
- // private oldChildNodesSet: Set<SnapshotInstance>;
136
99
  private removeChild = new Set<SnapshotInstance>();
137
100
  private insertBefore = new Map<SnapshotInstance, SnapshotInstance[]>(); // insert V before K
138
101
  private appendChild = [] as SnapshotInstance[];
@@ -140,15 +103,9 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
140
103
 
141
104
  onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void {
142
105
  if (newNode.parentNode) {
143
- // if (!this.oldChildNodesSet.has(newNode)) {
144
- // this.__commitAndReset();
145
- // }
146
106
  this.removeChild.add(newNode);
147
107
  }
148
108
  if (existingNode) {
149
- // if (!this.oldChildNodesSet.has(existingNode)) {
150
- // this.__commitAndReset();
151
- // }
152
109
  const newChildren = this.insertBefore.get(existingNode) ?? [];
153
110
  newChildren.push(newNode);
154
111
  this.insertBefore.set(existingNode, newChildren);
@@ -158,9 +115,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
158
115
  }
159
116
 
160
117
  onRemoveChild(child: SnapshotInstance): void {
161
- // if (!this.oldChildNodesSet.has(child)) {
162
- // this.__commitAndReset();
163
- // }
164
118
  this.removeChild.add(child);
165
119
  }
166
120
 
@@ -254,12 +208,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
254
208
  }
255
209
 
256
210
  toJSON(): [ListOperations] {
257
- // if (this.__pendingAttributes) {
258
- // return [...this.__pendingAttributes, this.__toAttribute()];
259
- // } else {
260
- // return [this.__toAttribute()];
261
- // }
262
-
263
211
  return [this.__toAttribute()] as const;
264
212
  }
265
213
  }
@@ -138,7 +138,7 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
138
138
 
139
139
  setPipeline(options?.pipelineOptions);
140
140
  markTiming('updateDiffVdomStart');
141
- {
141
+ try {
142
142
  __pendingListUpdates.clearAttachedLists();
143
143
  renderMainThread();
144
144
  // As said by codename `firstScreenEventIdSwap`, this swap will only be used for event remap,
@@ -152,17 +152,19 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
152
152
  // always call this before `__FlushElementTree`
153
153
  __pendingListUpdates.flush();
154
154
  applyRefQueue();
155
- }
156
155
 
157
- if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
158
- onFirstScreenTreeReady();
159
- }
156
+ if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
157
+ onFirstScreenTreeReady();
158
+ }
160
159
 
161
- flushOptions.triggerDataUpdated = true;
162
- markTiming('updateDiffVdomEnd');
160
+ flushOptions.triggerDataUpdated = true;
161
+ markTiming('updateDiffVdomEnd');
163
162
 
164
- if (typeof lepusng_gc === 'function') {
165
- lepusng_gc();
163
+ if (typeof lepusng_gc === 'function') {
164
+ lepusng_gc();
165
+ }
166
+ } finally {
167
+ setPipeline(undefined);
166
168
  }
167
169
  }
168
170
 
@@ -99,64 +99,6 @@ export function diffArrayLepus<A extends Typed, B extends Typed>(
99
99
  return result;
100
100
  }
101
101
 
102
- // export function diffIterableLepus<A extends Typed, B extends Typed>(
103
- // before: A[],
104
- // after: Iterable<B>,
105
- // isSameType: (a: A, b: B) => boolean,
106
- // onDiffChildren: (a: A, b: B) => void
107
- // ): DiffResult<B> {
108
- // let returnResult = EMPTY_DIFF_RESULT as DiffResult<B>;
109
- // let lastPlacedIndex = 0;
110
- // const result: DiffResult<B> = {
111
- // $$diff: true,
112
- // i: {},
113
- // r: [],
114
- // m: {},
115
- // };
116
- // const beforeMap: Record<string, Set<[A, number]>> = {};
117
-
118
- // for (let i = 0; i < before.length; i++) {
119
- // let node = before[i];
120
- // (beforeMap[node.type] ??= new Set()).add([node, i]);
121
- // }
122
-
123
- // let i = 0;
124
- // for (const afterNode of after) {
125
- // const beforeNodes = beforeMap[afterNode.type];
126
- // let beforeNode: [A, number];
127
-
128
- // if (beforeNodes && (([beforeNode] = beforeNodes), beforeNode) && isSameType(beforeNode[0], afterNode)) {
129
- // // Reuse old node
130
- // beforeNodes.delete(beforeNode);
131
-
132
- // const oldIndex = beforeNode[1];
133
- // onDiffChildren(beforeNode[0], afterNode);
134
- // if (oldIndex < lastPlacedIndex) {
135
- // result.m[oldIndex] = i;
136
- // returnResult = result;
137
- // i++;
138
- // continue;
139
- // } else {
140
- // lastPlacedIndex = oldIndex;
141
- // }
142
- // } else {
143
- // // Create new node
144
- // result.i[i] = afterNode;
145
- // returnResult = result;
146
- // }
147
- // i++;
148
- // }
149
- // // delete
150
- // for (const k in beforeMap) {
151
- // for (const [, i] of beforeMap[k]) {
152
- // result.r.push(i);
153
- // returnResult = result;
154
- // }
155
- // }
156
-
157
- // return result;
158
- // }
159
-
160
102
  export function diffArrayAction<T, K>(
161
103
  before: T[],
162
104
  diffResult: DiffResult<K>,