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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (565) hide show
  1. package/dist/adapters/filesystem.mjs +3 -3
  2. package/dist/adapters/gcs.mjs +3 -3
  3. package/dist/adapters/indexeddb.mjs +1 -1
  4. package/dist/adapters/s3.mjs +3 -3
  5. package/dist/browser/{chunk-N23GL72Q.mjs → chunk-4RNSFVWI.mjs} +20777 -19056
  6. package/dist/browser/chunk-MMHIIL5B.mjs +564 -0
  7. package/dist/browser/chunk-MZHQ65VI.mjs +1228 -0
  8. package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
  9. package/dist/browser/{chunk-VLJQW4J6.mjs → core-leaf-TJAGWPZZ.mjs} +4674 -3102
  10. package/dist/{react-native/chunks/durability-config-QXVZEO7T.mjs → browser/durability-config-SGB5ZP5K.mjs} +8 -3
  11. package/dist/browser/embed-RF2MPGAO.mjs +222 -0
  12. package/dist/{react-native/chunks/geo-index-PX3BIHAH.mjs → browser/geo-index-GNHY4PUB.mjs} +190 -93
  13. package/dist/{react-native/chunks/module-TTEVPRCW.mjs → browser/module-362VSIGR.mjs} +1570 -275
  14. package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
  15. package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
  16. package/dist/browser/optional-writes-WMZX4OEC.mjs +3196 -0
  17. package/dist/browser/phrase-module-22TKMXWI.mjs +616 -0
  18. package/dist/browser/resolve-vector-text-KI65IHMD.mjs +60 -0
  19. package/dist/browser/{restore-hooks-IE3GGYHG.mjs → restore-queue-S4BWOGMU.mjs} +98 -24
  20. package/dist/{react-native/chunks/runtime-R5E3TB3J.mjs → browser/runtime-NU6VOVH2.mjs} +61 -25
  21. package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
  22. package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
  23. package/dist/browser/storage-leaf-X6CNRHJS.mjs +18221 -0
  24. package/dist/browser/store-leaf-AEMTAVHX.mjs +2069 -0
  25. package/dist/browser/{chunk-GFAZPSWK.mjs → suggestions-leaf-3Y6MR6OF.mjs} +441 -119
  26. package/dist/browser/worker-copies-WQCPP3TS.mjs +2750 -0
  27. package/dist/{capabilities-D3AoBJoF.d.ts → capabilities-BKDrry0z.d.ts} +2 -2
  28. package/dist/chunk-2JRERUNZ.mjs +217 -0
  29. package/dist/chunk-2RIS76RJ.mjs +212 -0
  30. package/dist/chunk-3B775F3C.mjs +252 -0
  31. package/dist/{chunk-24FNVRKB.mjs → chunk-3D6RZGJH.mjs} +3 -3
  32. package/dist/{chunk-INJYO3BU.mjs → chunk-4CAMH7FO.mjs} +1 -1
  33. package/dist/{chunk-U476IXKQ.mjs → chunk-4PY4JYMY.mjs} +2 -1
  34. package/dist/chunk-6EZW2GQL.mjs +978 -0
  35. package/dist/chunk-75UNINFA.mjs +271 -0
  36. package/dist/chunk-77AUVDQ5.mjs +7 -0
  37. package/dist/{chunk-JTYPJF3T.mjs → chunk-7MWYORQC.mjs} +2 -2
  38. package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
  39. package/dist/{chunk-XIHUI4KB.mjs → chunk-AB27FWZM.mjs} +8 -3
  40. package/dist/{chunk-FUD5XSZ5.mjs → chunk-BXM7XM4G.mjs} +7 -3
  41. package/dist/{chunk-HJJI72X7.mjs → chunk-C7YQHCSO.mjs} +1 -1
  42. package/dist/{chunk-RVGRFOGN.mjs → chunk-D456ZFPQ.mjs} +2 -1
  43. package/dist/{chunk-KKQC526K.mjs → chunk-E2F6LZR3.mjs} +19 -21
  44. package/dist/{chunk-SMOOSIAW.mjs → chunk-FE3MRIBN.mjs} +104 -13
  45. package/dist/{chunk-KYYABCSW.mjs → chunk-FETZYCH7.mjs} +15 -1
  46. package/dist/{chunk-XXJZMTZT.mjs → chunk-FVZ5DB6Y.mjs} +3 -2
  47. package/dist/{chunk-EYD7K3H6.mjs → chunk-GF4K7IUK.mjs} +317 -120
  48. package/dist/chunk-GXCDWLQI.mjs +193 -0
  49. package/dist/{chunk-IIRIG7H5.mjs → chunk-H64YDF5M.mjs} +3 -3
  50. package/dist/{browser/chunk-VY5KW3HN.mjs → chunk-HOOR4CP5.mjs} +63 -7
  51. package/dist/chunk-IB4BYLE3.mjs +127 -0
  52. package/dist/{chunk-3C7MTCCI.mjs → chunk-IE3Q62QD.mjs} +2 -2
  53. package/dist/chunk-IH3G6SJO.mjs +40 -0
  54. package/dist/chunk-JV74RKCY.mjs +3041 -0
  55. package/dist/{chunk-ZPZ3YGXV.mjs → chunk-K67I3RF4.mjs} +261 -101
  56. package/dist/chunk-KLVMK3R5.mjs +47 -0
  57. package/dist/{chunk-5VV4R6P7.mjs → chunk-LAWIJRMJ.mjs} +4154 -2577
  58. package/dist/chunk-LF4GB4PO.mjs +281 -0
  59. package/dist/chunk-NC4QLCZC.mjs +59 -0
  60. package/dist/chunk-OOO54OVC.mjs +627 -0
  61. package/dist/chunk-OUWZKNO3.mjs +207 -0
  62. package/dist/{chunk-FJKKCV4D.mjs → chunk-P5YLI5ED.mjs} +343 -182
  63. package/dist/{chunk-4ZTHGTVX.mjs → chunk-PTTMGRG5.mjs} +9 -10
  64. package/dist/{react-native/chunks/chunk-DZ7H7D2C.mjs → chunk-Q3ZZH5Z7.mjs} +6 -0
  65. package/dist/{browser/chunk-EKMGCRSR.mjs → chunk-QBVTYY4J.mjs} +2 -9
  66. package/dist/{chunk-W5EB5XKI.mjs → chunk-R4CE4IVU.mjs} +341 -183
  67. package/dist/chunk-S2POFTLN.mjs +10 -0
  68. package/dist/{chunk-KJ3RTZDJ.mjs → chunk-S3BSDBF7.mjs} +10 -3
  69. package/dist/{chunk-4LMSZAK6.mjs → chunk-SHGN3QIF.mjs} +69 -13
  70. package/dist/chunk-SXIRM4MX.mjs +3549 -0
  71. package/dist/{chunk-TBC3XUL2.mjs → chunk-TGPKS2UM.mjs} +47 -1
  72. package/dist/chunk-TINW4BSH.mjs +31301 -0
  73. package/dist/{cold-module-VOJXMNZB.mjs → chunk-TSLV5P2J.mjs} +397 -80
  74. package/dist/{chunk-HHBUCIUY.mjs → chunk-TW543F33.mjs} +3 -3
  75. package/dist/chunk-U6B7DUQW.mjs +788 -0
  76. package/dist/{chunk-OQLD2BSW.mjs → chunk-V3SGPXWQ.mjs} +8 -9
  77. package/dist/chunk-W34VJXY7.mjs +4723 -0
  78. package/dist/chunk-YETKPX5M.mjs +5 -0
  79. package/dist/chunk-ZQ6QY42L.mjs +59 -0
  80. package/dist/{client-kqSMevVi.d.ts → client-CTp8RRiK.d.ts} +4 -4
  81. package/dist/client.d.ts +8 -8
  82. package/dist/client.mjs +66 -18
  83. package/dist/{config-B4v_Htpu.d.ts → config-PCNzWjHL.d.ts} +6 -3
  84. package/dist/{config-CTP01fns.d.ts → config-_WT5grSL.d.ts} +3 -3
  85. package/dist/core-leaf-KXFGP74A.mjs +7 -0
  86. package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
  87. package/dist/direct-executor-MKTZBR26.mjs +16 -0
  88. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  89. package/dist/distribution/coordinator/etcd.mjs +7 -4
  90. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  91. package/dist/distribution/coordinator/in-memory.mjs +1 -2
  92. package/dist/distribution/transport/grpc.mjs +7 -2
  93. package/dist/distribution/transport/tcp.mjs +7 -1
  94. package/dist/distribution.d.ts +7 -7
  95. package/dist/distribution.mjs +1199 -1092
  96. package/dist/{browser/durability-config-TIYKW6XX.mjs → durability-config-XV4XR7Y4.mjs} +7 -3
  97. package/dist/embed-4H7RTBVL.mjs +221 -0
  98. package/dist/embeddings/openai.mjs +2 -2
  99. package/dist/{engine-CkPn2PWE.d.ts → engine-DBRVR_d-.d.ts} +1252 -1239
  100. package/dist/{browser/geo-index-OTV7VPIR.mjs → geo-index-2ZMMWWSK.mjs} +190 -93
  101. package/dist/{index-C4AmUnl1.d.ts → index-Ck9w5WHz.d.ts} +1 -1
  102. package/dist/index.browser.mjs +4 -16
  103. package/dist/index.d.ts +1495 -78
  104. package/dist/index.mjs +14 -50
  105. package/dist/index.react-native.mjs +11 -28
  106. package/dist/invalidation/filesystem.mjs +1 -2
  107. package/dist/languages/albanian.mjs +1 -1
  108. package/dist/languages/amharic.mjs +1 -1
  109. package/dist/languages/arabic.mjs +1 -1
  110. package/dist/languages/armenian.mjs +1 -1
  111. package/dist/languages/azerbaijani.mjs +1 -1
  112. package/dist/languages/bambara.mjs +1 -1
  113. package/dist/languages/basque.mjs +1 -1
  114. package/dist/languages/belarusian.mjs +1 -1
  115. package/dist/languages/bengali.mjs +1 -1
  116. package/dist/languages/bosnian.mjs +1 -1
  117. package/dist/languages/breton.mjs +1 -1
  118. package/dist/languages/bulgarian.mjs +1 -1
  119. package/dist/languages/burmese.mjs +1 -1
  120. package/dist/languages/catalan.mjs +1 -1
  121. package/dist/languages/chinese.mjs +1 -1
  122. package/dist/languages/croatian.mjs +1 -1
  123. package/dist/languages/czech.mjs +1 -1
  124. package/dist/languages/dagbani.mjs +1 -1
  125. package/dist/languages/danish.mjs +1 -1
  126. package/dist/languages/dutch.mjs +1 -1
  127. package/dist/languages/english.mjs +1 -1
  128. package/dist/languages/esperanto.mjs +1 -1
  129. package/dist/languages/estonian.mjs +1 -1
  130. package/dist/languages/ewe.mjs +1 -1
  131. package/dist/languages/faroese.mjs +1 -1
  132. package/dist/languages/fijian.mjs +1 -1
  133. package/dist/languages/finnish.mjs +1 -1
  134. package/dist/languages/french.mjs +1 -1
  135. package/dist/languages/ga.mjs +1 -1
  136. package/dist/languages/galician.mjs +1 -1
  137. package/dist/languages/georgian.mjs +1 -1
  138. package/dist/languages/german.mjs +1 -1
  139. package/dist/languages/greek.mjs +1 -1
  140. package/dist/languages/guarani.mjs +1 -1
  141. package/dist/languages/gujarati.mjs +1 -1
  142. package/dist/languages/haitian-creole.mjs +1 -1
  143. package/dist/languages/hausa.mjs +1 -1
  144. package/dist/languages/hawaiian.mjs +1 -1
  145. package/dist/languages/hebrew.mjs +1 -1
  146. package/dist/languages/hindi.mjs +1 -1
  147. package/dist/languages/hungarian.mjs +1 -1
  148. package/dist/languages/icelandic.mjs +1 -1
  149. package/dist/languages/igbo.mjs +1 -1
  150. package/dist/languages/indonesian.mjs +1 -1
  151. package/dist/languages/irish.mjs +1 -1
  152. package/dist/languages/italian.mjs +1 -1
  153. package/dist/languages/japanese.mjs +1 -1
  154. package/dist/languages/kannada.mjs +1 -1
  155. package/dist/languages/kazakh.mjs +1 -1
  156. package/dist/languages/khmer.mjs +1 -1
  157. package/dist/languages/kinyarwanda.mjs +1 -1
  158. package/dist/languages/kirundi.mjs +1 -1
  159. package/dist/languages/korean.mjs +1 -1
  160. package/dist/languages/kurmanji.mjs +1 -1
  161. package/dist/languages/kyrgyz.mjs +1 -1
  162. package/dist/languages/lao.mjs +1 -1
  163. package/dist/languages/latin.mjs +1 -1
  164. package/dist/languages/latvian.mjs +1 -1
  165. package/dist/languages/lingala.mjs +1 -1
  166. package/dist/languages/lithuanian.mjs +1 -1
  167. package/dist/languages/luxembourgish.mjs +1 -1
  168. package/dist/languages/macedonian.mjs +1 -1
  169. package/dist/languages/malagasy.mjs +1 -1
  170. package/dist/languages/malay.mjs +1 -1
  171. package/dist/languages/malayalam.mjs +1 -1
  172. package/dist/languages/maltese.mjs +1 -1
  173. package/dist/languages/maori.mjs +1 -1
  174. package/dist/languages/marathi.mjs +1 -1
  175. package/dist/languages/nepali.mjs +1 -1
  176. package/dist/languages/norwegian.mjs +1 -1
  177. package/dist/languages/oromo.mjs +1 -1
  178. package/dist/languages/persian.mjs +1 -1
  179. package/dist/languages/polish.mjs +1 -1
  180. package/dist/languages/portuguese.mjs +1 -1
  181. package/dist/languages/punjabi.mjs +1 -1
  182. package/dist/languages/romanian.mjs +1 -1
  183. package/dist/languages/russian.mjs +1 -1
  184. package/dist/languages/samoan.mjs +1 -1
  185. package/dist/languages/sanskrit.mjs +1 -1
  186. package/dist/languages/scottish-gaelic.mjs +1 -1
  187. package/dist/languages/serbian.mjs +1 -1
  188. package/dist/languages/shona.mjs +1 -1
  189. package/dist/languages/sinhala.mjs +1 -1
  190. package/dist/languages/slovak.mjs +1 -1
  191. package/dist/languages/slovenian.mjs +1 -1
  192. package/dist/languages/sorani.mjs +1 -1
  193. package/dist/languages/spanish.mjs +1 -1
  194. package/dist/languages/swahili.mjs +1 -1
  195. package/dist/languages/swedish.mjs +1 -1
  196. package/dist/languages/tagalog.mjs +1 -1
  197. package/dist/languages/tamil.mjs +1 -1
  198. package/dist/languages/tatar.mjs +1 -1
  199. package/dist/languages/telugu.mjs +1 -1
  200. package/dist/languages/thai.mjs +1 -1
  201. package/dist/languages/tibetan.mjs +1 -1
  202. package/dist/languages/tigrinya.mjs +1 -1
  203. package/dist/languages/tongan.mjs +1 -1
  204. package/dist/languages/turkish.mjs +1 -1
  205. package/dist/languages/twi.mjs +1 -1
  206. package/dist/languages/ukrainian.mjs +1 -1
  207. package/dist/languages/urdu.mjs +1 -1
  208. package/dist/languages/vietnamese.mjs +1 -1
  209. package/dist/languages/welsh.mjs +1 -1
  210. package/dist/languages/wolof.mjs +1 -1
  211. package/dist/languages/xhosa.mjs +1 -1
  212. package/dist/languages/yoruba.mjs +1 -1
  213. package/dist/languages/zulu.mjs +1 -1
  214. package/dist/{long-query-thread-QDFQSJD6.mjs → long-query-thread-JMGNGF6V.mjs} +74 -58
  215. package/dist/{module-N55W4Q5C.mjs → module-ZJ6ARG6V.mjs} +444 -111
  216. package/dist/msgpack-leaf-5WFRP6JM.mjs +9 -0
  217. package/dist/optional-reads-BR3BOVZW.mjs +3373 -0
  218. package/dist/optional-writes-DDFHYUOH.mjs +218 -0
  219. package/dist/{paged-partition-archive-RLRGOXDX.mjs → paged-partition-archive-G576XGVE.mjs} +29 -69
  220. package/dist/partial-words.browser.mjs +1649 -0
  221. package/dist/partial-words.mjs +15 -14
  222. package/dist/{chunk-CITFCZKF.mjs → pattern.browser.mjs} +153 -186
  223. package/dist/pattern.mjs +6 -8
  224. package/dist/persistence/durability/checkpoint-worker.d.ts +32 -24
  225. package/dist/persistence/durability/checkpoint-worker.mjs +27 -59
  226. package/dist/phrase-module-XK3T44VU.mjs +634 -0
  227. package/dist/query-actions-OMXJEC2J.mjs +118 -0
  228. package/dist/query-suggestions/merge-worker.mjs +18 -54
  229. package/dist/query-suggestions.browser.mjs +26 -227
  230. package/dist/query-suggestions.d.ts +2 -2
  231. package/dist/query-suggestions.mjs +16 -67
  232. package/dist/react-native/chunks/chunk-4EXKQ2IB.mjs +565 -0
  233. package/dist/react-native/chunks/chunk-52QD7CBJ.mjs +52 -0
  234. package/dist/react-native/chunks/chunk-72OKYHZL.mjs +969 -0
  235. package/dist/react-native/chunks/chunk-AQOWRH2C.mjs +802 -0
  236. package/dist/react-native/chunks/{chunk-4COWCEY7.mjs → chunk-FTQ7JNMU.mjs} +341 -180
  237. package/dist/react-native/chunks/chunk-G3CUQ333.mjs +42 -0
  238. package/dist/react-native/chunks/{chunk-EJ33LCHV.mjs → chunk-HRDMIQ63.mjs} +53 -1
  239. package/dist/react-native/chunks/{chunk-4AV5PPH6.mjs → chunk-IY6U6HRA.mjs} +63 -7
  240. package/dist/react-native/chunks/chunk-J2NQW353.mjs +212 -0
  241. package/dist/react-native/chunks/chunk-L4R5ITVG.mjs +29047 -0
  242. package/dist/react-native/chunks/{chunk-OXM66LO6.mjs → chunk-OK3WUA6N.mjs} +2 -10
  243. package/dist/react-native/chunks/{chunk-MVXELMJX.mjs → chunk-PVMEHBQO.mjs} +1 -1
  244. package/dist/{browser/chunk-SRMZXJSL.mjs → react-native/chunks/chunk-TQ26BKBH.mjs} +6 -0
  245. package/dist/{browser/chunk-GPPOG6PT.mjs → react-native/chunks/chunk-VUJCSQG5.mjs} +3 -1
  246. package/dist/react-native/chunks/{chunk-ENLMYKSX.mjs → chunk-XEGKQKLY.mjs} +5385 -3114
  247. package/dist/react-native/chunks/chunk-YOTP2FPE.mjs +232 -0
  248. package/dist/react-native/chunks/chunk-ZIU6TWXG.mjs +127 -0
  249. package/dist/react-native/chunks/core-leaf-5B4JXCVA.mjs +6 -0
  250. package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
  251. package/dist/{durability-config-GE4U7MCZ.mjs → react-native/chunks/durability-config-3IOXIPYZ.mjs} +7 -3
  252. package/dist/react-native/chunks/embed-3WQ2CCR5.mjs +221 -0
  253. package/dist/{geo-index-MRH5JMIR.mjs → react-native/chunks/geo-index-QEYKEVPH.mjs} +190 -93
  254. package/dist/react-native/chunks/{chunk-CKNRFDTZ.mjs → gzip.react-native-DLO4WW27.mjs} +2 -1
  255. package/dist/{browser/module-TCT66FWA.mjs → react-native/chunks/module-VUA27HZZ.mjs} +1018 -540
  256. package/dist/react-native/chunks/msgpack-leaf-TR66ZVAX.mjs +7 -0
  257. package/dist/react-native/chunks/optional-reads-WDTLLHUT.mjs +3364 -0
  258. package/dist/react-native/chunks/optional-writes-FZV3QW34.mjs +267 -0
  259. package/dist/react-native/chunks/phrase-module-KCQWVXYZ.mjs +635 -0
  260. package/dist/react-native/chunks/resolve-vector-text-LXRYXF7M.mjs +59 -0
  261. package/dist/react-native/chunks/restore-queue-EI2V2I4S.mjs +179 -0
  262. package/dist/{browser/runtime-OTAGEFQW.mjs → react-native/chunks/runtime-BUCSAK4U.mjs} +61 -25
  263. package/dist/react-native/chunks/segment-codec-leaf-6ULP7H3I.mjs +12 -0
  264. package/dist/react-native/chunks/segment-merge-leaf-F4GQZNK6.mjs +13 -0
  265. package/dist/react-native/chunks/storage-leaf-OAXBU2L6.mjs +18042 -0
  266. package/dist/react-native/chunks/store-leaf-GY2ZZFXB.mjs +14 -0
  267. package/dist/react-native/chunks/{chunk-WW2X2AEI.mjs → suggestions-leaf-SQEZ4IBS.mjs} +332 -118
  268. package/dist/react-native/chunks/worker-copies-EEHSCFJW.mjs +2627 -0
  269. package/dist/react-native/partial-words.mjs +954 -35
  270. package/dist/react-native/pattern.mjs +238 -111
  271. package/dist/react-native/query-suggestions.mjs +33 -239
  272. package/dist/react-native/sync.mjs +95 -52
  273. package/dist/react-native/synonyms.mjs +256 -112
  274. package/dist/react.d.ts +9 -9
  275. package/dist/react.mjs +6 -0
  276. package/dist/{rerank-MQ37IYRV.mjs → rerank-Y6MWBMTT.mjs} +17 -8
  277. package/dist/rerankers/http.mjs +2 -2
  278. package/dist/resolve-vector-text-4PDRTPNQ.mjs +2 -0
  279. package/dist/restore-queue-KPYSRJ4A.mjs +184 -0
  280. package/dist/runtime-4GKUIAKV.mjs +595 -0
  281. package/dist/{schema-Jwt928nJ.d.ts → schema-C_7yRJLt.d.ts} +1 -1
  282. package/dist/segment-codec-leaf-6IFBSBPN.mjs +17 -0
  283. package/dist/segment-merge-leaf-VE3FUSVE.mjs +17 -0
  284. package/dist/server.d.ts +33 -13
  285. package/dist/server.mjs +81 -100
  286. package/dist/{browser/durability-wiring-GVZEE46O.mjs → storage-leaf-HMIIOUYN.mjs} +2334 -931
  287. package/dist/store-leaf-M7T7SUZJ.mjs +19 -0
  288. package/dist/stored-values-BWIMpiT_.d.ts +25 -0
  289. package/dist/suggestions-leaf-Q3Q5D6XV.mjs +53 -0
  290. package/dist/sync/filesystem.d.ts +3 -3
  291. package/dist/sync/filesystem.mjs +27 -11
  292. package/dist/sync/indexeddb.browser.mjs +287 -0
  293. package/dist/sync/indexeddb.d.ts +3 -3
  294. package/dist/sync/indexeddb.mjs +7 -2
  295. package/dist/sync.browser.mjs +88 -72
  296. package/dist/sync.d.ts +4 -4
  297. package/dist/sync.mjs +89 -59
  298. package/dist/{chunk-I5B7RXU7.mjs → synonyms.browser.mjs} +248 -135
  299. package/dist/synonyms.mjs +15 -11
  300. package/dist/{tasks-CoNjxbop.d.ts → tasks-B4tT4vmP.d.ts} +4 -4
  301. package/dist/thread-SNILJXX3.mjs +30 -0
  302. package/dist/{types-DPMjfOr_.d.ts → types-CTg0KaMy.d.ts} +2 -2
  303. package/dist/vector/search-worker.d.ts +7 -1
  304. package/dist/vector/search-worker.mjs +9 -13
  305. package/dist/worker-copies-ZLZS2CUM.mjs +2152 -0
  306. package/dist/workers/entry.mjs +60 -30
  307. package/openapi.json +66 -50
  308. package/package.json +233 -8
  309. package/dist/analysis-change-CKEMM2MC.mjs +0 -55
  310. package/dist/analysis-change-entry-SEDMJ6MW.mjs +0 -1
  311. package/dist/archive-history-E4R73RWD.mjs +0 -29
  312. package/dist/browser/analysis-change-ZKGJFENM.mjs +0 -942
  313. package/dist/browser/analysis-change-entry-5BFUVMHJ.mjs +0 -1
  314. package/dist/browser/archive-history-4IP5XQZY.mjs +0 -29
  315. package/dist/browser/chunk-25MTVDYD.mjs +0 -432
  316. package/dist/browser/chunk-3I27KXQD.mjs +0 -34
  317. package/dist/browser/chunk-3NLMB5CC.mjs +0 -217
  318. package/dist/browser/chunk-4RD3AFSB.mjs +0 -32
  319. package/dist/browser/chunk-5W3MMTLG.mjs +0 -19
  320. package/dist/browser/chunk-5YWB3E2W.mjs +0 -92
  321. package/dist/browser/chunk-7IGKGWSQ.mjs +0 -79
  322. package/dist/browser/chunk-AI5UI46D.mjs +0 -12
  323. package/dist/browser/chunk-ATEBYXP6.mjs +0 -10
  324. package/dist/browser/chunk-BLT4RHCJ.mjs +0 -241
  325. package/dist/browser/chunk-C26SPCGQ.mjs +0 -2636
  326. package/dist/browser/chunk-C4FJ3WDY.mjs +0 -177
  327. package/dist/browser/chunk-CXNTHHA7.mjs +0 -63
  328. package/dist/browser/chunk-DSXIBE6N.mjs +0 -78
  329. package/dist/browser/chunk-DUH6QUVU.mjs +0 -2374
  330. package/dist/browser/chunk-ELV4OZOI.mjs +0 -29
  331. package/dist/browser/chunk-EXQZGUQH.mjs +0 -193
  332. package/dist/browser/chunk-G64Q6OJF.mjs +0 -96
  333. package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
  334. package/dist/browser/chunk-HUCSHDTB.mjs +0 -100
  335. package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
  336. package/dist/browser/chunk-K3IPRX6D.mjs +0 -2559
  337. package/dist/browser/chunk-ML7THVLJ.mjs +0 -38
  338. package/dist/browser/chunk-MY2XKH22.mjs +0 -40
  339. package/dist/browser/chunk-NLWTBAGB.mjs +0 -111
  340. package/dist/browser/chunk-NXQG7DRA.mjs +0 -318
  341. package/dist/browser/chunk-OEDCEZXJ.mjs +0 -92
  342. package/dist/browser/chunk-OIZS5KIX.mjs +0 -6
  343. package/dist/browser/chunk-RA6LSBCM.mjs +0 -43
  344. package/dist/browser/chunk-TK63WFXK.mjs +0 -90
  345. package/dist/browser/chunk-TY7L6OXO.mjs +0 -69
  346. package/dist/browser/chunk-U3JOQGWX.mjs +0 -19
  347. package/dist/browser/chunk-U4YDIBUT.mjs +0 -653
  348. package/dist/browser/chunk-UATIJ4KU.mjs +0 -21
  349. package/dist/browser/chunk-UKOWD2K5.mjs +0 -315
  350. package/dist/browser/chunk-UTMHUHUV.mjs +0 -150
  351. package/dist/browser/chunk-V43N6TZO.mjs +0 -857
  352. package/dist/browser/chunk-VI7BQR4U.mjs +0 -21
  353. package/dist/browser/chunk-WN464PTL.mjs +0 -375
  354. package/dist/browser/chunk-WXLBZJMT.mjs +0 -25
  355. package/dist/browser/chunk-X7TXYUKO.mjs +0 -86
  356. package/dist/browser/chunk-XAWNZ4G2.mjs +0 -151
  357. package/dist/browser/chunk-Y6IBAUNO.mjs +0 -561
  358. package/dist/browser/chunk-ZI2V4VD7.mjs +0 -21
  359. package/dist/browser/cold-module-YNUUDNOM.mjs +0 -761
  360. package/dist/browser/engine-hooks-HBVS6YM4.mjs +0 -18
  361. package/dist/browser/gzip-5S7ROJFJ.mjs +0 -1
  362. package/dist/browser/import-5ESVMFDJ.mjs +0 -20
  363. package/dist/browser/methods-KTQCSIN4.mjs +0 -30
  364. package/dist/browser/module-NDSQLPMQ.mjs +0 -25
  365. package/dist/browser/operations-OJ3BXS55.mjs +0 -5
  366. package/dist/browser/phrase-module-HAT3TLZN.mjs +0 -328
  367. package/dist/browser/pool-3JLET5RO.mjs +0 -297
  368. package/dist/browser/release-HYXPVJVS.mjs +0 -32
  369. package/dist/browser/restore-queue-LQBBTODR.mjs +0 -55
  370. package/dist/browser/retention-TY3L3BFN.mjs +0 -211
  371. package/dist/browser/snapshot-5FHPPCNZ.mjs +0 -965
  372. package/dist/browser/start-2UZTOBG5.mjs +0 -26
  373. package/dist/browser/sync-state-P5XG6LTQ.mjs +0 -15
  374. package/dist/browser/write-ULXAN5B4.mjs +0 -196
  375. package/dist/chunk-2NE7VCYE.mjs +0 -212
  376. package/dist/chunk-2ROUFMQX.mjs +0 -543
  377. package/dist/chunk-37CD3OKS.mjs +0 -87
  378. package/dist/chunk-3MXV3VHR.mjs +0 -46
  379. package/dist/chunk-3OH67G7R.mjs +0 -214
  380. package/dist/chunk-4B7JIGQD.mjs +0 -106
  381. package/dist/chunk-5YNRKI2C.mjs +0 -81
  382. package/dist/chunk-6HTGOXIK.mjs +0 -875
  383. package/dist/chunk-6OEGXLBX.mjs +0 -57
  384. package/dist/chunk-6RC4K46J.mjs +0 -86
  385. package/dist/chunk-7GFE3PEY.mjs +0 -40
  386. package/dist/chunk-7GXJUJ24.mjs +0 -49
  387. package/dist/chunk-7V5IUP2T.mjs +0 -63
  388. package/dist/chunk-A4L7YTKX.mjs +0 -458
  389. package/dist/chunk-BEZH7VEH.mjs +0 -23
  390. package/dist/chunk-BNL5OPRV.mjs +0 -634
  391. package/dist/chunk-BTPGQC6Z.mjs +0 -27
  392. package/dist/chunk-C7XQYG6U.mjs +0 -50
  393. package/dist/chunk-CQZXZ75V.mjs +0 -562
  394. package/dist/chunk-CWS55TEX.mjs +0 -242
  395. package/dist/chunk-CZQ33DLW.mjs +0 -78
  396. package/dist/chunk-EEBCDP36.mjs +0 -32
  397. package/dist/chunk-FB6463IN.mjs +0 -1499
  398. package/dist/chunk-FCJ553HS.mjs +0 -655
  399. package/dist/chunk-FEZVDOWX.mjs +0 -6996
  400. package/dist/chunk-FOCV4CBZ.mjs +0 -87
  401. package/dist/chunk-FQBFZAWG.mjs +0 -27
  402. package/dist/chunk-G6HRSGOU.mjs +0 -74
  403. package/dist/chunk-GES7U2PM.mjs +0 -68
  404. package/dist/chunk-GH4WQ22V.mjs +0 -34
  405. package/dist/chunk-GPWMUPCA.mjs +0 -1126
  406. package/dist/chunk-GQPTDQCL.mjs +0 -54
  407. package/dist/chunk-HJSN7UYG.mjs +0 -10
  408. package/dist/chunk-I54T6CQP.mjs +0 -117
  409. package/dist/chunk-IPN7S4KX.mjs +0 -130
  410. package/dist/chunk-J4IJTTEX.mjs +0 -226
  411. package/dist/chunk-JSV6OQ4C.mjs +0 -74
  412. package/dist/chunk-K4ZIGL2O.mjs +0 -290
  413. package/dist/chunk-KAKQ74LS.mjs +0 -53
  414. package/dist/chunk-KCQYFO4K.mjs +0 -62
  415. package/dist/chunk-KHKIRS5D.mjs +0 -113
  416. package/dist/chunk-KOKM4PQN.mjs +0 -52
  417. package/dist/chunk-KP7TYHWT.mjs +0 -92
  418. package/dist/chunk-KZ3NX2P7.mjs +0 -21
  419. package/dist/chunk-L5ORED7V.mjs +0 -25
  420. package/dist/chunk-LDNCLRZU.mjs +0 -218
  421. package/dist/chunk-LHKOSI2J.mjs +0 -58
  422. package/dist/chunk-LQG5G2LY.mjs +0 -39
  423. package/dist/chunk-MATMVH65.mjs +0 -9
  424. package/dist/chunk-MP7ABPTD.mjs +0 -189
  425. package/dist/chunk-MW6BR4QP.mjs +0 -316
  426. package/dist/chunk-MWD5VPN7.mjs +0 -21
  427. package/dist/chunk-ODYKO5TO.mjs +0 -101
  428. package/dist/chunk-OG7UGJ6F.mjs +0 -63
  429. package/dist/chunk-ORN5BLL7.mjs +0 -11
  430. package/dist/chunk-OYABFKTW.mjs +0 -1974
  431. package/dist/chunk-P5LANSH6.mjs +0 -121
  432. package/dist/chunk-PELHVTO7.mjs +0 -24
  433. package/dist/chunk-PIH5SJ4N.mjs +0 -7481
  434. package/dist/chunk-PSZI4O24.mjs +0 -253
  435. package/dist/chunk-PV2CG7EJ.mjs +0 -886
  436. package/dist/chunk-PWGYQXML.mjs +0 -470
  437. package/dist/chunk-Q2UL2TPC.mjs +0 -21
  438. package/dist/chunk-QHPYS427.mjs +0 -66
  439. package/dist/chunk-QJVOLKU6.mjs +0 -111
  440. package/dist/chunk-QLDABJZM.mjs +0 -20
  441. package/dist/chunk-QYRNLLLI.mjs +0 -99
  442. package/dist/chunk-RCX4WNLC.mjs +0 -151
  443. package/dist/chunk-RFBLQLLZ.mjs +0 -16
  444. package/dist/chunk-RIHIVFIQ.mjs +0 -240
  445. package/dist/chunk-RLOES5SX.mjs +0 -31
  446. package/dist/chunk-RWURUDSP.mjs +0 -2639
  447. package/dist/chunk-RZWWB2XR.mjs +0 -96
  448. package/dist/chunk-S5LN746F.mjs +0 -10
  449. package/dist/chunk-SOI6LTHM.mjs +0 -216
  450. package/dist/chunk-SQJWAIF4.mjs +0 -12
  451. package/dist/chunk-TDIK6NTV.mjs +0 -10
  452. package/dist/chunk-TQXHPFWT.mjs +0 -177
  453. package/dist/chunk-U55XJEIG.mjs +0 -18
  454. package/dist/chunk-UD5HIS4U.mjs +0 -382
  455. package/dist/chunk-UHICS3JI.mjs +0 -83
  456. package/dist/chunk-UJDJB3NE.mjs +0 -913
  457. package/dist/chunk-VD7J552I.mjs +0 -28
  458. package/dist/chunk-VSLSGASN.mjs +0 -30
  459. package/dist/chunk-VZ2ONHEE.mjs +0 -3715
  460. package/dist/chunk-W7OSSKH5.mjs +0 -1427
  461. package/dist/chunk-WZ7YV54N.mjs +0 -152
  462. package/dist/chunk-X5CV2E2B.mjs +0 -1
  463. package/dist/chunk-Y4WPNHMC.mjs +0 -50
  464. package/dist/chunk-YEKL4JBK.mjs +0 -96
  465. package/dist/chunk-ZXNQEW43.mjs +0 -18
  466. package/dist/chunk-ZYAY26KG.mjs +0 -29
  467. package/dist/direct-executor-V5DRIECI.mjs +0 -34
  468. package/dist/durability-wiring-3TD62MBI.mjs +0 -4072
  469. package/dist/engine-hooks-HA3SBOBR.mjs +0 -54
  470. package/dist/gzip-F4HMIEEQ.mjs +0 -1
  471. package/dist/import-GPKLTSKA.mjs +0 -56
  472. package/dist/methods-7IOINERF.mjs +0 -30
  473. package/dist/module-JYHFTVPS.mjs +0 -63
  474. package/dist/operations-G5EP6JPX.mjs +0 -5
  475. package/dist/phrase-module-XW5MKWP5.mjs +0 -330
  476. package/dist/pool-Y4A46T36.mjs +0 -298
  477. package/dist/react-native/chunks/analysis-change-QUVDNABS.mjs +0 -934
  478. package/dist/react-native/chunks/analysis-change-entry-OC4XASBF.mjs +0 -1
  479. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +0 -29
  480. package/dist/react-native/chunks/chunk-2PRHILX3.mjs +0 -529
  481. package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +0 -1
  482. package/dist/react-native/chunks/chunk-3WI35N75.mjs +0 -226
  483. package/dist/react-native/chunks/chunk-4DII3ZSM.mjs +0 -73
  484. package/dist/react-native/chunks/chunk-4J74WHQM.mjs +0 -177
  485. package/dist/react-native/chunks/chunk-4NWR3NGS.mjs +0 -151
  486. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +0 -17
  487. package/dist/react-native/chunks/chunk-5MSX5FRT.mjs +0 -858
  488. package/dist/react-native/chunks/chunk-6OFDUYVX.mjs +0 -92
  489. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +0 -9
  490. package/dist/react-native/chunks/chunk-6ZELFCK5.mjs +0 -315
  491. package/dist/react-native/chunks/chunk-AAAETEJK.mjs +0 -27
  492. package/dist/react-native/chunks/chunk-AM7RSBPF.mjs +0 -32
  493. package/dist/react-native/chunks/chunk-BITYFZSZ.mjs +0 -242
  494. package/dist/react-native/chunks/chunk-C5G6TJ7A.mjs +0 -140
  495. package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +0 -43
  496. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +0 -10
  497. package/dist/react-native/chunks/chunk-DMIFXZ3Q.mjs +0 -432
  498. package/dist/react-native/chunks/chunk-DVDX4SDR.mjs +0 -375
  499. package/dist/react-native/chunks/chunk-DXRSEWA2.mjs +0 -12
  500. package/dist/react-native/chunks/chunk-F753DA54.mjs +0 -23
  501. package/dist/react-native/chunks/chunk-FHPW7P2O.mjs +0 -40
  502. package/dist/react-native/chunks/chunk-FTZHMRD2.mjs +0 -18
  503. package/dist/react-native/chunks/chunk-HJBJBH26.mjs +0 -34
  504. package/dist/react-native/chunks/chunk-IAENKE2D.mjs +0 -21
  505. package/dist/react-native/chunks/chunk-IO2SMUQD.mjs +0 -10
  506. package/dist/react-native/chunks/chunk-IYNT75CE.mjs +0 -111
  507. package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +0 -38
  508. package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +0 -15
  509. package/dist/react-native/chunks/chunk-KSBYEMCB.mjs +0 -100
  510. package/dist/react-native/chunks/chunk-KU646XXT.mjs +0 -164
  511. package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +0 -68
  512. package/dist/react-native/chunks/chunk-LVIKKAA6.mjs +0 -93
  513. package/dist/react-native/chunks/chunk-LZSLNSUN.mjs +0 -193
  514. package/dist/react-native/chunks/chunk-MJDQU5MW.mjs +0 -1225
  515. package/dist/react-native/chunks/chunk-NNE4VDMM.mjs +0 -8
  516. package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +0 -78
  517. package/dist/react-native/chunks/chunk-OCSLSH27.mjs +0 -22723
  518. package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +0 -29
  519. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +0 -79
  520. package/dist/react-native/chunks/chunk-PSWKQVVT.mjs +0 -9
  521. package/dist/react-native/chunks/chunk-RDWG33MM.mjs +0 -79
  522. package/dist/react-native/chunks/chunk-SK2PWYDH.mjs +0 -654
  523. package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +0 -96
  524. package/dist/react-native/chunks/chunk-TORU2OHQ.mjs +0 -218
  525. package/dist/react-native/chunks/chunk-U4KSKA4Z.mjs +0 -23
  526. package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +0 -68
  527. package/dist/react-native/chunks/chunk-WBYQRHDY.mjs +0 -86
  528. package/dist/react-native/chunks/chunk-WVWJNUMN.mjs +0 -2562
  529. package/dist/react-native/chunks/chunk-YH7QY657.mjs +0 -288
  530. package/dist/react-native/chunks/chunk-YZW4CHM6.mjs +0 -562
  531. package/dist/react-native/chunks/chunk-ZNZ6CPAZ.mjs +0 -562
  532. package/dist/react-native/chunks/chunk-ZVQMBF2H.mjs +0 -63
  533. package/dist/react-native/chunks/chunk-ZWAIN4GG.mjs +0 -2636
  534. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +0 -92
  535. package/dist/react-native/chunks/cold-module-N6KFNNZA.mjs +0 -773
  536. package/dist/react-native/chunks/durability-wiring-RN64S2TL.mjs +0 -4984
  537. package/dist/react-native/chunks/engine-hooks-CWA5CKCA.mjs +0 -30
  538. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +0 -3
  539. package/dist/react-native/chunks/import-5UAWBRJP.mjs +0 -32
  540. package/dist/react-native/chunks/methods-6W5U4C3H.mjs +0 -30
  541. package/dist/react-native/chunks/module-6RP4ZCBW.mjs +0 -37
  542. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +0 -5
  543. package/dist/react-native/chunks/phrase-module-QK22HSQ2.mjs +0 -329
  544. package/dist/react-native/chunks/pool-JR3NJCAF.mjs +0 -297
  545. package/dist/react-native/chunks/release-2SIHZWDO.mjs +0 -32
  546. package/dist/react-native/chunks/restore-hooks-ENFMDTWC.mjs +0 -127
  547. package/dist/react-native/chunks/restore-queue-4R6AASE5.mjs +0 -55
  548. package/dist/react-native/chunks/retention-5GTFT3GR.mjs +0 -223
  549. package/dist/react-native/chunks/snapshot-5LGPQXFS.mjs +0 -976
  550. package/dist/react-native/chunks/start-ZQJVZ5DN.mjs +0 -38
  551. package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +0 -15
  552. package/dist/react-native/chunks/write-6BRYIIZ7.mjs +0 -208
  553. package/dist/release-SMR4WJD4.mjs +0 -32
  554. package/dist/restore-hooks-HXLIEB4A.mjs +0 -153
  555. package/dist/restore-queue-LZH7LMLR.mjs +0 -55
  556. package/dist/retention-3K7ARGAG.mjs +0 -66
  557. package/dist/runtime-COIUORCN.mjs +0 -177
  558. package/dist/snapshot-O7ICP7NJ.mjs +0 -783
  559. package/dist/start-S4PFP6RS.mjs +0 -66
  560. package/dist/sync-state-ZWHLAFLE.mjs +0 -15
  561. package/dist/thread-YLJ3ZPQ3.mjs +0 -50
  562. package/dist/write-2OBJGLFS.mjs +0 -233
  563. /package/dist/browser/{chunk-M3MQE2X7.mjs → digest-leaf-64IPRPZD.mjs} +0 -0
  564. /package/dist/browser/{chunk-JNOAKDUM.mjs → gzip-JF3S6PPT.mjs} +0 -0
  565. /package/dist/{chunk-ZXNNR73R.mjs → gzip-2UCZW2MM.mjs} +0 -0
