@delali/narsil 0.1.15 → 0.2.1-next.25

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 (267) hide show
  1. package/NOTICE +54 -0
  2. package/README.md +38 -982
  3. package/dist/adapters/filesystem.d.ts +23 -1
  4. package/dist/adapters/filesystem.mjs +1 -1
  5. package/dist/adapters/indexeddb.d.ts +25 -1
  6. package/dist/adapters/indexeddb.mjs +1 -1
  7. package/dist/adapters/memory.d.ts +14 -1
  8. package/dist/adapters-CVqI5NBt.d.ts +149 -0
  9. package/dist/{chunk-HMO6OMZ3.mjs → chunk-ASI6AOW2.mjs} +1073 -506
  10. package/dist/{chunk-HRABJLPB.mjs → chunk-BKAI2WXI.mjs} +1 -0
  11. package/dist/{chunk-WISGW24C.mjs → chunk-FKK76OR7.mjs} +56 -55
  12. package/dist/chunk-GHJWC2E5.mjs +9 -0
  13. package/dist/chunk-KH3YGMVT.mjs +15 -0
  14. package/dist/chunk-TGP5M5R7.mjs +880 -0
  15. package/dist/chunk-U2BKYEC7.mjs +254 -0
  16. package/dist/{chunk-ALB35PRQ.mjs → chunk-UNJZ7ZDB.mjs} +18 -0
  17. package/dist/{chunk-MEW7HD75.mjs → chunk-WLR5BFL3.mjs} +2557 -1166
  18. package/dist/config-CAjTHzkH.d.ts +256 -0
  19. package/dist/direct-executor-3W4QRA4E.mjs +5 -0
  20. package/dist/distribution/coordinator/etcd.d.ts +44 -3
  21. package/dist/distribution/coordinator/etcd.mjs +2 -2
  22. package/dist/distribution/coordinator/in-memory.d.ts +14 -3
  23. package/dist/distribution.d.ts +318 -45
  24. package/dist/distribution.mjs +1875 -1772
  25. package/dist/embeddings/openai.d.ts +28 -1
  26. package/dist/embeddings/openai.mjs +1 -1
  27. package/dist/engine-CCrlfLyq.d.ts +431 -0
  28. package/dist/index.browser.mjs +4571 -1776
  29. package/dist/index.d.ts +180 -6
  30. package/dist/index.mjs +6 -5
  31. package/dist/invalidation/broadcast-channel.d.ts +20 -1
  32. package/dist/invalidation/filesystem.d.ts +24 -1
  33. package/dist/invalidation/noop.d.ts +14 -1
  34. package/dist/language-DB8KG1z5.d.ts +53 -0
  35. package/dist/languages/albanian.d.ts +15 -0
  36. package/dist/languages/albanian.mjs +103 -0
  37. package/dist/languages/amharic.d.ts +15 -0
  38. package/dist/languages/amharic.mjs +240 -0
  39. package/dist/languages/arabic.d.ts +10 -1
  40. package/dist/languages/arabic.mjs +939 -154
  41. package/dist/languages/armenian.d.ts +10 -1
  42. package/dist/languages/armenian.mjs +275 -243
  43. package/dist/languages/azerbaijani.d.ts +15 -0
  44. package/dist/languages/azerbaijani.mjs +152 -0
  45. package/dist/languages/bambara.d.ts +15 -0
  46. package/dist/languages/bambara.mjs +60 -0
  47. package/dist/languages/basque.d.ts +14 -0
  48. package/dist/languages/basque.mjs +726 -0
  49. package/dist/languages/belarusian.d.ts +15 -0
  50. package/dist/languages/belarusian.mjs +100 -0
  51. package/dist/languages/bengali.d.ts +15 -0
  52. package/dist/languages/bengali.mjs +128 -0
  53. package/dist/languages/bosnian.d.ts +15 -0
  54. package/dist/languages/bosnian.mjs +197 -0
  55. package/dist/languages/breton.d.ts +15 -0
  56. package/dist/languages/breton.mjs +96 -0
  57. package/dist/languages/bulgarian.d.ts +10 -1
  58. package/dist/languages/bulgarian.mjs +11 -2
  59. package/dist/languages/burmese.d.ts +15 -0
  60. package/dist/languages/burmese.mjs +57 -0
  61. package/dist/languages/catalan.d.ts +14 -0
  62. package/dist/languages/catalan.mjs +987 -0
  63. package/dist/languages/chinese.d.ts +11 -1
  64. package/dist/languages/chinese.mjs +4 -3
  65. package/dist/languages/croatian.d.ts +15 -0
  66. package/dist/languages/croatian.mjs +191 -0
  67. package/dist/languages/czech.d.ts +14 -0
  68. package/dist/languages/czech.mjs +628 -0
  69. package/dist/languages/dagbani.d.ts +11 -1
  70. package/dist/languages/dagbani.mjs +11 -2
  71. package/dist/languages/danish.d.ts +10 -1
  72. package/dist/languages/danish.mjs +215 -110
  73. package/dist/languages/dutch.d.ts +10 -1
  74. package/dist/languages/dutch.mjs +1248 -163
  75. package/dist/languages/english.d.ts +10 -1
  76. package/dist/languages/english.mjs +2 -1
  77. package/dist/languages/esperanto.d.ts +14 -0
  78. package/dist/languages/esperanto.mjs +689 -0
  79. package/dist/languages/estonian.d.ts +14 -0
  80. package/dist/languages/estonian.mjs +2160 -0
  81. package/dist/languages/ewe.d.ts +11 -1
  82. package/dist/languages/ewe.mjs +11 -2
  83. package/dist/languages/faroese.d.ts +15 -0
  84. package/dist/languages/faroese.mjs +93 -0
  85. package/dist/languages/fijian.d.ts +15 -0
  86. package/dist/languages/fijian.mjs +55 -0
  87. package/dist/languages/finnish.d.ts +10 -1
  88. package/dist/languages/finnish.mjs +528 -263
  89. package/dist/languages/french.d.ts +10 -1
  90. package/dist/languages/french.mjs +950 -437
  91. package/dist/languages/ga.d.ts +11 -1
  92. package/dist/languages/ga.mjs +2 -1
  93. package/dist/languages/galician.d.ts +15 -0
  94. package/dist/languages/galician.mjs +172 -0
  95. package/dist/languages/georgian.d.ts +15 -0
  96. package/dist/languages/georgian.mjs +91 -0
  97. package/dist/languages/german.d.ts +10 -1
  98. package/dist/languages/german.mjs +432 -162
  99. package/dist/languages/greek.d.ts +10 -1
  100. package/dist/languages/greek.mjs +1970 -281
  101. package/dist/languages/guarani.d.ts +15 -0
  102. package/dist/languages/guarani.mjs +132 -0
  103. package/dist/languages/gujarati.d.ts +15 -0
  104. package/dist/languages/gujarati.mjs +234 -0
  105. package/dist/languages/haitian-creole.d.ts +15 -0
  106. package/dist/languages/haitian-creole.mjs +106 -0
  107. package/dist/languages/hausa.d.ts +11 -1
  108. package/dist/languages/hausa.mjs +2 -1
  109. package/dist/languages/hawaiian.d.ts +15 -0
  110. package/dist/languages/hawaiian.mjs +69 -0
  111. package/dist/languages/hebrew.d.ts +15 -0
  112. package/dist/languages/hebrew.mjs +213 -0
  113. package/dist/languages/hindi.d.ts +10 -1
  114. package/dist/languages/hindi.mjs +175 -97
  115. package/dist/languages/hungarian.d.ts +10 -1
  116. package/dist/languages/hungarian.mjs +412 -326
  117. package/dist/languages/icelandic.d.ts +15 -0
  118. package/dist/languages/icelandic.mjs +161 -0
  119. package/dist/languages/igbo.d.ts +11 -1
  120. package/dist/languages/igbo.mjs +2 -1
  121. package/dist/languages/indonesian.d.ts +10 -1
  122. package/dist/languages/indonesian.mjs +329 -137
  123. package/dist/languages/irish.d.ts +10 -1
  124. package/dist/languages/irish.mjs +223 -139
  125. package/dist/languages/italian.d.ts +10 -1
  126. package/dist/languages/italian.mjs +703 -406
  127. package/dist/languages/japanese.d.ts +11 -1
  128. package/dist/languages/japanese.mjs +5 -108
  129. package/dist/languages/kannada.d.ts +15 -0
  130. package/dist/languages/kannada.mjs +94 -0
  131. package/dist/languages/kazakh.d.ts +15 -0
  132. package/dist/languages/kazakh.mjs +90 -0
  133. package/dist/languages/khmer.d.ts +15 -0
  134. package/dist/languages/khmer.mjs +181 -0
  135. package/dist/languages/kinyarwanda.d.ts +15 -0
  136. package/dist/languages/kinyarwanda.mjs +99 -0
  137. package/dist/languages/kirundi.d.ts +15 -0
  138. package/dist/languages/kirundi.mjs +92 -0
  139. package/dist/languages/korean.d.ts +15 -0
  140. package/dist/languages/korean.mjs +252 -0
  141. package/dist/languages/kurmanji.d.ts +15 -0
  142. package/dist/languages/kurmanji.mjs +50 -0
  143. package/dist/languages/kyrgyz.d.ts +15 -0
  144. package/dist/languages/kyrgyz.mjs +108 -0
  145. package/dist/languages/lao.d.ts +15 -0
  146. package/dist/languages/lao.mjs +63 -0
  147. package/dist/languages/latin.d.ts +15 -0
  148. package/dist/languages/latin.mjs +69 -0
  149. package/dist/languages/latvian.d.ts +15 -0
  150. package/dist/languages/latvian.mjs +173 -0
  151. package/dist/languages/lingala.d.ts +15 -0
  152. package/dist/languages/lingala.mjs +61 -0
  153. package/dist/languages/lithuanian.d.ts +14 -0
  154. package/dist/languages/lithuanian.mjs +571 -0
  155. package/dist/languages/luxembourgish.d.ts +15 -0
  156. package/dist/languages/luxembourgish.mjs +214 -0
  157. package/dist/languages/macedonian.d.ts +15 -0
  158. package/dist/languages/macedonian.mjs +808 -0
  159. package/dist/languages/malagasy.d.ts +15 -0
  160. package/dist/languages/malagasy.mjs +67 -0
  161. package/dist/languages/malay.d.ts +15 -0
  162. package/dist/languages/malay.mjs +482 -0
  163. package/dist/languages/malayalam.d.ts +15 -0
  164. package/dist/languages/malayalam.mjs +122 -0
  165. package/dist/languages/maltese.d.ts +15 -0
  166. package/dist/languages/maltese.mjs +139 -0
  167. package/dist/languages/maori.d.ts +15 -0
  168. package/dist/languages/maori.mjs +79 -0
  169. package/dist/languages/marathi.d.ts +15 -0
  170. package/dist/languages/marathi.mjs +111 -0
  171. package/dist/languages/nepali.d.ts +10 -1
  172. package/dist/languages/nepali.mjs +209 -99
  173. package/dist/languages/norwegian.d.ts +10 -1
  174. package/dist/languages/norwegian.mjs +218 -85
  175. package/dist/languages/oromo.d.ts +15 -0
  176. package/dist/languages/oromo.mjs +78 -0
  177. package/dist/languages/persian.d.ts +14 -0
  178. package/dist/languages/persian.mjs +710 -0
  179. package/dist/languages/polish.d.ts +14 -0
  180. package/dist/languages/polish.mjs +614 -0
  181. package/dist/languages/portuguese.d.ts +10 -1
  182. package/dist/languages/portuguese.mjs +613 -380
  183. package/dist/languages/punjabi.d.ts +15 -0
  184. package/dist/languages/punjabi.mjs +197 -0
  185. package/dist/languages/romanian.d.ts +10 -1
  186. package/dist/languages/romanian.mjs +561 -382
  187. package/dist/languages/russian.d.ts +10 -1
  188. package/dist/languages/russian.mjs +373 -244
  189. package/dist/languages/samoan.d.ts +15 -0
  190. package/dist/languages/samoan.mjs +63 -0
  191. package/dist/languages/sanskrit.d.ts +10 -1
  192. package/dist/languages/sanskrit.mjs +2 -2
  193. package/dist/languages/scottish-gaelic.d.ts +15 -0
  194. package/dist/languages/scottish-gaelic.mjs +370 -0
  195. package/dist/languages/serbian.d.ts +10 -1
  196. package/dist/languages/serbian.mjs +3635 -155
  197. package/dist/languages/shona.d.ts +15 -0
  198. package/dist/languages/shona.mjs +91 -0
  199. package/dist/languages/sinhala.d.ts +15 -0
  200. package/dist/languages/sinhala.mjs +182 -0
  201. package/dist/languages/slovak.d.ts +15 -0
  202. package/dist/languages/slovak.mjs +430 -0
  203. package/dist/languages/slovenian.d.ts +10 -1
  204. package/dist/languages/slovenian.mjs +11 -2
  205. package/dist/languages/sorani.d.ts +15 -0
  206. package/dist/languages/sorani.mjs +156 -0
  207. package/dist/languages/spanish.d.ts +10 -1
  208. package/dist/languages/spanish.mjs +676 -374
  209. package/dist/languages/swahili.d.ts +10 -1
  210. package/dist/languages/swahili.mjs +2 -1
  211. package/dist/languages/swedish.d.ts +10 -1
  212. package/dist/languages/swedish.mjs +237 -95
  213. package/dist/languages/tagalog.d.ts +15 -0
  214. package/dist/languages/tagalog.mjs +159 -0
  215. package/dist/languages/tamil.d.ts +10 -1
  216. package/dist/languages/tamil.mjs +836 -64
  217. package/dist/languages/tatar.d.ts +15 -0
  218. package/dist/languages/tatar.mjs +1017 -0
  219. package/dist/languages/telugu.d.ts +15 -0
  220. package/dist/languages/telugu.mjs +62 -0
  221. package/dist/languages/thai.d.ts +15 -0
  222. package/dist/languages/thai.mjs +65 -0
  223. package/dist/languages/tibetan.d.ts +15 -0
  224. package/dist/languages/tibetan.mjs +119 -0
  225. package/dist/languages/tigrinya.d.ts +15 -0
  226. package/dist/languages/tigrinya.mjs +194 -0
  227. package/dist/languages/tongan.d.ts +15 -0
  228. package/dist/languages/tongan.mjs +56 -0
  229. package/dist/languages/turkish.d.ts +10 -1
  230. package/dist/languages/turkish.mjs +1246 -393
  231. package/dist/languages/twi.d.ts +11 -1
  232. package/dist/languages/twi.mjs +13 -2
  233. package/dist/languages/ukrainian.d.ts +10 -1
  234. package/dist/languages/ukrainian.mjs +125 -47
  235. package/dist/languages/urdu.d.ts +15 -0
  236. package/dist/languages/urdu.mjs +528 -0
  237. package/dist/languages/vietnamese.d.ts +15 -0
  238. package/dist/languages/vietnamese.mjs +277 -0
  239. package/dist/languages/welsh.d.ts +15 -0
  240. package/dist/languages/welsh.mjs +446 -0
  241. package/dist/languages/wolof.d.ts +15 -0
  242. package/dist/languages/wolof.mjs +79 -0
  243. package/dist/languages/xhosa.d.ts +15 -0
  244. package/dist/languages/xhosa.mjs +95 -0
  245. package/dist/languages/yoruba.d.ts +11 -1
  246. package/dist/languages/yoruba.mjs +1 -0
  247. package/dist/languages/zulu.d.ts +11 -1
  248. package/dist/languages/zulu.mjs +2 -1
  249. package/dist/persistence/durability/checkpoint-worker.d.ts +13 -0
  250. package/dist/persistence/durability/checkpoint-worker.mjs +6 -5
  251. package/dist/schema-CE6S_aAr.d.ts +208 -0
  252. package/dist/search-CgQQIciB.d.ts +786 -0
  253. package/dist/server.d.ts +214 -12
  254. package/dist/server.mjs +41 -2
  255. package/dist/types-BV3nAKTL.d.ts +302 -0
  256. package/dist/vector/hnsw-build-worker.d.ts +68 -2
  257. package/dist/vector/hnsw-build-worker.mjs +0 -2
  258. package/dist/workers/entry.mjs +2 -2
  259. package/package.json +14 -4
  260. package/dist/adapters-Bo2JQg8b.d.ts +0 -37
  261. package/dist/chunk-TW6BXTOL.mjs +0 -338
  262. package/dist/config-CojEPOgS.d.ts +0 -481
  263. package/dist/direct-executor-E52FFGDE.mjs +0 -4
  264. package/dist/language-ONQ3iVDf.d.ts +0 -14
  265. package/dist/narsil-D-84Nvm4.d.ts +0 -72
  266. package/dist/schema-DCgkO1j4.d.ts +0 -65
  267. package/dist/types-DHX6zGeD.d.ts +0 -73
