@blaze-cache/core 0.3.0 → 0.4.0-beta.1
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 +78 -15
- package/dist/cache.d.ts +118 -23
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +541 -54
- package/dist/cache.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/persistence/indexeddb.d.ts +16 -2
- package/dist/persistence/indexeddb.d.ts.map +1 -1
- package/dist/persistence/indexeddb.js +248 -54
- package/dist/persistence/indexeddb.js.map +1 -1
- package/dist/persistence/types.d.ts +271 -0
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/reactivity.d.ts +63 -0
- package/dist/reactivity.d.ts.map +1 -0
- package/dist/reactivity.js +424 -0
- package/dist/reactivity.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm.d.ts +79 -1
- package/dist/wasm.d.ts.map +1 -1
- package/dist/wasm.js +142 -0
- package/dist/wasm.js.map +1 -1
- package/package.json +2 -1
- package/pkg/blaze_cache_wasm.d.ts +15 -10
- package/pkg/blaze_cache_wasm.js +159 -137
- package/pkg/blaze_cache_wasm_bg.wasm +0 -0
- package/pkg/blaze_cache_wasm_bg.wasm.d.ts +14 -9
- package/pkg/package.json +1 -1
package/dist/wasm.js
CHANGED
|
@@ -136,5 +136,147 @@ export function initBlazeWasm(input) {
|
|
|
136
136
|
});
|
|
137
137
|
return pending;
|
|
138
138
|
}
|
|
139
|
+
/** The one in-flight {@link loadBlazeWasm}, shared by every concurrent `createCache()`. */
|
|
140
|
+
let loading = null;
|
|
141
|
+
/** The four ways to say where the `.wasm` is, in the order they are reported and resolved. */
|
|
142
|
+
const SOURCE_KEYS = ['wasmUrl', 'module', 'instantiate', 'wasm'];
|
|
143
|
+
/**
|
|
144
|
+
* Loads and instantiates the Blaze Cache wasm module exactly once, from the source the
|
|
145
|
+
* given options describe.
|
|
146
|
+
*
|
|
147
|
+
* This is what `createCache()` awaits. Concurrent callers share one load: the first call's
|
|
148
|
+
* options decide where the binary comes from, every later call awaits that same promise
|
|
149
|
+
* and never fetches, compiles or instantiates again — so N simultaneous `createCache()`
|
|
150
|
+
* calls cost one download. A failure resets the promise, so the next call may retry.
|
|
151
|
+
*
|
|
152
|
+
* @param options Exactly one of `wasmUrl`, `module`, `instantiate` or `wasm`; with none of
|
|
153
|
+
* them the binary shipped next to this module is fetched.
|
|
154
|
+
*
|
|
155
|
+
* @throws TypeError if more than one source option is given — silently picking one would
|
|
156
|
+
* hide a real mistake.
|
|
157
|
+
* @throws Error if the binary cannot be fetched or instantiated. The message names the URL
|
|
158
|
+
* (or the step that failed) and what to do about it; the original error is on `cause`.
|
|
159
|
+
*/
|
|
160
|
+
export function loadBlazeWasm(options = {}) {
|
|
161
|
+
// Validate before any short-circuit: two sources is a programming error, and it should
|
|
162
|
+
// surface whether or not the module happens to be loaded already.
|
|
163
|
+
const requested = SOURCE_KEYS.filter((key) => options[key] !== undefined);
|
|
164
|
+
if (requested.length > 1) {
|
|
165
|
+
throw new TypeError(`@blaze-cache/core: pass at most one wasm source, got ${requested
|
|
166
|
+
.map((key) => `\`${key}\``)
|
|
167
|
+
.join(' and ')}. Use \`wasmUrl\` for an asset URL, \`module\` for a precompiled ` +
|
|
168
|
+
'WebAssembly.Module, `instantiate` for a custom loader, or `wasm` to hand a ' +
|
|
169
|
+
"source straight to wasm-bindgen's init().");
|
|
170
|
+
}
|
|
171
|
+
// Already loading/loaded: nothing to resolve, whatever the later callers asked for.
|
|
172
|
+
if (pending !== null)
|
|
173
|
+
return pending;
|
|
174
|
+
if (loading !== null)
|
|
175
|
+
return loading;
|
|
176
|
+
loading = (async () => {
|
|
177
|
+
const source = await resolveWasmSource(options);
|
|
178
|
+
try {
|
|
179
|
+
await initBlazeWasm(await prepareWasmSource(source));
|
|
180
|
+
}
|
|
181
|
+
catch (cause) {
|
|
182
|
+
throw new Error(`@blaze-cache/core: failed to instantiate the WebAssembly binary — ${describeCause(cause)}. ` +
|
|
183
|
+
'Check that the asset is the Blaze Cache `.wasm` for this package version and that ' +
|
|
184
|
+
'your server allows WebAssembly (a `Content-Type` of `application/wasm` lets the ' +
|
|
185
|
+
'loader stream it; anything else still works, just slower).', { cause });
|
|
186
|
+
}
|
|
187
|
+
})();
|
|
188
|
+
// Reset on failure so a bad URL or a transient network error is retryable. The original
|
|
189
|
+
// promise still rejects for whoever is awaiting it.
|
|
190
|
+
void loading.catch(() => {
|
|
191
|
+
loading = null;
|
|
192
|
+
});
|
|
193
|
+
return loading;
|
|
194
|
+
}
|
|
195
|
+
/** Picks the one requested source — or the default asset shipped with this module. */
|
|
196
|
+
async function resolveWasmSource(options) {
|
|
197
|
+
if (options.wasmUrl !== undefined)
|
|
198
|
+
return options.wasmUrl;
|
|
199
|
+
if (options.module !== undefined)
|
|
200
|
+
return options.module;
|
|
201
|
+
if (options.instantiate !== undefined)
|
|
202
|
+
return adoptWasmSource(await options.instantiate());
|
|
203
|
+
if (options.wasm !== undefined)
|
|
204
|
+
return options.wasm;
|
|
205
|
+
return wasmUrl; // default: the binary that ships next to this module
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Fetches URL sources here rather than handing them to the glue, so a wrong path, a blocked
|
|
209
|
+
* request and a corrupt binary each fail with their own message instead of one opaque
|
|
210
|
+
* "failed to load wasm". Bytes, `Response`s and `Module`s pass through untouched — there is
|
|
211
|
+
* nothing to fetch for those.
|
|
212
|
+
*/
|
|
213
|
+
async function prepareWasmSource(source) {
|
|
214
|
+
if (typeof source === 'string')
|
|
215
|
+
return await fetchWasmBinary(source);
|
|
216
|
+
if (typeof URL !== 'undefined' && source instanceof URL)
|
|
217
|
+
return await fetchWasmBinary(source);
|
|
218
|
+
return source;
|
|
219
|
+
}
|
|
220
|
+
/** `fetch()` with the failure modes spelled out; resolves to a body that is known good. */
|
|
221
|
+
async function fetchWasmBinary(target) {
|
|
222
|
+
const href = typeof target === 'string' ? target : target.href;
|
|
223
|
+
const hint = 'Pass `wasmUrl` for a public asset path or a CDN, `module` for a precompiled ' +
|
|
224
|
+
'WebAssembly.Module, or `instantiate` for a fully custom loader.';
|
|
225
|
+
let response;
|
|
226
|
+
try {
|
|
227
|
+
response = await fetch(target);
|
|
228
|
+
}
|
|
229
|
+
catch (cause) {
|
|
230
|
+
throw new Error(`@blaze-cache/core: could not fetch the WebAssembly binary from ${JSON.stringify(href)} — ` +
|
|
231
|
+
`${describeCause(cause)}. ${hint}`, { cause });
|
|
232
|
+
}
|
|
233
|
+
if (!response.ok) {
|
|
234
|
+
throw new Error(`@blaze-cache/core: could not fetch the WebAssembly binary — HTTP ${response.status} ` +
|
|
235
|
+
`${response.statusText} for ${JSON.stringify(response.url || href)}. ${hint}`);
|
|
236
|
+
}
|
|
237
|
+
return response;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Rejects the one shape the loader cannot honour, with the reason instead of a mystery deep
|
|
241
|
+
* inside wasm-bindgen. See {@link WasmLoadOptions.instantiate} for why an instance or an
|
|
242
|
+
* exports object cannot be adopted.
|
|
243
|
+
*/
|
|
244
|
+
function adoptWasmSource(source) {
|
|
245
|
+
if (isWasmSource(source))
|
|
246
|
+
return source;
|
|
247
|
+
throw new Error("@blaze-cache/core: `instantiate` must resolve to a *source* — a URL, a Request or " +
|
|
248
|
+
'Response, raw bytes, or a precompiled WebAssembly.Module — not to a ' +
|
|
249
|
+
'WebAssembly.Instance or to an object\'s exports. wasm-bindgen\'s generated glue owns ' +
|
|
250
|
+
'the import object and has to create the instance itself, so an instance built ' +
|
|
251
|
+
'elsewhere can never be wired up. Return the source instead, for example ' +
|
|
252
|
+
'`(await fetch(url)).arrayBuffer()`.');
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Narrows to {@link WasmSource} — everything `init()` can actually instantiate from. An
|
|
256
|
+
* `Instance` or an exports object falls through and is rejected by {@link adoptWasmSource}.
|
|
257
|
+
*/
|
|
258
|
+
function isWasmSource(value) {
|
|
259
|
+
if (typeof value === 'string')
|
|
260
|
+
return true;
|
|
261
|
+
if (typeof URL !== 'undefined' && value instanceof URL)
|
|
262
|
+
return true;
|
|
263
|
+
if (typeof Request !== 'undefined' && value instanceof Request)
|
|
264
|
+
return true;
|
|
265
|
+
if (typeof Response !== 'undefined' && value instanceof Response)
|
|
266
|
+
return true;
|
|
267
|
+
if (value instanceof WebAssembly.Module)
|
|
268
|
+
return true;
|
|
269
|
+
if (value instanceof ArrayBuffer)
|
|
270
|
+
return true;
|
|
271
|
+
if (ArrayBuffer.isView(value))
|
|
272
|
+
return true;
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
/** One line out of an unknown thrown value, for the messages above. */
|
|
276
|
+
function describeCause(cause) {
|
|
277
|
+
if (!(cause instanceof Error))
|
|
278
|
+
return String(cause);
|
|
279
|
+
return cause.name === 'Error' ? cause.message : `${cause.name}: ${cause.message}`;
|
|
280
|
+
}
|
|
139
281
|
export { WasmCache };
|
|
140
282
|
//# sourceMappingURL=wasm.js.map
|
package/dist/wasm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EACX,YAAY,EACZ,aAAa,EACb,UAAU,IAAI,SAAS,GACxB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EACX,YAAY,EACZ,aAAa,EACb,UAAU,IAAI,SAAS,GACxB,MAAM,4BAA4B,CAAC;AAYpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAQ,IAAI,GAAG,CAAC,iCAAiC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,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K,KAAK,CAAC,OAAO,EAAE,CAAC;AACpF,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cache/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-beta.1",
|
|
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",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"./dist/wasm.js"
|
|
48
48
|
],
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"fake-indexeddb": "^6.2.8",
|
|
50
51
|
"typescript": "^5.9.3"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
@@ -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) =>
|
|
239
|
+
readonly blazecache_drainDrops: (a: number) => any;
|
|
240
240
|
readonly blazecache_dropTracking: (a: number) => number;
|
|
241
|
-
readonly blazecache_entries: (a: number) =>
|
|
242
|
-
readonly blazecache_entry: (a: number, b: number, c: number) =>
|
|
243
|
-
readonly blazecache_get: (a: number, b: number, c: 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) =>
|
|
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) =>
|
|
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:
|
|
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:
|
|
259
|
-
readonly blazecache_setRaw: (a: number, b: number, c: number, d:
|
|
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;
|