2021-12-10 02:37:01 +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
|
2021-12-10 02:37:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-03-05 03:54:58 +00:00
|
|
|
import {ChangeDetectorRef, Component, inject, OnInit} from '@angular/core';
|
2025-05-08 13:20:37 +00:00
|
|
|
import {DevToolsComponent} from '../../../ng-devtools';
|
|
|
|
|
import {Events, MessageBus} from '../../../protocol';
|
2020-01-27 18:40:18 +00:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
2020-01-29 00:29:23 +00:00
|
|
|
templateUrl: './app.component.html',
|
2020-02-07 21:25:16 +00:00
|
|
|
styleUrls: ['./app.component.scss'],
|
2024-10-23 08:07:34 +00:00
|
|
|
imports: [DevToolsComponent],
|
2020-01-27 18:40:18 +00:00
|
|
|
})
|
|
|
|
|
export class AppComponent implements OnInit {
|
2024-03-05 03:54:58 +00:00
|
|
|
private _cd = inject(ChangeDetectorRef);
|
2024-05-14 12:27:27 +00:00
|
|
|
private readonly _messageBus = inject<MessageBus<Events>>(MessageBus);
|
|
|
|
|
private onProfilingStartedListener = () => {
|
|
|
|
|
this._messageBus.emit('enableTimingAPI');
|
|
|
|
|
};
|
|
|
|
|
private onProfilingStoppedListener = () => {
|
|
|
|
|
this._messageBus.emit('disableTimingAPI');
|
|
|
|
|
};
|
2020-01-29 00:29:23 +00:00
|
|
|
ngOnInit(): void {
|
2020-03-13 04:15:17 +00:00
|
|
|
chrome.devtools.network.onNavigated.addListener(() => {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
});
|
2024-09-27 13:38:46 +00:00
|
|
|
const chromeDevToolsPerformance = chrome.devtools.performance;
|
2024-05-14 12:27:27 +00:00
|
|
|
chromeDevToolsPerformance?.onProfilingStarted?.addListener?.(this.onProfilingStartedListener);
|
|
|
|
|
chromeDevToolsPerformance?.onProfilingStopped?.addListener?.(this.onProfilingStoppedListener);
|
2021-09-08 22:41:24 +00:00
|
|
|
|
2020-03-12 17:26:13 +00:00
|
|
|
this._cd.detectChanges();
|
2020-01-27 18:40:18 +00:00
|
|
|
}
|
2024-05-14 12:27:27 +00:00
|
|
|
ngOnDestroy(): void {
|
2024-09-27 13:38:46 +00:00
|
|
|
const chromeDevToolsPerformance = chrome.devtools.performance;
|
2024-05-14 12:27:27 +00:00
|
|
|
chromeDevToolsPerformance?.onProfilingStarted?.removeListener?.(
|
|
|
|
|
this.onProfilingStartedListener,
|
|
|
|
|
);
|
|
|
|
|
chromeDevToolsPerformance?.onProfilingStopped?.removeListener?.(
|
|
|
|
|
this.onProfilingStoppedListener,
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-01-27 18:40:18 +00:00
|
|
|
}
|