package/dist/index.d.ts CHANGED
@@ -1,19 +1,193 @@
1
- export { A as ArrayFilter, B as BatchResult, C as ComparisonFilter, E as ErrorCode, a as ErrorCodes, F as FacetConfig, b as FacetResult, c as FilterExpression, d as FlushConfig, G as GeoPolygonFilter, e as GeoRadiusFilter, f as GroupConfig, g as GroupReducer, h as GroupResult, H as HighlightConfig, i as HighlightMatch, j as Hit, k as HybridConfig, I as IndexContext, l as IndexInfo, m as IndexStats, n as InsertContext, M as MemoryStats, N as NarsilConfig, o as NarsilError, p as NarsilPlugin, P as PartitionContext, q as PartitionStatsResult, r as PreflightResult, s as PresenceFilter, t as ProcessMemoryReport, Q as QueryParams, u as QueryResult, R as RemoveContext, S as ScoreComponents, v as SearchContext, w as SearchMode, x as StringFilter, y as SuggestParams, z as SuggestResult, T as TermMatchPolicy, U as UpdateContext, V as VectorMaintenanceResult, D as VectorQueryConfig, W as WorkerConfig, J as WorkerContext } from './config-CojEPOgS.js';
2
- import { L as LanguageModule } from './language-ONQ3iVDf.js';
3
- export { N as Narsil, a as NarsilEventMap, c as createNarsil } from './narsil-D-84Nvm4.js';
4
- export { E as EmbeddingAdapter, I as InvalidationAdapter, a as InvalidationEvent, P as PartitionStatistics, b as PersistenceAdapter } from './adapters-Bo2JQg8b.js';
5
- export { A as AnyDocument, B as BM25Params, C as CustomTokenizer, E as EmbeddingFieldConfig, F as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, S as SchemaDefinition, b as ScoringMode } from './schema-DCgkO1j4.js';
1
+ import { S as StopWordOverride, C as CustomTokenizer } from './schema-CE6S_aAr.js';
2
+ export { A as AnyDocument, B as BM25Params, E as EmbeddingFieldConfig, F as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, b as SchemaDefinition, c as ScoringMode, V as VectorIndexConfig, d as VectorQuantizationMode } from './schema-CE6S_aAr.js';
3
+ import { L as LanguageModule } from './language-DB8KG1z5.js';
4
+ export { T as TokenizerConfig } from './language-DB8KG1z5.js';
5
+ export { A as ArrayFilter, B as BatchResult, C as ComparisonFilter, E as ErrorCode, a as ErrorCodes, F as FacetConfig, b as FacetResult, c as FieldFilter, d as FilterExpression, G as GeoFilter, e as GeoPolygonFilter, f as GeoRadiusFilter, g as GroupConfig, h as GroupReducer, i as GroupResult, H as HighlightConfig, j as HighlightMatch, k as Hit, l as HybridConfig, I as IndexInfo, m as IndexStats, M as MemoryStats, N as NarsilError, P as PartitionStatsResult, n as PreflightResult, o as PresenceFilter, p as ProcessMemoryReport, Q as QueryParams, q as QueryResult, S as ScoreComponents, r as SearchMode, s as StringFilter, t as SuggestParams, u as SuggestResult, T as TermMatchPolicy, V as VectorMaintenanceResult, v as VectorQueryConfig } from './search-CgQQIciB.js';
6
+ import { N as NarsilConfig } from './config-CAjTHzkH.js';
7
+ export { A as AnalysisConfig, D as DurabilityConfig, I as IndexContext, a as InsertContext, b as NarsilPlugin, P as PartitionContext, R as RemoveContext, S as SearchContext, c as StaleAnalysis, U as UpdateContext, W as WorkerConfig, d as WorkerContext } from './config-CAjTHzkH.js';
8
+ import { N as Narsil } from './engine-CCrlfLyq.js';
9
+ export { a as NarsilEventMap } from './engine-CCrlfLyq.js';
10
+ export { E as EmbeddingAdapter, I as InvalidationAdapter, a as InvalidationEvent, P as PartitionStatistics, b as PersistenceAdapter } from './adapters-CVqI5NBt.js';
6
11
 
