-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
README: Reorganization and new "Using programmatically" section #1721
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Architecture | ||
|
||
_Some incomplete notes_ | ||
|
||
## Components | ||
|
||
* **Driver** - Interfaces with [Chrome Debugging Protocol](https://developer.chrome.com/devtools/docs/debugger-protocol) ([API viewer](https://chromedevtools.github.io/debugger-protocol-viewer/)) | ||
* **Gathers** - Requesting data from the browser (and maybe post-processing) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gatherers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
* **Artifacts** - The output of gatherers | ||
* **Audits** - Non-performance evaluations of capabilities and issues. Includes a raw value and score of that value. | ||
* **Metrics** - Performance metrics summarizing the UX | ||
* **Diagnoses** - The perf problems that affect those metrics | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still a thing that we call Diagnoses? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
* **Aggregators** - Pulling audit results, grouping into user-facing components (eg. `install_to_homescreen`) and applying weighting and overall scoring. | ||
|
||
### Internal module graph | ||
|
||
![graph of lighthouse-core module dependencies](https://cloud.githubusercontent.com/assets/39191/19367685/04d4336a-9151-11e6-9ebb-3b87bdb09a4c.png) | ||
|
||
`npm install -g js-vd; vd --exclude "node_modules|third_party|fs|path|url|log" lighthouse-core/ > graph.html` | ||
|
||
## Protocol | ||
|
||
* _Interacting with Chrome:_ The Chrome protocol connection maintained via [WebSocket](https://github.com/websockets/ws) for the CLI [`chrome.debuggger` API](https://developer.chrome.com/extensions/debugger) when in the Chrome extension. | ||
* _Event binding & domains_: Some domains must be `enable()`d so they issue events. Once enabled, they flush any events that represent state. As such, network events will only issue after the domain is enabled. All the protocol agents resolve their `Domain.enable()` callback _after_ they have flushed any pending events. See example: | ||
|
||
```js | ||
// will NOT work | ||
driver.sendCommand('Security.enable').then(_ => { | ||
driver.on('Security.securityStateChanged', state => { /* ... */ }); | ||
}) | ||
|
||
// WILL work! happy happy. :) | ||
driver.on('Security.securityStateChanged', state => { /* ... */ }); // event binding is synchronous | ||
driver.sendCommand('Security.enable'); | ||
``` | ||
|
||
* _Debugging the protocol_: Read [Better debugging of the Protocol](https://github.com/GoogleChrome/lighthouse/issues/184). | ||
|
||
## Gatherers | ||
|
||
* _Reading the DOM:_ We prefer reading the DOM right from the browser (See #77). The driver exposes a `querySelector` method that can be used along with a `getAttribute` method to read values. | ||
|
||
## Audits | ||
|
||
The return value of each audit takes this shape: | ||
|
||
```js | ||
Promise.resolve({ | ||
name: 'audit-name', | ||
description: 'whatnot', | ||
// value: The score. Typically a boolean, but can be number 0-100 | ||
value: 0, | ||
// rawValue: Could be anything, as long as it can easily be stringified and displayed, | ||
// e.g. 'your score is bad because you wrote ${rawValue}' | ||
rawValue: {}, | ||
// debugString: Some *specific* error string for helping the user figure out why they failed here. | ||
// The reporter can handle *general* feedback on how to fix, e.g. links to the docs | ||
debugString: 'Your manifest 404ed', | ||
}); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this file can get merged with API-and-internals.md
and since readme and contributing are in root, i kinda prefer keeping this md file there rather than docs/. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you. I figured we'd have more in the future and wanted to declutter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch, which we could leverage someday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved and renamed that file to "headless-chrome.md". It didn't contain anything but headless Chrome stuff :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sg