- 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
1 line
4.6 KiB
Plaintext
1 line
4.6 KiB
Plaintext
{"version":3,"file":"Transitioner.cjs","names":[],"sources":["../../src/Transitioner.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { getLocationChangeInfo, trimPathRight } from '@tanstack/router-core'\nimport { useLayoutEffect } from './utils'\nimport { useRouter } from './useRouter'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport function settleOwner(\n owner: NonNullable<AnyRouter['_rendered']>,\n rendered: boolean,\n) {\n const settle = owner[1 /* settle */]\n owner.length = 0\n settle?.(rendered)\n}\n\nexport function Transitioner({\n t,\n}: {\n t: React.Dispatch<React.SetStateAction<AnyRouter | undefined>>\n}) {\n const router = useRouter()\n const acknowledgement = (router._rendered ??= [])\n const mounted =\n process.env.NODE_ENV !== 'production'\n ? // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useRef(false)\n : undefined\n\n router.startTransition = (fn, expected) =>\n new Promise((resolve, reject) => {\n settleOwner(acknowledgement, false)\n acknowledgement.push(expected, resolve)\n t(router)\n React.startTransition(() => {\n try {\n fn()\n } catch (cause) {\n if (acknowledgement[1 /* settle */] === resolve) {\n acknowledgement.length = 0\n }\n reject(cause)\n }\n })\n })\n if (process.env.NODE_ENV !== 'production') {\n ;(\n router as typeof router & { _cancelTransition?: () => void }\n )._cancelTransition = () => settleOwner(acknowledgement, false)\n }\n\n // Subscribe before canonicalizing so the initial URL has exactly one load.\n useLayoutEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n if (mounted?.current) {\n return unsub\n }\n if (mounted) {\n mounted.current = true\n }\n\n router.updateLatestLocation()\n const location = router.latestLocation\n const nextLocation = router.buildLocation({\n to: location.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) consistently with server\n // canonicalization.\n if (\n trimPathRight(location.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({\n ...nextLocation,\n replace: true,\n ignoreBlocker: true,\n })\n return unsub\n }\n\n const resolvedLocation = router.stores.resolvedLocation.get()\n if (\n resolvedLocation?.href === location.href &&\n resolvedLocation.state.__TSR_key === location.state.__TSR_key\n ) {\n acknowledgement.push(router.stores.matches.get(), (rendered) => {\n if (rendered) {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(resolvedLocation, resolvedLocation),\n })\n }\n })\n } else if (!router._tx) {\n router.load().catch(console.error)\n }\n\n return unsub\n // `mounted` exists only in development and is a stable ref when present.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [router, router.history])\n\n return null\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,YACd,OACA,UACA;CACA,MAAM,SAAS,MAAM;CACrB,MAAM,SAAS;CACf,SAAS,QAAQ;AACnB;AAEA,SAAgB,aAAa,EAC3B,KAGC;CACD,MAAM,SAAS,kBAAA,UAAU;CACzB,MAAM,kBAAmB,OAAO,cAAc,CAAC;CAC/C,MAAM,UAAA,QAAA,IAAA,aACqB,eAErB,MAAM,OAAO,KAAK,IAClB,KAAA;CAEN,OAAO,mBAAmB,IAAI,aAC5B,IAAI,SAAS,SAAS,WAAW;EAC/B,YAAY,iBAAiB,KAAK;EAClC,gBAAgB,KAAK,UAAU,OAAO;EACtC,EAAE,MAAM;EACR,MAAM,sBAAsB;GAC1B,IAAI;IACF,GAAG;GACL,SAAS,OAAO;IACd,IAAI,gBAAgB,OAAoB,SACtC,gBAAgB,SAAS;IAE3B,OAAO,KAAK;GACd;EACF,CAAC;CACH,CAAC;CACH,IAAA,QAAA,IAAA,aAA6B,cAC1B,OAEC,0BAA0B,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