12
+ /**
13
+ * Registers a tokeniser under a name that an index config can then reference.
14
+ *
15
+ * An index holds the name rather than the function, because a function
16
+ * survives neither a worker boundary nor a restart. Register the tokeniser on
17
+ * every thread that opens the index, and in the worker bootstrap module when
18
+ * the engine promotes to workers.
19
+ *
20
+ * @param name - The name an index config sets as its `tokenizer`.
21
+ * @param tokenizer - The tokeniser to bind to that name. Registering the same
22
+ * name again replaces what was there.
23
+ *
24
+ * @public
25
+ */
26
+ declare function registerTokenizer(name: string, tokenizer: CustomTokenizer): void;
27
+ /**
28
+ * Registers a stop word list under a name that an index config can then
29
+ * reference.
30
+ *
31
+ * An index holds the name rather than the list, so the same list survives a
32
+ * worker boundary and a restart. Register it on every thread that opens the
33
+ * index.
34
+ *
35
+ * @param name - The name an index config sets as its `stopWords`.
36
+ * @param stopWords - Either a fixed set of words, or a function that receives
37
+ * the language defaults and returns the set to use. Registering the same name
38
+ * again replaces what was there.
39
+ *
40
+ * @public
41
+ */
42
+ declare function registerStopWords(name: string, stopWords: StopWordOverride): void;
43
+ /**
44
+ * Reports whether a tokeniser is registered under this name, which is how a
45
+ * worker bootstrap checks its own work before an index needs it.
46
+ *
47
+ * @param name - The name to look for.
48
+ * @returns True once {@link registerTokenizer} has bound that name.
49
+ *
50
+ * @public
51
+ */
52
+ declare function hasTokenizer(name: string): boolean;
53
+ /**
54
+ * Reports whether a stop word list is registered under this name.
55
+ *
56
+ * @param name - The name to look for.
57
+ * @returns True once {@link registerStopWords} has bound that name.
58
+ *
59
+ * @public
60
+ */
61
+ declare function hasStopWords(name: string): boolean;
62
+ /**
63
+ * Returns the tokeniser registered under a name.
64
+ *
65
+ * @param name - The name {@link registerTokenizer} bound.
66
+ * @returns The registered tokeniser.
67
+ * @throws A `NarsilError` with `CONFIG_INVALID` when nothing holds that name.
68
+ *
69
+ * @public
70
+ */
71
+ declare function getTokenizer(name: string): CustomTokenizer;
72
+ /**
73
+ * Returns the stop word list registered under a name.
74
+ *
75
+ * @param name - The name {@link registerStopWords} bound.
76
+ * @returns The registered set, or the function that produces one.
77
+ * @throws A `NarsilError` with `CONFIG_INVALID` when nothing holds that name.
78
+ *
79
+ * @public
80
+ */
81
+ declare function getStopWords(name: string): StopWordOverride;
82
+
83
+ /**
84
+ * Sets how many normalised tokens the engine keeps cached.
85
+ *
86
+ * Normalising a token costs the same work every time the same word arrives, so
87
+ * the engine remembers the result. It sizes the cache from the host's memory
88
+ * on start-up; raise it for a corpus with a large vocabulary, and lower it on
89
+ * a memory-tight host.
90
+ *
91
+ * @param maxSize - Entries to keep. Zero switches the cache off.
92
+ * @throws A `NarsilError` with `CONFIG_INVALID` for a negative or non-finite
93
+ * size.
94
+ *
95
+ * @public
96
+ */
7
97
  declare function configureNormalizationCache(maxSize: number): void;
