ziex 0.1.0-dev.1466 → 0.1.0-dev.1568
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 +3 -9
- package/app.d.ts +37 -22
- package/build.zig.zon +1 -1
- package/index.d.ts +1 -1
- package/index.js +239 -218
- package/package.json +2 -2
- package/platforms/aws-lambda/index.d.ts +1 -1
- package/platforms/cloudflare/app.d.ts +31 -1
- package/platforms/cloudflare/index.d.ts +5 -4
- package/platforms/cloudflare/index.js +1722 -1645
- package/platforms/cloudflare/kv.d.ts +4 -2
- package/platforms/cloudflare/stateful.d.ts +26 -0
- package/platforms/cloudflare/worker.d.ts +1 -2
- package/platforms/vercel/index.d.ts +1 -1
- package/runtime/index.d.ts +20 -10
- package/runtime/kv/indexdb.d.ts +11 -3
- package/runtime/kv/localstorage.d.ts +11 -3
- package/runtime/kv/memory.d.ts +13 -6
- package/runtime/kv.d.ts +16 -18
- package/runtime/kv.js +178 -241
- package/runtime/wasi.d.ts +2 -7
- package/wasm/dom_cmd.d.ts +0 -9
- package/wasm/index.js +224 -188
- package/wasm/init.dev.js +224 -188
- package/wasm/init.js +3 -3
- package/platforms/cloudflare/do.d.ts +0 -50
package/runtime/kv.js
CHANGED
|
@@ -1,164 +1,3 @@
|
|
|
1
|
-
// src/runtime/kv/memory.ts
|
|
2
|
-
function createMemoryKV() {
|
|
3
|
-
const store = /* @__PURE__ */ new Map();
|
|
4
|
-
function read(key) {
|
|
5
|
-
const entry = store.get(key);
|
|
6
|
-
if (!entry) return null;
|
|
7
|
-
const expiresAt = entry[1];
|
|
8
|
-
if (expiresAt !== void 0 && Date.now() >= expiresAt) {
|
|
9
|
-
store.delete(key);
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return entry[0];
|
|
13
|
-
}
|
|
14
|
-
function write(key, value, options) {
|
|
15
|
-
let expiresAt;
|
|
16
|
-
if (options?.expiration !== void 0) {
|
|
17
|
-
expiresAt = options.expiration * 1e3;
|
|
18
|
-
} else if (options?.expirationTtl !== void 0) {
|
|
19
|
-
expiresAt = Date.now() + options.expirationTtl * 1e3;
|
|
20
|
-
}
|
|
21
|
-
store.set(key, [value, expiresAt]);
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
async get(key) {
|
|
25
|
-
return read(key);
|
|
26
|
-
},
|
|
27
|
-
async put(key, value, options) {
|
|
28
|
-
write(key, value, options);
|
|
29
|
-
},
|
|
30
|
-
async delete(key) {
|
|
31
|
-
store.delete(key);
|
|
32
|
-
},
|
|
33
|
-
async list(options) {
|
|
34
|
-
const keys = [...store.keys()].filter((k) => {
|
|
35
|
-
if (options?.prefix && !k.startsWith(options.prefix)) return false;
|
|
36
|
-
return read(k) !== null;
|
|
37
|
-
}).map((name) => ({ name }));
|
|
38
|
-
return { keys };
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// src/runtime/kv/localstorage.ts
|
|
44
|
-
function getLocalStorage() {
|
|
45
|
-
if (typeof localStorage === "undefined") {
|
|
46
|
-
throw new Error("localStorage is not available in this environment");
|
|
47
|
-
}
|
|
48
|
-
return localStorage;
|
|
49
|
-
}
|
|
50
|
-
function createLocalStorageKV(options = {}) {
|
|
51
|
-
const storage = getLocalStorage();
|
|
52
|
-
const namespace = options.namespace ?? "default";
|
|
53
|
-
const storagePrefix = options.storagePrefix ?? "ziex-kv";
|
|
54
|
-
const scopedKey = (key) => `${storagePrefix}:${namespace}:${key}`;
|
|
55
|
-
const namespacePrefix = scopedKey("");
|
|
56
|
-
return {
|
|
57
|
-
getSync(key) {
|
|
58
|
-
return storage.getItem(scopedKey(key));
|
|
59
|
-
},
|
|
60
|
-
async get(key) {
|
|
61
|
-
return this.getSync(key);
|
|
62
|
-
},
|
|
63
|
-
putSync(key, value) {
|
|
64
|
-
storage.setItem(scopedKey(key), value);
|
|
65
|
-
},
|
|
66
|
-
async put(key, value) {
|
|
67
|
-
this.putSync(key, value);
|
|
68
|
-
},
|
|
69
|
-
deleteSync(key) {
|
|
70
|
-
storage.removeItem(scopedKey(key));
|
|
71
|
-
},
|
|
72
|
-
async delete(key) {
|
|
73
|
-
this.deleteSync(key);
|
|
74
|
-
},
|
|
75
|
-
listSync(options2) {
|
|
76
|
-
const prefix = namespacePrefix + (options2?.prefix ?? "");
|
|
77
|
-
const keys = [];
|
|
78
|
-
for (let i = 0; i < storage.length; i += 1) {
|
|
79
|
-
const key = storage.key(i);
|
|
80
|
-
if (!key || !key.startsWith(prefix)) continue;
|
|
81
|
-
keys.push({ name: key.slice(namespacePrefix.length) });
|
|
82
|
-
}
|
|
83
|
-
return { keys };
|
|
84
|
-
},
|
|
85
|
-
async list(options2) {
|
|
86
|
-
return this.listSync(options2);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// src/runtime/kv/indexdb.ts
|
|
92
|
-
function getIndexedDb() {
|
|
93
|
-
if (typeof indexedDB === "undefined") {
|
|
94
|
-
throw new Error("IndexedDB is not available in this environment");
|
|
95
|
-
}
|
|
96
|
-
return indexedDB;
|
|
97
|
-
}
|
|
98
|
-
function requestToPromise(request) {
|
|
99
|
-
return new Promise((resolve, reject) => {
|
|
100
|
-
request.onsuccess = () => resolve(request.result);
|
|
101
|
-
request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function transactionToPromise(transaction) {
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
transaction.oncomplete = () => resolve();
|
|
107
|
-
transaction.onabort = () => reject(transaction.error ?? new Error("IndexedDB transaction aborted"));
|
|
108
|
-
transaction.onerror = () => reject(transaction.error ?? new Error("IndexedDB transaction failed"));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function createIndexedDbKV(options = {}) {
|
|
112
|
-
const databaseName = options.databaseName ?? "ziex-kv";
|
|
113
|
-
const storeName = options.storeName ?? "kv";
|
|
114
|
-
const namespace = options.namespace ?? "default";
|
|
115
|
-
const dbPromise = new Promise((resolve, reject) => {
|
|
116
|
-
const request = getIndexedDb().open(databaseName, 1);
|
|
117
|
-
request.onupgradeneeded = () => {
|
|
118
|
-
const db = request.result;
|
|
119
|
-
if (!db.objectStoreNames.contains(storeName)) {
|
|
120
|
-
db.createObjectStore(storeName);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
request.onsuccess = () => resolve(request.result);
|
|
124
|
-
request.onerror = () => reject(request.error ?? new Error("Failed to open IndexedDB"));
|
|
125
|
-
});
|
|
126
|
-
const scopedKey = (key) => `${namespace}:${key}`;
|
|
127
|
-
return {
|
|
128
|
-
async get(key) {
|
|
129
|
-
const db = await dbPromise;
|
|
130
|
-
const tx = db.transaction(storeName, "readonly");
|
|
131
|
-
const store = tx.objectStore(storeName);
|
|
132
|
-
const value = await requestToPromise(store.get(scopedKey(key)));
|
|
133
|
-
await transactionToPromise(tx);
|
|
134
|
-
return typeof value === "string" ? value : null;
|
|
135
|
-
},
|
|
136
|
-
async put(key, value) {
|
|
137
|
-
const db = await dbPromise;
|
|
138
|
-
const tx = db.transaction(storeName, "readwrite");
|
|
139
|
-
tx.objectStore(storeName).put(value, scopedKey(key));
|
|
140
|
-
await transactionToPromise(tx);
|
|
141
|
-
},
|
|
142
|
-
async delete(key) {
|
|
143
|
-
const db = await dbPromise;
|
|
144
|
-
const tx = db.transaction(storeName, "readwrite");
|
|
145
|
-
tx.objectStore(storeName).delete(scopedKey(key));
|
|
146
|
-
await transactionToPromise(tx);
|
|
147
|
-
},
|
|
148
|
-
async list(options2) {
|
|
149
|
-
const db = await dbPromise;
|
|
150
|
-
const tx = db.transaction(storeName, "readonly");
|
|
151
|
-
const store = tx.objectStore(storeName);
|
|
152
|
-
const keys = await requestToPromise(store.getAllKeys());
|
|
153
|
-
await transactionToPromise(tx);
|
|
154
|
-
const prefix = scopedKey(options2?.prefix ?? "");
|
|
155
|
-
return {
|
|
156
|
-
keys: keys.filter((key) => typeof key === "string" && key.startsWith(prefix)).map((key) => ({ name: key.slice(namespace.length + 1) }))
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
1
|
// ../../vendor/jsz/js/src/zigjs.ts
|
|
163
2
|
var NAN_PREFIX = 2146959360;
|
|
164
3
|
var predefined = {
|
|
@@ -434,110 +273,208 @@ function writeJsonOut(getMemory, allocRef, outPtrAddr, value) {
|
|
|
434
273
|
}
|
|
435
274
|
|
|
436
275
|
// src/runtime/kv/extern.ts
|
|
276
|
+
var Suspending = WebAssembly.Suspending;
|
|
277
|
+
var jspi = typeof Suspending === "function";
|
|
278
|
+
var miss = jspi ? -1 : 0;
|
|
437
279
|
function putOptions(ttlSeconds) {
|
|
438
280
|
if (ttlSeconds < 60) return void 0;
|
|
439
281
|
return { expirationTtl: ttlSeconds };
|
|
440
282
|
}
|
|
283
|
+
function kvDel(binding, key) {
|
|
284
|
+
const b = binding;
|
|
285
|
+
return (b.del ?? b.delete).call(b, key);
|
|
286
|
+
}
|
|
441
287
|
function isSyncKVNamespace(binding) {
|
|
442
|
-
|
|
443
|
-
return typeof candidate.getSync === "function" && typeof candidate.putSync === "function" && typeof candidate.deleteSync === "function" && typeof candidate.listSync === "function";
|
|
288
|
+
return typeof binding.get === "function" && binding.get.constructor.name !== "AsyncFunction";
|
|
444
289
|
}
|
|
445
|
-
function
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
290
|
+
function listOpts(prefix) {
|
|
291
|
+
return prefix.length > 0 ? { prefix } : void 0;
|
|
292
|
+
}
|
|
293
|
+
function maybeThen(r, f) {
|
|
294
|
+
return r instanceof Promise ? r.then(f) : f(r);
|
|
295
|
+
}
|
|
296
|
+
function readStr(getMemory, ptr, len) {
|
|
297
|
+
return textDecoder.decode(new Uint8Array(getMemory().buffer, ptr, len));
|
|
298
|
+
}
|
|
299
|
+
function resolve(bindings, ns) {
|
|
300
|
+
const b = bindings[ns] ?? bindings["default"] ?? null;
|
|
301
|
+
if (!b || jspi) return b;
|
|
302
|
+
return isSyncKVNamespace(b) ? b : null;
|
|
303
|
+
}
|
|
304
|
+
function encodeGet(getMemory, allocRef, value, out_ptr) {
|
|
305
|
+
if (value === null) return -1;
|
|
306
|
+
return writeBytesOut(getMemory, allocRef, out_ptr, textEncoder.encode(value));
|
|
307
|
+
}
|
|
308
|
+
function encodeList(getMemory, allocRef, names, out_ptr) {
|
|
309
|
+
if (names.length === 0) {
|
|
310
|
+
new DataView(getMemory().buffer).setUint32(out_ptr, 0, true);
|
|
311
|
+
return 0;
|
|
453
312
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
b.deleteSync(readStr(key_ptr, key_len));
|
|
479
|
-
return 0;
|
|
480
|
-
},
|
|
481
|
-
kv_list: (ns_ptr, ns_len, pfx_ptr, pfx_len, out_ptr) => {
|
|
482
|
-
const b = syncBinding2(readStr(ns_ptr, ns_len));
|
|
483
|
-
if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
|
|
484
|
-
const prefix = readStr(pfx_ptr, pfx_len);
|
|
485
|
-
const result = b.listSync(prefix.length > 0 ? { prefix } : void 0);
|
|
486
|
-
return writeJsonOut(getMemory, allocRef, out_ptr, result.keys.map((k) => k.name));
|
|
487
|
-
}
|
|
488
|
-
};
|
|
313
|
+
return writeJsonOut(getMemory, allocRef, out_ptr, names);
|
|
314
|
+
}
|
|
315
|
+
function get(b, key, out_ptr, getMemory, allocRef) {
|
|
316
|
+
return maybeThen(b.get(key), (v) => encodeGet(getMemory, allocRef, v, out_ptr));
|
|
317
|
+
}
|
|
318
|
+
function put(b, key, val, ttl) {
|
|
319
|
+
return maybeThen(b.put(key, val, putOptions(ttl)), () => 0);
|
|
320
|
+
}
|
|
321
|
+
function del(b, key) {
|
|
322
|
+
return maybeThen(kvDel(b, key), () => 0);
|
|
323
|
+
}
|
|
324
|
+
function list(b, prefix, out_ptr, getMemory, allocRef) {
|
|
325
|
+
return maybeThen(
|
|
326
|
+
b.list(listOpts(prefix)),
|
|
327
|
+
(result) => encodeList(getMemory, allocRef, result.keys.map((k) => k.name), out_ptr)
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
function wrapImport(impl) {
|
|
331
|
+
if (!jspi) {
|
|
332
|
+
return ((...args) => {
|
|
333
|
+
const r = impl(...args);
|
|
334
|
+
if (r instanceof Promise) throw new Error("async kv binding requires JSPI");
|
|
335
|
+
return r;
|
|
336
|
+
});
|
|
489
337
|
}
|
|
338
|
+
return new Suspending(impl);
|
|
339
|
+
}
|
|
340
|
+
function createKVImports(bindings, getMemory, allocRef) {
|
|
490
341
|
return {
|
|
491
|
-
kv_get:
|
|
492
|
-
const b =
|
|
342
|
+
kv_get: wrapImport((ns_ptr, ns_len, key_ptr, key_len, out_ptr) => {
|
|
343
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
493
344
|
if (!b) return -1;
|
|
494
|
-
|
|
495
|
-
if (value === null) return -1;
|
|
496
|
-
return writeBytesOut(getMemory, allocRef, out_ptr, encoder2.encode(value));
|
|
345
|
+
return get(b, readStr(getMemory, key_ptr, key_len), out_ptr, getMemory, allocRef);
|
|
497
346
|
}),
|
|
498
|
-
kv_put:
|
|
499
|
-
const b =
|
|
500
|
-
if (!b) return
|
|
501
|
-
|
|
502
|
-
|
|
347
|
+
kv_put: wrapImport((ns_ptr, ns_len, key_ptr, key_len, val_ptr, val_len, ttl_seconds) => {
|
|
348
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
349
|
+
if (!b) return miss;
|
|
350
|
+
return put(
|
|
351
|
+
b,
|
|
352
|
+
readStr(getMemory, key_ptr, key_len),
|
|
353
|
+
readStr(getMemory, val_ptr, val_len),
|
|
354
|
+
ttl_seconds
|
|
355
|
+
);
|
|
503
356
|
}),
|
|
504
|
-
kv_delete:
|
|
505
|
-
const b =
|
|
506
|
-
if (!b) return
|
|
507
|
-
|
|
508
|
-
return 0;
|
|
357
|
+
kv_delete: wrapImport((ns_ptr, ns_len, key_ptr, key_len) => {
|
|
358
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
359
|
+
if (!b) return miss;
|
|
360
|
+
return del(b, readStr(getMemory, key_ptr, key_len));
|
|
509
361
|
}),
|
|
510
|
-
kv_list:
|
|
511
|
-
const b =
|
|
362
|
+
kv_list: wrapImport((ns_ptr, ns_len, pfx_ptr, pfx_len, out_ptr) => {
|
|
363
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
512
364
|
if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
|
|
513
|
-
|
|
514
|
-
const result = await b.list(prefix.length > 0 ? { prefix } : void 0);
|
|
515
|
-
const names = result.keys.map((k) => k.name);
|
|
516
|
-
if (names.length === 0) {
|
|
517
|
-
new DataView(getMemory().buffer).setUint32(out_ptr, 0, true);
|
|
518
|
-
return 0;
|
|
519
|
-
}
|
|
520
|
-
return writeJsonOut(getMemory, allocRef, out_ptr, names);
|
|
365
|
+
return list(b, readStr(getMemory, pfx_ptr, pfx_len), out_ptr, getMemory, allocRef);
|
|
521
366
|
})
|
|
522
367
|
};
|
|
523
368
|
}
|
|
524
369
|
|
|
525
|
-
// src/runtime/kv.ts
|
|
526
|
-
|
|
527
|
-
|
|
370
|
+
// src/runtime/kv/localstorage.ts
|
|
371
|
+
var namespace = "default";
|
|
372
|
+
var storagePrefix = "ziex-kv";
|
|
373
|
+
var namespacePrefix = `${storagePrefix}:${namespace}:`;
|
|
374
|
+
function storage() {
|
|
375
|
+
if (typeof localStorage === "undefined") {
|
|
376
|
+
throw new Error("localStorage is not available in this environment");
|
|
377
|
+
}
|
|
378
|
+
return localStorage;
|
|
379
|
+
}
|
|
380
|
+
function get2(key) {
|
|
381
|
+
return storage().getItem(`${storagePrefix}:${namespace}:${key}`);
|
|
528
382
|
}
|
|
383
|
+
function put2(key, value) {
|
|
384
|
+
storage().setItem(`${storagePrefix}:${namespace}:${key}`, value);
|
|
385
|
+
}
|
|
386
|
+
function del2(key) {
|
|
387
|
+
storage().removeItem(`${storagePrefix}:${namespace}:${key}`);
|
|
388
|
+
}
|
|
389
|
+
function list2(options) {
|
|
390
|
+
const ls = storage();
|
|
391
|
+
const prefix = namespacePrefix + (options?.prefix ?? "");
|
|
392
|
+
const keys = [];
|
|
393
|
+
for (let i = 0; i < ls.length; i += 1) {
|
|
394
|
+
const key = ls.key(i);
|
|
395
|
+
if (!key || !key.startsWith(prefix)) continue;
|
|
396
|
+
keys.push({ name: key.slice(namespacePrefix.length) });
|
|
397
|
+
}
|
|
398
|
+
return { keys };
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// src/runtime/kv/indexdb.ts
|
|
402
|
+
var databaseName = "ziex-kv";
|
|
403
|
+
var storeName = "kv";
|
|
404
|
+
var namespace2 = "default";
|
|
405
|
+
var dbPromise;
|
|
406
|
+
function openDb() {
|
|
407
|
+
if (!dbPromise) {
|
|
408
|
+
if (typeof indexedDB === "undefined") {
|
|
409
|
+
return Promise.reject(new Error("IndexedDB is not available in this environment"));
|
|
410
|
+
}
|
|
411
|
+
dbPromise = new Promise((resolve2, reject) => {
|
|
412
|
+
const request = indexedDB.open(databaseName, 1);
|
|
413
|
+
request.onupgradeneeded = () => {
|
|
414
|
+
const db = request.result;
|
|
415
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
416
|
+
db.createObjectStore(storeName);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
request.onsuccess = () => resolve2(request.result);
|
|
420
|
+
request.onerror = () => reject(request.error ?? new Error("Failed to open IndexedDB"));
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return dbPromise;
|
|
424
|
+
}
|
|
425
|
+
function requestToPromise(request) {
|
|
426
|
+
return new Promise((resolve2, reject) => {
|
|
427
|
+
request.onsuccess = () => resolve2(request.result);
|
|
428
|
+
request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function transactionToPromise(transaction) {
|
|
432
|
+
return new Promise((resolve2, reject) => {
|
|
433
|
+
transaction.oncomplete = () => resolve2();
|
|
434
|
+
transaction.onabort = () => reject(transaction.error ?? new Error("IndexedDB transaction aborted"));
|
|
435
|
+
transaction.onerror = () => reject(transaction.error ?? new Error("IndexedDB transaction failed"));
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
async function get3(key) {
|
|
439
|
+
const db = await openDb();
|
|
440
|
+
const tx = db.transaction(storeName, "readonly");
|
|
441
|
+
const value = await requestToPromise(tx.objectStore(storeName).get(`${namespace2}:${key}`));
|
|
442
|
+
await transactionToPromise(tx);
|
|
443
|
+
return typeof value === "string" ? value : null;
|
|
444
|
+
}
|
|
445
|
+
async function put3(key, value) {
|
|
446
|
+
const db = await openDb();
|
|
447
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
448
|
+
tx.objectStore(storeName).put(value, `${namespace2}:${key}`);
|
|
449
|
+
await transactionToPromise(tx);
|
|
450
|
+
}
|
|
451
|
+
async function del3(key) {
|
|
452
|
+
const db = await openDb();
|
|
453
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
454
|
+
tx.objectStore(storeName).delete(`${namespace2}:${key}`);
|
|
455
|
+
await transactionToPromise(tx);
|
|
456
|
+
}
|
|
457
|
+
async function list3(options) {
|
|
458
|
+
const db = await openDb();
|
|
459
|
+
const tx = db.transaction(storeName, "readonly");
|
|
460
|
+
const keys = await requestToPromise(tx.objectStore(storeName).getAllKeys());
|
|
461
|
+
await transactionToPromise(tx);
|
|
462
|
+
const prefix = `${namespace2}:${options?.prefix ?? ""}`;
|
|
463
|
+
return {
|
|
464
|
+
keys: keys.filter((key) => typeof key === "string" && key.startsWith(prefix)).map((key) => ({ name: key.slice(namespace2.length + 1) }))
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// src/runtime/kv.ts
|
|
469
|
+
var hasJspi = typeof WebAssembly.Suspending === "function" && typeof WebAssembly.promising === "function";
|
|
529
470
|
function createBrowserKVBindings(options = {}) {
|
|
530
|
-
const
|
|
531
|
-
const isIndexedDb = hasJSPI() && !options.forceLocalStorage;
|
|
471
|
+
const namespace3 = options.namespace ?? "default";
|
|
532
472
|
return {
|
|
533
|
-
[
|
|
473
|
+
[namespace3]: hasJspi && !options.forceLocalStorage ? { get: get3, put: put3, del: del3, list: list3 } : { get: get2, put: put2, del: del2, list: list2 }
|
|
534
474
|
};
|
|
535
475
|
}
|
|
536
476
|
export {
|
|
537
477
|
createBrowserKVBindings,
|
|
538
|
-
createIndexedDbKV,
|
|
539
478
|
createKVImports,
|
|
540
|
-
|
|
541
|
-
createMemoryKV,
|
|
542
|
-
hasJSPI
|
|
479
|
+
hasJspi
|
|
543
480
|
};
|
package/runtime/wasi.d.ts
CHANGED
|
@@ -17,11 +17,10 @@ export type WASI = {
|
|
|
17
17
|
};
|
|
18
18
|
}): void;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
/** WASI imports for request argv/stdin. Response body uses `__zx_http`, not stdout. */
|
|
21
|
+
export declare function createWasiImports({ request, stdinData, }: {
|
|
21
22
|
request: Request;
|
|
22
23
|
stdinData?: Uint8Array;
|
|
23
|
-
/** Called for each stdout chunk. When provided, chunks are NOT buffered internally. */
|
|
24
|
-
onStdout?: (chunk: Uint8Array) => void;
|
|
25
24
|
}): {
|
|
26
25
|
wasiImport: {
|
|
27
26
|
args_sizes_get(argc_ptr: number, argv_buf_size_ptr: number): number;
|
|
@@ -71,9 +70,5 @@ export declare function createWasiImports({ request, stdinData, onStdout, }: {
|
|
|
71
70
|
poll_oneoff(_in: number, _out: number, _nsubscriptions: number, nevents_ptr: number): number;
|
|
72
71
|
};
|
|
73
72
|
setMemory: (m: WebAssembly.Memory) => void;
|
|
74
|
-
collectOutput: () => {
|
|
75
|
-
stdout: Uint8Array;
|
|
76
|
-
stderrText: string;
|
|
77
|
-
};
|
|
78
73
|
};
|
|
79
74
|
export declare function mergeUint8Arrays(arrays: Uint8Array[]): Uint8Array;
|
package/wasm/dom_cmd.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DomCmd flush decoder — must match `src/runtime/client/dom_cmd.zig`.
|
|
3
|
-
*
|
|
4
|
-
* Buffer layout (little-endian):
|
|
5
|
-
* Header (8): u32 record_count, u32 flags (0 = absolute WASM ptr+len strings)
|
|
6
|
-
* Records (24 each): u8 op, u8 flags, u16 pad, u32 p0..p4
|
|
7
|
-
*
|
|
8
|
-
* String fields are absolute linear-memory pointers (same as the old per-op ABI).
|
|
9
|
-
*/
|
|
10
1
|
export type DomFlushContext = {
|
|
11
2
|
domNodes: Map<number, Node>;
|
|
12
3
|
cleanupDomNodes: (node: Node) => void;
|