hermes-wasm 0.1.0

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.
@@ -0,0 +1,289 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ 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>;
24
+ }
25
+
26
+ 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;
94
+ }
95
+
96
+ 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;
186
+ }
187
+
188
+ /**
189
+ * Initialize panic hook and logging
190
+ */
191
+ export function init(): void;
192
+
193
+ /**
194
+ * Setup logging to browser console (can be called explicitly)
195
+ */
196
+ export function setup_logging(): void;
197
+
198
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
199
+
200
+ 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__hf0ae6e1302402218: (a: number, b: number, c: any) => void;
253
+ readonly wasm_bindgen__closure__destroy__he02095c7bca1c472: (a: number, b: number) => void;
254
+ readonly wasm_bindgen__convert__closures_____invoke__he0fab6886ed0c11a: (a: number, b: number, c: any) => void;
255
+ readonly wasm_bindgen__closure__destroy__h3d8374674b985d9e: (a: number, b: number) => void;
256
+ readonly wasm_bindgen__convert__closures_____invoke__hb63c839732b74d13: (a: number, b: number) => void;
257
+ readonly wasm_bindgen__closure__destroy__h1bff8044f851153e: (a: number, b: number) => void;
258
+ readonly wasm_bindgen__convert__closures_____invoke__h24eb9da7cece06fa: (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;
267
+ }
268
+
269
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
270
+
271
+ /**
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
+ */
279
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
280
+
281
+ /**
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
+ */
289
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;