/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/core/src/debug/ai/registration.ts
38 строк
1 KB
Cameron Smick
refactor(core): move devtools ai tool definition types to primitives
07 июл 2026, 20:18
07 июл 2026, 20:18
bf6dba8
Код
Авторство
О чём код?
/** * @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 {diGraphTool} from './di_graph'; import {signalGraphTool} from './signal_graph'; import {DevtoolsToolDiscoveryEvent} from '../../../primitives/devtools'; /** * Registers Angular AI tools with Chrome DevTools. * * This function listens for the `devtoolstooldiscovery` event and responds with * the available Angular-specific tools. * * @returns A callback function to unregister the tools. */ export function registerAiTools(): () => void { // No-op in non-browser environments. // Need to explicitly check for `addEventListener` as some hydration tests define `window = globalThis;`. if (typeof window === 'undefined' || !window.addEventListener) return () => {}; function listener(inputEvent: Event): void { const event = inputEvent as DevtoolsToolDiscoveryEvent; event.respondWith({ name: 'Angular', tools: [diGraphTool, signalGraphTool], }); } window.addEventListener('devtoolstooldiscovery', listener); return () => { window.removeEventListener('devtoolstooldiscovery', listener); }; }