webpack-bundle-analyzer 3.0.2 → 3.0.3
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 +5 -0
- package/README.md +2 -2
- package/lib/viewer.js +4 -2
- package/package.json +1 -1
- package/public/viewer.js +1 -1
- package/public/viewer.js.map +1 -1
- package/src/viewer.js +4 -2
- package/views/viewer.ejs +1 -0
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.0.3
|
|
18
|
+
|
|
19
|
+
* **Bug Fix**
|
|
20
|
+
* Disable viewer websocket connection when report is generated in `static` mode ([#215](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/215), [@sebastianhaeni](https://github.com/sebastianhaeni))
|
|
21
|
+
|
|
17
22
|
## 3.0.2
|
|
18
23
|
|
|
19
24
|
* **Improvements**
|
package/README.md
CHANGED
|
@@ -56,11 +56,11 @@ new BundleAnalyzerPlugin(options?: object)
|
|
|
56
56
|
|**`analyzerMode`**|One of: `server`, `static`, `disabled`|Default: `server`. In `server` mode analyzer will start HTTP server to show bundle report. In `static` mode single HTML file with bundle report will be generated. In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`. |
|
|
57
57
|
|**`analyzerHost`**|`{String}`|Default: `127.0.0.1`. Host that will be used in `server` mode to start HTTP server.|
|
|
58
58
|
|**`analyzerPort`**|`{Number}`|Default: `8888`. Port that will be used in `server` mode to start HTTP server.|
|
|
59
|
-
|**`reportFilename`**|`{String}`|Default: `report.html`. Path to bundle report file that will be generated in `static` mode.
|
|
59
|
+
|**`reportFilename`**|`{String}`|Default: `report.html`. Path to bundle report file that will be generated in `static` mode. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).|
|
|
60
60
|
|**`defaultSizes`**|One of: `stat`, `parsed`, `gzip`|Default: `parsed`. Module sizes to show in report by default. [Size definitions](#size-definitions) section describes what these values mean.|
|
|
61
61
|
|**`openAnalyzer`**|`{Boolean}`|Default: `true`. Automatically open report in default browser.|
|
|
62
62
|
|**`generateStatsFile`**|`{Boolean}`|Default: `false`. If `true`, webpack stats JSON file will be generated in bundle output directory|
|
|
63
|
-
|**`statsFilename`**|`{String}`|Default: `stats.json`. Name of webpack stats JSON file that will be generated if `generateStatsFile` is `true`.
|
|
63
|
+
|**`statsFilename`**|`{String}`|Default: `stats.json`. Name of webpack stats JSON file that will be generated if `generateStatsFile` is `true`. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).|
|
|
64
64
|
|**`statsOptions`**|`null` or `{Object}`|Default: `null`. Options for `stats.toJson()` method. For example you can exclude sources of your modules from stats file with `source: false` option. [See more options here](https://webpack.js.org/configuration/stats/). |
|
|
65
65
|
|**`excludeAssets`**|`{null\|pattern\|pattern[]}` where `pattern` equals to `{String\|RegExp\|function}`|Default: `null`. Patterns that will be used to match against asset names to exclude them from the report. If pattern is a string it will be converted to RegExp via `new RegExp(str)`. If pattern is a function it should have the following signature `(assetName: string) => boolean` and should return `true` to *exclude* matching asset. If multiple patterns are provided asset should match at least one of them to be excluded. |
|
|
66
66
|
|**`logLevel`**|One of: `info`, `warn`, `error`, `silent`|Default: `info`. Used to control how much details the plugin outputs.|
|
package/lib/viewer.js
CHANGED
|
@@ -74,7 +74,8 @@ function _startServer() {
|
|
|
74
74
|
return JSON.stringify(chartData);
|
|
75
75
|
},
|
|
76
76
|
|
|
77
|
-
defaultSizes: JSON.stringify(defaultSizes)
|
|
77
|
+
defaultSizes: JSON.stringify(defaultSizes),
|
|
78
|
+
enableWebSocket: true
|
|
78
79
|
});
|
|
79
80
|
});
|
|
80
81
|
const server = http.createServer(app);
|
|
@@ -140,7 +141,8 @@ function generateReport(bundleStats, opts) {
|
|
|
140
141
|
mode: 'static',
|
|
141
142
|
chartData: JSON.stringify(chartData),
|
|
142
143
|
assetContent: getAssetContent,
|
|
143
|
-
defaultSizes: JSON.stringify(defaultSizes)
|
|
144
|
+
defaultSizes: JSON.stringify(defaultSizes),
|
|
145
|
+
enableWebSocket: false
|
|
144
146
|
}, (err, reportHtml) => {
|
|
145
147
|
if (err) return logger.error(err);
|
|
146
148
|
const reportFilepath = path.resolve(bundleDir || process.cwd(), reportFilename);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-bundle-analyzer",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
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
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
* Copyright 2015, Yahoo! Inc.
|
|
38
38
|
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
39
39
|
*/
|
|
40
|
-
e.exports=function(){var e={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},t={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},n=Object.defineProperty,r=Object.getOwnPropertyNames,i=Object.getOwnPropertySymbols,o=Object.getOwnPropertyDescriptor,a=Object.getPrototypeOf,s=a&&a(Object);return function u(l,c,h){if("string"!=typeof c){if(s){var f=a(c);f&&f!==s&&u(l,f,h)}var d=r(c);i&&(d=d.concat(i(c)));for(var p=0;p<d.length;++p){var g=d[p];if(!(e[g]||t[g]||h&&h[g])){var b=o(c,g);try{n(l,g,b)}catch(e){}}}return l}return l}}()});var En={children:!0,key:!0,ref:!0},Gn=console;!function(e){function t(){return zn(this,t),Ln(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}jn(t,P),kn(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)En[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&&Gn.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)En[t]||this.props[t]===e[t]||Gn.warn("MobX Provider: Provided store '"+t+"' has changed. Please avoid replacing stores as the change might not propagate to all children")}}])}();if(!P)throw new Error("mobx-preact requires Preact to be available");function Bn(){return(Bn=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 Fn=n(20),Rn=n.n(Fn);class Un extends P{constructor(e){super(e),this.saveNodeRef=(e=>this.node=e),this.resize=(()=>{this.treemap.resize()}),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",Bn({},this.props,{ref:this.saveNodeRef}))}getTreemapDataObject(e=this.props.data){return{groups:e}}createTreemap(){const e=this,{props:t}=this;return new Rn.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(t){Vn(t),e.zoomOutDisabled=!1,this.zoom(t.group)},onGroupDoubleClick:Vn,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 Vn(t);n<1&&(e.zoomOutDisabled=!0,Vn(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 Vn(e){e.preventDefault()}var Hn=n(1),Wn=n.n(Hn),qn=n(15),$n=n.n(qn);class Kn extends P{constructor(e){super(e),this.saveNode=(e=>this.node=e),this.onMouseMove=(e=>{Object.assign(this.mouseCoords,{x:e.pageX,y:e.pageY}),this.props.visible&&this.updatePosition()}),this.mouseCoords={x:0,y:0},this.state={left:0,top:0}}componentDidMount(){document.addEventListener("mousemove",this.onMouseMove,!1)}shouldComponentUpdate(e){return this.props.visible||e.visible}componentWillUnmount(){document.removeEventListener("mousemove",this.onMouseMove)}render(){const{children:e,visible:t}=this.props,n=Wn()({[$n.a.container]:!0,[$n.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+Kn.marginX,top:this.mouseCoords.y+Kn.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-Kn.marginY-t.height),this.setState(e)}}function Yn(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}Kn.marginX=10,Kn.marginY=30;var Zn=n(9),Jn=n.n(Zn);class Qn extends P{shouldComponentUpdate(e,t){return!Xn(e,this.props)||!Xn(this.state,t)}}function Xn(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 er extends Qn{constructor(...e){super(...e),this.handleClick=(e=>{this.elem.blur(),this.props.onClick(e)}),this.saveRef=(e=>this.elem=e)}render(e){let{active:t,toggle:n,className:r,children:i}=e,o=Yn(e,["active","toggle","className","children"]);const a=Wn()(r,{[Jn.a.button]:!0,[Jn.a.active]:t,[Jn.a.toggle]:n});return s("button",Bn({},o,{ref:this.saveRef,type:"button",className:a,disabled:this.disabled,onClick:this.handleClick}),i)}get disabled(){const{props:e}=this;return e.disabled||e.active&&!e.toggle}}class tr extends Qn{constructor(...e){super(...e),this.handleClick=(()=>{this.props.onClick(this.props.item)})}render(e){let{item:t}=e,n=Yn(e,["item"]);return s(er,Bn({},n,{onClick:this.handleClick}),t.label)}}var nr=n(10),rr=n.n(nr);class ir extends Qn{render(){const{label:e,items:t,activeItem:n,onSwitch:r}=this.props;return s("div",{className:rr.a.container},s("div",{className:rr.a.label},e,":"),s("div",null,t.map(e=>s(tr,{key:e.label,className:rr.a.item,item:e,active:e===n,onClick:r}))))}}var or=n(4),ar=n.n(or),sr=n(21),ur=n.n(sr);const lr={"arrow-right":{src:n(32),size:[7,13]},pin:{src:n(33),size:[12,18]}};class cr extends Qn{render({className:e}){return s("i",{className:Wn()(ur.a.icon,e),style:this.style})}get style(){const{name:e,size:t,rotate:n}=this.props,r=lr[e];if(!r)throw new TypeError(`Can't find "${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(${r.src})`,width:`${i}px`,height:`${o}px`,transform:n?`rotate(${n}deg)`:""}}}const hr=parseInt(ar.a.toggleTime);class fr extends P{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=Wn()({[ar.a.container]:!0,[ar.a.pinned]:t,[ar.a.left]:"left"===e,[ar.a.hidden]:!r,[ar.a.empty]:!i});return s("div",{ref:this.saveNode,className:o,onClick:this.handleClick,onMouseLeave:this.handleMouseLeave},r&&s(er,{type:"button",title:"Pin",className:ar.a.pinButton,toggle:!0,active:t,onClick:this.handlePinButtonClick},s(cr,{name:"pin",size:13})),s(er,{type:"button",title:r?"Hide":"Show sidebar",className:ar.a.toggleButton,onClick:this.handleToggleButtonClick},s(cr,{name:"arrow-right",size:10,rotate:r?180:0})),t&&r&&s("div",{className:ar.a.resizer,onMouseDown:this.handleResizeStart}),s("div",{className:ar.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},hr),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)},hr))}updateNodeWidth(e=this.width){this.node.style.width=e?`${e}px`:""}}fr.defaultProps={pinned:!1,position:"left"};var dr=n(11),pr=n.n(dr);class gr extends P{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:Wn()(pr.a.label,t)},s("input",{className:pr.a.checkbox,type:"checkbox",checked:e,onChange:this.handleChange}),s("span",{className:pr.a.itemText},n))}}var br=n(7),vr=n.n(br);class yr extends P{constructor(...e){super(...e),this.handleChange=(()=>{this.props.onChange(this.props.item)})}render(){return s("div",{className:vr.a.item},s(gr,Bn({},this.props,{onChange:this.handleChange}),this.renderLabel()))}renderLabel(){const{children:e,item:t}=this.props;return e&&e.length?e[0](t):t===xr.ALL_ITEM?"All":t.label}}const mr=Symbol("ALL_ITEM");class xr extends Qn{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:vr.a.container},s("div",{className:vr.a.label},e,":"),s("div",null,s(yr,{item:mr,checked:this.isAllChecked(),onChange:this.handleToggleAllCheck},n),t.map(e=>s(yr,{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))}}xr.ALL_ITEM=mr;var wr=n(0),Cr=n.n(wr),Sr=n(22),Tr=n.n(Sr),Mr=n(6),zr=n.n(Mr);class kr extends Qn{constructor(...e){super(...e),this.handleValueChange=Tr()(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:zr.a.container},s("div",{className:zr.a.label},e,":"),s("div",{className:zr.a.row},s("input",{ref:this.saveInputNode,className:zr.a.input,type:"text",value:t,placeholder:"Enter regexp",onInput:this.handleValueChange,onBlur:this.handleInputBlur,onKeyDown:this.handleKeyDown}),s(er,{className:zr.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 jr,Lr,Dr=n(23),_r=n.n(Dr),Or=n(24),Ar=n.n(Or),Ir=n(8),Pr=n.n(Ir),Nr=n(25),Er=n.n(Nr),Gr=n(12),Br=n.n(Gr);class Fr extends Qn{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:Wn()(Br.a.container,Br.a[this.itemType],{[Br.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,Sn()(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,"ig"):new RegExp(`(?:${Er()(r)})+`,"i");let i,o;do{o=i,i=t.exec(n)}while(i);o&&(e=Pr()(n.slice(0,o.index))+`<strong>${Pr()(o[0])}</strong>`+Pr()(n.slice(o.index+o[0].length)))}return e||(e=Pr()(n)),e}get invisibleHint(){return`${Ar()(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 Rr extends Qn{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:Wn()(_r.a.container,i)},e.map(e=>s(Fr,{key:e.cid,module:e,showSize:t,highlightedText:n,isVisible:r,onClick:this.handleModuleClick})))}}const Ur=[{label:"Stat",prop:"statSize"},{label:"Parsed",prop:"parsedSize"},{label:"Gzipped",prop:"gzipSize"}];let Vr=Nn((B((Lr=class extends P{constructor(...e){super(...e),this.state={sidebarPinned:!1,showTooltip:!1,tooltipContent:null},this.renderChunkItemLabel=(e=>{const t=e===xr.ALL_ITEM,n=t?"All":e.label,r=t?wn.totalChunksSize:e[wn.activeSize];return[`${n} (`,s("strong",null,Sn()(r)),")"]}),this.handleConcatenatedModulesContentToggle=(e=>{wn.showConcatenatedModulesContent=e}),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=>{wn.selectedSize=e.prop}),this.handleQueryChange=(e=>{wn.searchQuery=e}),this.handleSelectedChunksChange=(e=>{wn.selectedChunks=e}),this.handleMouseLeaveTreemap=(()=>{this.setState({showTooltip:!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.isModuleVisible=(e=>this.treemap.isGroupRendered(e)),this.saveTreemapRef=(e=>this.treemap=e)}render(){const{sidebarPinned:e,showTooltip:t,tooltipContent:n}=this.state;return s("div",{className:Cr.a.container},s(fr,{pinned:e,onToggle:this.handleSidebarToggle,onPinStateChange:this.handleSidebarPinStateChange,onResize:this.handleSidebarResize},s("div",{className:Cr.a.sidebarGroup},s(ir,{label:"Treemap sizes",items:this.sizeSwitchItems,activeItem:this.activeSizeItem,onSwitch:this.handleSizeSwitch}),wn.hasConcatenatedModules&&s("div",{className:Cr.a.showOption},s(gr,{checked:wn.showConcatenatedModulesContent,onChange:this.handleConcatenatedModulesContentToggle},`Show content of concatenated modules${"statSize"===wn.activeSize?"":" (inaccurate)"}`))),s("div",{className:Cr.a.sidebarGroup},s(kr,{label:"Search modules",query:wn.searchQuery,autofocus:!0,onQueryChange:this.handleQueryChange}),s("div",{className:Cr.a.foundModulesInfo},this.foundModulesInfo),wn.isSearching&&wn.hasFoundModules&&s("div",{className:Cr.a.foundModulesContainer},wn.foundModulesByChunk.map(({chunk:e,modules:t})=>s("div",{key:e.cid,className:Cr.a.foundModulesChunk},s("div",{className:Cr.a.foundModulesChunkName,onClick:()=>this.treemap.zoomToGroup(e)},e.label),s(Rr,{className:Cr.a.foundModulesList,modules:t,showSize:wn.activeSize,highlightedText:wn.searchQueryRegexp,isModuleVisible:this.isModuleVisible,onModuleClick:this.handleFoundModuleClick}))))),this.chunkItems.length>1&&s("div",{className:Cr.a.sidebarGroup},s(xr,{label:"Show chunks",items:this.chunkItems,checkedItems:wn.selectedChunks,renderLabel:this.renderChunkItemLabel,onChange:this.handleSelectedChunksChange}))),s(Un,{ref:this.saveTreemapRef,className:Cr.a.map,data:wn.visibleChunks,highlightGroups:this.highlightedModules,weightProp:wn.activeSize,onMouseLeave:this.handleMouseLeaveTreemap,onGroupHover:this.handleTreemapGroupHover}),s(Kn,{visible:t},n))}renderModuleSize(e,t){const n=`${t}Size`,r=e[n],i=Ur.find(e=>e.prop===n).label,o=wn.activeSize===n;return"number"==typeof r?s("div",{className:o?Cr.a.activeSize:""},i," size: ",s("strong",null,Sn()(r))):null}get sizeSwitchItems(){return wn.hasParsedSizes?Ur:Ur.slice(0,1)}get activeSizeItem(){return this.sizeSwitchItems.find(e=>e.prop===wn.activeSize)}get chunkItems(){const{allChunks:e,activeSize:t}=wn;let n=[...e];return"statSize"!==t&&(n=n.filter(mn)),n.sort((e,n)=>n[t]-e[t]),n}get highlightedModules(){return new Set(wn.foundModules)}get foundModulesInfo(){return wn.isSearching?wn.hasFoundModules?[s("div",{className:Cr.a.foundModulesInfoItem},"Count: ",s("strong",null,wn.foundModules.length)),s("div",{className:Cr.a.foundModulesInfoItem},"Total size: ",s("strong",null,Sn()(wn.foundModulesSize)))]:"Nothing found"+(wn.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))):null}}).prototype,"sizeSwitchItems",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"sizeSwitchItems"),Lr.prototype),B(Lr.prototype,"activeSizeItem",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"activeSizeItem"),Lr.prototype),B(Lr.prototype,"chunkItems",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"chunkItems"),Lr.prototype),B(Lr.prototype,"highlightedModules",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"highlightedModules"),Lr.prototype),B(Lr.prototype,"foundModulesInfo",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"foundModulesInfo"),Lr.prototype),jr=Lr))||jr;n(63);let Hr;try{Hr=new WebSocket(`ws://${location.host}`)}catch(e){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",()=>{wn.defaultSize=`${window.defaultSizes}Size`,wn.setModules(window.chartData),N(s(Vr,null),document.getElementById("app")),Hr&&Hr.addEventListener("message",e=>{const t=JSON.parse(e.data);"chartDataUpdated"===t.event&&wn.setModules(t.data)})},!1)}]);
|
|
40
|
+
e.exports=function(){var e={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},t={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},n=Object.defineProperty,r=Object.getOwnPropertyNames,i=Object.getOwnPropertySymbols,o=Object.getOwnPropertyDescriptor,a=Object.getPrototypeOf,s=a&&a(Object);return function u(l,c,h){if("string"!=typeof c){if(s){var f=a(c);f&&f!==s&&u(l,f,h)}var d=r(c);i&&(d=d.concat(i(c)));for(var p=0;p<d.length;++p){var g=d[p];if(!(e[g]||t[g]||h&&h[g])){var b=o(c,g);try{n(l,g,b)}catch(e){}}}return l}return l}}()});var En={children:!0,key:!0,ref:!0},Gn=console;!function(e){function t(){return zn(this,t),Ln(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}jn(t,P),kn(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)En[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&&Gn.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)En[t]||this.props[t]===e[t]||Gn.warn("MobX Provider: Provided store '"+t+"' has changed. Please avoid replacing stores as the change might not propagate to all children")}}])}();if(!P)throw new Error("mobx-preact requires Preact to be available");function Bn(){return(Bn=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 Fn=n(20),Rn=n.n(Fn);class Un extends P{constructor(e){super(e),this.saveNodeRef=(e=>this.node=e),this.resize=(()=>{this.treemap.resize()}),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",Bn({},this.props,{ref:this.saveNodeRef}))}getTreemapDataObject(e=this.props.data){return{groups:e}}createTreemap(){const e=this,{props:t}=this;return new Rn.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(t){Vn(t),e.zoomOutDisabled=!1,this.zoom(t.group)},onGroupDoubleClick:Vn,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 Vn(t);n<1&&(e.zoomOutDisabled=!0,Vn(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 Vn(e){e.preventDefault()}var Hn=n(1),Wn=n.n(Hn),qn=n(15),$n=n.n(qn);class Kn extends P{constructor(e){super(e),this.saveNode=(e=>this.node=e),this.onMouseMove=(e=>{Object.assign(this.mouseCoords,{x:e.pageX,y:e.pageY}),this.props.visible&&this.updatePosition()}),this.mouseCoords={x:0,y:0},this.state={left:0,top:0}}componentDidMount(){document.addEventListener("mousemove",this.onMouseMove,!1)}shouldComponentUpdate(e){return this.props.visible||e.visible}componentWillUnmount(){document.removeEventListener("mousemove",this.onMouseMove)}render(){const{children:e,visible:t}=this.props,n=Wn()({[$n.a.container]:!0,[$n.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+Kn.marginX,top:this.mouseCoords.y+Kn.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-Kn.marginY-t.height),this.setState(e)}}function Yn(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}Kn.marginX=10,Kn.marginY=30;var Zn=n(9),Jn=n.n(Zn);class Qn extends P{shouldComponentUpdate(e,t){return!Xn(e,this.props)||!Xn(this.state,t)}}function Xn(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 er extends Qn{constructor(...e){super(...e),this.handleClick=(e=>{this.elem.blur(),this.props.onClick(e)}),this.saveRef=(e=>this.elem=e)}render(e){let{active:t,toggle:n,className:r,children:i}=e,o=Yn(e,["active","toggle","className","children"]);const a=Wn()(r,{[Jn.a.button]:!0,[Jn.a.active]:t,[Jn.a.toggle]:n});return s("button",Bn({},o,{ref:this.saveRef,type:"button",className:a,disabled:this.disabled,onClick:this.handleClick}),i)}get disabled(){const{props:e}=this;return e.disabled||e.active&&!e.toggle}}class tr extends Qn{constructor(...e){super(...e),this.handleClick=(()=>{this.props.onClick(this.props.item)})}render(e){let{item:t}=e,n=Yn(e,["item"]);return s(er,Bn({},n,{onClick:this.handleClick}),t.label)}}var nr=n(10),rr=n.n(nr);class ir extends Qn{render(){const{label:e,items:t,activeItem:n,onSwitch:r}=this.props;return s("div",{className:rr.a.container},s("div",{className:rr.a.label},e,":"),s("div",null,t.map(e=>s(tr,{key:e.label,className:rr.a.item,item:e,active:e===n,onClick:r}))))}}var or=n(4),ar=n.n(or),sr=n(21),ur=n.n(sr);const lr={"arrow-right":{src:n(32),size:[7,13]},pin:{src:n(33),size:[12,18]}};class cr extends Qn{render({className:e}){return s("i",{className:Wn()(ur.a.icon,e),style:this.style})}get style(){const{name:e,size:t,rotate:n}=this.props,r=lr[e];if(!r)throw new TypeError(`Can't find "${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(${r.src})`,width:`${i}px`,height:`${o}px`,transform:n?`rotate(${n}deg)`:""}}}const hr=parseInt(ar.a.toggleTime);class fr extends P{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=Wn()({[ar.a.container]:!0,[ar.a.pinned]:t,[ar.a.left]:"left"===e,[ar.a.hidden]:!r,[ar.a.empty]:!i});return s("div",{ref:this.saveNode,className:o,onClick:this.handleClick,onMouseLeave:this.handleMouseLeave},r&&s(er,{type:"button",title:"Pin",className:ar.a.pinButton,toggle:!0,active:t,onClick:this.handlePinButtonClick},s(cr,{name:"pin",size:13})),s(er,{type:"button",title:r?"Hide":"Show sidebar",className:ar.a.toggleButton,onClick:this.handleToggleButtonClick},s(cr,{name:"arrow-right",size:10,rotate:r?180:0})),t&&r&&s("div",{className:ar.a.resizer,onMouseDown:this.handleResizeStart}),s("div",{className:ar.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},hr),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)},hr))}updateNodeWidth(e=this.width){this.node.style.width=e?`${e}px`:""}}fr.defaultProps={pinned:!1,position:"left"};var dr=n(11),pr=n.n(dr);class gr extends P{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:Wn()(pr.a.label,t)},s("input",{className:pr.a.checkbox,type:"checkbox",checked:e,onChange:this.handleChange}),s("span",{className:pr.a.itemText},n))}}var br=n(7),vr=n.n(br);class yr extends P{constructor(...e){super(...e),this.handleChange=(()=>{this.props.onChange(this.props.item)})}render(){return s("div",{className:vr.a.item},s(gr,Bn({},this.props,{onChange:this.handleChange}),this.renderLabel()))}renderLabel(){const{children:e,item:t}=this.props;return e&&e.length?e[0](t):t===xr.ALL_ITEM?"All":t.label}}const mr=Symbol("ALL_ITEM");class xr extends Qn{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:vr.a.container},s("div",{className:vr.a.label},e,":"),s("div",null,s(yr,{item:mr,checked:this.isAllChecked(),onChange:this.handleToggleAllCheck},n),t.map(e=>s(yr,{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))}}xr.ALL_ITEM=mr;var wr=n(0),Cr=n.n(wr),Sr=n(22),Tr=n.n(Sr),Mr=n(6),zr=n.n(Mr);class kr extends Qn{constructor(...e){super(...e),this.handleValueChange=Tr()(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:zr.a.container},s("div",{className:zr.a.label},e,":"),s("div",{className:zr.a.row},s("input",{ref:this.saveInputNode,className:zr.a.input,type:"text",value:t,placeholder:"Enter regexp",onInput:this.handleValueChange,onBlur:this.handleInputBlur,onKeyDown:this.handleKeyDown}),s(er,{className:zr.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 jr,Lr,Dr=n(23),_r=n.n(Dr),Or=n(24),Ar=n.n(Or),Ir=n(8),Pr=n.n(Ir),Nr=n(25),Er=n.n(Nr),Gr=n(12),Br=n.n(Gr);class Fr extends Qn{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:Wn()(Br.a.container,Br.a[this.itemType],{[Br.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,Sn()(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,"ig"):new RegExp(`(?:${Er()(r)})+`,"i");let i,o;do{o=i,i=t.exec(n)}while(i);o&&(e=Pr()(n.slice(0,o.index))+`<strong>${Pr()(o[0])}</strong>`+Pr()(n.slice(o.index+o[0].length)))}return e||(e=Pr()(n)),e}get invisibleHint(){return`${Ar()(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 Rr extends Qn{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:Wn()(_r.a.container,i)},e.map(e=>s(Fr,{key:e.cid,module:e,showSize:t,highlightedText:n,isVisible:r,onClick:this.handleModuleClick})))}}const Ur=[{label:"Stat",prop:"statSize"},{label:"Parsed",prop:"parsedSize"},{label:"Gzipped",prop:"gzipSize"}];let Vr=Nn((B((Lr=class extends P{constructor(...e){super(...e),this.state={sidebarPinned:!1,showTooltip:!1,tooltipContent:null},this.renderChunkItemLabel=(e=>{const t=e===xr.ALL_ITEM,n=t?"All":e.label,r=t?wn.totalChunksSize:e[wn.activeSize];return[`${n} (`,s("strong",null,Sn()(r)),")"]}),this.handleConcatenatedModulesContentToggle=(e=>{wn.showConcatenatedModulesContent=e}),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=>{wn.selectedSize=e.prop}),this.handleQueryChange=(e=>{wn.searchQuery=e}),this.handleSelectedChunksChange=(e=>{wn.selectedChunks=e}),this.handleMouseLeaveTreemap=(()=>{this.setState({showTooltip:!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.isModuleVisible=(e=>this.treemap.isGroupRendered(e)),this.saveTreemapRef=(e=>this.treemap=e)}render(){const{sidebarPinned:e,showTooltip:t,tooltipContent:n}=this.state;return s("div",{className:Cr.a.container},s(fr,{pinned:e,onToggle:this.handleSidebarToggle,onPinStateChange:this.handleSidebarPinStateChange,onResize:this.handleSidebarResize},s("div",{className:Cr.a.sidebarGroup},s(ir,{label:"Treemap sizes",items:this.sizeSwitchItems,activeItem:this.activeSizeItem,onSwitch:this.handleSizeSwitch}),wn.hasConcatenatedModules&&s("div",{className:Cr.a.showOption},s(gr,{checked:wn.showConcatenatedModulesContent,onChange:this.handleConcatenatedModulesContentToggle},`Show content of concatenated modules${"statSize"===wn.activeSize?"":" (inaccurate)"}`))),s("div",{className:Cr.a.sidebarGroup},s(kr,{label:"Search modules",query:wn.searchQuery,autofocus:!0,onQueryChange:this.handleQueryChange}),s("div",{className:Cr.a.foundModulesInfo},this.foundModulesInfo),wn.isSearching&&wn.hasFoundModules&&s("div",{className:Cr.a.foundModulesContainer},wn.foundModulesByChunk.map(({chunk:e,modules:t})=>s("div",{key:e.cid,className:Cr.a.foundModulesChunk},s("div",{className:Cr.a.foundModulesChunkName,onClick:()=>this.treemap.zoomToGroup(e)},e.label),s(Rr,{className:Cr.a.foundModulesList,modules:t,showSize:wn.activeSize,highlightedText:wn.searchQueryRegexp,isModuleVisible:this.isModuleVisible,onModuleClick:this.handleFoundModuleClick}))))),this.chunkItems.length>1&&s("div",{className:Cr.a.sidebarGroup},s(xr,{label:"Show chunks",items:this.chunkItems,checkedItems:wn.selectedChunks,renderLabel:this.renderChunkItemLabel,onChange:this.handleSelectedChunksChange}))),s(Un,{ref:this.saveTreemapRef,className:Cr.a.map,data:wn.visibleChunks,highlightGroups:this.highlightedModules,weightProp:wn.activeSize,onMouseLeave:this.handleMouseLeaveTreemap,onGroupHover:this.handleTreemapGroupHover}),s(Kn,{visible:t},n))}renderModuleSize(e,t){const n=`${t}Size`,r=e[n],i=Ur.find(e=>e.prop===n).label,o=wn.activeSize===n;return"number"==typeof r?s("div",{className:o?Cr.a.activeSize:""},i," size: ",s("strong",null,Sn()(r))):null}get sizeSwitchItems(){return wn.hasParsedSizes?Ur:Ur.slice(0,1)}get activeSizeItem(){return this.sizeSwitchItems.find(e=>e.prop===wn.activeSize)}get chunkItems(){const{allChunks:e,activeSize:t}=wn;let n=[...e];return"statSize"!==t&&(n=n.filter(mn)),n.sort((e,n)=>n[t]-e[t]),n}get highlightedModules(){return new Set(wn.foundModules)}get foundModulesInfo(){return wn.isSearching?wn.hasFoundModules?[s("div",{className:Cr.a.foundModulesInfoItem},"Count: ",s("strong",null,wn.foundModules.length)),s("div",{className:Cr.a.foundModulesInfoItem},"Total size: ",s("strong",null,Sn()(wn.foundModulesSize)))]:"Nothing found"+(wn.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))):null}}).prototype,"sizeSwitchItems",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"sizeSwitchItems"),Lr.prototype),B(Lr.prototype,"activeSizeItem",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"activeSizeItem"),Lr.prototype),B(Lr.prototype,"chunkItems",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"chunkItems"),Lr.prototype),B(Lr.prototype,"highlightedModules",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"highlightedModules"),Lr.prototype),B(Lr.prototype,"foundModulesInfo",[ze],Object.getOwnPropertyDescriptor(Lr.prototype,"foundModulesInfo"),Lr.prototype),jr=Lr))||jr;n(63);let Hr;try{window.enableWebSocket&&(Hr=new WebSocket(`ws://${location.host}`))}catch(e){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",()=>{wn.defaultSize=`${window.defaultSizes}Size`,wn.setModules(window.chartData),N(s(Vr,null),document.getElementById("app")),Hr&&Hr.addEventListener("message",e=>{const t=JSON.parse(e.data);"chartDataUpdated"===t.event&&wn.setModules(t.data)})},!1)}]);
|
|
41
41
|
//# sourceMappingURL=viewer.js.map
|