@loontail/minecraft-kit 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/index.cjs +5037 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +2 -0
- package/dist/cli/{index.js → index.mjs} +2 -2
- package/dist/cli/index.mjs.map +1 -0
- package/dist/index.cjs +3804 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1714 -0
- package/dist/{index.js → index.mjs} +2 -2
- package/dist/index.mjs.map +1 -0
- package/package.json +26 -26
- package/dist/cli/index.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1714 @@
|
|
|
1
|
+
/** Pluggable in-memory cache for HTTP metadata responses. */
|
|
2
|
+
interface MetadataCache {
|
|
3
|
+
get<T>(key: string): T | undefined;
|
|
4
|
+
set<T>(key: string, value: T, ttlMs?: number): void;
|
|
5
|
+
delete(key: string): void;
|
|
6
|
+
clear(): void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Subset of fetch headers the library actually uses. */
|
|
10
|
+
type HttpHeaders = Readonly<Record<string, string>>;
|
|
11
|
+
/** Response delivered by the {@link HttpClient} interface. */
|
|
12
|
+
interface HttpResponse {
|
|
13
|
+
readonly status: number;
|
|
14
|
+
readonly headers: HttpHeaders;
|
|
15
|
+
readonly url: string;
|
|
16
|
+
text(): Promise<string>;
|
|
17
|
+
json<T = unknown>(): Promise<T>;
|
|
18
|
+
bytes(): Promise<Uint8Array>;
|
|
19
|
+
/** Stream the body. The stream may be consumed at most once. */
|
|
20
|
+
stream(): AsyncIterable<Uint8Array>;
|
|
21
|
+
}
|
|
22
|
+
/** Options for an HTTP request. */
|
|
23
|
+
interface HttpRequestOptions {
|
|
24
|
+
readonly headers?: HttpHeaders;
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
readonly timeoutMs?: number;
|
|
27
|
+
/** When true, do not consult the in-memory cache. */
|
|
28
|
+
readonly noCache?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pluggable HTTP client. The default implementation uses Node's built-in fetch; consumers
|
|
32
|
+
* can inject a fake (e.g. for tests) by passing an `httpClient` to the {@link MinecraftKit}
|
|
33
|
+
* constructor.
|
|
34
|
+
*/
|
|
35
|
+
interface HttpClient {
|
|
36
|
+
request(url: string, options?: HttpRequestOptions): Promise<HttpResponse>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Minecraft release channels matching the `type` field of Mojang version manifest entries.
|
|
41
|
+
*/
|
|
42
|
+
declare const MinecraftChannels: {
|
|
43
|
+
readonly RELEASE: "release";
|
|
44
|
+
readonly SNAPSHOT: "snapshot";
|
|
45
|
+
readonly OLD_BETA: "old_beta";
|
|
46
|
+
readonly OLD_ALPHA: "old_alpha";
|
|
47
|
+
};
|
|
48
|
+
/** Channel literal as it appears in version manifest entries. */
|
|
49
|
+
type MinecraftChannel = (typeof MinecraftChannels)[keyof typeof MinecraftChannels];
|
|
50
|
+
/**
|
|
51
|
+
* One entry from the top-level Minecraft `version_manifest_v2.json` listing.
|
|
52
|
+
*
|
|
53
|
+
* Note: this is a summary entry, not the full per-version manifest. Use
|
|
54
|
+
* {@link ResolvedMinecraft} for the resolved/parsed full manifest.
|
|
55
|
+
*/
|
|
56
|
+
interface MinecraftVersionSummary {
|
|
57
|
+
/** Version id (e.g. `"1.20.1"`). */
|
|
58
|
+
readonly id: string;
|
|
59
|
+
/** Release channel. */
|
|
60
|
+
readonly type: MinecraftChannel;
|
|
61
|
+
/** URL to the per-version manifest JSON. */
|
|
62
|
+
readonly url: string;
|
|
63
|
+
/** Manifest's last edit time (ISO-8601). */
|
|
64
|
+
readonly time: string;
|
|
65
|
+
/** Original release time (ISO-8601). */
|
|
66
|
+
readonly releaseTime: string;
|
|
67
|
+
/** SHA-1 of the per-version manifest (added in v2). */
|
|
68
|
+
readonly sha1: string;
|
|
69
|
+
/** Compliance level: 0 = legacy, 1 = secure-chat / safety features. */
|
|
70
|
+
readonly complianceLevel: number;
|
|
71
|
+
}
|
|
72
|
+
/** Subset of the per-version manifest used by resolvers and consumers. */
|
|
73
|
+
interface MinecraftVersionManifest {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly type: MinecraftChannel | string;
|
|
76
|
+
readonly mainClass: string;
|
|
77
|
+
/** Asset index reference. */
|
|
78
|
+
readonly assetIndex: AssetIndexReference;
|
|
79
|
+
/** Asset index id (also exposed for legacy callers). */
|
|
80
|
+
readonly assets: string;
|
|
81
|
+
readonly downloads: MinecraftDownloads;
|
|
82
|
+
readonly libraries: readonly MinecraftLibrary[];
|
|
83
|
+
/** Modern (1.13+) argument structure. Mutually exclusive with {@link minecraftArguments}. */
|
|
84
|
+
readonly arguments?: MinecraftArguments;
|
|
85
|
+
/** Legacy (≤1.12.2) argument string. Mutually exclusive with {@link arguments}. */
|
|
86
|
+
readonly minecraftArguments?: string;
|
|
87
|
+
readonly javaVersion?: MinecraftJavaVersion;
|
|
88
|
+
readonly logging?: MinecraftLogging;
|
|
89
|
+
readonly inheritsFrom?: string;
|
|
90
|
+
readonly releaseTime?: string;
|
|
91
|
+
readonly time?: string;
|
|
92
|
+
readonly minimumLauncherVersion?: number;
|
|
93
|
+
readonly complianceLevel?: number;
|
|
94
|
+
}
|
|
95
|
+
/** Reference to the asset-index JSON file. */
|
|
96
|
+
interface AssetIndexReference {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly sha1: string;
|
|
99
|
+
readonly size: number;
|
|
100
|
+
readonly totalSize: number;
|
|
101
|
+
readonly url: string;
|
|
102
|
+
}
|
|
103
|
+
/** Per-platform downloads block of the Minecraft per-version manifest. */
|
|
104
|
+
interface MinecraftDownloads {
|
|
105
|
+
readonly client: ArtifactDownload;
|
|
106
|
+
readonly server?: ArtifactDownload;
|
|
107
|
+
readonly client_mappings?: ArtifactDownload;
|
|
108
|
+
readonly server_mappings?: ArtifactDownload;
|
|
109
|
+
}
|
|
110
|
+
/** A single hash-verified download. */
|
|
111
|
+
interface ArtifactDownload {
|
|
112
|
+
readonly sha1: string;
|
|
113
|
+
readonly size: number;
|
|
114
|
+
readonly url: string;
|
|
115
|
+
}
|
|
116
|
+
/** Library entry. Combines vanilla, modern-natives, and legacy-classifier shapes. */
|
|
117
|
+
interface MinecraftLibrary {
|
|
118
|
+
readonly name: string;
|
|
119
|
+
readonly downloads?: MinecraftLibraryDownloads;
|
|
120
|
+
readonly natives?: Readonly<Record<string, string>>;
|
|
121
|
+
readonly extract?: {
|
|
122
|
+
readonly exclude?: readonly string[];
|
|
123
|
+
};
|
|
124
|
+
readonly rules?: readonly LibraryRule[];
|
|
125
|
+
/** Some Fabric/Forge libraries carry only a Maven base URL plus a coordinate. */
|
|
126
|
+
readonly url?: string;
|
|
127
|
+
}
|
|
128
|
+
/** Library downloads block. */
|
|
129
|
+
interface MinecraftLibraryDownloads {
|
|
130
|
+
readonly artifact?: LibraryArtifact;
|
|
131
|
+
readonly classifiers?: Readonly<Record<string, LibraryArtifact>>;
|
|
132
|
+
}
|
|
133
|
+
/** An individual library artifact (jar/zip). */
|
|
134
|
+
interface LibraryArtifact extends ArtifactDownload {
|
|
135
|
+
readonly path: string;
|
|
136
|
+
}
|
|
137
|
+
/** Rule entry used by libraries and modern arguments. */
|
|
138
|
+
interface LibraryRule {
|
|
139
|
+
readonly action: "allow" | "disallow";
|
|
140
|
+
readonly os?: {
|
|
141
|
+
readonly name?: string;
|
|
142
|
+
readonly arch?: string;
|
|
143
|
+
readonly version?: string;
|
|
144
|
+
};
|
|
145
|
+
readonly features?: Readonly<Record<string, boolean>>;
|
|
146
|
+
}
|
|
147
|
+
/** Modern (1.13+) arguments structure. */
|
|
148
|
+
interface MinecraftArguments {
|
|
149
|
+
readonly game: readonly ArgumentEntry[];
|
|
150
|
+
readonly jvm: readonly ArgumentEntry[];
|
|
151
|
+
}
|
|
152
|
+
/** A single argument entry: bare string or rule-gated value. */
|
|
153
|
+
type ArgumentEntry = string | {
|
|
154
|
+
readonly rules: readonly LibraryRule[];
|
|
155
|
+
readonly value: string | readonly string[];
|
|
156
|
+
};
|
|
157
|
+
/** Required Java runtime descriptor from the version manifest. */
|
|
158
|
+
interface MinecraftJavaVersion {
|
|
159
|
+
/** Mojang java-runtime component name (e.g. `java-runtime-gamma`). */
|
|
160
|
+
readonly component: string;
|
|
161
|
+
readonly majorVersion: number;
|
|
162
|
+
}
|
|
163
|
+
/** Logging-config entry from the version manifest. */
|
|
164
|
+
interface MinecraftLogging {
|
|
165
|
+
readonly client?: {
|
|
166
|
+
readonly argument: string;
|
|
167
|
+
readonly file: ArtifactDownload & {
|
|
168
|
+
readonly id: string;
|
|
169
|
+
};
|
|
170
|
+
readonly type: string;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Fully resolved Minecraft version: summary + parsed manifest, ready to feed into
|
|
175
|
+
* `kit.targets.create` or `kit.install.plan`.
|
|
176
|
+
*/
|
|
177
|
+
interface ResolvedMinecraft {
|
|
178
|
+
/** Version id (e.g. `"1.20.1"`). */
|
|
179
|
+
readonly version: string;
|
|
180
|
+
readonly channel: MinecraftChannel;
|
|
181
|
+
readonly manifest: MinecraftVersionManifest;
|
|
182
|
+
readonly summary: MinecraftVersionSummary;
|
|
183
|
+
}
|
|
184
|
+
/** Asset index document body. */
|
|
185
|
+
interface AssetIndexDocument {
|
|
186
|
+
readonly objects: Readonly<Record<string, AssetObject>>;
|
|
187
|
+
readonly virtual?: boolean;
|
|
188
|
+
readonly map_to_resources?: boolean;
|
|
189
|
+
}
|
|
190
|
+
/** A single asset object hash + size. */
|
|
191
|
+
interface AssetObject {
|
|
192
|
+
readonly hash: string;
|
|
193
|
+
readonly size: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Summary entry from `/v2/versions/loader`. */
|
|
197
|
+
interface FabricLoaderSummary {
|
|
198
|
+
readonly version: string;
|
|
199
|
+
readonly stable: boolean;
|
|
200
|
+
readonly maven: string;
|
|
201
|
+
readonly build: number;
|
|
202
|
+
readonly separator: string;
|
|
203
|
+
}
|
|
204
|
+
/** Compatibility entry from `/v2/versions/loader/{minecraftVersion}`. */
|
|
205
|
+
interface FabricCompatibilityEntry {
|
|
206
|
+
readonly loader: FabricLoaderSummary;
|
|
207
|
+
readonly intermediary: {
|
|
208
|
+
readonly version: string;
|
|
209
|
+
readonly maven: string;
|
|
210
|
+
readonly stable: boolean;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/** Fabric profile JSON returned by `/v2/versions/loader/{mc}/{loader}/profile/json`. */
|
|
214
|
+
interface FabricProfile {
|
|
215
|
+
readonly id: string;
|
|
216
|
+
readonly inheritsFrom: string;
|
|
217
|
+
readonly type: string;
|
|
218
|
+
readonly mainClass: string;
|
|
219
|
+
readonly libraries: readonly MinecraftLibrary[];
|
|
220
|
+
readonly arguments?: {
|
|
221
|
+
readonly game?: readonly string[];
|
|
222
|
+
readonly jvm?: readonly string[];
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/** Resolved Fabric loader for a specific Minecraft version. */
|
|
226
|
+
interface ResolvedFabricLoader {
|
|
227
|
+
readonly type: typeof Loaders.FABRIC;
|
|
228
|
+
readonly minecraftVersion: string;
|
|
229
|
+
readonly loaderVersion: string;
|
|
230
|
+
readonly profile: FabricProfile;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** A Forge build entry derived from the Maven metadata XML. */
|
|
234
|
+
interface ForgeBuildSummary {
|
|
235
|
+
/** Full Maven version string e.g. `"1.20.1-47.2.0"`. */
|
|
236
|
+
readonly fullVersion: string;
|
|
237
|
+
/** Minecraft version e.g. `"1.20.1"`. */
|
|
238
|
+
readonly minecraftVersion: string;
|
|
239
|
+
/** The portion after the first dash, including any branch suffix. */
|
|
240
|
+
readonly forgeVersion: string;
|
|
241
|
+
/** True when this build is the recommended one per `promotions_slim.json`. */
|
|
242
|
+
readonly isRecommended: boolean;
|
|
243
|
+
/** True when this build is the latest one per `promotions_slim.json`. */
|
|
244
|
+
readonly isLatest: boolean;
|
|
245
|
+
}
|
|
246
|
+
/** Modern Forge `install_profile.json` (spec 1) shape — only fields we actually consume. */
|
|
247
|
+
interface ForgeInstallProfile {
|
|
248
|
+
readonly spec: number;
|
|
249
|
+
readonly profile: string;
|
|
250
|
+
readonly version: string;
|
|
251
|
+
readonly minecraft: string;
|
|
252
|
+
readonly path?: string | null;
|
|
253
|
+
readonly json: string;
|
|
254
|
+
readonly logo?: string;
|
|
255
|
+
readonly welcome?: string;
|
|
256
|
+
readonly data: Readonly<Record<string, ForgeProfileData>>;
|
|
257
|
+
readonly libraries: readonly MinecraftLibrary[];
|
|
258
|
+
readonly processors: readonly ForgeProcessor[];
|
|
259
|
+
readonly serverJarPath?: string;
|
|
260
|
+
}
|
|
261
|
+
/** Side-keyed data value pair. */
|
|
262
|
+
interface ForgeProfileData {
|
|
263
|
+
readonly client: string;
|
|
264
|
+
readonly server: string;
|
|
265
|
+
}
|
|
266
|
+
/** A single processor invocation. */
|
|
267
|
+
interface ForgeProcessor {
|
|
268
|
+
readonly sides?: readonly ("client" | "server" | "extract")[];
|
|
269
|
+
readonly jar: string;
|
|
270
|
+
readonly classpath: readonly string[];
|
|
271
|
+
readonly args: readonly string[];
|
|
272
|
+
readonly outputs?: Readonly<Record<string, string>>;
|
|
273
|
+
}
|
|
274
|
+
/** The version.json stored inside the Forge installer JAR. */
|
|
275
|
+
interface ForgeVersionJson {
|
|
276
|
+
readonly id: string;
|
|
277
|
+
readonly inheritsFrom: string;
|
|
278
|
+
readonly type: string;
|
|
279
|
+
readonly mainClass: string;
|
|
280
|
+
readonly libraries: readonly MinecraftLibrary[];
|
|
281
|
+
readonly arguments?: {
|
|
282
|
+
readonly game?: readonly string[];
|
|
283
|
+
readonly jvm?: readonly string[];
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/** Resolved Forge loader. */
|
|
287
|
+
interface ResolvedForgeLoader {
|
|
288
|
+
readonly type: typeof Loaders.FORGE;
|
|
289
|
+
readonly minecraftVersion: string;
|
|
290
|
+
readonly forgeVersion: string;
|
|
291
|
+
readonly fullVersion: string;
|
|
292
|
+
readonly installerUrl: string;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Trivial loader used when no mod loader is in play. Carries the resolved Minecraft so the
|
|
297
|
+
* launch composer has a uniform view across vanilla / Fabric / Forge.
|
|
298
|
+
*/
|
|
299
|
+
interface ResolvedVanillaLoader {
|
|
300
|
+
readonly type: typeof Loaders.VANILLA;
|
|
301
|
+
/** Minecraft version this loader is pinned to. */
|
|
302
|
+
readonly minecraftVersion: string;
|
|
303
|
+
/** The Minecraft manifest used for launch — same as the target's `minecraft.manifest`. */
|
|
304
|
+
readonly minecraft: ResolvedMinecraft;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Discriminator literal identifying which mod loader is active for a target.
|
|
309
|
+
*
|
|
310
|
+
* Use the {@link Loaders} const object instead of bare strings. `loader.type === Loaders.FABRIC`
|
|
311
|
+
* is preferred over `loader.type === "fabric"`.
|
|
312
|
+
*/
|
|
313
|
+
declare const Loaders: {
|
|
314
|
+
/** Plain vanilla Minecraft, no mod loader. */
|
|
315
|
+
readonly VANILLA: "vanilla";
|
|
316
|
+
/** Fabric mod loader. */
|
|
317
|
+
readonly FABRIC: "fabric";
|
|
318
|
+
/** Modern (1.13+) Forge mod loader. */
|
|
319
|
+
readonly FORGE: "forge";
|
|
320
|
+
};
|
|
321
|
+
/** Loader-kind literal (used as discriminator on loader objects). */
|
|
322
|
+
type LoaderKind = (typeof Loaders)[keyof typeof Loaders];
|
|
323
|
+
/**
|
|
324
|
+
* A fully resolved loader pinned to a specific Minecraft version. Use the `type` field to
|
|
325
|
+
* narrow to the concrete shape.
|
|
326
|
+
*/
|
|
327
|
+
type Loader = ResolvedVanillaLoader | ResolvedFabricLoader | ResolvedForgeLoader;
|
|
328
|
+
/**
|
|
329
|
+
* Resolution preference used when a user wants the latest, recommended, or a specific version.
|
|
330
|
+
* Preferences are inputs to resolvers; resolved targets always carry concrete versions.
|
|
331
|
+
*/
|
|
332
|
+
declare const VersionPreference: {
|
|
333
|
+
readonly LATEST: "latest";
|
|
334
|
+
readonly RECOMMENDED: "recommended";
|
|
335
|
+
};
|
|
336
|
+
/** Resolution-preference literal. */
|
|
337
|
+
type VersionPreferenceKind = (typeof VersionPreference)[keyof typeof VersionPreference];
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Operating-system identifiers used by Mojang launcher metadata.
|
|
341
|
+
*
|
|
342
|
+
* Mojang manifests use `windows`, `osx`, and `linux` as canonical names. These differ
|
|
343
|
+
* from Node's {@link NodeJS.Platform} values (`win32` / `darwin` / `linux`).
|
|
344
|
+
*/
|
|
345
|
+
declare const OperatingSystems: {
|
|
346
|
+
readonly WINDOWS: "windows";
|
|
347
|
+
readonly OSX: "osx";
|
|
348
|
+
readonly LINUX: "linux";
|
|
349
|
+
};
|
|
350
|
+
/** OS literal as used inside Mojang/Forge/Fabric JSON manifests. */
|
|
351
|
+
type OperatingSystem = (typeof OperatingSystems)[keyof typeof OperatingSystems];
|
|
352
|
+
/**
|
|
353
|
+
* CPU architecture identifiers. Matches the values that appear in Mojang library `os.arch`
|
|
354
|
+
* fields, after normalization from Node's {@link NodeJS.Architecture}.
|
|
355
|
+
*/
|
|
356
|
+
declare const Architectures: {
|
|
357
|
+
readonly X86: "x86";
|
|
358
|
+
readonly X64: "x64";
|
|
359
|
+
readonly ARM64: "arm64";
|
|
360
|
+
};
|
|
361
|
+
/** Architecture literal used in launcher metadata. */
|
|
362
|
+
type Architecture = (typeof Architectures)[keyof typeof Architectures];
|
|
363
|
+
/**
|
|
364
|
+
* Identifies the host system for the launcher. All resolvers consume this object to
|
|
365
|
+
* pick the right artifacts (libraries, natives, runtime).
|
|
366
|
+
*/
|
|
367
|
+
interface RuntimeSystem {
|
|
368
|
+
/** OS identifier (mojang naming). */
|
|
369
|
+
readonly os: OperatingSystem;
|
|
370
|
+
/** CPU architecture (mojang naming). */
|
|
371
|
+
readonly arch: Architecture;
|
|
372
|
+
/** OS version string from `os.release()`. Used to evaluate library `os.version` regex rules. */
|
|
373
|
+
readonly osVersion: string;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Mojang Java-runtime component identifiers. New components appear over time
|
|
378
|
+
* (e.g. `java-runtime-delta` for Java 21).
|
|
379
|
+
*
|
|
380
|
+
* The launcher must respect the `javaVersion.component` field declared by the per-version
|
|
381
|
+
* Minecraft manifest. This list captures the set we have direct knowledge about; unknown
|
|
382
|
+
* components are still allowed and resolved dynamically against the runtime index.
|
|
383
|
+
*/
|
|
384
|
+
declare const RuntimeComponents: {
|
|
385
|
+
readonly JRE_LEGACY: "jre-legacy";
|
|
386
|
+
readonly JAVA_RUNTIME_ALPHA: "java-runtime-alpha";
|
|
387
|
+
readonly JAVA_RUNTIME_BETA: "java-runtime-beta";
|
|
388
|
+
readonly JAVA_RUNTIME_GAMMA: "java-runtime-gamma";
|
|
389
|
+
readonly JAVA_RUNTIME_GAMMA_SNAPSHOT: "java-runtime-gamma-snapshot";
|
|
390
|
+
readonly JAVA_RUNTIME_DELTA: "java-runtime-delta";
|
|
391
|
+
readonly JAVA_RUNTIME_EPSILON: "java-runtime-epsilon";
|
|
392
|
+
readonly MINECRAFT_JAVA_EXE: "minecraft-java-exe";
|
|
393
|
+
};
|
|
394
|
+
/** Runtime component literal. */
|
|
395
|
+
type RuntimeComponent = string;
|
|
396
|
+
/** User-supplied resolution preferences. */
|
|
397
|
+
declare const RuntimePreference: {
|
|
398
|
+
/** Component declared by the Minecraft manifest. */
|
|
399
|
+
readonly RECOMMENDED: "recommended";
|
|
400
|
+
/** Newest component available for the platform. */
|
|
401
|
+
readonly LATEST: "latest";
|
|
402
|
+
};
|
|
403
|
+
/** Runtime preference literal. */
|
|
404
|
+
type RuntimePreferenceKind = (typeof RuntimePreference)[keyof typeof RuntimePreference];
|
|
405
|
+
/** Top-level runtime index returned by Mojang. */
|
|
406
|
+
type RuntimeIndex = Readonly<Record<string, RuntimeIndexPlatform>>;
|
|
407
|
+
/** Per-platform component map inside the runtime index. */
|
|
408
|
+
type RuntimeIndexPlatform = Readonly<Record<string, readonly RuntimeIndexEntry[]>>;
|
|
409
|
+
/** A single available runtime release. */
|
|
410
|
+
interface RuntimeIndexEntry {
|
|
411
|
+
readonly availability: {
|
|
412
|
+
readonly group: number;
|
|
413
|
+
readonly progress: number;
|
|
414
|
+
};
|
|
415
|
+
readonly manifest: {
|
|
416
|
+
readonly sha1: string;
|
|
417
|
+
readonly size: number;
|
|
418
|
+
readonly url: string;
|
|
419
|
+
};
|
|
420
|
+
readonly version: {
|
|
421
|
+
readonly name: string;
|
|
422
|
+
readonly released: string;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/** Inner per-component file manifest. */
|
|
426
|
+
interface RuntimeFilesManifest {
|
|
427
|
+
readonly files: Readonly<Record<string, RuntimeFileEntry>>;
|
|
428
|
+
}
|
|
429
|
+
/** A single file in the runtime manifest. */
|
|
430
|
+
type RuntimeFileEntry = RuntimeFileFile | RuntimeFileDirectory | RuntimeFileLink;
|
|
431
|
+
/** A file entry: real bytes to download, may have lzma sidecar. */
|
|
432
|
+
interface RuntimeFileFile {
|
|
433
|
+
readonly type: "file";
|
|
434
|
+
readonly executable: boolean;
|
|
435
|
+
readonly downloads: {
|
|
436
|
+
readonly raw: {
|
|
437
|
+
readonly sha1: string;
|
|
438
|
+
readonly size: number;
|
|
439
|
+
readonly url: string;
|
|
440
|
+
};
|
|
441
|
+
readonly lzma?: {
|
|
442
|
+
readonly sha1: string;
|
|
443
|
+
readonly size: number;
|
|
444
|
+
readonly url: string;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
/** A directory placeholder. */
|
|
449
|
+
interface RuntimeFileDirectory {
|
|
450
|
+
readonly type: "directory";
|
|
451
|
+
}
|
|
452
|
+
/** A relative symlink. */
|
|
453
|
+
interface RuntimeFileLink {
|
|
454
|
+
readonly type: "link";
|
|
455
|
+
readonly target: string;
|
|
456
|
+
}
|
|
457
|
+
/** Resolved runtime ready to install or launch with. */
|
|
458
|
+
interface ResolvedRuntime {
|
|
459
|
+
/** Mojang component name (e.g. `java-runtime-gamma`). */
|
|
460
|
+
readonly component: string;
|
|
461
|
+
/** Platform key inside the runtime index (e.g. `windows-x64`). */
|
|
462
|
+
readonly platformKey: string;
|
|
463
|
+
/** Version name (e.g. `"17.0.8"`). */
|
|
464
|
+
readonly versionName: string;
|
|
465
|
+
/** Major Java version when known. */
|
|
466
|
+
readonly majorVersion?: number;
|
|
467
|
+
readonly system: RuntimeSystem;
|
|
468
|
+
/** URL of the per-component file manifest. */
|
|
469
|
+
readonly manifestUrl: string;
|
|
470
|
+
/** SHA-1 of the file manifest. */
|
|
471
|
+
readonly manifestSha1: string;
|
|
472
|
+
/**
|
|
473
|
+
* Absolute path containing component directories. When set, runtime files for `component`
|
|
474
|
+
* live at `<installRoot>/<component>/...`. When unset, defaults to `<target.directory>/runtime`.
|
|
475
|
+
*/
|
|
476
|
+
readonly installRoot?: string;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Fully resolved target: a concrete Minecraft + loader + runtime + directory.
|
|
481
|
+
*
|
|
482
|
+
* The library never persists a target — consumers are responsible for storing/recreating
|
|
483
|
+
* it. `kit.targets.create` produces a Target from already-resolved components;
|
|
484
|
+
* `kit.targets.resolve` resolves them in one go.
|
|
485
|
+
*/
|
|
486
|
+
interface Target {
|
|
487
|
+
/** Stable identifier chosen by the consumer. Used for diagnostics, not persistence. */
|
|
488
|
+
readonly id: string;
|
|
489
|
+
/** Absolute or relative path to the per-target Minecraft directory. */
|
|
490
|
+
readonly directory: string;
|
|
491
|
+
readonly minecraft: ResolvedMinecraft;
|
|
492
|
+
readonly loader: Loader;
|
|
493
|
+
readonly runtime: ResolvedRuntime;
|
|
494
|
+
}
|
|
495
|
+
/** Inputs accepted by `kit.targets.create`. */
|
|
496
|
+
interface TargetCreateInput {
|
|
497
|
+
readonly id: string;
|
|
498
|
+
readonly directory: string;
|
|
499
|
+
readonly minecraft: ResolvedMinecraft;
|
|
500
|
+
readonly loader: Loader;
|
|
501
|
+
readonly runtime: ResolvedRuntime;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Discovered installation found by scanning a root directory. Contains only what was
|
|
505
|
+
* actually read from disk — no assumptions about correctness, completeness, or repair state.
|
|
506
|
+
*/
|
|
507
|
+
interface DiscoveredTarget {
|
|
508
|
+
/** Subdirectory name under the scanned root. */
|
|
509
|
+
readonly id: string;
|
|
510
|
+
/** Absolute or normalized directory path. */
|
|
511
|
+
readonly directory: string;
|
|
512
|
+
/** Minecraft version ids found under `versions/`. */
|
|
513
|
+
readonly minecraftVersions: readonly string[];
|
|
514
|
+
/** Loader entries inferred from version-name conventions. */
|
|
515
|
+
readonly loaders: readonly DiscoveredLoaderHint[];
|
|
516
|
+
/** Detected Java executable, when one is present in the per-target `runtime/` folder. */
|
|
517
|
+
readonly runtime?: DiscoveredRuntimeHint;
|
|
518
|
+
}
|
|
519
|
+
/** Inferred loader hint (does not assert correctness). */
|
|
520
|
+
interface DiscoveredLoaderHint {
|
|
521
|
+
readonly type: LoaderKind;
|
|
522
|
+
readonly minecraftVersion?: string;
|
|
523
|
+
readonly version?: string;
|
|
524
|
+
}
|
|
525
|
+
/** Detected runtime files. */
|
|
526
|
+
interface DiscoveredRuntimeHint {
|
|
527
|
+
readonly component?: string;
|
|
528
|
+
readonly javaPath?: string;
|
|
529
|
+
readonly javaVersion?: string;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Coarse-grained install phases. Used in `install:phase-changed` events so consumers can
|
|
534
|
+
* render a progress bar with named steps.
|
|
535
|
+
*/
|
|
536
|
+
declare const InstallPhases: {
|
|
537
|
+
readonly PLANNING: "planning";
|
|
538
|
+
readonly DOWNLOADING_VERSION_MANIFEST: "downloading-version-manifest";
|
|
539
|
+
readonly DOWNLOADING_CLIENT_JAR: "downloading-client-jar";
|
|
540
|
+
readonly DOWNLOADING_LIBRARIES: "downloading-libraries";
|
|
541
|
+
readonly DOWNLOADING_ASSET_INDEX: "downloading-asset-index";
|
|
542
|
+
readonly DOWNLOADING_ASSETS: "downloading-assets";
|
|
543
|
+
readonly EXTRACTING_NATIVES: "extracting-natives";
|
|
544
|
+
readonly INSTALLING_RUNTIME: "installing-runtime";
|
|
545
|
+
readonly INSTALLING_FABRIC: "installing-fabric";
|
|
546
|
+
readonly INSTALLING_FORGE: "installing-forge";
|
|
547
|
+
readonly RUNNING_FORGE_PROCESSORS: "running-forge-processors";
|
|
548
|
+
readonly WRITING_FILES: "writing-files";
|
|
549
|
+
readonly COMPLETED: "completed";
|
|
550
|
+
};
|
|
551
|
+
/** Install phase literal. */
|
|
552
|
+
type InstallPhase = (typeof InstallPhases)[keyof typeof InstallPhases];
|
|
553
|
+
/** Action kinds inside an {@link InstallPlan}. */
|
|
554
|
+
declare const InstallActionKinds: {
|
|
555
|
+
readonly DOWNLOAD_FILE: "download-file";
|
|
556
|
+
readonly EXTRACT_NATIVE: "extract-native";
|
|
557
|
+
readonly RUN_FORGE_PROCESSOR: "run-forge-processor";
|
|
558
|
+
readonly WRITE_VERSION_JSON: "write-version-json";
|
|
559
|
+
readonly WRITE_LOGGING_CONFIG: "write-logging-config";
|
|
560
|
+
};
|
|
561
|
+
/** Discriminator for an install action. */
|
|
562
|
+
type InstallActionKind = (typeof InstallActionKinds)[keyof typeof InstallActionKinds];
|
|
563
|
+
/** A single download step. */
|
|
564
|
+
interface DownloadAction {
|
|
565
|
+
readonly kind: typeof InstallActionKinds.DOWNLOAD_FILE;
|
|
566
|
+
readonly url: string;
|
|
567
|
+
readonly target: string;
|
|
568
|
+
readonly expectedSha1?: string;
|
|
569
|
+
readonly expectedSize?: number;
|
|
570
|
+
readonly category: "client-jar" | "library" | "asset-index" | "asset" | "logging-config" | "fabric-library" | "forge-library" | "runtime-file" | "forge-installer";
|
|
571
|
+
}
|
|
572
|
+
/** A native extraction step. Source jar must already exist on disk. */
|
|
573
|
+
interface ExtractNativeAction {
|
|
574
|
+
readonly kind: typeof InstallActionKinds.EXTRACT_NATIVE;
|
|
575
|
+
readonly source: string;
|
|
576
|
+
readonly destination: string;
|
|
577
|
+
readonly exclude: readonly string[];
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* A Forge processor invocation. `Main-Class` is intentionally NOT carried here — the
|
|
581
|
+
* runner reads it from `classpath[0]`'s manifest at execution time, because the JAR is
|
|
582
|
+
* not guaranteed to exist on disk during planning (newer Forge versions ship some
|
|
583
|
+
* processor JARs as regular Maven libraries instead of bundling them in the installer).
|
|
584
|
+
*/
|
|
585
|
+
interface RunForgeProcessorAction {
|
|
586
|
+
readonly kind: typeof InstallActionKinds.RUN_FORGE_PROCESSOR;
|
|
587
|
+
readonly index: number;
|
|
588
|
+
/** First entry is the processor JAR; remaining entries are its declared classpath. */
|
|
589
|
+
readonly classpath: readonly string[];
|
|
590
|
+
readonly args: readonly string[];
|
|
591
|
+
readonly outputs: Readonly<Record<string, string>>;
|
|
592
|
+
}
|
|
593
|
+
/** Write a version JSON to disk (Fabric / Forge). */
|
|
594
|
+
interface WriteVersionJsonAction {
|
|
595
|
+
readonly kind: typeof InstallActionKinds.WRITE_VERSION_JSON;
|
|
596
|
+
readonly path: string;
|
|
597
|
+
readonly content: string;
|
|
598
|
+
}
|
|
599
|
+
/** Write a logging config (log4j XML) to disk. */
|
|
600
|
+
interface WriteLoggingConfigAction {
|
|
601
|
+
readonly kind: typeof InstallActionKinds.WRITE_LOGGING_CONFIG;
|
|
602
|
+
readonly path: string;
|
|
603
|
+
readonly content: string;
|
|
604
|
+
}
|
|
605
|
+
/** Discriminated union of install actions. */
|
|
606
|
+
type InstallAction = DownloadAction | ExtractNativeAction | RunForgeProcessorAction | WriteVersionJsonAction | WriteLoggingConfigAction;
|
|
607
|
+
/**
|
|
608
|
+
* Pre-computed install plan: a flat ordered list of actions plus computed totals.
|
|
609
|
+
*
|
|
610
|
+
* The runner consumes this; nothing is downloaded or written during planning. The plan
|
|
611
|
+
* carries a reference to the resolved target so the runner does not need a second target
|
|
612
|
+
* argument.
|
|
613
|
+
*/
|
|
614
|
+
interface InstallPlan {
|
|
615
|
+
readonly targetId: string;
|
|
616
|
+
readonly directory: string;
|
|
617
|
+
readonly target: Target;
|
|
618
|
+
readonly actions: readonly InstallAction[];
|
|
619
|
+
readonly totalBytes: number;
|
|
620
|
+
readonly totalActions: number;
|
|
621
|
+
}
|
|
622
|
+
/** Outcome summary returned by `install.run`. */
|
|
623
|
+
interface InstallReport {
|
|
624
|
+
readonly targetId: string;
|
|
625
|
+
readonly bytesDownloaded: number;
|
|
626
|
+
readonly actionsCompleted: number;
|
|
627
|
+
readonly actionsSkipped: number;
|
|
628
|
+
readonly durationMs: number;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** Inputs to {@link planRuntimeInstall}. */
|
|
632
|
+
interface PlanRuntimeInstallInput {
|
|
633
|
+
readonly target: Target;
|
|
634
|
+
readonly http: HttpClient;
|
|
635
|
+
readonly cache: MetadataCache;
|
|
636
|
+
readonly signal?: AbortSignal;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Build an install plan that downloads ONLY the Java runtime declared by `target.runtime`.
|
|
640
|
+
*
|
|
641
|
+
* Useful when the consumer wants to provision a JRE without touching the rest of the
|
|
642
|
+
* Minecraft installation (no client jar, no libraries, no assets). When `target.runtime.installRoot`
|
|
643
|
+
* is set the runtime files land in a shared global location instead of the per-target folder.
|
|
644
|
+
*
|
|
645
|
+
* The returned plan is a regular {@link InstallPlan}, so it can be passed to the existing
|
|
646
|
+
* install runner — directory placeholders and symlinks declared by the runtime manifest are
|
|
647
|
+
* still materialized after downloads complete.
|
|
648
|
+
*/
|
|
649
|
+
declare function planRuntimeInstall(input: PlanRuntimeInstallInput): Promise<InstallPlan>;
|
|
650
|
+
/** Inputs to {@link planStandaloneRuntimeInstall}. */
|
|
651
|
+
interface PlanStandaloneRuntimeInstallInput {
|
|
652
|
+
readonly id: string;
|
|
653
|
+
/** Where the runtime files live. Used as `directory` if `runtime.installRoot` is unset. */
|
|
654
|
+
readonly directory: string;
|
|
655
|
+
readonly runtime: ResolvedRuntime;
|
|
656
|
+
readonly http: HttpClient;
|
|
657
|
+
readonly cache: MetadataCache;
|
|
658
|
+
readonly signal?: AbortSignal;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Plan a runtime-only install **without a Minecraft target**. Useful for "Install Java/runtime"
|
|
662
|
+
* flows where the user just wants a JRE on disk and never had a Minecraft version to choose
|
|
663
|
+
* from. The returned plan is shaped exactly like a normal {@link InstallPlan} and runs through
|
|
664
|
+
* the standard install runner — but its `target.minecraft` and `target.loader` fields are
|
|
665
|
+
* intentional placeholders. The runner only reads `target.runtime` for runtime-only plans, so
|
|
666
|
+
* the placeholders are never accessed at runtime.
|
|
667
|
+
*/
|
|
668
|
+
declare function planStandaloneRuntimeInstall(input: PlanStandaloneRuntimeInstallInput): Promise<InstallPlan>;
|
|
669
|
+
|
|
670
|
+
/** Log levels accepted by the pluggable logger. */
|
|
671
|
+
declare const LogLevels: {
|
|
672
|
+
readonly DEBUG: "debug";
|
|
673
|
+
readonly INFO: "info";
|
|
674
|
+
readonly WARN: "warn";
|
|
675
|
+
readonly ERROR: "error";
|
|
676
|
+
};
|
|
677
|
+
/** Log-level literal. */
|
|
678
|
+
type LogLevel = (typeof LogLevels)[keyof typeof LogLevels];
|
|
679
|
+
/** Pluggable logger. Default implementation is a silent logger; pass your own to surface logs. */
|
|
680
|
+
interface Logger {
|
|
681
|
+
log(level: LogLevel, message: string, fields?: Readonly<Record<string, unknown>>): void;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** Shared context passed to every resolver. */
|
|
685
|
+
interface ResolverContext {
|
|
686
|
+
readonly http: HttpClient;
|
|
687
|
+
readonly cache: MetadataCache;
|
|
688
|
+
readonly logger: Logger;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/** Inputs to {@link FabricVersionsApi.list}. */
|
|
692
|
+
interface FabricListInput {
|
|
693
|
+
readonly minecraftVersion?: string;
|
|
694
|
+
readonly signal?: AbortSignal;
|
|
695
|
+
}
|
|
696
|
+
/** Inputs to {@link FabricVersionsApi.resolve}. */
|
|
697
|
+
interface FabricResolveInput {
|
|
698
|
+
readonly minecraftVersion: string;
|
|
699
|
+
readonly preference?: VersionPreferenceKind;
|
|
700
|
+
readonly loaderVersion?: string;
|
|
701
|
+
readonly signal?: AbortSignal;
|
|
702
|
+
}
|
|
703
|
+
/** Public Fabric versions API surface. */
|
|
704
|
+
declare class FabricVersionsApi {
|
|
705
|
+
private readonly ctx;
|
|
706
|
+
constructor(ctx: ResolverContext);
|
|
707
|
+
/** List Fabric loader versions, optionally constrained to a Minecraft version. */
|
|
708
|
+
list(input?: FabricListInput): Promise<readonly FabricLoaderSummary[]>;
|
|
709
|
+
/** Resolve a Fabric loader version against a Minecraft version. */
|
|
710
|
+
resolve(input: FabricResolveInput): Promise<ResolvedFabricLoader>;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/** Inputs to {@link ForgeVersionsApi.list}. */
|
|
714
|
+
interface ForgeListInput {
|
|
715
|
+
readonly minecraftVersion?: string;
|
|
716
|
+
readonly signal?: AbortSignal;
|
|
717
|
+
}
|
|
718
|
+
/** Inputs to {@link ForgeVersionsApi.resolve}. */
|
|
719
|
+
interface ForgeResolveInput {
|
|
720
|
+
readonly minecraftVersion: string;
|
|
721
|
+
readonly preference?: VersionPreferenceKind;
|
|
722
|
+
readonly forgeVersion?: string;
|
|
723
|
+
readonly signal?: AbortSignal;
|
|
724
|
+
}
|
|
725
|
+
/** Public Forge versions API surface. */
|
|
726
|
+
declare class ForgeVersionsApi {
|
|
727
|
+
private readonly ctx;
|
|
728
|
+
constructor(ctx: ResolverContext);
|
|
729
|
+
/** List Forge builds (across all Minecraft versions, or filtered to one). */
|
|
730
|
+
list(input?: ForgeListInput): Promise<readonly ForgeBuildSummary[]>;
|
|
731
|
+
/** Resolve a Forge build for a Minecraft version. */
|
|
732
|
+
resolve(input: ForgeResolveInput): Promise<ResolvedForgeLoader>;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/** Inputs to {@link MinecraftVersionsApi.list}. */
|
|
736
|
+
interface MinecraftListInput {
|
|
737
|
+
readonly channel?: MinecraftChannel;
|
|
738
|
+
readonly signal?: AbortSignal;
|
|
739
|
+
}
|
|
740
|
+
/** Inputs to {@link MinecraftVersionsApi.latest}. */
|
|
741
|
+
interface MinecraftLatestInput {
|
|
742
|
+
readonly channel?: MinecraftChannel;
|
|
743
|
+
readonly signal?: AbortSignal;
|
|
744
|
+
}
|
|
745
|
+
/** Inputs to {@link MinecraftVersionsApi.get} / `.resolve`. */
|
|
746
|
+
interface MinecraftGetInput {
|
|
747
|
+
readonly version: string;
|
|
748
|
+
readonly signal?: AbortSignal;
|
|
749
|
+
}
|
|
750
|
+
/** Public Minecraft versions API surface. */
|
|
751
|
+
declare class MinecraftVersionsApi {
|
|
752
|
+
private readonly ctx;
|
|
753
|
+
constructor(ctx: ResolverContext);
|
|
754
|
+
/** List all Minecraft versions, optionally filtered by channel. */
|
|
755
|
+
list(input?: MinecraftListInput): Promise<readonly MinecraftVersionSummary[]>;
|
|
756
|
+
/** Return the latest version on the given channel (defaults to RELEASE). */
|
|
757
|
+
latest(input?: MinecraftLatestInput): Promise<MinecraftVersionSummary>;
|
|
758
|
+
/** Return a single version summary or throw `MANIFEST_NOT_FOUND`. */
|
|
759
|
+
get(input: MinecraftGetInput): Promise<MinecraftVersionSummary>;
|
|
760
|
+
/** Fetch and parse the per-version manifest in addition to the summary. */
|
|
761
|
+
resolve(input: MinecraftGetInput): Promise<ResolvedMinecraft>;
|
|
762
|
+
private fetchManifestRoot;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/** Inputs to {@link RuntimeVersionsApi.list}. */
|
|
766
|
+
interface RuntimeListInput {
|
|
767
|
+
readonly system: RuntimeSystem;
|
|
768
|
+
readonly minecraftVersion?: string;
|
|
769
|
+
readonly signal?: AbortSignal;
|
|
770
|
+
}
|
|
771
|
+
/** A summary entry for the list API. */
|
|
772
|
+
interface RuntimeListEntry {
|
|
773
|
+
readonly component: string;
|
|
774
|
+
readonly platformKey: string;
|
|
775
|
+
readonly versionName: string;
|
|
776
|
+
readonly released: string;
|
|
777
|
+
readonly manifestUrl: string;
|
|
778
|
+
}
|
|
779
|
+
/** Inputs to {@link RuntimeVersionsApi.resolve}. */
|
|
780
|
+
interface RuntimeResolveInput {
|
|
781
|
+
readonly system: RuntimeSystem;
|
|
782
|
+
readonly minecraftVersion?: string;
|
|
783
|
+
readonly component?: string;
|
|
784
|
+
readonly preference?: RuntimePreferenceKind;
|
|
785
|
+
readonly signal?: AbortSignal;
|
|
786
|
+
}
|
|
787
|
+
/** Public runtime versions API surface. */
|
|
788
|
+
declare class RuntimeVersionsApi {
|
|
789
|
+
private readonly ctx;
|
|
790
|
+
constructor(ctx: ResolverContext);
|
|
791
|
+
/** List available runtime entries for the host platform. */
|
|
792
|
+
list(input: RuntimeListInput): Promise<readonly RuntimeListEntry[]>;
|
|
793
|
+
/** Resolve a single runtime for the host platform and Minecraft version. */
|
|
794
|
+
resolve(input: RuntimeResolveInput): Promise<ResolvedRuntime>;
|
|
795
|
+
private fetchIndex;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/** Inputs to {@link TargetsApi.resolve}. */
|
|
799
|
+
interface TargetResolveInput {
|
|
800
|
+
readonly id: string;
|
|
801
|
+
readonly directory: string;
|
|
802
|
+
readonly minecraft: {
|
|
803
|
+
readonly version: string;
|
|
804
|
+
};
|
|
805
|
+
readonly loader: TargetLoaderInput;
|
|
806
|
+
readonly runtime?: {
|
|
807
|
+
readonly preference?: RuntimePreferenceKind;
|
|
808
|
+
/** Override the runtime component. Defaults to the Minecraft manifest's `javaVersion.component`. */
|
|
809
|
+
readonly component?: string;
|
|
810
|
+
/**
|
|
811
|
+
* Custom install root (absolute path) holding the component directories.
|
|
812
|
+
* When unset, runtime files live under `<directory>/runtime/`.
|
|
813
|
+
*/
|
|
814
|
+
readonly installRoot?: string;
|
|
815
|
+
};
|
|
816
|
+
readonly system?: RuntimeSystem;
|
|
817
|
+
readonly signal?: AbortSignal;
|
|
818
|
+
}
|
|
819
|
+
/** Loader input variants. */
|
|
820
|
+
type TargetLoaderInput = {
|
|
821
|
+
readonly type: typeof Loaders.VANILLA;
|
|
822
|
+
} | {
|
|
823
|
+
readonly type: typeof Loaders.FABRIC;
|
|
824
|
+
readonly preference?: VersionPreferenceKind;
|
|
825
|
+
readonly version?: string;
|
|
826
|
+
} | {
|
|
827
|
+
readonly type: typeof Loaders.FORGE;
|
|
828
|
+
readonly preference?: VersionPreferenceKind;
|
|
829
|
+
readonly version?: string;
|
|
830
|
+
};
|
|
831
|
+
/** Inputs to {@link TargetsApi.list}. */
|
|
832
|
+
interface TargetListInput {
|
|
833
|
+
readonly rootDir: string;
|
|
834
|
+
}
|
|
835
|
+
/** Constructor inputs for {@link TargetsApi}. */
|
|
836
|
+
interface TargetsApiContext {
|
|
837
|
+
readonly minecraft: MinecraftVersionsApi;
|
|
838
|
+
readonly fabric: FabricVersionsApi;
|
|
839
|
+
readonly forge: ForgeVersionsApi;
|
|
840
|
+
readonly runtime: RuntimeVersionsApi;
|
|
841
|
+
readonly system: RuntimeSystem;
|
|
842
|
+
}
|
|
843
|
+
/** Public Targets API surface. */
|
|
844
|
+
declare class TargetsApi {
|
|
845
|
+
private readonly ctx;
|
|
846
|
+
constructor(ctx: TargetsApiContext);
|
|
847
|
+
/** The detected host system used by `resolve()` when no `system` is supplied. */
|
|
848
|
+
get system(): RuntimeSystem;
|
|
849
|
+
/** Build a {@link Target} from already-resolved components. */
|
|
850
|
+
create(input: TargetCreateInput): Target;
|
|
851
|
+
/** Sugar API: resolve every component then assemble a target. */
|
|
852
|
+
resolve(input: TargetResolveInput): Promise<Target>;
|
|
853
|
+
/** Scan a root directory for Minecraft installations. Returns only what is on disk. */
|
|
854
|
+
list(input: TargetListInput): Promise<readonly DiscoveredTarget[]>;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/** Aspect of an installation a verification result describes. */
|
|
858
|
+
declare const VerificationKinds: {
|
|
859
|
+
readonly MINECRAFT: "minecraft";
|
|
860
|
+
readonly FABRIC: "fabric";
|
|
861
|
+
readonly FORGE: "forge";
|
|
862
|
+
readonly RUNTIME: "runtime";
|
|
863
|
+
};
|
|
864
|
+
/** Verification kind literal. */
|
|
865
|
+
type VerificationKind = (typeof VerificationKinds)[keyof typeof VerificationKinds];
|
|
866
|
+
/** Status of an individual file checked during verification. */
|
|
867
|
+
declare const VerifyFileStatuses: {
|
|
868
|
+
readonly OK: "ok";
|
|
869
|
+
readonly MISSING: "missing";
|
|
870
|
+
readonly CORRUPT: "corrupt";
|
|
871
|
+
readonly WRONG_SIZE: "wrong-size";
|
|
872
|
+
};
|
|
873
|
+
/** File status literal. */
|
|
874
|
+
type VerifyFileStatus = (typeof VerifyFileStatuses)[keyof typeof VerifyFileStatuses];
|
|
875
|
+
/** Categories assigned to each verified file for easier filtering. */
|
|
876
|
+
declare const VerifyFileCategories: {
|
|
877
|
+
readonly CLIENT_JAR: "client-jar";
|
|
878
|
+
readonly LIBRARY: "library";
|
|
879
|
+
readonly ASSET: "asset";
|
|
880
|
+
readonly ASSET_INDEX: "asset-index";
|
|
881
|
+
readonly NATIVE: "native";
|
|
882
|
+
readonly LOADER_LIBRARY: "loader-library";
|
|
883
|
+
readonly RUNTIME_FILE: "runtime-file";
|
|
884
|
+
readonly LOGGING_CONFIG: "logging-config";
|
|
885
|
+
};
|
|
886
|
+
/** Verification file category literal. */
|
|
887
|
+
type VerifyFileCategory = (typeof VerifyFileCategories)[keyof typeof VerifyFileCategories];
|
|
888
|
+
/** A single verified file. */
|
|
889
|
+
interface VerificationFileResult {
|
|
890
|
+
readonly path: string;
|
|
891
|
+
readonly category: VerifyFileCategory;
|
|
892
|
+
readonly status: VerifyFileStatus;
|
|
893
|
+
readonly expectedSha1?: string;
|
|
894
|
+
readonly actualSha1?: string;
|
|
895
|
+
readonly expectedSize?: number;
|
|
896
|
+
readonly actualSize?: number;
|
|
897
|
+
/** Optional URL where the file can be re-downloaded if it's broken. */
|
|
898
|
+
readonly url?: string;
|
|
899
|
+
}
|
|
900
|
+
/** Aggregate verification result returned by each `verify.<kind>.run` API. */
|
|
901
|
+
interface VerificationResult {
|
|
902
|
+
readonly targetId: string;
|
|
903
|
+
readonly kind: VerificationKind;
|
|
904
|
+
readonly isValid: boolean;
|
|
905
|
+
readonly issues: readonly VerificationFileResult[];
|
|
906
|
+
readonly checkedFiles: number;
|
|
907
|
+
readonly durationMs: number;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/** Coarse-grained repair phases used for `repair:phase-changed` events. */
|
|
911
|
+
declare const RepairPhases: {
|
|
912
|
+
readonly PLANNING: "planning";
|
|
913
|
+
readonly REPAIRING_CLIENT_JAR: "repairing-client-jar";
|
|
914
|
+
readonly REPAIRING_LIBRARIES: "repairing-libraries";
|
|
915
|
+
readonly REPAIRING_ASSETS: "repairing-assets";
|
|
916
|
+
readonly REPAIRING_NATIVES: "repairing-natives";
|
|
917
|
+
readonly REPAIRING_RUNTIME: "repairing-runtime";
|
|
918
|
+
readonly REPAIRING_LOADER: "repairing-loader";
|
|
919
|
+
readonly COMPLETED: "completed";
|
|
920
|
+
};
|
|
921
|
+
/** Repair phase literal. */
|
|
922
|
+
type RepairPhase = (typeof RepairPhases)[keyof typeof RepairPhases];
|
|
923
|
+
/**
|
|
924
|
+
* A repair plan is, structurally, an install plan limited to actions needed to fix the
|
|
925
|
+
* issues reported by a previous {@link VerificationResult}. The runner is the same.
|
|
926
|
+
*/
|
|
927
|
+
interface RepairPlan {
|
|
928
|
+
readonly targetId: string;
|
|
929
|
+
readonly directory: string;
|
|
930
|
+
readonly target: Target;
|
|
931
|
+
readonly actions: readonly InstallAction[];
|
|
932
|
+
readonly totalBytes: number;
|
|
933
|
+
readonly totalActions: number;
|
|
934
|
+
}
|
|
935
|
+
/** Repair report — same shape as install report. */
|
|
936
|
+
interface RepairReport {
|
|
937
|
+
readonly targetId: string;
|
|
938
|
+
readonly bytesDownloaded: number;
|
|
939
|
+
readonly actionsCompleted: number;
|
|
940
|
+
readonly durationMs: number;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Inputs accepted by every aspect-specific `planXxxRepair` (`planMinecraftRepair`,
|
|
944
|
+
* `planFabricRepair`, `planForgeRepair`, `planRuntimeRepair`). The per-aspect input types
|
|
945
|
+
* are aliases over this shape.
|
|
946
|
+
*/
|
|
947
|
+
interface AspectRepairInput {
|
|
948
|
+
readonly target: Target;
|
|
949
|
+
readonly from: VerificationResult | readonly VerificationResult[];
|
|
950
|
+
readonly http: HttpClient;
|
|
951
|
+
readonly cache: MetadataCache;
|
|
952
|
+
readonly signal?: AbortSignal;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Stable string constants for the `type` discriminator of every {@link ProgressEvent}.
|
|
957
|
+
* Use these instead of bare string literals when filtering events.
|
|
958
|
+
*/
|
|
959
|
+
declare const EventTypes: {
|
|
960
|
+
readonly INSTALL_PHASE_CHANGED: "install:phase-changed";
|
|
961
|
+
readonly DOWNLOAD_STARTED: "download:started";
|
|
962
|
+
readonly DOWNLOAD_PROGRESS: "download:progress";
|
|
963
|
+
readonly DOWNLOAD_SKIPPED: "download:skipped";
|
|
964
|
+
readonly DOWNLOAD_COMPLETED: "download:completed";
|
|
965
|
+
readonly DOWNLOAD_FAILED: "download:failed";
|
|
966
|
+
readonly INTEGRITY_VERIFIED: "integrity:verified";
|
|
967
|
+
readonly INTEGRITY_MISMATCH: "integrity:mismatch";
|
|
968
|
+
readonly ARCHIVE_EXTRACTED: "archive:extracted";
|
|
969
|
+
readonly FORGE_PROCESSOR_STARTED: "forge:processor-started";
|
|
970
|
+
readonly FORGE_PROCESSOR_COMPLETED: "forge:processor-completed";
|
|
971
|
+
readonly FORGE_PROCESSOR_OUTPUT_VERIFIED: "forge:processor-output-verified";
|
|
972
|
+
readonly VERIFY_FILE_CHECKED: "verify:file-checked";
|
|
973
|
+
readonly VERIFY_COMPLETED: "verify:completed";
|
|
974
|
+
readonly REPAIR_PHASE_CHANGED: "repair:phase-changed";
|
|
975
|
+
readonly LAUNCH_STARTING: "launch:starting";
|
|
976
|
+
readonly LAUNCH_STARTED: "launch:started";
|
|
977
|
+
readonly LAUNCH_STDOUT: "launch:stdout";
|
|
978
|
+
readonly LAUNCH_STDERR: "launch:stderr";
|
|
979
|
+
readonly LAUNCH_EXITED: "launch:exited";
|
|
980
|
+
readonly LAUNCH_ABORTED: "launch:aborted";
|
|
981
|
+
};
|
|
982
|
+
/** Literal type of the `type` discriminator of a {@link ProgressEvent}. */
|
|
983
|
+
type EventType = (typeof EventTypes)[keyof typeof EventTypes];
|
|
984
|
+
/** Reference to a single file used in download events. */
|
|
985
|
+
interface FileRef {
|
|
986
|
+
readonly url: string;
|
|
987
|
+
readonly target: string;
|
|
988
|
+
readonly category?: string;
|
|
989
|
+
}
|
|
990
|
+
/** A single processor description used in Forge events. */
|
|
991
|
+
interface ProcessorRef {
|
|
992
|
+
readonly index: number;
|
|
993
|
+
readonly mainClass: string;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Discriminated union of all runtime progress events. Pass an `onEvent` callback to
|
|
997
|
+
* `install.run`, `update.run`, `verify.run`, `repair.run`, or `launch.run` to receive these.
|
|
998
|
+
*/
|
|
999
|
+
type ProgressEvent = {
|
|
1000
|
+
readonly type: "install:phase-changed";
|
|
1001
|
+
readonly phase: InstallPhase;
|
|
1002
|
+
readonly previous: InstallPhase | null;
|
|
1003
|
+
} | {
|
|
1004
|
+
readonly type: "download:started";
|
|
1005
|
+
readonly file: FileRef;
|
|
1006
|
+
readonly expectedSize: number;
|
|
1007
|
+
} | {
|
|
1008
|
+
readonly type: "download:progress";
|
|
1009
|
+
readonly file: FileRef;
|
|
1010
|
+
readonly bytesDownloaded: number;
|
|
1011
|
+
readonly totalBytes: number;
|
|
1012
|
+
} | {
|
|
1013
|
+
readonly type: "download:skipped";
|
|
1014
|
+
readonly file: FileRef;
|
|
1015
|
+
} | {
|
|
1016
|
+
readonly type: "download:completed";
|
|
1017
|
+
readonly file: FileRef;
|
|
1018
|
+
readonly durationMs: number;
|
|
1019
|
+
readonly bytes: number;
|
|
1020
|
+
} | {
|
|
1021
|
+
readonly type: "download:failed";
|
|
1022
|
+
readonly file: FileRef;
|
|
1023
|
+
readonly error: Error;
|
|
1024
|
+
readonly willRetry: boolean;
|
|
1025
|
+
} | {
|
|
1026
|
+
readonly type: "integrity:verified";
|
|
1027
|
+
readonly file: FileRef;
|
|
1028
|
+
readonly algorithm: "sha1" | "sha256";
|
|
1029
|
+
readonly hash: string;
|
|
1030
|
+
} | {
|
|
1031
|
+
readonly type: "integrity:mismatch";
|
|
1032
|
+
readonly file: FileRef;
|
|
1033
|
+
readonly algorithm: "sha1" | "sha256";
|
|
1034
|
+
readonly expected: string;
|
|
1035
|
+
readonly actual: string;
|
|
1036
|
+
} | {
|
|
1037
|
+
readonly type: "archive:extracted";
|
|
1038
|
+
readonly archive: string;
|
|
1039
|
+
readonly target: string;
|
|
1040
|
+
readonly fileCount: number;
|
|
1041
|
+
} | {
|
|
1042
|
+
readonly type: "forge:processor-started";
|
|
1043
|
+
readonly processor: ProcessorRef;
|
|
1044
|
+
readonly total: number;
|
|
1045
|
+
} | {
|
|
1046
|
+
readonly type: "forge:processor-completed";
|
|
1047
|
+
readonly processor: ProcessorRef;
|
|
1048
|
+
readonly exitCode: number;
|
|
1049
|
+
readonly durationMs: number;
|
|
1050
|
+
} | {
|
|
1051
|
+
readonly type: "forge:processor-output-verified";
|
|
1052
|
+
readonly processor: ProcessorRef;
|
|
1053
|
+
readonly path: string;
|
|
1054
|
+
} | {
|
|
1055
|
+
readonly type: "verify:file-checked";
|
|
1056
|
+
readonly file: VerificationFileResult;
|
|
1057
|
+
} | {
|
|
1058
|
+
readonly type: "verify:completed";
|
|
1059
|
+
readonly summary: VerificationResult;
|
|
1060
|
+
} | {
|
|
1061
|
+
readonly type: "repair:phase-changed";
|
|
1062
|
+
readonly phase: RepairPhase;
|
|
1063
|
+
readonly previous: RepairPhase | null;
|
|
1064
|
+
} | {
|
|
1065
|
+
readonly type: "launch:starting";
|
|
1066
|
+
readonly command: string;
|
|
1067
|
+
readonly args: readonly string[];
|
|
1068
|
+
readonly cwd: string;
|
|
1069
|
+
} | {
|
|
1070
|
+
readonly type: "launch:started";
|
|
1071
|
+
readonly pid: number;
|
|
1072
|
+
} | {
|
|
1073
|
+
readonly type: "launch:stdout";
|
|
1074
|
+
readonly line: string;
|
|
1075
|
+
} | {
|
|
1076
|
+
readonly type: "launch:stderr";
|
|
1077
|
+
readonly line: string;
|
|
1078
|
+
} | {
|
|
1079
|
+
readonly type: "launch:exited";
|
|
1080
|
+
readonly code: number | null;
|
|
1081
|
+
readonly signal: NodeJS.Signals | null;
|
|
1082
|
+
} | {
|
|
1083
|
+
readonly type: "launch:aborted";
|
|
1084
|
+
readonly reason: string;
|
|
1085
|
+
};
|
|
1086
|
+
/** Listener signature accepted by every long-running operation. */
|
|
1087
|
+
type ProgressListener = (event: ProgressEvent) => void;
|
|
1088
|
+
/** Common options accepted by long-running operations. */
|
|
1089
|
+
interface OperationOptions {
|
|
1090
|
+
readonly signal?: AbortSignal;
|
|
1091
|
+
readonly onEvent?: ProgressListener;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
/** Authentication modes accepted by the launch composer. */
|
|
1095
|
+
declare const AuthModes: {
|
|
1096
|
+
/** Offline-mode play with a chosen username and synthetic UUID. */
|
|
1097
|
+
readonly OFFLINE: "offline";
|
|
1098
|
+
/** Pre-authenticated session — caller provides the access token and identity. */
|
|
1099
|
+
readonly ONLINE: "online";
|
|
1100
|
+
};
|
|
1101
|
+
/** Auth mode literal. */
|
|
1102
|
+
type AuthMode = (typeof AuthModes)[keyof typeof AuthModes];
|
|
1103
|
+
/** Offline authentication. */
|
|
1104
|
+
interface OfflineAuth {
|
|
1105
|
+
readonly mode: typeof AuthModes.OFFLINE;
|
|
1106
|
+
readonly username: string;
|
|
1107
|
+
/** Optional explicit UUID. When omitted, a deterministic UUID is derived from the username. */
|
|
1108
|
+
readonly uuid?: string;
|
|
1109
|
+
}
|
|
1110
|
+
/** Online (token-based) authentication. */
|
|
1111
|
+
interface OnlineAuth {
|
|
1112
|
+
readonly mode: typeof AuthModes.ONLINE;
|
|
1113
|
+
readonly username: string;
|
|
1114
|
+
readonly uuid: string;
|
|
1115
|
+
readonly accessToken: string;
|
|
1116
|
+
readonly userType?: string;
|
|
1117
|
+
readonly clientId?: string;
|
|
1118
|
+
readonly xuid?: string;
|
|
1119
|
+
}
|
|
1120
|
+
/** Auth shape consumed by `kit.launch.compose`. */
|
|
1121
|
+
type LaunchAuth = OfflineAuth | OnlineAuth;
|
|
1122
|
+
|
|
1123
|
+
/** Optional memory configuration. */
|
|
1124
|
+
interface LaunchMemoryOptions {
|
|
1125
|
+
readonly minMb?: number;
|
|
1126
|
+
readonly maxMb?: number;
|
|
1127
|
+
}
|
|
1128
|
+
/** Optional resolution / window configuration. */
|
|
1129
|
+
interface LaunchResolutionOptions {
|
|
1130
|
+
readonly width: number;
|
|
1131
|
+
readonly height: number;
|
|
1132
|
+
}
|
|
1133
|
+
/** Inputs for `kit.launch.compose` (and the lower-level `composeLaunch` helper). */
|
|
1134
|
+
interface LaunchOptions {
|
|
1135
|
+
readonly auth: LaunchAuth;
|
|
1136
|
+
readonly memory?: LaunchMemoryOptions;
|
|
1137
|
+
readonly resolution?: LaunchResolutionOptions;
|
|
1138
|
+
readonly fullscreen?: boolean;
|
|
1139
|
+
/** Brand string injected as `${launcher_name}`. */
|
|
1140
|
+
readonly launcherName?: string;
|
|
1141
|
+
/** Version string injected as `${launcher_version}`. */
|
|
1142
|
+
readonly launcherVersion?: string;
|
|
1143
|
+
/** Extra JVM args appended after composed JVM args. */
|
|
1144
|
+
readonly extraJvmArgs?: readonly string[];
|
|
1145
|
+
/** Extra game args appended after composed game args. */
|
|
1146
|
+
readonly extraGameArgs?: readonly string[];
|
|
1147
|
+
/** Set of feature flags evaluated by argument rules (e.g. `is_demo_user`). */
|
|
1148
|
+
readonly features?: Readonly<Record<string, boolean>>;
|
|
1149
|
+
}
|
|
1150
|
+
/** Fully composed launch command, ready to be passed to `kit.launch.run`. */
|
|
1151
|
+
interface LaunchComposition {
|
|
1152
|
+
readonly targetId: string;
|
|
1153
|
+
readonly directory: string;
|
|
1154
|
+
readonly javaPath: string;
|
|
1155
|
+
readonly mainClass: string;
|
|
1156
|
+
readonly jvmArgs: readonly string[];
|
|
1157
|
+
readonly gameArgs: readonly string[];
|
|
1158
|
+
readonly classpath: readonly string[];
|
|
1159
|
+
readonly nativesDirectory: string;
|
|
1160
|
+
readonly auth: LaunchAuth;
|
|
1161
|
+
/** Spawn working directory (almost always equal to {@link directory}). */
|
|
1162
|
+
readonly workingDirectory: string;
|
|
1163
|
+
/** Environment variables to set on the spawned process. */
|
|
1164
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
1165
|
+
}
|
|
1166
|
+
/** Live handle for a running game process. */
|
|
1167
|
+
interface LaunchSession {
|
|
1168
|
+
/** Operating-system process id. */
|
|
1169
|
+
readonly pid: number;
|
|
1170
|
+
/** Resolves with the exit code/signal when the process terminates. */
|
|
1171
|
+
readonly exited: Promise<LaunchExit>;
|
|
1172
|
+
/** Best-effort cancel — sends SIGTERM, then SIGKILL after the grace period. */
|
|
1173
|
+
abort(reason?: string): void;
|
|
1174
|
+
}
|
|
1175
|
+
/** Outcome of a finished launch. */
|
|
1176
|
+
interface LaunchExit {
|
|
1177
|
+
readonly code: number | null;
|
|
1178
|
+
readonly signal: NodeJS.Signals | null;
|
|
1179
|
+
readonly aborted: boolean;
|
|
1180
|
+
}
|
|
1181
|
+
/** Options for `kit.launch.run` (and the lower-level `runLaunch` helper). */
|
|
1182
|
+
interface LaunchRunOptions {
|
|
1183
|
+
readonly signal?: AbortSignal;
|
|
1184
|
+
readonly onEvent?: (event: ProgressEvent) => void;
|
|
1185
|
+
/** Milliseconds to wait between SIGTERM and SIGKILL when aborting. */
|
|
1186
|
+
readonly killGracePeriodMs?: number;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/** Stream-of-text channel exposed by spawned processes. */
|
|
1190
|
+
interface ProcessStream {
|
|
1191
|
+
on(event: "data", listener: (chunk: string) => void): void;
|
|
1192
|
+
}
|
|
1193
|
+
/** Live handle for a child process. */
|
|
1194
|
+
interface SpawnedProcess {
|
|
1195
|
+
readonly pid: number;
|
|
1196
|
+
readonly stdout: ProcessStream;
|
|
1197
|
+
readonly stderr: ProcessStream;
|
|
1198
|
+
/** Resolves when the process exits with its exit info. */
|
|
1199
|
+
readonly exited: Promise<{
|
|
1200
|
+
readonly code: number | null;
|
|
1201
|
+
readonly signal: NodeJS.Signals | null;
|
|
1202
|
+
}>;
|
|
1203
|
+
/** Send a termination signal. Returns true on success. */
|
|
1204
|
+
kill(signal?: NodeJS.Signals): boolean;
|
|
1205
|
+
}
|
|
1206
|
+
/** Options accepted by the spawner. */
|
|
1207
|
+
interface SpawnOptions {
|
|
1208
|
+
readonly cwd: string;
|
|
1209
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Pluggable process spawner. The default implementation uses `node:child_process`; tests
|
|
1213
|
+
* inject a fake to avoid spawning real processes.
|
|
1214
|
+
*/
|
|
1215
|
+
interface Spawner {
|
|
1216
|
+
spawn(command: string, args: readonly string[], options: SpawnOptions): SpawnedProcess;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/** Update plan — additive list of actions to bring an installation up to date. */
|
|
1220
|
+
interface UpdatePlan {
|
|
1221
|
+
readonly targetId: string;
|
|
1222
|
+
readonly directory: string;
|
|
1223
|
+
readonly target: Target;
|
|
1224
|
+
readonly actions: readonly InstallAction[];
|
|
1225
|
+
readonly totalBytes: number;
|
|
1226
|
+
readonly totalActions: number;
|
|
1227
|
+
}
|
|
1228
|
+
/** Update report. */
|
|
1229
|
+
interface UpdateReport {
|
|
1230
|
+
readonly targetId: string;
|
|
1231
|
+
readonly bytesDownloaded: number;
|
|
1232
|
+
readonly actionsCompleted: number;
|
|
1233
|
+
/** Actions that found their target already correct on disk and were skipped. */
|
|
1234
|
+
readonly actionsSkipped: number;
|
|
1235
|
+
readonly durationMs: number;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/** Constructor options for {@link MinecraftKit}. */
|
|
1239
|
+
interface MinecraftKitOptions {
|
|
1240
|
+
readonly httpClient?: HttpClient;
|
|
1241
|
+
readonly cache?: MetadataCache;
|
|
1242
|
+
readonly logger?: Logger;
|
|
1243
|
+
readonly system?: RuntimeSystem;
|
|
1244
|
+
readonly spawner?: Spawner;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Single facade for the entire library.
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```ts
|
|
1251
|
+
* const kit = new MinecraftKit();
|
|
1252
|
+
* const target = await kit.targets.resolve({ id, directory, minecraft: { version: '1.20.1' }, loader: { type: Loaders.VANILLA } });
|
|
1253
|
+
* const plan = await kit.install.plan(target);
|
|
1254
|
+
* await kit.install.run(plan, { onEvent: console.log });
|
|
1255
|
+
* ```
|
|
1256
|
+
*/
|
|
1257
|
+
declare class MinecraftKit {
|
|
1258
|
+
readonly versions: {
|
|
1259
|
+
readonly minecraft: MinecraftVersionsApi;
|
|
1260
|
+
readonly fabric: FabricVersionsApi;
|
|
1261
|
+
readonly forge: ForgeVersionsApi;
|
|
1262
|
+
readonly runtime: RuntimeVersionsApi;
|
|
1263
|
+
};
|
|
1264
|
+
readonly targets: TargetsApi;
|
|
1265
|
+
readonly install: {
|
|
1266
|
+
plan(target: Target, options?: OperationOptions): Promise<InstallPlan>;
|
|
1267
|
+
run(plan: InstallPlan, options?: OperationOptions): Promise<InstallReport>;
|
|
1268
|
+
/** Install only the Java runtime declared by `target.runtime` (honours `installRoot`). */
|
|
1269
|
+
readonly runtime: {
|
|
1270
|
+
plan(target: Target, options?: OperationOptions): Promise<InstallPlan>;
|
|
1271
|
+
run(plan: InstallPlan, options?: OperationOptions): Promise<InstallReport>;
|
|
1272
|
+
/**
|
|
1273
|
+
* Plan a runtime-only install without an existing Minecraft Target. The caller
|
|
1274
|
+
* supplies a {@link ResolvedRuntime} (typically from `kit.versions.runtime.resolve`)
|
|
1275
|
+
* plus a directory and stable id.
|
|
1276
|
+
*/
|
|
1277
|
+
standalonePlan(input: Omit<PlanStandaloneRuntimeInstallInput, "http" | "cache">): Promise<InstallPlan>;
|
|
1278
|
+
};
|
|
1279
|
+
};
|
|
1280
|
+
readonly update: {
|
|
1281
|
+
plan(target: Target, options?: OperationOptions): Promise<UpdatePlan>;
|
|
1282
|
+
run(plan: UpdatePlan, options?: OperationOptions): Promise<UpdateReport>;
|
|
1283
|
+
};
|
|
1284
|
+
readonly verify: {
|
|
1285
|
+
/** Verify the vanilla Minecraft slice (client jar, libraries, assets, natives, log config). */
|
|
1286
|
+
readonly minecraft: {
|
|
1287
|
+
run(target: Target, options?: VerifyOperationOptions): Promise<VerificationResult>;
|
|
1288
|
+
};
|
|
1289
|
+
/** Verify the Fabric loader slice (profile JSON + libraries). Throws on non-Fabric targets. */
|
|
1290
|
+
readonly fabric: {
|
|
1291
|
+
run(target: Target, options?: VerifyOperationOptions): Promise<VerificationResult>;
|
|
1292
|
+
};
|
|
1293
|
+
/** Verify the Forge loader slice (version JSON + libraries). Throws on non-Forge targets. */
|
|
1294
|
+
readonly forge: {
|
|
1295
|
+
run(target: Target, options?: VerifyOperationOptions): Promise<VerificationResult>;
|
|
1296
|
+
};
|
|
1297
|
+
/** Verify the Java runtime files. Honours `target.runtime.installRoot` for shared installs. */
|
|
1298
|
+
readonly runtime: {
|
|
1299
|
+
run(target: Target, options?: VerifyOperationOptions): Promise<VerificationResult>;
|
|
1300
|
+
};
|
|
1301
|
+
};
|
|
1302
|
+
readonly repair: {
|
|
1303
|
+
/** Repair the vanilla Minecraft slice (client jar, libraries, assets, natives, log config). */
|
|
1304
|
+
readonly minecraft: RepairAspect;
|
|
1305
|
+
/** Repair the Fabric loader slice (profile JSON + libraries). Throws on non-Fabric targets. */
|
|
1306
|
+
readonly fabric: RepairAspect;
|
|
1307
|
+
/** Repair the Forge loader slice (version JSON + libraries + processors). Throws on non-Forge. */
|
|
1308
|
+
readonly forge: RepairAspect;
|
|
1309
|
+
/** Repair the Java runtime files. Honours `target.runtime.installRoot`. */
|
|
1310
|
+
readonly runtime: RepairAspect;
|
|
1311
|
+
};
|
|
1312
|
+
readonly launch: {
|
|
1313
|
+
compose(target: Target, options: LaunchOptions): Promise<LaunchComposition>;
|
|
1314
|
+
run(composition: LaunchComposition, options?: LaunchRunOptions): LaunchSession;
|
|
1315
|
+
};
|
|
1316
|
+
/** Cache surface useful for advanced consumers (e.g. clearing between operations). */
|
|
1317
|
+
readonly cache: MetadataCache;
|
|
1318
|
+
constructor(options?: MinecraftKitOptions);
|
|
1319
|
+
}
|
|
1320
|
+
/** Options accepted by every `verify.<kind>.run`. */
|
|
1321
|
+
interface VerifyOperationOptions {
|
|
1322
|
+
readonly signal?: AbortSignal;
|
|
1323
|
+
readonly onEvent?: ProgressListener;
|
|
1324
|
+
}
|
|
1325
|
+
/** Options for any `repair.<aspect>.plan` call. Accepts one or many verification results. */
|
|
1326
|
+
interface RepairPlanOptions {
|
|
1327
|
+
readonly from: VerificationResult | readonly VerificationResult[];
|
|
1328
|
+
readonly signal?: AbortSignal;
|
|
1329
|
+
}
|
|
1330
|
+
/** Shared shape of every aspect-specific repair surface (`repair.minecraft`, `.fabric`, …). */
|
|
1331
|
+
interface RepairAspect {
|
|
1332
|
+
plan(target: Target, options: RepairPlanOptions): Promise<RepairPlan>;
|
|
1333
|
+
run(plan: RepairPlan, options?: OperationOptions): Promise<RepairReport>;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/** Inputs to {@link createMemoryCache}. */
|
|
1337
|
+
interface MemoryCacheOptions {
|
|
1338
|
+
readonly maxEntries?: number;
|
|
1339
|
+
readonly ttlMs?: number;
|
|
1340
|
+
}
|
|
1341
|
+
/** In-memory metadata cache backed by `lru-cache`. */
|
|
1342
|
+
declare function createMemoryCache(options?: MemoryCacheOptions): MetadataCache;
|
|
1343
|
+
|
|
1344
|
+
/** Inputs allowing the host system to be derived from current Node values or overrides. */
|
|
1345
|
+
interface DetectSystemInput {
|
|
1346
|
+
readonly platform?: NodeJS.Platform;
|
|
1347
|
+
readonly arch?: NodeJS.Architecture;
|
|
1348
|
+
readonly osVersion?: string;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Resolve the current host system identifiers.
|
|
1352
|
+
*
|
|
1353
|
+
* @throws {@link MinecraftKitError} with code `RUNTIME_UNSUPPORTED_PLATFORM` when the
|
|
1354
|
+
* platform/arch combination is not understood.
|
|
1355
|
+
*/
|
|
1356
|
+
declare function detectSystem(input?: DetectSystemInput): RuntimeSystem;
|
|
1357
|
+
|
|
1358
|
+
/** Inputs to {@link verifyMinecraft}. */
|
|
1359
|
+
interface VerifyMinecraftInput {
|
|
1360
|
+
readonly target: Target;
|
|
1361
|
+
readonly http: HttpClient;
|
|
1362
|
+
readonly cache: MetadataCache;
|
|
1363
|
+
readonly signal?: AbortSignal;
|
|
1364
|
+
readonly onEvent?: ProgressListener;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Verify the vanilla Minecraft slice of an installation: the client jar, version JSON,
|
|
1368
|
+
* libraries (incl. native jars), assets (index + objects), logging config, and the
|
|
1369
|
+
* extracted natives directory.
|
|
1370
|
+
*/
|
|
1371
|
+
declare function verifyMinecraft(input: VerifyMinecraftInput): Promise<VerificationResult>;
|
|
1372
|
+
|
|
1373
|
+
/** Inputs to {@link verifyFabric}. */
|
|
1374
|
+
interface VerifyFabricInput {
|
|
1375
|
+
readonly target: Target;
|
|
1376
|
+
readonly http: HttpClient;
|
|
1377
|
+
readonly cache: MetadataCache;
|
|
1378
|
+
readonly signal?: AbortSignal;
|
|
1379
|
+
readonly onEvent?: ProgressListener;
|
|
1380
|
+
}
|
|
1381
|
+
/** Verify the Fabric loader slice: profile JSON + every library it pulls in. */
|
|
1382
|
+
declare function verifyFabric(input: VerifyFabricInput): Promise<VerificationResult>;
|
|
1383
|
+
|
|
1384
|
+
/** Inputs to {@link verifyForge}. */
|
|
1385
|
+
interface VerifyForgeInput {
|
|
1386
|
+
readonly target: Target;
|
|
1387
|
+
readonly http: HttpClient;
|
|
1388
|
+
readonly cache: MetadataCache;
|
|
1389
|
+
readonly signal?: AbortSignal;
|
|
1390
|
+
readonly onEvent?: ProgressListener;
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Verify the Forge loader slice: the on-disk Forge version JSON and every library it
|
|
1394
|
+
* declares. Libraries can only be enumerated once the JSON is present *and parsable*; a
|
|
1395
|
+
* malformed JSON is surfaced as a CORRUPT issue so repair rewrites it before re-running.
|
|
1396
|
+
*/
|
|
1397
|
+
declare function verifyForge(input: VerifyForgeInput): Promise<VerificationResult>;
|
|
1398
|
+
|
|
1399
|
+
/** Inputs to {@link verifyRuntime}. */
|
|
1400
|
+
interface VerifyRuntimeInput {
|
|
1401
|
+
readonly target: Target;
|
|
1402
|
+
readonly http: HttpClient;
|
|
1403
|
+
readonly cache: MetadataCache;
|
|
1404
|
+
readonly signal?: AbortSignal;
|
|
1405
|
+
readonly onEvent?: ProgressListener;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Verify the Java runtime files. Honours `target.runtime.installRoot` when set so a
|
|
1409
|
+
* shared/global runtime install is checked at its real location instead of the per-target
|
|
1410
|
+
* `runtime/` subfolder.
|
|
1411
|
+
*/
|
|
1412
|
+
declare function verifyRuntime(input: VerifyRuntimeInput): Promise<VerificationResult>;
|
|
1413
|
+
|
|
1414
|
+
/** Inputs to {@link runRepair}. Shared across all aspect-specific repair flows. */
|
|
1415
|
+
interface RunRepairInput {
|
|
1416
|
+
readonly plan: RepairPlan;
|
|
1417
|
+
readonly http: HttpClient;
|
|
1418
|
+
readonly cache: MetadataCache;
|
|
1419
|
+
readonly spawner: Spawner;
|
|
1420
|
+
readonly signal?: AbortSignal;
|
|
1421
|
+
readonly onEvent?: ProgressListener;
|
|
1422
|
+
}
|
|
1423
|
+
/** Execute any repair plan. Reuses the install runner. */
|
|
1424
|
+
declare function runRepair(input: RunRepairInput): Promise<RepairReport>;
|
|
1425
|
+
|
|
1426
|
+
/** Inputs to {@link planMinecraftRepair}. */
|
|
1427
|
+
type PlanMinecraftRepairInput = AspectRepairInput;
|
|
1428
|
+
/**
|
|
1429
|
+
* Build a repair plan covering only the vanilla Minecraft slice: client jar, version JSON,
|
|
1430
|
+
* libraries (incl. native jars), assets, logging config, and native extractions.
|
|
1431
|
+
*/
|
|
1432
|
+
declare function planMinecraftRepair(input: PlanMinecraftRepairInput): Promise<RepairPlan>;
|
|
1433
|
+
|
|
1434
|
+
/** Inputs to {@link planFabricRepair}. */
|
|
1435
|
+
type PlanFabricRepairInput = AspectRepairInput;
|
|
1436
|
+
/** Build a repair plan covering the Fabric loader slice: profile JSON + libraries. */
|
|
1437
|
+
declare function planFabricRepair(input: PlanFabricRepairInput): Promise<RepairPlan>;
|
|
1438
|
+
|
|
1439
|
+
/** Inputs to {@link planForgeRepair}. */
|
|
1440
|
+
type PlanForgeRepairInput = AspectRepairInput;
|
|
1441
|
+
/**
|
|
1442
|
+
* Build a repair plan covering the Forge loader slice: version JSON, libraries, installer
|
|
1443
|
+
* download, and the Forge processors that produce the final installation. When the Forge
|
|
1444
|
+
* version JSON was missing during verify (so libraries couldn't be enumerated), every
|
|
1445
|
+
* forge-library download is added defensively — `downloadFile` skips files already on disk.
|
|
1446
|
+
*/
|
|
1447
|
+
declare function planForgeRepair(input: PlanForgeRepairInput): Promise<RepairPlan>;
|
|
1448
|
+
|
|
1449
|
+
/** Inputs to {@link planRuntimeRepair}. */
|
|
1450
|
+
type PlanRuntimeRepairInput = AspectRepairInput;
|
|
1451
|
+
/**
|
|
1452
|
+
* Build a repair plan covering the Java runtime files. `target.runtime.installRoot` is
|
|
1453
|
+
* honoured automatically because both `planInstall` and the verify side resolve runtime
|
|
1454
|
+
* paths through the same `targetPaths.runtimeRoot(..., installRoot)` helper.
|
|
1455
|
+
*/
|
|
1456
|
+
declare function planRuntimeRepair(input: PlanRuntimeRepairInput): Promise<RepairPlan>;
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* Stable error code discriminator. Consumers can `switch (e.code)` exhaustively.
|
|
1460
|
+
*
|
|
1461
|
+
* Codes are stable across releases — adding new codes is non-breaking; removing or renaming
|
|
1462
|
+
* a code is a breaking change.
|
|
1463
|
+
*/
|
|
1464
|
+
type MinecraftKitErrorCode = "NETWORK_TIMEOUT" | "NETWORK_HTTP_ERROR" | "NETWORK_ABORTED" | "INTEGRITY_HASH_MISMATCH" | "INTEGRITY_SIZE_MISMATCH" | "MANIFEST_INVALID" | "MANIFEST_NOT_FOUND" | "METADATA_PARSE_ERROR" | "FILESYSTEM_PATH_TRAVERSAL" | "FILESYSTEM_WRITE_ERROR" | "FILESYSTEM_READ_ERROR" | "ARCHIVE_INVALID" | "ARCHIVE_TOO_LARGE" | "ARCHIVE_ENTRY_REJECTED" | "RUNTIME_NOT_FOUND" | "RUNTIME_UNSUPPORTED_PLATFORM" | "FORGE_PROCESSOR_FAILED" | "FORGE_INSTALLER_INVALID" | "LAUNCH_JAVA_NOT_FOUND" | "LAUNCH_PROCESS_FAILED" | "LAUNCH_ABORTED" | "VERIFICATION_FAILED" | "INVALID_INPUT" | "NOT_IMPLEMENTED" | "UNSUPPORTED_VERSION" | "LZMA_DECODE_ERROR";
|
|
1465
|
+
/** Structured context attached to errors. */
|
|
1466
|
+
interface MinecraftKitErrorContext {
|
|
1467
|
+
readonly url?: string;
|
|
1468
|
+
readonly filePath?: string;
|
|
1469
|
+
readonly expectedHash?: string;
|
|
1470
|
+
readonly actualHash?: string;
|
|
1471
|
+
readonly expectedSize?: number;
|
|
1472
|
+
readonly actualSize?: number;
|
|
1473
|
+
readonly httpStatus?: number;
|
|
1474
|
+
readonly exitCode?: number;
|
|
1475
|
+
readonly platform?: string;
|
|
1476
|
+
readonly version?: string;
|
|
1477
|
+
readonly [key: string]: unknown;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
/**
|
|
1481
|
+
* The single error class thrown by every public API in `@loontail/minecraft-kit`.
|
|
1482
|
+
*
|
|
1483
|
+
* Use {@link isMinecraftKitError} or {@link isErrorCode} for type-narrowing in `catch` blocks.
|
|
1484
|
+
*/
|
|
1485
|
+
declare class MinecraftKitError extends Error {
|
|
1486
|
+
readonly name = "MinecraftKitError";
|
|
1487
|
+
/** Stable discriminator. */
|
|
1488
|
+
readonly code: MinecraftKitErrorCode;
|
|
1489
|
+
/** Structured context; safe to serialize. */
|
|
1490
|
+
readonly context: Readonly<MinecraftKitErrorContext>;
|
|
1491
|
+
constructor(code: MinecraftKitErrorCode, message: string, options?: {
|
|
1492
|
+
cause?: unknown;
|
|
1493
|
+
context?: MinecraftKitErrorContext;
|
|
1494
|
+
});
|
|
1495
|
+
/** JSON-friendly representation. */
|
|
1496
|
+
toJSON(): Record<string, unknown>;
|
|
1497
|
+
}
|
|
1498
|
+
/** True when `e` is an {@link MinecraftKitError}. */
|
|
1499
|
+
declare function isMinecraftKitError(e: unknown): e is MinecraftKitError;
|
|
1500
|
+
/** True when `e` is an {@link MinecraftKitError} carrying the given code. */
|
|
1501
|
+
declare function isErrorCode<C extends MinecraftKitErrorCode>(e: unknown, code: C): e is MinecraftKitError & {
|
|
1502
|
+
code: C;
|
|
1503
|
+
};
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* Derive a stable v3-style UUID for an offline player username.
|
|
1507
|
+
*
|
|
1508
|
+
* Mojang's offline-mode formula: `MD5("OfflinePlayer:" + name)` with the version/variant
|
|
1509
|
+
* bits patched to UUID v3.
|
|
1510
|
+
*/
|
|
1511
|
+
declare function offlineUuidFor(username: string): string;
|
|
1512
|
+
/** Strip the dashes from a UUID. Used by `${auth_uuid}`. */
|
|
1513
|
+
declare function stripUuidDashes(uuid: string): string;
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Default {@link HttpClient} implementation backed by Node's built-in `fetch` (undici under
|
|
1517
|
+
* the hood). Maps fetch errors to {@link MinecraftKitError}.
|
|
1518
|
+
*/
|
|
1519
|
+
declare class FetchHttpClient implements HttpClient {
|
|
1520
|
+
request(url: string, options?: HttpRequestOptions): Promise<HttpResponse>;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/** Default spawner backed by `node:child_process.spawn`. */
|
|
1524
|
+
declare class ChildProcessSpawner implements Spawner {
|
|
1525
|
+
spawn(command: string, args: readonly string[], options: SpawnOptions): SpawnedProcess;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/** Logger that drops every message. Default when no logger is supplied. */
|
|
1529
|
+
declare const silentLogger: Logger;
|
|
1530
|
+
/** Logger that mirrors messages to `console.<level>` with structured fields. */
|
|
1531
|
+
declare const consoleLogger: Logger;
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Endpoint builders for every external HTTP request the library makes. Code MUST go through
|
|
1535
|
+
* these — never hard-code URLs at call sites.
|
|
1536
|
+
*/
|
|
1537
|
+
/** Endpoint builders. */
|
|
1538
|
+
declare const ApiEndpoints: {
|
|
1539
|
+
readonly mojang: {
|
|
1540
|
+
/** Top-level Minecraft version manifest (v2). */
|
|
1541
|
+
readonly versionManifest: () => string;
|
|
1542
|
+
/** Mojang Java-runtime index. */
|
|
1543
|
+
readonly runtimeIndex: () => string;
|
|
1544
|
+
};
|
|
1545
|
+
readonly resources: {
|
|
1546
|
+
/** Hash-addressed Minecraft asset object. */
|
|
1547
|
+
readonly asset: (hash: string) => string;
|
|
1548
|
+
};
|
|
1549
|
+
readonly fabric: {
|
|
1550
|
+
readonly gameVersions: () => string;
|
|
1551
|
+
readonly loaderVersions: () => string;
|
|
1552
|
+
readonly loaderForGame: (minecraftVersion: string) => string;
|
|
1553
|
+
readonly profile: (minecraftVersion: string, loaderVersion: string) => string;
|
|
1554
|
+
};
|
|
1555
|
+
readonly forge: {
|
|
1556
|
+
/** Forge Maven listing of all builds across all MC versions. */
|
|
1557
|
+
readonly mavenMetadata: () => string;
|
|
1558
|
+
/** Slim "recommended" / "latest" promotion mapping. */
|
|
1559
|
+
readonly promotions: () => string;
|
|
1560
|
+
/** URL of the modern installer JAR for a Maven version (e.g. `1.20.1-47.2.0`). */
|
|
1561
|
+
readonly installer: (mavenVersion: string) => string;
|
|
1562
|
+
};
|
|
1563
|
+
};
|
|
1564
|
+
/** Surface type useful for DI. */
|
|
1565
|
+
type ApiEndpointsShape = typeof ApiEndpoints;
|
|
1566
|
+
|
|
1567
|
+
/** HTTP request timeout for metadata calls, in milliseconds. */
|
|
1568
|
+
declare const HTTP_TIMEOUT_MS = 30000;
|
|
1569
|
+
/** Maximum retry attempts for transient HTTP failures. */
|
|
1570
|
+
declare const HTTP_RETRY_MAX = 4;
|
|
1571
|
+
/** Base delay for exponential backoff, in milliseconds. */
|
|
1572
|
+
declare const HTTP_RETRY_BACKOFF_BASE_MS = 500;
|
|
1573
|
+
/** Maximum delay for exponential backoff, in milliseconds. */
|
|
1574
|
+
declare const HTTP_RETRY_BACKOFF_CAP_MS = 30000;
|
|
1575
|
+
/**
|
|
1576
|
+
* Default per-host concurrency for downloads. The runner uses a worker-pool: when one file
|
|
1577
|
+
* finishes, the next file in the queue starts immediately. There is no batch barrier.
|
|
1578
|
+
*/
|
|
1579
|
+
declare const DOWNLOAD_CONCURRENCY = 32;
|
|
1580
|
+
/** TTL for in-memory metadata cache entries, in milliseconds. */
|
|
1581
|
+
declare const CACHE_TTL_MS: number;
|
|
1582
|
+
/** Maximum number of entries kept in the metadata cache. */
|
|
1583
|
+
declare const CACHE_MAX_ENTRIES = 256;
|
|
1584
|
+
/** User-agent value sent on every HTTP request. */
|
|
1585
|
+
declare const USER_AGENT = "minecraft-kit/0.1";
|
|
1586
|
+
/** Default launcher brand sent through `${launcher_name}`. */
|
|
1587
|
+
declare const DEFAULT_LAUNCHER_NAME = "minecraft-kit";
|
|
1588
|
+
/** Default launcher version sent through `${launcher_version}`. */
|
|
1589
|
+
declare const DEFAULT_LAUNCHER_VERSION = "0.1.0";
|
|
1590
|
+
/** Default min heap size in megabytes. */
|
|
1591
|
+
declare const DEFAULT_MIN_MB = 1024;
|
|
1592
|
+
/** Default max heap size in megabytes. */
|
|
1593
|
+
declare const DEFAULT_MAX_MB = 4096;
|
|
1594
|
+
/** Time after a SIGTERM before escalating to SIGKILL when aborting a launch. */
|
|
1595
|
+
declare const DEFAULT_KILL_GRACE_MS = 5000;
|
|
1596
|
+
/** Throttle interval for emitting download:progress events (in milliseconds). */
|
|
1597
|
+
declare const PROGRESS_EVENT_INTERVAL_MS = 100;
|
|
1598
|
+
/** Maximum number of stderr lines retained from a Forge processor for diagnostics. */
|
|
1599
|
+
declare const MAX_PROCESSOR_STDERR_LINES = 20;
|
|
1600
|
+
/**
|
|
1601
|
+
* Maximum bytes per line emitted by {@link ChildProcessSpawner}. Lines longer than this
|
|
1602
|
+
* are split: a Minecraft crash that prints megabytes of unbroken text should not exhaust
|
|
1603
|
+
* memory inside the launcher.
|
|
1604
|
+
*/
|
|
1605
|
+
declare const SPAWNER_MAX_LINE_BYTES: number;
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
1608
|
+
* Relative-path segments used to build per-target directory layouts.
|
|
1609
|
+
*
|
|
1610
|
+
* These are SEGMENTS — never use them as absolute paths. Compose with `path.join` at call sites.
|
|
1611
|
+
*/
|
|
1612
|
+
declare const VERSIONS_DIR = "versions";
|
|
1613
|
+
declare const LIBRARIES_DIR = "libraries";
|
|
1614
|
+
declare const ASSETS_DIR = "assets";
|
|
1615
|
+
declare const ASSETS_OBJECTS_DIR = "assets/objects";
|
|
1616
|
+
declare const ASSETS_INDEXES_DIR = "assets/indexes";
|
|
1617
|
+
declare const ASSETS_VIRTUAL_DIR = "assets/virtual";
|
|
1618
|
+
declare const ASSETS_LEGACY_DIR = "assets/virtual/legacy";
|
|
1619
|
+
declare const ASSETS_RESOURCES_DIR = "resources";
|
|
1620
|
+
declare const ASSETS_LOG_CONFIGS_DIR = "assets/log_configs";
|
|
1621
|
+
declare const RUNTIMES_DIR = "runtime";
|
|
1622
|
+
declare const NATIVES_DIR_NAME = "natives";
|
|
1623
|
+
declare const FORGE_INSTALLERS_DIR = "forge-installers";
|
|
1624
|
+
/** Java executable filename per OS (relative to the runtime root). */
|
|
1625
|
+
declare const JAVA_EXECUTABLE: {
|
|
1626
|
+
readonly windows: "bin/javaw.exe";
|
|
1627
|
+
readonly windowsConsole: "bin/java.exe";
|
|
1628
|
+
readonly linux: "bin/java";
|
|
1629
|
+
/** Note: macOS uses an extra `jre.bundle/Contents/Home/` prefix above this. */
|
|
1630
|
+
readonly osx: "bin/java";
|
|
1631
|
+
};
|
|
1632
|
+
/** macOS runtime layout adds this prefix above {@link JAVA_EXECUTABLE.osx}. */
|
|
1633
|
+
declare const MAC_RUNTIME_PREFIX = "jre.bundle/Contents/Home";
|
|
1634
|
+
|
|
1635
|
+
/** JVM args appended for every launch. */
|
|
1636
|
+
declare const BASE_JVM_ARGS: readonly ["-XX:+UnlockExperimentalVMOptions", "-XX:+UseG1GC", "-XX:G1NewSizePercent=20", "-XX:G1ReservePercent=20", "-XX:MaxGCPauseMillis=50", "-XX:G1HeapRegionSize=32M"];
|
|
1637
|
+
/** JVM args added for legacy (≤1.12) versions that lack `arguments.jvm`. */
|
|
1638
|
+
declare const LEGACY_JVM_ARGS: readonly ["-Djava.library.path=${natives_directory}", "-Dminecraft.launcher.brand=${launcher_name}", "-Dminecraft.launcher.version=${launcher_version}", "-cp", "${classpath}"];
|
|
1639
|
+
/** macOS-only JVM args (suppress dock label). */
|
|
1640
|
+
declare const MACOS_JVM_ARGS: readonly ["-Xdock:name=Minecraft"];
|
|
1641
|
+
|
|
1642
|
+
/** Per-file size cap during archive extraction (bytes). */
|
|
1643
|
+
declare const EXTRACTION_MAX_FILE_SIZE: number;
|
|
1644
|
+
/** Total decompressed-bytes cap per archive. */
|
|
1645
|
+
declare const EXTRACTION_MAX_TOTAL_SIZE: number;
|
|
1646
|
+
/** Maximum compression ratio (decompressed / compressed) before treating as a zip bomb. */
|
|
1647
|
+
declare const EXTRACTION_MAX_COMPRESSION_RATIO = 200;
|
|
1648
|
+
/** Maximum entry count per archive. */
|
|
1649
|
+
declare const EXTRACTION_MAX_ENTRY_COUNT = 100000;
|
|
1650
|
+
/** Reasonable maximum bytes a Forge installer JAR can be. */
|
|
1651
|
+
declare const FORGE_INSTALLER_MAX_SIZE: number;
|
|
1652
|
+
|
|
1653
|
+
/** Default Maven base URL when a library entry has no `url`. */
|
|
1654
|
+
declare const DEFAULT_LIBRARY_REPOSITORY = "https://libraries.minecraft.net/";
|
|
1655
|
+
/** Fabric's Maven base. */
|
|
1656
|
+
declare const FABRIC_MAVEN_BASE = "https://maven.fabricmc.net/";
|
|
1657
|
+
/** Forge's Maven base. */
|
|
1658
|
+
declare const FORGE_MAVEN_BASE = "https://maven.minecraftforge.net/";
|
|
1659
|
+
|
|
1660
|
+
/**
|
|
1661
|
+
* All `${...}` tokens substituted into JVM and game arguments.
|
|
1662
|
+
*
|
|
1663
|
+
* This map drives both substitution at launch time and documentation generation.
|
|
1664
|
+
*/
|
|
1665
|
+
declare const LAUNCH_PLACEHOLDERS: {
|
|
1666
|
+
readonly "${auth_player_name}": "Player display name.";
|
|
1667
|
+
readonly "${version_name}": "Resolved Minecraft version id.";
|
|
1668
|
+
readonly "${game_directory}": "Per-target directory.";
|
|
1669
|
+
readonly "${assets_root}": "Assets root (`<directory>/assets`).";
|
|
1670
|
+
readonly "${assets_index_name}": "Asset index id from the manifest.";
|
|
1671
|
+
readonly "${auth_uuid}": "Player UUID (no dashes).";
|
|
1672
|
+
readonly "${auth_access_token}": "Yggdrasil/MSA access token.";
|
|
1673
|
+
readonly "${auth_session}": "Legacy session token (`token:<token>:<uuid>`).";
|
|
1674
|
+
readonly "${clientid}": "MSA client id.";
|
|
1675
|
+
readonly "${auth_xuid}": "Xbox user id.";
|
|
1676
|
+
readonly "${user_type}": "`msa` | `mojang` | `legacy`.";
|
|
1677
|
+
readonly "${user_properties}": "User properties JSON (often `{}`).";
|
|
1678
|
+
readonly "${version_type}": "Channel string, e.g. `release`.";
|
|
1679
|
+
readonly "${game_assets}": "Legacy virtual assets directory.";
|
|
1680
|
+
readonly "${resolution_width}": "Window width (feature-gated).";
|
|
1681
|
+
readonly "${resolution_height}": "Window height (feature-gated).";
|
|
1682
|
+
readonly "${natives_directory}": "Extracted natives directory.";
|
|
1683
|
+
readonly "${classpath}": "Joined classpath of libraries + version jar.";
|
|
1684
|
+
readonly "${classpath_separator}": "OS-specific classpath separator (`:` / `;`).";
|
|
1685
|
+
readonly "${library_directory}": "Per-target libraries directory.";
|
|
1686
|
+
readonly "${launcher_name}": "Launcher brand string.";
|
|
1687
|
+
readonly "${launcher_version}": "Launcher version string.";
|
|
1688
|
+
readonly "${path}": "Path to the log4j config file (logging.client.argument only).";
|
|
1689
|
+
};
|
|
1690
|
+
/** Token literal type. */
|
|
1691
|
+
type LaunchPlaceholder = keyof typeof LAUNCH_PLACEHOLDERS;
|
|
1692
|
+
|
|
1693
|
+
/** Mapping from Node's `process.platform` to Mojang OS names. */
|
|
1694
|
+
declare const NODE_PLATFORM_TO_MOJANG_OS: {
|
|
1695
|
+
readonly win32: "windows";
|
|
1696
|
+
readonly darwin: "osx";
|
|
1697
|
+
readonly linux: "linux";
|
|
1698
|
+
};
|
|
1699
|
+
/** Mapping from Node's `process.arch` to Mojang/Mojang-runtime arch tags. */
|
|
1700
|
+
declare const NODE_ARCH_TO_MOJANG_ARCH: {
|
|
1701
|
+
readonly x64: "x64";
|
|
1702
|
+
readonly ia32: "x86";
|
|
1703
|
+
readonly arm64: "arm64";
|
|
1704
|
+
};
|
|
1705
|
+
/** Mapping from {OperatingSystem, Architecture} to the runtime-index platform key. */
|
|
1706
|
+
declare const RUNTIME_PLATFORM_KEYS: Readonly<Record<OperatingSystem, Readonly<Record<Architecture, string>>>>;
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* Fallback Mojang component when the per-version manifest declares none. Pre-1.7 vanilla
|
|
1710
|
+
* versions and a handful of legacy snapshots fall in this bucket.
|
|
1711
|
+
*/
|
|
1712
|
+
declare const FALLBACK_COMPONENT: string;
|
|
1713
|
+
|
|
1714
|
+
export { ASSETS_DIR, ASSETS_INDEXES_DIR, ASSETS_LEGACY_DIR, ASSETS_LOG_CONFIGS_DIR, ASSETS_OBJECTS_DIR, ASSETS_RESOURCES_DIR, ASSETS_VIRTUAL_DIR, ApiEndpoints, type ApiEndpointsShape, type Architecture, Architectures, type ArgumentEntry, type ArtifactDownload, type AspectRepairInput, type AssetIndexDocument, type AssetIndexReference, type AssetObject, type AuthMode, AuthModes, BASE_JVM_ARGS, CACHE_MAX_ENTRIES, CACHE_TTL_MS, ChildProcessSpawner, DEFAULT_KILL_GRACE_MS, DEFAULT_LAUNCHER_NAME, DEFAULT_LAUNCHER_VERSION, DEFAULT_LIBRARY_REPOSITORY, DEFAULT_MAX_MB, DEFAULT_MIN_MB, DOWNLOAD_CONCURRENCY, type DetectSystemInput, type DiscoveredLoaderHint, type DiscoveredRuntimeHint, type DiscoveredTarget, type DownloadAction, EXTRACTION_MAX_COMPRESSION_RATIO, EXTRACTION_MAX_ENTRY_COUNT, EXTRACTION_MAX_FILE_SIZE, EXTRACTION_MAX_TOTAL_SIZE, type EventType, EventTypes, type ExtractNativeAction, FABRIC_MAVEN_BASE, FALLBACK_COMPONENT, FORGE_INSTALLERS_DIR, FORGE_INSTALLER_MAX_SIZE, FORGE_MAVEN_BASE, type FabricCompatibilityEntry, type FabricListInput, type FabricLoaderSummary, type FabricProfile, type FabricResolveInput, FabricVersionsApi, FetchHttpClient, type FileRef, type ForgeBuildSummary, type ForgeInstallProfile, type ForgeListInput, type ForgeProcessor, type ForgeProfileData, type ForgeResolveInput, type ForgeVersionJson, ForgeVersionsApi, HTTP_RETRY_BACKOFF_BASE_MS, HTTP_RETRY_BACKOFF_CAP_MS, HTTP_RETRY_MAX, HTTP_TIMEOUT_MS, type HttpClient, type HttpHeaders, type HttpRequestOptions, type HttpResponse, type InstallAction, type InstallActionKind, InstallActionKinds, type InstallPhase, InstallPhases, type InstallPlan, type InstallReport, JAVA_EXECUTABLE, LAUNCH_PLACEHOLDERS, LEGACY_JVM_ARGS, LIBRARIES_DIR, type LaunchAuth, type LaunchComposition, type LaunchExit, type LaunchMemoryOptions, type LaunchOptions, type LaunchPlaceholder, type LaunchResolutionOptions, type LaunchRunOptions, type LaunchSession, type LibraryArtifact, type LibraryRule, type Loader, type LoaderKind, Loaders, type LogLevel, LogLevels, type Logger, MACOS_JVM_ARGS, MAC_RUNTIME_PREFIX, MAX_PROCESSOR_STDERR_LINES, type MemoryCacheOptions, type MetadataCache, type MinecraftArguments, type MinecraftChannel, MinecraftChannels, type MinecraftDownloads, type MinecraftGetInput, type MinecraftJavaVersion, MinecraftKit, MinecraftKitError, type MinecraftKitErrorCode, type MinecraftKitErrorContext, type MinecraftKitOptions, type MinecraftLatestInput, type MinecraftLibrary, type MinecraftLibraryDownloads, type MinecraftListInput, type MinecraftLogging, type MinecraftVersionManifest, type MinecraftVersionSummary, MinecraftVersionsApi, NATIVES_DIR_NAME, NODE_ARCH_TO_MOJANG_ARCH, NODE_PLATFORM_TO_MOJANG_OS, type OfflineAuth, type OnlineAuth, type OperatingSystem, OperatingSystems, type OperationOptions, PROGRESS_EVENT_INTERVAL_MS, type PlanFabricRepairInput, type PlanForgeRepairInput, type PlanMinecraftRepairInput, type PlanRuntimeInstallInput, type PlanRuntimeRepairInput, type PlanStandaloneRuntimeInstallInput, type ProcessStream, type ProcessorRef, type ProgressEvent, type ProgressListener, RUNTIMES_DIR, RUNTIME_PLATFORM_KEYS, type RepairAspect, type RepairPhase, RepairPhases, type RepairPlan, type RepairPlanOptions, type RepairReport, type ResolvedFabricLoader, type ResolvedForgeLoader, type ResolvedMinecraft, type ResolvedRuntime, type ResolvedVanillaLoader, type ResolverContext, type RunForgeProcessorAction, type RunRepairInput, type RuntimeComponent, RuntimeComponents, type RuntimeFileDirectory, type RuntimeFileEntry, type RuntimeFileFile, type RuntimeFileLink, type RuntimeFilesManifest, type RuntimeIndex, type RuntimeIndexEntry, type RuntimeIndexPlatform, type RuntimeListEntry, type RuntimeListInput, RuntimePreference, type RuntimePreferenceKind, type RuntimeResolveInput, type RuntimeSystem, RuntimeVersionsApi, SPAWNER_MAX_LINE_BYTES, type SpawnOptions, type SpawnedProcess, type Spawner, type Target, type TargetCreateInput, type TargetListInput, type TargetLoaderInput, type TargetResolveInput, TargetsApi, type TargetsApiContext, USER_AGENT, type UpdatePlan, type UpdateReport, VERSIONS_DIR, type VerificationFileResult, type VerificationKind, VerificationKinds, type VerificationResult, type VerifyFabricInput, VerifyFileCategories, type VerifyFileCategory, type VerifyFileStatus, VerifyFileStatuses, type VerifyForgeInput, type VerifyMinecraftInput, type VerifyOperationOptions, type VerifyRuntimeInput, VersionPreference, type VersionPreferenceKind, type WriteLoggingConfigAction, type WriteVersionJsonAction, consoleLogger, createMemoryCache, detectSystem, isErrorCode, isMinecraftKitError, offlineUuidFor, planFabricRepair, planForgeRepair, planMinecraftRepair, planRuntimeInstall, planRuntimeRepair, planStandaloneRuntimeInstall, runRepair, silentLogger, stripUuidDashes, verifyFabric, verifyForge, verifyMinecraft, verifyRuntime };
|