everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
36 lines (35 loc) • 1.52 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
//#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
exports.buildPublishedAccountHref = buildPublishedAccountHref;
exports.buildPublishedGatewayHref = buildPublishedGatewayHref;
exports.buildRuntimeHref = buildRuntimeHref;
exports.getAppName = getAppName;
exports.getCspNonce = getCspNonce;
exports.getRuntimeConfig = getRuntimeConfig;
//# sourceMappingURL=runtime.cjs.map