misc(treemap): initialize app structure#11635
Conversation
|
Should the commits for this be |
patrickhulce
left a comment
There was a problem hiding this comment.
thanks for the split up, much easier to follow! 🎉 💯
| m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m) | ||
| })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); | ||
|
|
||
| ga('create', 'UA-85519014-2', 'auto'); |
There was a problem hiding this comment.
is this the same analytics account as the viewer? I guess that's what we want when served over same domain anyway
| */ | ||
| function injectOptions() { | ||
| // @ts-expect-error | ||
| if (!window.__injected) return; |
There was a problem hiding this comment.
could this mean...?
| if (!window.__injected) return; | |
| // Don't inject again if we've already injected the options. | |
| if (window.__injected) return; |
There was a problem hiding this comment.
if so my dream about syncing the UI state to this seems to be DOA :)
There was a problem hiding this comment.
(I refactored this a bit, I think I was mistaken that a separated boolean was needed here)
What do you mean by syncing UI state? For the Ctrl-S document save? I suppose we could delete and keep replacing this script tag as the user changes the view, to facilitate that. Although I doubt many will know to do this, and a better future plan would be a gist-hosted solution.
| type Node = _Node; | ||
| } | ||
|
|
||
| interface WebTreeMapOptions { |
There was a problem hiding this comment.
these aren't used yet right?
There was a problem hiding this comment.
nope. Just types for the webtreemap library. https://github.com/paulirish/webtreemap-cdt#options
|
|
||
| async function main() { | ||
| if (window.__TREEMAP_OPTIONS) { | ||
| init(window.__TREEMAP_OPTIONS); |
There was a problem hiding this comment.
| init(window.__TREEMAP_OPTIONS); | |
| // Prefer the hardcoded options from a saved HTML file above all. | |
| init(window.__TREEMAP_OPTIONS); |
is this the only situation that this applies?
|
|
||
| declare global { | ||
| module Treemap { | ||
| interface Options { |
There was a problem hiding this comment.
will this eventually have options in it too?
right now options feels like a bit of a misnomer, payload, initialization data, do any of those seem right?
I'm mostly pushing on this a bit because it feels like we are about to get some UI state for this app, which feels distinctly different from an initial payload. Maybe it's the intention to have all UI state configurable from the initial payload though?
There was a problem hiding this comment.
Maybe it's the intention to have all UI state configurable from the initial payload though?
Yup. The UI state is called "Mode" in the WIP branch: https://github.com/GoogleChrome/lighthouse/compare/viewer-treemap-2#diff-c3c7c9ceaada02e42e7ba0b22d920ac101a4747c1742eae23000f6c7627c6f3bR13 The idea is that some bits of the LH report will set a mode to show a certain view.
How active do you expect treemap viewer to be once the bulk is built? If the answer is "as active as viewer" I'd vote |
|
|
|
|
||
| <script src="src/bundled.js"></script> | ||
| <script> | ||
| (function (i, s, o, g, r, a, m) { |
There was a problem hiding this comment.
A comment here that summarizes what's happening could be helpful if it's not too much trouble. Personally, at first glance this bit threw me for a loop.
There was a problem hiding this comment.
This is meant-to-be-unreadable code for google analytics :) it's what they give to you for copy/paste.
|
@patrickhulce what further changes are you requesting? |
| @@ -0,0 +1,28 @@ | |||
| import '../../types/treemap'; | |||
There was a problem hiding this comment.
I don't see any errors in vscode now, but yarn tsc -p lighthouse-treemap/ fails spectacularly. @brendankenny I'm quite lost here, do you have any advice?
There was a problem hiding this comment.
I think typeRoots might be your problem
I don't know yet I thought you were still working on this, sorry. Is this awaiting my feedback? |
patrickhulce
left a comment
There was a problem hiding this comment.
pretty much LGTM, just the types issue and cleanup of outstanding GA question
| * @param {LH.Treemap.Options} options | ||
| */ | ||
| function injectOptions(options) { | ||
| if (window.__treemapOptions) return; |
There was a problem hiding this comment.
definitely fits now, so not worth discussing much, but can I reserve the right to object to options if this turns into state in future PRs? 😃
| { | ||
| "extends": "../tsconfig", | ||
| "compilerOptions": { | ||
| "typeRoots": [ |
There was a problem hiding this comment.
I don't think this actually includes the types like you want it to, does it? That might be your problem, most of our types aren't packages, they're just files that should be in include, no?
There was a problem hiding this comment.
awesome, thanks!
| @@ -0,0 +1,28 @@ | |||
| import '../../types/treemap'; | |||
There was a problem hiding this comment.
I think typeRoots might be your problem
ref #11254, split off from #11545
Basic app structure, including build and puppeteer tests. Simply prints the LHR to the page.