- vm_api.py: pure FastAPI JSON API on :8098 with CORS - vm-api.service: systemd unit for API (replaces inline HTML vm_web.py for frontend) - vm_web.py: kept intact as fallback; Apache now proxies /api/ -> :8098 - frontend/: Vite + React + TanStack Query scaffold - Apache vhost updated: DocumentRoot -> frontend/dist, /api/ proxy, SPA fallback - All original HTML pages still functional via :8099 during transition
52 lines
2.4 KiB
JavaScript
52 lines
2.4 KiB
JavaScript
"use client";
|
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
const require_matchContext = require("./matchContext.cjs");
|
|
const require_useRouter = require("./useRouter.cjs");
|
|
let _tanstack_router_core = require("@tanstack/router-core");
|
|
let react = require("react");
|
|
react = require_runtime.__toESM(react, 1);
|
|
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
|
|
let _tanstack_react_store = require("@tanstack/react-store");
|
|
//#region src/useMatch.tsx
|
|
var dummyMatch = {};
|
|
function useStructuralSharing(opts, router) {
|
|
const previousResult = react.useRef();
|
|
return (slice) => {
|
|
const selected = opts?.select ? opts.select(slice) : slice;
|
|
if (opts?.structuralSharing ?? router.options.defaultStructuralSharing) return previousResult.current = (0, _tanstack_router_core.replaceEqualDeep)(previousResult.current, selected);
|
|
return selected;
|
|
};
|
|
}
|
|
/**
|
|
* Read and select the nearest or targeted route match.
|
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchHook
|
|
*/
|
|
function useMatch(opts) {
|
|
const router = require_useRouter.useRouter();
|
|
const nearestRouteId = react.useContext(opts.from ? require_matchContext.dummyMatchContext : require_matchContext.matchContext);
|
|
const routeId = opts.from ?? nearestRouteId;
|
|
const matchStore = router.stores.getMatchStore(routeId);
|
|
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
|
|
const match = matchStore.get();
|
|
if (!match) {
|
|
if (opts.shouldThrow ?? true) {
|
|
if (process.env.NODE_ENV !== "production") throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
|
|
(0, _tanstack_router_core.invariant)();
|
|
}
|
|
return;
|
|
}
|
|
return opts.select ? opts.select(match) : match;
|
|
}
|
|
const selector = useStructuralSharing(opts, router);
|
|
const matchSelection = (0, _tanstack_react_store.useStore)(matchStore, (match) => match ? selector(match) : dummyMatch);
|
|
if (matchSelection !== dummyMatch) return matchSelection;
|
|
if (opts.shouldThrow ?? true) {
|
|
if (process.env.NODE_ENV !== "production") throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
|
|
(0, _tanstack_router_core.invariant)();
|
|
}
|
|
}
|
|
//#endregion
|
|
exports.useMatch = useMatch;
|
|
exports.useStructuralSharing = useStructuralSharing;
|
|
|
|
//# sourceMappingURL=useMatch.cjs.map
|