@lynx-js/react 0.129.0 → 0.129.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 (206) hide show
  1. package/CHANGELOG.md +14 -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/hooks/useLynxGlobalEventListener.test.jsx +1 -1
  6. package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
  7. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
  8. package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
  9. package/runtime/__test__/element-template/native/mts-destroy.test.ts +83 -0
  10. package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
  11. package/runtime/__test__/element-template/native/reload.test.ts +31 -2
  12. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
  13. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +197 -7
  14. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
  15. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
  16. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
  17. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
  18. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
  19. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +121 -26
  20. package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
  21. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
  22. package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
  23. package/runtime/__test__/shared/component-stack.test.ts +211 -0
  24. package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
  25. package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
  26. package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
  27. package/runtime/__test__/snapshot/preact.test.jsx +0 -3
  28. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
  29. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
  30. package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
  31. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
  32. package/runtime/lazy/element-template-internal.js +0 -1
  33. package/runtime/lazy/internal.js +1 -1
  34. package/runtime/lazy/jsx-dev-runtime.js +1 -1
  35. package/runtime/lazy/jsx-runtime.js +1 -1
  36. package/runtime/lazy/legacy-react-runtime.js +1 -1
  37. package/runtime/lazy/react-lepus.js +1 -1
  38. package/runtime/lazy/react.js +1 -1
  39. package/runtime/lib/core/capture-main-thread-object.js +2 -1
  40. package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
  41. package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
  42. package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
  43. package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
  44. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  45. package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
  46. package/runtime/lib/core/lynx-data-processors.js +3 -0
  47. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  48. package/runtime/lib/core/runtime-destroy.js +1 -1
  49. package/runtime/lib/core/runtime-destroy.js.map +1 -1
  50. package/runtime/lib/document.js +0 -5
  51. package/runtime/lib/document.js.map +1 -1
  52. package/runtime/lib/element-template/background/commit-hook.js +11 -12
  53. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  54. package/runtime/lib/element-template/client/root.d.ts +1 -1
  55. package/runtime/lib/element-template/client/root.js.map +1 -1
  56. package/runtime/lib/element-template/index.d.ts +2 -2
  57. package/runtime/lib/element-template/index.js.map +1 -1
  58. package/runtime/lib/element-template/internal.d.ts +1 -1
  59. package/runtime/lib/element-template/internal.js +0 -13
  60. package/runtime/lib/element-template/internal.js.map +1 -1
  61. package/runtime/lib/element-template/lynx/env.js.map +1 -1
  62. package/runtime/lib/element-template/native/flush.d.ts +1 -0
  63. package/runtime/lib/element-template/native/flush.js +9 -0
  64. package/runtime/lib/element-template/native/flush.js.map +1 -0
  65. package/runtime/lib/element-template/native/main-thread-api.js +3 -7
  66. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
  67. package/runtime/lib/element-template/native/mts-destroy.js +8 -2
  68. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
  69. package/runtime/lib/element-template/native/patch-listener.js +57 -50
  70. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  71. package/runtime/lib/element-template/native/reload-main-thread.js +2 -1
  72. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  73. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  74. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
  75. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
  76. package/runtime/lib/element-template/runtime/patch.js +4 -0
  77. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  78. package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
  79. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
  80. package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
  81. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  82. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
  83. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
  84. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +1 -0
  85. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +41 -21
  86. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  87. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +1 -1
  88. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  89. package/runtime/lib/internal.d.ts +1 -1
  90. package/runtime/lib/internal.js +1 -1
  91. package/runtime/lib/internal.js.map +1 -1
  92. package/runtime/lib/lynx-api.d.ts +2 -125
  93. package/runtime/lib/lynx-api.js.map +1 -1
  94. package/runtime/lib/shared/component-stack.d.ts +0 -4
  95. package/runtime/lib/shared/component-stack.js +21 -5
  96. package/runtime/lib/shared/component-stack.js.map +1 -1
  97. package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
  98. package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
  99. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
  100. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
  101. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
  102. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
  103. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  104. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
  105. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  106. package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
  107. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  108. package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
  109. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  110. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
  111. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  112. package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
  113. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  114. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
  115. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  116. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
  117. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  118. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  119. package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
  120. package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
  121. package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
  122. package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
  123. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
  124. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
  125. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
  126. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
  127. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  128. package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
  129. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  130. package/runtime/package.json +2 -3
  131. package/runtime/src/core/capture-main-thread-object.ts +2 -1
  132. package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
  133. package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
  134. package/runtime/src/core/lynx-data-processors.ts +124 -1
  135. package/runtime/src/core/runtime-destroy.ts +1 -1
  136. package/runtime/src/document.ts +0 -6
  137. package/runtime/src/element-template/background/commit-hook.ts +18 -12
  138. package/runtime/src/element-template/client/root.ts +1 -3
  139. package/runtime/src/element-template/index.ts +2 -2
  140. package/runtime/src/element-template/internal.ts +0 -20
  141. package/runtime/src/element-template/lynx/env.ts +1 -1
  142. package/runtime/src/element-template/native/flush.ts +10 -0
  143. package/runtime/src/element-template/native/main-thread-api.ts +3 -6
  144. package/runtime/src/element-template/native/mts-destroy.ts +7 -2
  145. package/runtime/src/element-template/native/patch-listener.ts +62 -57
  146. package/runtime/src/element-template/native/reload-main-thread.ts +2 -1
  147. package/runtime/src/element-template/protocol/types.ts +0 -13
  148. package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
  149. package/runtime/src/element-template/runtime/patch.ts +5 -0
  150. package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
  151. package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
  152. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
  153. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +51 -21
  154. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +2 -2
  155. package/runtime/src/element-template/types.d.ts +6 -0
  156. package/runtime/src/internal.ts +1 -1
  157. package/runtime/src/lynx-api.ts +2 -124
  158. package/runtime/src/shared/component-stack.ts +22 -5
  159. package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
  160. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
  161. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
  162. package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
  163. package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
  164. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
  165. package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
  166. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
  167. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
  168. package/runtime/src/worklet-runtime/README.md +30 -10
  169. package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
  170. package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
  171. package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
  172. package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
  173. package/runtime/vitest.config.ts +0 -2
  174. package/testing-library/.turbo/turbo-build.log +6 -6
  175. package/testing-library/src/__tests__/act.test.jsx +0 -7
  176. package/testing-library/src/__tests__/alog.test.jsx +12 -54
  177. package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
  178. package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
  179. package/testing-library/src/__tests__/worklet.test.jsx +49 -0
  180. package/transform/.turbo/turbo-build$colon$wasm.log +98 -376
  181. package/transform/__test__/defines.spec.js +30 -0
  182. package/transform/__test__/object-methods.spec.js +79 -0
  183. package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
  184. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +56 -48
  185. package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
  186. package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
  187. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +6 -1
  188. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -1
  189. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +9 -0
  190. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +12 -1
  191. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +1 -1
  192. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +1 -1
  193. package/transform/dist/wasm.cjs +1 -1
  194. package/transform/package.json +0 -1
  195. package/transform/src/lib.rs +1 -1
  196. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +113 -42
  197. package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
  198. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  199. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +273 -66
  200. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
  201. package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
  202. package/runtime/lib/snapshot/worklet/hmr.js +0 -28
  203. package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
  204. package/runtime/src/snapshot/worklet/hmr.ts +0 -34
  205. /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
  206. /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
@@ -15,7 +15,7 @@ const EMPTY_ARR = [];
15
15
  const isArray = /* @__PURE__ */ Array.isArray;
16
16
  const assign = /* @__PURE__ */ Object.assign;
17
17
  // Global state for the current render pass
18
- let beforeDiff, beforeDiff2, afterDiff, renderHook, ummountHook;
18
+ let beforeDiff, beforeDiff2, afterDiff, renderHook, unmountHook;
19
19
  /**
20
20
  * Render Preact JSX + Components to an HTML string.
21
21
  * @param {VNode} vnode JSX Element / VNode to render
@@ -34,7 +34,7 @@ export function renderToString(vnode, context, into) {
34
34
  beforeDiff2 = options[DIFF2];
35
35
  afterDiff = options[DIFFED];
36
36
  renderHook = options[RENDER];
37
- ummountHook = options.unmount;
37
+ unmountHook = options.unmount;
38
38
  const parent = h(Fragment, null);
39
39
  parent[CHILDREN] = [vnode];
40
40
  const opcodes = [];
@@ -127,7 +127,7 @@ function _renderToString(vnode, context, slotIndex, selectValue, parent, opcodes
127
127
  _renderToString(child, context, slotIndex === true ? i : slotIndex, selectValue, parent, opcodes,
128
128
  /* v8 ignore start */
129
129
  __ENABLE_SSR__ ? opcodes.length : 0,
130
- /* v8 ignore end */
130
+ /* v8 ignore stop */
131
131
  into);
132
132
  }
133
133
  return;
@@ -197,7 +197,7 @@ function _renderToString(vnode, context, slotIndex, selectValue, parent, opcodes
197
197
  _renderToString(rendered, context, slotIndex, selectValue, vnode, opcodes,
198
198
  /* v8 ignore start */
199
199
  __ENABLE_SSR__ ? opcodes.length : 0,
200
- /* v8 ignore end */
200
+ /* v8 ignore stop */
201
201
  into);
202
202
  }
203
203
  catch (e) {
@@ -218,7 +218,7 @@ function _renderToString(vnode, context, slotIndex, selectValue, parent, opcodes
218
218
  _renderToString(rendered, context, slotIndex, selectValue, vnode, opcodes,
219
219
  /* v8 ignore start */
220
220
  __ENABLE_SSR__ ? opcodes.length : 0,
221
- /* v8 ignore end */
221
+ /* v8 ignore stop */
222
222
  into);
223
223
  }
224
224
  }
@@ -230,8 +230,8 @@ function _renderToString(vnode, context, slotIndex, selectValue, parent, opcodes
230
230
  if (afterDiff)
231
231
  afterDiff(vnode);
232
232
  vnode[PARENT] = undefined;
233
- if (ummountHook)
234
- ummountHook(vnode);
233
+ if (unmountHook)
234
+ unmountHook(vnode);
235
235
  }
236
236
  return;
237
237
  }
@@ -301,14 +301,14 @@ function _renderToString(vnode, context, slotIndex, selectValue, parent, opcodes
301
301
  _renderToString(children, context, _slotIndex, selectValue, vnode, opcodes,
302
302
  /* v8 ignore start */
303
303
  __ENABLE_SSR__ ? opcodes.length : 0,
304
- /* v8 ignore end */
304
+ /* v8 ignore stop */
305
305
  vnode);
306
306
  }
307
307
  if (afterDiff)
308
308
  afterDiff(vnode);
309
309
  vnode[PARENT] = undefined;
