/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
devtools/projects/ng-devtools-backend/src/lib/profiling/profiler/index.ts
48 строк
1 KB
hawkgs
refactor(devtools): reorganize backend code
20 июл 2026, 12:15
20 июл 2026, 12:15
a7ebf1c
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ngDebugClient} from '../../shared/ng-debug-api/ng-debug-api'; import {NgProfiler} from './native'; import {PatchingProfiler} from './polyfill'; import {Profiler} from './shared'; export {type Hooks, Profiler} from './shared'; // Global reference. let profiler: Profiler; /** * Factory method for creating profiler object. * Gives priority to NgProfiler, falls back on PatchingProfiler if framework APIs are not present. */ const selectProfilerStrategy = (): Profiler => { if (typeof ngDebugClient().ɵsetProfiler === 'function') { return new NgProfiler(); } return new PatchingProfiler(); }; /** * Get the Profiler reference. * Initializes the Profiler if it wasn't requested before. */ export function getProfiler( depsForTestOnly: { profiler?: new (...args: any[]) => Profiler; } = {}, ): Profiler { // Allow for overriding the Profiler implementation for testing purposes. if (depsForTestOnly.profiler) { profiler = new depsForTestOnly.profiler(); } if (!profiler) { profiler = selectProfilerStrategy(); } return profiler; }