webpack-bundle-analyzer 3.5.1 → 3.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -14,6 +14,11 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
14
14
 
15
15
  <!-- Add changelog entries for new changes under this section -->
16
16
 
17
+ ## 3.5.2
18
+
19
+ * **Bug Fix**
20
+ * Fix sidebar not showing visibility status of chunks hidden via popup menu (issue [#316](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/316) by [@gaokun](https://github.com/gaokun), fixed in [#317](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/317) by [@bregenspan](https://github.com/bregenspan))
21
+
17
22
  ## 3.5.1
18
23
 
19
24
  * **Bug Fix**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-bundle-analyzer",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
4
4
  "description": "Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap",
5
5
  "author": "Yury Grunin <grunin.ya@ya.ru>",
6
6
  "license": "MIT",
package/public/viewer.js CHANGED
@@ -36,5 +36,5 @@
36
36
  /**
37
37
  * Copyright 2015, Yahoo! Inc.
38
38
  * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
39
- */var n,r,i,o,a,s,u,l;e.exports=(n={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},r={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i=Object.defineProperty,o=Object.getOwnPropertyNames,a=Object.getOwnPropertySymbols,s=Object.getOwnPropertyDescriptor,u=Object.getPrototypeOf,l=u&&u(Object),function e(t,c,h){if("string"!=typeof c){if(l){var f=u(c);f&&f!==l&&e(t,f,h)}var d=o(c);a&&(d=d.concat(a(c)));for(var p=0;p<d.length;++p){var g=d[p];if(!(n[g]||r[g]||h&&h[g])){var b=s(c,g);try{i(t,g,b)}catch(v){}}}return t}return t})});var Fn={children:!0,key:!0,ref:!0},Un=console;!function(e){function t(){return _n(this,t),An(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}On(t,N),Dn(t,[{key:"render",value:function(e){var t=e.children;return t.length>1?s("div",null," ",t," "):t[0]}},{key:"getChildContext",value:function(){var e={},t=this.context.mobxStores;if(t)for(var n in t)e[n]=t[n];for(var r in this.props)Fn[r]||"suppressChangedStoreWarning"===r||(e[r]=this.props[r]);return{mobxStores:e}}},{key:"componentWillReceiveProps",value:function(e){if(Object.keys(e).length!==Object.keys(this.props).length&&Un.warn("MobX Provider: The set of provided stores has changed. Please avoid changing stores as the change might not propagate to all children"),!e.suppressChangedStoreWarning)for(var t in e)Fn[t]||this.props[t]===e[t]||Un.warn("MobX Provider: Provided store '"+t+"' has changed. Please avoid replacing stores as the change might not propagate to all children")}}])}();if(!N)throw new Error("mobx-preact requires Preact to be available");function Hn(){return(Hn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var Vn=n(22),Wn=n.n(Vn);class qn extends N{constructor(e){super(e),this.saveNodeRef=(e=>this.node=e),this.resize=(()=>{const{props:e}=this;this.treemap.resize(),e.onResize&&e.onResize()}),this.treemap=null,this.zoomOutDisabled=!1}componentDidMount(){this.treemap=this.createTreemap(),window.addEventListener("resize",this.resize)}componentWillReceiveProps(e){if(e.data!==this.props.data)this.treemap.set({dataObject:this.getTreemapDataObject(e.data)});else if(e.highlightGroups!==this.props.highlightGroups){const t=[...e.highlightGroups,...this.props.highlightGroups];setTimeout(()=>this.treemap.redraw(!1,t))}}shouldComponentUpdate(){return!1}componentWillUnmount(){window.removeEventListener("resize",this.resize),this.treemap.dispose()}render(){return s("div",Hn({},this.props,{ref:this.saveNodeRef}))}getTreemapDataObject(e=this.props.data){return{groups:e}}createTreemap(){const e=this,{props:t}=this;return new Wn.a({element:this.node,layout:"squarified",stacking:"flattened",pixelRatio:window.devicePixelRatio||1,maxGroups:1/0,maxGroupLevelsDrawn:1/0,maxGroupLabelLevelsDrawn:1/0,maxGroupLevelsAttached:1/0,groupMinDiameter:0,groupLabelVerticalPadding:.2,rolloutDuration:0,pullbackDuration:0,fadeDuration:0,groupExposureZoomMargin:.2,zoomMouseWheelDuration:300,openCloseDuration:200,dataObject:this.getTreemapDataObject(),titleBarDecorator(e,t,n){n.titleBarShown=!1},groupColorDecorator(t,n,r){const{highlightGroups:i}=e.props,o=n.group;i&&i.has(o)&&(r.groupColor={model:"rgba",r:255,g:0,b:0,a:.8})},onGroupClick(n){Kn(n),(n.ctrlKey||n.secondary)&&t.onGroupSecondaryClick?t.onGroupSecondaryClick.call(e,n):(e.zoomOutDisabled=!1,this.zoom(n.group))},onGroupDoubleClick:Kn,onGroupHover(n){n.group&&n.group.attribution?n.preventDefault():t.onGroupHover&&t.onGroupHover.call(e,n)},onGroupMouseWheel(t){const{scale:n}=this.get("viewport");if(t.delta<0){if(e.zoomOutDisabled)return Kn(t);n<1&&(e.zoomOutDisabled=!0,Kn(t))}else e.zoomOutDisabled=!1}})}zoomToGroup(e){for(this.zoomOutDisabled=!1;e&&!this.treemap.get("state",e).revealed;)e=this.treemap.get("hierarchy",e).parent;e&&this.treemap.zoom(e)}isGroupRendered(e){const t=this.treemap.get("state",e);return!!t&&t.revealed}update(){this.treemap.update()}}function Kn(e){e.preventDefault()}var Yn=n(0),Zn=n.n(Yn),$n=n(15),Jn=n.n($n);class Qn extends N{constructor(...e){super(...e),this.mouseCoords={x:0,y:0},this.state={left:0,top:0},this.handleMouseMove=(e=>{Object.assign(this.mouseCoords,{x:e.pageX,y:e.pageY}),this.props.visible&&this.updatePosition()}),this.saveNode=(e=>this.node=e)}componentDidMount(){document.addEventListener("mousemove",this.handleMouseMove,!0)}shouldComponentUpdate(e){return this.props.visible||e.visible}componentWillUnmount(){document.removeEventListener("mousemove",this.handleMouseMove,!0)}render(){const{children:e,visible:t}=this.props,n=Zn()({[Jn.a.container]:!0,[Jn.a.hidden]:!t});return s("div",{ref:this.saveNode,className:n,style:this.getStyle()},e)}getStyle(){return{left:this.state.left,top:this.state.top}}updatePosition(){if(!this.props.visible)return;const e={left:this.mouseCoords.x+Qn.marginX,top:this.mouseCoords.y+Qn.marginY},t=this.node.getBoundingClientRect();e.left+t.width>window.innerWidth&&(e.left=window.innerWidth-t.width),e.top+t.height>window.innerHeight&&(e.top=this.mouseCoords.y-Qn.marginY-t.height),this.setState(e)}}Qn.marginX=10,Qn.marginY=30;var Xn=n(9),er=n.n(Xn);class tr extends N{shouldComponentUpdate(e,t){return!nr(e,this.props)||!nr(this.state,t)}}function nr(e,t){if(e===t)return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++){const i=n[r];if(e[i]!==t[i])return!1}return!0}class rr extends tr{constructor(...e){super(...e),this.handleClick=(e=>{this.elem.blur(),this.props.onClick(e)}),this.saveRef=(e=>this.elem=e)}render({active:e,toggle:t,className:n,children:r,...i}){const o=Zn()(n,{[er.a.button]:!0,[er.a.active]:e,[er.a.toggle]:t});return s("button",Hn({},i,{ref:this.saveRef,type:"button",className:o,disabled:this.disabled,onClick:this.handleClick}),r)}get disabled(){const{props:e}=this;return e.disabled||e.active&&!e.toggle}}class ir extends tr{constructor(...e){super(...e),this.handleClick=(()=>{this.props.onClick(this.props.item)})}render({item:e,...t}){return s(rr,Hn({},t,{onClick:this.handleClick}),e.label)}}var or=n(10),ar=n.n(or);class sr extends tr{render(){const{label:e,items:t,activeItem:n,onSwitch:r}=this.props;return s("div",{className:ar.a.container},s("div",{className:ar.a.label},e,":"),s("div",null,t.map(e=>s(ir,{key:e.label,className:ar.a.item,item:e,active:e===n,onClick:r}))))}}var ur=n(4),lr=n.n(ur),cr=n(23),hr=n.n(cr);const fr={"arrow-right":{src:n(34),size:[7,13]},pin:{src:n(35),size:[12,18]}};class dr extends tr{render({className:e}){return s("i",{className:Zn()(hr.a.icon,e),style:this.style})}get style(){const{name:e,size:t,rotate:n}=this.props,r=fr[e];if(!r)throw new TypeError("Can't find \"".concat(e,'" icon.'));let[i,o]=r.size;if(t){const e=t/Math.max(i,o);i=Math.min(Math.ceil(i*e),t),o=Math.min(Math.ceil(o*e),t)}return{backgroundImage:"url(".concat(r.src,")"),width:"".concat(i,"px"),height:"".concat(o,"px"),transform:n?"rotate(".concat(n,"deg)"):""}}}const pr=parseInt(lr.a.toggleTime);class gr extends N{constructor(...e){super(...e),this.allowHide=!0,this.toggling=!1,this.hideContentTimeout=null,this.width=null,this.state={visible:!0,renderContent:!0},this.handleClick=(()=>{this.allowHide=!1}),this.handleMouseEnter=(()=>{this.toggling||this.props.pinned||(clearTimeout(this.hideTimeoutId),this.toggleVisibility(!0))}),this.handleMouseMove=(()=>{this.allowHide=!0}),this.handleMouseLeave=(()=>{!this.allowHide||this.toggling||this.props.pinned||this.toggleVisibility(!1)}),this.handleToggleButtonClick=(()=>{this.toggleVisibility()}),this.handlePinButtonClick=(()=>{const e=!this.props.pinned;this.width=e?this.node.getBoundingClientRect().width:null,this.updateNodeWidth(),this.props.onPinStateChange(e)}),this.handleResizeStart=(e=>{this.resizeInfo={startPageX:e.pageX,initialWidth:this.width},document.body.classList.add("resizing","col"),document.addEventListener("mousemove",this.handleResize,!0),document.addEventListener("mouseup",this.handleResizeEnd,!0)}),this.handleResize=(e=>{this.width=this.resizeInfo.initialWidth+(e.pageX-this.resizeInfo.startPageX),this.updateNodeWidth()}),this.handleResizeEnd=(()=>{document.body.classList.remove("resizing","col"),document.removeEventListener("mousemove",this.handleResize,!0),document.removeEventListener("mouseup",this.handleResizeEnd,!0),this.props.onResize()}),this.saveNode=(e=>this.node=e)}componentDidMount(){this.hideTimeoutId=setTimeout(()=>this.toggleVisibility(!1),3e3)}componentWillUnmount(){clearTimeout(this.hideTimeoutId),clearTimeout(this.hideContentTimeout)}render(){const{position:e,pinned:t,children:n}=this.props,{visible:r,renderContent:i}=this.state,o=Zn()({[lr.a.container]:!0,[lr.a.pinned]:t,[lr.a.left]:"left"===e,[lr.a.hidden]:!r,[lr.a.empty]:!i});return s("div",{ref:this.saveNode,className:o,onClick:this.handleClick,onMouseLeave:this.handleMouseLeave},r&&s(rr,{type:"button",title:"Pin",className:lr.a.pinButton,active:t,toggle:!0,onClick:this.handlePinButtonClick},s(dr,{name:"pin",size:13})),s(rr,{type:"button",title:r?"Hide":"Show sidebar",className:lr.a.toggleButton,onClick:this.handleToggleButtonClick},s(dr,{name:"arrow-right",size:10,rotate:r?180:0})),t&&r&&s("div",{className:lr.a.resizer,onMouseDown:this.handleResizeStart}),s("div",{className:lr.a.content,onMouseEnter:this.handleMouseEnter,onMouseMove:this.handleMouseMove},i?n:null))}toggleVisibility(e){clearTimeout(this.hideContentTimeout);const{visible:t}=this.state,{onToggle:n,pinned:r}=this.props;if(void 0===e)e=!t;else if(e===t)return;this.setState({visible:e}),this.toggling=!0,setTimeout(()=>{this.toggling=!1},pr),r&&this.updateNodeWidth(e?this.width:null),e||r?(this.setState({renderContent:e}),n(e)):e||(this.hideContentTimeout=setTimeout(()=>{this.hideContentTimeout=null,this.setState({renderContent:!1}),n(!1)},pr))}updateNodeWidth(e=this.width){this.node.style.width=e?"".concat(e,"px"):""}}gr.defaultProps={pinned:!1,position:"left"};var br=n(11),vr=n.n(br);class yr extends N{constructor(...e){super(...e),this.handleChange=(()=>{this.props.onChange(!this.props.checked)})}render(){const{checked:e,className:t,children:n}=this.props;return s("label",{className:Zn()(vr.a.label,t)},s("input",{className:vr.a.checkbox,type:"checkbox",checked:e,onChange:this.handleChange}),s("span",{className:vr.a.itemText},n))}}var mr=n(7),xr=n.n(mr);class wr extends N{constructor(...e){super(...e),this.handleChange=(()=>{this.props.onChange(this.props.item)})}render(){return s("div",{className:xr.a.item},s(yr,Hn({},this.props,{onChange:this.handleChange}),this.renderLabel()))}renderLabel(){const{children:e,item:t}=this.props;return e&&e.length?e[0](t):t===Sr.ALL_ITEM?"All":t.label}}const Cr=Symbol("ALL_ITEM");class Sr extends tr{constructor(e){super(e),this.handleToggleAllCheck=(()=>{const e=this.isAllChecked()?[]:this.props.items;this.setState({checkedItems:e}),this.informAboutChange(e)}),this.handleItemCheck=(e=>{let t;t=this.isItemChecked(e)?this.state.checkedItems.filter(t=>t!==e):[...this.state.checkedItems,e],this.setState({checkedItems:t}),this.informAboutChange(t)}),this.state={checkedItems:e.checkedItems||e.items}}componentWillReceiveProps(e){if(e.items!==this.props.items)if(this.isAllChecked())this.setState({checkedItems:e.items}),this.informAboutChange(e.items);else if(this.state.checkedItems.length){const t=e.items.filter(e=>this.state.checkedItems.find(t=>t.label===e.label));this.setState({checkedItems:t}),this.informAboutChange(t)}}render(){const{label:e,items:t,renderLabel:n}=this.props;return s("div",{className:xr.a.container},s("div",{className:xr.a.label},e,":"),s("div",null,s(wr,{item:Cr,checked:this.isAllChecked(),onChange:this.handleToggleAllCheck},n),t.map(e=>s(wr,{key:e.label,item:e,checked:this.isItemChecked(e),onChange:this.handleItemCheck},n))))}isItemChecked(e){return this.state.checkedItems.includes(e)}isAllChecked(){return this.props.items.length===this.state.checkedItems.length}informAboutChange(e){setTimeout(()=>this.props.onChange(e))}}Sr.ALL_ITEM=Cr;var Tr=n(16),Mr=n.n(Tr);function zr(){return!1}function kr({children:e,disabled:t,onClick:n}){return s("li",{className:Zn()({[Mr.a.item]:!0,[Mr.a.disabled]:t}),onClick:t?zr:n},e)}var jr=n(17),Lr=n.n(jr);class _r extends tr{constructor(...e){super(...e),this.handleClickHideChunk=(()=>{const{chunk:e}=this.props;if(e&&e.label){const t=Mn.selectedChunks.filter(t=>t.label!==e.label);Mn.selectedChunks=t}this.hide()}),this.handleClickFilterToChunk=(()=>{const{chunk:e}=this.props;if(e&&e.label){const t=Mn.allChunks.filter(t=>t.label===e.label);Mn.selectedChunks=t}this.hide()}),this.handleClickShowAllChunks=(()=>{Mn.selectedChunks=Mn.allChunks,this.hide()}),this.handleDocumentMousedown=(e=>{!(e.ctrlKey||2===e.button)&&function(e,t){return!(e===t||t.contains(e))}(e.target,this.node)&&(e.preventDefault(),e.stopPropagation(),this.hide())}),this.saveNode=(e=>this.node=e)}componentDidMount(){this.boundingRect=this.node.getBoundingClientRect()}componentDidUpdate(e){this.props.visible&&!e.visible?document.addEventListener("mousedown",this.handleDocumentMousedown,!0):e.visible&&!this.props.visible&&document.removeEventListener("mousedown",this.handleDocumentMousedown,!0)}render(){const{visible:e}=this.props,t=Zn()({[Lr.a.container]:!0,[Lr.a.hidden]:!e}),n=Mn.selectedChunks.length>1;return s("ul",{ref:this.saveNode,className:t,style:this.getStyle()},s(kr,{disabled:!n,onClick:this.handleClickHideChunk},"Hide chunk"),s(kr,{disabled:!n,onClick:this.handleClickFilterToChunk},"Hide all other chunks"),s("hr",null),s(kr,{disabled:Mn.allChunksSelected,onClick:this.handleClickShowAllChunks},"Show all chunks"))}hide(){this.props.onHide&&this.props.onHide()}getStyle(){const{boundingRect:e}=this;if(!e)return;const{coords:t}=this.props,n={left:t.x,top:t.y};return n.left+e.width>window.innerWidth&&(n.left=window.innerWidth-e.width),n.top+e.height>window.innerHeight&&(n.top=t.y-e.height),n}}var Dr=n(1),Or=n.n(Dr),Ar=n(24),Ir=n.n(Ar),Nr=n(6),Pr=n.n(Nr);class Er extends tr{constructor(...e){super(...e),this.handleValueChange=Ir()(e=>{this.informChange(e.target.value)},400),this.handleInputBlur=(()=>{this.handleValueChange.flush()}),this.handleClearClick=(()=>{this.clear(),this.focus()}),this.handleKeyDown=(e=>{let t=!0;switch(e.key){case"Escape":this.clear();break;case"Enter":this.handleValueChange.flush();break;default:t=!1}t&&e.stopPropagation()}),this.saveInputNode=(e=>this.input=e)}componentDidMount(){this.props.autofocus&&this.focus()}componentWillUnmount(){this.handleValueChange.cancel()}render(){const{label:e,query:t}=this.props;return s("div",{className:Pr.a.container},s("div",{className:Pr.a.label},e,":"),s("div",{className:Pr.a.row},s("input",{ref:this.saveInputNode,className:Pr.a.input,type:"text",value:t,placeholder:"Enter regexp",onInput:this.handleValueChange,onBlur:this.handleInputBlur,onKeyDown:this.handleKeyDown}),s(rr,{className:Pr.a.clear,onClick:this.handleClearClick},"x")))}focus(){this.input&&this.input.focus()}clear(){this.handleValueChange.cancel(),this.informChange(""),this.input.value=""}informChange(e){this.props.onQueryChange(e)}}var Gr,Br,Rr=n(25),Fr=n.n(Rr),Ur=n(26),Hr=n.n(Ur),Vr=n(8),Wr=n.n(Vr),qr=n(27),Kr=n.n(qr),Yr=n(12),Zr=n.n(Yr);class $r extends tr{constructor(...e){super(...e),this.state={visible:!0},this.handleClick=(()=>this.props.onClick(this.props.module)),this.handleMouseEnter=(()=>{this.props.isVisible&&this.setState({visible:this.isVisible})})}render({module:e,showSize:t}){const n=!this.state.visible;return s("div",{className:Zn()(Zr.a.container,Zr.a[this.itemType],{[Zr.a.invisible]:n}),title:n?this.invisibleHint:null,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave},s("span",{dangerouslySetInnerHTML:{__html:this.titleHtml}}),t&&[" (",s("strong",null,kn()(e[t])),")"])}get itemType(){const{module:e}=this.props;return e.path?e.groups?"folder":"module":"chunk"}get titleHtml(){let e;const{module:t}=this.props,n=t.path||t.label,r=this.props.highlightedText;if(r){const t=r instanceof RegExp?new RegExp(r.source,"igu"):new RegExp("(?:".concat(Kr()(r),")+"),"iu");let i,o;do{o=i,i=t.exec(n)}while(i);o&&(e=Wr()(n.slice(0,o.index))+"<strong>".concat(Wr()(o[0]),"</strong>")+Wr()(n.slice(o.index+o[0].length)))}return e||(e=Wr()(n)),e}get invisibleHint(){return"".concat(Hr()(this.itemType)," is not rendered in the treemap because it's too small.")}get isVisible(){const{isVisible:e}=this.props;return!e||e(this.props.module)}}class Jr extends tr{constructor(...e){super(...e),this.handleModuleClick=(e=>this.props.onModuleClick(e))}render({modules:e,showSize:t,highlightedText:n,isModuleVisible:r,className:i}){return s("div",{className:Zn()(Fr.a.container,i)},e.map(e=>s($r,{key:e.cid,module:e,showSize:t,highlightedText:n,isVisible:r,onClick:this.handleModuleClick})))}}const Qr=[{label:"Stat",prop:"statSize"},{label:"Parsed",prop:"parsedSize"},{label:"Gzipped",prop:"gzipSize"}];let Xr=Rn((G((Br=class extends N{constructor(...e){super(...e),this.mouseCoords={x:0,y:0},this.state={selectedChunk:null,selectedMouseCoords:{x:0,y:0},sidebarPinned:!1,showChunkContextMenu:!1,showTooltip:!1,tooltipContent:null},this.renderChunkItemLabel=(e=>{const t=e===Sr.ALL_ITEM,n=t?"All":e.label,r=t?Mn.totalChunksSize:e[Mn.activeSize];return["".concat(n," ("),s("strong",null,kn()(r)),")"]}),this.handleConcatenatedModulesContentToggle=(e=>{Mn.showConcatenatedModulesContent=e}),this.handleChunkContextMenuHide=(()=>{this.setState({showChunkContextMenu:!1})}),this.handleResize=(()=>{this.state.showChunkContextMenu&&this.setState({showChunkContextMenu:!1})}),this.handleSidebarToggle=(()=>{this.state.sidebarPinned&&setTimeout(()=>this.treemap.resize())}),this.handleSidebarPinStateChange=(e=>{this.setState({sidebarPinned:e}),setTimeout(()=>this.treemap.resize())}),this.handleSidebarResize=(()=>{this.treemap.resize()}),this.handleSizeSwitch=(e=>{Mn.selectedSize=e.prop}),this.handleQueryChange=(e=>{Mn.searchQuery=e}),this.handleSelectedChunksChange=(e=>{Mn.selectedChunks=e}),this.handleMouseLeaveTreemap=(()=>{this.setState({showTooltip:!1})}),this.handleTreemapGroupSecondaryClick=(e=>{const{group:t}=e;t&&t.isAsset?this.setState({selectedChunk:t,selectedMouseCoords:{...this.mouseCoords},showChunkContextMenu:!0}):this.setState({selectedChunk:null,showChunkContextMenu:!1})}),this.handleTreemapGroupHover=(e=>{const{group:t}=e;t?this.setState({showTooltip:!0,tooltipContent:this.getTooltipContent(t)}):this.setState({showTooltip:!1})}),this.handleFoundModuleClick=(e=>this.treemap.zoomToGroup(e)),this.handleMouseMove=(e=>{Object.assign(this.mouseCoords,{x:e.pageX,y:e.pageY})}),this.isModuleVisible=(e=>this.treemap.isGroupRendered(e)),this.saveTreemapRef=(e=>this.treemap=e)}componentDidMount(){document.addEventListener("mousemove",this.handleMouseMove,!0)}componentWillUnmount(){document.removeEventListener("mousemove",this.handleMouseMove,!0)}render(){const{selectedChunk:e,selectedMouseCoords:t,sidebarPinned:n,showChunkContextMenu:r,showTooltip:i,tooltipContent:o}=this.state;return s("div",{className:Or.a.container},s(gr,{pinned:n,onToggle:this.handleSidebarToggle,onPinStateChange:this.handleSidebarPinStateChange,onResize:this.handleSidebarResize},s("div",{className:Or.a.sidebarGroup},s(sr,{label:"Treemap sizes",items:this.sizeSwitchItems,activeItem:this.activeSizeItem,onSwitch:this.handleSizeSwitch}),Mn.hasConcatenatedModules&&s("div",{className:Or.a.showOption},s(yr,{checked:Mn.showConcatenatedModulesContent,onChange:this.handleConcatenatedModulesContentToggle},"Show content of concatenated modules".concat("statSize"===Mn.activeSize?"":" (inaccurate)")))),s("div",{className:Or.a.sidebarGroup},s(Er,{label:"Search modules",query:Mn.searchQuery,autofocus:!0,onQueryChange:this.handleQueryChange}),s("div",{className:Or.a.foundModulesInfo},this.foundModulesInfo),Mn.isSearching&&Mn.hasFoundModules&&s("div",{className:Or.a.foundModulesContainer},Mn.foundModulesByChunk.map(({chunk:e,modules:t})=>s("div",{key:e.cid,className:Or.a.foundModulesChunk},s("div",{className:Or.a.foundModulesChunkName,onClick:()=>this.treemap.zoomToGroup(e)},e.label),s(Jr,{className:Or.a.foundModulesList,modules:t,showSize:Mn.activeSize,highlightedText:Mn.searchQueryRegexp,isModuleVisible:this.isModuleVisible,onModuleClick:this.handleFoundModuleClick}))))),this.chunkItems.length>1&&s("div",{className:Or.a.sidebarGroup},s(Sr,{label:"Show chunks",items:this.chunkItems,checkedItems:Mn.selectedChunks,renderLabel:this.renderChunkItemLabel,onChange:this.handleSelectedChunksChange}))),s(qn,{ref:this.saveTreemapRef,className:Or.a.map,data:Mn.visibleChunks,highlightGroups:this.highlightedModules,weightProp:Mn.activeSize,onMouseLeave:this.handleMouseLeaveTreemap,onGroupHover:this.handleTreemapGroupHover,onGroupSecondaryClick:this.handleTreemapGroupSecondaryClick,onResize:this.handleResize}),s(Qn,{visible:i},o),s(_r,{visible:r,chunk:e,coords:t,onHide:this.handleChunkContextMenuHide}))}renderModuleSize(e,t){const n="".concat(t,"Size"),r=e[n],i=Qr.find(e=>e.prop===n).label,o=Mn.activeSize===n;return"number"==typeof r?s("div",{className:o?Or.a.activeSize:""},i," size: ",s("strong",null,kn()(r))):null}get sizeSwitchItems(){return Mn.hasParsedSizes?Qr:Qr.slice(0,1)}get activeSizeItem(){return this.sizeSwitchItems.find(e=>e.prop===Mn.activeSize)}get chunkItems(){const{allChunks:e,activeSize:t}=Mn;let n=[...e];return"statSize"!==t&&(n=n.filter(pn)),n.sort((e,n)=>n[t]-e[t]),n}get highlightedModules(){return new Set(Mn.foundModules)}get foundModulesInfo(){return Mn.isSearching?Mn.hasFoundModules?[s("div",{className:Or.a.foundModulesInfoItem},"Count: ",s("strong",null,Mn.foundModules.length)),s("div",{className:Or.a.foundModulesInfoItem},"Total size: ",s("strong",null,kn()(Mn.foundModulesSize)))]:"Nothing found"+(Mn.allChunksSelected?"":" in selected chunks"):" "}getTooltipContent(e){return e?s("div",null,s("div",null,s("strong",null,e.label)),s("br",null),this.renderModuleSize(e,"stat"),!e.inaccurateSizes&&this.renderModuleSize(e,"parsed"),!e.inaccurateSizes&&this.renderModuleSize(e,"gzip"),e.path&&s("div",null,"Path: ",s("strong",null,e.path)),e.isAsset&&s("div",null,s("br",null),s("strong",null,s("em",null,"Right-click to view options related to this chunk")))):null}}).prototype,"sizeSwitchItems",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"sizeSwitchItems"),Br.prototype),G(Br.prototype,"activeSizeItem",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"activeSizeItem"),Br.prototype),G(Br.prototype,"chunkItems",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"chunkItems"),Br.prototype),G(Br.prototype,"highlightedModules",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"highlightedModules"),Br.prototype),G(Br.prototype,"foundModulesInfo",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"foundModulesInfo"),Br.prototype),Gr=Br))||Gr;n(67);let ei;try{window.enableWebSocket&&(ei=new WebSocket("ws://".concat(location.host)))}catch(ti){console.warn("Couldn't connect to analyzer websocket server so you'll have to reload page manually to see updates in the treemap")}window.addEventListener("load",()=>{Mn.defaultSize="".concat(window.defaultSizes,"Size"),Mn.setModules(window.chartData),P(s(Xr,null),document.getElementById("app")),ei&&ei.addEventListener("message",e=>{const t=JSON.parse(e.data);"chartDataUpdated"===t.event&&Mn.setModules(t.data)})},!1)}]);
39
+ */var n,r,i,o,a,s,u,l;e.exports=(n={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},r={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i=Object.defineProperty,o=Object.getOwnPropertyNames,a=Object.getOwnPropertySymbols,s=Object.getOwnPropertyDescriptor,u=Object.getPrototypeOf,l=u&&u(Object),function e(t,c,h){if("string"!=typeof c){if(l){var f=u(c);f&&f!==l&&e(t,f,h)}var d=o(c);a&&(d=d.concat(a(c)));for(var p=0;p<d.length;++p){var g=d[p];if(!(n[g]||r[g]||h&&h[g])){var b=s(c,g);try{i(t,g,b)}catch(v){}}}return t}return t})});var Fn={children:!0,key:!0,ref:!0},Un=console;!function(e){function t(){return _n(this,t),An(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}On(t,N),Dn(t,[{key:"render",value:function(e){var t=e.children;return t.length>1?s("div",null," ",t," "):t[0]}},{key:"getChildContext",value:function(){var e={},t=this.context.mobxStores;if(t)for(var n in t)e[n]=t[n];for(var r in this.props)Fn[r]||"suppressChangedStoreWarning"===r||(e[r]=this.props[r]);return{mobxStores:e}}},{key:"componentWillReceiveProps",value:function(e){if(Object.keys(e).length!==Object.keys(this.props).length&&Un.warn("MobX Provider: The set of provided stores has changed. Please avoid changing stores as the change might not propagate to all children"),!e.suppressChangedStoreWarning)for(var t in e)Fn[t]||this.props[t]===e[t]||Un.warn("MobX Provider: Provided store '"+t+"' has changed. Please avoid replacing stores as the change might not propagate to all children")}}])}();if(!N)throw new Error("mobx-preact requires Preact to be available");function Hn(){return(Hn=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var Vn=n(22),Wn=n.n(Vn);class qn extends N{constructor(e){super(e),this.saveNodeRef=(e=>this.node=e),this.resize=(()=>{const{props:e}=this;this.treemap.resize(),e.onResize&&e.onResize()}),this.treemap=null,this.zoomOutDisabled=!1}componentDidMount(){this.treemap=this.createTreemap(),window.addEventListener("resize",this.resize)}componentWillReceiveProps(e){if(e.data!==this.props.data)this.treemap.set({dataObject:this.getTreemapDataObject(e.data)});else if(e.highlightGroups!==this.props.highlightGroups){const t=[...e.highlightGroups,...this.props.highlightGroups];setTimeout(()=>this.treemap.redraw(!1,t))}}shouldComponentUpdate(){return!1}componentWillUnmount(){window.removeEventListener("resize",this.resize),this.treemap.dispose()}render(){return s("div",Hn({},this.props,{ref:this.saveNodeRef}))}getTreemapDataObject(e=this.props.data){return{groups:e}}createTreemap(){const e=this,{props:t}=this;return new Wn.a({element:this.node,layout:"squarified",stacking:"flattened",pixelRatio:window.devicePixelRatio||1,maxGroups:1/0,maxGroupLevelsDrawn:1/0,maxGroupLabelLevelsDrawn:1/0,maxGroupLevelsAttached:1/0,groupMinDiameter:0,groupLabelVerticalPadding:.2,rolloutDuration:0,pullbackDuration:0,fadeDuration:0,groupExposureZoomMargin:.2,zoomMouseWheelDuration:300,openCloseDuration:200,dataObject:this.getTreemapDataObject(),titleBarDecorator(e,t,n){n.titleBarShown=!1},groupColorDecorator(t,n,r){const{highlightGroups:i}=e.props,o=n.group;i&&i.has(o)&&(r.groupColor={model:"rgba",r:255,g:0,b:0,a:.8})},onGroupClick(n){Kn(n),(n.ctrlKey||n.secondary)&&t.onGroupSecondaryClick?t.onGroupSecondaryClick.call(e,n):(e.zoomOutDisabled=!1,this.zoom(n.group))},onGroupDoubleClick:Kn,onGroupHover(n){n.group&&n.group.attribution?n.preventDefault():t.onGroupHover&&t.onGroupHover.call(e,n)},onGroupMouseWheel(t){const{scale:n}=this.get("viewport");if(t.delta<0){if(e.zoomOutDisabled)return Kn(t);n<1&&(e.zoomOutDisabled=!0,Kn(t))}else e.zoomOutDisabled=!1}})}zoomToGroup(e){for(this.zoomOutDisabled=!1;e&&!this.treemap.get("state",e).revealed;)e=this.treemap.get("hierarchy",e).parent;e&&this.treemap.zoom(e)}isGroupRendered(e){const t=this.treemap.get("state",e);return!!t&&t.revealed}update(){this.treemap.update()}}function Kn(e){e.preventDefault()}var Yn=n(0),Zn=n.n(Yn),$n=n(15),Jn=n.n($n);class Qn extends N{constructor(...e){super(...e),this.mouseCoords={x:0,y:0},this.state={left:0,top:0},this.handleMouseMove=(e=>{Object.assign(this.mouseCoords,{x:e.pageX,y:e.pageY}),this.props.visible&&this.updatePosition()}),this.saveNode=(e=>this.node=e)}componentDidMount(){document.addEventListener("mousemove",this.handleMouseMove,!0)}shouldComponentUpdate(e){return this.props.visible||e.visible}componentWillUnmount(){document.removeEventListener("mousemove",this.handleMouseMove,!0)}render(){const{children:e,visible:t}=this.props,n=Zn()({[Jn.a.container]:!0,[Jn.a.hidden]:!t});return s("div",{ref:this.saveNode,className:n,style:this.getStyle()},e)}getStyle(){return{left:this.state.left,top:this.state.top}}updatePosition(){if(!this.props.visible)return;const e={left:this.mouseCoords.x+Qn.marginX,top:this.mouseCoords.y+Qn.marginY},t=this.node.getBoundingClientRect();e.left+t.width>window.innerWidth&&(e.left=window.innerWidth-t.width),e.top+t.height>window.innerHeight&&(e.top=this.mouseCoords.y-Qn.marginY-t.height),this.setState(e)}}Qn.marginX=10,Qn.marginY=30;var Xn=n(9),er=n.n(Xn);class tr extends N{shouldComponentUpdate(e,t){return!nr(e,this.props)||!nr(this.state,t)}}function nr(e,t){if(e===t)return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++){const i=n[r];if(e[i]!==t[i])return!1}return!0}class rr extends tr{constructor(...e){super(...e),this.handleClick=(e=>{this.elem.blur(),this.props.onClick(e)}),this.saveRef=(e=>this.elem=e)}render({active:e,toggle:t,className:n,children:r,...i}){const o=Zn()(n,{[er.a.button]:!0,[er.a.active]:e,[er.a.toggle]:t});return s("button",Hn({},i,{ref:this.saveRef,type:"button",className:o,disabled:this.disabled,onClick:this.handleClick}),r)}get disabled(){const{props:e}=this;return e.disabled||e.active&&!e.toggle}}class ir extends tr{constructor(...e){super(...e),this.handleClick=(()=>{this.props.onClick(this.props.item)})}render({item:e,...t}){return s(rr,Hn({},t,{onClick:this.handleClick}),e.label)}}var or=n(10),ar=n.n(or);class sr extends tr{render(){const{label:e,items:t,activeItem:n,onSwitch:r}=this.props;return s("div",{className:ar.a.container},s("div",{className:ar.a.label},e,":"),s("div",null,t.map(e=>s(ir,{key:e.label,className:ar.a.item,item:e,active:e===n,onClick:r}))))}}var ur=n(4),lr=n.n(ur),cr=n(23),hr=n.n(cr);const fr={"arrow-right":{src:n(34),size:[7,13]},pin:{src:n(35),size:[12,18]}};class dr extends tr{render({className:e}){return s("i",{className:Zn()(hr.a.icon,e),style:this.style})}get style(){const{name:e,size:t,rotate:n}=this.props,r=fr[e];if(!r)throw new TypeError("Can't find \"".concat(e,'" icon.'));let[i,o]=r.size;if(t){const e=t/Math.max(i,o);i=Math.min(Math.ceil(i*e),t),o=Math.min(Math.ceil(o*e),t)}return{backgroundImage:"url(".concat(r.src,")"),width:"".concat(i,"px"),height:"".concat(o,"px"),transform:n?"rotate(".concat(n,"deg)"):""}}}const pr=parseInt(lr.a.toggleTime);class gr extends N{constructor(...e){super(...e),this.allowHide=!0,this.toggling=!1,this.hideContentTimeout=null,this.width=null,this.state={visible:!0,renderContent:!0},this.handleClick=(()=>{this.allowHide=!1}),this.handleMouseEnter=(()=>{this.toggling||this.props.pinned||(clearTimeout(this.hideTimeoutId),this.toggleVisibility(!0))}),this.handleMouseMove=(()=>{this.allowHide=!0}),this.handleMouseLeave=(()=>{!this.allowHide||this.toggling||this.props.pinned||this.toggleVisibility(!1)}),this.handleToggleButtonClick=(()=>{this.toggleVisibility()}),this.handlePinButtonClick=(()=>{const e=!this.props.pinned;this.width=e?this.node.getBoundingClientRect().width:null,this.updateNodeWidth(),this.props.onPinStateChange(e)}),this.handleResizeStart=(e=>{this.resizeInfo={startPageX:e.pageX,initialWidth:this.width},document.body.classList.add("resizing","col"),document.addEventListener("mousemove",this.handleResize,!0),document.addEventListener("mouseup",this.handleResizeEnd,!0)}),this.handleResize=(e=>{this.width=this.resizeInfo.initialWidth+(e.pageX-this.resizeInfo.startPageX),this.updateNodeWidth()}),this.handleResizeEnd=(()=>{document.body.classList.remove("resizing","col"),document.removeEventListener("mousemove",this.handleResize,!0),document.removeEventListener("mouseup",this.handleResizeEnd,!0),this.props.onResize()}),this.saveNode=(e=>this.node=e)}componentDidMount(){this.hideTimeoutId=setTimeout(()=>this.toggleVisibility(!1),3e3)}componentWillUnmount(){clearTimeout(this.hideTimeoutId),clearTimeout(this.hideContentTimeout)}render(){const{position:e,pinned:t,children:n}=this.props,{visible:r,renderContent:i}=this.state,o=Zn()({[lr.a.container]:!0,[lr.a.pinned]:t,[lr.a.left]:"left"===e,[lr.a.hidden]:!r,[lr.a.empty]:!i});return s("div",{ref:this.saveNode,className:o,onClick:this.handleClick,onMouseLeave:this.handleMouseLeave},r&&s(rr,{type:"button",title:"Pin",className:lr.a.pinButton,active:t,toggle:!0,onClick:this.handlePinButtonClick},s(dr,{name:"pin",size:13})),s(rr,{type:"button",title:r?"Hide":"Show sidebar",className:lr.a.toggleButton,onClick:this.handleToggleButtonClick},s(dr,{name:"arrow-right",size:10,rotate:r?180:0})),t&&r&&s("div",{className:lr.a.resizer,onMouseDown:this.handleResizeStart}),s("div",{className:lr.a.content,onMouseEnter:this.handleMouseEnter,onMouseMove:this.handleMouseMove},i?n:null))}toggleVisibility(e){clearTimeout(this.hideContentTimeout);const{visible:t}=this.state,{onToggle:n,pinned:r}=this.props;if(void 0===e)e=!t;else if(e===t)return;this.setState({visible:e}),this.toggling=!0,setTimeout(()=>{this.toggling=!1},pr),r&&this.updateNodeWidth(e?this.width:null),e||r?(this.setState({renderContent:e}),n(e)):e||(this.hideContentTimeout=setTimeout(()=>{this.hideContentTimeout=null,this.setState({renderContent:!1}),n(!1)},pr))}updateNodeWidth(e=this.width){this.node.style.width=e?"".concat(e,"px"):""}}gr.defaultProps={pinned:!1,position:"left"};var br=n(11),vr=n.n(br);class yr extends N{constructor(...e){super(...e),this.handleChange=(()=>{this.props.onChange(!this.props.checked)})}render(){const{checked:e,className:t,children:n}=this.props;return s("label",{className:Zn()(vr.a.label,t)},s("input",{className:vr.a.checkbox,type:"checkbox",checked:e,onChange:this.handleChange}),s("span",{className:vr.a.itemText},n))}}var mr=n(7),xr=n.n(mr);class wr extends N{constructor(...e){super(...e),this.handleChange=(()=>{this.props.onChange(this.props.item)})}render(){return s("div",{className:xr.a.item},s(yr,Hn({},this.props,{onChange:this.handleChange}),this.renderLabel()))}renderLabel(){const{children:e,item:t}=this.props;return e&&e.length?e[0](t):t===Sr.ALL_ITEM?"All":t.label}}const Cr=Symbol("ALL_ITEM");class Sr extends tr{constructor(e){super(e),this.handleToggleAllCheck=(()=>{const e=this.isAllChecked()?[]:this.props.items;this.setState({checkedItems:e}),this.informAboutChange(e)}),this.handleItemCheck=(e=>{let t;t=this.isItemChecked(e)?this.state.checkedItems.filter(t=>t!==e):[...this.state.checkedItems,e],this.setState({checkedItems:t}),this.informAboutChange(t)}),this.state={checkedItems:e.checkedItems||e.items}}componentWillReceiveProps(e){if(e.items!==this.props.items){if(this.isAllChecked())this.setState({checkedItems:e.items}),this.informAboutChange(e.items);else if(this.state.checkedItems.length){const t=e.items.filter(e=>this.state.checkedItems.find(t=>t.label===e.label));this.setState({checkedItems:t}),this.informAboutChange(t)}}else e.checkedItems!==this.props.checkedItems&&this.setState({checkedItems:e.checkedItems})}render(){const{label:e,items:t,renderLabel:n}=this.props;return s("div",{className:xr.a.container},s("div",{className:xr.a.label},e,":"),s("div",null,s(wr,{item:Cr,checked:this.isAllChecked(),onChange:this.handleToggleAllCheck},n),t.map(e=>s(wr,{key:e.label,item:e,checked:this.isItemChecked(e),onChange:this.handleItemCheck},n))))}isItemChecked(e){return this.state.checkedItems.includes(e)}isAllChecked(){return this.props.items.length===this.state.checkedItems.length}informAboutChange(e){setTimeout(()=>this.props.onChange(e))}}Sr.ALL_ITEM=Cr;var Tr=n(16),Mr=n.n(Tr);function zr(){return!1}function kr({children:e,disabled:t,onClick:n}){return s("li",{className:Zn()({[Mr.a.item]:!0,[Mr.a.disabled]:t}),onClick:t?zr:n},e)}var jr=n(17),Lr=n.n(jr);class _r extends tr{constructor(...e){super(...e),this.handleClickHideChunk=(()=>{const{chunk:e}=this.props;if(e&&e.label){const t=Mn.selectedChunks.filter(t=>t.label!==e.label);Mn.selectedChunks=t}this.hide()}),this.handleClickFilterToChunk=(()=>{const{chunk:e}=this.props;if(e&&e.label){const t=Mn.allChunks.filter(t=>t.label===e.label);Mn.selectedChunks=t}this.hide()}),this.handleClickShowAllChunks=(()=>{Mn.selectedChunks=Mn.allChunks,this.hide()}),this.handleDocumentMousedown=(e=>{!(e.ctrlKey||2===e.button)&&function(e,t){return!(e===t||t.contains(e))}(e.target,this.node)&&(e.preventDefault(),e.stopPropagation(),this.hide())}),this.saveNode=(e=>this.node=e)}componentDidMount(){this.boundingRect=this.node.getBoundingClientRect()}componentDidUpdate(e){this.props.visible&&!e.visible?document.addEventListener("mousedown",this.handleDocumentMousedown,!0):e.visible&&!this.props.visible&&document.removeEventListener("mousedown",this.handleDocumentMousedown,!0)}render(){const{visible:e}=this.props,t=Zn()({[Lr.a.container]:!0,[Lr.a.hidden]:!e}),n=Mn.selectedChunks.length>1;return s("ul",{ref:this.saveNode,className:t,style:this.getStyle()},s(kr,{disabled:!n,onClick:this.handleClickHideChunk},"Hide chunk"),s(kr,{disabled:!n,onClick:this.handleClickFilterToChunk},"Hide all other chunks"),s("hr",null),s(kr,{disabled:Mn.allChunksSelected,onClick:this.handleClickShowAllChunks},"Show all chunks"))}hide(){this.props.onHide&&this.props.onHide()}getStyle(){const{boundingRect:e}=this;if(!e)return;const{coords:t}=this.props,n={left:t.x,top:t.y};return n.left+e.width>window.innerWidth&&(n.left=window.innerWidth-e.width),n.top+e.height>window.innerHeight&&(n.top=t.y-e.height),n}}var Dr=n(1),Or=n.n(Dr),Ar=n(24),Ir=n.n(Ar),Nr=n(6),Pr=n.n(Nr);class Er extends tr{constructor(...e){super(...e),this.handleValueChange=Ir()(e=>{this.informChange(e.target.value)},400),this.handleInputBlur=(()=>{this.handleValueChange.flush()}),this.handleClearClick=(()=>{this.clear(),this.focus()}),this.handleKeyDown=(e=>{let t=!0;switch(e.key){case"Escape":this.clear();break;case"Enter":this.handleValueChange.flush();break;default:t=!1}t&&e.stopPropagation()}),this.saveInputNode=(e=>this.input=e)}componentDidMount(){this.props.autofocus&&this.focus()}componentWillUnmount(){this.handleValueChange.cancel()}render(){const{label:e,query:t}=this.props;return s("div",{className:Pr.a.container},s("div",{className:Pr.a.label},e,":"),s("div",{className:Pr.a.row},s("input",{ref:this.saveInputNode,className:Pr.a.input,type:"text",value:t,placeholder:"Enter regexp",onInput:this.handleValueChange,onBlur:this.handleInputBlur,onKeyDown:this.handleKeyDown}),s(rr,{className:Pr.a.clear,onClick:this.handleClearClick},"x")))}focus(){this.input&&this.input.focus()}clear(){this.handleValueChange.cancel(),this.informChange(""),this.input.value=""}informChange(e){this.props.onQueryChange(e)}}var Gr,Br,Rr=n(25),Fr=n.n(Rr),Ur=n(26),Hr=n.n(Ur),Vr=n(8),Wr=n.n(Vr),qr=n(27),Kr=n.n(qr),Yr=n(12),Zr=n.n(Yr);class $r extends tr{constructor(...e){super(...e),this.state={visible:!0},this.handleClick=(()=>this.props.onClick(this.props.module)),this.handleMouseEnter=(()=>{this.props.isVisible&&this.setState({visible:this.isVisible})})}render({module:e,showSize:t}){const n=!this.state.visible;return s("div",{className:Zn()(Zr.a.container,Zr.a[this.itemType],{[Zr.a.invisible]:n}),title:n?this.invisibleHint:null,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave},s("span",{dangerouslySetInnerHTML:{__html:this.titleHtml}}),t&&[" (",s("strong",null,kn()(e[t])),")"])}get itemType(){const{module:e}=this.props;return e.path?e.groups?"folder":"module":"chunk"}get titleHtml(){let e;const{module:t}=this.props,n=t.path||t.label,r=this.props.highlightedText;if(r){const t=r instanceof RegExp?new RegExp(r.source,"igu"):new RegExp("(?:".concat(Kr()(r),")+"),"iu");let i,o;do{o=i,i=t.exec(n)}while(i);o&&(e=Wr()(n.slice(0,o.index))+"<strong>".concat(Wr()(o[0]),"</strong>")+Wr()(n.slice(o.index+o[0].length)))}return e||(e=Wr()(n)),e}get invisibleHint(){return"".concat(Hr()(this.itemType)," is not rendered in the treemap because it's too small.")}get isVisible(){const{isVisible:e}=this.props;return!e||e(this.props.module)}}class Jr extends tr{constructor(...e){super(...e),this.handleModuleClick=(e=>this.props.onModuleClick(e))}render({modules:e,showSize:t,highlightedText:n,isModuleVisible:r,className:i}){return s("div",{className:Zn()(Fr.a.container,i)},e.map(e=>s($r,{key:e.cid,module:e,showSize:t,highlightedText:n,isVisible:r,onClick:this.handleModuleClick})))}}const Qr=[{label:"Stat",prop:"statSize"},{label:"Parsed",prop:"parsedSize"},{label:"Gzipped",prop:"gzipSize"}];let Xr=Rn((G((Br=class extends N{constructor(...e){super(...e),this.mouseCoords={x:0,y:0},this.state={selectedChunk:null,selectedMouseCoords:{x:0,y:0},sidebarPinned:!1,showChunkContextMenu:!1,showTooltip:!1,tooltipContent:null},this.renderChunkItemLabel=(e=>{const t=e===Sr.ALL_ITEM,n=t?"All":e.label,r=t?Mn.totalChunksSize:e[Mn.activeSize];return["".concat(n," ("),s("strong",null,kn()(r)),")"]}),this.handleConcatenatedModulesContentToggle=(e=>{Mn.showConcatenatedModulesContent=e}),this.handleChunkContextMenuHide=(()=>{this.setState({showChunkContextMenu:!1})}),this.handleResize=(()=>{this.state.showChunkContextMenu&&this.setState({showChunkContextMenu:!1})}),this.handleSidebarToggle=(()=>{this.state.sidebarPinned&&setTimeout(()=>this.treemap.resize())}),this.handleSidebarPinStateChange=(e=>{this.setState({sidebarPinned:e}),setTimeout(()=>this.treemap.resize())}),this.handleSidebarResize=(()=>{this.treemap.resize()}),this.handleSizeSwitch=(e=>{Mn.selectedSize=e.prop}),this.handleQueryChange=(e=>{Mn.searchQuery=e}),this.handleSelectedChunksChange=(e=>{Mn.selectedChunks=e}),this.handleMouseLeaveTreemap=(()=>{this.setState({showTooltip:!1})}),this.handleTreemapGroupSecondaryClick=(e=>{const{group:t}=e;t&&t.isAsset?this.setState({selectedChunk:t,selectedMouseCoords:{...this.mouseCoords},showChunkContextMenu:!0}):this.setState({selectedChunk:null,showChunkContextMenu:!1})}),this.handleTreemapGroupHover=(e=>{const{group:t}=e;t?this.setState({showTooltip:!0,tooltipContent:this.getTooltipContent(t)}):this.setState({showTooltip:!1})}),this.handleFoundModuleClick=(e=>this.treemap.zoomToGroup(e)),this.handleMouseMove=(e=>{Object.assign(this.mouseCoords,{x:e.pageX,y:e.pageY})}),this.isModuleVisible=(e=>this.treemap.isGroupRendered(e)),this.saveTreemapRef=(e=>this.treemap=e)}componentDidMount(){document.addEventListener("mousemove",this.handleMouseMove,!0)}componentWillUnmount(){document.removeEventListener("mousemove",this.handleMouseMove,!0)}render(){const{selectedChunk:e,selectedMouseCoords:t,sidebarPinned:n,showChunkContextMenu:r,showTooltip:i,tooltipContent:o}=this.state;return s("div",{className:Or.a.container},s(gr,{pinned:n,onToggle:this.handleSidebarToggle,onPinStateChange:this.handleSidebarPinStateChange,onResize:this.handleSidebarResize},s("div",{className:Or.a.sidebarGroup},s(sr,{label:"Treemap sizes",items:this.sizeSwitchItems,activeItem:this.activeSizeItem,onSwitch:this.handleSizeSwitch}),Mn.hasConcatenatedModules&&s("div",{className:Or.a.showOption},s(yr,{checked:Mn.showConcatenatedModulesContent,onChange:this.handleConcatenatedModulesContentToggle},"Show content of concatenated modules".concat("statSize"===Mn.activeSize?"":" (inaccurate)")))),s("div",{className:Or.a.sidebarGroup},s(Er,{label:"Search modules",query:Mn.searchQuery,autofocus:!0,onQueryChange:this.handleQueryChange}),s("div",{className:Or.a.foundModulesInfo},this.foundModulesInfo),Mn.isSearching&&Mn.hasFoundModules&&s("div",{className:Or.a.foundModulesContainer},Mn.foundModulesByChunk.map(({chunk:e,modules:t})=>s("div",{key:e.cid,className:Or.a.foundModulesChunk},s("div",{className:Or.a.foundModulesChunkName,onClick:()=>this.treemap.zoomToGroup(e)},e.label),s(Jr,{className:Or.a.foundModulesList,modules:t,showSize:Mn.activeSize,highlightedText:Mn.searchQueryRegexp,isModuleVisible:this.isModuleVisible,onModuleClick:this.handleFoundModuleClick}))))),this.chunkItems.length>1&&s("div",{className:Or.a.sidebarGroup},s(Sr,{label:"Show chunks",items:this.chunkItems,checkedItems:Mn.selectedChunks,renderLabel:this.renderChunkItemLabel,onChange:this.handleSelectedChunksChange}))),s(qn,{ref:this.saveTreemapRef,className:Or.a.map,data:Mn.visibleChunks,highlightGroups:this.highlightedModules,weightProp:Mn.activeSize,onMouseLeave:this.handleMouseLeaveTreemap,onGroupHover:this.handleTreemapGroupHover,onGroupSecondaryClick:this.handleTreemapGroupSecondaryClick,onResize:this.handleResize}),s(Qn,{visible:i},o),s(_r,{visible:r,chunk:e,coords:t,onHide:this.handleChunkContextMenuHide}))}renderModuleSize(e,t){const n="".concat(t,"Size"),r=e[n],i=Qr.find(e=>e.prop===n).label,o=Mn.activeSize===n;return"number"==typeof r?s("div",{className:o?Or.a.activeSize:""},i," size: ",s("strong",null,kn()(r))):null}get sizeSwitchItems(){return Mn.hasParsedSizes?Qr:Qr.slice(0,1)}get activeSizeItem(){return this.sizeSwitchItems.find(e=>e.prop===Mn.activeSize)}get chunkItems(){const{allChunks:e,activeSize:t}=Mn;let n=[...e];return"statSize"!==t&&(n=n.filter(pn)),n.sort((e,n)=>n[t]-e[t]),n}get highlightedModules(){return new Set(Mn.foundModules)}get foundModulesInfo(){return Mn.isSearching?Mn.hasFoundModules?[s("div",{className:Or.a.foundModulesInfoItem},"Count: ",s("strong",null,Mn.foundModules.length)),s("div",{className:Or.a.foundModulesInfoItem},"Total size: ",s("strong",null,kn()(Mn.foundModulesSize)))]:"Nothing found"+(Mn.allChunksSelected?"":" in selected chunks"):" "}getTooltipContent(e){return e?s("div",null,s("div",null,s("strong",null,e.label)),s("br",null),this.renderModuleSize(e,"stat"),!e.inaccurateSizes&&this.renderModuleSize(e,"parsed"),!e.inaccurateSizes&&this.renderModuleSize(e,"gzip"),e.path&&s("div",null,"Path: ",s("strong",null,e.path)),e.isAsset&&s("div",null,s("br",null),s("strong",null,s("em",null,"Right-click to view options related to this chunk")))):null}}).prototype,"sizeSwitchItems",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"sizeSwitchItems"),Br.prototype),G(Br.prototype,"activeSizeItem",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"activeSizeItem"),Br.prototype),G(Br.prototype,"chunkItems",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"chunkItems"),Br.prototype),G(Br.prototype,"highlightedModules",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"highlightedModules"),Br.prototype),G(Br.prototype,"foundModulesInfo",[ze],Object.getOwnPropertyDescriptor(Br.prototype,"foundModulesInfo"),Br.prototype),Gr=Br))||Gr;n(67);let ei;try{window.enableWebSocket&&(ei=new WebSocket("ws://".concat(location.host)))}catch(ti){console.warn("Couldn't connect to analyzer websocket server so you'll have to reload page manually to see updates in the treemap")}window.addEventListener("load",()=>{Mn.defaultSize="".concat(window.defaultSizes,"Size"),Mn.setModules(window.chartData),P(s(Xr,null),document.getElementById("app")),ei&&ei.addEventListener("message",e=>{const t=JSON.parse(e.data);"chartDataUpdated"===t.event&&Mn.setModules(t.data)})},!1)}]);
40
40
  //# sourceMappingURL=viewer.js.map