2021-12-09 21:37:01 -05:00
|
|
|
/**
|
|
|
|
|
* @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.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2021-12-09 00:44:17 -05:00
|
|
|
import {initializeMessageBus} from 'ng-devtools-backend';
|
2020-02-07 16:09:36 -05:00
|
|
|
|
2021-12-09 00:44:17 -05:00
|
|
|
import {unHighlight} from '../../../ng-devtools-backend/src/lib/highlighter';
|
|
|
|
|
|
|
|
|
|
import {initializeExtendedWindowOperations} from './chrome-window-extensions';
|
|
|
|
|
import {SamePageMessageBus} from './same-page-message-bus';
|
|
|
|
|
|
|
|
|
|
const messageBus =
|
|
|
|
|
new SamePageMessageBus('angular-devtools-backend', 'angular-devtools-content-script');
|
2020-01-27 13:40:18 -05:00
|
|
|
|
|
|
|
|
let initialized = false;
|
|
|
|
|
messageBus.on('handshake', () => {
|
|
|
|
|
if (initialized) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
initialized = true;
|
2020-02-07 16:09:36 -05:00
|
|
|
initializeMessageBus(messageBus);
|
|
|
|
|
initializeExtendedWindowOperations();
|
2020-04-14 18:27:59 -04:00
|
|
|
|
|
|
|
|
let inspectorRunning = false;
|
|
|
|
|
messageBus.on('inspectorStart', () => {
|
|
|
|
|
inspectorRunning = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
messageBus.on('inspectorEnd', () => {
|
|
|
|
|
inspectorRunning = false;
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-09 00:44:17 -05:00
|
|
|
// handles case when mouse leaves chrome extension too quickly. unHighlight() is not a very
|
|
|
|
|
// expensive function and has an if check so it's DOM api call is not called more than necessary
|
|
|
|
|
document.addEventListener('mousemove', () => {
|
|
|
|
|
if (!inspectorRunning) {
|
|
|
|
|
unHighlight();
|
|
|
|
|
}
|
|
|
|
|
}, false);
|
2020-01-27 13:40:18 -05:00
|
|
|
});
|