// source/graphiql/assets.ts import css from "./standalone.css" with { type: "text" }; import favicon from "./favicon.svg" with { type: "text" }; import js from "./standalone.js" with { type: "text" }; import { GRAPHIQL_VERSION } from "./version.ts"; const base = `/_graphiql/${GRAPHIQL_VERSION}`; export const assets: Record = { [`${base}/favicon.svg`]: { body: favicon, type: "image/svg+xml" }, [`${base}/standalone.css`]: { body: css, type: "text/css; charset=utf-8" }, [`${base}/standalone.js`]: { body: js, type: "text/javascript; charset=utf-8" } }; export function serveAsset(request: { url: string }): Response | undefined { const { pathname } = new URL(request.url); const key = Object.keys(assets).find((path) => pathname.endsWith(path)); if (!key) return; return new Response(assets[key].body, { headers: { "cache-control": "public, max-age=31536000, immutable", "content-type": assets[key].type } }); }