Skip to content

Commit 584f5be

Browse files
committed
feat(launcher): save code
1 parent 9b13f75 commit 584f5be

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
import { fetch } from "@tauri-apps/plugin-http";
2+
13
import type { LaunchStatusType } from "@/types/launcher/launch-status.type.ts";
4+
import type { VersionMetadataType } from "@/types/launcher/version-metadata.type.ts";
25

36
export async function getVersionMetadata({
47
changeStatus,
58
url,
69
}: {
710
"changeStatus": (newStatus: LaunchStatusType) => void;
811
"url" : string;
9-
}): object {}
12+
}): Promise<{
13+
"updateCache": boolean;
14+
"metadata" : VersionMetadataType;
15+
}> {
16+
const response = await fetch(url);
17+
const data = await response.json();
18+
19+
return {
20+
"updateCache": true,
21+
"metadata" : data,
22+
};
23+
}

src/lib/launcher/scopes/launch-with-checks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getManifestV2 } from "@/lib/launcher/scopes/get-manifest-v2.ts";
1111
import { getVersionMetadata } from "@/lib/launcher/scopes/get-version-metadata.ts";
1212
import type { LaunchStatusType } from "@/types/launcher/launch-status.type.ts";
1313
import type { ManifestV2Type } from "@/types/launcher/manifest-v2.type.ts";
14+
import type { VersionMetadataType } from "@/types/launcher/version-metadata.type.ts";
1415

1516
export async function launchWithChecks({
1617
instanceId,
@@ -39,13 +40,15 @@ export async function launchWithChecks({
3940
return changeStatus(LaunchStatus.Errors.VersionNotFoundInManifestV2);
4041
}
4142

42-
const [versionMetadata]: [object, void] = await Promise.all([
43+
const [versionMetadata]: [VersionMetadataType, void] = await Promise.all([
4344
getVersionMetadata({
4445
changeStatus,
4546
"url": manifestVersion.url,
4647
}),
4748
cacheManifestV2({ updateCache, manifest, cachedManifestV2Path }),
4849
]);
4950

51+
const assetIndex = versionMetadata.assetIndex;
52+
5053
return;
5154
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type {
2+
ManifestV2ComplianceLevel,
3+
ManifestV2VersionType,
4+
} from "@/types/launcher/manifest-v2.type.ts";
5+
6+
export type VersionArgumentsType = {
7+
"game": Array<string>;
8+
"jvm" : Array<string>;
9+
};
10+
export type VersionAssetIndexType = {
11+
"id" : string;
12+
"sha1" : string;
13+
"size" : number;
14+
"totalSize": number;
15+
"url" : string;
16+
};
17+
export type VersionDownloadsType = {
18+
"client": {
19+
"sha1": string;
20+
};
21+
"client_mappings": {};
22+
"server" : {};
23+
"server_mappings": {};
24+
};
25+
export type VersionMetadataType = {
26+
"arguments" : VersionArgumentsType;
27+
"assetIndex" : VersionAssetIndexType;
28+
"assets" : VersionAssetIndexType["id"];
29+
"complianceLevel" : ManifestV2ComplianceLevel;
30+
"downloads" : {};
31+
"id" : string;
32+
"javaVersion" : {};
33+
"libraries" : Array<{}>;
34+
"logging" : {};
35+
"mainClass" : string;
36+
"minimumLauncherVersion": number;
37+
"releaseTime" : string;
38+
"time" : string;
39+
"type" : ManifestV2VersionType;
40+
};

0 commit comments

Comments
 (0)