feat: add some funcs

This commit is contained in:
lucasdpt
2026-06-14 14:23:37 +02:00
parent 48fa508540
commit 4756420f8d
11 changed files with 240 additions and 44 deletions
+16 -6
View File
@@ -4,6 +4,9 @@ import { paths } from './paths'
import { config } from '../shared/config'
import { fetchText } from './download'
import { emit } from './events'
import type { PackMeta } from '../shared/ipc'
export type { PackMeta }
/**
* Gestion du modpack côté launcher :
@@ -15,11 +18,17 @@ import { emit } from './events'
* comportement "pas de re-download complet à chaque update" recherché.
*/
export interface PackMeta {
name: string
version: string
minecraft: string
neoforge: string
/** Dernière PackMeta lue avec succès (pour l'affichage UI, y compris hors flux Jouer). */
let lastMeta: PackMeta | null = null
/** Renvoie la dernière PackMeta connue, ou la récupère si jamais lue. Tolérant au offline. */
export async function getPackMetaCached(): Promise<PackMeta | null> {
if (lastMeta) return lastMeta
try {
return await fetchPackMeta()
} catch {
return null
}
}
/** Télécharge et parse le pack.toml distant. */
@@ -47,12 +56,13 @@ export async function fetchPackMeta(): Promise<PackMeta> {
)
}
return {
lastMeta = {
name: data.name ?? 'Modpack',
version: data.version ?? '0',
minecraft,
neoforge
}
return lastMeta
}
/**