mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(devtools): check if signal graph is supported (#61915)
add a new devtools field in SupportedApis to check if the getSignalGraphApi exists PR Close #61915
This commit is contained in:
parent
ef10aa4005
commit
fd2fca8bce
5 changed files with 32 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ import {
|
|||
ngDebugDependencyInjectionApiIsSupported,
|
||||
ngDebugProfilerApiIsSupported,
|
||||
ngDebugRoutesApiIsSupported,
|
||||
ngDebugSignalGraphApiIsSupported,
|
||||
} from './ng-debug-api';
|
||||
import {Framework} from '../component-tree/core-enums';
|
||||
|
||||
|
|
@ -113,4 +114,24 @@ describe('ng-debug-api', () => {
|
|||
expect(ngDebugRoutesApiIsSupported()).toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ngDebugSignalGraphIsSupported', () => {
|
||||
beforeEach(() => mockRoot());
|
||||
|
||||
it('should support Signal Graph API with getSignalGraph', () => {
|
||||
(globalThis as any).ng = fakeNgGlobal(Framework.Angular);
|
||||
(globalThis as any).ng.ɵgetSignalGraph = () => {};
|
||||
expect(ngDebugSignalGraphApiIsSupported()).toBeTrue();
|
||||
});
|
||||
|
||||
it('should not support Signal Graph API with no getSignalGraph', () => {
|
||||
(globalThis as any).ng = fakeNgGlobal(Framework.ACX);
|
||||
(globalThis as any).ng.ɵgetSignalGraph = 'not implemented';
|
||||
expect(ngDebugSignalGraphApiIsSupported()).toBeFalse();
|
||||
|
||||
(globalThis as any).ng = fakeNgGlobal(Framework.ACX);
|
||||
(globalThis as any).ng.ɵgetSignalGraph = undefined;
|
||||
expect(ngDebugSignalGraphApiIsSupported()).toBeFalse();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -75,3 +75,9 @@ export function ngDebugRoutesApiIsSupported(): boolean {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
/** Checks whether Signal Graph API is supported within window.ng */
|
||||
export function ngDebugSignalGraphApiIsSupported(): boolean {
|
||||
const ng = ngDebugClient();
|
||||
return ngDebugApiIsSupported(ng, 'ɵgetSignalGraph');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
ngDebugDependencyInjectionApiIsSupported,
|
||||
ngDebugProfilerApiIsSupported,
|
||||
ngDebugRoutesApiIsSupported,
|
||||
ngDebugSignalGraphApiIsSupported,
|
||||
} from './ng-debug-api';
|
||||
|
||||
/**
|
||||
|
|
@ -22,10 +23,12 @@ export function getSupportedApis(): SupportedApis {
|
|||
const profiler = ngDebugProfilerApiIsSupported();
|
||||
const dependencyInjection = ngDebugDependencyInjectionApiIsSupported();
|
||||
const routes = ngDebugRoutesApiIsSupported();
|
||||
const signals = ngDebugSignalGraphApiIsSupported();
|
||||
|
||||
return {
|
||||
profiler,
|
||||
dependencyInjection,
|
||||
routes,
|
||||
signals,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ export class DevToolsComponent implements OnDestroy {
|
|||
profiler: false,
|
||||
dependencyInjection: false,
|
||||
routes: false,
|
||||
signals: false,
|
||||
});
|
||||
readonly ivy = signal<boolean | undefined>(undefined);
|
||||
|
||||
|
|
|
|||
|
|
@ -338,6 +338,7 @@ export interface SupportedApis {
|
|||
profiler: boolean;
|
||||
dependencyInjection: boolean;
|
||||
routes: boolean;
|
||||
signals: boolean;
|
||||
}
|
||||
|
||||
export interface Events {
|
||||
|
|
|
|||
Loading…
Reference in a new issue