@tanstack/virtual-core 3.0.0-beta.8 → 3.0.0
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/LICENSE +21 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +27 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +31 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +27 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -0
- package/build/lib/index.d.ts +126 -0
- package/build/lib/index.esm.js +639 -0
- package/build/lib/index.esm.js.map +1 -0
- package/build/lib/index.js +654 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/index.mjs +639 -0
- package/build/lib/index.mjs.map +1 -0
- package/build/lib/utils.d.ts +10 -0
- package/build/lib/utils.esm.js +58 -0
- package/build/lib/utils.esm.js.map +1 -0
- package/build/{cjs/packages/virtual-core/src → lib}/utils.js +28 -21
- package/build/lib/utils.js.map +1 -0
- package/build/lib/utils.mjs +58 -0
- package/build/lib/utils.mjs.map +1 -0
- package/build/umd/index.development.js +592 -454
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +16 -14
- package/src/index.ts +551 -244
- package/src/utils.ts +17 -5
- package/build/cjs/packages/virtual-core/src/index.js +0 -466
- package/build/cjs/packages/virtual-core/src/index.js.map +0 -1
- package/build/cjs/packages/virtual-core/src/utils.js.map +0 -1
- package/build/esm/index.js +0 -560
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -2689
- package/build/stats.json +0 -101
- package/build/types/index.d.ts +0 -88
- package/build/types/utils.d.ts +0 -7
package/build/stats-html.html
DELETED
|
@@ -1,2689 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!DOCTYPE html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
|
8
|
-
<title>RollUp Visualizer</title>
|
|
9
|
-
<style>
|
|
10
|
-
:root {
|
|
11
|
-
--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
12
|
-
"Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
|
|
13
|
-
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
14
|
-
--background-color: #f7eedf;
|
|
15
|
-
--text-color: #333;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@media (prefers-color-scheme: dark) {
|
|
19
|
-
:root {
|
|
20
|
-
--background-color: #2b2d42;
|
|
21
|
-
--text-color: #edf2f4;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
html {
|
|
25
|
-
box-sizing: border-box;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
*,
|
|
29
|
-
*:before,
|
|
30
|
-
*:after {
|
|
31
|
-
box-sizing: inherit;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
html {
|
|
35
|
-
background-color: var(--background-color);
|
|
36
|
-
color: var(--text-color);
|
|
37
|
-
font-family: var(--font-family);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
body {
|
|
41
|
-
padding: 0;
|
|
42
|
-
margin: 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
html,
|
|
46
|
-
body {
|
|
47
|
-
height: 100%;
|
|
48
|
-
width: 100%;
|
|
49
|
-
overflow: hidden;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
body {
|
|
53
|
-
display: flex;
|
|
54
|
-
flex-direction: column;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
svg {
|
|
58
|
-
vertical-align: middle;
|
|
59
|
-
width: 100%;
|
|
60
|
-
height: 100%;
|
|
61
|
-
max-height: 100vh;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
main {
|
|
65
|
-
flex-grow: 1;
|
|
66
|
-
height: 100vh;
|
|
67
|
-
padding: 20px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.tooltip {
|
|
71
|
-
position: absolute;
|
|
72
|
-
z-index: 1070;
|
|
73
|
-
border: 2px solid;
|
|
74
|
-
border-radius: 5px;
|
|
75
|
-
padding: 5px;
|
|
76
|
-
white-space: nowrap;
|
|
77
|
-
font-size: 0.875rem;
|
|
78
|
-
background-color: var(--background-color);
|
|
79
|
-
color: var(--text-color);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.tooltip-hidden {
|
|
83
|
-
visibility: hidden;
|
|
84
|
-
opacity: 0;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.sidebar {
|
|
88
|
-
position: fixed;
|
|
89
|
-
top: 0;
|
|
90
|
-
left: 0;
|
|
91
|
-
right: 0;
|
|
92
|
-
display: flex;
|
|
93
|
-
flex-direction: row;
|
|
94
|
-
font-size: 0.7rem;
|
|
95
|
-
align-items: center;
|
|
96
|
-
margin: 0 50px;
|
|
97
|
-
height: 20px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.size-selectors {
|
|
101
|
-
display: flex;
|
|
102
|
-
flex-direction: row;
|
|
103
|
-
align-items: center;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.size-selector {
|
|
107
|
-
display: flex;
|
|
108
|
-
flex-direction: row;
|
|
109
|
-
align-items: center;
|
|
110
|
-
justify-content: center;
|
|
111
|
-
margin-right: 1rem;
|
|
112
|
-
}
|
|
113
|
-
.size-selector input {
|
|
114
|
-
margin: 0 0.3rem 0 0;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.filters {
|
|
118
|
-
flex: 1;
|
|
119
|
-
display: flex;
|
|
120
|
-
flex-direction: row;
|
|
121
|
-
align-items: center;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.module-filters {
|
|
125
|
-
display: flex;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.module-filter {
|
|
129
|
-
display: flex;
|
|
130
|
-
flex-direction: row;
|
|
131
|
-
align-items: center;
|
|
132
|
-
justify-content: center;
|
|
133
|
-
flex: 1;
|
|
134
|
-
}
|
|
135
|
-
.module-filter input {
|
|
136
|
-
flex: 1;
|
|
137
|
-
height: 1rem;
|
|
138
|
-
padding: 0.01rem;
|
|
139
|
-
font-size: 0.7rem;
|
|
140
|
-
margin-left: 0.3rem;
|
|
141
|
-
}
|
|
142
|
-
.module-filter + .module-filter {
|
|
143
|
-
margin-left: 0.5rem;
|
|
144
|
-
}
|
|
145
|
-
</style>
|
|
146
|
-
</head>
|
|
147
|
-
<body>
|
|
148
|
-
<main></main>
|
|
149
|
-
<script>
|
|
150
|
-
/*<!--*/
|
|
151
|
-
var drawChart = (function (exports) {
|
|
152
|
-
'use strict';
|
|
153
|
-
|
|
154
|
-
var n,l$1,u$1,t$1,r$1,o$2,f$1,e$2={},c$1=[],s$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function a$1(n,l){for(var u in l)n[u]=l[u];return n}function h$1(n){var l=n.parentNode;l&&l.removeChild(n);}function v$1(l,u,i){var t,r,o,f={};for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===f[o]&&(f[o]=l.defaultProps[o]);return y$1(l,f,t,r,null)}function y$1(n,i,t,r,o){var f={type:n,props:i,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++u$1:o};return null==o&&null!=l$1.vnode&&l$1.vnode(f),f}function d$1(n){return n.children}function _(n,l){this.props=n,this.context=l;}function k$1(n,l){if(null==l)return n.__?k$1(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?k$1(n):null}function b$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return b$1(n)}}function m$1(n){(!n.__d&&(n.__d=!0)&&t$1.push(n)&&!g$1.__r++||o$2!==l$1.debounceRendering)&&((o$2=l$1.debounceRendering)||r$1)(g$1);}function g$1(){for(var n;g$1.__r=t$1.length;)n=t$1.sort(function(n,l){return n.__v.__b-l.__v.__b}),t$1=[],n.some(function(n){var l,u,i,t,r,o;n.__d&&(r=(t=(l=n).__v).__e,(o=l.__P)&&(u=[],(i=a$1({},t)).__v=t.__v+1,j$1(o,t,i,l.__n,void 0!==o.ownerSVGElement,null!=t.__h?[r]:null,u,null==r?k$1(t):r,t.__h),z(u,t),t.__e!=r&&b$1(t)));});}function w$1(n,l,u,i,t,r,o,f,s,a){var h,v,p,_,b,m,g,w=i&&i.__k||c$1,A=w.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(_=u.__k[h]=null==(_=l[h])||"boolean"==typeof _?null:"string"==typeof _||"number"==typeof _||"bigint"==typeof _?y$1(null,_,null,null,_):Array.isArray(_)?y$1(d$1,{children:_},null,null,null):_.__b>0?y$1(_.type,_.props,_.key,null,_.__v):_)){if(_.__=u,_.__b=u.__b+1,null===(p=w[h])||p&&_.key==p.key&&_.type===p.type)w[h]=void 0;else for(v=0;v<A;v++){if((p=w[v])&&_.key==p.key&&_.type===p.type){w[v]=void 0;break}p=null;}j$1(n,_,p=p||e$2,t,r,o,f,s,a),b=_.__e,(v=_.ref)&&p.ref!=v&&(g||(g=[]),p.ref&&g.push(p.ref,null,_),g.push(v,_.__c||b,_)),null!=b?(null==m&&(m=b),"function"==typeof _.type&&_.__k===p.__k?_.__d=s=x$1(_,s,n):s=P(n,_,p,w,b,s),"function"==typeof u.type&&(u.__d=s)):s&&p.__e==s&&s.parentNode!=n&&(s=k$1(p));}for(u.__e=m,h=A;h--;)null!=w[h]&&("function"==typeof u.type&&null!=w[h].__e&&w[h].__e==u.__d&&(u.__d=k$1(i,h+1)),N(w[h],w[h]));if(g)for(h=0;h<g.length;h++)M(g[h],g[++h],g[++h]);}function x$1(n,l,u){for(var i,t=n.__k,r=0;t&&r<t.length;r++)(i=t[r])&&(i.__=n,l="function"==typeof i.type?x$1(i,l,u):P(u,i,i,t,i.__e,l));return l}function P(n,l,u,i,t,r){var o,f,e;if(void 0!==l.__d)o=l.__d,l.__d=void 0;else if(null==u||t!=r||null==t.parentNode)n:if(null==r||r.parentNode!==n)n.appendChild(t),o=null;else {for(f=r,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,r),o=r;}return void 0!==o?o:t.nextSibling}function C(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||H(n,r,null,u[r],i);for(r in l)t&&"function"!=typeof l[r]||"children"===r||"key"===r||"value"===r||"checked"===r||u[r]===l[r]||H(n,r,l[r],u[r],i);}function $(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||s$1.test(l)?u:u+"px";}function H(n,l,u,i,t){var r;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||$(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||$(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])r=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?i||n.addEventListener(l,r?T:I,r):n.removeEventListener(l,r?T:I,r);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function I(n){this.l[n.type+!1](l$1.event?l$1.event(n):n);}function T(n){this.l[n.type+!0](l$1.event?l$1.event(n):n);}function j$1(n,u,i,t,r,o,f,e,c){var s,h,v,y,p,k,b,m,g,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,o=[e]),(s=l$1.__b)&&s(u);try{n:if("function"==typeof P){if(m=u.props,g=(s=P.contextType)&&t[s.__c],x=s?g?g.props.value:s.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in P&&P.prototype.render?u.__c=h=new P(m,x):(u.__c=h=new _(m,x),h.constructor=P,h.render=O),g&&g.sub(h),h.props=m,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=P.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=a$1({},h.__s)),a$1(h.__s,P.getDerivedStateFromProps(m,h.__s))),y=h.props,p=h.state,v)null==P.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else {if(null==P.getDerivedStateFromProps&&m!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,x)||u.__v===i.__v){h.props=m,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,p,k);});}h.context=x,h.props=m,h.state=h.__s,(s=l$1.__r)&&s(u),h.__d=!1,h.__v=u,h.__P=n,s=h.render(h.props,h.state,h.context),h.state=h.__s,null!=h.getChildContext&&(t=a$1(a$1({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,p)),A=null!=s&&s.type===d$1&&null==s.key?s.props.children:s,w$1(n,Array.isArray(A)?A:[A],u,i,t,r,o,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1;}else null==o&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=L(i.__e,u,i,t,r,o,f,c);(s=l$1.diffed)&&s(u);}catch(n){u.__v=null,(c||null!=o)&&(u.__e=e,u.__h=!!c,o[o.indexOf(e)]=null),l$1.__e(n,u,i);}}function z(n,u){l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function L(l,u,i,t,r,o,f,c){var s,a,v,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(r=!0),null!=o)for(;_<o.length;_++)if((s=o[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,o[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=r?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),o=null,c=!1;}if(null===d)y===p||c&&l.data===p||(l.data=p);else {if(o=o&&n.call(l.childNodes),a=(y=i.props||e$2).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=o)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(v||a)&&(v&&(a&&v.__html==a.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""));}if(C(l,p,y,r,c),v)u.__k=[];else if(_=u.props.children,w$1(l,Array.isArray(_)?_:[_],u,i,t,r&&"foreignObject"!==d,o,f,o?o[0]:i.__k&&k$1(i,0),c),null!=o)for(_=o.length;_--;)null!=o[_]&&h$1(o[_]);c||("value"in p&&void 0!==(_=p.value)&&(_!==y.value||_!==l.value||"progress"===d&&!_)&&H(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&H(l,"checked",_,y.checked,!1));}return l}function M(n,u,i){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,i);}}function N(n,u,i){var t,r;if(l$1.unmount&&l$1.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||M(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(n){l$1.__e(n,u);}t.base=t.__P=null;}if(t=n.__k)for(r=0;r<t.length;r++)t[r]&&N(t[r],u,"function"!=typeof n.type);i||null==n.__e||h$1(n.__e),n.__e=n.__d=void 0;}function O(n,l,u){return this.constructor(n,u)}function S(u,i,t){var r,o,f;l$1.__&&l$1.__(u,i),o=(r="function"==typeof t)?null:t&&t.__k||i.__k,f=[],j$1(i,u=(!r&&t||i).__k=v$1(d$1,null,[u]),o||e$2,e$2,void 0!==i.ownerSVGElement,!r&&t?[t]:o?null:i.firstChild?n.call(i.childNodes):null,f,!r&&t?t:o?o.__e:i.firstChild,r),z(f,u);}function D(n,l){var u={__c:l="__cC"+f$1++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(m$1);},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=c$1.slice,l$1={__e:function(n,l){for(var u,i,t;l=l.__;)if((u=l.__c)&&!u.__)try{if((i=u.constructor)&&null!=i.getDerivedStateFromError&&(u.setState(i.getDerivedStateFromError(n)),t=u.__d),null!=u.componentDidCatch&&(u.componentDidCatch(n),t=u.__d),t)return u.__E=u}catch(l){n=l;}throw n}},u$1=0,_.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=a$1({},this.state),"function"==typeof n&&(n=n(a$1({},u),this.props)),n&&a$1(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),m$1(this));},_.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),m$1(this));},_.prototype.render=d$1,t$1=[],r$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,g$1.__r=0,f$1=0;
|
|
155
|
-
|
|
156
|
-
var o$1=0;function e$1(_,e,n,t,f){var l,s,u={};for(s in e)"ref"==s?l=e[s]:u[s]=e[s];var a={type:_,props:u,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--o$1,__source:t,__self:f};if("function"==typeof _&&(l=_.defaultProps))for(s in l)void 0===u[s]&&(u[s]=l[s]);return l$1.vnode&&l$1.vnode(a),a}
|
|
157
|
-
|
|
158
|
-
function count$1(node) {
|
|
159
|
-
var sum = 0,
|
|
160
|
-
children = node.children,
|
|
161
|
-
i = children && children.length;
|
|
162
|
-
if (!i) sum = 1;
|
|
163
|
-
else while (--i >= 0) sum += children[i].value;
|
|
164
|
-
node.value = sum;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function node_count() {
|
|
168
|
-
return this.eachAfter(count$1);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function node_each(callback, that) {
|
|
172
|
-
let index = -1;
|
|
173
|
-
for (const node of this) {
|
|
174
|
-
callback.call(that, node, ++index, this);
|
|
175
|
-
}
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function node_eachBefore(callback, that) {
|
|
180
|
-
var node = this, nodes = [node], children, i, index = -1;
|
|
181
|
-
while (node = nodes.pop()) {
|
|
182
|
-
callback.call(that, node, ++index, this);
|
|
183
|
-
if (children = node.children) {
|
|
184
|
-
for (i = children.length - 1; i >= 0; --i) {
|
|
185
|
-
nodes.push(children[i]);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return this;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function node_eachAfter(callback, that) {
|
|
193
|
-
var node = this, nodes = [node], next = [], children, i, n, index = -1;
|
|
194
|
-
while (node = nodes.pop()) {
|
|
195
|
-
next.push(node);
|
|
196
|
-
if (children = node.children) {
|
|
197
|
-
for (i = 0, n = children.length; i < n; ++i) {
|
|
198
|
-
nodes.push(children[i]);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
while (node = next.pop()) {
|
|
203
|
-
callback.call(that, node, ++index, this);
|
|
204
|
-
}
|
|
205
|
-
return this;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function node_find(callback, that) {
|
|
209
|
-
let index = -1;
|
|
210
|
-
for (const node of this) {
|
|
211
|
-
if (callback.call(that, node, ++index, this)) {
|
|
212
|
-
return node;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function node_sum(value) {
|
|
218
|
-
return this.eachAfter(function(node) {
|
|
219
|
-
var sum = +value(node.data) || 0,
|
|
220
|
-
children = node.children,
|
|
221
|
-
i = children && children.length;
|
|
222
|
-
while (--i >= 0) sum += children[i].value;
|
|
223
|
-
node.value = sum;
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function node_sort(compare) {
|
|
228
|
-
return this.eachBefore(function(node) {
|
|
229
|
-
if (node.children) {
|
|
230
|
-
node.children.sort(compare);
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function node_path(end) {
|
|
236
|
-
var start = this,
|
|
237
|
-
ancestor = leastCommonAncestor(start, end),
|
|
238
|
-
nodes = [start];
|
|
239
|
-
while (start !== ancestor) {
|
|
240
|
-
start = start.parent;
|
|
241
|
-
nodes.push(start);
|
|
242
|
-
}
|
|
243
|
-
var k = nodes.length;
|
|
244
|
-
while (end !== ancestor) {
|
|
245
|
-
nodes.splice(k, 0, end);
|
|
246
|
-
end = end.parent;
|
|
247
|
-
}
|
|
248
|
-
return nodes;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function leastCommonAncestor(a, b) {
|
|
252
|
-
if (a === b) return a;
|
|
253
|
-
var aNodes = a.ancestors(),
|
|
254
|
-
bNodes = b.ancestors(),
|
|
255
|
-
c = null;
|
|
256
|
-
a = aNodes.pop();
|
|
257
|
-
b = bNodes.pop();
|
|
258
|
-
while (a === b) {
|
|
259
|
-
c = a;
|
|
260
|
-
a = aNodes.pop();
|
|
261
|
-
b = bNodes.pop();
|
|
262
|
-
}
|
|
263
|
-
return c;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function node_ancestors() {
|
|
267
|
-
var node = this, nodes = [node];
|
|
268
|
-
while (node = node.parent) {
|
|
269
|
-
nodes.push(node);
|
|
270
|
-
}
|
|
271
|
-
return nodes;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function node_descendants() {
|
|
275
|
-
return Array.from(this);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function node_leaves() {
|
|
279
|
-
var leaves = [];
|
|
280
|
-
this.eachBefore(function(node) {
|
|
281
|
-
if (!node.children) {
|
|
282
|
-
leaves.push(node);
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
return leaves;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function node_links() {
|
|
289
|
-
var root = this, links = [];
|
|
290
|
-
root.each(function(node) {
|
|
291
|
-
if (node !== root) { // Don’t include the root’s parent, if any.
|
|
292
|
-
links.push({source: node.parent, target: node});
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
return links;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function* node_iterator() {
|
|
299
|
-
var node = this, current, next = [node], children, i, n;
|
|
300
|
-
do {
|
|
301
|
-
current = next.reverse(), next = [];
|
|
302
|
-
while (node = current.pop()) {
|
|
303
|
-
yield node;
|
|
304
|
-
if (children = node.children) {
|
|
305
|
-
for (i = 0, n = children.length; i < n; ++i) {
|
|
306
|
-
next.push(children[i]);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
} while (next.length);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function hierarchy(data, children) {
|
|
314
|
-
if (data instanceof Map) {
|
|
315
|
-
data = [undefined, data];
|
|
316
|
-
if (children === undefined) children = mapChildren;
|
|
317
|
-
} else if (children === undefined) {
|
|
318
|
-
children = objectChildren;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
var root = new Node$1(data),
|
|
322
|
-
node,
|
|
323
|
-
nodes = [root],
|
|
324
|
-
child,
|
|
325
|
-
childs,
|
|
326
|
-
i,
|
|
327
|
-
n;
|
|
328
|
-
|
|
329
|
-
while (node = nodes.pop()) {
|
|
330
|
-
if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
|
|
331
|
-
node.children = childs;
|
|
332
|
-
for (i = n - 1; i >= 0; --i) {
|
|
333
|
-
nodes.push(child = childs[i] = new Node$1(childs[i]));
|
|
334
|
-
child.parent = node;
|
|
335
|
-
child.depth = node.depth + 1;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return root.eachBefore(computeHeight);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function node_copy() {
|
|
344
|
-
return hierarchy(this).eachBefore(copyData);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function objectChildren(d) {
|
|
348
|
-
return d.children;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function mapChildren(d) {
|
|
352
|
-
return Array.isArray(d) ? d[1] : null;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function copyData(node) {
|
|
356
|
-
if (node.data.value !== undefined) node.value = node.data.value;
|
|
357
|
-
node.data = node.data.data;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function computeHeight(node) {
|
|
361
|
-
var height = 0;
|
|
362
|
-
do node.height = height;
|
|
363
|
-
while ((node = node.parent) && (node.height < ++height));
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
function Node$1(data) {
|
|
367
|
-
this.data = data;
|
|
368
|
-
this.depth =
|
|
369
|
-
this.height = 0;
|
|
370
|
-
this.parent = null;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
Node$1.prototype = hierarchy.prototype = {
|
|
374
|
-
constructor: Node$1,
|
|
375
|
-
count: node_count,
|
|
376
|
-
each: node_each,
|
|
377
|
-
eachAfter: node_eachAfter,
|
|
378
|
-
eachBefore: node_eachBefore,
|
|
379
|
-
find: node_find,
|
|
380
|
-
sum: node_sum,
|
|
381
|
-
sort: node_sort,
|
|
382
|
-
path: node_path,
|
|
383
|
-
ancestors: node_ancestors,
|
|
384
|
-
descendants: node_descendants,
|
|
385
|
-
leaves: node_leaves,
|
|
386
|
-
links: node_links,
|
|
387
|
-
copy: node_copy,
|
|
388
|
-
[Symbol.iterator]: node_iterator
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
function required(f) {
|
|
392
|
-
if (typeof f !== "function") throw new Error;
|
|
393
|
-
return f;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function constantZero() {
|
|
397
|
-
return 0;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function constant$1(x) {
|
|
401
|
-
return function() {
|
|
402
|
-
return x;
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function roundNode(node) {
|
|
407
|
-
node.x0 = Math.round(node.x0);
|
|
408
|
-
node.y0 = Math.round(node.y0);
|
|
409
|
-
node.x1 = Math.round(node.x1);
|
|
410
|
-
node.y1 = Math.round(node.y1);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function treemapDice(parent, x0, y0, x1, y1) {
|
|
414
|
-
var nodes = parent.children,
|
|
415
|
-
node,
|
|
416
|
-
i = -1,
|
|
417
|
-
n = nodes.length,
|
|
418
|
-
k = parent.value && (x1 - x0) / parent.value;
|
|
419
|
-
|
|
420
|
-
while (++i < n) {
|
|
421
|
-
node = nodes[i], node.y0 = y0, node.y1 = y1;
|
|
422
|
-
node.x0 = x0, node.x1 = x0 += node.value * k;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function treemapSlice(parent, x0, y0, x1, y1) {
|
|
427
|
-
var nodes = parent.children,
|
|
428
|
-
node,
|
|
429
|
-
i = -1,
|
|
430
|
-
n = nodes.length,
|
|
431
|
-
k = parent.value && (y1 - y0) / parent.value;
|
|
432
|
-
|
|
433
|
-
while (++i < n) {
|
|
434
|
-
node = nodes[i], node.x0 = x0, node.x1 = x1;
|
|
435
|
-
node.y0 = y0, node.y1 = y0 += node.value * k;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
var phi = (1 + Math.sqrt(5)) / 2;
|
|
440
|
-
|
|
441
|
-
function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
|
|
442
|
-
var rows = [],
|
|
443
|
-
nodes = parent.children,
|
|
444
|
-
row,
|
|
445
|
-
nodeValue,
|
|
446
|
-
i0 = 0,
|
|
447
|
-
i1 = 0,
|
|
448
|
-
n = nodes.length,
|
|
449
|
-
dx, dy,
|
|
450
|
-
value = parent.value,
|
|
451
|
-
sumValue,
|
|
452
|
-
minValue,
|
|
453
|
-
maxValue,
|
|
454
|
-
newRatio,
|
|
455
|
-
minRatio,
|
|
456
|
-
alpha,
|
|
457
|
-
beta;
|
|
458
|
-
|
|
459
|
-
while (i0 < n) {
|
|
460
|
-
dx = x1 - x0, dy = y1 - y0;
|
|
461
|
-
|
|
462
|
-
// Find the next non-empty node.
|
|
463
|
-
do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
|
|
464
|
-
minValue = maxValue = sumValue;
|
|
465
|
-
alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
|
|
466
|
-
beta = sumValue * sumValue * alpha;
|
|
467
|
-
minRatio = Math.max(maxValue / beta, beta / minValue);
|
|
468
|
-
|
|
469
|
-
// Keep adding nodes while the aspect ratio maintains or improves.
|
|
470
|
-
for (; i1 < n; ++i1) {
|
|
471
|
-
sumValue += nodeValue = nodes[i1].value;
|
|
472
|
-
if (nodeValue < minValue) minValue = nodeValue;
|
|
473
|
-
if (nodeValue > maxValue) maxValue = nodeValue;
|
|
474
|
-
beta = sumValue * sumValue * alpha;
|
|
475
|
-
newRatio = Math.max(maxValue / beta, beta / minValue);
|
|
476
|
-
if (newRatio > minRatio) { sumValue -= nodeValue; break; }
|
|
477
|
-
minRatio = newRatio;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// Position and record the row orientation.
|
|
481
|
-
rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
|
|
482
|
-
if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
|
|
483
|
-
else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
|
|
484
|
-
value -= sumValue, i0 = i1;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
return rows;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
var squarify = (function custom(ratio) {
|
|
491
|
-
|
|
492
|
-
function squarify(parent, x0, y0, x1, y1) {
|
|
493
|
-
squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
squarify.ratio = function(x) {
|
|
497
|
-
return custom((x = +x) > 1 ? x : 1);
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
return squarify;
|
|
501
|
-
})(phi);
|
|
502
|
-
|
|
503
|
-
function treemap() {
|
|
504
|
-
var tile = squarify,
|
|
505
|
-
round = false,
|
|
506
|
-
dx = 1,
|
|
507
|
-
dy = 1,
|
|
508
|
-
paddingStack = [0],
|
|
509
|
-
paddingInner = constantZero,
|
|
510
|
-
paddingTop = constantZero,
|
|
511
|
-
paddingRight = constantZero,
|
|
512
|
-
paddingBottom = constantZero,
|
|
513
|
-
paddingLeft = constantZero;
|
|
514
|
-
|
|
515
|
-
function treemap(root) {
|
|
516
|
-
root.x0 =
|
|
517
|
-
root.y0 = 0;
|
|
518
|
-
root.x1 = dx;
|
|
519
|
-
root.y1 = dy;
|
|
520
|
-
root.eachBefore(positionNode);
|
|
521
|
-
paddingStack = [0];
|
|
522
|
-
if (round) root.eachBefore(roundNode);
|
|
523
|
-
return root;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
function positionNode(node) {
|
|
527
|
-
var p = paddingStack[node.depth],
|
|
528
|
-
x0 = node.x0 + p,
|
|
529
|
-
y0 = node.y0 + p,
|
|
530
|
-
x1 = node.x1 - p,
|
|
531
|
-
y1 = node.y1 - p;
|
|
532
|
-
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
533
|
-
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
534
|
-
node.x0 = x0;
|
|
535
|
-
node.y0 = y0;
|
|
536
|
-
node.x1 = x1;
|
|
537
|
-
node.y1 = y1;
|
|
538
|
-
if (node.children) {
|
|
539
|
-
p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
|
|
540
|
-
x0 += paddingLeft(node) - p;
|
|
541
|
-
y0 += paddingTop(node) - p;
|
|
542
|
-
x1 -= paddingRight(node) - p;
|
|
543
|
-
y1 -= paddingBottom(node) - p;
|
|
544
|
-
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
545
|
-
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
546
|
-
tile(node, x0, y0, x1, y1);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
treemap.round = function(x) {
|
|
551
|
-
return arguments.length ? (round = !!x, treemap) : round;
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
treemap.size = function(x) {
|
|
555
|
-
return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
treemap.tile = function(x) {
|
|
559
|
-
return arguments.length ? (tile = required(x), treemap) : tile;
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
treemap.padding = function(x) {
|
|
563
|
-
return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
treemap.paddingInner = function(x) {
|
|
567
|
-
return arguments.length ? (paddingInner = typeof x === "function" ? x : constant$1(+x), treemap) : paddingInner;
|
|
568
|
-
};
|
|
569
|
-
|
|
570
|
-
treemap.paddingOuter = function(x) {
|
|
571
|
-
return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
treemap.paddingTop = function(x) {
|
|
575
|
-
return arguments.length ? (paddingTop = typeof x === "function" ? x : constant$1(+x), treemap) : paddingTop;
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
treemap.paddingRight = function(x) {
|
|
579
|
-
return arguments.length ? (paddingRight = typeof x === "function" ? x : constant$1(+x), treemap) : paddingRight;
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
treemap.paddingBottom = function(x) {
|
|
583
|
-
return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant$1(+x), treemap) : paddingBottom;
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
treemap.paddingLeft = function(x) {
|
|
587
|
-
return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant$1(+x), treemap) : paddingLeft;
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
return treemap;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
var treemapResquarify = (function custom(ratio) {
|
|
594
|
-
|
|
595
|
-
function resquarify(parent, x0, y0, x1, y1) {
|
|
596
|
-
if ((rows = parent._squarify) && (rows.ratio === ratio)) {
|
|
597
|
-
var rows,
|
|
598
|
-
row,
|
|
599
|
-
nodes,
|
|
600
|
-
i,
|
|
601
|
-
j = -1,
|
|
602
|
-
n,
|
|
603
|
-
m = rows.length,
|
|
604
|
-
value = parent.value;
|
|
605
|
-
|
|
606
|
-
while (++j < m) {
|
|
607
|
-
row = rows[j], nodes = row.children;
|
|
608
|
-
for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
|
|
609
|
-
if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += (y1 - y0) * row.value / value : y1);
|
|
610
|
-
else treemapSlice(row, x0, y0, value ? x0 += (x1 - x0) * row.value / value : x1, y1);
|
|
611
|
-
value -= row.value;
|
|
612
|
-
}
|
|
613
|
-
} else {
|
|
614
|
-
parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
|
615
|
-
rows.ratio = ratio;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
resquarify.ratio = function(x) {
|
|
620
|
-
return custom((x = +x) > 1 ? x : 1);
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
return resquarify;
|
|
624
|
-
})(phi);
|
|
625
|
-
|
|
626
|
-
const isModuleTree = (mod) => "children" in mod;
|
|
627
|
-
|
|
628
|
-
let count = 0;
|
|
629
|
-
class Id {
|
|
630
|
-
constructor(id) {
|
|
631
|
-
this._id = id;
|
|
632
|
-
const url = new URL(window.location.href);
|
|
633
|
-
url.hash = id;
|
|
634
|
-
this._href = url.toString();
|
|
635
|
-
}
|
|
636
|
-
get id() {
|
|
637
|
-
return this._id;
|
|
638
|
-
}
|
|
639
|
-
get href() {
|
|
640
|
-
return this._href;
|
|
641
|
-
}
|
|
642
|
-
toString() {
|
|
643
|
-
return `url(${this.href})`;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
function generateUniqueId(name) {
|
|
647
|
-
count += 1;
|
|
648
|
-
const id = ["O", name, count].filter(Boolean).join("-");
|
|
649
|
-
return new Id(id);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
const LABELS = {
|
|
653
|
-
renderedLength: "Rendered",
|
|
654
|
-
gzipLength: "Gzip",
|
|
655
|
-
brotliLength: "Brotli",
|
|
656
|
-
};
|
|
657
|
-
const getAvailableSizeOptions = (options) => {
|
|
658
|
-
const availableSizeProperties = ["renderedLength"];
|
|
659
|
-
if (options.gzip) {
|
|
660
|
-
availableSizeProperties.push("gzipLength");
|
|
661
|
-
}
|
|
662
|
-
if (options.brotli) {
|
|
663
|
-
availableSizeProperties.push("brotliLength");
|
|
664
|
-
}
|
|
665
|
-
return availableSizeProperties;
|
|
666
|
-
};
|
|
667
|
-
|
|
668
|
-
var t,u,r,o=0,i=[],c=l$1.__b,f=l$1.__r,e=l$1.diffed,a=l$1.__c,v=l$1.unmount;function m(t,r){l$1.__h&&l$1.__h(u,t,o||r),o=0;var i=u.__H||(u.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function l(n){return o=1,p(w,n)}function p(n,r,o){var i=m(t++,2);return i.t=n,i.__c||(i.__=[o?o(r):w(void 0,r),function(n){var t=i.t(i.__[0],n);i.__[0]!==t&&(i.__=[t,i.__[1]],i.__c.setState({}));}],i.__c=u),i.__}function y(r,o){var i=m(t++,3);!l$1.__s&&k(i.__H,o)&&(i.__=r,i.__H=o,u.__H.__h.push(i));}function h(r,o){var i=m(t++,4);!l$1.__s&&k(i.__H,o)&&(i.__=r,i.__H=o,u.__h.push(i));}function s(n){return o=5,d(function(){return {current:n}},[])}function d(n,u){var r=m(t++,7);return k(r.__H,u)&&(r.__=n(),r.__H=u,r.__h=n),r.__}function F(n){var r=u.context[n.__c],o=m(t++,9);return o.c=n,r?(null==o.__&&(o.__=!0,r.sub(u)),r.props.value):n.__}function x(){var t;for(i.sort(function(n,t){return n.__v.__b-t.__v.__b});t=i.pop();)if(t.__P)try{t.__H.__h.forEach(g),t.__H.__h.forEach(j),t.__H.__h=[];}catch(u){t.__H.__h=[],l$1.__e(u,t.__v);}}l$1.__b=function(n){u=null,c&&c(n);},l$1.__r=function(n){f&&f(n),t=0;var r=(u=n.__c).__H;r&&(r.__h.forEach(g),r.__h.forEach(j),r.__h=[]);},l$1.diffed=function(t){e&&e(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i.push(o)&&r===l$1.requestAnimationFrame||((r=l$1.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b&&(t=requestAnimationFrame(u));})(x)),u=null;},l$1.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g),t.__h=t.__h.filter(function(n){return !n.__||j(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],l$1.__e(r,t.__v);}}),a&&a(t,u);},l$1.unmount=function(t){v&&v(t);var u,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{g(n);}catch(n){u=n;}}),u&&l$1.__e(u,r.__v));};var b="function"==typeof requestAnimationFrame;function g(n){var t=u,r=n.__c;"function"==typeof r&&(n.__c=void 0,r()),u=t;}function j(n){var t=u;n.__c=n.__(),u=t;}function k(n,t){return !n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function w(n,t){return "function"==typeof t?t(n):t}
|
|
669
|
-
|
|
670
|
-
const SideBar = ({ availableSizeProperties, sizeProperty, setSizeProperty, onExcludeChange, onIncludeChange, }) => {
|
|
671
|
-
const [includeValue, setIncludeValue] = l("");
|
|
672
|
-
const [excludeValue, setExcludeValue] = l("");
|
|
673
|
-
const handleSizePropertyChange = (sizeProp) => () => {
|
|
674
|
-
if (sizeProp !== sizeProperty) {
|
|
675
|
-
setSizeProperty(sizeProp);
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
const handleIncludeChange = (event) => {
|
|
679
|
-
const value = event.currentTarget.value;
|
|
680
|
-
setIncludeValue(value);
|
|
681
|
-
onIncludeChange(value);
|
|
682
|
-
};
|
|
683
|
-
const handleExcludeChange = (event) => {
|
|
684
|
-
const value = event.currentTarget.value;
|
|
685
|
-
setExcludeValue(value);
|
|
686
|
-
onExcludeChange(value);
|
|
687
|
-
};
|
|
688
|
-
return (e$1("aside", Object.assign({ className: "sidebar" }, { children: [e$1("div", Object.assign({ className: "size-selectors" }, { children: availableSizeProperties.length > 1 &&
|
|
689
|
-
availableSizeProperties.map((sizeProp) => {
|
|
690
|
-
const id = `selector-${sizeProp}`;
|
|
691
|
-
return (e$1("div", Object.assign({ className: "size-selector" }, { children: [e$1("input", { type: "radio", id: id, checked: sizeProp === sizeProperty, onChange: handleSizePropertyChange(sizeProp) }, void 0), e$1("label", Object.assign({ htmlFor: id }, { children: LABELS[sizeProp] }), void 0)] }), sizeProp));
|
|
692
|
-
}) }), void 0), e$1("div", Object.assign({ className: "module-filters" }, { children: [e$1("div", Object.assign({ className: "module-filter" }, { children: [e$1("label", Object.assign({ htmlFor: "module-filter-exclude" }, { children: "Exclude" }), void 0), e$1("input", { type: "text", id: "module-filter-exclude", value: excludeValue, onInput: handleExcludeChange }, void 0)] }), void 0), e$1("div", Object.assign({ className: "module-filter" }, { children: [e$1("label", Object.assign({ htmlFor: "module-filter-include" }, { children: "Include" }), void 0), e$1("input", { type: "text", id: "module-filter-include", value: includeValue, onInput: handleIncludeChange }, void 0)] }), void 0)] }), void 0)] }), void 0));
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
const throttleFilter = (callback, limit) => {
|
|
696
|
-
let waiting = false;
|
|
697
|
-
return (val) => {
|
|
698
|
-
if (!waiting) {
|
|
699
|
-
callback(val);
|
|
700
|
-
waiting = true;
|
|
701
|
-
setTimeout(() => {
|
|
702
|
-
waiting = false;
|
|
703
|
-
}, limit);
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
};
|
|
707
|
-
const useFilter = () => {
|
|
708
|
-
const [includeFilter, setIncludeFilter] = l("");
|
|
709
|
-
const [excludeFilter, setExcludeFilter] = l("");
|
|
710
|
-
const setIncludeFilterTrottled = d(() => throttleFilter(setIncludeFilter, 200), []);
|
|
711
|
-
const setExcludeFilterTrottled = d(() => throttleFilter(setExcludeFilter, 200), []);
|
|
712
|
-
const isModuleIncluded = d(() => {
|
|
713
|
-
if (includeFilter === "") {
|
|
714
|
-
return () => true;
|
|
715
|
-
}
|
|
716
|
-
try {
|
|
717
|
-
const re = new RegExp(includeFilter);
|
|
718
|
-
return ({ id }) => re.test(id);
|
|
719
|
-
}
|
|
720
|
-
catch (err) {
|
|
721
|
-
return () => false;
|
|
722
|
-
}
|
|
723
|
-
}, [includeFilter]);
|
|
724
|
-
const isModuleExcluded = d(() => {
|
|
725
|
-
if (excludeFilter === "") {
|
|
726
|
-
return () => false;
|
|
727
|
-
}
|
|
728
|
-
try {
|
|
729
|
-
const re = new RegExp(excludeFilter);
|
|
730
|
-
return ({ id }) => re.test(id);
|
|
731
|
-
}
|
|
732
|
-
catch (err) {
|
|
733
|
-
return () => false;
|
|
734
|
-
}
|
|
735
|
-
}, [excludeFilter]);
|
|
736
|
-
const isDefaultInclude = includeFilter === "";
|
|
737
|
-
const getModuleFilterMultiplier = d(() => {
|
|
738
|
-
return (data) => {
|
|
739
|
-
if (isDefaultInclude) {
|
|
740
|
-
return isModuleExcluded(data) ? 0 : 1;
|
|
741
|
-
}
|
|
742
|
-
return isModuleExcluded(data) && !isModuleIncluded(data) ? 0 : 1;
|
|
743
|
-
};
|
|
744
|
-
}, [isDefaultInclude, isModuleExcluded, isModuleIncluded]);
|
|
745
|
-
return {
|
|
746
|
-
getModuleFilterMultiplier,
|
|
747
|
-
includeFilter,
|
|
748
|
-
excludeFilter,
|
|
749
|
-
setExcludeFilter: setExcludeFilterTrottled,
|
|
750
|
-
setIncludeFilter: setIncludeFilterTrottled,
|
|
751
|
-
};
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
function ascending(a, b) {
|
|
755
|
-
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
function bisector(f) {
|
|
759
|
-
let delta = f;
|
|
760
|
-
let compare1 = f;
|
|
761
|
-
let compare2 = f;
|
|
762
|
-
|
|
763
|
-
if (f.length !== 2) {
|
|
764
|
-
delta = (d, x) => f(d) - x;
|
|
765
|
-
compare1 = ascending;
|
|
766
|
-
compare2 = (d, x) => ascending(f(d), x);
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
function left(a, x, lo = 0, hi = a.length) {
|
|
770
|
-
if (lo < hi) {
|
|
771
|
-
if (compare1(x, x) !== 0) return hi;
|
|
772
|
-
do {
|
|
773
|
-
const mid = (lo + hi) >>> 1;
|
|
774
|
-
if (compare2(a[mid], x) < 0) lo = mid + 1;
|
|
775
|
-
else hi = mid;
|
|
776
|
-
} while (lo < hi);
|
|
777
|
-
}
|
|
778
|
-
return lo;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
function right(a, x, lo = 0, hi = a.length) {
|
|
782
|
-
if (lo < hi) {
|
|
783
|
-
if (compare1(x, x) !== 0) return hi;
|
|
784
|
-
do {
|
|
785
|
-
const mid = (lo + hi) >>> 1;
|
|
786
|
-
if (compare2(a[mid], x) <= 0) lo = mid + 1;
|
|
787
|
-
else hi = mid;
|
|
788
|
-
} while (lo < hi);
|
|
789
|
-
}
|
|
790
|
-
return lo;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
function center(a, x, lo = 0, hi = a.length) {
|
|
794
|
-
const i = left(a, x, lo, hi - 1);
|
|
795
|
-
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
return {left, center, right};
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
function number$1(x) {
|
|
802
|
-
return x === null ? NaN : +x;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
const ascendingBisect = bisector(ascending);
|
|
806
|
-
const bisectRight = ascendingBisect.right;
|
|
807
|
-
bisector(number$1).center;
|
|
808
|
-
var bisect = bisectRight;
|
|
809
|
-
|
|
810
|
-
class InternMap extends Map {
|
|
811
|
-
constructor(entries, key = keyof) {
|
|
812
|
-
super();
|
|
813
|
-
Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
|
|
814
|
-
if (entries != null) for (const [key, value] of entries) this.set(key, value);
|
|
815
|
-
}
|
|
816
|
-
get(key) {
|
|
817
|
-
return super.get(intern_get(this, key));
|
|
818
|
-
}
|
|
819
|
-
has(key) {
|
|
820
|
-
return super.has(intern_get(this, key));
|
|
821
|
-
}
|
|
822
|
-
set(key, value) {
|
|
823
|
-
return super.set(intern_set(this, key), value);
|
|
824
|
-
}
|
|
825
|
-
delete(key) {
|
|
826
|
-
return super.delete(intern_delete(this, key));
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
function intern_get({_intern, _key}, value) {
|
|
831
|
-
const key = _key(value);
|
|
832
|
-
return _intern.has(key) ? _intern.get(key) : value;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
function intern_set({_intern, _key}, value) {
|
|
836
|
-
const key = _key(value);
|
|
837
|
-
if (_intern.has(key)) return _intern.get(key);
|
|
838
|
-
_intern.set(key, value);
|
|
839
|
-
return value;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
function intern_delete({_intern, _key}, value) {
|
|
843
|
-
const key = _key(value);
|
|
844
|
-
if (_intern.has(key)) {
|
|
845
|
-
value = _intern.get(key);
|
|
846
|
-
_intern.delete(key);
|
|
847
|
-
}
|
|
848
|
-
return value;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
function keyof(value) {
|
|
852
|
-
return value !== null && typeof value === "object" ? value.valueOf() : value;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
function identity$2(x) {
|
|
856
|
-
return x;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
function group(values, ...keys) {
|
|
860
|
-
return nest(values, identity$2, identity$2, keys);
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
function nest(values, map, reduce, keys) {
|
|
864
|
-
return (function regroup(values, i) {
|
|
865
|
-
if (i >= keys.length) return reduce(values);
|
|
866
|
-
const groups = new InternMap();
|
|
867
|
-
const keyof = keys[i++];
|
|
868
|
-
let index = -1;
|
|
869
|
-
for (const value of values) {
|
|
870
|
-
const key = keyof(value, ++index, values);
|
|
871
|
-
const group = groups.get(key);
|
|
872
|
-
if (group) group.push(value);
|
|
873
|
-
else groups.set(key, [value]);
|
|
874
|
-
}
|
|
875
|
-
for (const [key, values] of groups) {
|
|
876
|
-
groups.set(key, regroup(values, i));
|
|
877
|
-
}
|
|
878
|
-
return map(groups);
|
|
879
|
-
})(values, 0);
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
var e10 = Math.sqrt(50),
|
|
883
|
-
e5 = Math.sqrt(10),
|
|
884
|
-
e2 = Math.sqrt(2);
|
|
885
|
-
|
|
886
|
-
function ticks(start, stop, count) {
|
|
887
|
-
var reverse,
|
|
888
|
-
i = -1,
|
|
889
|
-
n,
|
|
890
|
-
ticks,
|
|
891
|
-
step;
|
|
892
|
-
|
|
893
|
-
stop = +stop, start = +start, count = +count;
|
|
894
|
-
if (start === stop && count > 0) return [start];
|
|
895
|
-
if (reverse = stop < start) n = start, start = stop, stop = n;
|
|
896
|
-
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
|
|
897
|
-
|
|
898
|
-
if (step > 0) {
|
|
899
|
-
let r0 = Math.round(start / step), r1 = Math.round(stop / step);
|
|
900
|
-
if (r0 * step < start) ++r0;
|
|
901
|
-
if (r1 * step > stop) --r1;
|
|
902
|
-
ticks = new Array(n = r1 - r0 + 1);
|
|
903
|
-
while (++i < n) ticks[i] = (r0 + i) * step;
|
|
904
|
-
} else {
|
|
905
|
-
step = -step;
|
|
906
|
-
let r0 = Math.round(start * step), r1 = Math.round(stop * step);
|
|
907
|
-
if (r0 / step < start) ++r0;
|
|
908
|
-
if (r1 / step > stop) --r1;
|
|
909
|
-
ticks = new Array(n = r1 - r0 + 1);
|
|
910
|
-
while (++i < n) ticks[i] = (r0 + i) / step;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
if (reverse) ticks.reverse();
|
|
914
|
-
|
|
915
|
-
return ticks;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
function tickIncrement(start, stop, count) {
|
|
919
|
-
var step = (stop - start) / Math.max(0, count),
|
|
920
|
-
power = Math.floor(Math.log(step) / Math.LN10),
|
|
921
|
-
error = step / Math.pow(10, power);
|
|
922
|
-
return power >= 0
|
|
923
|
-
? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
|
|
924
|
-
: -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
function tickStep(start, stop, count) {
|
|
928
|
-
var step0 = Math.abs(stop - start) / Math.max(0, count),
|
|
929
|
-
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
|
|
930
|
-
error = step0 / step1;
|
|
931
|
-
if (error >= e10) step1 *= 10;
|
|
932
|
-
else if (error >= e5) step1 *= 5;
|
|
933
|
-
else if (error >= e2) step1 *= 2;
|
|
934
|
-
return stop < start ? -step1 : step1;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
const TOP_PADDING = 20;
|
|
938
|
-
const PADDING = 2;
|
|
939
|
-
|
|
940
|
-
const Node = ({ node, onMouseOver, onClick, selected }) => {
|
|
941
|
-
const { getModuleColor } = F(StaticContext);
|
|
942
|
-
const { backgroundColor, fontColor } = getModuleColor(node);
|
|
943
|
-
const { x0, x1, y1, y0, data, children = null } = node;
|
|
944
|
-
const textRef = s(null);
|
|
945
|
-
const textRectRef = s();
|
|
946
|
-
const width = x1 - x0;
|
|
947
|
-
const height = y1 - y0;
|
|
948
|
-
const textProps = {
|
|
949
|
-
"font-size": "0.7em",
|
|
950
|
-
"dominant-baseline": "middle",
|
|
951
|
-
"text-anchor": "middle",
|
|
952
|
-
x: width / 2,
|
|
953
|
-
};
|
|
954
|
-
if (children != null) {
|
|
955
|
-
textProps.y = (TOP_PADDING + PADDING) / 2;
|
|
956
|
-
}
|
|
957
|
-
else {
|
|
958
|
-
textProps.y = height / 2;
|
|
959
|
-
}
|
|
960
|
-
h(() => {
|
|
961
|
-
if (width == 0 || height == 0 || !textRef.current) {
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
|
-
if (textRectRef.current == null) {
|
|
965
|
-
textRectRef.current = textRef.current.getBoundingClientRect();
|
|
966
|
-
}
|
|
967
|
-
let scale = 1;
|
|
968
|
-
if (children != null) {
|
|
969
|
-
scale = Math.min((width * 0.9) / textRectRef.current.width, Math.min(height, TOP_PADDING + PADDING) / textRectRef.current.height);
|
|
970
|
-
scale = Math.min(1, scale);
|
|
971
|
-
textRef.current.setAttribute("y", String(Math.min(TOP_PADDING + PADDING, height) / 2 / scale));
|
|
972
|
-
textRef.current.setAttribute("x", String(width / 2 / scale));
|
|
973
|
-
}
|
|
974
|
-
else {
|
|
975
|
-
scale = Math.min((width * 0.9) / textRectRef.current.width, (height * 0.9) / textRectRef.current.height);
|
|
976
|
-
scale = Math.min(1, scale);
|
|
977
|
-
textRef.current.setAttribute("y", String(height / 2 / scale));
|
|
978
|
-
textRef.current.setAttribute("x", String(width / 2 / scale));
|
|
979
|
-
}
|
|
980
|
-
textRef.current.setAttribute("transform", `scale(${scale.toFixed(2)})`);
|
|
981
|
-
}, [children, height, width]);
|
|
982
|
-
if (width == 0 || height == 0) {
|
|
983
|
-
return null;
|
|
984
|
-
}
|
|
985
|
-
return (e$1("g", Object.assign({ className: "node", transform: `translate(${x0},${y0})`, onClick: (event) => {
|
|
986
|
-
event.stopPropagation();
|
|
987
|
-
onClick(node);
|
|
988
|
-
}, onMouseOver: (event) => {
|
|
989
|
-
event.stopPropagation();
|
|
990
|
-
onMouseOver(node);
|
|
991
|
-
} }, { children: [e$1("rect", { fill: backgroundColor, rx: 2, ry: 2, width: x1 - x0, height: y1 - y0, stroke: selected ? "#fff" : undefined, "stroke-width": selected ? 2 : undefined }, void 0), e$1("text", Object.assign({ ref: textRef, fill: fontColor, onClick: (event) => {
|
|
992
|
-
var _a;
|
|
993
|
-
if (((_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString()) !== "") {
|
|
994
|
-
event.stopPropagation();
|
|
995
|
-
}
|
|
996
|
-
} }, textProps, { children: data.name }), void 0)] }), void 0));
|
|
997
|
-
};
|
|
998
|
-
|
|
999
|
-
const TreeMap = ({ root, onNodeHover, selectedNode, onNodeClick }) => {
|
|
1000
|
-
const { width, height, getModuleIds } = F(StaticContext);
|
|
1001
|
-
console.time("layering");
|
|
1002
|
-
// this will make groups by height
|
|
1003
|
-
const nestedData = d(() => {
|
|
1004
|
-
const nestedDataMap = group(root.descendants(), (d) => d.height);
|
|
1005
|
-
const nestedData = Array.from(nestedDataMap, ([key, values]) => ({
|
|
1006
|
-
key,
|
|
1007
|
-
values,
|
|
1008
|
-
}));
|
|
1009
|
-
nestedData.sort((a, b) => b.key - a.key);
|
|
1010
|
-
return nestedData;
|
|
1011
|
-
}, [root]);
|
|
1012
|
-
console.timeEnd("layering");
|
|
1013
|
-
return (e$1("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${width} ${height}` }, { children: nestedData.map(({ key, values }) => {
|
|
1014
|
-
return (e$1("g", Object.assign({ className: "layer" }, { children: values.map((node) => {
|
|
1015
|
-
return (e$1(Node, { node: node, onMouseOver: onNodeHover, selected: selectedNode === node, onClick: onNodeClick }, getModuleIds(node.data).nodeUid.id));
|
|
1016
|
-
}) }), key));
|
|
1017
|
-
}) }), void 0));
|
|
1018
|
-
};
|
|
1019
|
-
|
|
1020
|
-
var bytes$1 = {exports: {}};
|
|
1021
|
-
|
|
1022
|
-
/*!
|
|
1023
|
-
* bytes
|
|
1024
|
-
* Copyright(c) 2012-2014 TJ Holowaychuk
|
|
1025
|
-
* Copyright(c) 2015 Jed Watson
|
|
1026
|
-
* MIT Licensed
|
|
1027
|
-
*/
|
|
1028
|
-
|
|
1029
|
-
/**
|
|
1030
|
-
* Module exports.
|
|
1031
|
-
* @public
|
|
1032
|
-
*/
|
|
1033
|
-
|
|
1034
|
-
bytes$1.exports = bytes;
|
|
1035
|
-
var format_1 = bytes$1.exports.format = format$1;
|
|
1036
|
-
bytes$1.exports.parse = parse;
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Module variables.
|
|
1040
|
-
* @private
|
|
1041
|
-
*/
|
|
1042
|
-
|
|
1043
|
-
var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
|
|
1044
|
-
|
|
1045
|
-
var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
|
|
1046
|
-
|
|
1047
|
-
var map$1 = {
|
|
1048
|
-
b: 1,
|
|
1049
|
-
kb: 1 << 10,
|
|
1050
|
-
mb: 1 << 20,
|
|
1051
|
-
gb: 1 << 30,
|
|
1052
|
-
tb: Math.pow(1024, 4),
|
|
1053
|
-
pb: Math.pow(1024, 5),
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
|
|
1057
|
-
|
|
1058
|
-
/**
|
|
1059
|
-
* Convert the given value in bytes into a string or parse to string to an integer in bytes.
|
|
1060
|
-
*
|
|
1061
|
-
* @param {string|number} value
|
|
1062
|
-
* @param {{
|
|
1063
|
-
* case: [string],
|
|
1064
|
-
* decimalPlaces: [number]
|
|
1065
|
-
* fixedDecimals: [boolean]
|
|
1066
|
-
* thousandsSeparator: [string]
|
|
1067
|
-
* unitSeparator: [string]
|
|
1068
|
-
* }} [options] bytes options.
|
|
1069
|
-
*
|
|
1070
|
-
* @returns {string|number|null}
|
|
1071
|
-
*/
|
|
1072
|
-
|
|
1073
|
-
function bytes(value, options) {
|
|
1074
|
-
if (typeof value === 'string') {
|
|
1075
|
-
return parse(value);
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
if (typeof value === 'number') {
|
|
1079
|
-
return format$1(value, options);
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
return null;
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
/**
|
|
1086
|
-
* Format the given value in bytes into a string.
|
|
1087
|
-
*
|
|
1088
|
-
* If the value is negative, it is kept as such. If it is a float,
|
|
1089
|
-
* it is rounded.
|
|
1090
|
-
*
|
|
1091
|
-
* @param {number} value
|
|
1092
|
-
* @param {object} [options]
|
|
1093
|
-
* @param {number} [options.decimalPlaces=2]
|
|
1094
|
-
* @param {number} [options.fixedDecimals=false]
|
|
1095
|
-
* @param {string} [options.thousandsSeparator=]
|
|
1096
|
-
* @param {string} [options.unit=]
|
|
1097
|
-
* @param {string} [options.unitSeparator=]
|
|
1098
|
-
*
|
|
1099
|
-
* @returns {string|null}
|
|
1100
|
-
* @public
|
|
1101
|
-
*/
|
|
1102
|
-
|
|
1103
|
-
function format$1(value, options) {
|
|
1104
|
-
if (!Number.isFinite(value)) {
|
|
1105
|
-
return null;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
var mag = Math.abs(value);
|
|
1109
|
-
var thousandsSeparator = (options && options.thousandsSeparator) || '';
|
|
1110
|
-
var unitSeparator = (options && options.unitSeparator) || '';
|
|
1111
|
-
var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
|
|
1112
|
-
var fixedDecimals = Boolean(options && options.fixedDecimals);
|
|
1113
|
-
var unit = (options && options.unit) || '';
|
|
1114
|
-
|
|
1115
|
-
if (!unit || !map$1[unit.toLowerCase()]) {
|
|
1116
|
-
if (mag >= map$1.pb) {
|
|
1117
|
-
unit = 'PB';
|
|
1118
|
-
} else if (mag >= map$1.tb) {
|
|
1119
|
-
unit = 'TB';
|
|
1120
|
-
} else if (mag >= map$1.gb) {
|
|
1121
|
-
unit = 'GB';
|
|
1122
|
-
} else if (mag >= map$1.mb) {
|
|
1123
|
-
unit = 'MB';
|
|
1124
|
-
} else if (mag >= map$1.kb) {
|
|
1125
|
-
unit = 'KB';
|
|
1126
|
-
} else {
|
|
1127
|
-
unit = 'B';
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
var val = value / map$1[unit.toLowerCase()];
|
|
1132
|
-
var str = val.toFixed(decimalPlaces);
|
|
1133
|
-
|
|
1134
|
-
if (!fixedDecimals) {
|
|
1135
|
-
str = str.replace(formatDecimalsRegExp, '$1');
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
if (thousandsSeparator) {
|
|
1139
|
-
str = str.split('.').map(function (s, i) {
|
|
1140
|
-
return i === 0
|
|
1141
|
-
? s.replace(formatThousandsRegExp, thousandsSeparator)
|
|
1142
|
-
: s
|
|
1143
|
-
}).join('.');
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
return str + unitSeparator + unit;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* Parse the string value into an integer in bytes.
|
|
1151
|
-
*
|
|
1152
|
-
* If no unit is given, it is assumed the value is in bytes.
|
|
1153
|
-
*
|
|
1154
|
-
* @param {number|string} val
|
|
1155
|
-
*
|
|
1156
|
-
* @returns {number|null}
|
|
1157
|
-
* @public
|
|
1158
|
-
*/
|
|
1159
|
-
|
|
1160
|
-
function parse(val) {
|
|
1161
|
-
if (typeof val === 'number' && !isNaN(val)) {
|
|
1162
|
-
return val;
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
if (typeof val !== 'string') {
|
|
1166
|
-
return null;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
// Test if the string passed is valid
|
|
1170
|
-
var results = parseRegExp.exec(val);
|
|
1171
|
-
var floatValue;
|
|
1172
|
-
var unit = 'b';
|
|
1173
|
-
|
|
1174
|
-
if (!results) {
|
|
1175
|
-
// Nothing could be extracted from the given string
|
|
1176
|
-
floatValue = parseInt(val, 10);
|
|
1177
|
-
unit = 'b';
|
|
1178
|
-
} else {
|
|
1179
|
-
// Retrieve the value and the unit
|
|
1180
|
-
floatValue = parseFloat(results[1]);
|
|
1181
|
-
unit = results[4].toLowerCase();
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
return Math.floor(map$1[unit] * floatValue);
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
const Tooltip_marginX = 10;
|
|
1188
|
-
const Tooltip_marginY = 30;
|
|
1189
|
-
const SOURCEMAP_RENDERED = (e$1("span", { children: [" ", e$1("b", { children: LABELS.renderedLength }, void 0), " is a number of characters in the file after individual and ", e$1("br", {}, void 0), " whole bundle transformations according to sourcemap."] }, void 0));
|
|
1190
|
-
const RENDRED = (e$1("span", { children: [e$1("b", { children: LABELS.renderedLength }, void 0), " is a byte size of individual file after transformations and treeshake."] }, void 0));
|
|
1191
|
-
const COMPRESSED = (e$1("span", { children: [e$1("b", { children: LABELS.gzipLength }, void 0), " and ", e$1("b", { children: LABELS.brotliLength }, void 0), " is a byte size of individual file after individual", " ", "transformations,", e$1("br", {}, void 0), " treeshake and compression."] }, void 0));
|
|
1192
|
-
const Tooltip = ({ node, visible, root, sizeProperty }) => {
|
|
1193
|
-
const { availableSizeProperties, getModuleSize, data } = F(StaticContext);
|
|
1194
|
-
const ref = s(null);
|
|
1195
|
-
const [style, setStyle] = l({});
|
|
1196
|
-
const content = d(() => {
|
|
1197
|
-
if (!node)
|
|
1198
|
-
return null;
|
|
1199
|
-
const mainSize = getModuleSize(node.data, sizeProperty);
|
|
1200
|
-
const percentageNum = (100 * mainSize) / getModuleSize(root.data, sizeProperty);
|
|
1201
|
-
const percentage = percentageNum.toFixed(2);
|
|
1202
|
-
const percentageString = percentage + "%";
|
|
1203
|
-
const path = node
|
|
1204
|
-
.ancestors()
|
|
1205
|
-
.reverse()
|
|
1206
|
-
.map((d) => d.data.name)
|
|
1207
|
-
.join("/");
|
|
1208
|
-
let dataNode = null;
|
|
1209
|
-
if (!isModuleTree(node.data)) {
|
|
1210
|
-
const mainUid = data.nodeParts[node.data.uid].mainUid;
|
|
1211
|
-
dataNode = data.nodeMetas[mainUid];
|
|
1212
|
-
}
|
|
1213
|
-
return (e$1(d$1, { children: [e$1("div", { children: path }, void 0), availableSizeProperties.map((sizeProp) => {
|
|
1214
|
-
if (sizeProp === sizeProperty) {
|
|
1215
|
-
return (e$1("div", { children: [e$1("b", { children: [LABELS[sizeProp], ": ", format_1(mainSize)] }, void 0), " ", "(", percentageString, ")"] }, void 0));
|
|
1216
|
-
}
|
|
1217
|
-
else {
|
|
1218
|
-
return (e$1("div", { children: [LABELS[sizeProp], ": ", format_1(getModuleSize(node.data, sizeProp))] }, void 0));
|
|
1219
|
-
}
|
|
1220
|
-
}), e$1("br", {}, void 0), dataNode && dataNode.importedBy.length > 0 && (e$1("div", { children: [e$1("div", { children: [e$1("b", { children: "Imported By" }, void 0), ":"] }, void 0), dataNode.importedBy.map(({ uid }) => {
|
|
1221
|
-
const id = data.nodeMetas[uid].id;
|
|
1222
|
-
return e$1("div", { children: id }, id);
|
|
1223
|
-
})] }, void 0)), e$1("br", {}, void 0), e$1("small", { children: data.options.sourcemap ? SOURCEMAP_RENDERED : RENDRED }, void 0), (data.options.gzip || data.options.brotli) && (e$1(d$1, { children: [e$1("br", {}, void 0), e$1("small", { children: COMPRESSED }, void 0)] }, void 0))] }, void 0));
|
|
1224
|
-
}, [availableSizeProperties, data, getModuleSize, node, root.data, sizeProperty]);
|
|
1225
|
-
const updatePosition = (mouseCoords) => {
|
|
1226
|
-
if (!ref.current)
|
|
1227
|
-
return;
|
|
1228
|
-
const pos = {
|
|
1229
|
-
left: mouseCoords.x + Tooltip_marginX,
|
|
1230
|
-
top: mouseCoords.y + Tooltip_marginY,
|
|
1231
|
-
};
|
|
1232
|
-
const boundingRect = ref.current.getBoundingClientRect();
|
|
1233
|
-
if (pos.left + boundingRect.width > window.innerWidth) {
|
|
1234
|
-
// Shifting horizontally
|
|
1235
|
-
pos.left = window.innerWidth - boundingRect.width;
|
|
1236
|
-
}
|
|
1237
|
-
if (pos.top + boundingRect.height > window.innerHeight) {
|
|
1238
|
-
// Flipping vertically
|
|
1239
|
-
pos.top = mouseCoords.y - Tooltip_marginY - boundingRect.height;
|
|
1240
|
-
}
|
|
1241
|
-
setStyle(pos);
|
|
1242
|
-
};
|
|
1243
|
-
y(() => {
|
|
1244
|
-
const handleMouseMove = (event) => {
|
|
1245
|
-
updatePosition({
|
|
1246
|
-
x: event.pageX,
|
|
1247
|
-
y: event.pageY,
|
|
1248
|
-
});
|
|
1249
|
-
};
|
|
1250
|
-
document.addEventListener("mousemove", handleMouseMove, true);
|
|
1251
|
-
return () => {
|
|
1252
|
-
document.removeEventListener("mousemove", handleMouseMove, true);
|
|
1253
|
-
};
|
|
1254
|
-
}, []);
|
|
1255
|
-
return (e$1("div", Object.assign({ className: `tooltip ${visible ? "" : "tooltip-hidden"}`, ref: ref, style: style }, { children: content }), void 0));
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1258
|
-
const Chart = ({ root, sizeProperty, selectedNode, setSelectedNode }) => {
|
|
1259
|
-
const [showTooltip, setShowTooltip] = l(false);
|
|
1260
|
-
const [tooltipNode, setTooltipNode] = l(undefined);
|
|
1261
|
-
y(() => {
|
|
1262
|
-
const handleMouseOut = () => {
|
|
1263
|
-
setShowTooltip(false);
|
|
1264
|
-
};
|
|
1265
|
-
document.addEventListener("mouseover", handleMouseOut);
|
|
1266
|
-
return () => {
|
|
1267
|
-
document.removeEventListener("mouseover", handleMouseOut);
|
|
1268
|
-
};
|
|
1269
|
-
}, []);
|
|
1270
|
-
return (e$1(d$1, { children: [e$1(TreeMap, { root: root, onNodeHover: (node) => {
|
|
1271
|
-
setTooltipNode(node);
|
|
1272
|
-
setShowTooltip(true);
|
|
1273
|
-
}, selectedNode: selectedNode, onNodeClick: (node) => {
|
|
1274
|
-
setSelectedNode(selectedNode === node ? undefined : node);
|
|
1275
|
-
} }, void 0), e$1(Tooltip, { visible: showTooltip, node: tooltipNode, root: root, sizeProperty: sizeProperty }, void 0)] }, void 0));
|
|
1276
|
-
};
|
|
1277
|
-
|
|
1278
|
-
const Main = () => {
|
|
1279
|
-
const { availableSizeProperties, rawHierarchy, getModuleSize, layout, data } = F(StaticContext);
|
|
1280
|
-
const [sizeProperty, setSizeProperty] = l(availableSizeProperties[0]);
|
|
1281
|
-
const [selectedNode, setSelectedNode] = l(undefined);
|
|
1282
|
-
const { getModuleFilterMultiplier, setExcludeFilter, setIncludeFilter } = useFilter();
|
|
1283
|
-
console.time("getNodeSizeMultiplier");
|
|
1284
|
-
const getNodeSizeMultiplier = d(() => {
|
|
1285
|
-
const rootSize = getModuleSize(rawHierarchy.data, sizeProperty);
|
|
1286
|
-
const selectedSize = selectedNode ? getModuleSize(selectedNode.data, sizeProperty) : 1;
|
|
1287
|
-
const multiplier = rootSize * 0.2 > selectedSize ? (rootSize * 0.2) / selectedSize : 3;
|
|
1288
|
-
if (selectedNode === undefined) {
|
|
1289
|
-
return () => 1;
|
|
1290
|
-
}
|
|
1291
|
-
else if (isModuleTree(selectedNode.data)) {
|
|
1292
|
-
const leaves = new Set(selectedNode.leaves().map((d) => d.data));
|
|
1293
|
-
return (node) => {
|
|
1294
|
-
if (leaves.has(node)) {
|
|
1295
|
-
return multiplier;
|
|
1296
|
-
}
|
|
1297
|
-
return 1;
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
else {
|
|
1301
|
-
return (node) => {
|
|
1302
|
-
if (node === selectedNode.data) {
|
|
1303
|
-
return multiplier;
|
|
1304
|
-
}
|
|
1305
|
-
return 1;
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
}, [getModuleSize, rawHierarchy.data, selectedNode, sizeProperty]);
|
|
1309
|
-
console.timeEnd("getNodeSizeMultiplier");
|
|
1310
|
-
console.time("root hierarchy compute");
|
|
1311
|
-
// root here always be the same as rawHierarchy even after layouting
|
|
1312
|
-
const root = d(() => {
|
|
1313
|
-
const rootWithSizesAndSorted = rawHierarchy
|
|
1314
|
-
.sum((node) => {
|
|
1315
|
-
if (isModuleTree(node))
|
|
1316
|
-
return 0;
|
|
1317
|
-
const ownSize = getModuleSize(node, sizeProperty);
|
|
1318
|
-
const zoomMultiplier = getNodeSizeMultiplier(node);
|
|
1319
|
-
const filterMultiplier = getModuleFilterMultiplier(data.nodeMetas[data.nodeParts[node.uid].mainUid]);
|
|
1320
|
-
return ownSize * zoomMultiplier * filterMultiplier;
|
|
1321
|
-
})
|
|
1322
|
-
.sort((a, b) => getModuleSize(a.data, sizeProperty) - getModuleSize(b.data, sizeProperty));
|
|
1323
|
-
return layout(rootWithSizesAndSorted);
|
|
1324
|
-
}, [data, getModuleFilterMultiplier, getModuleSize, getNodeSizeMultiplier, layout, rawHierarchy, sizeProperty]);
|
|
1325
|
-
console.timeEnd("root hierarchy compute");
|
|
1326
|
-
return (e$1(d$1, { children: [e$1(SideBar, { sizeProperty: sizeProperty, availableSizeProperties: availableSizeProperties, setSizeProperty: setSizeProperty, onExcludeChange: setExcludeFilter, onIncludeChange: setIncludeFilter }, void 0), e$1(Chart, { root: root, sizeProperty: sizeProperty, selectedNode: selectedNode, setSelectedNode: setSelectedNode }, void 0)] }, void 0));
|
|
1327
|
-
};
|
|
1328
|
-
|
|
1329
|
-
function initRange(domain, range) {
|
|
1330
|
-
switch (arguments.length) {
|
|
1331
|
-
case 0: break;
|
|
1332
|
-
case 1: this.range(domain); break;
|
|
1333
|
-
default: this.range(range).domain(domain); break;
|
|
1334
|
-
}
|
|
1335
|
-
return this;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
function initInterpolator(domain, interpolator) {
|
|
1339
|
-
switch (arguments.length) {
|
|
1340
|
-
case 0: break;
|
|
1341
|
-
case 1: {
|
|
1342
|
-
if (typeof domain === "function") this.interpolator(domain);
|
|
1343
|
-
else this.range(domain);
|
|
1344
|
-
break;
|
|
1345
|
-
}
|
|
1346
|
-
default: {
|
|
1347
|
-
this.domain(domain);
|
|
1348
|
-
if (typeof interpolator === "function") this.interpolator(interpolator);
|
|
1349
|
-
else this.range(interpolator);
|
|
1350
|
-
break;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
return this;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
function define(constructor, factory, prototype) {
|
|
1357
|
-
constructor.prototype = factory.prototype = prototype;
|
|
1358
|
-
prototype.constructor = constructor;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
function extend(parent, definition) {
|
|
1362
|
-
var prototype = Object.create(parent.prototype);
|
|
1363
|
-
for (var key in definition) prototype[key] = definition[key];
|
|
1364
|
-
return prototype;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
function Color() {}
|
|
1368
|
-
|
|
1369
|
-
var darker = 0.7;
|
|
1370
|
-
var brighter = 1 / darker;
|
|
1371
|
-
|
|
1372
|
-
var reI = "\\s*([+-]?\\d+)\\s*",
|
|
1373
|
-
reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
|
|
1374
|
-
reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
|
|
1375
|
-
reHex = /^#([0-9a-f]{3,8})$/,
|
|
1376
|
-
reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
|
|
1377
|
-
reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
|
|
1378
|
-
reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
|
|
1379
|
-
reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
|
|
1380
|
-
reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
|
|
1381
|
-
reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
|
|
1382
|
-
|
|
1383
|
-
var named = {
|
|
1384
|
-
aliceblue: 0xf0f8ff,
|
|
1385
|
-
antiquewhite: 0xfaebd7,
|
|
1386
|
-
aqua: 0x00ffff,
|
|
1387
|
-
aquamarine: 0x7fffd4,
|
|
1388
|
-
azure: 0xf0ffff,
|
|
1389
|
-
beige: 0xf5f5dc,
|
|
1390
|
-
bisque: 0xffe4c4,
|
|
1391
|
-
black: 0x000000,
|
|
1392
|
-
blanchedalmond: 0xffebcd,
|
|
1393
|
-
blue: 0x0000ff,
|
|
1394
|
-
blueviolet: 0x8a2be2,
|
|
1395
|
-
brown: 0xa52a2a,
|
|
1396
|
-
burlywood: 0xdeb887,
|
|
1397
|
-
cadetblue: 0x5f9ea0,
|
|
1398
|
-
chartreuse: 0x7fff00,
|
|
1399
|
-
chocolate: 0xd2691e,
|
|
1400
|
-
coral: 0xff7f50,
|
|
1401
|
-
cornflowerblue: 0x6495ed,
|
|
1402
|
-
cornsilk: 0xfff8dc,
|
|
1403
|
-
crimson: 0xdc143c,
|
|
1404
|
-
cyan: 0x00ffff,
|
|
1405
|
-
darkblue: 0x00008b,
|
|
1406
|
-
darkcyan: 0x008b8b,
|
|
1407
|
-
darkgoldenrod: 0xb8860b,
|
|
1408
|
-
darkgray: 0xa9a9a9,
|
|
1409
|
-
darkgreen: 0x006400,
|
|
1410
|
-
darkgrey: 0xa9a9a9,
|
|
1411
|
-
darkkhaki: 0xbdb76b,
|
|
1412
|
-
darkmagenta: 0x8b008b,
|
|
1413
|
-
darkolivegreen: 0x556b2f,
|
|
1414
|
-
darkorange: 0xff8c00,
|
|
1415
|
-
darkorchid: 0x9932cc,
|
|
1416
|
-
darkred: 0x8b0000,
|
|
1417
|
-
darksalmon: 0xe9967a,
|
|
1418
|
-
darkseagreen: 0x8fbc8f,
|
|
1419
|
-
darkslateblue: 0x483d8b,
|
|
1420
|
-
darkslategray: 0x2f4f4f,
|
|
1421
|
-
darkslategrey: 0x2f4f4f,
|
|
1422
|
-
darkturquoise: 0x00ced1,
|
|
1423
|
-
darkviolet: 0x9400d3,
|
|
1424
|
-
deeppink: 0xff1493,
|
|
1425
|
-
deepskyblue: 0x00bfff,
|
|
1426
|
-
dimgray: 0x696969,
|
|
1427
|
-
dimgrey: 0x696969,
|
|
1428
|
-
dodgerblue: 0x1e90ff,
|
|
1429
|
-
firebrick: 0xb22222,
|
|
1430
|
-
floralwhite: 0xfffaf0,
|
|
1431
|
-
forestgreen: 0x228b22,
|
|
1432
|
-
fuchsia: 0xff00ff,
|
|
1433
|
-
gainsboro: 0xdcdcdc,
|
|
1434
|
-
ghostwhite: 0xf8f8ff,
|
|
1435
|
-
gold: 0xffd700,
|
|
1436
|
-
goldenrod: 0xdaa520,
|
|
1437
|
-
gray: 0x808080,
|
|
1438
|
-
green: 0x008000,
|
|
1439
|
-
greenyellow: 0xadff2f,
|
|
1440
|
-
grey: 0x808080,
|
|
1441
|
-
honeydew: 0xf0fff0,
|
|
1442
|
-
hotpink: 0xff69b4,
|
|
1443
|
-
indianred: 0xcd5c5c,
|
|
1444
|
-
indigo: 0x4b0082,
|
|
1445
|
-
ivory: 0xfffff0,
|
|
1446
|
-
khaki: 0xf0e68c,
|
|
1447
|
-
lavender: 0xe6e6fa,
|
|
1448
|
-
lavenderblush: 0xfff0f5,
|
|
1449
|
-
lawngreen: 0x7cfc00,
|
|
1450
|
-
lemonchiffon: 0xfffacd,
|
|
1451
|
-
lightblue: 0xadd8e6,
|
|
1452
|
-
lightcoral: 0xf08080,
|
|
1453
|
-
lightcyan: 0xe0ffff,
|
|
1454
|
-
lightgoldenrodyellow: 0xfafad2,
|
|
1455
|
-
lightgray: 0xd3d3d3,
|
|
1456
|
-
lightgreen: 0x90ee90,
|
|
1457
|
-
lightgrey: 0xd3d3d3,
|
|
1458
|
-
lightpink: 0xffb6c1,
|
|
1459
|
-
lightsalmon: 0xffa07a,
|
|
1460
|
-
lightseagreen: 0x20b2aa,
|
|
1461
|
-
lightskyblue: 0x87cefa,
|
|
1462
|
-
lightslategray: 0x778899,
|
|
1463
|
-
lightslategrey: 0x778899,
|
|
1464
|
-
lightsteelblue: 0xb0c4de,
|
|
1465
|
-
lightyellow: 0xffffe0,
|
|
1466
|
-
lime: 0x00ff00,
|
|
1467
|
-
limegreen: 0x32cd32,
|
|
1468
|
-
linen: 0xfaf0e6,
|
|
1469
|
-
magenta: 0xff00ff,
|
|
1470
|
-
maroon: 0x800000,
|
|
1471
|
-
mediumaquamarine: 0x66cdaa,
|
|
1472
|
-
mediumblue: 0x0000cd,
|
|
1473
|
-
mediumorchid: 0xba55d3,
|
|
1474
|
-
mediumpurple: 0x9370db,
|
|
1475
|
-
mediumseagreen: 0x3cb371,
|
|
1476
|
-
mediumslateblue: 0x7b68ee,
|
|
1477
|
-
mediumspringgreen: 0x00fa9a,
|
|
1478
|
-
mediumturquoise: 0x48d1cc,
|
|
1479
|
-
mediumvioletred: 0xc71585,
|
|
1480
|
-
midnightblue: 0x191970,
|
|
1481
|
-
mintcream: 0xf5fffa,
|
|
1482
|
-
mistyrose: 0xffe4e1,
|
|
1483
|
-
moccasin: 0xffe4b5,
|
|
1484
|
-
navajowhite: 0xffdead,
|
|
1485
|
-
navy: 0x000080,
|
|
1486
|
-
oldlace: 0xfdf5e6,
|
|
1487
|
-
olive: 0x808000,
|
|
1488
|
-
olivedrab: 0x6b8e23,
|
|
1489
|
-
orange: 0xffa500,
|
|
1490
|
-
orangered: 0xff4500,
|
|
1491
|
-
orchid: 0xda70d6,
|
|
1492
|
-
palegoldenrod: 0xeee8aa,
|
|
1493
|
-
palegreen: 0x98fb98,
|
|
1494
|
-
paleturquoise: 0xafeeee,
|
|
1495
|
-
palevioletred: 0xdb7093,
|
|
1496
|
-
papayawhip: 0xffefd5,
|
|
1497
|
-
peachpuff: 0xffdab9,
|
|
1498
|
-
peru: 0xcd853f,
|
|
1499
|
-
pink: 0xffc0cb,
|
|
1500
|
-
plum: 0xdda0dd,
|
|
1501
|
-
powderblue: 0xb0e0e6,
|
|
1502
|
-
purple: 0x800080,
|
|
1503
|
-
rebeccapurple: 0x663399,
|
|
1504
|
-
red: 0xff0000,
|
|
1505
|
-
rosybrown: 0xbc8f8f,
|
|
1506
|
-
royalblue: 0x4169e1,
|
|
1507
|
-
saddlebrown: 0x8b4513,
|
|
1508
|
-
salmon: 0xfa8072,
|
|
1509
|
-
sandybrown: 0xf4a460,
|
|
1510
|
-
seagreen: 0x2e8b57,
|
|
1511
|
-
seashell: 0xfff5ee,
|
|
1512
|
-
sienna: 0xa0522d,
|
|
1513
|
-
silver: 0xc0c0c0,
|
|
1514
|
-
skyblue: 0x87ceeb,
|
|
1515
|
-
slateblue: 0x6a5acd,
|
|
1516
|
-
slategray: 0x708090,
|
|
1517
|
-
slategrey: 0x708090,
|
|
1518
|
-
snow: 0xfffafa,
|
|
1519
|
-
springgreen: 0x00ff7f,
|
|
1520
|
-
steelblue: 0x4682b4,
|
|
1521
|
-
tan: 0xd2b48c,
|
|
1522
|
-
teal: 0x008080,
|
|
1523
|
-
thistle: 0xd8bfd8,
|
|
1524
|
-
tomato: 0xff6347,
|
|
1525
|
-
turquoise: 0x40e0d0,
|
|
1526
|
-
violet: 0xee82ee,
|
|
1527
|
-
wheat: 0xf5deb3,
|
|
1528
|
-
white: 0xffffff,
|
|
1529
|
-
whitesmoke: 0xf5f5f5,
|
|
1530
|
-
yellow: 0xffff00,
|
|
1531
|
-
yellowgreen: 0x9acd32
|
|
1532
|
-
};
|
|
1533
|
-
|
|
1534
|
-
define(Color, color, {
|
|
1535
|
-
copy: function(channels) {
|
|
1536
|
-
return Object.assign(new this.constructor, this, channels);
|
|
1537
|
-
},
|
|
1538
|
-
displayable: function() {
|
|
1539
|
-
return this.rgb().displayable();
|
|
1540
|
-
},
|
|
1541
|
-
hex: color_formatHex, // Deprecated! Use color.formatHex.
|
|
1542
|
-
formatHex: color_formatHex,
|
|
1543
|
-
formatHsl: color_formatHsl,
|
|
1544
|
-
formatRgb: color_formatRgb,
|
|
1545
|
-
toString: color_formatRgb
|
|
1546
|
-
});
|
|
1547
|
-
|
|
1548
|
-
function color_formatHex() {
|
|
1549
|
-
return this.rgb().formatHex();
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
function color_formatHsl() {
|
|
1553
|
-
return hslConvert(this).formatHsl();
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
function color_formatRgb() {
|
|
1557
|
-
return this.rgb().formatRgb();
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
function color(format) {
|
|
1561
|
-
var m, l;
|
|
1562
|
-
format = (format + "").trim().toLowerCase();
|
|
1563
|
-
return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
|
|
1564
|
-
: l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
|
|
1565
|
-
: l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
|
|
1566
|
-
: l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
|
|
1567
|
-
: null) // invalid hex
|
|
1568
|
-
: (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
|
|
1569
|
-
: (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
|
|
1570
|
-
: (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
|
|
1571
|
-
: (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
|
|
1572
|
-
: (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
|
|
1573
|
-
: (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
|
|
1574
|
-
: named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
|
|
1575
|
-
: format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
|
|
1576
|
-
: null;
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
function rgbn(n) {
|
|
1580
|
-
return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
function rgba(r, g, b, a) {
|
|
1584
|
-
if (a <= 0) r = g = b = NaN;
|
|
1585
|
-
return new Rgb(r, g, b, a);
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
function rgbConvert(o) {
|
|
1589
|
-
if (!(o instanceof Color)) o = color(o);
|
|
1590
|
-
if (!o) return new Rgb;
|
|
1591
|
-
o = o.rgb();
|
|
1592
|
-
return new Rgb(o.r, o.g, o.b, o.opacity);
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
function rgb$1(r, g, b, opacity) {
|
|
1596
|
-
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
function Rgb(r, g, b, opacity) {
|
|
1600
|
-
this.r = +r;
|
|
1601
|
-
this.g = +g;
|
|
1602
|
-
this.b = +b;
|
|
1603
|
-
this.opacity = +opacity;
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
define(Rgb, rgb$1, extend(Color, {
|
|
1607
|
-
brighter: function(k) {
|
|
1608
|
-
k = k == null ? brighter : Math.pow(brighter, k);
|
|
1609
|
-
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
1610
|
-
},
|
|
1611
|
-
darker: function(k) {
|
|
1612
|
-
k = k == null ? darker : Math.pow(darker, k);
|
|
1613
|
-
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
1614
|
-
},
|
|
1615
|
-
rgb: function() {
|
|
1616
|
-
return this;
|
|
1617
|
-
},
|
|
1618
|
-
displayable: function() {
|
|
1619
|
-
return (-0.5 <= this.r && this.r < 255.5)
|
|
1620
|
-
&& (-0.5 <= this.g && this.g < 255.5)
|
|
1621
|
-
&& (-0.5 <= this.b && this.b < 255.5)
|
|
1622
|
-
&& (0 <= this.opacity && this.opacity <= 1);
|
|
1623
|
-
},
|
|
1624
|
-
hex: rgb_formatHex, // Deprecated! Use color.formatHex.
|
|
1625
|
-
formatHex: rgb_formatHex,
|
|
1626
|
-
formatRgb: rgb_formatRgb,
|
|
1627
|
-
toString: rgb_formatRgb
|
|
1628
|
-
}));
|
|
1629
|
-
|
|
1630
|
-
function rgb_formatHex() {
|
|
1631
|
-
return "#" + hex(this.r) + hex(this.g) + hex(this.b);
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
function rgb_formatRgb() {
|
|
1635
|
-
var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
|
|
1636
|
-
return (a === 1 ? "rgb(" : "rgba(")
|
|
1637
|
-
+ Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", "
|
|
1638
|
-
+ Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", "
|
|
1639
|
-
+ Math.max(0, Math.min(255, Math.round(this.b) || 0))
|
|
1640
|
-
+ (a === 1 ? ")" : ", " + a + ")");
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
function hex(value) {
|
|
1644
|
-
value = Math.max(0, Math.min(255, Math.round(value) || 0));
|
|
1645
|
-
return (value < 16 ? "0" : "") + value.toString(16);
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
function hsla(h, s, l, a) {
|
|
1649
|
-
if (a <= 0) h = s = l = NaN;
|
|
1650
|
-
else if (l <= 0 || l >= 1) h = s = NaN;
|
|
1651
|
-
else if (s <= 0) h = NaN;
|
|
1652
|
-
return new Hsl(h, s, l, a);
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
function hslConvert(o) {
|
|
1656
|
-
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
|
|
1657
|
-
if (!(o instanceof Color)) o = color(o);
|
|
1658
|
-
if (!o) return new Hsl;
|
|
1659
|
-
if (o instanceof Hsl) return o;
|
|
1660
|
-
o = o.rgb();
|
|
1661
|
-
var r = o.r / 255,
|
|
1662
|
-
g = o.g / 255,
|
|
1663
|
-
b = o.b / 255,
|
|
1664
|
-
min = Math.min(r, g, b),
|
|
1665
|
-
max = Math.max(r, g, b),
|
|
1666
|
-
h = NaN,
|
|
1667
|
-
s = max - min,
|
|
1668
|
-
l = (max + min) / 2;
|
|
1669
|
-
if (s) {
|
|
1670
|
-
if (r === max) h = (g - b) / s + (g < b) * 6;
|
|
1671
|
-
else if (g === max) h = (b - r) / s + 2;
|
|
1672
|
-
else h = (r - g) / s + 4;
|
|
1673
|
-
s /= l < 0.5 ? max + min : 2 - max - min;
|
|
1674
|
-
h *= 60;
|
|
1675
|
-
} else {
|
|
1676
|
-
s = l > 0 && l < 1 ? 0 : h;
|
|
1677
|
-
}
|
|
1678
|
-
return new Hsl(h, s, l, o.opacity);
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
function hsl(h, s, l, opacity) {
|
|
1682
|
-
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
function Hsl(h, s, l, opacity) {
|
|
1686
|
-
this.h = +h;
|
|
1687
|
-
this.s = +s;
|
|
1688
|
-
this.l = +l;
|
|
1689
|
-
this.opacity = +opacity;
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
define(Hsl, hsl, extend(Color, {
|
|
1693
|
-
brighter: function(k) {
|
|
1694
|
-
k = k == null ? brighter : Math.pow(brighter, k);
|
|
1695
|
-
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
1696
|
-
},
|
|
1697
|
-
darker: function(k) {
|
|
1698
|
-
k = k == null ? darker : Math.pow(darker, k);
|
|
1699
|
-
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
1700
|
-
},
|
|
1701
|
-
rgb: function() {
|
|
1702
|
-
var h = this.h % 360 + (this.h < 0) * 360,
|
|
1703
|
-
s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
|
|
1704
|
-
l = this.l,
|
|
1705
|
-
m2 = l + (l < 0.5 ? l : 1 - l) * s,
|
|
1706
|
-
m1 = 2 * l - m2;
|
|
1707
|
-
return new Rgb(
|
|
1708
|
-
hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
|
|
1709
|
-
hsl2rgb(h, m1, m2),
|
|
1710
|
-
hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
|
|
1711
|
-
this.opacity
|
|
1712
|
-
);
|
|
1713
|
-
},
|
|
1714
|
-
displayable: function() {
|
|
1715
|
-
return (0 <= this.s && this.s <= 1 || isNaN(this.s))
|
|
1716
|
-
&& (0 <= this.l && this.l <= 1)
|
|
1717
|
-
&& (0 <= this.opacity && this.opacity <= 1);
|
|
1718
|
-
},
|
|
1719
|
-
formatHsl: function() {
|
|
1720
|
-
var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
|
|
1721
|
-
return (a === 1 ? "hsl(" : "hsla(")
|
|
1722
|
-
+ (this.h || 0) + ", "
|
|
1723
|
-
+ (this.s || 0) * 100 + "%, "
|
|
1724
|
-
+ (this.l || 0) * 100 + "%"
|
|
1725
|
-
+ (a === 1 ? ")" : ", " + a + ")");
|
|
1726
|
-
}
|
|
1727
|
-
}));
|
|
1728
|
-
|
|
1729
|
-
/* From FvD 13.37, CSS Color Module Level 3 */
|
|
1730
|
-
function hsl2rgb(h, m1, m2) {
|
|
1731
|
-
return (h < 60 ? m1 + (m2 - m1) * h / 60
|
|
1732
|
-
: h < 180 ? m2
|
|
1733
|
-
: h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
|
|
1734
|
-
: m1) * 255;
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
var constant = x => () => x;
|
|
1738
|
-
|
|
1739
|
-
function linear$1(a, d) {
|
|
1740
|
-
return function(t) {
|
|
1741
|
-
return a + t * d;
|
|
1742
|
-
};
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
function exponential(a, b, y) {
|
|
1746
|
-
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
|
|
1747
|
-
return Math.pow(a + t * b, y);
|
|
1748
|
-
};
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
function gamma(y) {
|
|
1752
|
-
return (y = +y) === 1 ? nogamma : function(a, b) {
|
|
1753
|
-
return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
|
|
1754
|
-
};
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
function nogamma(a, b) {
|
|
1758
|
-
var d = b - a;
|
|
1759
|
-
return d ? linear$1(a, d) : constant(isNaN(a) ? b : a);
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
var rgb = (function rgbGamma(y) {
|
|
1763
|
-
var color = gamma(y);
|
|
1764
|
-
|
|
1765
|
-
function rgb(start, end) {
|
|
1766
|
-
var r = color((start = rgb$1(start)).r, (end = rgb$1(end)).r),
|
|
1767
|
-
g = color(start.g, end.g),
|
|
1768
|
-
b = color(start.b, end.b),
|
|
1769
|
-
opacity = nogamma(start.opacity, end.opacity);
|
|
1770
|
-
return function(t) {
|
|
1771
|
-
start.r = r(t);
|
|
1772
|
-
start.g = g(t);
|
|
1773
|
-
start.b = b(t);
|
|
1774
|
-
start.opacity = opacity(t);
|
|
1775
|
-
return start + "";
|
|
1776
|
-
};
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
rgb.gamma = rgbGamma;
|
|
1780
|
-
|
|
1781
|
-
return rgb;
|
|
1782
|
-
})(1);
|
|
1783
|
-
|
|
1784
|
-
function numberArray(a, b) {
|
|
1785
|
-
if (!b) b = [];
|
|
1786
|
-
var n = a ? Math.min(b.length, a.length) : 0,
|
|
1787
|
-
c = b.slice(),
|
|
1788
|
-
i;
|
|
1789
|
-
return function(t) {
|
|
1790
|
-
for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
|
|
1791
|
-
return c;
|
|
1792
|
-
};
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
|
-
function isNumberArray(x) {
|
|
1796
|
-
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
function genericArray(a, b) {
|
|
1800
|
-
var nb = b ? b.length : 0,
|
|
1801
|
-
na = a ? Math.min(nb, a.length) : 0,
|
|
1802
|
-
x = new Array(na),
|
|
1803
|
-
c = new Array(nb),
|
|
1804
|
-
i;
|
|
1805
|
-
|
|
1806
|
-
for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]);
|
|
1807
|
-
for (; i < nb; ++i) c[i] = b[i];
|
|
1808
|
-
|
|
1809
|
-
return function(t) {
|
|
1810
|
-
for (i = 0; i < na; ++i) c[i] = x[i](t);
|
|
1811
|
-
return c;
|
|
1812
|
-
};
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
function date(a, b) {
|
|
1816
|
-
var d = new Date;
|
|
1817
|
-
return a = +a, b = +b, function(t) {
|
|
1818
|
-
return d.setTime(a * (1 - t) + b * t), d;
|
|
1819
|
-
};
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
function interpolateNumber(a, b) {
|
|
1823
|
-
return a = +a, b = +b, function(t) {
|
|
1824
|
-
return a * (1 - t) + b * t;
|
|
1825
|
-
};
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
function object(a, b) {
|
|
1829
|
-
var i = {},
|
|
1830
|
-
c = {},
|
|
1831
|
-
k;
|
|
1832
|
-
|
|
1833
|
-
if (a === null || typeof a !== "object") a = {};
|
|
1834
|
-
if (b === null || typeof b !== "object") b = {};
|
|
1835
|
-
|
|
1836
|
-
for (k in b) {
|
|
1837
|
-
if (k in a) {
|
|
1838
|
-
i[k] = interpolate(a[k], b[k]);
|
|
1839
|
-
} else {
|
|
1840
|
-
c[k] = b[k];
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
return function(t) {
|
|
1845
|
-
for (k in i) c[k] = i[k](t);
|
|
1846
|
-
return c;
|
|
1847
|
-
};
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
|
|
1851
|
-
reB = new RegExp(reA.source, "g");
|
|
1852
|
-
|
|
1853
|
-
function zero(b) {
|
|
1854
|
-
return function() {
|
|
1855
|
-
return b;
|
|
1856
|
-
};
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
function one(b) {
|
|
1860
|
-
return function(t) {
|
|
1861
|
-
return b(t) + "";
|
|
1862
|
-
};
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
function string(a, b) {
|
|
1866
|
-
var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
|
|
1867
|
-
am, // current match in a
|
|
1868
|
-
bm, // current match in b
|
|
1869
|
-
bs, // string preceding current number in b, if any
|
|
1870
|
-
i = -1, // index in s
|
|
1871
|
-
s = [], // string constants and placeholders
|
|
1872
|
-
q = []; // number interpolators
|
|
1873
|
-
|
|
1874
|
-
// Coerce inputs to strings.
|
|
1875
|
-
a = a + "", b = b + "";
|
|
1876
|
-
|
|
1877
|
-
// Interpolate pairs of numbers in a & b.
|
|
1878
|
-
while ((am = reA.exec(a))
|
|
1879
|
-
&& (bm = reB.exec(b))) {
|
|
1880
|
-
if ((bs = bm.index) > bi) { // a string precedes the next number in b
|
|
1881
|
-
bs = b.slice(bi, bs);
|
|
1882
|
-
if (s[i]) s[i] += bs; // coalesce with previous string
|
|
1883
|
-
else s[++i] = bs;
|
|
1884
|
-
}
|
|
1885
|
-
if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
|
|
1886
|
-
if (s[i]) s[i] += bm; // coalesce with previous string
|
|
1887
|
-
else s[++i] = bm;
|
|
1888
|
-
} else { // interpolate non-matching numbers
|
|
1889
|
-
s[++i] = null;
|
|
1890
|
-
q.push({i: i, x: interpolateNumber(am, bm)});
|
|
1891
|
-
}
|
|
1892
|
-
bi = reB.lastIndex;
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
// Add remains of b.
|
|
1896
|
-
if (bi < b.length) {
|
|
1897
|
-
bs = b.slice(bi);
|
|
1898
|
-
if (s[i]) s[i] += bs; // coalesce with previous string
|
|
1899
|
-
else s[++i] = bs;
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
// Special optimization for only a single match.
|
|
1903
|
-
// Otherwise, interpolate each of the numbers and rejoin the string.
|
|
1904
|
-
return s.length < 2 ? (q[0]
|
|
1905
|
-
? one(q[0].x)
|
|
1906
|
-
: zero(b))
|
|
1907
|
-
: (b = q.length, function(t) {
|
|
1908
|
-
for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
|
|
1909
|
-
return s.join("");
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
function interpolate(a, b) {
|
|
1914
|
-
var t = typeof b, c;
|
|
1915
|
-
return b == null || t === "boolean" ? constant(b)
|
|
1916
|
-
: (t === "number" ? interpolateNumber
|
|
1917
|
-
: t === "string" ? ((c = color(b)) ? (b = c, rgb) : string)
|
|
1918
|
-
: b instanceof color ? rgb
|
|
1919
|
-
: b instanceof Date ? date
|
|
1920
|
-
: isNumberArray(b) ? numberArray
|
|
1921
|
-
: Array.isArray(b) ? genericArray
|
|
1922
|
-
: typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
|
|
1923
|
-
: interpolateNumber)(a, b);
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
function interpolateRound(a, b) {
|
|
1927
|
-
return a = +a, b = +b, function(t) {
|
|
1928
|
-
return Math.round(a * (1 - t) + b * t);
|
|
1929
|
-
};
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
function constants(x) {
|
|
1933
|
-
return function() {
|
|
1934
|
-
return x;
|
|
1935
|
-
};
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
function number(x) {
|
|
1939
|
-
return +x;
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
var unit = [0, 1];
|
|
1943
|
-
|
|
1944
|
-
function identity$1(x) {
|
|
1945
|
-
return x;
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
function normalize(a, b) {
|
|
1949
|
-
return (b -= (a = +a))
|
|
1950
|
-
? function(x) { return (x - a) / b; }
|
|
1951
|
-
: constants(isNaN(b) ? NaN : 0.5);
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
function clamper(a, b) {
|
|
1955
|
-
var t;
|
|
1956
|
-
if (a > b) t = a, a = b, b = t;
|
|
1957
|
-
return function(x) { return Math.max(a, Math.min(b, x)); };
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
|
|
1961
|
-
// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
|
|
1962
|
-
function bimap(domain, range, interpolate) {
|
|
1963
|
-
var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
|
|
1964
|
-
if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
|
|
1965
|
-
else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
|
|
1966
|
-
return function(x) { return r0(d0(x)); };
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
|
-
function polymap(domain, range, interpolate) {
|
|
1970
|
-
var j = Math.min(domain.length, range.length) - 1,
|
|
1971
|
-
d = new Array(j),
|
|
1972
|
-
r = new Array(j),
|
|
1973
|
-
i = -1;
|
|
1974
|
-
|
|
1975
|
-
// Reverse descending domains.
|
|
1976
|
-
if (domain[j] < domain[0]) {
|
|
1977
|
-
domain = domain.slice().reverse();
|
|
1978
|
-
range = range.slice().reverse();
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
while (++i < j) {
|
|
1982
|
-
d[i] = normalize(domain[i], domain[i + 1]);
|
|
1983
|
-
r[i] = interpolate(range[i], range[i + 1]);
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
return function(x) {
|
|
1987
|
-
var i = bisect(domain, x, 1, j) - 1;
|
|
1988
|
-
return r[i](d[i](x));
|
|
1989
|
-
};
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
|
-
function copy$1(source, target) {
|
|
1993
|
-
return target
|
|
1994
|
-
.domain(source.domain())
|
|
1995
|
-
.range(source.range())
|
|
1996
|
-
.interpolate(source.interpolate())
|
|
1997
|
-
.clamp(source.clamp())
|
|
1998
|
-
.unknown(source.unknown());
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2001
|
-
function transformer$1() {
|
|
2002
|
-
var domain = unit,
|
|
2003
|
-
range = unit,
|
|
2004
|
-
interpolate$1 = interpolate,
|
|
2005
|
-
transform,
|
|
2006
|
-
untransform,
|
|
2007
|
-
unknown,
|
|
2008
|
-
clamp = identity$1,
|
|
2009
|
-
piecewise,
|
|
2010
|
-
output,
|
|
2011
|
-
input;
|
|
2012
|
-
|
|
2013
|
-
function rescale() {
|
|
2014
|
-
var n = Math.min(domain.length, range.length);
|
|
2015
|
-
if (clamp !== identity$1) clamp = clamper(domain[0], domain[n - 1]);
|
|
2016
|
-
piecewise = n > 2 ? polymap : bimap;
|
|
2017
|
-
output = input = null;
|
|
2018
|
-
return scale;
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
function scale(x) {
|
|
2022
|
-
return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x)));
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
scale.invert = function(y) {
|
|
2026
|
-
return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
|
|
2027
|
-
};
|
|
2028
|
-
|
|
2029
|
-
scale.domain = function(_) {
|
|
2030
|
-
return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
|
|
2031
|
-
};
|
|
2032
|
-
|
|
2033
|
-
scale.range = function(_) {
|
|
2034
|
-
return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
|
|
2035
|
-
};
|
|
2036
|
-
|
|
2037
|
-
scale.rangeRound = function(_) {
|
|
2038
|
-
return range = Array.from(_), interpolate$1 = interpolateRound, rescale();
|
|
2039
|
-
};
|
|
2040
|
-
|
|
2041
|
-
scale.clamp = function(_) {
|
|
2042
|
-
return arguments.length ? (clamp = _ ? true : identity$1, rescale()) : clamp !== identity$1;
|
|
2043
|
-
};
|
|
2044
|
-
|
|
2045
|
-
scale.interpolate = function(_) {
|
|
2046
|
-
return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1;
|
|
2047
|
-
};
|
|
2048
|
-
|
|
2049
|
-
scale.unknown = function(_) {
|
|
2050
|
-
return arguments.length ? (unknown = _, scale) : unknown;
|
|
2051
|
-
};
|
|
2052
|
-
|
|
2053
|
-
return function(t, u) {
|
|
2054
|
-
transform = t, untransform = u;
|
|
2055
|
-
return rescale();
|
|
2056
|
-
};
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
function continuous() {
|
|
2060
|
-
return transformer$1()(identity$1, identity$1);
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
function formatDecimal(x) {
|
|
2064
|
-
return Math.abs(x = Math.round(x)) >= 1e21
|
|
2065
|
-
? x.toLocaleString("en").replace(/,/g, "")
|
|
2066
|
-
: x.toString(10);
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
// Computes the decimal coefficient and exponent of the specified number x with
|
|
2070
|
-
// significant digits p, where x is positive and p is in [1, 21] or undefined.
|
|
2071
|
-
// For example, formatDecimalParts(1.23) returns ["123", 0].
|
|
2072
|
-
function formatDecimalParts(x, p) {
|
|
2073
|
-
if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
|
|
2074
|
-
var i, coefficient = x.slice(0, i);
|
|
2075
|
-
|
|
2076
|
-
// The string returned by toExponential either has the form \d\.\d+e[-+]\d+
|
|
2077
|
-
// (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
|
|
2078
|
-
return [
|
|
2079
|
-
coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
|
|
2080
|
-
+x.slice(i + 1)
|
|
2081
|
-
];
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
function exponent(x) {
|
|
2085
|
-
return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
function formatGroup(grouping, thousands) {
|
|
2089
|
-
return function(value, width) {
|
|
2090
|
-
var i = value.length,
|
|
2091
|
-
t = [],
|
|
2092
|
-
j = 0,
|
|
2093
|
-
g = grouping[0],
|
|
2094
|
-
length = 0;
|
|
2095
|
-
|
|
2096
|
-
while (i > 0 && g > 0) {
|
|
2097
|
-
if (length + g + 1 > width) g = Math.max(1, width - length);
|
|
2098
|
-
t.push(value.substring(i -= g, i + g));
|
|
2099
|
-
if ((length += g + 1) > width) break;
|
|
2100
|
-
g = grouping[j = (j + 1) % grouping.length];
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
return t.reverse().join(thousands);
|
|
2104
|
-
};
|
|
2105
|
-
}
|
|
2106
|
-
|
|
2107
|
-
function formatNumerals(numerals) {
|
|
2108
|
-
return function(value) {
|
|
2109
|
-
return value.replace(/[0-9]/g, function(i) {
|
|
2110
|
-
return numerals[+i];
|
|
2111
|
-
});
|
|
2112
|
-
};
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
// [[fill]align][sign][symbol][0][width][,][.precision][~][type]
|
|
2116
|
-
var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
|
2117
|
-
|
|
2118
|
-
function formatSpecifier(specifier) {
|
|
2119
|
-
if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
|
|
2120
|
-
var match;
|
|
2121
|
-
return new FormatSpecifier({
|
|
2122
|
-
fill: match[1],
|
|
2123
|
-
align: match[2],
|
|
2124
|
-
sign: match[3],
|
|
2125
|
-
symbol: match[4],
|
|
2126
|
-
zero: match[5],
|
|
2127
|
-
width: match[6],
|
|
2128
|
-
comma: match[7],
|
|
2129
|
-
precision: match[8] && match[8].slice(1),
|
|
2130
|
-
trim: match[9],
|
|
2131
|
-
type: match[10]
|
|
2132
|
-
});
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
|
|
2136
|
-
|
|
2137
|
-
function FormatSpecifier(specifier) {
|
|
2138
|
-
this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
|
|
2139
|
-
this.align = specifier.align === undefined ? ">" : specifier.align + "";
|
|
2140
|
-
this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
|
|
2141
|
-
this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
|
|
2142
|
-
this.zero = !!specifier.zero;
|
|
2143
|
-
this.width = specifier.width === undefined ? undefined : +specifier.width;
|
|
2144
|
-
this.comma = !!specifier.comma;
|
|
2145
|
-
this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
|
|
2146
|
-
this.trim = !!specifier.trim;
|
|
2147
|
-
this.type = specifier.type === undefined ? "" : specifier.type + "";
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
FormatSpecifier.prototype.toString = function() {
|
|
2151
|
-
return this.fill
|
|
2152
|
-
+ this.align
|
|
2153
|
-
+ this.sign
|
|
2154
|
-
+ this.symbol
|
|
2155
|
-
+ (this.zero ? "0" : "")
|
|
2156
|
-
+ (this.width === undefined ? "" : Math.max(1, this.width | 0))
|
|
2157
|
-
+ (this.comma ? "," : "")
|
|
2158
|
-
+ (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0))
|
|
2159
|
-
+ (this.trim ? "~" : "")
|
|
2160
|
-
+ this.type;
|
|
2161
|
-
};
|
|
2162
|
-
|
|
2163
|
-
// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
|
|
2164
|
-
function formatTrim(s) {
|
|
2165
|
-
out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
|
|
2166
|
-
switch (s[i]) {
|
|
2167
|
-
case ".": i0 = i1 = i; break;
|
|
2168
|
-
case "0": if (i0 === 0) i0 = i; i1 = i; break;
|
|
2169
|
-
default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break;
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
var prefixExponent;
|
|
2176
|
-
|
|
2177
|
-
function formatPrefixAuto(x, p) {
|
|
2178
|
-
var d = formatDecimalParts(x, p);
|
|
2179
|
-
if (!d) return x + "";
|
|
2180
|
-
var coefficient = d[0],
|
|
2181
|
-
exponent = d[1],
|
|
2182
|
-
i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
|
|
2183
|
-
n = coefficient.length;
|
|
2184
|
-
return i === n ? coefficient
|
|
2185
|
-
: i > n ? coefficient + new Array(i - n + 1).join("0")
|
|
2186
|
-
: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
|
|
2187
|
-
: "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
function formatRounded(x, p) {
|
|
2191
|
-
var d = formatDecimalParts(x, p);
|
|
2192
|
-
if (!d) return x + "";
|
|
2193
|
-
var coefficient = d[0],
|
|
2194
|
-
exponent = d[1];
|
|
2195
|
-
return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
|
|
2196
|
-
: coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
|
|
2197
|
-
: coefficient + new Array(exponent - coefficient.length + 2).join("0");
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
var formatTypes = {
|
|
2201
|
-
"%": (x, p) => (x * 100).toFixed(p),
|
|
2202
|
-
"b": (x) => Math.round(x).toString(2),
|
|
2203
|
-
"c": (x) => x + "",
|
|
2204
|
-
"d": formatDecimal,
|
|
2205
|
-
"e": (x, p) => x.toExponential(p),
|
|
2206
|
-
"f": (x, p) => x.toFixed(p),
|
|
2207
|
-
"g": (x, p) => x.toPrecision(p),
|
|
2208
|
-
"o": (x) => Math.round(x).toString(8),
|
|
2209
|
-
"p": (x, p) => formatRounded(x * 100, p),
|
|
2210
|
-
"r": formatRounded,
|
|
2211
|
-
"s": formatPrefixAuto,
|
|
2212
|
-
"X": (x) => Math.round(x).toString(16).toUpperCase(),
|
|
2213
|
-
"x": (x) => Math.round(x).toString(16)
|
|
2214
|
-
};
|
|
2215
|
-
|
|
2216
|
-
function identity(x) {
|
|
2217
|
-
return x;
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
var map = Array.prototype.map,
|
|
2221
|
-
prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
|
|
2222
|
-
|
|
2223
|
-
function formatLocale(locale) {
|
|
2224
|
-
var group = locale.grouping === undefined || locale.thousands === undefined ? identity : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""),
|
|
2225
|
-
currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
|
|
2226
|
-
currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
|
|
2227
|
-
decimal = locale.decimal === undefined ? "." : locale.decimal + "",
|
|
2228
|
-
numerals = locale.numerals === undefined ? identity : formatNumerals(map.call(locale.numerals, String)),
|
|
2229
|
-
percent = locale.percent === undefined ? "%" : locale.percent + "",
|
|
2230
|
-
minus = locale.minus === undefined ? "−" : locale.minus + "",
|
|
2231
|
-
nan = locale.nan === undefined ? "NaN" : locale.nan + "";
|
|
2232
|
-
|
|
2233
|
-
function newFormat(specifier) {
|
|
2234
|
-
specifier = formatSpecifier(specifier);
|
|
2235
|
-
|
|
2236
|
-
var fill = specifier.fill,
|
|
2237
|
-
align = specifier.align,
|
|
2238
|
-
sign = specifier.sign,
|
|
2239
|
-
symbol = specifier.symbol,
|
|
2240
|
-
zero = specifier.zero,
|
|
2241
|
-
width = specifier.width,
|
|
2242
|
-
comma = specifier.comma,
|
|
2243
|
-
precision = specifier.precision,
|
|
2244
|
-
trim = specifier.trim,
|
|
2245
|
-
type = specifier.type;
|
|
2246
|
-
|
|
2247
|
-
// The "n" type is an alias for ",g".
|
|
2248
|
-
if (type === "n") comma = true, type = "g";
|
|
2249
|
-
|
|
2250
|
-
// The "" type, and any invalid type, is an alias for ".12~g".
|
|
2251
|
-
else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g";
|
|
2252
|
-
|
|
2253
|
-
// If zero fill is specified, padding goes after sign and before digits.
|
|
2254
|
-
if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
|
|
2255
|
-
|
|
2256
|
-
// Compute the prefix and suffix.
|
|
2257
|
-
// For SI-prefix, the suffix is lazily computed.
|
|
2258
|
-
var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
|
|
2259
|
-
suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
|
|
2260
|
-
|
|
2261
|
-
// What format function should we use?
|
|
2262
|
-
// Is this an integer type?
|
|
2263
|
-
// Can this type generate exponential notation?
|
|
2264
|
-
var formatType = formatTypes[type],
|
|
2265
|
-
maybeSuffix = /[defgprs%]/.test(type);
|
|
2266
|
-
|
|
2267
|
-
// Set the default precision if not specified,
|
|
2268
|
-
// or clamp the specified precision to the supported range.
|
|
2269
|
-
// For significant precision, it must be in [1, 21].
|
|
2270
|
-
// For fixed precision, it must be in [0, 20].
|
|
2271
|
-
precision = precision === undefined ? 6
|
|
2272
|
-
: /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
|
|
2273
|
-
: Math.max(0, Math.min(20, precision));
|
|
2274
|
-
|
|
2275
|
-
function format(value) {
|
|
2276
|
-
var valuePrefix = prefix,
|
|
2277
|
-
valueSuffix = suffix,
|
|
2278
|
-
i, n, c;
|
|
2279
|
-
|
|
2280
|
-
if (type === "c") {
|
|
2281
|
-
valueSuffix = formatType(value) + valueSuffix;
|
|
2282
|
-
value = "";
|
|
2283
|
-
} else {
|
|
2284
|
-
value = +value;
|
|
2285
|
-
|
|
2286
|
-
// Determine the sign. -0 is not less than 0, but 1 / -0 is!
|
|
2287
|
-
var valueNegative = value < 0 || 1 / value < 0;
|
|
2288
|
-
|
|
2289
|
-
// Perform the initial formatting.
|
|
2290
|
-
value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
|
|
2291
|
-
|
|
2292
|
-
// Trim insignificant zeros.
|
|
2293
|
-
if (trim) value = formatTrim(value);
|
|
2294
|
-
|
|
2295
|
-
// If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
|
|
2296
|
-
if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
|
|
2297
|
-
|
|
2298
|
-
// Compute the prefix and suffix.
|
|
2299
|
-
valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
|
|
2300
|
-
valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
|
|
2301
|
-
|
|
2302
|
-
// Break the formatted value into the integer “value” part that can be
|
|
2303
|
-
// grouped, and fractional or exponential “suffix” part that is not.
|
|
2304
|
-
if (maybeSuffix) {
|
|
2305
|
-
i = -1, n = value.length;
|
|
2306
|
-
while (++i < n) {
|
|
2307
|
-
if (c = value.charCodeAt(i), 48 > c || c > 57) {
|
|
2308
|
-
valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
|
|
2309
|
-
value = value.slice(0, i);
|
|
2310
|
-
break;
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
// If the fill character is not "0", grouping is applied before padding.
|
|
2317
|
-
if (comma && !zero) value = group(value, Infinity);
|
|
2318
|
-
|
|
2319
|
-
// Compute the padding.
|
|
2320
|
-
var length = valuePrefix.length + value.length + valueSuffix.length,
|
|
2321
|
-
padding = length < width ? new Array(width - length + 1).join(fill) : "";
|
|
2322
|
-
|
|
2323
|
-
// If the fill character is "0", grouping is applied after padding.
|
|
2324
|
-
if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
|
|
2325
|
-
|
|
2326
|
-
// Reconstruct the final output based on the desired alignment.
|
|
2327
|
-
switch (align) {
|
|
2328
|
-
case "<": value = valuePrefix + value + valueSuffix + padding; break;
|
|
2329
|
-
case "=": value = valuePrefix + padding + value + valueSuffix; break;
|
|
2330
|
-
case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
|
|
2331
|
-
default: value = padding + valuePrefix + value + valueSuffix; break;
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2334
|
-
return numerals(value);
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
format.toString = function() {
|
|
2338
|
-
return specifier + "";
|
|
2339
|
-
};
|
|
2340
|
-
|
|
2341
|
-
return format;
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
function formatPrefix(specifier, value) {
|
|
2345
|
-
var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
|
|
2346
|
-
e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3,
|
|
2347
|
-
k = Math.pow(10, -e),
|
|
2348
|
-
prefix = prefixes[8 + e / 3];
|
|
2349
|
-
return function(value) {
|
|
2350
|
-
return f(k * value) + prefix;
|
|
2351
|
-
};
|
|
2352
|
-
}
|
|
2353
|
-
|
|
2354
|
-
return {
|
|
2355
|
-
format: newFormat,
|
|
2356
|
-
formatPrefix: formatPrefix
|
|
2357
|
-
};
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
var locale;
|
|
2361
|
-
var format;
|
|
2362
|
-
var formatPrefix;
|
|
2363
|
-
|
|
2364
|
-
defaultLocale({
|
|
2365
|
-
thousands: ",",
|
|
2366
|
-
grouping: [3],
|
|
2367
|
-
currency: ["$", ""]
|
|
2368
|
-
});
|
|
2369
|
-
|
|
2370
|
-
function defaultLocale(definition) {
|
|
2371
|
-
locale = formatLocale(definition);
|
|
2372
|
-
format = locale.format;
|
|
2373
|
-
formatPrefix = locale.formatPrefix;
|
|
2374
|
-
return locale;
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
|
-
function precisionFixed(step) {
|
|
2378
|
-
return Math.max(0, -exponent(Math.abs(step)));
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
|
-
function precisionPrefix(step, value) {
|
|
2382
|
-
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
|
|
2383
|
-
}
|
|
2384
|
-
|
|
2385
|
-
function precisionRound(step, max) {
|
|
2386
|
-
step = Math.abs(step), max = Math.abs(max) - step;
|
|
2387
|
-
return Math.max(0, exponent(max) - exponent(step)) + 1;
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
function tickFormat(start, stop, count, specifier) {
|
|
2391
|
-
var step = tickStep(start, stop, count),
|
|
2392
|
-
precision;
|
|
2393
|
-
specifier = formatSpecifier(specifier == null ? ",f" : specifier);
|
|
2394
|
-
switch (specifier.type) {
|
|
2395
|
-
case "s": {
|
|
2396
|
-
var value = Math.max(Math.abs(start), Math.abs(stop));
|
|
2397
|
-
if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
|
|
2398
|
-
return formatPrefix(specifier, value);
|
|
2399
|
-
}
|
|
2400
|
-
case "":
|
|
2401
|
-
case "e":
|
|
2402
|
-
case "g":
|
|
2403
|
-
case "p":
|
|
2404
|
-
case "r": {
|
|
2405
|
-
if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
|
|
2406
|
-
break;
|
|
2407
|
-
}
|
|
2408
|
-
case "f":
|
|
2409
|
-
case "%": {
|
|
2410
|
-
if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
|
|
2411
|
-
break;
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
return format(specifier);
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
function linearish(scale) {
|
|
2418
|
-
var domain = scale.domain;
|
|
2419
|
-
|
|
2420
|
-
scale.ticks = function(count) {
|
|
2421
|
-
var d = domain();
|
|
2422
|
-
return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
|
|
2423
|
-
};
|
|
2424
|
-
|
|
2425
|
-
scale.tickFormat = function(count, specifier) {
|
|
2426
|
-
var d = domain();
|
|
2427
|
-
return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
|
|
2428
|
-
};
|
|
2429
|
-
|
|
2430
|
-
scale.nice = function(count) {
|
|
2431
|
-
if (count == null) count = 10;
|
|
2432
|
-
|
|
2433
|
-
var d = domain();
|
|
2434
|
-
var i0 = 0;
|
|
2435
|
-
var i1 = d.length - 1;
|
|
2436
|
-
var start = d[i0];
|
|
2437
|
-
var stop = d[i1];
|
|
2438
|
-
var prestep;
|
|
2439
|
-
var step;
|
|
2440
|
-
var maxIter = 10;
|
|
2441
|
-
|
|
2442
|
-
if (stop < start) {
|
|
2443
|
-
step = start, start = stop, stop = step;
|
|
2444
|
-
step = i0, i0 = i1, i1 = step;
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
while (maxIter-- > 0) {
|
|
2448
|
-
step = tickIncrement(start, stop, count);
|
|
2449
|
-
if (step === prestep) {
|
|
2450
|
-
d[i0] = start;
|
|
2451
|
-
d[i1] = stop;
|
|
2452
|
-
return domain(d);
|
|
2453
|
-
} else if (step > 0) {
|
|
2454
|
-
start = Math.floor(start / step) * step;
|
|
2455
|
-
stop = Math.ceil(stop / step) * step;
|
|
2456
|
-
} else if (step < 0) {
|
|
2457
|
-
start = Math.ceil(start * step) / step;
|
|
2458
|
-
stop = Math.floor(stop * step) / step;
|
|
2459
|
-
} else {
|
|
2460
|
-
break;
|
|
2461
|
-
}
|
|
2462
|
-
prestep = step;
|
|
2463
|
-
}
|
|
2464
|
-
|
|
2465
|
-
return scale;
|
|
2466
|
-
};
|
|
2467
|
-
|
|
2468
|
-
return scale;
|
|
2469
|
-
}
|
|
2470
|
-
|
|
2471
|
-
function linear() {
|
|
2472
|
-
var scale = continuous();
|
|
2473
|
-
|
|
2474
|
-
scale.copy = function() {
|
|
2475
|
-
return copy$1(scale, linear());
|
|
2476
|
-
};
|
|
2477
|
-
|
|
2478
|
-
initRange.apply(scale, arguments);
|
|
2479
|
-
|
|
2480
|
-
return linearish(scale);
|
|
2481
|
-
}
|
|
2482
|
-
|
|
2483
|
-
function transformer() {
|
|
2484
|
-
var x0 = 0,
|
|
2485
|
-
x1 = 1,
|
|
2486
|
-
t0,
|
|
2487
|
-
t1,
|
|
2488
|
-
k10,
|
|
2489
|
-
transform,
|
|
2490
|
-
interpolator = identity$1,
|
|
2491
|
-
clamp = false,
|
|
2492
|
-
unknown;
|
|
2493
|
-
|
|
2494
|
-
function scale(x) {
|
|
2495
|
-
return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x));
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
scale.domain = function(_) {
|
|
2499
|
-
return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1];
|
|
2500
|
-
};
|
|
2501
|
-
|
|
2502
|
-
scale.clamp = function(_) {
|
|
2503
|
-
return arguments.length ? (clamp = !!_, scale) : clamp;
|
|
2504
|
-
};
|
|
2505
|
-
|
|
2506
|
-
scale.interpolator = function(_) {
|
|
2507
|
-
return arguments.length ? (interpolator = _, scale) : interpolator;
|
|
2508
|
-
};
|
|
2509
|
-
|
|
2510
|
-
function range(interpolate) {
|
|
2511
|
-
return function(_) {
|
|
2512
|
-
var r0, r1;
|
|
2513
|
-
return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)];
|
|
2514
|
-
};
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
|
-
scale.range = range(interpolate);
|
|
2518
|
-
|
|
2519
|
-
scale.rangeRound = range(interpolateRound);
|
|
2520
|
-
|
|
2521
|
-
scale.unknown = function(_) {
|
|
2522
|
-
return arguments.length ? (unknown = _, scale) : unknown;
|
|
2523
|
-
};
|
|
2524
|
-
|
|
2525
|
-
return function(t) {
|
|
2526
|
-
transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0);
|
|
2527
|
-
return scale;
|
|
2528
|
-
};
|
|
2529
|
-
}
|
|
2530
|
-
|
|
2531
|
-
function copy(source, target) {
|
|
2532
|
-
return target
|
|
2533
|
-
.domain(source.domain())
|
|
2534
|
-
.interpolator(source.interpolator())
|
|
2535
|
-
.clamp(source.clamp())
|
|
2536
|
-
.unknown(source.unknown());
|
|
2537
|
-
}
|
|
2538
|
-
|
|
2539
|
-
function sequential() {
|
|
2540
|
-
var scale = linearish(transformer()(identity$1));
|
|
2541
|
-
|
|
2542
|
-
scale.copy = function() {
|
|
2543
|
-
return copy(scale, sequential());
|
|
2544
|
-
};
|
|
2545
|
-
|
|
2546
|
-
return initInterpolator.apply(scale, arguments);
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
const COLOR_BASE = "#cecece";
|
|
2550
|
-
|
|
2551
|
-
// https://www.w3.org/TR/WCAG20/#relativeluminancedef
|
|
2552
|
-
const rc = 0.2126;
|
|
2553
|
-
const gc = 0.7152;
|
|
2554
|
-
const bc = 0.0722;
|
|
2555
|
-
// low-gamma adjust coefficient
|
|
2556
|
-
const lowc = 1 / 12.92;
|
|
2557
|
-
function adjustGamma(p) {
|
|
2558
|
-
return Math.pow((p + 0.055) / 1.055, 2.4);
|
|
2559
|
-
}
|
|
2560
|
-
function relativeLuminance(o) {
|
|
2561
|
-
const rsrgb = o.r / 255;
|
|
2562
|
-
const gsrgb = o.g / 255;
|
|
2563
|
-
const bsrgb = o.b / 255;
|
|
2564
|
-
const r = rsrgb <= 0.03928 ? rsrgb * lowc : adjustGamma(rsrgb);
|
|
2565
|
-
const g = gsrgb <= 0.03928 ? gsrgb * lowc : adjustGamma(gsrgb);
|
|
2566
|
-
const b = bsrgb <= 0.03928 ? bsrgb * lowc : adjustGamma(bsrgb);
|
|
2567
|
-
return r * rc + g * gc + b * bc;
|
|
2568
|
-
}
|
|
2569
|
-
const createRainbowColor = (root) => {
|
|
2570
|
-
const colorParentMap = new Map();
|
|
2571
|
-
colorParentMap.set(root, COLOR_BASE);
|
|
2572
|
-
if (root.children != null) {
|
|
2573
|
-
const colorScale = sequential([0, root.children.length], (n) => hsl(360 * n, 0.3, 0.85));
|
|
2574
|
-
root.children.forEach((c, id) => {
|
|
2575
|
-
colorParentMap.set(c, colorScale(id).toString());
|
|
2576
|
-
});
|
|
2577
|
-
}
|
|
2578
|
-
const colorMap = new Map();
|
|
2579
|
-
const lightScale = linear().domain([0, root.height]).range([0.9, 0.3]);
|
|
2580
|
-
const getBackgroundColor = (node) => {
|
|
2581
|
-
const parents = node.ancestors();
|
|
2582
|
-
const colorStr = parents.length === 1 ? colorParentMap.get(parents[0]) : colorParentMap.get(parents[parents.length - 2]);
|
|
2583
|
-
const hslColor = hsl(colorStr);
|
|
2584
|
-
hslColor.l = lightScale(node.depth);
|
|
2585
|
-
return hslColor;
|
|
2586
|
-
};
|
|
2587
|
-
return (node) => {
|
|
2588
|
-
if (!colorMap.has(node)) {
|
|
2589
|
-
const backgroundColor = getBackgroundColor(node);
|
|
2590
|
-
const l = relativeLuminance(backgroundColor.rgb());
|
|
2591
|
-
const fontColor = l > 0.19 ? "#000" : "#fff";
|
|
2592
|
-
colorMap.set(node, {
|
|
2593
|
-
backgroundColor: backgroundColor.toString(),
|
|
2594
|
-
fontColor,
|
|
2595
|
-
});
|
|
2596
|
-
}
|
|
2597
|
-
return colorMap.get(node);
|
|
2598
|
-
};
|
|
2599
|
-
};
|
|
2600
|
-
|
|
2601
|
-
const StaticContext = D({});
|
|
2602
|
-
const drawChart = (parentNode, data, width, height) => {
|
|
2603
|
-
const availableSizeProperties = getAvailableSizeOptions(data.options);
|
|
2604
|
-
console.time("layout create");
|
|
2605
|
-
const layout = treemap()
|
|
2606
|
-
.size([width, height])
|
|
2607
|
-
.paddingOuter(PADDING)
|
|
2608
|
-
.paddingTop(TOP_PADDING)
|
|
2609
|
-
.paddingInner(PADDING)
|
|
2610
|
-
.round(true)
|
|
2611
|
-
.tile(treemapResquarify);
|
|
2612
|
-
console.timeEnd("layout create");
|
|
2613
|
-
console.time("rawHierarchy create");
|
|
2614
|
-
const rawHierarchy = hierarchy(data.tree);
|
|
2615
|
-
console.timeEnd("rawHierarchy create");
|
|
2616
|
-
const nodeSizesCache = new Map();
|
|
2617
|
-
const nodeIdsCache = new Map();
|
|
2618
|
-
const getModuleSize = (node, sizeKey) => { var _a, _b; return (_b = (_a = nodeSizesCache.get(node)) === null || _a === void 0 ? void 0 : _a[sizeKey]) !== null && _b !== void 0 ? _b : 0; };
|
|
2619
|
-
console.time("rawHierarchy eachAfter cache");
|
|
2620
|
-
rawHierarchy.eachAfter((node) => {
|
|
2621
|
-
var _a;
|
|
2622
|
-
const nodeData = node.data;
|
|
2623
|
-
nodeIdsCache.set(nodeData, {
|
|
2624
|
-
nodeUid: generateUniqueId("node"),
|
|
2625
|
-
clipUid: generateUniqueId("clip"),
|
|
2626
|
-
});
|
|
2627
|
-
const sizes = { renderedLength: 0, gzipLength: 0, brotliLength: 0 };
|
|
2628
|
-
if (isModuleTree(nodeData)) {
|
|
2629
|
-
for (const sizeKey of availableSizeProperties) {
|
|
2630
|
-
sizes[sizeKey] = nodeData.children.reduce((acc, child) => getModuleSize(child, sizeKey) + acc, 0);
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
else {
|
|
2634
|
-
for (const sizeKey of availableSizeProperties) {
|
|
2635
|
-
sizes[sizeKey] = (_a = data.nodeParts[nodeData.uid][sizeKey]) !== null && _a !== void 0 ? _a : 0;
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2638
|
-
nodeSizesCache.set(nodeData, sizes);
|
|
2639
|
-
});
|
|
2640
|
-
console.timeEnd("rawHierarchy eachAfter cache");
|
|
2641
|
-
const getModuleIds = (node) => nodeIdsCache.get(node);
|
|
2642
|
-
console.time("color");
|
|
2643
|
-
const getModuleColor = createRainbowColor(rawHierarchy);
|
|
2644
|
-
console.timeEnd("color");
|
|
2645
|
-
S(e$1(StaticContext.Provider, Object.assign({ value: {
|
|
2646
|
-
data,
|
|
2647
|
-
availableSizeProperties,
|
|
2648
|
-
width,
|
|
2649
|
-
height,
|
|
2650
|
-
getModuleSize,
|
|
2651
|
-
getModuleIds,
|
|
2652
|
-
getModuleColor,
|
|
2653
|
-
rawHierarchy,
|
|
2654
|
-
layout,
|
|
2655
|
-
} }, { children: e$1(Main, {}, void 0) }), void 0), parentNode);
|
|
2656
|
-
};
|
|
2657
|
-
|
|
2658
|
-
exports.StaticContext = StaticContext;
|
|
2659
|
-
exports["default"] = drawChart;
|
|
2660
|
-
|
|
2661
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2662
|
-
|
|
2663
|
-
return exports;
|
|
2664
|
-
|
|
2665
|
-
})({});
|
|
2666
|
-
//# sourceMappingURL=treemap.js.map
|
|
2667
|
-
|
|
2668
|
-
/*-->*/
|
|
2669
|
-
</script>
|
|
2670
|
-
<script>
|
|
2671
|
-
/*<!--*/
|
|
2672
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"node_modules/@reach/observe-rect/dist/observe-rect.esm.js","uid":"27cd-1"},{"name":"packages/virtual-core/src","children":[{"uid":"27cd-3","name":"utils.ts"},{"uid":"27cd-5","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"27cd-1":{"renderedLength":1732,"gzipLength":652,"brotliLength":0,"mainUid":"27cd-0"},"27cd-3":{"renderedLength":1432,"gzipLength":544,"brotliLength":0,"mainUid":"27cd-2"},"27cd-5":{"renderedLength":12964,"gzipLength":2877,"brotliLength":0,"mainUid":"27cd-4"}},"nodeMetas":{"27cd-0":{"id":"/node_modules/@reach/observe-rect/dist/observe-rect.esm.js","moduleParts":{"index.production.js":"27cd-1"},"imported":[],"importedBy":[{"uid":"27cd-4"}]},"27cd-2":{"id":"/packages/virtual-core/src/utils.ts","moduleParts":{"index.production.js":"27cd-3"},"imported":[],"importedBy":[{"uid":"27cd-4"}]},"27cd-4":{"id":"/packages/virtual-core/src/index.ts","moduleParts":{"index.production.js":"27cd-5"},"imported":[{"uid":"27cd-0"},{"uid":"27cd-2"}],"importedBy":[],"isEntry":true}},"env":{"rollup":"2.75.4"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
2673
|
-
|
|
2674
|
-
const run = () => {
|
|
2675
|
-
const width = window.innerWidth;
|
|
2676
|
-
const height = window.innerHeight;
|
|
2677
|
-
|
|
2678
|
-
const chartNode = document.querySelector("main");
|
|
2679
|
-
drawChart.default(chartNode, data, width, height);
|
|
2680
|
-
};
|
|
2681
|
-
|
|
2682
|
-
window.addEventListener('resize', run);
|
|
2683
|
-
|
|
2684
|
-
document.addEventListener('DOMContentLoaded', run);
|
|
2685
|
-
/*-->*/
|
|
2686
|
-
</script>
|
|
2687
|
-
</body>
|
|
2688
|
-
</html>
|
|
2689
|
-
|