@@ -1,2374 +0,0 @@
1
- import { MAX_LATITUDE_DEGREES, MAX_LONGITUDE_DEGREES } from './chunk-AI5UI46D.mjs';
2
- import { compareCodePoints, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, holdsUnpairedSurrogate, exceedsCodePoints } from './chunk-NXQG7DRA.mjs';
3
- import { MAX_DOCUMENT_ENCODING_DEPTH, MAX_FILE_BYTES, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, CHECKSUM_YIELD_CHUNK_BYTES } from './chunk-GPPOG6PT.mjs';
4
- import { NarsilError, ErrorCodes } from './chunk-SRMZXJSL.mjs';
5
- import { Encoder, decode } from '@msgpack/msgpack';
6
-
7
- // src/analysis/registry.ts
8
- var tokenizers = /* @__PURE__ */ new Map();
9
- var stopWordSets = /* @__PURE__ */ new Map();
10
- function requireName(name, kind) {
11
- if (typeof name !== "string" || name.trim().length === 0) {
12
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `A registered ${kind} needs a non-empty name`, { name });
13
- }
14
- }
15
- function registerTokenizer(name, tokenizer) {
16
- requireName(name, "tokenizer");
17
- if (typeof tokenizer?.tokenize !== "function") {
18
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Tokenizer "${name}" needs a tokenize method`, { tokenizer: name });
19
- }
20
- tokenizers.set(name, tokenizer);
21
- }
22
- function registerStopWords(name, stopWords2) {
23
- requireName(name, "stop word set");
24
- if (!(stopWords2 instanceof Set) && typeof stopWords2 !== "function") {
25
- throw new NarsilError(
26
- ErrorCodes.CONFIG_INVALID,
27
- `Stop word set "${name}" needs a Set of words or a function returning one`,
28
- { stopWords: name }
29
- );
30
- }
31
- stopWordSets.set(name, stopWords2);
32
- }
33
- function hasTokenizer(name) {
34
- return tokenizers.has(name);
35
- }
36
- function hasStopWords(name) {
37
- return stopWordSets.has(name);
38
- }
39
- function getTokenizer(name) {
40
- const tokenizer = tokenizers.get(name);
41
- if (!tokenizer) {
42
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Tokenizer "${name}" is not registered on this engine`, {
43
- tokenizer: name,
44
- available: [...tokenizers.keys()]
45
- });
46
- }
47
- return tokenizer;
48
- }
49
- function getStopWords(name) {
50
- const stopWords2 = stopWordSets.get(name);
51
- if (!stopWords2) {
52
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Stop word set "${name}" is not registered on this engine`, {
53
- stopWords: name,
54
- available: [...stopWordSets.keys()]
55
- });
56
- }
57
- return stopWords2;
58
- }
59
- function holdsPositionsOutOfOrder(entries) {
60
- for (let index = 1; index < entries.length; index++) {
61
- if (entries[index].position < entries[index - 1].position) return true;
62
- }
63
- return false;
64
- }
65
- function inPositionOrder(tokenizer) {
66
- return {
67
- tokenize(text) {
68
- const entries = tokenizer.tokenize(text);
69
- if (!holdsPositionsOutOfOrder(entries)) return entries;
70
- return [...entries].sort((first, second) => first.position - second.position);
71
- }
72
- };
73
- }
74
- function resolveIndexAnalysis(config) {
75
- const tokenizer = typeof config.tokenizer === "string" ? getTokenizer(config.tokenizer) : config.tokenizer;
76
- return {
77
- stopWords: typeof config.stopWords === "string" ? getStopWords(config.stopWords) : config.stopWords,
78
- customTokenizer: tokenizer === void 0 ? void 0 : inPositionOrder(tokenizer)
79
- };
80
- }
81
-
82
- // src/schema/constants.ts
83
- var MAX_NESTING_DEPTH = 4;
84
- var MAX_DOCUMENT_NESTING_DEPTH = 32;
85
- var DEFAULT_PATTERN_VALUE_LIMIT = 8192;
86
- var MIN_PATTERN_VALUE_LIMIT = 1;
87
- var MAX_PATTERN_VALUE_LIMIT = 65536;
88
- var MAX_VECTOR_DIMENSION = 4096;
89
- var MAX_STORED_VECTOR_DIMENSION = 65535;
90
- var MAX_TEXT_FIELDS = 65536;
91
- var MAX_DOCUMENT_BYTES = 16777216;
92
- var PARSED_FIELD_TYPE_CACHE_ENTRIES = 1024;
93
-
94
- // src/schema/validator/shared.ts
95
- var VECTOR_PATTERN = /^vector\[(\d+)]$/;
96
- function isGeopointOrVectorType(fieldType) {
97
- return fieldType === "geopoint" || fieldType !== void 0 && VECTOR_PATTERN.test(fieldType);
98
- }
99
- var FIELD_NAME_PATTERN = /^[A-Za-z0-9_]+$/;
100
- var RESERVED_ROOT_FIELDS = /* @__PURE__ */ new Set(["id"]);
101
- var PROTOTYPE_POLLUTION_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
102
- function isPlainObject(value) {
103
- return typeof value === "object" && value !== null && !Array.isArray(value);
104
- }
105
-
106
- // src/schema/validator/field-type.ts
107
- var FIELD_OPTION_ORDER = ["sortable", "pattern", "partial"];
108
- var OPTIONS_BY_BASE = {
109
- string: FIELD_OPTION_ORDER,
110
- "string[]": FIELD_OPTION_ORDER,
111
- verbatim: ["sortable"],
112
- "verbatim[]": ["sortable"],
113
- number: [],
114
- "number[]": [],
115
- boolean: [],
116
- "boolean[]": [],
117
- enum: [],
118
- "enum[]": [],
119
- geopoint: [],
120
- vector: []
121
- };
122
- var TYPE_SEPARATOR = ":";
123
- function isNamedBase(name) {
124
- return name !== "vector" && Object.hasOwn(OPTIONS_BY_BASE, name);
125
- }
126
- function describeAllowedOptions(baseName, allowed) {
127
- if (allowed.length === 0) return `the "${baseName}" type has no options`;
128
- const quoted = allowed.map((option) => `"${option}"`);
129
- if (quoted.length === 1) return `the only option of the "${baseName}" type is ${quoted[0]}`;
130
- return `the options of the "${baseName}" type are ${quoted.slice(0, -1).join(", ")}, and ${quoted[quoted.length - 1]}`;
131
- }
132
- function invalidType(path, type, message) {
133
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, message, { field: path, type });
134
- }
135
- function parseBase(baseName, path, type) {
136
- if (isNamedBase(baseName)) return { base: baseName, dimension: 0 };
137
- const vectorMatch = VECTOR_PATTERN.exec(baseName);
138
- if (vectorMatch === null) {
139
- invalidType(path, type, `Field "${path}" has an unsupported type: "${type}"`);
140
- }
141
- const dimension = Number.parseInt(vectorMatch[1], 10);
142
- if (dimension <= 0 || dimension > MAX_STORED_VECTOR_DIMENSION) {
143
- throw new NarsilError(
144
- ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
145
- `Vector field "${path}" has ${dimension} dimensions, but a vector field holds from 1 to ${MAX_STORED_VECTOR_DIMENSION}`,
146
- { field: path, dimension, maximum: MAX_STORED_VECTOR_DIMENSION }
147
- );
148
- }
149
- return { base: "vector", dimension };
150
- }
151
- function parseFieldType(type, path) {
152
- const separatorIndex = type.indexOf(TYPE_SEPARATOR);
153
- const baseName = separatorIndex === -1 ? type : type.slice(0, separatorIndex);
154
- const { base, dimension } = parseBase(baseName, path, type);
155
- const allowed = OPTIONS_BY_BASE[base];
156
- const options = /* @__PURE__ */ new Set();
157
- if (separatorIndex !== -1) {
158
- for (const option of type.slice(separatorIndex + 1).split(TYPE_SEPARATOR)) {
159
- if (!allowed.includes(option)) {
160
- invalidType(
161
- path,
162
- type,
163
- `Field "${path}" has type "${type}" with the option "${option}", but ${describeAllowedOptions(baseName, allowed)}`
164
- );
165
- }
166
- if (options.has(option)) {
167
- invalidType(path, type, `Field "${path}" has the "${option}" option twice in type "${type}"`);
168
- }
169
- options.add(option);
170
- }
171
- }
172
- const ordered = FIELD_OPTION_ORDER.filter((option) => options.has(option));
173
- const verbatim = base === "verbatim" || base === "verbatim[]";
174
- return {
175
- type: [baseName, ...ordered].join(TYPE_SEPARATOR),
176
- base,
177
- sortable: options.has("sortable"),
178
- pattern: verbatim || options.has("pattern"),
179
- partial: options.has("partial"),
180
- dimension
181
- };
182
- }
183
- var parsedTypesByName = /* @__PURE__ */ new Map();
184
- function parsedTypeOf(type) {
185
- if (type === void 0) return void 0;
186
- const known = parsedTypesByName.get(type);
187
- if (known !== void 0) return known;
188
- try {
189
- const parsed = Object.freeze(parseFieldType(type, ""));
190
- if (parsedTypesByName.size < PARSED_FIELD_TYPE_CACHE_ENTRIES) parsedTypesByName.set(type, parsed);
191
- return parsed;
192
- } catch {
193
- return void 0;
194
- }
195
- }
196
- function withSortableOption(parsed) {
197
- if (parsed.sortable) return parsed.type;
198
- const separatorIndex = parsed.type.indexOf(TYPE_SEPARATOR);
199
- const baseName = separatorIndex === -1 ? parsed.type : parsed.type.slice(0, separatorIndex);
200
- return parseFieldType(`${baseName}${TYPE_SEPARATOR}sortable${parsed.type.slice(baseName.length)}`, "").type;
201
- }
202
- function isListBase(base) {
203
- return base.endsWith("[]");
204
- }
205
- function isWordIndexedBase(base) {
206
- return base === "string" || base === "string[]";
207
- }
208
- function isSingleStringFieldType(fieldType) {
209
- return parsedTypeOf(fieldType)?.base === "string";
210
- }
211
- function isWordIndexedFieldType(fieldType) {
212
- const parsed = parsedTypeOf(fieldType);
213
- return parsed !== void 0 && isWordIndexedBase(parsed.base);
214
- }
215
- function isStringValuedBase(base) {
216
- return base === "string" || base === "string[]" || base === "verbatim" || base === "verbatim[]";
217
- }
218
-
219
- // src/schema/validator/schema.ts
220
- function validateSchemaFields(schema, depth, prefix) {
221
- if (depth > MAX_NESTING_DEPTH) {
222
- throw new NarsilError(
223
- ErrorCodes.SCHEMA_DEPTH_EXCEEDED,
224
- `Schema nesting exceeds the maximum depth of ${MAX_NESTING_DEPTH} at "${prefix}"`,
225
- { path: prefix, maxDepth: MAX_NESTING_DEPTH }
226
- );
227
- }
228
- let canonical = null;
229
- const replace = (field, value) => {
230
- if (canonical === null) canonical = { ...schema };
231
- canonical[field] = value;
232
- };
233
- for (const [field, type] of Object.entries(schema)) {
234
- const path = prefix ? `${prefix}.${field}` : field;
235
- if (PROTOTYPE_POLLUTION_KEYS.has(field)) {
236
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, `Field name "${field}" is not allowed in a schema`, {
237
- field,
238
- path
239
- });
240
- }
241
- if (!FIELD_NAME_PATTERN.test(field)) {
242
- throw new NarsilError(
243
- ErrorCodes.SCHEMA_INVALID_TYPE,
244
- `Field name "${field}" contains characters that are not allowed; use letters, digits, and underscores only`,
245
- { field, path }
246
- );
247
- }
248
- if (depth === 1 && RESERVED_ROOT_FIELDS.has(field)) {
249
- throw new NarsilError(
250
- ErrorCodes.SCHEMA_INVALID_TYPE,
251
- `Field "${field}" is reserved and cannot be defined in a schema`,
252
- { field, path }
253
- );
254
- }
255
- if (isPlainObject(type)) {
256
- const nested = validateSchemaFields(type, depth + 1, path);
257
- if (nested !== type) replace(field, nested);
258
- continue;
259
- }
260
- if (typeof type !== "string") {
261
- throw new NarsilError(
262
- ErrorCodes.SCHEMA_INVALID_TYPE,
263
- `Field "${path}" has an invalid type definition: ${String(type)}`,
264
- {
265
- field: path,
266
- type: String(type)
267
- }
268
- );
269
- }
270
- const parsed = parseFieldType(type, path);
271
- if (parsed.type !== type) replace(field, parsed.type);
272
- }
273
- return canonical ?? schema;
274
- }
275
- function validateSchema(schema) {
276
- if (!isPlainObject(schema)) {
277
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must be a plain object", {
278
- received: typeof schema
279
- });
280
- }
281
- if (Object.keys(schema).length === 0) {
282
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must define at least one field");
283
- }
284
- const validated = validateSchemaFields(schema, 1, "");
285
- requireTextFieldCount(schemaFieldsOf(validated).filter((field) => isWordIndexedBase(field.base)).length);
286
- return validated;
287
- }
288
- function requireTextFieldCount(count) {
289
- if (count <= MAX_TEXT_FIELDS) return;
290
- throw new NarsilError(
291
- ErrorCodes.SCHEMA_INVALID_TYPE,
292
- `The schema declares ${count} string and string[] fields, but a schema holds at most ${MAX_TEXT_FIELDS}`,
293
- { textFields: count, maximum: MAX_TEXT_FIELDS }
294
- );
295
- }
296
- function requireCreatableSchema(schema) {
297
- for (const field of schemaFieldsOf(schema)) {
298
- if (field.base !== "vector" || field.dimension <= MAX_VECTOR_DIMENSION) continue;
299
- throw new NarsilError(
300
- ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
301
- `Vector field "${field.path}" has ${field.dimension} dimensions, but a new index takes at most ${MAX_VECTOR_DIMENSION}`,
302
- { field: field.path, dimension: field.dimension, maximum: MAX_VECTOR_DIMENSION }
303
- );
304
- }
305
- }
306
- function requireValidFieldTypes(flatSchema) {
307
- let textFields = 0;
308
- for (const [path, type] of Object.entries(flatSchema)) {
309
- if (typeof type !== "string") {
310
- throw new NarsilError(
311
- ErrorCodes.SCHEMA_INVALID_TYPE,
312
- `Field "${path}" has an invalid type definition: ${String(type)}`,
313
- { field: path, type: String(type) }
314
- );
315
- }
316
- if (isWordIndexedBase(parseFieldType(type, path).base)) textFields += 1;
317
- }
318
- requireTextFieldCount(textFields);
319
- }
320
- function flattenRecursive(schema, prefix, result) {
321
- for (const [field, type] of Object.entries(schema)) {
322
- const path = prefix ? `${prefix}.${field}` : field;
323
- if (isPlainObject(type)) {
324
- flattenRecursive(type, path, result);
325
- } else {
326
- result[path] = type;
327
- }
328
- }
329
- }
330
- var flattenedSchemas = /* @__PURE__ */ new WeakMap();
331
- function flattenSchema(schema) {
332
- const cached = flattenedSchemas.get(schema);
333
- if (cached !== void 0) return cached;
334
- const result = /* @__PURE__ */ Object.create(null);
335
- flattenRecursive(schema, "", result);
336
- flattenedSchemas.set(schema, Object.freeze(result));
337
- return result;
338
- }
339
- var parsedSchemas = /* @__PURE__ */ new WeakMap();
340
- function schemaFieldsOf(schema) {
341
- const cached = parsedSchemas.get(schema);
342
- if (cached !== void 0) return cached;
343
- const fields = [];
344
- for (const [path, type] of Object.entries(flattenSchema(schema))) {
345
- fields.push({ ...parseFieldType(type, path), path });
346
- }
347
- const frozen = Object.freeze(fields);
348
- parsedSchemas.set(schema, frozen);
349
- return frozen;
350
- }
351
- var partialFieldsBySchema = /* @__PURE__ */ new WeakMap();
352
- function partialFieldsOf(schema) {
353
- const cached = partialFieldsBySchema.get(schema);
354
- if (cached !== void 0) return cached;
355
- const paths = [];
356
- for (const field of schemaFieldsOf(schema)) {
357
- if (field.partial) paths.push(field.path);
358
- }
359
- const frozen = Object.freeze(paths.sort(compareCodePoints));
360
- partialFieldsBySchema.set(schema, frozen);
361
- return frozen;
362
- }
363
- function extractVectorFieldsFromSchema(schema) {
364
- const result = /* @__PURE__ */ new Map();
365
- for (const field of schemaFieldsOf(schema)) {
366
- if (field.base === "vector") result.set(field.path, field.dimension);
367
- }
368
- return result;
369
- }
370
-
371
- // src/languages/snowball/base-stemmer.ts
372
- var BaseStemmer = class {
373
- current = "";
374
- c = 0;
375
- limit = 0;
376
- limit_backward = 0;
377
- bra = 0;
378
- ket = 0;
379
- af = 0;
380
- setCurrent(value) {
381
- this.current = value;
382
- this.c = 0;
383
- this.limit = this.current.length;
384
- this.limit_backward = 0;
385
- this.bra = 0;
386
- this.ket = 0;
387
- }
388
- getCurrent() {
389
- return this.current;
390
- }
391
- in_grouping(s, min, max) {
392
- if (this.c >= this.limit) return false;
393
- let ch = this.current.charCodeAt(this.c);
394
- if (ch > max || ch < min) return false;
395
- ch -= min;
396
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return false;
397
- this.c++;
398
- return true;
399
- }
400
- go_in_grouping(s, min, max) {
401
- while (this.c < this.limit) {
402
- let ch = this.current.charCodeAt(this.c);
403
- if (ch > max || ch < min) return true;
404
- ch -= min;
405
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return true;
406
- this.c++;
407
- }
408
- return false;
409
- }
410
- in_grouping_b(s, min, max) {
411
- if (this.c <= this.limit_backward) return false;
412
- let ch = this.current.charCodeAt(this.c - 1);
413
- if (ch > max || ch < min) return false;
414
- ch -= min;
415
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return false;
416
- this.c--;
417
- return true;
418
- }
419
- go_in_grouping_b(s, min, max) {
420
- while (this.c > this.limit_backward) {
421
- let ch = this.current.charCodeAt(this.c - 1);
422
- if (ch > max || ch < min) return true;
423
- ch -= min;
424
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) return true;
425
- this.c--;
426
- }
427
- return false;
428
- }
429
- out_grouping(s, min, max) {
430
- if (this.c >= this.limit) return false;
431
- let ch = this.current.charCodeAt(this.c);
432
- if (ch > max || ch < min) {
433
- this.c++;
434
- return true;
435
- }
436
- ch -= min;
437
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) {
438
- this.c++;
439
- return true;
440
- }
441
- return false;
442
- }
443
- go_out_grouping(s, min, max) {
444
- while (this.c < this.limit) {
445
- let ch = this.current.charCodeAt(this.c);
446
- if (ch <= max && ch >= min) {
447
- ch -= min;
448
- if ((s[ch >>> 3] & 1 << (ch & 7)) !== 0) return true;
449
- }
450
- this.c++;
451
- }
452
- return false;
453
- }
454
- out_grouping_b(s, min, max) {
455
- if (this.c <= this.limit_backward) return false;
456
- let ch = this.current.charCodeAt(this.c - 1);
457
- if (ch > max || ch < min) {
458
- this.c--;
459
- return true;
460
- }
461
- ch -= min;
462
- if ((s[ch >>> 3] & 1 << (ch & 7)) === 0) {
463
- this.c--;
464
- return true;
465
- }
466
- return false;
467
- }
468
- go_out_grouping_b(s, min, max) {
469
- while (this.c > this.limit_backward) {
470
- let ch = this.current.charCodeAt(this.c - 1);
471
- if (ch <= max && ch >= min) {
472
- ch -= min;
473
- if ((s[ch >>> 3] & 1 << (ch & 7)) !== 0) return true;
474
- }
475
- this.c--;
476
- }
477
- return false;
478
- }
479
- eq_s(s) {
480
- if (this.limit - this.c < s.length) return false;
481
- if (!this.current.startsWith(s, this.c)) return false;
482
- this.c += s.length;
483
- return true;
484
- }
485
- eq_s_b(s) {
486
- if (this.c - this.limit_backward < s.length) return false;
487
- if (!this.current.endsWith(s, this.c)) return false;
488
- this.c -= s.length;
489
- return true;
490
- }
491
- find_among(v, call_among_func) {
492
- let i = 0;
493
- let j = v.length;
494
- const c = this.c;
495
- const l = this.limit;
496
- let common_i = 0;
497
- let common_j = 0;
498
- let first_key_inspected = false;
499
- while (true) {
500
- const k = i + (j - i >>> 1);
501
- let diff = 0;
502
- let common = common_i < common_j ? common_i : common_j;
503
- const s = v[k][0];
504
- for (let i2 = common; i2 < s.length; i2++) {
505
- if (c + common === l) {
506
- diff = -1;
507
- break;
508
- }
509
- diff = this.current.charCodeAt(c + common) - s.charCodeAt(i2);
510
- if (diff !== 0) break;
511
- common++;
512
- }
513
- if (diff < 0) {
514
- j = k;
515
- common_j = common;
516
- } else {
517
- i = k;
518
- common_i = common;
519
- }
520
- if (j - i <= 1) {
521
- if (i > 0) break;
522
- if (j === i) break;
523
- if (first_key_inspected) break;
524
- first_key_inspected = true;
525
- }
526
- }
527
- while (true) {
528
- const w = v[i];
529
- const len = w[0].length;
530
- if (common_i >= len) {
531
- this.c = c + len;
532
- const action = w[3];
533
- if (action === void 0) return w[1];
534
- this.af = action;
535
- if (call_among_func?.call(this) === true) {
536
- this.c = c + len;
537
- return w[1];
538
- }
539
- }
540
- const back = w[2];
541
- if (back === void 0 || back === 0) return 0;
542
- i -= back;
543
- }
544
- }
545
- find_among_b(v, call_among_func) {
546
- let i = 0;
547
- let j = v.length;
548
- const c = this.c;
549
- const lb = this.limit_backward;
550
- let common_i = 0;
551
- let common_j = 0;
552
- let first_key_inspected = false;
553
- while (true) {
554
- const k = i + (j - i >> 1);
555
- let diff = 0;
556
- let common = common_i < common_j ? common_i : common_j;
557
- const s = v[k][0];
558
- for (let i2 = s.length - 1 - common; i2 >= 0; i2--) {
559
- if (c - common === lb) {
560
- diff = -1;
561
- break;
562
- }
563
- diff = this.current.charCodeAt(c - 1 - common) - s.charCodeAt(i2);
564
- if (diff !== 0) break;
565
- common++;
566
- }
567
- if (diff < 0) {
568
- j = k;
569
- common_j = common;
570
- } else {
571
- i = k;
572
- common_i = common;
573
- }
574
- if (j - i <= 1) {
575
- if (i > 0) break;
576
- if (j === i) break;
577
- if (first_key_inspected) break;
578
- first_key_inspected = true;
579
- }
580
- }
581
- while (true) {
582
- const w = v[i];
583
- const len = w[0].length;
584
- if (common_i >= len) {
585
- this.c = c - len;
586
- const action = w[3];
587
- if (action === void 0) return w[1];
588
- this.af = action;
589
- if (call_among_func?.call(this) === true) {
590
- this.c = c - len;
591
- return w[1];
592
- }
593
- }
594
- const back = w[2];
595
- if (back === void 0 || back === 0) return 0;
596
- i -= back;
597
- }
598
- }
599
- replace_s(c_bra, c_ket, s) {
600
- const adjustment = s.length - (c_ket - c_bra);
601
- this.current = this.current.slice(0, c_bra) + s + this.current.slice(c_ket);
602
- this.limit += adjustment;
603
- if (this.c >= c_ket) this.c += adjustment;
604
- else if (this.c > c_bra) this.c = c_bra;
605
- return adjustment;
606
- }
607
- slice_from(s) {
608
- this.replace_s(this.bra, this.ket, s);
609
- this.ket = this.bra + s.length;
610
- }
611
- slice_del() {
612
- this.slice_from("");
613
- }
614
- insert(c_bra, c_ket, s) {
615
- const adjustment = this.replace_s(c_bra, c_ket, s);
616
- if (c_bra <= this.bra) this.bra += adjustment;
617
- if (c_bra <= this.ket) this.ket += adjustment;
618
- }
619
- slice_to() {
620
- return this.current.slice(this.bra, this.ket);
621
- }
622
- };
623
-
624
- // src/languages/snowball/english.ts
625
- var a_0 = [
626
- ["arsen", -1],
627
- ["commun", -1],
628
- ["emerg", -1],
629
- ["gener", -1],
630
- ["inter", -1],
631
- ["later", -1],
632
- ["organ", -1],
633
- ["past", -1],
634
- ["univers", -1]
635
- ];
636
- var a_1 = [
637
- ["'", 1],
638
- ["'s'", 1, 1],
639
- ["'s", 1]
640
- ];
641
- var a_2 = [
642
- ["ied", 2],
643
- ["s", 3],
644
- ["ies", 2, 1],
645
- ["sses", 1, 2],
646
- ["ss", -1, 3],
647
- ["us", -1, 4]
648
- ];
649
- var a_3 = [
650
- ["succ", 1],
651
- ["proc", 1],
652
- ["exc", 1]
653
- ];
654
- var a_4 = [
655
- ["even", 2],
656
- ["cann", 2],
657
- ["inn", 2],
658
- ["earr", 2],
659
- ["herr", 2],
660
- ["out", 2],
661
- ["y", 1]
662
- ];
663
- var a_5 = [
664
- ["", -1],
665
- ["ed", 2, 1],
666
- ["eed", 1, 1],
667
- ["ing", 3, 3],
668
- ["edly", 2, 4],
669
- ["eedly", 1, 1],
670
- ["ingly", 2, 6]
671
- ];
672
- var a_6 = [
673
- ["", 3],
674
- ["bb", 2, 1],
675
- ["dd", 2, 2],
676
- ["ff", 2, 3],
677
- ["gg", 2, 4],
678
- ["bl", 1, 5],
679
- ["mm", 2, 6],
680
- ["nn", 2, 7],
681
- ["pp", 2, 8],
682
- ["rr", 2, 9],
683
- ["at", 1, 10],
684
- ["tt", 2, 11],
685
- ["iz", 1, 12]
686
- ];
687
- var a_7 = [
688
- ["anci", 3],
689
- ["enci", 2],
690
- ["ogi", 14],
691
- ["li", 16],
692
- ["bli", 12, 1],
693
- ["abli", 4, 1],
694
- ["alli", 8, 3],
695
- ["fulli", 9, 4],
696
- ["lessli", 15, 5],
697
- ["ousli", 10, 6],
698
- ["entli", 5, 7],
699
- ["aliti", 8],
700
- ["biliti", 12],
701
- ["iviti", 11],
702
- ["tional", 1],
703
- ["ational", 7, 1],
704
- ["alism", 8],
705
- ["ation", 7],
706
- ["ization", 6, 1],
707
- ["izer", 6],
708
- ["ator", 7],
709
- ["iveness", 11],
710
- ["fulness", 9],
711
- ["ousness", 10],
712
- ["ogist", 13]
713
- ];
714
- var a_8 = [
715
- ["icate", 4],
716
- ["ative", 6],
717
- ["alize", 3],
718
- ["iciti", 4],
719
- ["ical", 4],
720
- ["tional", 1],
721
- ["ational", 2, 1],
722
- ["ful", 5],
723
- ["ness", 5]
724
- ];
725
- var a_9 = [
726
- ["ic", 1],
727
- ["ance", 1],
728
- ["ence", 1],
729
- ["able", 1],
730
- ["ible", 1],
731
- ["ate", 1],
732
- ["ive", 1],
733
- ["ize", 1],
734
- ["iti", 1],
735
- ["al", 1],
736
- ["ism", 1],
737
- ["ion", 2],
738
- ["er", 1],
739
- ["ous", 1],
740
- ["ant", 1],
741
- ["ent", 1],
742
- ["ment", 1, 1],
743
- ["ement", 1, 1]
744
- ];
745
- var a_10 = [
746
- ["e", 1],
747
- ["l", 2]
748
- ];
749
- var a_11 = [
750
- ["andes", -1],
751
- ["atlas", -1],
752
- ["bias", -1],
753
- ["cosmos", -1],
754
- ["early", 6],
755
- ["gently", 4],
756
- ["howe", -1],
757
- ["idly", 3],
758
- ["news", -1],
759
- ["only", 7],
760
- ["singly", 8],
761
- ["skies", 2],
762
- ["skis", 1],
763
- ["sky", -1],
764
- ["ugly", 5]
765
- ];
766
- var as_11 = ["ski", "sky", "idl", "gentl", "ugli", "earli", "onli", "singl"];
767
- var g_aeo = [17, 64];
768
- var g_v = [17, 65, 16, 1];
769
- var g_v_WXY = [1, 17, 65, 208, 1];
770
- var g_valid_LI = [55, 141, 2];
771
- var EnglishStemmer = class extends BaseStemmer {
772
- #r_shortv() {
773
- lab0: {
774
- const v_1 = this.limit - this.c;
775
- lab1: {
776
- if (!this.out_grouping_b(g_v_WXY, 89, 121)) break lab1;
777
- if (!this.in_grouping_b(g_v, 97, 121)) break lab1;
778
- if (!this.out_grouping_b(g_v, 97, 121)) break lab1;
779
- break lab0;
780
- }
781
- this.c = this.limit - v_1;
782
- lab2: {
783
- if (!this.out_grouping_b(g_v, 97, 121)) break lab2;
784
- if (!this.in_grouping_b(g_v, 97, 121)) break lab2;
785
- if (
786
- /**@type {boolean}*/
787
- this.c > this.limit_backward
788
- ) break lab2;
789
- break lab0;
790
- }
791
- this.c = this.limit - v_1;
792
- if (!this.eq_s_b("past")) return false;
793
- }
794
- return true;
795
- }
796
- #stem() {
797
- let a;
798
- let B_Y_found;
799
- let I_p2;
800
- let I_p1;
801
- lab0: {
802
- const v_1 = this.c;
803
- lab1: {
804
- this.bra = this.c;
805
- a = this.find_among(a_11);
806
- if (a === 0) break lab1;
807
- this.ket = this.c;
808
- if (
809
- /**@type {boolean}*/
810
- this.c < this.limit
811
- ) break lab1;
812
- if (a > 0) {
813
- this.slice_from(as_11[a - 1]);
814
- }
815
- break lab0;
816
- }
817
- this.c = v_1;
818
- lab2: {
819
- lab3: {
820
- if (this.c + 3 > this.limit) break lab3;
821
- this.c += 3;
822
- break lab2;
823
- }
824
- break lab0;
825
- }
826
- this.c = v_1;
827
- {
828
- B_Y_found = false;
829
- const v_2 = this.c;
830
- lab5: {
831
- this.bra = this.c;
832
- if (!this.eq_s("'")) break lab5;
833
- this.ket = this.c;
834
- this.slice_del();
835
- }
836
- this.c = v_2;
837
- const v_3 = this.c;
838
- lab6: {
839
- this.bra = this.c;
840
- if (!this.eq_s("y")) break lab6;
841
- this.ket = this.c;
842
- this.slice_from("Y");
843
- B_Y_found = true;
844
- }
845
- this.c = v_3;
846
- const v_4 = this.c;
847
- while (true) {
848
- const v_5 = this.c;
849
- lab8: {
850
- while (true) {
851
- const v_6 = this.c;
852
- lab10: {
853
- if (!this.in_grouping(g_v, 97, 121)) break lab10;
854
- this.bra = this.c;
855
- if (!this.eq_s("y")) break lab10;
856
- this.ket = this.c;
857
- this.c = v_6;
858
- break;
859
- }
860
- this.c = v_6;
861
- if (this.c >= this.limit) break lab8;
862
- this.c++;
863
- }
864
- this.slice_from("Y");
865
- B_Y_found = true;
866
- continue;
867
- }
868
- this.c = v_5;
869
- break;
870
- }
871
- this.c = v_4;
872
- }
873
- {
874
- I_p1 = this.limit;
875
- I_p2 = this.limit;
876
- const v_7 = this.c;
877
- lab12: {
878
- lab13: {
879
- const v_8 = this.c;
880
- lab14: {
881
- if (this.find_among(a_0) === 0) break lab14;
882
- break lab13;
883
- }
884
- this.c = v_8;
885
- if (!this.go_out_grouping(g_v, 97, 121)) break lab12;
886
- this.c++;
887
- if (!this.go_in_grouping(g_v, 97, 121)) break lab12;
888
- this.c++;
889
- }
890
- I_p1 = this.c;
891
- if (!this.go_out_grouping(g_v, 97, 121)) break lab12;
892
- this.c++;
893
- if (!this.go_in_grouping(g_v, 97, 121)) break lab12;
894
- this.c++;
895
- I_p2 = this.c;
896
- }
897
- this.c = v_7;
898
- }
899
- this.limit_backward = this.c;
900
- this.c = this.limit;
901
- const v_9 = this.limit - this.c;
902
- lab15: {
903
- const v_10 = this.limit - this.c;
904
- lab16: {
905
- this.ket = this.c;
906
- if (this.find_among_b(a_1) === 0) {
907
- this.c = this.limit - v_10;
908
- break lab16;
909
- }
910
- this.bra = this.c;
911
- this.slice_del();
912
- }
913
- this.ket = this.c;
914
- a = this.find_among_b(a_2);
915
- if (a === 0) break lab15;
916
- this.bra = this.c;
917
- switch (a) {
918
- case 1: {
919
- this.slice_from("ss");
920
- break;
921
- }
922
- case 2: {
923
- lab17: {
924
- const v_11 = this.limit - this.c;
925
- lab18: {
926
- if (this.c - 2 < this.limit_backward) break lab18;
927
- this.c -= 2;
928
- this.slice_from("i");
929
- break lab17;
930
- }
931
- this.c = this.limit - v_11;
932
- this.slice_from("ie");
933
- }
934
- break;
935
- }
936
- case 3: {
937
- if (this.c <= this.limit_backward) break lab15;
938
- this.c--;
939
- if (!this.go_out_grouping_b(g_v, 97, 121)) break lab15;
940
- this.c--;
941
- this.slice_del();
942
- break;
943
- }
944
- }
945
- }
946
- this.c = this.limit - v_9;
947
- const v_12 = this.limit - this.c;
948
- lab19: {
949
- this.ket = this.c;
950
- a = this.find_among_b(a_5);
951
- this.bra = this.c;
952
- lab20: {
953
- const v_13 = this.limit - this.c;
954
- lab21: {
955
- switch (a) {
956
- case 1: {
957
- const v_14 = this.limit - this.c;
958
- lab22: {
959
- if (
960
- /**@type {boolean}*/
961
- I_p1 > this.c
962
- ) break lab22;
963
- lab23: {
964
- const v_15 = this.limit - this.c;
965
- lab24: {
966
- if (this.find_among_b(a_3) === 0) break lab24;
967
- if (
968
- /**@type {boolean}*/
969
- this.c > this.limit_backward
970
- ) break lab24;
971
- break lab23;
972
- }
973
- this.c = this.limit - v_15;
974
- this.slice_from("ee");
975
- }
976
- }
977
- this.c = this.limit - v_14;
978
- break;
979
- }
980
- case 2: {
981
- break lab21;
982
- }
983
- case 3: {
984
- a = this.find_among_b(a_4);
985
- if (a === 0) break lab21;
986
- switch (a) {
987
- case 1: {
988
- const v_16 = this.limit - this.c;
989
- if (!this.out_grouping_b(g_v, 97, 121)) break lab21;
990
- if (
991
- /**@type {boolean}*/
992
- this.c > this.limit_backward
993
- ) break lab21;
994
- this.c = this.limit - v_16;
995
- this.bra = this.c;
996
- this.slice_from("ie");
997
- break;
998
- }
999
- case 2: {
1000
- if (
1001
- /**@type {boolean}*/
1002
- this.c > this.limit_backward
1003
- ) break lab21;
1004
- break;
1005
- }
1006
- }
1007
- break;
1008
- }
1009
- }
1010
- break lab20;
1011
- }
1012
- this.c = this.limit - v_13;
1013
- const v_17 = this.limit - this.c;
1014
- if (!this.go_out_grouping_b(g_v, 97, 121)) break lab19;
1015
- this.c--;
1016
- this.c = this.limit - v_17;
1017
- this.slice_del();
1018
- this.ket = this.c;
1019
- this.bra = this.c;
1020
- const v_18 = this.limit - this.c;
1021
- a = this.find_among_b(a_6);
1022
- switch (a) {
1023
- case 1: {
1024
- this.slice_from("e");
1025
- break lab19;
1026
- }
1027
- case 2: {
1028
- {
1029
- const v_19 = this.limit - this.c;
1030
- lab25: {
1031
- if (!this.in_grouping_b(g_aeo, 97, 111)) break lab25;
1032
- if (
1033
- /**@type {boolean}*/
1034
- this.c > this.limit_backward
1035
- ) break lab25;
1036
- break lab19;
1037
- }
1038
- this.c = this.limit - v_19;
1039
- }
1040
- break;
1041
- }
1042
- case 3: {
1043
- if (
1044
- /**@type {boolean}*/
1045
- this.c !== I_p1
1046
- ) break lab19;
1047
- const v_20 = this.limit - this.c;
1048
- if (!this.#r_shortv()) break lab19;
1049
- this.c = this.limit - v_20;
1050
- this.slice_from("e");
1051
- break lab19;
1052
- }
1053
- }
1054
- this.c = this.limit - v_18;
1055
- this.ket = this.c;
1056
- if (this.c <= this.limit_backward) break lab19;
1057
- this.c--;
1058
- this.bra = this.c;
1059
- this.slice_del();
1060
- }
1061
- }
1062
- this.c = this.limit - v_12;
1063
- const v_21 = this.limit - this.c;
1064
- lab26: {
1065
- this.ket = this.c;
1066
- lab27: {
1067
- lab28: {
1068
- if (!this.eq_s_b("y")) break lab28;
1069
- break lab27;
1070
- }
1071
- if (!this.eq_s_b("Y")) break lab26;
1072
- }
1073
- this.bra = this.c;
1074
- if (!this.out_grouping_b(g_v, 97, 121)) break lab26;
1075
- if (
1076
- /**@type {boolean}*/
1077
- this.c <= this.limit_backward
1078
- ) break lab26;
1079
- this.slice_from("i");
1080
- }
1081
- this.c = this.limit - v_21;
1082
- const v_22 = this.limit - this.c;
1083
- lab29: {
1084
- this.ket = this.c;
1085
- a = this.find_among_b(a_7);
1086
- if (a === 0) break lab29;
1087
- this.bra = this.c;
1088
- if (
1089
- /**@type {boolean}*/
1090
- I_p1 > this.c
1091
- ) break lab29;
1092
- switch (a) {
1093
- case 1: {
1094
- this.slice_from("tion");
1095
- break;
1096
- }
1097
- case 2: {
1098
- this.slice_from("ence");
1099
- break;
1100
- }
1101
- case 3: {
1102
- this.slice_from("ance");
1103
- break;
1104
- }
1105
- case 4: {
1106
- this.slice_from("able");
1107
- break;
1108
- }
1109
- case 5: {
1110
- this.slice_from("ent");
1111
- break;
1112
- }
1113
- case 6: {
1114
- this.slice_from("ize");
1115
- break;
1116
- }
1117
- case 7: {
1118
- this.slice_from("ate");
1119
- break;
1120
- }
1121
- case 8: {
1122
- this.slice_from("al");
1123
- break;
1124
- }
1125
- case 9: {
1126
- this.slice_from("ful");
1127
- break;
1128
- }
1129
- case 10: {
1130
- this.slice_from("ous");
1131
- break;
1132
- }
1133
- case 11: {
1134
- this.slice_from("ive");
1135
- break;
1136
- }
1137
- case 12: {
1138
- this.slice_from("ble");
1139
- break;
1140
- }
1141
- case 13: {
1142
- this.slice_from("og");
1143
- break;
1144
- }
1145
- case 14: {
1146
- if (!this.eq_s_b("l")) break lab29;
1147
- this.slice_from("og");
1148
- break;
1149
- }
1150
- case 15: {
1151
- this.slice_from("less");
1152
- break;
1153
- }
1154
- case 16: {
1155
- if (!this.in_grouping_b(g_valid_LI, 99, 116)) break lab29;
1156
- this.slice_del();
1157
- break;
1158
- }
1159
- }
1160
- }
1161
- this.c = this.limit - v_22;
1162
- const v_23 = this.limit - this.c;
1163
- lab30: {
1164
- this.ket = this.c;
1165
- a = this.find_among_b(a_8);
1166
- if (a === 0) break lab30;
1167
- this.bra = this.c;
1168
- if (
1169
- /**@type {boolean}*/
1170
- I_p1 > this.c
1171
- ) break lab30;
1172
- switch (a) {
1173
- case 1: {
1174
- this.slice_from("tion");
1175
- break;
1176
- }
1177
- case 2: {
1178
- this.slice_from("ate");
1179
- break;
1180
- }
1181
- case 3: {
1182
- this.slice_from("al");
1183
- break;
1184
- }
1185
- case 4: {
1186
- this.slice_from("ic");
1187
- break;
1188
- }
1189
- case 5: {
1190
- this.slice_del();
1191
- break;
1192
- }
1193
- case 6: {
1194
- if (
1195
- /**@type {boolean}*/
1196
- I_p2 > this.c
1197
- ) break lab30;
1198
- this.slice_del();
1199
- break;
1200
- }
1201
- }
1202
- }
1203
- this.c = this.limit - v_23;
1204
- const v_24 = this.limit - this.c;
1205
- lab31: {
1206
- this.ket = this.c;
1207
- a = this.find_among_b(a_9);
1208
- if (a === 0) break lab31;
1209
- this.bra = this.c;
1210
- if (
1211
- /**@type {boolean}*/
1212
- I_p2 > this.c
1213
- ) break lab31;
1214
- switch (a) {
1215
- case 1: {
1216
- this.slice_del();
1217
- break;
1218
- }
1219
- case 2: {
1220
- lab32: {
1221
- lab33: {
1222
- if (!this.eq_s_b("s")) break lab33;
1223
- break lab32;
1224
- }
1225
- if (!this.eq_s_b("t")) break lab31;
1226
- }
1227
- this.slice_del();
1228
- break;
1229
- }
1230
- }
1231
- }
1232
- this.c = this.limit - v_24;
1233
- const v_25 = this.limit - this.c;
1234
- lab34: {
1235
- this.ket = this.c;
1236
- a = this.find_among_b(a_10);
1237
- if (a === 0) break lab34;
1238
- this.bra = this.c;
1239
- switch (a) {
1240
- case 1: {
1241
- lab35: {
1242
- lab36: {
1243
- if (
1244
- /**@type {boolean}*/
1245
- I_p2 > this.c
1246
- ) break lab36;
1247
- break lab35;
1248
- }
1249
- if (
1250
- /**@type {boolean}*/
1251
- I_p1 > this.c
1252
- ) break lab34;
1253
- {
1254
- const v_26 = this.limit - this.c;
1255
- lab37: {
1256
- if (!this.#r_shortv()) break lab37;
1257
- break lab34;
1258
- }
1259
- this.c = this.limit - v_26;
1260
- }
1261
- }
1262
- this.slice_del();
1263
- break;
1264
- }
1265
- case 2: {
1266
- if (
1267
- /**@type {boolean}*/
1268
- I_p2 > this.c
1269
- ) break lab34;
1270
- if (!this.eq_s_b("l")) break lab34;
1271
- this.slice_del();
1272
- break;
1273
- }
1274
- }
1275
- }
1276
- this.c = this.limit - v_25;
1277
- this.c = this.limit_backward;
1278
- const v_27 = this.c;
1279
- lab38: {
1280
- if (!B_Y_found) break lab38;
1281
- while (true) {
1282
- const v_28 = this.c;
1283
- lab39: {
1284
- while (true) {
1285
- const v_29 = this.c;
1286
- lab41: {
1287
- this.bra = this.c;
1288
- if (!this.eq_s("Y")) break lab41;
1289
- this.ket = this.c;
1290
- this.c = v_29;
1291
- break;
1292
- }
1293
- this.c = v_29;
1294
- if (this.c >= this.limit) break lab39;
1295
- this.c++;
1296
- }
1297
- this.slice_from("y");
1298
- continue;
1299
- }
1300
- this.c = v_28;
1301
- break;
1302
- }
1303
- }
1304
- this.c = v_27;
1305
- }
1306
- return true;
1307
- }
1308
- stem(input) {
1309
- this.setCurrent(input);
1310
- this.#stem();
1311
- return this.getCurrent();
1312
- }
1313
- };
1314
- var shared = new EnglishStemmer();
1315
- function stem(token) {
1316
- return shared.stem(token);
1317
- }
1318
-
1319
- // src/languages/english.ts
1320
- var stopWords = /* @__PURE__ */ new Set([
1321
- "a",
1322
- "an",
1323
- "the",
1324
- "i",
1325
- "me",
1326
- "my",
1327
- "myself",
1328
- "we",
1329
- "us",
1330
- "our",
1331
- "ours",
1332
- "ourselves",
1333
- "you",
1334
- "your",
1335
- "yours",
1336
- "yourself",
1337
- "yourselves",
1338
- "he",
1339
- "him",
1340
- "his",
1341
- "himself",
1342
- "she",
1343
- "her",
1344
- "hers",
1345
- "herself",
1346
- "it",
1347
- "its",
1348
- "itself",
1349
- "they",
1350
- "them",
1351
- "their",
1352
- "theirs",
1353
- "themselves",
1354
- "what",
1355
- "which",
1356
- "who",
1357
- "whom",
1358
- "this",
1359
- "that",
1360
- "these",
1361
- "those",
1362
- "am",
1363
- "is",
1364
- "are",
1365
- "was",
1366
- "were",
1367
- "be",
1368
- "been",
1369
- "being",
1370
- "have",
1371
- "has",
1372
- "had",
1373
- "having",
1374
- "do",
1375
- "does",
1376
- "did",
1377
- "doing",
1378
- "will",
1379
- "would",
1380
- "shall",
1381
- "should",
1382
- "can",
1383
- "could",
1384
- "may",
1385
- "might",
1386
- "must",
1387
- "ought",
1388
- "i'm",
1389
- "you're",
1390
- "we're",
1391
- "they're",
1392
- "i've",
1393
- "you've",
1394
- "we've",
1395
- "they've",
1396
- "i'd",
1397
- "you'd",
1398
- "he'd",
1399
- "she'd",
1400
- "we'd",
1401
- "they'd",
1402
- "i'll",
1403
- "you'll",
1404
- "he'll",
1405
- "she'll",
1406
- "we'll",
1407
- "they'll",
1408
- "isn't",
1409
- "aren't",
1410
- "wasn't",
1411
- "weren't",
1412
- "hasn't",
1413
- "haven't",
1414
- "hadn't",
1415
- "doesn't",
1416
- "don't",
1417
- "didn't",
1418
- "won't",
1419
- "wouldn't",
1420
- "shan't",
1421
- "shouldn't",
1422
- "can't",
1423
- "cannot",
1424
- "couldn't",
1425
- "mustn't",
1426
- "and",
1427
- "but",
1428
- "if",
1429
- "or",
1430
- "because",
1431
- "as",
1432
- "until",
1433
- "while",
1434
- "of",
1435
- "at",
1436
- "by",
1437
- "for",
1438
- "with",
1439
- "about",
1440
- "against",
1441
- "between",
1442
- "into",
1443
- "through",
1444
- "during",
1445
- "before",
1446
- "after",
1447
- "above",
1448
- "below",
1449
- "to",
1450
- "from",
1451
- "up",
1452
- "down",
1453
- "in",
1454
- "out",
1455
- "on",
1456
- "off",
1457
- "over",
1458
- "under",
1459
- "again",
1460
- "further",
1461
- "then",
1462
- "once",
1463
- "here",
1464
- "there",
1465
- "when",
1466
- "where",
1467
- "why",
1468
- "how",
1469
- "all",
1470
- "any",
1471
- "both",
1472
- "each",
1473
- "few",
1474
- "more",
1475
- "most",
1476
- "other",
1477
- "some",
1478
- "such",
1479
- "no",
1480
- "nor",
1481
- "not",
1482
- "only",
1483
- "own",
1484
- "same",
1485
- "so",
1486
- "than",
1487
- "too",
1488
- "very"
1489
- ]);
1490
- var english = {
1491
- name: "english",
1492
- revision: "ebae3448ae674b59",
1493
- stemmer: stem,
1494
- stopWords,
1495
- tokenizer: {
1496
- splitPattern: /[^\p{L}\p{M}\p{N}_']+/u,
1497
- stripPossessive: true
1498
- }
1499
- };
1500
-
1501
- // src/languages/registry.ts
1502
- var languages = /* @__PURE__ */ new Map();
1503
- languages.set("english", english);
1504
- function registerLanguage(module) {
1505
- languages.set(module.name, module);
1506
- }
1507
- function getLanguage(name) {
1508
- const lang = languages.get(name);
1509
- if (!lang) {
1510
- throw new NarsilError(ErrorCodes.LANGUAGE_NOT_SUPPORTED, `Language "${name}" is not registered`, { language: name });
1511
- }
1512
- return lang;
1513
- }
1514
- function hasLanguage(name) {
1515
- return languages.has(name);
1516
- }
1517
-
1518
- // src/geo/coordinates.ts
1519
- function isLatitude(value) {
1520
- return value >= -MAX_LATITUDE_DEGREES && value <= MAX_LATITUDE_DEGREES;
1521
- }
1522
- function isLongitude(value) {
1523
- return value >= -MAX_LONGITUDE_DEGREES && value <= MAX_LONGITUDE_DEGREES;
1524
- }
1525
-
1526
- // src/schema/validator/field-values.ts
1527
- function validateGeopoint(path, value) {
1528
- if (!isPlainObject(value)) {
1529
- throw new NarsilError(
1530
- ErrorCodes.SCHEMA_INVALID_GEOPOINT,
1531
- `Field "${path}" expected a geopoint object with lat and lon`,
1532
- {
1533
- field: path,
1534
- received: Array.isArray(value) ? "array" : typeof value
1535
- }
1536
- );
1537
- }
1538
- if (typeof value.lat !== "number" || typeof value.lon !== "number" || Number.isNaN(value.lat) || Number.isNaN(value.lon)) {
1539
- throw new NarsilError(ErrorCodes.SCHEMA_INVALID_GEOPOINT, `Field "${path}" geopoint requires numeric lat and lon`, {
1540
- field: path,
1541
- lat: Number.isNaN(value.lat) ? "NaN" : typeof value.lat,
1542
- lon: Number.isNaN(value.lon) ? "NaN" : typeof value.lon
1543
- });
1544
- }
1545
- if (!isLatitude(value.lat)) {
1546
- throw new NarsilError(
1547
- ErrorCodes.SCHEMA_INVALID_GEOPOINT,
1548
- `Field "${path}" geopoint lat must be between -90 and 90`,
1549
- {
1550
- field: path,
1551
- lat: value.lat
1552
- }
1553
- );
1554
- }
1555
- if (!isLongitude(value.lon)) {
1556
- throw new NarsilError(
1557
- ErrorCodes.SCHEMA_INVALID_GEOPOINT,
1558
- `Field "${path}" geopoint lon must be between -180 and 180`,
1559
- {
1560
- field: path,
1561
- lon: value.lon
1562
- }
1563
- );
1564
- }
1565
- }
1566
- function validateVector(path, value, expectedDimension) {
1567
- const isArray = Array.isArray(value);
1568
- const isFloat32 = value instanceof Float32Array;
1569
- if (!isArray && !isFloat32) {
1570
- throw new NarsilError(
1571
- ErrorCodes.DOC_VALIDATION_FAILED,
1572
- `Field "${path}" expected a vector (Array or Float32Array)`,
1573
- { field: path, received: typeof value }
1574
- );
1575
- }
1576
- const arr = value;
1577
- if (arr.length !== expectedDimension) {
1578
- throw new NarsilError(
1579
- ErrorCodes.DOC_VALIDATION_FAILED,
1580
- `Field "${path}" expected vector of dimension ${expectedDimension}, got ${arr.length}`,
1581
- { field: path, expected: expectedDimension, received: arr.length }
1582
- );
1583
- }
1584
- for (let i = 0; i < arr.length; i++) {
1585
- if (typeof arr[i] !== "number" || !Number.isFinite(arr[i])) {
1586
- throw new NarsilError(
1587
- ErrorCodes.DOC_VALIDATION_FAILED,
1588
- `Field "${path}" vector element at index ${i} is not a valid number`,
1589
- { field: path, index: i, value: arr[i] }
1590
- );
1591
- }
1592
- }
1593
- }
1594
- function validateTypedArray(path, value, elementType) {
1595
- if (!Array.isArray(value)) {
1596
- throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path}" expected an array`, {
1597
- field: path,
1598
- received: typeof value
1599
- });
1600
- }
1601
- for (let i = 0; i < value.length; i++) {
1602
- const el = value[i];
1603
- if (typeof el !== elementType) {
1604
- throw new NarsilError(
1605
- ErrorCodes.DOC_VALIDATION_FAILED,
1606
- `Field "${path}" array element at index ${i} expected ${elementType}, got ${typeof el}`,
1607
- { field: path, index: i, expected: elementType, received: typeof el }
1608
- );
1609
- }
1610
- if (elementType === "number" && !Number.isFinite(el)) {
1611
- throw new NarsilError(
1612
- ErrorCodes.DOC_VALIDATION_FAILED,
1613
- `Field "${path}" array element at index ${i} is ${String(el)}, while a number field holds finite numbers alone`,
1614
- { field: path, index: i }
1615
- );
1616
- }
1617
- }
1618
- }
1619
- function validatePatternValue(path, value, patternValueLimit, index) {
1620
- if (!exceedsCodePoints(value, patternValueLimit)) return;
1621
- const subject = index === void 0 ? `The value of field "${path}"` : `Element ${index} of field "${path}"`;
1622
- throw new NarsilError(
1623
- ErrorCodes.DOC_VALIDATION_FAILED,
1624
- `${subject} is longer than ${patternValueLimit} code points, which is the pattern value limit of this index`,
1625
- { field: path, limit: patternValueLimit, ...index === void 0 ? {} : { index } }
1626
- );
1627
- }
1628
- function validateFieldValue(path, value, type, patternValueLimit) {
1629
- switch (type.base) {
1630
- case "string":
1631
- case "verbatim":
1632
- if (typeof value !== "string") {
1633
- throw new NarsilError(
1634
- ErrorCodes.DOC_VALIDATION_FAILED,
1635
- `Field "${path}" expected string, got ${typeof value}`,
1636
- {
1637
- field: path,
1638
- expected: "string",
1639
- received: typeof value
1640
- }
1641
- );
1642
- }
1643
- if (type.pattern) validatePatternValue(path, value, patternValueLimit);
1644
- return;
1645
- case "number":
1646
- if (typeof value !== "number" || !Number.isFinite(value)) {
1647
- throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path}" expected a finite number`, {
1648
- field: path,
1649
- expected: "number",
1650
- received: typeof value === "number" ? String(value) : typeof value
1651
- });
1652
- }
1653
- return;
1654
- case "boolean":
1655
- if (typeof value !== "boolean") {
1656
- throw new NarsilError(
1657
- ErrorCodes.DOC_VALIDATION_FAILED,
1658
- `Field "${path}" expected boolean, got ${typeof value}`,
1659
- {
1660
- field: path,
1661
- expected: "boolean",
1662
- received: typeof value
1663
- }
1664
- );
1665
- }
1666
- return;
1667
- case "enum":
1668
- if (typeof value !== "string") {
1669
- throw new NarsilError(
1670
- ErrorCodes.DOC_VALIDATION_FAILED,
1671
- `Field "${path}" expected enum (string), got ${typeof value}`,
1672
- {
1673
- field: path,
1674
- expected: "enum",
1675
- received: typeof value
1676
- }
1677
- );
1678
- }
1679
- return;
1680
- case "geopoint":
1681
- validateGeopoint(path, value);
1682
- return;
1683
- case "string[]":
1684
- case "verbatim[]":
1685
- validateTypedArray(path, value, "string");
1686
- if (type.pattern) {
1687
- const elements = value;
1688
- for (let i = 0; i < elements.length; i++) validatePatternValue(path, elements[i], patternValueLimit, i);
1689
- }
1690
- return;
1691
- case "number[]":
1692
- validateTypedArray(path, value, "number");
1693
- return;
1694
- case "boolean[]":
1695
- validateTypedArray(path, value, "boolean");
1696
- return;
1697
- case "enum[]":
1698
- validateTypedArray(path, value, "string");
1699
- return;
1700
- case "vector":
1701
- validateVector(path, value, type.dimension);
1702
- return;
1703
- }
1704
- }
1705
-
1706
- // src/schema/validator/storable.ts
1707
- var RESERVED_OBJECT_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
1708
- var UNPAIRED_SURROGATE_REASON = "holds an unpaired surrogate, the half of a character such as an emoji whose other half is missing, so the engine cannot store it as UTF-8";
1709
- function reject(path, reason) {
1710
- throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path === "" ? "(document)" : path}" ${reason}`, {
1711
- field: path
1712
- });
1713
- }
1714
- function isPlainObject2(value) {
1715
- const proto = Object.getPrototypeOf(value);
1716
- return proto === Object.prototype || proto === null;
1717
- }
1718
- function walkStorable(value, path, depth, ancestors, skip) {
1719
- if (value === null || value === void 0) return;
1720
- const kind = typeof value;
1721
- if (kind === "string") {
1722
- if (holdsUnpairedSurrogate(value)) reject(path, UNPAIRED_SURROGATE_REASON);
1723
- return;
1724
- }
1725
- if (kind === "boolean" || kind === "number") return;
1726
- if (kind === "bigint" || kind === "symbol" || kind === "function") {
1727
- reject(path, `holds a ${kind}, which cannot be stored or recovered`);
1728
- }
1729
- const container = value;
1730
- if (container instanceof Date) {
1731
- if (Number.isNaN(container.getTime())) reject(path, "holds an invalid date, which the engine cannot store");
1732
- return;
1733
- }
1734
- if (container instanceof Uint8Array) return;
1735
- const isArray = Array.isArray(container);
1736
- if (!isArray && !isPlainObject2(container)) {
1737
- reject(
1738
- path,
1739
- "holds a value that does not survive storage; use plain objects, arrays, strings, numbers, booleans, dates, or Uint8Array bytes"
1740
- );
1741
- }
1742
- if (depth >= MAX_DOCUMENT_NESTING_DEPTH) {
1743
- reject(path, `nests deeper than ${MAX_DOCUMENT_NESTING_DEPTH} levels`);
1744
- }
1745
- if (ancestors.has(container)) {
1746
- reject(path, "refers back to one of its own ancestors");
1747
- }
1748
- ancestors.add(container);
1749
- if (isArray) {
1750
- const items = container;
1751
- for (let i = 0; i < items.length; i++) {
1752
- walkStorable(items[i], `${path}[${i}]`, depth + 1, ancestors, skip);
1753
- }
1754
- } else {
1755
- const record = container;
1756
- for (const key of Object.keys(record)) {
1757
- const keyPath = path === "" ? key : `${path}.${key}`;
1758
- if (RESERVED_OBJECT_KEYS.has(key)) {
1759
- reject(keyPath, "uses a reserved object key");
1760
- }
1761
- if (holdsUnpairedSurrogate(key)) reject(keyPath, `has a name that ${UNPAIRED_SURROGATE_REASON}`);
1762
- if (skip.has(keyPath)) continue;
1763
- walkStorable(record[key], keyPath, depth + 1, ancestors, skip);
1764
- }
1765
- }
1766
- ancestors.delete(container);
1767
- }
1768
- function assertStorableDocument(document, skipFieldPaths) {
1769
- walkStorable(document, "", 0, /* @__PURE__ */ new Set(), skipFieldPaths ?? /* @__PURE__ */ new Set());
1770
- }
1771
-
1772
- // src/schema/validator/document.ts
1773
- var vectorPathCache = /* @__PURE__ */ new WeakMap();
1774
- function vectorFieldPaths(schema) {
1775
- let paths = vectorPathCache.get(schema);
1776
- if (paths !== void 0) return paths;
1777
- paths = /* @__PURE__ */ new Set();
1778
- const collect = (level, prefix) => {
1779
- for (const [field, type] of Object.entries(level)) {
1780
- const path = prefix === "" ? field : `${prefix}.${field}`;
1781
- if (typeof type === "string" && VECTOR_PATTERN.test(type)) {
1782
- paths?.add(path);
1783
- } else if (isPlainObject(type)) {
1784
- collect(type, path);
1785
- }
1786
- }
1787
- };
1788
- collect(schema, "");
1789
- vectorPathCache.set(schema, paths);
1790
- return paths;
1791
- }
1792
- var parsedLevelCache = /* @__PURE__ */ new WeakMap();
1793
- function parsedLevel(schema, prefix) {
1794
- let entries = parsedLevelCache.get(schema);
1795
- if (entries !== void 0) return entries;
1796
- entries = Object.entries(schema).map(([field, type]) => {
1797
- if (isPlainObject(type)) return { field, nested: type, type: null };
1798
- const path = prefix ? `${prefix}.${field}` : field;
1799
- return { field, nested: null, type: parseFieldType(type, path) };
1800
- });
1801
- parsedLevelCache.set(schema, entries);
1802
- return entries;
1803
- }
1804
- function validateDocumentFields(doc, schema, prefix, patternValueLimit) {
1805
- for (const { field, nested, type } of parsedLevel(schema, prefix)) {
1806
- const value = doc[field];
1807
- if (value === void 0 || value === null) continue;
1808
- const path = prefix ? `${prefix}.${field}` : field;
1809
- if (nested !== null) {
1810
- if (!isPlainObject(value)) {
1811
- throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path}" expected an object`, {
1812
- field: path,
1813
- received: Array.isArray(value) ? "array" : typeof value
1814
- });
1815
- }
1816
- validateDocumentFields(value, nested, path, patternValueLimit);
1817
- continue;
1818
- }
1819
- if (type !== null) validateFieldValue(path, value, type, patternValueLimit);
1820
- }
1821
- }
1822
- function validateDocument(document, schema, patternValueLimit = DEFAULT_PATTERN_VALUE_LIMIT) {
1823
- if (!isPlainObject(document)) {
1824
- throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, "Document must be a plain object", {
1825
- received: typeof document
1826
- });
1827
- }
1828
- requireIdFieldKey(document);
1829
- assertStorableDocument(document, vectorFieldPaths(schema));
1830
- validateDocumentFields(document, schema, "", patternValueLimit);
1831
- }
1832
- function requireIdFieldKey(document) {
1833
- if (!Object.hasOwn(document, "id")) return;
1834
- const id = document.id;
1835
- if (typeof id === "string" && id.length > 0) return;
1836
- throw new NarsilError(
1837
- ErrorCodes.DOC_VALIDATION_FAILED,
1838
- `Field "id" holds ${typeof id === "string" ? "an empty string" : id === null ? "null" : `a ${typeof id}`}, while the engine stores a document under its id field, so that field must hold a non-empty string`,
1839
- { field: "id", received: id === null ? "null" : typeof id }
1840
- );
1841
- }
1842
- function collectExtraFields(doc, schema, prefix, extras) {
1843
- for (const key of Object.keys(doc)) {
1844
- if (key === "id") continue;
1845
- const path = prefix ? `${prefix}.${key}` : key;
1846
- if (!Object.hasOwn(schema, key)) {
1847
- extras.push(path);
1848
- continue;
1849
- }
1850
- const schemaType = schema[key];
1851
- if (isPlainObject(schemaType) && isPlainObject(doc[key])) {
1852
- collectExtraFields(doc[key], schemaType, path, extras);
1853
- }
1854
- }
1855
- }
1856
- function validateDocumentStrict(document, schema) {
1857
- const extras = [];
1858
- collectExtraFields(document, schema, "", extras);
1859
- if (extras.length > 0) {
1860
- throw new NarsilError(
1861
- ErrorCodes.DOC_VALIDATION_FAILED,
1862
- `Document contains fields not defined in schema: ${extras.join(", ")}`,
1863
- { extraFields: extras }
1864
- );
1865
- }
1866
- }
1867
- function resolveNestedValue(document, path) {
1868
- if (!path.includes(".")) return document[path];
1869
- const segments = path.split(".");
1870
- let current = document;
1871
- for (const segment of segments) {
1872
- if (current === null || current === void 0 || typeof current !== "object") return void 0;
1873
- current = current[segment];
1874
- }
1875
- return current;
1876
- }
1877
- function validateRequiredFields(document, required) {
1878
- if (required.length === 0) return;
1879
- for (const field of required) {
1880
- const value = resolveNestedValue(document, field);
1881
- if (value === void 0 || value === null) {
1882
- throw new NarsilError(ErrorCodes.DOC_MISSING_REQUIRED_FIELD, `Document is missing required field "${field}"`, {
1883
- field
1884
- });
1885
- }
1886
- }
1887
- }
1888
- var INTEGER_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH };
1889
- var FLOAT_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH, forceIntegerToFloat: true };
1890
- var integerEncoder = new Encoder(INTEGER_ENCODING);
1891
- var floatEncoder = new Encoder(FLOAT_ENCODING);
1892
- function encodeExactly(document, forceIntegerToFloat) {
1893
- const bytes = (forceIntegerToFloat ? floatEncoder : integerEncoder).encode(document);
1894
- if (bytes.byteLength > DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES) {
1895
- if (forceIntegerToFloat) floatEncoder = new Encoder(FLOAT_ENCODING);
1896
- else integerEncoder = new Encoder(INTEGER_ENCODING);
1897
- }
1898
- return bytes;
1899
- }
1900
- function holdsNegativeZero(value, depth) {
1901
- if (typeof value === "number") return Object.is(value, -0);
1902
- if (value === null || typeof value !== "object" || ArrayBuffer.isView(value) || depth > MAX_DOCUMENT_ENCODING_DEPTH) {
1903
- return false;
1904
- }
1905
- for (const child of Array.isArray(value) ? value : Object.values(value)) {
1906
- if (holdsNegativeZero(child, depth + 1)) return true;
1907
- }
1908
- return false;
1909
- }
1910
- function encodeDocument(document) {
1911
- try {
1912
- return encodeExactly(document, holdsNegativeZero(document, 1));
1913
- } catch (error) {
1914
- throw new NarsilError(
1915
- ErrorCodes.DOC_VALIDATION_FAILED,
1916
- `The document cannot be encoded as MessagePack: ${error instanceof Error ? error.message : String(error)}`
1917
- );
1918
- }
1919
- }
1920
-
1921
- // src/schema/validator/document-size.ts
1922
- var LARGEST_HEADER_BYTES = 5;
1923
- var LARGEST_NUMBER_BYTES = 9;
1924
- var LARGEST_TIMESTAMP_BYTES = 15;
1925
- var LARGEST_UTF8_BYTES_PER_UNIT = 3;
1926
- function upperBoundBytes(value, budget, depth) {
1927
- if (value === null || value === void 0 || typeof value === "boolean") return 1;
1928
- if (typeof value === "number") return LARGEST_NUMBER_BYTES;
1929
- if (typeof value === "string") return LARGEST_HEADER_BYTES + value.length * LARGEST_UTF8_BYTES_PER_UNIT;
1930
- if (value instanceof Date) return LARGEST_TIMESTAMP_BYTES;
1931
- if (ArrayBuffer.isView(value)) return LARGEST_HEADER_BYTES + value.byteLength;
1932
- if (typeof value !== "object" || depth > MAX_DOCUMENT_NESTING_DEPTH) return LARGEST_NUMBER_BYTES;
1933
- let total = LARGEST_HEADER_BYTES;
1934
- if (Array.isArray(value)) {
1935
- for (const item of value) {
1936
- total += upperBoundBytes(item, budget - total, depth + 1);
1937
- if (total > budget) return total;
1938
- }
1939
- return total;
1940
- }
1941
- const record = value;
1942
- for (const key of Object.keys(record)) {
1943
- total += LARGEST_HEADER_BYTES + key.length * LARGEST_UTF8_BYTES_PER_UNIT;
1944
- total += upperBoundBytes(record[key], budget - total, depth + 1);
1945
- if (total > budget) return total;
1946
- }
1947
- return total;
1948
- }
1949
- function messagePackUpperBoundBytes(value) {
1950
- return upperBoundBytes(value, Number.POSITIVE_INFINITY, 0);
1951
- }
1952
- function encodedBytesOf(document) {
1953
- try {
1954
- return encodeDocument(document).byteLength;
1955
- } catch {
1956
- return null;
1957
- }
1958
- }
1959
- function requireDocumentWithinSizeLimit(document) {
1960
- if (upperBoundBytes(document, MAX_DOCUMENT_BYTES, 0) <= MAX_DOCUMENT_BYTES) return;
1961
- const encodedBytes = encodedBytesOf(document);
1962
- if (encodedBytes === null || encodedBytes <= MAX_DOCUMENT_BYTES) return;
1963
- throw new NarsilError(
1964
- ErrorCodes.DOC_VALIDATION_FAILED,
1965
- `The document takes ${encodedBytes} bytes as MessagePack, vector values included, but a document may take at most ${MAX_DOCUMENT_BYTES}`,
1966
- { bytes: encodedBytes, maximum: MAX_DOCUMENT_BYTES }
1967
- );
1968
- }
1969
-
1970
- // src/schema/validator/vector-promotion.ts
1971
- var QUANTIZATION_MODES = /* @__PURE__ */ new Set(["osq8", "osq4", "osq2", "osq1", "none"]);
1972
- var STORAGE_MODES = /* @__PURE__ */ new Set(["memory", "disk"]);
1973
- function fail(message, details) {
1974
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, message, details);
1975
- }
1976
- function isPositiveInteger(value) {
1977
- return Number.isInteger(value) && value >= 1;
1978
- }
1979
- function isQuantizationMode(value) {
1980
- return typeof value === "string" && QUANTIZATION_MODES.has(value);
1981
- }
1982
- function isStorageMode(value) {
1983
- return typeof value === "string" && STORAGE_MODES.has(value);
1984
- }
1985
- function validateVectorStorage(config, filesystemDurability) {
1986
- if (config?.storage === "disk" && !filesystemDurability) {
1987
- fail("vectorPromotion.storage 'disk' needs filesystem durability, because a checkpoint file holds the vectors", {
1988
- storage: config.storage
1989
- });
1990
- }
1991
- }
1992
- function validateTextStorage(textStorage, filesystemDurability) {
1993
- if (textStorage === void 0 || textStorage === "memory" || textStorage === "disk" && filesystemDurability) return;
1994
- fail("textStorage must be 'memory', or 'disk' with filesystem durability", { textStorage });
1995
- }
1996
- function raiseEarlierReleaseGraphSetting(config) {
1997
- if (typeof config !== "object" || config === null) return config;
1998
- const hnsw = config.hnswConfig;
1999
- if (typeof hnsw !== "object" || hnsw === null) return config;
2000
- if (hnsw.m !== EARLIER_RELEASE_MIN_M) return config;
2001
- return { ...config, hnswConfig: { ...hnsw, m: MIN_M } };
2002
- }
2003
- function validateVectorPromotion(config) {
2004
- if (config === void 0) return;
2005
- if (config.threshold !== void 0 && !isPositiveInteger(config.threshold)) {
2006
- fail("vectorPromotion.threshold must be a positive integer", { threshold: config.threshold });
2007
- }
2008
- const quantization = config.quantization;
2009
- if (quantization !== void 0 && !isQuantizationMode(quantization)) {
2010
- fail("vectorPromotion.quantization must be 'osq8', 'osq4', 'osq2', 'osq1', or 'none'", { quantization });
2011
- }
2012
- const storage = config.storage;
2013
- if (storage !== void 0 && !isStorageMode(storage)) {
2014
- fail("vectorPromotion.storage must be 'memory' or 'disk'", { storage });
2015
- }
2016
- const hnsw = config.hnswConfig;
2017
- if (hnsw === void 0) return;
2018
- if (hnsw.m !== void 0 && (!Number.isInteger(hnsw.m) || hnsw.m < MIN_M || hnsw.m > MAX_M)) {
2019
- fail(`vectorPromotion.hnswConfig.m must be a whole number from ${MIN_M} to ${MAX_M}`, { m: hnsw.m });
2020
- }
2021
- if (hnsw.efConstruction !== void 0 && !isPositiveInteger(hnsw.efConstruction)) {
2022
- fail("vectorPromotion.hnswConfig.efConstruction must be a positive integer", {
2023
- efConstruction: hnsw.efConstruction
2024
- });
2025
- }
2026
- const metric = hnsw.metric;
2027
- if (metric !== void 0 && metric !== "cosine" && metric !== "dotProduct" && metric !== "euclidean") {
2028
- fail("vectorPromotion.hnswConfig.metric must be 'cosine', 'dotProduct', or 'euclidean'", { metric });
2029
- }
2030
- }
2031
-
2032
- // src/serialization/header.ts
2033
- var MAGIC_BYTES = new Uint8Array([78, 82, 83, 76]);
2034
- var HEADER_SIZE = 32;
2035
- var MAX_PAYLOAD_LENGTH = 4294967295;
2036
- var COMPRESSION_ALGORITHMS = {
2037
- 0: "none",
2038
- 1: "gzip",
2039
- 2: "lz4",
2040
- 3: "zstd"
2041
- };
2042
- var COMPRESSION_TO_BITS = {
2043
- none: 0,
2044
- gzip: 1,
2045
- lz4: 2,
2046
- zstd: 3
2047
- };
2048
- function encodeFlags(flags) {
2049
- let bits = 0;
2050
- if (flags.compressionEnabled) bits |= 1;
2051
- bits |= (COMPRESSION_TO_BITS[flags.compressionAlgorithm] & 3) << 1;
2052
- if (flags.checksumPresent) bits |= 1 << 3;
2053
- if (flags.encryptionEnabled) bits |= 1 << 4;
2054
- return bits;
2055
- }
2056
- function decodeFlags(value) {
2057
- const compressionEnabled = (value & 1) === 1;
2058
- const algorithmBits = value >> 1 & 3;
2059
- const checksumPresent = (value >> 3 & 1) === 1;
2060
- const encryptionEnabled = (value >> 4 & 1) === 1;
2061
- return {
2062
- compressionEnabled,
2063
- compressionAlgorithm: COMPRESSION_ALGORITHMS[algorithmBits] ?? "none",
2064
- checksumPresent,
2065
- encryptionEnabled
2066
- };
2067
- }
2068
- function writeHeader(header) {
2069
- if (header.payloadLength > MAX_PAYLOAD_LENGTH) {
2070
- throw new NarsilError(
2071
- ErrorCodes.PERSISTENCE_SAVE_FAILED,
2072
- `A payload of ${header.payloadLength} bytes exceeds the ${MAX_PAYLOAD_LENGTH} bytes the envelope header can describe`,
2073
- { payloadLength: header.payloadLength, maxPayloadLength: MAX_PAYLOAD_LENGTH }
2074
- );
2075
- }
2076
- const buffer = new Uint8Array(HEADER_SIZE);
2077
- const view = new DataView(buffer.buffer);
2078
- buffer.set(MAGIC_BYTES, 0);
2079
- buffer[4] = header.envelopeFormatVersion & 255;
2080
- buffer[5] = header.engineVersionMajor & 255;
2081
- buffer[6] = header.engineVersionMinor & 255;
2082
- buffer[7] = header.engineVersionPatch & 255;
2083
- view.setUint32(8, header.payloadLength, false);
2084
- view.setUint16(12, encodeFlags(header.flags), false);
2085
- view.setUint32(14, header.checksum, false);
2086
- for (let i = 18; i < HEADER_SIZE; i++) {
2087
- buffer[i] = 0;
2088
- }
2089
- return buffer;
2090
- }
2091
- function hasNrslMagic(data) {
2092
- 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];
2093
- }
2094
- function readHeader(data) {
2095
- if (data.length < HEADER_SIZE) {
2096
- throw new NarsilError(
2097
- ErrorCodes.ENVELOPE_INVALID_MAGIC,
2098
- `Expected at least ${HEADER_SIZE} bytes, received ${data.length}`
2099
- );
2100
- }
2101
- if (data[0] !== MAGIC_BYTES[0] || data[1] !== MAGIC_BYTES[1] || data[2] !== MAGIC_BYTES[2] || data[3] !== MAGIC_BYTES[3]) {
2102
- throw new NarsilError(ErrorCodes.ENVELOPE_INVALID_MAGIC, "File does not begin with NRSL magic bytes");
2103
- }
2104
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
2105
- const envelopeFormatVersion = data[4];
2106
- const engineVersionMajor = data[5];
2107
- const engineVersionMinor = data[6];
2108
- const engineVersionPatch = data[7];
2109
- const payloadLength = view.getUint32(8, false);
2110
- const flagBits = view.getUint16(12, false);
2111
- const checksum = view.getUint32(14, false);
2112
- const reserved = data.slice(18, HEADER_SIZE);
2113
- return {
2114
- magic: "NRSL",
2115
- envelopeFormatVersion,
2116
- engineVersionMajor,
2117
- engineVersionMinor,
2118
- engineVersionPatch,
2119
- payloadLength,
2120
- flags: decodeFlags(flagBits),
2121
- checksum,
2122
- reserved
2123
- };
2124
- }
2125
-
2126
- // src/serialization/crc32.ts
2127
- var IEEE_POLYNOMIAL = 3988292384;
2128
- var ALL_BITS = 4294967295;
2129
- var cachedTable = null;
2130
- function buildTable() {
2131
- const table = new Uint32Array(256);
2132
- for (let i = 0; i < 256; i++) {
2133
- let crc = i;
2134
- for (let bit = 0; bit < 8; bit++) {
2135
- crc = crc & 1 ? crc >>> 1 ^ IEEE_POLYNOMIAL : crc >>> 1;
2136
- }
2137
- table[i] = crc;
2138
- }
2139
- return table;
2140
- }
2141
- function getTable() {
2142
- if (cachedTable === null) {
2143
- cachedTable = buildTable();
2144
- }
2145
- return cachedTable;
2146
- }
2147
- function crc32(data) {
2148
- return crc32Final(crc32Update(crc32Init(), data));
2149
- }
2150
- function crc32Init() {
2151
- return ALL_BITS;
2152
- }
2153
- function crc32Update(state, data) {
2154
- const table = getTable();
2155
- let crc = state;
2156
- for (let i = 0; i < data.length; i++) {
2157
- crc = crc >>> 8 ^ table[(crc ^ data[i]) & 255];
2158
- }
2159
- return crc;
2160
- }
2161
- function crc32Final(state) {
2162
- return (state ^ ALL_BITS) >>> 0;
2163
- }
2164
-
2165
- // src/serialization/chunk-checksum.ts
2166
- function yieldToEventLoop() {
2167
- if (typeof setImmediate === "function") {
2168
- return new Promise((resolve) => setImmediate(resolve));
2169
- }
2170
- return new Promise((resolve) => setTimeout(resolve, 0));
2171
- }
2172
- async function advanceChecksum(start, payload) {
2173
- let state = start;
2174
- for (let offset = 0; offset < payload.length; offset += CHECKSUM_YIELD_CHUNK_BYTES) {
2175
- const end = Math.min(offset + CHECKSUM_YIELD_CHUNK_BYTES, payload.length);
2176
- state = crc32Update(state, payload.subarray(offset, end));
2177
- if (end < payload.length) {
2178
- await yieldToEventLoop();
2179
- }
2180
- }
2181
- return state;
2182
- }
2183
- async function checksumOfChunks(chunks) {
2184
- let state = crc32Init();
2185
- for (const chunk of chunks) state = await advanceChecksum(state, chunk);
2186
- return crc32Final(state);
2187
- }
2188
- function payloadByteLength(chunks) {
2189
- let total = 0;
2190
- for (const chunk of chunks) total += chunk.byteLength;
2191
- return total;
2192
- }
2193
- function requireWithinFileLimit(byteLength, what) {
2194
- if (byteLength <= MAX_FILE_BYTES) return;
2195
- throw new NarsilError(
2196
- ErrorCodes.PERSISTENCE_SAVE_FAILED,
2197
- `The ${what} would take ${byteLength} bytes, above the file size limit of ${MAX_FILE_BYTES}`,
2198
- { bytes: byteLength, maximum: MAX_FILE_BYTES }
2199
- );
2200
- }
2201
- function packEnvelopeWithEngineVersion(payloadChunks, envelopeFormatVersion, what, checksum, engineVersion) {
2202
- const payloadLength = payloadByteLength(payloadChunks);
2203
- requireWithinFileLimit(HEADER_SIZE + payloadLength, what);
2204
- const [major, minor, patch] = engineVersion;
2205
- const header = writeHeader({
2206
- envelopeFormatVersion,
2207
- engineVersionMajor: major,
2208
- engineVersionMinor: minor,
2209
- engineVersionPatch: patch,
2210
- payloadLength,
2211
- flags: { compressionEnabled: false, compressionAlgorithm: "none", checksumPresent: true, encryptionEnabled: false },
2212
- checksum});
2213
- return { chunks: [header, ...payloadChunks], byteLength: HEADER_SIZE + payloadLength, checksum };
2214
- }
2215
- function loadFailed(message, details) {
2216
- throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, message, details);
2217
- }
2218
- async function gunzipWithinLimit(compressed, what) {
2219
- const { gunzip } = await import('./gzip-5S7ROJFJ.mjs');
2220
- try {
2221
- return await gunzip(compressed, MAX_FILE_BYTES);
2222
- } catch (error) {
2223
- if (error?.code === "EFBIG") {
2224
- loadFailed(`The ${what} inflates past the file size limit of ${MAX_FILE_BYTES} bytes`);
2225
- }
2226
- loadFailed(`The ${what} holds a gzip payload that fails to inflate`, {
2227
- cause: error instanceof Error ? error.message : String(error)
2228
- });
2229
- }
2230
- }
2231
- async function openChecksummedEnvelope(data, expected) {
2232
- const { envelopeFormatVersion, what } = expected;
2233
- const header = readHeader(data);
2234
- if (header.envelopeFormatVersion !== envelopeFormatVersion) {
2235
- throw new NarsilError(
2236
- ErrorCodes.ENVELOPE_VERSION_MISMATCH,
2237
- `The ${what} holds envelope format v${header.envelopeFormatVersion}, while this build reads it as v${envelopeFormatVersion}`,
2238
- { version: header.envelopeFormatVersion, expected: envelopeFormatVersion }
2239
- );
2240
- }
2241
- if (header.flags.encryptionEnabled) {
2242
- throw new NarsilError(
2243
- ErrorCodes.ENVELOPE_VERSION_MISMATCH,
2244
- `The ${what} is encrypted, which this build cannot read`
2245
- );
2246
- }
2247
- if (header.flags.compressionEnabled && !expected.allowsCompression) {
2248
- loadFailed(`The ${what} is compressed, while its format stores it raw`);
2249
- }
2250
- if (header.flags.compressionEnabled && header.flags.compressionAlgorithm !== "gzip") {
2251
- throw new NarsilError(
2252
- ErrorCodes.ENVELOPE_VERSION_MISMATCH,
2253
- `The ${what} uses ${header.flags.compressionAlgorithm} compression, which this build cannot read`
2254
- );
2255
- }
2256
- if (!header.flags.checksumPresent) loadFailed(`The ${what} carries no checksum, while its format requires one`);
2257
- if (data.byteLength !== HEADER_SIZE + header.payloadLength) {
2258
- loadFailed(
2259
- `The ${what} holds ${data.byteLength} bytes where its header gives ${HEADER_SIZE + header.payloadLength}`,
2260
- { bytes: data.byteLength, expected: HEADER_SIZE + header.payloadLength }
2261
- );
2262
- }
2263
- const payload = data.subarray(HEADER_SIZE);
2264
- const computed = await checksumOfChunks([payload]);
2265
- if (computed !== header.checksum) {
2266
- throw new NarsilError(
2267
- ErrorCodes.PERSISTENCE_CRC_MISMATCH,
2268
- `The checksum of the ${what} does not match its payload`,
2269
- {
2270
- expected: header.checksum,
2271
- computed
2272
- }
2273
- );
2274
- }
2275
- if (header.flags.compressionEnabled) return { header, payload: await gunzipWithinLimit(payload, what) };
2276
- return { header, payload };
2277
- }
2278
- var INDEX_CONFIGURATION_ENVELOPE_VERSION = 5;
2279
- function requireConfigurationShape(raw, what) {
2280
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
2281
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The ${what} does not hold an index configuration`);
2282
- }
2283
- const configuration = raw;
2284
- if (configuration.schema === null || typeof configuration.schema !== "object") {
2285
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The ${what} holds no schema`);
2286
- }
2287
- if (typeof configuration.language !== "string" || configuration.language.length === 0) {
2288
- throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The ${what} holds no language`);
2289
- }
2290
- return configuration;
2291
- }
2292
- async function decodeIndexConfiguration(bytes) {
2293
- const { payload } = await openChecksummedEnvelope(bytes, {
2294
- envelopeFormatVersion: INDEX_CONFIGURATION_ENVELOPE_VERSION,
2295
- what: "index configuration",
2296
- allowsCompression: true
2297
- });
2298
- let raw;
2299
- try {
2300
- raw = decode(payload);
2301
- } catch {
2302
- throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, "The index configuration is not MessagePack");
2303
- }
2304
- return requireConfigurationShape(raw, "index configuration");
2305
- }
2306
-
2307
- // src/runtime/heap-statistics.browser.ts
2308
- function readHeapStatistics() {
2309
- return null;
2310
- }
2311
-
2312
- // src/core/partition/utils.ts
2313
- function getOrCreateFieldNameIndex(table, fieldName) {
2314
- const existing = table.indexMap.get(fieldName);
2315
- if (existing !== void 0) return existing;
2316
- const idx = table.names.length;
2317
- table.names.push(fieldName);
2318
- table.indexMap.set(fieldName, idx);
2319
- return idx;
2320
- }
2321
- var VECTOR_PATTERN2 = /^vector\[(\d+)]$/;
2322
- function getNestedValue(obj, path) {
2323
- const parts = path.split(".");
2324
- let current = obj;
2325
- for (let i = 0; i < parts.length; i++) {
2326
- if (current === null || current === void 0 || typeof current !== "object") return void 0;
2327
- if (!Object.hasOwn(current, parts[i])) return void 0;
2328
- current = current[parts[i]];
2329
- }
2330
- return current;
2331
- }
2332
- function stringArraysEqual(a, b) {
2333
- if (a === b) return true;
2334
- if (!a || !b) return false;
2335
- if (a.length !== b.length) return false;
2336
- for (let i = 0; i < a.length; i++) {
2337
- if (a[i] !== b[i]) return false;
2338
- }
2339
- return true;
2340
- }
2341
- function textFieldsChanged(oldDoc, newDoc, fields) {
2342
- for (const { path, base } of fields) {
2343
- if (!isWordIndexedBase(base)) continue;
2344
- const oldVal = getNestedValue(oldDoc, path);
2345
- const newVal = getNestedValue(newDoc, path);
2346
- if (base === "string") {
2347
- if (oldVal !== newVal) return true;
2348
- } else {
2349
- if (!stringArraysEqual(oldVal, newVal)) return true;
2350
- }
2351
- }
2352
- return false;
2353
- }
2354
- function parseVectorDimension(fieldType) {
2355
- const match = VECTOR_PATTERN2.exec(fieldType);
2356
- return match ? Number.parseInt(match[1], 10) : null;
2357
- }
2358
- function tokenizeOptions(options) {
2359
- return {
2360
- stem: true,
2361
- removeStopWords: true,
2362
- collectSurfaces: options?.collectSurfaces === true,
2363
- stopWordOverride: options?.stopWordOverride,
2364
- customTokenizer: options?.customTokenizer
2365
- };
2366
- }
2367
- function getFlatSchema(state, schema) {
2368
- if (state.lastSchemaRef === schema && state.flatSchemaCache) return state.flatSchemaCache;
2369
- state.flatSchemaCache = flattenSchema(schema);
2370
- state.lastSchemaRef = schema;
2371
- return state.flatSchemaCache;
2372
- }
2373
-
2374
- export { HEADER_SIZE, INDEX_CONFIGURATION_ENVELOPE_VERSION, MAX_DOCUMENT_NESTING_DEPTH, MAX_NESTING_DEPTH, MAX_PATTERN_VALUE_LIMIT, MIN_PATTERN_VALUE_LIMIT, PROTOTYPE_POLLUTION_KEYS, VECTOR_PATTERN, checksumOfChunks, crc32, crc32Final, crc32Init, crc32Update, decodeIndexConfiguration, encodeDocument, extractVectorFieldsFromSchema, flattenSchema, getFlatSchema, getLanguage, getNestedValue, getOrCreateFieldNameIndex, getStopWords, getTokenizer, hasLanguage, hasNrslMagic, hasStopWords, hasTokenizer, isGeopointOrVectorType, isLatitude, isListBase, isLongitude, isPlainObject, isQuantizationMode, isSingleStringFieldType, isStorageMode, isStringValuedBase, isWordIndexedBase, isWordIndexedFieldType, messagePackUpperBoundBytes, openChecksummedEnvelope, packEnvelopeWithEngineVersion, parseVectorDimension, parsedTypeOf, partialFieldsOf, payloadByteLength, raiseEarlierReleaseGraphSetting, readHeader, readHeapStatistics, registerLanguage, registerStopWords, registerTokenizer, requireConfigurationShape, requireCreatableSchema, requireDocumentWithinSizeLimit, requireValidFieldTypes, requireWithinFileLimit, resolveIndexAnalysis, schemaFieldsOf, textFieldsChanged, tokenizeOptions, validateDocument, validateDocumentStrict, validateRequiredFields, validateSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, withSortableOption, writeHeader };