@delali/narsil 0.3.1-next.154 → 0.3.1-next.155

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 (297) hide show
  1. package/README.md +1 -0
  2. package/dist/adapters/filesystem.mjs +2 -2
  3. package/dist/adapters/gcs.mjs +2 -2
  4. package/dist/adapters/indexeddb.mjs +1 -1
  5. package/dist/adapters/s3.mjs +2 -2
  6. package/dist/{analysis-change-4GCRVRBW.mjs → analysis-change-3TFIHT5E.mjs} +25 -25
  7. package/dist/{react-native/chunks/analysis-change-entry-TNLUC6IZ.mjs → analysis-change-entry-KA6JAO4X.mjs} +1 -1
  8. package/dist/archive-history-E4R73RWD.mjs +29 -0
  9. package/dist/browser/{analysis-change-IXWPXXJJ.mjs → analysis-change-TC36BU47.mjs} +29 -10
  10. package/dist/{analysis-change-entry-KYGSXW4K.mjs → browser/analysis-change-entry-4MH3CZXH.mjs} +1 -1
  11. package/dist/browser/archive-history-4IP5XQZY.mjs +29 -0
  12. package/dist/browser/{chunk-4PD752F6.mjs → chunk-23XRXIBW.mjs} +1 -1
  13. package/dist/browser/chunk-3UIEB4QF.mjs +63 -0
  14. package/dist/browser/{chunk-AJ4HHOVT.mjs → chunk-4EWUGZYZ.mjs} +4 -4
  15. package/dist/browser/{chunk-U2E3HMYW.mjs → chunk-4WCVMOU3.mjs} +1 -1
  16. package/dist/browser/{chunk-QXTPSX2H.mjs → chunk-56W3HQVJ.mjs} +7 -7
  17. package/dist/browser/{chunk-3U3QR5YP.mjs → chunk-5TCXK5SB.mjs} +2 -2
  18. package/dist/browser/chunk-7IGKGWSQ.mjs +79 -0
  19. package/dist/browser/{chunk-J433A7P3.mjs → chunk-A5KUEGDY.mjs} +5 -5
  20. package/dist/browser/{chunk-XRV72TJD.mjs → chunk-ABCXENU5.mjs} +2 -2
  21. package/dist/browser/chunk-ATEBYXP6.mjs +10 -0
  22. package/dist/{react-native/chunks/chunk-3XKMRNRE.mjs → browser/chunk-BXM5XOCA.mjs} +27 -10
  23. package/dist/browser/chunk-CJSYBQ4J.mjs +100 -0
  24. package/dist/{react-native/chunks/chunk-DCKMICOB.mjs → browser/chunk-EXQZGUQH.mjs} +1 -1
  25. package/dist/browser/{chunk-VCOYGVP7.mjs → chunk-FNIFPFB7.mjs} +3 -3
  26. package/dist/browser/{chunk-ML6HY7T7.mjs → chunk-G64Q6OJF.mjs} +1 -1
  27. package/dist/browser/chunk-GPPOG6PT.mjs +9 -0
  28. package/dist/browser/chunk-IKDKX5VQ.mjs +1007 -0
  29. package/dist/browser/{chunk-7TTWXUH6.mjs → chunk-JIJXMI42.mjs} +3 -2
  30. package/dist/browser/chunk-JVBP5EYO.mjs +1106 -0
  31. package/dist/browser/{chunk-2FX6ROWR.mjs → chunk-K4GCSZLI.mjs} +4 -4
  32. package/dist/browser/{chunk-EUNBNLKM.mjs → chunk-K5AXJBLL.mjs} +5 -5
  33. package/dist/browser/chunk-KKAMCABR.mjs +432 -0
  34. package/dist/browser/{chunk-7MEYN7V6.mjs → chunk-LFIWRCEA.mjs} +1 -9
  35. package/dist/browser/chunk-M3MQE2X7.mjs +151 -0
  36. package/dist/browser/{chunk-W5X2UFWQ.mjs → chunk-NLWTBAGB.mjs} +12 -3
  37. package/dist/browser/chunk-OEDCEZXJ.mjs +92 -0
  38. package/dist/browser/{chunk-G7LUMBSG.mjs → chunk-RND5CLX3.mjs} +28 -18
  39. package/dist/browser/{chunk-AYY6PIKL.mjs → chunk-RQBUNZQW.mjs} +2 -2
  40. package/dist/browser/{chunk-C4KS2QNF.mjs → chunk-RRO3EV4C.mjs} +9 -9
  41. package/dist/browser/{chunk-2SHAKW2Z.mjs → chunk-SMEQ36NT.mjs} +80 -134
  42. package/dist/{chunk-KUZKUONM.mjs → browser/chunk-SRMZXJSL.mjs} +1 -0
  43. package/dist/{react-native/chunks/chunk-3O57C2ZO.mjs → browser/chunk-SUDNZKPL.mjs} +2 -2
  44. package/dist/browser/{chunk-SJB6VIZG.mjs → chunk-U3JOQGWX.mjs} +1 -1
  45. package/dist/browser/{chunk-H6QFBMVE.mjs → chunk-XY4VVBBO.mjs} +3 -3
  46. package/dist/browser/{cold-module-VTUGDYNY.mjs → cold-module-NEUGHUPA.mjs} +18 -17
  47. package/dist/browser/durability-config-TIYKW6XX.mjs +89 -0
  48. package/dist/browser/{durability-wiring-GL4A7KDV.mjs → durability-wiring-CVGPRO6D.mjs} +46 -150
  49. package/dist/browser/engine-hooks-YXMPHZKZ.mjs +16 -0
  50. package/dist/browser/{import-YI5GNB4H.mjs → import-OM6QAW45.mjs} +10 -9
  51. package/dist/browser/{methods-LMUTS7OI.mjs → methods-KTQCSIN4.mjs} +3 -3
  52. package/dist/browser/{module-EC3FYW7N.mjs → module-3HNFCBJ5.mjs} +10 -9
  53. package/dist/browser/{module-M4JNBV6V.mjs → module-E33X4AOK.mjs} +14 -13
  54. package/dist/browser/operations-OJ3BXS55.mjs +5 -0
  55. package/dist/browser/{phrase-module-NPYUVX75.mjs → phrase-module-ZXXU7S3B.mjs} +1 -1
  56. package/dist/browser/{pool-WCGDZHJP.mjs → pool-3JLET5RO.mjs} +1 -1
  57. package/dist/browser/restore-hooks-IF2ZROUP.mjs +113 -0
  58. package/dist/browser/restore-queue-ZBS7CJA6.mjs +55 -0
  59. package/dist/browser/{retention-6QMRS5VK.mjs → retention-ASWUHAYI.mjs} +16 -14
  60. package/dist/browser/{runtime-3EW2AGB6.mjs → runtime-OTAGEFQW.mjs} +1 -1
  61. package/dist/browser/{snapshot-DN3CRVUQ.mjs → snapshot-PN7ZW6Q4.mjs} +65 -31
  62. package/dist/browser/start-ZIRB7MQ2.mjs +24 -0
  63. package/dist/browser/{write-WAWAFGKQ.mjs → write-HMDYCTV2.mjs} +14 -13
  64. package/dist/{capabilities-B3Brs1Rc.d.ts → capabilities-Da4ywVVl.d.ts} +35 -3
  65. package/dist/{chunk-K4B7OH65.mjs → chunk-2MANFZJ3.mjs} +2 -2
  66. package/dist/{chunk-O43Z4MS6.mjs → chunk-2NE7VCYE.mjs} +2 -2
  67. package/dist/{chunk-3Y3J4V2R.mjs → chunk-3C7MTCCI.mjs} +1 -1
  68. package/dist/{chunk-RVKFI3A2.mjs → chunk-3HB3PEC6.mjs} +11 -8
  69. package/dist/chunk-3HHQLEEQ.mjs +1092 -0
  70. package/dist/{chunk-HVYICDY3.mjs → chunk-3OH67G7R.mjs} +1 -1
  71. package/dist/{chunk-QKZHLADX.mjs → chunk-3R4UZWQG.mjs} +26 -17
  72. package/dist/{chunk-ZIFJXCKA.mjs → chunk-4BYWRYPM.mjs} +1 -1
  73. package/dist/{chunk-VMXSVVXG.mjs → chunk-4KRC2APY.mjs} +5 -5
  74. package/dist/{chunk-IQ4R2I6N.mjs → chunk-5FLRXF73.mjs} +5 -1
  75. package/dist/chunk-5FVU47TB.mjs +20 -0
  76. package/dist/chunk-5YNRKI2C.mjs +81 -0
  77. package/dist/chunk-6L3XJXGU.mjs +470 -0
  78. package/dist/{chunk-C6ASEFZI.mjs → chunk-6OEGXLBX.mjs} +1 -1
  79. package/dist/{browser/chunk-SIR3LMTV.mjs → chunk-6RC4K46J.mjs} +2 -2
  80. package/dist/{chunk-466PYR4P.mjs → chunk-AILVAOLX.mjs} +2 -2
  81. package/dist/chunk-BDRIVYOK.mjs +72 -0
  82. package/dist/{chunk-TRISKD4Q.mjs → chunk-BY6ZDGYS.mjs} +2 -2
  83. package/dist/{chunk-NZMAXR2S.mjs → chunk-DCNKVEDB.mjs} +121 -10
  84. package/dist/{chunk-C73JLU4E.mjs → chunk-DIBHI6W5.mjs} +2 -2
  85. package/dist/{chunk-VREK3MYG.mjs → chunk-DUOLGBTE.mjs} +3 -3
  86. package/dist/{chunk-USR7FQRZ.mjs → chunk-GH4WQ22V.mjs} +2 -2
  87. package/dist/chunk-GQPTDQCL.mjs +54 -0
  88. package/dist/chunk-H4KHPLHJ.mjs +382 -0
  89. package/dist/{chunk-K7KLL263.mjs → chunk-H6VIGE62.mjs} +12 -12
  90. package/dist/{chunk-YROWNOMH.mjs → chunk-HJJI72X7.mjs} +1 -1
  91. package/dist/{chunk-37IVJLP6.mjs → chunk-HNVVEQP7.mjs} +1 -1
  92. package/dist/{chunk-PFKM7VNZ.mjs → chunk-HW5TNXBO.mjs} +28 -10
  93. package/dist/{chunk-3A5KI24C.mjs → chunk-I54T6CQP.mjs} +1 -1
  94. package/dist/{chunk-YBJDOA2T.mjs → chunk-INJYO3BU.mjs} +1 -1
  95. package/dist/{chunk-KCUIFVVW.mjs → chunk-J4IWBIVY.mjs} +9 -9
  96. package/dist/{chunk-AO2FAYIZ.mjs → chunk-K4ZIGL2O.mjs} +1 -1
  97. package/dist/{chunk-7NTMUDC5.mjs → chunk-KBDBPVLN.mjs} +5 -5
  98. package/dist/{chunk-JFNKIBDT.mjs → chunk-KBKEXQZA.mjs} +2 -2
  99. package/dist/{chunk-REL7LFLR.mjs → chunk-KFLK5NA2.mjs} +3 -3
  100. package/dist/{chunk-WCBA2LVZ.mjs → chunk-KHKIRS5D.mjs} +1 -1
  101. package/dist/{chunk-7QUGDVFC.mjs → chunk-KJ3RTZDJ.mjs} +1 -1
  102. package/dist/{chunk-LSM2YTKM.mjs → chunk-KMUNHGBQ.mjs} +81 -139
  103. package/dist/chunk-KP7TYHWT.mjs +92 -0
  104. package/dist/{chunk-MMBEANB2.mjs → chunk-KPIV4RUC.mjs} +3 -3
  105. package/dist/{chunk-62G63NMH.mjs → chunk-KXCVQWOR.mjs} +4 -4
  106. package/dist/{chunk-TV2L3BN7.mjs → chunk-L7ZD4L3K.mjs} +263 -263
  107. package/dist/{chunk-OKX2BBNW.mjs → chunk-LC3FDWTX.mjs} +2 -2
  108. package/dist/{chunk-URPCYQVJ.mjs → chunk-LHKOSI2J.mjs} +1 -1
  109. package/dist/chunk-LNGE7SLY.mjs +151 -0
  110. package/dist/{react-native/chunks/chunk-CUNGPR5R.mjs → chunk-MP7ABPTD.mjs} +1 -0
  111. package/dist/chunk-MT2NRTA6.mjs +216 -0
  112. package/dist/{chunk-Q3TCTQCC.mjs → chunk-NF4DT3IH.mjs} +1 -1
  113. package/dist/{chunk-3OFU3NJT.mjs → chunk-OIJ64LGT.mjs} +1 -1
  114. package/dist/{chunk-4HWZV5MK.mjs → chunk-PCRA7HTI.mjs} +5 -5
  115. package/dist/chunk-PHQNACDT.mjs +63 -0
  116. package/dist/{chunk-Q7MS6P2J.mjs → chunk-Q622CTMC.mjs} +2 -2
  117. package/dist/{chunk-HVKXNBFL.mjs → chunk-Q7G3BV3Y.mjs} +1 -1
  118. package/dist/{chunk-IBNLW3AV.mjs → chunk-QH3YIQP4.mjs} +20 -6
  119. package/dist/{chunk-B7S6YEBP.mjs → chunk-QJVOLKU6.mjs} +12 -3
  120. package/dist/chunk-QUJHMPTP.mjs +30 -0
  121. package/dist/{chunk-7HCZWC7B.mjs → chunk-RSVULW4Q.mjs} +49 -7
  122. package/dist/{chunk-YPUEV6ZC.mjs → chunk-RVGRFOGN.mjs} +1 -1
  123. package/dist/{chunk-JCLTESFN.mjs → chunk-RZWWB2XR.mjs} +1 -1
  124. package/dist/{chunk-X6NSJYQ3.mjs → chunk-S2EQU2GE.mjs} +13 -13
  125. package/dist/chunk-S5LN746F.mjs +10 -0
  126. package/dist/{chunk-MMEMEUOO.mjs → chunk-SG3JBNHY.mjs} +2 -2
  127. package/dist/{chunk-LKUE5GXS.mjs → chunk-SMVH6JBE.mjs} +2 -2
  128. package/dist/{chunk-IJU7LL7D.mjs → chunk-SY3EWKQY.mjs} +5 -5
  129. package/dist/{chunk-CP5RRPJR.mjs → chunk-TQXHPFWT.mjs} +1 -1
  130. package/dist/{chunk-5KGYQT6W.mjs → chunk-U4BS74YN.mjs} +26 -9
  131. package/dist/{chunk-S2N75OTN.mjs → chunk-UHICS3JI.mjs} +1 -1
  132. package/dist/chunk-UZRZKNNZ.mjs +101 -0
  133. package/dist/{chunk-DMQPFLGI.mjs → chunk-VGF7CFRP.mjs} +5 -5
  134. package/dist/chunk-VHBNF4MA.mjs +543 -0
  135. package/dist/{chunk-BPSKLCS7.mjs → chunk-VQEUR6T6.mjs} +3 -3
  136. package/dist/{chunk-Z3TNWCI5.mjs → chunk-WQRN64Q6.mjs} +2 -2
  137. package/dist/{chunk-LTUGDMV4.mjs → chunk-WZ7YV54N.mjs} +1 -1
  138. package/dist/{chunk-NTZOXVUZ.mjs → chunk-YEDIDCR7.mjs} +3 -3
  139. package/dist/{chunk-PGVPE7GJ.mjs → chunk-YEKL4JBK.mjs} +1 -1
  140. package/dist/{chunk-5FUOVJKG.mjs → chunk-Z2BE2MAM.mjs} +13 -13
  141. package/dist/{chunk-HWEDFLB7.mjs → chunk-ZAUJFLEN.mjs} +10 -10
  142. package/dist/{chunk-MLHNSAPK.mjs → chunk-ZHCUZZE5.mjs} +2 -2
  143. package/dist/{chunk-ECX4SGX6.mjs → chunk-ZTW5WTGG.mjs} +9 -9
  144. package/dist/{client-Df76GNKm.d.ts → client-DRv7UVeY.d.ts} +123 -11
  145. package/dist/client.d.ts +9 -8
  146. package/dist/client.mjs +65 -3
  147. package/dist/{cold-module-YLWMTTZG.mjs → cold-module-7XXCEGTZ.mjs} +35 -35
  148. package/dist/{config-B8DP2VwR.d.ts → config-CoSig5Ox.d.ts} +22 -3
  149. package/dist/{config-05G_hy-1.d.ts → config-DMwffLKn.d.ts} +20 -5
  150. package/dist/{direct-executor-FI5GJHWX.mjs → direct-executor-G5TK7NLA.mjs} +16 -16
  151. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  152. package/dist/distribution/coordinator/etcd.mjs +1 -1
  153. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  154. package/dist/distribution/transport/grpc.mjs +4 -4
  155. package/dist/distribution/transport/in-memory.mjs +2 -2
  156. package/dist/distribution/transport/tcp.mjs +3 -3
  157. package/dist/distribution.d.ts +8 -8
  158. package/dist/distribution.mjs +6788 -5934
  159. package/dist/durability-config-GE4U7MCZ.mjs +89 -0
  160. package/dist/{durability-wiring-RHLXDIVF.mjs → durability-wiring-NCKUC5EO.mjs} +71 -175
  161. package/dist/embeddings/openai.mjs +2 -2
  162. package/dist/{sync-uXR7MmM7.d.ts → engine-CFxPYqEk.d.ts} +702 -2
  163. package/dist/engine-hooks-DHCMOADY.mjs +47 -0
  164. package/dist/{import-SRBNC6TE.mjs → import-NBFXFCSG.mjs} +26 -26
  165. package/dist/{index-nRqDM6uS.d.ts → index-C4AmUnl1.d.ts} +1 -1
  166. package/dist/index.browser.mjs +7 -6
  167. package/dist/index.d.ts +7 -7
  168. package/dist/index.mjs +23 -23
  169. package/dist/index.react-native.mjs +13 -12
  170. package/dist/{long-query-thread-EMYTGSJP.mjs → long-query-thread-J4DVRM4A.mjs} +25 -24
  171. package/dist/{methods-ABM5ELBR.mjs → methods-7IOINERF.mjs} +3 -3
  172. package/dist/{module-MG7JMV2U.mjs → module-DWKPBSMN.mjs} +31 -31
  173. package/dist/{module-3OMJZUFT.mjs → module-UN76TF7I.mjs} +11 -11
  174. package/dist/operations-G5EP6JPX.mjs +5 -0
  175. package/dist/{paged-partition-archive-UOLHOEZJ.mjs → paged-partition-archive-DPNWVSK2.mjs} +38 -34
  176. package/dist/partial-words.mjs +7 -7
  177. package/dist/pattern.mjs +3 -3
  178. package/dist/persistence/durability/checkpoint-worker.d.ts +8 -1
  179. package/dist/persistence/durability/checkpoint-worker.mjs +32 -32
  180. package/dist/{phrase-module-O3MDRQXP.mjs → phrase-module-ZI4WSQVH.mjs} +1 -1
  181. package/dist/{pool-CQXYPFLG.mjs → pool-Y4A46T36.mjs} +1 -1
  182. package/dist/query-suggestions/merge-worker.d.ts +55 -0
  183. package/dist/query-suggestions/merge-worker.mjs +81 -0
  184. package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
  185. package/dist/query-suggestions.browser.mjs +246 -0
  186. package/dist/query-suggestions.d.ts +20 -0
  187. package/dist/query-suggestions.mjs +62 -0
  188. package/dist/react-native/chunks/{analysis-change-EAYO3Y6Q.mjs → analysis-change-6BPDPH6K.mjs} +36 -17
  189. package/dist/{browser/analysis-change-entry-FCSHFQSS.mjs → react-native/chunks/analysis-change-entry-JLL42PH6.mjs} +1 -1
  190. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +29 -0
  191. package/dist/react-native/chunks/{chunk-O32RB3BL.mjs → chunk-3JIBF3XT.mjs} +3 -3
  192. package/dist/react-native/chunks/{chunk-75VWIY35.mjs → chunk-4DII3ZSM.mjs} +1 -1
  193. package/dist/react-native/chunks/{chunk-NKIZX26F.mjs → chunk-4J74WHQM.mjs} +2 -2
  194. package/dist/{browser/chunk-TTD27VXX.mjs → react-native/chunks/chunk-4LCEN2IU.mjs} +27 -10
  195. package/dist/react-native/chunks/{chunk-AUT7PMA4.mjs → chunk-4Y53T4YE.mjs} +5 -5
  196. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +17 -0
  197. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +9 -0
  198. package/dist/react-native/chunks/{chunk-SJWDBRNP.mjs → chunk-6WA3C3DV.mjs} +1 -1
  199. package/dist/react-native/chunks/chunk-7GRCBBME.mjs +63 -0
  200. package/dist/react-native/chunks/{chunk-7GWPJDOA.mjs → chunk-7PXRWYUU.mjs} +1 -1
  201. package/dist/react-native/chunks/{chunk-GFYFQLJD.mjs → chunk-ALOIBXWN.mjs} +2 -2
  202. package/dist/react-native/chunks/{chunk-VQSKZ3EZ.mjs → chunk-C3PTWYKT.mjs} +8 -8
  203. package/dist/react-native/chunks/{chunk-OQQVRWZ2.mjs → chunk-C5G6TJ7A.mjs} +1 -1
  204. package/dist/react-native/chunks/{chunk-RVAEBN74.mjs → chunk-CKNRFDTZ.mjs} +1 -1
  205. package/dist/react-native/chunks/{chunk-UWDNZDWK.mjs → chunk-CUH5F57W.mjs} +6 -6
  206. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +10 -0
  207. package/dist/react-native/chunks/{chunk-YBEW6YTR.mjs → chunk-DVDX4SDR.mjs} +2 -2
  208. package/dist/{browser/chunk-MYITLCHT.mjs → react-native/chunks/chunk-DZ7H7D2C.mjs} +1 -0
  209. package/dist/react-native/chunks/{chunk-RYMDHGL4.mjs → chunk-EIOYM5TO.mjs} +5 -5
  210. package/dist/react-native/chunks/chunk-GIZTJXYW.mjs +1007 -0
  211. package/dist/react-native/chunks/{chunk-NP7DD4G5.mjs → chunk-GJFXPHXI.mjs} +5 -5
  212. package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
  213. package/dist/react-native/chunks/{chunk-63YSZOXB.mjs → chunk-HUOYZJ3Q.mjs} +88 -142
  214. package/dist/react-native/chunks/{chunk-DH3TVWWK.mjs → chunk-IYNT75CE.mjs} +12 -3
  215. package/dist/react-native/chunks/{chunk-NCJS3WIY.mjs → chunk-JLIIWJUV.mjs} +1 -1
  216. package/dist/react-native/chunks/chunk-KJIG57UD.mjs +1106 -0
  217. package/dist/react-native/chunks/{chunk-JX2RIAXH.mjs → chunk-KTTAU63H.mjs} +5 -5
  218. package/dist/{browser/chunk-ZPTA75ZC.mjs → react-native/chunks/chunk-LZSLNSUN.mjs} +1 -1
  219. package/dist/react-native/chunks/{chunk-ZBSWRSBG.mjs → chunk-MJDQU5MW.mjs} +1 -1
  220. package/dist/react-native/chunks/{chunk-IOY2SM2P.mjs → chunk-MVXELMJX.mjs} +1 -1
  221. package/dist/react-native/chunks/{chunk-2CGSQM4O.mjs → chunk-N2WUOWLL.mjs} +12 -12
  222. package/dist/react-native/chunks/{chunk-YHKZSLOC.mjs → chunk-OL3WDV53.mjs} +5 -5
  223. package/dist/react-native/chunks/{chunk-VVFYOADG.mjs → chunk-PEHS2UO3.mjs} +6 -6
  224. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +79 -0
  225. package/dist/react-native/chunks/chunk-QJXTNPLQ.mjs +100 -0
  226. package/dist/react-native/chunks/{chunk-EH5CFV6Z.mjs → chunk-RDWG33MM.mjs} +2 -2
  227. package/dist/react-native/chunks/{chunk-ZYDKJXQJ.mjs → chunk-SUPXRTMD.mjs} +1 -1
  228. package/dist/react-native/chunks/chunk-TYIRMPD3.mjs +432 -0
  229. package/dist/react-native/chunks/{chunk-JPAJWO6D.mjs → chunk-U4KSKA4Z.mjs} +1 -1
  230. package/dist/react-native/chunks/{chunk-I5PGWQJF.mjs → chunk-VXGE4ZXL.mjs} +31 -22
  231. package/dist/{chunk-DVWYODEB.mjs → react-native/chunks/chunk-WBYQRHDY.mjs} +2 -2
  232. package/dist/react-native/chunks/{chunk-C2H2QQFW.mjs → chunk-YH7QY657.mjs} +3 -3
  233. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +92 -0
  234. package/dist/react-native/chunks/{cold-module-TJL6AFAD.mjs → cold-module-5PHF6DZR.mjs} +24 -23
  235. package/dist/react-native/chunks/durability-config-QXVZEO7T.mjs +89 -0
  236. package/dist/react-native/chunks/{durability-wiring-RRDYJLLM.mjs → durability-wiring-KO565FZC.mjs} +52 -156
  237. package/dist/react-native/chunks/engine-hooks-MVRRHH6B.mjs +28 -0
  238. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +3 -0
  239. package/dist/react-native/chunks/import-YVZA4V4V.mjs +30 -0
  240. package/dist/react-native/chunks/{methods-X6F36SJE.mjs → methods-6W5U4C3H.mjs} +3 -3
  241. package/dist/react-native/chunks/{module-S4DKSWMF.mjs → module-H5MVPSP2.mjs} +11 -10
  242. package/dist/react-native/chunks/{module-QT5HZAY4.mjs → module-ZL5ZG6YB.mjs} +20 -19
  243. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +5 -0
  244. package/dist/react-native/chunks/{phrase-module-JZ37TB7N.mjs → phrase-module-RTVKEWJT.mjs} +1 -1
  245. package/dist/react-native/chunks/{pool-RTGXJXPU.mjs → pool-JR3NJCAF.mjs} +1 -1
  246. package/dist/react-native/chunks/restore-hooks-SILFPU6B.mjs +125 -0
  247. package/dist/react-native/chunks/restore-queue-HSYP2AEC.mjs +55 -0
  248. package/dist/react-native/chunks/{retention-PPCTP2VY.mjs → retention-7I7UAWYK.mjs} +21 -19
  249. package/dist/react-native/chunks/{runtime-KUATOLYB.mjs → runtime-R5E3TB3J.mjs} +1 -1
  250. package/dist/react-native/chunks/{snapshot-ZBIEOZTZ.mjs → snapshot-EZYB6SLF.mjs} +70 -36
  251. package/dist/react-native/chunks/start-SHVZ72I5.mjs +36 -0
  252. package/dist/react-native/chunks/{write-2W4FTX7J.mjs → write-JUESXHDL.mjs} +20 -19
  253. package/dist/react-native/partial-words.mjs +7 -6
  254. package/dist/react-native/pattern.mjs +3 -3
  255. package/dist/react-native/query-suggestions.mjs +258 -0
  256. package/dist/react-native/sync.mjs +76 -13
  257. package/dist/react-native/synonyms.mjs +4 -4
  258. package/dist/react.d.ts +11 -11
  259. package/dist/react.mjs +1 -0
  260. package/dist/{rerank-IZOB6NII.mjs → rerank-MQ37IYRV.mjs} +4 -4
  261. package/dist/rerankers/http.mjs +2 -2
  262. package/dist/restore-hooks-HZ3ILAMO.mjs +146 -0
  263. package/dist/restore-queue-JVGENGGE.mjs +55 -0
  264. package/dist/{retention-55WA7GPU.mjs → retention-HROPV2QU.mjs} +33 -32
  265. package/dist/{runtime-UZOC3NPY.mjs → runtime-COIUORCN.mjs} +5 -5
  266. package/dist/{schema-DDauvDOv.d.ts → schema-Jwt928nJ.d.ts} +1 -1
  267. package/dist/server.d.ts +108 -12
  268. package/dist/server.mjs +293 -46
  269. package/dist/{snapshot-NFX2EYN2.mjs → snapshot-4HS2G2UM.mjs} +85 -54
  270. package/dist/start-UTWHGH42.mjs +59 -0
  271. package/dist/sync/filesystem.d.ts +4 -4
  272. package/dist/sync/filesystem.mjs +4 -4
  273. package/dist/sync/indexeddb.d.ts +4 -4
  274. package/dist/sync/indexeddb.mjs +2 -2
  275. package/dist/sync.browser.mjs +74 -11
  276. package/dist/sync.d.ts +5 -5
  277. package/dist/sync.mjs +76 -14
  278. package/dist/synonyms.mjs +5 -5
  279. package/dist/{tasks-BShx8pdK.d.ts → tasks-qrJojgST.d.ts} +13 -5
  280. package/dist/{thread-P2G2FWM2.mjs → thread-6MOXY2KD.mjs} +24 -23
  281. package/dist/{types-SnO7_tAI.d.ts → types-BZCGjfLn.d.ts} +2 -3
  282. package/dist/vector/search-worker.d.ts +1 -1
  283. package/dist/vector/search-worker.mjs +5 -5
  284. package/dist/workers/entry.mjs +8 -8
  285. package/dist/{write-FGB62BHQ.mjs → write-GTTWWRRG.mjs} +30 -30
  286. package/openapi.json +798 -7
  287. package/package.json +24 -7
  288. package/dist/browser/operations-WVYLF72Q.mjs +0 -5
  289. package/dist/browser/restore-queue-TYIGDL5L.mjs +0 -41
  290. package/dist/engine-DYu-e0oR.d.ts +0 -674
  291. package/dist/operations-PGOAY2KS.mjs +0 -5
  292. package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +0 -25
  293. package/dist/react-native/chunks/gzip.react-native-DNB5YNFA.mjs +0 -3
  294. package/dist/react-native/chunks/import-JYBMEJPQ.mjs +0 -29
  295. package/dist/react-native/chunks/operations-RYKTSZQA.mjs +0 -5
  296. package/dist/react-native/chunks/restore-queue-ZBVIKJWI.mjs +0 -41
  297. package/dist/restore-queue-COI2GSSK.mjs +0 -41
