core(tsc): add type checking to viewer (#5258)

This commit is contained in:
Brendan Kenny 2018-05-18 18:52:10 -07:00 коммит произвёл Paul Irish
Родитель 1b5bf18ad0
Коммит ef0def4c3a
30 изменённых файлов: 218 добавлений и 992 удалений

Просмотреть файл

@ -1,105 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for the `devtools-timeline-model` module.
* @externs
*/
/**
* @constructor
* @param {!Array<!Object>} traceData
*/
var DevtoolsTimelineModel = function(traceData) {};
/**
* @return {!DevtoolsTimelineModel.TimelineModel}
*/
DevtoolsTimelineModel.prototype.timelineModel = function() {};
/**
* @struct
* @record
*/
DevtoolsTimelineModel.TimelineModel = function() {};
/**
* @return {!Array<!DevtoolsTimelineModel.MainThreadEvent>}
*/
DevtoolsTimelineModel.TimelineModel.prototype.mainThreadEvents = function() {};
/**
* @return {!DevtoolsTimelineModel.MainThreadAsyncEvents}
*/
DevtoolsTimelineModel.TimelineModel.prototype.mainThreadAsyncEvents = function() {};
/**
* @struct
* @record
*/
DevtoolsTimelineModel.MainThreadEvent = function() {};
/** @type {string} */
DevtoolsTimelineModel.MainThreadEvent.prototype.categoriesString;
/** @type {string} */
DevtoolsTimelineModel.MainThreadEvent.prototype.name;
/** @type {number} */
DevtoolsTimelineModel.MainThreadEvent.prototype.startTime;
/** @type {!Object} */
DevtoolsTimelineModel.MainThreadEvent.prototype.args;
/** @type {!string} */
DevtoolsTimelineModel.MainThreadEvent.prototype.phase;
/** @type {function(!string):!boolean} */
DevtoolsTimelineModel.MainThreadEvent.prototype.hasCategory;
/**
* @struct
* @record
*/
DevtoolsTimelineModel.MainThreadAsyncEvents = function() {};
/**
* @type {function():!Array<string>}
*/
DevtoolsTimelineModel.MainThreadAsyncEvents.prototype.keys;
/**
* @type {function(Object):!Array<!Object>}
*/
DevtoolsTimelineModel.MainThreadAsyncEvents.prototype.get;
/**
* @see chrome-devtools-frontend/front_end/sdk/TracingModel.js
* @struct
* @record
*/
DevtoolsTimelineModel.TracingModel = function() {};
/**
* @return {!Array.<!DevtoolsTimelineModel.TracingModel.Event>}
*/
DevtoolsTimelineModel.TracingModel.prototype.devToolsMetadataEvents = function() {};
/**
* @see chrome-devtools-frontend/front_end/sdk/TracingModel.js
* @struct
* @record
*/
DevtoolsTimelineModel.TracingModel.Event = function() {};
/** @type {string} */
DevtoolsTimelineModel.TracingModel.Event.prototype.name;
/** @type {number} */
DevtoolsTimelineModel.TracingModel.Event.prototype.startTime;
/** @type {!Object} */
DevtoolsTimelineModel.TracingModel.Event.prototype.args;

Просмотреть файл

@ -1,27 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for the `chrome-devtools-frontend` module.
* @externs
*/
/**
* @const
*/
var WebInspector = {};
/**
* @constructor
* @struct
*/
WebInspector.Color = function() {};
/**
* @param {string} text
* @return {?WebInspector.Color}
*/
WebInspector.Color.parse = function(text) {};

Просмотреть файл

@ -1,16 +0,0 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Read-only externs for module checks. Will fail if written to.
* @externs
*/
/** @const */
const module = {};
/** @const */
module.exports = {};

16
lighthouse-core/closure/third_party/node.js поставляемый
Просмотреть файл

@ -1,16 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* @externs
*/
/** @type {string} */
var __dirname = '';
/** @type {!Object} */
var global = {};

Просмотреть файл

@ -1,34 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for collected output of the artifact gatherers stage.
* @externs
*/
/**
* @struct
* @record
*/
function AccessibilityRule() {}
/** @type {string} */
AccessibilityRule.prototype.id;
/** @type {string} */
AccessibilityRule.prototype.help;
/** @type {!Array<!Object>} */
AccessibilityRule.prototype.nodes;
/**
* @struct
* @record
*/
function Accessibility() {}
/** @type {!Array<!AccessibilityRule>} */
Accessibility.prototype.violations;

Просмотреть файл

@ -1,81 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for collected output of the artifact gatherers stage.
* @externs
*/
/** @typedef {!Array<{method: string, params: (!Object<string, *>|undefined)}>} */
let DevtoolsLog;
/**
* @constructor
* @struct
* @record
* @extends {ComputedArtifacts}
*/
function Artifacts() {}
/** @type {string} */
Artifacts.prototype.HTML;
/** @type {{value: (string|number), debugString: (string|undefined)}} */
Artifacts.prototype.HTMLWithoutJavaScript;
/** @type {boolean} */
Artifacts.prototype.HTTPS;
/** @type {!Array<!Object>} */
Artifacts.prototype.traces;
/** @type {!Object<!Array>} */
Artifacts.prototype.networkRecords;
/** @type {!ManifestNode<(!Manifest|undefined)>} */
Artifacts.prototype.Manifest;
/** @type {!ServiceWorkerArtifact} */
Artifacts.prototype.ServiceWorker;
/** @type {?string} */
Artifacts.prototype.ThemeColor;
/** @type {string} */
Artifacts.prototype.URL;
/** @type {?string} */
Artifacts.prototype.Viewport;
/** @type {number} */
Artifacts.prototype.Offline;
/** @type {{value: boolean, debugString: (string|undefined)}} */
Artifacts.prototype.HTTPRedirect;
/** @type {!Accessibility} */
Artifacts.prototype.Accessibility;
/** @type {!Array<!Object>} */
Artifacts.prototype.ScreenshotFilmstrip;
/** @type {!Object<!Object>} */
Artifacts.prototype.CriticalRequestChains;
/** @type {{first: number, complete: number, duration: number, frames: !Array<!Object>, debugString: (string|undefined)}} */
Artifacts.prototype.Speedline;
/** @type {{innerWidth: number, outerWidth: number}} */
Artifacts.prototype.ViewportDimensions;
/** @type {!Array<string>} */
Artifacts.prototype.CacheContents;
/** @type {boolean|number} */
Artifacts.prototype.GeolocationOnStart;
/** @type {!Object<string, !DevtoolsLog>} */
Artifacts.prototype.devtoolsLogs;

Просмотреть файл

@ -1,25 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for audit classes.
* @externs
*/
/**
* @struct
* @record
*/
function AuditMeta() {}
/** @type {string} */
AuditMeta.prototype.name;
/** @type {string} */
AuditMeta.prototype.description;
/** @type {!Array<string>} */
AuditMeta.prototype.requiredArtifacts;

Просмотреть файл

@ -1,144 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for the result of an audit.
* @externs
*/
/**
* @struct
* @record
*/
function AuditResult() {}
/**
* The only required value in an audit result. Used as the `score` if no score
* is provided.
* @type {(boolean|number)}
*/
AuditResult.prototype.rawValue;
/** @type {(number|undefined)} */
AuditResult.prototype.score;
/** @type {(string|undefined)} */
AuditResult.prototype.displayValue;
/**
* Optional error string for helping the user figure out why they failed here.
* @type {(string|undefined)}
*/
AuditResult.prototype.debugString;
/** @type {(AuditExtendedInfo|undefined|null)} */
AuditResult.prototype.extendedInfo;
/** @type {(Object|undefined)} */
AuditResult.prototype.details;
/**
* The full audit result as generated by Audit.generateAuditResult from an
* AuditResult. See Config.assertValidAudit for audit required meta fields.
* @struct
* @record
*/
function AuditFullResult() {}
/** @type {(number)} */
AuditFullResult.prototype.score;
/** @type {string} */
AuditFullResult.prototype.scoreDisplayMode;
/** @type {string} */
AuditFullResult.prototype.displayValue;
/** @type {(boolean|number)} */
AuditFullResult.prototype.rawValue;
/**
* Optional property indicating that some error occurred either in generating an
* artifact required by this audit or within the audit itself and so the audit
* is un-scoreable. Audits can create an error by simply throwing an exception.
* @type {(boolean|undefined)}
*/
AuditFullResult.prototype.error;
/** @type {(string|undefined)} */
AuditFullResult.prototype.debugString;
/** @type {(AuditExtendedInfo|undefined|null)} */
AuditFullResult.prototype.extendedInfo;
/** @type {string} */
AuditFullResult.prototype.name;
/** @type {string} */
AuditFullResult.prototype.description;
/** @type {string} */
AuditFullResult.prototype.helpText;
/** @type {(Object|undefined)} */
AuditFullResult.prototype.details;
/**
* @struct
* @record
*/
function AuditExtendedInfo() {}
/** @type {(Object|Array<UserTimingsExtendedInfo>|FirstMeaningfulPaintExtendedInfo|undefined)} */
AuditExtendedInfo.prototype.value;
/**
* @struct
* @record
*/
function UserTimingsExtendedInfo() {}
/** @type {!string} */
UserTimingsExtendedInfo.prototype.name;
/** @type {!boolean} */
UserTimingsExtendedInfo.prototype.isMark;
/** @type {!Object} */
UserTimingsExtendedInfo.prototype.args;
/** @type {!number} */
UserTimingsExtendedInfo.prototype.startTime;
/** @type {(number|undefined)} */
UserTimingsExtendedInfo.prototype.endTime;
/** @type {(number|undefined)} */
UserTimingsExtendedInfo.prototype.duration;
/**
* @struct
* @record
*/
function FirstMeaningfulPaintExtendedInfo() {}
/** @type {!FirstMeaningfulPaintTimings} */
FirstMeaningfulPaintExtendedInfo.prototype.timings;
/**
* @struct
* @record
*/
function FirstMeaningfulPaintTimings() {}
/** @type {number} */
FirstMeaningfulPaintTimings.prototype.fCP;
/** @type {number} */
FirstMeaningfulPaintTimings.prototype.fMP;
/** @type {number} */
FirstMeaningfulPaintTimings.prototype.navStart;

Просмотреть файл

@ -1,74 +0,0 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for computed artifacts object.
* @externs
*/
/** @typedef
* {{
* navigationStart: number,
* firstPaint: number,
* firstContentfulPaint: number,
* firstMeaningfulPaint: number,
* traceEnd: number,
* onLoad: number,
* domContentLoaded: number,
* }}
*/
let TraceTimes;
/** @typedef
{{
timings: !TraceTimes,
timestamps: !TraceTimes,
processEvents: !Array<!TraceEvent>,
mainThreadEvents: !Array<!TraceEvent>,
startedInPageEvt: !TraceEvent,
navigationStartEvt: !TraceEvent,
firstPaintEvt: TraceEvent,
firstContentfulPaintEvt: TraceEvent,
firstMeaningfulPaintEvt: TraceEvent,
onLoadEvt: TraceEvent,
fmpFellBack: boolean,
}} */
let TraceOfTabArtifact;
/**
* @constructor
* @struct
* @record
*/
function ComputedArtifacts() {}
/** @type {function(!DevtoolsLog): !Promise<!Object>} */
ComputedArtifacts.prototype.requestCriticalRequestChains;
/** @type {function(!DevtoolsLog): !Promise<!Array<!WebInspector.NetworkRequest>>} */
ComputedArtifacts.prototype.requestNetworkRecords;
/** @type {function(ManifestNode<(!Manifest|undefined)>): !Promise<{isParseFailure: boolean, parseFailureReason: string, allChecks: !Array<{passing: boolean, failureText: string}>}>} */
ComputedArtifacts.prototype.requestManifestValues;
/** @type {function(!DevtoolsLog): !Promise<number>} */
ComputedArtifacts.prototype.requestNetworkThroughput;
// ComputedArtifacts.prototype.requestPushedRequests;
// ComputedArtifacts.prototype.requestScreenshots;
/** @type {function(!Trace): !Promise<!SpeedlineArtifact>} */
ComputedArtifacts.prototype.requestSpeedline;
/** @type {function(!Trace): !Promise<LH.Artifacts.TraceOfTab>} */
ComputedArtifacts.prototype.requestTraceOfTab;
/** @type {function(!Trace): !Promise<{timeInMs: number, timestamp: number}>} */
ComputedArtifacts.prototype.requestFirstCPUIdle;
/** @type {function(!DevtoolsLog): !Promise<WebInspector.NetworkRequest>} */
ComputedArtifacts.prototype.requestMainResource;

Просмотреть файл

@ -1,27 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for config class.
* @externs
*/
/**
* @struct
* @record
*/
var PassConfig = function() {};
/** type {boolean} */
PassConfig.prototype.recordTrace;
/** type {string} */
PassConfig.prototype.loadDataName;
/** type {!Array<!string>} */
PassConfig.prototype.gatherers;

Просмотреть файл

@ -1,105 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for parsed Manifest.
* @externs
*/
/**
* @struct
* @template T
* @record
*/
function ManifestNode() {}
/** @type {!*} */
ManifestNode.prototype.raw;
/** @type {T} */
ManifestNode.prototype.value;
/** @type {string|undefined} */
ManifestNode.prototype.debugString;
/**
* @struct
* @record
*/
function ManifestImageValue() {}
/** @type {!ManifestNode<(string|undefined)>} */
ManifestImageValue.prototype.src;
/** @type {!ManifestNode<(string|undefined)>} */
ManifestImageValue.prototype.type;
/** @type {!ManifestNode<number>} */
ManifestImageValue.prototype.density;
/** @type {!ManifestNode<(!Array<string>|undefined)>} */
ManifestImageValue.prototype.sizes;
/**
* @typedef {!ManifestNode<!ManifestImageValue>}
*/
var ManifestImageNode;
/**
* @struct
* @record
*/
function ManifestApplicationValue() {}
/** @type {!ManifestNode<(string|undefined)>} */
ManifestApplicationValue.prototype.platform;
/** @type {!ManifestNode<(string|undefined)>} */
ManifestApplicationValue.prototype.id;
/** @type {!ManifestNode<(string|undefined)>} */
ManifestApplicationValue.prototype.url;
/**
* @typedef {!ManifestNode<!ManifestApplicationValue>}
*/
var ManifestApplicationNode;
/**
* @struct
* @record
*/
function Manifest() {}
/** @type {!ManifestNode<(string|undefined)>} */
Manifest.prototype.name;
/** @type {!ManifestNode<(string|undefined)>} */
Manifest.prototype.short_name;
/** @type {!ManifestNode<(string|undefined)>} */
Manifest.prototype.start_url;
/** @type {!ManifestNode<string>} */
Manifest.prototype.display;
/** @type {!ManifestNode<(string|undefined)>} */
Manifest.prototype.orientation;
/** @type {!ManifestNode<!Array<!ManifestImageNode>>} */
Manifest.prototype.icons;
/** @type {!ManifestNode<(!Array<!ManifestApplicationNode>|undefined)>} */
Manifest.prototype.related_applications;
/** @type {!ManifestNode<(boolean|undefined)>} */
Manifest.prototype.prefer_related_applications;
/** @type {!ManifestNode<(string|undefined)>} */
Manifest.prototype.theme_color;
/** @type {!ManifestNode<(string|undefined)>} */
Manifest.prototype.background_color;

Просмотреть файл

@ -1,54 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for Chrome protocol ServiceWorker.workerVersionUpdated request, used as an
* artifact.
* @see https://chromedevtools.github.io/debugger-protocol-viewer/ServiceWorker/#event-workerVersionUpdated
* @externs
*/
/**
* @struct
* @record
*/
function ServiceWorkerArtifact() {}
/** @type {(string|undefined)} */
ServiceWorkerArtifact.prototype.debugString;
/** @type {(!Array<!ServiceWorkerVersion>|undefined)} */
ServiceWorkerArtifact.prototype.versions;
/**
* @struct
* @record
*/
function ServiceWorkerVersion() {}
/** @type {string} */
ServiceWorkerVersion.prototype.versionId;
/** @type {string} */
ServiceWorkerVersion.prototype.registrationId;
/** @type {string} */
ServiceWorkerVersion.prototype.scriptURL;
/** @type {string} */
ServiceWorkerVersion.prototype.runningStatus;
/** @type {string} */
ServiceWorkerVersion.prototype.status;
/** @type {number} */
ServiceWorkerVersion.prototype.scriptLastModified;
/** @type {number} */
ServiceWorkerVersion.prototype.scriptResponseTime;
/** @type {!Array<string>} */
ServiceWorkerVersion.prototype.controlledClients;

Просмотреть файл

@ -1,49 +0,0 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for speedline results.
* @externs
*/
/**
* @struct
* @record
*/
function SpeedlineFrames() {}
/** @return {number} */
SpeedlineFrames.prototype.getProgress = function() {};
/** @return {number} */
SpeedlineFrames.prototype.getPerceptualProgress = function() {};
/** @return {number} */
SpeedlineFrames.prototype.getTimeStamp = function() {};
/**
* @struct
* @record
*/
function SpeedlineArtifact() {}
/** @type {number} */
SpeedlineArtifact.prototype.first;
/** @type {number} */
SpeedlineArtifact.prototype.complete;
/** @type {number} */
SpeedlineArtifact.prototype.duration;
/** @type {!Array<!SpeedlineFrames>} */
SpeedlineArtifact.prototype.frames;
/** @type {(string|undefined)} */
SpeedlineArtifact.prototype.debugString;
/** @type {number} */
SpeedlineArtifact.prototype.speedIndex;

Просмотреть файл

@ -1,57 +0,0 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
/**
* Typing externs file for raw trace events
* @see https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
* @externs
*/
/**
* @struct
* @record
*/
function TraceEvent() {}
/** @type {string} */
TraceEvent.prototype.cat;
/** @type {number} */
TraceEvent.prototype.pid;
/** @type {number} */
TraceEvent.prototype.tid;
/** @type {number} */
TraceEvent.prototype.ts;
/** @type {string} */
TraceEvent.prototype.ph;
/** @type {string} */
TraceEvent.prototype.name;
/** @type {!Object} */
TraceEvent.prototype.args;
/** @type {number} */
TraceEvent.prototype.dur;
/** @type {string} */
TraceEvent.prototype.id;
/** @type {string} */
TraceEvent.prototype.bind_id;
/**
* @struct
* @record
*/
function Trace() {}
/** @type {{traceEvents: !Array<!TraceEvent>}} */
Trace.prototype.traceEvents;

Просмотреть файл

@ -1,53 +0,0 @@
/**
* @license Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
'use strict';
/**
* Typing externs file needed for DevTools compilation.
* @externs
*/
/**
* @struct
* @record
*/
function ThrottlingSettings() {}
/** @type {number} */
ThrottlingSettings.prototype.rttMs;
/** @type {number} */
ThrottlingSettings.prototype.throughputKbps;
/** @type {number} */
ThrottlingSettings.prototype.requestLatencyMs;
/** @type {number} */
ThrottlingSettings.prototype.downloadThroughputKbps;
/** @type {number} */
ThrottlingSettings.prototype.uploadThroughputKbps;
/** @type {number} */
ThrottlingSettings.prototype.cpuSlowdownMultiplier;
var LH = {};
LH.Config = {};
/**
* @struct
* @record
*/
LH.Config.Settings = function() {};
/** @type {boolean} */
LH.Config.Settings.prototype.disableDeviceEmulation;
/** @type {string} */
LH.Config.Settings.prototype.throttlingMethod;
/** @type {ThrottlingSettings} */
LH.Config.Settings.prototype.throttling;

Просмотреть файл

@ -1,28 +0,0 @@
/**
* @license Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
'use strict';
/**
* Typing externs file needed for DevTools compilation.
* @externs
*/
/**
* Add extra properties to Element so closure doens't crash
*/
/** @typedef
* {{
* value: number,
* }}
*/
let CSSStyleValue;
/**
* @return {!Map<string, CSSStyleValue>}
*/
Element.prototype.computedStyleMap = function() {}

Просмотреть файл

@ -1,23 +0,0 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
'use strict';
/**
* Typing externs file needed for Viewer compilation.
* @externs
*/
/**
* @struct
* @constructor
*/
function ReportGenerator() {}
/**
* @param {!ReportRenderer.ReportJSON} reportJson
* @return {string}
*/
ReportGenerator.generateReportHtml = function(reportJson) {};

Просмотреть файл

@ -44,6 +44,7 @@ function getUrlConstructor() {
}
}
// @ts-ignore - suppress `module` error for type-checking in a browser context.
if (typeof module !== 'undefined' && module.exports) {
module.exports = {getFilenamePrefix};
}

