Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(tsc): add type defs for Chrome Remote Debugging Protocol #4816

Merged
merged 2 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"npm-run-posix-or-windows": "^2.0.2",
"sinon": "^2.3.5",
"typescript": "^2.8.0-rc",
"vscode-chrome-debug-core": "^3.23.8",
"zone.js": "^0.7.3"
},
"dependencies": {
Expand Down
147 changes: 76 additions & 71 deletions typings/audit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,85 +4,90 @@
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

declare namespace LH.Audit {
export interface ScoringModes {
NUMERIC: 'numeric';
BINARY: 'binary';
}
declare global {
module LH.Audit {
export interface ScoringModes {
NUMERIC: 'numeric';
BINARY: 'binary';
}

export type ScoringModeValue = Audit.ScoringModes[keyof Audit.ScoringModes];
export type ScoringModeValue = Audit.ScoringModes[keyof Audit.ScoringModes];

export interface Meta {
name: string;
description: string;
helpText: string;
requiredArtifacts: Array<string>;
failureDescription?: string;
informative?: boolean;
manual?: boolean;
scoreDisplayMode?: Audit.ScoringModeValue;
}
export interface Meta {
name: string;
description: string;
helpText: string;
requiredArtifacts: Array<string>;
failureDescription?: string;
informative?: boolean;
manual?: boolean;
scoreDisplayMode?: Audit.ScoringModeValue;
}

export interface Heading {
key: string;
itemType: string;
text: string;
}
export interface Heading {
key: string;
itemType: string;
text: string;
}

export interface HeadingsResult {
results: number;
headings: Array<Audit.Heading>;
passes: boolean;
debugString?: string;
}
export interface HeadingsResult {
results: number;
headings: Array<Audit.Heading>;
passes: boolean;
debugString?: string;
}

// TODO: placeholder typedefs until Details are typed
export interface DetailsRendererDetailsSummary {
wastedMs?: number;
wastedBytes?: number;
}
// TODO: placeholder typedefs until Details are typed
export interface DetailsRendererDetailsSummary {
wastedMs?: number;
wastedBytes?: number;
}

// TODO: placeholder typedefs until Details are typed
export interface DetailsRendererDetailsJSON {
type: 'table';
headings: Array<Audit.Heading>;
items: Array<{[x: string]: string}>;
summary: DetailsRendererDetailsSummary;
}
// TODO: placeholder typedefs until Details are typed
export interface DetailsRendererDetailsJSON {
type: 'table';
headings: Array<Audit.Heading>;
items: Array<{[x: string]: string}>;
summary: DetailsRendererDetailsSummary;
}

// Type returned by Audit.audit(). Only rawValue is required.
export interface Product {
rawValue: boolean | number | null;
displayValue?: string;
debugString?: string;
score?: number;
extendedInfo?: {value: string};
notApplicable?: boolean;
error?: boolean;
// TODO: define details
details?: object;
}
// Type returned by Audit.audit(). Only rawValue is required.
export interface Product {
rawValue: boolean | number | null;
displayValue?: string;
debugString?: string;
score?: number;
extendedInfo?: {value: string};
notApplicable?: boolean;
error?: boolean;
// TODO: define details
details?: object;
}

/* Audit result returned in Lighthouse report. All audits offer a description and score of 0-1 */
export interface Result {
rawValue: boolean | number | null;
displayValue: string;
debugString?: string;
score: number;
scoreDisplayMode: ScoringModeValue;
description: string;
extendedInfo?: {value: string};
notApplicable?: boolean;
error?: boolean;
name: string;
helpText?: string;
informative?: boolean;
manual?: boolean;
// TODO: define details
details?: object;
}
/* Audit result returned in Lighthouse report. All audits offer a description and score of 0-1 */
export interface Result {
rawValue: boolean | number | null;
displayValue: string;
debugString?: string;
score: number;
scoreDisplayMode: ScoringModeValue;
description: string;
extendedInfo?: {value: string};
notApplicable?: boolean;
error?: boolean;
name: string;
helpText?: string;
informative?: boolean;
manual?: boolean;
// TODO: define details
details?: object;
}

export interface Results {
[metric: string]: Result;
export interface Results {
[metric: string]: Result;
}
}
}

// empty export to keep file a module
export {}
215 changes: 110 additions & 105 deletions typings/externs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,110 +4,115 @@
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

declare namespace LH {

export interface Flags {
_: string[];
port: number;
chromeFlags: string;
output: any;
outputPath: string;
saveAssets: boolean;
view: boolean;
maxWaitForLoad: number;
logLevel: string;
hostname: string;
blockedUrlPatterns: string[];
extraHeaders: string;
enableErrorReporting: boolean;
listAllAudits: boolean;
listTraceCategories: boolean;
auditMode: boolean|string;
gatherMode: boolean|string;
configPath?: string;
perf: boolean;
mixedContent: boolean;
verbose: boolean;
quiet: boolean;
}

export interface Config {}

export interface Results {
url: string;
audits: LH.Audit.Results;
lighthouseVersion: string;
artifacts?: Object;
initialUrl: string;
generatedTime: string;
}

export interface LaunchedChrome {
pid: number;
port: number;
kill: () => Promise<{}>;
}

export interface LighthouseError extends Error {
code?: string;
friendlyMessage?: string;
}

export interface TraceEvent {
name: string;
args: any;
tid: number;
ts: number;
dur: number;
}

export interface NetworkRequest {
requestId: string;
connectionId: string;
connectionReused: boolean;

url: string;
protocol: string;
origin: string | null;
parsedURL: DevToolsParsedURL;

startTime: number;
endTime: number;

transferSize: number;

_initiator: NetworkRequestInitiator;
_timing: NetworkRequestTiming;
_resourceType: any;
priority(): 'VeryHigh' | 'High' | 'Medium' | 'Low';
}

export interface NetworkRequestInitiator {
type: 'script' | 'parser';
}

export interface NetworkRequestTiming {
connectStart: number;
connectEnd: number
sslStart: number;
sslEnd: number;
sendStart: number;
sendEnd: number;
receiveHeadersEnd: number;
}

export interface DevToolsParsedURL {
scheme: string;
host: string;
}

export interface DevToolsJsonTarget {
description: string;
devtoolsFrontendUrl: string;
id: string;
title: string;
type: string;
url: string;
webSocketDebuggerUrl: string;
import _Crdp from "../node_modules/vscode-chrome-debug-core/lib/crdp/crdp";

declare global {
module LH {
export import Crdp = _Crdp;

export interface Flags {
_: string[];
port: number;
chromeFlags: string;
output: any;
outputPath: string;
saveAssets: boolean;
view: boolean;
maxWaitForLoad: number;
logLevel: string;
hostname: string;
blockedUrlPatterns: string[];
extraHeaders: string;
enableErrorReporting: boolean;
listAllAudits: boolean;
listTraceCategories: boolean;
auditMode: boolean|string;
gatherMode: boolean|string;
configPath?: string;
perf: boolean;
mixedContent: boolean;
verbose: boolean;
quiet: boolean;
}

export interface Config {}

export interface Results {
url: string;
audits: Audit.Results;
lighthouseVersion: string;
artifacts?: Object;
initialUrl: string;
generatedTime: string;
}

export interface LaunchedChrome {
pid: number;
port: number;
kill: () => Promise<{}>;
}

export interface LighthouseError extends Error {
code?: string;
friendlyMessage?: string;
}

export interface TraceEvent {
name: string;
args: any;
tid: number;
ts: number;
dur: number;
}

export interface NetworkRequest {
requestId: string;
connectionId: string;
connectionReused: boolean;

url: string;
protocol: string;
origin: string | null;
parsedURL: DevToolsParsedURL;

startTime: number;
endTime: number;

transferSize: number;

_initiator: NetworkRequestInitiator;
_timing: NetworkRequestTiming;
_resourceType: any;
priority(): 'VeryHigh' | 'High' | 'Medium' | 'Low';
}

export interface NetworkRequestInitiator {
type: 'script' | 'parser';
}

export interface NetworkRequestTiming {
connectStart: number;
connectEnd: number
sslStart: number;
sslEnd: number;
sendStart: number;
sendEnd: number;
receiveHeadersEnd: number;
}

export interface DevToolsParsedURL {
scheme: string;
host: string;
}

export interface DevToolsJsonTarget {
description: string;
devtoolsFrontendUrl: string;
id: string;
title: string;
type: string;
url: string;
webSocketDebuggerUrl: string;
}
}
}
Loading