UNPKG

everything-dev

Version:

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

30 lines (29 loc) • 1.29 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 getAppName(config) { const runtimeConfig = config ?? (typeof window === "undefined" ? void 0 : window.__RUNTIME_CONFIG__); return runtimeConfig?.runtime?.title ?? runtimeConfig?.account ?? ""; } 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, getAppName, getCspNonce, getRuntimeConfig }; //# sourceMappingURL=runtime.mjs.map