@tonyclaw/agent-inspector 3.0.45 → 3.0.47

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 (343) hide show
  1. package/.output/{nitro.json → backend/nitro.json} +3 -3
  2. package/.output/backend-public/assets/index-D4LX-sw-.js +11 -0
  3. package/.output/cli.js +8018 -5451
  4. package/.output/server/_libs/extend.mjs +4 -8
  5. package/.output/server/_libs/jszip.mjs +9 -35
  6. package/.output/server/_libs/react-dom.mjs +2 -3
  7. package/.output/server/_libs/react.mjs +1 -27
  8. package/.output/server/_libs/tanstack__react-router.mjs +1 -329
  9. package/.output/server/_libs/tanstack__router-core.mjs +42 -100
  10. package/.output/server/_libs/use-sync-external-store.mjs +1 -64
  11. package/.output/server/_libs/ws.mjs +1 -1
  12. package/.output/server/_ssr/index.mjs +4 -4
  13. package/.output/server/_ssr/{publicBasePathContext-5264L3rX.mjs → publicBasePathContext-IH2ilOfu.mjs} +52 -24
  14. package/.output/server/_ssr/{router-BJ_ltLim.mjs → router-BwZEsYfS.mjs} +19794 -19444
  15. package/.output/server/_ssr/{start-C6MjPjxp.mjs → start-COQu_AgD.mjs} +1 -1
  16. package/.output/server/_tanstack-start-manifest_v-DnbdNeun.mjs +4 -0
  17. package/.output/server/index.mjs +5 -145
  18. package/.output/{public/assets/CompareDrawer-B3_TLTJh.js → ui/assets/CompareDrawer-V-8lPASC.js} +1 -1
  19. package/.output/{public/assets/InspectorPet-Cpn6hv4P.js → ui/assets/InspectorPet-D4CVnfdf.js} +1 -1
  20. package/.output/ui/assets/ProxyViewerContainer-CO3ZVHLX.js +59 -0
  21. package/.output/{public/assets/ReplayDialog-B3EKVdJk.js → ui/assets/ReplayDialog-CpGyTLtt.js} +1 -1
  22. package/.output/{public/assets/RequestAnatomy-COOQjyUC.js → ui/assets/RequestAnatomy-BLuJL9dZ.js} +1 -1
  23. package/.output/ui/assets/ResponseView-BuSC-CH7.js +2 -0
  24. package/.output/ui/assets/StreamingChunkSequence-DeA-JJKa.js +1 -0
  25. package/.output/{public/assets/_sessionId-zbgYl7ZJ.js → ui/assets/_sessionId-8HuHFhjo.js} +1 -1
  26. package/.output/{public/assets/_sessionId-BJlM3nmt.js → ui/assets/_sessionId-Chp67th6.js} +1 -1
  27. package/.output/ui/assets/favicon-DYEkHSNl.svg +21 -0
  28. package/.output/ui/assets/index-BvXp42al.css +1 -0
  29. package/.output/{public/assets/index-xF_NY8Yb.js → ui/assets/index-DPmKK_5d.js} +5 -5
  30. package/.output/{public/assets/index-BIK4bPTv.js → ui/assets/index-atoQrlb8.js} +1 -1
  31. package/.output/ui/assets/index-nY3E1vxV.js +73 -0
  32. package/.output/{public/assets/index-D2Qw6Ri2.js → ui/assets/index-nl9-dpZn.js} +1 -1
  33. package/.output/ui/assets/json-viewer-B9kIzqeX.js +1 -0
  34. package/.output/{public/assets/jszip.min-B_rfAUCe.js → ui/assets/jszip.min-B7tfyE-I.js} +1 -1
  35. package/.output/ui/index.html +229 -0
  36. package/.output/ui/runtime-config.js +2 -0
  37. package/.output/workers/logFinalizer.worker.js +979 -414
  38. package/.output/workers/sessionWorkerEntry.js +979 -414
  39. package/README.md +182 -43
  40. package/docs/instance-control.openapi.yaml +59 -4
  41. package/package.json +40 -6
  42. package/scripts/generate-theme-scales.mjs +3 -3
  43. package/src/{router.tsx → backend/router.tsx} +3 -15
  44. package/src/backend/routes/$.ts +26 -0
  45. package/src/backend/routes/__root.ts +4 -0
  46. package/src/backend/routes/api/-instances.ts +7 -0
  47. package/src/{routes → backend/routes}/api/alerts.summary.ts +3 -3
  48. package/src/{routes → backend/routes}/api/alerts.ts +4 -4
  49. package/src/{routes → backend/routes}/api/config.paths.ts +1 -1
  50. package/src/{routes → backend/routes}/api/config.ts +11 -2
  51. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.help.ts +1 -1
  52. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.install.ts +1 -1
  53. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.runner-presets.ts +1 -1
  54. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.upgrade.ts +1 -1
  55. package/src/{routes → backend/routes}/api/ecosystem.packages.ts +5 -1
  56. package/src/{routes → backend/routes}/api/ecosystem.recipes.$recipeId.run.ts +1 -1
  57. package/src/{routes → backend/routes}/api/ecosystem.tasks.$taskId.ts +1 -1
  58. package/src/{routes → backend/routes}/api/ecosystem.tasks.ts +1 -1
  59. package/src/{routes → backend/routes}/api/groups.$groupId.evidence.ts +2 -2
  60. package/src/{routes → backend/routes}/api/groups.$groupId.sessions.ts +2 -2
  61. package/src/{routes → backend/routes}/api/groups.$groupId.ts +2 -2
  62. package/src/{routes → backend/routes}/api/groups.ts +2 -2
  63. package/src/{routes → backend/routes}/api/health.ts +3 -3
  64. package/src/{routes → backend/routes}/api/instances.$name.connection.ts +1 -1
  65. package/src/{routes → backend/routes}/api/instances.$name.restart.ts +2 -2
  66. package/src/{routes → backend/routes}/api/instances.$name.start.ts +2 -2
  67. package/src/{routes → backend/routes}/api/instances.$name.stop.ts +2 -2
  68. package/src/{routes → backend/routes}/api/instances.$name.ts +1 -1
  69. package/src/{routes → backend/routes}/api/instances.ts +1 -1
  70. package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.promote.ts +2 -2
  71. package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.ts +2 -2
  72. package/src/{routes → backend/routes}/api/knowledge.candidates.ts +1 -1
  73. package/src/{routes → backend/routes}/api/knowledge.project-context.ts +2 -2
  74. package/src/{routes → backend/routes}/api/knowledge.search.ts +2 -2
  75. package/src/{routes → backend/routes}/api/knowledge.sessions.$sessionId.candidates.ts +3 -3
  76. package/src/{routes → backend/routes}/api/logs.$id.body.ts +6 -6
  77. package/src/{routes → backend/routes}/api/logs.$id.chunks.ts +5 -4
  78. package/src/{routes → backend/routes}/api/logs.$id.replay.ts +12 -11
  79. package/src/{routes → backend/routes}/api/logs.$id.ts +4 -3
  80. package/src/{routes → backend/routes}/api/logs.import.ts +3 -3
  81. package/src/{routes → backend/routes}/api/logs.stream.ts +11 -7
  82. package/src/{routes → backend/routes}/api/logs.ts +17 -9
  83. package/src/{routes → backend/routes}/api/mcp.ts +1 -1
  84. package/src/{routes → backend/routes}/api/models.ts +1 -1
  85. package/src/{routes → backend/routes}/api/pi-agent.ts +2 -2
  86. package/src/{routes → backend/routes}/api/providers.$providerId.model-metadata.ts +5 -5
  87. package/src/{routes → backend/routes}/api/providers.$providerId.test.log.ts +7 -7
  88. package/src/{routes → backend/routes}/api/providers.$providerId.ts +4 -4
  89. package/src/{routes → backend/routes}/api/providers.export.ts +1 -1
  90. package/src/{routes → backend/routes}/api/providers.import.ts +3 -3
  91. package/src/{routes → backend/routes}/api/providers.scan.ts +2 -2
  92. package/src/{routes → backend/routes}/api/providers.ts +9 -4
  93. package/src/{routes → backend/routes}/api/runs.$runId.evidence.ts +2 -2
  94. package/src/{routes → backend/routes}/api/runs.$runId.ts +2 -2
  95. package/src/{routes → backend/routes}/api/runs.ts +4 -4
  96. package/src/backend/routes/api/runtime.ts +46 -0
  97. package/src/{routes → backend/routes}/api/sessions.ts +3 -3
  98. package/src/{routes → backend/routes}/proxy/$.ts +1 -1
  99. package/src/{routes → backend/routes}/readyz.ts +1 -1
  100. package/src/{start.ts → backend/start.ts} +1 -1
  101. package/src/cli/alias.ts +2 -11
  102. package/src/cli/doctor.ts +32 -9
  103. package/src/cli/instance.ts +36 -13
  104. package/src/cli/instanceApi.ts +213 -0
  105. package/src/cli/instanceArgs.ts +46 -11
  106. package/src/cli/instanceControl.ts +10 -2
  107. package/src/cli/instanceModel.ts +18 -17
  108. package/src/cli/instanceRegistry.ts +0 -9
  109. package/src/cli/networkHints.ts +27 -14
  110. package/src/cli/onboard.ts +69 -2
  111. package/src/cli/onboardTarget.ts +89 -40
  112. package/src/cli/rustBackendPackage.ts +450 -0
  113. package/src/cli/templates/codex-skill-onboard.ts +44 -14
  114. package/src/cli/templates/skill-onboard.ts +64 -28
  115. package/src/cli.ts +341 -75
  116. package/src/components/ProxyViewer.tsx +11 -9
  117. package/src/components/ProxyViewerContainer.tsx +12 -11
  118. package/src/components/pi-agent/PiAgentPanel.tsx +2 -2
  119. package/src/components/providers/ProviderCard.tsx +1 -1
  120. package/src/components/providers/ProviderTestResultsView.tsx +1 -1
  121. package/src/components/providers/SettingsDialog.tsx +159 -144
  122. package/src/components/proxy-viewer/ApplicationBar.tsx +2 -1
  123. package/src/components/proxy-viewer/LogEntry.tsx +1 -1
  124. package/src/components/proxy-viewer/log-formats/index.ts +1 -1
  125. package/src/contracts/index.ts +5 -0
  126. package/src/contracts/log.ts +33 -3
  127. package/src/knowledge/types.ts +3 -2
  128. package/src/lib/alertContract.ts +2 -2
  129. package/src/lib/apiClient.ts +30 -7
  130. package/src/lib/apiFormat.ts +29 -0
  131. package/src/lib/backendImplementation.ts +16 -0
  132. package/src/lib/basePath.ts +29 -11
  133. package/src/lib/browserRuntimeContract.ts +124 -0
  134. package/src/lib/browserRuntimeResolver.ts +244 -0
  135. package/src/{proxy → lib}/claudeCodeStrip.ts +6 -7
  136. package/src/lib/codingAgentEndpoints.ts +38 -0
  137. package/src/lib/instanceContract.ts +30 -11
  138. package/src/lib/managedInstance.ts +9 -1
  139. package/src/lib/piAgentContract.ts +3 -2
  140. package/src/lib/publicBasePathContext.ts +40 -10
  141. package/src/lib/resourceLimits.ts +2 -0
  142. package/src/lib/runContract.ts +3 -3
  143. package/src/lib/sessionInfoContract.ts +3 -2
  144. package/src/mcp/instanceHandlers.ts +2 -0
  145. package/src/mcp/server.ts +19 -24
  146. package/src/proxy/config.ts +25 -30
  147. package/src/proxy/dataDir.ts +43 -7
  148. package/src/proxy/ecosystemTasks.ts +161 -70
  149. package/src/proxy/formats/registry.ts +6 -21
  150. package/src/proxy/handler.ts +129 -29
  151. package/src/proxy/identityProxy.ts +567 -39
  152. package/src/proxy/jsonlRecovery.ts +554 -0
  153. package/src/proxy/logFinalizer.ts +25 -10
  154. package/src/proxy/logImporter.ts +2 -1
  155. package/src/proxy/logIndex.ts +191 -95
  156. package/src/proxy/logger.ts +77 -14
  157. package/src/proxy/platformCommands.ts +41 -0
  158. package/src/proxy/privateDataPath.ts +310 -88
  159. package/src/proxy/rawStreamCapture.ts +194 -13
  160. package/src/proxy/runtimeAdmission.ts +5 -2
  161. package/src/proxy/runtimeHealth.ts +14 -1
  162. package/src/proxy/runtimeShutdown.ts +11 -1
  163. package/src/proxy/schemas.ts +7 -1
  164. package/src/proxy/sessionArchive.ts +70 -14
  165. package/src/proxy/sqliteLogIndex.ts +65 -42
  166. package/src/proxy/store.ts +141 -34
  167. package/src/proxy/uiAssetServer.ts +106 -0
  168. package/src/proxy/upstream.ts +29 -2
  169. package/src/ui/bootstrap.ts +167 -0
  170. package/src/ui/index.html +38 -0
  171. package/src/ui/logsStreamClient.ts +20 -0
  172. package/src/ui/main.tsx +13 -0
  173. package/src/ui/public/runtime-config.js +2 -0
  174. package/src/ui/router.tsx +13 -0
  175. package/src/ui/routes/__root.tsx +69 -0
  176. package/src/{routes → ui/routes}/index.tsx +2 -3
  177. package/src/{routes → ui/routes}/session/$sessionId.tsx +5 -11
  178. package/src/ui/runtimeDiscovery.ts +50 -0
  179. package/styles/globals.css +1 -0
  180. package/.output/public/assets/ProxyViewerContainer-BEAhuGOJ.js +0 -126
  181. package/.output/public/assets/ResponseView-DBCjkwye.js +0 -2
  182. package/.output/public/assets/StreamingChunkSequence-CuXhDgMo.js +0 -1
  183. package/.output/public/assets/index-BZo_8koU.js +0 -70
  184. package/.output/public/assets/index-ZWschkCh.css +0 -1
  185. package/.output/public/assets/json-viewer-B-Ao6pwW.js +0 -1
  186. package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +0 -1
  187. package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +0 -344
  188. package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +0 -2
  189. package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +0 -2
  190. package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +0 -2
  191. package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +0 -11
  192. package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +0 -69
  193. package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +0 -1
  194. package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +0 -28
  195. package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +0 -6
  196. package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +0 -34
  197. package/.output/server/_libs/aria-hidden.mjs +0 -122
  198. package/.output/server/_libs/bail.mjs +0 -8
  199. package/.output/server/_libs/character-entities.mjs +0 -2130
  200. package/.output/server/_libs/class-variance-authority.mjs +0 -44
  201. package/.output/server/_libs/clsx.mjs +0 -16
  202. package/.output/server/_libs/comma-separated-tokens.mjs +0 -10
  203. package/.output/server/_libs/decode-named-character-reference+[...].mjs +0 -8
  204. package/.output/server/_libs/dequal.mjs +0 -27
  205. package/.output/server/_libs/detect-node-es.mjs +0 -1
  206. package/.output/server/_libs/devlop.mjs +0 -8
  207. package/.output/server/_libs/diff.mjs +0 -320
  208. package/.output/server/_libs/estree-util-is-identifier-name.mjs +0 -11
  209. package/.output/server/_libs/floating-ui__core.mjs +0 -725
  210. package/.output/server/_libs/floating-ui__dom.mjs +0 -622
  211. package/.output/server/_libs/floating-ui__react-dom.mjs +0 -292
  212. package/.output/server/_libs/floating-ui__utils.mjs +0 -320
  213. package/.output/server/_libs/get-nonce.mjs +0 -9
  214. package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  215. package/.output/server/_libs/hast-util-whitespace.mjs +0 -10
  216. package/.output/server/_libs/html-url-attributes.mjs +0 -26
  217. package/.output/server/_libs/inline-style-parser.mjs +0 -142
  218. package/.output/server/_libs/is-plain-obj.mjs +0 -10
  219. package/.output/server/_libs/lucide-react.mjs +0 -1027
  220. package/.output/server/_libs/mdast-util-from-markdown.mjs +0 -717
  221. package/.output/server/_libs/mdast-util-to-hast.mjs +0 -710
  222. package/.output/server/_libs/mdast-util-to-string.mjs +0 -38
  223. package/.output/server/_libs/micromark-core-commonmark.mjs +0 -2259
  224. package/.output/server/_libs/micromark-factory-destination.mjs +0 -94
  225. package/.output/server/_libs/micromark-factory-label.mjs +0 -63
  226. package/.output/server/_libs/micromark-factory-space.mjs +0 -24
  227. package/.output/server/_libs/micromark-factory-title.mjs +0 -65
  228. package/.output/server/_libs/micromark-factory-whitespace.mjs +0 -22
  229. package/.output/server/_libs/micromark-util-character.mjs +0 -44
  230. package/.output/server/_libs/micromark-util-chunked.mjs +0 -36
  231. package/.output/server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  232. package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  233. package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  234. package/.output/server/_libs/micromark-util-decode-string.mjs +0 -21
  235. package/.output/server/_libs/micromark-util-encode.mjs +0 -1
  236. package/.output/server/_libs/micromark-util-html-tag-name.mjs +0 -69
  237. package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  238. package/.output/server/_libs/micromark-util-resolve-all.mjs +0 -15
  239. package/.output/server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  240. package/.output/server/_libs/micromark-util-subtokenize.mjs +0 -346
  241. package/.output/server/_libs/micromark.mjs +0 -906
  242. package/.output/server/_libs/property-information.mjs +0 -1209
  243. package/.output/server/_libs/radix-ui.mjs +0 -1
  244. package/.output/server/_libs/radix-ui__number.mjs +0 -6
  245. package/.output/server/_libs/radix-ui__primitive.mjs +0 -11
  246. package/.output/server/_libs/radix-ui__react-accordion.mjs +0 -1
  247. package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +0 -1
  248. package/.output/server/_libs/radix-ui__react-arrow.mjs +0 -23
  249. package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +0 -1
  250. package/.output/server/_libs/radix-ui__react-avatar.mjs +0 -1
  251. package/.output/server/_libs/radix-ui__react-checkbox.mjs +0 -1
  252. package/.output/server/_libs/radix-ui__react-collapsible.mjs +0 -144
  253. package/.output/server/_libs/radix-ui__react-collection.mjs +0 -69
  254. package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -38
  255. package/.output/server/_libs/radix-ui__react-context-menu.mjs +0 -1
  256. package/.output/server/_libs/radix-ui__react-context.mjs +0 -64
  257. package/.output/server/_libs/radix-ui__react-dialog.mjs +0 -280
  258. package/.output/server/_libs/radix-ui__react-direction.mjs +0 -9
  259. package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +0 -1
  260. package/.output/server/_libs/radix-ui__react-focus-guards.mjs +0 -39
  261. package/.output/server/_libs/radix-ui__react-focus-scope.mjs +0 -210
  262. package/.output/server/_libs/radix-ui__react-form.mjs +0 -1
  263. package/.output/server/_libs/radix-ui__react-hover-card.mjs +0 -1
  264. package/.output/server/_libs/radix-ui__react-id.mjs +0 -14
  265. package/.output/server/_libs/radix-ui__react-label.mjs +0 -1
  266. package/.output/server/_libs/radix-ui__react-menu.mjs +0 -1
  267. package/.output/server/_libs/radix-ui__react-menubar.mjs +0 -1
  268. package/.output/server/_libs/radix-ui__react-popover.mjs +0 -1
  269. package/.output/server/_libs/radix-ui__react-popper.mjs +0 -340
  270. package/.output/server/_libs/radix-ui__react-portal.mjs +0 -16
  271. package/.output/server/_libs/radix-ui__react-presence.mjs +0 -173
  272. package/.output/server/_libs/radix-ui__react-primitive.mjs +0 -42
  273. package/.output/server/_libs/radix-ui__react-progress.mjs +0 -1
  274. package/.output/server/_libs/radix-ui__react-radio-group.mjs +0 -1
  275. package/.output/server/_libs/radix-ui__react-roving-focus.mjs +0 -235
  276. package/.output/server/_libs/radix-ui__react-scroll-area.mjs +0 -731
  277. package/.output/server/_libs/radix-ui__react-select.mjs +0 -1207
  278. package/.output/server/_libs/radix-ui__react-separator.mjs +0 -28
  279. package/.output/server/_libs/radix-ui__react-slider.mjs +0 -1
  280. package/.output/server/_libs/radix-ui__react-slot.mjs +0 -132
  281. package/.output/server/_libs/radix-ui__react-switch.mjs +0 -1
  282. package/.output/server/_libs/radix-ui__react-tabs.mjs +0 -194
  283. package/.output/server/_libs/radix-ui__react-toast.mjs +0 -2
  284. package/.output/server/_libs/radix-ui__react-toggle-group.mjs +0 -1
  285. package/.output/server/_libs/radix-ui__react-toggle.mjs +0 -1
  286. package/.output/server/_libs/radix-ui__react-toolbar.mjs +0 -1
  287. package/.output/server/_libs/radix-ui__react-tooltip.mjs +0 -498
  288. package/.output/server/_libs/radix-ui__react-use-previous.mjs +0 -14
  289. package/.output/server/_libs/radix-ui__react-use-size.mjs +0 -39
  290. package/.output/server/_libs/react-markdown.mjs +0 -235
  291. package/.output/server/_libs/react-remove-scroll-bar.mjs +0 -82
  292. package/.output/server/_libs/react-remove-scroll.mjs +0 -328
  293. package/.output/server/_libs/react-style-singleton.mjs +0 -69
  294. package/.output/server/_libs/remark-parse.mjs +0 -19
  295. package/.output/server/_libs/remark-rehype.mjs +0 -21
  296. package/.output/server/_libs/space-separated-tokens.mjs +0 -6
  297. package/.output/server/_libs/style-to-js.mjs +0 -72
  298. package/.output/server/_libs/style-to-object.mjs +0 -38
  299. package/.output/server/_libs/swr.mjs +0 -947
  300. package/.output/server/_libs/tailwind-merge.mjs +0 -3255
  301. package/.output/server/_libs/tanstack__react-virtual.mjs +0 -130
  302. package/.output/server/_libs/tanstack__virtual-core.mjs +0 -1319
  303. package/.output/server/_libs/three.mjs +0 -26016
  304. package/.output/server/_libs/trim-lines.mjs +0 -41
  305. package/.output/server/_libs/trough.mjs +0 -85
  306. package/.output/server/_libs/tslib.mjs +0 -1
  307. package/.output/server/_libs/ungap__structured-clone.mjs +0 -212
  308. package/.output/server/_libs/unified.mjs +0 -661
  309. package/.output/server/_libs/unist-util-is.mjs +0 -100
  310. package/.output/server/_libs/unist-util-position.mjs +0 -27
  311. package/.output/server/_libs/unist-util-stringify-position.mjs +0 -27
  312. package/.output/server/_libs/unist-util-visit-parents.mjs +0 -82
  313. package/.output/server/_libs/unist-util-visit.mjs +0 -24
  314. package/.output/server/_libs/use-callback-ref.mjs +0 -66
  315. package/.output/server/_libs/use-sidecar.mjs +0 -106
  316. package/.output/server/_libs/vfile-message.mjs +0 -138
  317. package/.output/server/_libs/vfile.mjs +0 -467
  318. package/.output/server/_sessionId-CJ99gZFV.mjs +0 -84
  319. package/.output/server/_sessionId-DEjScBpK.mjs +0 -146
  320. package/.output/server/_ssr/CompareDrawer-DtOIMeQB.mjs +0 -1060
  321. package/.output/server/_ssr/InspectorPet-CXc4oCBQ.mjs +0 -938
  322. package/.output/server/_ssr/ProxyViewerContainer-DVPlwfkt.mjs +0 -17632
  323. package/.output/server/_ssr/ReplayDialog-BQEA95qC.mjs +0 -725
  324. package/.output/server/_ssr/RequestAnatomy-BMyd8B7Q.mjs +0 -837
  325. package/.output/server/_ssr/ResponseView-qrTaEIM8.mjs +0 -757
  326. package/.output/server/_ssr/StreamingChunkSequence-BFTL8mIy.mjs +0 -274
  327. package/.output/server/_ssr/index-Bcj1Hcy4.mjs +0 -135
  328. package/.output/server/_ssr/index-DW-M7XUG.mjs +0 -84
  329. package/.output/server/_ssr/json-viewer-DiI0Yjsn.mjs +0 -483
  330. package/.output/server/_tanstack-start-manifest_v-C6pXXX9R.mjs +0 -4
  331. package/.output/server/node_modules/tslib/modules/index.js +0 -70
  332. package/.output/server/node_modules/tslib/modules/package.json +0 -3
  333. package/.output/server/node_modules/tslib/package.json +0 -47
  334. package/.output/server/node_modules/tslib/tslib.js +0 -484
  335. package/.output/server/package.json +0 -9
  336. package/src/routes/__root.tsx +0 -170
  337. package/src/routes/api/-instances.ts +0 -109
  338. /package/.output/{public → ui}/assets/agent-inspector-58K1_MsC.ico +0 -0
  339. /package/.output/{public → ui}/assets/alibaba-TTwafVwX.svg +0 -0
  340. /package/.output/{public → ui}/assets/minimax-BPMzvuL-.jpeg +0 -0
  341. /package/.output/{public → ui}/assets/qwen-mMn3f5ul.webp +0 -0
  342. /package/.output/{public → ui}/assets/zhipuai-BPNAnxo-.svg +0 -0
  343. /package/src/{routes → backend/routes}/livez.ts +0 -0
