2023-12-07 23:22:28 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
2024-09-20 15:23:15 +00:00
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
2023-12-07 23:22:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import type {ɵGlobalDevModeUtils as GlobalDevModeUtils} from '@angular/core';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a handle to window.ng APIs (global angular debugging).
|
|
|
|
|
*
|
|
|
|
|
* @returns window.ng
|
|
|
|
|
*/
|
2025-03-04 23:24:10 +00:00
|
|
|
export const ngDebugClient = () => (window as any).ng as Partial<GlobalDevModeUtils['ng']>;
|
2023-12-07 23:22:28 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks whether a given debug API is supported within window.ng
|
|
|
|
|
*
|
|
|
|
|
* @returns boolean
|
|
|
|
|
*/
|
|
|
|
|
export function ngDebugApiIsSupported(api: keyof GlobalDevModeUtils['ng']): boolean {
|
|
|
|
|
const ng = ngDebugClient();
|
|
|
|
|
return typeof ng[api] === 'function';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks whether Dependency Injection debug API is supported within window.ng
|
|
|
|
|
*
|
|
|
|
|
* @returns boolean
|
|
|
|
|
*/
|
|
|
|
|
export function ngDebugDependencyInjectionApiIsSupported(): boolean {
|
2025-03-04 22:49:53 +00:00
|
|
|
if (!ngDebugApiIsSupported('getInjector')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-12-07 23:22:28 +00:00
|
|
|
if (!ngDebugApiIsSupported('ɵgetInjectorResolutionPath')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!ngDebugApiIsSupported('ɵgetDependenciesFromInjectable')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!ngDebugApiIsSupported('ɵgetInjectorProviders')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!ngDebugApiIsSupported('ɵgetInjectorMetadata')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|