@blaze-cache/core 0.3.0 → 0.4.0-beta.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,424 @@
1
+ /**
2
+ * The mutation events a subscription listens to — exactly the eight the cache raises for a
3
+ * change.
4
+ *
5
+ * `hit`/`miss` are deliberately absent: they are reads, and a lookup must never wake a
6
+ * subscriber. Registering them as **typed** listeners (rather than the wildcard) is what
7
+ * keeps the read path out of the layer entirely.
8
+ */
9
+ const CHANGE_TYPES = [
10
+ 'set',
11
+ 'delete',
12
+ 'touch',
13
+ 'evict',
14
+ 'expire',
15
+ 'invalidate',
16
+ 'prune',
17
+ 'clear',
18
+ ];
19
+ /**
20
+ * The opt-in reactivity layer behind {@link BlazeCache.subscribe} / `subscribeTag` /
21
+ * `subscribeMany`.
22
+ *
23
+ * ## Design
24
+ *
25
+ * Nothing here runs until the first `subscribe` call. That call attaches the layer to the
26
+ * event bus — eight **typed** listeners, one per change type — and snapshots the live keys
27
+ * so `clear` (which names nothing) can still be reported precisely. From then on every
28
+ * mutation is dispatched twice over: the mirrors first, so a subscriber always observes a
29
+ * cache the layer already agrees with, and the subscribers second.
30
+ *
31
+ * Two mirrors, both dropped the moment the last subscription stops:
32
+ *
33
+ * * `#live` — the live keys, kept in step by the events themselves (a `set` adds, a
34
+ * removal deletes, `clear` empties). It is what proves a key was present when `clear`
35
+ * hit, so a subscription for an absent key is never woken by one.
36
+ * * `#tagged` — per *watched* tag, the live keys carrying it, hydrated straight from
37
+ * {@link BlazeCache.keysWithTag} the first time somebody subscribes to that tag. Removal
38
+ * events carry no tags, so this is what attributes a `delete`/`evict`/`expire`/
39
+ * `invalidate`/`prune`/`clear` to the tag subscriptions it concerns — without it the
40
+ * layer would have to guess, or poll the cache.
41
+ *
42
+ * The cost of a subscription is therefore bounded and paid only while one exists: one
43
+ * `keys()` crossing at attach, one `keysWithTag()` per watched tag, one `tagsOf()` per
44
+ * write *only while a tag subscription is live*, and a `peek()` per change to a key
45
+ * somebody actually subscribed to. With no subscription the layer does not exist and the
46
+ * hot path is untouched.
47
+ *
48
+ * Delivery mirrors the event bus: a snapshot of the subscriber set is taken before each
49
+ * notification and membership re-checked per subscriber, so one that unsubscribes mid-event
50
+ * — by its own handle, or because a `{ once: true }` sibling fired — is never visited for
51
+ * that event. A subscriber that throws is isolated with `console.error`; the mutation it
52
+ * was told about stands and the remaining subscribers still run.
53
+ */
54
+ export class CacheSubscriptions {
55
+ #cache;
56
+ /** `subscribe` / `subscribeMany` registrations, indexed by each key they watch. */
57
+ #byKey = new Map();
58
+ /** `subscribeTag` registrations, indexed by tag. */
59
+ #byTag = new Map();
60
+ /** Watched tag → the live keys carrying it. Empty (and rebuilt) while nobody watches. */
61
+ #tagged = new Map();
62
+ /** Live keys while attached — the proof `clear` needs. `undefined` once detached. */
63
+ #live;
64
+ /** Unsubscribe handles for the eight bus listeners currently registered. */
65
+ #detachers = [];
66
+ /** Active registrations; reaching zero detaches the layer from the bus. */
67
+ #count = 0;
68
+ constructor(cache) {
69
+ this.#cache = cache;
70
+ }
71
+ // ------------------------------------------------------------- subscribe
72
+ /**
73
+ * Watches one key. The listener receives the key's **current** value — `undefined` once
74
+ * the change removed it or it expired — plus the mutation that woke it.
75
+ */
76
+ subscribe(key, listener, options) {
77
+ const sub = {
78
+ keys: [key],
79
+ once: options?.once === true,
80
+ active: true,
81
+ invoke: (_key, value, change) => listener(value, change),
82
+ };
83
+ return this.#addKey(sub);
84
+ }
85
+ /**
86
+ * Watches several keys with one listener, which is told *which* key changed. Duplicates
87
+ * collapse, and an empty list subscribes to nothing — it never attaches and returns a
88
+ * no-op handle.
89
+ */
90
+ subscribeMany(keys, listener, options) {
91
+ const unique = [...new Set(keys)];
92
+ if (unique.length === 0)
93
+ return () => { };
94
+ const sub = {
95
+ keys: unique,
96
+ once: options?.once === true,
97
+ active: true,
98
+ invoke: (key, value, change) => listener(key, value, change),
99
+ };
100
+ return this.#addKey(sub);
101
+ }
102
+ /**
103
+ * Watches one tag. The listener is told which of that tag's keys the mutation touched —
104
+ * a write reports the key that entered or stayed in the tag, a removal reports the keys
105
+ * that left it — and what the mutation was.
106
+ */
107
+ subscribeTag(tag, listener, options) {
108
+ this.#attach();
109
+ // First watcher of this tag: its key set comes straight from the cache, so the mirror
110
+ // starts out exactly as wide as the tag actually is.
111
+ if (!this.#tagged.has(tag))
112
+ this.#tagged.set(tag, new Set(this.#cache.keysWithTag(tag)));
113
+ const sub = {
114
+ tag,
115
+ once: options?.once === true,
116
+ active: true,
117
+ invoke: listener,
118
+ };
119
+ let set = this.#byTag.get(tag);
120
+ if (set === undefined) {
121
+ set = new Set();
122
+ this.#byTag.set(tag, set);
123
+ }
124
+ set.add(sub);
125
+ this.#count += 1;
126
+ return () => this.#stopTag(sub);
127
+ }
128
+ // ---------------------------------------------------------- unsubscribe
129
+ /** Re-registers the eight bus listeners after `cache.off()` dropped them. See `rebind`. */
130
+ rebind() {
131
+ if (this.#count === 0)
132
+ return;
133
+ this.#unbind();
134
+ this.#attach();
135
+ }
136
+ /** Drops every subscription and detaches from the bus — `BlazeCache.dispose` calls this. */
137
+ dispose() {
138
+ this.#detach();
139
+ }
140
+ // ------------------------------------------------------------- internals
141
+ #addKey(sub) {
142
+ this.#attach();
143
+ for (const key of sub.keys) {
144
+ let set = this.#byKey.get(key);
145
+ if (set === undefined) {
146
+ set = new Set();
147
+ this.#byKey.set(key, set);
148
+ }
149
+ set.add(sub);
150
+ }
151
+ this.#count += 1;
152
+ return () => this.#stopKey(sub);
153
+ }
154
+ /** Idempotent: a handle released twice — or already consumed by `once` — costs nothing. */
155
+ #stopKey(sub) {
156
+ if (!sub.active)
157
+ return;
158
+ sub.active = false;
159
+ for (const key of sub.keys) {
160
+ const set = this.#byKey.get(key);
161
+ if (set === undefined)
162
+ continue;
163
+ set.delete(sub);
164
+ if (set.size === 0)
165
+ this.#byKey.delete(key);
166
+ }
167
+ this.#count -= 1;
168
+ this.#maybeDetach();
169
+ }
170
+ #stopTag(sub) {
171
+ if (!sub.active)
172
+ return;
173
+ sub.active = false;
174
+ const set = this.#byTag.get(sub.tag);
175
+ if (set !== undefined) {
176
+ set.delete(sub);
177
+ if (set.size === 0) {
178
+ this.#byTag.delete(sub.tag);
179
+ // Last watcher of this tag out — stop mirroring its keys (and rebuild the mirror
180
+ // fresh from the cache should anybody subscribe to the tag again).
181
+ this.#tagged.delete(sub.tag);
182
+ }
183
+ }
184
+ this.#count -= 1;
185
+ this.#maybeDetach();
186
+ }
187
+ #maybeDetach() {
188
+ if (this.#count > 0)
189
+ return;
190
+ this.#detach();
191
+ }
192
+ /**
193
+ * Attaches to the bus: snapshots the live keys, rebuilds the per-tag mirrors and
194
+ * registers the eight change listeners. Idempotent — a second call (from `rebind`, or
195
+ * from a later `subscribe` after everything stopped) only runs once the handles are gone.
196
+ */
197
+ #attach() {
198
+ if (this.#detachers.length > 0)
199
+ return;
200
+ this.#live = new Set(this.#cache.keys());
201
+ for (const tag of this.#byTag.keys()) {
202
+ this.#tagged.set(tag, new Set(this.#cache.keysWithTag(tag)));
203
+ }
204
+ for (const type of CHANGE_TYPES) {
205
+ this.#detachers.push(this.#cache.on(type, (event) => this.#dispatch(event)));
206
+ }
207
+ }
208
+ /** Releases the bus listeners and the mirrors — the subscriptions themselves survive. */
209
+ #unbind() {
210
+ for (const unbind of this.#detachers.splice(0))
211
+ unbind();
212
+ this.#live = undefined;
213
+ this.#tagged.clear();
214
+ }
215
+ /** Full teardown: release everything *and* deactivate every outstanding handle. */
216
+ #detach() {
217
+ this.#unbind();
218
+ for (const set of this.#byKey.values())
219
+ for (const sub of set)
220
+ sub.active = false;
221
+ for (const set of this.#byTag.values())
222
+ for (const sub of set)
223
+ sub.active = false;
224
+ this.#byKey.clear();
225
+ this.#byTag.clear();
226
+ this.#count = 0;
227
+ }
228
+ // -------------------------------------------------------------- dispatch
229
+ /** One bus event → mirrors first, then the subscribers it concerns. */
230
+ #dispatch(change) {
231
+ switch (change.type) {
232
+ case 'set':
233
+ case 'touch':
234
+ case 'delete':
235
+ case 'evict':
236
+ case 'expire':
237
+ this.#dispatchKey(change);
238
+ break;
239
+ case 'invalidate':
240
+ case 'prune':
241
+ this.#dispatchKeys(change.keys, change);
242
+ break;
243
+ case 'clear':
244
+ this.#dispatchClear(change);
245
+ break;
246
+ }
247
+ }
248
+ #dispatchKey(change) {
249
+ const live = this.#live;
250
+ // Detached while this event was already in flight — every handle is dead, so there is
251
+ // nothing left to wake.
252
+ if (live === undefined)
253
+ return;
254
+ const key = change.key;
255
+ // Mirrors first: by the time a subscriber runs, the layer agrees with the cache.
256
+ let tags;
257
+ switch (change.type) {
258
+ case 'set':
259
+ live.add(key);
260
+ tags = this.#retag(key); // membership may have changed in either direction
261
+ break;
262
+ case 'touch':
263
+ live.add(key); // a touch only ever succeeds on a live entry
264
+ tags = this.#holding(key); // membership is unchanged — just who holds it
265
+ break;
266
+ default: // delete | evict | expire — the entry is gone
267
+ live.delete(key);
268
+ tags = this.#untag(key);
269
+ break;
270
+ }
271
+ const set = this.#byKey.get(key);
272
+ if (set !== undefined) {
273
+ // `set`/`touch` happen to a live entry, so read the value back; every other mutation
274
+ // removed it, and `undefined` is the truth — no crossing needed to say so. For
275
+ // `evict`/`expire` the dropped reference is still on `change.value`.
276
+ const removing = change.type !== 'set' && change.type !== 'touch';
277
+ this.#notifyKey(set, key, removing ? undefined : this.#cache.peek(key), change);
278
+ }
279
+ if (tags !== undefined)
280
+ for (const tag of tags)
281
+ this.#notifyTag(tag, [key], change);
282
+ }
283
+ #dispatchKeys(keys, change) {
284
+ const live = this.#live;
285
+ if (live === undefined)
286
+ return;
287
+ const tags = this.#tagged.size > 0 ? new Map() : undefined;
288
+ // Mirrors first.
289
+ for (const key of keys) {
290
+ live.delete(key);
291
+ if (tags === undefined)
292
+ continue;
293
+ for (const [tag, held] of this.#tagged) {
294
+ if (!held.delete(key))
295
+ continue;
296
+ const list = tags.get(tag);
297
+ if (list === undefined)
298
+ tags.set(tag, [key]);
299
+ else
300
+ list.push(key);
301
+ }
302
+ }
303
+ // Then the subscribers. The event itself lists exactly what was removed, so no mirror
304
+ // is consulted to decide *who* to wake — only to decide which tags those keys left.
305
+ for (const key of keys) {
306
+ const set = this.#byKey.get(key);
307
+ if (set !== undefined)
308
+ this.#notifyKey(set, key, undefined, change);
309
+ }
310
+ if (tags !== undefined)
311
+ for (const [tag, list] of tags)
312
+ this.#notifyTag(tag, list, change);
313
+ }
314
+ #dispatchClear(change) {
315
+ const live = this.#live;
316
+ if (live === undefined)
317
+ return;
318
+ // A `clear` payload names nothing, so the mirrors are the only proof of what was
319
+ // there: a subscription for a key the cache never held stays silent.
320
+ const keys = [];
321
+ for (const key of this.#byKey.keys())
322
+ if (live.has(key))
323
+ keys.push(key);
324
+ const tags = new Map();
325
+ for (const [tag, held] of this.#tagged)
326
+ if (held.size > 0)
327
+ tags.set(tag, [...held]);
328
+ // Mirrors first.
329
+ live.clear();
330
+ for (const held of this.#tagged.values())
331
+ held.clear();
332
+ // Then the subscribers.
333
+ for (const key of keys) {
334
+ const set = this.#byKey.get(key);
335
+ if (set !== undefined)
336
+ this.#notifyKey(set, key, undefined, change);
337
+ }
338
+ for (const [tag, list] of tags)
339
+ this.#notifyTag(tag, list, change);
340
+ }
341
+ // --------------------------------------------------------------- mirrors
342
+ /**
343
+ * Re-reads `key`'s tags after a write and settles the watched tags against them,
344
+ * returning every watched tag that holds it now **or** did a moment ago — a write can
345
+ * move a key into a tag, out of one, or both at once.
346
+ */
347
+ #retag(key) {
348
+ if (this.#tagged.size === 0)
349
+ return undefined;
350
+ const next = this.#cache.tagsOf(key);
351
+ const hits = [];
352
+ for (const [tag, held] of this.#tagged) {
353
+ const wasIn = held.has(key);
354
+ const isIn = next.includes(tag);
355
+ if (isIn)
356
+ held.add(key);
357
+ else
358
+ held.delete(key);
359
+ if (wasIn || isIn)
360
+ hits.push(tag);
361
+ }
362
+ return hits;
363
+ }
364
+ /** The watched tags currently holding `key`, mirror untouched. */
365
+ #holding(key) {
366
+ if (this.#tagged.size === 0)
367
+ return undefined;
368
+ const hits = [];
369
+ for (const [tag, held] of this.#tagged)
370
+ if (held.has(key))
371
+ hits.push(tag);
372
+ return hits;
373
+ }
374
+ /** Drops `key` from every watched tag, returning the tags it just left. */
375
+ #untag(key) {
376
+ if (this.#tagged.size === 0)
377
+ return undefined;
378
+ const hits = [];
379
+ for (const [tag, held] of this.#tagged)
380
+ if (held.delete(key))
381
+ hits.push(tag);
382
+ return hits;
383
+ }
384
+ // -------------------------------------------------------------- deliver
385
+ #notifyKey(set, key, value, change) {
386
+ // Snapshot + membership check, exactly like the event bus: a subscriber that stops
387
+ // mid-event (its own handle, or a `{ once: true }` sibling) is never visited for it,
388
+ // and one added mid-event only hears the next change.
389
+ for (const sub of [...set]) {
390
+ if (!sub.active || !set.has(sub))
391
+ continue;
392
+ if (sub.once)
393
+ this.#stopKey(sub); // detach before invoking, like `once` on the bus
394
+ this.#call(() => sub.invoke(key, value, change));
395
+ }
396
+ }
397
+ #notifyTag(tag, keys, change) {
398
+ const set = this.#byTag.get(tag);
399
+ if (set === undefined || set.size === 0)
400
+ return;
401
+ // One shared payload for every subscriber of this tag — the bus hands the same event
402
+ // object to all of its listeners too.
403
+ const info = { tag, keys, change };
404
+ for (const sub of [...set]) {
405
+ if (!sub.active || !set.has(sub))
406
+ continue;
407
+ if (sub.once)
408
+ this.#stopTag(sub);
409
+ this.#call(() => sub.invoke(info));
410
+ }
411
+ }
412
+ /** Runs one subscriber, isolating its failure from every other subscriber. */
413
+ #call(run) {
414
+ try {
415
+ run();
416
+ }
417
+ catch (error) {
418
+ // The mutation already happened — a bad subscriber must not abort its siblings or
419
+ // surface out of a successful `set`.
420
+ console.error('[blaze-cache] subscription listener failed — the other subscribers still run.', error);
421
+ }
422
+ }
423
+ }
424
+ //# sourceMappingURL=reactivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactivity.js","sourceRoot":"","sources":["../src/reactivity.ts"],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Ac,EAAE,MAAwB;QAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO;QAChD,qFAAqF;QACrF,sCAAsC;QACtC,MAAM,IAAI,GAAsB,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACtD,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC3C,IAAI,GAAG,CAAC,IAAI;gBAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,8EAA8E;IAC9E,KAAK,CAAC,GAAe;QACnB,IAAI,CAAC;YACH,GAAG,EAAE,CAAC;QACR,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,kFAAkF;YAClF,qCAAqC;YACrC,OAAO,CAAC,KAAK,CACX,+EAA+E,EAC/E,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -186,6 +186,47 @@ export type CacheEventListener<V = any, K extends CacheEventType = CacheEventTyp
186
186
  * {@link CacheEventListener}) before reading fields shared by mutation events only.