310
- if (ummountHook)
311
- ummountHook(vnode);
310
+ if (unmountHook)
311
+ unmountHook(vnode);
312
312
  if (__ENABLE_SSR__) {
313
313
  opcodes.push(__OpEnd);
314
314
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/snapshot/renderToOpcodes/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;GAIG;AAEH,cAAc;AAEd,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,SAAS,EACT,eAAe,EACf,IAAI,EACJ,KAAK,EACL,MAAM,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,MAAM,EACN,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,iBAAiB,GAClB,MAAM,kCAAkC,CAAC;AAE1C,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AAiB,EAAE,SAAiB;IAC3G,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,CAAC,WAAW,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC5B,IAAI,cAAc,EAAE,CAAC;QACnB,iGAAiG;QACjG,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,eAAe,cAAc,CAAC;AAC9B,MAAM,CAAC,MAAM,MAAM,GAA0B,cAAc,CAAC;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAA0B,cAAc,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Implements rendering to opcodes.\n * This module is modified from preact-render-to-string@6.0.3 to generate\n * opcodes instead of HTML strings for Lynx.\n */\n\n// @ts-nocheck\n\nimport { Fragment, h, options, isValidElement } from 'preact';\nimport { SnapshotInstance } from '../snapshot/snapshot.js';\n\nimport {\n BITS,\n CHILDREN,\n COMMIT,\n COMPONENT,\n COMPONENT_DIRTY,\n DIFF,\n DIFF2,\n DIFFED,\n GLOBAL_CONTEXT,\n NEXT_STATE,\n PARENT,\n RENDER,\n SKIP_EFFECTS,\n VNODE,\n HOOK,\n CHILD_DID_SUSPEND,\n} from '../../shared/render-constants.js';\n\n/** @typedef {import('preact').VNode} VNode */\n\nconst EMPTY_ARR = [];\nconst isArray = /* @__PURE__ */ Array.isArray;\nconst assign = /* @__PURE__ */ Object.assign;\n\n// Global state for the current render pass\nlet beforeDiff, beforeDiff2, afterDiff, renderHook, ummountHook;\n\n/**\n * Render Preact JSX + Components to an HTML string.\n * @param {VNode} vnode\tJSX Element / VNode to render\n * @param {object} [context] Initial root context object\n */\nexport function renderToString(vnode: any, context: any, into: SnapshotInstance): any[] {\n // Performance optimization: `renderToString` is synchronous and we\n // therefore don't execute any effects. To do that we pass an empty\n // array to `options._commit` (`__c`). But we can go one step further\n // and avoid a lot of dirty checks and allocations by setting\n // `options._skipEffects` (`__s`) too.\n const previousSkipEffects = options[SKIP_EFFECTS];\n options[SKIP_EFFECTS] = true;\n\n // store options hooks once before each synchronous render call\n beforeDiff = options[DIFF];\n beforeDiff2 = options[DIFF2];\n afterDiff = options[DIFFED];\n renderHook = options[RENDER];\n ummountHook = options.unmount;\n\n const parent = h(Fragment, null);\n parent[CHILDREN] = [vnode];\n\n const opcodes = [];\n\n try {\n _renderToString(\n vnode,\n context || EMPTY_OBJ,\n 0,\n undefined,\n parent,\n opcodes,\n 0,\n into,\n );\n } finally {\n // options._commit, we don't schedule any effects in this library right now,\n // so we can pass an empty queue to this hook.\n if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);\n options[SKIP_EFFECTS] = previousSkipEffects;\n EMPTY_ARR.length = 0;\n }\n\n return opcodes;\n}\n\n// Installed as setState/forceUpdate for function components\nfunction markAsDirty() {\n this[BITS] |= COMPONENT_DIRTY;\n}\n\nconst EMPTY_OBJ = {};\n\nexport const __OpBegin = 0;\nexport const __OpEnd = 1;\nexport const __OpAttr = 2;\nexport const __OpText = 3;\n\n/**\n * @param {VNode} vnode\n * @param {Record<string, unknown>} context\n */\nfunction renderClassComponent(vnode, context, globalContext) {\n const type = /** @type {import(\"preact\").ComponentClass<typeof vnode.props>} */ (vnode.type);\n\n let c;\n if (vnode[COMPONENT]) {\n c = vnode[COMPONENT];\n c.state = c[NEXT_STATE];\n } else {\n c = new type(vnode.props, context);\n }\n\n vnode[COMPONENT] = c;\n c[VNODE] = vnode;\n\n c.props = vnode.props;\n c.context = context;\n c[GLOBAL_CONTEXT] = globalContext;\n // turn off stateful re-rendering:\n c[BITS] |= COMPONENT_DIRTY;\n\n if (c.state == null) c.state = EMPTY_OBJ;\n\n if (c[NEXT_STATE] == null) {\n c[NEXT_STATE] = c.state;\n }\n\n if (type.getDerivedStateFromProps) {\n c.state = assign(\n {},\n c.state,\n type.getDerivedStateFromProps(c.props, c.state),\n );\n }\n\n if (renderHook) renderHook(vnode);\n\n return c.render(c.props, c.state, context);\n}\n\n/**\n * Recursively render VNodes to HTML.\n * @param {VNode|any} vnode\n * @param {any} context\n * @param {number | true} slotIndex\n * @param {any} selectValue\n * @param {VNode} parent\n * @param {any[]} opcodes\n * @param {number} opcodesLength\n * @param {SnapshotInstance} into\n */\nfunction _renderToString(\n vnode,\n context,\n slotIndex,\n selectValue,\n parent,\n opcodes,\n opcodesLength,\n into,\n) {\n // Ignore non-rendered VNodes/values\n if (vnode == null || vnode === true || vnode === false || vnode === '') {\n return;\n }\n\n let vnodeType = typeof vnode;\n // Text VNodes: escape as HTML\n if (vnodeType !== 'object') {\n if (vnodeType === 'function') return;\n renderToTextNode(into, vnode, opcodes, slotIndex);\n return;\n }\n\n // Recurse into children / Arrays\n if (isArray(vnode)) {\n parent[CHILDREN] = vnode;\n for (let i = 0; i < vnode.length; i++) {\n const child = vnode[i];\n if (child == null || typeof child === 'boolean') continue;\n\n _renderToString(\n child,\n context,\n slotIndex === true ? i : slotIndex,\n selectValue,\n parent,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore end */\n into,\n );\n }\n return;\n }\n\n // VNodes have {constructor:undefined} to prevent JSON injection:\n // if (vnode.constructor !== undefined) return;\n\n vnode[PARENT] = parent;\n if (beforeDiff) beforeDiff(vnode);\n if (beforeDiff2) beforeDiff2(vnode, EMPTY_OBJ);\n\n let type = vnode.type,\n props = vnode.props,\n cctx = context,\n contextType,\n rendered,\n component;\n\n // Invoke rendering on Components\n if (typeof type === 'function') {\n if (type === Fragment) {\n rendered = props.children;\n } else {\n contextType = type.contextType;\n if (contextType != null) {\n const provider = context[contextType.__c];\n cctx = provider ? provider.props.value : contextType.__;\n }\n\n if (type.prototype && typeof type.prototype.render === 'function') {\n rendered = /**#__NOINLINE__**/ renderClassComponent(vnode, cctx, context);\n component = vnode[COMPONENT];\n } else {\n component = {\n [VNODE]: vnode,\n props,\n context: cctx,\n [GLOBAL_CONTEXT]: context,\n // silently drop state updates\n setState: markAsDirty,\n forceUpdate: markAsDirty,\n [BITS]: COMPONENT_DIRTY,\n // hooks\n [HOOK]: [],\n };\n vnode[COMPONENT] = component;\n component.constructor = type;\n component.render = doRender;\n\n // If a hook invokes setState() to invalidate the component during rendering,\n // re-render it up to 25 times to allow \"settling\" of memoized states.\n let count = 0;\n while (component[BITS] & COMPONENT_DIRTY && count++ < 25) {\n component[BITS] &= ~COMPONENT_DIRTY;\n\n if (renderHook) renderHook(vnode);\n\n rendered = component.render(props, component.state, cctx);\n }\n component[BITS] |= COMPONENT_DIRTY;\n }\n\n if (component.getChildContext != null) {\n context = assign({}, context, component.getChildContext());\n }\n }\n\n // When a component returns a Fragment node we flatten it in core, so we\n // need to mirror that logic here too\n const isTopLevelFragment = rendered != null && rendered.type === Fragment\n && rendered.key == null;\n rendered = isTopLevelFragment ? rendered.props.children : rendered;\n\n let lastChild = into.__lastChild;\n // Recurse into children before invoking the after-diff hook\n try {\n _renderToString(\n rendered,\n context,\n slotIndex,\n selectValue,\n vnode,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore end */\n into,\n );\n } catch (e) {\n // clear existing children\n into.removeChildren(\n lastChild\n ? lastChild.__nextSibling\n : into.__firstChild,\n );\n if (e && typeof e === 'object' && e.then && component && /* _childDidSuspend */ component[CHILD_DID_SUSPEND]) {\n component[NEXT_STATE] = assign({}, component[NEXT_STATE], {\n /* _suspended */ __a: true,\n });\n if (component[BITS] & COMPONENT_DIRTY) {\n rendered = renderClassComponent(vnode, context);\n component = vnode[COMPONENT];\n\n if (__ENABLE_SSR__) {\n opcodes.length = opcodesLength;\n }\n _renderToString(\n rendered,\n context,\n slotIndex,\n selectValue,\n vnode,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore end */\n into,\n );\n }\n } else {\n throw e;\n }\n } finally {\n if (afterDiff) afterDiff(vnode);\n vnode[PARENT] = undefined;\n\n if (ummountHook) ummountHook(vnode);\n }\n\n return;\n }\n\n let children;\n let hasNamedChildren = false;\n\n // hack for runtime test\n if (process.env['NODE_ENV'] === 'test' && isValidElement(vnode) && typeof vnode.type === 'string') {\n vnode = Object.assign(new SnapshotInstance(type), vnode, { $$typeof: undefined });\n }\n // already inserted\n if (vnode.__parent) {\n vnode = new SnapshotInstance(type);\n }\n if (__ENABLE_SSR__) {\n opcodes.push(__OpBegin, vnode, slotIndex);\n }\n vnode.__slotIndex = slotIndex;\n into.insertBefore(vnode);\n\n for (const name in props) {\n const v = props[name];\n\n switch (name) {\n case 'children':\n children = v;\n continue;\n\n // VDOM-specific props\n /* c8 ignore next 5 */\n case 'key':\n case 'ref':\n case '__self':\n case '__source':\n continue;\n\n default: {\n if (name.startsWith('$')) {\n children ??= [];\n children[+name.slice(1)] = v;\n hasNamedChildren = true;\n continue;\n }\n }\n }\n\n // write this attribute to the buffer\n if (v != null && v !== false && typeof v !== 'function') {\n if (__ENABLE_SSR__) {\n opcodes.push(__OpAttr, name, v);\n }\n vnode.setAttribute(name, v);\n }\n }\n\n let childrenType = typeof children;\n if (childrenType === 'string' || childrenType === 'number') {\n // single text child\n renderToTextNode(vnode, children, opcodes, slotIndex);\n } else if (children != null && children !== false && children !== true) {\n // recurse into this element VNode's children\n let _slotIndex = slotIndex;\n if (hasNamedChildren) {\n // @ts-expect-error children must be an array\n if (children.length === 1) {\n children = children[0];\n _slotIndex = 0;\n } else {\n _slotIndex = true;\n }\n }\n _renderToString(\n children,\n context,\n _slotIndex,\n selectValue,\n vnode,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore end */\n vnode,\n );\n }\n\n if (afterDiff) afterDiff(vnode);\n vnode[PARENT] = undefined;\n if (ummountHook) ummountHook(vnode);\n\n if (__ENABLE_SSR__) {\n opcodes.push(__OpEnd);\n }\n vnode[CHILDREN] = undefined;\n\n return;\n}\n\n/** The `.render()` method for a PFC backing instance. */\nfunction doRender(props, state, context) {\n return this.constructor(props, context);\n}\n\nfunction renderToTextNode(into: SnapshotInstance, text: string | number, opcodes: Opcode[], slotIndex: number) {\n const textNode = new SnapshotInstance(null);\n textNode.__slotIndex = slotIndex;\n textNode.setAttribute(0, text);\n into.insertBefore(textNode);\n if (__ENABLE_SSR__) {\n // We need store the just created SnapshotInstance, or it will be lost when we leave the function\n text = [textNode, text];\n opcodes.push(__OpText, text, slotIndex);\n }\n}\n\nexport default renderToString;\nexport const render: typeof renderToString = renderToString;\nexport const renderToStaticMarkup: typeof renderToString = renderToString;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/snapshot/renderToOpcodes/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;GAIG;AAEH,cAAc;AAEd,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,SAAS,EACT,eAAe,EACf,IAAI,EACJ,KAAK,EACL,MAAM,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,MAAM,EACN,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,iBAAiB,GAClB,MAAM,kCAAkC,CAAC;AAE1C,8CAA8C;AAE9C,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC;AAC9C,MA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,SAAS,CAAC;IACjC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC5B,IAAI,cAAc,EAAE,CAAC;QACnB,iGAAiG;QACjG,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,eAAe,cAAc,CAAC;AAC9B,MAAM,CAAC,MAAM,MAAM,GAA0B,cAAc,CAAC;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAA0B,cAAc,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Implements rendering to opcodes.\n * This module is modified from preact-render-to-string@6.0.3 to generate\n * opcodes instead of HTML strings for Lynx.\n */\n\n// @ts-nocheck\n\nimport { Fragment, h, options, isValidElement } from 'preact';\nimport { SnapshotInstance } from '../snapshot/snapshot.js';\n\nimport {\n BITS,\n CHILDREN,\n COMMIT,\n COMPONENT,\n COMPONENT_DIRTY,\n DIFF,\n DIFF2,\n DIFFED,\n GLOBAL_CONTEXT,\n NEXT_STATE,\n PARENT,\n RENDER,\n SKIP_EFFECTS,\n VNODE,\n HOOK,\n CHILD_DID_SUSPEND,\n} from '../../shared/render-constants.js';\n\n/** @typedef {import('preact').VNode} VNode */\n\nconst EMPTY_ARR = [];\nconst isArray = /* @__PURE__ */ Array.isArray;\nconst assign = /* @__PURE__ */ Object.assign;\n\n// Global state for the current render pass\nlet beforeDiff, beforeDiff2, afterDiff, renderHook, unmountHook;\n\n/**\n * Render Preact JSX + Components to an HTML string.\n * @param {VNode} vnode\tJSX Element / VNode to render\n * @param {object} [context] Initial root context object\n */\nexport function renderToString(vnode: any, context: any, into: SnapshotInstance): any[] {\n // Performance optimization: `renderToString` is synchronous and we\n // therefore don't execute any effects. To do that we pass an empty\n // array to `options._commit` (`__c`). But we can go one step further\n // and avoid a lot of dirty checks and allocations by setting\n // `options._skipEffects` (`__s`) too.\n const previousSkipEffects = options[SKIP_EFFECTS];\n options[SKIP_EFFECTS] = true;\n\n // store options hooks once before each synchronous render call\n beforeDiff = options[DIFF];\n beforeDiff2 = options[DIFF2];\n afterDiff = options[DIFFED];\n renderHook = options[RENDER];\n unmountHook = options.unmount;\n\n const parent = h(Fragment, null);\n parent[CHILDREN] = [vnode];\n\n const opcodes = [];\n\n try {\n _renderToString(\n vnode,\n context || EMPTY_OBJ,\n 0,\n undefined,\n parent,\n opcodes,\n 0,\n into,\n );\n } finally {\n // options._commit, we don't schedule any effects in this library right now,\n // so we can pass an empty queue to this hook.\n if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);\n options[SKIP_EFFECTS] = previousSkipEffects;\n EMPTY_ARR.length = 0;\n }\n\n return opcodes;\n}\n\n// Installed as setState/forceUpdate for function components\nfunction markAsDirty() {\n this[BITS] |= COMPONENT_DIRTY;\n}\n\nconst EMPTY_OBJ = {};\n\nexport const __OpBegin = 0;\nexport const __OpEnd = 1;\nexport const __OpAttr = 2;\nexport const __OpText = 3;\n\n/**\n * @param {VNode} vnode\n * @param {Record<string, unknown>} context\n */\nfunction renderClassComponent(vnode, context, globalContext) {\n const type = /** @type {import(\"preact\").ComponentClass<typeof vnode.props>} */ (vnode.type);\n\n let c;\n if (vnode[COMPONENT]) {\n c = vnode[COMPONENT];\n c.state = c[NEXT_STATE];\n } else {\n c = new type(vnode.props, context);\n }\n\n vnode[COMPONENT] = c;\n c[VNODE] = vnode;\n\n c.props = vnode.props;\n c.context = context;\n c[GLOBAL_CONTEXT] = globalContext;\n // turn off stateful re-rendering:\n c[BITS] |= COMPONENT_DIRTY;\n\n if (c.state == null) c.state = EMPTY_OBJ;\n\n if (c[NEXT_STATE] == null) {\n c[NEXT_STATE] = c.state;\n }\n\n if (type.getDerivedStateFromProps) {\n c.state = assign(\n {},\n c.state,\n type.getDerivedStateFromProps(c.props, c.state),\n );\n }\n\n if (renderHook) renderHook(vnode);\n\n return c.render(c.props, c.state, context);\n}\n\n/**\n * Recursively render VNodes to HTML.\n * @param {VNode|any} vnode\n * @param {any} context\n * @param {number | true} slotIndex\n * @param {any} selectValue\n * @param {VNode} parent\n * @param {any[]} opcodes\n * @param {number} opcodesLength\n * @param {SnapshotInstance} into\n */\nfunction _renderToString(\n vnode,\n context,\n slotIndex,\n selectValue,\n parent,\n opcodes,\n opcodesLength,\n into,\n) {\n // Ignore non-rendered VNodes/values\n if (vnode == null || vnode === true || vnode === false || vnode === '') {\n return;\n }\n\n let vnodeType = typeof vnode;\n // Text VNodes: escape as HTML\n if (vnodeType !== 'object') {\n if (vnodeType === 'function') return;\n renderToTextNode(into, vnode, opcodes, slotIndex);\n return;\n }\n\n // Recurse into children / Arrays\n if (isArray(vnode)) {\n parent[CHILDREN] = vnode;\n for (let i = 0; i < vnode.length; i++) {\n const child = vnode[i];\n if (child == null || typeof child === 'boolean') continue;\n\n _renderToString(\n child,\n context,\n slotIndex === true ? i : slotIndex,\n selectValue,\n parent,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore stop */\n into,\n );\n }\n return;\n }\n\n // VNodes have {constructor:undefined} to prevent JSON injection:\n // if (vnode.constructor !== undefined) return;\n\n vnode[PARENT] = parent;\n if (beforeDiff) beforeDiff(vnode);\n if (beforeDiff2) beforeDiff2(vnode, EMPTY_OBJ);\n\n let type = vnode.type,\n props = vnode.props,\n cctx = context,\n contextType,\n rendered,\n component;\n\n // Invoke rendering on Components\n if (typeof type === 'function') {\n if (type === Fragment) {\n rendered = props.children;\n } else {\n contextType = type.contextType;\n if (contextType != null) {\n const provider = context[contextType.__c];\n cctx = provider ? provider.props.value : contextType.__;\n }\n\n if (type.prototype && typeof type.prototype.render === 'function') {\n rendered = /**#__NOINLINE__**/ renderClassComponent(vnode, cctx, context);\n component = vnode[COMPONENT];\n } else {\n component = {\n [VNODE]: vnode,\n props,\n context: cctx,\n [GLOBAL_CONTEXT]: context,\n // silently drop state updates\n setState: markAsDirty,\n forceUpdate: markAsDirty,\n [BITS]: COMPONENT_DIRTY,\n // hooks\n [HOOK]: [],\n };\n vnode[COMPONENT] = component;\n component.constructor = type;\n component.render = doRender;\n\n // If a hook invokes setState() to invalidate the component during rendering,\n // re-render it up to 25 times to allow \"settling\" of memoized states.\n let count = 0;\n while (component[BITS] & COMPONENT_DIRTY && count++ < 25) {\n component[BITS] &= ~COMPONENT_DIRTY;\n\n if (renderHook) renderHook(vnode);\n\n rendered = component.render(props, component.state, cctx);\n }\n component[BITS] |= COMPONENT_DIRTY;\n }\n\n if (component.getChildContext != null) {\n context = assign({}, context, component.getChildContext());\n }\n }\n\n // When a component returns a Fragment node we flatten it in core, so we\n // need to mirror that logic here too\n const isTopLevelFragment = rendered != null && rendered.type === Fragment\n && rendered.key == null;\n rendered = isTopLevelFragment ? rendered.props.children : rendered;\n\n let lastChild = into.__lastChild;\n // Recurse into children before invoking the after-diff hook\n try {\n _renderToString(\n rendered,\n context,\n slotIndex,\n selectValue,\n vnode,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore stop */\n into,\n );\n } catch (e) {\n // clear existing children\n into.removeChildren(\n lastChild\n ? lastChild.__nextSibling\n : into.__firstChild,\n );\n if (e && typeof e === 'object' && e.then && component && /* _childDidSuspend */ component[CHILD_DID_SUSPEND]) {\n component[NEXT_STATE] = assign({}, component[NEXT_STATE], {\n /* _suspended */ __a: true,\n });\n if (component[BITS] & COMPONENT_DIRTY) {\n rendered = renderClassComponent(vnode, context);\n component = vnode[COMPONENT];\n\n if (__ENABLE_SSR__) {\n opcodes.length = opcodesLength;\n }\n _renderToString(\n rendered,\n context,\n slotIndex,\n selectValue,\n vnode,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore stop */\n into,\n );\n }\n } else {\n throw e;\n }\n } finally {\n if (afterDiff) afterDiff(vnode);\n vnode[PARENT] = undefined;\n\n if (unmountHook) unmountHook(vnode);\n }\n\n return;\n }\n\n let children;\n let hasNamedChildren = false;\n\n // hack for runtime test\n if (process.env['NODE_ENV'] === 'test' && isValidElement(vnode) && typeof vnode.type === 'string') {\n vnode = Object.assign(new SnapshotInstance(type), vnode, { $$typeof: undefined });\n }\n // already inserted\n if (vnode.__parent) {\n vnode = new SnapshotInstance(type);\n }\n if (__ENABLE_SSR__) {\n opcodes.push(__OpBegin, vnode, slotIndex);\n }\n vnode.__slotIndex = slotIndex;\n into.insertBefore(vnode);\n\n for (const name in props) {\n const v = props[name];\n\n switch (name) {\n case 'children':\n children = v;\n continue;\n\n // VDOM-specific props\n /* c8 ignore next 5 */\n case 'key':\n case 'ref':\n case '__self':\n case '__source':\n continue;\n\n default: {\n if (name.startsWith('$')) {\n children ??= [];\n children[+name.slice(1)] = v;\n hasNamedChildren = true;\n continue;\n }\n }\n }\n\n // write this attribute to the buffer\n if (v != null && v !== false && typeof v !== 'function') {\n if (__ENABLE_SSR__) {\n opcodes.push(__OpAttr, name, v);\n }\n vnode.setAttribute(name, v);\n }\n }\n\n let childrenType = typeof children;\n if (childrenType === 'string' || childrenType === 'number') {\n // single text child\n renderToTextNode(vnode, children, opcodes, slotIndex);\n } else if (children != null && children !== false && children !== true) {\n // recurse into this element VNode's children\n let _slotIndex = slotIndex;\n if (hasNamedChildren) {\n // @ts-expect-error children must be an array\n if (children.length === 1) {\n children = children[0];\n _slotIndex = 0;\n } else {\n _slotIndex = true;\n }\n }\n _renderToString(\n children,\n context,\n _slotIndex,\n selectValue,\n vnode,\n opcodes,\n /* v8 ignore start */\n __ENABLE_SSR__ ? opcodes.length : 0,\n /* v8 ignore stop */\n vnode,\n );\n }\n\n if (afterDiff) afterDiff(vnode);\n vnode[PARENT] = undefined;\n if (unmountHook) unmountHook(vnode);\n\n if (__ENABLE_SSR__) {\n opcodes.push(__OpEnd);\n }\n vnode[CHILDREN] = undefined;\n\n return;\n}\n\n/** The `.render()` method for a PFC backing instance. */\nfunction doRender(props, state, context) {\n return this.constructor(props, context);\n}\n\nfunction renderToTextNode(into: SnapshotInstance, text: string | number, opcodes: Opcode[], slotIndex: number) {\n const textNode = new SnapshotInstance(null);\n textNode.__slotIndex = slotIndex;\n textNode.setAttribute(0, text);\n into.insertBefore(textNode);\n if (__ENABLE_SSR__) {\n // We need store the just created SnapshotInstance, or it will be lost when we leave the function\n text = [textNode, text];\n opcodes.push(__OpText, text, slotIndex);\n }\n}\n\nexport default renderToString;\nexport const render: typeof renderToString = renderToString;\nexport const renderToStaticMarkup: typeof renderToString = renderToString;\n"]}
@@ -76,55 +76,4 @@ export function ssrHydrateByOpcodes(opcodes, into, refMap) {
76
76
  }
77
77
  }
