chore(trace viewer): support HMR (#33609)
This commit is contained in:
parent
a14d9750b3
commit
ed2be67e47
|
@ -125,7 +125,13 @@ export async function installRootRedirect(server: HttpServer, traceUrls: string[
|
|||
for (const reporter of options.reporter || [])
|
||||
params.append('reporter', reporter);
|
||||
|
||||
const urlPath = `./trace/${options.webApp || 'index.html'}?${params.toString()}`;
|
||||
let baseUrl = '.';
|
||||
if (process.env.PW_HMR) {
|
||||
baseUrl = 'http://localhost:44223'; // port is hardcoded in build.js
|
||||
params.set('server', server.urlPrefix('precise'));
|
||||
}
|
||||
|
||||
const urlPath = `${baseUrl}/trace/${options.webApp || 'index.html'}?${params.toString()}`;
|
||||
server.routePath('/', (_, response) => {
|
||||
response.statusCode = 302;
|
||||
response.setHeader('Location', urlPath);
|
||||
|
|
|
@ -43,10 +43,8 @@ async function loadTrace(traceUrl: string, traceFileName: string | null, client:
|
|||
const clientId = client?.id ?? '';
|
||||
let data = clientIdToTraceUrls.get(clientId);
|
||||
if (!data) {
|
||||
let traceViewerServerBaseUrl = new URL('../', client?.url ?? self.registration.scope);
|
||||
if (traceViewerServerBaseUrl.searchParams.has('server'))
|
||||
traceViewerServerBaseUrl = new URL(traceViewerServerBaseUrl.searchParams.get('server')!, traceViewerServerBaseUrl);
|
||||
|
||||
const clientURL = new URL(client?.url ?? self.registration.scope);
|
||||
const traceViewerServerBaseUrl = new URL(clientURL.searchParams.get('server') ?? '../', clientURL);
|
||||
data = { limit, traceUrls: new Set(), traceViewerServer: new TraceViewerServer(traceViewerServerBaseUrl) };
|
||||
clientIdToTraceUrls.set(clientId, data);
|
||||
}
|
||||
|
|
|
@ -344,7 +344,8 @@ export function extendSnapshot(snapshot: Snapshot): SnapshotUrls {
|
|||
|
||||
const popoutParams = new URLSearchParams();
|
||||
popoutParams.set('r', snapshotUrl);
|
||||
popoutParams.set('server', serverParam ?? '');
|
||||
if (serverParam)
|
||||
popoutParams.set('server', serverParam);
|
||||
popoutParams.set('trace', context(snapshot.action).traceUrl);
|
||||
if (snapshot.point) {
|
||||
popoutParams.set('pointX', String(snapshot.point.x));
|
||||
|
|
|
@ -47,9 +47,7 @@ const xtermDataSource: XtermDataSource = {
|
|||
};
|
||||
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
let testServerBaseUrl = new URL('../', window.location.href);
|
||||
if (testServerBaseUrl.searchParams.has('server'))
|
||||
testServerBaseUrl = new URL(testServerBaseUrl.searchParams.get('server')!, testServerBaseUrl);
|
||||
const testServerBaseUrl = new URL(searchParams.get('server') ?? '../', window.location.href);
|
||||
const wsURL = new URL(searchParams.get('ws')!, testServerBaseUrl);
|
||||
wsURL.protocol = (wsURL.protocol === 'https:' ? 'wss:' : 'ws:');
|
||||
const queryParams = {
|
||||
|
|
Loading…
Reference in New Issue