@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
@@ -0,0 +1,470 @@
1
+ import { isGroup, isNormalPhrase } from './chunk-GQPTDQCL.mjs';
2
+ import { MAX_HISTORY_FILE_BYTES, KEY_FINGERPRINT_BYTES, SCRAMBLED_ID_BYTES, MAX_INDEX_UUID_LENGTH, MAX_MAX_LENGTH, MAX_MAX_WORDS, MAX_PEOPLE_PER_PHRASE_IN_FILE } from './chunk-5YNRKI2C.mjs';
3
+ import { packEnvelopeWithChecksum } from './chunk-KMUNHGBQ.mjs';
4
+ import { HEADER_SIZE, openChecksummedEnvelope } from './chunk-3OH67G7R.mjs';
5
+ import { crc32 } from './chunk-7GXJUJ24.mjs';
6
+
7
+ // src/query-suggestions/msgpack-cursor.ts
8
+ var MalformedPayload = class extends Error {
9
+ };
10
+ function utf8ByteLength(text) {
11
+ let bytes = 0;
12
+ for (let i = 0; i < text.length; i++) {
13
+ const unit = text.charCodeAt(i);
14
+ if (unit < 128) bytes += 1;
15
+ else if (unit < 2048) bytes += 2;
16
+ else if (unit >= 55296 && unit <= 56319 && i + 1 < text.length) {
17
+ const next = text.charCodeAt(i + 1);
18
+ if (next >= 56320 && next <= 57343) {
19
+ bytes += 4;
20
+ i++;
21
+ } else bytes += 3;
22
+ } else bytes += 3;
23
+ }
24
+ return bytes;
25
+ }
26
+ function headerBytes(length, fixLimit) {
27
+ if (length <= fixLimit) return 1;
28
+ if (length <= 255) return 2;
29
+ if (length <= 65535) return 3;
30
+ return 5;
31
+ }
32
+ function stringSize(text) {
33
+ const length = utf8ByteLength(text);
34
+ return headerBytes(length, 31) + length;
35
+ }
36
+ function binarySize(length) {
37
+ return (length <= 255 ? 2 : length <= 65535 ? 3 : 5) + length;
38
+ }
39
+ function containerHeaderSize(length) {
40
+ if (length <= 15) return 1;
41
+ return length <= 65535 ? 3 : 5;
42
+ }
43
+ function uintSize(value) {
44
+ if (value < 128) return 1;
45
+ if (value <= 255) return 2;
46
+ if (value <= 65535) return 3;
47
+ if (value <= 4294967295) return 5;
48
+ return 9;
49
+ }
50
+ var ExactWriter = class {
51
+ bytes;
52
+ view;
53
+ position;
54
+ encoder = new TextEncoder();
55
+ constructor(bytes, start) {
56
+ this.bytes = bytes;
57
+ this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
58
+ this.position = start;
59
+ }
60
+ get offset() {
61
+ return this.position;
62
+ }
63
+ skip(length) {
64
+ this.position += length;
65
+ }
66
+ map(length) {
67
+ this.container(length, 128, 222, 223);
68
+ }
69
+ array(length) {
70
+ this.container(length, 144, 220, 221);
71
+ }
72
+ string(text) {
73
+ const length = utf8ByteLength(text);
74
+ if (length <= 31) this.bytes[this.position++] = 160 | length;
75
+ else if (length <= 255) {
76
+ this.bytes[this.position++] = 217;
77
+ this.bytes[this.position++] = length;
78
+ } else if (length <= 65535) {
79
+ this.bytes[this.position++] = 218;
80
+ this.view.setUint16(this.position, length);
81
+ this.position += 2;
82
+ } else {
83
+ this.bytes[this.position++] = 219;
84
+ this.view.setUint32(this.position, length);
85
+ this.position += 4;
86
+ }
87
+ const written = this.encoder.encodeInto(text, this.bytes.subarray(this.position, this.position + length)).written;
88
+ if (written !== length) throw new MalformedPayload("A string took a different number of bytes than measured");
89
+ this.position += length;
90
+ }
91
+ binary(source, offset, length) {
92
+ if (length <= 255) {
93
+ this.bytes[this.position++] = 196;
94
+ this.bytes[this.position++] = length;
95
+ } else if (length <= 65535) {
96
+ this.bytes[this.position++] = 197;
97
+ this.view.setUint16(this.position, length);
98
+ this.position += 2;
99
+ } else {
100
+ this.bytes[this.position++] = 198;
101
+ this.view.setUint32(this.position, length);
102
+ this.position += 4;
103
+ }
104
+ this.bytes.set(source.subarray(offset, offset + length), this.position);
105
+ this.position += length;
106
+ }
107
+ uint(value) {
108
+ if (value < 128) this.bytes[this.position++] = value;
109
+ else if (value <= 255) {
110
+ this.bytes[this.position++] = 204;
111
+ this.bytes[this.position++] = value;
112
+ } else if (value <= 65535) {
113
+ this.bytes[this.position++] = 205;
114
+ this.view.setUint16(this.position, value);
115
+ this.position += 2;
116
+ } else if (value <= 4294967295) {
117
+ this.bytes[this.position++] = 206;
118
+ this.view.setUint32(this.position, value);
119
+ this.position += 4;
120
+ } else {
121
+ this.bytes[this.position++] = 207;
122
+ this.view.setBigUint64(this.position, BigInt(value));
123
+ this.position += 8;
124
+ }
125
+ }
126
+ container(length, fix, sixteen, thirtyTwo) {
127
+ if (length <= 15) this.bytes[this.position++] = fix | length;
128
+ else if (length <= 65535) {
129
+ this.bytes[this.position++] = sixteen;
130
+ this.view.setUint16(this.position, length);
131
+ this.position += 2;
132
+ } else {
133
+ this.bytes[this.position++] = thirtyTwo;
134
+ this.view.setUint32(this.position, length);
135
+ this.position += 4;
136
+ }
137
+ }
138
+ };
139
+ var StrictReader = class {
140
+ bytes;
141
+ view;
142
+ position;
143
+ decoder = new TextDecoder("utf-8", { fatal: true });
144
+ constructor(bytes, start) {
145
+ this.bytes = bytes;
146
+ this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
147
+ this.position = start;
148
+ }
149
+ get offset() {
150
+ return this.position;
151
+ }
152
+ get atEnd() {
153
+ return this.position === this.bytes.byteLength;
154
+ }
155
+ map() {
156
+ return this.container(128, 222, 223, "a map");
157
+ }
158
+ array() {
159
+ return this.container(144, 220, 221, "an array");
160
+ }
161
+ string() {
162
+ const tag = this.byte();
163
+ let length;
164
+ if ((tag & 224) === 160) length = tag & 31;
165
+ else if (tag === 217) length = this.byte();
166
+ else if (tag === 218) length = this.uint16();
167
+ else if (tag === 219) length = this.uint32();
168
+ else throw new MalformedPayload("Expected a string");
169
+ const end = this.take(length);
170
+ try {
171
+ return this.decoder.decode(this.bytes.subarray(end - length, end));
172
+ } catch {
173
+ throw new MalformedPayload("A string holds invalid UTF-8");
174
+ }
175
+ }
176
+ binary() {
177
+ const tag = this.byte();
178
+ let length;
179
+ if (tag === 196) length = this.byte();
180
+ else if (tag === 197) length = this.uint16();
181
+ else if (tag === 198) length = this.uint32();
182
+ else throw new MalformedPayload("Expected bytes");
183
+ const end = this.take(length);
184
+ return { offset: end - length, length };
185
+ }
186
+ uint() {
187
+ const tag = this.byte();
188
+ if (tag < 128) return tag;
189
+ if (tag === 204) return this.byte();
190
+ if (tag === 205) return this.uint16();
191
+ if (tag === 206) return this.uint32();
192
+ if (tag === 207) {
193
+ this.take(8);
194
+ const value = this.view.getBigUint64(this.position - 8);
195
+ if (value > BigInt(Number.MAX_SAFE_INTEGER)) throw new MalformedPayload("An integer is out of range");
196
+ return Number(value);
197
+ }
198
+ throw new MalformedPayload("Expected an unsigned integer");
199
+ }
200
+ container(fix, sixteen, thirtyTwo, what) {
201
+ const tag = this.byte();
202
+ if ((tag & 240) === fix) return tag & 15;
203
+ if (tag === sixteen) return this.uint16();
204
+ if (tag === thirtyTwo) return this.uint32();
205
+ throw new MalformedPayload(`Expected ${what}`);
206
+ }
207
+ take(length) {
208
+ const end = this.position + length;
209
+ if (end > this.bytes.byteLength) throw new MalformedPayload("The payload ends early");
210
+ this.position = end;
211
+ return end;
212
+ }
213
+ byte() {
214
+ this.take(1);
215
+ return this.bytes[this.position - 1];
216
+ }
217
+ uint16() {
218
+ this.take(2);
219
+ return this.view.getUint16(this.position - 2);
220
+ }
221
+ uint32() {
222
+ this.take(4);
223
+ return this.view.getUint32(this.position - 4);
224
+ }
225
+ };
226
+
227
+ // src/query-suggestions/counts-groups.ts
228
+ var FILE_LIMITS = {
229
+ minLetters: 1,
230
+ maxLength: MAX_MAX_LENGTH,
231
+ maxWords: MAX_MAX_WORDS,
232
+ maxDigits: MAX_MAX_LENGTH
233
+ };
234
+ var KEY_PHRASE = "phrase";
235
+ var KEY_COUNT = "count";
236
+ var KEY_PEOPLE = "people";
237
+ var MAX_UINT32 = 4294967295;
238
+ function readPeople(reader) {
239
+ const people = reader.array();
240
+ if (people > MAX_PEOPLE_PER_PHRASE_IN_FILE) throw new MalformedPayload("A phrase lists too many people");
241
+ const offsets = [];
242
+ for (let i = 0; i < people; i++) {
243
+ const { offset, length } = reader.binary();
244
+ if (length !== SCRAMBLED_ID_BYTES) throw new MalformedPayload("A scrambled ID has the wrong length");
245
+ offsets.push(offset);
246
+ }
247
+ return offsets;
248
+ }
249
+ function walkGroups(reader, payload, visitor, onGroup = null) {
250
+ const groupCount = reader.map();
251
+ const validating = visitor === null && onGroup === null;
252
+ const seenGroups = validating ? /* @__PURE__ */ new Set() : null;
253
+ for (let g = 0; g < groupCount; g++) {
254
+ const group = reader.string();
255
+ onGroup?.(group);
256
+ if (seenGroups !== null) {
257
+ if (!isGroup(group) || seenGroups.has(group)) throw new MalformedPayload("A group is invalid or repeated");
258
+ seenGroups.add(group);
259
+ }
260
+ const phraseCount = reader.array();
261
+ const seenPhrases = validating ? /* @__PURE__ */ new Set() : null;
262
+ for (let p = 0; p < phraseCount; p++) {
263
+ const fields = reader.map();
264
+ let phrase = null;
265
+ let count = null;
266
+ let offsets = null;
267
+ for (let f = 0; f < fields; f++) {
268
+ const key = reader.string();
269
+ if (key === KEY_PHRASE && phrase === null) phrase = reader.string();
270
+ else if (key === KEY_COUNT && count === null) count = reader.uint();
271
+ else if (key === KEY_PEOPLE && offsets === null) offsets = readPeople(reader);
272
+ else throw new MalformedPayload(`A phrase holds an unexpected or repeated key "${key}"`);
273
+ }
274
+ if (phrase === null || count === null || offsets === null) throw new MalformedPayload("A phrase lacks a key");
275
+ if (seenPhrases !== null) {
276
+ if (!isNormalPhrase(phrase, FILE_LIMITS) || seenPhrases.has(phrase)) {
277
+ throw new MalformedPayload("A phrase is invalid or repeated");
278
+ }
279
+ if (offsets.length > count || count > MAX_UINT32) {
280
+ throw new MalformedPayload("A phrase lists more people than its count");
281
+ }
282
+ seenPhrases.add(phrase);
283
+ }
284
+ visitor?.(group, phrase, count, { source: payload, offsets });
285
+ }
286
+ }
287
+ }
288
+
289
+ // src/query-suggestions/counts-file.ts
290
+ var DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
291
+ var WHAT = "query counts file";
292
+ var QUERY_COUNTS_FILE_FORMAT_VERSION = 1;
293
+ var KEY_DAY = "day";
294
+ var KEY_FINGERPRINT = "keyFingerprint";
295
+ var KEY_SAVED_AT = "savedAt";
296
+ var KEY_INDEX_UUID = "indexUuid";
297
+ var KEY_GROUPS = "groups";
298
+ var KEY_PHRASE2 = "phrase";
299
+ var KEY_COUNT2 = "count";
300
+ var KEY_PEOPLE2 = "people";
301
+ var REQUIRED_TOP_LEVEL_KEYS = 4;
302
+ var PHRASE_KEYS = 3;
303
+ function isDay(value) {
304
+ if (!DAY_PATTERN.test(value)) return false;
305
+ const parsed = /* @__PURE__ */ new Date(`${value}T00:00:00.000Z`);
306
+ return !Number.isNaN(parsed.getTime()) && parsed.toISOString().slice(0, 10) === value;
307
+ }
308
+ function topLevelSize(header) {
309
+ const keys = REQUIRED_TOP_LEVEL_KEYS + (header.indexUuid === null ? 0 : 1);
310
+ return containerHeaderSize(keys) + stringSize(KEY_DAY) + stringSize(header.day) + stringSize(KEY_FINGERPRINT) + binarySize(header.fingerprint.byteLength) + stringSize(KEY_SAVED_AT) + uintSize(header.savedAt) + (header.indexUuid === null ? 0 : stringSize(KEY_INDEX_UUID) + stringSize(header.indexUuid)) + stringSize(KEY_GROUPS);
311
+ }
312
+ function writeTopLevel(writer, header) {
313
+ writer.map(REQUIRED_TOP_LEVEL_KEYS + (header.indexUuid === null ? 0 : 1));
314
+ writer.string(KEY_DAY);
315
+ writer.string(header.day);
316
+ writer.string(KEY_FINGERPRINT);
317
+ writer.binary(header.fingerprint, 0, header.fingerprint.byteLength);
318
+ writer.string(KEY_SAVED_AT);
319
+ writer.uint(header.savedAt);
320
+ if (header.indexUuid !== null) {
321
+ writer.string(KEY_INDEX_UUID);
322
+ writer.string(header.indexUuid);
323
+ }
324
+ writer.string(KEY_GROUPS);
325
+ }
326
+ function groupsSize(counts) {
327
+ let size = containerHeaderSize(counts.groupTables.size);
328
+ for (const [group, phrases] of counts.groupTables) {
329
+ size += stringSize(group) + containerHeaderSize(phrases.size);
330
+ for (const [phrase, number] of phrases) {
331
+ const people = counts.peopleLengthOf(number);
332
+ size += containerHeaderSize(PHRASE_KEYS) + stringSize(KEY_PHRASE2) + stringSize(phrase) + stringSize(KEY_COUNT2) + uintSize(counts.countOf(number)) + stringSize(KEY_PEOPLE2) + containerHeaderSize(people) + people * binarySize(SCRAMBLED_ID_BYTES);
333
+ }
334
+ }
335
+ return size;
336
+ }
337
+ function writeGroups(writer, counts) {
338
+ writer.map(counts.groupTables.size);
339
+ const people = counts.peopleBytes;
340
+ for (const [group, phrases] of counts.groupTables) {
341
+ writer.string(group);
342
+ writer.array(phrases.size);
343
+ for (const [phrase, number] of phrases) {
344
+ writer.map(PHRASE_KEYS);
345
+ writer.string(KEY_PHRASE2);
346
+ writer.string(phrase);
347
+ writer.string(KEY_COUNT2);
348
+ writer.uint(counts.countOf(number));
349
+ writer.string(KEY_PEOPLE2);
350
+ const length = counts.peopleLengthOf(number);
351
+ const offset = counts.peopleOffsetOf(number);
352
+ writer.array(length);
353
+ for (let i = 0; i < length; i++) writer.binary(people, offset + i * SCRAMBLED_ID_BYTES, SCRAMBLED_ID_BYTES);
354
+ }
355
+ }
356
+ }
357
+ function sealed(bytes, writer) {
358
+ if (writer.offset !== bytes.byteLength) throw new MalformedPayload("The query counts file took an unexpected size");
359
+ if (bytes.byteLength > MAX_HISTORY_FILE_BYTES) {
360
+ throw new MalformedPayload(`A query counts file must stay at or below ${MAX_HISTORY_FILE_BYTES} bytes`);
361
+ }
362
+ const payload = bytes.subarray(HEADER_SIZE);
363
+ const packed = packEnvelopeWithChecksum([payload], QUERY_COUNTS_FILE_FORMAT_VERSION, WHAT, crc32(payload));
364
+ bytes.set(packed.chunks[0], 0);
365
+ return bytes;
366
+ }
367
+ function encodeCountsFile(counts, header) {
368
+ const full = { ...header, day: counts.day };
369
+ const bytes = new Uint8Array(HEADER_SIZE + topLevelSize(full) + groupsSize(counts));
370
+ const writer = new ExactWriter(bytes, HEADER_SIZE);
371
+ writeTopLevel(writer, full);
372
+ writeGroups(writer, counts);
373
+ return sealed(bytes, writer);
374
+ }
375
+ function rewrittenFile(header, groups) {
376
+ const bytes = new Uint8Array(HEADER_SIZE + topLevelSize(header) + groups.byteLength);
377
+ const writer = new ExactWriter(bytes, HEADER_SIZE);
378
+ writeTopLevel(writer, header);
379
+ bytes.set(groups, writer.offset);
380
+ writer.skip(groups.byteLength);
381
+ return sealed(bytes, writer);
382
+ }
383
+ function readTopLevel(payload) {
384
+ const reader = new StrictReader(payload, 0);
385
+ const keys = reader.map();
386
+ let day = null;
387
+ let fingerprint = null;
388
+ let savedAt = null;
389
+ let indexUuid = null;
390
+ let groupsStart = null;
391
+ let groupsEnd = 0;
392
+ const seen = /* @__PURE__ */ new Set();
393
+ for (let i = 0; i < keys; i++) {
394
+ const key = reader.string();
395
+ if (seen.has(key)) throw new MalformedPayload(`The file holds the key "${key}" twice`);
396
+ seen.add(key);
397
+ if (key === KEY_DAY) day = reader.string();
398
+ else if (key === KEY_FINGERPRINT) {
399
+ const { offset, length } = reader.binary();
400
+ fingerprint = payload.subarray(offset, offset + length);
401
+ } else if (key === KEY_SAVED_AT) savedAt = reader.uint();
402
+ else if (key === KEY_INDEX_UUID) {
403
+ indexUuid = reader.string();
404
+ if (indexUuid.length === 0 || indexUuid.length > MAX_INDEX_UUID_LENGTH) {
405
+ throw new MalformedPayload("The file holds an indexUuid of the wrong length");
406
+ }
407
+ } else if (key === KEY_GROUPS) {
408
+ groupsStart = reader.offset;
409
+ walkGroups(reader, payload, null);
410
+ groupsEnd = reader.offset;
411
+ } else throw new MalformedPayload(`The file holds an unexpected key "${key}"`);
412
+ }
413
+ if (!reader.atEnd) throw new MalformedPayload("The payload holds bytes after its map");
414
+ if (day === null || fingerprint === null || savedAt === null || groupsStart === null) {
415
+ throw new MalformedPayload("The file lacks a required key");
416
+ }
417
+ return { day, fingerprint, savedAt, indexUuid, groupsStart, groupsEnd };
418
+ }
419
+ async function openCountsFile(bytes, expectedDay, fingerprint) {
420
+ if (bytes.byteLength > MAX_HISTORY_FILE_BYTES) {
421
+ return { kind: "damaged", reason: `The file is longer than ${MAX_HISTORY_FILE_BYTES} bytes` };
422
+ }
423
+ let payload;
424
+ try {
425
+ payload = (await openChecksummedEnvelope(bytes, {
426
+ envelopeFormatVersion: QUERY_COUNTS_FILE_FORMAT_VERSION,
427
+ what: WHAT,
428
+ allowsCompression: false
429
+ })).payload;
430
+ } catch (error) {
431
+ return { kind: "damaged", reason: error instanceof Error ? error.message : String(error) };
432
+ }
433
+ let top;
434
+ try {
435
+ top = readTopLevel(payload);
436
+ } catch (error) {
437
+ if (error instanceof MalformedPayload) return { kind: "damaged", reason: error.message };
438
+ throw error;
439
+ }
440
+ if (!isDay(top.day) || expectedDay !== null && top.day !== expectedDay) {
441
+ return { kind: "damaged", reason: "The file holds a day that differs from its key" };
442
+ }
443
+ if (top.fingerprint.byteLength !== KEY_FINGERPRINT_BYTES) {
444
+ return { kind: "damaged", reason: "The key fingerprint has the wrong length" };
445
+ }
446
+ if (!sameBytes(top.fingerprint, fingerprint)) return { kind: "other-key" };
447
+ const { groupsStart, groupsEnd, ...header } = top;
448
+ return {
449
+ kind: "counts",
450
+ ...header,
451
+ visit(visitor) {
452
+ walkGroups(new StrictReader(payload, groupsStart), payload, visitor);
453
+ },
454
+ groupNames() {
455
+ const names = [];
456
+ walkGroups(new StrictReader(payload, groupsStart), payload, null, (group) => names.push(group));
457
+ return names;
458
+ },
459
+ withIndexUuid(indexUuid, savedAt) {
460
+ return rewrittenFile({ ...header, indexUuid, savedAt }, payload.subarray(groupsStart, groupsEnd));
461
+ }
462
+ };
463
+ }
464
+ function sameBytes(left, right) {
465
+ if (left.byteLength !== right.byteLength) return false;
466
+ for (let i = 0; i < left.byteLength; i++) if (left[i] !== right[i]) return false;
467
+ return true;
468
+ }
469
+
470
+ export { encodeCountsFile, openCountsFile, sameBytes };
@@ -0,0 +1,32 @@
1
+ // src/sync/device/constants.ts
2
+ var RECONNECT_MIN_DELAY_MS = 500;
3
+ var RETRY_MAX_DELAY_MS = 3e4;
4
+ var BACKOFF_DOUBLINGS_LIMIT = 30;
5
+ var DEFAULT_REPLAY_LIMIT_OF_SNAPSHOT = 1;
6
+ var KEPT_ENTRY_FLUSH_BYTES = 4 * 1024 * 1024;
7
+ var KEPT_ENTRY_FLUSH_IDLE_MS = 1e3;
8
+ var UPLOAD_RETRY_DELAY_MS = 1e3;
9
+ var SNAPSHOT_RETRY_DELAY_MS = 5e3;
10
+ var SNAPSHOT_MEMORY_PER_ARCHIVE_BYTE = 3;
11
+ var QUEUE_COMPACTION_BYTES = 1024 * 1024;
12
+ var STORE_FRAME_LIMIT_BYTES = 256 * 1024 * 1024;
13
+ var DOWNLOAD_FRAME_BYTES = 1024 * 1024;
14
+ var DOWNLOAD_SAVE_BYTES = 1024 * 1024;
15
+ var UPLOAD_BATCH_WRITES = 100;
16
+ var KEPT_ENTRY_OVERHEAD_BYTES = 32;
17
+ var DEFAULT_INDEXEDDB_DEVICE_STORE_NAME = "narsil-device-sync";
18
+ var INDEXEDDB_DEVICE_STORE_BLOCKED_TIMEOUT_MS = 5e3;
19
+
20
+ // src/sync/device/stores/serial.ts
21
+ function createSerial() {
22
+ let tail = Promise.resolve();
23
+ return {
24
+ run(task) {
25
+ const result = tail.then(task, task);
26
+ tail = result.catch(() => void 0);
27
+ return result;
28
+ }
29
+ };
30
+ }
31
+
32
+ export { BACKOFF_DOUBLINGS_LIMIT, DEFAULT_INDEXEDDB_DEVICE_STORE_NAME, DEFAULT_REPLAY_LIMIT_OF_SNAPSHOT, DOWNLOAD_FRAME_BYTES, DOWNLOAD_SAVE_BYTES, INDEXEDDB_DEVICE_STORE_BLOCKED_TIMEOUT_MS, KEPT_ENTRY_FLUSH_BYTES, KEPT_ENTRY_FLUSH_IDLE_MS, KEPT_ENTRY_OVERHEAD_BYTES, QUEUE_COMPACTION_BYTES, RECONNECT_MIN_DELAY_MS, RETRY_MAX_DELAY_MS, SNAPSHOT_MEMORY_PER_ARCHIVE_BYTE, SNAPSHOT_RETRY_DELAY_MS, STORE_FRAME_LIMIT_BYTES, UPLOAD_BATCH_WRITES, UPLOAD_RETRY_DELAY_MS, createSerial };
@@ -1,5 +1,5 @@
1
1
  import { MIN_HYBRID_DEPTH, MAX_HYBRID_DEPTH } from './chunk-FQBFZAWG.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-MDF6PDIA.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