187
187
  */
188
188
  export type CacheListener = (change: CacheChange) => void;
189
+ /**
190
+ * The mutation a subscription reports — the event union minus the read events
191
+ * (`hit`/`miss`), so a subscriber only ever wakes for something that actually changed the
192
+ * cache.
193
+ *
194
+ * `evict`/`expire` carry the dropped entry's live reference (exactly what `get` would have
195
+ * returned a moment earlier); every other member is the very object the event system emits.
196
+ */
197
+ export type CacheMutation<V = any> = CacheEventMap<V>[Exclude<CacheEventType, 'hit' | 'miss'>];
198
+ /**
199
+ * What a {@link BlazeCache.subscribeTag} listener receives: which tag woke it, which of its
200
+ * keys the mutation touched, and the mutation itself.
201
+ */
202
+ export interface CacheTagChange<V = any> {
203
+ /** The tag that was subscribed to. */
204
+ tag: string;
205
+ /** The keys that carried `tag` and were hit by `change` — never empty. */
206
+ keys: string[];
207
+ /** What happened; narrow on `change.type` for the per-mutation fields. */
208
+ change: CacheMutation<V>;
209
+ }
210
+ /**
211
+ * A {@link BlazeCache.subscribe} listener: the key's current value, then what changed it.
212
+ *
213
+ * `value` is `undefined` once the change removed the entry (or it expired) — the event
214
+ * that removed it is the second argument, and for `evict`/`expire` its `value` field still
215
+ * holds the dropped reference.
216
+ */
217
+ export type CacheKeySubscriber<V = any> = (value: V | undefined, change: CacheMutation<V>) => void;
218
+ /** A {@link BlazeCache.subscribeMany} listener: which key, its value, then what changed. */
219
+ export type CacheManySubscriber<V = any> = (key: string, value: V | undefined, change: CacheMutation<V>) => void;
220
+ /** A {@link BlazeCache.subscribeTag} listener. */
221
+ export type CacheTagSubscriber<V = any> = (info: CacheTagChange<V>) => void;
222
+ /** Options shared by `subscribe` / `subscribeMany` / `subscribeTag`. */
223
+ export interface CacheSubscribeOptions {
224
+ /**
225
+ * Fire at most once and then unsubscribe automatically — the handle the call returns
226
+ * simply becomes a no-op, exactly like {@link BlazeCache.once}.
227
+ */
228
+ once?: boolean;
229
+ }
189
230
  /**
190
231
  * The structural contract the Axios adapter and the React Query integration program against.
191
232
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,MA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version": "0.3.0",
3
+ "version": "0.4.0-beta.0",
4
4
  "description": "WebAssembly client-side cache for the browser: SIEVE eviction, per-entry TTLs, tag invalidation and optional IndexedDB persistence",
5
5
  "keywords": [
6
6
  "cache",
@@ -154,7 +154,7 @@ export class BlazeCache {
154
154
  * clamped rather than trusted: a non-monotonic or out-of-range pair yields no tags
155
155
  * for that entry instead of panicking and trapping the wasm instance.
156
156
  */
