UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

26 lines (25 loc) 1.08 kB
//#region src/ui/runtime.ts function getRuntimeConfig() { if (typeof window === "undefined") throw new Error("Runtime config is only available in the browser"); if (!window.__RUNTIME_CONFIG__) throw new Error("Missing runtime config"); return window.__RUNTIME_CONFIG__; } function getCspNonce() { if (typeof window === "undefined") return; return window.__CSP_NONCE__; } function buildRuntimeHref(pathname, runtimeConfig) { const basePath = runtimeConfig?.runtime?.runtimeBasePath ?? "/"; if (basePath === "/") return pathname; if (!pathname.startsWith("/")) return `${basePath}/${pathname}`; return pathname === "/" ? basePath : `${basePath}${pathname}`; } function buildPublishedAccountHref(accountId) { return `/apps/${encodeURIComponent(accountId)}`; } function buildPublishedGatewayHref(accountId, gatewayId) { return `${buildPublishedAccountHref(accountId)}/${encodeURIComponent(gatewayId)}`; } //#endregion export { buildPublishedAccountHref, buildPublishedGatewayHref, buildRuntimeHref, getCspNonce, getRuntimeConfig }; //# sourceMappingURL=runtime.mjs.map