@delali/narsil 0.3.1-next.157 → 0.3.1-next.161

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 (565) hide show
  1. package/dist/adapters/filesystem.mjs +3 -3
  2. package/dist/adapters/gcs.mjs +3 -3
  3. package/dist/adapters/indexeddb.mjs +1 -1
  4. package/dist/adapters/s3.mjs +3 -3
  5. package/dist/browser/{chunk-N23GL72Q.mjs → chunk-4RNSFVWI.mjs} +20777 -19056
  6. package/dist/browser/chunk-MMHIIL5B.mjs +564 -0
  7. package/dist/browser/chunk-MZHQ65VI.mjs +1228 -0
  8. package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
  9. package/dist/browser/{chunk-VLJQW4J6.mjs → core-leaf-TJAGWPZZ.mjs} +4674 -3102
  10. package/dist/{react-native/chunks/durability-config-QXVZEO7T.mjs → browser/durability-config-SGB5ZP5K.mjs} +8 -3
  11. package/dist/browser/embed-RF2MPGAO.mjs +222 -0
  12. package/dist/{react-native/chunks/geo-index-PX3BIHAH.mjs → browser/geo-index-GNHY4PUB.mjs} +190 -93
  13. package/dist/{react-native/chunks/module-TTEVPRCW.mjs → browser/module-362VSIGR.mjs} +1570 -275
  14. package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
  15. package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
  16. package/dist/browser/optional-writes-WMZX4OEC.mjs +3196 -0
  17. package/dist/browser/phrase-module-22TKMXWI.mjs +616 -0
  18. package/dist/browser/resolve-vector-text-KI65IHMD.mjs +60 -0
  19. package/dist/browser/{restore-hooks-IE3GGYHG.mjs → restore-queue-S4BWOGMU.mjs} +98 -24
  20. package/dist/{react-native/chunks/runtime-R5E3TB3J.mjs → browser/runtime-NU6VOVH2.mjs} +61 -25
  21. package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
  22. package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
  23. package/dist/browser/storage-leaf-X6CNRHJS.mjs +18221 -0
  24. package/dist/browser/store-leaf-AEMTAVHX.mjs +2069 -0
  25. package/dist/browser/{chunk-GFAZPSWK.mjs → suggestions-leaf-3Y6MR6OF.mjs} +441 -119
  26. package/dist/browser/worker-copies-WQCPP3TS.mjs +2750 -0
  27. package/dist/{capabilities-D3AoBJoF.d.ts → capabilities-BKDrry0z.d.ts} +2 -2
  28. package/dist/chunk-2JRERUNZ.mjs +217 -0
  29. package/dist/chunk-2RIS76RJ.mjs +212 -0
  30. package/dist/chunk-3B775F3C.mjs +252 -0
  31. package/dist/{chunk-24FNVRKB.mjs → chunk-3D6RZGJH.mjs} +3 -3
  32. package/dist/{chunk-INJYO3BU.mjs → chunk-4CAMH7FO.mjs} +1 -1
  33. package/dist/{chunk-U476IXKQ.mjs → chunk-4PY4JYMY.mjs} +2 -1
  34. package/dist/chunk-6EZW2GQL.mjs +978 -0
  35. package/dist/chunk-75UNINFA.mjs +271 -0
  36. package/dist/chunk-77AUVDQ5.mjs +7 -0
  37. package/dist/{chunk-JTYPJF3T.mjs → chunk-7MWYORQC.mjs} +2 -2
  38. package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
  39. package/dist/{chunk-XIHUI4KB.mjs → chunk-AB27FWZM.mjs} +8 -3
  40. package/dist/{chunk-FUD5XSZ5.mjs → chunk-BXM7XM4G.mjs} +7 -3
  41. package/dist/{chunk-HJJI72X7.mjs → chunk-C7YQHCSO.mjs} +1 -1
  42. package/dist/{chunk-RVGRFOGN.mjs → chunk-D456ZFPQ.mjs} +2 -1
  43. package/dist/{chunk-KKQC526K.mjs → chunk-E2F6LZR3.mjs} +19 -21
  44. package/dist/{chunk-SMOOSIAW.mjs → chunk-FE3MRIBN.mjs} +104 -13
  45. package/dist/{chunk-KYYABCSW.mjs → chunk-FETZYCH7.mjs} +15 -1
  46. package/dist/{chunk-XXJZMTZT.mjs → chunk-FVZ5DB6Y.mjs} +3 -2
  47. package/dist/{chunk-EYD7K3H6.mjs → chunk-GF4K7IUK.mjs} +317 -120
  48. package/dist/chunk-GXCDWLQI.mjs +193 -0
  49. package/dist/{chunk-IIRIG7H5.mjs → chunk-H64YDF5M.mjs} +3 -3
  50. package/dist/{browser/chunk-VY5KW3HN.mjs → chunk-HOOR4CP5.mjs} +63 -7
  51. package/dist/chunk-IB4BYLE3.mjs +127 -0
  52. package/dist/{chunk-3C7MTCCI.mjs → chunk-IE3Q62QD.mjs} +2 -2
  53. package/dist/chunk-IH3G6SJO.mjs +40 -0
  54. package/dist/chunk-JV74RKCY.mjs +3041 -0
  55. package/dist/{chunk-ZPZ3YGXV.mjs → chunk-K67I3RF4.mjs} +261 -101
  56. package/dist/chunk-KLVMK3R5.mjs +47 -0
  57. package/dist/{chunk-5VV4R6P7.mjs → chunk-LAWIJRMJ.mjs} +4154 -2577
  58. package/dist/chunk-LF4GB4PO.mjs +281 -0
  59. package/dist/chunk-NC4QLCZC.mjs +59 -0
  60. package/dist/chunk-OOO54OVC.mjs +627 -0
  61. package/dist/chunk-OUWZKNO3.mjs +207 -0
  62. package/dist/{chunk-FJKKCV4D.mjs → chunk-P5YLI5ED.mjs} +343 -182
  63. package/dist/{chunk-4ZTHGTVX.mjs → chunk-PTTMGRG5.mjs} +9 -10
  64. package/dist/{react-native/chunks/chunk-DZ7H7D2C.mjs → chunk-Q3ZZH5Z7.mjs} +6 -0
  65. package/dist/{browser/chunk-EKMGCRSR.mjs → chunk-QBVTYY4J.mjs} +2 -9
  66. package/dist/{chunk-W5EB5XKI.mjs → chunk-R4CE4IVU.mjs} +341 -183
  67. package/dist/chunk-S2POFTLN.mjs +10 -0
  68. package/dist/{chunk-KJ3RTZDJ.mjs → chunk-S3BSDBF7.mjs} +10 -3
  69. package/dist/{chunk-4LMSZAK6.mjs → chunk-SHGN3QIF.mjs} +69 -13
  70. package/dist/chunk-SXIRM4MX.mjs +3549 -0
  71. package/dist/{chunk-TBC3XUL2.mjs → chunk-TGPKS2UM.mjs} +47 -1
  72. package/dist/chunk-TINW4BSH.mjs +31301 -0
  73. package/dist/{cold-module-VOJXMNZB.mjs → chunk-TSLV5P2J.mjs} +397 -80
  74. package/dist/{chunk-HHBUCIUY.mjs → chunk-TW543F33.mjs} +3 -3
  75. package/dist/chunk-U6B7DUQW.mjs +788 -0
  76. package/dist/{chunk-OQLD2BSW.mjs → chunk-V3SGPXWQ.mjs} +8 -9
  77. package/dist/chunk-W34VJXY7.mjs +4723 -0
  78. package/dist/chunk-YETKPX5M.mjs +5 -0
  79. package/dist/chunk-ZQ6QY42L.mjs +59 -0
  80. package/dist/{client-kqSMevVi.d.ts → client-CTp8RRiK.d.ts} +4 -4
  81. package/dist/client.d.ts +8 -8
  82. package/dist/client.mjs +66 -18
  83. package/dist/{config-B4v_Htpu.d.ts → config-PCNzWjHL.d.ts} +6 -3
  84. package/dist/{config-CTP01fns.d.ts → config-_WT5grSL.d.ts} +3 -3
  85. package/dist/core-leaf-KXFGP74A.mjs +7 -0
  86. package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
  87. package/dist/direct-executor-MKTZBR26.mjs +16 -0
  88. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  89. package/dist/distribution/coordinator/etcd.mjs +7 -4
  90. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  91. package/dist/distribution/coordinator/in-memory.mjs +1 -2
  92. package/dist/distribution/transport/grpc.mjs +7 -2
  93. package/dist/distribution/transport/tcp.mjs +7 -1
  94. package/dist/distribution.d.ts +7 -7
  95. package/dist/distribution.mjs +1199 -1092
  96. package/dist/{browser/durability-config-TIYKW6XX.mjs → durability-config-XV4XR7Y4.mjs} +7 -3
  97. package/dist/embed-4H7RTBVL.mjs +221 -0
  98. package/dist/embeddings/openai.mjs +2 -2
  99. package/dist/{engine-CkPn2PWE.d.ts → engine-DBRVR_d-.d.ts} +1252 -1239
  100. package/dist/{browser/geo-index-OTV7VPIR.mjs → geo-index-2ZMMWWSK.mjs} +190 -93
  101. package/dist/{index-C4AmUnl1.d.ts → index-Ck9w5WHz.d.ts} +1 -1
  102. package/dist/index.browser.mjs +4 -16
  103. package/dist/index.d.ts +1495 -78
  104. package/dist/index.mjs +14 -50
  105. package/dist/index.react-native.mjs +11 -28
  106. package/dist/invalidation/filesystem.mjs +1 -2
  107. package/dist/languages/albanian.mjs +1 -1
  108. package/dist/languages/amharic.mjs +1 -1
  109. package/dist/languages/arabic.mjs +1 -1
  110. package/dist/languages/armenian.mjs +1 -1
  111. package/dist/languages/azerbaijani.mjs +1 -1
  112. package/dist/languages/bambara.mjs +1 -1
  113. package/dist/languages/basque.mjs +1 -1
  114. package/dist/languages/belarusian.mjs +1 -1
  115. package/dist/languages/bengali.mjs +1 -1
  116. package/dist/languages/bosnian.mjs +1 -1
  117. package/dist/languages/breton.mjs +1 -1
  118. package/dist/languages/bulgarian.mjs +1 -1
  119. package/dist/languages/burmese.mjs +1 -1
  120. package/dist/languages/catalan.mjs +1 -1
  121. package/dist/languages/chinese.mjs +1 -1
  122. package/dist/languages/croatian.mjs +1 -1
  123. package/dist/languages/czech.mjs +1 -1
  124. package/dist/languages/dagbani.mjs +1 -1
  125. package/dist/languages/danish.mjs +1 -1
  126. package/dist/languages/dutch.mjs +1 -1
  127. package/dist/languages/english.mjs +1 -1
  128. package/dist/languages/esperanto.mjs +1 -1
  129. package/dist/languages/estonian.mjs +1 -1
  130. package/dist/languages/ewe.mjs +1 -1
  131. package/dist/languages/faroese.mjs +1 -1
  132. package/dist/languages/fijian.mjs +1 -1
  133. package/dist/languages/finnish.mjs +1 -1
  134. package/dist/languages/french.mjs +1 -1
  135. package/dist/languages/ga.mjs +1 -1
  136. package/dist/languages/galician.mjs +1 -1
  137. package/dist/languages/georgian.mjs +1 -1
  138. package/dist/languages/german.mjs +1 -1
  139. package/dist/languages/greek.mjs +1 -1
  140. package/dist/languages/guarani.mjs +1 -1
  141. package/dist/languages/gujarati.mjs +1 -1
  142. package/dist/languages/haitian-creole.mjs +1 -1
  143. package/dist/languages/hausa.mjs +1 -1
  144. package/dist/languages/hawaiian.mjs +1 -1
  145. package/dist/languages/hebrew.mjs +1 -1
  146. package/dist/languages/hindi.mjs +1 -1
  147. package/dist/languages/hungarian.mjs +1 -1
  148. package/dist/languages/icelandic.mjs +1 -1
  149. package/dist/languages/igbo.mjs +1 -1
  150. package/dist/languages/indonesian.mjs +1 -1
  151. package/dist/languages/irish.mjs +1 -1
  152. package/dist/languages/italian.mjs +1 -1
  153. package/dist/languages/japanese.mjs +1 -1
  154. package/dist/languages/kannada.mjs +1 -1
  155. package/dist/languages/kazakh.mjs +1 -1
  156. package/dist/languages/khmer.mjs +1 -1
  157. package/dist/languages/kinyarwanda.mjs +1 -1
  158. package/dist/languages/kirundi.mjs +1 -1
  159. package/dist/languages/korean.mjs +1 -1
  160. package/dist/languages/kurmanji.mjs +1 -1
  161. package/dist/languages/kyrgyz.mjs +1 -1
  162. package/dist/languages/lao.mjs +1 -1
  163. package/dist/languages/latin.mjs +1 -1
  164. package/dist/languages/latvian.mjs +1 -1
  165. package/dist/languages/lingala.mjs +1 -1
  166. package/dist/languages/lithuanian.mjs +1 -1
  167. package/dist/languages/luxembourgish.mjs +1 -1
  168. package/dist/languages/macedonian.mjs +1 -1
  169. package/dist/languages/malagasy.mjs +1 -1
  170. package/dist/languages/malay.mjs +1 -1
  171. package/dist/languages/malayalam.mjs +1 -1
  172. package/dist/languages/maltese.mjs +1 -1
  173. package/dist/languages/maori.mjs +1 -1
  174. package/dist/languages/marathi.mjs +1 -1
  175. package/dist/languages/nepali.mjs +1 -1
  176. package/dist/languages/norwegian.mjs +1 -1
  177. package/dist/languages/oromo.mjs +1 -1
  178. package/dist/languages/persian.mjs +1 -1
  179. package/dist/languages/polish.mjs +1 -1
  180. package/dist/languages/portuguese.mjs +1 -1
  181. package/dist/languages/punjabi.mjs +1 -1
  182. package/dist/languages/romanian.mjs +1 -1
  183. package/dist/languages/russian.mjs +1 -1
  184. package/dist/languages/samoan.mjs +1 -1
  185. package/dist/languages/sanskrit.mjs +1 -1
  186. package/dist/languages/scottish-gaelic.mjs +1 -1
  187. package/dist/languages/serbian.mjs +1 -1
  188. package/dist/languages/shona.mjs +1 -1
  189. package/dist/languages/sinhala.mjs +1 -1
  190. package/dist/languages/slovak.mjs +1 -1
  191. package/dist/languages/slovenian.mjs +1 -1
  192. package/dist/languages/sorani.mjs +1 -1
  193. package/dist/languages/spanish.mjs +1 -1
  194. package/dist/languages/swahili.mjs +1 -1
  195. package/dist/languages/swedish.mjs +1 -1
  196. package/dist/languages/tagalog.mjs +1 -1
  197. package/dist/languages/tamil.mjs +1 -1
  198. package/dist/languages/tatar.mjs +1 -1
  199. package/dist/languages/telugu.mjs +1 -1
  200. package/dist/languages/thai.mjs +1 -1
  201. package/dist/languages/tibetan.mjs +1 -1
  202. package/dist/languages/tigrinya.mjs +1 -1
  203. package/dist/languages/tongan.mjs +1 -1
  204. package/dist/languages/turkish.mjs +1 -1
  205. package/dist/languages/twi.mjs +1 -1
  206. package/dist/languages/ukrainian.mjs +1 -1
  207. package/dist/languages/urdu.mjs +1 -1
  208. package/dist/languages/vietnamese.mjs +1 -1
  209. package/dist/languages/welsh.mjs +1 -1
  210. package/dist/languages/wolof.mjs +1 -1
  211. package/dist/languages/xhosa.mjs +1 -1
  212. package/dist/languages/yoruba.mjs +1 -1
  213. package/dist/languages/zulu.mjs +1 -1
  214. package/dist/{long-query-thread-QDFQSJD6.mjs → long-query-thread-JMGNGF6V.mjs} +74 -58
  215. package/dist/{module-N55W4Q5C.mjs → module-ZJ6ARG6V.mjs} +444 -111
  216. package/dist/msgpack-leaf-5WFRP6JM.mjs +9 -0
  217. package/dist/optional-reads-BR3BOVZW.mjs +3373 -0
  218. package/dist/optional-writes-DDFHYUOH.mjs +218 -0
  219. package/dist/{paged-partition-archive-RLRGOXDX.mjs → paged-partition-archive-G576XGVE.mjs} +29 -69
  220. package/dist/partial-words.browser.mjs +1649 -0
  221. package/dist/partial-words.mjs +15 -14
  222. package/dist/{chunk-CITFCZKF.mjs → pattern.browser.mjs} +153 -186
  223. package/dist/pattern.mjs +6 -8
  224. package/dist/persistence/durability/checkpoint-worker.d.ts +32 -24
  225. package/dist/persistence/durability/checkpoint-worker.mjs +27 -59
  226. package/dist/phrase-module-XK3T44VU.mjs +634 -0
  227. package/dist/query-actions-OMXJEC2J.mjs +118 -0
  228. package/dist/query-suggestions/merge-worker.mjs +18 -54
  229. package/dist/query-suggestions.browser.mjs +26 -227
  230. package/dist/query-suggestions.d.ts +2 -2
  231. package/dist/query-suggestions.mjs +16 -67
  232. package/dist/react-native/chunks/chunk-4EXKQ2IB.mjs +565 -0
  233. package/dist/react-native/chunks/chunk-52QD7CBJ.mjs +52 -0
  234. package/dist/react-native/chunks/chunk-72OKYHZL.mjs +969 -0
  235. package/dist/react-native/chunks/chunk-AQOWRH2C.mjs +802 -0
  236. package/dist/react-native/chunks/{chunk-4COWCEY7.mjs → chunk-FTQ7JNMU.mjs} +341 -180
  237. package/dist/react-native/chunks/chunk-G3CUQ333.mjs +42 -0
  238. package/dist/react-native/chunks/{chunk-EJ33LCHV.mjs → chunk-HRDMIQ63.mjs} +53 -1
  239. package/dist/react-native/chunks/{chunk-4AV5PPH6.mjs → chunk-IY6U6HRA.mjs} +63 -7
  240. package/dist/react-native/chunks/chunk-J2NQW353.mjs +212 -0
  241. package/dist/react-native/chunks/chunk-L4R5ITVG.mjs +29047 -0
  242. package/dist/react-native/chunks/{chunk-OXM66LO6.mjs → chunk-OK3WUA6N.mjs} +2 -10
  243. package/dist/react-native/chunks/{chunk-MVXELMJX.mjs → chunk-PVMEHBQO.mjs} +1 -1
  244. package/dist/{browser/chunk-SRMZXJSL.mjs → react-native/chunks/chunk-TQ26BKBH.mjs} +6 -0
  245. package/dist/{browser/chunk-GPPOG6PT.mjs → react-native/chunks/chunk-VUJCSQG5.mjs} +3 -1
  246. package/dist/react-native/chunks/{chunk-ENLMYKSX.mjs → chunk-XEGKQKLY.mjs} +5385 -3114
  247. package/dist/react-native/chunks/chunk-YOTP2FPE.mjs +232 -0
  248. package/dist/react-native/chunks/chunk-ZIU6TWXG.mjs +127 -0
  249. package/dist/react-native/chunks/core-leaf-5B4JXCVA.mjs +6 -0
  250. package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
  251. package/dist/{durability-config-GE4U7MCZ.mjs → react-native/chunks/durability-config-3IOXIPYZ.mjs} +7 -3
  252. package/dist/react-native/chunks/embed-3WQ2CCR5.mjs +221 -0
  253. package/dist/{geo-index-MRH5JMIR.mjs → react-native/chunks/geo-index-QEYKEVPH.mjs} +190 -93
  254. package/dist/react-native/chunks/{chunk-CKNRFDTZ.mjs → gzip.react-native-DLO4WW27.mjs} +2 -1
  255. package/dist/{browser/module-TCT66FWA.mjs → react-native/chunks/module-VUA27HZZ.mjs} +1018 -540
  256. package/dist/react-native/chunks/msgpack-leaf-TR66ZVAX.mjs +7 -0
  257. package/dist/react-native/chunks/optional-reads-WDTLLHUT.mjs +3364 -0
  258. package/dist/react-native/chunks/optional-writes-FZV3QW34.mjs +267 -0
  259. package/dist/react-native/chunks/phrase-module-KCQWVXYZ.mjs +635 -0
  260. package/dist/react-native/chunks/resolve-vector-text-LXRYXF7M.mjs +59 -0
  261. package/dist/react-native/chunks/restore-queue-EI2V2I4S.mjs +179 -0
  262. package/dist/{browser/runtime-OTAGEFQW.mjs → react-native/chunks/runtime-BUCSAK4U.mjs} +61 -25
  263. package/dist/react-native/chunks/segment-codec-leaf-6ULP7H3I.mjs +12 -0
  264. package/dist/react-native/chunks/segment-merge-leaf-F4GQZNK6.mjs +13 -0
  265. package/dist/react-native/chunks/storage-leaf-OAXBU2L6.mjs +18042 -0
  266. package/dist/react-native/chunks/store-leaf-GY2ZZFXB.mjs +14 -0
  267. package/dist/react-native/chunks/{chunk-WW2X2AEI.mjs → suggestions-leaf-SQEZ4IBS.mjs} +332 -118
  268. package/dist/react-native/chunks/worker-copies-EEHSCFJW.mjs +2627 -0
  269. package/dist/react-native/partial-words.mjs +954 -35
  270. package/dist/react-native/pattern.mjs +238 -111
  271. package/dist/react-native/query-suggestions.mjs +33 -239
  272. package/dist/react-native/sync.mjs +95 -52
  273. package/dist/react-native/synonyms.mjs +256 -112
  274. package/dist/react.d.ts +9 -9
  275. package/dist/react.mjs +6 -0
  276. package/dist/{rerank-MQ37IYRV.mjs → rerank-Y6MWBMTT.mjs} +17 -8
  277. package/dist/rerankers/http.mjs +2 -2
  278. package/dist/resolve-vector-text-4PDRTPNQ.mjs +2 -0
  279. package/dist/restore-queue-KPYSRJ4A.mjs +184 -0
  280. package/dist/runtime-4GKUIAKV.mjs +595 -0
  281. package/dist/{schema-Jwt928nJ.d.ts → schema-C_7yRJLt.d.ts} +1 -1
  282. package/dist/segment-codec-leaf-6IFBSBPN.mjs +17 -0
  283. package/dist/segment-merge-leaf-VE3FUSVE.mjs +17 -0
  284. package/dist/server.d.ts +33 -13
  285. package/dist/server.mjs +81 -100
  286. package/dist/{browser/durability-wiring-GVZEE46O.mjs → storage-leaf-HMIIOUYN.mjs} +2334 -931
  287. package/dist/store-leaf-M7T7SUZJ.mjs +19 -0
  288. package/dist/stored-values-BWIMpiT_.d.ts +25 -0
  289. package/dist/suggestions-leaf-Q3Q5D6XV.mjs +53 -0
  290. package/dist/sync/filesystem.d.ts +3 -3
  291. package/dist/sync/filesystem.mjs +27 -11
  292. package/dist/sync/indexeddb.browser.mjs +287 -0
  293. package/dist/sync/indexeddb.d.ts +3 -3
  294. package/dist/sync/indexeddb.mjs +7 -2
  295. package/dist/sync.browser.mjs +88 -72
  296. package/dist/sync.d.ts +4 -4
  297. package/dist/sync.mjs +89 -59
  298. package/dist/{chunk-I5B7RXU7.mjs → synonyms.browser.mjs} +248 -135
  299. package/dist/synonyms.mjs +15 -11
  300. package/dist/{tasks-CoNjxbop.d.ts → tasks-B4tT4vmP.d.ts} +4 -4
  301. package/dist/thread-SNILJXX3.mjs +30 -0
  302. package/dist/{types-DPMjfOr_.d.ts → types-CTg0KaMy.d.ts} +2 -2
  303. package/dist/vector/search-worker.d.ts +7 -1
  304. package/dist/vector/search-worker.mjs +9 -13
  305. package/dist/worker-copies-ZLZS2CUM.mjs +2152 -0
  306. package/dist/workers/entry.mjs +60 -30
  307. package/openapi.json +66 -50
  308. package/package.json +233 -8
  309. package/dist/analysis-change-CKEMM2MC.mjs +0 -55
  310. package/dist/analysis-change-entry-SEDMJ6MW.mjs +0 -1
  311. package/dist/archive-history-E4R73RWD.mjs +0 -29
  312. package/dist/browser/analysis-change-ZKGJFENM.mjs +0 -942
  313. package/dist/browser/analysis-change-entry-5BFUVMHJ.mjs +0 -1
  314. package/dist/browser/archive-history-4IP5XQZY.mjs +0 -29
  315. package/dist/browser/chunk-25MTVDYD.mjs +0 -432
  316. package/dist/browser/chunk-3I27KXQD.mjs +0 -34
  317. package/dist/browser/chunk-3NLMB5CC.mjs +0 -217
  318. package/dist/browser/chunk-4RD3AFSB.mjs +0 -32
  319. package/dist/browser/chunk-5W3MMTLG.mjs +0 -19
  320. package/dist/browser/chunk-5YWB3E2W.mjs +0 -92
  321. package/dist/browser/chunk-7IGKGWSQ.mjs +0 -79
  322. package/dist/browser/chunk-AI5UI46D.mjs +0 -12
  323. package/dist/browser/chunk-ATEBYXP6.mjs +0 -10
  324. package/dist/browser/chunk-BLT4RHCJ.mjs +0 -241
  325. package/dist/browser/chunk-C26SPCGQ.mjs +0 -2636
  326. package/dist/browser/chunk-C4FJ3WDY.mjs +0 -177
  327. package/dist/browser/chunk-CXNTHHA7.mjs +0 -63
  328. package/dist/browser/chunk-DSXIBE6N.mjs +0 -78
  329. package/dist/browser/chunk-DUH6QUVU.mjs +0 -2374
  330. package/dist/browser/chunk-ELV4OZOI.mjs +0 -29
  331. package/dist/browser/chunk-EXQZGUQH.mjs +0 -193
  332. package/dist/browser/chunk-G64Q6OJF.mjs +0 -96
  333. package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
  334. package/dist/browser/chunk-HUCSHDTB.mjs +0 -100
  335. package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
  336. package/dist/browser/chunk-K3IPRX6D.mjs +0 -2559
  337. package/dist/browser/chunk-ML7THVLJ.mjs +0 -38
  338. package/dist/browser/chunk-MY2XKH22.mjs +0 -40
  339. package/dist/browser/chunk-NLWTBAGB.mjs +0 -111
  340. package/dist/browser/chunk-NXQG7DRA.mjs +0 -318
  341. package/dist/browser/chunk-OEDCEZXJ.mjs +0 -92
  342. package/dist/browser/chunk-OIZS5KIX.mjs +0 -6
  343. package/dist/browser/chunk-RA6LSBCM.mjs +0 -43
  344. package/dist/browser/chunk-TK63WFXK.mjs +0 -90
  345. package/dist/browser/chunk-TY7L6OXO.mjs +0 -69
  346. package/dist/browser/chunk-U3JOQGWX.mjs +0 -19
  347. package/dist/browser/chunk-U4YDIBUT.mjs +0 -653
  348. package/dist/browser/chunk-UATIJ4KU.mjs +0 -21
  349. package/dist/browser/chunk-UKOWD2K5.mjs +0 -315
  350. package/dist/browser/chunk-UTMHUHUV.mjs +0 -150
  351. package/dist/browser/chunk-V43N6TZO.mjs +0 -857
  352. package/dist/browser/chunk-VI7BQR4U.mjs +0 -21
  353. package/dist/browser/chunk-WN464PTL.mjs +0 -375
  354. package/dist/browser/chunk-WXLBZJMT.mjs +0 -25
  355. package/dist/browser/chunk-X7TXYUKO.mjs +0 -86
  356. package/dist/browser/chunk-XAWNZ4G2.mjs +0 -151
  357. package/dist/browser/chunk-Y6IBAUNO.mjs +0 -561
  358. package/dist/browser/chunk-ZI2V4VD7.mjs +0 -21
  359. package/dist/browser/cold-module-YNUUDNOM.mjs +0 -761
  360. package/dist/browser/engine-hooks-HBVS6YM4.mjs +0 -18
  361. package/dist/browser/gzip-5S7ROJFJ.mjs +0 -1
  362. package/dist/browser/import-5ESVMFDJ.mjs +0 -20
  363. package/dist/browser/methods-KTQCSIN4.mjs +0 -30
  364. package/dist/browser/module-NDSQLPMQ.mjs +0 -25
  365. package/dist/browser/operations-OJ3BXS55.mjs +0 -5
  366. package/dist/browser/phrase-module-HAT3TLZN.mjs +0 -328
  367. package/dist/browser/pool-3JLET5RO.mjs +0 -297
  368. package/dist/browser/release-HYXPVJVS.mjs +0 -32
  369. package/dist/browser/restore-queue-LQBBTODR.mjs +0 -55
  370. package/dist/browser/retention-TY3L3BFN.mjs +0 -211
  371. package/dist/browser/snapshot-5FHPPCNZ.mjs +0 -965
  372. package/dist/browser/start-2UZTOBG5.mjs +0 -26
  373. package/dist/browser/sync-state-P5XG6LTQ.mjs +0 -15
  374. package/dist/browser/write-ULXAN5B4.mjs +0 -196
  375. package/dist/chunk-2NE7VCYE.mjs +0 -212
  376. package/dist/chunk-2ROUFMQX.mjs +0 -543
  377. package/dist/chunk-37CD3OKS.mjs +0 -87
  378. package/dist/chunk-3MXV3VHR.mjs +0 -46
  379. package/dist/chunk-3OH67G7R.mjs +0 -214
  380. package/dist/chunk-4B7JIGQD.mjs +0 -106
  381. package/dist/chunk-5YNRKI2C.mjs +0 -81
  382. package/dist/chunk-6HTGOXIK.mjs +0 -875
  383. package/dist/chunk-6OEGXLBX.mjs +0 -57
  384. package/dist/chunk-6RC4K46J.mjs +0 -86
  385. package/dist/chunk-7GFE3PEY.mjs +0 -40
  386. package/dist/chunk-7GXJUJ24.mjs +0 -49
  387. package/dist/chunk-7V5IUP2T.mjs +0 -63
  388. package/dist/chunk-A4L7YTKX.mjs +0 -458
  389. package/dist/chunk-BEZH7VEH.mjs +0 -23
  390. package/dist/chunk-BNL5OPRV.mjs +0 -634
  391. package/dist/chunk-BTPGQC6Z.mjs +0 -27
  392. package/dist/chunk-C7XQYG6U.mjs +0 -50
  393. package/dist/chunk-CQZXZ75V.mjs +0 -562
  394. package/dist/chunk-CWS55TEX.mjs +0 -242
  395. package/dist/chunk-CZQ33DLW.mjs +0 -78
  396. package/dist/chunk-EEBCDP36.mjs +0 -32
  397. package/dist/chunk-FB6463IN.mjs +0 -1499
  398. package/dist/chunk-FCJ553HS.mjs +0 -655
  399. package/dist/chunk-FEZVDOWX.mjs +0 -6996
  400. package/dist/chunk-FOCV4CBZ.mjs +0 -87
  401. package/dist/chunk-FQBFZAWG.mjs +0 -27
  402. package/dist/chunk-G6HRSGOU.mjs +0 -74
  403. package/dist/chunk-GES7U2PM.mjs +0 -68
  404. package/dist/chunk-GH4WQ22V.mjs +0 -34
  405. package/dist/chunk-GPWMUPCA.mjs +0 -1126
  406. package/dist/chunk-GQPTDQCL.mjs +0 -54
  407. package/dist/chunk-HJSN7UYG.mjs +0 -10
  408. package/dist/chunk-I54T6CQP.mjs +0 -117
  409. package/dist/chunk-IPN7S4KX.mjs +0 -130
  410. package/dist/chunk-J4IJTTEX.mjs +0 -226
  411. package/dist/chunk-JSV6OQ4C.mjs +0 -74
  412. package/dist/chunk-K4ZIGL2O.mjs +0 -290
  413. package/dist/chunk-KAKQ74LS.mjs +0 -53
  414. package/dist/chunk-KCQYFO4K.mjs +0 -62
  415. package/dist/chunk-KHKIRS5D.mjs +0 -113
  416. package/dist/chunk-KOKM4PQN.mjs +0 -52
  417. package/dist/chunk-KP7TYHWT.mjs +0 -92
  418. package/dist/chunk-KZ3NX2P7.mjs +0 -21
  419. package/dist/chunk-L5ORED7V.mjs +0 -25
  420. package/dist/chunk-LDNCLRZU.mjs +0 -218
  421. package/dist/chunk-LHKOSI2J.mjs +0 -58
  422. package/dist/chunk-LQG5G2LY.mjs +0 -39
  423. package/dist/chunk-MATMVH65.mjs +0 -9
  424. package/dist/chunk-MP7ABPTD.mjs +0 -189
  425. package/dist/chunk-MW6BR4QP.mjs +0 -316
  426. package/dist/chunk-MWD5VPN7.mjs +0 -21
  427. package/dist/chunk-ODYKO5TO.mjs +0 -101
  428. package/dist/chunk-OG7UGJ6F.mjs +0 -63
  429. package/dist/chunk-ORN5BLL7.mjs +0 -11
  430. package/dist/chunk-OYABFKTW.mjs +0 -1974
  431. package/dist/chunk-P5LANSH6.mjs +0 -121
  432. package/dist/chunk-PELHVTO7.mjs +0 -24
  433. package/dist/chunk-PIH5SJ4N.mjs +0 -7481
  434. package/dist/chunk-PSZI4O24.mjs +0 -253
  435. package/dist/chunk-PV2CG7EJ.mjs +0 -886
  436. package/dist/chunk-PWGYQXML.mjs +0 -470
  437. package/dist/chunk-Q2UL2TPC.mjs +0 -21
  438. package/dist/chunk-QHPYS427.mjs +0 -66
  439. package/dist/chunk-QJVOLKU6.mjs +0 -111
  440. package/dist/chunk-QLDABJZM.mjs +0 -20
  441. package/dist/chunk-QYRNLLLI.mjs +0 -99
  442. package/dist/chunk-RCX4WNLC.mjs +0 -151
  443. package/dist/chunk-RFBLQLLZ.mjs +0 -16
  444. package/dist/chunk-RIHIVFIQ.mjs +0 -240
  445. package/dist/chunk-RLOES5SX.mjs +0 -31
  446. package/dist/chunk-RWURUDSP.mjs +0 -2639
  447. package/dist/chunk-RZWWB2XR.mjs +0 -96
  448. package/dist/chunk-S5LN746F.mjs +0 -10
  449. package/dist/chunk-SOI6LTHM.mjs +0 -216
  450. package/dist/chunk-SQJWAIF4.mjs +0 -12
  451. package/dist/chunk-TDIK6NTV.mjs +0 -10
  452. package/dist/chunk-TQXHPFWT.mjs +0 -177
  453. package/dist/chunk-U55XJEIG.mjs +0 -18
  454. package/dist/chunk-UD5HIS4U.mjs +0 -382
  455. package/dist/chunk-UHICS3JI.mjs +0 -83
  456. package/dist/chunk-UJDJB3NE.mjs +0 -913
  457. package/dist/chunk-VD7J552I.mjs +0 -28
  458. package/dist/chunk-VSLSGASN.mjs +0 -30
  459. package/dist/chunk-VZ2ONHEE.mjs +0 -3715
  460. package/dist/chunk-W7OSSKH5.mjs +0 -1427
  461. package/dist/chunk-WZ7YV54N.mjs +0 -152
  462. package/dist/chunk-X5CV2E2B.mjs +0 -1
  463. package/dist/chunk-Y4WPNHMC.mjs +0 -50
  464. package/dist/chunk-YEKL4JBK.mjs +0 -96
  465. package/dist/chunk-ZXNQEW43.mjs +0 -18
  466. package/dist/chunk-ZYAY26KG.mjs +0 -29
  467. package/dist/direct-executor-V5DRIECI.mjs +0 -34
  468. package/dist/durability-wiring-3TD62MBI.mjs +0 -4072
  469. package/dist/engine-hooks-HA3SBOBR.mjs +0 -54
  470. package/dist/gzip-F4HMIEEQ.mjs +0 -1
  471. package/dist/import-GPKLTSKA.mjs +0 -56
  472. package/dist/methods-7IOINERF.mjs +0 -30
  473. package/dist/module-JYHFTVPS.mjs +0 -63
  474. package/dist/operations-G5EP6JPX.mjs +0 -5
  475. package/dist/phrase-module-XW5MKWP5.mjs +0 -330
  476. package/dist/pool-Y4A46T36.mjs +0 -298
  477. package/dist/react-native/chunks/analysis-change-QUVDNABS.mjs +0 -934
  478. package/dist/react-native/chunks/analysis-change-entry-OC4XASBF.mjs +0 -1
  479. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +0 -29
  480. package/dist/react-native/chunks/chunk-2PRHILX3.mjs +0 -529
  481. package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +0 -1
  482. package/dist/react-native/chunks/chunk-3WI35N75.mjs +0 -226
  483. package/dist/react-native/chunks/chunk-4DII3ZSM.mjs +0 -73
  484. package/dist/react-native/chunks/chunk-4J74WHQM.mjs +0 -177
  485. package/dist/react-native/chunks/chunk-4NWR3NGS.mjs +0 -151
  486. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +0 -17
  487. package/dist/react-native/chunks/chunk-5MSX5FRT.mjs +0 -858
  488. package/dist/react-native/chunks/chunk-6OFDUYVX.mjs +0 -92
  489. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +0 -9
  490. package/dist/react-native/chunks/chunk-6ZELFCK5.mjs +0 -315
  491. package/dist/react-native/chunks/chunk-AAAETEJK.mjs +0 -27
  492. package/dist/react-native/chunks/chunk-AM7RSBPF.mjs +0 -32
  493. package/dist/react-native/chunks/chunk-BITYFZSZ.mjs +0 -242
  494. package/dist/react-native/chunks/chunk-C5G6TJ7A.mjs +0 -140
  495. package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +0 -43
  496. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +0 -10
  497. package/dist/react-native/chunks/chunk-DMIFXZ3Q.mjs +0 -432
  498. package/dist/react-native/chunks/chunk-DVDX4SDR.mjs +0 -375
  499. package/dist/react-native/chunks/chunk-DXRSEWA2.mjs +0 -12
  500. package/dist/react-native/chunks/chunk-F753DA54.mjs +0 -23
  501. package/dist/react-native/chunks/chunk-FHPW7P2O.mjs +0 -40
  502. package/dist/react-native/chunks/chunk-FTZHMRD2.mjs +0 -18
  503. package/dist/react-native/chunks/chunk-HJBJBH26.mjs +0 -34
  504. package/dist/react-native/chunks/chunk-IAENKE2D.mjs +0 -21
  505. package/dist/react-native/chunks/chunk-IO2SMUQD.mjs +0 -10
  506. package/dist/react-native/chunks/chunk-IYNT75CE.mjs +0 -111
  507. package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +0 -38
  508. package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +0 -15
  509. package/dist/react-native/chunks/chunk-KSBYEMCB.mjs +0 -100
  510. package/dist/react-native/chunks/chunk-KU646XXT.mjs +0 -164
  511. package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +0 -68
  512. package/dist/react-native/chunks/chunk-LVIKKAA6.mjs +0 -93
  513. package/dist/react-native/chunks/chunk-LZSLNSUN.mjs +0 -193
  514. package/dist/react-native/chunks/chunk-MJDQU5MW.mjs +0 -1225
  515. package/dist/react-native/chunks/chunk-NNE4VDMM.mjs +0 -8
  516. package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +0 -78
  517. package/dist/react-native/chunks/chunk-OCSLSH27.mjs +0 -22723
  518. package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +0 -29
  519. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +0 -79
  520. package/dist/react-native/chunks/chunk-PSWKQVVT.mjs +0 -9
  521. package/dist/react-native/chunks/chunk-RDWG33MM.mjs +0 -79
  522. package/dist/react-native/chunks/chunk-SK2PWYDH.mjs +0 -654
  523. package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +0 -96
  524. package/dist/react-native/chunks/chunk-TORU2OHQ.mjs +0 -218
  525. package/dist/react-native/chunks/chunk-U4KSKA4Z.mjs +0 -23
  526. package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +0 -68
  527. package/dist/react-native/chunks/chunk-WBYQRHDY.mjs +0 -86
  528. package/dist/react-native/chunks/chunk-WVWJNUMN.mjs +0 -2562
  529. package/dist/react-native/chunks/chunk-YH7QY657.mjs +0 -288
  530. package/dist/react-native/chunks/chunk-YZW4CHM6.mjs +0 -562
  531. package/dist/react-native/chunks/chunk-ZNZ6CPAZ.mjs +0 -562
  532. package/dist/react-native/chunks/chunk-ZVQMBF2H.mjs +0 -63
  533. package/dist/react-native/chunks/chunk-ZWAIN4GG.mjs +0 -2636
  534. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +0 -92
  535. package/dist/react-native/chunks/cold-module-N6KFNNZA.mjs +0 -773
  536. package/dist/react-native/chunks/durability-wiring-RN64S2TL.mjs +0 -4984
  537. package/dist/react-native/chunks/engine-hooks-CWA5CKCA.mjs +0 -30
  538. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +0 -3
  539. package/dist/react-native/chunks/import-5UAWBRJP.mjs +0 -32
  540. package/dist/react-native/chunks/methods-6W5U4C3H.mjs +0 -30
  541. package/dist/react-native/chunks/module-6RP4ZCBW.mjs +0 -37
  542. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +0 -5
  543. package/dist/react-native/chunks/phrase-module-QK22HSQ2.mjs +0 -329
  544. package/dist/react-native/chunks/pool-JR3NJCAF.mjs +0 -297
  545. package/dist/react-native/chunks/release-2SIHZWDO.mjs +0 -32
  546. package/dist/react-native/chunks/restore-hooks-ENFMDTWC.mjs +0 -127
  547. package/dist/react-native/chunks/restore-queue-4R6AASE5.mjs +0 -55
  548. package/dist/react-native/chunks/retention-5GTFT3GR.mjs +0 -223
  549. package/dist/react-native/chunks/snapshot-5LGPQXFS.mjs +0 -976
  550. package/dist/react-native/chunks/start-ZQJVZ5DN.mjs +0 -38
  551. package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +0 -15
  552. package/dist/react-native/chunks/write-6BRYIIZ7.mjs +0 -208
  553. package/dist/release-SMR4WJD4.mjs +0 -32
  554. package/dist/restore-hooks-HXLIEB4A.mjs +0 -153
  555. package/dist/restore-queue-LZH7LMLR.mjs +0 -55
  556. package/dist/retention-3K7ARGAG.mjs +0 -66
  557. package/dist/runtime-COIUORCN.mjs +0 -177
  558. package/dist/snapshot-O7ICP7NJ.mjs +0 -783
  559. package/dist/start-S4PFP6RS.mjs +0 -66
  560. package/dist/sync-state-ZWHLAFLE.mjs +0 -15
  561. package/dist/thread-YLJ3ZPQ3.mjs +0 -50
  562. package/dist/write-2OBJGLFS.mjs +0 -233
  563. /package/dist/browser/{chunk-M3MQE2X7.mjs → digest-leaf-64IPRPZD.mjs} +0 -0
  564. /package/dist/browser/{chunk-JNOAKDUM.mjs → gzip-JF3S6PPT.mjs} +0 -0
  565. /package/dist/{chunk-ZXNNR73R.mjs → gzip-2UCZW2MM.mjs} +0 -0