98
+ /**
99
+ * Empties the normalisation cache while keeping the size you configured.
100
+ *
101
+ * Call it to release the memory the cache holds after a large load, or after
102
+ * registering a language module that normalises differently from the one whose
103
+ * results are cached.
104
+ *
105
+ * @public
106
+ */
8
107
  declare function clearNormalizationCache(): void;
108
+ /**
109
+ * Empties the normalisation cache and returns its size to the value the engine
110
+ * derives from the host's memory, undoing
111
+ * {@link configureNormalizationCache}.
112
+ *
113
+ * @public
114
+ */
9
115
  declare function resetNormalizationCache(): void;
116
+ /**
117
+ * Returns the number of normalised tokens the cache currently holds, which is
118
+ * what you watch to decide whether the configured size fits your vocabulary.
119
+ *
120
+ * @returns Entries held, across every language.
121
+ *
122
+ * @public
123
+ */
10
124
  declare function getNormalizationCacheSize(): number;
11
125
 
126
+ /**
127
+ * Makes a language available to indexes that name it.
128
+ *
129
+ * English is registered already. Every other language is its own module, so a
130
+ * bundle carries only what you import. Import the one you want and register
131
+ * it before you create an index that sets it as `language`.
132
+ *
133
+ * @param module - The language module, which registers under its own `name`.
134
+ * Registering a name again replaces what was there.
135
+ *
136
+ * @public
137
+ */
12
138
  declare function registerLanguage(module: LanguageModule): void;
