add utils
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s

This commit is contained in:
2026-05-08 12:47:51 +02:00
parent 610c9a9586
commit 369a35d92a
7 changed files with 99 additions and 6 deletions

23
dist/sigpro.js vendored
View File

@@ -833,8 +833,29 @@
router.back = () => window.history.back();
router.path = () => window.location.hash.replace(/^#/, "") || "/";
// src/utils.js
var db = async (url, data = {}, loading = null) => {
if (loading)
loading(true);
try {
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
});
if (!res.ok) {
const errorText = await res.text();
throw new Error(`Error ${res.status}: ${errorText}`);
}
return await res.json();
} finally {
if (loading)
loading(false);
}
};
// src/build_umd.js
if (typeof window !== "undefined") {
Object.assign(window, { $, watch, h, Fragment, when, each, router, mount, batch, onUnmount, isArr, isFunc, isObj });
Object.assign(window, { $, watch, h, Fragment, when, each, router, mount, batch, onUnmount, isArr, isFunc, isObj, db });
}
})();

2
dist/sigpro.min.js vendored

File diff suppressed because one or more lines are too long

23
dist/utils.js vendored Normal file
View File

@@ -0,0 +1,23 @@
// src/utils.js
var db = async (url, data = {}, loading = null) => {
if (loading)
loading(true);
try {
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
});
if (!res.ok) {
const errorText = await res.text();
throw new Error(`Error ${res.status}: ${errorText}`);
}
return await res.json();
} finally {
if (loading)
loading(false);
}
};
export {
db
};