@@ -0,0 +1,151 @@
1
+ // src/persistence/durability/sha256.ts
2
+ var ROUND_CONSTANTS = new Uint32Array([
3
+ 1116352408,
4
+ 1899447441,
5
+ 3049323471,
6
+ 3921009573,
7
+ 961987163,
8
+ 1508970993,
9
+ 2453635748,
10
+ 2870763221,
11
+ 3624381080,
12
+ 310598401,
13
+ 607225278,
14
+ 1426881987,
15
+ 1925078388,
16
+ 2162078206,
17
+ 2614888103,
18
+ 3248222580,
19
+ 3835390401,
20
+ 4022224774,
21
+ 264347078,
22
+ 604807628,
23
+ 770255983,
24
+ 1249150122,
25
+ 1555081692,
26
+ 1996064986,
27
+ 2554220882,
28
+ 2821834349,
29
+ 2952996808,
30
+ 3210313671,
31
+ 3336571891,
32
+ 3584528711,
33
+ 113926993,
34
+ 338241895,
35
+ 666307205,
36
+ 773529912,
37
+ 1294757372,
38
+ 1396182291,
39
+ 1695183700,
40
+ 1986661051,
41
+ 2177026350,
42
+ 2456956037,
43
+ 2730485921,
44
+ 2820302411,
45
+ 3259730800,
46
+ 3345764771,
47
+ 3516065817,
48
+ 3600352804,
49
+ 4094571909,
50
+ 275423344,
51
+ 430227734,
52
+ 506948616,
53
+ 659060556,
54
+ 883997877,
55
+ 958139571,
56
+ 1322822218,
57
+ 1537002063,
58
+ 1747873779,
59
+ 1955562222,
60
+ 2024104815,
61
+ 2227730452,
62
+ 2361852424,
63
+ 2428436474,
64
+ 2756734187,
65
+ 3204031479,
66
+ 3329325298
67
+ ]);
68
+ var SHA256_INITIAL_STATE = [
69
+ 1779033703,
70
+ 3144134277,
71
+ 1013904242,
72
+ 2773480762,
73
+ 1359893119,
74
+ 2600822924,
75
+ 528734635,
76
+ 1541459225
77
+ ];
78
+ var SHA256_BLOCK_BYTES = 64;
79
+ var LENGTH_BYTES = 8;
80
+ function rotateRight(value, bits) {
81
+ return value >>> bits | value << 32 - bits;
82
+ }
83
+ function paddedSha256Message(bytes, precedingBytes = 0) {
84
+ const total = Math.ceil((bytes.byteLength + 1 + LENGTH_BYTES) / SHA256_BLOCK_BYTES) * SHA256_BLOCK_BYTES;
85
+ const message = new Uint8Array(total);
86
+ message.set(bytes);
87
+ message[bytes.byteLength] = 128;
88
+ const view = new DataView(message.buffer);
89
+ const bitLength = (precedingBytes + bytes.byteLength) * 8;
90
+ view.setUint32(total - LENGTH_BYTES, Math.floor(bitLength / 4294967296), false);
91
+ view.setUint32(total - 4, bitLength >>> 0, false);
92
+ return view;
93
+ }
94
+ function compressSha256Block(state, view, block, words) {
95
+ for (let i = 0; i < 16; i++) words[i] = view.getUint32(block + i * 4, false);
96
+ for (let i = 16; i < 64; i++) {
97
+ const w15 = words[i - 15];
98
+ const w2 = words[i - 2];
99
+ const s0 = rotateRight(w15, 7) ^ rotateRight(w15, 18) ^ w15 >>> 3;
100
+ const s1 = rotateRight(w2, 17) ^ rotateRight(w2, 19) ^ w2 >>> 10;
101
+ words[i] = words[i - 16] + s0 + words[i - 7] + s1 >>> 0;
102
+ }
103
+ let a = state[0];
104
+ let b = state[1];
105
+ let c = state[2];
106
+ let d = state[3];
107
+ let e = state[4];
108
+ let f = state[5];
109
+ let g = state[6];
110
+ let h = state[7];
111
+ for (let i = 0; i < 64; i++) {
112
+ const s1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
113
+ const choice = e & f ^ ~e & g;
114
+ const t1 = h + s1 + choice + ROUND_CONSTANTS[i] + words[i] >>> 0;
115
+ const s0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
116
+ const majority = a & b ^ a & c ^ b & c;
117
+ const t2 = s0 + majority >>> 0;
118
+ h = g;
119
+ g = f;
120
+ f = e;
121
+ e = d + t1 >>> 0;
122
+ d = c;
123
+ c = b;
124
+ b = a;
125
+ a = t1 + t2 >>> 0;
126
+ }
127
+ state[0] = state[0] + a >>> 0;
128
+ state[1] = state[1] + b >>> 0;
129
+ state[2] = state[2] + c >>> 0;
130
+ state[3] = state[3] + d >>> 0;
131
+ state[4] = state[4] + e >>> 0;
132
+ state[5] = state[5] + f >>> 0;
133
+ state[6] = state[6] + g >>> 0;
134
+ state[7] = state[7] + h >>> 0;
135
+ }
136
+ function sha256Digest(state) {
137
+ const digest = new Uint8Array(32);
138
+ const out = new DataView(digest.buffer);
139
+ for (let i = 0; i < 8; i++) out.setUint32(i * 4, state[i], false);
140
+ return digest;
141
+ }
142
+ function sha256(bytes) {
143
+ const view = paddedSha256Message(bytes);
144
+ const state = Uint32Array.from(SHA256_INITIAL_STATE);
145
+ const words = new Uint32Array(64);
146
+ for (let block = 0; block < view.byteLength; block += SHA256_BLOCK_BYTES)
147
+ compressSha256Block(state, view, block, words);
148
+ return sha256Digest(state);
149
+ }
150
+
151
+ export { SHA256_BLOCK_BYTES, SHA256_INITIAL_STATE, compressSha256Block, paddedSha256Message, sha256, sha256Digest };
@@ -39,6 +39,7 @@ var ErrorCodes = {
39
39
  SYNC_NOT_READY: "SYNC_NOT_READY",
40
40
  SYNC_NOT_ENABLED: "SYNC_NOT_ENABLED",
41
41
  SYNC_SNAPSHOT_PREPARING: "SYNC_SNAPSHOT_PREPARING",
42
+ QUERY_SUGGESTIONS_NOT_ENABLED: "QUERY_SUGGESTIONS_NOT_ENABLED",
42
43
  SEARCH_INVALID_FIELD: "SEARCH_INVALID_FIELD",
43
44
  VECTOR_DIMENSION_MISMATCH: "VECTOR_DIMENSION_MISMATCH",
44
45
  SEARCH_INVALID_FILTER: "SEARCH_INVALID_FILTER",
@@ -0,0 +1,216 @@
1
+ import { suggestionsIndexName, markedSuggestionIndexes, ensureSuggestionsIndex, suggestionDocument, ORIGIN_MANUAL, removeSuggestions, enabledSetting, mergeHistory, groupsToWrite, meetsMinResults } from './chunk-3HHQLEEQ.mjs';
2
+ import { normaliseBan, banListFromInput, withState } from './chunk-UZRZKNNZ.mjs';
3
+ import { invalidSetting, resolveSetting, validateSetting, requireFieldsInSchema } from './chunk-H4KHPLHJ.mjs';
4
+ import { isGroup, GROUP_FORMAT, acceptedPhrase } from './chunk-GQPTDQCL.mjs';
5
+ import { MAX_MANUAL_SUGGESTION_COUNT, MAX_SOURCE_INDEX_NAME_LENGTH, DEFAULT_PREVIEW_LIMIT, MAX_PREVIEW_LIMIT } from './chunk-5YNRKI2C.mjs';
6
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
7
+
8
+ // src/query-suggestions/preview.ts
9
+ function previewOrder(left, right) {
10
+ if (left.count !== right.count) return right.count - left.count;
11
+ if (left.group !== right.group) return left.group < right.group ? -1 : 1;
12
+ return left.query < right.query ? -1 : left.query > right.query ? 1 : 0;
13
+ }
14
+ async function previewBuild(ctx, indexName, max) {
15
+ const setting = enabledSetting(ctx.host, indexName);
16
+ const merged = await mergeHistory(ctx, indexName, setting, Date.now());
17
+ const { groups } = groupsToWrite(ctx, indexName, setting, merged.result);
18
+ const banned = new Set(ctx.host.view(indexName)?.state?.bannedQueries ?? []);
19
+ const candidates = [];
20
+ for (const group of groups) {
21
+ for (const { phrase, count } of merged.result.groups[group] ?? []) {
22
+ if (!banned.has(phrase)) candidates.push({ group, query: phrase, count });
23
+ }
24
+ }
25
+ candidates.sort(previewOrder);
26
+ const checked = /* @__PURE__ */ new Map();
27
+ const entries = [];
28
+ let next = 0;
29
+ while (next < candidates.length && entries.length < max) {
30
+ const candidate = candidates[next];
31
+ next += 1;
32
+ if (candidate === void 0) break;
33
+ let passes = checked.get(candidate.query);
34
+ if (passes === void 0) {
35
+ passes = await meetsMinResults(ctx, indexName, setting, candidate.query);
36
+ checked.set(candidate.query, passes);
37
+ }
38
+ if (passes) entries.push(candidate);
39
+ }
40
+ return { entries, truncated: next < candidates.length };
41
+ }
42
+
43
+ // src/query-suggestions/operations.ts
44
+ function requireView(runtime, indexName) {
45
+ const view = runtime.host.view(indexName);
46
+ if (view === null) {
47
+ throw new NarsilError(ErrorCodes.INDEX_NOT_FOUND, `Index "${indexName}" does not exist`, { indexName });
48
+ }
49
+ return view;
50
+ }
51
+ function requireSourceView(runtime, indexName) {
52
+ const view = requireView(runtime, indexName);
53
+ if (view.state?.querySuggestionsSource !== void 0) {
54
+ invalidSetting(`Index "${indexName}" is a suggestions index, so it takes no query suggestions of its own`, {
55
+ indexName
56
+ });
57
+ }
58
+ if (indexName.length > MAX_SOURCE_INDEX_NAME_LENGTH) {
59
+ invalidSetting(
60
+ `Index "${indexName}" has a name longer than ${MAX_SOURCE_INDEX_NAME_LENGTH} characters, which leaves no room for the names of its suggestions indexes`,
61
+ { indexName }
62
+ );
63
+ }
64
+ return view;
65
+ }
66
+ function requireAcceptable(runtime, indexName, setting) {
67
+ const view = requireSourceView(runtime, indexName);
68
+ requireFieldsInSchema(setting, view.schema);
69
+ if (!setting.enabled) return;
70
+ if (runtime.scrambler === null) {
71
+ invalidSetting("This engine has no query suggestions key, so it cannot turn the feature on", { indexName });
72
+ }
73
+ if (view.hasSync) {
74
+ invalidSetting(
75
+ `Index "${indexName}" has device sync on, and a device receives the whole index of one user while a suggestion comes from the searches of several people`,
76
+ { indexName }
77
+ );
78
+ }
79
+ }
80
+ async function updateSetting(runtime, indexName, raw) {
81
+ const setting = validateSetting(raw);
82
+ requireAcceptable(runtime, indexName, setting);
83
+ await runtime.host.updateState(indexName, (current) => {
84
+ requireAcceptable(runtime, indexName, setting);
85
+ return withState(current, { querySuggestions: setting });
86
+ });
87
+ if (!setting.enabled) await runtime.discardHistory(indexName);
88
+ runtime.settingChanged(indexName);
89
+ }
90
+ async function status(runtime, indexName) {
91
+ const view = requireView(runtime, indexName);
92
+ return {
93
+ indexName,
94
+ setting: view.state?.querySuggestions ?? null,
95
+ lastBuild: await runtime.builds.lastBuild(indexName),
96
+ nextBuildAt: runtime.timers.nextBuildAt(indexName),
97
+ suggestionIndexes: [...markedSuggestionIndexes(runtime.host, indexName).values()].sort()
98
+ };
99
+ }
100
+ function previewLimitOf(limit) {
101
+ if (limit === void 0) return DEFAULT_PREVIEW_LIMIT;
102
+ if (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 1 || limit > MAX_PREVIEW_LIMIT) {
103
+ invalidSetting(`The preview limit must be a whole number from 1 to ${MAX_PREVIEW_LIMIT}`);
104
+ }
105
+ return limit;
106
+ }
107
+ async function preview(runtime, indexName, limit) {
108
+ const max = previewLimitOf(limit);
109
+ runtime.enabledSetting(indexName);
110
+ const scrambler = runtime.scrambler;
111
+ if (scrambler === null) invalidSetting("This engine has no query suggestions key, so it holds no counts");
112
+ const context = {
113
+ host: runtime.host,
114
+ scrambler,
115
+ saveDay: (name) => runtime.saveDay(name),
116
+ withWriteLock: (name, work) => runtime.withWriteLock(name, work),
117
+ isStopping: () => runtime.isStopping
118
+ };
119
+ return previewBuild(context, indexName, max);
120
+ }
121
+ async function banPhrases(runtime, indexName, next) {
122
+ requireSourceView(runtime, indexName);
123
+ let added = [];
124
+ let stored = [];
125
+ await runtime.host.updateState(indexName, (current) => {
126
+ requireSourceView(runtime, indexName);
127
+ const previous = current?.bannedQueries ?? [];
128
+ stored = next(previous);
129
+ const before = new Set(previous);
130
+ added = stored.filter((phrase) => !before.has(phrase));
131
+ return withState(current, { bannedQueries: stored });
132
+ });
133
+ return { stored, added };
134
+ }
135
+ async function removeFromSuggestions(runtime, indexName, phrases) {
136
+ let holders = 0;
137
+ if (phrases.length === 0) return holders;
138
+ for (const name of markedSuggestionIndexes(runtime.host, indexName).values()) {
139
+ if (await removeSuggestions(runtime.host, name, phrases) > 0) holders += 1;
140
+ }
141
+ return holders;
142
+ }
143
+ function updateBans(runtime, indexName, raw) {
144
+ const phrases = banListFromInput(raw);
145
+ return runtime.withWriteLock(indexName, async () => {
146
+ const { stored, added } = await banPhrases(runtime, indexName, () => phrases);
147
+ await removeFromSuggestions(runtime, indexName, added);
148
+ return stored;
149
+ });
150
+ }
151
+ function removeQuery(runtime, indexName, raw) {
152
+ const phrase = normaliseBan(raw);
153
+ return runtime.withWriteLock(indexName, async () => {
154
+ await banPhrases(runtime, indexName, (current) => current.includes(phrase) ? [...current] : [...current, phrase]);
155
+ return removeFromSuggestions(runtime, indexName, [phrase]);
156
+ });
157
+ }
158
+ function manualCountOf(count) {
159
+ if (count === void 0) return 0;
160
+ if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0 || count > MAX_MANUAL_SUGGESTION_COUNT) {
161
+ invalidSetting(`A suggestion's count must be a whole number from 0 to ${MAX_MANUAL_SUGGESTION_COUNT}`);
162
+ }
163
+ return count;
164
+ }
165
+ function addSuggestion(runtime, indexName, raw) {
166
+ const { group, query, count } = raw ?? {};
167
+ if (!isGroup(group)) invalidSetting(`A suggestion needs a group of ${GROUP_FORMAT}`);
168
+ if (typeof query !== "string") invalidSetting("A suggestion needs its query as a string");
169
+ const documentCount = manualCountOf(count);
170
+ return runtime.withWriteLock(indexName, async () => {
171
+ const view = requireSourceView(runtime, indexName);
172
+ const setting = resolveSetting(view.state?.querySuggestions ?? { enabled: false, fields: [] });
173
+ const phrase = acceptedPhrase(query, setting);
174
+ if (phrase === null) invalidSetting("The suggestion is not a phrase that the setting of the index accepts");
175
+ if ((view.state?.bannedQueries ?? []).includes(phrase)) {
176
+ invalidSetting("The ban list of the index holds this phrase", { indexName });
177
+ }
178
+ const marked = markedSuggestionIndexes(runtime.host, indexName);
179
+ if (!marked.has(group) && marked.size >= setting.maxGroups) {
180
+ invalidSetting(`Index "${indexName}" already has ${setting.maxGroups} groups`, { indexName });
181
+ }
182
+ const name = await ensureSuggestionsIndex(runtime.host, indexName, group);
183
+ const document = suggestionDocument(phrase, documentCount, ORIGIN_MANUAL);
184
+ if (await runtime.host.engine.has(name, phrase)) await runtime.host.engine.update(name, phrase, document);
185
+ else await runtime.host.engine.insert(name, document);
186
+ return name;
187
+ });
188
+ }
189
+ function querySuggestionsOf(runtime) {
190
+ return {
191
+ recordQuery: async (indexName, query) => (await runtime()).record(indexName, query),
192
+ updateSetting: async (indexName, setting) => updateSetting(await runtime(), indexName, setting),
193
+ status: async (indexName) => status(await runtime(), indexName),
194
+ build: async (indexName) => (await runtime()).builds.start(indexName, "caller"),
195
+ preview: async (indexName, limit) => preview(await runtime(), indexName, limit),
196
+ bans: async (indexName) => [...requireView(await runtime(), indexName).state?.bannedQueries ?? []],
197
+ updateBans: async (indexName, phrases) => updateBans(await runtime(), indexName, phrases),
198
+ removeQuery: async (indexName, query) => removeQuery(await runtime(), indexName, query),
199
+ addSuggestion: async (indexName, suggestion) => addSuggestion(await runtime(), indexName, suggestion),
200
+ suggestionsIndexName: (indexName, group) => {
201
+ if (!isGroup(group)) invalidSetting(`A group holds ${GROUP_FORMAT}`);
202
+ return suggestionsIndexName(indexName, group);
203
+ }
204
+ };
205
+ }
206
+
207
+ // src/query-suggestions/providers.ts
208
+ var providers = /* @__PURE__ */ new WeakMap();
209
+ function bindQuerySuggestions(owner, provide) {
210
+ providers.set(owner, provide);
211
+ }
212
+ function boundQuerySuggestionsOf(owner) {
213
+ return providers.get(owner);
214
+ }
215
+
216
+ export { bindQuerySuggestions, boundQuerySuggestionsOf, querySuggestionsOf };
@@ -1,5 +1,5 @@
1
1
  import { fnv1a } from './chunk-KAKQ74LS.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
