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