157
- setMany(keys: string[], values: any, ttl_ms: Float64Array, tags_flat: string[], tag_offsets: Uint32Array): void;
157
+ setMany(keys: string[], values: any, ttl_ms: Float64Array | number[], tags_flat: string[], tag_offsets: Uint32Array | number[]): void;
158
158
  /**
159
159
  * [`set`](Self::set) with a pre-encoded key and **no tags** — the untagged write fast
160
160
  * path. Untagged writes skip the `Vec<String>` boundary crossing entirely; use
@@ -236,13 +236,13 @@ export interface InitOutput {
236
236
  readonly blazecache_delete: (a: number, b: number, c: number) => number;
237
237
  readonly blazecache_deleteMany: (a: number, b: number, c: number, d: number) => void;
238
238
  readonly blazecache_deleteRaw: (a: number, b: number, c: number) => number;
239
- readonly blazecache_drainDrops: (a: number) => number;
239
+ readonly blazecache_drainDrops: (a: number) => any;
240
240
  readonly blazecache_dropTracking: (a: number) => number;
241
- readonly blazecache_entries: (a: number) => number;
242
- readonly blazecache_entry: (a: number, b: number, c: number) => number;
243
- readonly blazecache_get: (a: number, b: number, c: number) => number;
241
+ readonly blazecache_entries: (a: number) => any;
242
+ readonly blazecache_entry: (a: number, b: number, c: number) => any;
243
+ readonly blazecache_get: (a: number, b: number, c: number) => any;
244
244
  readonly blazecache_getMany: (a: number, b: number, c: number, d: number) => void;
245
- readonly blazecache_getRaw: (a: number, b: number, c: number) => number;
245
+ readonly blazecache_getRaw: (a: number, b: number, c: number) => any;
246
246
  readonly blazecache_has: (a: number, b: number, c: number) => number;
247
247
  readonly blazecache_hasMany: (a: number, b: number, c: number, d: number) => void;
248
248
  readonly blazecache_hasTag: (a: number, b: number, c: number, d: number, e: number) => number;
@@ -250,13 +250,13 @@ export interface InitOutput {
250
250
  readonly blazecache_keys: (a: number, b: number) => void;
251
251
  readonly blazecache_keysWithTag: (a: number, b: number, c: number, d: number) => void;
252
252
  readonly blazecache_new: (a: number) => number;
253
- readonly blazecache_peek: (a: number, b: number, c: number) => number;
253
+ readonly blazecache_peek: (a: number, b: number, c: number) => any;
254
254
  readonly blazecache_prune: (a: number, b: number) => void;
255
255
  readonly blazecache_resetStats: (a: number) => void;
256
- readonly blazecache_set: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
256
+ readonly blazecache_set: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number) => void;
257
257
  readonly blazecache_setDropTracking: (a: number, b: number) => void;
258
- readonly blazecache_setMany: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
259
- readonly blazecache_setRaw: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
258
+ readonly blazecache_setMany: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number, i: number, j: number) => void;
259
+ readonly blazecache_setRaw: (a: number, b: number, c: number, d: any, e: number, f: number) => void;
260
260
  readonly blazecache_size: (a: number) => number;
261
261
  readonly blazecache_stats: (a: number, b: number) => void;
262
262
  readonly blazecache_tagsOf: (a: number, b: number, c: number, d: number) => void;
@@ -268,7 +268,12 @@ export interface InitOutput {
268
268
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
269
269
  readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
270
270
  readonly __wbindgen_export4: (a: number) => void;
271
+ readonly __wbindgen_export5: () => number;
272
+ readonly __wbindgen_externrefs: WebAssembly.Table;
271
273
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
274
+ readonly __wbindgen_export6: (a: number, b: number) => void;
275
+ readonly __wbindgen_export7: (a: number) => void;
276
+ readonly __wbindgen_start: () => void;
272
277
  }
273
278
 
274
279
  export type SyncInitInput = BufferSource | WebAssembly.Module;