139
+ /**
140
+ * Returns the language module registered under a name.
141
+ *
142
+ * @param name - The name the module registered under.
143
+ * @returns The registered module.
144
+ * @throws A `NarsilError` with `LANGUAGE_NOT_SUPPORTED` when nothing holds
145
+ * that name, which usually means the module was never imported.
146
+ *
147
+ * @public
148
+ */
13
149
  declare function getLanguage(name: string): LanguageModule;
14
150
 
151
+ /**
152
+ * Creates a search engine that runs inside your process, with no server to
153
+ * provision.
154
+ *
155
+ * The engine holds every index you create, so an application usually keeps one
156
+ * instance for its lifetime. When you configure persistence, this recovers the
157
+ * indexes already on disk before it resolves, so the engine is ready to query
158
+ * as soon as you have it.
159
+ *
160
+ * @param config - This carries the persistence, partitioning, and worker
161
+ * invalidation settings. Omit it for an engine that keeps everything in memory.
162
+ * @returns The engine, ready for {@link Narsil.createIndex} to run against.
163
+ *
164
+ * @public
165
+ */
166
+ declare function createNarsil(config?: NarsilConfig): Promise<Narsil>;
167
+
168
+ /**
169
+ * Reports whether the runtime loaded the SIMD module that speeds up vector
170
+ * distance work.
171
+ *
172
+ * Vector search works either way, so read this to explain a difference in
173
+ * search latency between two hosts rather than to decide whether to search.
174
+ *
175
+ * @returns True once the SIMD module has loaded.
176
+ *
177
+ * @public
178
+ */
15
179
  declare function isSimdAvailable(): boolean;
