@blaze-cache/core 0.2.0-beta → 0.2.1-beta

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/README.md CHANGED
@@ -15,9 +15,12 @@ also usable on its own.
15
15
  ## Install
16
16
 
17
17
  ```sh
18
- npm install @blaze-cache/core
18
+ npm install @blaze-cache/core@beta
19
19
  ```
20
20
 
21
+ `@beta` is npm's dist-tag for the prerelease; drop it to install the last stable
22
+ release.
23
+
21
24
  ## Quick start
22
25
 
23
26
  ```ts
@@ -51,8 +54,17 @@ cache.stats(); // { hits, misses, evictions, expirations,
51
54
 
52
55
  * **Types are bundled** — no `@types/*` packages to install.
53
56
  * **ESM only, browser only.** Node/SSR targets are out of scope by design.
57
+ * **Values are shared by reference** — `set` hands the object over and `get`/`peek`/
58
+ `entry` hand the same object back, so mutating it rewrites the cache (and, after the
59
+ next flush, the persisted row). Clone on the way out if you need to edit: the sharing
60
+ is what keeps `get`/`set` allocation-free.
54
61
  * **Persistence is optional** and off by default; a blocked IndexedDB (private mode)
55
- degrades to memory-only instead of breaking the app.
62
+ degrades to memory-only instead of breaking the app. A flush that fails later — a quota
63
+ error, a transient IndexedDB problem — is logged and its records go straight back on
64
+ the queue for the next flush, rather than being dropped.
65
+ * **`capacity` is normalised** — below `1` clamps up, above `1_000_000` clamps down, and
66
+ a non-finite value falls back to the wasm default — so `capacity()` reports a real
67
+ number back.
56
68
 
57
69
  ## Documentation
58
70
 
package/dist/cache.d.ts CHANGED
@@ -22,7 +22,14 @@ export interface IndexedDbPersistenceOptions extends IndexedDbOptions {
22
22
  }
23
23
  /** Options accepted by {@link BlazeCache.create}. */