3
3
 
4
4
  // src/search/hybrid-depth.ts
5
5
  function fixedHybridDepthOf(hybrid) {
@@ -1,5 +1,5 @@
1
- import { NUMBER_TAG, DATE_TAG, BYTES_TAG, encodeBase64, startsWithTagPrefix, OBJECT_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND } from './chunk-NYSONUB7.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-MDF6PDIA.mjs';
1
+ import { NUMBER_TAG, DATE_TAG, BYTES_TAG, encodeBase64, startsWithTagPrefix, OBJECT_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND } from './chunk-TQXHPFWT.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
3
3
 
4
4
  // src/engine/export/json-line.ts
5
5
  function refuse(path, kind, docId) {
@@ -0,0 +1,49 @@
1
+ import { NATIVE_CRC32_MIN_BYTES } from './chunk-U476IXKQ.mjs';
2
+ import * as zlib from 'zlib';
3
+
4
+ var candidate = zlib.crc32;
5
+ var nativeCrc32 = typeof candidate === "function" ? candidate : null;
6
+
7
+ // src/serialization/crc32.ts
8
+ var IEEE_POLYNOMIAL = 3988292384;
9
+ var ALL_BITS = 4294967295;
10
+ var cachedTable = null;
11
+ function buildTable() {
12
+ const table = new Uint32Array(256);
13
+ for (let i = 0; i < 256; i++) {
14
+ let crc = i;
15
+ for (let bit = 0; bit < 8; bit++) {
16
+ crc = crc & 1 ? crc >>> 1 ^ IEEE_POLYNOMIAL : crc >>> 1;
17
+ }
18
+ table[i] = crc;
19
+ }
20
+ return table;
21
+ }
22
+ function getTable() {
23
+ if (cachedTable === null) {
24
+ cachedTable = buildTable();
25
+ }
26
+ return cachedTable;
27
+ }
28
+ function crc322(data) {
29
+ return crc32Final(crc32Update(crc32Init(), data));
30
+ }
31
+ function crc32Init() {
32
+ return ALL_BITS;
33
+ }
34
+ function crc32Update(state, data) {
35
+ if (nativeCrc32 !== null && data.length >= NATIVE_CRC32_MIN_BYTES) {
36
+ return nativeCrc32(data, (state ^ ALL_BITS) >>> 0) ^ ALL_BITS;
37
+ }
38
+ const table = getTable();
39
+ let crc = state;
40
+ for (let i = 0; i < data.length; i++) {
41
+ crc = crc >>> 8 ^ table[(crc ^ data[i]) & 255];
42
+ }
43
+ return crc;
44
+ }
45
+ function crc32Final(state) {
46
+ return (state ^ ALL_BITS) >>> 0;
47
+ }
48
+
49
+ export { crc322 as crc32, crc32Final, crc32Init, crc32Update };
@@ -1,5 +1,5 @@
1
- import { sanitizeSurfaceForms, patternIndexesFromWire, dropStoredVectorValues } from './chunk-ZS6CMXAE.mjs';
2
- import { requireValidFieldTypes } from './chunk-SOUZMPME.mjs';
1
+ import { sanitizeSurfaceForms, patternIndexesFromWire, dropStoredVectorValues } from './chunk-3R4UZWQG.mjs';
2
+ import { requireValidFieldTypes } from './chunk-WQRN64Q6.mjs';
3
3
  import { VALID_HNSW_METRICS } from './chunk-U476IXKQ.mjs';
4
4
  import { decode } from '@msgpack/msgpack';
5
5
 
@@ -0,0 +1,72 @@
1
+ import { openCountsFile } from './chunk-6L3XJXGU.mjs';
2
+ import { SCRAMBLED_ID_BYTES } from './chunk-5YNRKI2C.mjs';
3
+
4
+ // src/query-suggestions/merge.ts
5
+ var SEPARATOR = "\0";
6
+ function idKey(source, offset) {
7
+ let key = "";
8
+ for (let i = 0; i < SCRAMBLED_ID_BYTES; i++) key += String.fromCharCode(source[offset + i]);
9
+ return key;
10
+ }
11
+ var Merger = class {
12
+ settings;
13
+ banned;
14
+ entries = /* @__PURE__ */ new Map();
15
+ groups;
16
+ discarded = 0;
17
+ constructor(settings) {
18
+ this.settings = settings;
19
+ this.banned = new Set(settings.banned);
20
+ this.groups = new Set(settings.markedGroups);
21
+ }
22
+ async addFile(bytes, expectedDay) {
23
+ const opened = await openCountsFile(bytes, expectedDay, this.settings.fingerprint);
24
+ if (opened.kind !== "counts") return opened;
25
+ if (this.settings.clustered && (opened.indexUuid === null || opened.indexUuid !== this.settings.indexUuid)) {
26
+ return { kind: "other-index" };
27
+ }
28
+ const { minPeople, maxMergePhrases, maxGroups } = this.settings;
29
+ opened.visit((group, phrase, count, people) => {
30
+ if (this.banned.has(phrase)) return;
31
+ const key = `${group}${SEPARATOR}${phrase}`;
32
+ let entry = this.entries.get(key);
33
+ if (entry === void 0) {
34
+ const newGroup = !this.groups.has(group);
35
+ if (newGroup && this.groups.size >= maxGroups || this.entries.size >= maxMergePhrases) {
36
+ this.discarded += 1;
37
+ return;
38
+ }
39
+ if (newGroup) this.groups.add(group);
40
+ entry = { count: 0, people: /* @__PURE__ */ new Set() };
41
+ this.entries.set(key, entry);
42
+ }
43
+ entry.count += count;
44
+ if (entry.people === null) return;
45
+ for (const offset of people.offsets) {
46
+ entry.people.add(idKey(people.source, offset));
47
+ if (entry.people.size >= minPeople) {
48
+ entry.people = null;
49
+ return;
50
+ }
51
+ }
52
+ });
53
+ return { kind: "merged", day: opened.day, savedAt: opened.savedAt };
54
+ }
55
+ result() {
56
+ const groups = {};
57
+ for (const [key, entry] of this.entries) {
58
+ if (entry.people !== null) continue;
59
+ const split = key.indexOf(SEPARATOR);
60
+ const group = key.slice(0, split);
61
+ const list = groups[group] ?? [];
62
+ list.push({ phrase: key.slice(split + 1), count: entry.count });
63
+ groups[group] = list;
64
+ }
65
+ for (const list of Object.values(groups)) {
66
+ list.sort((left, right) => right.count - left.count || (left.phrase < right.phrase ? -1 : 1));
67
+ }
68
+ return { groups, discarded: this.discarded };
69
+ }
70
+ };
71
+
72
+ export { Merger };
@@ -0,0 +1,15 @@
1
+ // src/sync/epoch.ts
2
+ var SYNC_EPOCH_BYTES = 16;
3
+ var SYNC_EPOCH_PATTERN = /^[0-9a-f]{32}$/;
4
+ function isSyncEpoch(value) {
5
+ return typeof value === "string" && SYNC_EPOCH_PATTERN.test(value);
6
+ }
7
+ function newSyncEpoch() {
8
+ const bytes = new Uint8Array(SYNC_EPOCH_BYTES);
9
+ crypto.getRandomValues(bytes);
10
+ let hex = "";
11
+ for (const byte of bytes) hex += byte.toString(16).padStart(2, "0");
12
+ return hex;
13
+ }
14
+
15
+ export { isSyncEpoch, newSyncEpoch };