@westacks/vortex
Version:
Server-based routing for SPAs
42 lines (41 loc) • 1.17 kB
JavaScript
import { p as v } from "../page-DkBioJVC.js";
import "axios";
import { v as d, l as p } from "../dom-BXbsE9_c.js";
import { u as b, b as R } from "../form-6EHLr-hJ.js";
import { useRef as u, useState as k, useEffect as s, useCallback as g } from "react";
const $ = () => i(v), x = a(p), A = a(d);
function D(e, r) {
return i(b(e, r));
}
function E(e, r = "default") {
return i(R(e, r));
}
function i({ get: e, subscribe: r }) {
const t = u(void 0), [, n] = k({});
return t.current === void 0 && (t.current = e()), s(() => r((o) => n({})), []), t.current;
}
function a(e) {
return (r = !0) => {
const t = u(r);
t.current = r;
const n = u(void 0), o = u(void 0), f = u(null), m = g((c) => {
if (c === null) {
n.current?.(), n.current = void 0, o.current = void 0, f.current = null;
return;
}
f.current = c;
const l = e(c, t.current);
n.current = l?.destroy, o.current = l?.update;
}, []);
return s(() => {
o.current?.(t.current);
}, [r]), s(() => () => n.current?.(), []), m;
};
}
export {
D as useForm,
x as useLink,
$ as usePage,
E as useRemember,
A as useVisible
};