hermes-wasm 0.4.3 → 0.4.6

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.
package/hermes_wasm.d.ts CHANGED
@@ -1,188 +1,200 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Index registry for managing multiple indexes
6
+ */
4
7
  export class IndexRegistry {
5
- free(): void;
6
- [Symbol.dispose](): void;
7
- /**
8
- * Add a remote index
9
- */
10
- add_remote(name: string, base_url: string): Promise<void>;
11
- constructor();
12
- /**
13
- * List index names
14
- */
15
- list(): any;
16
- /**
17
- * Remove an index
18
- */
19
- remove(name: string): void;
20
- /**
21
- * Search an index by name
22
- */
23
- search(index_name: string, text: string, limit: number): Promise<any>;
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Add a remote index
12
+ */
13
+ add_remote(name: string, base_url: string): Promise<void>;
14
+ /**
15
+ * List index names
16
+ */
17
+ list(): any;
18
+ constructor();
19
+ /**
20
+ * Remove an index
21
+ */
22
+ remove(name: string): void;
23
+ /**
24
+ * Search an index by name
25
+ */
26
+ search(index_name: string, text: string, limit: number): Promise<any>;
24
27
  }
25
28
 
29
+ /**
30
+ * IPFS Index that uses JavaScript verified-fetch for content retrieval
31
+ *
32
+ * This allows loading indexes from IPFS without using gateways by
33
+ * leveraging @helia/verified-fetch in JavaScript.
34
+ */
26
35
  export class IpfsIndex {
27
- free(): void;
28
- [Symbol.dispose](): void;
29
- /**
30
- * Get cache statistics
31
- */
32
- cache_stats(): any;
33
- /**
34
- * Get field names
35
- */
36
- field_names(): any;
37
- /**
38
- * Export cache
39
- */
40
- export_cache(): Uint8Array | undefined;
41
- /**
42
- * Get a document by address
43
- */
44
- get_document(segment_id: string, doc_id: number): Promise<any>;
45
- /**
46
- * Import cache
47
- */
48
- import_cache(data: Uint8Array): void;
49
- /**
50
- * Get number of segments
51
- */
52
- num_segments(): number;
53
- /**
54
- * Get default fields
55
- */
56
- default_fields(): any;
57
- /**
58
- * Clear IndexedDB cache
59
- */
60
- clear_idb_cache(): Promise<void>;
61
- /**
62
- * Create with custom cache size
63
- */
64
- static with_cache_size(base_path: string, cache_size: number): IpfsIndex;
65
- /**
66
- * Save cache to IndexedDB
67
- */
68
- save_cache_to_idb(): Promise<void>;
69
- /**
70
- * Load cache from IndexedDB
71
- */
72
- load_cache_from_idb(): Promise<boolean>;
73
- /**
74
- * Create a new IPFS index
75
- *
76
- * @param base_path - The IPFS path (e.g., "/ipfs/Qm..." or "/ipns/...")
77
- */
78
- constructor(base_path: string);
79
- /**
80
- * Load index using JavaScript fetch functions
81
- *
82
- * @param fetch_fn - JS function: (path: string) => Promise<Uint8Array>
83
- * @param size_fn - JS function: (path: string) => Promise<number>
84
- */
85
- load(fetch_fn: Function, size_fn: Function): Promise<void>;
86
- /**
87
- * Search the index
88
- */
89
- search(query_str: string, limit: number): Promise<any>;
90
- /**
91
- * Get number of documents
92
- */
93
- num_docs(): number;
36
+ free(): void;
37
+ [Symbol.dispose](): void;
38
+ /**
39
+ * Get cache statistics
40
+ */
41
+ cache_stats(): any;
42
+ /**
43
+ * Clear IndexedDB cache
44
+ */
45
+ clear_idb_cache(): Promise<void>;
46
+ /**
47
+ * Get default fields
48
+ */
49
+ default_fields(): any;
50
+ /**
51
+ * Export cache
52
+ */
53
+ export_cache(): Uint8Array | undefined;
54
+ /**
55
+ * Get field names
56
+ */
57
+ field_names(): any;
58
+ /**
59
+ * Get a document by address
60
+ */
61
+ get_document(segment_id: string, doc_id: number): Promise<any>;
62
+ /**
63
+ * Import cache
64
+ */
65
+ import_cache(data: Uint8Array): void;
66
+ /**
67
+ * Load index using JavaScript fetch functions
68
+ *
69
+ * @param fetch_fn - JS function: (path: string) => Promise<Uint8Array>
70
+ * @param size_fn - JS function: (path: string) => Promise<number>
71
+ */
72
+ load(fetch_fn: Function, size_fn: Function): Promise<void>;
73
+ /**
74
+ * Load cache from IndexedDB
75
+ */
76
+ load_cache_from_idb(): Promise<boolean>;
77
+ /**
78
+ * Create a new IPFS index
79
+ *
80
+ * @param base_path - The IPFS path (e.g., "/ipfs/Qm..." or "/ipns/...")
81
+ */
82
+ constructor(base_path: string);
83
+ /**
84
+ * Get number of documents
85
+ */
86
+ num_docs(): number;
87
+ /**
88
+ * Get number of segments
89
+ */
90
+ num_segments(): number;
91
+ /**
92
+ * Save cache to IndexedDB
93
+ */
94
+ save_cache_to_idb(): Promise<void>;
95
+ /**
96
+ * Search the index
97
+ */
98
+ search(query_str: string, limit: number): Promise<any>;
99
+ /**
100
+ * Create with custom cache size
101
+ */
102
+ static with_cache_size(base_path: string, cache_size: number): IpfsIndex;
94
103
  }
