Build 533169stable
Module 194871
5,505 characters · in no known chunkDependencies
Required by (24)
Lazily required by (0)none
Requires (16)
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>z}),n(142703);var r=n(735438),i=n.n(r),s=n(311907),a=n(73153),o=n(77729),l=n(728071),u=n(961350),c=n(189081),d=n(645243),_=n(927813),f=n(674378),p=n(723702),h=n(144914),m=n(966846),E=n(775228),g=n(652215);let A=200,I=200,T=+_.A.Millis.MINUTE,S={},y="content",v="file://",N=!1,C=0,R=0,O=0,b=[],D=[],L=[],w=!1;function M(){N=!1}function P(e,t){return t.some(t=>t.platforms.includes(e))}function x(e){let{build_id:t,target_build_id:n,manifest_ids:r,target_manifest_ids:s,application_id:a,branch_id:l,launch_commands:u,launch_options:c,storage:_,install_path:f,installed_size:h,repairing:m}=e,{should_patch:E}=e;switch(null==E&&(E=!0),e.state.type){case g.l6E.COMPLETE:{let e,A={},I=null;if(m)e=g.WTw.REPAIRING;else if(null==t)e=g.WTw.INSTALL_REQUIRED;else if(E&&(t!==n||null!=r&&0!==i().difference(r,s).length))e=g.WTw.UPDATE_REQUIRED;else if(e=g.WTw.UP_TO_DATE,null!=f){let e=o.A.fileManager.join(f,y),t=(0,d.O)();if(null!=c&&0!==c.length){for(let n of(t!==g.lM6.WIN64||P(t,c)||(t=g.lM6.WIN32),c))if(n.platforms.includes(t)){let t,{executable:r,name:i,working_dir:s}=n,a=i,l=o.A.fileManager.join(e,r);(0,p.isMac)()&&!l.startsWith(v)&&(l=`${v}${l}`),t=null!=s?o.A.fileManager.join(e,s):o.A.fileManager.dirname(l),A[a]={...n,id:a,fullExecutablePath:l,fullWorkingDir:t},null==I&&(I=a)}}else if(null!=u){t===g.lM6.WIN64&&null==u[t]&&(t=g.lM6.WIN32);let n=u[t];if(null!=n){let{executable:r}=n,i="Default",s=i;A[s]={...n,name:i,id:s,fullExecutablePath:o.A.fileManager.join(e,r),fullWorkingDir:e,platforms:[t]},I=s}}}return{type:e,applicationId:a,branchId:l,buildId:t,manifestIds:r,targetBuildId:n,targetManifestIds:s,installPath:f,installedSize:h,launchOptions:A,defaultLaunchOptionId:I,shouldPatch:E,storage:_}}case g.l6E.TRANSITION:{let i,{stage:o,disk_progress:u,network_progress:c,reader_progress:d,progress:_,total:p,paused:A}=e.state,I=o.type;return{type:i=I===g.OQC.UNINSTALLING?g.WTw.UNINSTALLING:m?g.WTw.REPAIRING:null==t?g.WTw.INSTALLING:g.WTw.UPDATING,stage:I,applicationId:a,branchId:l,buildId:t,manifestIds:r,targetBuildId:n,targetManifestIds:s,installPath:f,installedSize:h,diskProgress:u,networkProgress:c,readerProgress:d,progress:_,total:p,paused:A,shouldPatch:E}}}throw Error(`Invalid Dispatch State. state=${e.state.type}`)}function k(e){return e.type===g.WTw.INSTALLING||e.type===g.WTw.UPDATING||e.type===g.WTw.REPAIRING?e.networkProgress:null}function U(e){return e.type===g.WTw.INSTALLING||e.type===g.WTw.UPDATING||e.type===g.WTw.REPAIRING?e.diskProgress:null}function G(e){return e.type===g.WTw.INSTALLING||e.type===g.WTw.UPDATING||e.type===g.WTw.REPAIRING?e.readerProgress:null}function F(e){D=(D=[{bytes:e,timestamp:Date.now()},...D]).slice(0,I)}function V(e){let t=Date.now(),n=t-T;b=(b=[{bytes:e,timestamp:t},...b]).slice(0,I).filter(e=>{let{timestamp:t}=e;return t>=n})}function B(e){L=(L=[{bytes:e,timestamp:Date.now()},...L]).slice(0,I)}let H=i().throttle(F,A),j=i().throttle(V,A),Y=i().throttle(B,A);function W(e,t,n){let r=n(S[t]),i=n(e[t]);return null!=r&&null!=i&&0!==r?Math.max(i-r,0):0}function K(e){let{state:t}=e;N=!0;let n={},r=t.applications,i=null!=t.currentTask?t.currentTask.branchId:null,s=!1;for(let e in r)for(let t in r[e]){let u=(0,f.gW)(e,t);if(n[u]=x(r[e][t]),null!=S[u]){let e=W(n,u,k);e>0&&H(C+=e);let r=W(n,u,U);r>0&&Y(R+=r);let a=W(n,u,G);if(a>0&&j(O+=a),i===t){let e=n[u];if(!0!==e.paused&&(e.type===g.WTw.UNINSTALLING||e.type===g.WTw.INSTALLING||e.type===g.WTw.UPDATING))switch(e.stage){case g.OQC.PATCHING:case g.OQC.FINALIZING:case g.OQC.VERIFYING:case g.OQC.REPAIRING:case g.OQC.POST_INSTALL_SCRIPTS:l.A.setProgress("dispatch_application_progress",(0,f.uA)(e.progress,e.total)/100),s=!0}}}if(!w){let r=o.A.fileManager.dirname(n[u].installPath);E.A.getInstallationPath(e,t)!==r&&a.h.wait(()=>{a.h.dispatch({type:"DISPATCH_APPLICATION_ADD_TO_INSTALLATIONS",applicationId:e,branchId:t,installationPath:r})}),-1===m.A.getQueuePosition(e,t)&&(n[u].type===g.WTw.INSTALLING||n[u].type===g.WTw.UPDATING)&&c.A.hasApplication(e,t)&&E.A.shouldBeInstalled(e,t)&&a.h.wait(()=>{a.h.dispatch({type:"DISPATCH_APPLICATION_UPDATE",applicationId:e,branchId:t,automatic:!0})})}}s||"dispatch_application_progress"!==l.A.taskID||l.A.clearProgress("dispatch_application_progress"),S=n,w=!0}class $ extends s.Ay.Store{static displayName="DispatchApplicationStore";initialize(){this.waitFor(u.default)}getState(e,t){return S[(0,f.gW)(e,t)]}isUpToDate(e,t){let n=S[(0,f.gW)(e,t)];return null!=n&&n.type===g.WTw.UP_TO_DATE}shouldPatch(e,t){let n=S[(0,f.gW)(e,t)];return null!=n&&!0===n.shouldPatch}isInstalled(e,t){let n=S[(0,f.gW)(e,t)];return null!=n?n.type!==g.WTw.UNINSTALLING:E.A.shouldBeInstalled(e,t)}supportsCloudSync(e,t){null==t&&(t=e);let n=S[(0,f.gW)(e,t)];return null!=n&&null!=n.storage&&!!n.storage.sync}isLaunchable(e,t){if(!(0,h.S)())return!1;let n=S[(0,f.gW)(e,t)];return null!=n&&n.type===g.WTw.UP_TO_DATE&&null!=n.launchOptions&&0!==n.launchOptions.length}getDefaultLaunchOption(e,t){let n=S[(0,f.gW)(e,t)];if(null==n)return null;let{defaultLaunchOptionId:r,launchOptions:i}=n;return null==r||null==i?null:i[r]}getLaunchOptions(e,t){let n=S[(0,f.gW)(e,t)];return null==n||null==n.launchOptions?[]:Object.values(n.launchOptions)}getHistoricalTotalBytesRead(){return b}getHistoricalTotalBytesDownloaded(){return D}getHistoricalTotalBytesWritten(){return L}whenInitialized(e){this.addConditionalChangeListener(()=>{if(N)return setImmediate(e),!1})}}let z=new $(a.h,{CONNECTION_OPEN:M,DISPATCH_APPLICATION_STATE_UPDATE:K})}