16
180
 
181
+ /**
182
+ * Engine version written into the engine-version bytes of every `.nrsl` file,
183
+ * for diagnostics.
184
+ *
185
+ * It records which engine produced a file and carries no relation to the
186
+ * published package version, so read it when inspecting a file rather than
187
+ * when checking what you installed. Change it by hand and on purpose.
188
+ *
189
+ * @public
190
+ */
17
191
  declare const VERSION = "0.1.0";
18
192
 
19
- export { LanguageModule, VERSION, clearNormalizationCache, configureNormalizationCache, getLanguage, getNormalizationCacheSize, isSimdAvailable, registerLanguage, resetNormalizationCache };
193
+ export { CustomTokenizer, LanguageModule, Narsil, NarsilConfig, StopWordOverride, VERSION, clearNormalizationCache, configureNormalizationCache, createNarsil, getLanguage, getNormalizationCacheSize, getStopWords, getTokenizer, hasStopWords, hasTokenizer, isSimdAvailable, registerLanguage, registerStopWords, registerTokenizer, resetNormalizationCache };
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
- export { VERSION, createNarsil } from './chunk-MEW7HD75.mjs';
2
- export { clearNormalizationCache, configureNormalizationCache, getLanguage, getNormalizationCacheSize, registerLanguage, resetNormalizationCache } from './chunk-HMO6OMZ3.mjs';
1
+ export { VERSION, createNarsil } from './chunk-WLR5BFL3.mjs';
2
+ export { clearNormalizationCache, configureNormalizationCache, getLanguage, getNormalizationCacheSize, getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerLanguage, registerStopWords, registerTokenizer, resetNormalizationCache } from './chunk-ASI6AOW2.mjs';
3
+ import './chunk-TGP5M5R7.mjs';
3
4
  export { isSimdAvailable } from './chunk-S7RJJMHI.mjs';
4
5
  import './chunk-KMMJMDUA.mjs';
5
- import './chunk-TW6BXTOL.mjs';
6
- export { ErrorCodes, NarsilError } from './chunk-ALB35PRQ.mjs';
7
- import './chunk-HRABJLPB.mjs';
6
+ import './chunk-U2BKYEC7.mjs';
7
+ export { ErrorCodes, NarsilError } from './chunk-UNJZ7ZDB.mjs';
8
+ import './chunk-BKAI2WXI.mjs';
@@ -1,8 +1,27 @@
1
- import { I as InvalidationAdapter } from '../adapters-Bo2JQg8b.js';
1
+ import { I as InvalidationAdapter } from '../adapters-CVqI5NBt.js';
2
2
 
3
+ /**
4
+ * Which channel {@link createBroadcastChannelInvalidation} publishes on.
5
+ *
6
+ * @public
7
+ */
3
8
  interface BroadcastChannelInvalidationConfig {
9
+ /** Every participating tab or worker must name the same channel. The adapter uses `narsil-invalidation` by default. */
4
10
  channelName?: string;
5
11
  }
12
+ /**
13
+ * Builds an invalidation adapter that carries partition changes over the
14
+ * browser's `BroadcastChannel`, which is how several tabs sharing one
15
+ * IndexedDB index stay consistent.
16
+ *
17
+ * The browser delivers each event at once instead of on a poll, so a write in
18
+ * one tab reaches the others as soon as it dispatches.
19
+ *
20
+ * @param config - The channel name. Omit it to accept the default.
21
+ * @returns An adapter you pass as `invalidation` when creating an engine.
22
+ *
23
+ * @public
24
+ */
6
25
  declare function createBroadcastChannelInvalidation(config?: BroadcastChannelInvalidationConfig): InvalidationAdapter;
7
26
 
8
27
  export { type BroadcastChannelInvalidationConfig, createBroadcastChannelInvalidation };
@@ -1,10 +1,33 @@
1
- import { I as InvalidationAdapter } from '../adapters-Bo2JQg8b.js';
1
+ import { I as InvalidationAdapter } from '../adapters-CVqI5NBt.js';
2
2
 
3
+ /**
4
+ * How {@link createFilesystemInvalidation} exchanges events between processes.
5
+ *
6
+ * @public
7
+ */
3
8
  interface FilesystemInvalidationConfig {
9
+ /** The adapter writes its marker files to this directory. Every instance sharing an index must point at the same one. */
4
10
  directory: string;
11
+ /** The adapter sweeps the directory this many milliseconds apart, and 1000 apart by default. A shorter interval shortens the lag and costs more reads. */
5
12
  pollInterval?: number;
13
+ /** This identifies the instance, so it skips the markers it wrote itself. The adapter generates a random id by default. */
6
14
  instanceId?: string;
7
15
  }
16
+ /**
17
+ * Builds an invalidation adapter that carries partition changes through marker
18
+ * files in a shared directory, which is how several Node processes on one host
19
+ * keep one persisted index consistent.
20
+ *
21
+ * Each publisher drops a marker and every other instance picks it up on its
22
+ * next sweep, so a change reaches the others within one poll interval. The
23
+ * adapter clears an old marker as it reads it.
24
+ *
25
+ * @param config - The shared directory, the poll interval, and this instance's
26
+ * identifier.
27
+ * @returns An adapter you pass as `invalidation` when creating an engine.
28
+ *
29
+ * @public
30
+ */
8
31
  declare function createFilesystemInvalidation(config: FilesystemInvalidationConfig): InvalidationAdapter;
9
32
 
10
33
  export { type FilesystemInvalidationConfig, createFilesystemInvalidation };
@@ -1,5 +1,18 @@
1
- import { I as InvalidationAdapter } from '../adapters-Bo2JQg8b.js';
1
+ import { I as InvalidationAdapter } from '../adapters-CVqI5NBt.js';
2
2
 
3
+ /**
4
+ * Builds an invalidation adapter that discards every event, which suits a
5
+ * single process holding a store nothing else writes to.
6
+ *
7
+ * Use it to satisfy code paths that expect an adapter without paying for a
8
+ * channel, and swap in {@link createFilesystemInvalidation} or
9
+ * {@link createBroadcastChannelInvalidation} once a second instance shares the
10
+ * store.
11
+ *
12
+ * @returns An adapter you pass as `invalidation` when creating an engine.
13
+ *
14
+ * @public
15
+ */
3
16
  declare function createNoopInvalidation(): InvalidationAdapter;
4
17
 
5
18
  export { createNoopInvalidation };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Everything the engine needs to analyse one language: how to split text into
3
+ * tokens, which words to drop, and how to reduce a word to its stem.
4
+ *
5
+ * Each language is its own module, so a bundle carries only the languages you
6
+ * import. Register one with {@link registerLanguage} before an index names it.
7
+ *
8
+ * @public
9
+ */
10
+ interface LanguageModule {
11
+ /** An index config sets this name as its `language`. */
12
+ name: string;
13
+ /**
14
+ * This fingerprints the module's analysis. The engine records it with each
15
+ * index and reports the index as stale once the two differ, which is how a
16
+ * corrected stemmer or stop word list reaches indexes already written.
17
+ */
18
+ revision: string;
19
+ /**
20
+ * This reduces one token to the stem the engine indexes and searches on. It
21
+ * is `null` for a language the project analyses no further than its
22
+ * normaliser.
23
+ */
24
+ stemmer: ((token: string) => string) | null;
25
+ /** The engine drops these words before indexing, because they appear too widely to separate one document from another. */
26
+ stopWords: Set<string>;
27
+ /** This folds a token's script before stemming, which is where case, diacritics, and lookalike letters are settled. */
28
+ normalizer?: (token: string) => string;
29
+ /** These rules split text into tokens, when this language needs something other than the engine's default. */
30
+ tokenizer?: TokenizerConfig;
31
+ }
32
+ /**
33
+ * How the engine splits text into tokens for one language.
34
+ *
35
+ * Leave every field unset to accept the engine's default rules, which suit a
36
+ * space-separated script written in words.
37
+ *
38
+ * @public
39
+ */
40
+ interface TokenizerConfig {
41
+ /** The engine splits on this pattern, which a script without spaces between words replaces. */
42
+ splitPattern?: RegExp;
43
+ /** Setting this folds accented letters onto their base letters, so `café` and `cafe` match. */
44
+ normalizeDiacritics?: boolean;
45
+ /** The engine drops a token shorter than this, which keeps stray fragments out of the index. */
46
+ minTokenLength?: number;
47
+ /** Setting this strips a trailing possessive, so `reader's` indexes as `reader`. */
48
+ stripPossessive?: boolean;
49
+ /** The engine cuts each run of characters into overlapping n-grams this long, which is how a script without word breaks is indexed. */
50
+ ngramSize?: number;
51
+ }
52
+
53
+ export type { LanguageModule as L, TokenizerConfig as T };
@@ -0,0 +1,15 @@
1
+ import { L as LanguageModule } from '../language-DB8KG1z5.js';
2
+
3
+ /**
4
+ * Albanian analysis: the stop word list and the rules that split Albanian
5
+ * text into tokens. Tokens are indexed as the normaliser leaves them,
6
+ * without stemming.
7
+ *
8
+ * Import it and pass it to {@link registerLanguage} before you create an index
9
+ * whose `language` is `albanian`.
10
+ *
11
+ * @public
12
+ */
13
+ declare const albanian: LanguageModule;
14
+
15
+ export { albanian };
@@ -0,0 +1,103 @@
1
+ // src/languages/albanian.ts
2
+ var stopWords = /* @__PURE__ */ new Set([
3
+ "ai",
4
+ "ajo",
5
+ "as",
6
+ "asnj\xEB",
7
+ "ata",
8
+ "atje",
9
+ "ato",
10
+ "aty",
11
+ "brenda",
12
+ "\xE7do",
13
+ "\xE7far\xEB",
14
+ "cila",
15
+ "cil\xEBt",
16
+ "cili",
17
+ "deri",
18
+ "dhe",
19
+ "disa",
20
+ "do",
21
+ "e",
22
+ "edhe",
23
+ "\xEBsht\xEB",
24
+ "gjat\xEB",
25
+ "gjithashtu",
26
+ "gjith\xEB",
27
+ "i",
28
+ "im",
29
+ "ime",
30
+ "ishte",
31
+ "jan\xEB",
32
+ "jasht\xEB",
33
+ "jon\xEB",
34
+ "jote",
35
+ "ju",
36
+ "juaj",
37
+ "ka",
38
+ "kam",
39
+ "kan\xEB",
40
+ "ke",
41
+ "kemi",
42
+ "keni",
43
+ "k\xEBta",
44
+ "k\xEBto",
45
+ "k\xEBtu",
46
+ "kjo",
47
+ "ku",
48
+ "kur",
49
+ "ky",
50
+ "lart",
51
+ "mbi",
52
+ "me",
53
+ "m\xEB",
54
+ "midis",
55
+ "mos",
56
+ "nd\xEBr",
57
+ "nd\xEBrmjet",
58
+ "ne",
59
+ "n\xEB",
60
+ "n\xEBn",
61
+ "nga",
62
+ "nj\xEB",
63
+ "nuk",
64
+ "ose",
65
+ "pa",
66
+ "pak",
67
+ "para",
68
+ "pas",
69
+ "pastaj",
70
+ "p\xEBr",
71
+ "por",
72
+ "posht\xEB",
73
+ "prej",
74
+ "q\xEB",
75
+ "sa",
76
+ "saj",
77
+ "shum\xEB",
78
+ "si",
79
+ "sipas",
80
+ "tani",
81
+ "te",
82
+ "t\xEB",
83
+ "tek",
84
+ "ti",
85
+ "tij",
86
+ "tjet\xEBr",
87
+ "tyre",
88
+ "u",
89
+ "un\xEB",
90
+ "vet\xEB",
91
+ "vet\xEBm",
92
+ "veten",
93
+ "yt"
94
+ ]);
95
+ var albanian = {
96
+ name: "albanian",
97
+ revision: "1",
98
+ stemmer: null,
99
+ stopWords,
100
+ tokenizer: { splitPattern: /[^a-z0-9çë]+/gi }
101
+ };
102
+
103
+ export { albanian };
@@ -0,0 +1,15 @@
1
+ import { L as LanguageModule } from '../language-DB8KG1z5.js';
2
+
3
+ /**
4
+ * Amharic analysis: the stop word list and the rules that split Amharic
5
+ * text into tokens. Tokens are indexed as the normaliser leaves them,
6
+ * without stemming.
7
+ *
8
+ * Import it and pass it to {@link registerLanguage} before you create an index
9
+ * whose `language` is `amharic`.
10
+ *
11
+ * @public
12
+ */
13
+ declare const amharic: LanguageModule;
14
+
15
+ export { amharic };