everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
22 lines (21 loc) • 962 B
JavaScript
//#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 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, getRuntimeConfig };
//# sourceMappingURL=runtime.mjs.map