95
104
 
105
+ /**
106
+ * Remote index that loads data via HTTP with slice caching
107
+ */
96
108
  export class RemoteIndex {
97
- free(): void;
98
- [Symbol.dispose](): void;
99
- /**
100
- * Get cache statistics
101
- */
102
- cache_stats(): any;
103
- /**
104
- * Get field names
105
- */
106
- field_names(): any;
107
- /**
108
- * Export the current slice cache as bytes
109
- *
110
- * Returns the serialized cache data that can be stored in IndexedDB
111
- * or other persistent storage for later restoration.
112
- */
113
- export_cache(): Uint8Array | undefined;
114
- /**
115
- * Get a document by its address (segment_id + doc_id)
116
- *
117
- * Returns the document as a JSON object, or null if not found.
118
- */
119
- get_document(segment_id: string, doc_id: number): Promise<any>;
120
- /**
121
- * Import a previously exported slice cache
122
- *
123
- * Merges the cached slices into the current cache, reducing
124
- * network requests for previously fetched data.
125
- */
126
- import_cache(data: Uint8Array): void;
127
- /**
128
- * Get number of segments
129
- */
130
- num_segments(): number;
131
- /**
132
- * Get network statistics (requests made, bytes transferred, etc.)
133
- */
134
- network_stats(): any;
135
- /**
136
- * Get default field names for query parsing
137
- */
138
- default_fields(): any;
139
- /**
140
- * Clear the persisted cache from IndexedDB
141
- */
142
- clear_idb_cache(): Promise<void>;
143
- /**
144
- * Create with custom cache size (in bytes)
145
- */
146
- static with_cache_size(base_url: string, cache_size: number): RemoteIndex;
147
- /**
148
- * Save the slice cache to IndexedDB for persistence across sessions
149
- *
150
- * The cache is stored under a key derived from the base URL.
151
- */
152
- save_cache_to_idb(): Promise<void>;
153
- /**
154
- * Load the slice cache from IndexedDB
155
- *
156
- * Call this after load() to restore cached data from a previous session.
157
- */
158
- load_cache_from_idb(): Promise<boolean>;
159
- /**
160
- * Reset network statistics
161
- */
162
- reset_network_stats(): void;
163
- /**
164
- * Create a new remote index pointing to a URL
165
- */
166
- constructor(base_url: string);
167
- /**
168
- * Load index from URL using hermes-core Index with slice caching
169
- *
170
- * Automatically attempts to load the slice cache file (index.slicecache)
171
- * to prefill the cache with hot data, reducing cold-start latency.
172
- */
173
- load(): Promise<void>;
174
- /**
175
- * Search the index
176
- *
177
- * Accepts both query language syntax (field:term, AND, OR, NOT, grouping)
178
- * and simple text (tokenized and searched across default fields).
179
- * Returns document addresses (segment_id + doc_id) without document content.
180
- */
181
- search(query_str: string, limit: number): Promise<any>;
182
- /**
183
- * Get number of documents
184
- */
185
- num_docs(): number;
109
+ free(): void;
110
+ [Symbol.dispose](): void;
111
+ /**
112
+ * Get cache statistics
113
+ */
114
+ cache_stats(): any;
115
+ /**
116
+ * Clear the persisted cache from IndexedDB
117
+ */
118
+ clear_idb_cache(): Promise<void>;
119
+ /**
120
+ * Get default field names for query parsing
121
+ */
122
+ default_fields(): any;
123
+ /**
124
+ * Export the current slice cache as bytes
125
+ *
126
+ * Returns the serialized cache data that can be stored in IndexedDB
127
+ * or other persistent storage for later restoration.
128
+ */
129
+ export_cache(): Uint8Array | undefined;
130
+ /**
131
+ * Get field names
132
+ */
133
+ field_names(): any;
134
+ /**
135
+ * Get a document by its address (segment_id + doc_id)
136
+ *
137
+ * Returns the document as a JSON object, or null if not found.
138
+ */
139
+ get_document(segment_id: string, doc_id: number): Promise<any>;
140
+ /**
141
+ * Import a previously exported slice cache
142
+ *
143
+ * Merges the cached slices into the current cache, reducing
144
+ * network requests for previously fetched data.
145
+ */
146
+ import_cache(data: Uint8Array): void;
147
+ /**
148
+ * Load index from URL using hermes-core Index with slice caching
149
+ *
150
+ * Automatically attempts to load the slice cache file (index.slicecache)
151
+ * to prefill the cache with hot data, reducing cold-start latency.
152
+ */
153
+ load(): Promise<void>;
154
+ /**
155
+ * Load the slice cache from IndexedDB
156
+ *
157
+ * Call this after load() to restore cached data from a previous session.
158
+ */
159
+ load_cache_from_idb(): Promise<boolean>;
160
+ /**
161
+ * Get network statistics (requests made, bytes transferred, etc.)
162
+ */
163
+ network_stats(): any;
164
+ /**
165
+ * Create a new remote index pointing to a URL
166
+ */
167
+ constructor(base_url: string);
168
+ /**
169
+ * Get number of documents
170
+ */
171
+ num_docs(): number;
172
+ /**
173
+ * Get number of segments
174
+ */
175
+ num_segments(): number;
176
+ /**
177
+ * Reset network statistics
178
+ */
179
+ reset_network_stats(): void;
180
+ /**
181
+ * Save the slice cache to IndexedDB for persistence across sessions
182
+ *
183
+ * The cache is stored under a key derived from the base URL.
184
+ */
185
+ save_cache_to_idb(): Promise<void>;
186
+ /**
187
+ * Search the index
188
+ *
189
+ * Accepts both query language syntax (field:term, AND, OR, NOT, grouping)
190
+ * and simple text (tokenized and searched across default fields).
191
+ * Returns document addresses (segment_id + doc_id) without document content.
192
+ */
193
+ search(query_str: string, limit: number): Promise<any>;
194
+ /**
195
+ * Create with custom cache size (in bytes)
196
+ */
197
+ static with_cache_size(base_url: string, cache_size: number): RemoteIndex;
186
198
  }