Просмотреть файл

@ -10,10 +10,15 @@
*/
class DragAndDrop {
/**
* @param {function(!File)} fileHandlerCallback Invoked when the user chooses a new file.
* @param {function(File)} fileHandlerCallback Invoked when the user chooses a new file.
*/
constructor(fileHandlerCallback) {
this._dropZone = document.querySelector('.drop_zone');
const dropZone = document.querySelector('.drop_zone');
if (!dropZone) {
throw new Error('Drag and drop `.drop_zone` element not found in page');
}
this._dropZone = dropZone;
this._fileHandlerCallback = fileHandlerCallback;
this._dragging = false;

Просмотреть файл

@ -12,12 +12,12 @@
*/
class FirebaseAuth {
constructor() {
/** @private {?string} */
/** @type {?string} */
this._accessToken = null;
/** @private {Object} */
/** @type {?import('@firebase/auth-types').User} */
this._firebaseUser = null;
/** @private {!Object} */
/** @type {import('@firebase/auth-types').GithubAuthProvider} */
this._provider = new firebase.auth.GithubAuthProvider();
this._provider.addScope('gist');
@ -32,7 +32,7 @@ class FirebaseAuth {
/**
* Promise which resolves after the first check of auth state. After this,
* _accessToken will be set if user is logged in and has access token.
* @private {!Promise<undefined>}
* @type {Promise<void>}
*/
this._ready = Promise.all([
new Promise(resolve => firebase.auth().onAuthStateChanged(resolve)),
@ -48,7 +48,7 @@ class FirebaseAuth {
/**
* Returns the GitHub access token if already logged in. If not logged in,
* returns null (and will not trigger sign in).
* @return {!Promise<?string>}
* @return {Promise<?string>}
*/
getAccessTokenIfLoggedIn() {
return this._ready.then(_ => this._accessToken);
@ -56,7 +56,7 @@ class FirebaseAuth {
/**
* Returns the GitHub access token, triggering sign in if needed.
* @return {!Promise<string>}
* @return {Promise<string>}
*/
getAccessToken() {
return this._ready.then(_ => this._accessToken ? this._accessToken : this.signIn());
@ -64,22 +64,24 @@ class FirebaseAuth {
/**
* Signs in the user to GitHub using the Firebase API.
* @return {!Promise<string>} The logged in user.
* @return {Promise<string>} The logged in user.
*/
signIn() {
return firebase.auth().signInWithPopup(this._provider).then(result => {
this._accessToken = result.credential.accessToken;
/** @type {string} */
const accessToken = result.credential.accessToken;
this._accessToken = accessToken;
this._firebaseUser = result.user;
// A limitation of firebase auth is that it doesn't return an oauth token
// after a page refresh. We'll get a firebase token, but not an oauth token
// for GitHub. Since GitHub's tokens never expire, stash the access token in IDB.
return idbKeyval.set('accessToken', this._accessToken).then(_ => this._accessToken);
return idbKeyval.set('accessToken', accessToken).then(_ => accessToken);
});
}
/**
* Signs the user out.
* @return {!Promise<undefined>}
* @return {Promise<void>}
*/
signOut() {
return firebase.auth().signOut().then(_ => {
@ -89,6 +91,7 @@ class FirebaseAuth {
}
}
// @ts-ignore - node export for testing.
if (typeof module !== 'undefined' && module.exports) {
module.exports = FirebaseAuth;
}

Просмотреть файл

@ -7,6 +7,9 @@
/* global logger, FirebaseAuth, idbKeyval, getFilenamePrefix */
/** @typedef {import('../../../lighthouse-core/report/html/renderer/report-renderer.js').ReportJSON} ReportJSON */
/** @typedef {{etag: ?string, content: ReportJSON}} CachableGist */
/**
* Wrapper around the GitHub API for reading/writing gists.
*/
@ -22,8 +25,8 @@ class GithubApi {
/**
* Creates a gist under the users account.
* @param {!ReportRenderer.ReportJSON} jsonFile The gist file body.
* @return {!Promise<string>} id of the created gist.
* @param {ReportJSON} jsonFile The gist file body.
* @return {Promise<string>} id of the created gist.
*/
createGist(jsonFile) {
if (this._saving) {
@ -71,7 +74,7 @@ class GithubApi {
/**
* Fetches a Lighthouse report from a gist.
* @param {string} id The id of a gist.
* @return {!Promise<!ReportRenderer.ReportJSON>}
* @return {Promise<ReportJSON>}
*/
getGistFileContentAsJson(id) {
logger.log('Fetching report from GitHub...', false);
@ -85,16 +88,16 @@ class GithubApi {
headers.set('Authorization', `token ${accessToken}`);
}
return idbKeyval.get(id).then(cachedGist => {
return idbKeyval.get(id).then(/** @param {?CachableGist} cachedGist */ (cachedGist) => {
if (cachedGist && cachedGist.etag) {
headers.set('If-None-Match', cachedGist.etag);
}
// Always make the request to see if there's newer content.
return fetch(`https://api.github.com/gists/${id}`, {headers}).then(resp => {
const remaining = resp.headers.get('X-RateLimit-Remaining');
const limit = resp.headers.get('X-RateLimit-Limit');
if (Number(remaining) < 10) {
const remaining = Number(resp.headers.get('X-RateLimit-Remaining'));
const limit = Number(resp.headers.get('X-RateLimit-Limit'));
if (remaining < 10) {
logger.warn('Approaching GitHub\'s rate limit. ' +
`${limit - remaining}/${limit} requests used. Consider signing ` +
'in to increase this limit.');
@ -102,7 +105,7 @@ class GithubApi {
if (!resp.ok) {
if (resp.status === 304) {
return cachedGist;
return Promise.resolve(cachedGist);
} else if (resp.status === 404) {
// Delete the entry from IDB if it no longer exists on the server.
idbKeyval.delete(id); // Note: async.
@ -126,7 +129,8 @@ class GithubApi {
.then(resp => resp.json())
.then(content => ({etag, content}));
}
return {etag, content: JSON.parse(f.content)};
const lhr = /** @type {ReportJSON} */ (JSON.parse(f.content));
return {etag, content: lhr};
});
});
});
@ -136,12 +140,14 @@ class GithubApi {
// not return a 304 and so will be overwritten.
return idbKeyval.set(id, response).then(_ => {
logger.hide();
// @ts-ignore - TODO(bckenny): tsc unable to flatten promise chain here
return response.content;
});
});
}
}
// @ts-ignore - node export for testing.
if (typeof module !== 'undefined' && module.exports) {
module.exports = GithubApi;
}

Просмотреть файл

@ -7,6 +7,24 @@
/* global DOM, ViewerUIFeatures, ReportRenderer, DragAndDrop, GithubApi, logger, idbKeyval */
/** @typedef {import('../../../lighthouse-core/report/html/renderer/report-renderer.js').ReportJSON} ReportJSON */
/**
* Guaranteed context.querySelector. Always returns an element or throws if
* nothing matches query.
* @param {string} query
* @param {ParentNode} context
* @return {HTMLElement}
*/
function find(query, context) {
/** @type {?HTMLElement} */
const result = context.querySelector(query);
if (result === null) {
throw new Error(`query ${query} not found`);
}
return result;
}
/**
* Class that manages viewing Lighthouse reports.
*/
@ -22,7 +40,7 @@ class LighthouseReportViewer {
/**
* Used for tracking whether to offer to upload as a gist.
* @private {boolean}
* @type {boolean}
*/
this._reportIsFromGist = false;
@ -40,22 +58,32 @@ class LighthouseReportViewer {
* @private
*/
_addEventListeners() {
// @ts-ignore - tsc thinks document can't listen for `paste`
document.addEventListener('paste', this._onPaste);
const gistUrlInput = document.querySelector('.js-gist-url');
const gistUrlInput = find('.js-gist-url', document);
gistUrlInput.addEventListener('change', this._onUrlInputChange);
// Hidden file input to trigger manual file selector.
const fileInput = document.querySelector('#hidden-file-input');
const fileInput = find('#hidden-file-input', document);
fileInput.addEventListener('change', e => {
this._onFileLoad(e.target.files[0]);
e.target.value = null;
if (!e.target) {
return;
}
const inputTarget = /** @type {HTMLInputElement} */ (e.target);
if (inputTarget.files) {
this._onFileLoad(inputTarget.files[0]);
}
inputTarget.value = '';
});
// A click on the visual placeholder will trigger the hidden file input.
const placeholderTarget = document.querySelector('.viewer-placeholder-inner');
const placeholderTarget = find('.viewer-placeholder-inner', document);
placeholderTarget.addEventListener('click', e => {
if (e.target.localName !== 'input') {
const target = /** @type {?Element} */ (e.target);
if (target && target.localName !== 'input') {
fileInput.click();
}
});
@ -63,7 +91,7 @@ class LighthouseReportViewer {
/**
* Attempts to pull gist id from URL and render report from it.
* @return {!Promise<undefined>}
* @return {Promise<void>}
* @private
*/
_loadFromDeepLink() {
@ -81,7 +109,7 @@ class LighthouseReportViewer {
/**
* Basic Lighthouse report JSON validation.
* @param {!ReportRenderer.ReportJSON} reportJson
* @param {ReportJSON} reportJson
* @private
*/
_validateReportJson(reportJson) {
@ -107,7 +135,7 @@ class LighthouseReportViewer {
}
/**
* @param {!ReportRenderer.ReportJSON} json
* @param {ReportJSON} json
* @private
*/
_replaceReportHtml(json) {
@ -121,7 +149,7 @@ class LighthouseReportViewer {
const dom = new DOM(document);
const renderer = new ReportRenderer(dom);
const container = document.querySelector('main');
const container = find('main', document);
try {
renderer.renderReport(json, container);
@ -130,7 +158,7 @@ class LighthouseReportViewer {
let saveCallback = null;
if (!this._reportIsFromGist) {
saveCallback = this._onSaveJson;
history.pushState({}, null, LighthouseReportViewer.APP_URL);
history.pushState({}, undefined, LighthouseReportViewer.APP_URL);
}
const features = new ViewerUIFeatures(dom, saveCallback);
@ -155,8 +183,8 @@ class LighthouseReportViewer {
/**
* Updates the page's HTML with contents of the JSON file passed in.
* @param {!File} file
* @return {!Promise<undefined>}
* @param {File} file
* @return {Promise<void>}
* @throws file was not valid JSON generated by Lighthouse or an unknown file
* type was used.
* @private
@ -176,31 +204,31 @@ class LighthouseReportViewer {
/**
* Stores v2.x report in IDB, then navigates to legacy viewer in current tab
* @param {!ReportRenderer.ReportJSON} reportJson
* @param {ReportJSON} reportJson
* @private
*/
_loadInLegacyViewerVersion(json) {
_loadInLegacyViewerVersion(reportJson) {
const warnMsg = `Version mismatch between viewer and JSON. Opening compatible viewer...`;
logger.log(warnMsg, false);
// Place report in IDB, then navigate current tab to the legacy viewer
const viewerPath = new URL('../viewer2x/', location.href);
idbKeyval.set('2xreport', json).then(_ => {
window.location.href = viewerPath;
idbKeyval.set('2xreport', reportJson).then(_ => {
window.location.href = viewerPath.href;
});
}
/**
* Reads a file and returns its content as a string.
* @param {!File} file
* @return {!Promise<string>}
* @param {File} file
* @return {Promise<string>}
* @private
*/
_readFile(file) {
return new Promise((resolve, reject) => {
const reader = new window.FileReader();
const reader = new FileReader();
reader.onload = function(e) {
resolve(e.target.result);
resolve(e.target && e.target.result);
};
reader.onerror = reject;
reader.readAsText(file);
@ -209,8 +237,8 @@ class LighthouseReportViewer {
/**
* Saves the current report by creating a gist on GitHub.
* @param {!ReportRenderer.ReportJSON} reportJson
* @return {!Promise<string>} id of the created gist.
* @param {ReportJSON} reportJson
* @return {Promise<string|void>} id of the created gist.
* @private
*/
_onSaveJson(reportJson) {
@ -225,7 +253,7 @@ class LighthouseReportViewer {
}
this._reportIsFromGist = true;
history.pushState({}, null, `${LighthouseReportViewer.APP_URL}?gist=${id}`);
history.pushState({}, undefined, `${LighthouseReportViewer.APP_URL}?gist=${id}`);
return id;
}).catch(err => logger.log(err.message));
@ -233,6 +261,7 @@ class LighthouseReportViewer {
/**
* Enables pasting a JSON report or gist URL on the page.
* @param {ClipboardEvent} e
* @private
*/
_onPaste(e) {
@ -241,7 +270,7 @@ class LighthouseReportViewer {
// Try paste as gist URL.
try {
const url = new URL(e.clipboardData.getData('text'));
this._loadFromGistURL(url);
this._loadFromGistURL(url.href);
if (window.ga) {
window.ga('send', 'event', 'report', 'paste-link');
@ -254,7 +283,7 @@ class LighthouseReportViewer {
try {
const json = JSON.parse(e.clipboardData.getData('text'));
this._reportIsFromGist = false;
this._replaceReportHTML(json);
this._replaceReportHtml(json);
if (window.ga) {
window.ga('send', 'event', 'report', 'paste');
@ -266,17 +295,20 @@ class LighthouseReportViewer {
/**
* Handles changes to the gist url input.
* @param {Event} e
* @private
*/
_onUrlInputChange(e) {
e.stopPropagation();
if (!e.target.value) {
if (!e.target) {
return;
}
const inputElement = /** @type {HTMLInputElement} */ (e.target);
try {
this._loadFromGistURL(e.target.value);
this._loadFromGistURL(inputElement.value);
} catch (err) {
logger.error('Invalid URL');
}
@ -285,12 +317,12 @@ class LighthouseReportViewer {
/**
* Loads report json from gist URL, if valid. Updates page URL with gist ID
* and loads from github.
* @param {string} url Gist URL.
* @param {string} urlStr Gist URL.
* @private
*/
_loadFromGistURL(url) {
_loadFromGistURL(urlStr) {
try {
url = new URL(url);
const url = new URL(urlStr);
if (url.origin !== 'https://gist.github.com') {
logger.error('URL was not a gist');
@ -299,7 +331,7 @@ class LighthouseReportViewer {
const match = url.pathname.match(/[a-f0-9]{5,}/);
if (match) {
history.pushState({}, null, `${LighthouseReportViewer.APP_URL}?gist=${match[0]}`);
history.pushState({}, undefined, `${LighthouseReportViewer.APP_URL}?gist=${match[0]}`);
this._loadFromDeepLink();
}
} catch (err) {
@ -333,6 +365,7 @@ class LighthouseReportViewer {
}
}
// @ts-ignore - node export for testing.
if (typeof module !== 'undefined' && module.exports) {
module.exports = LighthouseReportViewer;
}

Просмотреть файл

@ -7,6 +7,10 @@
/* global LighthouseReportViewer, Logger */
/**
* @param {string} src
* @return {Promise}
*/
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
@ -28,19 +32,26 @@ if (!('URLSearchParams' in window)) {
// Lazy load polyfills that are needed. If any of the load promises fails,
// stop and don't create a report.
Promise.all(loadPolyfillPromises).then(_ => {
window.logger = new Logger(document.querySelector('#lh-log'));
const logEl = document.querySelector('#lh-log');
if (!logEl) {
throw new Error('logger element not found');
}
// TODO: switch all global uses of logger to `lh-log` events.
window.logger = new Logger(logEl);
// Listen for log events from main report.
document.addEventListener('lh-log', e => {
switch (e.detail.cmd) {
const ce = /** @type {CustomEvent<{cmd: string, msg: string}>} */ (e);
switch (ce.detail.cmd) {
case 'log':
window.logger.log(e.detail.msg);
window.logger.log(ce.detail.msg);
break;
case 'warn':
window.logger.warn(e.detail.msg);
window.logger.warn(ce.detail.msg);
break;
case 'error':
window.logger.error(e.detail.msg);
window.logger.error(ce.detail.msg);
break;
case 'hide':
window.logger.hide();
@ -50,8 +61,11 @@ Promise.all(loadPolyfillPromises).then(_ => {
// Listen for analytics events from main report.
document.addEventListener('lh-analytics', e => {
const ce = /** @type {CustomEvent<{cmd: string, fields: UniversalAnalytics.FieldsObject}>} */
(e);
if (window.ga) {
window.ga(e.detail.cmd, e.detail.fields);
window.ga(ce.detail.cmd, ce.detail.fields);
}
});

Просмотреть файл

@ -7,24 +7,25 @@
/* global ReportUIFeatures, ReportGenerator */
/** @typedef {import('../../../lighthouse-core/report/html/renderer/report-renderer.js').ReportJSON} ReportJSON */
/**
* Extends ReportUIFeatures to add an (optional) ability to save to a gist and
* generates the saved report from a browserified ReportGenerator.
*/
class ViewerUIFeatures extends ReportUIFeatures {
/**
* @param {!DOM} dom
* @param {?function(!ReportRenderer.ReportJSON)} saveGistCallback
* @param {DOM} dom
* @param {?function(ReportJSON)} saveGistCallback
*/
constructor(dom, saveGistCallback) {
super(dom);
/** @private {?function(!ReportRenderer.ReportJSON)} */
this._saveGistCallback = saveGistCallback;
}
/**
* @param {!ReportRenderer.ReportJSON} report
* @param {ReportJSON} report
* @override
*/
initFeatures(report) {
@ -33,7 +34,7 @@ class ViewerUIFeatures extends ReportUIFeatures {
// Disable option to save as gist if no callback for saving.
if (!this._saveGistCallback) {
const saveGistItem = this._dom.find('.lh-export--gist', this._document);
saveGistItem.setAttribute('disabled', true);
saveGistItem.setAttribute('disabled', 'true');
}
}
@ -43,6 +44,7 @@ class ViewerUIFeatures extends ReportUIFeatures {
* @override
*/
getReportHtml() {
// @ts-ignore - TODO(bckenny): remove ignore when this.json is an LHR instead of ReportJSON.
return ReportGenerator.generateReportHtml(this.json);
}
@ -59,10 +61,11 @@ class ViewerUIFeatures extends ReportUIFeatures {
// Disable save-as-gist option after saving.
const saveGistItem = this._dom.find('.lh-export--gist', this._document);
saveGistItem.setAttribute('disabled', true);
saveGistItem.setAttribute('disabled', 'true');
}
}
// @ts-ignore - node export for testing.
if (typeof module !== 'undefined' && module.exports) {
module.exports = ViewerUIFeatures;
}

Просмотреть файл

@ -7,9 +7,14 @@
"scripts": {
"watch": "gulp watch",
"build": "gulp",
"pptr-test": "mocha test/viewer-test-pptr.js"
"pptr-test": "mocha test/viewer-test-pptr.js",
"type-check": "../node_modules/.bin/tsc -p ."
},
"devDependencies": {
"@firebase/app-types": "^0.3.1",
"@firebase/auth-types": "^0.3.2",
"@firebase/util": "^0.2.1",
"@types/google.analytics": "^0.0.39",
"brfs": "^1.4.3",
"browserify": "^13.0.0",
"del": "^2.2.0",
@ -28,7 +33,6 @@
"run-sequence": "^1.1.5",
"streamqueue": "^1.1.1",
"tsify": "^2.0.3",
"typescript": "^2.1.4",
"uglify-es": "^3.0.15",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"

Просмотреть файл

@ -0,0 +1,15 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"typeRoots": [
"@types",
"../typings",
"./types",
],
},
"include": [
"app/src/**/*.js",
"../typings/*.d.ts",
"./types/*.d.ts",
],
}

43
lighthouse-viewer/types/viewer.d.ts поставляемый Normal file
Просмотреть файл

@ -0,0 +1,43 @@
/**
* @license Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* 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.
*/
import _ReportGenerator = require('../../lighthouse-core/report/report-generator.js');
import _Logger = require('../../lighthouse-core/report/html/renderer/logger.js');
import _LighthouseReportViewer = require('../app/src/lighthouse-report-viewer.js');
import _DragAndDrop = require('../app/src/drag-and-drop.js');
import _GithubApi = require('../app/src/github-api.js');
import _FirebaseAuth = require('../app/src/firebase-auth.js');
import _ViewerUIFeatures = require('../app/src/viewer-ui-features.js');
import 'google.analytics';
import {FirebaseNamespace} from '@firebase/app-types';
import '@firebase/auth-types';
declare global {
var ReportGenerator: typeof _ReportGenerator;
var Logger: typeof _Logger;
var logger: _Logger;
var LighthouseReportViewer: typeof _LighthouseReportViewer;
var DragAndDrop: typeof _DragAndDrop;
var GithubApi: typeof _GithubApi;
var FirebaseAuth: typeof _FirebaseAuth;
var ViewerUIFeatures: typeof _ViewerUIFeatures;
var idbKeyval: typeof import('idb-keyval');
var firebase: Required<FirebaseNamespace>;
interface Window {
logger: _Logger;
viewer: _LighthouseReportViewer;
ga: UniversalAnalytics.ga;
// Inserted by viewer gulpfile build.
LH_CURRENT_VERSION: string;
}
}
// empty export to keep file a module
export {}

Просмотреть файл

@ -2,6 +2,24 @@
# yarn lockfile v1
"@firebase/app-types@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.3.1.tgz#df4e79c38f759e606a421e866cecb7da4577b606"
"@firebase/auth-types@^0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.3.2.tgz#fc636084eb82cb098e4e76efc5fffd315e22abdd"
"@firebase/util@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.1.tgz#b59a2fbf14fce21401cbebf776a3e0260b591380"
dependencies:
tslib "1.9.0"
"@types/google.analytics@^0.0.39":
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/google.analytics/-/google.analytics-0.0.39.tgz#19a952003dbf3c7373d655a5c3203b4726b8b802"
JSONStream@^1.0.3:
version "1.2.1"
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.2.1.tgz#32aa5790e799481083b49b4b7fa94e23bae69bf9"
@ -3356,6 +3374,10 @@ tsify@^2.0.3:
through2 "^2.0.0"
tsconfig "^5.0.3"
tslib@1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
tty-browserify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
@ -3378,10 +3400,6 @@ typedarray@^0.0.6, typedarray@~0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
typescript@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.4.tgz#b53b69fb841126acb1dd4b397d21daba87572251"
uglify-es@^3.0.15:
version "3.0.15"
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.0.15.tgz#4a23d0e9cb5f25f7bb3f1f0bbe0bb364e600d047"

Просмотреть файл

@ -57,7 +57,7 @@
"bundlesize": "bundlesize",
"plots-smoke": "bash plots/test/smoke.sh",
"changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file",
"type-check": "tsc -p .",
"type-check": "tsc -p . && cd ./lighthouse-viewer && yarn type-check",
"update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js -G",
"update:sample-json": "node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --throttling-method=devtools --output=json --output-path=./lighthouse-core/test/results/sample_v2.json http://localhost/dobetterweb/dbw_tester.html && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing",
"diff:sample-json": "bash lighthouse-core/scripts/assert-golden-lhr-unchanged.sh",

Просмотреть файл

@ -21,7 +21,6 @@
"lighthouse-cli/**/*.js",
"lighthouse-core/**/*.js",
"./typings/*.d.ts",
],
"exclude": [
"lighthouse-cli/test/**/*.js",