24
24
  export interface BlazeCacheOptions {
25
- /** Maximum number of entries kept in memory (clamped to `>= 1`). Default {@link DEFAULT_CAPACITY}. */
25
+ /**
26
+ * Maximum number of entries kept in memory. The wasm binding normalises it before it is
27
+ * ever used: below `1` clamps up, above `1_000_000` clamps down, and a non-finite value
28
+ * (`NaN`, `Infinity`) falls back to the wasm default of 1024. Pass a value inside that
29
+ * range to be sure of what {@link BlazeCache.capacity} reports back.
30
+ *
31
+ * Default {@link DEFAULT_CAPACITY}.
32
+ */
26
33
  capacity?: number;
27
34
  /**
28
35
  * Durable storage. `false`/omitted means memory only.
@@ -55,6 +62,32 @@ export interface BlazeCacheOptions {
55
62
  * await cache.dispose();
56
63
  * ```
57
64
  *
65
+ * ### Value ownership
66
+ *
67
+ * Values are held — and handed back — **by reference**. The object you pass to
68
+ * {@link BlazeCache.set} is the very object {@link BlazeCache.get}, {@link BlazeCache.peek},
69
+ * {@link BlazeCache.entry} and {@link BlazeCache.entries} return later: mutating either one
70
+ * silently rewrites the cache — and, after the next flush, the persisted row — with no error
71
+ * and no warning. Treat values living in the cache as read-only: clone on the way *out*
72
+ * (`structuredClone(cache.get(key))`) before editing, or clone on the way *in* if you want
73
+ * to keep mutating your own copy. The sharing is deliberate, not an oversight — the Rust
74
+ * core promises allocation-free `get`/`set` precisely *because* values are never cloned or
75
+ * serialised on the hot path, and cloning on read would only close one half of the alias
76
+ * anyway (your original reference from `set` survives either way). The contract is
77
+ * ownership transfer, not deep-copy semantics.
78
+ *
79
+ * ### Multiple tabs
80
+ *
81
+ * Tabs share one IndexedDB namespace but nothing else: each one holds its own WebAssembly
82
+ * instance, hydrated once at startup, and each flushes the keys it wrote. There is no
83
+ * coordination between them — writes are last-writer-wins per key. For ordinary use that is
84
+ * what you want (the tab in the foreground refetches on focus and rewrites its own fresh
85
+ * copy), but a tab that keeps working while hidden — a timer, a background sync — can flush
86
+ * a value older than the one the focused tab just wrote, and after a reload that older
87
+ * value is what hydration paints until revalidation corrects it. If that matters, use a
88
+ * short `ttlMs` on records written from background tabs, or filter on a timestamp you store
89
+ * inside the value itself.
90
+ *
58
91
  * All reads and writes are synchronous — the wasm module is instantiated during `create`, so
59
92
  * the hot path never touches a `Promise`.
60
93
  */
@@ -68,14 +101,20 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
68
101
  * console warning instead of rejecting.
69
102
  */
70
103
  static create<V = any>(options?: BlazeCacheOptions): Promise<BlazeCache<V>>;
71
- /** Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss. */
104
+ /**
105
+ * Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss.
106
+ *
107
+ * The value comes back as the cache's **live reference** — see *Value ownership* on the
108
+ * class before mutating it.
109
+ */
72
110
  get(key: string): V | undefined;
73
111
  /**
74
112
  * The same lookup as {@link BlazeCache.get}, minus every side effect: no hit or miss is
75
113
  * recorded, the entry is not marked used for eviction, and nothing is reclaimed.
76
114
  *
77
115
  * The read for "is this here?" questions — a UI check must not be able to move the hit
78
- * rate or decide who gets evicted next.
116
+ * rate or decide who gets evicted next. The value is still the cache's **live reference**,
117
+ * exactly like {@link BlazeCache.get}.
79
118
  */
80
119
  peek(key: string): V | undefined;
81
120
  /**
@@ -88,9 +127,15 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
88
127
  ttl(key: string): number | undefined;
89
128
  /** `true` when `key` is present and not expired. Never changes eviction state. */
90
129
  has(key: string): boolean;
91
- /** Live entry — value, remaining TTL and tags — without touching statistics. */
130
+ /**
131
+ * Live entry — value, remaining TTL and tags — without touching statistics. The `value`
132
+ * field is the cache's live reference — see *Value ownership* on the class.
133
+ */
92
134
  entry(key: string): CacheEntry<V> | undefined;
93
- /** Snapshot of every live entry, oldest first. */
135
+ /**
136
+ * Snapshot of every live entry, oldest first. The `value` fields are the cache's live
137
+ * references — see *Value ownership* on the class.
138
+ */
94
139
  entries(): CacheEntry<V>[];
95
140
  /** Live keys, oldest first. */
96
141
  keys(): string[];
@@ -111,7 +156,12 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
111
156
  capacity(): number;
112
157
  /** Cumulative counters plus a computed `hitRate`. */
113
158
  stats(): CacheStats;
114
- /** Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags. */
159
+ /**
160
+ * Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags.
161
+ *
162
+ * The value is stored **by reference** — the cache takes ownership for the lifetime of the
163
+ * entry, so mutating it afterwards rewrites the cache (see *Value ownership* on the class).
164
+ */
115
165
  set(key: string, value: V, options?: SetOptions): void;
116
166
  /**
117
167
  * Marks `key` as recently used for eviction and optionally renews its TTL — the stored
@@ -136,7 +186,9 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
136
186
  * Subscribes to mutations. Returns the unsubscribe function.
137
187
  *
138
188
  * Persistence uses this internally, so listeners fire for every change regardless of
139
- * whether storage is enabled.
189
+ * whether storage is enabled. A listener that throws is isolated: the failure is logged
190
+ * with `console.error`, the mutation it was told about stands, and the remaining listeners
191
+ * are still notified.
140
192
  */
141
193
  on(listener: CacheListener): () => void;
142
194
  /**
@@ -144,13 +196,20 @@ export declare class BlazeCache<V = any> implements BlazeCacheLike<V> {
144
196
  *
145
197
  * Resolves once the underlying transaction commits. Concurrent calls are serialised, so
146
198
  * this is safe to call from a `beforeunload` handler while a debounced flush is pending.
199
+ *
200
+ * When the write itself fails — quota, a blocked or transient IndexedDB error — the pass
201
+ * rejects **and hands every record it had claimed back onto the queue**, so the next flush
202
+ * (a later mutation's timer, an explicit call, `pagehide`, `dispose`) retries them instead
203
+ * of losing them.
147
204
  */
148
205
  flush(): Promise<void>;
149
206
  /**
150
207
  * Flushes, unbinds page-lifecycle listeners and frees the wasm memory.
151
208
  *
152
209
  * The cache is unusable afterwards. A failed flush still rejects — the caller may retry or
153
- * report it.
210
+ * report it — but teardown happens in a `finally`, so a storage outage can never leak the
211
+ * wasm instance, the timers or the `pagehide`/`visibilitychange` listeners behind a
212
+ * rejected promise.
154
213
  */
155
214
  dispose(): Promise<void>;
156
215
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,YAAY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rD,KAAK,IAAI,UAAU;IAQnB;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAQtD;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO;IAQnD,qDAAqD;IACrD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAM5B,8EAA8E;IAC9E,cAAc,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAS3C,+DAA+D;IAC/D,KAAK,IAAI,MAAM,EAAE;IAQjB,yBAAyB;IACzB,KAAK,IAAI,IAAI;IAKb,sEAAsE;IACtE,UAAU,IAAI,IAAI;IAMlB;;;;;;;OAOG;IACH,EAAE,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAOvC;;;;;;;;;;OAUG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IActB;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA2Q/B;AAED,+CAA+C;AAC/C,wBAAgB,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAExF"}
package/dist/cache.js CHANGED
@@ -30,6 +30,32 @@ const NO_TAGS = [];
30
30
  * await cache.dispose();
31
31
  * ```
32
32
  *
33
+ * ### Value ownership
34
+ *
35
+ * Values are held — and handed back — **by reference**. The object you pass to
36
+ * {@link BlazeCache.set} is the very object {@link BlazeCache.get}, {@link BlazeCache.peek},
37
+ * {@link BlazeCache.entry} and {@link BlazeCache.entries} return later: mutating either one
38
+ * silently rewrites the cache — and, after the next flush, the persisted row — with no error
39
+ * and no warning. Treat values living in the cache as read-only: clone on the way *out*
40
+ * (`structuredClone(cache.get(key))`) before editing, or clone on the way *in* if you want
41
+ * to keep mutating your own copy. The sharing is deliberate, not an oversight — the Rust
42
+ * core promises allocation-free `get`/`set` precisely *because* values are never cloned or
43
+ * serialised on the hot path, and cloning on read would only close one half of the alias
44
+ * anyway (your original reference from `set` survives either way). The contract is
45
+ * ownership transfer, not deep-copy semantics.
46
+ *
47
+ * ### Multiple tabs
48
+ *
49
+ * Tabs share one IndexedDB namespace but nothing else: each one holds its own WebAssembly
50
+ * instance, hydrated once at startup, and each flushes the keys it wrote. There is no
51
+ * coordination between them — writes are last-writer-wins per key. For ordinary use that is
52
+ * what you want (the tab in the foreground refetches on focus and rewrites its own fresh
53
+ * copy), but a tab that keeps working while hidden — a timer, a background sync — can flush
54
+ * a value older than the one the focused tab just wrote, and after a reload that older
55
+ * value is what hydration paints until revalidation corrects it. If that matters, use a
56
+ * short `ttlMs` on records written from background tabs, or filter on a timestamp you store
57
+ * inside the value itself.
58
+ *
33
59
  * All reads and writes are synchronous — the wasm module is instantiated during `create`, so
34
60
  * the hot path never touches a `Promise`.
35
61
  */
@@ -62,7 +88,12 @@ export class BlazeCache {
62
88
  return cache;
63
89
  }
64
90
  // ------------------------------------------------------------------ reads
65
- /** Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss. */
91
+ /**
92
+ * Value stored under `key`, or `undefined` when missing or expired. Counts a hit/miss.
93
+ *
94
+ * The value comes back as the cache's **live reference** — see *Value ownership* on the
95
+ * class before mutating it.
96
+ */
66
97
  get(key) {
67
98
  return this.#wasm.get(key);
68
99
  }
@@ -71,7 +102,8 @@ export class BlazeCache {
71
102
  * recorded, the entry is not marked used for eviction, and nothing is reclaimed.
72
103
  *
73
104
  * The read for "is this here?" questions — a UI check must not be able to move the hit
74
- * rate or decide who gets evicted next.
105
+ * rate or decide who gets evicted next. The value is still the cache's **live reference**,
106
+ * exactly like {@link BlazeCache.get}.
75
107
  */
76
108
  peek(key) {
77
109
  return this.#wasm.peek(key);
@@ -90,11 +122,17 @@ export class BlazeCache {
90
122
  has(key) {
91
123
  return this.#wasm.has(key);
92
124
  }
93
- /** Live entry — value, remaining TTL and tags — without touching statistics. */
125
+ /**
126
+ * Live entry — value, remaining TTL and tags — without touching statistics. The `value`
127
+ * field is the cache's live reference — see *Value ownership* on the class.
128
+ */
94
129
  entry(key) {
95
130
  return this.#wasm.entry(key);
96
131
  }
97
- /** Snapshot of every live entry, oldest first. */
132
+ /**
133
+ * Snapshot of every live entry, oldest first. The `value` fields are the cache's live
134
+ * references — see *Value ownership* on the class.
135
+ */
98
136
  entries() {
99
137
  return this.#wasm.entries();
100
138
  }
@@ -134,7 +172,12 @@ export class BlazeCache {
134
172
  return { ...base, hitRate: total === 0 ? 0 : base.hits / total };
135
173
  }
136
174
  // ----------------------------------------------------------------- writes
137
- /** Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags. */
175
+ /**
176
+ * Stores (or replaces) `key`. Replacing refreshes the TTL and replaces the tags.
177
+ *
178
+ * The value is stored **by reference** — the cache takes ownership for the lifetime of the
179
+ * entry, so mutating it afterwards rewrites the cache (see *Value ownership* on the class).
180
+ */
138
181
  set(key, value, options) {
139
182
  // No defensive copy of `tags`: the binding reads the array synchronously while building
140
183
  // the wasm call and never retains it, so the `readonly`→`string[]` cast below is safe.
@@ -199,7 +242,9 @@ export class BlazeCache {
199
242
  * Subscribes to mutations. Returns the unsubscribe function.
200
243
  *
201
244
  * Persistence uses this internally, so listeners fire for every change regardless of
202
- * whether storage is enabled.
245
+ * whether storage is enabled. A listener that throws is isolated: the failure is logged
246
+ * with `console.error`, the mutation it was told about stands, and the remaining listeners
247
+ * are still notified.
203
248
  */
204
249
  on(listener) {
205
250
  this.#listeners.add(listener);
@@ -212,6 +257,11 @@ export class BlazeCache {
212
257
  *
213
258
  * Resolves once the underlying transaction commits. Concurrent calls are serialised, so
214
259
  * this is safe to call from a `beforeunload` handler while a debounced flush is pending.
260
+ *
261
+ * When the write itself fails — quota, a blocked or transient IndexedDB error — the pass
262
+ * rejects **and hands every record it had claimed back onto the queue**, so the next flush
263
+ * (a later mutation's timer, an explicit call, `pagehide`, `dispose`) retries them instead
264
+ * of losing them.
215
265
  */
216
266
  flush() {
217
267
  if (this.#disposed)
@@ -228,23 +278,36 @@ export class BlazeCache {
228
278
  * Flushes, unbinds page-lifecycle listeners and frees the wasm memory.
229
279
  *
230
280
  * The cache is unusable afterwards. A failed flush still rejects — the caller may retry or
231
- * report it.
281
+ * report it — but teardown happens in a `finally`, so a storage outage can never leak the
282
+ * wasm instance, the timers or the `pagehide`/`visibilitychange` listeners behind a
283
+ * rejected promise.
232
284
  */
233
285
  async dispose() {
234
286
  if (this.#disposed)
235
287
  return;
236
- await this.flush();
237
- this.#disposed = true;
238
- if (this.#timer !== null) {
239
- clearTimeout(this.#timer);
240
- this.#timer = null;
288
+ try {
289
+ await this.flush();
290
+ }
291
+ finally {
292
+ this.#disposed = true;
293
+ if (this.#timer !== null) {
294
+ clearTimeout(this.#timer);
295
+ this.#timer = null;
296
+ }
297
+ for (const unbind of this.#unbind.splice(0))
298
+ unbind();
299
+ this.#listeners.clear();
300
+ try {
301
+ await this.#persist?.close?.();
302
+ }
303
+ catch (error) {
304
+ // Closing is best-effort (the IndexedDB adapter says as much): a failing adapter
305
+ // must neither break disposal nor mask the flush error this `finally` rethrows.
306
+ console.error('[blaze-cache] closing the persistence adapter failed.', error);
307
+ }
308
+ this.#persist = null;
309
+ this.#wasm.free();
241
310
  }
242
- for (const unbind of this.#unbind.splice(0))
243
- unbind();
244
- this.#listeners.clear();
245
- await this.#persist?.close?.();
246
- this.#persist = null;
247
- this.#wasm.free();
248
311
  }
249
312
  // ----------------------------------------------------------- persistence
250
313
  async #setupPersistence(spec) {
@@ -276,16 +339,55 @@ export class BlazeCache {
276
339
  }
277
340
  this.#bindPageLifecycle();
278
341
  }
279
- /** Fills the cache from storage, dropping records whose TTL elapsed while we were away. */
342
+ /**
343
+ * Fills the cache from storage, dropping records whose TTL elapsed while we were away —
344
+ * and records no well-formed write could ever have produced.
345
+ *
346
+ * `load()` hands back whatever sits on disk: an older package version, another tab or a
347
+ * flaky adapter may have left a row that no longer matches {@link PersistedRecord} — a
348
+ * missing key, `tags` that are not an array, a deadline that is not a number. One such row
349
+ * must cost exactly that row: every record is shape-checked (and its wasm `set` guarded)
350
+ * individually, so the remaining records still hydrate. The complaint is a single
351
+ * `console.warn` per run, not one per bad row.
352
+ */
280
353
  async #hydrate(adapter) {
281
354
  const records = await adapter.load();
282
355
  const now = Date.now();
356
+ let reported = false;
357
+ const skip = (reason, record, error) => {
358
+ if (reported)
359
+ return;
360
+ reported = true;
361
+ console.warn(`[blaze-cache] skipping malformed persisted record — ${reason}.`, record, ...(error === undefined ? [] : [error]));
362
+ };
283
363
  for (const record of records) {
284
- const remaining = record.ttlMs === null ? null : record.ttlMs - (now - record.storedAt);
285
- if (remaining !== null && remaining <= 0)
364
+ let reason = null;
365
+ if (typeof record?.key !== 'string') {
366
+ reason = 'key is missing or not a string';
367
+ }
368
+ else if (!Array.isArray(record.tags) || record.tags.some((tag) => typeof tag !== 'string')) {
369
+ reason = 'tags are not an array of strings';
370
+ }
371
+ else if (record.ttlMs !== null &&
372
+ (!Number.isFinite(record.ttlMs) || !Number.isFinite(record.storedAt))) {
373
+ // With a TTL present, both halves of the deadline must be real numbers — anything
374
+ // else yields a `NaN` that would masquerade as "never expires".
375
+ reason = 'ttl or storedAt is not a finite number';
376
+ }
377
+ if (reason !== null) {
378
+ skip(reason, record);
286
379
  continue;
287
- // Direct wasm call: hydration is not a user write, so it emits no change event.
288
- this.#wasm.set(record.key, record.value, remaining, record.tags);
380
+ }
381
+ try {
382
+ const remaining = record.ttlMs === null ? null : record.ttlMs - (now - record.storedAt);
383
+ if (remaining !== null && remaining <= 0)
384
+ continue;
385
+ // Direct wasm call: hydration is not a user write, so it emits no change event.
386
+ this.#wasm.set(record.key, record.value, remaining, record.tags);
387
+ }
388
+ catch (error) {
389
+ skip('the wasm core refused the write', record, error);
390
+ }
289
391
  }
290
392
  }
291
393
  #bindPageLifecycle() {
@@ -322,34 +424,82 @@ export class BlazeCache {
322
424
  if (!persist || this.#disposed)
323
425
  return;
324
426
  // Take ownership of the pending work up front, so a `set` racing with the awaits below
325
- // lands in the *next* pass instead of being written twice.
427
+ // lands in the *next* pass instead of being written twice. The claimed records stay in
428
+ // these locals for the whole pass: if the adapter rejects — quota, a transient
429
+ // IndexedDB failure — the catch below hands every one of them back to the queues, so a
430
+ // failed flush delays work rather than destroying it. Single-flight still holds: this
431
+ // run is chained on `#chain`, and the next `flush()` chains onto *our* settled promise,
432
+ // requeued work included.
326
433
  const clearAll = this.#clearAll;
327
434
  const deleted = [...this.#deleted];
328
435
  const dirty = [...this.#dirty].filter((key) => !this.#deleted.has(key));
329
436
  this.#clearAll = false;
330
437
  this.#dirty.clear();
331
438
  this.#deleted.clear();
332
- if (clearAll)
333
- await persist.clear();
334
- if (dirty.length > 0) {
335
- const records = [];
336
- for (const key of dirty.slice(-this.#maxRecords)) {
337
- const entry = this.#wasm.entry(key);
338
- if (!entry)
339
- continue;
340
- records.push({
341
- key,
342
- value: entry.value,
343
- tags: entry.tags,
344
- ttlMs: entry.ttlMs,
345
- storedAt: Date.now(),
346
- });
439
+ let toRemove = deleted;
440
+ try {
441
+ if (clearAll)
442
+ await persist.clear();
443
+ if (dirty.length > 0) {
444
+ const records = [];
445
+ for (const key of dirty.slice(-this.#maxRecords)) {
446
+ const entry = this.#wasm.entry(key);
447
+ if (!entry)
448
+ continue;
449
+ records.push({
450
+ key,
451
+ value: entry.value,
452
+ tags: entry.tags,
453
+ ttlMs: entry.ttlMs,
454
+ storedAt: Date.now(),
455
+ });
456
+ }
457
+ if (records.length > 0)
458
+ await persist.save(records);
347
459
  }
348
- if (records.length > 0)
349
- await persist.save(records);
460
+ // Reconcile the rows the wasm core dropped on its own. A capacity eviction inside
461
+ // `set` and a lapsed TTL never emit a change event — nothing queued a delete for them
462
+ // — so without this diff their rows would outlive every flush, be re-hydrated at the
463
+ // next startup, and eat quota until a `QuotaExceededError` kills persistence outright.
464
+ // Any key storage still holds that the wasm core no longer lists is stale. Skipped
465
+ // after `clear()` (storage was just emptied) and for adapters without `keys()`.
466
+ if (!clearAll && typeof persist.keys === 'function') {
467
+ const persisted = await persist.keys();
468
+ // Read the live set *after* the await, so a `set` landing mid-pass counts as live
469
+ // and keeps its row — and nothing awaits before `remove`, so the diff cannot go
470
+ // stale under our feet.
471
+ const live = new Set(this.#wasm.keys());
472
+ const stale = persisted.filter((key) => !live.has(key));
473
+ if (stale.length > 0)
474
+ toRemove = [...new Set([...deleted, ...stale])];
475
+ }
476
+ // One last synchronous guard: a key re-`set` while the pass was awaiting belongs to
477
+ // the *next* pass's `save`, so removing its row here would only open a window where
478
+ // memory and storage disagree.
479
+ const targets = toRemove.filter((key) => !this.#dirty.has(key));
480
+ if (targets.length > 0)
481
+ await persist.remove(targets);
482
+ }
483
+ catch (error) {
484
+ // Hand back exactly what this pass claimed. Concurrent work that landed during the
485
+ // awaits is kept as-is, and the two queues stay disjoint — a key the runner may have
486
+ // touched in the meantime belongs to whoever claimed it last.
487
+ if (clearAll)
488
+ this.#clearAll = true;
489
+ for (const key of dirty) {
490
+ // Deleted while we were awaiting? Its delete bookkeeping is already queued — don't
491
+ // resurrect it on the dirty side.
492
+ if (!this.#deleted.has(key))
493
+ this.#dirty.add(key);
494
+ }
495
+ for (const key of toRemove) {
496
+ // Re-`set` while we were awaiting? Then the next pass must save it, not delete the
497
+ // row that save would write.
498
+ if (!this.#dirty.has(key))
499
+ this.#deleted.add(key);
500
+ }
501
+ throw error;
350
502
  }
351
- if (deleted.length > 0)
352
- await persist.remove(deleted);
353
503
  }
354
504
  /**
355
505
  * `true` when a change event would actually reach someone — persistence bookkeeping or at
@@ -390,8 +540,16 @@ export class BlazeCache {
390
540
  }
391
541
  this.#scheduleFlush();
392
542
  }
393
- for (const listener of this.#listeners)
394
- listener(change);
543
+ for (const listener of this.#listeners) {
544
+ try {
545
+ listener(change);
546
+ }
547
+ catch (error) {
548
+ // The mutation already happened and the bookkeeping above already ran — a bad
549
+ // subscriber must not abort its siblings or surface out of a successful `set`.
550
+ console.error('[blaze-cache] change listener failed — the remaining listeners still run.', error);
551
+ }
552
+ }
395
553
  }
396
554
  }
397
555
  /** Shorthand for {@link BlazeCache.create}. */
package/dist/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE,iDAAiD;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC;;;;;;GAMG;AACH,MAAM,OAAO,GAAa,EAAE,CAAC;AAqC7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,UAAU;IACZ,KAAK,CAAY;IACjB,UAAU,GAAG,IAAI,GAAG,EAAiB,CAAC;IACtC,OAAO,GAAsB,EAAE,CAAC;IACzC,QAAQ,GAA4B,IAAI,CAAC;IACzC,aAAa,GAAG,sBAAsB,CAAC;IACvC,WAAW,GAAG,mBAAmB,CAAC;IAClC,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3B,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAC7B,SAAS,GAAG,KAAK,CAAC;IAClB,MAAM,GAAyC,IAAI,CAAC;IACpD,MAAM,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1C,SAAS,GAAG,KAAK,CAAC;IAElB,YAAoB,IAAe;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC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B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,8EAA8E;gBAC9E,+EAA+E;gBAC/E,OAAO,CAAC,KAAK,CAAC,2EAA2E,EAAE,KAAK,CAAC,CAAC;YACpG,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,+CAA+C;AAC/C,MAAM,UAAU,WAAW,CAAU,OAA2B;IAC9D,OAAO,UAAU,CAAC,MAAM,CAAI,OAAO,CAAC,CAAC;AACvC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../src/persistence/indexeddb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAC;AAatF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAsIrF"}
1
+ {"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../src/persistence/indexeddb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAC;AAatF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAyJrF"}
@@ -39,6 +39,16 @@ export function indexedDbPersistence(options = {}) {
39
39
  };
40
40
  request.onsuccess = () => {
41
41
  const db = request.result;
42
+ // Another tab can bump the database version at any moment; without a handler our
43
+ // connection would block their `versionchange` event forever. Closing here keeps
44
+ // the world coherent: `opening` only ever promises a *usable* connection, so the
45
+ // next `open()` re-establishes one instead of handing out this closed zombie.
46
+ const settled = opening;
47
+ db.onversionchange = () => {
48
+ db.close();
49
+ if (opening === settled)
50
+ opening = null;
51
+ };
42
52
  if (db.objectStoreNames.contains(store)) {
43
53
  resolve(db);
44
54
  return;
@@ -128,6 +138,15 @@ export function indexedDbPersistence(options = {}) {
128
138
  objectStore.delete(key);
129
139
  });
130
140
  },
141
+ async keys() {
142
+ const db = await open();
143
+ const ids = await indexKeys(db);
144
+ const prefix = `${namespace}\u0000`;
145
+ // The index hands back composite ids; strip the prefix to recover the cache keys, and
146
+ // ignore anything that somehow lacks it rather than feeding nonsense to reconciliation.
147
+ return ids.filter((id) => typeof id === 'string' && id.startsWith(prefix))
148
+ .map((id) => id.slice(prefix.length));
149
+ },
131
150
  async close() {
132
151
  if (!opening)
133
152
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"indexeddb.js","sourceRoot":"","sources":["../../src/persistence/indexeddb.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAG,aAAa,CAAC;AACvC,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,UAAU,GAAG,CAAC,CAAC;AAQrB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAA4B,EAAE;IACjE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,gBAAgB,CAAC;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC;IAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC;IAEzD,qFAAqF;IACrF,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,SAAS,SAAS,GAAG,EAAE,CAAC;IAElE,IAAI,OAAO,GAAgC,IAAI,CAAC;IAEhD,MAAM,IAAI,GAAG,CAAC,OAAgB,EAAwB,EAAE;QACtD,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;QAE5B,OAAO,GAAG,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrD,MAAM,OAAO,GACX,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,I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,CAAC,WAAW,EAAE,EAAE;gBACpD,KAAK,MAAM,GAAG,IAAI,IAAI;oBAAE,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,IAAI;YACR,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,EAAE,CAAC,CAAC;YAChC,MAAM,MAAM,GAAG,GAAG,SAAS,QAAQ,CAAC;YACpC,sFAAsF;YACtF,wFAAwF;YACxF,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;iBACrF,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,CAAC,KAAK;YACT,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,uEAAuE;YACvE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAC3C,OAAO,GAAG,IAAI,CAAC;YACf,EAAE,EAAE,KAAK,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -28,6 +28,18 @@ export interface CachePersistence {
28
28
  remove(keys: string[]): Promise<void>;
29
29
  /** Deletes every record belonging to this cache (other namespaces are left alone). */
30
30
  clear(): Promise<void>;
31
+ /**
32
+ * Every record key currently stored for this cache's namespace.
33
+ *
34
+ * Optional, and only needed for reconciliation: the wasm core drops entries on its own —
35
+ * a capacity eviction or a lapsed TTL never produces a change event — so those rows would
36
+ * otherwise sit in storage until quota runs out. A flush compares this list against the
37
+ * live keys and calls {@link CachePersistence.remove} for the difference.
38
+ *
39
+ * Adapters that do not implement it keep working exactly as before; they simply skip the
40
+ * diff, and any explicit `delete`/`invalidateTags`/`prune` still reaches `remove`.
41
+ */
42
+ keys?(): Promise<string[]>;
31
43
  /** Releases any underlying handle. */
32
44
  close?(): void | Promise<void>;
33
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/persistence/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,mFAAmF;IACnF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kFAAkF;IAClF,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACnC,yDAAyD;IACzD,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,8BAA8B;IAC9B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,sFAAsF;IACtF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,sCAAsC;IACtC,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/persistence/types.ts"],"names":[],"mappings":"AAAA;;;;;G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M,GAAG,SAAS,CAMtE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA0BtD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMtE"}
package/dist/utils.js CHANGED
@@ -22,7 +22,17 @@ export function stableStringify(value) {
22
22
  const source = raw;
23
23
  const sorted = {};
24
24
  for (const key of Object.keys(source).sort()) {
25
- sorted[key] = source[key];
25
+ // Plain `sorted[key] = …` would *not* create an own property for a literal `__proto__`
26
+ // key: the inherited setter would swap `sorted`'s prototype instead, dropping the key
27
+ // from the output and mutating the fresh object we just allocated. `defineProperty`
28
+ // always defines an own data property, so hostile keys serialise normally — and only
29
+ // ever inside this throwaway `sorted`, never on `Object.prototype`.
30
+ Object.defineProperty(sorted, key, {
31
+ value: source[key],
32
+ enumerable: true,
33
+ writable: true,
34
+ configurable: true,
35
+ });
26
36
  }
27
37
  return sorted;
28
38
  });
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IAE5C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAY,EAAE,EAAE;QACxD,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;QAC9E,MAAM,MAAM,GAAG,GAA8B,CAAC;QAC9C,MAAM,MAAM,GAA4B,EAAE,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AM,CAAC,GAAG,CAAC;gBAClB,UAAU,EAAE,IAAI;gBAChB,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,sFAAsF;IACtF,2DAA2D;IAC3D,OAAO,IAAI,IAAI,MAAM,CAAC;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cache/core",
3
- "version": "0.2.0-beta",
3
+ "version": "0.2.1-beta",
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",
@@ -59,7 +59,18 @@ export class BlazeCache {
59
59
  */
60
60
  keys(): string[];
61
61
  /**
62
- * Creates a cache that holds at most `capacity` entries (clamped to `>= 1`).
62
+ * Creates a cache that holds at most `capacity` entries.
63
+ *
64
+ * `capacity` arrives as a JS `Number`, so it is validated before anything else sees it:
65
+ *
66
+ * * non-finite (`NaN`, `Infinity`) — meaningless as a size, falls back to the default;
67
+ * * below `1` — clamped up to `1`, exactly as the core clamps `0`; note this also
68
+ * covers negatives, which JS→integer conversion would otherwise deliver as ~4.29e9;
69
+ * * above [`MAX_CAPACITY`] — clamped down, because `capacity()` reports it back and
70
+ * nobody builds a browser cache meant to hold a billion entries.
71
+ *
72
+ * The core also caps its own index reservation, so even an unvalidated number could no
73
+ * longer abort the instance with a huge up-front allocation.
63
74
  */
64
75
  constructor(capacity: number);
65
76
  /**
@@ -159,7 +159,18 @@ export class BlazeCache {
159
159
  }
160
160
  }
161
161
  /**
162
- * Creates a cache that holds at most `capacity` entries (clamped to `>= 1`).
162
+ * Creates a cache that holds at most `capacity` entries.
163
+ *
164
+ * `capacity` arrives as a JS `Number`, so it is validated before anything else sees it:
165
+ *
166
+ * * non-finite (`NaN`, `Infinity`) — meaningless as a size, falls back to the default;
167
+ * * below `1` — clamped up to `1`, exactly as the core clamps `0`; note this also
168
+ * covers negatives, which JS→integer conversion would otherwise deliver as ~4.29e9;
169
+ * * above [`MAX_CAPACITY`] — clamped down, because `capacity()` reports it back and
170
+ * nobody builds a browser cache meant to hold a billion entries.
171
+ *
172
+ * The core also caps its own index reservation, so even an unvalidated number could no
173
+ * longer abort the instance with a huge up-front allocation.
163
174
  * @param {number} capacity
164
175
  */
165
176
  constructor(capacity) {
Binary file