Skip to content

Commit

Permalink
clients(lr): expose listenForStatus (#14024)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Jun 27, 2022
1 parent 28ab5c2 commit 70d2267
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions clients/devtools/devtools-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function setUpWorkerConnection(port) {
/** @param {(status: [string, string, string]) => void} listenCallback */
function listenForStatus(listenCallback) {
log.events.addListener('status', listenCallback);
log.events.addListener('warning', listenCallback);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions clients/lightrider/lightrider-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import {Buffer} from 'buffer';

import log from 'lighthouse-logger';
import lighthouse from '../../lighthouse-core/index.js';
import LHError from '../../lighthouse-core/lib/lh-error.js';
import preprocessor from '../../lighthouse-core/lib/proto-preprocessor.js';
Expand Down Expand Up @@ -103,8 +104,16 @@ export async function runLighthouseInLR(connection, url, flags, lrOpts) {
}
}

/** @param {(status: [string, string, string]) => void} listenCallback */
function listenForStatus(listenCallback) {
log.events.addListener('status', listenCallback);
log.events.addListener('warning', listenCallback);
}

// Expose on window for browser-residing consumers of file.
if (typeof window !== 'undefined') {
// @ts-expect-error - not worth typing a property on `window`.
window.runLighthouseInLR = runLighthouseInLR;
// @ts-expect-error
self.listenForStatus = listenForStatus;
}

0 comments on commit 70d2267

Please sign in to comment.