@delali/narsil 0.3.1-next.153 → 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 (330) hide show
  1. package/README.md +3 -1
  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-2OYM7ARW.mjs → analysis-change-3TFIHT5E.mjs} +32 -23
  7. package/dist/{react-native/chunks/analysis-change-entry-CXNRW324.mjs → analysis-change-entry-KA6JAO4X.mjs} +1 -1
  8. package/dist/archive-history-E4R73RWD.mjs +29 -0
  9. package/dist/browser/{analysis-change-2V2HZ2NY.mjs → analysis-change-TC36BU47.mjs} +39 -10
  10. package/dist/{analysis-change-entry-QD7YNDEE.mjs → browser/analysis-change-entry-4MH3CZXH.mjs} +1 -1
  11. package/dist/browser/archive-history-4IP5XQZY.mjs +29 -0
  12. package/dist/browser/chunk-23XRXIBW.mjs +85 -0
  13. package/dist/browser/chunk-3UIEB4QF.mjs +63 -0
  14. package/dist/browser/{chunk-CSCKZBVJ.mjs → chunk-4EWUGZYZ.mjs} +4 -4
  15. package/dist/browser/chunk-4WCVMOU3.mjs +151 -0
  16. package/dist/browser/{chunk-QJCO3TJU.mjs → chunk-56W3HQVJ.mjs} +9 -150
  17. package/dist/{react-native/chunks/chunk-VGUWIZFQ.mjs → browser/chunk-5TCXK5SB.mjs} +2 -2
  18. package/dist/browser/chunk-5W3MMTLG.mjs +19 -0
  19. package/dist/browser/chunk-7IGKGWSQ.mjs +79 -0
  20. package/dist/browser/chunk-A5KUEGDY.mjs +241 -0
  21. package/dist/browser/{chunk-HT7J73QL.mjs → chunk-ABCXENU5.mjs} +2 -2
  22. package/dist/browser/chunk-ATEBYXP6.mjs +10 -0
  23. package/dist/browser/chunk-BXM5XOCA.mjs +315 -0
  24. package/dist/browser/chunk-CJSYBQ4J.mjs +100 -0
  25. package/dist/browser/chunk-DSXIBE6N.mjs +78 -0
  26. package/dist/browser/chunk-ELV4OZOI.mjs +29 -0
  27. package/dist/{react-native/chunks/chunk-QC4ZRBSX.mjs → browser/chunk-EXQZGUQH.mjs} +2 -79
  28. package/dist/browser/{chunk-2A2IPRC3.mjs → chunk-FNIFPFB7.mjs} +5 -31
  29. package/dist/browser/chunk-G64Q6OJF.mjs +96 -0
  30. package/dist/browser/chunk-GPPOG6PT.mjs +9 -0
  31. package/dist/browser/chunk-IKDKX5VQ.mjs +1007 -0
  32. package/dist/browser/chunk-JIJXMI42.mjs +1829 -0
  33. package/dist/browser/chunk-JVBP5EYO.mjs +1106 -0
  34. package/dist/browser/{chunk-TQ5UMFG5.mjs → chunk-K4GCSZLI.mjs} +15 -6
  35. package/dist/browser/{chunk-PM4MUM5N.mjs → chunk-K5AXJBLL.mjs} +6 -5
  36. package/dist/browser/chunk-KKAMCABR.mjs +432 -0
  37. package/dist/browser/{chunk-IAXZAVYL.mjs → chunk-LFIWRCEA.mjs} +1 -159
  38. package/dist/browser/chunk-M3MQE2X7.mjs +151 -0
  39. package/dist/browser/chunk-ML7THVLJ.mjs +38 -0
  40. package/dist/browser/chunk-NLWTBAGB.mjs +111 -0
  41. package/dist/browser/chunk-OEDCEZXJ.mjs +92 -0
  42. package/dist/browser/{chunk-MPK76GVS.mjs → chunk-RA6LSBCM.mjs} +1 -21
  43. package/dist/browser/{chunk-GJKXW3SF.mjs → chunk-RND5CLX3.mjs} +147 -253
  44. package/dist/{react-native/chunks/chunk-DFQJ4IJB.mjs → browser/chunk-RQBUNZQW.mjs} +2 -2
  45. package/dist/browser/{chunk-VD7JEUIR.mjs → chunk-RRO3EV4C.mjs} +9 -8
  46. package/dist/browser/{chunk-KWYQ6KX4.mjs → chunk-SMEQ36NT.mjs} +162 -2019
  47. package/dist/{chunk-MDF6PDIA.mjs → browser/chunk-SRMZXJSL.mjs} +8 -1
  48. package/dist/browser/{chunk-7ZJTRUVW.mjs → chunk-SUDNZKPL.mjs} +2 -2
  49. package/dist/browser/{chunk-LURXVCHG.mjs → chunk-U3JOQGWX.mjs} +1 -1
  50. package/dist/browser/chunk-VI7BQR4U.mjs +21 -0
  51. package/dist/browser/{chunk-B3JM6Z74.mjs → chunk-XY4VVBBO.mjs} +3 -2
  52. package/dist/browser/chunk-YJHGOJAC.mjs +15 -0
  53. package/dist/browser/chunk-ZI2V4VD7.mjs +21 -0
  54. package/dist/browser/{cold-module-YECAK4MN.mjs → cold-module-NEUGHUPA.mjs} +21 -14
  55. package/dist/browser/durability-config-TIYKW6XX.mjs +89 -0
  56. package/dist/browser/{durability-wiring-LM7WFL6X.mjs → durability-wiring-CVGPRO6D.mjs} +1299 -881
  57. package/dist/browser/engine-hooks-YXMPHZKZ.mjs +16 -0
  58. package/dist/browser/import-OM6QAW45.mjs +18 -0
  59. package/dist/browser/methods-KTQCSIN4.mjs +30 -0
  60. package/dist/browser/{module-XQLEOYNM.mjs → module-3HNFCBJ5.mjs} +10 -8
  61. package/dist/browser/{module-KAMRAJLE.mjs → module-E33X4AOK.mjs} +17 -10
  62. package/dist/browser/operations-OJ3BXS55.mjs +5 -0
  63. package/dist/browser/{phrase-module-CNKMUY4U.mjs → phrase-module-ZXXU7S3B.mjs} +1 -1
  64. package/dist/browser/{pool-DTYSPBMQ.mjs → pool-3JLET5RO.mjs} +3 -2
  65. package/dist/browser/restore-hooks-IF2ZROUP.mjs +113 -0
  66. package/dist/browser/restore-queue-ZBS7CJA6.mjs +55 -0
  67. package/dist/browser/retention-ASWUHAYI.mjs +209 -0
  68. package/dist/browser/{runtime-D2ULZGCN.mjs → runtime-OTAGEFQW.mjs} +1 -1
  69. package/dist/browser/{snapshot-UGZVMP4H.mjs → snapshot-PN7ZW6Q4.mjs} +80 -315
  70. package/dist/browser/start-ZIRB7MQ2.mjs +24 -0
  71. package/dist/browser/sync-state-P5XG6LTQ.mjs +15 -0
  72. package/dist/browser/{write-I5P5MW4O.mjs → write-HMDYCTV2.mjs} +17 -11
  73. package/dist/{capabilities-BT-HLDC8.d.ts → capabilities-Da4ywVVl.d.ts} +94 -7
  74. package/dist/{chunk-LDGGR7YT.mjs → chunk-2MANFZJ3.mjs} +2 -2
  75. package/dist/{chunk-IZT3G24Q.mjs → chunk-2NE7VCYE.mjs} +2 -2
  76. package/dist/{chunk-3TVDTACC.mjs → chunk-3C7MTCCI.mjs} +1 -1
  77. package/dist/chunk-3HB3PEC6.mjs +240 -0
  78. package/dist/chunk-3HHQLEEQ.mjs +1092 -0
  79. package/dist/chunk-3OH67G7R.mjs +214 -0
  80. package/dist/{chunk-ZS6CMXAE.mjs → chunk-3R4UZWQG.mjs} +98 -250
  81. package/dist/{chunk-65WCV5JO.mjs → chunk-4BYWRYPM.mjs} +1 -1
  82. package/dist/{chunk-SOUZMPME.mjs → chunk-4KRC2APY.mjs} +7 -194
  83. package/dist/{chunk-5QMHMELB.mjs → chunk-5FLRXF73.mjs} +8 -1
  84. package/dist/chunk-5FVU47TB.mjs +20 -0
  85. package/dist/chunk-5YNRKI2C.mjs +81 -0
  86. package/dist/chunk-6L3XJXGU.mjs +470 -0
  87. package/dist/chunk-6MSZ543Y.mjs +32 -0
  88. package/dist/{chunk-T4CJDBBE.mjs → chunk-6OEGXLBX.mjs} +1 -1
  89. package/dist/{chunk-3SBJVQLL.mjs → chunk-6RC4K46J.mjs} +2 -2
  90. package/dist/chunk-7GXJUJ24.mjs +49 -0
  91. package/dist/{chunk-FNBNZCGP.mjs → chunk-AILVAOLX.mjs} +2 -2
  92. package/dist/chunk-BDRIVYOK.mjs +72 -0
  93. package/dist/chunk-BUMREPLU.mjs +15 -0
  94. package/dist/chunk-BY6ZDGYS.mjs +50 -0
  95. package/dist/{chunk-5WB2A3XU.mjs → chunk-DCNKVEDB.mjs} +511 -27
  96. package/dist/{chunk-NITCPDFL.mjs → chunk-DIBHI6W5.mjs} +2 -2
  97. package/dist/{chunk-4QCSHLNM.mjs → chunk-DUOLGBTE.mjs} +3 -3
  98. package/dist/chunk-GES7U2PM.mjs +68 -0
  99. package/dist/chunk-GH4WQ22V.mjs +34 -0
  100. package/dist/chunk-GQPTDQCL.mjs +54 -0
  101. package/dist/chunk-H4KHPLHJ.mjs +382 -0
  102. package/dist/{chunk-7TE2AJIH.mjs → chunk-H6VIGE62.mjs} +13 -10
  103. package/dist/{chunk-J7M73VY7.mjs → chunk-HJJI72X7.mjs} +1 -1
  104. package/dist/{chunk-DGRM4EZZ.mjs → chunk-HNVVEQP7.mjs} +1 -1
  105. package/dist/{chunk-RBEHLIKX.mjs → chunk-HW5TNXBO.mjs} +35 -11
  106. package/dist/{chunk-KYVRZAYP.mjs → chunk-I54T6CQP.mjs} +2 -69
  107. package/dist/{chunk-IRWP524D.mjs → chunk-INJYO3BU.mjs} +1 -1
  108. package/dist/chunk-IPN7S4KX.mjs +130 -0
  109. package/dist/{chunk-CSHHU7PA.mjs → chunk-J4IWBIVY.mjs} +11 -30
  110. package/dist/{chunk-G5KHSM6E.mjs → chunk-K4ZIGL2O.mjs} +1 -1
  111. package/dist/{chunk-6RKSY3BX.mjs → chunk-KBDBPVLN.mjs} +5 -5
  112. package/dist/{chunk-J4BDAH2W.mjs → chunk-KBKEXQZA.mjs} +2 -2
  113. package/dist/{chunk-IJSFWGVW.mjs → chunk-KFLK5NA2.mjs} +3 -3
  114. package/dist/{chunk-YGQOPB2Z.mjs → chunk-KHKIRS5D.mjs} +1 -1
  115. package/dist/chunk-KJ3RTZDJ.mjs +101 -0
  116. package/dist/{chunk-2PNYKG2D.mjs → chunk-KMUNHGBQ.mjs} +139 -432
  117. package/dist/chunk-KP7TYHWT.mjs +92 -0
  118. package/dist/{chunk-VP6XRMWR.mjs → chunk-KPIV4RUC.mjs} +6 -32
  119. package/dist/{chunk-NPXVQS33.mjs → chunk-KXCVQWOR.mjs} +4 -3
  120. package/dist/chunk-KYYABCSW.mjs +72 -0
  121. package/dist/{chunk-6F6USYII.mjs → chunk-L7ZD4L3K.mjs} +267 -265
  122. package/dist/{chunk-U46IZNCW.mjs → chunk-LC3FDWTX.mjs} +3 -2
  123. package/dist/{chunk-6BWLDLS3.mjs → chunk-LHKOSI2J.mjs} +1 -1
  124. package/dist/chunk-LNGE7SLY.mjs +151 -0
  125. package/dist/{react-native/chunks/chunk-YH7W556M.mjs → chunk-MP7ABPTD.mjs} +12 -2
  126. package/dist/chunk-MT2NRTA6.mjs +216 -0
  127. package/dist/chunk-NF4DT3IH.mjs +85 -0
  128. package/dist/{chunk-POUYICOU.mjs → chunk-OIJ64LGT.mjs} +1 -1
  129. package/dist/{chunk-SEAJS664.mjs → chunk-PCRA7HTI.mjs} +5 -5
  130. package/dist/chunk-PHQNACDT.mjs +63 -0
  131. package/dist/chunk-Q622CTMC.mjs +74 -0
  132. package/dist/{chunk-NVTFQFUL.mjs → chunk-Q7G3BV3Y.mjs} +1 -1
  133. package/dist/chunk-QDZJM7NI.mjs +23 -0
  134. package/dist/{chunk-52QQWEBS.mjs → chunk-QH3YIQP4.mjs} +36 -7
  135. package/dist/chunk-QJVOLKU6.mjs +111 -0
  136. package/dist/chunk-QUJHMPTP.mjs +30 -0
  137. package/dist/{chunk-3E4RRF5J.mjs → chunk-RSVULW4Q.mjs} +100 -8
  138. package/dist/{chunk-IJPK5PGM.mjs → chunk-RVGRFOGN.mjs} +1 -1
  139. package/dist/chunk-RZWWB2XR.mjs +96 -0
  140. package/dist/{chunk-KQJVNPRM.mjs → chunk-S2EQU2GE.mjs} +19 -16
  141. package/dist/chunk-S5LN746F.mjs +10 -0
  142. package/dist/{chunk-LJ4ENXOD.mjs → chunk-SG3JBNHY.mjs} +2 -2
  143. package/dist/{chunk-B2FTZNNF.mjs → chunk-SMVH6JBE.mjs} +34 -14
  144. package/dist/chunk-SY3EWKQY.mjs +242 -0
  145. package/dist/{chunk-NYSONUB7.mjs → chunk-TQXHPFWT.mjs} +1 -1
  146. package/dist/{chunk-ZHAXP7SD.mjs → chunk-U4BS74YN.mjs} +26 -238
  147. package/dist/chunk-UHICS3JI.mjs +83 -0
  148. package/dist/chunk-UZRZKNNZ.mjs +101 -0
  149. package/dist/chunk-V6EUBAIT.mjs +19 -0
  150. package/dist/{chunk-TTCKT2RT.mjs → chunk-VGF7CFRP.mjs} +134 -11
  151. package/dist/chunk-VHBNF4MA.mjs +543 -0
  152. package/dist/{chunk-AWNHDBKV.mjs → chunk-VQEUR6T6.mjs} +16 -8
  153. package/dist/chunk-WQRN64Q6.mjs +196 -0
  154. package/dist/{chunk-DMNPYF54.mjs → chunk-WZ7YV54N.mjs} +2 -2
  155. package/dist/chunk-Y4WPNHMC.mjs +50 -0
  156. package/dist/{chunk-2HJWQPR6.mjs → chunk-YEDIDCR7.mjs} +6 -122
  157. package/dist/chunk-YEKL4JBK.mjs +96 -0
  158. package/dist/{chunk-UGVUW27S.mjs → chunk-Z2BE2MAM.mjs} +14 -10
  159. package/dist/{chunk-3HV7M5OJ.mjs → chunk-ZAUJFLEN.mjs} +11 -135
  160. package/dist/{chunk-FDG4KXX5.mjs → chunk-ZHCUZZE5.mjs} +6 -4
  161. package/dist/chunk-ZTW5WTGG.mjs +167 -0
  162. package/dist/chunk-ZYAY26KG.mjs +29 -0
  163. package/dist/{client-Cn3gNxUU.d.ts → client-DRv7UVeY.d.ts} +193 -11
  164. package/dist/client.d.ts +9 -7
  165. package/dist/client.mjs +120 -7
  166. package/dist/{cold-module-PYSSBIL7.mjs → cold-module-7XXCEGTZ.mjs} +43 -33
  167. package/dist/config-CoSig5Ox.d.ts +482 -0
  168. package/dist/{config-CfhH1IWQ.d.ts → config-DMwffLKn.d.ts} +20 -5
  169. package/dist/{direct-executor-WYALQSMD.mjs → direct-executor-G5TK7NLA.mjs} +18 -13
  170. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  171. package/dist/distribution/coordinator/etcd.mjs +1 -1
  172. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  173. package/dist/distribution/transport/grpc.mjs +4 -4
  174. package/dist/distribution/transport/in-memory.mjs +2 -2
  175. package/dist/distribution/transport/tcp.mjs +3 -3
  176. package/dist/distribution.d.ts +41 -9
  177. package/dist/distribution.mjs +9304 -7271
  178. package/dist/durability-config-GE4U7MCZ.mjs +89 -0
  179. package/dist/{durability-wiring-7VBZEJLG.mjs → durability-wiring-NCKUC5EO.mjs} +1293 -872
  180. package/dist/embeddings/openai.mjs +2 -2
  181. package/dist/{config-aIsy7mcL.d.ts → engine-CFxPYqEk.d.ts} +716 -407
  182. package/dist/engine-hooks-DHCMOADY.mjs +47 -0
  183. package/dist/{import-GJOMB2HC.mjs → import-NBFXFCSG.mjs} +32 -24
  184. package/dist/{index-MsF7e5hL.d.ts → index-C4AmUnl1.d.ts} +1 -1
  185. package/dist/index.browser.mjs +9 -4
  186. package/dist/index.d.ts +7 -6
  187. package/dist/index.mjs +29 -21
  188. package/dist/index.react-native.mjs +19 -12
  189. package/dist/{long-query-thread-SCUE62TO.mjs → long-query-thread-J4DVRM4A.mjs} +33 -19
  190. package/dist/methods-7IOINERF.mjs +30 -0
  191. package/dist/{module-6RLIKSZQ.mjs → module-DWKPBSMN.mjs} +38 -28
  192. package/dist/{module-AVQEIB7O.mjs → module-UN76TF7I.mjs} +14 -14
  193. package/dist/operations-G5EP6JPX.mjs +5 -0
  194. package/dist/{paged-partition-archive-KGRW366Y.mjs → paged-partition-archive-DPNWVSK2.mjs} +46 -31
  195. package/dist/partial-words.mjs +7 -5
  196. package/dist/pattern.mjs +4 -3
  197. package/dist/persistence/durability/checkpoint-worker.d.ts +16 -1
  198. package/dist/persistence/durability/checkpoint-worker.mjs +40 -29
  199. package/dist/{phrase-module-OUQIRUQU.mjs → phrase-module-ZI4WSQVH.mjs} +1 -1
  200. package/dist/{pool-UPV5PVPY.mjs → pool-Y4A46T36.mjs} +2 -2
  201. package/dist/query-suggestions/merge-worker.d.ts +55 -0
  202. package/dist/query-suggestions/merge-worker.mjs +81 -0
  203. package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
  204. package/dist/query-suggestions.browser.mjs +246 -0
  205. package/dist/query-suggestions.d.ts +20 -0
  206. package/dist/query-suggestions.mjs +62 -0
  207. package/dist/react-native/chunks/{analysis-change-DXPZRGWF.mjs → analysis-change-6BPDPH6K.mjs} +50 -19
  208. package/dist/{browser/analysis-change-entry-JL5U2N3Q.mjs → react-native/chunks/analysis-change-entry-JLL42PH6.mjs} +1 -1
  209. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +29 -0
  210. package/dist/react-native/chunks/chunk-3JIBF3XT.mjs +191 -0
  211. package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +1 -0
  212. package/dist/react-native/chunks/{chunk-UFNCLEQM.mjs → chunk-4DII3ZSM.mjs} +1 -1
  213. package/dist/react-native/chunks/{chunk-BRNAVOKP.mjs → chunk-4J74WHQM.mjs} +2 -2
  214. package/dist/react-native/chunks/chunk-4LCEN2IU.mjs +315 -0
  215. package/dist/react-native/chunks/{chunk-PU55IOG4.mjs → chunk-4Y53T4YE.mjs} +6 -190
  216. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +17 -0
  217. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +9 -0
  218. package/dist/react-native/chunks/chunk-6WA3C3DV.mjs +85 -0
  219. package/dist/react-native/chunks/chunk-7GRCBBME.mjs +63 -0
  220. package/dist/react-native/chunks/{chunk-2J2727V4.mjs → chunk-7PXRWYUU.mjs} +1 -1
  221. package/dist/{browser/chunk-VBX2TI5V.mjs → react-native/chunks/chunk-ALOIBXWN.mjs} +2 -2
  222. package/dist/react-native/chunks/{chunk-FS7BYE23.mjs → chunk-C3PTWYKT.mjs} +10 -153
  223. package/dist/react-native/chunks/{chunk-DKJTZ625.mjs → chunk-C5G6TJ7A.mjs} +2 -69
  224. package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +43 -0
  225. package/dist/react-native/chunks/{chunk-LRGWK367.mjs → chunk-CKNRFDTZ.mjs} +1 -1
  226. package/dist/react-native/chunks/chunk-CUH5F57W.mjs +242 -0
  227. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +10 -0
  228. package/dist/{browser/chunk-55WYRLDZ.mjs → react-native/chunks/chunk-DVDX4SDR.mjs} +2 -2
  229. package/dist/{browser/chunk-PIS7ZAP7.mjs → react-native/chunks/chunk-DZ7H7D2C.mjs} +12 -2
  230. package/dist/react-native/chunks/{chunk-KOCTCUXW.mjs → chunk-EIOYM5TO.mjs} +17 -9
  231. package/dist/react-native/chunks/chunk-F753DA54.mjs +23 -0
  232. package/dist/react-native/chunks/chunk-GIZTJXYW.mjs +1007 -0
  233. package/dist/react-native/chunks/{chunk-CLE3LZ77.mjs → chunk-GJFXPHXI.mjs} +5 -4
  234. package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
  235. package/dist/react-native/chunks/{chunk-IDFMNRIC.mjs → chunk-HUOYZJ3Q.mjs} +140 -430
  236. package/dist/react-native/chunks/chunk-IYNT75CE.mjs +111 -0
  237. package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +38 -0
  238. package/dist/react-native/chunks/{chunk-LQAKO5QV.mjs → chunk-JLIIWJUV.mjs} +2 -2
  239. package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +15 -0
  240. package/dist/react-native/chunks/chunk-KJIG57UD.mjs +1106 -0
  241. package/dist/react-native/chunks/{chunk-KLZGAOLT.mjs → chunk-KTTAU63H.mjs} +5 -5
  242. package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +68 -0
  243. package/dist/{browser/chunk-NVEJJP4R.mjs → react-native/chunks/chunk-LZSLNSUN.mjs} +2 -79
  244. package/dist/react-native/chunks/{chunk-3CTWSQRW.mjs → chunk-MJDQU5MW.mjs} +4 -30
  245. package/dist/react-native/chunks/{chunk-NFGBOI46.mjs → chunk-MVXELMJX.mjs} +1 -1
  246. package/dist/react-native/chunks/{chunk-D7LFYPYI.mjs → chunk-N2WUOWLL.mjs} +12 -10
  247. package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +78 -0
  248. package/dist/react-native/chunks/{chunk-JYL35A4A.mjs → chunk-OL3WDV53.mjs} +7 -33
  249. package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +29 -0
  250. package/dist/react-native/chunks/{chunk-UCJU6WNH.mjs → chunk-PEHS2UO3.mjs} +7 -6
  251. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +79 -0
  252. package/dist/react-native/chunks/chunk-Q32DDFKX.mjs +19 -0
  253. package/dist/react-native/chunks/chunk-QJXTNPLQ.mjs +100 -0
  254. package/dist/react-native/chunks/{chunk-ZCKNBPQ4.mjs → chunk-RDWG33MM.mjs} +2 -2
  255. package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +96 -0
  256. package/dist/react-native/chunks/chunk-TYIRMPD3.mjs +432 -0
  257. package/dist/react-native/chunks/{chunk-TLYD7IJ2.mjs → chunk-U4KSKA4Z.mjs} +1 -1
  258. package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +68 -0
  259. package/dist/react-native/chunks/{chunk-7IQR3SZO.mjs → chunk-VXGE4ZXL.mjs} +151 -257
  260. package/dist/react-native/chunks/{chunk-R4OPUZQ5.mjs → chunk-WBYQRHDY.mjs} +2 -2
  261. package/dist/react-native/chunks/chunk-YH7QY657.mjs +288 -0
  262. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +92 -0
  263. package/dist/react-native/chunks/{cold-module-KFGEWYEL.mjs → cold-module-5PHF6DZR.mjs} +31 -22
  264. package/dist/react-native/chunks/durability-config-QXVZEO7T.mjs +89 -0
  265. package/dist/react-native/chunks/{durability-wiring-QKJB2QBT.mjs → durability-wiring-KO565FZC.mjs} +1309 -889
  266. package/dist/react-native/chunks/engine-hooks-MVRRHH6B.mjs +28 -0
  267. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +3 -0
  268. package/dist/react-native/chunks/import-YVZA4V4V.mjs +30 -0
  269. package/dist/react-native/chunks/methods-6W5U4C3H.mjs +30 -0
  270. package/dist/react-native/chunks/{module-UJ5VUARS.mjs → module-H5MVPSP2.mjs} +13 -11
  271. package/dist/react-native/chunks/module-ZL5ZG6YB.mjs +34 -0
  272. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +5 -0
  273. package/dist/react-native/chunks/{phrase-module-76UAPPSG.mjs → phrase-module-RTVKEWJT.mjs} +1 -1
  274. package/dist/react-native/chunks/{pool-CD4ANYUI.mjs → pool-JR3NJCAF.mjs} +3 -2
  275. package/dist/react-native/chunks/restore-hooks-SILFPU6B.mjs +125 -0
  276. package/dist/react-native/chunks/restore-queue-HSYP2AEC.mjs +55 -0
  277. package/dist/react-native/chunks/retention-7I7UAWYK.mjs +221 -0
  278. package/dist/react-native/chunks/{runtime-3MCDLJAF.mjs → runtime-R5E3TB3J.mjs} +1 -1
  279. package/dist/react-native/chunks/{snapshot-KVBD4LRC.mjs → snapshot-EZYB6SLF.mjs} +90 -323
  280. package/dist/react-native/chunks/start-SHVZ72I5.mjs +36 -0
  281. package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +15 -0
  282. package/dist/react-native/chunks/{write-ES5A3WUA.mjs → write-JUESXHDL.mjs} +27 -19
  283. package/dist/react-native/partial-words.mjs +8 -5
  284. package/dist/react-native/pattern.mjs +4 -3
  285. package/dist/react-native/query-suggestions.mjs +258 -0
  286. package/dist/react-native/sync.mjs +2299 -0
  287. package/dist/react-native/synonyms.mjs +7 -4
  288. package/dist/react.d.ts +11 -10
  289. package/dist/react.mjs +8 -1
  290. package/dist/{rerank-3W54N6P2.mjs → rerank-MQ37IYRV.mjs} +4 -4
  291. package/dist/rerankers/http.mjs +2 -2
  292. package/dist/restore-hooks-HZ3ILAMO.mjs +146 -0
  293. package/dist/restore-queue-JVGENGGE.mjs +55 -0
  294. package/dist/retention-HROPV2QU.mjs +59 -0
  295. package/dist/{runtime-L2DZYY6N.mjs → runtime-COIUORCN.mjs} +5 -5
  296. package/dist/{schema-D33CyXCy.d.ts → schema-Jwt928nJ.d.ts} +1 -1
  297. package/dist/server.d.ts +119 -20
  298. package/dist/server.mjs +1123 -58
  299. package/dist/{snapshot-WMX6JCLP.mjs → snapshot-4HS2G2UM.mjs} +106 -49
  300. package/dist/start-UTWHGH42.mjs +59 -0
  301. package/dist/sync/filesystem.d.ts +30 -0
  302. package/dist/sync/filesystem.mjs +271 -0
  303. package/dist/sync/indexeddb.d.ts +30 -0
  304. package/dist/sync/indexeddb.mjs +237 -0
  305. package/dist/sync-state-ZWHLAFLE.mjs +15 -0
  306. package/dist/sync.browser.mjs +2294 -0
  307. package/dist/sync.d.ts +23 -0
  308. package/dist/sync.mjs +2268 -0
  309. package/dist/synonyms.mjs +6 -4
  310. package/dist/{tasks-C4ElXr4P.d.ts → tasks-qrJojgST.d.ts} +13 -5
  311. package/dist/thread-6MOXY2KD.mjs +45 -0
  312. package/dist/types-BZCGjfLn.d.ts +227 -0
  313. package/dist/vector/search-worker.d.ts +1 -1
  314. package/dist/vector/search-worker.mjs +7 -7
  315. package/dist/workers/entry.mjs +8 -8
  316. package/dist/{write-SKJ6HW7O.mjs → write-GTTWWRRG.mjs} +36 -28
  317. package/openapi.json +912 -5
  318. package/package.json +45 -8
  319. package/dist/browser/import-QOY6ZH6X.mjs +0 -12
  320. package/dist/browser/restore-queue-UQ6AAUVX.mjs +0 -41
  321. package/dist/chunk-7LDMWKP6.mjs +0 -209
  322. package/dist/engine-CJRUHXgf.d.ts +0 -664
  323. package/dist/react-native/chunks/chunk-L4M7QJNP.mjs +0 -110
  324. package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +0 -25
  325. package/dist/react-native/chunks/gzip.react-native-7JWCLVOB.mjs +0 -3
  326. package/dist/react-native/chunks/import-XFBCCENV.mjs +0 -22
  327. package/dist/react-native/chunks/module-FHJ2GOBI.mjs +0 -25
  328. package/dist/react-native/chunks/restore-queue-H5VCN453.mjs +0 -41
  329. package/dist/restore-queue-AOF5OTQV.mjs +0 -41
  330. package/dist/thread-I7DVHHW7.mjs +0 -31
