UNPKG

1.97 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
6 * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
7 * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
8 * Google as part of the polymer project is also subject to an additional IP
9 * rights grant found at http://polymer.github.io/PATENTS.txt
10 */
11/// <reference types="node" />
12import * as http from 'http';
13import { BenchmarkResponse } from './types';
14import { NpmInstall } from './versions';
15export interface ServerOpts {
16 host: string;
17 ports: number[];
18 root: string;
19 npmInstalls: NpmInstall[];
20 mountPoints: MountPoint[];
21 resolveBareModules: boolean;
22 cache: boolean;
23}
24export interface MountPoint {
25 diskPath: string;
26 urlPath: string;
27}
28export interface Session {
29 bytesSent: number;
30 userAgent: string;
31}
32export declare class Server {
33 readonly url: string;
34 readonly port: number;
35 private readonly server;
36 private session;
37 private deferredResults;
38 private readonly urlCache;
39 static start(opts: ServerOpts): Promise<Server>;
40 constructor(server: http.Server, opts: ServerOpts);
41 /**
42 * Mark the end of one session, return the data instrumented from it, and
43 * begin a new session.
44 */
45 endSession(): Session;
46 nextResults(): Promise<BenchmarkResponse>;
47 close(): Promise<unknown>;
48 private instrumentRequests;
49 /**
50 * Cache all downstream middleware responses by URL in memory. This is
51 * especially helpful when bare module resolution is enabled, because that
52 * requires expensive parsing of all HTML and JavaScript that we really don't
53 * want to do for every benchmark sample.
54 */
55 private cache;
56 private serveBenchLib;
57 private submitResults;
58}