78
78
  }
79
- // export function renderOpcodesInto(opcodes: any[], into: SnapshotInstance): void {
80
- // let top: SnapshotInstance = into;
81
- // const stack: SnapshotInstance[] = [into];
82
- // for (let i = 0; i < opcodes.length;) {
83
- // const opcode = opcodes[i];
84
- // switch (opcode) {
85
- // case OpcodeBegin: {
86
- // const p = top;
87
- // top = opcodes[i + 1];
88
- // // @ts-ignore
89
- // if (top.__parent) {
90
- // // already inserted
91
- // top = new SnapshotInstance(top.type);
92
- // opcodes[i + 1] = top;
93
- // }
94
- // p.insertBefore(top);
95
- // stack.push(top);
96
- // i += 2;
97
- // break;
98
- // }
99
- // case OpcodeEnd: {
100
- // // @ts-ignore
101
- // top[CHILDREN] = undefined;
102
- // stack.pop();
103
- // const p = stack[stack.length - 1];
104
- // top = p!;
105
- // i += 1;
106
- // break;
107
- // }
108
- // case OpcodeAttr: {
109
- // const key = opcodes[i + 1];
110
- // const value = opcodes[i + 2];
111
- // top.setAttribute(key, value);
112
- // i += 3;
113
- // break;
114
- // }
115
- // case OpcodeText: {
116
- // const text = opcodes[i + 1];
117
- // const s = new SnapshotInstance(null as unknown as string);
118
- // if (__ENABLE_SSR__) {
119
- // // We need store the just created SnapshotInstance, or it will be lost when we leave the function
120
- // opcodes[i + 1] = [s, text];
121
- // }
122
- // s.setAttribute(0, text);
123
- // top.insertBefore(s);
124
- // i += 2;
125
- // break;
126
- // }
127
- // }
128
- // }
129
- // }
130
79
  //# sourceMappingURL=opcodes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"opcodes.js","sourceRoot":"","sources":["../../../src/snapshot/renderToOpcodes/opcodes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC1G,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,UAAU,GAAG,CAAC,CAAC;AAOrB,MAAM,UAAU,mBAAmB,CACjC,OAAc,EACd,IAAsB,EACtB,MAAqC;IAErC,IAAI,GAAG,GAAiE,IAAI,CAAC;IAC7E,MAAM,KAAK,GAAuB,CAAC,IAAI,CAAC,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC;QACpC,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,WAAW,CAAC,CAAC,CAAC;gBACjB,MAAM,CAAC,GAAG,GAAG,CAAC;gBACd,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,OAAO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":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { hydrate } from './hydrate.js';\nimport { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list/list.js';\nimport { CHILDREN } from '../../shared/render-constants.js';\nimport { SnapshotInstance } from '../snapshot/snapshot.js';\n\nconst OpcodeBegin = 0;\nconst OpcodeEnd = 1;\nconst OpcodeAttr = 2;\nconst OpcodeText = 3;\n\ninterface SSRFiberElement {\n ssrID: string;\n}\nexport type SSRSnapshotInstance = [string, number, SSRFiberElement[]];\n\nexport function ssrHydrateByOpcodes(\n opcodes: any[],\n into: SnapshotInstance,\n refMap?: Record<string, FiberElement>,\n): void {\n let top: SnapshotInstance & { __pendingElements?: SSRFiberElement[] } = into;\n const stack: SnapshotInstance[] = [into];\n for (let i = 0; i < opcodes.length;) {\n const opcode = opcodes[i];\n switch (opcode) {\n case OpcodeBegin: {\n const p = top;\n const [type, __id, elements] = opcodes[i + 1] as SSRSnapshotInstance;\n top = new SnapshotInstance(type, __id);\n top.__pendingElements = elements;\n top.__slotIndex = opcodes[i + 2];\n p.insertBefore(top);\n stack.push(top);\n\n i += 3;\n break;\n }\n case OpcodeEnd: {\n // @ts-ignore\n top[CHILDREN] = undefined;\n\n top.__elements = top.__pendingElements!.map(({ ssrID }) => refMap![ssrID]!);\n top.__element_root = top.__elements[0];\n delete top.__pendingElements;\n\n if (top.__snapshot_def.isListHolder) {\n const [, elementIndex] = top.__snapshot_def.slot[0]!;\n const listElement = top.__elements[elementIndex]!;\n const listElementUniqueID = __GetElementUniqueID(listElement);\n const signMap = gSignMap[listElementUniqueID] = new Map();\n gRecycleMap[listElementUniqueID] = new Map();\n const enqueueFunc = enqueueComponentFactory();\n const [componentAtIndex, componentAtIndexes] = componentAtIndexFactory(top.childNodes, hydrate);\n for (const child of top.childNodes) {\n if (child.__element_root) {\n const childElementUniqueID = __GetElementUniqueID(child.__element_root);\n signMap.set(childElementUniqueID, child);\n enqueueFunc(\n listElement,\n listElementUniqueID,\n childElementUniqueID,\n );\n }\n }\n __UpdateListCallbacks(listElement, componentAtIndex, enqueueFunc, componentAtIndexes);\n }\n\n stack.pop();\n const p = stack[stack.length - 1];\n top = p!;\n\n i += 1;\n break;\n }\n case OpcodeAttr: {\n const key = opcodes[i + 1];\n const value = opcodes[i + 2];\n top.setAttribute(key, value);\n\n i += 3;\n break;\n }\n case OpcodeText: {\n const [[type, __id, elements], text] = opcodes[i + 1] as [SSRSnapshotInstance, string];\n const s = new SnapshotInstance(type, __id);\n s.__slotIndex = opcodes[i + 2];\n s.setAttribute(0, text);\n top.insertBefore(s);\n s.__elements = elements.map(({ ssrID }) => refMap![ssrID]!);\n s.__element_root = s.__elements[0];\n i += 3;\n break;\n }\n }\n }\n}\n\n// export function renderOpcodesInto(opcodes: any[], into: SnapshotInstance): void {\n// let top: SnapshotInstance = into;\n// const stack: SnapshotInstance[] = [into];\n// for (let i = 0; i < opcodes.length;) {\n// const opcode = opcodes[i];\n// switch (opcode) {\n// case OpcodeBegin: {\n// const p = top;\n// top = opcodes[i + 1];\n// // @ts-ignore\n// if (top.__parent) {\n// // already inserted\n// top = new SnapshotInstance(top.type);\n// opcodes[i + 1] = top;\n// }\n// p.insertBefore(top);\n// stack.push(top);\n\n// i += 2;\n// break;\n// }\n// case OpcodeEnd: {\n// // @ts-ignore\n// top[CHILDREN] = undefined;\n\n// stack.pop();\n// const p = stack[stack.length - 1];\n// top = p!;\n\n// i += 1;\n// break;\n// }\n// case OpcodeAttr: {\n// const key = opcodes[i + 1];\n// const value = opcodes[i + 2];\n// top.setAttribute(key, value);\n\n// i += 3;\n// break;\n// }\n// case OpcodeText: {\n// const text = opcodes[i + 1];\n// const s = new SnapshotInstance(null as unknown as string);\n// if (__ENABLE_SSR__) {\n// // We need store the just created SnapshotInstance, or it will be lost when we leave the function\n// opcodes[i + 1] = [s, text];\n// }\n// s.setAttribute(0, text);\n// top.insert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,CAAC,CAAC;gBACpB,CAAC,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,MAAO,CAAC,KAAK,CAAE,CAAC,CAAC;gBAC5D,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACnC,CAAC,IAAI,CAAC,CAAC;gBACP,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { hydrate } from './hydrate.js';\nimport { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list/list.js';\nimport { CHILDREN } from '../../shared/render-constants.js';\nimport { SnapshotInstance } from '../snapshot/snapshot.js';\n\nconst OpcodeBegin = 0;\nconst OpcodeEnd = 1;\nconst OpcodeAttr = 2;\nconst OpcodeText = 3;\n\ninterface SSRFiberElement {\n ssrID: string;\n}\nexport type SSRSnapshotInstance = [string, number, SSRFiberElement[]];\n\nexport function ssrHydrateByOpcodes(\n opcodes: any[],\n into: SnapshotInstance,\n refMap?: Record<string, FiberElement>,\n): void {\n let top: SnapshotInstance & { __pendingElements?: SSRFiberElement[] } = into;\n const stack: SnapshotInstance[] = [into];\n for (let i = 0; i < opcodes.length;) {\n const opcode = opcodes[i];\n switch (opcode) {\n case OpcodeBegin: {\n const p = top;\n const [type, __id, elements] = opcodes[i + 1] as SSRSnapshotInstance;\n top = new SnapshotInstance(type, __id);\n top.__pendingElements = elements;\n top.__slotIndex = opcodes[i + 2];\n p.insertBefore(top);\n stack.push(top);\n\n i += 3;\n break;\n }\n case OpcodeEnd: {\n // @ts-ignore\n top[CHILDREN] = undefined;\n\n top.__elements = top.__pendingElements!.map(({ ssrID }) => refMap![ssrID]!);\n top.__element_root = top.__elements[0];\n delete top.__pendingElements;\n\n if (top.__snapshot_def.isListHolder) {\n const [, elementIndex] = top.__snapshot_def.slot[0]!;\n const listElement = top.__elements[elementIndex]!;\n const listElementUniqueID = __GetElementUniqueID(listElement);\n const signMap = gSignMap[listElementUniqueID] = new Map();\n gRecycleMap[listElementUniqueID] = new Map();\n const enqueueFunc = enqueueComponentFactory();\n const [componentAtIndex, componentAtIndexes] = componentAtIndexFactory(top.childNodes, hydrate);\n for (const child of top.childNodes) {\n if (child.__element_root) {\n const childElementUniqueID = __GetElementUniqueID(child.__element_root);\n signMap.set(childElementUniqueID, child);\n enqueueFunc(\n listElement,\n listElementUniqueID,\n childElementUniqueID,\n );\n }\n }\n __UpdateListCallbacks(listElement, componentAtIndex, enqueueFunc, componentAtIndexes);\n }\n\n stack.pop();\n const p = stack[stack.length - 1];\n top = p!;\n\n i += 1;\n break;\n }\n case OpcodeAttr: {\n const key = opcodes[i + 1];\n const value = opcodes[i + 2];\n top.setAttribute(key, value);\n\n i += 3;\n break;\n }\n case OpcodeText: {\n const [[type, __id, elements], text] = opcodes[i + 1] as [SSRSnapshotInstance, string];\n const s = new SnapshotInstance(type, __id);\n s.__slotIndex = opcodes[i + 2];\n s.setAttribute(0, text);\n top.insertBefore(s);\n s.__elements = elements.map(({ ssrID }) => refMap![ssrID]!);\n s.__element_root = s.__elements[0];\n i += 3;\n break;\n }\n }\n }\n}\n"]}
