okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
361c8d94a
main
1export interface DownloadProgress { percent ?:number ; done_gb ?:number ; total_gb ?:number ; remaining_gb ?:number ; file ?:string } 2/** The native installer reports each shard, not whole-model progress. */ 3export function downloadCounter ( size :number | undefined , progress :DownloadProgress | undefined , running :boolean ){ 4if ( running && progress ?. file === 'checking files' ) return { value :undefined , label :'Preparing files…' , key :'preparing' }; // nothing is downloaded while setup checks the files (DL99) 5if ( running && progress ){ 6if ( Number . isFinite ( progress . remaining_gb )) return { value :Math . max ( 0 , progress . remaining_gb ! ), label :'GB left to download' , key :'total' }; 7if ( Number . isFinite ( progress . total_gb ) && Number . isFinite ( progress . done_gb )) return { value :Math . max ( 0 , progress . total_gb !- progress . done_gb ! ), label :'GB left in this file' , key :progress . file ?? 'file' }; 8if ( Number . isFinite ( progress . total_gb ) && Number . isFinite ( progress . percent )) return { value :Math . max ( 0 , progress . total_gb !* ( 1 - Math . min ( 100 , Math . max ( 0 , progress . percent ! )) / 100 )), label :'GB left in this file' , key :progress . file ?? 'file' }; 9} 10return running ?{ value :undefined , label :progress ?'Downloading…' :'Preparing files…' , key :'preparing' } :{ value :size , label :'GB to download' , key :'size' }; 11} 12/** The setup wizard moves on from its download page only when the model is ready. An install that ended with every file in, for a model that is not ready 13* because the engine for this PC is missing or can't be used, left the page at its last figure (99%) with no word (DL99): it then says so, with the next step. */ 14export function engineNotReadyAfterInstall ( installState :string | undefined , modelReady :boolean | undefined , engineUsable :boolean | undefined ){ 15return installState === 'done' && modelReady !== true && engineUsable === false ; 16} 17export function onboardingError ( message :string ){ 18if ( / (?:not enough.*(?:disk|storage)|disk.*(?:space|full)|ENOSPC) / i . test ( message )){ 19const needed = message . match ( / (?:about\s+)?([\d.]+)\s*GB\s+(?:needed|required) / i )?.[ 1 ]; 20const free = message . match ( / ([\d.]+)\s*GB\s+(?:free|available) / i )?.[ 1 ]; 21return { title :'You need more storage.' , message :needed ?`This model needs about ${ needed } GB. ${ free ? ` You have ${ free } GB free.` : '' } ` :'There isn’t enough free space to download this model.' , next :'Choose another folder or a smaller model.' , storage :true }; 22} 23return { title :'Something needs your attention.' , message, next :undefined , storage :false }; 24} 25export function modelFolderLabel ( path :string ){ 26return / [\\/]Documents[\\/]Strata[\\/]Models[\\/]?$ / i . test ( path ) ?'Documents / Strata / Models' :path ; 27}