@@ -1,773 +0,0 @@
1
- import { magnitude, defaultRescoreDepth, defaultEfSearch, computeCodeBlockLayout, toScore, osqQuantize, createOsqScratch, scalarQueryProducts, osqEstimate, osqDistance, toDistance } from './chunk-ENLMYKSX.mjs';
2
- export { createHNSWIndex, osqBitsOf } from './chunk-ENLMYKSX.mjs';
3
- import { readWholeSectionChecked, checkEverySectionPage, readFileRange, openPagedFile, readCacheOfThisThread, createSectionReader, closePagedFile } from './chunk-ZWAIN4GG.mjs';
4
- export { actionPartitionsOf, adoptSegmentsOnWorker, bytesThatSegmentsHoldInMemory, checkPagedSegmentFully, closeUnusedSegments, countsAsLatestHolder, createPagedFrozenSegment, isPagedSegmentFile, keysThatSegmentsStillRead, mergePagedWindow, openFileVectorReads, openPagedSegmentScan, openPagedSnapshot, openRewriteSpill, pagedListingOf, pagedPartitionLines, pagedTombstonesFor, prepareDiskAdoption, startReadingOpeningSectionsAhead, swapPreparedPartitions, writePagedSegment } from './chunk-ZWAIN4GG.mjs';
5
- import './chunk-WBYQRHDY.mjs';
6
- import './chunk-4J74WHQM.mjs';
7
- import { COLD_LOAD_WAIT_WITHOUT_SEARCH_MS, loadFailed, decodeSections, SEGMENT_PAGE_BYTES, RECORD_PAGE_BYTES, COLD_WALK_NODES_READ_AHEAD } from './chunk-5MSX5FRT.mjs';
8
- import './chunk-ZNZ6CPAZ.mjs';
9
- import './chunk-F753DA54.mjs';
10
- import './chunk-4DII3ZSM.mjs';
11
- import { isDead, VECTOR_FILE_PAYLOAD_VERSION, bytesToVectors, stageQueryLevels, readTrailer } from './chunk-DVDX4SDR.mjs';
12
- import './chunk-OXM66LO6.mjs';
13
- import './chunk-6OFDUYVX.mjs';
14
- import { yieldToEventLoop } from './chunk-OCSLSH27.mjs';
15
- import './chunk-NNE4VDMM.mjs';
16
- import './chunk-IO2SMUQD.mjs';
17
- import './chunk-YZW4CHM6.mjs';
18
- import './chunk-LU3Y3P63.mjs';
19
- import './chunk-AM7RSBPF.mjs';
20
- import './chunk-MVXELMJX.mjs';
21
- import './chunk-RDWG33MM.mjs';
22
- import './chunk-KU646XXT.mjs';
23
- import './chunk-UNUFZ2QY.mjs';
24
- import './chunk-3NQOVO3K.mjs';
25
- import './chunk-JDOEEMEF.mjs';
26
- import './chunk-2PRHILX3.mjs';
27
- import { HEADER_SIZE, crc32, readHeader } from './chunk-YH7QY657.mjs';
28
- import './chunk-CHPTFFJM.mjs';
29
- import './chunk-4COWCEY7.mjs';
30
- import './chunk-5CQX3XXV.mjs';
31
- import './chunk-6VBXNFLE.mjs';
32
- import './chunk-C5G6TJ7A.mjs';
33
- import './chunk-MJDQU5MW.mjs';
34
- import './chunk-3WI35N75.mjs';
35
- import { compareCodePoints } from './chunk-EJ33LCHV.mjs';
36
- import './chunk-FHPW7P2O.mjs';
37
- import './chunk-DXRSEWA2.mjs';
38
- import './chunk-LVIKKAA6.mjs';
39
- import './chunk-AAAETEJK.mjs';
40
- import './chunk-FTZHMRD2.mjs';
41
- import { NarsilError, ErrorCodes } from './chunk-DZ7H7D2C.mjs';
42
- import { decode, decodeMulti } from '@msgpack/msgpack';
43
-
44
- // src/persistence/paged/cold-search.ts
45
- function pushMin(heap, number, distance) {
46
- let at = heap.numbers.length;
47
- heap.numbers.push(number);
48
- heap.distances.push(distance);
49
- while (at > 0) {
50
- const parent = at - 1 >> 1;
51
- if (heap.distances[parent] <= distance) break;
52
- heap.numbers[at] = heap.numbers[parent];
53
- heap.distances[at] = heap.distances[parent];
54
- at = parent;
55
- }
56
- heap.numbers[at] = number;
57
- heap.distances[at] = distance;
58
- }
59
- function popMin(heap) {
60
- const size = heap.numbers.length;
61
- if (size === 0) return null;
62
- const top = { number: heap.numbers[0], distance: heap.distances[0] };
63
- const number = heap.numbers[size - 1];
64
- const distance = heap.distances[size - 1];
65
- heap.numbers.pop();
66
- heap.distances.pop();
67
- const remaining = size - 1;
68
- if (remaining === 0) return top;
69
- let at = 0;
70
- for (; ; ) {
71
- let child = 2 * at + 1;
72
- if (child >= remaining) break;
73
- if (child + 1 < remaining && heap.distances[child + 1] < heap.distances[child]) child += 1;
74
- if (heap.distances[child] >= distance) break;
75
- heap.numbers[at] = heap.numbers[child];
76
- heap.distances[at] = heap.distances[child];
77
- at = child;
78
- }
79
- heap.numbers[at] = number;
80
- heap.distances[at] = distance;
81
- return top;
82
- }
83
- function negated(heap) {
84
- return heap.distances.length === 0 ? Number.POSITIVE_INFINITY : -heap.distances[0];
85
- }
86
- function neighbourList(data, number, layer) {
87
- const part = data.parts[Math.floor(number / COLD_GRAPH_PART_VECTORS)];
88
- const offset = number % COLD_GRAPH_PART_VECTORS;
89
- const start = part.nodeOffsets[offset];
90
- const end = part.nodeOffsets[offset + 1];
91
- const bytes = part.neighbours.bytesAt(start, end - start);
92
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
93
- let cursor = 0;
94
- for (let current = 0; ; current++) {
95
- if (cursor + 4 > bytes.byteLength) loadFailed(`The neighbour lists of vector ${number} end inside a list`);
96
- const count = view.getUint32(cursor, true);
97
- if (cursor + 4 + count * 4 > bytes.byteLength)
98
- loadFailed(`The neighbour list of vector ${number} runs past its node`);
99
- if (current === layer) return { view, count, at: cursor + 4 };
100
- cursor += 4 + count * 4;
101
- }
102
- }
103
- function fetchNeighbourLists(data, numbers) {
104
- const reads = [];
105
- for (const number of numbers) {
106
- const part = data.parts[Math.floor(number / COLD_GRAPH_PART_VECTORS)];
107
- const offset = number % COLD_GRAPH_PART_VECTORS;
108
- const start = part.nodeOffsets[offset];
109
- const size = part.nodeOffsets[offset + 1] - start;
110
- if (size === 0) continue;
111
- const read = part.neighbours.fetchRows([start], size);
112
- if (read !== null) reads.push(read);
113
- }
114
- return reads.length === 0 ? null : Promise.all(reads);
115
- }
116
- function unseenNeighbours(scope, numbers, layer) {
117
- const unseen = /* @__PURE__ */ new Set();
118
- for (const number of numbers) {
119
- const list = neighbourList(scope.data, number, layer);
120
- for (let at = 0; at < list.count; at++) {
121
- const neighbour = list.view.getUint32(list.at + at * 4, true);
122
- if (neighbour < scope.data.total && scope.visited[neighbour] === 0) unseen.add(neighbour);
123
- }
124
- }
125
- return [...unseen];
126
- }
127
- function* readTheWalkAhead(scope, next, frontier, layer) {
128
- const { data } = scope;
129
- const listOfNext = fetchNeighbourLists(data, [next]);
130
- const rowsOfNext = listOfNext === null ? scope.fetchDistanceRows(unseenNeighbours(scope, [next], layer)) : null;
131
- if (listOfNext === null && rowsOfNext === null) return;
132
- const others = frontier.numbers.slice(0, COLD_WALK_NODES_READ_AHEAD - 1);
133
- yield Promise.all([listOfNext, rowsOfNext, fetchNeighbourLists(data, others)]);
134
- const rows = scope.fetchDistanceRows(unseenNeighbours(scope, [next, ...others], layer));
135
- if (rows !== null) yield rows;
136
- }
137
- function* walkLayer(scope, entries, ef, layer, excludes) {
138
- const { data, distanceOf, isAccepted } = scope;
139
- const visited = scope.visited;
140
- visited.fill(0);
141
- const frontier = { numbers: [], distances: [] };
142
- const found = { numbers: [], distances: [] };
143
- function take(number, distance) {
144
- pushMin(found, number, -distance);
145
- if (found.numbers.length > ef) popMin(found);
146
- }
147
- for (const entry of entries) {
148
- if (visited[entry] === 1) continue;
149
- visited[entry] = 1;
150
- if (data.topLayerOf(entry) < layer) continue;
151
- const distance = distanceOf(entry);
152
- if (distance === Number.POSITIVE_INFINITY) continue;
153
- pushMin(frontier, entry, distance);
154
- if (excludes && !isAccepted(entry)) continue;
155
- take(entry, distance);
156
- }
157
- let furthest = found.numbers.length > 0 ? negated(found) : Number.POSITIVE_INFINITY;
158
- for (; ; ) {
159
- const next = popMin(frontier);
160
- if (next === null) break;
161
- if (next.distance > furthest && found.numbers.length >= ef) break;
162
- if (scope.fetchesRows) yield* readTheWalkAhead(scope, next.number, frontier, layer);
163
- const list = neighbourList(data, next.number, layer);
164
- scope.clock?.tick(list.count * data.dimension);
165
- for (let at = 0; at < list.count; at++) {
166
- const neighbour = list.view.getUint32(list.at + at * 4, true);
167
- if (neighbour >= data.total || visited[neighbour] === 1) continue;
168
- visited[neighbour] = 1;
169
- if (data.topLayerOf(neighbour) < layer) continue;
170
- const distance = distanceOf(neighbour);
171
- if (distance === Number.POSITIVE_INFINITY) continue;
172
- if (distance < furthest || found.numbers.length < ef) {
173
- pushMin(frontier, neighbour, distance);
174
- if (excludes && !isAccepted(neighbour)) continue;
175
- take(neighbour, distance);
176
- furthest = negated(found);
177
- }
178
- }
179
- }
180
- return found;
181
- }
182
- function nearestFirst(found) {
183
- const numbers = [];
184
- const distances = [];
185
- for (; ; ) {
186
- const top = popMin(found);
187
- if (top === null) break;
188
- numbers.push(top.number);
189
- distances.push(-top.distance);
190
- }
191
- numbers.reverse();
192
- distances.reverse();
193
- return { numbers, distances };
194
- }
195
- function entryNumberOf(data) {
196
- const { entryPoint } = data.graph;
197
- if (entryPoint !== null && data.topLayerOf(entryPoint) >= 0) return entryPoint;
198
- let best = null;
199
- let bestTop = -1;
200
- for (let number = 0; number < data.total; number++) {
201
- const top = data.topLayerOf(number);
202
- if (top > bestTop) {
203
- bestTop = top;
204
- best = number;
205
- }
206
- }
207
- return best;
208
- }
209
- function codeDistance(data, query, metric) {
210
- const { codes, dimension } = data;
211
- if (codes === null) return null;
212
- const layout = computeCodeBlockLayout(dimension, codes.bits);
213
- const code = osqQuantize(query, codes.centroid, layout.queryBits, metric, createOsqScratch(dimension));
214
- const packed = new Uint8Array(layout.queryBytes);
215
- stageQueryLevels(code.levels, codes.bits, packed);
216
- let centroidDot = 0;
217
- for (let at = 0; at < dimension; at++) centroidDot += codes.centroid[at] * codes.centroid[at];
218
- const trailer = { lower: 0, upper: 0, correction: 0, sum: 0 };
219
- const { codeBytes, slotStride, queryBits, bits } = layout;
220
- const record = new Uint8Array(slotStride);
221
- const recordView = new DataView(record.buffer);
222
- return (number) => {
223
- const file = data.fileOfNumber(number);
224
- if (file.records === null) return Number.POSITIVE_INFINITY;
225
- file.records.read((number - file.firstNumber) * slotStride, record);
226
- const products = scalarQueryProducts(layout, record, 0, packed);
227
- readTrailer(recordView, 0, codeBytes, trailer);
228
- const estimate = osqEstimate(products, trailer, bits, code, queryBits, dimension, centroidDot, metric);
229
- return osqDistance(estimate, metric);
230
- };
231
- }
232
- function numbersThatCanReachTheTop(scored, k) {
233
- if (k <= 0 || scored.length <= k) return scored;
234
- scored.sort((a, b) => b.score - a.score);
235
- const lowestKept = scored[k - 1].score;
236
- let end = k;
237
- while (end < scored.length && scored[end].score === lowestKept) end += 1;
238
- return scored.slice(0, end);
239
- }
240
- function bestHits(hits, k) {
241
- return hits.sort((a, b) => b.score - a.score || compareCodePoints(a.docId, b.docId)).slice(0, Math.max(k, 0));
242
- }
243
- function searchColdGraph(data, query, k, options, accepts, excluded) {
244
- const walk = walkColdGraph(data, query, k, options, accepts, excluded, false);
245
- let step = walk.next();
246
- while (step.done !== true) step = walk.next();
247
- return step.value;
248
- }
249
- async function searchColdGraphConcurrently(data, query, k, options, accepts, excluded) {
250
- const walk = walkColdGraph(data, query, k, options, accepts, excluded, true);
251
- let step = walk.next();
252
- while (step.done !== true) {
253
- await step.value;
254
- step = walk.next();
255
- }
256
- return step.value;
257
- }
258
- function* walkColdGraph(data, query, k, options, accepts, excluded, fetchesRows) {
259
- const { metric, minSimilarity } = options;
260
- const entry = entryNumberOf(data);
261
- if (entry === null) return [];
262
- const qMag = magnitude(query);
263
- const fromCodes = codeDistance(data, query, metric);
264
- const fullDistance = (number) => {
265
- const vector = data.reusedVectorAt(number);
266
- return toDistance(query, vector, qMag, metric === "cosine" ? magnitude(vector) : 0, metric);
267
- };
268
- const distanceOf = fromCodes ?? fullDistance;
269
- const acceptance = /* @__PURE__ */ new Map();
270
- const isAccepted = (number) => {
271
- if (excluded.has(number) || data.isDeadNumber(number)) return false;
272
- if (accepts === null) return true;
273
- const held = acceptance.get(number);
274
- if (held !== void 0) return held;
275
- const accepted = accepts(data.idAt(number));
276
- acceptance.set(number, accepted);
277
- return accepted;
278
- };
279
- const window = options.rescoreWindow ?? k;
280
- const codes = data.codes;
281
- let depth = window;
282
- if (codes !== null) {
283
- depth = options.oversample === void 0 ? defaultRescoreDepth(codes.bits, data.dimension, window) : Math.ceil(window * options.oversample);
284
- }
285
- const ef = Math.max(options.efSearch ?? defaultEfSearch(data.dimension, window), depth);
286
- const codeRowBytes = codes === null ? null : computeCodeBlockLayout(data.dimension, codes.bits).slotStride;
287
- const scope = {
288
- data,
289
- distanceOf,
290
- isAccepted,
291
- visited: new Uint8Array(data.total),
292
- clock: options.clock,
293
- fetchesRows,
294
- fetchDistanceRows: (numbers2) => codeRowBytes === null ? fetchVectorRows(numbers2) : data.fetchRows(numbers2, (file) => file.records, codeRowBytes)
295
- };
296
- function fetchVectorRows(numbers2) {
297
- return data.fetchRows(numbers2, (file) => file.vectors, data.dimension * 4);
298
- }
299
- let current = entry;
300
- for (let layer = Math.min(data.graph.maxLayer, data.topLayerOf(entry)); layer >= 1; layer--) {
301
- const { numbers: numbers2 } = nearestFirst(yield* walkLayer(scope, [current], 1, layer, false));
302
- if (numbers2.length > 0) current = numbers2[0];
303
- }
304
- const { numbers, distances } = nearestFirst(yield* walkLayer(scope, [current], ef, 0, true));
305
- const scored = [];
306
- const rescores = codes !== null;
307
- const rescoreUntil = rescores ? Math.min(depth, numbers.length) : 0;
308
- if (fetchesRows && rescoreUntil > 0) {
309
- const reading = fetchVectorRows(numbers.slice(0, rescoreUntil));
310
- if (reading !== null) yield reading;
311
- }
312
- for (let at = 0; at < numbers.length; at++) {
313
- const number = numbers[at];
314
- if (rescores && at >= rescoreUntil && (options.rescoreWindow === void 0 || minSimilarity !== Number.NEGATIVE_INFINITY)) {
315
- break;
316
- }
317
- const distance = at < rescoreUntil ? fullDistance(number) : distances[at];
318
- const score = toScore(distance, metric);
319
- if (score < minSimilarity) continue;
320
- scored.push({ number, score });
321
- }
322
- const hits = numbersThatCanReachTheTop(scored, k).map(({ number, score }) => ({ docId: data.idAt(number), score }));
323
- return bestHits(hits, k);
324
- }
325
- var FLOAT64_BYTES = 8;
326
- var CODES_KEY_AND_MAP_HEADER_BYTES = 7;
327
- var BIN8_MAX_BYTES = 255;
328
- var BIN16_MAX_BYTES = 65535;
329
- var VECTOR_PAGE_SIZES = /* @__PURE__ */ new Set([SEGMENT_PAGE_BYTES, RECORD_PAGE_BYTES]);
330
- var NEIGHBOUR_PAGE_SIZES = /* @__PURE__ */ new Set([RECORD_PAGE_BYTES]);
331
- var LEVEL_PAGE_SIZES = /* @__PURE__ */ new Set([SEGMENT_PAGE_BYTES]);
332
- function holdsRawPayload(path) {
333
- const header = new Uint8Array(HEADER_SIZE);
334
- readFileRange(path, 0, header);
335
- return !readHeader(header).flags.compressionEnabled;
336
- }
337
- function readHead(path, ref) {
338
- const { headOffset, headLength, headChecksum } = ref;
339
- if (headOffset === void 0 || headLength === void 0 || headChecksum === void 0) return null;
340
- if (!holdsRawPayload(path)) return null;
341
- const head = new Uint8Array(headLength);
342
- readFileRange(path, HEADER_SIZE + headOffset, head);
343
- if (crc32(head) !== headChecksum) {
344
- throw new NarsilError(
345
- ErrorCodes.PERSISTENCE_CRC_MISMATCH,
346
- `The head of the file "${ref.key}" does not match its checksum`,
347
- { key: ref.key }
348
- );
349
- }
350
- return head;
351
- }
352
- function decodedHead(head, key) {
353
- let raw;
354
- try {
355
- raw = decode(head);
356
- } catch (error) {
357
- loadFailed(`The head of "${key}" is not MessagePack: ${error instanceof Error ? error.message : String(error)}`);
358
- }
359
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) loadFailed(`The head of "${key}" is not a map`);
360
- return raw;
361
- }
362
- function binHeaderBytes(length) {
363
- if (length <= BIN8_MAX_BYTES) return 2;
364
- return length <= BIN16_MAX_BYTES ? 3 : 5;
365
- }
366
- function isUint32OfThisHost(bytes) {
367
- return bytes.byteOffset % 4 === 0 && new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
368
- }
369
- function uint32ValuesOf(bytes) {
370
- if (isUint32OfThisHost(bytes)) return new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
371
- const values = new Uint32Array(bytes.byteLength / 4);
372
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
373
- for (let at = 0; at < values.length; at++) values[at] = view.getUint32(at * 4, true);
374
- return values;
375
- }
376
- function codesOfFile(path, sections, key) {
377
- const records = sections.get("records");
378
- const docIds = sections.get("docIds");
379
- if (records === void 0 || docIds === void 0) return null;
380
- const start = docIds.offset + docIds.length;
381
- const length = records.offset - start - binHeaderBytes(records.length);
382
- if (length <= CODES_KEY_AND_MAP_HEADER_BYTES) loadFailed(`The file "${key}" places its codes before its IDs`);
383
- const bytes = new Uint8Array(length);
384
- readFileRange(path, HEADER_SIZE + start, bytes);
385
- const values = [];
386
- try {
387
- for (const value of decodeMulti(bytes.subarray(CODES_KEY_AND_MAP_HEADER_BYTES))) values.push(value);
388
- } catch (error) {
389
- loadFailed(`The codes of "${key}" are not MessagePack: ${error instanceof Error ? error.message : String(error)}`);
390
- }
391
- const [bitsKey, bits, centroidKey, centroid] = values;
392
- if (bitsKey !== "bits" || centroidKey !== "centroid" || !Array.isArray(centroid)) {
393
- loadFailed(`The file "${key}" holds its codes in another layout`);
394
- }
395
- if (bits !== 1 && bits !== 2 && bits !== 4 && bits !== 8)
396
- loadFailed(`The file "${key}" holds ${String(bits)} bit codes`);
397
- return { bits, centroid: Float32Array.from(centroid.map(Number)) };
398
- }
399
- function sameCodes(left, right) {
400
- if (left.bits !== right.bits || left.centroid.length !== right.centroid.length) return false;
401
- for (let at = 0; at < left.centroid.length; at++) if (left.centroid[at] !== right.centroid[at]) return false;
402
- return true;
403
- }
404
- function requiredSection(sections, name, key) {
405
- const section = sections.get(name);
406
- if (section === void 0) loadFailed(`The head of "${key}" lists no section "${name}"`);
407
- return section;
408
- }
409
- function closeHeldFiles(held) {
410
- for (const { file } of held) closePagedFile(file);
411
- }
412
- function openOneFile(input, at, firstNumber, held, codes) {
413
- const { ref, path } = input.files[at];
414
- const head = readHead(path, ref);
415
- if (head === null) return false;
416
- const sectionsRaw = decodedHead(head, ref.key).sections;
417
- const list = decodeSections(sectionsRaw, ref.bytes - HEADER_SIZE, `head of "${ref.key}"`, VECTOR_PAGE_SIZES);
418
- const sections = new Map(list.map((section) => [section.name, section]));
419
- const fileCodes = codesOfFile(path, sections, ref.key);
420
- if (input.codeBits !== null) {
421
- if (fileCodes === null || fileCodes.bits !== input.codeBits) return false;
422
- if (codes !== null && !sameCodes(codes, fileCodes)) return false;
423
- }
424
- const records = sections.get("records");
425
- const magnitudeCount = requiredSection(sections, "magnitudes", ref.key).length / FLOAT64_BYTES;
426
- if (magnitudeCount !== ref.count) loadFailed(`The file "${ref.key}" holds ${magnitudeCount} magnitudes`);
427
- const ids = requiredSection(sections, "docIds", ref.key);
428
- const idOffsets = requiredSection(sections, "idOffsets", ref.key);
429
- const idOrder = requiredSection(sections, "idOrder", ref.key);
430
- const vectors = requiredSection(sections, "vectors", ref.key);
431
- const file = openPagedFile(path, readCacheOfThisThread());
432
- held.push({
433
- firstNumber,
434
- count: ref.count,
435
- dead: ref.dead,
436
- file,
437
- ids: createSectionReader(file, ids),
438
- idOffsets: createSectionReader(file, idOffsets),
439
- idOrder: createSectionReader(file, idOrder),
440
- records: records === void 0 ? null : createSectionReader(file, records),
441
- vectors: createSectionReader(file, vectors)
442
- });
443
- return input.codeBits === null ? null : fileCodes;
444
- }
445
- function openFiles(input) {
446
- const files = [];
447
- let codes = null;
448
- let firstNumber = 0;
449
- try {
450
- for (let at = 0; at < input.files.length; at++) {
451
- const opened = openOneFile(input, at, firstNumber, files, codes);
452
- if (opened === false) {
453
- closeHeldFiles(files);
454
- return null;
455
- }
456
- codes = opened;
457
- firstNumber += input.files[at].ref.count;
458
- }
459
- } catch (error) {
460
- closeHeldFiles(files);
461
- throw error;
462
- }
463
- return { files, codes };
464
- }
465
- function graphLayoutOf(head, ref) {
466
- const { graphs } = head;
467
- if (!Array.isArray(graphs) || graphs.length !== 1) return null;
468
- const layout = graphs[0];
469
- const payloadLength = ref.bytes - HEADER_SIZE;
470
- const [levels] = decodeSections([layout.levels], payloadLength, `head of "${ref.key}"`, LEVEL_PAGE_SIZES);
471
- const [neighbours] = decodeSections([layout.neighbours], payloadLength, `head of "${ref.key}"`, NEIGHBOUR_PAGE_SIZES);
472
- if (!(layout.nodeOffsets instanceof Uint8Array)) loadFailed(`The head of "${ref.key}" holds no node offsets`);
473
- const nodeOffsets = uint32ValuesOf(layout.nodeOffsets);
474
- if (nodeOffsets.length !== levels.length + 1) loadFailed(`The head of "${ref.key}" holds the wrong number of offsets`);
475
- for (let at = 1; at < nodeOffsets.length; at++) {
476
- if (nodeOffsets[at] < nodeOffsets[at - 1]) loadFailed(`The head of "${ref.key}" holds descending node offsets`);
477
- }
478
- if (nodeOffsets[nodeOffsets.length - 1] > neighbours.length) {
479
- loadFailed(`The node offsets of "${ref.key}" end outside its neighbour lists`);
480
- }
481
- return { entryPoint: layout.entryPoint, maxLayer: layout.maxLayer, m: layout.m, levels, nodeOffsets, neighbours };
482
- }
483
- function openParts(input) {
484
- const parts = [];
485
- let graph = null;
486
- try {
487
- for (const { ref, path } of input.graphParts) {
488
- const head = readHead(path, ref);
489
- const layout = head === null ? null : graphLayoutOf(decodedHead(head, ref.key), ref);
490
- if (layout === null) {
491
- closeHeldFiles(parts);
492
- return null;
493
- }
494
- const { entryPoint, maxLayer, m } = layout;
495
- if (typeof maxLayer !== "number" || typeof m !== "number") loadFailed(`The head of "${ref.key}" holds no layers`);
496
- if (entryPoint !== null && typeof entryPoint !== "number") loadFailed(`The head of "${ref.key}" holds no entry`);
497
- if (graph === null) graph = { entryPoint, maxLayer, m };
498
- const levels = readWholeSectionChecked(path, layout.levels, false);
499
- const file = openPagedFile(path, readCacheOfThisThread());
500
- parts.push({
501
- file,
502
- levels,
503
- nodeOffsets: layout.nodeOffsets,
504
- neighbours: createSectionReader(file, layout.neighbours)
505
- });
506
- }
507
- } catch (error) {
508
- closeHeldFiles(parts);
509
- throw error;
510
- }
511
- return graph === null ? null : { parts, graph };
512
- }
513
-
514
- // src/persistence/paged/cold-field/index.ts
515
- var COLD_GRAPH_PART_VECTORS = 16384;
516
- var FIXSTR = 160;
517
- var FIXSTR_MAX_BYTES = 31;
518
- var ASCII_MAX = 127;
519
- function shortAsciiIdOf(encoded) {
520
- const length = encoded[0] - FIXSTR;
521
- if (length < 0 || length > FIXSTR_MAX_BYTES || encoded.length !== length + 1) return null;
522
- let id = "";
523
- for (let at = 1; at <= length; at++) {
524
- const code = encoded[at];
525
- if (code > ASCII_MAX) return null;
526
- id += String.fromCharCode(code);
527
- }
528
- return id;
529
- }
530
- function everyLiveVectorHoldsANode(files, parts) {
531
- for (const file of files) {
532
- for (let at = 0; at < file.count; at++) {
533
- if (isDead(file.dead, at)) continue;
534
- const number = file.firstNumber + at;
535
- const part = parts[Math.floor(number / COLD_GRAPH_PART_VECTORS)];
536
- if (part === void 0) return false;
537
- if (part.levels[number % COLD_GRAPH_PART_VECTORS] === 0) return false;
538
- }
539
- }
540
- return true;
541
- }
542
- function createFieldData(input, opened, graph, parts) {
543
- const { files, codes } = opened;
544
- const lastFile = files[files.length - 1];
545
- const total = lastFile === void 0 ? 0 : lastFile.firstNumber + lastFile.count;
546
- const stride = input.dimension * 4;
547
- const reusedBytes = new Uint8Array(stride);
548
- const reusedVector = bytesToVectors(reusedBytes);
549
- const idOffsetBytes = new Uint8Array(8);
550
- const idOffsetView = new DataView(idOffsetBytes.buffer);
551
- function fileOfNumber(number) {
552
- let low = 0;
553
- let high = files.length - 1;
554
- while (low < high) {
555
- const middle = low + high + 1 >> 1;
556
- if (files[middle].firstNumber <= number) low = middle;
557
- else high = middle - 1;
558
- }
559
- return files[low];
560
- }
561
- function idInFile(file, position) {
562
- file.idOffsets.read(position * 4, idOffsetBytes);
563
- const start = idOffsetView.getUint32(0, true);
564
- const end = idOffsetView.getUint32(4, true);
565
- if (end < start) loadFailed(`The ID offsets of "${file.file.path}" descend at position ${position}`);
566
- const encoded = file.ids.bytesAt(start, end - start);
567
- const id = shortAsciiIdOf(encoded) ?? decode(encoded);
568
- if (typeof id !== "string") loadFailed(`Position ${position} of "${file.file.path}" holds no ID`);
569
- return id;
570
- }
571
- return {
572
- dimension: input.dimension,
573
- metric: input.metric,
574
- total,
575
- codes,
576
- graph,
577
- files,
578
- parts,
579
- fileOfNumber,
580
- topLayerOf(number) {
581
- const part = parts[Math.floor(number / COLD_GRAPH_PART_VECTORS)];
582
- if (part === void 0) return -1;
583
- const at = number % COLD_GRAPH_PART_VECTORS;
584
- return at < part.levels.length ? part.levels[at] - 1 : -1;
585
- },
586
- idAt(number) {
587
- const file = fileOfNumber(number);
588
- return idInFile(file, number - file.firstNumber);
589
- },
590
- vectorAt(number) {
591
- const file = fileOfNumber(number);
592
- const bytes = new Uint8Array(stride);
593
- file.vectors.read((number - file.firstNumber) * stride, bytes);
594
- return bytesToVectors(bytes);
595
- },
596
- reusedVectorAt(number) {
597
- const file = fileOfNumber(number);
598
- file.vectors.read((number - file.firstNumber) * stride, reusedBytes);
599
- return reusedVector.buffer === reusedBytes.buffer ? reusedVector : bytesToVectors(reusedBytes);
600
- },
601
- isDeadNumber(number) {
602
- const file = fileOfNumber(number);
603
- return isDead(file.dead, number - file.firstNumber);
604
- },
605
- fetchRows(numbers, sectionOf, rowBytes) {
606
- const positionsByFile = /* @__PURE__ */ new Map();
607
- for (const number of numbers) {
608
- const file = fileOfNumber(number);
609
- const positions = positionsByFile.get(file);
610
- const position = (number - file.firstNumber) * rowBytes;
611
- if (positions === void 0) positionsByFile.set(file, [position]);
612
- else positions.push(position);
613
- }
614
- const reads = [];
615
- for (const [file, positions] of positionsByFile) {
616
- const read = sectionOf(file)?.fetchRows(positions, rowBytes) ?? null;
617
- if (read !== null) reads.push(read);
618
- }
619
- return reads.length === 0 ? null : Promise.all(reads);
620
- }
621
- };
622
- }
623
- function positionOfId(file, docId, idAt, slot, view) {
624
- let low = 0;
625
- let high = file.count - 1;
626
- while (low <= high) {
627
- const middle = low + high >> 1;
628
- file.idOrder.read(middle * 4, slot);
629
- const position = view.getUint32(0, true);
630
- if (position >= file.count) loadFailed(`The ID order of "${file.file.path}" holds position ${position}`);
631
- const order = compareCodePoints(idAt(file.firstNumber + position), docId);
632
- if (order === 0) return position;
633
- if (order < 0) low = middle + 1;
634
- else high = middle - 1;
635
- }
636
- return void 0;
637
- }
638
- function openColdVectorField(input) {
639
- const opened = openFiles(input);
640
- if (opened === null) return null;
641
- let graphed;
642
- try {
643
- graphed = openParts(input);
644
- } catch (error) {
645
- closeHeldFiles(opened.files);
646
- throw error;
647
- }
648
- if (graphed === null) {
649
- closeHeldFiles(opened.files);
650
- return null;
651
- }
652
- const { parts, graph } = graphed;
653
- function closeAll() {
654
- closeHeldFiles(opened?.files ?? []);
655
- closeHeldFiles(parts);
656
- }
657
- if (!everyLiveVectorHoldsANode(opened.files, parts)) {
658
- closeAll();
659
- return null;
660
- }
661
- const data = createFieldData(input, opened, graph, parts);
662
- let live = 0;
663
- for (const file of opened.files) {
664
- for (let at = 0; at < file.count; at++) if (!isDead(file.dead, at)) live += 1;
665
- }
666
- let residentBytes = 0;
667
- for (const part of parts) residentBytes += part.levels.byteLength + part.nodeOffsets.byteLength;
668
- const orderSlot = new Uint8Array(4);
669
- const orderView = new DataView(orderSlot.buffer);
670
- function liveNumberOf(docId) {
671
- for (let at = data.files.length; at > 0; at--) {
672
- const file = data.files[at - 1];
673
- const position = positionOfId(file, docId, data.idAt, orderSlot, orderView);
674
- if (position !== void 0 && !isDead(file.dead, position)) return file.firstNumber + position;
675
- }
676
- return void 0;
677
- }
678
- return {
679
- liveCount: live,
680
- residentBytes,
681
- numberOf: liveNumberOf,
682
- vectorOfNumber: (number) => data.vectorAt(number),
683
- reusedVectorOfNumber: (number) => data.reusedVectorAt(number),
684
- partitionOf: (docId) => input.resolvePartition(docId),
685
- filePaths: () => [...input.files, ...input.graphParts].map((file) => file.path),
686
- search: (query, k, options, accepts, excluded) => searchColdGraph(data, query, k, options, accepts, excluded),
687
- searchConcurrently: (query, k, options, accepts, excluded) => searchColdGraphConcurrently(data, query, k, options, accepts, excluded),
688
- close: closeAll
689
- };
690
- }
691
- var FILE_PAGE_SIZES = /* @__PURE__ */ new Set([SEGMENT_PAGE_BYTES, RECORD_PAGE_BYTES]);
692
- var FLOAT32_BYTES = 4;
693
- var FLOAT64_BYTES2 = 8;
694
- function waitBeforeColdLoad(loadingWanted) {
695
- return new Promise((resolve) => {
696
- const timer = setTimeout(resolve, COLD_LOAD_WAIT_WITHOUT_SEARCH_MS);
697
- if (typeof timer.unref === "function") timer.unref();
698
- void loadingWanted.then(() => {
699
- clearTimeout(timer);
700
- resolve();
701
- });
702
- });
703
- }
704
- function sectionsOfFile(input) {
705
- const { ref, path } = input;
706
- const { headOffset, headLength } = ref;
707
- if (headOffset === void 0 || headLength === void 0) loadFailed(`The vector file "${ref.key}" holds no head`);
708
- const head = new Uint8Array(headLength);
709
- readFileRange(path, HEADER_SIZE + headOffset, head);
710
- const raw = decode(head);
711
- const list = decodeSections(raw.sections, ref.bytes - HEADER_SIZE, `head of "${ref.key}"`, FILE_PAGE_SIZES);
712
- return new Map(list.map((section) => [section.name, section]));
713
- }
714
- function requiredSection2(sections, name, key) {
715
- const section = sections.get(name);
716
- if (section === void 0) loadFailed(`The head of "${key}" lists no section "${name}"`);
717
- return section;
718
- }
719
- function magnitudesOf(bytes) {
720
- const values = new Float64Array(bytes.byteLength / FLOAT64_BYTES2);
721
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
722
- for (let at = 0; at < values.length; at++) values[at] = view.getFloat64(at * FLOAT64_BYTES2, true);
723
- return values;
724
- }
725
- async function loadFilesByParts(files, restore, fieldPath, dimension, stillWanted) {
726
- for (const input of files) {
727
- await yieldToEventLoop();
728
- if (!stillWanted()) return;
729
- const { ref, path } = input;
730
- const sections = sectionsOfFile(input);
731
- const idBytes = readWholeSectionChecked(path, requiredSection2(sections, "docIds", ref.key), false);
732
- const docIds = decode(idBytes);
733
- if (!Array.isArray(docIds) || docIds.length !== ref.count) {
734
- loadFailed(`The vector file "${ref.key}" lists the wrong number of IDs`);
735
- }
736
- const recordSection = sections.get("records");
737
- const records = recordSection === void 0 ? null : readWholeSectionChecked(path, recordSection, false);
738
- const magnitudes = magnitudesOf(
739
- readWholeSectionChecked(path, requiredSection2(sections, "magnitudes", ref.key), false)
740
- );
741
- const vectorSection = requiredSection2(sections, "vectors", ref.key);
742
- const stride = dimension * FLOAT32_BYTES;
743
- await checkEverySectionPage(path, vectorSection, stillWanted);
744
- if (!stillWanted()) return;
745
- const fileCodes = codesOfFile(path, sections, ref.key);
746
- restore.addFile({
747
- id: ref.id,
748
- key: ref.key,
749
- payload: {
750
- v: VECTOR_FILE_PAYLOAD_VERSION,
751
- fieldName: fieldPath,
752
- dimension,
753
- docIds,
754
- codes: records === null || fileCodes === null ? null : { bits: fileCodes.bits, centroid: Array.from(fileCodes.centroid), records },
755
- vectors: new Uint8Array(0)
756
- },
757
- dead: ref.dead,
758
- location: { path, vectorsOffset: HEADER_SIZE + vectorSection.offset },
759
- byParts: {
760
- magnitudes,
761
- vectorAt(position) {
762
- const bytes = new Uint8Array(stride);
763
- readFileRange(path, HEADER_SIZE + vectorSection.offset + position * stride, bytes);
764
- return bytesToVectors(bytes);
765
- }
766
- }
767
- });
768
- }
769
- await yieldToEventLoop();
770
- if (stillWanted()) restore.finish();
771
- }
772
-
773
- export { loadFilesByParts, openColdVectorField, waitBeforeColdLoad };