- 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
8.4 KiB
Plaintext
1 line
8.4 KiB
Plaintext
{"version":3,"file":"headContentUtils.cjs","names":[],"sources":["../../src/headContentUtils.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport {\n _getAssetMatches,\n appendUniqueUserTags,\n deepEqual,\n escapeHtml,\n getAssetCrossOrigin,\n getScriptPreloadAttrs,\n resolveManifestCssLink,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouteMatch,\n AssetCrossOriginConfig,\n RouterManagedTag,\n} from '@tanstack/router-core'\n\nfunction buildTagsFromMatches(\n router: ReturnType<typeof useRouter>,\n nonce: string | undefined,\n matches: Array<AnyRouteMatch>,\n assetCrossOrigin?: AssetCrossOriginConfig,\n): Array<RouterManagedTag> {\n matches = _getAssetMatches(matches)\n const routeMeta = matches\n .map((match) => match.meta)\n .filter((meta) => meta !== undefined)\n\n const resultMeta: Array<RouterManagedTag> = []\n const metaByAttribute: Record<string, true> = {}\n let title: RouterManagedTag | undefined\n for (let i = routeMeta.length - 1; i >= 0; i--) {\n const metas = routeMeta[i]!\n for (let j = metas.length - 1; j >= 0; j--) {\n const m = metas[j]\n if (!m) continue\n\n if (m.title) {\n if (!title) {\n title = {\n tag: 'title',\n children: m.title,\n }\n }\n } else if ('script:ld+json' in m) {\n try {\n const json = JSON.stringify(m['script:ld+json'])\n resultMeta.push({\n tag: 'script',\n attrs: {\n type: 'application/ld+json',\n },\n children: escapeHtml(json),\n })\n } catch {\n // Skip invalid JSON-LD objects\n }\n } else {\n const attribute = m.name ?? m.property\n if (attribute) {\n if (metaByAttribute[attribute]) {\n continue\n } else {\n metaByAttribute[attribute] = true\n }\n }\n\n resultMeta.push({\n tag: 'meta',\n attrs: {\n ...m,\n nonce,\n },\n })\n }\n }\n }\n\n if (title) {\n resultMeta.push(title)\n }\n\n if (nonce) {\n resultMeta.push({\n tag: 'meta',\n attrs: {\n property: 'csp-nonce',\n content: nonce,\n },\n })\n }\n resultMeta.reverse()\n\n const constructedLinks = matches\n .flatMap((match) => match.links ?? [])\n .filter((link) => link !== undefined)\n .map((link) => ({\n tag: 'link',\n attrs: {\n ...link,\n nonce,\n },\n })) satisfies Array<RouterManagedTag>\n\n const manifest = router.ssr?.manifest\n const manifestCssTags: Array<RouterManagedTag> = []\n if (manifest) {\n matches.forEach((match) => {\n const css = manifest.routes[match.routeId]?.css\n css?.forEach((link) => {\n const resolvedLink = resolveManifestCssLink(link)\n manifestCssTags.push({\n tag: 'link',\n attrs: {\n rel: 'stylesheet',\n ...resolvedLink,\n crossOrigin:\n getAssetCrossOrigin(assetCrossOrigin, 'stylesheet') ??\n resolvedLink.crossOrigin,\n suppressHydrationWarning: true,\n nonce,\n },\n })\n })\n })\n\n if (manifest.inlineStyle) {\n manifestCssTags.push({\n tag: 'style',\n attrs: {\n ...manifest.inlineStyle.attrs,\n nonce,\n },\n children: manifest.inlineStyle.children,\n inlineCss: true,\n })\n }\n }\n\n const preloadLinks: Array<RouterManagedTag> = []\n if (manifest) {\n matches.forEach((match) => {\n manifest.routes[match.routeId]?.preloads?.forEach((preload) => {\n preloadLinks.push({\n tag: 'link',\n attrs: {\n ...getScriptPreloadAttrs(manifest, preload, assetCrossOrigin),\n nonce,\n },\n })\n })\n })\n }\n\n const styles = matches\n .flatMap((match) => match.styles ?? [])\n .filter((style) => style !== undefined)\n .map(({ children, ...attrs }) => ({\n tag: 'style',\n attrs: {\n ...attrs,\n nonce,\n },\n children: children as string | undefined,\n })) satisfies Array<RouterManagedTag>\n\n const headScripts = matches\n .flatMap((match) => match.headScripts ?? [])\n .filter((script) => script !== undefined)\n .map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n nonce,\n },\n children: children as string | undefined,\n })) satisfies Array<RouterManagedTag>\n\n const tags: Array<RouterManagedTag> = []\n appendUniqueUserTags(tags, resultMeta)\n tags.push(...preloadLinks)\n appendUniqueUserTags(tags, constructedLinks)\n tags.push(...manifestCssTags)\n appendUniqueUserTags(tags, styles)\n appendUniqueUserTags(tags, headScripts)\n return tags\n}\n\n/**\n * Build the head/link/meta/script tags from the renderable presented prefix.\n * Used internally by `HeadContent`.\n */\nexport const useTags = (assetCrossOrigin?: AssetCrossOriginConfig) => {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n\n if (isServer ?? router.isServer) {\n return buildTagsFromMatches(\n router,\n nonce,\n router.stores.matches.get(),\n assetCrossOrigin,\n )\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks -- condition is static\n const selectTags = React.useCallback(\n (matches: Array<AnyRouteMatch>) =>\n buildTagsFromMatches(router, nonce, matches, assetCrossOrigin),\n [assetCrossOrigin, nonce, router],\n )\n // eslint-disable-next-line react-hooks/rules-of-hooks -- condition is static\n return useStore(router.stores.matches, selectTags, deepEqual)\n}\n"],"mappings":";;;;;;;;AAmBA,SAAS,qBACP,QACA,OACA,SACA,kBACyB;CACzB,WAAA,GAAA,sBAAA,kBAA2B,OAAO;CAClC,MAAM,YAAY,QACf,KAAK,UAAU,MAAM,IAAI,EACzB,QAAQ,SAAS,SAAS,KAAA,CAAS;CAEtC,MAAM,aAAsC,CAAC;CAC7C,MAAM,kBAAwC,CAAC;CAC/C,IAAI;CACJ,KAAK,IAAI,IAAI,UAAU,SAAS,GAAG,KAAK,GAAG,KAAK;EAC9C,MAAM,QAAQ,UAAU;EACxB,KAAK,IAAI,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK;GAC1C,MAAM,IAAI,MAAM;GAChB,IAAI,CAAC,GAAG;GAER,IAAI,EAAE;QACA,CAAC,OACH,Q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