-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
misc(treemap): add placeholder, gist and file upload features #12511
Conversation
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.
WDYT about "misc(treemap): add placeholder, load from gist, and file drop features" for PR name? I was hunting around for the upload functionality until I saw the "gist creation" was a todo which was the only upload I could think of.
I wasn't able to build treemap locally either (complaining about umd.js
of eventtargetshim) so I couldn't test anything out, but looks like a solid copy of viewer :)
@@ -36,6 +36,7 @@ class GithubApi { | |||
return Promise.reject(new Error('Save already in progress')); | |||
} | |||
|
|||
// @ts-ignore |
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.
what's with all the explanationless ignores? :)
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 have no idea...all the sudden tsc -p .
fails because of these. but not in my editor...having weird issues lately :/
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.
ok it's b/c the Strings
import in build-treemap causes TSC to more than it should for tsc -p .
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.
Have you tried replacing with window.logger
? That's what's declared on the typedefs.
* @param {File} file | ||
* @return {Promise<string>} | ||
*/ | ||
readFile(file) { |
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.
seems like it should be static?
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.
ah I see below that would be annoying for tests, alright
lighthouse-treemap/app/index.html
Outdated
<h1 class="treemap-placeholder__heading">Lighthouse Treemap</h1> | ||
<div class="treemap-placeholder__help">To view a treemap: Paste the Lighthouse result json or a Gist URL.<br> | ||
You can also drag 'n drop the file or click here to select it.<br><br> | ||
To get a fresh report, use the Lighthouse browser extension (<a href="https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk">Chrome</a> / <a href="https://addons.mozilla.org/en-US/firefox/addon/google-lighthouse/">Firefox</a>)<br> |
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.
The extension bit might be more confusing advice for treemap since they'll end up back over at viewer instead of the treemap and they may or may not have the "view treemap" button.
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.
They should always have it after PSI upgrades. does that resolve your concern?
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.
They should always have it after PSI upgrades. does that resolve your concern?
Not particularly. My concern is that if we didn't copy/paste from viewer it feels like we wouldn't have written this that paragraph this way and especially not encourage the extension (the reason we did so for viewer is because the extension is the entrypoint for most people using viewer).
The "may or may not have the view treemap button" was also a comment on the general applicability of this page compared to viewer and how appropriate it is to explain that. For example, should we use this space instead to link to a treemap / sourcemaps article on web.dev?
lighthouse-treemap/app/src/main.js
Outdated
*/ | ||
convertToOptions(json) { | ||
if (json instanceof Object) { | ||
if ('lhr' in json) return json; |
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.
it's so messed up that TS thinks this is OK 😆
json
is inferred to be never
at this point, so we've basically silently devolved from unknown
to any
Co-authored-by: Patrick Hulce <[email protected]>
what's the error? I get no error. |
Same error as CI. The issue is In Node 10 this works as expected by requiring that file. In Node 12+ this looks for an export called |
woah... why does CI keep going after this.. idk i'm on v12.13.0 |
what's that now? Then why do the following lines, which also import a file with the .js extension work? or is it different because it's not multiple path levels deep? what is this node 12 feature/change to module resolution called? EDIT: oh, I just noticed the exports field in package.json, guess that's it. |
types/i18n.d.ts
Outdated
|
||
export type LhlMessages = Record<string, {message: string}>; | ||
|
||
export type Strings = Record<LH.Locale, LhlMessages>; |
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'd really like to avoid making global types when they aren't needed, or at least scope these to treemap.d.ts
. Defining LhlMessages
in locales.js
where the actual object is also defined was very intentional, and LH.Strings
is a simple and can just be defined in place.
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.
removed Strings. but LhlMessages is used in 6 different files, so despite intention it is being used globally just in the more cumbersome jsdoc import style.
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.
so despite intention it is being used globally just in the more cumbersome jsdoc import style.
Strong disagree. At no point has anyone suggested setting global.i18n = require('./lighthouse-core/lib/i18n/i18n.js')
so we can avoid require('../../../lib/i18n/i18n.js')
in all the files that use it, for instance.
I think that it's not worth hashing out the usefulness of globals (whether in value- or type-space) in this PR, though, but more importantly I think there's enough going on in here without making changes to types in core. Can we revert and follow up later? Happy to discuss at another time.
A few months ago we discussed an idea of merging these into a single webapp. The report viewer, the treemap, the calculator. At the time I think it was decided things were too early. Seems like it's time to reopen that conversation? :) |
Happy to discuss this, but it shouldn't block moving forward with this PR :) wdyt of adding to placeholder: "What is this? Show me an example" text that links to a gist? |
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.
It seemed like this wasn't actually waiting on committer, so I took another look.
WDYT about "misc(treemap): add placeholder UI, load from gist, and file drop features" for PR name? I was hunting around for the upload functionality until I saw the "gist creation" was a todo which was the only upload I could think of.
Bump :)
The treemap tests appear to be broken in CI, but I wasn't able to manually reproduce. Something else might have changed with the programmatic triggering?
@@ -0,0 +1,116 @@ | |||
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
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 can't comment directly on them, but those favicon file renames seem like a mistake. I don't see a manifest.json for the treemap app that references them and I don't see the viewer references removed either.
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.
oops... I copied the images folder, and accidently deleted excess images from the wrong folder. hence "rename"
Co-authored-by: Patrick Hulce <[email protected]>
I renamed the title:
Been poking at this. No idea why this is failing now. |
haha, oxford comma aside, the both |
@@ -77,9 +77,12 @@ describe('Lighthouse Treemap', () => { | |||
await new Promise(resolve => browser.on('targetcreated', resolve)); | |||
const target = (await browser.targets()).find(target => target.url() === treemapUrl); | |||
page = await target.page(); | |||
await openerPage.close(); |
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.
deleting await openerPage.close();
fixed the issue. shrug.
Co-authored-by: Patrick Hulce <[email protected]>
ref #11254
https://gist.github.com/connorjclark/060f0322480cc9dbad793b8cea405e46
https://lighthouse-git-treemap-appify-googlechrome.vercel.app/gh-pages/treemap/?gist=060f0322480cc9dbad793b8cea405e46
TODO/follow up PR: