mirror of
https://github.com/goauthentik/authentik
synced 2026-05-15 11:26:31 +02:00
* Bump related TS packages. * Fix type. * Fix styles. * web: bump typescript from 5.9.3 to 6.0.2 in /web Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.9.3 to 6.0.2. - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Commits](https://github.com/microsoft/TypeScript/compare/v5.9.3...v6.0.2) --- updated-dependencies: - dependency-name: typescript dependency-version: 6.0.2 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Partial upgrade. * Add dep. * Re-add preinstall. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { type ContextControllerRegistryMap } from "#elements/types";
|
|
|
|
/**
|
|
* Check if the environment supports Symbol-keyed WeakMaps.
|
|
*
|
|
* @see {@link https://caniuse.com/mdn-javascript_builtins_weakmap_symbol_as_keys | Can I use}
|
|
*
|
|
* @todo Re-evaluate browser coverage after 2027-01-01
|
|
*/
|
|
function supportsSymbolKeyedWeakMap(): boolean {
|
|
const testKey = Symbol("test");
|
|
const wm = new WeakMap();
|
|
|
|
try {
|
|
wm.set(testKey, "value");
|
|
return wm.has(testKey);
|
|
} catch (_error) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A constructor for either WeakMap or Map, depending on environment support.
|
|
*
|
|
* @remarks
|
|
*
|
|
* A preference for `WeakMap` is optional at the moment.
|
|
* However, if we ever support short-lived context controllers, such as
|
|
*/
|
|
const ContextControllerConstructor = supportsSymbolKeyedWeakMap() ? WeakMap : Map;
|
|
|
|
/**
|
|
* A registry of context controllers added to the Interface.
|
|
*
|
|
* @singleton
|
|
*
|
|
* @remarks
|
|
*
|
|
* This is exported separately to avoid circular dependencies.
|
|
*/
|
|
export const ContextControllerRegistry =
|
|
new (ContextControllerConstructor as WeakMapConstructor)() as ContextControllerRegistryMap;
|