187
199
 
188
200
  /**
@@ -198,92 +210,92 @@ export function setup_logging(): void;
198
210
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
199
211
 
200
212
  export interface InitOutput {
201
- readonly memory: WebAssembly.Memory;
202
- readonly __wbg_ipfsindex_free: (a: number, b: number) => void;
203
- readonly ipfsindex_cache_stats: (a: number) => any;
204
- readonly ipfsindex_clear_idb_cache: (a: number) => any;
205
- readonly ipfsindex_default_fields: (a: number) => any;
206
- readonly ipfsindex_export_cache: (a: number) => [number, number];
207
- readonly ipfsindex_field_names: (a: number) => any;
208
- readonly ipfsindex_get_document: (a: number, b: number, c: number, d: number) => any;
209
- readonly ipfsindex_import_cache: (a: number, b: number, c: number) => [number, number];
210
- readonly ipfsindex_load: (a: number, b: any, c: any) => any;
211
- readonly ipfsindex_load_cache_from_idb: (a: number) => any;
212
- readonly ipfsindex_new: (a: number, b: number) => number;
213
- readonly ipfsindex_num_docs: (a: number) => number;
214
- readonly ipfsindex_num_segments: (a: number) => number;
215
- readonly ipfsindex_save_cache_to_idb: (a: number) => any;
216
- readonly ipfsindex_search: (a: number, b: number, c: number, d: number) => any;
217
- readonly ipfsindex_with_cache_size: (a: number, b: number, c: number) => number;
218
- readonly init: () => void;
219
- readonly setup_logging: () => void;
220
- readonly __wbg_indexregistry_free: (a: number, b: number) => void;
221
- readonly indexregistry_add_remote: (a: number, b: number, c: number, d: number, e: number) => any;
222
- readonly indexregistry_list: (a: number) => any;
223
- readonly indexregistry_new: () => number;
224
- readonly indexregistry_remove: (a: number, b: number, c: number) => void;
225
- readonly indexregistry_search: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
226
- readonly __wbg_remoteindex_free: (a: number, b: number) => void;
227
- readonly remoteindex_cache_stats: (a: number) => any;
228
- readonly remoteindex_clear_idb_cache: (a: number) => any;
229
- readonly remoteindex_default_fields: (a: number) => any;
230
- readonly remoteindex_export_cache: (a: number) => [number, number];
231
- readonly remoteindex_field_names: (a: number) => any;
232
- readonly remoteindex_get_document: (a: number, b: number, c: number, d: number) => any;
233
- readonly remoteindex_import_cache: (a: number, b: number, c: number) => [number, number];
234
- readonly remoteindex_load: (a: number) => any;
235
- readonly remoteindex_load_cache_from_idb: (a: number) => any;
236
- readonly remoteindex_network_stats: (a: number) => any;
237
- readonly remoteindex_new: (a: number, b: number) => number;
238
- readonly remoteindex_num_docs: (a: number) => number;
239
- readonly remoteindex_num_segments: (a: number) => number;
240
- readonly remoteindex_reset_network_stats: (a: number) => void;
241
- readonly remoteindex_save_cache_to_idb: (a: number) => any;
242
- readonly remoteindex_search: (a: number, b: number, c: number, d: number) => any;
243
- readonly remoteindex_with_cache_size: (a: number, b: number, c: number) => number;
244
- readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
245
- readonly rust_zstd_wasm_shim_free: (a: number) => void;
246
- readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
247
- readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
248
- readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
249
- readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
250
- readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
251
- readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
252
- readonly wasm_bindgen__convert__closures_____invoke__h439efdfeda72ac88: (a: number, b: number, c: any) => void;
253
- readonly wasm_bindgen__closure__destroy__h4fdfb4a1331c6e84: (a: number, b: number) => void;
254
- readonly wasm_bindgen__convert__closures_____invoke__haa072074c85bd216: (a: number, b: number, c: any) => void;
255
- readonly wasm_bindgen__closure__destroy__h7b55ee774e6ec527: (a: number, b: number) => void;
256
- readonly wasm_bindgen__convert__closures_____invoke__h31cab8129ff204d7: (a: number, b: number) => void;
257
- readonly wasm_bindgen__closure__destroy__hb957e677ca4e125e: (a: number, b: number) => void;
258
- readonly wasm_bindgen__convert__closures_____invoke__h1d5a4b72e8f7feb4: (a: number, b: number, c: any, d: any) => void;
259
- readonly __wbindgen_malloc: (a: number, b: number) => number;
260
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
261
- readonly __wbindgen_exn_store: (a: number) => void;
262
- readonly __externref_table_alloc: () => number;
263
- readonly __wbindgen_externrefs: WebAssembly.Table;
264
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
265
- readonly __externref_table_dealloc: (a: number) => void;
266
- readonly __wbindgen_start: () => void;
213
+ readonly memory: WebAssembly.Memory;
214
+ readonly __wbg_ipfsindex_free: (a: number, b: number) => void;
215
+ readonly ipfsindex_cache_stats: (a: number) => any;
216
+ readonly ipfsindex_clear_idb_cache: (a: number) => any;
217
+ readonly ipfsindex_default_fields: (a: number) => any;
218
+ readonly ipfsindex_export_cache: (a: number) => [number, number];
219
+ readonly ipfsindex_field_names: (a: number) => any;
220
+ readonly ipfsindex_get_document: (a: number, b: number, c: number, d: number) => any;
221
+ readonly ipfsindex_import_cache: (a: number, b: number, c: number) => [number, number];
222
+ readonly ipfsindex_load: (a: number, b: any, c: any) => any;
223
+ readonly ipfsindex_load_cache_from_idb: (a: number) => any;
224
+ readonly ipfsindex_new: (a: number, b: number) => number;
225
+ readonly ipfsindex_num_docs: (a: number) => number;
226
+ readonly ipfsindex_num_segments: (a: number) => number;
227
+ readonly ipfsindex_save_cache_to_idb: (a: number) => any;
228
+ readonly ipfsindex_search: (a: number, b: number, c: number, d: number) => any;
229
+ readonly ipfsindex_with_cache_size: (a: number, b: number, c: number) => number;
230
+ readonly init: () => void;
231
+ readonly setup_logging: () => void;
232
+ readonly __wbg_remoteindex_free: (a: number, b: number) => void;
233
+ readonly remoteindex_cache_stats: (a: number) => any;
234
+ readonly remoteindex_clear_idb_cache: (a: number) => any;
235
+ readonly remoteindex_default_fields: (a: number) => any;
236
+ readonly remoteindex_export_cache: (a: number) => [number, number];
237
+ readonly remoteindex_field_names: (a: number) => any;
238
+ readonly remoteindex_get_document: (a: number, b: number, c: number, d: number) => any;
239
+ readonly remoteindex_import_cache: (a: number, b: number, c: number) => [number, number];
240
+ readonly remoteindex_load: (a: number) => any;
241
+ readonly remoteindex_load_cache_from_idb: (a: number) => any;
242
+ readonly remoteindex_network_stats: (a: number) => any;
243
+ readonly remoteindex_new: (a: number, b: number) => number;
244
+ readonly remoteindex_num_docs: (a: number) => number;
245
+ readonly remoteindex_num_segments: (a: number) => number;
246
+ readonly remoteindex_reset_network_stats: (a: number) => void;
247
+ readonly remoteindex_save_cache_to_idb: (a: number) => any;
248
+ readonly remoteindex_search: (a: number, b: number, c: number, d: number) => any;
249
+ readonly remoteindex_with_cache_size: (a: number, b: number, c: number) => number;
250
+ readonly __wbg_indexregistry_free: (a: number, b: number) => void;
251
+ readonly indexregistry_add_remote: (a: number, b: number, c: number, d: number, e: number) => any;
252
+ readonly indexregistry_list: (a: number) => any;
253
+ readonly indexregistry_new: () => number;
254
+ readonly indexregistry_remove: (a: number, b: number, c: number) => void;
255
+ readonly indexregistry_search: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
256
+ readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
257
+ readonly rust_zstd_wasm_shim_free: (a: number) => void;
258
+ readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
259
+ readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
260
+ readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
261
+ readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
262
+ readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
263
+ readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
264
+ readonly wasm_bindgen__closure__destroy__h179e3bd1e5f7737b: (a: number, b: number) => void;
265
+ readonly wasm_bindgen__closure__destroy__h1350f7c666e1bbd4: (a: number, b: number) => void;
266
+ readonly wasm_bindgen__closure__destroy__h5abbeebb46a4841f: (a: number, b: number) => void;
267
+ readonly wasm_bindgen__convert__closures_____invoke__hb9974b33ecb02c45: (a: number, b: number, c: any, d: any) => void;
268
+ readonly wasm_bindgen__convert__closures_____invoke__h0a76af665a0b0a4a: (a: number, b: number, c: any) => void;
269
+ readonly wasm_bindgen__convert__closures_____invoke__h92271f2d5d02a5fa: (a: number, b: number, c: any) => void;
270
+ readonly wasm_bindgen__convert__closures_____invoke__h12264eefbd788797: (a: number, b: number) => void;
271
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
272
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
273
+ readonly __wbindgen_exn_store: (a: number) => void;
274
+ readonly __externref_table_alloc: () => number;
275
+ readonly __wbindgen_externrefs: WebAssembly.Table;
276
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
277
+ readonly __externref_table_dealloc: (a: number) => void;
278
+ readonly __wbindgen_start: () => void;
267
279
  }
268
280
 
269
281
  export type SyncInitInput = BufferSource | WebAssembly.Module;
270
282
 
271
283
  /**
272
- * Instantiates the given `module`, which can either be bytes or
273
- * a precompiled `WebAssembly.Module`.
274
- *
275
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
276
- *
277
- * @returns {InitOutput}
278
- */
284
+ * Instantiates the given `module`, which can either be bytes or
285
+ * a precompiled `WebAssembly.Module`.
286
+ *
287
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
288
+ *
289
+ * @returns {InitOutput}
290
+ */
279
291
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
280
292
 
281
293
  /**
282
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
283
- * for everything else, calls `WebAssembly.instantiate` directly.
284
- *
285
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
286
- *
287
- * @returns {Promise<InitOutput>}
288
- */
294
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
295
+ * for everything else, calls `WebAssembly.instantiate` directly.
296
+ *
297
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
298
+ *
299
+ * @returns {Promise<InitOutput>}
300
+ */
289
301
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;