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/wasm/index.js
CHANGED
|
@@ -276,7 +276,7 @@ var ZigJS = class {
|
|
|
276
276
|
function createFetchImports(getMemory) {
|
|
277
277
|
const encoder2 = new TextEncoder();
|
|
278
278
|
const decoder2 = new TextDecoder();
|
|
279
|
-
function
|
|
279
|
+
function readStr2(ptr, len) {
|
|
280
280
|
return decoder2.decode(new Uint8Array(getMemory().buffer, ptr, len));
|
|
281
281
|
}
|
|
282
282
|
function writeBytes2(buf_ptr, buf_max, data) {
|
|
@@ -302,9 +302,9 @@ function createFetchImports(getMemory) {
|
|
|
302
302
|
return headers;
|
|
303
303
|
}
|
|
304
304
|
async function doFetch(url_ptr, url_len, method_ptr, method_len, headers_ptr, headers_len, body_ptr, body_len, timeout_ms, status_out, buf_ptr, buf_max) {
|
|
305
|
-
const url =
|
|
306
|
-
const method = method_len > 0 ?
|
|
307
|
-
const headersJson = headers_len > 0 ?
|
|
305
|
+
const url = readStr2(url_ptr, url_len);
|
|
306
|
+
const method = method_len > 0 ? readStr2(method_ptr, method_len) : "GET";
|
|
307
|
+
const headersJson = headers_len > 0 ? readStr2(headers_ptr, headers_len) : "{}";
|
|
308
308
|
const body = body_len > 0 ? readBytes(body_ptr, body_len) : void 0;
|
|
309
309
|
const headers = parseHeaders(headersJson);
|
|
310
310
|
const controller = new AbortController();
|
|
@@ -327,14 +327,14 @@ function createFetchImports(getMemory) {
|
|
|
327
327
|
return -1;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
331
|
-
if (typeof
|
|
330
|
+
const Suspending2 = WebAssembly.Suspending;
|
|
331
|
+
if (typeof Suspending2 !== "function") {
|
|
332
332
|
return {
|
|
333
333
|
fetch: (_url_ptr, _url_len, _method_ptr, _method_len, _headers_ptr, _headers_len, _body_ptr, _body_len, _timeout_ms, _status_out, _buf_ptr, _buf_max) => -1
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
336
|
return {
|
|
337
|
-
fetch: new
|
|
337
|
+
fetch: new Suspending2(doFetch)
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
340
|
|
|
@@ -805,6 +805,55 @@ var SVG_TAG_START_INDEX = 140;
|
|
|
805
805
|
var CUSTOM_TAG_INDEX = 199;
|
|
806
806
|
|
|
807
807
|
// src/wasm/dom_cmd.ts
|
|
808
|
+
var BOOL_PROPS = /* @__PURE__ */ new Set([
|
|
809
|
+
"checked",
|
|
810
|
+
"selected",
|
|
811
|
+
"muted",
|
|
812
|
+
"defaultChecked",
|
|
813
|
+
"indeterminate"
|
|
814
|
+
]);
|
|
815
|
+
function enqueueAfterConnect(queue, el, kind) {
|
|
816
|
+
for (let i = 0; i < queue.length; i++) {
|
|
817
|
+
const job = queue[i];
|
|
818
|
+
if (job.el === el && job.kind === kind) return;
|
|
819
|
+
}
|
|
820
|
+
queue.push({ el, kind });
|
|
821
|
+
}
|
|
822
|
+
function runAfterConnect(queue) {
|
|
823
|
+
for (let i = 0; i < queue.length; i++) {
|
|
824
|
+
const job = queue[i];
|
|
825
|
+
if (!job.el.isConnected) continue;
|
|
826
|
+
switch (job.kind) {
|
|
827
|
+
case "focus": {
|
|
828
|
+
if (typeof job.el.focus !== "function") break;
|
|
829
|
+
try {
|
|
830
|
+
job.el.focus({ preventScroll: true });
|
|
831
|
+
} catch {
|
|
832
|
+
job.el.focus();
|
|
833
|
+
}
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
function assignProp(el, name, val) {
|
|
840
|
+
if (BOOL_PROPS.has(name)) {
|
|
841
|
+
const on = val !== "false";
|
|
842
|
+
el[name] = on;
|
|
843
|
+
if (name === "defaultChecked" && "checked" in el) {
|
|
844
|
+
el.checked = on;
|
|
845
|
+
}
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
if (name === "defaultValue") {
|
|
849
|
+
el.defaultValue = val;
|
|
850
|
+
if (typeof el.value === "string" && (el.value === "" || el.value === el.defaultValue)) {
|
|
851
|
+
el.value = val;
|
|
852
|
+
}
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
el[name] = val;
|
|
856
|
+
}
|
|
808
857
|
function flushDomCmds(ptr, len, ctx) {
|
|
809
858
|
const start = ptr >>> 0;
|
|
810
859
|
const length = len >>> 0;
|
|
@@ -816,6 +865,7 @@ function flushDomCmds(ptr, len, ctx) {
|
|
|
816
865
|
const recordsBytes = count * DOM_CMD_RECORD_SIZE;
|
|
817
866
|
if (DOM_CMD_HEADER_SIZE + recordsBytes > length) return;
|
|
818
867
|
const { domNodes: domNodes2, cleanupDomNodes: cleanupDomNodes2 } = ctx;
|
|
868
|
+
const afterConnect = [];
|
|
819
869
|
for (let i = 0; i < count; i++) {
|
|
820
870
|
const off = DOM_CMD_HEADER_SIZE + i * DOM_CMD_RECORD_SIZE;
|
|
821
871
|
const op = view.getUint8(off);
|
|
@@ -848,20 +898,19 @@ function flushDomCmds(ptr, len, ctx) {
|
|
|
848
898
|
break;
|
|
849
899
|
}
|
|
850
900
|
case DomOp_SetAttr: {
|
|
851
|
-
domNodes2.get(p0)
|
|
901
|
+
const el = domNodes2.get(p0);
|
|
902
|
+
if (!el) break;
|
|
903
|
+
const name = readString(p1, p2);
|
|
904
|
+
const val = readString(p3, p4);
|
|
905
|
+
el.setAttribute(name, val);
|
|
906
|
+
if (name === "autofocus") {
|
|
907
|
+
enqueueAfterConnect(afterConnect, el, "focus");
|
|
908
|
+
}
|
|
852
909
|
break;
|
|
853
910
|
}
|
|
854
911
|
case DomOp_SetProp: {
|
|
855
912
|
const el = domNodes2.get(p0);
|
|
856
|
-
if (el)
|
|
857
|
-
const name = readString(p1, p2);
|
|
858
|
-
const val = readString(p3, p4);
|
|
859
|
-
if (name === "checked" || name === "selected" || name === "muted") {
|
|
860
|
-
el[name] = val !== "false";
|
|
861
|
-
} else {
|
|
862
|
-
el[name] = val;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
913
|
+
if (el) assignProp(el, readString(p1, p2), readString(p3, p4));
|
|
865
914
|
break;
|
|
866
915
|
}
|
|
867
916
|
case DomOp_RemoveAttr: {
|
|
@@ -914,225 +963,208 @@ function flushDomCmds(ptr, len, ctx) {
|
|
|
914
963
|
break;
|
|
915
964
|
}
|
|
916
965
|
}
|
|
966
|
+
runAfterConnect(afterConnect);
|
|
917
967
|
}
|
|
918
968
|
|
|
919
969
|
// src/runtime/kv/extern.ts
|
|
970
|
+
var Suspending = WebAssembly.Suspending;
|
|
971
|
+
var jspi = typeof Suspending === "function";
|
|
972
|
+
var miss = jspi ? -1 : 0;
|
|
920
973
|
function putOptions(ttlSeconds) {
|
|
921
974
|
if (ttlSeconds < 60) return void 0;
|
|
922
975
|
return { expirationTtl: ttlSeconds };
|
|
923
976
|
}
|
|
977
|
+
function kvDel(binding, key) {
|
|
978
|
+
const b = binding;
|
|
979
|
+
return (b.del ?? b.delete).call(b, key);
|
|
980
|
+
}
|
|
924
981
|
function isSyncKVNamespace(binding) {
|
|
925
|
-
|
|
926
|
-
return typeof candidate.getSync === "function" && typeof candidate.putSync === "function" && typeof candidate.deleteSync === "function" && typeof candidate.listSync === "function";
|
|
982
|
+
return typeof binding.get === "function" && binding.get.constructor.name !== "AsyncFunction";
|
|
927
983
|
}
|
|
928
|
-
function
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
984
|
+
function listOpts(prefix) {
|
|
985
|
+
return prefix.length > 0 ? { prefix } : void 0;
|
|
986
|
+
}
|
|
987
|
+
function maybeThen(r, f) {
|
|
988
|
+
return r instanceof Promise ? r.then(f) : f(r);
|
|
989
|
+
}
|
|
990
|
+
function readStr(getMemory, ptr, len) {
|
|
991
|
+
return textDecoder.decode(new Uint8Array(getMemory().buffer, ptr, len));
|
|
992
|
+
}
|
|
993
|
+
function resolve(bindings, ns) {
|
|
994
|
+
const b = bindings[ns] ?? bindings["default"] ?? null;
|
|
995
|
+
if (!b || jspi) return b;
|
|
996
|
+
return isSyncKVNamespace(b) ? b : null;
|
|
997
|
+
}
|
|
998
|
+
function encodeGet(getMemory, allocRef, value, out_ptr) {
|
|
999
|
+
if (value === null) return -1;
|
|
1000
|
+
return writeBytesOut(getMemory, allocRef, out_ptr, textEncoder.encode(value));
|
|
1001
|
+
}
|
|
1002
|
+
function encodeList(getMemory, allocRef, names, out_ptr) {
|
|
1003
|
+
if (names.length === 0) {
|
|
1004
|
+
new DataView(getMemory().buffer).setUint32(out_ptr, 0, true);
|
|
1005
|
+
return 0;
|
|
936
1006
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
b.deleteSync(readStr(key_ptr, key_len));
|
|
962
|
-
return 0;
|
|
963
|
-
},
|
|
964
|
-
kv_list: (ns_ptr, ns_len, pfx_ptr, pfx_len, out_ptr) => {
|
|
965
|
-
const b = syncBinding2(readStr(ns_ptr, ns_len));
|
|
966
|
-
if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
|
|
967
|
-
const prefix = readStr(pfx_ptr, pfx_len);
|
|
968
|
-
const result = b.listSync(prefix.length > 0 ? { prefix } : void 0);
|
|
969
|
-
return writeJsonOut(getMemory, allocRef, out_ptr, result.keys.map((k) => k.name));
|
|
970
|
-
}
|
|
971
|
-
};
|
|
1007
|
+
return writeJsonOut(getMemory, allocRef, out_ptr, names);
|
|
1008
|
+
}
|
|
1009
|
+
function get(b, key, out_ptr, getMemory, allocRef) {
|
|
1010
|
+
return maybeThen(b.get(key), (v) => encodeGet(getMemory, allocRef, v, out_ptr));
|
|
1011
|
+
}
|
|
1012
|
+
function put(b, key, val, ttl) {
|
|
1013
|
+
return maybeThen(b.put(key, val, putOptions(ttl)), () => 0);
|
|
1014
|
+
}
|
|
1015
|
+
function del(b, key) {
|
|
1016
|
+
return maybeThen(kvDel(b, key), () => 0);
|
|
1017
|
+
}
|
|
1018
|
+
function list(b, prefix, out_ptr, getMemory, allocRef) {
|
|
1019
|
+
return maybeThen(
|
|
1020
|
+
b.list(listOpts(prefix)),
|
|
1021
|
+
(result) => encodeList(getMemory, allocRef, result.keys.map((k) => k.name), out_ptr)
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
function wrapImport(impl) {
|
|
1025
|
+
if (!jspi) {
|
|
1026
|
+
return ((...args) => {
|
|
1027
|
+
const r = impl(...args);
|
|
1028
|
+
if (r instanceof Promise) throw new Error("async kv binding requires JSPI");
|
|
1029
|
+
return r;
|
|
1030
|
+
});
|
|
972
1031
|
}
|
|
1032
|
+
return new Suspending(impl);
|
|
1033
|
+
}
|
|
1034
|
+
function createKVImports(bindings, getMemory, allocRef) {
|
|
973
1035
|
return {
|
|
974
|
-
kv_get:
|
|
975
|
-
const b =
|
|
1036
|
+
kv_get: wrapImport((ns_ptr, ns_len, key_ptr, key_len, out_ptr) => {
|
|
1037
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
976
1038
|
if (!b) return -1;
|
|
977
|
-
|
|
978
|
-
if (value === null) return -1;
|
|
979
|
-
return writeBytesOut(getMemory, allocRef, out_ptr, encoder2.encode(value));
|
|
1039
|
+
return get(b, readStr(getMemory, key_ptr, key_len), out_ptr, getMemory, allocRef);
|
|
980
1040
|
}),
|
|
981
|
-
kv_put:
|
|
982
|
-
const b =
|
|
983
|
-
if (!b) return
|
|
984
|
-
|
|
985
|
-
|
|
1041
|
+
kv_put: wrapImport((ns_ptr, ns_len, key_ptr, key_len, val_ptr, val_len, ttl_seconds) => {
|
|
1042
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
1043
|
+
if (!b) return miss;
|
|
1044
|
+
return put(
|
|
1045
|
+
b,
|
|
1046
|
+
readStr(getMemory, key_ptr, key_len),
|
|
1047
|
+
readStr(getMemory, val_ptr, val_len),
|
|
1048
|
+
ttl_seconds
|
|
1049
|
+
);
|
|
986
1050
|
}),
|
|
987
|
-
kv_delete:
|
|
988
|
-
const b =
|
|
989
|
-
if (!b) return
|
|
990
|
-
|
|
991
|
-
return 0;
|
|
1051
|
+
kv_delete: wrapImport((ns_ptr, ns_len, key_ptr, key_len) => {
|
|
1052
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
1053
|
+
if (!b) return miss;
|
|
1054
|
+
return del(b, readStr(getMemory, key_ptr, key_len));
|
|
992
1055
|
}),
|
|
993
|
-
kv_list:
|
|
994
|
-
const b =
|
|
1056
|
+
kv_list: wrapImport((ns_ptr, ns_len, pfx_ptr, pfx_len, out_ptr) => {
|
|
1057
|
+
const b = resolve(bindings, readStr(getMemory, ns_ptr, ns_len));
|
|
995
1058
|
if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
|
|
996
|
-
|
|
997
|
-
const result = await b.list(prefix.length > 0 ? { prefix } : void 0);
|
|
998
|
-
const names = result.keys.map((k) => k.name);
|
|
999
|
-
if (names.length === 0) {
|
|
1000
|
-
new DataView(getMemory().buffer).setUint32(out_ptr, 0, true);
|
|
1001
|
-
return 0;
|
|
1002
|
-
}
|
|
1003
|
-
return writeJsonOut(getMemory, allocRef, out_ptr, names);
|
|
1059
|
+
return list(b, readStr(getMemory, pfx_ptr, pfx_len), out_ptr, getMemory, allocRef);
|
|
1004
1060
|
})
|
|
1005
1061
|
};
|
|
1006
1062
|
}
|
|
1007
1063
|
|
|
1008
1064
|
// src/runtime/kv/localstorage.ts
|
|
1009
|
-
|
|
1065
|
+
var namespace = "default";
|
|
1066
|
+
var storagePrefix = "ziex-kv";
|
|
1067
|
+
var namespacePrefix = `${storagePrefix}:${namespace}:`;
|
|
1068
|
+
function storage() {
|
|
1010
1069
|
if (typeof localStorage === "undefined") {
|
|
1011
1070
|
throw new Error("localStorage is not available in this environment");
|
|
1012
1071
|
}
|
|
1013
1072
|
return localStorage;
|
|
1014
1073
|
}
|
|
1015
|
-
function
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
deleteSync(key) {
|
|
1035
|
-
storage.removeItem(scopedKey(key));
|
|
1036
|
-
},
|
|
1037
|
-
async delete(key) {
|
|
1038
|
-
this.deleteSync(key);
|
|
1039
|
-
},
|
|
1040
|
-
listSync(options2) {
|
|
1041
|
-
const prefix = namespacePrefix + (options2?.prefix ?? "");
|
|
1042
|
-
const keys = [];
|
|
1043
|
-
for (let i = 0; i < storage.length; i += 1) {
|
|
1044
|
-
const key = storage.key(i);
|
|
1045
|
-
if (!key || !key.startsWith(prefix)) continue;
|
|
1046
|
-
keys.push({ name: key.slice(namespacePrefix.length) });
|
|
1047
|
-
}
|
|
1048
|
-
return { keys };
|
|
1049
|
-
},
|
|
1050
|
-
async list(options2) {
|
|
1051
|
-
return this.listSync(options2);
|
|
1052
|
-
}
|
|
1053
|
-
};
|
|
1074
|
+
function get2(key) {
|
|
1075
|
+
return storage().getItem(`${storagePrefix}:${namespace}:${key}`);
|
|
1076
|
+
}
|
|
1077
|
+
function put2(key, value) {
|
|
1078
|
+
storage().setItem(`${storagePrefix}:${namespace}:${key}`, value);
|
|
1079
|
+
}
|
|
1080
|
+
function del2(key) {
|
|
1081
|
+
storage().removeItem(`${storagePrefix}:${namespace}:${key}`);
|
|
1082
|
+
}
|
|
1083
|
+
function list2(options) {
|
|
1084
|
+
const ls = storage();
|
|
1085
|
+
const prefix = namespacePrefix + (options?.prefix ?? "");
|
|
1086
|
+
const keys = [];
|
|
1087
|
+
for (let i = 0; i < ls.length; i += 1) {
|
|
1088
|
+
const key = ls.key(i);
|
|
1089
|
+
if (!key || !key.startsWith(prefix)) continue;
|
|
1090
|
+
keys.push({ name: key.slice(namespacePrefix.length) });
|
|
1091
|
+
}
|
|
1092
|
+
return { keys };
|
|
1054
1093
|
}
|
|
1055
1094
|
|
|
1056
1095
|
// src/runtime/kv/indexdb.ts
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1096
|
+
var databaseName = "ziex-kv";
|
|
1097
|
+
var storeName = "kv";
|
|
1098
|
+
var namespace2 = "default";
|
|
1099
|
+
var dbPromise;
|
|
1100
|
+
function openDb() {
|
|
1101
|
+
if (!dbPromise) {
|
|
1102
|
+
if (typeof indexedDB === "undefined") {
|
|
1103
|
+
return Promise.reject(new Error("IndexedDB is not available in this environment"));
|
|
1104
|
+
}
|
|
1105
|
+
dbPromise = new Promise((resolve2, reject) => {
|
|
1106
|
+
const request = indexedDB.open(databaseName, 1);
|
|
1107
|
+
request.onupgradeneeded = () => {
|
|
1108
|
+
const db = request.result;
|
|
1109
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
1110
|
+
db.createObjectStore(storeName);
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
request.onsuccess = () => resolve2(request.result);
|
|
1114
|
+
request.onerror = () => reject(request.error ?? new Error("Failed to open IndexedDB"));
|
|
1115
|
+
});
|
|
1060
1116
|
}
|
|
1061
|
-
return
|
|
1117
|
+
return dbPromise;
|
|
1062
1118
|
}
|
|
1063
1119
|
function requestToPromise(request) {
|
|
1064
|
-
return new Promise((
|
|
1065
|
-
request.onsuccess = () =>
|
|
1120
|
+
return new Promise((resolve2, reject) => {
|
|
1121
|
+
request.onsuccess = () => resolve2(request.result);
|
|
1066
1122
|
request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
|
|
1067
1123
|
});
|
|
1068
1124
|
}
|
|
1069
1125
|
function transactionToPromise(transaction) {
|
|
1070
|
-
return new Promise((
|
|
1071
|
-
transaction.oncomplete = () =>
|
|
1126
|
+
return new Promise((resolve2, reject) => {
|
|
1127
|
+
transaction.oncomplete = () => resolve2();
|
|
1072
1128
|
transaction.onabort = () => reject(transaction.error ?? new Error("IndexedDB transaction aborted"));
|
|
1073
1129
|
transaction.onerror = () => reject(transaction.error ?? new Error("IndexedDB transaction failed"));
|
|
1074
1130
|
});
|
|
1075
1131
|
}
|
|
1076
|
-
function
|
|
1077
|
-
const
|
|
1078
|
-
const
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1132
|
+
async function get3(key) {
|
|
1133
|
+
const db = await openDb();
|
|
1134
|
+
const tx = db.transaction(storeName, "readonly");
|
|
1135
|
+
const value = await requestToPromise(tx.objectStore(storeName).get(`${namespace2}:${key}`));
|
|
1136
|
+
await transactionToPromise(tx);
|
|
1137
|
+
return typeof value === "string" ? value : null;
|
|
1138
|
+
}
|
|
1139
|
+
async function put3(key, value) {
|
|
1140
|
+
const db = await openDb();
|
|
1141
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
1142
|
+
tx.objectStore(storeName).put(value, `${namespace2}:${key}`);
|
|
1143
|
+
await transactionToPromise(tx);
|
|
1144
|
+
}
|
|
1145
|
+
async function del3(key) {
|
|
1146
|
+
const db = await openDb();
|
|
1147
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
1148
|
+
tx.objectStore(storeName).delete(`${namespace2}:${key}`);
|
|
1149
|
+
await transactionToPromise(tx);
|
|
1150
|
+
}
|
|
1151
|
+
async function list3(options) {
|
|
1152
|
+
const db = await openDb();
|
|
1153
|
+
const tx = db.transaction(storeName, "readonly");
|
|
1154
|
+
const keys = await requestToPromise(tx.objectStore(storeName).getAllKeys());
|
|
1155
|
+
await transactionToPromise(tx);
|
|
1156
|
+
const prefix = `${namespace2}:${options?.prefix ?? ""}`;
|
|
1092
1157
|
return {
|
|
1093
|
-
|
|
1094
|
-
const db = await dbPromise;
|
|
1095
|
-
const tx = db.transaction(storeName, "readonly");
|
|
1096
|
-
const store = tx.objectStore(storeName);
|
|
1097
|
-
const value = await requestToPromise(store.get(scopedKey(key)));
|
|
1098
|
-
await transactionToPromise(tx);
|
|
1099
|
-
return typeof value === "string" ? value : null;
|
|
1100
|
-
},
|
|
1101
|
-
async put(key, value) {
|
|
1102
|
-
const db = await dbPromise;
|
|
1103
|
-
const tx = db.transaction(storeName, "readwrite");
|
|
1104
|
-
tx.objectStore(storeName).put(value, scopedKey(key));
|
|
1105
|
-
await transactionToPromise(tx);
|
|
1106
|
-
},
|
|
1107
|
-
async delete(key) {
|
|
1108
|
-
const db = await dbPromise;
|
|
1109
|
-
const tx = db.transaction(storeName, "readwrite");
|
|
1110
|
-
tx.objectStore(storeName).delete(scopedKey(key));
|
|
1111
|
-
await transactionToPromise(tx);
|
|
1112
|
-
},
|
|
1113
|
-
async list(options2) {
|
|
1114
|
-
const db = await dbPromise;
|
|
1115
|
-
const tx = db.transaction(storeName, "readonly");
|
|
1116
|
-
const store = tx.objectStore(storeName);
|
|
1117
|
-
const keys = await requestToPromise(store.getAllKeys());
|
|
1118
|
-
await transactionToPromise(tx);
|
|
1119
|
-
const prefix = scopedKey(options2?.prefix ?? "");
|
|
1120
|
-
return {
|
|
1121
|
-
keys: keys.filter((key) => typeof key === "string" && key.startsWith(prefix)).map((key) => ({ name: key.slice(namespace.length + 1) }))
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1158
|
+
keys: keys.filter((key) => typeof key === "string" && key.startsWith(prefix)).map((key) => ({ name: key.slice(namespace2.length + 1) }))
|
|
1124
1159
|
};
|
|
1125
1160
|
}
|
|
1126
1161
|
|
|
1127
1162
|
// src/runtime/kv.ts
|
|
1128
|
-
function
|
|
1129
|
-
return typeof WebAssembly.Suspending === "function" && typeof WebAssembly.promising === "function";
|
|
1130
|
-
}
|
|
1163
|
+
var hasJspi = typeof WebAssembly.Suspending === "function" && typeof WebAssembly.promising === "function";
|
|
1131
1164
|
function createBrowserKVBindings(options = {}) {
|
|
1132
|
-
const
|
|
1133
|
-
const isIndexedDb = hasJSPI() && !options.forceLocalStorage;
|
|
1165
|
+
const namespace3 = options.namespace ?? "default";
|
|
1134
1166
|
return {
|
|
1135
|
-
[
|
|
1167
|
+
[namespace3]: hasJspi && !options.forceLocalStorage ? { get: get3, put: put3, del: del3, list: list3 } : { get: get2, put: put2, del: del2, list: list2 }
|
|
1136
1168
|
};
|
|
1137
1169
|
}
|
|
1138
1170
|
|
|
@@ -1404,6 +1436,10 @@ var ZxBridge = class extends ZxBridgeCore {
|
|
|
1404
1436
|
if (!form || !(form instanceof HTMLFormElement)) return;
|
|
1405
1437
|
const statesJson = statesLen > 0 ? readString(statesPtr, statesLen) : "[]";
|
|
1406
1438
|
bridgeRef[0]?.submitFormActionAsync(form, actionId, statesJson, fetchId);
|
|
1439
|
+
},
|
|
1440
|
+
_formReset: (vnodeId) => {
|
|
1441
|
+
const form = domNodes.get(Number(vnodeId));
|
|
1442
|
+
if (form instanceof HTMLFormElement) form.reset();
|
|
1407
1443
|
}
|
|
1408
1444
|
}
|
|
1409
1445
|
};
|