3
3
 
4
4
  // src/persistence/durability/segment/layout.ts
5
5
  var SEGMENT_ID_WIDTH = 16;
@@ -1,4 +1,4 @@
1
- import { ReplicationMessageTypes } from './chunk-IQ4R2I6N.mjs';
1
+ import { ReplicationMessageTypes } from './chunk-5FLRXF73.mjs';
2
2
 
3
3
  // src/distribution/transport/reply-deadline.ts
4
4
  function replyDeadlineMs(messageType, config) {
@@ -1,11 +1,11 @@
1
- import { untagDocumentLine } from './chunk-CP5RRPJR.mjs';
2
- import { restoredConfigFields, restoredEmbedding } from './chunk-YBJDOA2T.mjs';
1
+ import { untagDocumentLine } from './chunk-TQXHPFWT.mjs';
2
+ import { restoredConfigFields, restoredEmbedding } from './chunk-INJYO3BU.mjs';
3
3
  import { chunksOf } from './chunk-CZQ33DLW.mjs';
4
4
  import { MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, MAX_IMPORT_REFUSALS_REPORTED } from './chunk-EEBCDP36.mjs';
5
- import { requireConfigurationShape } from './chunk-USR7FQRZ.mjs';
5
+ import { requireConfigurationShape } from './chunk-GH4WQ22V.mjs';
6
+ import { flattenSchema } from './chunk-WQRN64Q6.mjs';
6
7
  import { turnsAreBudgeted, turnIsSpent, yieldTurn } from './chunk-LQG5G2LY.mjs';
7
- import { flattenSchema } from './chunk-Z3TNWCI5.mjs';
8
- import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
8
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
9
9
 
10
10
  // src/engine/export/lines.ts
11
11
  var NEWLINE = 10;
@@ -0,0 +1,63 @@
1
+ import { attachedRuntimeOf } from './chunk-S5LN746F.mjs';
2
+ import { emitWriteEventAfter, dropEngineIndex } from './chunk-KMUNHGBQ.mjs';
3
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
4
+
5
+ // src/query-suggestions/engine-hooks.ts
6
+ function suggestionIndexesOf(core, sourceName) {
7
+ const names = [];
8
+ for (const [name, entry] of core.indexRegistry) {
9
+ if (name !== sourceName && entry.querySuggestions?.querySuggestionsSource?.index === sourceName) names.push(name);
10
+ }
11
+ return names;
12
+ }
13
+ async function dropSuggestionIndexesOf(core, sourceName) {
14
+ if (core.mutationCtx.capacityScope === "partition") return;
15
+ for (const name of suggestionIndexesOf(core, sourceName)) {
16
+ if (!core.indexRegistry.has(name)) continue;
17
+ await emitWriteEventAfter(core, name, dropEngineIndex(core, name));
18
+ }
19
+ }
20
+ async function clearLeftoversOfName(core, name) {
21
+ if (core.mutationCtx.capacityScope === "partition") return;
22
+ await dropSuggestionIndexesOf(core, name);
23
+ await core.durability?.manager.removeQueryHistory?.(name);
24
+ }
25
+ function hooksOf(core) {
26
+ return {
27
+ async beforeCreate(indexName) {
28
+ await clearLeftoversOfName(core, indexName);
29
+ if (core.indexRegistry.has(indexName)) {
30
+ throw new NarsilError(ErrorCodes.INDEX_ALREADY_EXISTS, `Index "${indexName}" already exists`, { indexName });
31
+ }
32
+ },
33
+ beforeDrop: (indexName) => dropSuggestionIndexesOf(core, indexName),
34
+ async afterDrop(indexName) {
35
+ await attachedRuntimeOf(core)?.onDrop(indexName);
36
+ },
37
+ async shutdown() {
38
+ await attachedRuntimeOf(core)?.stop().catch(() => void 0);
39
+ }
40
+ };
41
+ }
42
+ function installSuggestionHooks(core) {
43
+ core.querySuggestionHooks ??= hooksOf(core);
44
+ }
45
+ function holdsEnabledSetting(core) {
46
+ for (const entry of core.indexRegistry.values()) {
47
+ if (entry.querySuggestions?.querySuggestions?.enabled === true) return true;
48
+ }
49
+ return false;
50
+ }
51
+ async function startQuerySuggestions(core, engine, config) {
52
+ installSuggestionHooks(core);
53
+ if (config?.querySuggestions === void 0 && !holdsEnabledSetting(core)) return;
54
+ try {
55
+ const { localRuntimeOf } = await import('./start-UTWHGH42.mjs');
56
+ await localRuntimeOf(core, engine, config);
57
+ } catch (error) {
58
+ await engine.shutdown().catch(() => void 0);
59
+ throw error;
60
+ }
61
+ }
62
+
63
+ export { clearLeftoversOfName, dropSuggestionIndexesOf, installSuggestionHooks, startQuerySuggestions };
@@ -1,5 +1,5 @@
1
- import { ARCHIVE_CONFIG_ENTRY, ARCHIVE_MANIFEST_ENTRY, tarEntryHeaders, tarPadding, tarEnd, ARCHIVE_ENTRY_ESTIMATE_BYTES, ARCHIVE_FILE_CHUNK_BYTES } from './chunk-5KGYQT6W.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
1
+ import { ARCHIVE_CONFIG_ENTRY, ARCHIVE_MANIFEST_ENTRY, tarEntryHeaders, tarPadding, tarEnd, ARCHIVE_ENTRY_ESTIMATE_BYTES, ARCHIVE_FILE_CHUNK_BYTES } from './chunk-U4BS74YN.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
3
3
 
4
4
  // src/persistence/archive/range-layout.ts
5
5
  function archiveLayout(config, manifestBytes, files) {
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
1
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
2
2
  import { existsSync } from 'fs';
3
3
  import { createRequire } from 'module';
4
4
  import { join, dirname } from 'path';
@@ -1,11 +1,12 @@
1
- import { isValidInteger, isRecord } from './chunk-7HCZWC7B.mjs';
1
+ import { isValidInteger, isRecord } from './chunk-RSVULW4Q.mjs';
2
2
  import { isSyncEpoch } from './chunk-BUMREPLU.mjs';
3
3
  import { MAX_REPLICATION_FACTOR, MAX_PARTITION_COUNT } from './chunk-JDDXV6UF.mjs';
4
- import { packChecksummedEnvelope } from './chunk-LSM2YTKM.mjs';
5
- import { openChecksummedEnvelope } from './chunk-HVYICDY3.mjs';
6
- import { joinChunks } from './chunk-3Y3J4V2R.mjs';
4
+ import { MAX_HISTORY_FILE_BYTES } from './chunk-5YNRKI2C.mjs';
5
+ import { packChecksummedEnvelope } from './chunk-KMUNHGBQ.mjs';
6
+ import { openChecksummedEnvelope } from './chunk-3OH67G7R.mjs';
7
+ import { joinChunks } from './chunk-3C7MTCCI.mjs';
7
8
  import { MAX_FILE_BYTES } from './chunk-U476IXKQ.mjs';
8
- import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
9
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
9
10
  import { decode, encode } from '@msgpack/msgpack';
10
11
 
11
12
  // src/narsil/write-blocks.ts
@@ -65,6 +66,7 @@ var BACKUP_PROGRESS_REPORT_INTERVAL_MS = 1e3;
65
66
  var BACKUP_SWEEP_INTERVAL_MS = 3e4;
66
67
  var BACKUP_PUBLISH_RETRY_MS = 1e3;
67
68
  var MAX_BACKUP_FILES_PER_PARTITION = 1e6;
69
+ var MAX_BACKUP_HISTORY_FILES = 1e6;
68
70
  var MAX_BACKUP_FILE_PATH_LENGTH = 1024;
69
71
  var BACKUP_MANIFEST_READS_AT_ONCE = 8;
70
72
  var SYNC_BACKUPS_KEPT = 2;
@@ -213,9 +215,21 @@ function validateManifest(raw, backupName) {
213
215
  replicationFactor: raw.replicationFactor,
214
216
  constraints,
215
217
  config: readStoredFile(raw.config, backupName),
218
+ ...readQueryHistory(raw.queryHistory, backupName),
216
219
  partitions
217
220
  };
218
221
  }
222
+ function readQueryHistory(value, backupName) {
223
+ if (value === void 0) return {};
224
+ if (!Array.isArray(value) || value.length > MAX_BACKUP_HISTORY_FILES) {
225
+ throw damaged(backupName, "holds a malformed query history list");
226
+ }
227
+ const files = value.map((entry) => readStoredFile(entry, backupName));
228
+ if (files.some((file) => file.bytes > MAX_HISTORY_FILE_BYTES)) {
229
+ throw damaged(backupName, `lists a query history file longer than ${MAX_HISTORY_FILE_BYTES} bytes`);
230
+ }
231
+ return { queryHistory: files };
232
+ }
219
233
  async function decodeBackupManifest(bytes, backupName) {
220
234
  let raw;
221
235
  try {
@@ -235,7 +249,7 @@ async function encodeBackupManifest(manifest) {
235
249
  return joinChunks(packed.chunks, packed.byteLength);
236
250
  }
237
251
  function storedFilesOf(manifest) {
238
- const files = [manifest.config];
252
+ const files = [manifest.config, ...manifest.queryHistory ?? []];
239
253
  for (const partition of manifest.partitions) files.push(partition.manifest, ...partition.files);
240
254
  return files;
241
255
  }
@@ -1,7 +1,7 @@
1
- import { oneSyncChangeAtATime } from './chunk-V6EUBAIT.mjs';
2
1
  import { newSyncEpoch } from './chunk-BUMREPLU.mjs';
2
+ import { oneSyncChangeAtATime } from './chunk-V6EUBAIT.mjs';
3
3
  import { withOpenIndex, emitSyncChange } from './chunk-Y4WPNHMC.mjs';
4
- import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
4
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
5
5
 
6
6
  // src/engine/sync/operations.ts
7
7
  function invalidLimit(name, value) {
@@ -26,6 +26,14 @@ function requireSyncSetting(setting) {
26
26
  ...historyMaxBytes !== void 0 ? { historyMaxBytes } : {}
27
27
  };
28
28
  }
29
+ function requireNoQuerySuggestions(state, indexName) {
30
+ if (state?.querySuggestions?.enabled !== true) return;
31
+ throw new NarsilError(
32
+ ErrorCodes.CONFIG_INVALID,
33
+ `Index "${indexName}" has popular query suggestions on, so it cannot sync to devices: a device receives the whole index of one user, while a suggestion comes from the searches of several people`,
34
+ { indexName }
35
+ );
36
+ }
29
37
  function syncStorageOf(core, indexName) {
30
38
  const storage = core.durability?.manager.syncStorage?.();
31
39
  if (storage === void 0) {
@@ -56,6 +64,7 @@ function updateIndexSync(core, indexName, value) {
56
64
  core,
57
65
  indexName,
58
66
  () => oneSyncChangeAtATime(core.indexRegistry, indexName, async () => {
67
+ if (setting.enabled) requireNoQuerySuggestions(core.requireIndex(indexName).querySuggestions, indexName);
59
68
  const previous = core.requireIndex(indexName).sync;
60
69
  if (!setting.enabled) {
61
70
  if (previous === null) return;
@@ -99,4 +108,4 @@ function holdRenewedSyncEpoch(core, indexName) {
99
108
  });
100
109
  }
101
110
 
102
- export { holdRenewedSyncEpoch, requireSyncSetting, syncStorageOf, updateIndexSync };
111
+ export { holdRenewedSyncEpoch, requireNoQuerySuggestions, requireSyncSetting, syncStorageOf, updateIndexSync };
@@ -0,0 +1,30 @@
1
+ import { installSuggestionHooks } from './chunk-PHQNACDT.mjs';
2
+ import { attachedRuntimeOf, attachRuntime } from './chunk-S5LN746F.mjs';
3
+ import { keyBytesOf, QuerySuggestionsRuntime, createLocalHost } from './chunk-3HHQLEEQ.mjs';
4
+
5
+ // src/query-suggestions/start.ts
6
+ var starting = /* @__PURE__ */ new WeakMap();
7
+ async function startRuntime(core, engine, config) {
8
+ const keySetting = config?.querySuggestions?.key;
9
+ const key = keySetting === void 0 ? null : keyBytesOf(keySetting);
10
+ const runtime = new QuerySuggestionsRuntime(createLocalHost(core, engine, config), key);
11
+ attachRuntime(core, runtime);
12
+ installSuggestionHooks(core);
13
+ await runtime.start();
14
+ return runtime;
15
+ }
16
+ function localRuntimeOf(core, engine, config) {
17
+ const attached = attachedRuntimeOf(core);
18
+ if (attached !== void 0) return Promise.resolve(attached);
19
+ const pending = starting.get(core);
20
+ if (pending !== void 0) return pending;
21
+ const started = startRuntime(core, engine, config);
22
+ starting.set(core, started);
23
+ void started.then(
24
+ () => starting.delete(core),
25
+ () => starting.delete(core)
26
+ );
27
+ return started;
28
+ }
29
+
30
+ export { localRuntimeOf };