-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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(lhr): lhr-lite type declaration #4983
Conversation
typings/lhr-lite.d.ts
Outdated
* 'notApplicable': the audit turned out to not apply to the page. Ignore the score. | ||
* 'manual': The audit exists only to tell you to review something yourself. Ignore the score. | ||
*/ | ||
scoreDisplayMode: 'binary' | 'numeric' | 'informative' | 'notApplicable' | 'manual'; |
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.
should we have an 'error'
scoreDisplayMode
? That brings us (basically) back to a boolean and a string, which isn't ideal, but it also makes sense as it affects interpretation of the score in the same way that 'informative'
'notApplicable'
, and 'manual'
do (you should ignore whatever is in score
) and you won't have to look in multiple places to see how you should interpret score
(like you do currently)
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.
I like it 👍
typings/lhr-lite.d.ts
Outdated
wastedMs: number | ||
wastedBytes?: number | ||
headings: AuditColumnHeading[]; | ||
rows: AuditTableRow[]; |
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.
renaming items
to rows
, eh? :)
I prefer items
personally because it doesn't imply these table semantics. Table-ness is a visual/report thing, which i don't think is relevant to most consumers of the LHR
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.
renaming items to rows, eh? :)
hehe, caught me. I can switch back, but "headings" doesn't really make sense without some matrix/table-ness structure imposed on the data anyways
typings/lhr-lite.d.ts
Outdated
valueType: 'url' | 'text' | 'link' | 'timespanMs'; | ||
} | ||
|
||
export type AuditTableRow = WastedBytesDetailsRow | WastedTimeDetailsRow; |
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.
can u inline this into the two uses above?
typings/lhr-lite.d.ts
Outdated
export interface AuditOpportunityDetails { | ||
type: 'opportunity'; | ||
wastedMs: number | ||
wastedBytes?: number |
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.
should we rename these totalWastedMs
/totalWastedBytes
? To make it clear what they are
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.
Crazy idea. since these are opportunities, we could stay on the optimistic side.. something like.. "estimatedSavingsMs"
?
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.
estimatedSavingsMs
I'm on board with that @patrickhulce
typings/lhr-lite.d.ts
Outdated
/** An object containing the top-level categories, their overall scores, and reference to member audits. */ | ||
categories?: Record<string, ResultLite.Category>; | ||
/** Descriptions of the audit groups referenced by AuditRefs. */ | ||
categoryGroups?: Record<string, ResultLite.CategoryGroup>; |
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.
Did we decide of groups
for this? I don't remember at this point 😆 or auditGroups
aka "groups of related audits"
/** The version of Lighthouse with which these results were generated. */ | ||
lighthouseVersion: string; | ||
/** An object containing the results of the audits. */ | ||
audits: Record<string, ResultLite.Audit>; |
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.
since we don't have any references to what auditId
really is how do you feel about aliases like type AuditId = string
?
typings/lhr-lite.d.ts
Outdated
* 'notApplicable': the audit turned out to not apply to the page. Ignore the score. | ||
* 'manual': The audit exists only to tell you to review something yourself. Ignore the score. | ||
*/ | ||
scoreDisplayMode: 'binary' | 'numeric' | 'informative' | 'notApplicable' | 'manual'; |
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.
I like it 👍
typings/lhr-lite.d.ts
Outdated
export interface AuditColumnHeading { | ||
key: string; | ||
label: string; | ||
valueType: 'url' | 'text' | 'link' | 'timespanMs'; |
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.
also have bytes
and duration
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.
duration -> timespanMs I thought? Also do we actually have text or links if it's just WastedBytesDetailsItem or WastedTimeDetailsItem?
typings/lhr-lite.d.ts
Outdated
} | ||
|
||
export interface AuditTableDetails { | ||
type: 'table'; |
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.
do we actually have any of these that we want to expose? seems like we're only wanting to expose the opportunities which all use the table headings/rows types
oh yeah, a big one is |
typings/lhr-lite.d.ts
Outdated
/** An object containing the results of the audits. */ | ||
audits: Record<string, ResultLite.Audit>; | ||
/** An object containing the top-level categories, their overall scores, and reference to member audits. */ | ||
categories?: Record<string, ResultLite.Category>; |
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.
should be required, even if an empty object (API responses should always have categories, so no need to make people jump through hoops checking for categories
existence every time)
I think the last decision is Any thoughts on that and last changes before I commit us to this? :) |
Aw shoot sorry I forgot to submit my review!! Yes I have a thought. Do we even need these in LHR lite? |
if it were I can't remember exactly why we added them to LHR-lite but I believe @paulirish thought it would be desired by consumers/trivial to add. |
okay i'm on board with leaving groups out of LHR-lite. we're not 100% on them and there's not a high priority reason to include them. (i think i started with "hey, might as well.")
The only one there that could be useful is k let's boot groups. |
cool cool +1 to brendan's fav for |
ready for final 🎖 💯 @vinamratasingal FYI on API return value |
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.
I think this is great! I left 😬 everywhere I have a sinking feeling I'll regret that in ~6 months, but IMO this could ship today and I'm 👍
/** The overall score of the category, the weighted average of all its audits. */ | ||
score: number; | ||
/** An array of references to all the audit members of this category. */ | ||
auditRefs: AuditRef[]; |
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.
😬
/** An array of references to all the audit members of this category. */ | ||
auditRefs: AuditRef[]; | ||
/** An optional description for manual audits within this category. */ | ||
manualDescription?: string; |
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.
😬
/** A more detailed description that describes why the audit is important and links to Lighthouse documentation on the audit; markdown links supported. */ | ||
description: string; | ||
/** The scored value determined by the audit, in the range `0-1`, or null if `scoreDisplayMode` indicates not scored. */ | ||
score: number | null; |
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.
FWIW I'd prefer score?: number
export interface MetricDetails { | ||
type: 'metric'; | ||
/** The value of the metric expressed in milliseconds. */ | ||
timespanMs?: number; |
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.
I'm still 😬, but I think we mostly exhausted options. last-ditch effort anyone like ms
timeMs
timingMs
more?
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.
i consider timespanMs/ms/timingMs to be equally 😬 and i'd be fine with any of those.
@paulirish up to you now |
ready for feedback on design/implementation of the design :)