@@ -1,1319 +0,0 @@
1
- function createLazyMeasurementsView(count, flat, getItemKey) {
2
- const cache = new Array(count);
3
- return new Proxy(cache, {
4
- get(target, prop, receiver) {
5
- if (typeof prop === "string") {
6
- const c = prop.charCodeAt(0);
7
- if (c >= 48 && c <= 57) {
8
- const i = +prop;
9
- if (Number.isInteger(i) && i >= 0 && i < count) {
10
- let v = target[i];
11
- if (!v) {
12
- const s = flat[i * 2];
13
- v = target[i] = {
14
- index: i,
15
- key: getItemKey(i),
16
- start: s,
17
- size: flat[i * 2 + 1],
18
- end: s + flat[i * 2 + 1],
19
- lane: 0
20
- };
21
- }
22
- return v;
23
- }
24
- }
25
- if (prop === "length") return count;
26
- }
27
- return Reflect.get(target, prop, receiver);
28
- }
29
- });
30
- }
31
- function memo(getDeps, fn, opts) {
32
- let deps = opts.initialDeps ?? [];
33
- let result;
34
- let isInitial = true;
35
- function memoizedFunction() {
36
- const newDeps = getDeps();
37
- const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
38
- if (!depsChanged) {
39
- return result;
40
- }
41
- deps = newDeps;
42
- result = fn(...newDeps);
43
- if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
44
- opts.onChange(result);
45
- }
46
- isInitial = false;
47
- return result;
48
- }
49
- memoizedFunction.updateDeps = (newDeps) => {
50
- deps = newDeps;
51
- };
52
- return memoizedFunction;
53
- }
54
- function notUndefined(value, msg) {
55
- if (value === void 0) {
56
- throw new Error(`Unexpected undefined${""}`);
57
- } else {
58
- return value;
59
- }
60
- }
61
- const approxEqual = (a, b) => Math.abs(a - b) < 1.01;
62
- const debounce = (targetWindow, fn, ms) => {
63
- let timeoutId;
64
- return function(...args) {
65
- targetWindow.clearTimeout(timeoutId);
66
- timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
67
- };
68
- };
69
- let _isIOSResult;
70
- const isIOSWebKit = () => {
71
- if (_isIOSResult !== void 0) return _isIOSResult;
72
- if (typeof navigator === "undefined") return _isIOSResult = false;
73
- if (/iP(hone|od|ad)/.test(navigator.userAgent)) return _isIOSResult = true;
74
- const mtp = navigator.maxTouchPoints;
75
- return _isIOSResult = navigator.platform === "MacIntel" && mtp !== void 0 && mtp > 0;
76
- };
77
- const getRect = (element) => {
78
- const { offsetWidth, offsetHeight } = element;
79
- return { width: offsetWidth, height: offsetHeight };
80
- };
81
- const defaultKeyExtractor = (index) => index;
82
- const defaultRangeExtractor = (range) => {
83
- const start = Math.max(range.startIndex - range.overscan, 0);
84
- const end = Math.min(range.endIndex + range.overscan, range.count - 1);
85
- const len = end - start + 1;
86
- const arr = new Array(len);
87
- for (let i = 0; i < len; i++) {
88
- arr[i] = start + i;
89
- }
90
- return arr;
91
- };
92
- const observeElementRect = (instance, cb) => {
93
- const element = instance.scrollElement;
94
- if (!element) {
95
- return;
96
- }
97
- const targetWindow = instance.targetWindow;
98
- if (!targetWindow) {
99
- return;
100
- }
101
- const handler = (rect) => {
102
- const { width, height } = rect;
103
- cb({ width: Math.round(width), height: Math.round(height) });
104
- };
105
- handler(getRect(element));
106
- if (!targetWindow.ResizeObserver) {
107
- return () => {
108
- };
109
- }
110
- const observer = new targetWindow.ResizeObserver((entries) => {
111
- const run = () => {
112
- const entry = entries[0];
113
- if (entry == null ? void 0 : entry.borderBoxSize) {
114
- const box = entry.borderBoxSize[0];
115
- if (box) {
116
- handler({ width: box.inlineSize, height: box.blockSize });
117
- return;
118
- }
119
- }
120
- handler(getRect(element));
121
- };
122
- instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
123
- });
124
- observer.observe(element, { box: "border-box" });
125
- return () => {
126
- observer.unobserve(element);
127
- };
128
- };
129
- const addEventListenerOptions = {
130
- passive: true
131
- };
132
- const observeWindowRect = (instance, cb) => {
133
- const element = instance.scrollElement;
134
- if (!element) {
135
- return;
136
- }
137
- const handler = () => {
138
- cb({ width: element.innerWidth, height: element.innerHeight });
139
- };
140
- handler();
141
- element.addEventListener("resize", handler, addEventListenerOptions);
142
- return () => {
143
- element.removeEventListener("resize", handler);
144
- };
145
- };
146
- const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
147
- const observeOffset = (instance, cb, readOffset) => {
148
- const element = instance.scrollElement;
149
- if (!element) {
150
- return;
151
- }
152
- const targetWindow = instance.targetWindow;
153
- if (!targetWindow) {
154
- return;
155
- }
156
- const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
157
- let offset = 0;
158
- const fallback = registerScrollendEvent ? null : debounce(
159
- targetWindow,
160
- () => cb(offset, false),
161
- instance.options.isScrollingResetDelay
162
- );
163
- const createHandler = (isScrolling) => () => {
164
- offset = readOffset(element);
165
- fallback == null ? void 0 : fallback();
166
- cb(offset, isScrolling);
167
- };
168
- const handler = createHandler(true);
169
- const endHandler = createHandler(false);
170
- element.addEventListener("scroll", handler, addEventListenerOptions);
171
- if (registerScrollendEvent) {
172
- element.addEventListener("scrollend", endHandler, addEventListenerOptions);
173
- }
174
- return () => {
175
- element.removeEventListener("scroll", handler);
176
- if (registerScrollendEvent) {
177
- element.removeEventListener("scrollend", endHandler);
178
- }
179
- };
180
- };
181
- const observeElementOffset = (instance, cb) => observeOffset(instance, cb, (el) => {
182
- const { horizontal, isRtl } = instance.options;
183
- return horizontal ? el.scrollLeft * (isRtl && -1 || 1) : el.scrollTop;
184
- });
185
- const observeWindowOffset = (instance, cb) => observeOffset(
186
- instance,
187
- cb,
188
- (win) => instance.options.horizontal ? win.scrollX : win.scrollY
189
- );
190
- const measureElement = (element, entry, instance) => {
191
- if (instance.options.useCachedMeasurements) {
192
- const index = instance.indexFromElement(element);
193
- const key = instance.options.getItemKey(index);
194
- return instance.itemSizeCache.get(key) ?? instance.options.estimateSize(index);
195
- }
196
- if (entry == null ? void 0 : entry.borderBoxSize) {
197
- const box = entry.borderBoxSize[0];
198
- if (box) {
199
- const size = Math.round(
200
- box[instance.options.horizontal ? "inlineSize" : "blockSize"]
201
- );
202
- return size;
203
- }
204
- }
205
- if (!entry) {
206
- const index = instance.indexFromElement(element);
207
- const key = instance.options.getItemKey(index);
208
- const cachedSize = instance.itemSizeCache.get(key);
209
- if (cachedSize !== void 0) {
210
- return cachedSize;
211
- }
212
- }
213
- return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
214
- };
215
- const scrollWithAdjustments = (offset, {
216
- adjustments = 0,
217
- behavior
218
- }, instance) => {
219
- var _a, _b;
220
- (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
221
- [instance.options.horizontal ? "left" : "top"]: offset + adjustments,
222
- behavior
223
- });
224
- };
225
- const windowScroll = scrollWithAdjustments;
226
- const elementScroll = scrollWithAdjustments;
227
- class Virtualizer {
228
- constructor(opts) {
229
- this.unsubs = [];
230
- this.scrollElement = null;
231
- this.targetWindow = null;
232
- this.isScrolling = false;
233
- this.scrollState = null;
234
- this.measurementsCache = [];
235
- this._flatMeasurements = null;
236
- this.itemSizeCache = /* @__PURE__ */ new Map();
237
- this.itemSizeCacheVersion = 0;
238
- this.laneAssignments = /* @__PURE__ */ new Map();
239
- this.pendingMin = null;
240
- this.prevLanes = void 0;
241
- this.lanesChangedFlag = false;
242
- this.lanesSettling = false;
243
- this.pendingScrollAnchor = null;
244
- this.scrollRect = null;
245
- this.scrollOffset = null;
246
- this.scrollDirection = null;
247
- this.scrollAdjustments = 0;
248
- this._iosDeferredAdjustment = 0;
249
- this._iosTouching = false;
250
- this._iosJustTouchEnded = false;
251
- this._iosTouchEndTimerId = null;
252
- this._intendedScrollOffset = null;
253
- this.elementsCache = /* @__PURE__ */ new Map();
254
- this.now = () => {
255
- var _a, _b, _c;
256
- return ((_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) ?? Date.now();
257
- };
258
- this.observer = /* @__PURE__ */ (() => {
259
- let _ro = null;
260
- const get = () => {
261
- if (_ro) {
262
- return _ro;
263
- }
264
- if (!this.targetWindow || !this.targetWindow.ResizeObserver) {
265
- return null;
266
- }
267
- return _ro = new this.targetWindow.ResizeObserver((entries) => {
268
- entries.forEach((entry) => {
269
- const run = () => {
270
- const node = entry.target;
271
- const index = this.indexFromElement(node);
272
- if (!node.isConnected) {
273
- this.observer.unobserve(node);
274
- for (const [cacheKey, cachedNode] of this.elementsCache) {
275
- if (cachedNode === node) {
276
- this.elementsCache.delete(cacheKey);
277
- break;
278
- }
279
- }
280
- return;
281
- }
282
- if (this.shouldMeasureDuringScroll(index)) {
283
- this.resizeItem(
284
- index,
285
- this.options.measureElement(node, entry, this)
286
- );
287
- }
288
- };
289
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
290
- });
291
- });
292
- };
293
- return {
294
- disconnect: () => {
295
- var _a;
296
- (_a = get()) == null ? void 0 : _a.disconnect();
297
- _ro = null;
298
- },
299
- observe: (target) => {
300
- var _a;
301
- return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
302
- },
303
- unobserve: (target) => {
304
- var _a;
305
- return (_a = get()) == null ? void 0 : _a.unobserve(target);
306
- }
307
- };
308
- })();
309
- this.range = null;
310
- this.setOptions = (opts2) => {
311
- var _a, _b;
312
- const merged = {
313
- debug: false,
314
- initialOffset: 0,
315
- overscan: 1,
316
- paddingStart: 0,
317
- paddingEnd: 0,
318
- scrollPaddingStart: 0,
319
- scrollPaddingEnd: 0,
320
- horizontal: false,
321
- getItemKey: defaultKeyExtractor,
322
- rangeExtractor: defaultRangeExtractor,
323
- onChange: () => {
324
- },
325
- measureElement,
326
- initialRect: { width: 0, height: 0 },
327
- scrollMargin: 0,
328
- gap: 0,
329
- indexAttribute: "data-index",
330
- initialMeasurementsCache: [],
331
- lanes: 1,
332
- anchorTo: "start",
333
- followOnAppend: false,
334
- scrollEndThreshold: 1,
335
- isScrollingResetDelay: 150,
336
- enabled: true,
337
- isRtl: false,
338
- useScrollendEvent: false,
339
- useAnimationFrameWithResizeObserver: false,
340
- laneAssignmentMode: "estimate",
341
- useCachedMeasurements: false
342
- };
343
- for (const key in opts2) {
344
- const v = opts2[key];
345
- if (v !== void 0) merged[key] = v;
346
- }
347
- const prevOptions = this.options;
348
- let anchor = null;
349
- let followOnAppend = null;
350
- let edgeKeysChanged = false;
351
- if (prevOptions !== void 0 && prevOptions.enabled && merged.enabled && merged.anchorTo === "end" && this.scrollElement !== null) {
352
- const prevCount = prevOptions.count;
353
- const nextCount = merged.count;
354
- const measurements = this.getMeasurements();
355
- const prevFirstKey = prevCount > 0 ? ((_a = measurements[0]) == null ? void 0 : _a.key) ?? prevOptions.getItemKey(0) : null;
356
- const prevLastKey = prevCount > 0 ? ((_b = measurements[prevCount - 1]) == null ? void 0 : _b.key) ?? prevOptions.getItemKey(prevCount - 1) : null;
357
- const didCountChange = nextCount !== prevCount;
358
- const didEdgeKeysChange = didCountChange || prevCount > 0 && nextCount > 0 && (merged.getItemKey(0) !== prevFirstKey || merged.getItemKey(nextCount - 1) !== prevLastKey);
359
- if (didEdgeKeysChange) {
360
- edgeKeysChanged = true;
361
- const item = prevCount > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? measurements[0] : null;
362
- if (item) {
363
- anchor = [item.key, this.getScrollOffset() - item.start];
364
- }
365
- const behavior = merged.followOnAppend === true ? "auto" : merged.followOnAppend || null;
366
- if (behavior && nextCount > prevCount && this.isAtEnd(prevOptions.scrollEndThreshold) && (prevCount === 0 || merged.getItemKey(nextCount - 1) !== prevLastKey)) {
367
- followOnAppend = behavior;
368
- }
369
- }
370
- }
371
- this.options = merged;
372
- if (edgeKeysChanged) {
373
- this.pendingMin = 0;
374
- this.itemSizeCacheVersion++;
375
- }
376
- let anchorResolved = false;
377
- let anchorDelta = 0;
378
- if (anchor && this.scrollOffset !== null) {
379
- const [anchorKey, anchorOffset] = anchor;
380
- const newMeasurements = this.getMeasurements();
381
- const { count, getItemKey } = this.options;
382
- let idx = 0;
383
- while (idx < count && getItemKey(idx) !== anchorKey) {
384
- idx++;
385
- }
386
- if (idx < count) {
387
- const anchorItem = newMeasurements[idx];
388
- if (anchorItem) {
389
- const newOffset = anchorItem.start + anchorOffset;
390
- if (newOffset !== this.scrollOffset) {
391
- anchorDelta = newOffset - this.scrollOffset;
392
- this.scrollOffset = newOffset;
393
- anchorResolved = true;
394
- }
395
- }
396
- }
397
- }
398
- if (anchorResolved || followOnAppend) {
399
- this.pendingScrollAnchor = [
400
- anchorResolved ? anchor[0] : null,
401
- anchorResolved ? anchor[1] : 0,
402
- followOnAppend,
403
- anchorDelta
404
- ];
405
- }
406
- };
407
- this.notify = (sync) => {
408
- var _a, _b;
409
- (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
410
- };
411
- this.maybeNotify = memo(
412
- () => {
413
- this.calculateRange();
414
- return [
415
- this.isScrolling,
416
- this.range ? this.range.startIndex : null,
417
- this.range ? this.range.endIndex : null
418
- ];
419
- },
420
- (isScrolling) => {
421
- this.notify(isScrolling);
422
- },
423
- {
424
- key: false,
425
- debug: () => this.options.debug,
426
- initialDeps: [
427
- this.isScrolling,
428
- this.range ? this.range.startIndex : null,
429
- this.range ? this.range.endIndex : null
430
- ]
431
- }
432
- );
433
- this.cleanup = () => {
434
- this.unsubs.filter(Boolean).forEach((d) => d());
435
- this.unsubs = [];
436
- this.observer.disconnect();
437
- if (this.rafId != null && this.targetWindow) {
438
- this.targetWindow.cancelAnimationFrame(this.rafId);
439
- this.rafId = null;
440
- }
441
- this.scrollState = null;
442
- this._iosDeferredAdjustment = 0;
443
- this._iosTouching = false;
444
- this._iosJustTouchEnded = false;
445
- this.scrollElement = null;
446
- this.targetWindow = null;
447
- };
448
- this._didMount = () => {
449
- return () => {
450
- this.cleanup();
451
- };
452
- };
453
- this._willUpdate = () => {
454
- var _a;
455
- const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
456
- if (this.scrollElement !== scrollElement) {
457
- this.cleanup();
458
- if (!scrollElement) {
459
- this.maybeNotify();
460
- return;
461
- }
462
- this.scrollElement = scrollElement;
463
- if (this.scrollElement && "ownerDocument" in this.scrollElement) {
464
- this.targetWindow = this.scrollElement.ownerDocument.defaultView;
465
- } else {
466
- this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
467
- }
468
- this.elementsCache.forEach((cached) => {
469
- this.observer.observe(cached);
470
- });
471
- this.unsubs.push(
472
- this.options.observeElementRect(this, (rect) => {
473
- this.scrollRect = rect;
474
- this.maybeNotify();
475
- })
476
- );
477
- this.unsubs.push(
478
- this.options.observeElementOffset(this, (offset, isScrolling) => {
479
- if (isScrolling && this._intendedScrollOffset === null && offset === this.scrollOffset) {
480
- return;
481
- }
482
- if (this._intendedScrollOffset !== null && Math.abs(offset - this._intendedScrollOffset) < 1.5) {
483
- offset = this._intendedScrollOffset;
484
- }
485
- this._intendedScrollOffset = null;
486
- this.scrollAdjustments = 0;
487
- const prevOffset = this.getScrollOffset();
488
- this.scrollDirection = isScrolling ? prevOffset === offset ? this.scrollDirection : prevOffset < offset ? "forward" : "backward" : null;
489
- this.scrollOffset = offset;
490
- this.isScrolling = isScrolling;
491
- this._flushIosDeferredIfReady();
492
- if (this.scrollState) {
493
- this.scheduleScrollReconcile();
494
- }
495
- this.maybeNotify();
496
- })
497
- );
498
- if ("addEventListener" in this.scrollElement) {
499
- const scrollEl = this.scrollElement;
500
- const onTouchStart = () => {
501
- this._iosTouching = true;
502
- this._iosJustTouchEnded = false;
503
- if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
504
- this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
505
- this._iosTouchEndTimerId = null;
506
- }
507
- };
508
- const onTouchEnd = () => {
509
- this._iosTouching = false;
510
- if (!isIOSWebKit() || this.targetWindow == null) {
511
- return;
512
- }
513
- this._iosJustTouchEnded = true;
514
- this._iosTouchEndTimerId = this.targetWindow.setTimeout(() => {
515
- this._iosJustTouchEnded = false;
516
- this._iosTouchEndTimerId = null;
517
- this._flushIosDeferredIfReady();
518
- }, 150);
519
- };
520
- scrollEl.addEventListener(
521
- "touchstart",
522
- onTouchStart,
523
- addEventListenerOptions
524
- );
525
- scrollEl.addEventListener(
526
- "touchend",
527
- onTouchEnd,
528
- addEventListenerOptions
529
- );
530
- this.unsubs.push(() => {
531
- scrollEl.removeEventListener("touchstart", onTouchStart);
532
- scrollEl.removeEventListener("touchend", onTouchEnd);
533
- if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
534
- this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
535
- this._iosTouchEndTimerId = null;
536
- }
537
- });
538
- }
539
- this._scrollToOffset(this.getScrollOffset(), {
540
- adjustments: void 0,
541
- behavior: void 0
542
- });
543
- }
544
- const anchor = this.pendingScrollAnchor;
545
- this.pendingScrollAnchor = null;
546
- if (anchor && this.scrollElement && this.options.enabled) {
547
- const [key, _offset, followOnAppend, anchorDelta] = anchor;
548
- if (key !== null && !followOnAppend) {
549
- if (isIOSWebKit() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) {
550
- if (anchorDelta !== 0) {
551
- this._iosDeferredAdjustment += anchorDelta;
552
- }
553
- } else {
554
- this._scrollToOffset(this.getScrollOffset(), {
555
- adjustments: void 0,
556
- behavior: void 0
557
- });
558
- }
559
- }
560
- if (followOnAppend) {
561
- this.scrollToEnd({ behavior: followOnAppend });
562
- }
563
- }
564
- };
565
- this._flushIosDeferredIfReady = () => {
566
- if (this._iosDeferredAdjustment === 0) return;
567
- if (this.isScrolling) return;
568
- if (this._iosTouching) return;
569
- if (this._iosJustTouchEnded) return;
570
- const cur = this.getScrollOffset();
571
- const max = this.getMaxScrollOffset();
572
- if (cur < 0 || cur > max) return;
573
- const delta = this._iosDeferredAdjustment;
574
- this._iosDeferredAdjustment = 0;
575
- this._scrollToOffset(cur, {
576
- adjustments: this.scrollAdjustments += delta,
577
- behavior: void 0
578
- });
579
- };
580
- this.rafId = null;
581
- this.getSize = () => {
582
- if (!this.options.enabled) {
583
- this.scrollRect = null;
584
- return 0;
585
- }
586
- this.scrollRect = this.scrollRect ?? this.options.initialRect;
587
- return this.scrollRect[this.options.horizontal ? "width" : "height"];
588
- };
589
- this.getScrollOffset = () => {
590
- if (!this.options.enabled) {
591
- this.scrollOffset = null;
592
- return 0;
593
- }
594
- this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
595
- return this.scrollOffset;
596
- };
597
- this.getMeasurementOptions = memo(
598
- () => [
599
- this.options.count,
600
- this.options.paddingStart,
601
- this.options.scrollMargin,
602
- this.options.getItemKey,
603
- this.options.enabled,
604
- this.options.lanes,
605
- this.options.laneAssignmentMode,
606
- this.options.gap
607
- ],
608
- (count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode, gap) => {
609
- const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
610
- if (lanesChanged) {
611
- this.lanesChangedFlag = true;
612
- }
613
- this.prevLanes = lanes;
614
- this.pendingMin = null;
615
- return {
616
- count,
617
- paddingStart,
618
- scrollMargin,
619
- getItemKey,
620
- enabled,
621
- lanes,
622
- laneAssignmentMode,
623
- gap
624
- };
625
- },
626
- {
627
- key: false
628
- }
629
- );
630
- this.getMeasurements = memo(
631
- () => [this.getMeasurementOptions(), this.itemSizeCacheVersion],
632
- ({
633
- count,
634
- paddingStart,
635
- scrollMargin,
636
- getItemKey,
637
- enabled,
638
- lanes,
639
- laneAssignmentMode,
640
- gap
641
- }, _itemSizeCacheVersion) => {
642
- const itemSizeCache = this.itemSizeCache;
643
- if (!enabled) {
644
- this.measurementsCache = [];
645
- this.itemSizeCache.clear();
646
- this.laneAssignments.clear();
647
- return [];
648
- }
649
- if (this.laneAssignments.size > count) {
650
- for (const index of this.laneAssignments.keys()) {
651
- if (index >= count) {
652
- this.laneAssignments.delete(index);
653
- }
654
- }
655
- }
656
- if (this.lanesChangedFlag) {
657
- this.lanesChangedFlag = false;
658
- this.lanesSettling = true;
659
- this.measurementsCache = [];
660
- this.itemSizeCache.clear();
661
- this.laneAssignments.clear();
662
- this.pendingMin = null;
663
- }
664
- if (this.measurementsCache.length === 0 && !this.lanesSettling) {
665
- this.measurementsCache = this.options.initialMeasurementsCache;
666
- this.measurementsCache.forEach((item) => {
667
- this.itemSizeCache.set(item.key, item.size);
668
- });
669
- }
670
- const min = this.lanesSettling ? 0 : this.pendingMin ?? 0;
671
- this.pendingMin = null;
672
- if (this.lanesSettling && this.measurementsCache.length === count) {
673
- this.lanesSettling = false;
674
- }
675
- if (lanes === 1) {
676
- const need = count * 2;
677
- let flat = this._flatMeasurements;
678
- if (!flat || flat.length < need) {
679
- const next = new Float64Array(need);
680
- if (flat && min > 0) next.set(flat.subarray(0, min * 2));
681
- flat = next;
682
- this._flatMeasurements = flat;
683
- }
684
- let runningStart;
685
- if (min === 0) {
686
- runningStart = paddingStart + scrollMargin;
687
- } else {
688
- const prevIdx = min - 1;
689
- runningStart = flat[prevIdx * 2] + flat[prevIdx * 2 + 1] + gap;
690
- }
691
- for (let i = min; i < count; i++) {
692
- const key = getItemKey(i);
693
- const measuredSize = itemSizeCache.get(key);
694
- const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
695
- flat[i * 2] = runningStart;
696
- flat[i * 2 + 1] = size;
697
- runningStart += size + gap;
698
- }
699
- const view = createLazyMeasurementsView(count, flat, getItemKey);
700
- this.measurementsCache = view;
701
- return view;
702
- }
703
- const measurements = this.measurementsCache.slice(0, min);
704
- const laneLastIndex = new Array(lanes).fill(
705
- void 0
706
- );
707
- const laneEnds = new Float64Array(lanes);
708
- let filledLanes = 0;
709
- for (let m = 0; m < min; m++) {
710
- const item = measurements[m];
711
- if (item) {
712
- if (laneLastIndex[item.lane] === void 0) filledLanes++;
713
- laneLastIndex[item.lane] = m;
714
- laneEnds[item.lane] = item.end;
715
- }
716
- }
717
- for (let i = min; i < count; i++) {
718
- const key = getItemKey(i);
719
- const cachedLane = this.laneAssignments.get(i);
720
- let lane;
721
- let start;
722
- const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
723
- if (cachedLane !== void 0 && this.options.lanes > 1) {
724
- lane = cachedLane;
725
- const prevIndex = laneLastIndex[lane];
726
- const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
727
- start = prevInLane ? prevInLane.end + gap : paddingStart + scrollMargin;
728
- } else if (filledLanes === lanes) {
729
- let bestLane = 0;
730
- let bestEnd = laneEnds[0];
731
- let bestIdx = laneLastIndex[0];
732
- for (let l = 1; l < lanes; l++) {
733
- const e = laneEnds[l];
734
- if (e < bestEnd || e === bestEnd && laneLastIndex[l] < bestIdx) {
735
- bestLane = l;
736
- bestEnd = e;
737
- bestIdx = laneLastIndex[l];
738
- }
739
- }
740
- lane = bestLane;
741
- start = bestEnd + gap;
742
- if (shouldCacheLane) {
743
- this.laneAssignments.set(i, lane);
744
- }
745
- } else {
746
- lane = i % this.options.lanes;
747
- start = paddingStart + scrollMargin;
748
- if (shouldCacheLane) {
749
- this.laneAssignments.set(i, lane);
750
- }
751
- }
752
- const measuredSize = itemSizeCache.get(key);
753
- const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
754
- const end = start + size;
755
- measurements[i] = {
756
- index: i,
757
- start,
758
- size,
759
- end,
760
- key,
761
- lane
762
- };
763
- if (laneLastIndex[lane] === void 0) filledLanes++;
764
- laneLastIndex[lane] = i;
765
- laneEnds[lane] = end;
766
- }
767
- this.measurementsCache = measurements;
768
- return measurements;
769
- },
770
- {
771
- key: false,
772
- debug: () => this.options.debug
773
- }
774
- );
775
- this.calculateRange = memo(
776
- () => [
777
- this.getMeasurements(),
778
- this.getSize(),
779
- this.getScrollOffset(),
780
- this.options.lanes
781
- ],
782
- (measurements, outerSize, scrollOffset, lanes) => {
783
- if (measurements.length === 0 || outerSize === 0) {
784
- this.range = null;
785
- return null;
786
- }
787
- this.range = calculateRangeImpl(
788
- measurements,
789
- outerSize,
790
- scrollOffset,
791
- lanes,
792
- // Pass the typed array so binary search + forward-walk can read
793
- // start/end directly from Float64Array, skipping the Proxy traps.
794
- lanes === 1 && this._flatMeasurements != null ? this._flatMeasurements : null
795
- );
796
- return this.range;
797
- },
798
- {
799
- key: false,
800
- debug: () => this.options.debug
801
- }
802
- );
803
- this.getVirtualIndexes = memo(
804
- () => {
805
- let startIndex = null;
806
- let endIndex = null;
807
- const range = this.calculateRange();
808
- if (range) {
809
- startIndex = range.startIndex;
810
- endIndex = range.endIndex;
811
- }
812
- this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]);
813
- return [
814
- this.options.rangeExtractor,
815
- this.options.overscan,
816
- this.options.count,
817
- startIndex,
818
- endIndex
819
- ];
820
- },
821
- (rangeExtractor, overscan, count, startIndex, endIndex) => {
822
- return startIndex === null || endIndex === null ? [] : rangeExtractor({
823
- startIndex,
824
- endIndex,
825
- overscan,
826
- count
827
- });
828
- },
829
- {
830
- key: false,
831
- debug: () => this.options.debug
832
- }
833
- );
834
- this.indexFromElement = (node) => {
835
- const attributeName = this.options.indexAttribute;
836
- const indexStr = node.getAttribute(attributeName);
837
- if (!indexStr) {
838
- console.warn(
839
- `Missing attribute name '${attributeName}={index}' on measured element.`
840
- );
841
- return -1;
842
- }
843
- return parseInt(indexStr, 10);
844
- };
845
- this.shouldMeasureDuringScroll = (index) => {
846
- var _a;
847
- if (!this.scrollState || this.scrollState.behavior !== "smooth") {
848
- return true;
849
- }
850
- const scrollIndex = this.scrollState.index ?? ((_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index);
851
- if (scrollIndex !== void 0 && this.range) {
852
- const bufferSize = Math.max(
853
- this.options.overscan,
854
- Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
855
- );
856
- const minIndex = Math.max(0, scrollIndex - bufferSize);
857
- const maxIndex = Math.min(
858
- this.options.count - 1,
859
- scrollIndex + bufferSize
860
- );
861
- return index >= minIndex && index <= maxIndex;
862
- }
863
- return true;
864
- };
865
- this.measureElement = (node) => {
866
- if (!node) {
867
- this.elementsCache.forEach((cached, key2) => {
868
- if (!cached.isConnected) {
869
- this.observer.unobserve(cached);
870
- this.elementsCache.delete(key2);
871
- }
872
- });
873
- return;
874
- }
875
- const index = this.indexFromElement(node);
876
- const key = this.options.getItemKey(index);
877
- const prevNode = this.elementsCache.get(key);
878
- if (prevNode !== node) {
879
- if (prevNode) {
880
- this.observer.unobserve(prevNode);
881
- }
882
- this.observer.observe(node);
883
- this.elementsCache.set(key, node);
884
- }
885
- if ((!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) {
886
- this.resizeItem(index, this.options.measureElement(node, void 0, this));
887
- }
888
- };
889
- this.resizeItem = (index, size) => {
890
- var _a, _b;
891
- if (index < 0 || index >= this.options.count) return;
892
- let cachedSize;
893
- let itemStart;
894
- let key;
895
- const flat = this._flatMeasurements;
896
- if (this.options.lanes === 1 && flat !== null) {
897
- key = this.options.getItemKey(index);
898
- itemStart = flat[index * 2];
899
- cachedSize = flat[index * 2 + 1];
900
- } else {
901
- const item = this.measurementsCache[index];
902
- if (!item) return;
903
- key = item.key;
904
- itemStart = item.start;
905
- cachedSize = item.size;
906
- }
907
- const itemSize = this.itemSizeCache.get(key) ?? cachedSize;
908
- const delta = size - itemSize;
909
- if (delta !== 0) {
910
- const wasAtEnd = this.options.anchorTo === "end" && ((_a = this.scrollState) == null ? void 0 : _a.behavior) !== "smooth" && this.getVirtualDistanceFromEnd() <= this.options.scrollEndThreshold;
911
- const prevTotalSize = wasAtEnd ? this.getTotalSize() : 0;
912
- const shouldAdjustScroll = ((_b = this.scrollState) == null ? void 0 : _b.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(
913
- // The callback expects a VirtualItem; build one lazily only
914
- // when the consumer actually supplied a custom predicate.
915
- this.measurementsCache[index] ?? {
916
- index,
917
- key,
918
- start: itemStart,
919
- size: cachedSize,
920
- end: itemStart + cachedSize,
921
- lane: 0
922
- },
923
- delta,
924
- this
925
- ) : (
926
- // Default: adjust when the resize is an above-viewport item.
927
- // First measurement (!has(key)): always adjust — the item
928
- // has never been sized, so the estimate→actual delta must
929
- // be compensated regardless of scroll direction.
930
- // Re-measurement (has(key)): skip during backward scroll
931
- // to avoid the "items jump while scrolling up" cascade.
932
- itemStart < this.getScrollOffset() + this.scrollAdjustments && (!this.itemSizeCache.has(key) || this.scrollDirection !== "backward")
933
- ));
934
- if (this.pendingMin === null || index < this.pendingMin) {
935
- this.pendingMin = index;
936
- }
937
- this.itemSizeCache.set(key, size);
938
- this.itemSizeCacheVersion++;
939
- if (wasAtEnd) {
940
- this.applyScrollAdjustment(this.getTotalSize() - prevTotalSize);
941
- } else if (shouldAdjustScroll) {
942
- this.applyScrollAdjustment(delta);
943
- }
944
- this.notify(false);
945
- }
946
- };
947
- this.getVirtualItems = memo(
948
- () => [this.getVirtualIndexes(), this.getMeasurements()],
949
- (indexes, measurements) => {
950
- const virtualItems = [];
951
- for (let k = 0, len = indexes.length; k < len; k++) {
952
- const i = indexes[k];
953
- const measurement = measurements[i];
954
- virtualItems.push(measurement);
955
- }
956
- return virtualItems;
957
- },
958
- {
959
- key: false,
960
- debug: () => this.options.debug
961
- }
962
- );
963
- this.getVirtualItemForOffset = (offset) => {
964
- const measurements = this.getMeasurements();
965
- if (measurements.length === 0) {
966
- return void 0;
967
- }
968
- const flat = this._flatMeasurements;
969
- const useFlat = this.options.lanes === 1 && flat != null;
970
- const idx = findNearestBinarySearch(
971
- 0,
972
- measurements.length - 1,
973
- useFlat ? (i) => flat[i * 2] : (i) => notUndefined(measurements[i]).start,
974
- offset
975
- );
976
- return notUndefined(measurements[idx]);
977
- };
978
- this.getMaxScrollOffset = () => {
979
- if (!this.scrollElement) return 0;
980
- if ("scrollHeight" in this.scrollElement) {
981
- return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
982
- } else {
983
- const doc = this.scrollElement.document.documentElement;
984
- return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
985
- }
986
- };
987
- this.getVirtualDistanceFromEnd = () => {
988
- return Math.max(
989
- this.getTotalSize() - this.getSize() - this.getScrollOffset(),
990
- 0
991
- );
992
- };
993
- this.getDistanceFromEnd = () => {
994
- return Math.max(this.getMaxScrollOffset() - this.getScrollOffset(), 0);
995
- };
996
- this.isAtEnd = (threshold = this.options.scrollEndThreshold) => {
997
- return this.getDistanceFromEnd() <= threshold;
998
- };
999
- this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
1000
- if (!this.scrollElement) return 0;
1001
- const size = this.getSize();
1002
- const scrollOffset = this.getScrollOffset();
1003
- if (align === "auto") {
1004
- align = toOffset >= scrollOffset + size ? "end" : "start";
1005
- }
1006
- if (align === "center") {
1007
- toOffset += (itemSize - size) / 2;
1008
- } else if (align === "end") {
1009
- toOffset -= size;
1010
- }
1011
- const maxOffset = this.getMaxScrollOffset();
1012
- return Math.max(Math.min(maxOffset, toOffset), 0);
1013
- };
1014
- this.getOffsetForIndex = (index, align = "auto") => {
1015
- index = Math.max(0, Math.min(index, this.options.count - 1));
1016
- const size = this.getSize();
1017
- const scrollOffset = this.getScrollOffset();
1018
- const item = this.measurementsCache[index];
1019
- if (!item) return;
1020
- if (align === "auto") {
1021
- if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {
1022
- align = "end";
1023
- } else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
1024
- align = "start";
1025
- } else {
1026
- return [scrollOffset, align];
1027
- }
1028
- }
1029
- if (align === "end" && index === this.options.count - 1) {
1030
- return [this.getMaxScrollOffset(), align];
1031
- }
1032
- const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
1033
- return [
1034
- this.getOffsetForAlignment(toOffset, align, item.size),
1035
- align
1036
- ];
1037
- };
1038
- this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
1039
- const offset = this.getOffsetForAlignment(toOffset, align);
1040
- const now = this.now();
1041
- this.scrollState = {
1042
- index: null,
1043
- align,
1044
- behavior,
1045
- startedAt: now,
1046
- lastTargetOffset: offset,
1047
- stableFrames: 0
1048
- };
1049
- this._scrollToOffset(offset, { adjustments: void 0, behavior });
1050
- this.scheduleScrollReconcile();
1051
- };
1052
- this.scrollToIndex = (index, {
1053
- align: initialAlign = "auto",
1054
- behavior = "auto"
1055
- } = {}) => {
1056
- index = Math.max(0, Math.min(index, this.options.count - 1));
1057
- const offsetInfo = this.getOffsetForIndex(index, initialAlign);
1058
- if (!offsetInfo) {
1059
- return;
1060
- }
1061
- const [offset, align] = offsetInfo;
1062
- const now = this.now();
1063
- this.scrollState = {
1064
- index,
1065
- align,
1066
- behavior,
1067
- startedAt: now,
1068
- lastTargetOffset: offset,
1069
- stableFrames: 0
1070
- };
1071
- this._scrollToOffset(offset, { adjustments: void 0, behavior });
1072
- this.scheduleScrollReconcile();
1073
- };
1074
- this.scrollBy = (delta, { behavior = "auto" } = {}) => {
1075
- const offset = this.getScrollOffset() + delta;
1076
- const now = this.now();
1077
- this.scrollState = {
1078
- index: null,
1079
- align: "start",
1080
- behavior,
1081
- startedAt: now,
1082
- lastTargetOffset: offset,
1083
- stableFrames: 0
1084
- };
1085
- this._scrollToOffset(offset, { adjustments: void 0, behavior });
1086
- this.scheduleScrollReconcile();
1087
- };
1088
- this.scrollToEnd = ({ behavior = "auto" } = {}) => {
1089
- if (this.options.count > 0) {
1090
- this.scrollToIndex(this.options.count - 1, {
1091
- align: "end",
1092
- behavior
1093
- });
1094
- return;
1095
- }
1096
- this.scrollToOffset(Math.max(this.getTotalSize() - this.getSize(), 0), {
1097
- behavior
1098
- });
1099
- };
1100
- this.getTotalSize = () => {
1101
- var _a;
1102
- const measurements = this.getMeasurements();
1103
- let end;
1104
- if (measurements.length === 0) {
1105
- end = this.options.paddingStart;
1106
- } else if (this.options.lanes === 1) {
1107
- const lastIdx = measurements.length - 1;
1108
- const flat = this._flatMeasurements;
1109
- if (flat != null) {
1110
- end = flat[lastIdx * 2] + flat[lastIdx * 2 + 1];
1111
- } else {
1112
- end = ((_a = measurements[lastIdx]) == null ? void 0 : _a.end) ?? 0;
1113
- }
1114
- } else {
1115
- const endByLane = Array(this.options.lanes).fill(null);
1116
- let endIndex = measurements.length - 1;
1117
- while (endIndex >= 0 && endByLane.some((val) => val === null)) {
1118
- const item = measurements[endIndex];
1119
- if (endByLane[item.lane] === null) {
1120
- endByLane[item.lane] = item.end;
1121
- }
1122
- endIndex--;
1123
- }
1124
- end = Math.max(...endByLane.filter((val) => val !== null));
1125
- }
1126
- return Math.max(
1127
- end - this.options.scrollMargin + this.options.paddingEnd,
1128
- 0
1129
- );
1130
- };
1131
- this.takeSnapshot = () => {
1132
- const snapshot = [];
1133
- if (this.itemSizeCache.size === 0) return snapshot;
1134
- const m = this.getMeasurements();
1135
- for (const item of m) {
1136
- if (item && this.itemSizeCache.has(item.key)) {
1137
- snapshot.push({
1138
- index: item.index,
1139
- key: item.key,
1140
- start: item.start,
1141
- size: item.size,
1142
- end: item.end,
1143
- lane: item.lane
1144
- });
1145
- }
1146
- }
1147
- return snapshot;
1148
- };
1149
- this._scrollToOffset = (offset, {
1150
- adjustments,
1151
- behavior
1152
- }) => {
1153
- this._intendedScrollOffset = offset + (adjustments ?? 0);
1154
- this.options.scrollToFn(offset, { behavior, adjustments }, this);
1155
- };
1156
- this.measure = () => {
1157
- this.pendingMin = null;
1158
- this.itemSizeCache.clear();
1159
- this.laneAssignments.clear();
1160
- this.itemSizeCacheVersion++;
1161
- this.notify(false);
1162
- };
1163
- this.setOptions(opts);
1164
- }
1165
- applyScrollAdjustment(delta, behavior) {
1166
- if (delta === 0) return;
1167
- if (isIOSWebKit() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) {
1168
- this._iosDeferredAdjustment += delta;
1169
- } else {
1170
- this._scrollToOffset(this.getScrollOffset(), {
1171
- adjustments: this.scrollAdjustments += delta,
1172
- behavior
1173
- });
1174
- if (this.scrollOffset !== null) {
1175
- this.scrollOffset += this.scrollAdjustments;
1176
- this.scrollAdjustments = 0;
1177
- }
1178
- }
1179
- }
1180
- scheduleScrollReconcile() {
1181
- if (!this.targetWindow) {
1182
- this.scrollState = null;
1183
- return;
1184
- }
1185
- if (this.rafId != null) return;
1186
- this.rafId = this.targetWindow.requestAnimationFrame(() => {
1187
- this.rafId = null;
1188
- this.reconcileScroll();
1189
- });
1190
- }
1191
- reconcileScroll() {
1192
- if (!this.scrollState) return;
1193
- const el = this.scrollElement;
1194
- if (!el) return;
1195
- const MAX_RECONCILE_MS = 5e3;
1196
- if (this.now() - this.scrollState.startedAt > MAX_RECONCILE_MS) {
1197
- this.scrollState = null;
1198
- return;
1199
- }
1200
- const offsetInfo = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0;
1201
- const targetOffset = offsetInfo ? offsetInfo[0] : this.scrollState.lastTargetOffset;
1202
- const STABLE_FRAMES = 1;
1203
- const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
1204
- if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
1205
- this.scrollState.stableFrames++;
1206
- if (this.scrollState.stableFrames >= STABLE_FRAMES) {
1207
- if (this.getScrollOffset() !== targetOffset) {
1208
- this._scrollToOffset(targetOffset, {
1209
- adjustments: void 0,
1210
- behavior: "auto"
1211
- });
1212
- }
1213
- this.scrollState = null;
1214
- return;
1215
- }
1216
- } else {
1217
- this.scrollState.stableFrames = 0;
1218
- if (targetChanged) {
1219
- const viewport = this.getSize() || 600;
1220
- const distance = Math.abs(targetOffset - this.getScrollOffset());
1221
- const keepSmooth = this.scrollState.behavior === "smooth" && distance > viewport;
1222
- this.scrollState.lastTargetOffset = targetOffset;
1223
- if (!keepSmooth) {
1224
- this.scrollState.behavior = "auto";
1225
- }
1226
- this._scrollToOffset(targetOffset, {
1227
- adjustments: void 0,
1228
- behavior: keepSmooth ? "smooth" : "auto"
1229
- });
1230
- }
1231
- }
1232
- this.scheduleScrollReconcile();
1233
- }
1234
- }
1235
- const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
1236
- while (low <= high) {
1237
- const middle = (low + high) / 2 | 0;
1238
- const currentValue = getCurrentValue(middle);
1239
- if (currentValue < value) {
1240
- low = middle + 1;
1241
- } else if (currentValue > value) {
1242
- high = middle - 1;
1243
- } else {
1244
- return middle;
1245
- }
1246
- }
1247
- if (low > 0) {
1248
- return low - 1;
1249
- } else {
1250
- return 0;
1251
- }
1252
- };
1253
- function findNearestBinarySearchFlat(flat, high, value) {
1254
- let low = 0;
1255
- while (low <= high) {
1256
- const middle = (low + high) / 2 | 0;
1257
- const currentValue = flat[middle * 2];
1258
- if (currentValue < value) {
1259
- low = middle + 1;
1260
- } else if (currentValue > value) {
1261
- high = middle - 1;
1262
- } else {
1263
- return middle;
1264
- }
1265
- }
1266
- return low > 0 ? low - 1 : 0;
1267
- }
1268
- function calculateRangeImpl(measurements, outerSize, scrollOffset, lanes, flat) {
1269
- const lastIndex = measurements.length - 1;
1270
- if (measurements.length <= lanes) {
1271
- return { startIndex: 0, endIndex: lastIndex };
1272
- }
1273
- if (lanes === 1 && flat !== null) {
1274
- const startIndex2 = findNearestBinarySearchFlat(
1275
- flat,
1276
- lastIndex,
1277
- scrollOffset
1278
- );
1279
- let endIndex2 = startIndex2;
1280
- const limit = scrollOffset + outerSize;
1281
- while (endIndex2 < lastIndex && flat[endIndex2 * 2] + flat[endIndex2 * 2 + 1] < limit) {
1282
- endIndex2++;
1283
- }
1284
- return { startIndex: startIndex2, endIndex: endIndex2 };
1285
- }
1286
- const getStart = (index) => measurements[index].start;
1287
- let startIndex = findNearestBinarySearch(0, lastIndex, getStart, scrollOffset);
1288
- let endIndex = startIndex;
1289
- if (lanes === 1) {
1290
- while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) {
1291
- endIndex++;
1292
- }
1293
- } else if (lanes > 1) {
1294
- const endPerLane = Array(lanes).fill(0);
1295
- while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
1296
- const item = measurements[endIndex];
1297
- endPerLane[item.lane] = item.end;
1298
- endIndex++;
1299
- }
1300
- const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
1301
- while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
1302
- const item = measurements[startIndex];
1303
- startPerLane[item.lane] = item.start;
1304
- startIndex--;
1305
- }
1306
- startIndex = Math.max(0, startIndex - startIndex % lanes);
1307
- endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
1308
- }
1309
- return { startIndex, endIndex };
1310
- }
1311
- export {
1312
- Virtualizer as V,
1313
- observeElementRect as a,
1314
- observeWindowOffset as b,
1315
- observeWindowRect as c,
1316
- elementScroll as e,
1317
- observeElementOffset as o,
1318
- windowScroll as w
1319
- };