@@ -1,382 +1,22 @@
1
- import { fnv1a, createRequestId, FNV_OFFSET_BASIS, fnv1aContinue, isValidWorkerResponse, fnv1aContinueTaggedNumbers } from './chunk-MPK76GVS.mjs';
1
+ import { emitSyncChange, withOpenIndex, oneAtATime } from './chunk-ML7THVLJ.mjs';
2
+ import { createRequestId, isValidWorkerResponse } from './chunk-VI7BQR4U.mjs';
2
3
  import { DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS } from './chunk-JPTQZWJQ.mjs';
4
+ import { parsedTypeOf, flattenSchema, isSingleStringFieldType, partialFieldsOf, resolveIndexAnalysis, schemaFieldsOf, isWordIndexedBase, MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, requireWithinFileLimit, HEADER_SIZE, payloadByteLength, checksumOfChunks, packEnvelopeWithEngineVersion, INDEX_CONFIGURATION_ENVELOPE_VERSION, validateSchema, requireCreatableSchema, getLanguage, DEFAULT_PATTERN_VALUE_LIMIT, MAX_DOCUMENT_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, encodeDocument, isPlainObject, MAX_NESTING_DEPTH, extractVectorFieldsFromSchema, isWordIndexedFieldType, readHeapStatistics, VECTOR_PATTERN, parseFieldType, isStringValuedBase, withSortableOption, isGeopointOrVectorType, isListBase, MAX_DOCUMENT_BYTES } from './chunk-JIJXMI42.mjs';
5
+ import { fnv1a, FNV_OFFSET_BASIS, fnv1aContinue, fnv1aContinueTaggedNumbers } from './chunk-RA6LSBCM.mjs';
3
6
  import { TARGET_BLOCK_ENTRIES, bitsetHas, createBitSet, LOOKUP_KEY_SCRATCH_BYTES, GrowableUint32, SEGMENT_TOKEN_TABLE_START, SEGMENT_POSTING_LOG_START, SEGMENT_POSITION_POOL_START, SEGMENT_FIELD_SCRATCH_START, bitsetIsEmpty, bitsetSet, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, bitsetOrInto, bitsetAndNotInto, bitsetAndInto, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, SORT_COLUMN_REBUILD_FRACTION_SHIFT, bitsetFromSet } from './chunk-26A5JFT2.mjs';