@@ -15,7 +15,7 @@ import { globalPipelineOptions } from '../../core/performance.js';
15
15
  import { profileEnd, profileStart } from '../../shared/profile.js';
16
16
  import { isDirectOrDeepEqual } from '../../utils.js';
17
17
  import { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';
18
- import { prepareGestureForCommit } from '../gesture/processGestureBagkround.js';
18
+ import { prepareGestureForCommit } from '../gesture/processGestureBackground.js';
19
19
  import { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';
20
20
  import { SnapshotOperation, __globalSnapshotPatch, initGlobalSnapshotPatch, takeGlobalSnapshotPatch, } from '../lifecycle/patch/snapshotPatch.js';
21
21
  import { clearPendingPortalInsertBefore } from '../lynx/portalsPending.js';
@@ -1 +1 @@
1
- {"version":3,"file":"backgroundSnapshot.js","sourceRoot":"","sources":["../../../src/snapshot/snapshot/backgroundSnapshot.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAU1D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,uCAAuC,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACpH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,yCAAyC,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,EACL,iBAAiB,EACjB,qBAA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AM;oBACR,CAAC;oBACD,KAAK,eAAe,CAAC,UAAU,CAAC;oBAChC,KAAK,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;wBAClC,IAAI,wBAAwB,GAAG,gBAAgB,CAAC;wBAChD,IAAI,uBAAuB,GAAG,eAAe,CAAC;wBAC9C,IAAI,IAAI,KAAK,eAAe,CAAC,UAAU,EAAE,CAAC;4BACxC,wBAAwB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;4BACtF,uBAAuB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC;wBACjF,CAAC;wBAED,YAAY,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,IAAI,CAAC,CAAC;wBACtE,MAAM;oBACR,CAAC;oBACD;wBACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACtB,uIAAuI;QACvI,eAAe,EAAE,CAAC;QAClB,8BAA8B,EAAE,CAAC;QACjC,OAAO,uBAAuB,EAAG,CAAC;IACpC,CAAC;YAAS,CAAC;QACT,IAAI,aAAa,EAAE,CAAC;YAClB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Background snapshot implementation that runs in the background thread.\n *\n * This is the mirror of main thread's {@link SnapshotInstance}:\n */\n\nimport type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { createCloneSnapshot, createRuntimeSnapshot, snapshotManager } from './definition.js';\nimport type { Snapshot } from './definition.js';\nimport { DynamicPartType } from './dynamicPartType.js';\nimport { getListItemPlatformInfoFromIndexedValue } from './platformInfo.js';\nimport type { PlatformInfo } from './platformInfo.js';\nimport { reconstructInstanceTree } from './reconstructInstanceTree.js';\nimport { clearQueuedRefs, getRefFromValue, queueRefAttrUpdate } from './ref.js';\nimport type { Ref } from './ref.js';\nimport { snapshotCreatorMap } from './snapshot.js';\nimport { snapshotCreatorRuntime } from './snapshotCreatorMap.js';\nimport { hydrationMap } from './snapshotInstanceHydrationMap.js';\nimport { transformSpread } from './spread.js';\nimport type { SerializedSnapshotInstance } from './types.js';\nimport { isCloneSnapshot, isCompiledSnapshot, traverseSnapshotInstance } from './utils.js';\nimport { globalPipelineOptions } from '../../core/performance.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { isDirectOrDeepEqual } from '../../utils.js';\nimport { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';\nimport { prepareGestureForCommit } from '../gesture/processGestureBagkround.js';\nimport type { GestureKind } from '../gesture/types.js';\nimport { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';\nimport {\n SnapshotOperation,\n __globalSnapshotPatch,\n initGlobalSnapshotPatch,\n takeGlobalSnapshotPatch,\n} from '../lifecycle/patch/snapshotPatch.js';\nimport type { SnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';\nimport { clearPendingPortalInsertBefore } from '../lynx/portalsPending.js';\nimport { diffArrayAction, diffArrayLepus } from '../renderToOpcodes/hydrate.js';\nimport { onPostWorkletCtx } from '../worklet/ctx.js';\n\n/**\n * Background snapshot instance manager that manages all background snapshot instances.\n */\nexport const backgroundSnapshotInstanceManager: {\n nextId: number;\n values: Map<number, BackgroundSnapshotInstance>;\n clear(): void;\n updateId(id: number, newId: number): void;\n getValueBySign(str: string): unknown;\n} = {\n nextId: 0,\n values: /* @__PURE__ */ new Map<number, BackgroundSnapshotInstance>(),\n clear() {\n // not resetting `nextId` to prevent id collision\n this.values.clear();\n if (__DEV__) {\n clearSnapshotVNodeSource();\n }\n },\n updateId(id: number, newId: number) {\n const values = this.values;\n const si = values.get(id)!;\n // For PreactDevtools, on first hydration,\n // PreactDevtools can get the real snapshot instance id in main-thread\n if (__DEV__ && __BACKGROUND__) {\n lynx.getJSModule('GlobalEventEmitter').emit('onBackgroundSnapshotInstanceUpdateId', [\n {\n backgroundSnapshotInstance: si,\n oldId: id,\n newId,\n },\n ]);\n }\n values.delete(id);\n values.set(newId, si);\n si.__id = newId;\n if (__DEV__) {\n moveSnapshotVNodeSource(id, newId);\n }\n },\n getValueBySign(str: string): unknown {\n const res = str?.split(':');\n if (!res || (res.length != 2 && res.length != 3)) {\n throw new Error('Invalid ctx format: ' + str);\n }\n const id = Number(res[0]);\n const expIndex = Number(res[1]);\n const ctx = this.values.get(id);\n if (!ctx) {\n return null;\n }\n /**\n * 1. normal event\n * `${ctx.__id}:${expIndex}:${spreadKey}`\n * 2. defer list event\n * ${ctx.__id}:__extraProps:onRecycleComponent`\n * ${ctx.__id}:__extraProps:onComponentAtIndex`\n */\n const spreadKey = res[2];\n if (res[1] === '__extraProps') {\n if (spreadKey) {\n return ctx.__extraProps![spreadKey];\n }\n throw new Error('unreachable');\n } else {\n if (spreadKey) {\n return (ctx.__values![expIndex] as { [spreadKey]: unknown })[spreadKey];\n } else {\n return ctx.__values![expIndex];\n }\n }\n },\n};\n\nfunction prepareWorkletForCommit(worklet: Worklet): Worklet | null {\n // Copy-on-commit: do not mutate the background-side worklet ctx.\n // `_execId` is injected into the payload object that will be sent to the main thread.\n return onPostWorkletCtx({ ...(worklet as unknown as Record<string, unknown>) } as Worklet);\n}\n\nfunction prepareSpreadForCommit(\n spread: Record<string, unknown>,\n oldSpread: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n let committed: Record<string, unknown> | undefined;\n for (const key in spread) {\n const v = spread[key];\n if (key === '__lynx_timing_flag' && oldSpread?.[key] != v && globalPipelineOptions) {\n globalPipelineOptions.needTimestamps = true;\n }\n if (!v || typeof v !== 'object') {\n continue;\n }\n const valueRecord = v as Record<string, unknown>;\n let committedValue: unknown;\n if ('_wkltId' in valueRecord) {\n committedValue = prepareWorkletForCommit(v as Worklet);\n } else if ('__isGesture' in valueRecord) {\n committedValue = prepareGestureForCommit(v as GestureKind);\n } else {\n continue;\n }\n\n committed ??= { ...spread };\n committed[key] = committedValue;\n }\n return committed ?? spread;\n}\n\nexport class BackgroundSnapshotInstance {\n constructor(public type: string) {\n // Suspense uses 'div'\n if (!snapshotManager.values.has(type) && type !== 'div') {\n if (snapshotCreatorMap[type]) {\n snapshotCreatorMap[type](type, snapshotCreatorRuntime);\n } else if (isCloneSnapshot(type)) {\n createCloneSnapshot(type);\n } else if (isCompiledSnapshot(type)) {\n throw new Error('BackgroundSnapshot not found: ' + type);\n } else {\n // add runtime snapshot to backgroundSnapshotInstanceManager\n createRuntimeSnapshot(type);\n }\n }\n this.__snapshot_def = snapshotManager.values.get(type)!;\n const id = this.__id = backgroundSnapshotInstanceManager.nextId += 1;\n backgroundSnapshotInstanceManager.values.set(id, this);\n\n __globalSnapshotPatch?.push(SnapshotOperation.CreateElement, type, id);\n }\n\n __id: number;\n __values: unknown[] | undefined;\n __snapshot_def: Snapshot;\n __listItemPlatformInfo?: PlatformInfo;\n __extraProps?: Record<string, unknown> | undefined;\n __slotIndex: number = 0;\n private __listItemPlatformInfoIndex?: number;\n\n private __parent: BackgroundSnapshotInstance | null = null;\n private __firstChild: BackgroundSnapshotInstance | null = null;\n private __lastChild: BackgroundSnapshotInstance | null = null;\n private __previousSibling: BackgroundSnapshotInstance | null = null;\n private __nextSibling: BackgroundSnapshotInstance | null = null;\n private __removed_from_tree?: boolean;\n\n get parentNode(): BackgroundSnapshotInstance | null {\n return this.__parent;\n }\n\n get nextSibling(): BackgroundSnapshotInstance | null {\n return this.__nextSibling;\n }\n\n // get isConnected() {\n // return !!this.__parent;\n // }\n\n // contains(child: BackgroundSnapshotInstance): boolean {\n // return child.parentNode === this;\n // }\n\n // Preact 11's `removeNode` calls `node.remove()` instead of\n // `parentNode.removeChild(node)`.\n remove(): void {\n this.parentNode?.removeChild(this);\n }\n\n // This will be called in `lazy`/`Suspense`.\n appendChild(child: BackgroundSnapshotInstance): void {\n return this.insertBefore(child);\n }\n\n insertBefore(\n node: BackgroundSnapshotInstance,\n beforeNode?: BackgroundSnapshotInstance,\n ): void {\n if (node.__removed_from_tree) {\n node.__removed_from_tree = false;\n // This is only called by `lazy`/`Suspense` through `appendChild` so beforeNode is always undefined.\n /* v8 ignore next */\n reconstructInstanceTree([node], this.__id, beforeNode?.__id);\n } else {\n __globalSnapshotPatch?.push(\n SnapshotOperation.InsertBefore,\n this.__id,\n node.__id,\n beforeNode?.__id,\n node.__slotIndex,\n );\n }\n\n // If the node already has a parent, remove it from its current parent\n const p = node.__parent;\n if (p) {\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n p.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n p.__lastChild = node.__previousSibling;\n }\n }\n\n // If beforeNode is not provided, add the new node as the last child\n if (beforeNode) {\n // If beforeNode is provided, insert the new node before beforeNode\n if (beforeNode.__previousSibling) {\n beforeNode.__previousSibling.__nextSibling = node;\n node.__previousSibling = beforeNode.__previousSibling;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n beforeNode.__previousSibling = node;\n node.__nextSibling = beforeNode;\n node.__parent = this;\n } else {\n if (this.__lastChild) {\n this.__lastChild.__nextSibling = node;\n node.__previousSibling = this.__lastChild;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n this.__lastChild = node;\n node.__parent = this;\n node.__nextSibling = null;\n }\n }\n\n removeChild(node: BackgroundSnapshotInstance): void {\n __globalSnapshotPatch?.push(\n SnapshotOperation.RemoveChild,\n this.__id,\n node.__id,\n );\n node.__removed_from_tree = true;\n\n if (node.__parent !== this) {\n throw new Error('The node to be removed is not a child of this node.');\n }\n\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n this.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n this.__lastChild = node.__previousSibling;\n }\n\n node.__parent = null;\n node.__previousSibling = null;\n node.__nextSibling = null;\n\n traverseSnapshotInstance(node, instance => {\n if (instance.__values) {\n instance.__snapshot_def.refAndSpreadIndexes?.forEach(index => {\n const ref = getRefFromValue(instance.__values![index]);\n if (ref) {\n queueRefAttrUpdate(ref, null, instance, index);\n }\n });\n }\n });\n\n globalBackgroundSnapshotInstancesToRemove.push(node.__id);\n }\n\n tearDown(): void {\n traverseSnapshotInstance(this, v => {\n v.__parent = null;\n v.__previousSibling = null;\n v.__nextSibling = null;\n backgroundSnapshotInstanceManager.values.delete(v.__id);\n });\n }\n\n get childNodes(): BackgroundSnapshotInstance[] {\n const nodes: BackgroundSnapshotInstance[] = [];\n let node = this.__firstChild;\n while (node) {\n nodes.push(node);\n node = node.__nextSibling;\n }\n return nodes;\n }\n\n setAttribute(key: string | number, value: unknown): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::BSI::setAttribute');\n }\n if (key === 'values') {\n if (__globalSnapshotPatch) {\n const oldValues = this.__values;\n if (oldValues) {\n for (let index = 0; index < (value as unknown[]).length; index++) {\n const { needUpdate, valueToCommit } = this.setAttributeImpl(\n (value as unknown[])[index],\n oldValues[index],\n index,\n );\n if (needUpdate) {\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n index,\n valueToCommit,\n );\n }\n }\n } else {\n const patch = [];\n const length = (value as unknown[]).length;\n for (let index = 0; index < length; ++index) {\n const { valueToCommit } = this.setAttributeImpl((value as unknown[])[index], null, index);\n patch[index] = valueToCommit;\n }\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttributes,\n this.__id,\n patch,\n );\n }\n } else {\n this.__snapshot_def.refAndSpreadIndexes?.forEach((index) => {\n // In first render, this.__values is undefined.\n // In next rerenders before hydration, this.__values is not undefined.\n const oldValue: unknown = this.__values?.[index];\n const v = (value as unknown[])[index];\n queueRefAttrUpdate(getRefFromValue(oldValue), getRefFromValue(v), this, index);\n });\n }\n this.__values = value as unknown[];\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n\n if (typeof key === 'string') {\n if (key === '__listItemPlatformInfoIndex') {\n this.__listItemPlatformInfoIndex = value as number;\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n if (key === '__listItemPlatformInfo') {\n this.__listItemPlatformInfo = value as PlatformInfo;\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n (this.__extraProps ??= {})[key] = value;\n } else {\n // old path (`this.setAttribute(0, xxx)`)\n // is reserved as slow path\n (this.__values ??= [])[key] = value;\n this.syncListItemPlatformInfo();\n }\n __globalSnapshotPatch?.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n key,\n value,\n );\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n\n private syncListItemPlatformInfo(): void {\n if (this.__listItemPlatformInfoIndex === undefined || !this.__values) {\n return;\n }\n const index = this.__listItemPlatformInfoIndex;\n this.__listItemPlatformInfo = getListItemPlatformInfoFromIndexedValue(\n this.__values[index],\n this.__snapshot_def.refAndSpreadIndexes?.includes(index),\n );\n }\n\n private setAttributeImpl(newValue: unknown, oldValue: unknown, index: number): {\n needUpdate: boolean;\n valueToCommit: unknown;\n } {\n if (!newValue) {\n const oldRef = getRefFromValue(oldValue);\n if (oldRef) {\n queueRefAttrUpdate(oldRef, null, this, index);\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n\n const newType = typeof newValue;\n if (newType === 'object') {\n const newValueObj = newValue as Record<string, unknown>;\n if ('__spread' in newValueObj) {\n const oldSpread = (oldValue as { __spread?: Record<string, unknown> } | undefined)?.__spread;\n const newSpread = transformSpread(this, index, newValueObj);\n const needUpdate = !isDirectOrDeepEqual(oldSpread, newSpread);\n // use __spread to cache the transform result for next diff\n newValueObj['__spread'] = newSpread;\n queueRefAttrUpdate(\n oldSpread && ((oldValue as { ref?: Ref }).ref),\n newValueObj['ref'] as Ref,\n this,\n index,\n );\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareSpreadForCommit(newSpread, oldSpread) : newSpread,\n };\n }\n if ('__ref' in newValueObj) {\n queueRefAttrUpdate(oldValue as Ref, newValueObj as unknown as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n if ('_wkltId' in newValueObj) {\n // Worklet ctx can be stable across rerenders (e.g. memoized by the user).\n // In that case we should NOT re-register / re-send it, otherwise `_execId` churn\n // will cause unnecessary patches.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareWorkletForCommit(newValueObj as Worklet) : newValue,\n };\n }\n if ('__isGesture' in newValueObj) {\n // Gestures are large objects; if the reference is stable, avoid reprocessing and patching.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate\n ? prepareGestureForCommit(newValueObj as unknown as GestureKind)\n : newValue,\n };\n }\n if ('__ltf' in newValueObj) {\n // __lynx_timing_flag\n if (globalPipelineOptions && (oldValue as { __ltf?: unknown } | undefined)?.__ltf != newValueObj['__ltf']) {\n globalPipelineOptions.needTimestamps = true;\n return { needUpdate: true, valueToCommit: newValue };\n }\n return { needUpdate: false, valueToCommit: newValue };\n }\n return { needUpdate: !isDirectOrDeepEqual(oldValue, newValue), valueToCommit: newValue };\n }\n if (newType === 'function') {\n if ((newValue as { __ref?: unknown }).__ref) {\n queueRefAttrUpdate(oldValue as Ref, newValue as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n /* event */\n return { needUpdate: !oldValue, valueToCommit: 1 };\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n}\n\nexport function hydrate(\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n): SnapshotPatch {\n const shouldProfile = typeof __PROFILE__ !== 'undefined' && __PROFILE__;\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::hydrate');\n }\n try {\n initGlobalSnapshotPatch();\n\n const helper = (\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n ) => {\n hydrationMap.set(after.__id, before.id);\n backgroundSnapshotInstanceManager.updateId(after.__id, before.id);\n // handle value by index\n after.__values?.forEach((value: unknown, index) => {\n // render with different root would cause different values length\n const old: unknown = before.values?.[index];\n\n if (value) {\n if (typeof value === 'object') {\n if ('__spread' in value) {\n // `value.__spread` my contain event ids using snapshot ids before hydration. Remove it.\n delete value.__spread;\n const __spread = transformSpread(after, index, value);\n // Cache a clean spread for future diffs. For the patch payload, create a committed copy\n // with runtime fields (e.g. `_execId`) injected.\n (after.__values![index]! as Record<string, unknown>)['__spread'] = __spread;\n value = prepareSpreadForCommit(__spread, old as Record<string, unknown> | undefined);\n } else if ('__ref' in value) {\n // skip patch\n value = old;\n } else if ('_wkltId' in value) {\n value = prepareWorkletForCommit(value as Worklet);\n } else if ('__isGesture' in value) {\n value = prepareGestureForCommit(value as GestureKind);\n }\n } else if (typeof value === 'function') {\n if ('__ref' in value) {\n // skip patch\n value = old;\n } else {\n value = `${after.__id}:${index}:`;\n }\n }\n }\n\n if (!isDirectOrDeepEqual(value, old)) {\n if (value === undefined && old === null) {\n // This is a workaround for the case where we set an attribute to `undefined` in the main thread,\n // but the old value becomes `null` during JSON serialization.\n // In this case, we should not patch the value.\n } else {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: String(index),\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n }\n }\n }\n });\n\n // handle extraProps as attributes and set by key\n if (after.__extraProps) {\n for (const key in after.__extraProps) {\n const value = after.__extraProps[key];\n const old = before.extraProps?.[key];\n if (!isDirectOrDeepEqual(value, old)) {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: key,\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n }\n }\n }\n }\n\n const { slot } = after.__snapshot_def;\n\n const beforeChildNodes = before.children ?? [];\n const afterChildNodes = after.childNodes;\n\n if (!slot) {\n return;\n }\n\n // Hoisted out of the loop: none of this depends on the slot entry.\n const diffChildren = (\n filteredBeforeChildNodes: SerializedSnapshotInstance[],\n filteredAfterChildNodes: BackgroundSnapshotInstance[],\n isListHasItemKey: boolean,\n ) => {\n const diffResult = diffArrayLepus(\n filteredBeforeChildNodes,\n filteredAfterChildNodes,\n (a, b) => a.type === b.type,\n (a, b) => {\n helper(a, b);\n },\n isListHasItemKey,\n );\n diffArrayAction(\n filteredBeforeChildNodes,\n diffResult,\n (node, target) => {\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::reconstructInstanceTree', {\n args: {\n id: String(node.__id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.__id) ?? '',\n },\n });\n }\n try {\n reconstructInstanceTree([node], before.id, target?.id);\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n return undefined as unknown as SerializedSnapshotInstance;\n },\n node => {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::removeChild', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n }\n },\n (node, target) => {\n // changedList.push([SnapshotOperation.RemoveChild, before.id, node.id]);\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::insertBefore', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n targetId: String(target?.id ?? ''),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n }\n },\n );\n };\n\n slot.forEach(([type], index) => {\n switch (type) {\n case DynamicPartType.Slot:\n case DynamicPartType.MultiChildren: {\n // TODO: the following null assertions are not 100% safe\n const v1 = beforeChildNodes[index]!;\n const v2 = afterChildNodes[index]!;\n helper(v1, v2);\n break;\n }\n case DynamicPartType.SlotV2:\n case DynamicPartType.Children: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.SlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n // Children match pairwise by type, so the diff is empty — do what\n // `diffArrayLepus` + `diffArrayAction` would do without allocating\n // the diff structures.\n const length = filteredBeforeChildNodes.length;\n if (length === filteredAfterChildNodes.length) {\n let samePairwise = true;\n for (let i = 0; i < length; i++) {\n if (filteredBeforeChildNodes[i]!.type !== filteredAfterChildNodes[i]!.type) {\n samePairwise = false;\n break;\n }\n }\n if (samePairwise) {\n for (let i = 0; i < length; i++) {\n helper(filteredBeforeChildNodes[i]!, filteredAfterChildNodes[i]!);\n }\n break;\n }\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, false);\n break;\n }\n case DynamicPartType.ListSlotV2:\n case DynamicPartType.ListChildren: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.ListSlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, true);\n break;\n }\n default:\n throw new Error('Unexpected slot type: ' + type);\n }\n });\n };\n\n helper(before, after);\n // Hydration should not trigger ref updates. They were incorrectly triggered when using `setAttribute` to add values to the patch list.\n clearQueuedRefs();\n clearPendingPortalInsertBefore();\n return takeGlobalSnapshotPatch()!;\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"backgroundSnapshot.js","sourceRoot":"","sources":["../../../src/snapshot/snapshot/backgroundSnapshot.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAU1D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,uCAAuC,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B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AAK,CAAC,CAAC;wBACjF,CAAC;wBAED,YAAY,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,IAAI,CAAC,CAAC;wBACtE,MAAM;oBACR,CAAC;oBACD;wBACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACtB,uIAAuI;QACvI,eAAe,EAAE,CAAC;QAClB,8BAA8B,EAAE,CAAC;QACjC,OAAO,uBAAuB,EAAG,CAAC;IACpC,CAAC;YAAS,CAAC;QACT,IAAI,aAAa,EAAE,CAAC;YAClB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Background snapshot implementation that runs in the background thread.\n *\n * This is the mirror of main thread's {@link SnapshotInstance}:\n */\n\nimport type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { createCloneSnapshot, createRuntimeSnapshot, snapshotManager } from './definition.js';\nimport type { Snapshot } from './definition.js';\nimport { DynamicPartType } from './dynamicPartType.js';\nimport { getListItemPlatformInfoFromIndexedValue } from './platformInfo.js';\nimport type { PlatformInfo } from './platformInfo.js';\nimport { reconstructInstanceTree } from './reconstructInstanceTree.js';\nimport { clearQueuedRefs, getRefFromValue, queueRefAttrUpdate } from './ref.js';\nimport type { Ref } from './ref.js';\nimport { snapshotCreatorMap } from './snapshot.js';\nimport { snapshotCreatorRuntime } from './snapshotCreatorMap.js';\nimport { hydrationMap } from './snapshotInstanceHydrationMap.js';\nimport { transformSpread } from './spread.js';\nimport type { SerializedSnapshotInstance } from './types.js';\nimport { isCloneSnapshot, isCompiledSnapshot, traverseSnapshotInstance } from './utils.js';\nimport { globalPipelineOptions } from '../../core/performance.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { isDirectOrDeepEqual } from '../../utils.js';\nimport { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';\nimport { prepareGestureForCommit } from '../gesture/processGestureBackground.js';\nimport type { GestureKind } from '../gesture/types.js';\nimport { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';\nimport {\n SnapshotOperation,\n __globalSnapshotPatch,\n initGlobalSnapshotPatch,\n takeGlobalSnapshotPatch,\n} from '../lifecycle/patch/snapshotPatch.js';\nimport type { SnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';\nimport { clearPendingPortalInsertBefore } from '../lynx/portalsPending.js';\nimport { diffArrayAction, diffArrayLepus } from '../renderToOpcodes/hydrate.js';\nimport { onPostWorkletCtx } from '../worklet/ctx.js';\n\n/**\n * Background snapshot instance manager that manages all background snapshot instances.\n */\nexport const backgroundSnapshotInstanceManager: {\n nextId: number;\n values: Map<number, BackgroundSnapshotInstance>;\n clear(): void;\n updateId(id: number, newId: number): void;\n getValueBySign(str: string): unknown;\n} = {\n nextId: 0,\n values: /* @__PURE__ */ new Map<number, BackgroundSnapshotInstance>(),\n clear() {\n // not resetting `nextId` to prevent id collision\n this.values.clear();\n if (__DEV__) {\n clearSnapshotVNodeSource();\n }\n },\n updateId(id: number, newId: number) {\n const values = this.values;\n const si = values.get(id)!;\n // For PreactDevtools, on first hydration,\n // PreactDevtools can get the real snapshot instance id in main-thread\n if (__DEV__ && __BACKGROUND__) {\n lynx.getJSModule('GlobalEventEmitter').emit('onBackgroundSnapshotInstanceUpdateId', [\n {\n backgroundSnapshotInstance: si,\n oldId: id,\n newId,\n },\n ]);\n }\n values.delete(id);\n values.set(newId, si);\n si.__id = newId;\n if (__DEV__) {\n moveSnapshotVNodeSource(id, newId);\n }\n },\n getValueBySign(str: string): unknown {\n const res = str?.split(':');\n if (!res || (res.length != 2 && res.length != 3)) {\n throw new Error('Invalid ctx format: ' + str);\n }\n const id = Number(res[0]);\n const expIndex = Number(res[1]);\n const ctx = this.values.get(id);\n if (!ctx) {\n return null;\n }\n /**\n * 1. normal event\n * `${ctx.__id}:${expIndex}:${spreadKey}`\n * 2. defer list event\n * ${ctx.__id}:__extraProps:onRecycleComponent`\n * ${ctx.__id}:__extraProps:onComponentAtIndex`\n */\n const spreadKey = res[2];\n if (res[1] === '__extraProps') {\n if (spreadKey) {\n return ctx.__extraProps![spreadKey];\n }\n throw new Error('unreachable');\n } else {\n if (spreadKey) {\n return (ctx.__values![expIndex] as { [spreadKey]: unknown })[spreadKey];\n } else {\n return ctx.__values![expIndex];\n }\n }\n },\n};\n\nfunction prepareWorkletForCommit(worklet: Worklet): Worklet | null {\n // Copy-on-commit: do not mutate the background-side worklet ctx.\n // `_execId` is injected into the payload object that will be sent to the main thread.\n return onPostWorkletCtx({ ...(worklet as unknown as Record<string, unknown>) } as Worklet);\n}\n\nfunction prepareSpreadForCommit(\n spread: Record<string, unknown>,\n oldSpread: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n let committed: Record<string, unknown> | undefined;\n for (const key in spread) {\n const v = spread[key];\n if (key === '__lynx_timing_flag' && oldSpread?.[key] != v && globalPipelineOptions) {\n globalPipelineOptions.needTimestamps = true;\n }\n if (!v || typeof v !== 'object') {\n continue;\n }\n const valueRecord = v as Record<string, unknown>;\n let committedValue: unknown;\n if ('_wkltId' in valueRecord) {\n committedValue = prepareWorkletForCommit(v as Worklet);\n } else if ('__isGesture' in valueRecord) {\n committedValue = prepareGestureForCommit(v as GestureKind);\n } else {\n continue;\n }\n\n committed ??= { ...spread };\n committed[key] = committedValue;\n }\n return committed ?? spread;\n}\n\nexport class BackgroundSnapshotInstance {\n constructor(public type: string) {\n // Suspense uses 'div'\n if (!snapshotManager.values.has(type) && type !== 'div') {\n if (snapshotCreatorMap[type]) {\n snapshotCreatorMap[type](type, snapshotCreatorRuntime);\n } else if (isCloneSnapshot(type)) {\n createCloneSnapshot(type);\n } else if (isCompiledSnapshot(type)) {\n throw new Error('BackgroundSnapshot not found: ' + type);\n } else {\n // add runtime snapshot to backgroundSnapshotInstanceManager\n createRuntimeSnapshot(type);\n }\n }\n this.__snapshot_def = snapshotManager.values.get(type)!;\n const id = this.__id = backgroundSnapshotInstanceManager.nextId += 1;\n backgroundSnapshotInstanceManager.values.set(id, this);\n\n __globalSnapshotPatch?.push(SnapshotOperation.CreateElement, type, id);\n }\n\n __id: number;\n __values: unknown[] | undefined;\n __snapshot_def: Snapshot;\n __listItemPlatformInfo?: PlatformInfo;\n __extraProps?: Record<string, unknown> | undefined;\n __slotIndex: number = 0;\n private __listItemPlatformInfoIndex?: number;\n\n private __parent: BackgroundSnapshotInstance | null = null;\n private __firstChild: BackgroundSnapshotInstance | null = null;\n private __lastChild: BackgroundSnapshotInstance | null = null;\n private __previousSibling: BackgroundSnapshotInstance | null = null;\n private __nextSibling: BackgroundSnapshotInstance | null = null;\n private __removed_from_tree?: boolean;\n\n get parentNode(): BackgroundSnapshotInstance | null {\n return this.__parent;\n }\n\n get nextSibling(): BackgroundSnapshotInstance | null {\n return this.__nextSibling;\n }\n\n // get isConnected() {\n // return !!this.__parent;\n // }\n\n // contains(child: BackgroundSnapshotInstance): boolean {\n // return child.parentNode === this;\n // }\n\n // Preact 11's `removeNode` calls `node.remove()` instead of\n // `parentNode.removeChild(node)`.\n remove(): void {\n this.parentNode?.removeChild(this);\n }\n\n // This will be called in `lazy`/`Suspense`.\n appendChild(child: BackgroundSnapshotInstance): void {\n return this.insertBefore(child);\n }\n\n insertBefore(\n node: BackgroundSnapshotInstance,\n beforeNode?: BackgroundSnapshotInstance,\n ): void {\n if (node.__removed_from_tree) {\n node.__removed_from_tree = false;\n // This is only called by `lazy`/`Suspense` through `appendChild` so beforeNode is always undefined.\n /* v8 ignore next */\n reconstructInstanceTree([node], this.__id, beforeNode?.__id);\n } else {\n __globalSnapshotPatch?.push(\n SnapshotOperation.InsertBefore,\n this.__id,\n node.__id,\n beforeNode?.__id,\n node.__slotIndex,\n );\n }\n\n // If the node already has a parent, remove it from its current parent\n const p = node.__parent;\n if (p) {\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n p.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n p.__lastChild = node.__previousSibling;\n }\n }\n\n // If beforeNode is not provided, add the new node as the last child\n if (beforeNode) {\n // If beforeNode is provided, insert the new node before beforeNode\n if (beforeNode.__previousSibling) {\n beforeNode.__previousSibling.__nextSibling = node;\n node.__previousSibling = beforeNode.__previousSibling;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n beforeNode.__previousSibling = node;\n node.__nextSibling = beforeNode;\n node.__parent = this;\n } else {\n if (this.__lastChild) {\n this.__lastChild.__nextSibling = node;\n node.__previousSibling = this.__lastChild;\n } else {\n this.__firstChild = node;\n node.__previousSibling = null;\n }\n this.__lastChild = node;\n node.__parent = this;\n node.__nextSibling = null;\n }\n }\n\n removeChild(node: BackgroundSnapshotInstance): void {\n __globalSnapshotPatch?.push(\n SnapshotOperation.RemoveChild,\n this.__id,\n node.__id,\n );\n node.__removed_from_tree = true;\n\n if (node.__parent !== this) {\n throw new Error('The node to be removed is not a child of this node.');\n }\n\n if (node.__previousSibling) {\n node.__previousSibling.__nextSibling = node.__nextSibling;\n } else {\n this.__firstChild = node.__nextSibling;\n }\n\n if (node.__nextSibling) {\n node.__nextSibling.__previousSibling = node.__previousSibling;\n } else {\n this.__lastChild = node.__previousSibling;\n }\n\n node.__parent = null;\n node.__previousSibling = null;\n node.__nextSibling = null;\n\n traverseSnapshotInstance(node, instance => {\n if (instance.__values) {\n instance.__snapshot_def.refAndSpreadIndexes?.forEach(index => {\n const ref = getRefFromValue(instance.__values![index]);\n if (ref) {\n queueRefAttrUpdate(ref, null, instance, index);\n }\n });\n }\n });\n\n globalBackgroundSnapshotInstancesToRemove.push(node.__id);\n }\n\n tearDown(): void {\n traverseSnapshotInstance(this, v => {\n v.__parent = null;\n v.__previousSibling = null;\n v.__nextSibling = null;\n backgroundSnapshotInstanceManager.values.delete(v.__id);\n });\n }\n\n get childNodes(): BackgroundSnapshotInstance[] {\n const nodes: BackgroundSnapshotInstance[] = [];\n let node = this.__firstChild;\n while (node) {\n nodes.push(node);\n node = node.__nextSibling;\n }\n return nodes;\n }\n\n setAttribute(key: string | number, value: unknown): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::BSI::setAttribute');\n }\n if (key === 'values') {\n if (__globalSnapshotPatch) {\n const oldValues = this.__values;\n if (oldValues) {\n for (let index = 0; index < (value as unknown[]).length; index++) {\n const { needUpdate, valueToCommit } = this.setAttributeImpl(\n (value as unknown[])[index],\n oldValues[index],\n index,\n );\n if (needUpdate) {\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n index,\n valueToCommit,\n );\n }\n }\n } else {\n const patch = [];\n const length = (value as unknown[]).length;\n for (let index = 0; index < length; ++index) {\n const { valueToCommit } = this.setAttributeImpl((value as unknown[])[index], null, index);\n patch[index] = valueToCommit;\n }\n __globalSnapshotPatch.push(\n SnapshotOperation.SetAttributes,\n this.__id,\n patch,\n );\n }\n } else {\n this.__snapshot_def.refAndSpreadIndexes?.forEach((index) => {\n // In first render, this.__values is undefined.\n // In next rerenders before hydration, this.__values is not undefined.\n const oldValue: unknown = this.__values?.[index];\n const v = (value as unknown[])[index];\n queueRefAttrUpdate(getRefFromValue(oldValue), getRefFromValue(v), this, index);\n });\n }\n this.__values = value as unknown[];\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n\n if (typeof key === 'string') {\n if (key === '__listItemPlatformInfoIndex') {\n this.__listItemPlatformInfoIndex = value as number;\n this.syncListItemPlatformInfo();\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n if (key === '__listItemPlatformInfo') {\n this.__listItemPlatformInfo = value as PlatformInfo;\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n return;\n }\n (this.__extraProps ??= {})[key] = value;\n } else {\n // old path (`this.setAttribute(0, xxx)`)\n // is reserved as slow path\n (this.__values ??= [])[key] = value;\n this.syncListItemPlatformInfo();\n }\n __globalSnapshotPatch?.push(\n SnapshotOperation.SetAttribute,\n this.__id,\n key,\n value,\n );\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n\n private syncListItemPlatformInfo(): void {\n if (this.__listItemPlatformInfoIndex === undefined || !this.__values) {\n return;\n }\n const index = this.__listItemPlatformInfoIndex;\n this.__listItemPlatformInfo = getListItemPlatformInfoFromIndexedValue(\n this.__values[index],\n this.__snapshot_def.refAndSpreadIndexes?.includes(index),\n );\n }\n\n private setAttributeImpl(newValue: unknown, oldValue: unknown, index: number): {\n needUpdate: boolean;\n valueToCommit: unknown;\n } {\n if (!newValue) {\n const oldRef = getRefFromValue(oldValue);\n if (oldRef) {\n queueRefAttrUpdate(oldRef, null, this, index);\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n\n const newType = typeof newValue;\n if (newType === 'object') {\n const newValueObj = newValue as Record<string, unknown>;\n if ('__spread' in newValueObj) {\n const oldSpread = (oldValue as { __spread?: Record<string, unknown> } | undefined)?.__spread;\n const newSpread = transformSpread(this, index, newValueObj);\n const needUpdate = !isDirectOrDeepEqual(oldSpread, newSpread);\n // use __spread to cache the transform result for next diff\n newValueObj['__spread'] = newSpread;\n queueRefAttrUpdate(\n oldSpread && ((oldValue as { ref?: Ref }).ref),\n newValueObj['ref'] as Ref,\n this,\n index,\n );\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareSpreadForCommit(newSpread, oldSpread) : newSpread,\n };\n }\n if ('__ref' in newValueObj) {\n queueRefAttrUpdate(oldValue as Ref, newValueObj as unknown as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n if ('_wkltId' in newValueObj) {\n // Worklet ctx can be stable across rerenders (e.g. memoized by the user).\n // In that case we should NOT re-register / re-send it, otherwise `_execId` churn\n // will cause unnecessary patches.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate ? prepareWorkletForCommit(newValueObj as Worklet) : newValue,\n };\n }\n if ('__isGesture' in newValueObj) {\n // Gestures are large objects; if the reference is stable, avoid reprocessing and patching.\n const needUpdate = oldValue !== newValue;\n return {\n needUpdate,\n valueToCommit: needUpdate\n ? prepareGestureForCommit(newValueObj as unknown as GestureKind)\n : newValue,\n };\n }\n if ('__ltf' in newValueObj) {\n // __lynx_timing_flag\n if (globalPipelineOptions && (oldValue as { __ltf?: unknown } | undefined)?.__ltf != newValueObj['__ltf']) {\n globalPipelineOptions.needTimestamps = true;\n return { needUpdate: true, valueToCommit: newValue };\n }\n return { needUpdate: false, valueToCommit: newValue };\n }\n return { needUpdate: !isDirectOrDeepEqual(oldValue, newValue), valueToCommit: newValue };\n }\n if (newType === 'function') {\n if ((newValue as { __ref?: unknown }).__ref) {\n queueRefAttrUpdate(oldValue as Ref, newValue as Ref, this, index);\n return { needUpdate: false, valueToCommit: 1 };\n }\n /* event */\n return { needUpdate: !oldValue, valueToCommit: 1 };\n }\n return { needUpdate: oldValue !== newValue, valueToCommit: newValue };\n }\n}\n\nexport function hydrate(\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n): SnapshotPatch {\n const shouldProfile = typeof __PROFILE__ !== 'undefined' && __PROFILE__;\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::hydrate');\n }\n try {\n initGlobalSnapshotPatch();\n\n const helper = (\n before: SerializedSnapshotInstance,\n after: BackgroundSnapshotInstance,\n ) => {\n hydrationMap.set(after.__id, before.id);\n backgroundSnapshotInstanceManager.updateId(after.__id, before.id);\n // handle value by index\n after.__values?.forEach((value: unknown, index) => {\n // render with different root would cause different values length\n const old: unknown = before.values?.[index];\n\n if (value) {\n if (typeof value === 'object') {\n if ('__spread' in value) {\n // `value.__spread` my contain event ids using snapshot ids before hydration. Remove it.\n delete value.__spread;\n const __spread = transformSpread(after, index, value);\n // Cache a clean spread for future diffs. For the patch payload, create a committed copy\n // with runtime fields (e.g. `_execId`) injected.\n (after.__values![index]! as Record<string, unknown>)['__spread'] = __spread;\n value = prepareSpreadForCommit(__spread, old as Record<string, unknown> | undefined);\n } else if ('__ref' in value) {\n // skip patch\n value = old;\n } else if ('_wkltId' in value) {\n value = prepareWorkletForCommit(value as Worklet);\n } else if ('__isGesture' in value) {\n value = prepareGestureForCommit(value as GestureKind);\n }\n } else if (typeof value === 'function') {\n if ('__ref' in value) {\n // skip patch\n value = old;\n } else {\n value = `${after.__id}:${index}:`;\n }\n }\n }\n\n if (!isDirectOrDeepEqual(value, old)) {\n if (value === undefined && old === null) {\n // This is a workaround for the case where we set an attribute to `undefined` in the main thread,\n // but the old value becomes `null` during JSON serialization.\n // In this case, we should not patch the value.\n } else {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: String(index),\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n index,\n value,\n );\n }\n }\n }\n });\n\n // handle extraProps as attributes and set by key\n if (after.__extraProps) {\n for (const key in after.__extraProps) {\n const value = after.__extraProps[key];\n const old = before.extraProps?.[key];\n if (!isDirectOrDeepEqual(value, old)) {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::setAttribute', {\n args: {\n id: String(after.__id),\n snapshotType: String(after.type),\n source: getSnapshotVNodeSource(after.__id) ?? '',\n dynamicPartIndex: key,\n valueType: value === null ? 'null' : typeof value,\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.SetAttribute,\n after.__id,\n key,\n value,\n );\n }\n }\n }\n }\n\n const { slot } = after.__snapshot_def;\n\n const beforeChildNodes = before.children ?? [];\n const afterChildNodes = after.childNodes;\n\n if (!slot) {\n return;\n }\n\n // Hoisted out of the loop: none of this depends on the slot entry.\n const diffChildren = (\n filteredBeforeChildNodes: SerializedSnapshotInstance[],\n filteredAfterChildNodes: BackgroundSnapshotInstance[],\n isListHasItemKey: boolean,\n ) => {\n const diffResult = diffArrayLepus(\n filteredBeforeChildNodes,\n filteredAfterChildNodes,\n (a, b) => a.type === b.type,\n (a, b) => {\n helper(a, b);\n },\n isListHasItemKey,\n );\n diffArrayAction(\n filteredBeforeChildNodes,\n diffResult,\n (node, target) => {\n if (shouldProfile) {\n profileStart('ReactLynx::BSI::reconstructInstanceTree', {\n args: {\n id: String(node.__id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.__id) ?? '',\n },\n });\n }\n try {\n reconstructInstanceTree([node], before.id, target?.id);\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n return undefined as unknown as SerializedSnapshotInstance;\n },\n node => {\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::removeChild', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.RemoveChild,\n before.id,\n node.id,\n );\n }\n },\n (node, target) => {\n // changedList.push([SnapshotOperation.RemoveChild, before.id, node.id]);\n if (shouldProfile) {\n profileStart('ReactLynx::hydrate::insertBefore', {\n args: {\n id: String(node.id),\n snapshotType: String(node.type),\n source: getSnapshotVNodeSource(node.id) ?? '',\n parentId: String(before.id),\n targetId: String(target?.id ?? ''),\n },\n });\n try {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n } finally {\n profileEnd();\n }\n } else {\n __globalSnapshotPatch!.push(\n SnapshotOperation.InsertBefore,\n before.id,\n node.id,\n target?.id,\n node.slotIndex ?? 0,\n );\n }\n },\n );\n };\n\n slot.forEach(([type], index) => {\n switch (type) {\n case DynamicPartType.Slot:\n case DynamicPartType.MultiChildren: {\n // TODO: the following null assertions are not 100% safe\n const v1 = beforeChildNodes[index]!;\n const v2 = afterChildNodes[index]!;\n helper(v1, v2);\n break;\n }\n case DynamicPartType.SlotV2:\n case DynamicPartType.Children: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.SlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n // Children match pairwise by type, so the diff is empty — do what\n // `diffArrayLepus` + `diffArrayAction` would do without allocating\n // the diff structures.\n const length = filteredBeforeChildNodes.length;\n if (length === filteredAfterChildNodes.length) {\n let samePairwise = true;\n for (let i = 0; i < length; i++) {\n if (filteredBeforeChildNodes[i]!.type !== filteredAfterChildNodes[i]!.type) {\n samePairwise = false;\n break;\n }\n }\n if (samePairwise) {\n for (let i = 0; i < length; i++) {\n helper(filteredBeforeChildNodes[i]!, filteredAfterChildNodes[i]!);\n }\n break;\n }\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, false);\n break;\n }\n case DynamicPartType.ListSlotV2:\n case DynamicPartType.ListChildren: {\n let filteredBeforeChildNodes = beforeChildNodes;\n let filteredAfterChildNodes = afterChildNodes;\n if (type === DynamicPartType.ListSlotV2) {\n filteredBeforeChildNodes = beforeChildNodes.filter(v => (v.slotIndex ?? 0) === index);\n filteredAfterChildNodes = afterChildNodes.filter(v => v.__slotIndex === index);\n }\n\n diffChildren(filteredBeforeChildNodes, filteredAfterChildNodes, true);\n break;\n }\n default:\n throw new Error('Unexpected slot type: ' + type);\n }\n });\n };\n\n helper(before, after);\n // Hydration should not trigger ref updates. They were incorrectly triggered when using `setAttribute` to add values to the patch list.\n clearQueuedRefs();\n clearPendingPortalInsertBefore();\n return takeGlobalSnapshotPatch()!;\n } finally {\n if (shouldProfile) {\n profileEnd();\n }\n }\n}\n"]}