From 19fd89ba8680502cc4cadc7955ac75e3a2089007 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Mon, 11 Nov 2019 21:18:16 -0300 Subject: [PATCH 01/38] Add file icon --- src/res/fonts/icons.eot | Bin 3224 -> 3564 bytes src/res/fonts/icons.svg | 33 +++++++++++++++++---------------- src/res/fonts/icons.ttf | Bin 3068 -> 3400 bytes src/res/fonts/icons.woff | Bin 3144 -> 3476 bytes src/scss/_fonts.scss | 3 +++ 5 files changed, 20 insertions(+), 16 deletions(-) mode change 100755 => 100644 src/res/fonts/icons.eot mode change 100755 => 100644 src/res/fonts/icons.svg mode change 100755 => 100644 src/res/fonts/icons.ttf mode change 100755 => 100644 src/res/fonts/icons.woff diff --git a/src/res/fonts/icons.eot b/src/res/fonts/icons.eot old mode 100755 new mode 100644 index 5b837243e9839bda9683f251771a92faed788d9f..e35710b9ad0e15ae8fc2366e127289ceb1c6e772 GIT binary patch literal 3564 zcmb7HZ){rE6+ibr3?>*bJm6vC+WaYCWE-#_JVH`qr<#c~8z=FIok+`O;t(fMY%Cj3 z@l-8r?W(p~)o7X`In$(kXd(@J|Nng0`XL`HZE8CWrD_*VY+WRGtCW7}wrn-*-1i;{ zPMuD<=-&G~=N`^I_uO;OyZ0j_z!+8n6m}K@R|w-w9No!hvPvPMs6fnUQ!uiHn7~oavvIBGM<2?perPS^^iGMY@Ev zdoj0=U;m>1zer!lIbK{UtQ65sEXE!-4x9$a6=(sV>-6`?c}?lbKR_gUCf8I5n!U4( z0DKtW&erE)ojVKbIM{GLlXJ61o{i1eiDOF7$x@x5fh)*&<4=P<0e3Z2?X6B!e|GoH zyMMS_+2XgJ+xp4YuRaXax9fG3Kv`L0T$Xs}fy6IW2~z){`%m5PcmK9~#&yuO-?dNp zkMLb#R`{~xBb>R}GFjPY8Uh68F*iwK&?S=cA0Phv^LZ3**WcoL>3#4(1Q#XRbS9$H z>g>LFAQ&dWKwPv5T|{t*gNYPLNO7Gv5Vyo6anND6*tGP6F}p1tj>L|~BH^^nKF0H@ zP^hmz6iV^@U*i)KF|1@QF%Zpkbm(4vRoBsxi4G*9Jw3^Gv$;Ll(-SR?#|gy8$K!Qu zaor`f=bLEH)6fqR08ey5v}hN5qy!H5yn!J?h(E5F#M`vGV2Z@WU(?@7KX>l$+-a9< zP)KXdy7)vLD5=#a;<1Uc%^K6|$LQPJap@OkUh{~J21Az38+tBb3EFL1pGWnNXVCE!q3@QU3HuvAW1>fpV$>@7+(oXp<{^5ki{9ThNH23OiqhgMwSDBz zOf`#v4Gp1wcn0nB;-;c^(3i5;A|y=EX$eW*R&h|?WNc8zOk@eR{b4eMay|;;>4?$L zopfoh zB}@8{y@~wC>Jm9wi>xbdk@eCI{AU(5Y-B5_;(oTWy@_f_1=+Pt9ALI_1lK~@TH2rk z`~ZGDI2a}vB^a@mW+JZeWEKTqEaq*lUWL9PbA8?z0YsvRDBA#Rz7~w7*SQTmKSl__ zC>(=RY)&a5Dtjv8SyoSSOg`T}FAE8+T{-2v5(joA3;4WB3W&)u!YM~gHs0TaDGX$U zv}<*IV%3!vGSNe+;Zu9DoElE0oAJrXOwsG{c#E0I6HWLV{=Iwstdjl)x)BaMJ2mxe zApE1wy{A&CL+Rm^qA@j$8WDGL#N%C=L_L|wqQ~p?6elw$PfSj(cs;dSinfL>bh+k% zPyBEYGH?>z)bK$-&LQ$LgYw~Ejp_{C9{E)4>J7eW>wHa^g0kjTtq|?NGvW}i+H@DfX{ot>1@|q_5arkvt3M; z;OJ`f7#l3lD6wI}uNx4St#mAxV|KAy*n%uUG;@e}EFyi^Wvv}AW7_Jqy2@5(xfZfI zY40>SVs&oPX_mWcB?3$yb()l9{kKs+`<56Wi24VmcnnR(*mCTQtAS{9Tv6y7 z9`0pzSV|mq3X$+qBpit>g(HIVXhI_SR9`O>NRjUe!ZFNO*<9{sV&A^R&0H>L|KM@B9(B}sT z$38~t{@S!`Zy!f-S1tV=E>Q@E47GMoB;uh}PsG&uZNYE6W(mEh*KNCXdc7_)`J2on zZ>(OgjTm{}NN%zAF_?Z|5M3SpmQGW|^XYY2=aL~5l!TDwn$iF17SqSg>hx73UjyFA zG#UBQX8^{PdY5_rPL+Js{LCj{VAn5z_wKFFJnZWw4MET0rS!qo8~-QY_2lbXy{^Ig z5|eK#yrStL2kF~bOKP2F<5ei2SW>YD@v4g17tpR^ zE%L`zya#XDudrLCMvoj5jwqNSo>wu4cu2(>#Lua?1s@o06>E_{rQ$shgV)c`6&4DG z#htH|>HPA_`NE=mAROKOX|n6Tc4bcG=T|T0mUq5+c9l#Q7K`rr{9=ANSInPrpI&nx xo-1U~wlJjSXHgMXF^>JG&g-?j!n7FA*bw_BTeaF^&{o+K+Qxt$q6F!R>=Gq8_?Jv$R6X zv<{(#&QOKs=^8Cknbv@~s03sU(krT#m*Nzm7$p0@1i%;Sr5cG8`^Gn;6V|KxaUj1( zzc{;8UVZ)RFD9UL82p>_<@Hs}1K{srHq9?ypZnJ@bvp3x5gFfIsFW|;*YEz2$XtV5 zSpZ;M5MKfRF8Cu0OVyW;k?GsuAAmo(xH4O|Jm`B2ua1BZEtOwhB{y9JUjXl2E-zI+ z_{q{8@QYYud39yI3O~_$`S)HDb;MpHJ&|xncpu2mw3$7k1T%BJuEyZ@{`Nf4?mOaK zYo6|ibA(ks3p&^H@vGk@6O21*iK>Rt%vVD{NQ0@ z*S`Cs-Cys%)7opbxS_UuN|pcdGx={+IcxoO_%FjB4*zcWTb{3ZzUp~S{`F|evn;I`{h^dCsU#*`PMgCZe02#d5OSzGe@$r$7oMitv zS(r+pvztmhUKkuSZETnZ2Mh7I5(__@89>WC8-A&fWR#kkO0_7-PhO-N{Hej8BlHzY z5!snB43D1TkCKKU;13;Vj0IDgPj-jF7|ycPZ-qZ7Z@V)?`~4c6kn;wMDOqUYI<|;= zS9eHBvst*mrzme*CH(;x`+D+BEF`^*njbbznw!BBUd1u$hOZ2F=PZ0ZOLj16TiEF^ z1bpoP`4AytyI%K5O_JPhNg&C?eo=3Z*WchQ+u|eAmrCvZ4j}*AyX_b`%EEdZgQX$1 zA^csrrL!0`W8SJb+VnG%w9*lgCpd{X>`>+5Kn#*n`^@fP%wjbxZe zAXx(T6rUI$okJ=llp4iat=MSR8ns$OxY?*Ri?v3PjRW2S{<*diqH0C8m9nXJg*v`0 z!opUu0TZoaV{Z#)SOYM}YTP%GVJ`yTOE3Hi5CxGFND*X6Qn7c@X%*pj3RjB!$wc5O zeUqa}e;~oALlrs88N%*Mtxd6xd(%%NG)brF0$)!_C$#fS;0|jyIF(fIb->Tl!Qj+x zw_VEtr*``Te(mZf)%*~(tED;~?4kvVP0RVgA52YM^W&1mq2GiP21Mz>%km(8EZc3I5kU|l4iud3RauKN6b zUv+xs-1+I5s?XQFr&;UR3i90O#N-G)PX#)MFm+-OQr`}Bn_=~0@ZtXmM)$D=x{gpF zZObNuE9OxqCeDXKLj$s$@%uuIX))>Adv_fE?D7uF=znX^TpN4$#9Rhle}B~H8wvRX zN8Pf`ESdBFD+m{dV9M)~hdMLQL;l8ea>IlB!CxsOf5iD4C8OKIc(sl*pH0}tb5*M2 zwHlQ?b;(_Cj!JG}l%18_TSAGyST(n_SA#-{)nIoUcKL5dFNI-uLP;e<0Y7rewLhQY zvF>~lXe^f<=RKQNPRnvMvKoo1gDjs`((L=WvGFWdU_a-8k}HPowdxPv+JpUU6PWm=JHR;TyGfL4xy!kz49+k|ucqf!{{2wR?%n z(d+0OM`xVoc&Br`q*~}92dbSpRE8h19yZ5rus7NJf*@>&1L8696_HnD+yjZe%PTUp zj;AWq9xU{$wx3MZ(tH-kNHc9*1RiVCI?%Iin!oIwD#rjk*T#FugF+W|lFkgI2NI1I zP?eo+(<1Oxo7RC|Xw!NW%APiD0RCc|?x7@YT$x>2=Jj*C&MsBf)~~EAd*hMV(~Ii^ z`UluEmHBIn<+c5l`T?E%%5v2^UsfLr)F2CS5}rIlvm66DtS@nS5Wrz e;=W8(%$I>(qU#t>sjf~#lm9V59f#d~Vf!!oo Generated by IcoMoon - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/res/fonts/icons.ttf b/src/res/fonts/icons.ttf old mode 100755 new mode 100644 index ae2d611d882651ac4dfead54adc0fdae4e4586de..9a5b3cb2c673a39b7feeac1fa3243f1aace8c6be GIT binary patch literal 3400 zcmb7GU2Gf25uV+nNYNBUkw@|TbNE#GuQv*s{zx1ip1M?;FLeIHUPk#O%KeLl%gf+}b0}9(_AM0_iyNOc{|Dt8ILGtLrPVUp ziN)H_`hhb5xe9Fnbc6mDH7{!|`5TDD%*M48f@VKl#sS_BbLSchu)&>!4eVsTXcnIe z*leu!V4v1<>Zl$tz*W@y@Mpl5fUh2{57ejXKe_wb-QV4h~uI}r>T>ej3!r53P)lj5|%`#&`SijIFibc zlq{J7VacA9#Syp5?ljW(4!fM$SUh&9D8~(>eizQ3xq~s%@yrZ;hW`+;-$^3u^{a%5iXzNjMqUTcfh|6gV`gQ;K zN8C>k`c}2-b?h`89*=_(hnKuuRR*iqm`JwR_Zr(&3N!keyTH?2ag*o(iL}{?%Jwb# zq5MLd)u{3L%G`kBCuWD2-rupv-{jgf((;SSKJrIK&0=8FKxhb_Li+-^spuW_rRudf zi4k;KN>;a398otJKRCul)Ddj^V`LP^1u2MU;#Nyv+H16#%{JpjBbMQG`pU$_k;4-c zSJLTWrn#u~deeOtYy6Bz-mux8>+l$C5l>5REEEDAIYi|`KO{c0T1e3`? zYYk}fO;sBVBncoAMMU`~VDq(MEWN^Q;`y;c6ei#poMv;%DN)-~5zn%Il9THB4hC3A z7+u;a=e0O+X;~l`&{9BBjS)^eVyf|>7EEC{CuF^AlT&NntdL6_%8Z@fi{*L z>NN7?rpx|7z+axuojN%^y&CW7pV7rNZ=z$YO%2st=~Zfg1})~y2%0%c{C1JP<#i}0s+hJ09NwzKQ&pl44;`2xM;)FmI>U08QX$}R>|ELOIA%yi z<-ddc>@KlD1o=l~DTyXyY`GtftKmdzTu~St8yjGCOin%H5#q7scq|@Yj>QGfGbx!A zGlK(cK!$ur5RPHK$`=Z^Qv3F$ZWRjoOiDf`;DP5Jtj!1k$l&ZQ!4$EJTyvuzGuWwc z+xMq~?(E~mG7Z&Nw7LpC2F`yNvYxbsE{;K1$-Q*@wElq7aE%lrDcf z?x%HsytC&ULdbgE9(~?y+VPppW>aqZSGj54TEC%;TY26}ZnN(rF#WC|db@}0J)Lp? zM>kZ?WlJ<73sL)ZYv`kG#>dT>%ylcT0B>bXR=)BHfN`b2WxoDyoqW;u)Q4bU&o6+t z?`_O}+%_r(f}X=iDaN^0@PF!CPkpX68U}nX={?Pc*O;0jOBHYjYela!tRHI?E7M~o z3^RSRGCjlND$5>x3-sc9_Eo5p4sxDU$Sv|ZHPWk`llu(!HSRBlWz`BE&f&JE6hTLn{HhHWc@%1&Ptqm1%TjB&-T+^=TZrwDGb`v{F zTtwO3)>`qST18rfprXG){ozEQR)CP;M}H#350Ko5M}?xINBv@$|DfXVZ*QU1- zk7cAYb6)qGGiT1s9UuVE4K?5(_S7@cQTtir2x>k=IytpaT72cnClUZ;7s_wWmX;TB z>_zzoj+WW^^E3Z_!(c%9BLMUJbJL~M&gH9r1+do8uFRprJjcC=^7|<7o?EECuooa`0Da0&GfVKz9hp-$Ww+!)@-Z(O_c(VfrkG&Y@^f7^U}^WD}~tED1o_Hotz z=}-1|R6A*XGw{{GmjfRRJnMVh_o(j?;YZ;W;iT{!V(Vj4fwpx72+m;F`B8vWTK(+) zx4*8Vu->}K4bc{e5WzGgTxJ_Fo6PP&G8B%Ga44B@2@es$lNe29NJ=sLLrI6MBt|`M zhs#87A9T6LqLE}ljz-7au7gfKJ2*HpGB}v!oww!ucoK-ybX<%ZN8*2KAh4<0c)(+(o zXVeg@|7<=&zV`B$)tb0w06GkNFg8DKC}sxpsAeomA_NnbQq(O?jH(-q9s1ab>cO@? zLiV8_g~X|7PxnCDXR=$ZcGFoCws<;yVQlQsp|P2#cF&T7`awAf{fOp%**`%60n zqdn}^8Kc3VZ0qT<$-!V$2j&gijjo=T><(7m1nR98SEQ?8!MlQnQ&Lh2Qy|4=eeb=k z|4_?4y4tLx@Ll0M=5K&?7{>a&h<8CZI6y#%1QtucnPdZDy}Msk(PE=es}&l}TBBBL z(2I>)vruak$Ox*}Q2&cq2~I^(v62oIm)7yi0wSyx8VJ!UG`7|dhBQ#kbTt+mM{q5a zt)&~|3IGJLCa^@XLS)6M<5Q}Johdw0;FlADpP^NzmHmMPfeu$-A`<{tUu>;%bv!pc zFbHFC7*4SHlvG07&jg-f?F1)f^;`%1tQ<^k?Q}b}8gOf;Kj7DnzO2>Rmty{suPpPj!#ThC8>EsL+fA#S#5N3vKtMb-b;Hcwe3O)|*4TmkyDmymyTj*^O26@>?}@ zD3TiDt|Kn{cXUG-aYvP;918fcraTYUQ#_`xCkn&a%m|}QN;xbD(a2&Xs&;~KSV@t; zWQRvG%z?bh6iT*GDqT%syILw0vI_fz{UiJ*TIXb+tq+BAf)%gA8%Jzl*qmf>}b@%%}+xPw(y74)M?en4d+52N_6>o9&j<8_9 zwT9oQZx<|Z*05(t`o?RP`zn;zk!o!!GCNWoiRqCD zKh@^h&E9$Cm{6Z>>$|`QOYEIwu%f05EgDbpRd%$^bEr?Yc?0ruZQckT{95xjq5g?B z-vu(PoSCYWm*ETsP=PWm7pIq&&s54{JQBlbO4aGp;;HlEp{dG5rBaSSPMxWWbIl?^S)IQGRUA*F X?i8HI{*W5#1bVWl@EwP%`PKG6XqPfJ diff --git a/src/res/fonts/icons.woff b/src/res/fonts/icons.woff old mode 100755 new mode 100644 index e2bfc02f387420dc8391207dce9144fa3586c958..b383e7b427d205799da34ea01af7beee9b391b05 GIT binary patch literal 3476 zcmb7GZ){sv6+ibr$Byedj{R&u$ITM|neA9fY$wmpuG_^)C*r0gPS)ZktwbSi>Ljh2 zI7%F7&_oT4X`7fN*%->Xf1Avy>^T5)Zbk>x_mD|1Wv z733}Ae4A0e=S$ZX@@vSWcAPU=M(qn1H|CMoiPIXRLiN%Ii-r6-fPMFIJ;BH+e`RYC znE<9Z&L3xFxWIjFajA3(d8cqb!Ds|puU#z8F}dqF?_t#T7i(!Le+lkjzAQB_an;U6wo-sTE z@KKPPuP?wRHxHZ0A&jjxk1{H|AnL?5hC8umQk|fKD>!=ar^AterxvdD)+TB{y7Tip zzrIu5;dh?i`Qgs%9|h~X^*TzRtRgY4Nc`%7#7{K|Qva~~x83h|ztuhCKH@&)J}CTM z_^vQ3e9`%_wx^=xp&bE&`&iJDMxy}9lrsH)c@%Ef-{yMhJ@7&lof7SaHe%2l9DXSn zijYuH675145uD;+GEI^R$>0l0)_6i3bULhdJ^gUZVb4UO@ssgrBx84s@q9WQ?&}YS z(>(tNX<{OdL^hHGv1~_&;l&pX9Ua-&Kr+_TlWMnE+EYC}vGTY?KpG#H>e!>-WwhrT zXwT!&&+?5Yh7ek`hdqfTF8F=HAwoz%QcdFRdP68pB=HUUi^PvzhdMuNmwQmi=q(0m zq7IbE^$96HQL)?NM&lTLXID!6#KPo%9mMv2W$UaH7_m8)z@wpo9bog9T}&F6M- zH9T%8I!r<>R-$P84*fLoT#H$+>hqMiUfD~GHaESuYf3!NwWvxflZj(8BRwVCOEYIwB=`0~v(`qCT6x*O5K8EGi#mAoMeWJazG-QE2wHQuE+-&?mW1Sp0Nw z8v>Za8(0@iU}}*f zRF}vpS`=N9Rnbeg@Si!L>qFZ-bb0ssNLIG84w zC77|+=82^86cz=4Jnm~IpE|#xaQ(hG0YsvRDAxdNzZT4;>)aOJA2Wnu6pq6gwr3(K zs%I+VUDj@LT)E$VA4>_nL%rp^ng!l_qGF+R|QDGX$VjC*~2V%?n) zvazG-;WG!Yof%GNn(^t$Y{}>K`byc!Q%(5mfddBuj7Wb2-G~IAJaOX5VC4Iq2hOC^ zM>E4|RbzS>H6rfhh}X9^iF&e=C9lutElp-mpPHOp^Lgc4sOagEOvTz#1 z)QCY)sUeD+A?0$gP74Mek8&&aj0WFybp9qxLG`&+FT^^qOr8z~x-5cl2{Phr`TY@R=FxJQ25PH`=Lqcn=Ft-uKo2AJGIxtBW2Nvy3XZ}_ zm_tvLI*j(?lc2{(*NNwqz&AJ;3gKn;OI-wCy~cAP#>7KJ92~%yA0`}ojI{H$>)F{p zY{p%+_IJ2NArv;r?cQkAOKaX}Tj#fhfccs={H)Qi>oFLOhV0~<*-749dsQAW^Sqhd zV*Nuf{hlDYJNm7iZBg(2R~4Nrrf?`Bgss=if%`j5A2(|-*37&NyqRe-^X2~lm{;1j z%(p(MkuO`G_!La+^9$g;yPGrr8tY{p!N{@iSo{i78valD)>A&$>UAA{FKH`{fmby( zrmR%JZKSeB(`+57g2ebpgki>S5aTmEqG;KN-vV7Q4?lw%*-sWpncO6AQ$4-H*}2bg z-{k(NTT!gw;T)bfYYl6aiPp8j4>Vf|7?7vhO%cy(m_wY|~(6Ao);~L%v zZg_!xRqBk$X~Pv2Q^X4z<`55QScmv&4Yz<3JQ~&`|AdD3K^(51pDQjEi_35xQ?&?7 zNJUtlF08JdFD`oqA~BeT0<6Ls3g80j8Gs1H_WakL%oBx$^^5sc+_Zp(uERyh!|I-r znc{NEvrt$rtmaFFbDpyso?~;xEZP=!{_HD z(QTZzHc{lk2m~|;+8};T;0H=bkst{Qv=4bKiaay`EwqUd2nh_R2w((g3$#T=cIJ+( zX(LXX1!i~V+qv19+1b7Q@w0^jFu*o=3iqaYGJi< z1+f*BUnhF`o6n?{E9;2yL6k|CXn6VZwI#&d0OsEi{qr@0VP&y$0l@k`&Z|VO_1iyL zK@h-ZK=}ZXc|~}BWwrhsVh2$^Msye~-@RO0AU#|MB1HDPgZEb}&!KF473F|NJ~&sc ztS%ykYqBcQ2R~oEb)~jm$9Tz}t|uTT7=XP5M)dI(Cy#!ikL)u@F)PabjScrp#D4=| z_Z?xWvkbR{CAftMBe>fF+NiC9+#n95cudED;R+7TD_w;HWU^W)590Z9jKg;4jxfPH5P%q_A>}sPnb~Cagwl~{ zj71~qlv{d&N#4|SCdV?WIT%Sh6*V>O^*G%o{>d@7XC@v?my~#X#^XNb67%EZQ&Z#P zdC~QWQk+dAu^VbKSsWR$Y;0IYMvBR#nus3E4r9w6jDD-AFi6kNraPb%F$e(~=uZRv zIRIaSG=Phlqv+8W_@icUA{2}qVT^^-x=${*$sEnG^t=2I>RZ0-=)-=EOiKlm-J%pb zz@Y==UDGWpRx7`=r>bu`MB^ha4%!M#C@KL4?GM`)-OcdPfa;#`p|1=Ya0-1r1uhga z&Zx(23d!9B$(SL&-E8{BHi$l-$U*e8Up3oP%~wcdThwFuLb)67FrZC6+Mba^ENXNz zv^2^#_}|o<2D?c&7N`po?I5#=e%{#|RBsAK-D3U4_LJ;mpZJPa6K@)TPr@PeEr=V6 znZZ128H=+R!-Qp2ZA(+r+6H5XIu533(ALM;5!B<5Iv*bz7|Z%i4y)B+x@5wZ%x168 z%p5;HGjlzgO%ifRpB>2tZ1&g!yW?=YFen)vQD5I=JRDZ+Lqm2Y9FF%H^FR`6k^%RvyjBX*tS)mD|n3_xJw6E%*6myNSZ*rO!#<0NXH$^?L*Ff&p-X zgeFp0EFo8#21dPSRD*cARcbU!t#+f;Xtel^R-;{Nv`TCW;Vr};YbzyaRy12_r)HNo z@yilg*ebQqM5ol++d?y}g)m_a@=ahE3#V8H(610c7;6Gc1S>>QU448;L+DK5k%FL- z3Vi`>5~>74DF!{RL?Q`*(U&`$LKDx;5RAhNoPe{mo|;MN`Q{|91r*L91?R31K+?hW9XW@PO!bEJU$8E;LPoF&bbU40+R`R*R(OjR!Tpq0pAj@^l&Rks% z2IczP{OL1u^L1Hnzo%R4*$Pu_^m1|lZ~P*h#x(VE5Yg@qEzGEPFsS=KlF`3yp}sBT zpoeTRc@uthdiqQxGCC|t*`OR@OwUPQ?EQK8vo|m%A^oL0k~YTfPk2p+p`o}ek4J)` zLq5rA6|IH;m4tJnXe!{9MtdXGA>A>(+VJD~pj*mJmpI)~5|T5Dx7HCRJNY(VSLG(& zRuiJXDf*i23DL(V*eTJs#mjVKHGJY;0~N}wfp)jiF8w1)!W~%SmWILUSMaUziRvW$Lt)R+*wm^GT3W<^>U?sp?@^et9L*9 z>kk}<{|*E6i~{)6MDo&uv9pP{IK3k*m~Xw|H`?0;3!EDEWU0T2`pg3e#<&EIQuXTMB;?Hz>8z``GaiLaShl}Vy4XUtSUR+zhSgQt-u>@vh z5!a+inhHP?UrmWe^dAvVE-qiaTv>yY_~|lSh09QZwMTRcwQ4=EyjWdatJD`S1kPUz w9ABu-)oRrk6ttDoGh3`0w=1bdu08k1vy#N3J diff --git a/src/scss/_fonts.scss b/src/scss/_fonts.scss index 2a00340..f106f40 100755 --- a/src/scss/_fonts.scss +++ b/src/scss/_fonts.scss @@ -89,3 +89,6 @@ .icon-videocam_off:before { content: "\e04c"; } +.icon-file-text2:before { + content: "\e926"; +} From 3352c68f5c3cdc47ab856c57e5c21a61d78be5ee Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Mon, 11 Nov 2019 22:13:31 -0300 Subject: [PATCH 02/38] Disable pointer events on notifications and alerts --- src/scss/_alert.scss | 1 + src/scss/_notification.scss | 1 + 2 files changed, 2 insertions(+) diff --git a/src/scss/_alert.scss b/src/scss/_alert.scss index e34c6df..7767c95 100644 --- a/src/scss/_alert.scss +++ b/src/scss/_alert.scss @@ -9,6 +9,7 @@ top: 0; transition: visibility 100ms ease-in, opacity 100ms ease-in; z-index: 4; + pointer-events: none; span { display: inline-block; diff --git a/src/scss/_notification.scss b/src/scss/_notification.scss index ee22eee..fdf2d47 100644 --- a/src/scss/_notification.scss +++ b/src/scss/_notification.scss @@ -1,4 +1,5 @@ .notifications { + pointer-events: none; font-family: $font-monospace; font-size: 10px; left: 1rem; From 644fcbe06df48e978720e394c504a579e0f23331 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Mon, 11 Nov 2019 22:14:37 -0300 Subject: [PATCH 03/38] Add ability to send file via base64-encoded msg --- src/client/actions/PeerActions.js | 61 ++++++++++++++++++++++++++++--- src/client/components/App.js | 3 ++ src/client/components/Chat.js | 7 +++- src/client/components/Toolbar.js | 31 ++++++++++++++++ src/client/containers/App.js | 3 +- 5 files changed, 98 insertions(+), 7 deletions(-) diff --git a/src/client/actions/PeerActions.js b/src/client/actions/PeerActions.js index 7e44a39..c05a10d 100644 --- a/src/client/actions/PeerActions.js +++ b/src/client/actions/PeerActions.js @@ -1,3 +1,4 @@ +import * as ChatActions from '../actions/ChatActions.js' import * as NotifyActions from '../actions/NotifyActions.js' import * as StreamActions from '../actions/StreamActions.js' import * as constants from '../constants.js' @@ -46,10 +47,25 @@ class PeerHandler { } handleData = object => { const { dispatch, user } = this - object = JSON.parse(new window.TextDecoder('utf-8').decode(object)) + const message = JSON.parse(new window.TextDecoder('utf-8').decode(object)) debug('peer: %s, message: %o', user.id, object) - const message = user.id + ': ' + object.message - dispatch(NotifyActions.info(message)) + switch (object.type) { + case 'file': + dispatch(ChatActions.addMessage({ + userId: user.id, + message: 'Sent a file: "' + message.payload.name, + timestamp: new Date().toLocaleString(), + image: message.payload.data + })) + break + default: + dispatch(ChatActions.addMessage({ + userId: user.id, + message: message.payload, + timestamp: new Date().toLocaleString(), + image: null + })) + } } handleClose = () => { const { dispatch, user } = this @@ -126,7 +142,42 @@ export const destroyPeers = () => ({ }) export const sendMessage = message => (dispatch, getState) => { - message = JSON.stringify({ message }) const { peers } = getState() - _.each(peers, peer => peer.send(message)) + dispatch(NotifyActions.info('Sending message type: {0} to {1} peers.', + message.type, Object.keys(peers).length)) + _.each(peers, peer => { + switch (message.type) { + case 'file': + dispatch(ChatActions.addMessage({ + userId: 'You', + message: 'Send file: "' + + message.payload.name + '" to peer: ' + peer._id, + timestamp: new Date().toLocaleString(), + image: message.payload.data + })) + } + peer.send(JSON.stringify(message)) + }) +} + +export const sendFile = file => async (dispatch, getState) => { + const { name, size, type } = file + if (!window.FileReader) { + dispatch(NotifyActions.error('File API is not supported by your browser')) + return + } + const reader = new window.FileReader() + const base64File = await new Promise(resolve => { + reader.addEventListener('load', () => { + resolve({ + name, + size, + type, + data: reader.result + }) + }) + reader.readAsDataURL(file) + }) + + sendMessage({ payload: base64File, type: 'file' })(dispatch, getState) } diff --git a/src/client/components/App.js b/src/client/components/App.js index 955f003..5cdd1d7 100644 --- a/src/client/components/App.js +++ b/src/client/components/App.js @@ -20,6 +20,7 @@ export default class App extends React.PureComponent { peers: PropTypes.object.isRequired, sendMessage: PropTypes.func.isRequired, streams: PropTypes.objectOf(StreamPropType).isRequired, + onSendFile: PropTypes.func.isRequired, toggleActive: PropTypes.func.isRequired } constructor () { @@ -56,6 +57,7 @@ export default class App extends React.PureComponent { notifications, notify, messages, + onSendFile, peers, sendMessage, toggleActive, @@ -70,6 +72,7 @@ export default class App extends React.PureComponent { chatVisible={this.state.chatVisible} messages={messages} onToggleChat={this.handleToggleChat} + onSendFile={onSendFile} stream={streams[constants.ME]} /> diff --git a/src/client/components/Chat.js b/src/client/components/Chat.js index cc4e428..74d6966 100644 --- a/src/client/components/Chat.js +++ b/src/client/components/Chat.js @@ -82,7 +82,12 @@ export default class Chat extends React.PureComponent { -

{message.message}

+

+ {message.image && ( + + )} + {message.message} +

)} diff --git a/src/client/components/Toolbar.js b/src/client/components/Toolbar.js index 65c52f9..dd060d2 100644 --- a/src/client/components/Toolbar.js +++ b/src/client/components/Toolbar.js @@ -5,13 +5,22 @@ import screenfull from 'screenfull' import { MessagePropTypes } from './Chat.js' import { StreamPropType } from './Video.js' +const hidden = { + display: 'none' +} + export default class Toolbar extends React.PureComponent { static propTypes = { messages: PropTypes.arrayOf(MessagePropTypes).isRequired, stream: StreamPropType, onToggleChat: PropTypes.func.isRequired, + onSendFile: PropTypes.func.isRequired, chatVisible: PropTypes.bool.isRequired } + constructor (props) { + super(props) + this.file = React.createRef() + } handleMicClick = () => { const { stream } = this.props stream.mediaStream.getAudioTracks().forEach(track => { @@ -35,6 +44,14 @@ export default class Toolbar extends React.PureComponent { handleHangoutClick = () => { window.location.href = '/' } + handleSendFile = () => { + this.file.current.click() + } + handleSelectFiles = () => { + Array + .from(this.file.current.files) + .forEach(file => this.props.onSendFile(file)) + } render () { const { messages, stream } = this.props @@ -49,6 +66,20 @@ export default class Toolbar extends React.PureComponent { > +
+ + +
{stream && (
diff --git a/src/client/containers/App.js b/src/client/containers/App.js index 72c4b77..552be30 100644 --- a/src/client/containers/App.js +++ b/src/client/containers/App.js @@ -23,7 +23,8 @@ function mapDispatchToProps (dispatch) { sendMessage: bindActionCreators(PeerActions.sendMessage, dispatch), dismissAlert: bindActionCreators(NotifyActions.dismissAlert, dispatch), init: bindActionCreators(CallActions.init, dispatch), - notify: bindActionCreators(NotifyActions.info, dispatch) + notify: bindActionCreators(NotifyActions.info, dispatch), + onSendFile: bindActionCreators(PeerActions.sendFile, dispatch) } } From 7e5c7db3f9e59091104ca2e2782fc2b18a5f9673 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Mon, 11 Nov 2019 22:21:25 -0300 Subject: [PATCH 04/38] Show all notifications in chat log --- src/client/actions/NotifyActions.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client/actions/NotifyActions.js b/src/client/actions/NotifyActions.js index 43f4095..5cdf875 100644 --- a/src/client/actions/NotifyActions.js +++ b/src/client/actions/NotifyActions.js @@ -1,4 +1,5 @@ import * as constants from '../constants.js' +import * as ChatActions from './ChatActions.js' import _ from 'underscore' const TIMEOUT = 5000 @@ -18,6 +19,12 @@ const _notify = (type, args) => dispatch => { type: constants.NOTIFY, payload }) + dispatch(ChatActions.addMessage({ + userId: '[PeerCalls]', + message, + timestamp: new Date().toLocaleString(), + image: null + })) setTimeout(() => { dispatch({ type: constants.NOTIFY_DISMISS, From 6d3201d1feecea2c868a01dab02a5544abba802e Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Mon, 11 Nov 2019 23:10:10 -0300 Subject: [PATCH 05/38] Fix broken tests --- src/client/actions/CallActions.test.js | 24 ++++++++++++++ src/client/actions/ChatActions.js | 5 --- src/client/actions/PeerActions.js | 18 ++++++++--- src/client/actions/PeerActions.test.js | 23 +++++++------ src/client/actions/SocketActions.js | 13 -------- src/client/components/App.js | 3 -- src/client/components/Chat.js | 32 +++++++++++------- src/client/components/Input.js | 45 ++++++++++---------------- src/client/components/Input.test.js | 9 +++--- src/client/components/Toolbar.js | 4 +-- src/client/components/Toolbar.test.js | 35 +++++++++++++++++--- src/client/constants.js | 3 -- src/client/containers/App.js | 1 - src/client/reducers/messages.js | 2 -- src/client/reducers/messages.test.js | 8 ----- src/server/socket.js | 23 +------------ src/server/socket.test.js | 5 ++- 17 files changed, 124 insertions(+), 129 deletions(-) diff --git a/src/client/actions/CallActions.test.js b/src/client/actions/CallActions.test.js index 375c1bb..bc3f6d6 100644 --- a/src/client/actions/CallActions.test.js +++ b/src/client/actions/CallActions.test.js @@ -39,6 +39,14 @@ describe('reducers/alerts', () => { message: 'Connected to server socket', type: 'warning' } + }, { + type: constants.MESSAGE_ADD, + payload: { + image: null, + message: 'Connected to server socket', + timestamp: jasmine.any(String), + userId: '[PeerCalls]' + } }]) await promise expect(SocketActions.handshake.mock.calls).toEqual([[{ @@ -62,6 +70,14 @@ describe('reducers/alerts', () => { message: 'Connected to server socket', type: 'warning' } + }, { + type: constants.MESSAGE_ADD, + payload: { + image: null, + message: 'Connected to server socket', + timestamp: jasmine.any(String), + userId: '[PeerCalls]' + } }, { type: constants.NOTIFY, payload: { @@ -69,6 +85,14 @@ describe('reducers/alerts', () => { message: 'Server socket disconnected', type: 'error' } + }, { + type: constants.MESSAGE_ADD, + payload: { + image: null, + message: 'Server socket disconnected', + timestamp: jasmine.any(String), + userId: '[PeerCalls]' + } }]) await promise }) diff --git a/src/client/actions/ChatActions.js b/src/client/actions/ChatActions.js index e057a60..ef01410 100644 --- a/src/client/actions/ChatActions.js +++ b/src/client/actions/ChatActions.js @@ -9,8 +9,3 @@ export const addMessage = ({ userId, message, timestamp, image }) => ({ image } }) - -export const loadHistory = messages => ({ - type: constants.MESSAGES_HISTORY, - messages -}) diff --git a/src/client/actions/PeerActions.js b/src/client/actions/PeerActions.js index c05a10d..eba865e 100644 --- a/src/client/actions/PeerActions.js +++ b/src/client/actions/PeerActions.js @@ -49,7 +49,7 @@ class PeerHandler { const { dispatch, user } = this const message = JSON.parse(new window.TextDecoder('utf-8').decode(object)) debug('peer: %s, message: %o', user.id, object) - switch (object.type) { + switch (message.type) { case 'file': dispatch(ChatActions.addMessage({ userId: user.id, @@ -143,18 +143,26 @@ export const destroyPeers = () => ({ export const sendMessage = message => (dispatch, getState) => { const { peers } = getState() - dispatch(NotifyActions.info('Sending message type: {0} to {1} peers.', - message.type, Object.keys(peers).length)) - _.each(peers, peer => { + debug('Sending message type: %s to %s peers.', + message.type, Object.keys(peers).length) + _.each(peers, (peer, userId) => { switch (message.type) { case 'file': dispatch(ChatActions.addMessage({ userId: 'You', message: 'Send file: "' + - message.payload.name + '" to peer: ' + peer._id, + message.payload.name + '" to peer: ' + userId, timestamp: new Date().toLocaleString(), image: message.payload.data })) + break + default: + dispatch(ChatActions.addMessage({ + userId: 'You', + message: message.payload, + timestamp: new Date().toLocaleString(), + image: null + })) } peer.send(JSON.stringify(message)) }) diff --git a/src/client/actions/PeerActions.test.js b/src/client/actions/PeerActions.test.js index e011607..45f46a0 100644 --- a/src/client/actions/PeerActions.test.js +++ b/src/client/actions/PeerActions.test.js @@ -96,16 +96,15 @@ describe('PeerActions', () => { }) it('decodes a message', () => { - const message = 'test' - const object = JSON.stringify({ message }) + const payload = 'test' + const object = JSON.stringify({ payload }) peer.emit('data', Buffer.from(object, 'utf-8')) - const { notifications } = store.getState() - const keys = Object.keys(notifications) - const n = notifications[keys[keys.length - 1]] - expect(n).toEqual({ - id: jasmine.any(String), - type: 'info', - message: `${user.id}: ${message}` + const { messages } = store.getState() + expect(messages[messages.length - 1]).toEqual({ + userId: 'user2', + timestamp: jasmine.any(String), + image: null, + message: 'test' }) }) }) @@ -158,12 +157,12 @@ describe('PeerActions', () => { }) it('sends a message to all peers', () => { - store.dispatch(PeerActions.sendMessage('test')) + store.dispatch(PeerActions.sendMessage({ payload: 'test', type: 'text' })) const { peers } = store.getState() expect(peers['user2'].send.mock.calls) - .toEqual([[ '{"message":"test"}' ]]) + .toEqual([[ '{"payload":"test","type":"text"}' ]]) expect(peers['user3'].send.mock.calls) - .toEqual([[ '{"message":"test"}' ]]) + .toEqual([[ '{"payload":"test","type":"text"}' ]]) }) }) diff --git a/src/client/actions/SocketActions.js b/src/client/actions/SocketActions.js index f017d14..69c6429 100644 --- a/src/client/actions/SocketActions.js +++ b/src/client/actions/SocketActions.js @@ -1,4 +1,3 @@ -import * as ChatActions from '../actions/ChatActions.js' import * as NotifyActions from '../actions/NotifyActions.js' import * as PeerActions from '../actions/PeerActions.js' import * as constants from '../constants.js' @@ -42,16 +41,6 @@ class SocketHandler { .filter(id => !newUsersMap[id]) .forEach(id => peers[id].destroy()) } - handleMessages = (messages) => { - const { dispatch } = this - debug('socket messages: %o', messages) - dispatch(ChatActions.loadHistory(messages)) - } - handleNewMessage = (payload) => { - const { dispatch } = this - debug('socket message: %o', payload) - dispatch(ChatActions.addMessage(payload)) - } } export function handshake ({ socket, roomName, stream }) { @@ -66,8 +55,6 @@ export function handshake ({ socket, roomName, stream }) { socket.on(constants.SOCKET_EVENT_SIGNAL, handler.handleSignal) socket.on(constants.SOCKET_EVENT_USERS, handler.handleUsers) - socket.on(constants.SOCKET_EVENT_MESSAGES, handler.handleMessages) - socket.on(constants.SOCKET_EVENT_NEW_MESSAGE, handler.handleNewMessage) debug('socket.id: %s', socket.id) debug('emit ready for room: %s', roomName) diff --git a/src/client/components/App.js b/src/client/components/App.js index 5cdd1d7..79ce691 100644 --- a/src/client/components/App.js +++ b/src/client/components/App.js @@ -15,7 +15,6 @@ export default class App extends React.PureComponent { dismissAlert: PropTypes.func.isRequired, init: PropTypes.func.isRequired, notifications: PropTypes.objectOf(NotificationPropTypes).isRequired, - notify: PropTypes.func.isRequired, messages: PropTypes.arrayOf(MessagePropTypes).isRequired, peers: PropTypes.object.isRequired, sendMessage: PropTypes.func.isRequired, @@ -55,7 +54,6 @@ export default class App extends React.PureComponent { alerts, dismissAlert, notifications, - notify, messages, onSendFile, peers, @@ -79,7 +77,6 @@ export default class App extends React.PureComponent { + {message.image && ( + + )} + {message.message} +

+ ) +} + +Message.propTypes = { + message: MessagePropTypes +} + export default class Chat extends React.PureComponent { static propTypes = { visible: PropTypes.bool.isRequired, messages: PropTypes.arrayOf(MessagePropTypes).isRequired, - notify: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, sendMessage: PropTypes.func.isRequired, videos: PropTypes.object.isRequired @@ -35,7 +49,7 @@ export default class Chat extends React.PureComponent { this.scrollToBottom() } render () { - const { messages, videos, notify, sendMessage } = this.props + const { messages, videos, sendMessage } = this.props return (
(
- {message.userId === socket.id ? ( + {message.userId === 'You' ? (
@@ -61,7 +75,7 @@ export default class Chat extends React.PureComponent { -

{message.message}

+
{message.image ? ( @@ -82,12 +96,7 @@ export default class Chat extends React.PureComponent { -

- {message.image && ( - - )} - {message.message} -

+
)} @@ -104,7 +113,6 @@ export default class Chat extends React.PureComponent {
diff --git a/src/client/components/Input.js b/src/client/components/Input.js index adb52df..cfa8ec1 100644 --- a/src/client/components/Input.js +++ b/src/client/components/Input.js @@ -1,11 +1,8 @@ import PropTypes from 'prop-types' import React from 'react' -import socket from '../socket.js' export default class Input extends React.PureComponent { static propTypes = { - videos: PropTypes.object.isRequired, - notify: PropTypes.func.isRequired, sendMessage: PropTypes.func.isRequired } constructor () { @@ -35,35 +32,27 @@ export default class Input extends React.PureComponent { }) } submit = () => { - const { videos, notify, sendMessage } = this.props + const { sendMessage } = this.props const { message } = this.state if (message) { - notify('You: ' + message) - sendMessage(message) - - const userId = socket.id - const timestamp = new Date().toLocaleString('en-US', { - hour: 'numeric', - minute: 'numeric', - hour12: false + sendMessage({ + payload: message, + type: 'text' }) - let image = null + // let image = null - // take snapshoot - try { - const video = videos[userId] - if (video) { - const canvas = document.createElement('canvas') - canvas.height = video.videoHeight - canvas.width = video.videoWidth - const avatar = canvas.getContext('2d') - avatar.drawImage(video, 0, 0, canvas.width, canvas.height) - image = canvas.toDataURL() - } - } catch (e) {} - - const payload = { userId, message, timestamp, image } - socket.emit('new_message', payload) + // // take snapshoot + // try { + // const video = videos[userId] + // if (video) { + // const canvas = document.createElement('canvas') + // canvas.height = video.videoHeight + // canvas.width = video.videoWidth + // const avatar = canvas.getContext('2d') + // avatar.drawImage(video, 0, 0, canvas.width, canvas.height) + // image = canvas.toDataURL() + // } + // } catch (e) {} } this.setState({ message: '' }) } diff --git a/src/client/components/Input.test.js b/src/client/components/Input.test.js index 2b1ff5f..b0b9e40 100644 --- a/src/client/components/Input.test.js +++ b/src/client/components/Input.test.js @@ -39,8 +39,8 @@ describe('components/Input', () => { it('sends a message', () => { TestUtils.Simulate.submit(node) expect(input.value).toBe('') - expect(sendMessage.mock.calls).toEqual([[ message ]]) - expect(notify.mock.calls).toEqual([[ `You: ${message}` ]]) + expect(sendMessage.mock.calls) + .toEqual([[ { payload: message, type: 'text' } ]]) }) }) @@ -50,8 +50,8 @@ describe('components/Input', () => { key: 'Enter' }) expect(input.value).toBe('') - expect(sendMessage.mock.calls).toEqual([[ message ]]) - expect(notify.mock.calls).toEqual([[ `You: ${message}` ]]) + expect(sendMessage.mock.calls) + .toEqual([[ { payload: message, type: 'text' } ]]) }) it('does nothing when other key pressed', () => { @@ -59,7 +59,6 @@ describe('components/Input', () => { key: 'test' }) expect(sendMessage.mock.calls.length).toBe(0) - expect(notify.mock.calls.length).toBe(0) }) }) diff --git a/src/client/components/Toolbar.js b/src/client/components/Toolbar.js index dd060d2..4fb7447 100644 --- a/src/client/components/Toolbar.js +++ b/src/client/components/Toolbar.js @@ -47,9 +47,9 @@ export default class Toolbar extends React.PureComponent { handleSendFile = () => { this.file.current.click() } - handleSelectFiles = () => { + handleSelectFiles = (event) => { Array - .from(this.file.current.files) + .from(event.target.files) .forEach(file => this.props.onSendFile(file)) } render () { diff --git a/src/client/components/Toolbar.test.js b/src/client/components/Toolbar.test.js index 8baf47c..a01eb85 100644 --- a/src/client/components/Toolbar.test.js +++ b/src/client/components/Toolbar.test.js @@ -17,20 +17,23 @@ describe('components/Toolbar', () => { return } } - let component, node, mediaStream, url, onToggleChat + let component, node, mediaStream, url, onToggleChat, onSendFile function render () { mediaStream = new MediaStream() onToggleChat = jest.fn() + onSendFile = jest.fn() component = TestUtils.renderIntoDocument( @@ -38,10 +41,8 @@ describe('components/Toolbar', () => { node = ReactDOM.findDOMNode(component) } - describe('render', () => { - it('should not fail', () => { - render() - }) + beforeEach(() => { + render() }) describe('handleChatClick', () => { @@ -85,4 +86,28 @@ describe('components/Toolbar', () => { }) }) + describe('handleSendFile', () => { + it('triggers input dialog', () => { + const sendFileButton = node.querySelector('.send-file') + const click = jest.fn() + const file = node.querySelector('input[type=file]') + file.click = click + TestUtils.Simulate.click(sendFileButton) + expect(click.mock.calls.length).toBe(1) + }) + }) + + describe('handleSelectFiles', () => { + it('iterates through files and calls onSendFile for each', () => { + const file = node.querySelector('input[type=file]') + const files = [{ name: 'first' }] + TestUtils.Simulate.change(file, { + target: { + files + } + }) + expect(onSendFile.mock.calls).toEqual([[ files[0] ]]) + }) + }) + }) diff --git a/src/client/constants.js b/src/client/constants.js index 3e16f4a..a5eba94 100644 --- a/src/client/constants.js +++ b/src/client/constants.js @@ -18,7 +18,6 @@ export const NOTIFY_DISMISS = 'NOTIFY_DISMISS' export const NOTIFY_CLEAR = 'NOTIFY_CLEAR' export const MESSAGE_ADD = 'MESSAGE_ADD' -export const MESSAGES_HISTORY = 'MESSAGES_HISTORY' export const PEER_ADD = 'PEER_ADD' export const PEER_REMOVE = 'PEER_REMOVE' @@ -33,8 +32,6 @@ export const PEER_EVENT_DATA = 'data' export const SOCKET_EVENT_SIGNAL = 'signal' export const SOCKET_EVENT_USERS = 'users' -export const SOCKET_EVENT_MESSAGES = 'messages' -export const SOCKET_EVENT_NEW_MESSAGE = 'new_message' export const STREAM_ADD = 'PEER_STREAM_ADD' export const STREAM_REMOVE = 'PEER_STREAM_REMOVE' diff --git a/src/client/containers/App.js b/src/client/containers/App.js index 552be30..a72f8e2 100644 --- a/src/client/containers/App.js +++ b/src/client/containers/App.js @@ -23,7 +23,6 @@ function mapDispatchToProps (dispatch) { sendMessage: bindActionCreators(PeerActions.sendMessage, dispatch), dismissAlert: bindActionCreators(NotifyActions.dismissAlert, dispatch), init: bindActionCreators(CallActions.init, dispatch), - notify: bindActionCreators(NotifyActions.info, dispatch), onSendFile: bindActionCreators(PeerActions.sendFile, dispatch) } } diff --git a/src/client/reducers/messages.js b/src/client/reducers/messages.js index 505c7d2..b9fcaa2 100644 --- a/src/client/reducers/messages.js +++ b/src/client/reducers/messages.js @@ -9,8 +9,6 @@ export default function messages (state = defaultState, action) { const messages = state.asMutable() messages.push(action.payload) return Immutable(messages) - case constants.MESSAGES_HISTORY: - return Immutable(action.messages) default: return state } diff --git a/src/client/reducers/messages.test.js b/src/client/reducers/messages.test.js index 37c23a3..8bf788c 100644 --- a/src/client/reducers/messages.test.js +++ b/src/client/reducers/messages.test.js @@ -17,12 +17,4 @@ describe('reducers/messages', () => { }) }) - describe('messageHistory', () => { - it('get chat message hisotry', () => { - let state = messages() - state = messages(state, ChatActions.loadHistory([])) - expect(state).toEqual([]) - }) - }) - }) diff --git a/src/server/socket.js b/src/server/socket.js index a9dd036..5f67b6b 100644 --- a/src/server/socket.js +++ b/src/server/socket.js @@ -2,8 +2,6 @@ const debug = require('debug')('peer-calls:socket') const _ = require('underscore') -const messages = {} - module.exports = function (socket, io) { socket.on('signal', payload => { // debug('signal: %s, payload: %o', socket.id, payload) @@ -13,11 +11,6 @@ module.exports = function (socket, io) { }) }) - socket.on('new_message', payload => { - addMesssage(socket.room, payload) - io.to(socket.room).emit('new_message', payload) - }) - socket.on('ready', roomName => { debug('ready: %s, room: %s', socket.id, roomName) if (socket.room) socket.leave(socket.room) @@ -26,17 +19,13 @@ module.exports = function (socket, io) { socket.room = roomName let users = getUsers(roomName) - let messages = getMesssages(roomName) - debug('ready: %s, room: %s, users: %o, messages: %o', - socket.id, roomName, users, messages) + debug('ready: %s, room: %s, users: %o', socket.id, roomName, users) io.to(roomName).emit('users', { initiator: socket.id, users }) - - io.to(roomName).emit('messages', messages) }) function getUsers (roomName) { @@ -45,14 +34,4 @@ module.exports = function (socket, io) { }) } - function getMesssages (roomName) { - if (_.isUndefined(messages[roomName])) { - messages[roomName] = [] - } - return messages[roomName] - } - - function addMesssage (roomName, payload) { - getMesssages(roomName).push(payload) - } } diff --git a/src/server/socket.test.js b/src/server/socket.test.js index dff952c..3c5dd5c 100644 --- a/src/server/socket.test.js +++ b/src/server/socket.test.js @@ -83,7 +83,7 @@ describe('server/socket', () => { it('should emit users', () => { socket.emit('ready', 'room3') - expect(io.to.mock.calls).toEqual([[ 'room3' ], [ 'room3' ]]) + expect(io.to.mock.calls).toEqual([[ 'room3' ]]) expect(io.to('room3').emit.mock.calls).toEqual([ [ 'users', { @@ -96,8 +96,7 @@ describe('server/socket', () => { id: 'socket2' }] } - ], - ['messages', []] + ] ]) }) }) From 47ed465252438cac6895cb9522adcc8adb21ec70 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Mon, 11 Nov 2019 23:17:56 -0300 Subject: [PATCH 06/38] Fix unread messages --- src/client/components/Toolbar.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/components/Toolbar.js b/src/client/components/Toolbar.js index 4fb7447..16dfe76 100644 --- a/src/client/components/Toolbar.js +++ b/src/client/components/Toolbar.js @@ -20,6 +20,9 @@ export default class Toolbar extends React.PureComponent { constructor (props) { super(props) this.file = React.createRef() + this.state = { + readMessages: props.messages.length + } } handleMicClick = () => { const { stream } = this.props @@ -52,16 +55,23 @@ export default class Toolbar extends React.PureComponent { .from(event.target.files) .forEach(file => this.props.onSendFile(file)) } + handleToggleChat = () => { + this.setState({ + readMessages: this.props.messages.length + }) + this.props.onToggleChat() + } render () { const { messages, stream } = this.props return (
-
this.state.readMessages} title="Chat" > From 085fae4b22f970e85eb9430c32c4cf601ce54c8e Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Mon, 11 Nov 2019 23:18:53 -0300 Subject: [PATCH 07/38] Fix send file name --- src/client/actions/PeerActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/actions/PeerActions.js b/src/client/actions/PeerActions.js index eba865e..c92a550 100644 --- a/src/client/actions/PeerActions.js +++ b/src/client/actions/PeerActions.js @@ -53,7 +53,7 @@ class PeerHandler { case 'file': dispatch(ChatActions.addMessage({ userId: user.id, - message: 'Sent a file: "' + message.payload.name, + message: message.payload.name, timestamp: new Date().toLocaleString(), image: message.payload.data })) From 1eaca46a169c45c572f3ca33ed2ea1aec5473c68 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 00:54:35 -0300 Subject: [PATCH 08/38] Install typescript, upgrade server to TypeScript --- .eslintrc | 21 - .eslintrc.yaml | 66 + jest.config.js | 16 + jest.setup.js | 1 - package-lock.json | 2074 +++++++++++++++-- package.json | 51 +- src/index.js | 6 +- src/server/{app.test.js => app.test.ts} | 19 +- src/server/{app.js => app.ts} | 29 +- src/server/config.ts | 26 + src/server/routes/call.js | 23 - src/server/routes/call.ts | 23 + src/server/routes/index.js | 9 - src/server/routes/index.ts | 9 + src/server/server.js | 17 - src/server/{server.test.js => server.test.ts} | 12 +- src/server/server.ts | 16 + src/server/{socket.test.js => socket.test.ts} | 70 +- src/server/{socket.js => socket.ts} | 19 +- src/server/turn.js | 35 - src/server/{turn.test.js => turn.test.ts} | 14 +- src/server/turn.ts | 45 + tsconfig.json | 24 + 23 files changed, 2174 insertions(+), 451 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.yaml create mode 100644 jest.config.js rename src/server/{app.test.js => app.test.ts} (70%) rename src/server/{app.js => app.ts} (53%) create mode 100644 src/server/config.ts delete mode 100644 src/server/routes/call.js create mode 100644 src/server/routes/call.ts delete mode 100644 src/server/routes/index.js create mode 100644 src/server/routes/index.ts delete mode 100644 src/server/server.js rename src/server/{server.test.js => server.test.ts} (71%) create mode 100644 src/server/server.ts rename src/server/{socket.test.js => socket.test.ts} (62%) rename src/server/{socket.js => socket.ts} (63%) delete mode 100644 src/server/turn.js rename src/server/{turn.test.js => turn.test.ts} (78%) create mode 100644 src/server/turn.ts create mode 100644 tsconfig.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f1531dd..0000000 --- a/.eslintrc +++ /dev/null @@ -1,21 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": ["standard", "standard-react"], - "rules": { - "max-len": [2, 80, 4], - "jsx-quotes": ["error", "prefer-double"], - "padded-blocks": 0, - "import/first": 0, - "no-return-assign": 0, - "indent": ["error", 2, { "MemberExpression": 0, "SwitchCase": 1, "flatTernaryExpressions": true }], - }, - "globals": { - "expect": true, - "jest": true, - "jasmine": true, - "it": true, - "beforeEach": true, - "afterEach": true, - "describe": true - } -} diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 0000000..3bb2c82 --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,66 @@ +extends: + - eslint:recommended + - plugin:react/recommended + - plugin:@typescript-eslint/eslint-recommended + - plugin:@typescript-eslint/recommended +plugins: + - import +settings: + react: + version: 'detect' +rules: + max-len: + - warn + - code: 80 + ignorePattern: '^import .* from ' + comma-dangle: + - warn + - arrays: always-multiline + objects: always-multiline + imports: always-multiline + exports: always-multiline + functions: always-multiline + + semi: + - warn + - never + quotes: + - warn + - single + - allowTemplateLiterals: true + # interface-name-prefix: + 'import/no-extraneous-dependencies': off + '@typescript-eslint/member-delimiter-style': + - warn + - multiline: + delimiter: none + singleline: + delimiter: comma + '@typescript-eslint/no-unused-vars': + - warn + - vars: all + args: none + ignoreRestSiblings: true + '@typescript-eslint/explicit-function-return-type': off + '@typescript-eslint/no-non-null-assertion': off + '@typescript-eslint/no-use-before-define': off + '@typescript-eslint/no-empty-interface': off + '@typescript-eslint/no-explicit-any': + - warn + - ignoreRestArgs: true + '@typescript-eslint/triple-slash-reference': + - warn + - path: always +overrides: + - files: + - '*.test.ts' + - '*.test.tsx' + rules: + '@typescript-eslint/no-explicit-any': off + - files: + - '*.js' + rules: + '@typescript-eslint/no-var-requires': off + env: + node: true + es6: true diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..737dab0 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,16 @@ +module.exports = { + roots: [ + '/src' + ], + transform: { + '^.+\\.tsx?$': 'ts-jest' + }, + testRegex: '(/__tests__/.*|\\.(test|spec))\\.tsx?$', + moduleFileExtensions: [ + 'ts', + 'tsx', + 'js', + 'jsx' + ], + setupFiles: ['/jest.setup.js'] +} diff --git a/jest.setup.js b/jest.setup.js index 33b7c42..e69de29 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -1 +0,0 @@ -import '@babel/polyfill' diff --git a/package-lock.json b/package-lock.json index cecbbd0..b88cc50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1933,6 +1933,70 @@ "@types/babel-types": "*" } }, + "@types/body-parser": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz", + "integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==", + "dev": true, + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/config": { + "version": "0.0.36", + "resolved": "https://registry.npmjs.org/@types/config/-/config-0.0.36.tgz", + "integrity": "sha512-EoAeT1MyFWh2BJvBDEFInY714bQBbHOAucqxqqhprhbBFqr+B7fuN5T9CJqUIGDzvwubnKKRqmSo6yPo0aSpNw==", + "dev": true + }, + "@types/connect": { + "version": "3.4.32", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.32.tgz", + "integrity": "sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/cookiejar": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.1.tgz", + "integrity": "sha512-aRnpPa7ysx3aNW60hTiCtLHlQaIFsXFCgQlpakNgDNVFzbtusSY8PwjAQgRWfSk0ekNoBjO51eQRB6upA9uuyw==", + "dev": true + }, + "@types/debug": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz", + "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==", + "dev": true + }, + "@types/eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", + "dev": true + }, + "@types/express": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.2.tgz", + "integrity": "sha512-5mHFNyavtLoJmnusB8OKJ5bshSzw+qkMIBAobLrIM48HJvunFva9mOa6aBwh64lBFyNwBbs0xiEFuj4eU/NjCA==", + "dev": true, + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.16.11", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.11.tgz", + "integrity": "sha512-K8d2M5t3tBQimkyaYTXxtHYyoJPUEhy2/omVRnTAKw5FEdT+Ft6lTaTOpoJdHeG+mIwQXXtqiTcYZ6IR8LTzjQ==", + "dev": true, + "requires": { + "@types/node": "*", + "@types/range-parser": "*" + } + }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -1958,18 +2022,223 @@ "@types/istanbul-lib-report": "*" } }, + "@types/jest": { + "version": "24.0.23", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.23.tgz", + "integrity": "sha512-L7MBvwfNpe7yVPTXLn32df/EK+AMBFAFvZrRuArGs7npEWnlziUXK+5GMIUTI4NIuwok3XibsjXCs5HxviYXjg==", + "dev": true, + "requires": { + "jest-diff": "^24.3.0" + } + }, + "@types/json-schema": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz", + "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", + "dev": true + }, + "@types/mime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz", + "integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==", + "dev": true + }, + "@types/node": { + "version": "12.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz", + "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==", + "dev": true + }, + "@types/range-parser": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.3.tgz", + "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==", + "dev": true + }, + "@types/serve-static": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.3.tgz", + "integrity": "sha512-oprSwp094zOglVrXdlo/4bAHtKTAxX6VT8FOZlBKrmyLbNvE1zxZyJ6yikMVtHIvwP45+ZQGJn+FdXGKTozq0g==", + "dev": true, + "requires": { + "@types/express-serve-static-core": "*", + "@types/mime": "*" + } + }, + "@types/socket.io": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@types/socket.io/-/socket.io-2.1.4.tgz", + "integrity": "sha512-cI98INy7tYnweTsUlp8ocveVdAxENUThO0JsLSCs51cjOP2yV5Mqo5QszMDPckyRRA+PO6+wBgKvGvHUCc23TQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/socket.io-client": { + "version": "1.4.32", + "resolved": "https://registry.npmjs.org/@types/socket.io-client/-/socket.io-client-1.4.32.tgz", + "integrity": "sha512-Vs55Kq8F+OWvy1RLA31rT+cAyemzgm0EWNeax6BWF8H7QiiOYMJIdcwSDdm5LVgfEkoepsWkS+40+WNb7BUMbg==", + "dev": true + }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", "integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==", "dev": true }, + "@types/superagent": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.4.tgz", + "integrity": "sha512-SRH2q6/5/nhOkAuLXm3azRGjBYpoKCZWh138Rt1AxSIyE6/1b9uClIH2V+JfyDtjIvgr5yQqYgNUmdpbneJoZQ==", + "dev": true, + "requires": { + "@types/cookiejar": "*", + "@types/node": "*" + } + }, + "@types/supertest": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-2.0.8.tgz", + "integrity": "sha512-wcax7/ip4XSSJRLbNzEIUVy2xjcBIZZAuSd2vtltQfRK7kxhx5WMHbLHkYdxN3wuQCrwpYrg86/9byDjPXoGMA==", + "dev": true, + "requires": { + "@types/superagent": "*" + } + }, + "@types/underscore": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.9.3.tgz", + "integrity": "sha512-SwbHKB2DPIDlvYqtK5O+0LFtZAyrUSw4c0q+HWwmH1Ve3KMQ0/5PlV3RX97+3dP7yMrnNQ8/bCWWvQpPl03Mug==", + "dev": true + }, + "@types/uuid": { + "version": "3.4.6", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.6.tgz", + "integrity": "sha512-cCdlC/1kGEZdEglzOieLDYBxHsvEOIg7kp/2FYyVR9Pxakq+Qf/inL3RKQ+PA8gOlI/NnL+fXmQH12nwcGzsHw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/yargs": { "version": "12.0.12", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.12.tgz", "integrity": "sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw==", "dev": true }, + "@types/yargs-parser": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-13.1.0.tgz", + "integrity": "sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg==", + "dev": true + }, + "@typescript-eslint/eslint-plugin": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.7.0.tgz", + "integrity": "sha512-H5G7yi0b0FgmqaEUpzyBlVh0d9lq4cWG2ap0RKa6BkF3rpBb6IrAoubt1NWh9R2kRs/f0k6XwRDiDz3X/FqXhQ==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "2.7.0", + "eslint-utils": "^1.4.2", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^2.0.1", + "tsutils": "^3.17.1" + } + }, + "@typescript-eslint/experimental-utils": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.7.0.tgz", + "integrity": "sha512-9/L/OJh2a5G2ltgBWJpHRfGnt61AgDeH6rsdg59BH0naQseSwR7abwHq3D5/op0KYD/zFT4LS5gGvWcMmegTEg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.7.0", + "eslint-scope": "^5.0.0" + }, + "dependencies": { + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + } + } + }, + "@typescript-eslint/parser": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.7.0.tgz", + "integrity": "sha512-ctC0g0ZvYclxMh/xI+tyqP0EC2fAo6KicN9Wm2EIao+8OppLfxji7KAGJosQHSGBj3TcqUrA96AjgXuKa5ob2g==", + "dev": true, + "requires": { + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "2.7.0", + "@typescript-eslint/typescript-estree": "2.7.0", + "eslint-visitor-keys": "^1.1.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + } + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.7.0.tgz", + "integrity": "sha512-vVCE/DY72N4RiJ/2f10PTyYekX2OLaltuSIBqeHYI44GQ940VCYioInIb8jKMrK9u855OEJdFC+HmWAZTnC+Ag==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "glob": "^7.1.4", + "is-glob": "^4.0.1", + "lodash.unescape": "4.0.1", + "semver": "^6.3.0", + "tsutils": "^3.17.1" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", @@ -2028,9 +2297,9 @@ } }, "acorn-jsx": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", - "integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", + "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", "dev": true }, "acorn-node": { @@ -2065,9 +2334,9 @@ "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" }, "ajv": { - "version": "6.6.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.1.tgz", - "integrity": "sha512-ZoJjft5B+EJBjUyu9C9Hc0OZyPZSSlOF+plzouTrg6UlA8f+e/n8NIgBFG/9tppJtpPWfthHakK7juJdNDODww==", + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -2454,6 +2723,12 @@ "readable-stream": "^2.0.6" } }, + "arg": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", + "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -3299,6 +3574,15 @@ "node-releases": "^1.1.23" } }, + "bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "requires": { + "fast-json-stable-stringify": "2.x" + } + }, "bser": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.0.tgz", @@ -3378,24 +3662,15 @@ "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", "dev": true }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "requires": { - "callsites": "^0.2.0" - } - }, "callsite": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" }, "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, "camelcase": { @@ -3631,12 +3906,6 @@ "safe-buffer": "^5.0.1" } }, - "circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", - "dev": true - }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -3686,12 +3955,12 @@ "dev": true }, "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", "dev": true, "requires": { - "restore-cursor": "^2.0.0" + "restore-cursor": "^3.1.0" } }, "cli-width": { @@ -4280,6 +4549,12 @@ "minimist": "^1.1.1" } }, + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + }, "diff-sequences": { "version": "24.3.0", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.3.0.tgz", @@ -4298,9 +4573,9 @@ } }, "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "requires": { "esutils": "^2.0.2" @@ -4394,6 +4669,12 @@ "minimalistic-crypto-utils": "^1.0.0" } }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -4537,54 +4818,54 @@ } }, "eslint": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.10.0.tgz", - "integrity": "sha512-HpqzC+BHULKlnPwWae9MaVZ5AXJKpkxCVXQHrFaRw3hbDj26V/9ArYM4Rr/SQ8pi6qUPLXSSXC4RBJlyq2Z2OQ==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.6.0.tgz", + "integrity": "sha512-PpEBq7b6qY/qrOmpYQ/jTMDYfuQMELR4g4WI1M/NaSDDD/bdcMb+dj4Hgks7p41kW2caXsPsEZAEAyAgjVVC0g==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "ajv": "^6.5.3", + "ajv": "^6.10.0", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", "debug": "^4.0.1", - "doctrine": "^2.1.0", - "eslint-scope": "^4.0.0", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.0", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", "esquery": "^1.0.1", "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", + "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", + "glob-parent": "^5.0.0", "globals": "^11.7.0", "ignore": "^4.0.6", + "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.1.0", - "js-yaml": "^3.12.0", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.5", + "lodash": "^4.17.14", "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "pluralize": "^7.0.0", "progress": "^2.0.0", "regexpp": "^2.0.1", - "require-uncached": "^1.0.3", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", - "table": "^5.0.2", - "text-table": "^0.2.0" + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" }, "dependencies": { "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, "ansi-styles": { @@ -4597,9 +4878,9 @@ } }, "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "requires": { "ansi-styles": "^3.2.1", @@ -4618,48 +4899,68 @@ "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } } }, "debug": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", - "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "requires": { "ms": "^2.1.1" } }, "eslint-scope": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz", - "integrity": "sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", "dev": true, "requires": { "esrecurse": "^4.1.0", "estraverse": "^4.1.1" } }, - "globals": { - "version": "11.9.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.9.0.tgz", - "integrity": "sha512-5cJVtyXWH8PiJPVLZzzoIizXx944O4OmRro5MWKx5fT4MgcN7OfaMutPeaTdJCCURwbWdhhcCWcKIffPnmTzBg==", + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", "dev": true }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^4.1.0" } }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -4703,13 +5004,13 @@ } }, "eslint-module-utils": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz", - "integrity": "sha1-snA2LNiLGkitMIl2zn+lTphBF0Y=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.1.tgz", + "integrity": "sha512-H6DOj+ejw7Tesdgbfs4jeS4YMFrT8uI8xwd1gtQqXssaR0EQ26L+2O/w6wkYFy2MymON0fTwHmXBvvfLNZVZEw==", "dev": true, "requires": { "debug": "^2.6.8", - "pkg-dir": "^1.0.0" + "pkg-dir": "^2.0.0" } }, "eslint-plugin-es": { @@ -4723,21 +5024,22 @@ } }, "eslint-plugin-import": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.14.0.tgz", - "integrity": "sha512-FpuRtniD/AY6sXByma2Wr0TXvXJ4nA/2/04VPlfpmUDPOpOY264x+ILiwnrk/k4RINgDAyFZByxqPUbSQ5YE7g==", + "version": "2.18.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.2.tgz", + "integrity": "sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==", "dev": true, "requires": { + "array-includes": "^3.0.3", "contains-path": "^0.1.0", - "debug": "^2.6.8", + "debug": "^2.6.9", "doctrine": "1.5.0", - "eslint-import-resolver-node": "^0.3.1", - "eslint-module-utils": "^2.2.0", - "has": "^1.0.1", - "lodash": "^4.17.4", - "minimatch": "^3.0.3", + "eslint-import-resolver-node": "^0.3.2", + "eslint-module-utils": "^2.4.0", + "has": "^1.0.3", + "minimatch": "^3.0.4", + "object.values": "^1.1.0", "read-pkg-up": "^2.0.0", - "resolve": "^1.6.0" + "resolve": "^1.11.0" }, "dependencies": { "doctrine": { @@ -4792,6 +5094,15 @@ "read-pkg": "^2.0.0" } }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -4829,16 +5140,57 @@ "dev": true }, "eslint-plugin-react": { - "version": "7.11.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.11.1.tgz", - "integrity": "sha512-cVVyMadRyW7qsIUh3FHp3u6QHNhOgVrLQYdQEB1bPWBsgbNCHdFAeNMquBMCcZJu59eNthX053L70l7gRt4SCw==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.16.0.tgz", + "integrity": "sha512-GacBAATewhhptbK3/vTP09CbFrgUJmBSaaRcWdbQLFvUZy9yVcQxigBNHGPU/KE2AyHpzj3AWXpxoMTsIDiHug==", "dev": true, "requires": { "array-includes": "^3.0.3", "doctrine": "^2.1.0", "has": "^1.0.3", - "jsx-ast-utils": "^2.0.1", - "prop-types": "^15.6.2" + "jsx-ast-utils": "^2.2.1", + "object.entries": "^1.1.0", + "object.fromentries": "^2.0.0", + "object.values": "^1.1.0", + "prop-types": "^15.7.2", + "resolve": "^1.12.0" + }, + "dependencies": { + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, + "react-is": { + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz", + "integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==", + "dev": true + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } } }, "eslint-plugin-standard": { @@ -4881,20 +5233,26 @@ "dev": true }, "espree": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.0.tgz", - "integrity": "sha512-1MpUfwsdS9MMoN7ZXqAr9e9UKdVHDcvrJpyx7mm1WuQlx/ygErEQBzgi5Nh5qBHIoYweprhtMkTCb9GhcAIcsA==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", + "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", "dev": true, "requires": { - "acorn": "^6.0.2", - "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" + "acorn": "^7.1.0", + "acorn-jsx": "^5.1.0", + "eslint-visitor-keys": "^1.1.0" }, "dependencies": { "acorn": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.4.tgz", - "integrity": "sha512-VY4i5EKSKkofY2I+6QLTbTTN/UvEQPCo6eiwzzSaSWfpaDhOmStMCMod6wmuPciNq+XS0faCglFu2lHZpdHUtg==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", + "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "dev": true + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", "dev": true } } @@ -5107,9 +5465,9 @@ } }, "external-editor": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", - "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", "dev": true, "requires": { "chardet": "^0.7.0", @@ -5233,22 +5591,21 @@ } }, "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz", + "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==", "dev": true, "requires": { "escape-string-regexp": "^1.0.5" } }, "file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", "dev": true, "requires": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flat-cache": "^2.0.1" } }, "fill-range": { @@ -5298,17 +5655,33 @@ } }, "flat-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", - "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", "dev": true, "requires": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", - "write": "^0.2.1" + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + }, + "dependencies": { + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } } }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "dev": true + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -6024,6 +6397,15 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, "global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", @@ -6352,6 +6734,16 @@ "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", "dev": true }, + "import-fresh": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", + "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, "import-lazy": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", @@ -6487,30 +6879,39 @@ } }, "inquirer": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.1.tgz", - "integrity": "sha512-088kl3DRT2dLU5riVMKKr1DlImd6X7smDhpXUCkJDCKvTEJeRiXh0G132HG9u5a+6Ylw9plFRY7RuTnwohYSpg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.0.tgz", + "integrity": "sha512-rSdC7zelHdRQFkWnhsMu2+2SO41mpv2oF2zy4tMhmiLWkcKbOAs87fWAJhVXttKVwhdZvymvnuM95EyEXg2/tQ==", "dev": true, "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", + "ansi-escapes": "^4.2.1", + "chalk": "^2.4.2", + "cli-cursor": "^3.1.0", "cli-width": "^2.0.0", - "external-editor": "^3.0.0", - "figures": "^2.0.0", - "lodash": "^4.17.10", - "mute-stream": "0.0.7", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.15", + "mute-stream": "0.0.8", "run-async": "^2.2.0", - "rxjs": "^6.1.0", - "string-width": "^2.1.0", - "strip-ansi": "^5.0.0", + "rxjs": "^6.4.0", + "string-width": "^4.1.0", + "strip-ansi": "^5.1.0", "through": "^2.3.6" }, "dependencies": { + "ansi-escapes": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.2.1.tgz", + "integrity": "sha512-Cg3ymMAdN10wOk/VYfLV7KCQyv7EDirJ64500sU7n9UlmioEtDuU5Gd+hj73hXSU/ex7tHJSssmyftDdkMLO8Q==", + "dev": true, + "requires": { + "type-fest": "^0.5.2" + } + }, "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "ansi-styles": { @@ -6523,9 +6924,9 @@ } }, "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "requires": { "ansi-styles": "^3.2.1", @@ -6534,45 +6935,46 @@ } }, "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true }, "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" }, "dependencies": { "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^5.0.0" } } } }, "strip-ansi": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.0.0.tgz", - "integrity": "sha512-Uu7gQyZI7J7gn5qLn1Np3G9vcYGTVqB+lFTytnDJv83dd8T22aGH451P3jueT2/QemInJDfxHB5Tde5OzgG1Ow==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { - "ansi-regex": "^4.0.0" + "ansi-regex": "^4.1.0" }, "dependencies": { "ansi-regex": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.0.0.tgz", - "integrity": "sha512-iB5Dda8t/UqpPI/IjsejXu5jOGDrzn41wJyljwPH65VCIbk6+1BzFIMJGFwTNrYXT1CrD+B4l19U7awiQ8rk7w==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true } } @@ -6734,6 +7136,12 @@ "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", "dev": true }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-finite": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", @@ -6758,6 +7166,15 @@ "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, "is-installed-globally": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", @@ -7127,6 +7544,983 @@ "handlebars": "^4.1.2" } }, + "jest": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-24.9.0.tgz", + "integrity": "sha512-YvkBL1Zm7d2B1+h5fHEOdyjCG+sGMz4f8D86/0HiqJ6MB4MnDc8FgP5vdWsGnemOQro7lnYo8UakZ3+5A0jxGw==", + "dev": true, + "requires": { + "import-local": "^2.0.0", + "jest-cli": "^24.9.0" + }, + "dependencies": { + "@jest/core": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-24.9.0.tgz", + "integrity": "sha512-Fogg3s4wlAr1VX7q+rhV9RVnUv5tD7VuWfYy1+whMiWUrvl7U3QJSJyWcDio9Lq2prqYsZaeTv2Rz24pWGkJ2A==", + "dev": true, + "requires": { + "@jest/console": "^24.7.1", + "@jest/reporters": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "graceful-fs": "^4.1.15", + "jest-changed-files": "^24.9.0", + "jest-config": "^24.9.0", + "jest-haste-map": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-resolve": "^24.9.0", + "jest-resolve-dependencies": "^24.9.0", + "jest-runner": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-snapshot": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "jest-watcher": "^24.9.0", + "micromatch": "^3.1.10", + "p-each-series": "^1.0.0", + "realpath-native": "^1.1.0", + "rimraf": "^2.5.4", + "slash": "^2.0.0", + "strip-ansi": "^5.0.0" + } + }, + "@jest/environment": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-24.9.0.tgz", + "integrity": "sha512-5A1QluTPhvdIPFYnO3sZC3smkNeXPVELz7ikPbhUj0bQjB07EoE9qtLrem14ZUYWdVayYbsjVwIiL4WBIMV4aQ==", + "dev": true, + "requires": { + "@jest/fake-timers": "^24.9.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "jest-mock": "^24.9.0" + } + }, + "@jest/fake-timers": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-24.9.0.tgz", + "integrity": "sha512-eWQcNa2YSwzXWIMC5KufBh3oWRIijrQFROsIqt6v/NS9Io/gknw1jsAC9c+ih/RQX4A3O7SeWAhQeN0goKhT9A==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-mock": "^24.9.0" + } + }, + "@jest/reporters": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-24.9.0.tgz", + "integrity": "sha512-mu4X0yjaHrffOsWmVLzitKmmmWSQ3GGuefgNscUSWNiUNcEOSEQk9k3pERKEQVBb0Cnn88+UESIsZEMH3o88Gw==", + "dev": true, + "requires": { + "@jest/environment": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "glob": "^7.1.2", + "istanbul-lib-coverage": "^2.0.2", + "istanbul-lib-instrument": "^3.0.1", + "istanbul-lib-report": "^2.0.4", + "istanbul-lib-source-maps": "^3.0.1", + "istanbul-reports": "^2.2.6", + "jest-haste-map": "^24.9.0", + "jest-resolve": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-util": "^24.9.0", + "jest-worker": "^24.6.0", + "node-notifier": "^5.4.2", + "slash": "^2.0.0", + "source-map": "^0.6.0", + "string-length": "^2.0.0" + } + }, + "@jest/source-map": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-24.9.0.tgz", + "integrity": "sha512-/Xw7xGlsZb4MJzNDgB7PW5crou5JqWiBQaz6xyPd3ArOg2nfn/PunV8+olXbbEZzNl591o5rWKE9BRDaFAuIBg==", + "dev": true, + "requires": { + "callsites": "^3.0.0", + "graceful-fs": "^4.1.15", + "source-map": "^0.6.0" + } + }, + "@jest/test-result": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-24.9.0.tgz", + "integrity": "sha512-XEFrHbBonBJ8dGp2JmF8kP/nQI/ImPpygKHwQ/SY+es59Z3L5PI4Qb9TQQMAEeYsThG1xF0k6tmG0tIKATNiiA==", + "dev": true, + "requires": { + "@jest/console": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/istanbul-lib-coverage": "^2.0.0" + }, + "dependencies": { + "@jest/console": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-24.9.0.tgz", + "integrity": "sha512-Zuj6b8TnKXi3q4ymac8EQfc3ea/uhLeCGThFqXeC8H9/raaH8ARPUTdId+XyGd03Z4In0/VjD2OYFcBF09fNLQ==", + "dev": true, + "requires": { + "@jest/source-map": "^24.9.0", + "chalk": "^2.0.1", + "slash": "^2.0.0" + } + } + } + }, + "@jest/test-sequencer": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-24.9.0.tgz", + "integrity": "sha512-6qqsU4o0kW1dvA95qfNog8v8gkRN9ph6Lz7r96IvZpHdNipP2cBcb07J1Z45mz/VIS01OHJ3pY8T5fUY38tg4A==", + "dev": true, + "requires": { + "@jest/test-result": "^24.9.0", + "jest-haste-map": "^24.9.0", + "jest-runner": "^24.9.0", + "jest-runtime": "^24.9.0" + } + }, + "@jest/transform": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-24.9.0.tgz", + "integrity": "sha512-TcQUmyNRxV94S0QpMOnZl0++6RMiqpbH/ZMccFB/amku6Uwvyb1cjYX7xkp5nGNkbX4QPH/FcB6q1HBTHynLmQ==", + "dev": true, + "requires": { + "@babel/core": "^7.1.0", + "@jest/types": "^24.9.0", + "babel-plugin-istanbul": "^5.1.0", + "chalk": "^2.0.1", + "convert-source-map": "^1.4.0", + "fast-json-stable-stringify": "^2.0.0", + "graceful-fs": "^4.1.15", + "jest-haste-map": "^24.9.0", + "jest-regex-util": "^24.9.0", + "jest-util": "^24.9.0", + "micromatch": "^3.1.10", + "pirates": "^4.0.1", + "realpath-native": "^1.1.0", + "slash": "^2.0.0", + "source-map": "^0.6.1", + "write-file-atomic": "2.4.1" + }, + "dependencies": { + "jest-regex-util": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-24.9.0.tgz", + "integrity": "sha512-05Cmb6CuxaA+Ys6fjr3PhvV3bGQmO+2p2La4hFbU+W5uOc479f7FdLXUWXw4pYMAhhSZIuKHwSXSu6CsSBAXQA==", + "dev": true + } + } + }, + "@jest/types": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-24.9.0.tgz", + "integrity": "sha512-XKK7ze1apu5JWQ5eZjHITP66AX+QsLlbaJRBGYr8pNzwcAE2JVkwnf0yqjHTsDRcjR0mujy/NmZMXw5kl+kGBw==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^1.1.1", + "@types/yargs": "^13.0.0" + } + }, + "@types/yargs": { + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.3.tgz", + "integrity": "sha512-K8/LfZq2duW33XW/tFwEAfnZlqIfVsoyRB3kfXdPXYhl0nfM8mmh7GS0jg7WrX2Dgq/0Ha/pR1PaR+BvmWwjiQ==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "babel-jest": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.9.0.tgz", + "integrity": "sha512-ntuddfyiN+EhMw58PTNL1ph4C9rECiQXjI4nMMBKBaNjXvqLdkXpPRcMSr4iyBrJg/+wz9brFUD6RhOAT6r4Iw==", + "dev": true, + "requires": { + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/babel__core": "^7.1.0", + "babel-plugin-istanbul": "^5.1.0", + "babel-preset-jest": "^24.9.0", + "chalk": "^2.4.2", + "slash": "^2.0.0" + } + }, + "babel-plugin-jest-hoist": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.9.0.tgz", + "integrity": "sha512-2EMA2P8Vp7lG0RAzr4HXqtYwacfMErOuv1U3wrvxHX6rD1sV6xS3WXG3r8TRQ2r6w8OhvSdWt+z41hQNwNm3Xw==", + "dev": true, + "requires": { + "@types/babel__traverse": "^7.0.6" + } + }, + "babel-preset-jest": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-24.9.0.tgz", + "integrity": "sha512-izTUuhE4TMfTRPF92fFwD2QfdXaZW08qvWTFCI51V8rW5x00UuPgc3ajRoWofXOuxjfcOM5zzSYsQS3H8KGCAg==", + "dev": true, + "requires": { + "@babel/plugin-syntax-object-rest-spread": "^7.0.0", + "babel-plugin-jest-hoist": "^24.9.0" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "diff-sequences": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.9.0.tgz", + "integrity": "sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "expect": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-24.9.0.tgz", + "integrity": "sha512-wvVAx8XIol3Z5m9zvZXiyZOQ+sRJqNTIm6sGjdWlaZIeupQGO3WbYI+15D/AmEwZywL6wtJkbAbJtzkOfBuR0Q==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "ansi-styles": "^3.2.0", + "jest-get-type": "^24.9.0", + "jest-matcher-utils": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-regex-util": "^24.9.0" + }, + "dependencies": { + "jest-regex-util": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-24.9.0.tgz", + "integrity": "sha512-05Cmb6CuxaA+Ys6fjr3PhvV3bGQmO+2p2La4hFbU+W5uOc479f7FdLXUWXw4pYMAhhSZIuKHwSXSu6CsSBAXQA==", + "dev": true + } + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "dev": true, + "requires": { + "ci-info": "^2.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "jest-changed-files": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-24.9.0.tgz", + "integrity": "sha512-6aTWpe2mHF0DhL28WjdkO8LyGjs3zItPET4bMSeXU6T3ub4FPMw+mcOcbdGXQOAfmLcxofD23/5Bl9Z4AkFwqg==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "execa": "^1.0.0", + "throat": "^4.0.0" + } + }, + "jest-cli": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-24.9.0.tgz", + "integrity": "sha512-+VLRKyitT3BWoMeSUIHRxV/2g8y9gw91Jh5z2UmXZzkZKpbC08CSehVxgHUwTpy+HwGcns/tqafQDJW7imYvGg==", + "dev": true, + "requires": { + "@jest/core": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "import-local": "^2.0.0", + "is-ci": "^2.0.0", + "jest-config": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "prompts": "^2.0.1", + "realpath-native": "^1.1.0", + "yargs": "^13.3.0" + } + }, + "jest-config": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-24.9.0.tgz", + "integrity": "sha512-RATtQJtVYQrp7fvWg6f5y3pEFj9I+H8sWw4aKxnDZ96mob5i5SD6ZEGWgMLXQ4LE8UurrjbdlLWdUeo+28QpfQ==", + "dev": true, + "requires": { + "@babel/core": "^7.1.0", + "@jest/test-sequencer": "^24.9.0", + "@jest/types": "^24.9.0", + "babel-jest": "^24.9.0", + "chalk": "^2.0.1", + "glob": "^7.1.1", + "jest-environment-jsdom": "^24.9.0", + "jest-environment-node": "^24.9.0", + "jest-get-type": "^24.9.0", + "jest-jasmine2": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-resolve": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "micromatch": "^3.1.10", + "pretty-format": "^24.9.0", + "realpath-native": "^1.1.0" + } + }, + "jest-diff": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-24.9.0.tgz", + "integrity": "sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "diff-sequences": "^24.9.0", + "jest-get-type": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-each": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-24.9.0.tgz", + "integrity": "sha512-ONi0R4BvW45cw8s2Lrx8YgbeXL1oCQ/wIDwmsM3CqM/nlblNCPmnC3IPQlMbRFZu3wKdQ2U8BqM6lh3LJ5Bsog==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "jest-get-type": "^24.9.0", + "jest-util": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-environment-jsdom": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-24.9.0.tgz", + "integrity": "sha512-Zv9FV9NBRzLuALXjvRijO2351DRQeLYXtpD4xNvfoVFw21IOKNhZAEUKcbiEtjTkm2GsJ3boMVgkaR7rN8qetA==", + "dev": true, + "requires": { + "@jest/environment": "^24.9.0", + "@jest/fake-timers": "^24.9.0", + "@jest/types": "^24.9.0", + "jest-mock": "^24.9.0", + "jest-util": "^24.9.0", + "jsdom": "^11.5.1" + } + }, + "jest-environment-node": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-24.9.0.tgz", + "integrity": "sha512-6d4V2f4nxzIzwendo27Tr0aFm+IXWa0XEUnaH6nU0FMaozxovt+sfRvh4J47wL1OvF83I3SSTu0XK+i4Bqe7uA==", + "dev": true, + "requires": { + "@jest/environment": "^24.9.0", + "@jest/fake-timers": "^24.9.0", + "@jest/types": "^24.9.0", + "jest-mock": "^24.9.0", + "jest-util": "^24.9.0" + } + }, + "jest-get-type": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.9.0.tgz", + "integrity": "sha512-lUseMzAley4LhIcpSP9Jf+fTrQ4a1yHQwLNeeVa2cEmbCGeoZAtYPOIv8JaxLD/sUpKxetKGP+gsHl8f8TSj8Q==", + "dev": true + }, + "jest-haste-map": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.9.0.tgz", + "integrity": "sha512-kfVFmsuWui2Sj1Rp1AJ4D9HqJwE4uwTlS/vO+eRUaMmd54BFpli2XhMQnPC2k4cHFVbB2Q2C+jtI1AGLgEnCjQ==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "anymatch": "^2.0.0", + "fb-watchman": "^2.0.0", + "fsevents": "^1.2.7", + "graceful-fs": "^4.1.15", + "invariant": "^2.2.4", + "jest-serializer": "^24.9.0", + "jest-util": "^24.9.0", + "jest-worker": "^24.9.0", + "micromatch": "^3.1.10", + "sane": "^4.0.3", + "walker": "^1.0.7" + }, + "dependencies": { + "jest-worker": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz", + "integrity": "sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==", + "dev": true, + "requires": { + "merge-stream": "^2.0.0", + "supports-color": "^6.1.0" + } + }, + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "jest-jasmine2": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-24.9.0.tgz", + "integrity": "sha512-Cq7vkAgaYKp+PsX+2/JbTarrk0DmNhsEtqBXNwUHkdlbrTBLtMJINADf2mf5FkowNsq8evbPc07/qFO0AdKTzw==", + "dev": true, + "requires": { + "@babel/traverse": "^7.1.0", + "@jest/environment": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "co": "^4.6.0", + "expect": "^24.9.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^24.9.0", + "jest-matcher-utils": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-snapshot": "^24.9.0", + "jest-util": "^24.9.0", + "pretty-format": "^24.9.0", + "throat": "^4.0.0" + } + }, + "jest-leak-detector": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-24.9.0.tgz", + "integrity": "sha512-tYkFIDsiKTGwb2FG1w8hX9V0aUb2ot8zY/2nFg087dUageonw1zrLMP4W6zsRO59dPkTSKie+D4rhMuP9nRmrA==", + "dev": true, + "requires": { + "jest-get-type": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-matcher-utils": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-24.9.0.tgz", + "integrity": "sha512-OZz2IXsu6eaiMAwe67c1T+5tUAtQyQx27/EMEkbFAGiw52tB9em+uGbzpcgYVpA8wl0hlxKPZxrly4CXU/GjHA==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "jest-diff": "^24.9.0", + "jest-get-type": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-message-util": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-24.9.0.tgz", + "integrity": "sha512-oCj8FiZ3U0hTP4aSui87P4L4jC37BtQwUMqk+zk/b11FR19BJDeZsZAvIHutWnmtw7r85UmR3CEWZ0HWU2mAlw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/stack-utils": "^1.0.1", + "chalk": "^2.0.1", + "micromatch": "^3.1.10", + "slash": "^2.0.0", + "stack-utils": "^1.0.1" + } + }, + "jest-mock": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-24.9.0.tgz", + "integrity": "sha512-3BEYN5WbSq9wd+SyLDES7AHnjH9A/ROBwmz7l2y+ol+NtSFO8DYiEBzoO1CeFc9a8DYy10EO4dDFVv/wN3zl1w==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0" + } + }, + "jest-resolve": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-24.9.0.tgz", + "integrity": "sha512-TaLeLVL1l08YFZAt3zaPtjiVvyy4oSA6CRe+0AFPPVX3Q/VI0giIWWoAvoS5L96vj9Dqxj4fB5p2qrHCmTU/MQ==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "browser-resolve": "^1.11.3", + "chalk": "^2.0.1", + "jest-pnp-resolver": "^1.2.1", + "realpath-native": "^1.1.0" + } + }, + "jest-resolve-dependencies": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-24.9.0.tgz", + "integrity": "sha512-Fm7b6AlWnYhT0BXy4hXpactHIqER7erNgIsIozDXWl5dVm+k8XdGVe1oTg1JyaFnOxarMEbax3wyRJqGP2Pq+g==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-snapshot": "^24.9.0" + } + }, + "jest-runner": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-24.9.0.tgz", + "integrity": "sha512-KksJQyI3/0mhcfspnxxEOBueGrd5E4vV7ADQLT9ESaCzz02WnbdbKWIf5Mkaucoaj7obQckYPVX6JJhgUcoWWg==", + "dev": true, + "requires": { + "@jest/console": "^24.7.1", + "@jest/environment": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.4.2", + "exit": "^0.1.2", + "graceful-fs": "^4.1.15", + "jest-config": "^24.9.0", + "jest-docblock": "^24.3.0", + "jest-haste-map": "^24.9.0", + "jest-jasmine2": "^24.9.0", + "jest-leak-detector": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-resolve": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-util": "^24.9.0", + "jest-worker": "^24.6.0", + "source-map-support": "^0.5.6", + "throat": "^4.0.0" + } + }, + "jest-runtime": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-24.9.0.tgz", + "integrity": "sha512-8oNqgnmF3v2J6PVRM2Jfuj8oX3syKmaynlDMMKQ4iyzbQzIG6th5ub/lM2bCMTmoTKM3ykcUYI2Pw9xwNtjMnw==", + "dev": true, + "requires": { + "@jest/console": "^24.7.1", + "@jest/environment": "^24.9.0", + "@jest/source-map": "^24.3.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/yargs": "^13.0.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.1.15", + "jest-config": "^24.9.0", + "jest-haste-map": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-mock": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-resolve": "^24.9.0", + "jest-snapshot": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "realpath-native": "^1.1.0", + "slash": "^2.0.0", + "strip-bom": "^3.0.0", + "yargs": "^13.3.0" + } + }, + "jest-serializer": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-serializer/-/jest-serializer-24.9.0.tgz", + "integrity": "sha512-DxYipDr8OvfrKH3Kel6NdED3OXxjvxXZ1uIY2I9OFbGg+vUkkg7AGvi65qbhbWNPvDckXmzMPbK3u3HaDO49bQ==", + "dev": true + }, + "jest-snapshot": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-24.9.0.tgz", + "integrity": "sha512-uI/rszGSs73xCM0l+up7O7a40o90cnrk429LOiK3aeTvfC0HHmldbd81/B7Ix81KSFe1lwkbl7GnBGG4UfuDew==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "expect": "^24.9.0", + "jest-diff": "^24.9.0", + "jest-get-type": "^24.9.0", + "jest-matcher-utils": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-resolve": "^24.9.0", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "pretty-format": "^24.9.0", + "semver": "^6.2.0" + } + }, + "jest-util": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-24.9.0.tgz", + "integrity": "sha512-x+cZU8VRmOJxbA1K5oDBdxQmdq0OIdADarLxk0Mq+3XS4jgvhG/oKGWcIDCtPG0HgjxOYvF+ilPJQsAyXfbNOg==", + "dev": true, + "requires": { + "@jest/console": "^24.9.0", + "@jest/fake-timers": "^24.9.0", + "@jest/source-map": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "callsites": "^3.0.0", + "chalk": "^2.0.1", + "graceful-fs": "^4.1.15", + "is-ci": "^2.0.0", + "mkdirp": "^0.5.1", + "slash": "^2.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "@jest/console": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-24.9.0.tgz", + "integrity": "sha512-Zuj6b8TnKXi3q4ymac8EQfc3ea/uhLeCGThFqXeC8H9/raaH8ARPUTdId+XyGd03Z4In0/VjD2OYFcBF09fNLQ==", + "dev": true, + "requires": { + "@jest/source-map": "^24.9.0", + "chalk": "^2.0.1", + "slash": "^2.0.0" + } + } + } + }, + "jest-validate": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-24.9.0.tgz", + "integrity": "sha512-HPIt6C5ACwiqSiwi+OfSSHbK8sG7akG8eATl+IPKaeIjtPOeBUd/g3J7DghugzxrGjI93qS/+RPKe1H6PqvhRQ==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "camelcase": "^5.3.1", + "chalk": "^2.0.1", + "jest-get-type": "^24.9.0", + "leven": "^3.1.0", + "pretty-format": "^24.9.0" + } + }, + "jest-watcher": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-24.9.0.tgz", + "integrity": "sha512-+/fLOfKPXXYJDYlks62/4R4GoT+GU1tYZed99JSCOsmzkkF7727RqKrjNAxtfO4YpGv11wybgRvCjR73lK2GZw==", + "dev": true, + "requires": { + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/yargs": "^13.0.0", + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.1", + "jest-util": "^24.9.0", + "string-length": "^2.0.0" + } + }, + "leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node-notifier": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.3.tgz", + "integrity": "sha512-M4UBGcs4jeOK9CjTsYwkvH6/MzuUmGCyTW+kCY7uO+1ZVr0+FHGdPdIf5CCLqAaxnRrWidyoQlNkMIIVwbKB8Q==", + "dev": true, + "requires": { + "growly": "^1.3.0", + "is-wsl": "^1.1.0", + "semver": "^5.5.0", + "shellwords": "^0.1.1", + "which": "^1.3.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "pretty-format": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-24.9.0.tgz", + "integrity": "sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "ansi-regex": "^4.0.0", + "ansi-styles": "^3.2.0", + "react-is": "^16.8.4" + } + }, + "react-is": { + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz", + "integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } + }, + "write-file-atomic": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.1.tgz", + "integrity": "sha512-TGHFeZEZMnv+gBFRfjAcxL5bPHrsGKtnb4qsFAws7/vlh+QfwAaySIw4AXP9ZskTTh5GWu3FLuJhsWVdiJPGvg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, "jest-changed-files": { "version": "24.8.0", "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-24.8.0.tgz", @@ -8456,12 +9850,13 @@ } }, "jsx-ast-utils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", - "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz", + "integrity": "sha512-EdIHFMm+1BPynpKOpdPqiOsvnIrInRGJD7bzPZdPkjitQEqpdpUuFpq4T0npZFKTiB3RhWFdGN+oqOJIdhDhQA==", "dev": true, "requires": { - "array-includes": "^3.0.3" + "array-includes": "^3.0.3", + "object.assign": "^4.1.0" } }, "kind-of": { @@ -8585,6 +9980,12 @@ "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "dev": true }, + "lodash.unescape": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", + "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=", + "dev": true + }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", @@ -8641,6 +10042,12 @@ } } }, + "make-error": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", + "dev": true + }, "makeerror": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.11.tgz", @@ -8810,9 +10217,9 @@ } }, "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, "minimalistic-assert": { @@ -8908,9 +10315,9 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, "nan": { @@ -9225,6 +10632,12 @@ } } }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, "object-keys": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", @@ -9260,6 +10673,56 @@ "object-keys": "^1.0.11" } }, + "object.entries": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", + "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, + "object.fromentries": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.1.tgz", + "integrity": "sha512-PUQv8Hbg3j2QX0IQYv3iAGCbGcu4yY4KQ92/dhA4sFSixBmSmp13UpDLs6jGK8rBtbmhNNIK99LD2k293jpiGA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.15.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + }, + "dependencies": { + "es-abstract": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.0.tgz", + "integrity": "sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.0", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-inspect": "^1.6.0", + "object-keys": "^1.1.1", + "string.prototype.trimleft": "^2.1.0", + "string.prototype.trimright": "^2.1.0" + } + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + } + } + }, "object.getownpropertydescriptors": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", @@ -9287,6 +10750,18 @@ } } }, + "object.values": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz", + "integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -9305,12 +10780,12 @@ } }, "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "mimic-fn": "^2.1.0" } }, "optimist": { @@ -9530,6 +11005,15 @@ "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==", "dev": true }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", @@ -9708,41 +11192,14 @@ } }, "pkg-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", - "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", "dev": true, "requires": { - "find-up": "^1.0.0" - }, - "dependencies": { - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } - } + "find-up": "^2.1.0" } }, - "pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", - "dev": true - }, "pn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", @@ -10789,16 +12246,6 @@ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "dev": true }, - "require-uncached": { - "version": "1.0.3", - "resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" - } - }, "resolve": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", @@ -10825,9 +12272,9 @@ } }, "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, "resolve-url": { @@ -10837,12 +12284,12 @@ "dev": true }, "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", "dev": true, "requires": { - "onetime": "^2.0.0", + "onetime": "^5.1.0", "signal-exit": "^3.0.2" } }, @@ -10895,9 +12342,9 @@ } }, "rxjs": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", - "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", + "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -11227,9 +12674,9 @@ "dev": true }, "slice-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.0.0.tgz", - "integrity": "sha512-4j2WTWjp3GsZ+AOagyzVbzp4vWGtZ0hEZ/gDY/uTvm6MTxUfTUIsnMIFb1bn8o0RuXiqUw15H1bue8f22Vw2oQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", "dev": true, "requires": { "ansi-styles": "^3.2.0", @@ -11692,6 +13139,26 @@ "strip-ansi": "^3.0.0" } }, + "string.prototype.trimleft": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", + "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", + "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -11820,21 +13287,27 @@ } }, "table": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/table/-/table-5.1.1.tgz", - "integrity": "sha512-NUjapYb/qd4PeFW03HnAuOJ7OMcBkJlqeClWxeNlQ0lXGSb52oZXGzkO0/I0ARegQ2eUT1g2VDJH0eUxDRcHmw==", + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", "dev": true, "requires": { - "ajv": "^6.6.1", - "lodash": "^4.17.11", - "slice-ansi": "2.0.0", - "string-width": "^2.1.1" + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" }, "dependencies": { "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, "is-fullwidth-code-point": { @@ -11844,22 +13317,23 @@ "dev": true }, "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "dev": true, "requires": { + "emoji-regex": "^7.0.1", "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "strip-ansi": "^5.1.0" } }, "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^4.1.0" } } } @@ -12200,12 +13674,84 @@ "glob": "^7.1.2" } }, + "ts-jest": { + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.1.0.tgz", + "integrity": "sha512-HEGfrIEAZKfu1pkaxB9au17b1d9b56YZSqz5eCVE8mX68+5reOvlM93xGOzzCREIov9mdH7JBG+s0UyNAqr0tQ==", + "dev": true, + "requires": { + "bs-logger": "0.x", + "buffer-from": "1.x", + "fast-json-stable-stringify": "2.x", + "json5": "2.x", + "lodash.memoize": "4.x", + "make-error": "1.x", + "mkdirp": "0.x", + "resolve": "1.x", + "semver": "^5.5", + "yargs-parser": "10.x" + }, + "dependencies": { + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, + "json5": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz", + "integrity": "sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=", + "dev": true + }, + "yargs-parser": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", + "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", + "dev": true, + "requires": { + "camelcase": "^4.1.0" + } + } + } + }, + "ts-node": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.0.tgz", + "integrity": "sha512-fbG32iZEupNV2E2Fd2m2yt1TdAwR3GTCrJQBHDevIiEBNy1A8kqnyl1fv7jmRmmbtcapFab2glZXHJvfD1ed0Q==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.6", + "yn": "^3.0.0" + } + }, "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", "dev": true }, + "tsutils": { + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -12236,6 +13782,12 @@ "prelude-ls": "~1.1.2" } }, + "type-fest": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.5.2.tgz", + "integrity": "sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw==", + "dev": true + }, "type-is": { "version": "1.6.16", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", @@ -12251,6 +13803,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz", + "integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==", + "dev": true + }, "uglify-js": { "version": "3.4.9", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", @@ -12552,6 +14110,12 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -12905,9 +14469,9 @@ "dev": true }, "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", "dev": true, "requires": { "mkdirp": "^0.5.1" @@ -13042,6 +14606,12 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true } } } diff --git a/package.json b/package.json index dfd3798..506b2cb 100644 --- a/package.json +++ b/package.json @@ -3,27 +3,29 @@ "version": "2.0.12", "description": "Group peer to peer video calls for anybody.", "repository": "https://github.com/jeremija/peer-calls", - "main": "src/index.js", + "main": "lib/index.js", "bin": { - "peercalls": "./src/index.js" + "peercalls": "./lib/index.js" }, "scripts": { - "start": "node src/index.js", - "start:server": "nodemon src/index.js --ignore build/ --ignore src/client", - "start:watch": "chastifol [ npm run js:watch ] [ npm run css:watch ] [ npm run start:server ]", + "start": "node lib/index.js", + "start:server": "nodemon -ignore build/ --ignore lib/client lib/index.js", + "start:watch": "chastifol [ npm run ts:watch ] [ npm run js:watch ] [ npm run css:watch ] [ npm run start:server ]", "watch": "", "prepublishOnly": "npm run build", "build": "npm run css && npm run js", "test": "jest", "test:coverage": "jest --coverage", "test:watch": "jest --watch", - "js": "browserify -t babelify ./src/client/index.js -o ./build/index.js", - "js:watch": "watchify -d -v -t babelify ./src/client/index.js -o ./build/index.js", + "js": "browserify -t babelify ./lib/client/index.js -o ./build/index.js", + "js:watch": "watchify -d -v -t babelify ./lib/client/index.js -o ./build/index.js", "css": "node-sass ./src/scss/style.scss -o ./build/", "css:watch": "npm run css && node-sass --watch ./src/scss/style.scss -o ./build/", "lint": "eslint .", "lint:fix": "eslint . --fix", - "ci": "npm run lint && npm run test:coverage && npm run build" + "ci": "npm run lint && npm run test:coverage && npm run build", + "ts:watch": "tsc --build . --watch --preserveWatchOutput", + "ts": "tsc --build ." }, "babel": { "presets": [ @@ -78,36 +80,41 @@ "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.5.0", "@babel/preset-react": "^7.0.0", + "@types/config": "0.0.36", + "@types/debug": "^4.1.5", + "@types/express": "^4.17.2", + "@types/jest": "^24.0.23", + "@types/node": "^12.12.7", + "@types/socket.io": "^2.1.4", + "@types/socket.io-client": "^1.4.32", + "@types/supertest": "^2.0.8", + "@types/underscore": "^1.9.3", + "@types/uuid": "^3.4.6", + "@typescript-eslint/eslint-plugin": "^2.7.0", + "@typescript-eslint/parser": "^2.7.0", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^24.8.0", "babelify": "^10.0.0", "chastifol": "^4.1.0", - "eslint": "^5.10.0", + "eslint": "^6.6.0", "eslint-config-standard": "^12.0.0", "eslint-config-standard-react": "^7.0.2", - "eslint-plugin-import": "^2.3.0", + "eslint-plugin-import": "^2.18.2", "eslint-plugin-node": "^8.0.0", "eslint-plugin-promise": "^4.0.1", - "eslint-plugin-react": "^7.0.1", + "eslint-plugin-react": "^7.16.0", "eslint-plugin-standard": "^4.0.0", + "jest": "^24.9.0", "jest-cli": "^24.8.0", "node-sass": "^4.13.0", "nodemon": "^1.18.8", "redux-mock-store": "^1.2.3", "supertest": "^3.0.0", + "ts-jest": "^24.1.0", + "ts-node": "^8.5.0", + "typescript": "^3.6.4", "uglify-js": "^3.4.9", "watchify": "^3.11.1" - }, - "jest": { - "transform": { - "^.+\\.[t|j]sx?$": "/node_modules/babel-jest" - }, - "setupFiles": [ - "/jest.setup.js" - ], - "modulePathIgnorePatterns": [ - "/node_modules/" - ] } } diff --git a/src/index.js b/src/index.js index eca5937..5c7199a 100755 --- a/src/index.js +++ b/src/index.js @@ -4,8 +4,10 @@ if (!process.env.DEBUG) { process.env.DEBUG = 'peercalls' } -const app = require('./server/app.js') -const debug = require('debug')('peercalls') +import app from './server/app' +import _debug from 'debug' + +const debug = _debug('peercalls') const port = process.env.PORT || 3000 const server = app.listen(port, () => debug('Listening on: %s', port)) diff --git a/src/server/app.test.js b/src/server/app.test.ts similarity index 70% rename from src/server/app.test.js rename to src/server/app.test.ts index 1ea6357..8116b41 100644 --- a/src/server/app.test.js +++ b/src/server/app.test.ts @@ -1,16 +1,19 @@ jest.mock('socket.io', () => { + // eslint-disable-next-line const { EventEmitter } = require('events') return jest.fn().mockReturnValue(new EventEmitter()) }) -jest.mock('./socket.js') +jest.mock('./socket') -const app = require('./app.js') -const config = require('config') -const handleSocket = require('./socket.js') -const io = require('socket.io')() -const request = require('supertest') +import app from './app' +import { config } from './config' +import handleSocket from './socket' +import SocketIO from 'socket.io' +import request from 'supertest' -const BASE_URL = config.get('baseUrl') +const io = SocketIO() + +const BASE_URL: string = config.get('baseUrl') describe('server/app', () => { @@ -50,7 +53,7 @@ describe('server/app', () => { it('calls handleSocket with socket', () => { const socket = { hi: 'me socket' } io.emit('connection', socket) - expect(handleSocket.mock.calls).toEqual([[ socket, io ]]) + expect((handleSocket as jest.Mock).mock.calls).toEqual([[ socket, io ]]) }) }) diff --git a/src/server/app.js b/src/server/app.ts similarity index 53% rename from src/server/app.js rename to src/server/app.ts index 7c64357..aa0604f 100644 --- a/src/server/app.js +++ b/src/server/app.ts @@ -1,20 +1,23 @@ -#!/usr/bin/env node -'use strict' -const config = require('config') -const debug = require('debug')('peercalls') -const express = require('express') -const handleSocket = require('./socket.js') -const path = require('path') -const { createServer } = require('./server.js') +import { config } from './config' +import _debug from 'debug' +import express from 'express' +import handleSocket from './socket' +import path from 'path' +import { createServer } from './server' +import SocketIO from 'socket.io' +import call from './routes/call' +import index from './routes/index' -const BASE_URL = config.get('baseUrl') +const debug = _debug('peercalls') + +const BASE_URL: string = config.get('baseUrl') const SOCKET_URL = `${BASE_URL}/ws` debug(`WebSocket URL: ${SOCKET_URL}`) const app = express() const server = createServer(config, app) -const io = require('socket.io')(server, { path: SOCKET_URL }) +const io = SocketIO(server, { path: SOCKET_URL }) app.locals.version = require('../../package.json').version app.locals.baseUrl = BASE_URL @@ -25,10 +28,10 @@ app.set('views', path.join(__dirname, '../views')) const router = express.Router() router.use('/res', express.static(path.join(__dirname, '../res'))) router.use('/static', express.static(path.join(__dirname, '../../build'))) -router.use('/call', require('./routes/call.js')) -router.use('/', require('./routes/index.js')) +router.use('/call', call) +router.use('/', index) app.use(BASE_URL, router) io.on('connection', socket => handleSocket(socket, io)) -module.exports = server +export default server diff --git a/src/server/config.ts b/src/server/config.ts new file mode 100644 index 0000000..c5c3772 --- /dev/null +++ b/src/server/config.ts @@ -0,0 +1,26 @@ +import cfg, { IConfig } from 'config' + +export type ICEServer = { + url: string + urls: string[] | string + auth: 'secret' + username: string + secret: string +} | { + url: string + urls: string[] | string + auth: undefined + username: string + credential: string +} + +export interface Config { + baseUrl: string + iceServers: ICEServer[] + ssl: { + cert: string + key: string + } +} + +export const config = cfg as IConfig & Config diff --git a/src/server/routes/call.js b/src/server/routes/call.js deleted file mode 100644 index 671be4b..0000000 --- a/src/server/routes/call.js +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env node -'use strict' -const config = require('config') -const turn = require('../turn.js') -const router = require('express').Router() -const uuid = require('uuid') - -const BASE_URL = config.get('baseUrl') -const cfgIceServers = config.get('iceServers') - -router.get('/', (req, res) => { - res.redirect(`${BASE_URL}/call/${uuid.v4()}`) -}) - -router.get('/:callId', (req, res) => { - const iceServers = turn.processServers(cfgIceServers) - res.render('call', { - callId: encodeURIComponent(req.params.callId), - iceServers - }) -}) - -module.exports = router diff --git a/src/server/routes/call.ts b/src/server/routes/call.ts new file mode 100644 index 0000000..8c74bbf --- /dev/null +++ b/src/server/routes/call.ts @@ -0,0 +1,23 @@ +import { config, ICEServer } from '../config' +import * as turn from '../turn' +import { Router } from 'express' +import { v4 } from 'uuid' + +const router = Router() + +const BASE_URL: string = config.get('baseUrl') +const cfgIceServers = config.get('iceServers') as ICEServer[] + +router.get('/', (req, res) => { + res.redirect(`${BASE_URL}/call/${v4()}`) +}) + +router.get('/:callId', (req, res) => { + const iceServers = turn.processServers(cfgIceServers) + res.render('call', { + callId: encodeURIComponent(req.params.callId), + iceServers, + }) +}) + +export default router diff --git a/src/server/routes/index.js b/src/server/routes/index.js deleted file mode 100644 index 9691e9f..0000000 --- a/src/server/routes/index.js +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env node -'use strict' -const router = require('express').Router() - -router.get('/', (req, res) => { - res.render('index') -}) - -module.exports = router diff --git a/src/server/routes/index.ts b/src/server/routes/index.ts new file mode 100644 index 0000000..a3fdbe7 --- /dev/null +++ b/src/server/routes/index.ts @@ -0,0 +1,9 @@ +import { Router } from 'express' + +const router = Router() + +router.get('/', (req, res) => { + res.render('index') +}) + +export default router diff --git a/src/server/server.js b/src/server/server.js deleted file mode 100644 index e7fe100..0000000 --- a/src/server/server.js +++ /dev/null @@ -1,17 +0,0 @@ -const fs = require('fs') -const path = require('path') - -const projectRoot = path.resolve(path.join(__dirname, '../..')) - -const readFile = file => fs.readFileSync(path.resolve(projectRoot, file)) - -function createServer (config, app) { - if (config.ssl) { - const key = readFile(config.ssl.key) - const cert = readFile(config.ssl.cert) - return require('https').createServer({ key, cert }, app) - } - return require('http').createServer(app) -} - -module.exports = { createServer } diff --git a/src/server/server.test.js b/src/server/server.test.ts similarity index 71% rename from src/server/server.test.js rename to src/server/server.test.ts index 3adc808..ea02343 100644 --- a/src/server/server.test.js +++ b/src/server/server.test.ts @@ -1,11 +1,11 @@ -const express = require('express') -const http = require('http') -const https = require('https') -const { createServer } = require('./server.js') +import express from 'express' +import http from 'http' +import https from 'https' +import { createServer } from './server' describe('server', () => { - let app, config + let app: Express.Application, config: any beforeEach(() => { config = {} app = express() @@ -15,7 +15,7 @@ describe('server', () => { it('creates https server when config.ssl', () => { config.ssl = { cert: 'config/cert.example.pem', - key: 'config/cert.example.key' + key: 'config/cert.example.key', } const s = createServer(config, app) expect(s).toEqual(jasmine.any(https.Server)) diff --git a/src/server/server.ts b/src/server/server.ts new file mode 100644 index 0000000..e93b08c --- /dev/null +++ b/src/server/server.ts @@ -0,0 +1,16 @@ +import { readFileSync } from 'fs' +import { resolve, join } from 'path' +import { Config } from './config' + +const projectRoot = resolve(join(__dirname, '../..')) + +const readFile = (file: string) => readFileSync(resolve(projectRoot, file)) + +export function createServer (config: Config, app: Express.Application) { + if (config.ssl) { + const key = readFile(config.ssl.key) + const cert = readFile(config.ssl.cert) + return require('https').createServer({ key, cert }, app) + } + return require('http').createServer(app) +} diff --git a/src/server/socket.test.js b/src/server/socket.test.ts similarity index 62% rename from src/server/socket.test.js rename to src/server/socket.test.ts index 3c5dd5c..78c7333 100644 --- a/src/server/socket.test.js +++ b/src/server/socket.test.ts @@ -1,21 +1,33 @@ -'use strict' - -const EventEmitter = require('events').EventEmitter -const handleSocket = require('./socket.js') +import { EventEmitter } from 'events' +import handleSocket from './socket' +import { Socket, Server } from 'socket.io' describe('server/socket', () => { - let socket, io, rooms + type SocketMock = Socket & { + id: string + room?: string + join: jest.Mock + leave: jest.Mock + emit: jest.Mock + } + + let socket: SocketMock + let io: Server & { + in: jest.Mock<(room: string) => SocketMock> + to: jest.Mock<(room: string) => SocketMock> + } + let rooms: Record beforeEach(() => { - socket = new EventEmitter() + socket = new EventEmitter() as SocketMock socket.id = 'socket0' socket.join = jest.fn() socket.leave = jest.fn() rooms = {} - io = {} + io = {} as any io.in = io.to = jest.fn().mockImplementation(room => { return (rooms[room] = rooms[room] || { - emit: jest.fn() + emit: jest.fn(), }) }) @@ -23,21 +35,21 @@ describe('server/socket', () => { adapter: { rooms: { room1: { - 'socket0': true - }, + socket0: true, + } as any, room2: { - 'socket0': true - }, + socket0: true, + } as any, room3: { sockets: { 'socket0': true, 'socket1': true, - 'socket2': true - } - } - } - } - } + 'socket2': true, + }, + } as any, + }, + } as any, + } as any socket.leave = jest.fn() socket.join = jest.fn() @@ -52,16 +64,16 @@ describe('server/socket', () => { describe('signal', () => { it('should broadcast signal to specific user', () => { - let signal = { type: 'signal' } + const signal = { type: 'signal' } socket.emit('signal', { userId: 'a', signal }) expect(io.to.mock.calls).toEqual([[ 'a' ]]) - expect(io.to('a').emit.mock.calls).toEqual([[ + expect((io.to('a').emit as jest.Mock).mock.calls).toEqual([[ 'signal', { userId: 'socket0', - signal - } + signal, + }, ]]) }) }) @@ -84,19 +96,19 @@ describe('server/socket', () => { socket.emit('ready', 'room3') expect(io.to.mock.calls).toEqual([[ 'room3' ]]) - expect(io.to('room3').emit.mock.calls).toEqual([ + expect((io.to('room3').emit as jest.Mock).mock.calls).toEqual([ [ 'users', { initiator: 'socket0', users: [{ - id: 'socket0' + id: 'socket0', }, { - id: 'socket1' + id: 'socket1', }, { - id: 'socket2' - }] - } - ] + id: 'socket2', + }], + }, + ], ]) }) }) diff --git a/src/server/socket.js b/src/server/socket.ts similarity index 63% rename from src/server/socket.js rename to src/server/socket.ts index 5f67b6b..55760ad 100644 --- a/src/server/socket.js +++ b/src/server/socket.ts @@ -1,13 +1,18 @@ 'use strict' -const debug = require('debug')('peer-calls:socket') -const _ = require('underscore') +import _debug from 'debug' +import _ from 'underscore' +import { Socket, Server } from 'socket.io' -module.exports = function (socket, io) { +const debug = _debug('peercalls:socket') + +type SocketWithRoom = Socket & { room?: string } + +export default function handleSocket(socket: SocketWithRoom, io: Server) { socket.on('signal', payload => { // debug('signal: %s, payload: %o', socket.id, payload) io.to(payload.userId).emit('signal', { userId: socket.id, - signal: payload.signal + signal: payload.signal, }) }) @@ -18,17 +23,17 @@ module.exports = function (socket, io) { socket.join(roomName) socket.room = roomName - let users = getUsers(roomName) + const users = getUsers(roomName) debug('ready: %s, room: %s, users: %o', socket.id, roomName, users) io.to(roomName).emit('users', { initiator: socket.id, - users + users, }) }) - function getUsers (roomName) { + function getUsers (roomName: string) { return _.map(io.sockets.adapter.rooms[roomName].sockets, (_, id) => { return { id } }) diff --git a/src/server/turn.js b/src/server/turn.js deleted file mode 100644 index 86a4cea..0000000 --- a/src/server/turn.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' -const crypto = require('crypto') - -function getCredentials (name, secret) { - // this credential would be valid for the next 24 hours - const timestamp = parseInt(Date.now() / 1000, 10) + 24 * 3600 - const username = [timestamp, name].join(':') - const hmac = crypto.createHmac('sha1', secret) - hmac.setEncoding('base64') - hmac.write(username) - hmac.end() - const credential = hmac.read() - return { username, credential } -} - -function processServers (iceServers) { - return iceServers.map(server => { - switch (server.auth) { - case undefined: - return server - case 'secret': - const cred = getCredentials(server.username, server.secret) - return { - url: server.url, - urls: server.urls, - username: cred.username, - credential: cred.credential - } - default: - throw new Error('Authentication type not implemented: ' + server.auth) - } - }) -} - -module.exports = { getCredentials, processServers } diff --git a/src/server/turn.test.js b/src/server/turn.test.ts similarity index 78% rename from src/server/turn.test.js rename to src/server/turn.test.ts index e48edaa..ed957e8 100644 --- a/src/server/turn.test.js +++ b/src/server/turn.test.ts @@ -1,4 +1,5 @@ -const turn = require('./turn.js') +import * as turn from './turn' +import { ICEServer } from './config' describe('server/turn', () => { describe('getCredentials', () => { @@ -11,17 +12,18 @@ describe('server/turn', () => { }) describe('processServers', () => { - const servers = [{ + const servers: ICEServer[] = [{ url: 'server1', urls: 'server1', + auth: undefined, username: 'a', - credential: 'b' + credential: 'b', }, { url: 'server2', urls: 'server2', username: 'c', secret: 'd', - auth: 'secret' + auth: 'secret', }] it('does not expose secret', () => { @@ -32,13 +34,13 @@ describe('server/turn', () => { url: 'server2', urls: 'server2', username: jasmine.any(String), - credential: jasmine.any(String) + credential: jasmine.any(String), }) expect(s[1].username).toMatch(/^[0-9]+:c$/) }) it('throws error when unknown auth type', () => { - expect(() => turn.processServers([{ auth: 'bla' }])) + expect(() => turn.processServers([{ auth: 'bla' } as any])) .toThrowError(/not implemented/) }) }) diff --git a/src/server/turn.ts b/src/server/turn.ts new file mode 100644 index 0000000..b8eda59 --- /dev/null +++ b/src/server/turn.ts @@ -0,0 +1,45 @@ +import crypto from 'crypto' +import { ICEServer } from './config' + +export interface Credentials { + username: string + credential: string +} + +export function getCredentials (name: string, secret: string): Credentials { + // this credential would be valid for the next 24 hours + const timestamp = Math.floor(Date.now() / 1000) + 24 * 3600 + const username = [timestamp, name].join(':') + const hmac = crypto.createHmac('sha1', secret) + hmac.setEncoding('base64') + hmac.write(username) + hmac.end() + const credential = hmac.read() + return { username, credential } +} + +function getServerConfig(server: ICEServer, cred: Credentials) { + return { + url: server.url, + urls: server.urls, + username: cred.username, + credential: cred.credential, + } +} + +export function processServers (iceServers: ICEServer[]) { + return iceServers.map(server => { + switch (server.auth) { + case undefined: + return server + case 'secret': + return getServerConfig( + server, + getCredentials(server.username, server.secret), + ) + default: + throw new Error('Authentication type not implemented: ' + + (server as {auth: string}).auth) + } + }) +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a82d996 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "composite": true, + "declaration": true, + "declarationMap": true, + "inlineSourceMap": true, + "inlineSources": true, + "lib": ["es2015", "dom"], + "target": "es3", + "moduleResolution": "node", + "jsx": "react", + "noImplicitAny": true, + "strict": true, + "skipLibCheck": true, + "noUnusedLocals": false, + "esModuleInterop": true, + "emitDecoratorMetadata": false, + "experimentalDecorators": false, + "allowJs": false, + "checkJs": false, + "outDir": "lib", + "rootDir": "src" + } +} From e9926e3484d0b61b0b6747577ff7dac38b76efd3 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 11:16:09 -0300 Subject: [PATCH 09/38] Refactor actions/reducers to TS --- package-lock.json | 149 +++++++++++++++ package.json | 8 + src/client/__mocks__/{socket.js => socket.ts} | 0 src/client/__mocks__/{store.js => store.ts} | 0 src/client/__mocks__/{window.js => window.ts} | 8 +- src/client/actions/CallActions.js | 50 ----- ...allActions.test.js => CallActions.test.ts} | 0 src/client/actions/CallActions.ts | 62 ++++++ src/client/actions/ChatActions.js | 11 -- src/client/actions/ChatActions.ts | 18 ++ src/client/actions/NotifyActions.js | 75 -------- src/client/actions/NotifyActions.ts | 137 ++++++++++++++ src/client/actions/PeerActions.test.js | 169 ----------------- src/client/actions/PeerActions.test.ts | 177 ++++++++++++++++++ .../{PeerActions.js => PeerActions.ts} | 143 ++++++++++---- src/client/actions/SocketActions.js | 64 ------- ...tActions.test.js => SocketActions.test.ts} | 75 ++++---- src/client/actions/SocketActions.ts | 98 ++++++++++ src/client/actions/StreamActions.js | 24 --- src/client/actions/StreamActions.ts | 61 ++++++ .../components/{Alerts.js => Alerts.ts} | 0 src/client/components/{App.js => App.ts} | 0 src/client/components/{Chat.js => Chat.ts} | 0 .../{Input.test.js => Input.test.ts} | 0 src/client/components/{Input.js => Input.ts} | 0 .../{Notifications.js => Notifications.ts} | 0 .../{Toolbar.test.js => Toolbar.test.ts} | 0 .../components/{Toolbar.js => Toolbar.ts} | 0 .../{Video.test.js => Video.test.ts} | 0 src/client/components/{Video.js => Video.ts} | 0 src/client/{constants.js => constants.ts} | 1 - .../containers/{App.test.js => App.test.ts} | 0 src/client/containers/{App.js => App.ts} | 0 src/client/debug/{index.js => index.ts} | 0 src/client/{index.js => index.tsx} | 3 +- ...iddlewares.test.js => middlewares.test.ts} | 0 src/client/{middlewares.js => middlewares.ts} | 2 +- .../{active.test.js => active.test.ts} | 0 src/client/reducers/{active.js => active.ts} | 2 +- .../{alerts.test.js => alerts.test.ts} | 0 src/client/reducers/{alerts.js => alerts.ts} | 0 src/client/reducers/{index.js => index.ts} | 0 src/client/reducers/messages.js | 15 -- .../{messages.test.js => messages.test.ts} | 0 src/client/reducers/messages.ts | 17 ++ .../{notifications.js => notifications.ts} | 0 src/client/reducers/{peers.js => peers.ts} | 14 +- .../{streams.test.js => streams.test.ts} | 18 +- .../reducers/{streams.js => streams.ts} | 25 ++- src/client/{socket.js => socket.ts} | 2 +- src/client/store.js | 13 -- src/client/store.ts | 19 ++ src/client/{window.test.js => window.test.ts} | 47 ++--- src/client/{window.js => window.ts} | 21 ++- 54 files changed, 972 insertions(+), 556 deletions(-) rename src/client/__mocks__/{socket.js => socket.ts} (100%) rename src/client/__mocks__/{store.js => store.ts} (100%) rename src/client/__mocks__/{window.js => window.ts} (78%) delete mode 100644 src/client/actions/CallActions.js rename src/client/actions/{CallActions.test.js => CallActions.test.ts} (100%) create mode 100644 src/client/actions/CallActions.ts delete mode 100644 src/client/actions/ChatActions.js create mode 100644 src/client/actions/ChatActions.ts delete mode 100644 src/client/actions/NotifyActions.js create mode 100644 src/client/actions/NotifyActions.ts delete mode 100644 src/client/actions/PeerActions.test.js create mode 100644 src/client/actions/PeerActions.test.ts rename src/client/actions/{PeerActions.js => PeerActions.ts} (59%) delete mode 100644 src/client/actions/SocketActions.js rename src/client/actions/{SocketActions.test.js => SocketActions.test.ts} (60%) create mode 100644 src/client/actions/SocketActions.ts delete mode 100644 src/client/actions/StreamActions.js create mode 100644 src/client/actions/StreamActions.ts rename src/client/components/{Alerts.js => Alerts.ts} (100%) rename src/client/components/{App.js => App.ts} (100%) rename src/client/components/{Chat.js => Chat.ts} (100%) rename src/client/components/{Input.test.js => Input.test.ts} (100%) rename src/client/components/{Input.js => Input.ts} (100%) rename src/client/components/{Notifications.js => Notifications.ts} (100%) rename src/client/components/{Toolbar.test.js => Toolbar.test.ts} (100%) rename src/client/components/{Toolbar.js => Toolbar.ts} (100%) rename src/client/components/{Video.test.js => Video.test.ts} (100%) rename src/client/components/{Video.js => Video.ts} (100%) rename src/client/{constants.js => constants.ts} (99%) rename src/client/containers/{App.test.js => App.test.ts} (100%) rename src/client/containers/{App.js => App.ts} (100%) rename src/client/debug/{index.js => index.ts} (100%) rename src/client/{index.js => index.tsx} (86%) rename src/client/{middlewares.test.js => middlewares.test.ts} (100%) rename src/client/{middlewares.js => middlewares.ts} (85%) rename src/client/reducers/{active.test.js => active.test.ts} (100%) rename src/client/reducers/{active.js => active.ts} (83%) rename src/client/reducers/{alerts.test.js => alerts.test.ts} (100%) rename src/client/reducers/{alerts.js => alerts.ts} (100%) rename src/client/reducers/{index.js => index.ts} (100%) delete mode 100644 src/client/reducers/messages.js rename src/client/reducers/{messages.test.js => messages.test.ts} (100%) create mode 100644 src/client/reducers/messages.ts rename src/client/reducers/{notifications.js => notifications.ts} (100%) rename src/client/reducers/{peers.js => peers.ts} (52%) rename src/client/reducers/{streams.test.js => streams.test.ts} (83%) rename src/client/reducers/{streams.js => streams.ts} (54%) rename src/client/{socket.js => socket.ts} (56%) delete mode 100644 src/client/store.js create mode 100644 src/client/store.ts rename src/client/{window.test.js => window.test.ts} (72%) rename src/client/{window.js => window.ts} (54%) diff --git a/package-lock.json b/package-lock.json index b88cc50..fb0fe95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1933,6 +1933,12 @@ "@types/babel-types": "*" } }, + "@types/bluebird": { + "version": "3.5.29", + "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.29.tgz", + "integrity": "sha512-kmVtnxTuUuhCET669irqQmPAez4KFnFVKvpleVRyfC3g+SHD1hIkFZcWLim9BVcwUBLO59o8VZE4yGCmTif8Yw==", + "dev": true + }, "@types/body-parser": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz", @@ -1997,6 +2003,33 @@ "@types/range-parser": "*" } }, + "@types/hoist-non-react-statics": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", + "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", + "dev": true, + "requires": { + "@types/react": "*", + "hoist-non-react-statics": "^3.3.0" + }, + "dependencies": { + "hoist-non-react-statics": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz", + "integrity": "sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==", + "dev": true, + "requires": { + "react-is": "^16.7.0" + } + }, + "react-is": { + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz", + "integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==", + "dev": true + } + } + }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -2049,12 +2082,107 @@ "integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==", "dev": true }, + "@types/prop-types": { + "version": "15.7.3", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", + "integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==", + "dev": true + }, "@types/range-parser": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.3.tgz", "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==", "dev": true }, + "@types/react": { + "version": "16.9.11", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.11.tgz", + "integrity": "sha512-UBT4GZ3PokTXSWmdgC/GeCGEJXE5ofWyibCcecRLUVN2ZBpXQGVgQGtG2foS7CrTKFKlQVVswLvf7Js6XA/CVQ==", + "dev": true, + "requires": { + "@types/prop-types": "*", + "csstype": "^2.2.0" + } + }, + "@types/react-dom": { + "version": "16.9.4", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.4.tgz", + "integrity": "sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, + "@types/react-redux": { + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.5.tgz", + "integrity": "sha512-ZoNGQMDxh5ENY7PzU7MVonxDzS1l/EWiy8nUhDqxFqUZn4ovboCyvk4Djf68x6COb7vhGTKjyjxHxtFdAA5sUA==", + "dev": true, + "requires": { + "@types/hoist-non-react-statics": "^3.3.0", + "@types/react": "*", + "hoist-non-react-statics": "^3.3.0", + "redux": "^4.0.0" + }, + "dependencies": { + "hoist-non-react-statics": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz", + "integrity": "sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==", + "dev": true, + "requires": { + "react-is": "^16.7.0" + } + }, + "react-is": { + "version": "16.11.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz", + "integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==", + "dev": true + } + } + }, + "@types/redux": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@types/redux/-/redux-3.6.0.tgz", + "integrity": "sha1-8evh5UEVGAcuT9/KXHbhbnTBOZo=", + "dev": true, + "requires": { + "redux": "*" + } + }, + "@types/redux-logger": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/redux-logger/-/redux-logger-3.0.7.tgz", + "integrity": "sha512-oV9qiCuowhVR/ehqUobWWkXJjohontbDGLV88Be/7T4bqMQ3kjXwkFNL7doIIqlbg3X2PC5WPziZ8/j/QHNQ4A==", + "dev": true, + "requires": { + "redux": "^3.6.0" + }, + "dependencies": { + "redux": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/redux/-/redux-3.7.2.tgz", + "integrity": "sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A==", + "dev": true, + "requires": { + "lodash": "^4.2.1", + "lodash-es": "^4.2.1", + "loose-envify": "^1.1.0", + "symbol-observable": "^1.0.3" + } + } + } + }, + "@types/redux-mock-store": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/redux-mock-store/-/redux-mock-store-1.0.1.tgz", + "integrity": "sha512-1egEnh2/+sRRKImnCo5EMVm0Uxu4fBHeLHk/inhSp/VpE93It8lk3gYeNfehUgXd6OzqP5LLA9kzO9x7o3WfwA==", + "dev": true, + "requires": { + "redux": "^4.0.0" + } + }, "@types/serve-static": { "version": "1.13.3", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.3.tgz", @@ -2065,6 +2193,15 @@ "@types/mime": "*" } }, + "@types/simple-peer": { + "version": "6.1.6", + "resolved": "https://registry.npmjs.org/@types/simple-peer/-/simple-peer-6.1.6.tgz", + "integrity": "sha512-jnktVe4nDkNAIf/5brRQ4VqMP845dtRCrFMRagOxiTdC9gZ3rpnidt8EGR89b55Wtol+otYEJveFkEy3IpxA0Q==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/socket.io": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@types/socket.io/-/socket.io-2.1.4.tgz", @@ -4330,6 +4467,12 @@ "cssom": "~0.3.6" } }, + "csstype": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.7.tgz", + "integrity": "sha512-9Mcn9sFbGBAdmimWb2gLVDtFJzeKtDGIr76TUqmjZrw9LFXBMSU70lcs+C0/7fyCd6iBDqmksUcCOUIkisPHsQ==", + "dev": true + }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", @@ -9956,6 +10099,12 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, + "lodash-es": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.15.tgz", + "integrity": "sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ==", + "dev": true + }, "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", diff --git a/package.json b/package.json index 506b2cb..d3de070 100644 --- a/package.json +++ b/package.json @@ -80,11 +80,19 @@ "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.5.0", "@babel/preset-react": "^7.0.0", + "@types/bluebird": "^3.5.29", "@types/config": "0.0.36", "@types/debug": "^4.1.5", "@types/express": "^4.17.2", "@types/jest": "^24.0.23", "@types/node": "^12.12.7", + "@types/react": "^16.9.11", + "@types/react-dom": "^16.9.4", + "@types/react-redux": "^7.1.5", + "@types/redux": "^3.6.0", + "@types/redux-logger": "^3.0.7", + "@types/redux-mock-store": "^1.0.1", + "@types/simple-peer": "^6.1.6", "@types/socket.io": "^2.1.4", "@types/socket.io-client": "^1.4.32", "@types/supertest": "^2.0.8", diff --git a/src/client/__mocks__/socket.js b/src/client/__mocks__/socket.ts similarity index 100% rename from src/client/__mocks__/socket.js rename to src/client/__mocks__/socket.ts diff --git a/src/client/__mocks__/store.js b/src/client/__mocks__/store.ts similarity index 100% rename from src/client/__mocks__/store.js rename to src/client/__mocks__/store.ts diff --git a/src/client/__mocks__/window.js b/src/client/__mocks__/window.ts similarity index 78% rename from src/client/__mocks__/window.js rename to src/client/__mocks__/window.ts index 0af2b0a..342d8cf 100644 --- a/src/client/__mocks__/window.js +++ b/src/client/__mocks__/window.ts @@ -7,21 +7,21 @@ export const revokeObjectURL = jest.fn() export class MediaStream { getVideoTracks () { return [{ - enabled: true + enabled: true, }] } getAudioTracks () { return [{ - enabled: true + enabled: true, }] } } export function getUserMedia () { - return !getUserMedia.shouldFail + return !(getUserMedia as any).shouldFail ? Promise.resolve(getUserMedia.stream) : Promise.reject(new Error('test')) } -getUserMedia.fail = shouldFail => getUserMedia.shouldFail = shouldFail +getUserMedia.fail = (shouldFail: boolean) => (getUserMedia as any).shouldFail = shouldFail getUserMedia.stream = new MediaStream() export const navigator = window.navigator diff --git a/src/client/actions/CallActions.js b/src/client/actions/CallActions.js deleted file mode 100644 index bff2ca6..0000000 --- a/src/client/actions/CallActions.js +++ /dev/null @@ -1,50 +0,0 @@ -import * as NotifyActions from './NotifyActions.js' -import * as SocketActions from './SocketActions.js' -import * as StreamActions from './StreamActions.js' -import * as constants from '../constants.js' -import Promise from 'bluebird' -import socket from '../socket.js' -import { callId, getUserMedia } from '../window.js' - -export const init = () => dispatch => { - return dispatch({ - type: constants.INIT, - payload: Promise.all([ - connect()(dispatch), - getCameraStream()(dispatch) - ]) - .spread((socket, stream) => { - dispatch(SocketActions.handshake({ - socket, - roomName: callId, - stream - })) - }) - }) -} - -export const connect = () => dispatch => { - return new Promise(resolve => { - socket.once('connect', () => { - resolve(socket) - }) - socket.on('connect', () => { - dispatch(NotifyActions.warning('Connected to server socket')) - }) - socket.on('disconnect', () => { - dispatch(NotifyActions.error('Server socket disconnected')) - }) - }) -} - -export const getCameraStream = () => dispatch => { - return getUserMedia({ video: { facingMode: 'user' }, audio: true }) - .then(stream => { - dispatch(StreamActions.addStream({ stream, userId: constants.ME })) - return stream - }) - .catch(() => { - dispatch(NotifyActions.alert('Could not get access to microphone & camera')) - return null - }) -} diff --git a/src/client/actions/CallActions.test.js b/src/client/actions/CallActions.test.ts similarity index 100% rename from src/client/actions/CallActions.test.js rename to src/client/actions/CallActions.test.ts diff --git a/src/client/actions/CallActions.ts b/src/client/actions/CallActions.ts new file mode 100644 index 0000000..fdafb9b --- /dev/null +++ b/src/client/actions/CallActions.ts @@ -0,0 +1,62 @@ +import * as NotifyActions from './NotifyActions.js' +import * as SocketActions from './SocketActions.js' +import * as StreamActions from './StreamActions.js' +import * as constants from '../constants.js' +import socket from '../socket.js' +import { callId, getUserMedia } from '../window.js' +import { Dispatch } from 'redux' +import { GetState } from '../store.js' + +export interface InitAction { + type: 'INIT' + payload: Promise +} + +interface InitializeAction { + type: 'INIT' +} + +const initialize = (): InitializeAction => ({ + type: 'INIT', +}) + +export const init = async (dispatch: Dispatch, getState: GetState) => { + dispatch(initialize()) + + const socket = await connect(dispatch) + const stream = await getCameraStream(dispatch) + + SocketActions.handshake({ + socket, + roomName: callId, + stream, + })(dispatch, getState) +} + +export async function connect (dispatch: Dispatch) { + return new Promise(resolve => { + socket.once('connect', () => { + resolve(socket) + }) + socket.on('connect', () => { + NotifyActions.warning('Connected to server socket')(dispatch) + }) + socket.on('disconnect', () => { + NotifyActions.error('Server socket disconnected')(dispatch) + }) + }) +} + +export async function getCameraStream (dispatch: Dispatch) { + try { + const stream = await getUserMedia({ + video: { facingMode: 'user' }, + audio: true, + }) + dispatch(StreamActions.addStream({ stream, userId: constants.ME })) + return stream + } catch (err) { + dispatch(NotifyActions.alert('Could not get access to microphone & camera')) + return + } +} diff --git a/src/client/actions/ChatActions.js b/src/client/actions/ChatActions.js deleted file mode 100644 index ef01410..0000000 --- a/src/client/actions/ChatActions.js +++ /dev/null @@ -1,11 +0,0 @@ -import * as constants from '../constants.js' - -export const addMessage = ({ userId, message, timestamp, image }) => ({ - type: constants.MESSAGE_ADD, - payload: { - userId, - message, - timestamp, - image - } -}) diff --git a/src/client/actions/ChatActions.ts b/src/client/actions/ChatActions.ts new file mode 100644 index 0000000..1e5b54a --- /dev/null +++ b/src/client/actions/ChatActions.ts @@ -0,0 +1,18 @@ +import { MESSAGE_ADD } from '../constants.js' + +export interface MessageAddAction { + type: 'MESSAGE_ADD' + payload: Message +} + +export interface Message { + userId: string + message: string + timestamp: string + image?: string +} + +export const addMessage = (message: Message): MessageAddAction => ({ + type: MESSAGE_ADD, + payload: message, +}) diff --git a/src/client/actions/NotifyActions.js b/src/client/actions/NotifyActions.js deleted file mode 100644 index 5cdf875..0000000 --- a/src/client/actions/NotifyActions.js +++ /dev/null @@ -1,75 +0,0 @@ -import * as constants from '../constants.js' -import * as ChatActions from './ChatActions.js' -import _ from 'underscore' - -const TIMEOUT = 5000 - -function format (string, args) { - string = args - .reduce((string, arg, i) => string.replace('{' + i + '}', arg), string) - return string -} - -const _notify = (type, args) => dispatch => { - let string = args[0] || '' - let message = format(string, Array.prototype.slice.call(args, 1)) - const id = _.uniqueId('notification') - const payload = { id, type, message } - dispatch({ - type: constants.NOTIFY, - payload - }) - dispatch(ChatActions.addMessage({ - userId: '[PeerCalls]', - message, - timestamp: new Date().toLocaleString(), - image: null - })) - setTimeout(() => { - dispatch({ - type: constants.NOTIFY_DISMISS, - payload: { id } - }) - }, TIMEOUT) -} - -export const info = function () { - return dispatch => _notify('info', arguments)(dispatch) -} - -export const warning = function () { - return dispatch => _notify('warning', arguments)(dispatch) -} - -export const error = function () { - return dispatch => _notify('error', arguments)(dispatch) -} - -export const clear = () => ({ - type: constants.NOTIFY_CLEAR -}) - -export function alert (message, dismissable) { - return { - type: constants.ALERT, - payload: { - action: dismissable ? 'Dismiss' : '', - dismissable: !!dismissable, - message, - type: 'warning' - } - } -} - -export const dismissAlert = alert => { - return { - type: constants.ALERT_DISMISS, - payload: alert - } -} - -export const clearAlerts = () => { - return { - type: constants.ALERT_CLEAR - } -} diff --git a/src/client/actions/NotifyActions.ts b/src/client/actions/NotifyActions.ts new file mode 100644 index 0000000..f411c4f --- /dev/null +++ b/src/client/actions/NotifyActions.ts @@ -0,0 +1,137 @@ +import * as constants from '../constants.js' +import * as ChatActions from './ChatActions.js' +import { Dispatch } from 'redux' +import _ from 'underscore' + +const TIMEOUT = 5000 + +function format (string: string, args: string[]) { + string = args + .reduce((string, arg, i) => string.replace('{' + i + '}', arg), string) + return string +} + +export type NotifyType = 'info' | 'warning' | 'error' + +const _notify = (type: NotifyType, args: string[]) => (dispatch: Dispatch) => { + const string = args[0] || '' + const message = format(string, Array.prototype.slice.call(args, 1)) + const id = _.uniqueId('notification') + const payload: Notification = { id, type, message } + dispatch(addNotification(payload)) + dispatch(ChatActions.addMessage({ + userId: '[PeerCalls]', + message, + timestamp: new Date().toLocaleString(), + image: undefined, + })) + setTimeout(() => { + dispatch(dismissNotification(id)) + }, TIMEOUT) +} + +function addNotification(payload: Notification): NotificationAddAction { + return { + type: constants.NOTIFY, + payload, + } +} + +function dismissNotification(id: string): NotificationDismissAction { + return { + type: constants.NOTIFY_DISMISS, + payload: { id }, + } +} + +export interface Notification { + id: string + type: NotifyType + message: string +} + +export interface NotificationAddAction { + type: 'NOTIFY' + payload: Notification +} + +export interface NotificationDismissAction { + type: 'NOTIFY_DISMISS' + payload: { id: string } +} + +export function info (...args: any[]) { + return (dispatch: Dispatch) => _notify('info', args)(dispatch) +} + +export function warning (...args: any[]) { + return (dispatch: Dispatch) => _notify('warning', args)(dispatch) +} + +export function error (...args: any[]) { + return (dispatch: Dispatch) => _notify('error', args)(dispatch) +} + +export interface NotificationClearAction { + type: 'NOTIFY_CLEAR' +} + +export const clear = (): NotificationClearAction => ({ + type: constants.NOTIFY_CLEAR, +}) + +export interface Alert { + action?: string + dismissable: boolean + message: string + type: NotifyType +} + +export interface AlertAddAction { + type: 'ALERT' + payload: Alert +} + +export function alert (message: string, dismissable = false): AlertAddAction { + return { + type: constants.ALERT, + payload: { + action: dismissable ? 'Dismiss' : '', + dismissable: !!dismissable, + message, + type: 'warning', + }, + } +} + +export interface AlertDismissAction { + type: 'ALERT_DISMISS' + payload: Alert +} + +export const dismissAlert = (alert: Alert): AlertDismissAction => { + return { + type: constants.ALERT_DISMISS, + payload: alert, + } +} + +export interface AlertClearAction { + type: 'ALERT_CLEAR' +} + +export const clearAlerts = (): AlertClearAction => { + return { + type: constants.ALERT_CLEAR, + } +} + +export type AlertActionType = + AlertAddAction | + AlertDismissAction | + AlertClearAction + +export type NotificationActionType = + NotificationAddAction | + NotificationDismissAction | + NotificationClearAction diff --git a/src/client/actions/PeerActions.test.js b/src/client/actions/PeerActions.test.js deleted file mode 100644 index 45f46a0..0000000 --- a/src/client/actions/PeerActions.test.js +++ /dev/null @@ -1,169 +0,0 @@ -jest.mock('../window.js') -jest.mock('simple-peer') - -import * as PeerActions from './PeerActions.js' -import Peer from 'simple-peer' -import { EventEmitter } from 'events' -import { createStore } from '../store.js' -import { play } from '../window.js' - -describe('PeerActions', () => { - function createSocket () { - const socket = new EventEmitter() - socket.id = 'user1' - return socket - } - - let socket, stream, user, store - beforeEach(() => { - store = createStore() - - user = { id: 'user2' } - socket = createSocket() - Peer.instances = [] - Peer.mockClear() - play.mockClear() - stream = { stream: true } - }) - - describe('create', () => { - it('creates a new peer', () => { - store.dispatch( - PeerActions.createPeer({ socket, user, initiator: 'user2', stream }) - ) - - expect(Peer.instances.length).toBe(1) - expect(Peer.mock.calls.length).toBe(1) - expect(Peer.mock.calls[0][0].initiator).toBe(false) - expect(Peer.mock.calls[0][0].stream).toBe(stream) - }) - - it('sets initiator correctly', () => { - store.dispatch( - PeerActions.createPeer({ socket, user, initiator: 'user1', stream }) - ) - - expect(Peer.instances.length).toBe(1) - expect(Peer.mock.calls.length).toBe(1) - expect(Peer.mock.calls[0][0].initiator).toBe(true) - expect(Peer.mock.calls[0][0].stream).toBe(stream) - }) - - it('destroys old peer before creating new one', () => { - store.dispatch( - PeerActions.createPeer({ socket, user, initiator: 'user2', stream }) - ) - store.dispatch( - PeerActions.createPeer({ socket, user, initiator: 'user2', stream }) - ) - - expect(Peer.instances.length).toBe(2) - expect(Peer.mock.calls.length).toBe(2) - expect(Peer.instances[0].destroy.mock.calls.length).toBe(1) - expect(Peer.instances[1].destroy.mock.calls.length).toBe(0) - }) - }) - - describe('events', () => { - let peer - - beforeEach(() => { - store.dispatch( - PeerActions.createPeer({ socket, user, initiator: 'user1', stream }) - ) - peer = Peer.instances[0] - }) - - describe('connect', () => { - beforeEach(() => peer.emit('connect')) - - it('dispatches "play" action', () => { - expect(play.mock.calls.length).toBe(1) - }) - }) - - describe('data', () => { - - beforeEach(() => { - window.TextDecoder = class TextDecoder { - constructor (encoding) { - this.encoding = encoding - } - decode (object) { - return object.toString(this.encoding) - } - } - }) - - it('decodes a message', () => { - const payload = 'test' - const object = JSON.stringify({ payload }) - peer.emit('data', Buffer.from(object, 'utf-8')) - const { messages } = store.getState() - expect(messages[messages.length - 1]).toEqual({ - userId: 'user2', - timestamp: jasmine.any(String), - image: null, - message: 'test' - }) - }) - }) - }) - - describe('get', () => { - it('returns undefined when not found', () => { - const { peers } = store.getState() - expect(peers[user.id]).not.toBeDefined() - }) - - it('returns Peer instance when found', () => { - store.dispatch( - PeerActions.createPeer({ socket, user, initiator: 'user2', stream }) - ) - - const { peers } = store.getState() - expect(peers[user.id]).toBe(Peer.instances[0]) - }) - }) - - describe('destroyPeers', () => { - it('destroys all peers and removes them', () => { - store.dispatch(PeerActions.createPeer({ - socket, user: { id: 'user2' }, initiator: 'user2', stream - })) - store.dispatch(PeerActions.createPeer({ - socket, user: { id: 'user3' }, initiator: 'user3', stream - })) - - store.dispatch(PeerActions.destroyPeers()) - - expect(Peer.instances[0].destroy.mock.calls.length).toEqual(1) - expect(Peer.instances[1].destroy.mock.calls.length).toEqual(1) - - const { peers } = store.getState() - expect(Object.keys(peers)).toEqual([]) - }) - }) - - describe('sendMessage', () => { - - beforeEach(() => { - store.dispatch(PeerActions.createPeer({ - socket, user: { id: 'user2' }, initiator: 'user2', stream - })) - store.dispatch(PeerActions.createPeer({ - socket, user: { id: 'user3' }, initiator: 'user3', stream - })) - }) - - it('sends a message to all peers', () => { - store.dispatch(PeerActions.sendMessage({ payload: 'test', type: 'text' })) - const { peers } = store.getState() - expect(peers['user2'].send.mock.calls) - .toEqual([[ '{"payload":"test","type":"text"}' ]]) - expect(peers['user3'].send.mock.calls) - .toEqual([[ '{"payload":"test","type":"text"}' ]]) - }) - - }) -}) diff --git a/src/client/actions/PeerActions.test.ts b/src/client/actions/PeerActions.test.ts new file mode 100644 index 0000000..abc1caf --- /dev/null +++ b/src/client/actions/PeerActions.test.ts @@ -0,0 +1,177 @@ +jest.mock('../window.js') +jest.mock('simple-peer') + +import * as PeerActions from './PeerActions.js' +import Peer from 'simple-peer' +import { EventEmitter } from 'events' +import { createStore, Store, GetState } from '../store.js' +import { play } from '../window.js' +import { Dispatch } from 'redux' + +describe('PeerActions', () => { + function createSocket () { + const socket = new EventEmitter() as unknown as SocketIOClient.Socket + socket.id = 'user1' + return socket + } + + let socket: SocketIOClient.Socket + let stream: MediaStream + let user: { id: string } + let store: Store + let instances: Peer.Instance[] + let dispatch: Dispatch + let getState: GetState + let PeerMock: jest.Mock + + beforeEach(() => { + store = createStore() + dispatch = store.dispatch + getState = store.getState + + user = { id: 'user2' } + socket = createSocket() + instances = (Peer as any).instances = []; + (Peer as unknown as jest.Mock).mockClear(); + (play as jest.Mock).mockClear() + stream = { stream: true } as unknown as MediaStream + PeerMock = Peer as unknown as jest.Mock + }) + + describe('create', () => { + it('creates a new peer', () => { + PeerActions.createPeer({ socket, user, initiator: 'user2', stream })( + dispatch, getState) + + expect(instances.length).toBe(1) + expect(PeerMock.mock.calls.length).toBe(1) + expect(PeerMock.mock.calls[0][0].initiator).toBe(false) + expect(PeerMock.mock.calls[0][0].stream).toBe(stream) + }) + + it('sets initiator correctly', () => { + PeerActions + .createPeer({ + socket, user, initiator: 'user1', stream, + })(dispatch, getState) + + expect(instances.length).toBe(1) + expect(PeerMock.mock.calls.length).toBe(1) + expect(PeerMock.mock.calls[0][0].initiator).toBe(true) + expect(PeerMock.mock.calls[0][0].stream).toBe(stream) + }) + + it('destroys old peer before creating new one', () => { + PeerActions.createPeer({ socket, user, initiator: 'user2', stream })( + dispatch, getState) + PeerActions.createPeer({ socket, user, initiator: 'user2', stream })( + dispatch, getState) + + expect(instances.length).toBe(2) + expect(PeerMock.mock.calls.length).toBe(2) + expect((instances[0].destroy as jest.Mock).mock.calls.length).toBe(1) + expect((instances[1].destroy as jest.Mock).mock.calls.length).toBe(0) + }) + }) + + describe('events', () => { + let peer: Peer.Instance + + beforeEach(() => { + PeerActions.createPeer({ socket, user, initiator: 'user1', stream })( + dispatch, getState) + peer = instances[0] + }) + + describe('connect', () => { + beforeEach(() => peer.emit('connect')) + + it('dispatches "play" action', () => { + expect((play as jest.Mock).mock.calls.length).toBe(1) + }) + }) + + describe('data', () => { + + beforeEach(() => { + (window as any).TextDecoder = class TextDecoder { + constructor (readonly encoding: string) { + } + decode (object: any) { + return object.toString(this.encoding) + } + } + }) + + it('decodes a message', () => { + const payload = 'test' + const object = JSON.stringify({ payload }) + peer.emit('data', Buffer.from(object, 'utf-8')) + const { messages } = store.getState() + expect(messages[messages.length - 1]).toEqual({ + userId: 'user2', + timestamp: jasmine.any(String), + image: null, + message: 'test', + }) + }) + }) + }) + + describe('get', () => { + it('returns undefined when not found', () => { + const { peers } = store.getState() + expect(peers[user.id]).not.toBeDefined() + }) + + it('returns Peer instance when found', () => { + PeerActions.createPeer({ socket, user, initiator: 'user2', stream })( + dispatch, getState) + + const { peers } = store.getState() + expect(peers[user.id]).toBe(instances[0]) + }) + }) + + describe('destroyPeers', () => { + it('destroys all peers and removes them', () => { + PeerActions.createPeer({ + socket, user: { id: 'user2' }, initiator: 'user2', stream, + })(dispatch, getState) + PeerActions.createPeer({ + socket, user: { id: 'user3' }, initiator: 'user3', stream, + })(dispatch, getState) + + store.dispatch(PeerActions.destroyPeers()) + + expect((instances[0].destroy as jest.Mock).mock.calls.length).toEqual(1) + expect((instances[1].destroy as jest.Mock).mock.calls.length).toEqual(1) + + const { peers } = store.getState() + expect(Object.keys(peers)).toEqual([]) + }) + }) + + describe('sendMessage', () => { + + beforeEach(() => { + PeerActions.createPeer({ + socket, user: { id: 'user2' }, initiator: 'user2', stream, + })(dispatch, getState) + PeerActions.createPeer({ + socket, user: { id: 'user3' }, initiator: 'user3', stream, + })(dispatch, getState) + }) + + it('sends a message to all peers', () => { + PeerActions.sendMessage({ payload: 'test', type: 'text' })( + dispatch, getState) + const { peers } = store.getState() + expect(peers['user2'].send.mock.calls) + .toEqual([[ '{"payload":"test","type":"text"}' ]]) + expect(peers['user3'].send.mock.calls) + .toEqual([[ '{"payload":"test","type":"text"}' ]]) + }) + + }) +}) diff --git a/src/client/actions/PeerActions.js b/src/client/actions/PeerActions.ts similarity index 59% rename from src/client/actions/PeerActions.js rename to src/client/actions/PeerActions.ts index c92a550..71906e0 100644 --- a/src/client/actions/PeerActions.js +++ b/src/client/actions/PeerActions.ts @@ -6,25 +6,44 @@ import Peer from 'simple-peer' import _ from 'underscore' import _debug from 'debug' import { play, iceServers } from '../window.js' +import { Dispatch } from 'redux' const debug = _debug('peercalls') +export interface Peers { + [id: string]: Peer.Instance +} + +export type GetState = () => { peers: Peers } + +export interface PeerHandlerOptions { + socket: SocketIOClient.Socket + user: { id: string } + dispatch: Dispatch + getState: GetState +} + class PeerHandler { - constructor ({ socket, user, dispatch, getState }) { - this.socket = socket - this.user = user - this.dispatch = dispatch - this.getState = getState + socket: SocketIOClient.Socket + user: { id: string } + dispatch: Dispatch + getState: GetState + + constructor (readonly options: PeerHandlerOptions) { + this.socket = options.socket + this.user = options.user + this.dispatch = options.dispatch + this.getState = options.getState } - handleError = err => { + handleError = (err: Error) => { const { dispatch, getState, user } = this debug('peer: %s, error %s', user.id, err.stack) - dispatch(NotifyActions.error('A peer connection error occurred')) + NotifyActions.error('A peer connection error occurred')(dispatch) const peer = getState().peers[user.id] peer && peer.destroy() dispatch(removePeer(user.id)) } - handleSignal = signal => { + handleSignal = (signal: unknown) => { const { socket, user } = this debug('peer: %s, signal: %o', user.id, signal) @@ -34,18 +53,18 @@ class PeerHandler { handleConnect = () => { const { dispatch, user } = this debug('peer: %s, connect', user.id) - dispatch(NotifyActions.warning('Peer connection established')) + NotifyActions.warning('Peer connection established')(dispatch) play() } - handleStream = stream => { + handleStream = (stream: MediaStream) => { const { user, dispatch } = this debug('peer: %s, stream', user.id) dispatch(StreamActions.addStream({ userId: user.id, - stream + stream, })) } - handleData = object => { + handleData = (object: any) => { const { dispatch, user } = this const message = JSON.parse(new window.TextDecoder('utf-8').decode(object)) debug('peer: %s, message: %o', user.id, object) @@ -55,7 +74,7 @@ class PeerHandler { userId: user.id, message: message.payload.name, timestamp: new Date().toLocaleString(), - image: message.payload.data + image: message.payload.data, })) break default: @@ -63,19 +82,26 @@ class PeerHandler { userId: user.id, message: message.payload, timestamp: new Date().toLocaleString(), - image: null + image: undefined, })) } } handleClose = () => { const { dispatch, user } = this debug('peer: %s, close', user.id) - dispatch(NotifyActions.error('Peer connection closed')) + NotifyActions.error('Peer connection closed')(dispatch) dispatch(StreamActions.removeStream(user.id)) dispatch(removePeer(user.id)) } } +export interface CreatePeerOptions { + socket: SocketIOClient.Socket + user: { id: string } + initiator: string + stream?: MediaStream +} + /** * @param {Object} options * @param {Socket} options.socket @@ -84,15 +110,17 @@ class PeerHandler { * @param {Boolean} [options.initiator=false] * @param {MediaStream} [options.stream] */ -export function createPeer ({ socket, user, initiator, stream }) { - return (dispatch, getState) => { +export function createPeer (options: CreatePeerOptions) { + const { socket, user, initiator, stream } = options + + return (dispatch: Dispatch, getState: GetState) => { const userId = user.id debug('create peer: %s, stream:', userId, stream) - dispatch(NotifyActions.warning('Connecting to peer...')) + NotifyActions.warning('Connecting to peer...')(dispatch) const oldPeer = getState().peers[userId] if (oldPeer) { - dispatch(NotifyActions.info('Cleaning up old connection...')) + NotifyActions.info('Cleaning up old connection...')(dispatch) oldPeer.destroy() dispatch(removePeer(userId)) } @@ -104,16 +132,16 @@ export function createPeer ({ socket, user, initiator, stream }) { // https://github.com/feross/simple-peer/issues/95 offerConstraints: { offerToReceiveAudio: true, - offerToReceiveVideo: true + offerToReceiveVideo: true, }, - stream + stream, }) const handler = new PeerHandler({ socket, user, dispatch, - getState + getState, }) peer.once(constants.PEER_EVENT_ERROR, handler.handleError) @@ -127,21 +155,65 @@ export function createPeer ({ socket, user, initiator, stream }) { } } -export const addPeer = ({ peer, userId }) => ({ +export interface AddPeerParams { + peer: Peer.Instance + userId: string +} + +export interface AddPeerAction { + type: 'PEER_ADD' + payload: AddPeerParams +} + +export const addPeer = (payload: AddPeerParams): AddPeerAction => ({ type: constants.PEER_ADD, - payload: { peer, userId } + payload, }) -export const removePeer = userId => ({ +export interface RemovePeerAction { + type: 'PEER_REMOVE' + payload: { userId: string } +} + +export const removePeer = (userId: string): RemovePeerAction => ({ type: constants.PEER_REMOVE, - payload: { userId } + payload: { userId }, }) -export const destroyPeers = () => ({ - type: constants.PEERS_DESTROY +export interface DestroyPeersAction { + type: 'PEERS_DESTROY' +} + +export const destroyPeers = (): DestroyPeersAction => ({ + type: constants.PEERS_DESTROY, }) -export const sendMessage = message => (dispatch, getState) => { +export type PeerAction = + AddPeerAction | + RemovePeerAction | + DestroyPeersAction + +export interface TextMessage { + type: 'text' + payload: string +} + +export interface Base64File { + name: string + size: number + type: string + data: string +} + +export interface FileMessage { + type: 'file' + payload: Base64File +} + +export type Message = TextMessage | FileMessage + +export const sendMessage = (message: Message) => +(dispatch: Dispatch, getState: GetState) => { const { peers } = getState() debug('Sending message type: %s to %s peers.', message.type, Object.keys(peers).length) @@ -153,7 +225,7 @@ export const sendMessage = message => (dispatch, getState) => { message: 'Send file: "' + message.payload.name + '" to peer: ' + userId, timestamp: new Date().toLocaleString(), - image: message.payload.data + image: message.payload.data, })) break default: @@ -161,27 +233,28 @@ export const sendMessage = message => (dispatch, getState) => { userId: 'You', message: message.payload, timestamp: new Date().toLocaleString(), - image: null + image: undefined, })) } peer.send(JSON.stringify(message)) }) } -export const sendFile = file => async (dispatch, getState) => { +export const sendFile = (file: File) => +async (dispatch: Dispatch, getState: GetState) => { const { name, size, type } = file if (!window.FileReader) { - dispatch(NotifyActions.error('File API is not supported by your browser')) + NotifyActions.error('File API is not supported by your browser')(dispatch) return } const reader = new window.FileReader() - const base64File = await new Promise(resolve => { + const base64File = await new Promise(resolve => { reader.addEventListener('load', () => { resolve({ name, size, type, - data: reader.result + data: reader.result as string, }) }) reader.readAsDataURL(file) diff --git a/src/client/actions/SocketActions.js b/src/client/actions/SocketActions.js deleted file mode 100644 index 69c6429..0000000 --- a/src/client/actions/SocketActions.js +++ /dev/null @@ -1,64 +0,0 @@ -import * as NotifyActions from '../actions/NotifyActions.js' -import * as PeerActions from '../actions/PeerActions.js' -import * as constants from '../constants.js' -import _ from 'underscore' -import _debug from 'debug' - -const debug = _debug('peercalls') - -class SocketHandler { - constructor ({ socket, roomName, stream, dispatch, getState }) { - this.socket = socket - this.roomName = roomName - this.stream = stream - this.dispatch = dispatch - this.getState = getState - } - handleSignal = ({ userId, signal }) => { - const { getState } = this - const peer = getState().peers[userId] - // debug('socket signal, userId: %s, signal: %o', userId, signal); - if (!peer) return debug('user: %s, no peer found', userId) - peer.signal(signal) - } - handleUsers = ({ initiator, users }) => { - const { socket, stream, dispatch, getState } = this - debug('socket users: %o', users) - dispatch(NotifyActions.info('Connected users: {0}', users.length)) - const { peers } = getState() - - users - .filter(user => !peers[user.id] && user.id !== socket.id) - .forEach(user => dispatch(PeerActions.createPeer({ - socket, - user, - initiator, - stream - }))) - - let newUsersMap = _.indexBy(users, 'id') - _.keys(peers) - .filter(id => !newUsersMap[id]) - .forEach(id => peers[id].destroy()) - } -} - -export function handshake ({ socket, roomName, stream }) { - return (dispatch, getState) => { - const handler = new SocketHandler({ - socket, - roomName, - stream, - dispatch, - getState - }) - - socket.on(constants.SOCKET_EVENT_SIGNAL, handler.handleSignal) - socket.on(constants.SOCKET_EVENT_USERS, handler.handleUsers) - - debug('socket.id: %s', socket.id) - debug('emit ready for room: %s', roomName) - dispatch(NotifyActions.info('Ready for connections')) - socket.emit('ready', roomName) - } -} diff --git a/src/client/actions/SocketActions.test.js b/src/client/actions/SocketActions.test.ts similarity index 60% rename from src/client/actions/SocketActions.test.js rename to src/client/actions/SocketActions.test.ts index 56900f9..491d00c 100644 --- a/src/client/actions/SocketActions.test.js +++ b/src/client/actions/SocketActions.test.ts @@ -5,94 +5,101 @@ import * as SocketActions from './SocketActions.js' import * as constants from '../constants.js' import Peer from 'simple-peer' import { EventEmitter } from 'events' -import { createStore } from '../store.js' +import { createStore, Store, GetState } from '../store.js' +import { Dispatch } from 'redux' describe('SocketActions', () => { const roomName = 'bla' - let socket, store + let socket: SocketIOClient.Socket + let store: Store + let dispatch: Dispatch + let getState: GetState + let instances: Peer.Instance[] beforeEach(() => { - socket = new EventEmitter() - socket.id = 'a' + socket = new EventEmitter() as any; + (socket as any).id = 'a' store = createStore() + getState = store.getState + dispatch = store.dispatch - Peer.instances = [] + instances = (Peer as any).instances = [] }) describe('handshake', () => { describe('users', () => { beforeEach(() => { - store.dispatch(SocketActions.handshake({ socket, roomName })) + SocketActions.handshake({ socket, roomName })(dispatch, getState) const payload = { users: [{ id: 'a' }, { id: 'b' }], - initiator: 'a' + initiator: 'a', } socket.emit('users', payload) - expect(Peer.instances.length).toBe(1) + expect(instances.length).toBe(1) }) it('adds a peer for each new user and destroys peers for missing', () => { const payload = { users: [{ id: 'a' }, { id: 'c' }], - initiator: 'c' + initiator: 'c', } socket.emit(constants.SOCKET_EVENT_USERS, payload) // then - expect(Peer.instances.length).toBe(2) - expect(Peer.instances[0].destroy.mock.calls.length).toBe(1) - expect(Peer.instances[1].destroy.mock.calls.length).toBe(0) + expect(instances.length).toBe(2) + expect((instances[0].destroy as jest.Mock).mock.calls.length).toBe(1) + expect((instances[1].destroy as jest.Mock).mock.calls.length).toBe(0) }) }) describe('signal', () => { - let data + let data: Peer.SignalData beforeEach(() => { - data = {} - store.dispatch(SocketActions.handshake({ socket, roomName })) + data = {} as any + SocketActions.handshake({ socket, roomName })(dispatch, getState) socket.emit('users', { initiator: 'a', - users: [{ id: 'a' }, { id: 'b' }] + users: [{ id: 'a' }, { id: 'b' }], }) }) it('should forward signal to peer', () => { socket.emit('signal', { userId: 'b', - data + data, }) - expect(Peer.instances.length).toBe(1) - expect(Peer.instances[0].signal.mock.calls.length).toBe(1) + expect(instances.length).toBe(1) + expect((instances[0].signal as jest.Mock).mock.calls.length).toBe(1) }) it('does nothing if no peer', () => { socket.emit('signal', { userId: 'a', - data + data, }) - expect(Peer.instances.length).toBe(1) - expect(Peer.instances[0].signal.mock.calls.length).toBe(0) + expect(instances.length).toBe(1) + expect((instances[0].signal as jest.Mock).mock.calls.length).toBe(0) }) }) }) describe('peer events', () => { - let peer + let peer: Peer.Instance beforeEach(() => { let ready = false socket.once('ready', () => { ready = true }) - store.dispatch(SocketActions.handshake({ socket, roomName })) + SocketActions.handshake({ socket, roomName })(dispatch, getState) socket.emit('users', { initiator: 'a', - users: [{ id: 'a' }, { id: 'b' }] + users: [{ id: 'a' }, { id: 'b' }], }) - expect(Peer.instances.length).toBe(1) - peer = Peer.instances[0] + expect(instances.length).toBe(1) + peer = instances[0] expect(ready).toBeDefined() }) @@ -100,15 +107,15 @@ describe('SocketActions', () => { describe('error', () => { it('destroys peer', () => { peer.emit(constants.PEER_EVENT_ERROR, new Error('bla')) - expect(peer.destroy.mock.calls.length).toBe(1) + expect((peer.destroy as jest.Mock).mock.calls.length).toBe(1) }) }) describe('signal', () => { it('emits socket signal with user id', done => { - let signal = { bla: 'bla' } + const signal = { bla: 'bla' } - socket.once('signal', payload => { + socket.once('signal', (payload: SocketActions.SignalOptions) => { expect(payload.userId).toEqual('b') expect(payload.signal).toBe(signal) done() @@ -126,8 +133,8 @@ describe('SocketActions', () => { expect(store.getState().streams).toEqual({ b: { mediaStream: stream, - url: jasmine.any(String) - } + url: jasmine.any(String), + }, }) }) }) @@ -139,8 +146,8 @@ describe('SocketActions', () => { expect(store.getState().streams).toEqual({ b: { mediaStream: stream, - url: jasmine.any(String) - } + url: jasmine.any(String), + }, }) }) diff --git a/src/client/actions/SocketActions.ts b/src/client/actions/SocketActions.ts new file mode 100644 index 0000000..3bcbda2 --- /dev/null +++ b/src/client/actions/SocketActions.ts @@ -0,0 +1,98 @@ +import * as NotifyActions from '../actions/NotifyActions.js' +import * as PeerActions from '../actions/PeerActions.js' +import * as constants from '../constants.js' +import _ from 'underscore' +import _debug from 'debug' +import { Dispatch } from 'redux' +import { SignalData } from 'simple-peer' + +const debug = _debug('peercalls') + +export interface SocketHandlerOptions { + socket: SocketIOClient.Socket + roomName: string + stream?: MediaStream + dispatch: Dispatch + getState: PeerActions.GetState +} + +export interface SignalOptions { + signal: SignalData + userId: string +} + +export interface UsersOptions { + initiator: string + users: Array<{ id: string }> +} + +class SocketHandler { + socket: SocketIOClient.Socket + roomName: string + stream?: MediaStream + dispatch: Dispatch + getState: PeerActions.GetState + + constructor (options: SocketHandlerOptions) { + this.socket = options.socket + this.roomName = options.roomName + this.stream = options.stream + this.dispatch = options.dispatch + this.getState = options.getState + } + handleSignal = ({ userId, signal }: SignalOptions) => { + const { getState } = this + const peer = getState().peers[userId] + // debug('socket signal, userId: %s, signal: %o', userId, signal); + if (!peer) return debug('user: %s, no peer found', userId) + peer.signal(signal) + } + handleUsers = ({ initiator, users }: UsersOptions) => { + const { socket, stream, dispatch, getState } = this + debug('socket users: %o', users) + NotifyActions.info('Connected users: {0}', users.length)(dispatch) + const { peers } = getState() + + users + .filter(user => !peers[user.id] && user.id !== socket.id) + .forEach(user => PeerActions.createPeer({ + socket, + user, + initiator, + stream, + })(dispatch, getState)) + + const newUsersMap = _.indexBy(users, 'id') + _.keys(peers) + .filter(id => !newUsersMap[id]) + .forEach(id => peers[id].destroy()) + } +} + +export interface HandshakeOptions { + socket: SocketIOClient.Socket + roomName: string + stream?: MediaStream +} + +export function handshake (options: HandshakeOptions) { + const { socket, roomName, stream } = options + + return (dispatch: Dispatch, getState: PeerActions.GetState) => { + const handler = new SocketHandler({ + socket, + roomName, + stream, + dispatch, + getState, + }) + + socket.on(constants.SOCKET_EVENT_SIGNAL, handler.handleSignal) + socket.on(constants.SOCKET_EVENT_USERS, handler.handleUsers) + + debug('socket.id: %s', socket.id) + debug('emit ready for room: %s', roomName) + NotifyActions.info('Ready for connections')(dispatch) + socket.emit('ready', roomName) + } +} diff --git a/src/client/actions/StreamActions.js b/src/client/actions/StreamActions.js deleted file mode 100644 index 59f4863..0000000 --- a/src/client/actions/StreamActions.js +++ /dev/null @@ -1,24 +0,0 @@ -import * as constants from '../constants.js' - -export const addStream = ({ stream, userId }) => ({ - type: constants.STREAM_ADD, - payload: { - userId, - stream - } -}) - -export const removeStream = userId => ({ - type: constants.STREAM_REMOVE, - payload: { userId } -}) - -export const setActive = userId => ({ - type: constants.ACTIVE_SET, - payload: { userId } -}) - -export const toggleActive = userId => ({ - type: constants.ACTIVE_TOGGLE, - payload: { userId } -}) diff --git a/src/client/actions/StreamActions.ts b/src/client/actions/StreamActions.ts new file mode 100644 index 0000000..2320f95 --- /dev/null +++ b/src/client/actions/StreamActions.ts @@ -0,0 +1,61 @@ +import * as constants from '../constants.js' + +export interface AddStreamPayload { + userId: string + stream: MediaStream + url?: string +} + +export interface AddStreamAction { + type: 'PEER_STREAM_ADD' + payload: AddStreamPayload +} + +export interface RemoveStreamAction { + type: 'PEER_STREAM_REMOVE' + payload: RemoveStreamPayload +} + +export interface RemoveStreamPayload { + userId: string +} + +export interface SetActiveStreamAction { + type: 'ACTIVE_SET' + payload: RemoveStreamPayload +} + +export interface ToggleActiveStreamAction { + type: 'ACTIVE_TOGGLE' + payload: UserIdPayload +} + +export interface UserIdPayload { + userId: string +} + +export const addStream = (payload: AddStreamPayload): AddStreamAction => ({ + type: constants.STREAM_ADD, + payload, +}) + +export const removeStream = (userId: string): RemoveStreamAction => ({ + type: constants.STREAM_REMOVE, + payload: { userId }, +}) + +export const setActive = (userId: string): SetActiveStreamAction => ({ + type: constants.ACTIVE_SET, + payload: { userId }, +}) + +export const toggleActive = (userId: string): ToggleActiveStreamAction => ({ + type: constants.ACTIVE_TOGGLE, + payload: { userId }, +}) + +export type StreamAction = + AddStreamAction | + RemoveStreamAction + // SetActiveStreamAction | + // ToggleActiveStreamAction diff --git a/src/client/components/Alerts.js b/src/client/components/Alerts.ts similarity index 100% rename from src/client/components/Alerts.js rename to src/client/components/Alerts.ts diff --git a/src/client/components/App.js b/src/client/components/App.ts similarity index 100% rename from src/client/components/App.js rename to src/client/components/App.ts diff --git a/src/client/components/Chat.js b/src/client/components/Chat.ts similarity index 100% rename from src/client/components/Chat.js rename to src/client/components/Chat.ts diff --git a/src/client/components/Input.test.js b/src/client/components/Input.test.ts similarity index 100% rename from src/client/components/Input.test.js rename to src/client/components/Input.test.ts diff --git a/src/client/components/Input.js b/src/client/components/Input.ts similarity index 100% rename from src/client/components/Input.js rename to src/client/components/Input.ts diff --git a/src/client/components/Notifications.js b/src/client/components/Notifications.ts similarity index 100% rename from src/client/components/Notifications.js rename to src/client/components/Notifications.ts diff --git a/src/client/components/Toolbar.test.js b/src/client/components/Toolbar.test.ts similarity index 100% rename from src/client/components/Toolbar.test.js rename to src/client/components/Toolbar.test.ts diff --git a/src/client/components/Toolbar.js b/src/client/components/Toolbar.ts similarity index 100% rename from src/client/components/Toolbar.js rename to src/client/components/Toolbar.ts diff --git a/src/client/components/Video.test.js b/src/client/components/Video.test.ts similarity index 100% rename from src/client/components/Video.test.js rename to src/client/components/Video.test.ts diff --git a/src/client/components/Video.js b/src/client/components/Video.ts similarity index 100% rename from src/client/components/Video.js rename to src/client/components/Video.ts diff --git a/src/client/constants.js b/src/client/constants.ts similarity index 99% rename from src/client/constants.js rename to src/client/constants.ts index a5eba94..616d2a1 100644 --- a/src/client/constants.js +++ b/src/client/constants.ts @@ -1,4 +1,3 @@ - export const ACTIVE_SET = 'ACTIVE_SET' export const ACTIVE_TOGGLE = 'ACTIVE_TOGGLE' diff --git a/src/client/containers/App.test.js b/src/client/containers/App.test.ts similarity index 100% rename from src/client/containers/App.test.js rename to src/client/containers/App.test.ts diff --git a/src/client/containers/App.js b/src/client/containers/App.ts similarity index 100% rename from src/client/containers/App.js rename to src/client/containers/App.ts diff --git a/src/client/debug/index.js b/src/client/debug/index.ts similarity index 100% rename from src/client/debug/index.js rename to src/client/debug/index.ts diff --git a/src/client/index.js b/src/client/index.tsx similarity index 86% rename from src/client/index.js rename to src/client/index.tsx index a41932d..d512f88 100644 --- a/src/client/index.js +++ b/src/client/index.tsx @@ -1,6 +1,5 @@ -'use strict' import '@babel/polyfill' -import App from './containers/App.js' +import App from './containers/App' import React from 'react' import ReactDOM from 'react-dom' import store from './store.js' diff --git a/src/client/middlewares.test.js b/src/client/middlewares.test.ts similarity index 100% rename from src/client/middlewares.test.js rename to src/client/middlewares.test.ts diff --git a/src/client/middlewares.js b/src/client/middlewares.ts similarity index 85% rename from src/client/middlewares.js rename to src/client/middlewares.ts index d0e109a..785af08 100644 --- a/src/client/middlewares.js +++ b/src/client/middlewares.ts @@ -3,7 +3,7 @@ import promiseMiddleware from 'redux-promise-middleware' import thunk from 'redux-thunk' export const middlewares = [thunk, promiseMiddleware()] -export const create = log => { +export const create = (log = false) => { const m = middlewares.slice() log && m.push(logger) return m diff --git a/src/client/reducers/active.test.js b/src/client/reducers/active.test.ts similarity index 100% rename from src/client/reducers/active.test.js rename to src/client/reducers/active.test.ts diff --git a/src/client/reducers/active.js b/src/client/reducers/active.ts similarity index 83% rename from src/client/reducers/active.js rename to src/client/reducers/active.ts index ad27756..8af5773 100644 --- a/src/client/reducers/active.js +++ b/src/client/reducers/active.ts @@ -1,6 +1,6 @@ import * as constants from '../constants.js' -export default function active (state = null, action) { +export default function active (state = null, action: Action) { switch (action && action.type) { case constants.ACTIVE_SET: case constants.STREAM_ADD: diff --git a/src/client/reducers/alerts.test.js b/src/client/reducers/alerts.test.ts similarity index 100% rename from src/client/reducers/alerts.test.js rename to src/client/reducers/alerts.test.ts diff --git a/src/client/reducers/alerts.js b/src/client/reducers/alerts.ts similarity index 100% rename from src/client/reducers/alerts.js rename to src/client/reducers/alerts.ts diff --git a/src/client/reducers/index.js b/src/client/reducers/index.ts similarity index 100% rename from src/client/reducers/index.js rename to src/client/reducers/index.ts diff --git a/src/client/reducers/messages.js b/src/client/reducers/messages.js deleted file mode 100644 index b9fcaa2..0000000 --- a/src/client/reducers/messages.js +++ /dev/null @@ -1,15 +0,0 @@ -import * as constants from '../constants.js' -import Immutable from 'seamless-immutable' - -const defaultState = Immutable([]) - -export default function messages (state = defaultState, action) { - switch (action && action.type) { - case constants.MESSAGE_ADD: - const messages = state.asMutable() - messages.push(action.payload) - return Immutable(messages) - default: - return state - } -} diff --git a/src/client/reducers/messages.test.js b/src/client/reducers/messages.test.ts similarity index 100% rename from src/client/reducers/messages.test.js rename to src/client/reducers/messages.test.ts diff --git a/src/client/reducers/messages.ts b/src/client/reducers/messages.ts new file mode 100644 index 0000000..a5472e2 --- /dev/null +++ b/src/client/reducers/messages.ts @@ -0,0 +1,17 @@ +import * as constants from '../constants.js' +import { Message, MessageAddAction } from '../actions/ChatActions.js' + +export type MessagesState = Message[] + +const defaultState: MessagesState = [] + +export default function messages ( + state = defaultState, action: MessageAddAction, +) { + switch (action && action.type) { + case constants.MESSAGE_ADD: + return [...state, action.payload] + default: + return state + } +} diff --git a/src/client/reducers/notifications.js b/src/client/reducers/notifications.ts similarity index 100% rename from src/client/reducers/notifications.js rename to src/client/reducers/notifications.ts diff --git a/src/client/reducers/peers.js b/src/client/reducers/peers.ts similarity index 52% rename from src/client/reducers/peers.js rename to src/client/reducers/peers.ts index 9f46115..1f702e8 100644 --- a/src/client/reducers/peers.js +++ b/src/client/reducers/peers.ts @@ -1,14 +1,20 @@ import * as constants from '../constants.js' import _ from 'underscore' +import Peer from 'simple-peer' +import { PeerAction } from '../actions/PeerActions' -const defaultState = {} +export interface PeersState { + [userId: string]: Peer.Instance +} -export default function peers (state = defaultState, action) { - switch (action && action.type) { +const defaultState: PeersState = {} + +export default function peers (state = defaultState, action: PeerAction) { + switch (action.type) { case constants.PEER_ADD: return { ...state, - [action.payload.userId]: action.payload.peer + [action.payload.userId]: action.payload.peer, } case constants.PEER_REMOVE: return _.omit(state, [action.payload.userId]) diff --git a/src/client/reducers/streams.test.js b/src/client/reducers/streams.test.ts similarity index 83% rename from src/client/reducers/streams.test.js rename to src/client/reducers/streams.test.ts index f43070d..13435c8 100644 --- a/src/client/reducers/streams.test.js +++ b/src/client/reducers/streams.test.ts @@ -3,23 +3,23 @@ jest.mock('../window.js') import * as StreamActions from '../actions/StreamActions.js' import reducers from './index.js' import { createObjectURL, MediaStream } from '../window.js' -import { applyMiddleware, createStore } from 'redux' +import { applyMiddleware, createStore, Store } from 'redux' import { create } from '../middlewares.js' describe('reducers/alerts', () => { - let store, stream, userId + let store: Store, stream: MediaStream, userId: string beforeEach(() => { store = createStore( reducers, - applyMiddleware.apply(null, create()) + applyMiddleware(...create()), ) userId = 'test id' stream = new MediaStream() }) afterEach(() => { - createObjectURL + (createObjectURL as jest.Mock) .mockImplementation(object => 'blob://' + String(object)) }) @@ -35,19 +35,19 @@ describe('reducers/alerts', () => { expect(store.getState().streams).toEqual({ [userId]: { mediaStream: stream, - url: jasmine.any(String) - } + url: jasmine.any(String), + }, }) }) it('does not fail when createObjectURL fails', () => { - createObjectURL + (createObjectURL as jest.Mock) .mockImplementation(() => { throw new Error('test') }) store.dispatch(StreamActions.addStream({ userId, stream })) expect(store.getState().streams).toEqual({ [userId]: { mediaStream: stream, - url: null - } + url: null, + }, }) }) }) diff --git a/src/client/reducers/streams.js b/src/client/reducers/streams.ts similarity index 54% rename from src/client/reducers/streams.js rename to src/client/reducers/streams.ts index ff0701e..5ca6292 100644 --- a/src/client/reducers/streams.js +++ b/src/client/reducers/streams.ts @@ -1,12 +1,13 @@ -import * as constants from '../constants.js' import _ from 'underscore' import { createObjectURL, revokeObjectURL } from '../window.js' import _debug from 'debug' +import { AddStreamPayload, AddStreamAction, RemoveStreamAction, StreamAction } from '../actions/StreamActions.js' +import { STREAM_ADD, STREAM_REMOVE } from '../constants.js' const debug = _debug('peercalls') const defaultState = Object.freeze({}) -function safeCreateObjectURL (stream) { +function safeCreateObjectURL (stream: MediaStream) { try { return createObjectURL(stream) } catch (err) { @@ -15,18 +16,22 @@ function safeCreateObjectURL (stream) { } } -function addStream (state, action) { +export interface StreamsState { + [userId: string]: AddStreamPayload +} + +function addStream (state: StreamsState, action: AddStreamAction) { const { userId, stream } = action.payload return Object.freeze({ ...state, [userId]: Object.freeze({ mediaStream: stream, - url: safeCreateObjectURL(stream) - }) + url: safeCreateObjectURL(stream), + }), }) } -function removeStream (state, action) { +function removeStream (state: StreamsState, action: RemoveStreamAction) { const { userId } = action.payload const stream = state[userId] if (stream && stream.url) { @@ -35,11 +40,11 @@ function removeStream (state, action) { return Object.freeze(_.omit(state, [userId])) } -export default function streams (state = defaultState, action) { - switch (action && action.type) { - case constants.STREAM_ADD: +export default function streams (state = defaultState, action: StreamAction) { + switch (action.type) { + case STREAM_ADD: return addStream(state, action) - case constants.STREAM_REMOVE: + case STREAM_REMOVE: return removeStream(state, action) default: return state diff --git a/src/client/socket.js b/src/client/socket.ts similarity index 56% rename from src/client/socket.js rename to src/client/socket.ts index 9d8ce1b..6a7535a 100644 --- a/src/client/socket.js +++ b/src/client/socket.ts @@ -1,3 +1,3 @@ import SocketIOClient from 'socket.io-client' import { baseUrl } from './window.js' -export default new SocketIOClient('', { path: baseUrl + '/ws' }) +export default SocketIOClient('', { path: baseUrl + '/ws' }) diff --git a/src/client/store.js b/src/client/store.js deleted file mode 100644 index 69e09fa..0000000 --- a/src/client/store.js +++ /dev/null @@ -1,13 +0,0 @@ -import { create } from './middlewares.js' -import reducers from './reducers' -import { applyMiddleware, createStore as _createStore } from 'redux' -export const middlewares = create( - window.localStorage && window.localStorage.log -) - -export const createStore = () => _createStore( - reducers, - applyMiddleware.apply(null, middlewares) -) - -export default createStore() diff --git a/src/client/store.ts b/src/client/store.ts new file mode 100644 index 0000000..6e5c824 --- /dev/null +++ b/src/client/store.ts @@ -0,0 +1,19 @@ +import { create } from './middlewares.js' +import reducers from './reducers' +import { applyMiddleware, createStore as _createStore, Store as ReduxStore } from 'redux' +export const middlewares = create( + window.localStorage && window.localStorage.log, +) + +export const createStore = () => _createStore( + reducers, + applyMiddleware(...middlewares), +) + +export default createStore() + +export type Store = ReturnType + +type TGetState = T extends ReduxStore ? State : never +export type State = TGetState +export type GetState = () => State diff --git a/src/client/window.test.js b/src/client/window.test.ts similarity index 72% rename from src/client/window.test.js rename to src/client/window.test.ts index b81904e..9cb0916 100644 --- a/src/client/window.test.js +++ b/src/client/window.test.ts @@ -1,12 +1,10 @@ -import Promise from 'bluebird' - import { createObjectURL, revokeObjectURL, getUserMedia, navigator, play, - valueOf + valueOf, } from './window.js' describe('window', () => { @@ -18,47 +16,50 @@ describe('window', () => { const constraints = { video: true } afterEach(() => { - delete navigator.mediaDevices + delete (navigator as any).mediaDevices delete navigator.getUserMedia - delete navigator.webkitGetUserMedia + delete (navigator as any).webkitGetUserMedia }) it('calls navigator.mediaDevices.getUserMedia', () => { - const promise = Promise.resolve(stream) - navigator.mediaDevices = { - getUserMedia: jest.fn().mockReturnValue(promise) + const promise = Promise.resolve(stream); + (navigator as any).mediaDevices = { + getUserMedia: jest.fn().mockReturnValue(promise), } expect(getUserMedia(constraints)).toBe(promise) }) ;['getUserMedia', 'webkitGetUserMedia'].forEach((method) => { it(`it calls navigator.${method} as a fallback`, () => { - navigator[method] = jest.fn() + (navigator as any)[method] = jest.fn() .mockImplementation( - (constraints, onSuccess, onError) => onSuccess(stream) + (constraints, onSuccess, onError) => onSuccess(stream), ) return getUserMedia(constraints) .then(s => expect(s).toBe(stream)) }) }) - it('throws error when no supported method', done => { - getUserMedia(constraints) - .asCallback(err => { - expect(err).toBeTruthy() - expect(err.message).toBe('Browser unsupported') - done() - }) + it('throws error when no supported method', async () => { + let error: Error + try { + await getUserMedia(constraints) + } catch (err) { + error = err + } + expect(error!).toBeTruthy() + expect(error!.message).toBe('Browser unsupported') }) }) describe('play', () => { - let v1, v2 + let v1: HTMLVideoElement & { play: jest.Mock } + let v2: HTMLVideoElement & { play: jest.Mock } beforeEach(() => { - v1 = window.document.createElement('video') - v2 = window.document.createElement('video') + v1 = window.document.createElement('video') as any + v2 = window.document.createElement('video') as any window.document.body.appendChild(v1) window.document.body.appendChild(v2) v1.play = jest.fn() @@ -96,7 +97,7 @@ describe('window', () => { it('calls window.URL.createObjectURL', () => { window.URL.createObjectURL = jest.fn().mockReturnValue('test') - expect(createObjectURL()).toBe('test') + expect(createObjectURL('bla')).toBe('test') }) }) @@ -105,14 +106,14 @@ describe('window', () => { it('calls window.URL.revokeObjectURL', () => { window.URL.revokeObjectURL = jest.fn() - expect(revokeObjectURL()).toBe(undefined) + expect(revokeObjectURL('bla')).toBe(undefined) }) }) describe('valueOf', () => { - let input + let input: HTMLInputElement beforeEach(() => { input = window.document.createElement('input') input.setAttribute('id', 'my-main-id') diff --git a/src/client/window.js b/src/client/window.ts similarity index 54% rename from src/client/window.js rename to src/client/window.ts index 8b8bda5..5f74af3 100644 --- a/src/client/window.js +++ b/src/client/window.ts @@ -1,27 +1,28 @@ -import Promise from 'bluebird' import _debug from 'debug' const debug = _debug('peercalls') -export function getUserMedia (constraints) { +export async function getUserMedia (constraints: MediaStreamConstraints) { if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { return navigator.mediaDevices.getUserMedia(constraints) } - return new Promise((resolve, reject) => { - const getMedia = navigator.getUserMedia || navigator.webkitGetUserMedia + return new Promise((resolve, reject) => { + const getMedia = navigator.getUserMedia || + (navigator as any).webkitGetUserMedia if (!getMedia) reject(new Error('Browser unsupported')) getMedia.call(navigator, constraints, resolve, reject) }) } -export const createObjectURL = object => window.URL.createObjectURL(object) -export const revokeObjectURL = url => window.URL.revokeObjectURL(url) +export const createObjectURL = (object: unknown) => + window.URL.createObjectURL(object) +export const revokeObjectURL = (url: string) => window.URL.revokeObjectURL(url) export const navigator = window.navigator export function play () { - let videos = window.document.querySelectorAll('video') + const videos = window.document.querySelectorAll('video') Array.prototype.forEach.call(videos, (video, index) => { debug('playing video: %s', index) try { @@ -32,13 +33,13 @@ export function play () { }) } -export const valueOf = id => { - const el = window.document.getElementById(id) +export const valueOf = (id: string) => { + const el = window.document.getElementById(id) as HTMLInputElement return el && el.value } export const baseUrl = valueOf('baseUrl') export const callId = valueOf('callId') -export const iceServers = JSON.parse(valueOf('iceServers')) +export const iceServers = JSON.parse(valueOf('iceServers')!) export const MediaStream = window.MediaStream From 69122466b11be9e6088c3745be2d1ce2be4e9e13 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 16:23:35 -0300 Subject: [PATCH 10/38] Add async middleware --- src/client/async/action.ts | 59 +++++++++++++ src/client/async/middleware.test.ts | 128 ++++++++++++++++++++++++++++ src/client/async/middleware.ts | 36 ++++++++ src/client/async/reducer.ts | 18 ++++ 4 files changed, 241 insertions(+) create mode 100644 src/client/async/action.ts create mode 100644 src/client/async/middleware.test.ts create mode 100644 src/client/async/middleware.ts create mode 100644 src/client/async/reducer.ts diff --git a/src/client/async/action.ts b/src/client/async/action.ts new file mode 100644 index 0000000..4fa3865 --- /dev/null +++ b/src/client/async/action.ts @@ -0,0 +1,59 @@ +import { Action } from 'redux' + +export type PendingAction = Action & Promise

& { + status: 'pending' +} + +export type ResolvedAction = Action & { + payload: P + status: 'resolved' +} + +export type RejectedAction = Action & { + payload: Error + status: 'rejected' +} + +export type AsyncAction = + PendingAction | + ResolvedAction | + RejectedAction + +export type GetAsyncAction = + A extends PendingAction + ? AsyncAction + : A extends ResolvedAction + ? AsyncAction + : never + +export type GetAllActions = { + [K in keyof T]: T[K] extends (...args: any[]) => infer R + ? R + : never +}[keyof T] + +export type GetAllAsyncActions = GetAsyncAction> + +function isPromise(value: unknown): value is Promise { + return value && typeof value === 'object' && + typeof (value as Promise).then === 'function' +} + +export function isPendingAction( + value: unknown, +): value is PendingAction { + return isPromise(value) && + typeof (value as unknown as { type: 'string' }).type === 'string' +} + +export function makeAction( + type: T, + impl: (...args: A) => Promise

, +): (...args: A) => PendingAction{ + return (...args: A) => { + const pendingAction= impl(...args) as PendingAction + pendingAction.type = type + pendingAction.status = 'pending' + return pendingAction + } +} diff --git a/src/client/async/middleware.test.ts b/src/client/async/middleware.test.ts new file mode 100644 index 0000000..8025883 --- /dev/null +++ b/src/client/async/middleware.test.ts @@ -0,0 +1,128 @@ +import { GetAllAsyncActions, makeAction } from './action' +import { middleware } from './middleware' +import { reduce } from './reducer' +import { createStore, applyMiddleware, combineReducers } from 'redux' + +describe('middleware', () => { + + interface State { + sum: number + status: 'pending' | 'resolved' | 'rejected' + } + + const defaultState: State = { + status: 'resolved', + sum: 0, + } + + const actions = { + add: makeAction('add', async (a: number, b: number) => { + return {a, b} + }), + subtract: makeAction('subtract', async (a: number, b: number) => { + return {a, b} + }), + reject: makeAction('reject', async (a: number, b: number) => { + throw new Error('Test reject') + }), + } + + type Action = GetAllAsyncActions + + function result(state = defaultState, action: Action): State { + switch (action.type) { + case 'add': + return reduce( + state, + action, + (state, pending) => ({ + status: pending.status, + sum: state.sum, + }), + (state, resolved) => ({ + status: resolved.status, + sum: resolved.payload.a + resolved.payload.b, + }), + (state, rejected) => ({status: rejected.status, sum: 0}), + ) + case 'subtract': + return reduce( + state, + action, + (state, pending) => ({ + status: pending.status, + sum: state.sum, + }), + (state, resolved) => ({ + status: resolved.status, + sum: resolved.payload.a - resolved.payload.b, + }), + (state, rejected) => ({status: rejected.status, sum: 0}), + ) + case 'reject': + return reduce( + state, + action, + (state, pending) => ({ + status: pending.status, + sum: state.sum, + }), + (state, resolved) => ({ + status: resolved.status, + sum: 0, + }), + (state, rejected) => ({status: rejected.status, sum: 0}), + ) + default: + return state + } + } + + function getStore() { + return createStore( + combineReducers({ result }), + applyMiddleware(middleware), + ) + } + + describe('pending and resolved', () => { + it('makes it easy to dispatch async actions for redux', async () => { + const store = getStore() + await store.dispatch(actions.add(1, 2)) + expect(store.getState()).toEqual({ + result: { + status: 'resolved', + sum: 3, + }, + }) + await store.dispatch(actions.subtract(1, 2)) + expect(store.getState()).toEqual({ + result: { + status: 'resolved', + sum: -1, + }, + }) + }) + }) + + describe('rejected', () => { + it('handles rejected actions', async () => { + const store = getStore() + let error!: Error + try { + await store.dispatch(actions.reject(1, 2)) + } catch (err) { + error = err + } + expect(error).toBeTruthy() + expect(error.message).toBe('Test reject') + expect(store.getState()).toEqual({ + result: { + status: 'rejected', + sum: 0, + }, + }) + }) + }) + +}) diff --git a/src/client/async/middleware.ts b/src/client/async/middleware.ts new file mode 100644 index 0000000..cad7720 --- /dev/null +++ b/src/client/async/middleware.ts @@ -0,0 +1,36 @@ +import { AnyAction, Middleware } from 'redux' +import { isPendingAction, ResolvedAction, PendingAction, RejectedAction } from './action' + +export const middleware: Middleware = store => next => (action: AnyAction) => { + if (!isPendingAction(action)) { + return next(action) + } + + const promise = action + .then(payload => { + const resolvedAction: ResolvedAction = { + payload, + type: action.type, + status: 'resolved', + } + store.dispatch(resolvedAction) + }) + + // Propagate this action. Only attach listeners to the promise. + next({ + type: action.type, + status: 'pending', + }) + + const promise2 = promise + .catch((err: Error) => { + const rejectedAction: RejectedAction = { + payload: err, + type: action.type, + status: 'rejected', + } + store.dispatch(rejectedAction) + }) + + return promise2.then(() => action) +} diff --git a/src/client/async/reducer.ts b/src/client/async/reducer.ts new file mode 100644 index 0000000..9c2c39a --- /dev/null +++ b/src/client/async/reducer.ts @@ -0,0 +1,18 @@ +import { AsyncAction, PendingAction, ResolvedAction, RejectedAction } from './action' + +export function reduce( + state: State, + action: AsyncAction, + handlePending: (state: State, action: PendingAction) => State, + handleResolved: (state: State, action: ResolvedAction) => State, + handleRejected: (state: State, action: RejectedAction) => State, +): State { + switch (action.status) { + case 'pending': + return handlePending(state, action) + case 'resolved': + return handleResolved(state, action) + case 'rejected': + return handleRejected(state, action) + } +} From 4fa6a0d17a04bfea26df87e68b4a5f874d1c5645 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 18:36:31 -0300 Subject: [PATCH 11/38] Refactor all components --- package-lock.json | 63 +++++---- package.json | 7 +- src/client/__mocks__/store.ts | 2 +- src/client/__mocks__/window.ts | 2 - src/client/actions/CallActions.test.ts | 72 ++++++----- src/client/actions/CallActions.ts | 14 +- src/client/actions/ChatActions.ts | 2 +- src/client/actions/NotifyActions.ts | 4 +- src/client/actions/PeerActions.test.ts | 8 +- src/client/actions/PeerActions.ts | 10 +- src/client/actions/SocketActions.test.ts | 8 +- src/client/actions/SocketActions.ts | 6 +- src/client/actions/StreamActions.ts | 8 +- .../components/{Alerts.ts => Alerts.tsx} | 28 ++-- src/client/components/{App.ts => App.tsx} | 68 +++++----- src/client/components/{Chat.ts => Chat.tsx} | 51 +++----- .../{Input.test.ts => Input.test.tsx} | 43 ++++--- src/client/components/{Input.ts => Input.tsx} | 41 +++--- src/client/components/Notifications.ts | 41 ------ src/client/components/Notifications.tsx | 41 ++++++ .../{Toolbar.test.ts => Toolbar.test.tsx} | 80 +++++++----- .../components/{Toolbar.ts => Toolbar.tsx} | 92 +++++++++----- src/client/components/Video.test.ts | 90 ------------- src/client/components/Video.test.tsx | 120 ++++++++++++++++++ src/client/components/Video.ts | 69 ---------- src/client/components/Video.tsx | 66 ++++++++++ .../containers/{App.test.ts => App.test.tsx} | 16 +-- src/client/containers/{App.ts => App.tsx} | 21 +-- src/client/debug/index.ts | 59 +++++---- src/client/index.tsx | 4 +- src/client/middlewares.test.ts | 2 +- src/client/reducers/active.test.ts | 8 +- src/client/reducers/active.ts | 10 +- src/client/reducers/alerts.test.ts | 49 ++++--- src/client/reducers/alerts.ts | 16 +-- src/client/reducers/index.ts | 14 +- src/client/reducers/messages.test.ts | 11 +- src/client/reducers/messages.ts | 4 +- src/client/reducers/notifications.ts | 30 +++-- src/client/reducers/peers.ts | 2 +- src/client/reducers/streams.test.ts | 10 +- src/client/reducers/streams.ts | 6 +- src/client/socket.ts | 2 +- src/client/store.ts | 2 +- src/client/window.test.ts | 2 +- src/screenfull.d.ts | 10 ++ src/scss/style.scss | 4 +- 47 files changed, 718 insertions(+), 600 deletions(-) rename src/client/components/{Alerts.ts => Alerts.tsx} (58%) rename src/client/components/{App.ts => App.tsx} (60%) rename src/client/components/{Chat.ts => Chat.tsx} (74%) rename src/client/components/{Input.test.ts => Input.test.tsx} (67%) rename src/client/components/{Input.ts => Input.tsx} (73%) delete mode 100644 src/client/components/Notifications.ts create mode 100644 src/client/components/Notifications.tsx rename src/client/components/{Toolbar.test.ts => Toolbar.test.tsx} (55%) rename src/client/components/{Toolbar.ts => Toolbar.tsx} (57%) delete mode 100644 src/client/components/Video.test.ts create mode 100644 src/client/components/Video.test.tsx delete mode 100644 src/client/components/Video.ts create mode 100644 src/client/components/Video.tsx rename src/client/containers/{App.test.ts => App.test.tsx} (88%) rename src/client/containers/{App.ts => App.tsx} (57%) create mode 100644 src/screenfull.d.ts diff --git a/package-lock.json b/package-lock.json index fb0fe95..86fa0de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1949,6 +1949,12 @@ "@types/node": "*" } }, + "@types/classnames": { + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/@types/classnames/-/classnames-2.2.9.tgz", + "integrity": "sha512-MNl+rT5UmZeilaPxAVs6YaPC2m6aA8rofviZbhbxpPpl61uKodfdQVsBtgJGTqGizEf02oW3tsVe7FYB8kK14A==", + "dev": true + }, "@types/config": { "version": "0.0.36", "resolved": "https://registry.npmjs.org/@types/config/-/config-0.0.36.tgz", @@ -2142,6 +2148,15 @@ } } }, + "@types/react-transition-group": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.2.3.tgz", + "integrity": "sha512-Hk8jiuT7iLOHrcjKP/ZVSyCNXK73wJAUz60xm0mVhiRujrdiI++j4duLiL282VGxwAgxetHQFfqA29LgEeSkFA==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, "@types/redux": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/@types/redux/-/redux-3.6.0.tgz", @@ -2183,6 +2198,15 @@ "redux": "^4.0.0" } }, + "@types/screenfull": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@types/screenfull/-/screenfull-4.1.0.tgz", + "integrity": "sha512-TuFSOzuzGFVCdQmwp+a0/Qim+nJhclaWha18yK/xmjrwdPI7qrfeyoSyPx8MoJP8X5d2MwB4a6d2sZhUjJwz9A==", + "dev": true, + "requires": { + "screenfull": "*" + } + }, "@types/serve-static": { "version": "1.13.3", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.3.tgz", @@ -3862,11 +3886,6 @@ "lazy-cache": "^1.0.3" } }, - "chain-function": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/chain-function/-/chain-function-1.0.1.tgz", - "integrity": "sha512-SxltgMwL9uCko5/ZCLiyG2B7R9fY4pDZUw7hJ4MhirdjBLosoDqkWABi3XMucddHdLiFJMb7PD2MZifZriuMTg==" - }, "chalk": { "version": "1.1.3", "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -4733,6 +4752,7 @@ "version": "3.4.0", "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz", "integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==", + "dev": true, "requires": { "@babel/runtime": "^7.1.2" } @@ -11762,6 +11782,12 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.6.3.tgz", "integrity": "sha512-u7FDWtthB4rWibG/+mFbVd5FvdI20yde86qKGx4lVUTWmPlSWQ4QxbBIrrs+HnXGbxOUlUzTAP/VDmvCwaP2yA==" }, + "react-lifecycles-compat": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", + "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==", + "dev": true + }, "react-redux": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-6.0.0.tgz", @@ -11776,15 +11802,15 @@ } }, "react-transition-group": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-1.2.1.tgz", - "integrity": "sha512-CWaL3laCmgAFdxdKbhhps+c0HRGF4c+hdM4H23+FI1QBNUyx/AMeIJGWorehPNSaKnQNOAxL7PQmqMu78CDj3Q==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.5.1.tgz", + "integrity": "sha512-8x/CxUL9SjYFmUdzsBPTgtKeCxt7QArjNSte0wwiLtF/Ix/o1nWNJooNy5o9XbHIKS31pz7J5VF2l41TwlvbHQ==", + "dev": true, "requires": { - "chain-function": "^1.0.0", - "dom-helpers": "^3.2.0", - "loose-envify": "^1.3.1", - "prop-types": "^15.5.6", - "warning": "^3.0.0" + "dom-helpers": "^3.3.1", + "loose-envify": "^1.4.0", + "prop-types": "^15.6.2", + "react-lifecycles-compat": "^3.0.4" } }, "read-only-stream": { @@ -12604,7 +12630,8 @@ "screenfull": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/screenfull/-/screenfull-3.3.3.tgz", - "integrity": "sha512-DzYUuXr+OV2BDvYXaYzlYgJd4WXZZ2CW5NFC7Kw6TUCpzXJAx4MwlVD6CH+Mu6fi8rfAQIQfqdFZ4jtDsEkWig==" + "integrity": "sha512-DzYUuXr+OV2BDvYXaYzlYgJd4WXZZ2CW5NFC7Kw6TUCpzXJAx4MwlVD6CH+Mu6fi8rfAQIQfqdFZ4jtDsEkWig==", + "dev": true }, "scss-tokenizer": { "version": "0.2.3", @@ -14320,14 +14347,6 @@ "makeerror": "1.0.x" } }, - "warning": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", - "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", - "requires": { - "loose-envify": "^1.0.0" - } - }, "watchify": { "version": "3.11.1", "resolved": "https://registry.npmjs.org/watchify/-/watchify-3.11.1.tgz", diff --git a/package.json b/package.json index d3de070..addc991 100644 --- a/package.json +++ b/package.json @@ -60,12 +60,10 @@ "react": "^16.6.3", "react-dom": "^16.6.3", "react-redux": "^6.0.0", - "react-transition-group": "^1.2.1", "redux": "^4.0.1", "redux-logger": "^3.0.6", "redux-promise-middleware": "^5.1.1", "redux-thunk": "^2.2.0", - "screenfull": "^3.3.3", "seamless-immutable": "^7.1.2", "simple-peer": "^9.1.2", "socket.io": "^2.2.0", @@ -81,6 +79,7 @@ "@babel/preset-env": "^7.5.0", "@babel/preset-react": "^7.0.0", "@types/bluebird": "^3.5.29", + "@types/classnames": "^2.2.9", "@types/config": "0.0.36", "@types/debug": "^4.1.5", "@types/express": "^4.17.2", @@ -89,9 +88,11 @@ "@types/react": "^16.9.11", "@types/react-dom": "^16.9.4", "@types/react-redux": "^7.1.5", + "@types/react-transition-group": "^4.2.3", "@types/redux": "^3.6.0", "@types/redux-logger": "^3.0.7", "@types/redux-mock-store": "^1.0.1", + "@types/screenfull": "^4.1.0", "@types/simple-peer": "^6.1.6", "@types/socket.io": "^2.1.4", "@types/socket.io-client": "^1.4.32", @@ -117,7 +118,9 @@ "jest-cli": "^24.8.0", "node-sass": "^4.13.0", "nodemon": "^1.18.8", + "react-transition-group": "^2.5.1", "redux-mock-store": "^1.2.3", + "screenfull": "^3.3.3", "supertest": "^3.0.0", "ts-jest": "^24.1.0", "ts-node": "^8.5.0", diff --git a/src/client/__mocks__/store.ts b/src/client/__mocks__/store.ts index 4bf55af..62809d3 100644 --- a/src/client/__mocks__/store.ts +++ b/src/client/__mocks__/store.ts @@ -1,3 +1,3 @@ import configureStore from 'redux-mock-store' -import { middlewares } from '../middlewares.js' +import { middlewares } from '../middlewares' export default configureStore(middlewares)({}) diff --git a/src/client/__mocks__/window.ts b/src/client/__mocks__/window.ts index 342d8cf..6904fac 100644 --- a/src/client/__mocks__/window.ts +++ b/src/client/__mocks__/window.ts @@ -1,5 +1,3 @@ -import Promise from 'bluebird' - export const createObjectURL = jest.fn() .mockImplementation(object => 'blob://' + String(object)) export const revokeObjectURL = jest.fn() diff --git a/src/client/actions/CallActions.test.ts b/src/client/actions/CallActions.test.ts index bc3f6d6..9fcba4a 100644 --- a/src/client/actions/CallActions.test.ts +++ b/src/client/actions/CallActions.test.ts @@ -1,23 +1,26 @@ -jest.mock('../socket.js') -jest.mock('../window.js') -jest.mock('../store.js') -jest.mock('./SocketActions.js') +jest.mock('../socket') +jest.mock('../window') +jest.mock('../store') +jest.mock('./SocketActions') -import * as CallActions from './CallActions.js' -import * as SocketActions from './SocketActions.js' -import * as constants from '../constants.js' -import socket from '../socket.js' -import store from '../store.js' -import { callId, getUserMedia } from '../window.js' +import * as CallActions from './CallActions' +import * as SocketActions from './SocketActions' +import * as constants from '../constants' +import socket from '../socket' +import storeMock from '../store' +import { callId, getUserMedia } from '../window' +import { MockStore } from 'redux-mock-store' jest.useFakeTimers() describe('reducers/alerts', () => { + const store: MockStore = storeMock as any + beforeEach(() => { - store.clearActions() - getUserMedia.fail(false) - SocketActions.handshake.mockReturnValue(jest.fn()) + store.clearActions(); + (getUserMedia as any).fail(false); + (SocketActions.handshake as jest.Mock).mockReturnValue(jest.fn()) }) afterEach(() => { @@ -28,81 +31,80 @@ describe('reducers/alerts', () => { describe('init', () => { it('calls handshake.init when connected & got camera stream', async () => { - const promise = store.dispatch(CallActions.init()) + const promise = CallActions.init(store.dispatch, store.getState) socket.emit('connect') expect(store.getActions()).toEqual([{ - type: constants.INIT_PENDING + type: constants.INIT_PENDING, }, { type: constants.NOTIFY, payload: { id: jasmine.any(String), message: 'Connected to server socket', - type: 'warning' - } + type: 'warning', + }, }, { type: constants.MESSAGE_ADD, payload: { image: null, message: 'Connected to server socket', timestamp: jasmine.any(String), - userId: '[PeerCalls]' - } + userId: '[PeerCalls]', + }, }]) await promise - expect(SocketActions.handshake.mock.calls).toEqual([[{ + expect((SocketActions.handshake as jest.Mock).mock.calls).toEqual([[{ socket, roomName: callId, - stream: getUserMedia.stream + stream: (getUserMedia as any).stream, }]]) }) it('calls dispatches disconnect message on disconnect', async () => { - const promise = store.dispatch(CallActions.init()) + const promise = CallActions.init(store.dispatch, store.getState) socket.emit('connect') socket.emit('disconnect') expect(store.getActions()).toEqual([{ - type: constants.INIT_PENDING + type: constants.INIT_PENDING, }, { type: constants.NOTIFY, payload: { id: jasmine.any(String), message: 'Connected to server socket', - type: 'warning' - } + type: 'warning', + }, }, { type: constants.MESSAGE_ADD, payload: { image: null, message: 'Connected to server socket', timestamp: jasmine.any(String), - userId: '[PeerCalls]' - } + userId: '[PeerCalls]', + }, }, { type: constants.NOTIFY, payload: { id: jasmine.any(String), message: 'Server socket disconnected', - type: 'error' - } + type: 'error', + }, }, { type: constants.MESSAGE_ADD, payload: { image: null, message: 'Server socket disconnected', timestamp: jasmine.any(String), - userId: '[PeerCalls]' - } + userId: '[PeerCalls]', + }, }]) await promise }) it('dispatches alert when failed to get media stream', async () => { - getUserMedia.fail(true) - const promise = store.dispatch(CallActions.init()) + (getUserMedia as any).fail(true) + const promise = CallActions.init(store.dispatch, store.getState) socket.emit('connect') - const result = await promise - expect(result.value).toBe(null) + await promise }) }) diff --git a/src/client/actions/CallActions.ts b/src/client/actions/CallActions.ts index fdafb9b..5279ebc 100644 --- a/src/client/actions/CallActions.ts +++ b/src/client/actions/CallActions.ts @@ -1,11 +1,11 @@ -import * as NotifyActions from './NotifyActions.js' -import * as SocketActions from './SocketActions.js' -import * as StreamActions from './StreamActions.js' -import * as constants from '../constants.js' -import socket from '../socket.js' -import { callId, getUserMedia } from '../window.js' +import * as NotifyActions from './NotifyActions' +import * as SocketActions from './SocketActions' +import * as StreamActions from './StreamActions' +import * as constants from '../constants' +import socket from '../socket' +import { callId, getUserMedia } from '../window' import { Dispatch } from 'redux' -import { GetState } from '../store.js' +import { GetState } from '../store' export interface InitAction { type: 'INIT' diff --git a/src/client/actions/ChatActions.ts b/src/client/actions/ChatActions.ts index 1e5b54a..0ea8351 100644 --- a/src/client/actions/ChatActions.ts +++ b/src/client/actions/ChatActions.ts @@ -1,4 +1,4 @@ -import { MESSAGE_ADD } from '../constants.js' +import { MESSAGE_ADD } from '../constants' export interface MessageAddAction { type: 'MESSAGE_ADD' diff --git a/src/client/actions/NotifyActions.ts b/src/client/actions/NotifyActions.ts index f411c4f..7ce0dad 100644 --- a/src/client/actions/NotifyActions.ts +++ b/src/client/actions/NotifyActions.ts @@ -1,5 +1,5 @@ -import * as constants from '../constants.js' -import * as ChatActions from './ChatActions.js' +import * as constants from '../constants' +import * as ChatActions from './ChatActions' import { Dispatch } from 'redux' import _ from 'underscore' diff --git a/src/client/actions/PeerActions.test.ts b/src/client/actions/PeerActions.test.ts index abc1caf..b475acc 100644 --- a/src/client/actions/PeerActions.test.ts +++ b/src/client/actions/PeerActions.test.ts @@ -1,11 +1,11 @@ -jest.mock('../window.js') +jest.mock('../window') jest.mock('simple-peer') -import * as PeerActions from './PeerActions.js' +import * as PeerActions from './PeerActions' import Peer from 'simple-peer' import { EventEmitter } from 'events' -import { createStore, Store, GetState } from '../store.js' -import { play } from '../window.js' +import { createStore, Store, GetState } from '../store' +import { play } from '../window' import { Dispatch } from 'redux' describe('PeerActions', () => { diff --git a/src/client/actions/PeerActions.ts b/src/client/actions/PeerActions.ts index 71906e0..9879b54 100644 --- a/src/client/actions/PeerActions.ts +++ b/src/client/actions/PeerActions.ts @@ -1,11 +1,11 @@ -import * as ChatActions from '../actions/ChatActions.js' -import * as NotifyActions from '../actions/NotifyActions.js' -import * as StreamActions from '../actions/StreamActions.js' -import * as constants from '../constants.js' +import * as ChatActions from '../actions/ChatActions' +import * as NotifyActions from '../actions/NotifyActions' +import * as StreamActions from '../actions/StreamActions' +import * as constants from '../constants' import Peer from 'simple-peer' import _ from 'underscore' import _debug from 'debug' -import { play, iceServers } from '../window.js' +import { play, iceServers } from '../window' import { Dispatch } from 'redux' const debug = _debug('peercalls') diff --git a/src/client/actions/SocketActions.test.ts b/src/client/actions/SocketActions.test.ts index 491d00c..855d700 100644 --- a/src/client/actions/SocketActions.test.ts +++ b/src/client/actions/SocketActions.test.ts @@ -1,11 +1,11 @@ jest.mock('simple-peer') -jest.mock('../window.js') +jest.mock('../window') -import * as SocketActions from './SocketActions.js' -import * as constants from '../constants.js' +import * as SocketActions from './SocketActions' +import * as constants from '../constants' import Peer from 'simple-peer' import { EventEmitter } from 'events' -import { createStore, Store, GetState } from '../store.js' +import { createStore, Store, GetState } from '../store' import { Dispatch } from 'redux' describe('SocketActions', () => { diff --git a/src/client/actions/SocketActions.ts b/src/client/actions/SocketActions.ts index 3bcbda2..96c8ef9 100644 --- a/src/client/actions/SocketActions.ts +++ b/src/client/actions/SocketActions.ts @@ -1,6 +1,6 @@ -import * as NotifyActions from '../actions/NotifyActions.js' -import * as PeerActions from '../actions/PeerActions.js' -import * as constants from '../constants.js' +import * as NotifyActions from '../actions/NotifyActions' +import * as PeerActions from '../actions/PeerActions' +import * as constants from '../constants' import _ from 'underscore' import _debug from 'debug' import { Dispatch } from 'redux' diff --git a/src/client/actions/StreamActions.ts b/src/client/actions/StreamActions.ts index 2320f95..51eb4dd 100644 --- a/src/client/actions/StreamActions.ts +++ b/src/client/actions/StreamActions.ts @@ -1,4 +1,4 @@ -import * as constants from '../constants.js' +import * as constants from '../constants' export interface AddStreamPayload { userId: string @@ -56,6 +56,6 @@ export const toggleActive = (userId: string): ToggleActiveStreamAction => ({ export type StreamAction = AddStreamAction | - RemoveStreamAction - // SetActiveStreamAction | - // ToggleActiveStreamAction + RemoveStreamAction | + SetActiveStreamAction | + ToggleActiveStreamAction diff --git a/src/client/components/Alerts.ts b/src/client/components/Alerts.tsx similarity index 58% rename from src/client/components/Alerts.ts rename to src/client/components/Alerts.tsx index bfb95dc..168b207 100644 --- a/src/client/components/Alerts.ts +++ b/src/client/components/Alerts.tsx @@ -1,18 +1,13 @@ import React from 'react' -import PropTypes from 'prop-types' import classnames from 'classnames' +import { Alert as AlertType } from '../actions/NotifyActions' -export const AlertPropType = PropTypes.shape({ - dismissable: PropTypes.bool, - action: PropTypes.string.isRequired, - message: PropTypes.string.isRequired -}) +export interface AlertProps { + alert: AlertType + dismiss: (alert: AlertType) => void +} -export class Alert extends React.PureComponent { - static propTypes = { - alert: AlertPropType, - dismiss: PropTypes.func.isRequired - } +export class Alert extends React.PureComponent { dismiss = () => { const { alert, dismiss } = this.props dismiss(alert) @@ -34,11 +29,12 @@ export class Alert extends React.PureComponent { } } -export default class Alerts extends React.PureComponent { - static propTypes = { - alerts: PropTypes.arrayOf(AlertPropType).isRequired, - dismiss: PropTypes.func.isRequired - } +export interface AlertsProps { + alerts: AlertType[] + dismiss: (alert: AlertType) => void +} + +export default class Alerts extends React.PureComponent { render () { const { alerts, dismiss } = this.props return ( diff --git a/src/client/components/App.ts b/src/client/components/App.tsx similarity index 60% rename from src/client/components/App.ts rename to src/client/components/App.tsx index 79ce691..a80e7d6 100644 --- a/src/client/components/App.ts +++ b/src/client/components/App.tsx @@ -1,42 +1,49 @@ -import * as constants from '../constants.js' -import Alerts, { AlertPropType } from './Alerts.js' -import Chat, { MessagePropTypes } from './Chat.js' -import Notifications, { NotificationPropTypes } from './Notifications.js' -import PropTypes from 'prop-types' import React from 'react' -import Toolbar from './Toolbar.js' -import Video, { StreamPropType } from './Video.js' +import Peer from 'simple-peer' import _ from 'underscore' +import { Message } from '../actions/ChatActions' +import { Alert, Notification } from '../actions/NotifyActions' +import { TextMessage } from '../actions/PeerActions' +import { AddStreamPayload } from '../actions/StreamActions' +import * as constants from '../constants' +import Alerts from './Alerts' +import Chat from './Chat' +import Notifications from './Notifications' +import Toolbar from './Toolbar' +import Video from './Video' -export default class App extends React.PureComponent { - static propTypes = { - active: PropTypes.string, - alerts: PropTypes.arrayOf(AlertPropType).isRequired, - dismissAlert: PropTypes.func.isRequired, - init: PropTypes.func.isRequired, - notifications: PropTypes.objectOf(NotificationPropTypes).isRequired, - messages: PropTypes.arrayOf(MessagePropTypes).isRequired, - peers: PropTypes.object.isRequired, - sendMessage: PropTypes.func.isRequired, - streams: PropTypes.objectOf(StreamPropType).isRequired, - onSendFile: PropTypes.func.isRequired, - toggleActive: PropTypes.func.isRequired - } - constructor () { - super() - this.state = { - videos: {}, - chatVisible: false - } +export interface AppProps { + active: string | null + alerts: Alert[] + dismissAlert: (alert: Alert) => void + init: () => void + notifications: Record + messages: Message[] + peers: Record + sendMessage: (message: TextMessage) => void + streams: Record + onSendFile: (file: File) => void + toggleActive: (userId: string) => void +} + +export interface AppState { + videos: Record + chatVisible: boolean +} + +export default class App extends React.PureComponent { + state: AppState = { + videos: {}, + chatVisible: false, } handleShowChat = () => { this.setState({ - chatVisible: true + chatVisible: true, }) } handleHideChat = () => { this.setState({ - chatVisible: false + chatVisible: false, }) } handleToggleChat = () => { @@ -59,7 +66,7 @@ export default class App extends React.PureComponent { peers, sendMessage, toggleActive, - streams + streams, } = this.props const { videos } = this.state @@ -79,7 +86,6 @@ export default class App extends React.PureComponent { messages={messages} onClose={this.handleHideChat} sendMessage={sendMessage} - videos={videos} visible={this.state.chatVisible} />

diff --git a/src/client/components/Chat.ts b/src/client/components/Chat.tsx similarity index 74% rename from src/client/components/Chat.ts rename to src/client/components/Chat.tsx index 3fdaf91..ab368d8 100644 --- a/src/client/components/Chat.ts +++ b/src/client/components/Chat.tsx @@ -1,16 +1,14 @@ -import Input from './Input.js' -import PropTypes from 'prop-types' -import React from 'react' import classnames from 'classnames' +import React from 'react' +import { Message as MessageType } from '../actions/ChatActions' +import { TextMessage } from '../actions/PeerActions' +import Input from './Input' -export const MessagePropTypes = PropTypes.shape({ - userId: PropTypes.string.isRequired, - message: PropTypes.string.isRequired, - timestamp: PropTypes.string.isRequired, - image: PropTypes.string -}) +export interface MessageProps { + message: MessageType +} -function Message (props) { +function Message (props: MessageProps) { const { message } = props return (

@@ -22,24 +20,18 @@ function Message (props) { ) } -Message.propTypes = { - message: MessagePropTypes +export interface ChatProps { + visible: boolean + messages: MessageType[] + onClose: () => void + sendMessage: (message: TextMessage) => void } -export default class Chat extends React.PureComponent { - static propTypes = { - visible: PropTypes.bool.isRequired, - messages: PropTypes.arrayOf(MessagePropTypes).isRequired, - onClose: PropTypes.func.isRequired, - sendMessage: PropTypes.func.isRequired, - videos: PropTypes.object.isRequired - } - constructor () { - super() - this.chatHistoryRef = React.createRef() - } +export default class Chat extends React.PureComponent { + chatHistoryRef = React.createRef() + scrollToBottom = () => { - const chatHistoryRef = this.chatHistoryRef.current + const chatHistoryRef = this.chatHistoryRef.current! chatHistoryRef.scrollTop = chatHistoryRef.scrollHeight } componentDidMount () { @@ -49,10 +41,10 @@ export default class Chat extends React.PureComponent { this.scrollToBottom() } render () { - const { messages, videos, sendMessage } = this.props + const { messages, sendMessage } = this.props return (

@@ -111,10 +103,7 @@ export default class Chat extends React.PureComponent {
- +
) } diff --git a/src/client/components/Input.test.ts b/src/client/components/Input.test.tsx similarity index 67% rename from src/client/components/Input.test.ts rename to src/client/components/Input.test.tsx index b0b9e40..ccf10df 100644 --- a/src/client/components/Input.test.ts +++ b/src/client/components/Input.test.tsx @@ -1,36 +1,39 @@ -import Input from './Input.js' +import Input from './Input' import React from 'react' import ReactDOM from 'react-dom' import TestUtils from 'react-dom/test-utils' +import { TextMessage } from '../actions/PeerActions' describe('components/Input', () => { - let component, node, videos, notify, sendMessage - function render () { - videos = {} - notify = jest.fn() + let node: Element + let sendMessage: jest.Mock<(message: TextMessage) => void> + async function render () { sendMessage = jest.fn() - component = TestUtils.renderIntoDocument( - - ) - node = ReactDOM.findDOMNode(component) + const div = document.createElement('div') + await new Promise(resolve => { + ReactDOM.render( + resolve(input!)} + sendMessage={sendMessage} + />, + div, + ) + }) + node = div.children[0] } - let message = 'test message' + const message = 'test message' beforeEach(() => render()) describe('send message', () => { - let input + let input: HTMLTextAreaElement beforeEach(() => { sendMessage.mockClear() - input = node.querySelector('textarea') + input = node.querySelector('textarea')! TestUtils.Simulate.change(input, { - target: { value: message } + target: { value: message } as any, }) expect(input.value).toBe(message) }) @@ -47,7 +50,7 @@ describe('components/Input', () => { describe('handleKeyPress', () => { it('sends a message', () => { TestUtils.Simulate.keyPress(input, { - key: 'Enter' + key: 'Enter', }) expect(input.value).toBe('') expect(sendMessage.mock.calls) @@ -56,7 +59,7 @@ describe('components/Input', () => { it('does nothing when other key pressed', () => { TestUtils.Simulate.keyPress(input, { - key: 'test' + key: 'test', }) expect(sendMessage.mock.calls.length).toBe(0) }) @@ -64,7 +67,7 @@ describe('components/Input', () => { describe('handleSmileClick', () => { it('adds smile to message', () => { - const div = node.querySelector('.chat-controls-buttons-smile') + const div = node.querySelector('.chat-controls-buttons-smile')! TestUtils.Simulate.click(div) expect(input.value).toBe('test message😑') }) diff --git a/src/client/components/Input.ts b/src/client/components/Input.tsx similarity index 73% rename from src/client/components/Input.ts rename to src/client/components/Input.tsx index cfa8ec1..afbda6c 100644 --- a/src/client/components/Input.ts +++ b/src/client/components/Input.tsx @@ -1,34 +1,37 @@ -import PropTypes from 'prop-types' -import React from 'react' +import React, { ReactEventHandler, ChangeEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react' +import { TextMessage } from '../actions/PeerActions' -export default class Input extends React.PureComponent { - static propTypes = { - sendMessage: PropTypes.func.isRequired +export interface InputProps { + sendMessage: (message: TextMessage) => void +} + +export interface InputState { + message: string +} + +export default class Input extends React.PureComponent { + textArea = React.createRef() + state = { + message: '', } - constructor () { - super() - this.state = { - message: '' - } - } - handleChange = e => { + handleChange: ChangeEventHandler = event => { this.setState({ - message: e.target.value + message: event.target.value, }) } - handleSubmit = e => { + handleSubmit: ReactEventHandler = e => { e.preventDefault() this.submit() } - handleKeyPress = e => { + handleKeyPress: KeyboardEventHandler = e => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() this.submit() } } - handleSmileClick = e => { + handleSmileClick: MouseEventHandler = event => { this.setState({ - message: this.textArea.value + e.currentTarget.innerHTML + message: this.textArea.current!.value + event.currentTarget.innerHTML, }) } submit = () => { @@ -37,7 +40,7 @@ export default class Input extends React.PureComponent { if (message) { sendMessage({ payload: message, - type: 'text' + type: 'text', }) // let image = null @@ -66,7 +69,7 @@ export default class Input extends React.PureComponent { onKeyPress={this.handleKeyPress} placeholder="Type a message" value={message} - ref={node => { this.textArea = node }} + ref={this.textArea} />
- - {Object.keys(notifications).slice(-max).map(id => ( -
- {notifications[id].message} -
- ))} -
-
- ) - } -} diff --git a/src/client/components/Notifications.tsx b/src/client/components/Notifications.tsx new file mode 100644 index 0000000..2d72f31 --- /dev/null +++ b/src/client/components/Notifications.tsx @@ -0,0 +1,41 @@ +import CSSTransition from 'react-transition-group/CSSTransition' +import React from 'react' +import classnames from 'classnames' +import { Notification } from '../actions/NotifyActions' + +export interface NotificationProps { + notifications: Record + max: number +} + +const transitionTimeout = { + enter: 200, + exit: 100, +} + +export default class Notifications +extends React.PureComponent { + static defaultProps = { + max: 10, + } + render () { + const { notifications, max } = this.props + return ( +
+ + {Object.keys(notifications).slice(-max).map(id => ( +
+ {notifications[id].message} +
+ ))} +
+
+ ) + } +} diff --git a/src/client/components/Toolbar.test.ts b/src/client/components/Toolbar.test.tsx similarity index 55% rename from src/client/components/Toolbar.test.ts rename to src/client/components/Toolbar.test.tsx index a01eb85..6a297e9 100644 --- a/src/client/components/Toolbar.test.ts +++ b/src/client/components/Toolbar.test.tsx @@ -1,17 +1,20 @@ -jest.mock('../window.js') +jest.mock('../window') import React from 'react' import ReactDOM from 'react-dom' import TestUtils from 'react-dom/test-utils' -import Toolbar from './Toolbar.js' -import { MediaStream } from '../window.js' +import Toolbar, { ToolbarProps } from './Toolbar' +import { MediaStream } from '../window' +import { AddStreamPayload } from '../actions/StreamActions' describe('components/Toolbar', () => { - class ToolbarWrapper extends React.PureComponent { - static propTypes = Toolbar.propTypes - constructor () { - super() - this.state = {} + interface StreamState { + stream: AddStreamPayload | null + } + + class ToolbarWrapper extends React.PureComponent { + state = { + stream: null, } render () { return { } } - let component, node, mediaStream, url, onToggleChat, onSendFile - function render () { + let node: Element + let mediaStream: MediaStream + let url: string + let onToggleChat: jest.Mock<() => void> + let onSendFile: jest.Mock<(file: File) => void> + async function render () { mediaStream = new MediaStream() onToggleChat = jest.fn() onSendFile = jest.fn() - component = TestUtils.renderIntoDocument( - - ) - node = ReactDOM.findDOMNode(component) + const div = document.createElement('div') + await new Promise(resolve => { + ReactDOM.render( + resolve(instance!)} + chatVisible + onToggleChat={onToggleChat} + onSendFile={onSendFile} + messages={[]} + stream={{ userId: '', stream: mediaStream, url }} + />, + div, + ) + }) + node = div.children[0] } - beforeEach(() => { - render() + beforeEach(async () => { + await render() }) describe('handleChatClick', () => { it('toggle chat', () => { expect(onToggleChat.mock.calls.length).toBe(0) - const button = node.querySelector('.chat') + const button = node.querySelector('.chat')! TestUtils.Simulate.click(button) expect(onToggleChat.mock.calls.length).toBe(1) }) @@ -56,7 +68,7 @@ describe('components/Toolbar', () => { describe('handleMicClick', () => { it('toggle mic', () => { - const button = node.querySelector('.mute-audio') + const button = node.querySelector('.mute-audio')! TestUtils.Simulate.click(button) expect(button.classList.contains('on')).toBe(true) }) @@ -64,7 +76,7 @@ describe('components/Toolbar', () => { describe('handleCamClick', () => { it('toggle cam', () => { - const button = node.querySelector('.mute-video') + const button = node.querySelector('.mute-video')! TestUtils.Simulate.click(button) expect(button.classList.contains('on')).toBe(true) }) @@ -72,7 +84,7 @@ describe('components/Toolbar', () => { describe('handleFullscreenClick', () => { it('toggle fullscreen', () => { - const button = node.querySelector('.fullscreen') + const button = node.querySelector('.fullscreen')! TestUtils.Simulate.click(button) expect(button.classList.contains('on')).toBe(false) }) @@ -80,7 +92,7 @@ describe('components/Toolbar', () => { describe('handleHangoutClick', () => { it('hangout', () => { - const button = node.querySelector('.hangup') + const button = node.querySelector('.hangup')! TestUtils.Simulate.click(button) expect(window.location.href).toBe('http://localhost/') }) @@ -88,10 +100,10 @@ describe('components/Toolbar', () => { describe('handleSendFile', () => { it('triggers input dialog', () => { - const sendFileButton = node.querySelector('.send-file') + const sendFileButton = node.querySelector('.send-file')! const click = jest.fn() - const file = node.querySelector('input[type=file]') - file.click = click + const file = node.querySelector('input[type=file]')!; + (file as any).click = click TestUtils.Simulate.click(sendFileButton) expect(click.mock.calls.length).toBe(1) }) @@ -99,12 +111,12 @@ describe('components/Toolbar', () => { describe('handleSelectFiles', () => { it('iterates through files and calls onSendFile for each', () => { - const file = node.querySelector('input[type=file]') - const files = [{ name: 'first' }] + const file = node.querySelector('input[type=file]')! + const files = [{ name: 'first' }] as any TestUtils.Simulate.change(file, { target: { - files - } + files, + } as any, }) expect(onSendFile.mock.calls).toEqual([[ files[0] ]]) }) diff --git a/src/client/components/Toolbar.ts b/src/client/components/Toolbar.tsx similarity index 57% rename from src/client/components/Toolbar.ts rename to src/client/components/Toolbar.tsx index 16dfe76..3cb1019 100644 --- a/src/client/components/Toolbar.ts +++ b/src/client/components/Toolbar.tsx @@ -1,63 +1,85 @@ -import PropTypes from 'prop-types' -import React from 'react' +import React, { ReactEventHandler } from 'react' import classnames from 'classnames' import screenfull from 'screenfull' -import { MessagePropTypes } from './Chat.js' -import { StreamPropType } from './Video.js' +import { Message } from '../actions/ChatActions' +import { AddStreamPayload } from '../actions/StreamActions' const hidden = { - display: 'none' + display: 'none', } -export default class Toolbar extends React.PureComponent { - static propTypes = { - messages: PropTypes.arrayOf(MessagePropTypes).isRequired, - stream: StreamPropType, - onToggleChat: PropTypes.func.isRequired, - onSendFile: PropTypes.func.isRequired, - chatVisible: PropTypes.bool.isRequired - } - constructor (props) { +export interface ToolbarProps { + messages: Message[] + stream: AddStreamPayload + onToggleChat: () => void + onSendFile: (file: File) => void + chatVisible: boolean +} + +export interface ToolbarState { + readMessages: number + camDisabled: boolean + micMuted: boolean + fullScreenEnabled: boolean +} + +export default class Toolbar +extends React.PureComponent { + file = React.createRef() + + constructor(props: ToolbarProps) { super(props) - this.file = React.createRef() this.state = { - readMessages: props.messages.length + readMessages: props.messages.length, + camDisabled: false, + micMuted: false, + fullScreenEnabled: false, } } + handleMicClick = () => { const { stream } = this.props - stream.mediaStream.getAudioTracks().forEach(track => { + stream.stream.getAudioTracks().forEach(track => { track.enabled = !track.enabled }) - this.mixButton.classList.toggle('on') + this.setState({ + ...this.state, + micMuted: !this.state.micMuted, + }) } handleCamClick = () => { const { stream } = this.props - stream.mediaStream.getVideoTracks().forEach(track => { + stream.stream.getVideoTracks().forEach(track => { track.enabled = !track.enabled }) - this.camButton.classList.toggle('on') + this.setState({ + ...this.state, + camDisabled: !this.state.camDisabled, + }) } handleFullscreenClick = () => { if (screenfull.enabled) { screenfull.toggle() - this.fullscreenButton.classList.toggle('on') + this.setState({ + ...this.state, + fullScreenEnabled: !this.state.fullScreenEnabled, + }) } } handleHangoutClick = () => { window.location.href = '/' } handleSendFile = () => { - this.file.current.click() + this.file.current!.click() } - handleSelectFiles = (event) => { + handleSelectFiles: ReactEventHandler = event => { Array - .from(event.target.files) + .from(this.file.current!.files!) .forEach(file => this.props.onSendFile(file)) } handleToggleChat = () => { this.setState({ - readMessages: this.props.messages.length + readMessages: this.props.messages.length, }) this.props.onToggleChat() } @@ -68,7 +90,7 @@ export default class Toolbar extends React.PureComponent {
this.state.readMessages} @@ -93,17 +115,20 @@ export default class Toolbar extends React.PureComponent { {stream && (
-
{ this.mixButton = node }} - className="button mute-audio" +
{ this.camButton = node }} - className="button mute-video" + className={classnames('button mute-video', { + on: this.state.camDisabled, + })} title="Mute video" > @@ -113,8 +138,9 @@ export default class Toolbar extends React.PureComponent { )}
{ this.fullscreenButton = node }} - className="button fullscreen" + className={classnames('button fullscreen', { + on: this.state.fullScreenEnabled, + })} title="Enter fullscreen" > diff --git a/src/client/components/Video.test.ts b/src/client/components/Video.test.ts deleted file mode 100644 index 642f1b5..0000000 --- a/src/client/components/Video.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -jest.mock('../window.js') -import React from 'react' -import ReactDOM from 'react-dom' -import TestUtils from 'react-dom/test-utils' -import Video from './Video.js' -import { MediaStream } from '../window.js' - -describe('components/Video', () => { - - class VideoWrapper extends React.PureComponent { - static propTypes = Video.propTypes - constructor () { - super() - this.state = {} - } - render () { - return
resolve(app!)}> +
resolve(div!)}>
, @@ -56,8 +58,8 @@ describe('App', () => { } describe('render', () => { - it('renders without issues', () => { - render() + it('renders without issues', async () => { + await render() expect(node).toBeTruthy() expect((init as jest.Mock).mock.calls.length).toBe(1) }) @@ -65,7 +67,7 @@ describe('App', () => { describe('state', () => { let alert: Alert - beforeEach(() => { + beforeEach(async () => { state.streams = { test: { mediaStream: new MediaStream(), @@ -82,18 +84,20 @@ describe('App', () => { type: 'warning', }, } - state.alerts = [{ + alert = { dismissable: true, action: 'Dismiss', message: 'test alert', type: 'info', - }] - render() + } + state.alerts = [alert] + await render() }) describe('alerts', () => { it('can be dismissed', () => { const dismiss = node.querySelector('.action-alert-dismiss')! + dispatchSpy.mockReset() TestUtils.Simulate.click(dismiss) expect(dispatchSpy.mock.calls).toEqual([[{ type: constants.ALERT_DISMISS, @@ -104,6 +108,7 @@ describe('App', () => { describe('video', () => { it('can be activated', () => { + dispatchSpy.mockReset() const video = node.querySelector('video')! TestUtils.Simulate.click(video) expect(dispatchSpy.mock.calls).toEqual([[{ From 4bdd2e4cae753f6d6554f19e5efc2907fa501640 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 21:28:43 -0300 Subject: [PATCH 14/38] Fix CallActions.test.ts --- src/client/actions/CallActions.test.ts | 64 +++++++++++--------------- src/client/actions/CallActions.ts | 22 +++++---- src/client/actions/NotifyActions.ts | 6 +-- src/client/async/action.ts | 6 +-- src/client/async/middleware.ts | 15 +++++- src/client/constants.ts | 3 -- src/client/middlewares.ts | 5 +- src/client/store.ts | 3 +- 8 files changed, 63 insertions(+), 61 deletions(-) diff --git a/src/client/actions/CallActions.test.ts b/src/client/actions/CallActions.test.ts index 9b998e9..8da26eb 100644 --- a/src/client/actions/CallActions.test.ts +++ b/src/client/actions/CallActions.test.ts @@ -1,26 +1,38 @@ jest.mock('../socket') jest.mock('../window') -jest.mock('../store') jest.mock('./SocketActions') import * as CallActions from './CallActions' import * as SocketActions from './SocketActions' import * as constants from '../constants' import socket from '../socket' -import storeMock from '../store' import { callId, getUserMedia } from '../window' -import { MockStore } from 'redux-mock-store' -import { bindActionCreators } from 'redux' +import { bindActionCreators, createStore, AnyAction, combineReducers, applyMiddleware } from 'redux' +import reducers from '../reducers' +import { middlewares } from '../middlewares' jest.useFakeTimers() -describe('reducers/alerts', () => { +describe('CallActions', () => { - const store: MockStore = storeMock as any - const callActions = bindActionCreators(CallActions, store.dispatch) + let callActions: typeof CallActions + + function allActions(state: AnyAction[] = [], action: AnyAction) { + return [...state, action] + } + + const configureStore = () => createStore( + combineReducers({...reducers, allActions }), + applyMiddleware(...middlewares), + ) + let store: ReturnType beforeEach(() => { - store.clearActions(); + store = createStore( + combineReducers({ allActions }), + applyMiddleware(...middlewares), + ) + callActions = bindActionCreators(CallActions, store.dispatch); (getUserMedia as any).fail(false); (SocketActions.handshake as jest.Mock).mockReturnValue(jest.fn()) }) @@ -35,9 +47,8 @@ describe('reducers/alerts', () => { it('calls handshake.init when connected & got camera stream', async () => { const promise = callActions.init() socket.emit('connect') - expect(store.getActions()).toEqual([{ - type: constants.INIT_PENDING, - }, { + await promise + expect(store.getState().allActions.slice(1)).toEqual([{ type: constants.NOTIFY, payload: { id: jasmine.any(String), @@ -45,15 +56,14 @@ describe('reducers/alerts', () => { type: 'warning', }, }, { - type: constants.MESSAGE_ADD, + type: constants.STREAM_ADD, payload: { - image: null, - message: 'Connected to server socket', - timestamp: jasmine.any(String), - userId: '[PeerCalls]', + stream: jasmine.anything(), + userId: constants.ME, }, + }, { + type: constants.INIT, }]) - await promise expect((SocketActions.handshake as jest.Mock).mock.calls).toEqual([[{ socket, roomName: callId, @@ -65,23 +75,13 @@ describe('reducers/alerts', () => { const promise = callActions.init() socket.emit('connect') socket.emit('disconnect') - expect(store.getActions()).toEqual([{ - type: constants.INIT_PENDING, - }, { + expect(store.getState().allActions.slice(1)).toEqual([{ type: constants.NOTIFY, payload: { id: jasmine.any(String), message: 'Connected to server socket', type: 'warning', }, - }, { - type: constants.MESSAGE_ADD, - payload: { - image: null, - message: 'Connected to server socket', - timestamp: jasmine.any(String), - userId: '[PeerCalls]', - }, }, { type: constants.NOTIFY, payload: { @@ -89,14 +89,6 @@ describe('reducers/alerts', () => { message: 'Server socket disconnected', type: 'error', }, - }, { - type: constants.MESSAGE_ADD, - payload: { - image: null, - message: 'Server socket disconnected', - timestamp: jasmine.any(String), - userId: '[PeerCalls]', - }, }]) await promise }) diff --git a/src/client/actions/CallActions.ts b/src/client/actions/CallActions.ts index c746725..18ca3ed 100644 --- a/src/client/actions/CallActions.ts +++ b/src/client/actions/CallActions.ts @@ -4,7 +4,8 @@ import * as StreamActions from './StreamActions' import * as constants from '../constants' import socket from '../socket' import { callId, getUserMedia } from '../window' -import { Dispatch, GetState } from '../store' +import { Dispatch, GetState, ThunkResult } from '../store' +import { makeAction } from '../async' export interface InitAction { type: 'INIT' @@ -19,20 +20,21 @@ const initialize = (): InitializeAction => ({ type: 'INIT', }) -export const init = () => async (dispatch: Dispatch, getState: GetState) => { - dispatch(initialize()) +export const init = (): ThunkResult> => +async (dispatch, getState) => { + const socket = await dispatch(connect()) + const stream = await dispatch(getCameraStream()) - const socket = await connect(dispatch) - const stream = await getCameraStream(dispatch) - - SocketActions.handshake({ + dispatch(SocketActions.handshake({ socket, roomName: callId, stream, - })(dispatch, getState) + })) + + dispatch(initialize()) } -export async function connect (dispatch: Dispatch) { +export const connect = () => (dispatch: Dispatch) => { return new Promise(resolve => { socket.once('connect', () => { resolve(socket) @@ -46,7 +48,7 @@ export async function connect (dispatch: Dispatch) { }) } -export async function getCameraStream (dispatch: Dispatch) { +export const getCameraStream = () => async (dispatch: Dispatch) => { try { const stream = await getUserMedia({ video: { facingMode: 'user' }, diff --git a/src/client/actions/NotifyActions.ts b/src/client/actions/NotifyActions.ts index 72c3c16..513cd83 100644 --- a/src/client/actions/NotifyActions.ts +++ b/src/client/actions/NotifyActions.ts @@ -27,15 +27,15 @@ function notify(dispatch: Dispatch, type: NotifyType, args: string[]) { } export const info = (...args: any[]): ThunkResult => { - return dispatch => notify(dispatch, 'info', args) + return dispatch => dispatch(notify(dispatch, 'info', args)) } export const warning = (...args: any[]): ThunkResult => { - return dispatch => notify(dispatch, 'warning', args) + return dispatch => dispatch(notify(dispatch, 'warning', args)) } export const error = (...args: any[]): ThunkResult => { - return dispatch => notify(dispatch, 'error', args) + return dispatch => dispatch(notify(dispatch, 'error', args)) } function addNotification(payload: Notification): NotificationAddAction { diff --git a/src/client/async/action.ts b/src/client/async/action.ts index 4fa3865..e243757 100644 --- a/src/client/async/action.ts +++ b/src/client/async/action.ts @@ -1,4 +1,4 @@ -import { Action } from 'redux' +import { Action, Dispatch } from 'redux' export type PendingAction = Action & Promise

& { status: 'pending' @@ -49,9 +49,9 @@ export function isPendingAction( export function makeAction( type: T, impl: (...args: A) => Promise

, -): (...args: A) => PendingAction{ +): (...args: A) => PendingAction { return (...args: A) => { - const pendingAction= impl(...args) as PendingAction + const pendingAction = impl(...args) as PendingAction pendingAction.type = type pendingAction.status = 'pending' return pendingAction diff --git a/src/client/async/middleware.ts b/src/client/async/middleware.ts index cad7720..b0e0510 100644 --- a/src/client/async/middleware.ts +++ b/src/client/async/middleware.ts @@ -1,13 +1,20 @@ import { AnyAction, Middleware } from 'redux' -import { isPendingAction, ResolvedAction, PendingAction, RejectedAction } from './action' +import { isPendingAction, ResolvedAction, RejectedAction } from './action' +import _debug from 'debug' + +const debug = _debug('peercalls:async') export const middleware: Middleware = store => next => (action: AnyAction) => { if (!isPendingAction(action)) { + debug('NOT pending %o', action) return next(action) } + debug('Pending: %s %s', action.type, action.status) + const promise = action .then(payload => { + debug('Resolved: %s resolved', action.type) const resolvedAction: ResolvedAction = { payload, type: action.type, @@ -17,6 +24,7 @@ export const middleware: Middleware = store => next => (action: AnyAction) => { }) // Propagate this action. Only attach listeners to the promise. + debug('Calling next for %s %s', action.type, action.status) next({ type: action.type, status: 'pending', @@ -24,6 +32,7 @@ export const middleware: Middleware = store => next => (action: AnyAction) => { const promise2 = promise .catch((err: Error) => { + debug('Rejected: %s rejected %s', action.type, err.stack) const rejectedAction: RejectedAction = { payload: err, type: action.type, @@ -32,5 +41,7 @@ export const middleware: Middleware = store => next => (action: AnyAction) => { store.dispatch(rejectedAction) }) - return promise2.then(() => action) + return promise2.then(() => { + return action + }) } diff --git a/src/client/constants.ts b/src/client/constants.ts index 616d2a1..e433276 100644 --- a/src/client/constants.ts +++ b/src/client/constants.ts @@ -6,9 +6,6 @@ export const ALERT_DISMISS = 'ALERT_DISMISS' export const ALERT_CLEAR = 'ALERT_CLEAR' export const INIT = 'INIT' -export const INIT_PENDING = `${INIT}_PENDING` -export const INIT_FULFILLED = `${INIT}_FULFILLED` -export const INIT_REJECTED = `${INIT}_REJECTED` export const ME = '_me_' diff --git a/src/client/middlewares.ts b/src/client/middlewares.ts index 785af08..7bf52b7 100644 --- a/src/client/middlewares.ts +++ b/src/client/middlewares.ts @@ -1,8 +1,9 @@ +import { Middleware } from 'redux' import logger from 'redux-logger' -import promiseMiddleware from 'redux-promise-middleware' import thunk from 'redux-thunk' +import { middleware as asyncMiddleware } from './async' -export const middlewares = [thunk, promiseMiddleware()] +export const middlewares: Middleware[] = [thunk, asyncMiddleware] export const create = (log = false) => { const m = middlewares.slice() log && m.push(logger) diff --git a/src/client/store.ts b/src/client/store.ts index 5e069e0..476c618 100644 --- a/src/client/store.ts +++ b/src/client/store.ts @@ -1,7 +1,6 @@ import { Action, applyMiddleware, createStore as _createStore, Store as ReduxStore } from 'redux' import { ThunkAction, ThunkDispatch } from 'redux-thunk' import { create } from './middlewares' -import { middleware as asyncMiddleware }from './async' import reducers from './reducers' export const middlewares = create( @@ -10,7 +9,7 @@ export const middlewares = create( export const createStore = () => _createStore( reducers, - applyMiddleware(...middlewares, asyncMiddleware), + applyMiddleware(...middlewares), ) export default createStore() From 0075d938794364266ccf56119f27ca3e2e66144c Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 21:34:14 -0300 Subject: [PATCH 15/38] Fix simple-peer mock --- __mocks__/simple-peer.js | 12 ------------ src/__mocks__/simple-peer.ts | 14 ++++++++++++++ src/client/actions/CallActions.ts | 9 ++++----- src/client/actions/PeerActions.test.ts | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 __mocks__/simple-peer.js create mode 100644 src/__mocks__/simple-peer.ts diff --git a/__mocks__/simple-peer.js b/__mocks__/simple-peer.js deleted file mode 100644 index b274693..0000000 --- a/__mocks__/simple-peer.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable */ -import EventEmitter from 'events' -const Peer = jest.fn().mockImplementation(() => { - const peer = new EventEmitter() - peer.destroy = jest.fn() - peer.signal = jest.fn() - peer.send = jest.fn() - Peer.instances.push(peer) - return peer -}) -Peer.instances = [] -export default Peer diff --git a/src/__mocks__/simple-peer.ts b/src/__mocks__/simple-peer.ts new file mode 100644 index 0000000..5005806 --- /dev/null +++ b/src/__mocks__/simple-peer.ts @@ -0,0 +1,14 @@ +/* eslint-disable */ +import EventEmitter from 'events' + +const Peer = jest.fn().mockImplementation(() => { + const peer = new EventEmitter(); + (peer as any).destroy = jest.fn(); + (peer as any).signal = jest.fn(); + (peer as any).send = jest.fn(); + (Peer as any).instances.push(peer) + return peer +}); + +(Peer as any).instances = [] +export default Peer diff --git a/src/client/actions/CallActions.ts b/src/client/actions/CallActions.ts index 18ca3ed..3201db0 100644 --- a/src/client/actions/CallActions.ts +++ b/src/client/actions/CallActions.ts @@ -1,11 +1,10 @@ +import * as constants from '../constants' +import socket from '../socket' +import { Dispatch, ThunkResult } from '../store' +import { callId, getUserMedia } from '../window' import * as NotifyActions from './NotifyActions' import * as SocketActions from './SocketActions' import * as StreamActions from './StreamActions' -import * as constants from '../constants' -import socket from '../socket' -import { callId, getUserMedia } from '../window' -import { Dispatch, GetState, ThunkResult } from '../store' -import { makeAction } from '../async' export interface InitAction { type: 'INIT' diff --git a/src/client/actions/PeerActions.test.ts b/src/client/actions/PeerActions.test.ts index 233aefb..6b01ac4 100644 --- a/src/client/actions/PeerActions.test.ts +++ b/src/client/actions/PeerActions.test.ts @@ -111,7 +111,7 @@ describe('PeerActions', () => { expect(messages[messages.length - 1]).toEqual({ userId: 'user2', timestamp: jasmine.any(String), - image: null, + image: undefined, message: 'test', }) }) From 4659151892d805003810e6fe62a30dda6a73dcd7 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 21:35:27 -0300 Subject: [PATCH 16/38] Fix NotifyActions.test.ts --- src/client/actions/NotifyActions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/actions/NotifyActions.ts b/src/client/actions/NotifyActions.ts index 513cd83..fb9d14f 100644 --- a/src/client/actions/NotifyActions.ts +++ b/src/client/actions/NotifyActions.ts @@ -92,7 +92,7 @@ export function alert (message: string, dismissable = false): AlertAddAction { return { type: constants.ALERT, payload: { - action: dismissable ? 'Dismiss' : '', + action: dismissable ? 'Dismiss' : undefined, dismissable: !!dismissable, message, type: 'warning', From 9e8b353dea7bf7922a4c194757730b54f1878e9c Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 22:06:17 -0300 Subject: [PATCH 17/38] Fix all TypeScript tests --- src/client/components/Toolbar.tsx | 6 +++--- src/client/components/Video.test.tsx | 12 ++++++------ src/client/components/Video.tsx | 8 ++++---- src/client/window.test.ts | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/client/components/Toolbar.tsx b/src/client/components/Toolbar.tsx index 3cb1019..c53973c 100644 --- a/src/client/components/Toolbar.tsx +++ b/src/client/components/Toolbar.tsx @@ -1,4 +1,4 @@ -import React, { ReactEventHandler } from 'react' +import React, { ReactEventHandler, ChangeEvent } from 'react' import classnames from 'classnames' import screenfull from 'screenfull' import { Message } from '../actions/ChatActions' @@ -72,9 +72,9 @@ extends React.PureComponent { handleSendFile = () => { this.file.current!.click() } - handleSelectFiles: ReactEventHandler = event => { + handleSelectFiles = (event: React.ChangeEvent) => { Array - .from(this.file.current!.files!) + .from(event.target!.files!) .forEach(file => this.props.onSendFile(file)) } handleToggleChat = () => { diff --git a/src/client/components/Video.test.tsx b/src/client/components/Video.test.tsx index c55db6b..b95f487 100644 --- a/src/client/components/Video.test.tsx +++ b/src/client/components/Video.test.tsx @@ -81,8 +81,8 @@ describe('components/Video', () => { await render() }) - it('Mirrored and active propogate to rendered classes', () => { - render({ active: true, mirrored: true }) + it('Mirrored and active propogate to rendered classes', async () => { + await render({ active: true, mirrored: true }) expect(wrapper.className).toBe('video-container active mirrored') }) }) @@ -91,25 +91,25 @@ describe('components/Video', () => { describe('src', () => { beforeEach(async () => { await render() - delete video.video.current!.srcObject + delete video.videoRef.current!.srcObject }) it('updates src only when changed', () => { mediaStream = new MediaStream() component.setState({ stream: { url: 'test', stream: mediaStream, userId: '' }, }) - expect(video.video.current!.src).toBe('http://localhost/test') + expect(video.videoRef.current!.src).toBe('http://localhost/test') component.setState({ stream: { url: 'test', stream: mediaStream, userId: '' }, }) }) it('updates srcObject only when changed', () => { - video.video.current!.srcObject = null + video.videoRef.current!.srcObject = null mediaStream = new MediaStream() component.setState({ stream: { url: 'test', stream: mediaStream, userId: '' }, }) - expect(video.video.current!.srcObject).toBe(mediaStream) + expect(video.videoRef.current!.srcObject).toBe(mediaStream) component.setState({ stream: { url: 'test', stream: mediaStream, userId: '' }, }) diff --git a/src/client/components/Video.tsx b/src/client/components/Video.tsx index 82b9e0d..5ae2d2b 100644 --- a/src/client/components/Video.tsx +++ b/src/client/components/Video.tsx @@ -14,7 +14,7 @@ export interface VideoProps { } export default class Video extends React.PureComponent { - video = React.createRef() + videoRef = React.createRef() static defaultProps = { muted: false, @@ -34,10 +34,10 @@ export default class Video extends React.PureComponent { } componentDidUpdate () { const { videos, stream } = this.props - const video = this.video.current! + const video = this.videoRef.current! const mediaStream = stream && stream.stream || null const url = stream && stream.url - if (!('srcObject' in video as unknown)) { + if ('srcObject' in video as unknown) { if (video.srcObject !== mediaStream) { video.srcObject = mediaStream } @@ -57,7 +57,7 @@ export default class Video extends React.PureComponent { onClick={this.handleClick} onLoadedMetadata={this.play} playsInline - ref={this.video} + ref={this.videoRef} muted={muted} />

diff --git a/src/client/window.test.ts b/src/client/window.test.ts index 589d47c..daf6513 100644 --- a/src/client/window.test.ts +++ b/src/client/window.test.ts @@ -21,12 +21,12 @@ describe('window', () => { delete (navigator as any).webkitGetUserMedia }) - it('calls navigator.mediaDevices.getUserMedia', () => { + it('calls navigator.mediaDevices.getUserMedia', async () => { const promise = Promise.resolve(stream); (navigator as any).mediaDevices = { getUserMedia: jest.fn().mockReturnValue(promise), } - expect(getUserMedia(constraints)).toBe(promise) + expect(await getUserMedia(constraints)).toBe(stream) }) ;['getUserMedia', 'webkitGetUserMedia'].forEach((method) => { From b7f2b454ba89a77f40c4364fc3b4db7f154e3648 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 22:16:34 -0300 Subject: [PATCH 18/38] Replace underscore by lodash --- package-lock.json | 33 ++++++----------------------- package.json | 8 ++----- src/client/actions/NotifyActions.ts | 6 +++--- src/client/actions/PeerActions.ts | 4 ++-- src/client/actions/SocketActions.ts | 6 +++--- src/client/components/App.tsx | 4 ++-- src/client/reducers/alerts.test.ts | 4 ++-- src/client/reducers/peers.ts | 9 ++++---- src/client/reducers/streams.ts | 12 +++++------ src/server/socket.ts | 4 ++-- 10 files changed, 33 insertions(+), 57 deletions(-) diff --git a/package-lock.json b/package-lock.json index 86fa0de..a1d4fd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1933,12 +1933,6 @@ "@types/babel-types": "*" } }, - "@types/bluebird": { - "version": "3.5.29", - "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.29.tgz", - "integrity": "sha512-kmVtnxTuUuhCET669irqQmPAez4KFnFVKvpleVRyfC3g+SHD1hIkFZcWLim9BVcwUBLO59o8VZE4yGCmTif8Yw==", - "dev": true - }, "@types/body-parser": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz", @@ -2076,6 +2070,12 @@ "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", "dev": true }, + "@types/lodash": { + "version": "4.14.147", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.147.tgz", + "integrity": "sha512-+0zY1Axql6ru5T85Rh6aR6Zr0xT7c0USLqsHv01b3ID//dOrV3OvpXJGjm69+4QpxoZ0oMNEfmW1ltwXe2WVzQ==", + "dev": true + }, "@types/mime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz", @@ -2266,12 +2266,6 @@ "@types/superagent": "*" } }, - "@types/underscore": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.9.3.tgz", - "integrity": "sha512-SwbHKB2DPIDlvYqtK5O+0LFtZAyrUSw4c0q+HWwmH1Ve3KMQ0/5PlV3RX97+3dP7yMrnNQ8/bCWWvQpPl03Mug==", - "dev": true - }, "@types/uuid": { "version": "3.4.6", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.6.tgz", @@ -3396,11 +3390,6 @@ "inherits": "~2.0.0" } }, - "bluebird": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", - "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==" - }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", @@ -12654,11 +12643,6 @@ } } }, - "seamless-immutable": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/seamless-immutable/-/seamless-immutable-7.1.4.tgz", - "integrity": "sha512-XiUO1QP4ki4E2PHegiGAlu6r82o5A+6tRh7IkGGTVg/h+UoeX4nFBeCGPOhb4CYjvkqsfm/TUtvOMYC1xmV30A==" - }, "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", @@ -14029,11 +14013,6 @@ "debug": "^2.2.0" } }, - "underscore": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", - "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" - }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", diff --git a/package.json b/package.json index addc991..995fde1 100644 --- a/package.json +++ b/package.json @@ -51,11 +51,9 @@ "author": "Jerko Steiner", "license": "MIT", "dependencies": { - "bluebird": "^3.3.4", "classnames": "^2.2.5", "config": "^3.0.0", "express": "^4.13.3", - "prop-types": "^15.5.10", "pug": "^2.0.0-rc.2", "react": "^16.6.3", "react-dom": "^16.6.3", @@ -64,11 +62,9 @@ "redux-logger": "^3.0.6", "redux-promise-middleware": "^5.1.1", "redux-thunk": "^2.2.0", - "seamless-immutable": "^7.1.2", "simple-peer": "^9.1.2", "socket.io": "^2.2.0", "socket.io-client": "^2.2.0", - "underscore": "^1.8.3", "uuid": "^3.3.2" }, "devDependencies": { @@ -78,12 +74,12 @@ "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.5.0", "@babel/preset-react": "^7.0.0", - "@types/bluebird": "^3.5.29", "@types/classnames": "^2.2.9", "@types/config": "0.0.36", "@types/debug": "^4.1.5", "@types/express": "^4.17.2", "@types/jest": "^24.0.23", + "@types/lodash": "^4.14.147", "@types/node": "^12.12.7", "@types/react": "^16.9.11", "@types/react-dom": "^16.9.4", @@ -97,7 +93,6 @@ "@types/socket.io": "^2.1.4", "@types/socket.io-client": "^1.4.32", "@types/supertest": "^2.0.8", - "@types/underscore": "^1.9.3", "@types/uuid": "^3.4.6", "@typescript-eslint/eslint-plugin": "^2.7.0", "@typescript-eslint/parser": "^2.7.0", @@ -116,6 +111,7 @@ "eslint-plugin-standard": "^4.0.0", "jest": "^24.9.0", "jest-cli": "^24.8.0", + "lodash": "^4.17.15", "node-sass": "^4.13.0", "nodemon": "^1.18.8", "react-transition-group": "^2.5.1", diff --git a/src/client/actions/NotifyActions.ts b/src/client/actions/NotifyActions.ts index fb9d14f..3b10653 100644 --- a/src/client/actions/NotifyActions.ts +++ b/src/client/actions/NotifyActions.ts @@ -1,6 +1,6 @@ +import uniqueId from 'lodash/uniqueId' +import { Dispatch } from 'redux' import * as constants from '../constants' -import { Dispatch } from 'redux' -import _ from 'underscore' import { ThunkResult } from '../store' const TIMEOUT = 5000 @@ -16,7 +16,7 @@ export type NotifyType = 'info' | 'warning' | 'error' function notify(dispatch: Dispatch, type: NotifyType, args: string[]) { const string = args[0] || '' const message = format(string, Array.prototype.slice.call(args, 1)) - const id = _.uniqueId('notification') + const id = uniqueId('notification') const payload: Notification = { id, type, message } setTimeout(() => { diff --git a/src/client/actions/PeerActions.ts b/src/client/actions/PeerActions.ts index 70539ba..502dcbb 100644 --- a/src/client/actions/PeerActions.ts +++ b/src/client/actions/PeerActions.ts @@ -3,7 +3,7 @@ import * as NotifyActions from '../actions/NotifyActions' import * as StreamActions from '../actions/StreamActions' import * as constants from '../constants' import Peer from 'simple-peer' -import _ from 'underscore' +import forEach from 'lodash/forEach' import _debug from 'debug' import { play, iceServers } from '../window' import { Dispatch, GetState } from '../store' @@ -215,7 +215,7 @@ export const sendMessage = (message: Message) => const { peers } = getState() debug('Sending message type: %s to %s peers.', message.type, Object.keys(peers).length) - _.each(peers, (peer, userId) => { + forEach(peers, (peer, userId) => { switch (message.type) { case 'file': dispatch(ChatActions.addMessage({ diff --git a/src/client/actions/SocketActions.ts b/src/client/actions/SocketActions.ts index 7fb67c4..f164465 100644 --- a/src/client/actions/SocketActions.ts +++ b/src/client/actions/SocketActions.ts @@ -1,7 +1,7 @@ import * as NotifyActions from '../actions/NotifyActions' import * as PeerActions from '../actions/PeerActions' import * as constants from '../constants' -import _ from 'underscore' +import keyBy from 'lodash/keyBy' import _debug from 'debug' import { SignalData } from 'simple-peer' import { Dispatch, GetState } from '../store' @@ -62,8 +62,8 @@ class SocketHandler { stream, })(dispatch, getState)) - const newUsersMap = _.indexBy(users, 'id') - _.keys(peers) + const newUsersMap = keyBy(users, 'id') + Object.keys(peers) .filter(id => !newUsersMap[id]) .forEach(id => peers[id].destroy()) } diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index a80e7d6..ae32a06 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -1,6 +1,6 @@ +import map from 'lodash/map' import React from 'react' import Peer from 'simple-peer' -import _ from 'underscore' import { Message } from '../actions/ChatActions' import { Alert, Notification } from '../actions/NotifyActions' import { TextMessage } from '../actions/PeerActions' @@ -99,7 +99,7 @@ export default class App extends React.PureComponent { mirrored /> - {_.map(peers, (_, userId) => ( + {map(peers, (_, userId) => (