4
- import { MAX_DOCUMENT_ENCODING_DEPTH, singleFoldTable, appendFoldedCodePoint, compareCodePoints, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, createDocIdMap, MAX_FILE_BYTES, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, CHECKSUM_YIELD_CHUNK_BYTES, detectRuntime, toReducedSortValue, compareComparableValues, defaultSortMode, resolveWorkerEntry, missingWorkerEntry, countWrite, holdsUnpairedSurrogate, readSortField, truncateSortString, exceedsCodePoints, turnIsSpent, yieldTurn, toComparableSortValue, SORT_VALUE_MAX_CODE_POINTS, compareComparableKeys, sortModeOf, isSortMode, SORT_MODES, MIN_OVERSAMPLE, compareSortValues, noteThreadSlotGone, threadSlotOfWorker, codePointCount, turnsAreBudgeted, indexChangeOutsideExternalWaits, changeIndexOutsideExternalWaits } from './chunk-IAXZAVYL.mjs';
5
- import { splitWorkerBudget, resolveWorkerCount, DEFAULT_REQUEST_TIMEOUT_MS, resolveRequestThreadCount, MAX_RENUMBERED_SEARCH_ATTEMPTS, SHUTDOWN_TIMEOUT_MS, DEFAULT_BACKPRESSURE_LIMIT, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH } from './chunk-TY7L6OXO.mjs';
6
- import { MAX_INDEX_CONFIGURATION_BYTES, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_SUGGEST_LIMIT, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_WARNING_FRACTION, DEFAULT_SUGGEST_LIMIT, DEFAULT_LIMIT, DEFAULT_OFFSET, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, BATCH_CHUNK_SIZE, MAX_DOC_ID_LENGTH } from './chunk-4RD3AFSB.mjs';
7
- import { DEFAULT_FUZZY_PREFIX_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, BM25_DISPLAYED_NAME_LENGTH, RESULT_WINDOW, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_PAGE_SIZE, DEFAULT_MAX_PER_GROUP, PREFIX_MAX_EXPANSIONS, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-WXLBZJMT.mjs';
8
- import { ErrorCodes, NarsilError, createNarsilError } from './chunk-PIS7ZAP7.mjs';
9
- import { Encoder, Decoder, decode, encode } from '@msgpack/msgpack';
10
-
11
- // src/analysis/registry.ts
12
- var tokenizers = /* @__PURE__ */ new Map();
13
- var stopWordSets = /* @__PURE__ */ new Map();
14
- function requireName(name, kind) {
15
- if (typeof name !== "string" || name.trim().length === 0) {
16
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `A registered ${kind} needs a non-empty name`, { name });
17
- }
18
- }
19
- function registerTokenizer(name, tokenizer) {
20
- requireName(name, "tokenizer");
21
- if (typeof tokenizer?.tokenize !== "function") {
22
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Tokenizer "${name}" needs a tokenize method`, { tokenizer: name });
23
- }
24
- tokenizers.set(name, tokenizer);
25
- }
26
- function registerStopWords(name, stopWords2) {
27
- requireName(name, "stop word set");
28
- if (!(stopWords2 instanceof Set) && typeof stopWords2 !== "function") {
29
- throw new NarsilError(
30
- ErrorCodes.CONFIG_INVALID,
31
- `Stop word set "${name}" needs a Set of words or a function returning one`,
32
- { stopWords: name }
33
- );
34
- }
35
- stopWordSets.set(name, stopWords2);
36
- }
37
- function hasTokenizer(name) {
38
- return tokenizers.has(name);
39
- }
40
- function hasStopWords(name) {
41
- return stopWordSets.has(name);
42
- }
43
- function getTokenizer(name) {
44
- const tokenizer = tokenizers.get(name);
45
- if (!tokenizer) {
46
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Tokenizer "${name}" is not registered on this engine`, {
47
- tokenizer: name,
48
- available: [...tokenizers.keys()]
49
- });
50
- }
51
- return tokenizer;
52
- }
53
- function getStopWords(name) {
54
- const stopWords2 = stopWordSets.get(name);
55
- if (!stopWords2) {
56
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Stop word set "${name}" is not registered on this engine`, {
57
- stopWords: name,
58
- available: [...stopWordSets.keys()]
59
- });
60
- }
61
- return stopWords2;
62
- }
63
- function holdsPositionsOutOfOrder(entries) {
64
- for (let index = 1; index < entries.length; index++) {
65
- if (entries[index].position < entries[index - 1].position) return true;
66
- }
67
- return false;
68
- }
69
- function inPositionOrder(tokenizer) {
70
- return {
71
- tokenize(text) {
72
- const entries = tokenizer.tokenize(text);
73
- if (!holdsPositionsOutOfOrder(entries)) return entries;
74
- return [...entries].sort((first, second) => first.position - second.position);
75
- }
76
- };
77
- }
78
- function resolveIndexAnalysis(config) {
79
- const tokenizer = typeof config.tokenizer === "string" ? getTokenizer(config.tokenizer) : config.tokenizer;
80
- return {
81
- stopWords: typeof config.stopWords === "string" ? getStopWords(config.stopWords) : config.stopWords,
82
- customTokenizer: tokenizer === void 0 ? void 0 : inPositionOrder(tokenizer)
83
- };
84
- }
7
+ import { createDocIdMap, turnsAreBudgeted, turnIsSpent, yieldTurn, indexChangeOutsideExternalWaits, changeIndexOutsideExternalWaits, detectRuntime, resolveWorkerEntry, missingWorkerEntry, countWrite, MIN_OVERSAMPLE, noteThreadSlotGone, threadSlotOfWorker } from './chunk-4WCVMOU3.mjs';
8
+ import { splitWorkerBudget, resolveWorkerCount, resolveRequestThreadCount, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RENUMBERED_SEARCH_ATTEMPTS, SHUTDOWN_TIMEOUT_MS, DEFAULT_BACKPRESSURE_LIMIT, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH } from './chunk-TY7L6OXO.mjs';
9
+ import { MAX_INDEX_CONFIGURATION_BYTES, BATCH_CHUNK_SIZE, MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, MAX_SUGGEST_LIMIT, FOREIGN_STATS_TTL_MS, DEFAULT_SUGGEST_LIMIT, DEFAULT_LIMIT, DEFAULT_OFFSET, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION } from './chunk-4RD3AFSB.mjs';
10
+ import { singleFoldTable, appendFoldedCodePoint, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, compareCodePoints, toReducedSortValue, compareComparableValues, defaultSortMode, holdsUnpairedSurrogate, readSortField, truncateSortString, exceedsCodePoints, toComparableSortValue, SORT_VALUE_MAX_CODE_POINTS, compareComparableKeys, sortModeOf, isSortMode, SORT_MODES, compareSortValues, codePointCount } from './chunk-LFIWRCEA.mjs';
11
+ import { BM25_DISPLAYED_NAME_LENGTH, DEFAULT_FUZZY_PREFIX_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, RESULT_WINDOW, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_PAGE_SIZE, DEFAULT_MAX_PER_GROUP, PREFIX_MAX_EXPANSIONS, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-WXLBZJMT.mjs';
12
+ import { ErrorCodes, NarsilError, createNarsilError } from './chunk-SRMZXJSL.mjs';
13
+ import { Decoder, decode, encode } from '@msgpack/msgpack';
85
14
 
86
15
  // src/core/partition/partial-words/platform.browser.ts
87
16
  function platformPartialWordSearch() {
88
17
  return null;
89
18
  }
90
19
 
91
- // src/schema/constants.ts
92
- var MAX_NESTING_DEPTH = 4;
93
- var MAX_DOCUMENT_NESTING_DEPTH = 32;
94
- var DEFAULT_PATTERN_VALUE_LIMIT = 8192;
95
- var MIN_PATTERN_VALUE_LIMIT = 1;
96
- var MAX_PATTERN_VALUE_LIMIT = 65536;
97
- var MAX_VECTOR_DIMENSION = 4096;
98
- var MAX_STORED_VECTOR_DIMENSION = 65535;
99
- var MAX_TEXT_FIELDS = 65536;
100
- var MAX_DOCUMENT_BYTES = 16777216;
101
- var PARSED_FIELD_TYPE_CACHE_ENTRIES = 1024;
102
-
103
- // src/schema/validator/shared.ts
104
- var VECTOR_PATTERN = /^vector\[(\d+)]$/;
105
- function isGeopointOrVectorType(fieldType) {
106
- return fieldType === "geopoint" || fieldType !== void 0 && VECTOR_PATTERN.test(fieldType);
107
- }
108
- var FIELD_NAME_PATTERN = /^[A-Za-z0-9_]+$/;
109
- var RESERVED_ROOT_FIELDS = /* @__PURE__ */ new Set(["id"]);
110
- var PROTOTYPE_POLLUTION_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
111
- function isPlainObject(value) {
112
- return typeof value === "object" && value !== null && !Array.isArray(value);
113
- }
114
-
115
- // src/schema/validator/field-type.ts
116
- var FIELD_OPTION_ORDER = ["sortable", "pattern", "partial"];
117
- var OPTIONS_BY_BASE = {
118
- string: FIELD_OPTION_ORDER,
119
- "string[]": FIELD_OPTION_ORDER,
120
- verbatim: ["sortable"],
121
- "verbatim[]": ["sortable"],
122
- number: [],
123
- "number[]": [],
124
- boolean: [],
125
- "boolean[]": [],
126
- enum: [],
127
- "enum[]": [],
128
- geopoint: [],
129
- vector: []
130
- };
131
- var TYPE_SEPARATOR = ":";
132
- function isNamedBase(name) {
133
- return name !== "vector" && Object.hasOwn(OPTIONS_BY_BASE, name);
134
- }
135
- function describeAllowedOptions(baseName, allowed) {
136
- if (allowed.length === 0) return `the "${baseName}" type has no options`;
137
- const quoted = allowed.map((option) => `"${option}"`);
138
- if (quoted.length === 1) return `the only option of the "${baseName}" type is ${quoted[0]}`;
139
- return `the options of the "${baseName}" type are ${quoted.slice(0, -1).join(", ")}, and ${quoted[quoted.length - 1]}`;
140
- }
141
- function invalidType(path, type, message) {
142
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, message, { field: path, type });
143
- }
144
- function parseBase(baseName, path, type) {
145
- if (isNamedBase(baseName)) return { base: baseName, dimension: 0 };
146
- const vectorMatch = VECTOR_PATTERN.exec(baseName);
147
- if (vectorMatch === null) {
148
- invalidType(path, type, `Field "${path}" has an unsupported type: "${type}"`);
149
- }
150
- const dimension = Number.parseInt(vectorMatch[1], 10);
151
- if (dimension <= 0 || dimension > MAX_STORED_VECTOR_DIMENSION) {
152
- throw new NarsilError(
153
- ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
154
- `Vector field "${path}" has ${dimension} dimensions, but a vector field holds from 1 to ${MAX_STORED_VECTOR_DIMENSION}`,
155
- { field: path, dimension, maximum: MAX_STORED_VECTOR_DIMENSION }
156
- );
157
- }
158
- return { base: "vector", dimension };
159
- }
160
- function parseFieldType(type, path) {
161
- const separatorIndex = type.indexOf(TYPE_SEPARATOR);
162
- const baseName = separatorIndex === -1 ? type : type.slice(0, separatorIndex);
163
- const { base, dimension } = parseBase(baseName, path, type);
164
- const allowed = OPTIONS_BY_BASE[base];
165
- const options = /* @__PURE__ */ new Set();
166
- if (separatorIndex !== -1) {
167
- for (const option of type.slice(separatorIndex + 1).split(TYPE_SEPARATOR)) {
168
- if (!allowed.includes(option)) {
169
- invalidType(
170
- path,
171
- type,
172
- `Field "${path}" has type "${type}" with the option "${option}", but ${describeAllowedOptions(baseName, allowed)}`
173
- );
174
- }
175
- if (options.has(option)) {
176
- invalidType(path, type, `Field "${path}" has the "${option}" option twice in type "${type}"`);
177
- }
178
- options.add(option);
179
- }
180
- }
181
- const ordered = FIELD_OPTION_ORDER.filter((option) => options.has(option));
182
- const verbatim = base === "verbatim" || base === "verbatim[]";
183
- return {
184
- type: [baseName, ...ordered].join(TYPE_SEPARATOR),
185
- base,
186
- sortable: options.has("sortable"),
187
- pattern: verbatim || options.has("pattern"),
188
- partial: options.has("partial"),
189
- dimension
190
- };
191
- }
192
- var parsedTypesByName = /* @__PURE__ */ new Map();
193
- function parsedTypeOf(type) {
194
- if (type === void 0) return void 0;
195
- const known = parsedTypesByName.get(type);
196
- if (known !== void 0) return known;
197
- try {
198
- const parsed = Object.freeze(parseFieldType(type, ""));
199
- if (parsedTypesByName.size < PARSED_FIELD_TYPE_CACHE_ENTRIES) parsedTypesByName.set(type, parsed);
200
- return parsed;
201
- } catch {
202
- return void 0;
203
- }
204
- }
205
- function withSortableOption(parsed) {
206
- if (parsed.sortable) return parsed.type;
207
- const separatorIndex = parsed.type.indexOf(TYPE_SEPARATOR);
208
- const baseName = separatorIndex === -1 ? parsed.type : parsed.type.slice(0, separatorIndex);
209
- return parseFieldType(`${baseName}${TYPE_SEPARATOR}sortable${parsed.type.slice(baseName.length)}`, "").type;
210
- }
211
- function isListBase(base) {
212
- return base.endsWith("[]");
213
- }
214
- function isWordIndexedBase(base) {
215
- return base === "string" || base === "string[]";
216
- }
217
- function isSingleStringFieldType(fieldType) {
218
- return parsedTypeOf(fieldType)?.base === "string";
219
- }
220
- function isWordIndexedFieldType(fieldType) {
221
- const parsed = parsedTypeOf(fieldType);
222
- return parsed !== void 0 && isWordIndexedBase(parsed.base);
223
- }
224
- function isStringValuedBase(base) {
225
- return base === "string" || base === "string[]" || base === "verbatim" || base === "verbatim[]";
226
- }
227
-
228
- // src/schema/validator/schema.ts
229
- function validateSchemaFields(schema, depth, prefix) {
230
- if (depth > MAX_NESTING_DEPTH) {
231
- throw new NarsilError(
232
- ErrorCodes.SCHEMA_DEPTH_EXCEEDED,
233
- `Schema nesting exceeds the maximum depth of ${MAX_NESTING_DEPTH} at "${prefix}"`,
234
- { path: prefix, maxDepth: MAX_NESTING_DEPTH }
235
- );
236
- }
237
- let canonical = null;
238
- const replace = (field, value) => {
239
- if (canonical === null) canonical = { ...schema };
240
- canonical[field] = value;
241
- };
242
- for (const [field, type] of Object.entries(schema)) {
243
- const path = prefix ? `${prefix}.${field}` : field;
244
- if (PROTOTYPE_POLLUTION_KEYS.has(field)) {
245
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, `Field name "${field}" is not allowed in a schema`, {
246
- field,
247
- path
248
- });
249
- }
250
- if (!FIELD_NAME_PATTERN.test(field)) {
251
- throw new NarsilError(
252
- ErrorCodes.SCHEMA_INVALID_TYPE,
253
- `Field name "${field}" contains characters that are not allowed; use letters, digits, and underscores only`,
254
- { field, path }
255
- );
256
- }
257
- if (depth === 1 && RESERVED_ROOT_FIELDS.has(field)) {
258
- throw new NarsilError(
259
- ErrorCodes.SCHEMA_INVALID_TYPE,
260
- `Field "${field}" is reserved and cannot be defined in a schema`,
261
- { field, path }
262
- );
263
- }
264
- if (isPlainObject(type)) {
265
- const nested = validateSchemaFields(type, depth + 1, path);
266
- if (nested !== type) replace(field, nested);
267
- continue;
268
- }
269
- if (typeof type !== "string") {
270
- throw new NarsilError(
271
- ErrorCodes.SCHEMA_INVALID_TYPE,
272
- `Field "${path}" has an invalid type definition: ${String(type)}`,
273
- {
274
- field: path,
275
- type: String(type)
276
- }
277
- );
278
- }
279
- const parsed = parseFieldType(type, path);
280
- if (parsed.type !== type) replace(field, parsed.type);
281
- }
282
- return canonical ?? schema;
283
- }
284
- function validateSchema(schema) {
285
- if (!isPlainObject(schema)) {
286
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must be a plain object", {
287
- received: typeof schema
288
- });
289
- }
290
- if (Object.keys(schema).length === 0) {
291
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must define at least one field");
292
- }
293
- const validated = validateSchemaFields(schema, 1, "");
294
- requireTextFieldCount(schemaFieldsOf(validated).filter((field) => isWordIndexedBase(field.base)).length);
295
- return validated;
296
- }
297
- function requireTextFieldCount(count) {
298
- if (count <= MAX_TEXT_FIELDS) return;
299
- throw new NarsilError(
300
- ErrorCodes.SCHEMA_INVALID_TYPE,
301
- `The schema declares ${count} string and string[] fields, but a schema holds at most ${MAX_TEXT_FIELDS}`,
302
- { textFields: count, maximum: MAX_TEXT_FIELDS }
303
- );
304
- }
305
- function requireCreatableSchema(schema) {
306
- for (const field of schemaFieldsOf(schema)) {
307
- if (field.base !== "vector" || field.dimension <= MAX_VECTOR_DIMENSION) continue;
308
- throw new NarsilError(
309
- ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
310
- `Vector field "${field.path}" has ${field.dimension} dimensions, but a new index takes at most ${MAX_VECTOR_DIMENSION}`,
311
- { field: field.path, dimension: field.dimension, maximum: MAX_VECTOR_DIMENSION }
312
- );
313
- }
314
- }
315
- function requireValidFieldTypes(flatSchema) {
316
- let textFields = 0;
317
- for (const [path, type] of Object.entries(flatSchema)) {
318
- if (typeof type !== "string") {
319
- throw new NarsilError(
320
- ErrorCodes.SCHEMA_INVALID_TYPE,
321
- `Field "${path}" has an invalid type definition: ${String(type)}`,
322
- { field: path, type: String(type) }
323
- );
324
- }
325
- if (isWordIndexedBase(parseFieldType(type, path).base)) textFields += 1;
326
- }
327
- requireTextFieldCount(textFields);
328
- }
329
- function flattenRecursive(schema, prefix, result) {
330
- for (const [field, type] of Object.entries(schema)) {
331
- const path = prefix ? `${prefix}.${field}` : field;
332
- if (isPlainObject(type)) {
333
- flattenRecursive(type, path, result);
334
- } else {
335
- result[path] = type;
336
- }
337
- }
338
- }
339
- var flattenedSchemas = /* @__PURE__ */ new WeakMap();
340
- function flattenSchema(schema) {
341
- const cached = flattenedSchemas.get(schema);
342
- if (cached !== void 0) return cached;
343
- const result = /* @__PURE__ */ Object.create(null);
344
- flattenRecursive(schema, "", result);
345
- flattenedSchemas.set(schema, Object.freeze(result));
346
- return result;
347
- }
348
- var parsedSchemas = /* @__PURE__ */ new WeakMap();
349
- function schemaFieldsOf(schema) {
350
- const cached = parsedSchemas.get(schema);
351
- if (cached !== void 0) return cached;
352
- const fields = [];
353
- for (const [path, type] of Object.entries(flattenSchema(schema))) {
354
- fields.push({ ...parseFieldType(type, path), path });
355
- }
356
- const frozen = Object.freeze(fields);
357
- parsedSchemas.set(schema, frozen);
358
- return frozen;
359
- }
360
- var partialFieldsBySchema = /* @__PURE__ */ new WeakMap();
361
- function partialFieldsOf(schema) {
362
- const cached = partialFieldsBySchema.get(schema);
363
- if (cached !== void 0) return cached;
364
- const paths = [];
365
- for (const field of schemaFieldsOf(schema)) {
366
- if (field.partial) paths.push(field.path);
367
- }
368
- const frozen = Object.freeze(paths.sort(compareCodePoints));
369
- partialFieldsBySchema.set(schema, frozen);
370
- return frozen;
371
- }
372
- function extractVectorFieldsFromSchema(schema) {
373
- const result = /* @__PURE__ */ new Map();
374
- for (const field of schemaFieldsOf(schema)) {
375
- if (field.base === "vector") result.set(field.path, field.dimension);
376
- }
377
- return result;
378
- }
379
-
380
20
  // src/core/partition/partial-words/registry.ts
381
21
  var registered = null;
382
22
  var MODULE_FUNCTIONS = [
@@ -716,8 +356,8 @@ function evictOldestEntries(count) {
716
356
  }
717
357
  }
718
358
  }
719
- function transformToken(raw, language, stem2, removeDiacritics) {
720
- const flags = (stem2 ? "s" : "") + (removeDiacritics ? "d" : "");
359
+ function transformToken(raw, language, stem, removeDiacritics) {
360
+ const flags = (stem ? "s" : "") + (removeDiacritics ? "d" : "");
721
361
  let bucket = getCacheBucket(language, flags);
722
362
  const cached = bucket.get(raw);
723
363
  if (cached !== void 0) return cached;
@@ -728,7 +368,7 @@ function transformToken(raw, language, stem2, removeDiacritics) {
728
368
  if (removeDiacritics) {
729
369
  normalized = stripDiacritics(normalized);
730
370
  }
731
- if (stem2 && language.stemmer) {
371
+ if (stem && language.stemmer) {
732
372
  normalized = language.stemmer(normalized);
733
373
  }
734
374
  if (normalizationCacheSize >= maxCacheSize) {
@@ -924,7 +564,7 @@ function stripPossessive(token) {
924
564
  }
925
565
  function visitTokens(text, language, options, visit) {
926
566
  const {
927
- stem: stem2 = true,
567
+ stem = true,
928
568
  removeStopWords = true,
929
569
  removeDiacritics = false,
930
570
  collectSurfaces = false,
@@ -938,14 +578,14 @@ function visitTokens(text, language, options, visit) {
938
578
  const rawParts = splitText(normalizeForSplitting(text), language);
939
579
  const minLength = language.tokenizer?.minTokenLength ?? DEFAULT_MIN_TOKEN_LENGTH;
940
580
  const effectiveDiacritics = removeDiacritics || (language.tokenizer?.normalizeDiacritics ?? false);
941
- const wantSurfaces = collectSurfaces && stem2 && language.stemmer !== null;
942
- const stopWords2 = removeStopWords ? resolveStopWords(language, stopWordOverride) : null;
581
+ const wantSurfaces = collectSurfaces && stem && language.stemmer !== null;
582
+ const stopWords = removeStopWords ? resolveStopWords(language, stopWordOverride) : null;
943
583
  const stripPossessives = language.tokenizer?.stripPossessive ?? false;
944
584
  for (let position = 0; position < rawParts.length; position++) {
945
585
  const part = rawParts[position];
946
586
  const candidate = stripPossessives ? stripPossessive(part) : part;
947
- if (candidate.length < minLength || stopWords2?.has(candidate)) continue;
948
- const processed = transformToken(candidate, language, stem2, effectiveDiacritics);
587
+ if (candidate.length < minLength || stopWords?.has(candidate)) continue;
588
+ const processed = transformToken(candidate, language, stem, effectiveDiacritics);
949
589
  if (processed.length === 0) continue;
950
590
  if (!wantSurfaces) {
951
591
  visit(processed, position, void 0, part);
@@ -982,1150 +622,6 @@ function tokenize(text, language, options) {
982
622
  return { tokens, originalTokens, surfaces };
983
623
  }
984
624
 
985
- // src/languages/snowball/base-stemmer.ts
986
- var BaseStemmer = class {
987
- current = "";
988
- c = 0;
989
- limit = 0;
990
- limit_backward = 0;
991
- bra = 0;
992
- ket = 0;
993
- af = 0;
994
- setCurrent(value) {
995
- this.current = value;
996
- this.c = 0;
997
- this.limit = this.current.length;
998
- this.limit_backward = 0;
999
- this.bra = 0;
1000
- this.ket = 0;
1001
- }
1002
- getCurrent() {
1003
- return this.current;
1004
- }
1005
- in_grouping(s, min, max) {
1006
- if (this.c >= this.limit) return false;
1007
- let ch = this.current.charCodeAt(this.c);
1008
- if (ch > max || ch < min) return false;
1009
- ch -= min;
1010
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return false;
1011
- this.c++;
1012
- return true;
1013
- }
1014
- go_in_grouping(s, min, max) {
1015
- while (this.c < this.limit) {
1016
- let ch = this.current.charCodeAt(this.c);
1017
- if (ch > max || ch < min) return true;
1018
- ch -= min;
1019
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return true;
1020
- this.c++;
1021
- }
1022
- return false;
1023
- }
1024
- in_grouping_b(s, min, max) {
1025
- if (this.c <= this.limit_backward) return false;
1026
- let ch = this.current.charCodeAt(this.c - 1);
1027
- if (ch > max || ch < min) return false;
1028
- ch -= min;
1029
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return false;
1030
- this.c--;
1031
- return true;
1032
- }
1033
- go_in_grouping_b(s, min, max) {
1034
- while (this.c > this.limit_backward) {
1035
- let ch = this.current.charCodeAt(this.c - 1);
1036
- if (ch > max || ch < min) return true;
1037
- ch -= min;
1038
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return true;
1039
- this.c--;
1040
- }
1041
- return false;
1042
- }
1043
- out_grouping(s, min, max) {
1044
- if (this.c >= this.limit) return false;
1045
- let ch = this.current.charCodeAt(this.c);
1046
- if (ch > max || ch < min) {
1047
- this.c++;
1048
- return true;
1049
- }
1050
- ch -= min;
1051
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) {
1052
- this.c++;
1053
- return true;
1054
- }
1055
- return false;
1056
- }
1057
- go_out_grouping(s, min, max) {
1058
- while (this.c < this.limit) {
1059
- let ch = this.current.charCodeAt(this.c);
1060
- if (ch <= max && ch >= min) {
1061
- ch -= min;
1062
- if ((s[ch >>> 3] & 1 << (ch & 7)) !== 0) return true;
1063
- }
1064
- this.c++;
1065
- }
1066
- return false;
1067
- }
1068
- out_grouping_b(s, min, max) {
1069
- if (this.c <= this.limit_backward) return false;
1070
- let ch = this.current.charCodeAt(this.c - 1);
1071
- if (ch > max || ch < min) {
1072
- this.c--;
1073
- return true;
1074
- }
1075
- ch -= min;
1076
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) {
1077
- this.c--;
1078
- return true;
1079
- }
1080
- return false;
1081
- }
1082
- go_out_grouping_b(s, min, max) {
1083
- while (this.c > this.limit_backward) {
1084
- let ch = this.current.charCodeAt(this.c - 1);
1085
- if (ch <= max && ch >= min) {
1086
- ch -= min;
1087
- if ((s[ch >>> 3] & 1 << (ch & 7)) !== 0) return true;
1088
- }
1089
- this.c--;
1090
- }
1091
- return false;
1092
- }
1093
- eq_s(s) {
1094
- if (this.limit - this.c < s.length) return false;
1095
- if (!this.current.startsWith(s, this.c)) return false;
1096
- this.c += s.length;
1097
- return true;
1098
- }
1099
- eq_s_b(s) {
1100
- if (this.c - this.limit_backward < s.length) return false;
1101
- if (!this.current.endsWith(s, this.c)) return false;
1102
- this.c -= s.length;
1103
- return true;
1104
- }
1105
- find_among(v, call_among_func) {
1106
- let i = 0;
1107
- let j = v.length;
1108
- const c = this.c;
1109
- const l = this.limit;
1110
- let common_i = 0;
1111
- let common_j = 0;
1112
- let first_key_inspected = false;
1113
- while (true) {
1114
- const k = i + (j - i >>> 1);
1115
- let diff = 0;
1116
- let common = common_i < common_j ? common_i : common_j;
1117
- const s = v[k][0];
1118
- for (let i2 = common; i2 < s.length; i2++) {
1119
- if (c + common === l) {
1120
- diff = -1;
1121
- break;
1122
- }
1123
- diff = this.current.charCodeAt(c + common) - s.charCodeAt(i2);
1124
- if (diff !== 0) break;
1125
- common++;
1126
- }
1127
- if (diff < 0) {
1128
- j = k;
1129
- common_j = common;
1130
- } else {
1131
- i = k;
1132
- common_i = common;
1133
- }
1134
- if (j - i <= 1) {
1135
- if (i > 0) break;
1136
- if (j === i) break;
1137
- if (first_key_inspected) break;
1138
- first_key_inspected = true;
1139
- }
1140
- }
1141
- while (true) {
1142
- const w = v[i];
1143
- const len = w[0].length;
1144
- if (common_i >= len) {
1145
- this.c = c + len;
1146
- const action = w[3];
1147
- if (action === void 0) return w[1];
1148
- this.af = action;
1149
- if (call_among_func?.call(this) === true) {
1150
- this.c = c + len;
1151
- return w[1];
1152
- }
1153
- }
1154
- const back = w[2];
1155
- if (back === void 0 || back === 0) return 0;
1156
- i -= back;
1157
- }
1158
- }
1159
- find_among_b(v, call_among_func) {
1160
- let i = 0;
1161
- let j = v.length;
1162
- const c = this.c;
1163
- const lb = this.limit_backward;
1164
- let common_i = 0;
1165
- let common_j = 0;
1166
- let first_key_inspected = false;
1167
- while (true) {
1168
- const k = i + (j - i >> 1);
1169
- let diff = 0;
1170
- let common = common_i < common_j ? common_i : common_j;
1171
- const s = v[k][0];
1172
- for (let i2 = s.length - 1 - common; i2 >= 0; i2--) {
1173
- if (c - common === lb) {
1174
- diff = -1;
1175
- break;
1176
- }
1177
- diff = this.current.charCodeAt(c - 1 - common) - s.charCodeAt(i2);
1178
- if (diff !== 0) break;
1179
- common++;
1180
- }
1181
- if (diff < 0) {
1182
- j = k;
1183
- common_j = common;
1184
- } else {
1185
- i = k;
1186
- common_i = common;
1187
- }
1188
- if (j - i <= 1) {
1189
- if (i > 0) break;
1190
- if (j === i) break;
1191
- if (first_key_inspected) break;
1192
- first_key_inspected = true;
1193
- }
1194
- }
1195
- while (true) {
1196
- const w = v[i];
1197
- const len = w[0].length;
1198
- if (common_i >= len) {
1199
- this.c = c - len;
1200
- const action = w[3];
1201
- if (action === void 0) return w[1];
1202
- this.af = action;
1203
- if (call_among_func?.call(this) === true) {
1204
- this.c = c - len;
1205
- return w[1];
1206
- }
1207
- }
1208
- const back = w[2];
1209
- if (back === void 0 || back === 0) return 0;
1210
- i -= back;
1211
- }
1212
- }
1213
- replace_s(c_bra, c_ket, s) {
1214
- const adjustment = s.length - (c_ket - c_bra);
1215
- this.current = this.current.slice(0, c_bra) + s + this.current.slice(c_ket);
1216
- this.limit += adjustment;
1217
- if (this.c >= c_ket) this.c += adjustment;
1218
- else if (this.c > c_bra) this.c = c_bra;
1219
- return adjustment;
1220
- }
1221
- slice_from(s) {
1222
- this.replace_s(this.bra, this.ket, s);
1223
- this.ket = this.bra + s.length;
1224
- }
1225
- slice_del() {
1226
- this.slice_from("");
1227
- }
1228
- insert(c_bra, c_ket, s) {
1229
- const adjustment = this.replace_s(c_bra, c_ket, s);
1230
- if (c_bra <= this.bra) this.bra += adjustment;
1231
- if (c_bra <= this.ket) this.ket += adjustment;
1232
- }
1233
- slice_to() {
1234
- return this.current.slice(this.bra, this.ket);
1235
- }
1236
- };
1237
-
1238
- // src/languages/snowball/english.ts
1239
- var a_0 = [
1240
- ["arsen", -1],
1241
- ["commun", -1],
1242
- ["emerg", -1],
1243
- ["gener", -1],
1244
- ["inter", -1],
1245
- ["later", -1],
1246
- ["organ", -1],
1247
- ["past", -1],
1248
- ["univers", -1]
1249
- ];
1250
- var a_1 = [
1251
- ["'", 1],
1252
- ["'s'", 1, 1],
1253
- ["'s", 1]
1254
- ];
1255
- var a_2 = [
1256
- ["ied", 2],
1257
- ["s", 3],
1258
- ["ies", 2, 1],
1259
- ["sses", 1, 2],
1260
- ["ss", -1, 3],
1261
- ["us", -1, 4]
1262
- ];
1263
- var a_3 = [
1264
- ["succ", 1],
1265
- ["proc", 1],
1266
- ["exc", 1]
1267
- ];
1268
- var a_4 = [
1269
- ["even", 2],
1270
- ["cann", 2],
1271
- ["inn", 2],
1272
- ["earr", 2],
1273
- ["herr", 2],
1274
- ["out", 2],
1275
- ["y", 1]
1276
- ];
1277
- var a_5 = [
1278
- ["", -1],
1279
- ["ed", 2, 1],
1280
- ["eed", 1, 1],
1281
- ["ing", 3, 3],
1282
- ["edly", 2, 4],
1283
- ["eedly", 1, 1],
1284
- ["ingly", 2, 6]
1285
- ];
1286
- var a_6 = [
1287
- ["", 3],
1288
- ["bb", 2, 1],
1289
- ["dd", 2, 2],
1290
- ["ff", 2, 3],
1291
- ["gg", 2, 4],
1292
- ["bl", 1, 5],
1293
- ["mm", 2, 6],
1294
- ["nn", 2, 7],
1295
- ["pp", 2, 8],
1296
- ["rr", 2, 9],
1297
- ["at", 1, 10],
1298
- ["tt", 2, 11],
1299
- ["iz", 1, 12]
1300
- ];
1301
- var a_7 = [
1302
- ["anci", 3],
1303
- ["enci", 2],
1304
- ["ogi", 14],
1305
- ["li", 16],
1306
- ["bli", 12, 1],
1307
- ["abli", 4, 1],
1308
- ["alli", 8, 3],
1309
- ["fulli", 9, 4],
1310
- ["lessli", 15, 5],
1311
- ["ousli", 10, 6],
1312
- ["entli", 5, 7],
1313
- ["aliti", 8],
1314
- ["biliti", 12],
1315
- ["iviti", 11],
1316
- ["tional", 1],
1317
- ["ational", 7, 1],
1318
- ["alism", 8],
1319
- ["ation", 7],
1320
- ["ization", 6, 1],
1321
- ["izer", 6],
1322
- ["ator", 7],
1323
- ["iveness", 11],
1324
- ["fulness", 9],
1325
- ["ousness", 10],
1326
- ["ogist", 13]
1327
- ];
1328
- var a_8 = [
1329
- ["icate", 4],
1330
- ["ative", 6],
1331
- ["alize", 3],
1332
- ["iciti", 4],
1333
- ["ical", 4],
1334
- ["tional", 1],
1335
- ["ational", 2, 1],
1336
- ["ful", 5],
1337
- ["ness", 5]
1338
- ];
1339
- var a_9 = [
1340
- ["ic", 1],
1341
- ["ance", 1],
1342
- ["ence", 1],
1343
- ["able", 1],
1344
- ["ible", 1],
1345
- ["ate", 1],
1346
- ["ive", 1],
1347
- ["ize", 1],
1348
- ["iti", 1],
1349
- ["al", 1],
1350
- ["ism", 1],
1351
- ["ion", 2],
1352
- ["er", 1],
1353
- ["ous", 1],
1354
- ["ant", 1],
1355
- ["ent", 1],
1356
- ["ment", 1, 1],
1357
- ["ement", 1, 1]
1358
- ];
1359
- var a_10 = [
1360
- ["e", 1],
1361
- ["l", 2]
1362
- ];
1363
- var a_11 = [
1364
- ["andes", -1],
1365
- ["atlas", -1],
1366
- ["bias", -1],
1367
- ["cosmos", -1],
1368
- ["early", 6],
1369
- ["gently", 4],
1370
- ["howe", -1],
1371
- ["idly", 3],
1372
- ["news", -1],
1373
- ["only", 7],
1374
- ["singly", 8],
1375
- ["skies", 2],
1376
- ["skis", 1],
1377
- ["sky", -1],
1378
- ["ugly", 5]
1379
- ];
1380
- var as_11 = ["ski", "sky", "idl", "gentl", "ugli", "earli", "onli", "singl"];
1381
- var g_aeo = [17, 64];
1382
- var g_v = [17, 65, 16, 1];
1383
- var g_v_WXY = [1, 17, 65, 208, 1];
1384
- var g_valid_LI = [55, 141, 2];
1385
- var EnglishStemmer = class extends BaseStemmer {
1386
- #r_shortv() {
1387
- lab0: {
1388
- const v_1 = this.limit - this.c;
1389
- lab1: {
1390
- if (!this.out_grouping_b(g_v_WXY, 89, 121)) break lab1;
1391
- if (!this.in_grouping_b(g_v, 97, 121)) break lab1;
1392
- if (!this.out_grouping_b(g_v, 97, 121)) break lab1;
1393
- break lab0;
1394
- }
1395
- this.c = this.limit - v_1;
1396
- lab2: {
1397
- if (!this.out_grouping_b(g_v, 97, 121)) break lab2;
1398
- if (!this.in_grouping_b(g_v, 97, 121)) break lab2;
1399
- if (
1400
- /**@type {boolean}*/
1401
- this.c > this.limit_backward
1402
- ) break lab2;
1403
- break lab0;
1404
- }
1405
- this.c = this.limit - v_1;
1406
- if (!this.eq_s_b("past")) return false;
1407
- }
1408
- return true;
1409
- }
1410
- #stem() {
1411
- let a;
1412
- let B_Y_found;
1413
- let I_p2;
1414
- let I_p1;
1415
- lab0: {
1416
- const v_1 = this.c;
1417
- lab1: {
1418
- this.bra = this.c;
1419
- a = this.find_among(a_11);
1420
- if (a === 0) break lab1;
1421
- this.ket = this.c;
1422
- if (
1423
- /**@type {boolean}*/
1424
- this.c < this.limit
1425
- ) break lab1;
1426
- if (a > 0) {
1427
- this.slice_from(as_11[a - 1]);
1428
- }
1429
- break lab0;
1430
- }
1431
- this.c = v_1;
1432
- lab2: {
1433
- lab3: {
1434
- if (this.c + 3 > this.limit) break lab3;
1435
- this.c += 3;
1436
- break lab2;
1437
- }
1438
- break lab0;
1439
- }
1440
- this.c = v_1;
1441
- {
1442
- B_Y_found = false;
1443
- const v_2 = this.c;
1444
- lab5: {
1445
- this.bra = this.c;
1446
- if (!this.eq_s("'")) break lab5;
1447
- this.ket = this.c;
1448
- this.slice_del();
1449
- }
1450
- this.c = v_2;
1451
- const v_3 = this.c;
1452
- lab6: {
1453
- this.bra = this.c;
1454
- if (!this.eq_s("y")) break lab6;
1455
- this.ket = this.c;
1456
- this.slice_from("Y");
1457
- B_Y_found = true;
1458
- }
1459
- this.c = v_3;
1460
- const v_4 = this.c;
1461
- while (true) {
1462
- const v_5 = this.c;
1463
- lab8: {
1464
- while (true) {
1465
- const v_6 = this.c;
1466
- lab10: {
1467
- if (!this.in_grouping(g_v, 97, 121)) break lab10;
1468
- this.bra = this.c;
1469
- if (!this.eq_s("y")) break lab10;
1470
- this.ket = this.c;
1471
- this.c = v_6;
1472
- break;
1473
- }
1474
- this.c = v_6;
1475
- if (this.c >= this.limit) break lab8;
1476
- this.c++;
1477
- }
1478
- this.slice_from("Y");
1479
- B_Y_found = true;
1480
- continue;
1481
- }
1482
- this.c = v_5;
1483
- break;
1484
- }
1485
- this.c = v_4;
1486
- }
1487
- {
1488
- I_p1 = this.limit;
1489
- I_p2 = this.limit;
1490
- const v_7 = this.c;
1491
- lab12: {
1492
- lab13: {
1493
- const v_8 = this.c;
1494
- lab14: {
1495
- if (this.find_among(a_0) === 0) break lab14;
1496
- break lab13;
1497
- }
1498
- this.c = v_8;
1499
- if (!this.go_out_grouping(g_v, 97, 121)) break lab12;
1500
- this.c++;
1501
- if (!this.go_in_grouping(g_v, 97, 121)) break lab12;
1502
- this.c++;
1503
- }
1504
- I_p1 = this.c;
1505
- if (!this.go_out_grouping(g_v, 97, 121)) break lab12;
1506
- this.c++;
1507
- if (!this.go_in_grouping(g_v, 97, 121)) break lab12;
1508
- this.c++;
1509
- I_p2 = this.c;
1510
- }
1511
- this.c = v_7;
1512
- }
1513
- this.limit_backward = this.c;
1514
- this.c = this.limit;
1515
- const v_9 = this.limit - this.c;
1516
- lab15: {
1517
- const v_10 = this.limit - this.c;
1518
- lab16: {
1519
- this.ket = this.c;
1520
- if (this.find_among_b(a_1) === 0) {
1521
- this.c = this.limit - v_10;
1522
- break lab16;
1523
- }
1524
- this.bra = this.c;
1525
- this.slice_del();
1526
- }
1527
- this.ket = this.c;
1528
- a = this.find_among_b(a_2);
1529
- if (a === 0) break lab15;
1530
- this.bra = this.c;
1531
- switch (a) {
1532
- case 1: {
1533
- this.slice_from("ss");
1534
- break;
1535
- }
1536
- case 2: {
1537
- lab17: {
1538
- const v_11 = this.limit - this.c;
1539
- lab18: {
1540
- if (this.c - 2 < this.limit_backward) break lab18;
1541
- this.c -= 2;
1542
- this.slice_from("i");
1543
- break lab17;
1544
- }
1545
- this.c = this.limit - v_11;
1546
- this.slice_from("ie");
1547
- }
1548
- break;
1549
- }
1550
- case 3: {
1551
- if (this.c <= this.limit_backward) break lab15;
1552
- this.c--;
1553
- if (!this.go_out_grouping_b(g_v, 97, 121)) break lab15;
1554
- this.c--;
1555
- this.slice_del();
1556
- break;
1557
- }
1558
- }
1559
- }
1560
- this.c = this.limit - v_9;
1561
- const v_12 = this.limit - this.c;
1562
- lab19: {
1563
- this.ket = this.c;
1564
- a = this.find_among_b(a_5);
1565
- this.bra = this.c;
1566
- lab20: {
1567
- const v_13 = this.limit - this.c;
1568
- lab21: {
1569
- switch (a) {
1570
- case 1: {
1571
- const v_14 = this.limit - this.c;
1572
- lab22: {
1573
- if (
1574
- /**@type {boolean}*/
1575
- I_p1 > this.c
1576
- ) break lab22;
1577
- lab23: {
1578
- const v_15 = this.limit - this.c;
1579
- lab24: {
1580
- if (this.find_among_b(a_3) === 0) break lab24;
1581
- if (
1582
- /**@type {boolean}*/
1583
- this.c > this.limit_backward
1584
- ) break lab24;
1585
- break lab23;
1586
- }
1587
- this.c = this.limit - v_15;
1588
- this.slice_from("ee");
1589
- }
1590
- }
1591
- this.c = this.limit - v_14;
1592
- break;
1593
- }
1594
- case 2: {
1595
- break lab21;
1596
- }
1597
- case 3: {
1598
- a = this.find_among_b(a_4);
1599
- if (a === 0) break lab21;
1600
- switch (a) {
1601
- case 1: {
1602
- const v_16 = this.limit - this.c;
1603
- if (!this.out_grouping_b(g_v, 97, 121)) break lab21;
1604
- if (
1605
- /**@type {boolean}*/
1606
- this.c > this.limit_backward
1607
- ) break lab21;
1608
- this.c = this.limit - v_16;
1609
- this.bra = this.c;
1610
- this.slice_from("ie");
1611
- break;
1612
- }
1613
- case 2: {
1614
- if (
1615
- /**@type {boolean}*/
1616
- this.c > this.limit_backward
1617
- ) break lab21;
1618
- break;
1619
- }
1620
- }
1621
- break;
1622
- }
1623
- }
1624
- break lab20;
1625
- }
1626
- this.c = this.limit - v_13;
1627
- const v_17 = this.limit - this.c;
1628
- if (!this.go_out_grouping_b(g_v, 97, 121)) break lab19;
1629
- this.c--;
1630
- this.c = this.limit - v_17;
1631
- this.slice_del();
1632
- this.ket = this.c;
1633
- this.bra = this.c;
1634
- const v_18 = this.limit - this.c;
1635
- a = this.find_among_b(a_6);
1636
- switch (a) {
1637
- case 1: {
1638
- this.slice_from("e");
1639
- break lab19;
1640
- }
1641
- case 2: {
1642
- {
1643
- const v_19 = this.limit - this.c;
1644
- lab25: {
1645
- if (!this.in_grouping_b(g_aeo, 97, 111)) break lab25;
1646
- if (
1647
- /**@type {boolean}*/
1648
- this.c > this.limit_backward
1649
- ) break lab25;
1650
- break lab19;
1651
- }
1652
- this.c = this.limit - v_19;
1653
- }
1654
- break;
1655
- }
1656
- case 3: {
1657
- if (
1658
- /**@type {boolean}*/
1659
- this.c !== I_p1
1660
- ) break lab19;
1661
- const v_20 = this.limit - this.c;
1662
- if (!this.#r_shortv()) break lab19;
1663
- this.c = this.limit - v_20;
1664
- this.slice_from("e");
1665
- break lab19;
1666
- }
1667
- }
1668
- this.c = this.limit - v_18;
1669
- this.ket = this.c;
1670
- if (this.c <= this.limit_backward) break lab19;
1671
- this.c--;
1672
- this.bra = this.c;
1673
- this.slice_del();
1674
- }
1675
- }
1676
- this.c = this.limit - v_12;
1677
- const v_21 = this.limit - this.c;
1678
- lab26: {
1679
- this.ket = this.c;
1680
- lab27: {
1681
- lab28: {
1682
- if (!this.eq_s_b("y")) break lab28;
1683
- break lab27;
1684
- }
1685
- if (!this.eq_s_b("Y")) break lab26;
1686
- }
1687
- this.bra = this.c;
1688
- if (!this.out_grouping_b(g_v, 97, 121)) break lab26;
1689
- if (
1690
- /**@type {boolean}*/
1691
- this.c <= this.limit_backward
1692
- ) break lab26;
1693
- this.slice_from("i");
1694
- }
1695
- this.c = this.limit - v_21;
1696
- const v_22 = this.limit - this.c;
1697
- lab29: {
1698
- this.ket = this.c;
1699
- a = this.find_among_b(a_7);
1700
- if (a === 0) break lab29;
1701
- this.bra = this.c;
1702
- if (
1703
- /**@type {boolean}*/
1704
- I_p1 > this.c
1705
- ) break lab29;
1706
- switch (a) {
1707
- case 1: {
1708
- this.slice_from("tion");
1709
- break;
1710
- }
1711
- case 2: {
1712
- this.slice_from("ence");
1713
- break;
1714
- }
1715
- case 3: {
1716
- this.slice_from("ance");
1717
- break;
1718
- }
1719
- case 4: {
1720
- this.slice_from("able");
1721
- break;
1722
- }
1723
- case 5: {
1724
- this.slice_from("ent");
1725
- break;
1726
- }
1727
- case 6: {
1728
- this.slice_from("ize");
1729
- break;
1730
- }
1731
- case 7: {
1732
- this.slice_from("ate");
1733
- break;
1734
- }
1735
- case 8: {
1736
- this.slice_from("al");
1737
- break;
1738
- }
1739
- case 9: {
1740
- this.slice_from("ful");
1741
- break;
1742
- }
1743
- case 10: {
1744
- this.slice_from("ous");
1745
- break;
1746
- }
1747
- case 11: {
1748
- this.slice_from("ive");
1749
- break;
1750
- }
1751
- case 12: {
1752
- this.slice_from("ble");
1753
- break;
1754
- }
1755
- case 13: {
1756
- this.slice_from("og");
1757
- break;
1758
- }
1759
- case 14: {
1760
- if (!this.eq_s_b("l")) break lab29;
1761
- this.slice_from("og");
1762
- break;
1763
- }
1764
- case 15: {
1765
- this.slice_from("less");
1766
- break;
1767
- }
1768
- case 16: {
1769
- if (!this.in_grouping_b(g_valid_LI, 99, 116)) break lab29;
1770
- this.slice_del();
1771
- break;
1772
- }
1773
- }
1774
- }
1775
- this.c = this.limit - v_22;
1776
- const v_23 = this.limit - this.c;
1777
- lab30: {
1778
- this.ket = this.c;
1779
- a = this.find_among_b(a_8);
1780
- if (a === 0) break lab30;
1781
- this.bra = this.c;
1782
- if (
1783
- /**@type {boolean}*/
1784
- I_p1 > this.c
1785
- ) break lab30;
1786
- switch (a) {
1787
- case 1: {
1788
- this.slice_from("tion");
1789
- break;
1790
- }
1791
- case 2: {
1792
- this.slice_from("ate");
1793
- break;
1794
- }
1795
- case 3: {
1796
- this.slice_from("al");
1797
- break;
1798
- }
1799
- case 4: {
1800
- this.slice_from("ic");
1801
- break;
1802
- }
1803
- case 5: {
1804
- this.slice_del();
1805
- break;
1806
- }
1807
- case 6: {
1808
- if (
1809
- /**@type {boolean}*/
1810
- I_p2 > this.c
1811
- ) break lab30;
1812
- this.slice_del();
1813
- break;
1814
- }
1815
- }
1816
- }
1817
- this.c = this.limit - v_23;
1818
- const v_24 = this.limit - this.c;
1819
- lab31: {
1820
- this.ket = this.c;
1821
- a = this.find_among_b(a_9);
1822
- if (a === 0) break lab31;
1823
- this.bra = this.c;
1824
- if (
1825
- /**@type {boolean}*/
1826
- I_p2 > this.c
1827
- ) break lab31;
1828
- switch (a) {
1829
- case 1: {
1830
- this.slice_del();
1831
- break;
1832
- }
1833
- case 2: {
1834
- lab32: {
1835
- lab33: {
1836
- if (!this.eq_s_b("s")) break lab33;
1837
- break lab32;
1838
- }
1839
- if (!this.eq_s_b("t")) break lab31;
1840
- }
1841
- this.slice_del();
1842
- break;
1843
- }
1844
- }
1845
- }
1846
- this.c = this.limit - v_24;
1847
- const v_25 = this.limit - this.c;
1848
- lab34: {
1849
- this.ket = this.c;
1850
- a = this.find_among_b(a_10);
1851
- if (a === 0) break lab34;
1852
- this.bra = this.c;
1853
- switch (a) {
1854
- case 1: {
1855
- lab35: {
1856
- lab36: {
1857
- if (
1858
- /**@type {boolean}*/
1859
- I_p2 > this.c
1860
- ) break lab36;
1861
- break lab35;
1862
- }
1863
- if (
1864
- /**@type {boolean}*/
1865
- I_p1 > this.c
1866
- ) break lab34;
1867
- {
1868
- const v_26 = this.limit - this.c;
1869
- lab37: {
1870
- if (!this.#r_shortv()) break lab37;
1871
- break lab34;
1872
- }
1873
- this.c = this.limit - v_26;
1874
- }
1875
- }
1876
- this.slice_del();
1877
- break;
1878
- }
1879
- case 2: {
1880
- if (
1881
- /**@type {boolean}*/
1882
- I_p2 > this.c
1883
- ) break lab34;
1884
- if (!this.eq_s_b("l")) break lab34;
1885
- this.slice_del();
1886
- break;
1887
- }
1888
- }
1889
- }
1890
- this.c = this.limit - v_25;
1891
- this.c = this.limit_backward;
1892
- const v_27 = this.c;
1893
- lab38: {
1894
- if (!B_Y_found) break lab38;
1895
- while (true) {
1896
- const v_28 = this.c;
1897
- lab39: {
1898
- while (true) {
1899
- const v_29 = this.c;
1900
- lab41: {
1901
- this.bra = this.c;
1902
- if (!this.eq_s("Y")) break lab41;
1903
- this.ket = this.c;
1904
- this.c = v_29;
1905
- break;
1906
- }
1907
- this.c = v_29;
1908
- if (this.c >= this.limit) break lab39;
1909
- this.c++;
1910
- }
1911
- this.slice_from("y");
1912
- continue;
1913
- }
1914
- this.c = v_28;
1915
- break;
1916
- }
1917
- }
1918
- this.c = v_27;
1919
- }
1920
- return true;
1921
- }
1922
- stem(input) {
1923
- this.setCurrent(input);
1924
- this.#stem();
1925
- return this.getCurrent();
1926
- }
1927
- };
1928
- var shared = new EnglishStemmer();
1929
- function stem(token) {
1930
- return shared.stem(token);
1931
- }
1932
-
1933
- // src/languages/english.ts
1934
- var stopWords = /* @__PURE__ */ new Set([
1935
- "a",
1936
- "an",
1937
- "the",
1938
- "i",
1939
- "me",
1940
- "my",
1941
- "myself",
1942
- "we",
1943
- "us",
1944
- "our",
1945
- "ours",
1946
- "ourselves",
1947
- "you",
1948
- "your",
1949
- "yours",
1950
- "yourself",
1951
- "yourselves",
1952
- "he",
1953
- "him",
1954
- "his",
1955
- "himself",
1956
- "she",
1957
- "her",
1958
- "hers",
1959
- "herself",
1960
- "it",
1961
- "its",
1962
- "itself",
1963
- "they",
1964
- "them",
1965
- "their",
1966
- "theirs",
1967
- "themselves",
1968
- "what",
1969
- "which",
1970
- "who",
1971
- "whom",
1972
- "this",
1973
- "that",
1974
- "these",
1975
- "those",
1976
- "am",
1977
- "is",
1978
- "are",
1979
- "was",
1980
- "were",
1981
- "be",
1982
- "been",
1983
- "being",
1984
- "have",
1985
- "has",
1986
- "had",
1987
- "having",
1988
- "do",
1989
- "does",
1990
- "did",
1991
- "doing",
1992
- "will",
1993
- "would",
1994
- "shall",
1995
- "should",
1996
- "can",
1997
- "could",
1998
- "may",
1999
- "might",
2000
- "must",
2001
- "ought",
2002
- "i'm",
2003
- "you're",
2004
- "we're",
2005
- "they're",
2006
- "i've",
2007
- "you've",
2008
- "we've",
2009
- "they've",
2010
- "i'd",
2011
- "you'd",
2012
- "he'd",
2013
- "she'd",
2014
- "we'd",
2015
- "they'd",
2016
- "i'll",
2017
- "you'll",
2018
- "he'll",
2019
- "she'll",
2020
- "we'll",
2021
- "they'll",
2022
- "isn't",
2023
- "aren't",
2024
- "wasn't",
2025
- "weren't",
2026
- "hasn't",
2027
- "haven't",
2028
- "hadn't",
2029
- "doesn't",
2030
- "don't",
2031
- "didn't",
2032
- "won't",
2033
- "wouldn't",
2034
- "shan't",
2035
- "shouldn't",
2036
- "can't",
2037
- "cannot",
2038
- "couldn't",
2039
- "mustn't",
2040
- "and",
2041
- "but",
2042
- "if",
2043
- "or",
2044
- "because",
2045
- "as",
2046
- "until",
2047
- "while",
2048
- "of",
2049
- "at",
2050
- "by",
2051
- "for",
2052
- "with",
2053
- "about",
2054
- "against",
2055
- "between",
2056
- "into",
2057
- "through",
2058
- "during",
2059
- "before",
2060
- "after",
2061
- "above",
2062
- "below",
2063
- "to",
2064
- "from",
2065
- "up",
2066
- "down",
2067
- "in",
2068
- "out",
2069
- "on",
2070
- "off",
2071
- "over",
2072
- "under",
2073
- "again",
2074
- "further",
2075
- "then",
2076
- "once",
2077
- "here",
2078
- "there",
2079
- "when",
2080
- "where",
2081
- "why",
2082
- "how",
2083
- "all",
2084
- "any",
2085
- "both",
2086
- "each",
2087
- "few",
2088
- "more",
2089
- "most",
2090
- "other",
2091
- "some",
2092
- "such",
2093
- "no",
2094
- "nor",
2095
- "not",
2096
- "only",
2097
- "own",
2098
- "same",
2099
- "so",
2100
- "than",
2101
- "too",
2102
- "very"
2103
- ]);
2104
- var english = {
2105
- name: "english",
2106
- revision: "ebae3448ae674b59",
2107
- stemmer: stem,
2108
- stopWords,
2109
- tokenizer: {
2110
- splitPattern: /[^\p{L}\p{M}\p{N}_']+/u,
2111
- stripPossessive: true
2112
- }
2113
- };
2114
-
2115
- // src/languages/registry.ts
2116
- var languages = /* @__PURE__ */ new Map();
2117
- languages.set("english", english);
2118
- function registerLanguage(module) {
2119
- languages.set(module.name, module);
2120
- }
2121
- function getLanguage(name) {
2122
- const lang = languages.get(name);
2123
- if (!lang) {
2124
- throw new NarsilError(ErrorCodes.LANGUAGE_NOT_SUPPORTED, `Language "${name}" is not registered`, { language: name });
2125
- }
2126
- return lang;
2127
- }
2128
-
2129
625
  // src/engine/memory/write-block.browser.ts
2130
626
  function validateMemorySettings(_settings) {
2131
627
  }
@@ -2150,7 +646,8 @@ var NARSIL_CONFIG_KEYS = {
2150
646
  lifecycle: true,
2151
647
  patternWorkCap: true,
2152
648
  events: true,
2153
- memory: true
649
+ memory: true,
650
+ querySuggestions: true
2154
651
  };
2155
652
  var EVENT_NAMES = {
2156
653
  write: true,
@@ -2164,7 +661,9 @@ var EVENT_NAMES = {
2164
661
  layoutUpgrade: true,
2165
662
  checkpointHeld: true,
2166
663
  durabilityError: true,
2167
- invalidationError: true
664
+ invalidationError: true,
665
+ querySuggestionsBuild: true,
666
+ querySuggestionsWarning: true
2168
667
  };
2169
668
  var DURABILITY_CONFIG_KEYS = {
2170
669
  tier: true,
@@ -2798,38 +1297,6 @@ function validateRequiredFields(document, required) {
2798
1297
  }
2799
1298
  }
2800
1299
  }
2801
- var INTEGER_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH };
2802
- var FLOAT_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH, forceIntegerToFloat: true };
2803
- var integerEncoder = new Encoder(INTEGER_ENCODING);
2804
- var floatEncoder = new Encoder(FLOAT_ENCODING);
2805
- function encodeExactly(document, forceIntegerToFloat) {
2806
- const bytes = (forceIntegerToFloat ? floatEncoder : integerEncoder).encode(document);
2807
- if (bytes.byteLength > DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES) {
2808
- if (forceIntegerToFloat) floatEncoder = new Encoder(FLOAT_ENCODING);
2809
- else integerEncoder = new Encoder(INTEGER_ENCODING);
2810
- }
2811
- return bytes;
2812
- }
2813
- function holdsNegativeZero(value, depth) {
2814
- if (typeof value === "number") return Object.is(value, -0);
2815
- if (value === null || typeof value !== "object" || ArrayBuffer.isView(value) || depth > MAX_DOCUMENT_ENCODING_DEPTH) {
2816
- return false;
2817
- }
2818
- for (const child of Array.isArray(value) ? value : Object.values(value)) {
2819
- if (holdsNegativeZero(child, depth + 1)) return true;
2820
- }
2821
- return false;
2822
- }
2823
- function encodeDocument(document) {
2824
- try {
2825
- return encodeExactly(document, holdsNegativeZero(document, 1));
2826
- } catch (error) {
2827
- throw new NarsilError(
2828
- ErrorCodes.DOC_VALIDATION_FAILED,
2829
- `The document cannot be encoded as MessagePack: ${error instanceof Error ? error.message : String(error)}`
2830
- );
2831
- }
2832
- }
2833
1300
 
2834
1301
  // src/schema/validator/document-size.ts
2835
1302
  var LARGEST_HEADER_BYTES = 5;
@@ -3059,11 +1526,6 @@ function validateRequiredFieldsInSchema(required, schema) {
3059
1526
  }
3060
1527
  }
3061
1528
 
3062
- // src/runtime/heap-statistics.browser.ts
3063
- function readHeapStatistics() {
3064
- return null;
3065
- }
3066
-
3067
1529
  // src/core/partition/utils.ts
3068
1530
  function getOrCreateFieldNameIndex(table, fieldName) {
3069
1531
  const existing = table.indexMap.get(fieldName);
@@ -3158,8 +1620,8 @@ function splitPaths(paths) {
3158
1620
  return split;
3159
1621
  }
3160
1622
  function overlaps(a, b) {
3161
- const shared2 = Math.min(a.length, b.length);
3162
- for (let i = 0; i < shared2; i++) {
1623
+ const shared = Math.min(a.length, b.length);
1624
+ for (let i = 0; i < shared; i++) {
3163
1625
  if (a[i] !== b[i]) return false;
3164
1626
  }
3165
1627
  return true;
@@ -7842,7 +6304,7 @@ function requireLoadedPhraseCode() {
7842
6304
  }
7843
6305
  function loadPhraseCode() {
7844
6306
  if (loading === null) {
7845
- loading = import('./phrase-module-CNKMUY4U.mjs').then(
6307
+ loading = import('./phrase-module-ZXXU7S3B.mjs').then(
7846
6308
  (code) => {
7847
6309
  loaded = code;
7848
6310
  return code;
@@ -11664,7 +10126,7 @@ function localMeter(cap, spent, matcherStateBytes, flushUnits, clock) {
11664
10126
  new BigInt64Array(counter)[0] = BigInt(seed);
11665
10127
  preparedTypoTests = new SharedArrayBuffer(PREPARED_TYPO_TEST_BYTES);
11666
10128
  }
11667
- const shared2 = {
10129
+ const shared = {
11668
10130
  cap,
11669
10131
  spent: seed,
11670
10132
  counter,
@@ -11673,7 +10135,7 @@ function localMeter(cap, spent, matcherStateBytes, flushUnits, clock) {
11673
10135
  flushUnits: Math.max(1, Math.floor(flushUnits / copies))
11674
10136
  };
11675
10137
  return {
11676
- shared: shared2,
10138
+ shared,
11677
10139
  settle(reportedUnits) {
11678
10140
  if (counter === null) {
11679
10141
  meter.add(reportedUnits);
@@ -12989,8 +11451,8 @@ function encodedProjectionPathOf(path) {
12989
11451
  return segments;
12990
11452
  }
12991
11453
  function sharesPrefix(left, right) {
12992
- const shared2 = Math.min(left.length, right.length);
12993
- for (let at = 0; at < shared2; at++) {
11454
+ const shared = Math.min(left.length, right.length);
11455
+ for (let at = 0; at < shared; at++) {
12994
11456
  if (left[at] !== right[at]) return false;
12995
11457
  }
12996
11458
  return true;
@@ -13204,8 +11666,8 @@ function encodeExternalIdTableData(docIds) {
13204
11666
  }
13205
11667
  function compareBytes(blob, start, end, query) {
13206
11668
  const length = end - start;
13207
- const shared2 = length < query.length ? length : query.length;
13208
- for (let i = 0; i < shared2; i++) {
11669
+ const shared = length < query.length ? length : query.length;
11670
+ for (let i = 0; i < shared; i++) {
13209
11671
  const diff = blob[start + i] - query[i];
13210
11672
  if (diff !== 0) return diff;
13211
11673
  }
@@ -14021,8 +12483,8 @@ var encoder3 = new TextEncoder();
14021
12483
  var decoder3 = new TextDecoder();
14022
12484
  function compareBytes2(blob, start, end, query) {
14023
12485
  const length = end - start;
14024
- const shared2 = length < query.length ? length : query.length;
14025
- for (let i = 0; i < shared2; i++) {
12486
+ const shared = length < query.length ? length : query.length;
12487
+ for (let i = 0; i < shared; i++) {
14026
12488
  const diff = blob[start + i] - query[i];
14027
12489
  if (diff !== 0) return diff;
14028
12490
  }
@@ -15353,7 +13815,7 @@ async function attachSegments(entry, action) {
15353
13815
  growPartitionsTo(entry.manager, segment.partitionId);
15354
13816
  const surfaceForms = segment.survivingSurfaceForms;
15355
13817
  const spellings = surfaceForms === void 0 ? void 0 : NO_REMOVED_SPELLINGS;
15356
- const frozen = isPagedSnapshot(segment.snapshot) ? (await import('./module-KAMRAJLE.mjs')).createPagedFrozenSegment(segment.snapshot) : createSharedFrozenSegment(segment.snapshot, surfaceForms);
13818
+ const frozen = isPagedSnapshot(segment.snapshot) ? (await import('./module-E33X4AOK.mjs')).createPagedFrozenSegment(segment.snapshot) : createSharedFrozenSegment(segment.snapshot, surfaceForms);
15357
13819
  for (const docId of segment.tombstonedDocIds ?? []) frozen.tombstoneDocument(docId, spellings);
15358
13820
  entry.manager.attachFrozenSegment(segment.partitionId, frozen);
15359
13821
  }
@@ -15408,7 +13870,7 @@ function runSegmentAction(entry, action) {
15408
13870
  case "attachSegments":
15409
13871
  return attachSegments(entry, action);
15410
13872
  case "adoptDiskSegments":
15411
- return import('./module-KAMRAJLE.mjs').then((code) => code.adoptSegmentsOnWorker(entry.manager, action));
13873
+ return import('./module-E33X4AOK.mjs').then((code) => code.adoptSegmentsOnWorker(entry.manager, action));
15412
13874
  case "compactSegments": {
15413
13875
  const partition = requireComposite(entry, action.indexName, action.partitionId, "compact");
15414
13876
  return mergeFrozenSegments(
@@ -15456,7 +13918,7 @@ function requireLoadedVectorCode() {
15456
13918
  function loadVectorCode() {
15457
13919
  if (loaded2 !== null) return Promise.resolve(loaded2);
15458
13920
  if (loading2 === null) {
15459
- loading2 = import('./module-XQLEOYNM.mjs').then(
13921
+ loading2 = import('./module-3HNFCBJ5.mjs').then(
15460
13922
  (code) => {
15461
13923
  loaded2 = code;
15462
13924
  return code;
@@ -15872,7 +14334,7 @@ var TEXT_REBUILD_SWITCH_BACKLOG_DOCUMENTS = 1e3;
15872
14334
  // src/partitioning/rewrite-spill-of.ts
15873
14335
  async function rewriteSpillOf(storage, manager, target) {
15874
14336
  if (storage === void 0 || (target?.config ?? manager.config).textStorage !== "disk") return null;
15875
- const { openRewriteSpill } = await import('./module-KAMRAJLE.mjs');
14337
+ const { openRewriteSpill } = await import('./module-E33X4AOK.mjs');
15876
14338
  return openRewriteSpill(storage, manager, target);
15877
14339
  }
15878
14340
 
@@ -16184,91 +14646,6 @@ function createAnalysisRebuildCoordinator(config, deps) {
16184
14646
  };
16185
14647
  }
16186
14648
 
16187
- // src/engine/durability-config.ts
16188
- var WAL_ONLY_FIELDS = ["directory", "mode", "flushIntervalMs", "segmentMaxBytes", "compactionThreshold"];
16189
- function configError(message) {
16190
- return new NarsilError(ErrorCodes.CONFIG_INVALID, message);
16191
- }
16192
- function requireKnob(name, value, minimum) {
16193
- if (value === void 0) {
16194
- return;
16195
- }
16196
- if (typeof value !== "number" || !Number.isFinite(value) || value < minimum) {
16197
- throw configError(`durability.${name} must be a finite number of at least ${minimum}, got ${String(value)}`);
16198
- }
16199
- }
16200
- function requireValidDurabilityConfig(durability) {
16201
- if (durability.tier !== void 0 && durability.tier !== "wal" && durability.tier !== "snapshot") {
16202
- throw configError(`durability.tier must be "wal" or "snapshot", got "${String(durability.tier)}"`);
16203
- }
16204
- if (durability.mode !== void 0 && durability.mode !== "sync" && durability.mode !== "async") {
16205
- throw configError(`durability.mode must be "sync" or "async", got "${String(durability.mode)}"`);
16206
- }
16207
- requireKnob("checkpointIntervalMs", durability.checkpointIntervalMs, 0);
16208
- requireKnob("checkpointMutationThreshold", durability.checkpointMutationThreshold, 1);
16209
- requireKnob("flushIntervalMs", durability.flushIntervalMs, 0);
16210
- requireKnob("segmentMaxBytes", durability.segmentMaxBytes, 1);
16211
- if (durability.segmentMaxBytes !== void 0 && durability.segmentMaxBytes > MAX_FILE_BYTES) {
16212
- throw configError(
16213
- `durability.segmentMaxBytes must be at most ${MAX_FILE_BYTES}, the largest file that every implementation reads, got ${durability.segmentMaxBytes}`
16214
- );
16215
- }
16216
- requireKnob("compactionThreshold", durability.compactionThreshold, 1);
16217
- if (durability.tier === "snapshot") {
16218
- for (const field of WAL_ONLY_FIELDS) {
16219
- if (durability[field] !== void 0) {
16220
- throw configError(
16221
- `durability.${field} applies to the write-ahead log tier only and cannot combine with durability.tier "snapshot"`
16222
- );
16223
- }
16224
- }
16225
- }
16226
- }
16227
- function filesystemBackedDirectory(config) {
16228
- const adapterDirectory = config.persistence?.directory;
16229
- if (adapterDirectory !== void 0 && adapterDirectory.trim().length > 0) {
16230
- return adapterDirectory;
16231
- }
16232
- return null;
16233
- }
16234
- function resolveDurabilityTier(config) {
16235
- const filesystemDirectory = filesystemBackedDirectory(config);
16236
- if (config.durability) {
16237
- requireValidDurabilityConfig(config.durability);
16238
- }
16239
- if (config.durability?.tier === "snapshot") {
16240
- if (config.persistence === void 0) {
16241
- throw configError(
16242
- "Snapshot durability persists through a persistence adapter. Configure persistence, or remove durability.tier"
16243
- );
16244
- }
16245
- return { kind: "snapshot", config: { ...config.durability }, adapter: config.persistence };
16246
- }
16247
- if (config.durability) {
16248
- if (config.durability.directory !== void 0 && config.durability.directory.trim().length > 0) {
16249
- return { kind: "wal", config: { ...config.durability } };
16250
- }
16251
- if (filesystemDirectory !== null) {
16252
- return { kind: "wal", config: { ...config.durability, directory: filesystemDirectory } };
16253
- }
16254
- if (config.persistence !== void 0) {
16255
- throw configError(
16256
- "WAL durability requires a filesystem directory, but the configured persistence adapter is not filesystem-backed. Use a filesystem persistence adapter or set durability.directory"
16257
- );
16258
- }
16259
- throw configError(
16260
- "Durability requires a directory. Set durability.directory explicitly, or configure a filesystem persistence adapter"
16261
- );
16262
- }
16263
- if (config.persistence === void 0) {
16264
- return null;
16265
- }
16266
- if (filesystemDirectory !== null) {
16267
- return { kind: "wal", config: { directory: filesystemDirectory } };
16268
- }
16269
- return { kind: "snapshot", config: {}, adapter: config.persistence };
16270
- }
16271
-
16272
14649
  // src/engine/array-positions.ts
16273
14650
  function holdsStringArrayField(schema) {
16274
14651
  return schemaFieldsOf(schema).some((field) => field.base === "string[]");
@@ -16565,7 +14942,7 @@ async function createIndexFromMetadata(deps, metadata, loadData) {
16565
14942
  const existing = deps.indexRegistry.get(metadata.indexName);
16566
14943
  if (existing !== void 0) {
16567
14944
  if ((metadata.analysisGeneration ?? 0) > existing.analysisGeneration) {
16568
- const { adoptSavedAnalysis } = await import('./analysis-change-2V2HZ2NY.mjs');
14945
+ const { adoptSavedAnalysis } = await import('./analysis-change-TC36BU47.mjs');
16569
14946
  adoptSavedAnalysis(deps.executor.getManager(metadata.indexName), existing, metadata);
16570
14947
  }
16571
14948
  if (loadData && deps.executor.getManager(metadata.indexName) === void 0) {
@@ -16620,7 +14997,9 @@ async function createIndexFromMetadata(deps, metadata, loadData) {
16620
14997
  synonyms,
16621
14998
  analysisGeneration: metadata.analysisGeneration ?? 0,
16622
14999
  pendingAnalysis: metadata.pendingAnalysis ?? null,
16623
- durableAnalysis: null
15000
+ durableAnalysis: null,
15001
+ sync: metadata.sync?.enabled === true ? (await import('./sync-state-P5XG6LTQ.mjs')).syncStateOfMetadata(metadata) : null,
15002
+ querySuggestions: metadata.querySuggestions ?? null
16624
15003
  });
16625
15004
  if (loadData) await deps.indexState().registerOpen(metadata.indexName);
16626
15005
  else deps.indexState().registerClosed(metadata.indexName);
@@ -17415,9 +15794,9 @@ function captureComposite(manager, partitionId) {
17415
15794
  const segmentIds = partition.frozenSegmentSizes().map((size) => size.segmentId);
17416
15795
  const frozen = [];
17417
15796
  for (const segment of partition.frozenSegmentsById(segmentIds)) {
17418
- const shared2 = shareFrozenSegment(segment, manager.partialWordAnalysis);
17419
- if (shared2 === null) return null;
17420
- frozen.push(shared2);
15797
+ const shared = shareFrozenSegment(segment, manager.partialWordAnalysis);
15798
+ if (shared === null) return null;
15799
+ frozen.push(shared);
17421
15800
  }
17422
15801
  return { partitionId, live: captureLiveTail(partition.live), frozen };
17423
15802
  }
@@ -17461,11 +15840,11 @@ async function sendPartition(manager, executors, captured) {
17461
15840
  );
17462
15841
  }
17463
15842
  if (captured.frozen.length === 0) return;
17464
- const segments = captured.frozen.map((shared2) => ({
15843
+ const segments = captured.frozen.map((shared) => ({
17465
15844
  partitionId: captured.partitionId,
17466
- snapshot: shared2.snapshot,
17467
- tombstonedDocIds: shared2.tombstonedDocIds,
17468
- survivingSurfaceForms: shared2.survivingSurfaceForms
15845
+ snapshot: shared.snapshot,
15846
+ tombstonedDocIds: shared.tombstonedDocIds,
15847
+ survivingSurfaceForms: shared.survivingSurfaceForms
17469
15848
  }));
17470
15849
  await Promise.all(
17471
15850
  executors.map(
@@ -18687,7 +17066,7 @@ async function startPool(state) {
18687
17066
  );
18688
17067
  }
18689
17068
  eligibleIndexNames(state);
18690
- const [factory, { createWorkerPool }] = await Promise.all([createWorkerFactory(), import('./pool-DTYSPBMQ.mjs')]);
17069
+ const [factory, { createWorkerPool }] = await Promise.all([createWorkerFactory(), import('./pool-3JLET5RO.mjs')]);
18691
17070
  let started = null;
18692
17071
  const pool = createWorkerPool({
18693
17072
  count: state.keywordWorkerCount + state.longQueryWorkerCount,
@@ -19378,18 +17757,18 @@ async function emitWriteEventAfter(source, indexName, write) {
19378
17757
  // src/engine/core.ts
19379
17758
  async function createEngineCore(config, hooks, capacityScope = "index") {
19380
17759
  validateWorkerConfig(config?.workers, config?.lifecycle);
19381
- const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-D2ULZGCN.mjs')).resolveRerankSettings(config);
17760
+ const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-OTAGEFQW.mjs')).resolveRerankSettings(config);
19382
17761
  const eventHandlers = eventHandlersOf(config?.events);
19383
17762
  const vectorWorkerCount = splitWorkerBudget(resolveWorkerCount(config?.workers?.count)).vector;
19384
17763
  const vectorCopyPolicy = {
19385
17764
  enabled: (config?.workers?.enabled ?? workersEnabledByDefault()) && vectorWorkerCount > 0,
19386
17765
  count: vectorWorkerCount
19387
17766
  };
19388
- const durabilityTier = config !== void 0 ? resolveDurabilityTier(config) : null;
17767
+ const durabilityTier = config !== void 0 && (config.durability || config.persistence !== void 0) ? (await import('./durability-config-TIYKW6XX.mjs')).resolveDurabilityTier(config) : null;
19389
17768
  if (config?.lifecycle !== void 0 && durabilityTier === null) {
19390
17769
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index lifecycle settings require durability");
19391
17770
  }
19392
- const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-LM7WFL6X.mjs');
17771
+ const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-CVGPRO6D.mjs');
19393
17772
  const filesystemDurability = durabilityTier?.kind === "wal";
19394
17773
  const executor = createDirectExecutor({
19395
17774
  vectorWorkerCopies: vectorCopyPolicy,
@@ -19516,7 +17895,8 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
19516
17895
  if (entry === void 0) return;
19517
17896
  entry.documentCount = documentCount;
19518
17897
  entry.partitionCount = partitionCount;
19519
- }
17898
+ },
17899
+ engineCore: () => engineCore
19520
17900
  });
19521
17901
  invalidation = createInvalidationFromConfig(config, durabilityTier?.kind ?? null, {
19522
17902
  getManager: (indexName) => executor.getManager(indexName) ?? void 0,
@@ -19574,7 +17954,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
19574
17954
  requireManager,
19575
17955
  resumeChange: async (indexName) => {
19576
17956
  if ((indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
19577
- await (await import('./analysis-change-entry-JL5U2N3Q.mjs')).resumeChangeOf(engineCore, indexName);
17957
+ await (await import('./analysis-change-entry-4MH3CZXH.mjs')).resumeChangeOf(engineCore, indexName);
19578
17958
  },
19579
17959
  onClose: hooks?.onIndexClose,
19580
17960
  onOpen: (indexName) => {
@@ -19634,6 +18014,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
19634
18014
  orchestrator,
19635
18015
  rebalanceRouter,
19636
18016
  rebalancingIndexes,
18017
+ restoresInFlight: /* @__PURE__ */ new Map(),
19637
18018
  waqMap,
19638
18019
  guardShutdown,
19639
18020
  requireIndex,
@@ -19658,7 +18039,7 @@ async function startEngineCore(core, config) {
19658
18039
  checkHeapAfterRecovery(core);
19659
18040
  }
19660
18041
  if (core.invalidation) await core.invalidation.start();
19661
- if (core.durability) await (await import('./analysis-change-entry-JL5U2N3Q.mjs')).resumeEveryChange(core);
18042
+ if (core.durability) await (await import('./analysis-change-entry-4MH3CZXH.mjs')).resumeEveryChange(core);
19662
18043
  if (config?.lifecycle === void 0) await core.analysisRebuild.reviewStaleIndexes();
19663
18044
  } catch (err) {
19664
18045
  await core.durability?.manager.shutdown().catch(() => void 0);
@@ -19668,6 +18049,7 @@ async function startEngineCore(core, config) {
19668
18049
  }
19669
18050
  async function shutdownEngine(core) {
19670
18051
  const { executor, durability, indexRegistry, eventHandlers, orchestrator } = core;
18052
+ await core.querySuggestionHooks?.shutdown();
19671
18053
  core.indexState.dispose();
19672
18054
  if (durability) {
19673
18055
  await durability.manager.shutdown();
@@ -19696,7 +18078,7 @@ async function shutdownEngine(core) {
19696
18078
  }
19697
18079
  }
19698
18080
  if (core.rerankAdapters.size > 0) {
19699
- await (await import('./runtime-D2ULZGCN.mjs')).shutdownRerankAdapters(core.rerankAdapters);
18081
+ await (await import('./runtime-OTAGEFQW.mjs')).shutdownRerankAdapters(core.rerankAdapters);
19700
18082
  }
19701
18083
  await orchestrator.shutdown();
19702
18084
  await executor.shutdown();
@@ -19828,162 +18210,7 @@ function storedBM25Params(params) {
19828
18210
  return Object.keys(stored).length === 0 ? void 0 : stored;
19829
18211
  }
19830
18212
 
19831
- // src/serialization/crc32.ts
19832
- var IEEE_POLYNOMIAL = 3988292384;
19833
- var ALL_BITS = 4294967295;
19834
- var cachedTable = null;
19835
- function buildTable() {
19836
- const table = new Uint32Array(256);
19837
- for (let i = 0; i < 256; i++) {
19838
- let crc = i;
19839
- for (let bit = 0; bit < 8; bit++) {
19840
- crc = crc & 1 ? crc >>> 1 ^ IEEE_POLYNOMIAL : crc >>> 1;
19841
- }
19842
- table[i] = crc;
19843
- }
19844
- return table;
19845
- }
19846
- function getTable() {
19847
- if (cachedTable === null) {
19848
- cachedTable = buildTable();
19849
- }
19850
- return cachedTable;
19851
- }
19852
- function crc32(data) {
19853
- return crc32Final(crc32Update(crc32Init(), data));
19854
- }
19855
- function crc32Init() {
19856
- return ALL_BITS;
19857
- }
19858
- function crc32Update(state, data) {
19859
- const table = getTable();
19860
- let crc = state;
19861
- for (let i = 0; i < data.length; i++) {
19862
- crc = crc >>> 8 ^ table[(crc ^ data[i]) & 255];
19863
- }
19864
- return crc;
19865
- }
19866
- function crc32Final(state) {
19867
- return (state ^ ALL_BITS) >>> 0;
19868
- }
19869
-
19870
- // src/serialization/chunk-checksum.ts
19871
- function yieldToEventLoop3() {
19872
- if (typeof setImmediate === "function") {
19873
- return new Promise((resolve) => setImmediate(resolve));
19874
- }
19875
- return new Promise((resolve) => setTimeout(resolve, 0));
19876
- }
19877
- async function advanceChecksum(start, payload) {
19878
- let state = start;
19879
- for (let offset = 0; offset < payload.length; offset += CHECKSUM_YIELD_CHUNK_BYTES) {
19880
- const end = Math.min(offset + CHECKSUM_YIELD_CHUNK_BYTES, payload.length);
19881
- state = crc32Update(state, payload.subarray(offset, end));
19882
- if (end < payload.length) {
19883
- await yieldToEventLoop3();
19884
- }
19885
- }
19886
- return state;
19887
- }
19888
- async function checksumOfChunks(chunks) {
19889
- let state = crc32Init();
19890
- for (const chunk of chunks) state = await advanceChecksum(state, chunk);
19891
- return crc32Final(state);
19892
- }
19893
-
19894
- // src/serialization/header.ts
19895
- var MAGIC_BYTES = new Uint8Array([78, 82, 83, 76]);
19896
- var HEADER_SIZE = 32;
19897
- var MAX_PAYLOAD_LENGTH = 4294967295;
19898
- var COMPRESSION_ALGORITHMS = {
19899
- 0: "none",
19900
- 1: "gzip",
19901
- 2: "lz4",
19902
- 3: "zstd"
19903
- };
19904
- var COMPRESSION_TO_BITS = {
19905
- none: 0,
19906
- gzip: 1,
19907
- lz4: 2,
19908
- zstd: 3
19909
- };
19910
- function encodeFlags(flags) {
19911
- let bits = 0;
19912
- if (flags.compressionEnabled) bits |= 1;
19913
- bits |= (COMPRESSION_TO_BITS[flags.compressionAlgorithm] & 3) << 1;
19914
- if (flags.checksumPresent) bits |= 1 << 3;
19915
- if (flags.encryptionEnabled) bits |= 1 << 4;
19916
- return bits;
19917
- }
19918
- function decodeFlags(value) {
19919
- const compressionEnabled = (value & 1) === 1;
19920
- const algorithmBits = value >> 1 & 3;
19921
- const checksumPresent = (value >> 3 & 1) === 1;
19922
- const encryptionEnabled = (value >> 4 & 1) === 1;
19923
- return {
19924
- compressionEnabled,
19925
- compressionAlgorithm: COMPRESSION_ALGORITHMS[algorithmBits] ?? "none",
19926
- checksumPresent,
19927
- encryptionEnabled
19928
- };
19929
- }
19930
- function writeHeader(header) {
19931
- if (header.payloadLength > MAX_PAYLOAD_LENGTH) {
19932
- throw new NarsilError(
19933
- ErrorCodes.PERSISTENCE_SAVE_FAILED,
19934
- `A payload of ${header.payloadLength} bytes exceeds the ${MAX_PAYLOAD_LENGTH} bytes the envelope header can describe`,
19935
- { payloadLength: header.payloadLength, maxPayloadLength: MAX_PAYLOAD_LENGTH }
19936
- );
19937
- }
19938
- const buffer = new Uint8Array(HEADER_SIZE);
19939
- const view = new DataView(buffer.buffer);
19940
- buffer.set(MAGIC_BYTES, 0);
19941
- buffer[4] = header.envelopeFormatVersion & 255;
19942
- buffer[5] = header.engineVersionMajor & 255;
19943
- buffer[6] = header.engineVersionMinor & 255;
19944
- buffer[7] = header.engineVersionPatch & 255;
19945
- view.setUint32(8, header.payloadLength, false);
19946
- view.setUint16(12, encodeFlags(header.flags), false);
19947
- view.setUint32(14, header.checksum, false);
19948
- for (let i = 18; i < HEADER_SIZE; i++) {
19949
- buffer[i] = 0;
19950
- }
19951
- return buffer;
19952
- }
19953
- function hasNrslMagic(data) {
19954
- return data.length >= MAGIC_BYTES.length && data[0] === MAGIC_BYTES[0] && data[1] === MAGIC_BYTES[1] && data[2] === MAGIC_BYTES[2] && data[3] === MAGIC_BYTES[3];
19955
- }
19956
- function readHeader(data) {
19957
- if (data.length < HEADER_SIZE) {
19958
- throw new NarsilError(
19959
- ErrorCodes.ENVELOPE_INVALID_MAGIC,
19960
- `Expected at least ${HEADER_SIZE} bytes, received ${data.length}`
19961
- );
19962
- }
19963
- if (data[0] !== MAGIC_BYTES[0] || data[1] !== MAGIC_BYTES[1] || data[2] !== MAGIC_BYTES[2] || data[3] !== MAGIC_BYTES[3]) {
19964
- throw new NarsilError(ErrorCodes.ENVELOPE_INVALID_MAGIC, "File does not begin with NRSL magic bytes");
19965
- }
19966
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
19967
- const envelopeFormatVersion = data[4];
19968
- const engineVersionMajor = data[5];
19969
- const engineVersionMinor = data[6];
19970
- const engineVersionPatch = data[7];
19971
- const payloadLength = view.getUint32(8, false);
19972
- const flagBits = view.getUint16(12, false);
19973
- const checksum = view.getUint32(14, false);
19974
- const reserved = data.slice(18, HEADER_SIZE);
19975
- return {
19976
- magic: "NRSL",
19977
- envelopeFormatVersion,
19978
- engineVersionMajor,
19979
- engineVersionMinor,
19980
- engineVersionPatch,
19981
- payloadLength,
19982
- flags: decodeFlags(flagBits),
19983
- checksum,
19984
- reserved
19985
- };
19986
- }
18213
+ // src/serialization/envelope-file.ts
19987
18214
  function engineVersionParts() {
19988
18215
  const parts = VERSION.split(".");
19989
18216
  return [
@@ -19992,103 +18219,15 @@ function engineVersionParts() {
19992
18219
  Number.parseInt(parts[2] ?? "0", 10)
19993
18220
  ];
19994
18221
  }
19995
- function payloadByteLength(chunks) {
19996
- let total = 0;
19997
- for (const chunk of chunks) total += chunk.byteLength;
19998
- return total;
19999
- }
20000
- function requireWithinFileLimit(byteLength, what) {
20001
- if (byteLength <= MAX_FILE_BYTES) return;
20002
- throw new NarsilError(
20003
- ErrorCodes.PERSISTENCE_SAVE_FAILED,
20004
- `The ${what} would take ${byteLength} bytes, above the file size limit of ${MAX_FILE_BYTES}`,
20005
- { bytes: byteLength, maximum: MAX_FILE_BYTES }
20006
- );
20007
- }
20008
18222
  async function packChecksummedEnvelope(payloadChunks, envelopeFormatVersion, what) {
20009
18223
  requireWithinFileLimit(HEADER_SIZE + payloadByteLength(payloadChunks), what);
20010
18224
  return packEnvelopeWithChecksum(payloadChunks, envelopeFormatVersion, what, await checksumOfChunks(payloadChunks));
20011
18225
  }
20012
18226
  function packEnvelopeWithChecksum(payloadChunks, envelopeFormatVersion, what, checksum) {
20013
- const payloadLength = payloadByteLength(payloadChunks);
20014
- requireWithinFileLimit(HEADER_SIZE + payloadLength, what);
20015
- const [major, minor, patch] = engineVersionParts();
20016
- const header = writeHeader({
20017
- envelopeFormatVersion,
20018
- engineVersionMajor: major,
20019
- engineVersionMinor: minor,
20020
- engineVersionPatch: patch,
20021
- payloadLength,
20022
- flags: { compressionEnabled: false, compressionAlgorithm: "none", checksumPresent: true, encryptionEnabled: false },
20023
- checksum});
20024
- return { chunks: [header, ...payloadChunks], byteLength: HEADER_SIZE + payloadLength, checksum };
20025
- }
20026
- function loadFailed(message, details) {
20027
- throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, message, details);
20028
- }
20029
- async function gunzipWithinLimit(compressed, what) {
20030
- const { gunzip } = await import('./gzip-5S7ROJFJ.mjs');
20031
- try {
20032
- return await gunzip(compressed, MAX_FILE_BYTES);
20033
- } catch (error) {
20034
- if (error?.code === "EFBIG") {
20035
- loadFailed(`The ${what} inflates past the file size limit of ${MAX_FILE_BYTES} bytes`);
20036
- }
20037
- loadFailed(`The ${what} holds a gzip payload that fails to inflate`, {
20038
- cause: error instanceof Error ? error.message : String(error)
20039
- });
20040
- }
20041
- }
20042
- async function openChecksummedEnvelope(data, expected) {
20043
- const { envelopeFormatVersion, what } = expected;
20044
- const header = readHeader(data);
20045
- if (header.envelopeFormatVersion !== envelopeFormatVersion) {
20046
- throw new NarsilError(
20047
- ErrorCodes.ENVELOPE_VERSION_MISMATCH,
20048
- `The ${what} holds envelope format v${header.envelopeFormatVersion}, while this build reads it as v${envelopeFormatVersion}`,
20049
- { version: header.envelopeFormatVersion, expected: envelopeFormatVersion }
20050
- );
20051
- }
20052
- if (header.flags.encryptionEnabled) {
20053
- throw new NarsilError(
20054
- ErrorCodes.ENVELOPE_VERSION_MISMATCH,
20055
- `The ${what} is encrypted, which this build cannot read`
20056
- );
20057
- }
20058
- if (header.flags.compressionEnabled && !expected.allowsCompression) {
20059
- loadFailed(`The ${what} is compressed, while its format stores it raw`);
20060
- }
20061
- if (header.flags.compressionEnabled && header.flags.compressionAlgorithm !== "gzip") {
20062
- throw new NarsilError(
20063
- ErrorCodes.ENVELOPE_VERSION_MISMATCH,
20064
- `The ${what} uses ${header.flags.compressionAlgorithm} compression, which this build cannot read`
20065
- );
20066
- }
20067
- if (!header.flags.checksumPresent) loadFailed(`The ${what} carries no checksum, while its format requires one`);
20068
- if (data.byteLength !== HEADER_SIZE + header.payloadLength) {
20069
- loadFailed(
20070
- `The ${what} holds ${data.byteLength} bytes where its header gives ${HEADER_SIZE + header.payloadLength}`,
20071
- { bytes: data.byteLength, expected: HEADER_SIZE + header.payloadLength }
20072
- );
20073
- }
20074
- const payload = data.subarray(HEADER_SIZE);
20075
- const computed = await checksumOfChunks([payload]);
20076
- if (computed !== header.checksum) {
20077
- throw new NarsilError(
20078
- ErrorCodes.PERSISTENCE_CRC_MISMATCH,
20079
- `The checksum of the ${what} does not match its payload`,
20080
- {
20081
- expected: header.checksum,
20082
- computed
20083
- }
20084
- );
20085
- }
20086
- if (header.flags.compressionEnabled) return { header, payload: await gunzipWithinLimit(payload, what) };
20087
- return { header, payload };
18227
+ return packEnvelopeWithEngineVersion(payloadChunks, envelopeFormatVersion, what, checksum, engineVersionParts());
20088
18228
  }
20089
18229
 
20090
18230
  // src/engine/snapshot/index-configuration.ts
20091
- var INDEX_CONFIGURATION_ENVELOPE_VERSION = 5;
20092
18231
  function refuseCode(entry) {
20093
18232
  if (entry.config.tokenizer !== void 0 && typeof entry.config.tokenizer !== "string") {
20094
18233
  throw new NarsilError(
@@ -20106,7 +18245,7 @@ function refuseCode(entry) {
20106
18245
  function indexConfigurationOf(entry) {
20107
18246
  refuseCode(entry);
20108
18247
  const synonyms = entry.synonyms === null ? void 0 : rulesOfStoredSynonyms(entry.synonyms);
20109
- return configurationPayloadOf(
18248
+ const payload = configurationPayloadOf(
20110
18249
  entry.config,
20111
18250
  entry.language,
20112
18251
  entry.embeddingAdapterName,
@@ -20115,6 +18254,8 @@ function indexConfigurationOf(entry) {
20115
18254
  synonyms,
20116
18255
  entry.analysisGeneration
20117
18256
  );
18257
+ const withSuggestions = { ...payload, ...entry.querySuggestions };
18258
+ return entry.sync === null ? withSuggestions : { ...withSuggestions, syncEpoch: entry.sync.epoch };
20118
18259
  }
20119
18260
  function requireConfigurationWithinSizeLimit(config, language) {
20120
18261
  const adapter = config.embedding?.adapter;
@@ -20184,33 +18325,6 @@ async function encodeIndexConfiguration(entry) {
20184
18325
  }
20185
18326
  return bytes;
20186
18327
  }
20187
- function requireConfigurationShape(raw, what) {
20188
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
20189
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The ${what} does not hold an index configuration`);
20190
- }
20191
- const configuration = raw;
20192
- if (configuration.schema === null || typeof configuration.schema !== "object") {
20193
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The ${what} holds no schema`);
20194
- }
20195
- if (typeof configuration.language !== "string" || configuration.language.length === 0) {
20196
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The ${what} holds no language`);
20197
- }
20198
- return configuration;
20199
- }
20200
- async function decodeIndexConfiguration(bytes) {
20201
- const { payload } = await openChecksummedEnvelope(bytes, {
20202
- envelopeFormatVersion: INDEX_CONFIGURATION_ENVELOPE_VERSION,
20203
- what: "index configuration",
20204
- allowsCompression: true
20205
- });
20206
- let raw;
20207
- try {
20208
- raw = decode(payload);
20209
- } catch {
20210
- throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, "The index configuration is not MessagePack");
20211
- }
20212
- return requireConfigurationShape(raw, "index configuration");
20213
- }
20214
18328
 
