everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 1.78 kB
Source Map (JSON)
{"version":3,"file":"runtime.cjs","names":[],"sources":["../../src/ui/runtime.ts"],"sourcesContent":["import type { ClientRuntimeConfig } from \"../types\";\n\nexport type { ClientRuntimeInfo } from \"../types\";\n\ndeclare global {\n interface Window {\n __RUNTIME_CONFIG__?: ClientRuntimeConfig;\n }\n}\n\nexport function getRuntimeConfig(): ClientRuntimeConfig {\n if (typeof window === \"undefined\") {\n throw new Error(\"Runtime config is only available in the browser\");\n }\n\n if (!window.__RUNTIME_CONFIG__) {\n throw new Error(\"Missing runtime config\");\n }\n\n return window.__RUNTIME_CONFIG__;\n}\n\nexport function buildRuntimeHref(pathname: string, runtimeConfig?: Partial<ClientRuntimeConfig>) {\n const basePath = runtimeConfig?.runtime?.runtimeBasePath ?? \"/\";\n if (basePath === \"/\") {\n return pathname;\n }\n\n if (!pathname.startsWith(\"/\")) {\n return `${basePath}/${pathname}`;\n }\n\n return pathname === \"/\" ? basePath : `${basePath}${pathname}`;\n}\n\nexport function buildPublishedAccountHref(accountId: string) {\n return `/apps/${encodeURIComponent(accountId)}`;\n}\n\nexport function buildPublishedGatewayHref(accountId: string, gatewayId: string) {\n return `${buildPublishedAccountHref(accountId)}/${encodeURIComponent(gatewayId)}`;\n}\n"],"mappings":";;;AAUA,SAAgB,mBAAwC;AACtD,KAAI,OAAO,WAAW,YACpB,OAAM,IAAI,MAAM,kDAAkD;AAGpE,KAAI,CAAC,OAAO,mBACV,OAAM,IAAI,MAAM,yBAAyB;AAG3C,QAAO,OAAO;;AAGhB,SAAgB,iBAAiB,UAAkB,eAA8C;CAC/F,MAAM,WAAW,eAAe,SAAS,mBAAmB;AAC5D,KAAI,aAAa,IACf,QAAO;AAGT,KAAI,CAAC,SAAS,WAAW,IAAI,CAC3B,QAAO,GAAG,SAAS,GAAG;AAGxB,QAAO,aAAa,MAAM,WAAW,GAAG,WAAW;;AAGrD,SAAgB,0BAA0B,WAAmB;AAC3D,QAAO,SAAS,mBAAmB,UAAU;;AAG/C,SAAgB,0BAA0B,WAAmB,WAAmB;AAC9E,QAAO,GAAG,0BAA0B,UAAU,CAAC,GAAG,mBAAmB,UAAU"}