2021-11-07 20:17:14 +01:00
|
|
|
import type { KcContextBase } from "./KcContextBase";
|
|
|
|
import type { AndByDiscriminatingKey } from "../tools/AndByDiscriminatingKey";
|
2023-03-16 22:43:09 +01:00
|
|
|
import { ftlValuesGlobalName } from "../bin/keycloakify/ftlValuesGlobalName";
|
2021-11-07 20:17:14 +01:00
|
|
|
|
|
|
|
export type ExtendsKcContextBase<KcContextExtended extends { pageId: string }> = [KcContextExtended] extends [never]
|
|
|
|
? KcContextBase
|
2023-03-18 16:17:33 +01:00
|
|
|
: AndByDiscriminatingKey<"pageId", KcContextExtended & KcContextBase.Common, KcContextBase>;
|
2021-11-07 20:17:14 +01:00
|
|
|
|
|
|
|
export function getKcContextFromWindow<KcContextExtended extends { pageId: string } = never>(): ExtendsKcContextBase<KcContextExtended> | undefined {
|
|
|
|
return typeof window === "undefined" ? undefined : (window as any)[ftlValuesGlobalName];
|
|
|
|
}
|