20215
18329
  // src/engine/index-lifecycle.ts
20216
18330
  async function runLifecycleHook(core, hookName, context) {
@@ -20308,6 +18422,7 @@ async function createEngineIndex(core, config, name, requestedConfig, creation =
20308
18422
  const language = getLanguage(indexConfig.language ?? "english");
20309
18423
  if (appliesCreationLimits) requireConfigurationWithinSizeLimit(indexConfig, language);
20310
18424
  const synonyms = prepareConfiguredSynonyms(configured, language, appliesCreationLimits);
18425
+ await core.querySuggestionHooks?.beforeCreate(name);
20311
18426
  core.executor.createIndex(name, indexConfig, language, false, synonyms?.lookup ?? null);
20312
18427
  core.indexRegistry.set(name, {
20313
18428
  config: indexConfig,
@@ -20324,7 +18439,9 @@ async function createEngineIndex(core, config, name, requestedConfig, creation =
20324
18439
  synonyms: synonyms?.encoded ?? null,
20325
18440
  analysisGeneration: 0,
20326
18441
  pendingAnalysis: null,
20327
- durableAnalysis: null
18442
+ durableAnalysis: null,
18443
+ sync: null,
18444
+ querySuggestions: creation.querySuggestions ?? null
20328
18445
  });
20329
18446
  await core.indexState.registerOpen(name);
20330
18447
  if (core.durability) {
@@ -20337,10 +18454,11 @@ async function dropEngineIndex(core, name) {
20337
18454
  const entry = core.requireIndex(name);
20338
18455
  const changeRecorded = () => entry.pendingAnalysis !== null || entry.durableAnalysis !== null;
20339
18456
  const abandonChange = async () => {
20340
- await (await import('./analysis-change-entry-JL5U2N3Q.mjs')).abandonChangeOf(core, name);
18457
+ await (await import('./analysis-change-entry-4MH3CZXH.mjs')).abandonChangeOf(core, name);
20341
18458
  };
20342
18459
  if (changeRecorded()) await abandonChange();
20343
18460
  await core.indexState.drop(name, async () => {
18461
+ await core.querySuggestionHooks?.beforeDrop(name);
20344
18462
  await core.analysisRebuild.abandon(name);
20345
18463
  if (changeRecorded()) await abandonChange();
20346
18464
  await core.orchestrator.closeIndex(name);
@@ -20356,7 +18474,9 @@ async function dropEngineIndex(core, name) {
20356
18474
  core.indexRegistry.delete(name);
20357
18475
  core.watermarkNotifier.forget(name);
20358
18476
  core.analysisRebuild.clearStale(name);
18477
+ if (entry.sync !== null) emitSyncChange(core.indexRegistry, { kind: "dropped", indexName: name });
20359
18478
  });
18479
+ await core.querySuggestionHooks?.afterDrop(name);
20360
18480
  await runLifecycleHook(core, "onIndexDrop", { indexName: name, config: entry.config });
20361
18481
  }
20362
18482
  function registerEngineEmbeddingAdapter(core, name, adapter) {
@@ -21179,11 +19299,11 @@ function payloadSegments(segments) {
21179
19299
  return plain;
21180
19300
  }
21181
19301
  function snapshotSegments(segments) {
21182
- const shared2 = [];
19302
+ const shared = [];
21183
19303
  for (const segment of segments) {
21184
- if (segment.snapshot !== null) shared2.push({ partitionId: segment.partitionId, snapshot: segment.snapshot });
19304
+ if (segment.snapshot !== null) shared.push({ partitionId: segment.partitionId, snapshot: segment.snapshot });
21185
19305
  }
21186
- return shared2;
19306
+ return shared;
21187
19307
  }
21188
19308
  function attachSegments2(orchestrator, indexName, segments) {
21189
19309
  return orchestrator.replicateToWorkers({
@@ -21199,8 +19319,8 @@ async function broadcastBuiltSegments(orchestrator, indexName, segments, skipClo
21199
19319
  await attachSegments2(orchestrator, indexName, frozen);
21200
19320
  return;
21201
19321
  }
21202
- const shared2 = snapshotSegments(segments);
21203
- if (shared2.length > 0) await attachSegments2(orchestrator, indexName, shared2);
19322
+ const shared = snapshotSegments(segments);
19323
+ if (shared.length > 0) await attachSegments2(orchestrator, indexName, shared);
21204
19324
  const plain = payloadSegments(segments);
21205
19325
  if (plain.length === 0) return;
21206
19326
  await orchestrator.replicateToWorkers({
@@ -21966,6 +20086,31 @@ async function updateDocumentBatch(ctx, indexName, updates, options) {
21966
20086
  return { succeeded, failed };
21967
20087
  }
21968
20088
 
20089
+ // src/engine/sync-epoch.ts
20090
+ async function holdSyncEpochChange(core, indexName) {
20091
+ if ((core.indexRegistry.get(indexName)?.sync ?? null) === null) return () => void 0;
20092
+ return (await import('./operations-OJ3BXS55.mjs')).holdRenewedSyncEpoch(core, indexName);
20093
+ }
20094
+ async function withRenewedSyncEpoch(core, indexName, change) {
20095
+ const release = await holdSyncEpochChange(core, indexName);
20096
+ try {
20097
+ return await change();
20098
+ } finally {
20099
+ release();
20100
+ }
20101
+ }
20102
+
20103
+ // src/engine/clear-index.ts
20104
+ function clearEngineIndex(core, indexName) {
20105
+ return withRenewedSyncEpoch(core, indexName, async () => {
20106
+ await core.executor.execute({ type: "clear", indexName, requestId: indexName });
20107
+ await core.orchestrator.replicateToWorkers({ type: "clear", indexName, requestId: `replicate-clear-${indexName}` });
20108
+ core.watermarkNotifier.forget(indexName);
20109
+ const durable = core.durability?.manager;
20110
+ await (durable?.checkpointFromMemory?.(indexName) ?? durable?.checkpoint(indexName));
20111
+ });
20112
+ }
20113
+
21969
20114
  // src/runtime/process-memory.ts
21970
20115
  function readProcessMemory() {
21971
20116
  const proc = globalThis.process;
@@ -21990,35 +20135,6 @@ function readProcessMemory() {
21990
20135
  }
21991
20136
  }
21992
20137
 
21993
- // src/engine/serial-index-update.ts
21994
- var updatingByCore = /* @__PURE__ */ new WeakMap();
21995
- async function withOpenIndex(core, indexName, action) {
21996
- core.guardShutdown();
21997
- core.requireIndex(indexName);
21998
- const release = await core.indexState.acquire(indexName);
21999
- try {
22000
- return await action();
22001
- } finally {
22002
- release();
22003
- }
22004
- }
22005
- async function oneAtATime(core, indexName, action) {
22006
- let chains = updatingByCore.get(core);
22007
- if (chains === void 0) {
22008
- chains = /* @__PURE__ */ new Map();
22009
- updatingByCore.set(core, chains);
22010
- }
22011
- const updating = chains;
22012
- const earlier = updating.get(indexName) ?? Promise.resolve();
22013
- const current = earlier.catch(() => void 0).then(action);
22014
- updating.set(indexName, current);
22015
- try {
22016
- return await current;
22017
- } finally {
22018
- if (updating.get(indexName) === current) updating.delete(indexName);
22019
- }
22020
- }
22021
-
22022
20138
  // src/engine/bm25-update.ts
22023
20139
  async function replaceNow(core, indexName, bm25) {
22024
20140
  const { config } = core.requireIndex(indexName);
@@ -22037,6 +20153,7 @@ async function replaceNow(core, indexName, bm25) {
22037
20153
  ...bm25 !== void 0 ? { bm25 } : {}
22038
20154
  });
22039
20155
  await core.orchestrator.awaitWrites(indexName);
20156
+ if (core.requireIndex(indexName).sync !== null) emitSyncChange(core.indexRegistry, { kind: "settings", indexName });
22040
20157
  }
22041
20158
  function updateIndexBm25(core, indexName, value) {
22042
20159
  return withOpenIndex(
@@ -22064,6 +20181,9 @@ var engineCores = /* @__PURE__ */ new WeakMap();
22064
20181
  function bindEngineCore(engine, core) {
22065
20182
  engineCores.set(engine, core);
22066
20183
  }
20184
+ function engineCoreOf(engine) {
20185
+ return engineCores.get(engine);
20186
+ }
22067
20187
 
22068
20188
  // src/narsil/portability.ts
22069
20189
  function portabilityOperations(core, config, engine) {
@@ -22077,7 +20197,23 @@ function portabilityOperations(core, config, engine) {
22077
20197
  release();
22078
20198
  }
22079
20199
  }
22080
- const restoresInFlight = /* @__PURE__ */ new Map();
20200
+ function queueRestore(indexName, data) {
20201
+ const { restoresInFlight } = core;
20202
+ const previous = restoresInFlight.get(indexName) ?? Promise.resolve();
20203
+ const restored = previous.then(async () => {
20204
+ const { runRestore } = await import('./restore-queue-ZBS7CJA6.mjs');
20205
+ await runRestore(core, restoreHost, indexName, data, engine());
20206
+ });
20207
+ const settled2 = restored.then(
20208
+ () => void 0,
20209
+ () => void 0
20210
+ );
20211
+ restoresInFlight.set(indexName, settled2);
20212
+ void settled2.then(() => {
20213
+ if (restoresInFlight.get(indexName) === settled2) restoresInFlight.delete(indexName);
20214
+ });
20215
+ return restored;
20216
+ }
22081
20217
  const restoreHost = {
22082
20218
  getVectorFieldPaths,
22083
20219
  announceIndexCreated: (name, restoredConfig) => announceIndexCreated(core, name, restoredConfig),
@@ -22094,26 +20230,23 @@ function portabilityOperations(core, config, engine) {
22094
20230
  };
22095
20231
  }
22096
20232
  return {
22097
- snapshot(indexName) {
20233
+ snapshot(indexName, options) {
22098
20234
  return withOpenIndex2(indexName, async () => {
22099
- const { createSnapshot } = await import('./snapshot-UGZVMP4H.mjs');
22100
- return createSnapshot(snapshotDepsOf(indexName));
20235
+ const { createSnapshot } = await import('./snapshot-PN7ZW6Q4.mjs');
20236
+ return createSnapshot(snapshotDepsOf(indexName), options?.queryHistory === true ? core : null);
22101
20237
  });
22102
20238
  },
22103
20239
  async restore(indexName, data) {
22104
20240
  core.guardShutdown();
22105
20241
  validateIndexName(indexName);
22106
- const restored = import('./restore-queue-UQ6AAUVX.mjs').then(
22107
- ({ queueRestore }) => queueRestore(core, restoreHost, restoresInFlight, indexName, data)
22108
- );
22109
- await emitWriteEventAfter(core, indexName, restored);
20242
+ await emitWriteEventAfter(core, indexName, queueRestore(indexName, data));
22110
20243
  core.heapPressureNotifier.check(indexName);
22111
20244
  },
22112
20245
  exportDocuments(indexName) {
22113
20246
  return withOpenIndex2(indexName, async () => {
22114
20247
  const [{ checkpointForArchive }, { documentExportStream }] = await Promise.all([
22115
- import('./snapshot-UGZVMP4H.mjs'),
22116
- import('./write-I5P5MW4O.mjs')
20248
+ import('./snapshot-PN7ZW6Q4.mjs'),
20249
+ import('./write-HMDYCTV2.mjs')
22117
20250
  ]);
22118
20251
  const header = indexConfigurationOf(core.requireIndex(indexName));
22119
20252
  return documentExportStream(header, await checkpointForArchive(snapshotDepsOf(indexName)));
@@ -22121,7 +20254,7 @@ function portabilityOperations(core, config, engine) {
22121
20254
  },
22122
20255
  importDocumentExport(indexName, data) {
22123
20256
  core.guardShutdown();
22124
- const imported = import('./import-QOY6ZH6X.mjs').then(
20257
+ const imported = import('./import-OM6QAW45.mjs').then(
22125
20258
  ({ readDocumentExport }) => readDocumentExport(engine(), indexName, data)
22126
20259
  );
22127
20260
  return emitWriteEventAfter(core, indexName, imported);
@@ -23428,7 +21561,7 @@ function requireCursorDepth(cursor, signature, binding) {
23428
21561
  }
23429
21562
  function hybridSearchOf(params, context, limit, offset, cursorDepth) {
23430
21563
  if ((params.hybrid?.depth ?? null) === null) return executeHybridSearch(params, context, limit, offset, cursorDepth);
23431
- return import('./runtime-D2ULZGCN.mjs').then(
21564
+ return import('./runtime-OTAGEFQW.mjs').then(
23432
21565
  (runtime) => runtime.searchFixedDepthHybrid(params, context, { cursorDepth: cursorDepth ?? 0, offset, limit }, runtimeHost)
23433
21566
  );
23434
21567
  }
@@ -23438,7 +21571,7 @@ function executeQuery(request, callerContext) {
23438
21571
  if (loadingPhraseCode === null) return runQuery(request, callerContext);
23439
21572
  return loadingPhraseCode.then(() => runQuery(request, callerContext));
23440
21573
  }
23441
- return import('./runtime-D2ULZGCN.mjs').then(
21574
+ return import('./runtime-OTAGEFQW.mjs').then(
23442
21575
  (runtime) => runtime.executeRerankedQuery(request, callerContext, executeQuery, runtimeHost)
23443
21576
  );
23444
21577
  }
@@ -23837,7 +21970,7 @@ async function runEngineQuery(core, indexName, params, options) {
23837
21970
  const manager = core.requireManager(indexName);
23838
21971
  const scoped = scopedParams(params, options);
23839
21972
  await core.pluginRegistry.runHook("beforeSearch", { indexName, params: scoped });
23840
- const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-D2ULZGCN.mjs');
21973
+ const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-OTAGEFQW.mjs');
23841
21974
  const resolvedParams = await resolveVectorText(
23842
21975
  rerank === void 0 ? scoped : rerank.withRerankQueryText(scoped),
23843
21976
  entry.embeddingAdapter,
@@ -23956,6 +22089,14 @@ async function runEngineListDocuments(core, indexName, params, partitionIds) {
23956
22089
  }
23957
22090
  }
23958
22091
 
22092
+ // src/narsil/sync.ts
22093
+ function syncOperations(core) {
22094
+ return {
22095
+ updateSync: async (indexName, setting) => (await import('./methods-KTQCSIN4.mjs')).updateSyncOf(core, indexName, setting),
22096
+ getSync: async (indexName) => (await import('./methods-KTQCSIN4.mjs')).syncOf(core, indexName)
22097
+ };
22098
+ }
22099
+
23959
22100
  // src/narsil/synonyms.ts
23960
22101
  function synonymOperations(core) {
23961
22102
  return {
@@ -24134,7 +22275,7 @@ function createNarsilFromCore(core, config) {
24134
22275
  const entry = requireIndex(indexName);
24135
22276
  await withOpenIndexWrite(indexName, async () => {
24136
22277
  if (entry.pendingAnalysis === null) return core.analysisRebuild.rebuild(indexName);
24137
- return (await import('./analysis-change-2V2HZ2NY.mjs')).resumeAnalysisChange(core, indexName);
22278
+ return (await import('./analysis-change-TC36BU47.mjs')).resumeAnalysisChange(core, indexName);
24138
22279
  });
24139
22280
  },
24140
22281
  async changeAnalysis(indexName, change) {
@@ -24142,13 +22283,14 @@ function createNarsilFromCore(core, config) {
24142
22283
  requireIndex(indexName);
24143
22284
  const changed = withOpenIndex2(
24144
22285
  indexName,
24145
- async () => (await import('./analysis-change-2V2HZ2NY.mjs')).changeIndexAnalysis(core, indexName, change)
22286
+ async () => (await import('./analysis-change-TC36BU47.mjs')).changeIndexAnalysis(core, indexName, change)
24146
22287
  );
24147
22288
  await emitWriteEventAfter(core, indexName, changed);
24148
22289
  },
24149
22290
  ...portabilityOperations(core, config, () => narsil),
24150
22291
  ...synonymOperations(core),
24151
22292
  ...bm25Operations(core),
22293
+ ...syncOperations(core),
24152
22294
  async checkpoint(indexName) {
24153
22295
  guardShutdown();
24154
22296
  requireIndex(indexName);
@@ -24159,13 +22301,7 @@ function createNarsilFromCore(core, config) {
24159
22301
  async clear(indexName) {
24160
22302
  guardShutdown();
24161
22303
  requireIndex(indexName);
24162
- await withOpenIndexWrite(indexName, async () => {
24163
- await executor.execute({ type: "clear", indexName, requestId: indexName });
24164
- await orchestrator.replicateToWorkers({ type: "clear", indexName, requestId: `replicate-clear-${indexName}` });
24165
- core.watermarkNotifier.forget(indexName);
24166
- const durable = core.durability?.manager;
24167
- await (durable?.checkpointFromMemory?.(indexName) ?? durable?.checkpoint(indexName));
24168
- });
22304
+ await withOpenIndexWrite(indexName, () => clearEngineIndex(core, indexName));
24169
22305
  },
24170
22306
  async rebalance(indexName, targetPartitionCount) {
24171
22307
  guardShutdown();
@@ -24179,12 +22315,15 @@ function createNarsilFromCore(core, config) {
24179
22315
  if (rebalancesStarting.get(indexName) === started) rebalancesStarting.delete(indexName);
24180
22316
  }
24181
22317
  rebalancesStarting.set(indexName, started);
24182
- const rebalanced = withOpenIndex2(indexName, async () => {
24183
- const { executeRebalance } = await import('./analysis-change-2V2HZ2NY.mjs');
24184
- const running = executeRebalance(requireManager(indexName), indexName, targetPartitionCount, rebalanceCtx);
24185
- releaseWrites();
24186
- return running;
24187
- });
22318
+ const rebalanced = withOpenIndex2(
22319
+ indexName,
22320
+ () => withRenewedSyncEpoch(core, indexName, async () => {
22321
+ const { executeRebalance } = await import('./analysis-change-TC36BU47.mjs');
22322
+ const running = executeRebalance(requireManager(indexName), indexName, targetPartitionCount, rebalanceCtx);
22323
+ releaseWrites();
22324
+ await running;
22325
+ })
22326
+ );
24188
22327
  return emitWriteEventAfter(core, indexName, rebalanced).finally(releaseWrites);
24189
22328
  },
24190
22329
  async updatePartitionConfig(indexName, partitionConfig) {
@@ -24301,10 +22440,14 @@ async function createNarsil(config) {
24301
22440
  const runnableConfig = await resolveRunnableConfig(config);
24302
22441
  const core = await createEngineCore(runnableConfig);
24303
22442
  await startEngineCore(core, runnableConfig);
24304
- return createNarsilFromCore(core, runnableConfig);
22443
+ const engine = createNarsilFromCore(core, runnableConfig);
22444
+ if (runnableConfig?.querySuggestions !== void 0 || core.durability !== null) {
22445
+ await (await import('./engine-hooks-YXMPHZKZ.mjs')).startQuerySuggestions(core, engine, runnableConfig);
22446
+ }
22447
+ return engine;
24305
22448
  }
24306
22449
 
24307
22450
  // src/index.ts
24308
22451
  var VERSION = "0.1.0";
24309
22452
 
24310
- export { ARRAY_POSITION_GAP, DEFAULT_BM25_B, DEFAULT_BM25_K1, DEFAULT_WRITE_AHEAD_QUEUE_MAX_SIZE, HEADER_SIZE, MAX_DOCUMENT_NESTING_DEPTH, REBALANCE_CHUNK_SIZE, VECTOR_PATTERN, VERSION, arrayPositionsAreStale, assemblePagedFrozenSegment, buildPartialWordTableFrom, buildSegmentPayload, checksumOfChunks, clearNormalizationCache, configureNormalizationCache, crc32, crc32Final, crc32Init, crc32Update, createCompositePartition, createEncodedDocumentSource, createFrozenSegment, createNarsil, createPartitionIndex, createPartitionManager, createPartitionRouter, createSharedFrozenSegment, decodeEveryStoredDocument, decodeIndexConfiguration, decodeMapWithoutFields, decodeStoredDocument, decodeSurfaceTable, deleteNestedValue, emitEngineEvent, encodeDocument, encodeIndexConfiguration, encodeSurfaceTable, endOfValue, engineVersionParts, extractVectorFieldsFromSchema, extractVectorFromDoc, fieldIndexRemapOf, flattenSchema, freezeSegmentShared, generateId, getLanguage, getNestedValue, getNormalizationCacheSize, getStopWords, getTokenizer, hasNrslMagic, hasStopWords, hasTokenizer, holdsADiscardedField, insertDocumentVectors, isCompositePartition, isQuantizationMode, isStorageMode, loadVectorCodeFor, mergeDocFrequencies, mergeFieldIndexes2 as mergeFieldIndexes, mergeFieldLengths, mergePartialWords, mergeSegmentContents, mergeSurfaceForms2 as mergeSurfaceForms, messagePackUpperBoundBytes, openChecksummedEnvelope, packChecksummedEnvelope, packEnvelopeWithChecksum, parseVectorDimension, partialFieldsOf, partitionStateOf, prepareConfiguredSynonyms, prepareDocumentVectors, prepareStoredSynonyms, raiseEarlierReleaseGraphSetting, readHeader, readHeapStatistics, readResidentMemory, rebuildTextIndexes, reconstructSchemaFromMetadata, registerLanguage, registerPartialWordSearch, registerPatternSearch, registerStopWords, registerSynonyms, registerTokenizer, removeDocumentVectors, requireConfigurationShape, requireConfigurationWithinSizeLimit, requireSurfaceFormsForPartialFields, requireValidFieldTypes, requireWithinFileLimit, resetNormalizationCache, resolveIndexAnalysis, resolvePartialWordAnalysis, resolvePartitionInsertOptions, rewriteSpillOf, rulesOfStoredSynonyms, scanPostingBlocks, segmentArraysOf, selectionKeeps, shareSegmentArrays, storedArrayPositionGap, survivorDocumentsOf, textRebuildTargetOf, toError2 as toError, validateEmbeddingConfig, validatePatternValueLimit, validateRequiredFieldsInSchema, validateSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, vectorsEqual, wrapFrozenTokenTable, writeHeader, yieldToEventLoop2 as yieldToEventLoop };
22453
+ export { ARRAY_POSITION_GAP, DEFAULT_BM25_B, DEFAULT_BM25_K1, DEFAULT_WRITE_AHEAD_QUEUE_MAX_SIZE, REBALANCE_CHUNK_SIZE, VERSION, arrayPositionsAreStale, assemblePagedFrozenSegment, buildPartialWordTableFrom, buildSegmentPayload, clearNormalizationCache, configureNormalizationCache, createCompositePartition, createEncodedDocumentSource, createEngineIndex, createFrozenSegment, createNarsil, createPartitionIndex, createPartitionManager, createPartitionRouter, createSharedFrozenSegment, decodeEveryStoredDocument, decodeMapWithoutFields, decodeStoredDocument, decodeSurfaceTable, deleteNestedValue, dropEngineIndex, emitEngineEvent, emitWriteEventAfter, encodeIndexConfiguration, encodeSurfaceTable, endOfValue, engineCoreOf, engineVersionParts, extractVectorFromDoc, fieldIndexRemapOf, freezeSegmentShared, generateId, getNestedValue, getNormalizationCacheSize, holdSyncEpochChange, holdsADiscardedField, insertDocumentVectors, isCompositePartition, isQuantizationMode, isStorageMode, loadVectorCodeFor, mergeDocFrequencies, mergeFieldIndexes2 as mergeFieldIndexes, mergeFieldLengths, mergePartialWords, mergeSegmentContents, mergeSurfaceForms2 as mergeSurfaceForms, messagePackUpperBoundBytes, packChecksummedEnvelope, packEnvelopeWithChecksum, parseVectorDimension, partitionStateOf, prepareConfiguredSynonyms, prepareDocumentVectors, prepareStoredSynonyms, raiseEarlierReleaseGraphSetting, readResidentMemory, rebuildTextIndexes, reconstructSchemaFromMetadata, registerPartialWordSearch, registerPatternSearch, registerSynonyms, removeDocumentBatch, removeDocumentVectors, requireConfigurationWithinSizeLimit, requireSurfaceFormsForPartialFields, resetNormalizationCache, resolvePartialWordAnalysis, resolvePartitionInsertOptions, rewriteSpillOf, rulesOfStoredSynonyms, scanPostingBlocks, segmentArraysOf, selectionKeeps, shareSegmentArrays, storedArrayPositionGap, survivorDocumentsOf, textRebuildTargetOf, toError2 as toError, validateEmbeddingConfig, validatePatternValueLimit, validateRequiredFieldsInSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, vectorsEqual, wrapFrozenTokenTable, yieldToEventLoop2 as yieldToEventLoop };