@bkm016/calcite 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +416 -2
- package/THIRD_PARTY_NOTICES.md +44 -0
- package/dist/accounts.d.ts +46 -0
- package/dist/accounts.js +194 -0
- package/dist/accounts.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +332 -0
- package/dist/cli.js.map +1 -0
- package/dist/client-core.d.ts +66 -0
- package/dist/client-core.js +530 -0
- package/dist/client-core.js.map +1 -0
- package/dist/client.d.ts +127 -0
- package/dist/client.js +185 -0
- package/dist/client.js.map +1 -0
- package/dist/display.d.ts +23 -0
- package/dist/display.js +164 -0
- package/dist/display.js.map +1 -0
- package/dist/hmc.d.ts +53 -0
- package/dist/hmc.js +168 -0
- package/dist/hmc.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +48 -0
- package/dist/install.js +119 -0
- package/dist/install.js.map +1 -0
- package/dist/java.d.ts +37 -0
- package/dist/java.js +222 -0
- package/dist/java.js.map +1 -0
- package/dist/loaders.d.ts +41 -0
- package/dist/loaders.js +86 -0
- package/dist/loaders.js.map +1 -0
- package/dist/lock.d.ts +13 -0
- package/dist/lock.js +79 -0
- package/dist/lock.js.map +1 -0
- package/dist/log.d.ts +13 -0
- package/dist/log.js +20 -0
- package/dist/log.js.map +1 -0
- package/dist/manager.d.ts +15 -0
- package/dist/manager.js +65 -0
- package/dist/manager.js.map +1 -0
- package/dist/mcp.d.ts +13 -0
- package/dist/mcp.js +377 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mods.d.ts +21 -0
- package/dist/mods.js +135 -0
- package/dist/mods.js.map +1 -0
- package/dist/mojang.d.ts +54 -0
- package/dist/mojang.js +73 -0
- package/dist/mojang.js.map +1 -0
- package/dist/names.d.ts +53 -0
- package/dist/names.js +267 -0
- package/dist/names.js.map +1 -0
- package/dist/net.d.ts +26 -0
- package/dist/net.js +286 -0
- package/dist/net.js.map +1 -0
- package/dist/options.d.ts +14 -0
- package/dist/options.js +50 -0
- package/dist/options.js.map +1 -0
- package/dist/paths.d.ts +29 -0
- package/dist/paths.js +49 -0
- package/dist/paths.js.map +1 -0
- package/dist/probe-server.d.ts +28 -0
- package/dist/probe-server.js +132 -0
- package/dist/probe-server.js.map +1 -0
- package/dist/types.d.ts +235 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/dist/zip.d.ts +5 -0
- package/dist/zip.js +65 -0
- package/dist/zip.js.map +1 -0
- package/package.json +57 -4
- package/vendor/calcite-probe.jar +0 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import type { CalcitePaths } from './paths.js';
|
|
2
|
+
export type RenderMode = 'off' | 'on-demand' | 'always';
|
|
3
|
+
export type Account = {
|
|
4
|
+
type: 'offline';
|
|
5
|
+
username: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'microsoft';
|
|
8
|
+
name?: string;
|
|
9
|
+
};
|
|
10
|
+
export type Phase = 'idle' | 'preparing' | 'waiting_for_server' | 'starting' | 'connecting' | 'in_game' | 'disconnected' | 'reconnecting' | 'stopping' | 'stopped' | 'crashed';
|
|
11
|
+
export interface ServerAddress {
|
|
12
|
+
host: string;
|
|
13
|
+
port: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ClientOptions {
|
|
16
|
+
/** Instance name; also the game directory name. Letters, digits, '-', '_' and '.' only. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Minecraft version id, "latest" or "snapshot". */
|
|
19
|
+
version: string;
|
|
20
|
+
/**
|
|
21
|
+
* Mod loader: "fabric", "forge" or "neoforge", optionally with a loader version ("fabric@0.19.5"). Installed on
|
|
22
|
+
* first use; without a version the newest installed one (or the loader's current release) is used.
|
|
23
|
+
*/
|
|
24
|
+
loader?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Mods to put in the game's mods folder (needs a loader): local jars or folders of jars, http(s) URLs, or
|
|
27
|
+
* "modrinth:<project>[@<version>]" (resolved for this Minecraft version and loader, with required dependencies).
|
|
28
|
+
* Mods Calcite placed earlier and no longer listed are removed; other files in the folder are kept.
|
|
29
|
+
*/
|
|
30
|
+
mods?: string[];
|
|
31
|
+
/** Server to join ("host[:port]"). Without a server the client stays on the title screen. */
|
|
32
|
+
server?: string | ServerAddress;
|
|
33
|
+
/** Account: offline (any username, for online-mode=false servers) or a stored Microsoft account. */
|
|
34
|
+
account?: Account;
|
|
35
|
+
/**
|
|
36
|
+
* World rendering: 'off' (no renderer, cheapest, no screenshots), 'on-demand' (renders only for screenshots,
|
|
37
|
+
* default), 'always'. Rendering needs a display (Linux: DISPLAY or Xvfb) and, with an offline account, Linux.
|
|
38
|
+
*/
|
|
39
|
+
render?: RenderMode;
|
|
40
|
+
/** Explicit java executable for the game. */
|
|
41
|
+
javaPath?: string;
|
|
42
|
+
/** Download a Temurin runtime when the required Java is missing (default true). */
|
|
43
|
+
allowJavaDownload?: boolean;
|
|
44
|
+
/** Max heap, e.g. "2G" (default "2G"). */
|
|
45
|
+
memory?: string;
|
|
46
|
+
/** Extra JVM / game arguments (must not contain spaces). */
|
|
47
|
+
jvmArgs?: string[];
|
|
48
|
+
gameArgs?: string[];
|
|
49
|
+
renderDistance?: number;
|
|
50
|
+
maxFps?: number;
|
|
51
|
+
/** Reconnect (relaunch) after a disconnect or crash. Default: enabled, 10 attempts. */
|
|
52
|
+
reconnect?: boolean | {
|
|
53
|
+
maxAttempts?: number;
|
|
54
|
+
};
|
|
55
|
+
/** How long to wait for the server port before launching (default 120 s). */
|
|
56
|
+
waitForServerMs?: number;
|
|
57
|
+
/** Overall start timeout including downloads (default 15 min). */
|
|
58
|
+
startTimeoutMs?: number;
|
|
59
|
+
paths?: CalcitePaths;
|
|
60
|
+
}
|
|
61
|
+
export interface LogLine {
|
|
62
|
+
seq: number;
|
|
63
|
+
time: number;
|
|
64
|
+
source: 'game' | 'calcite';
|
|
65
|
+
line: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ChatLine {
|
|
68
|
+
seq: number;
|
|
69
|
+
time: number;
|
|
70
|
+
message: string;
|
|
71
|
+
}
|
|
72
|
+
export interface PlayerState {
|
|
73
|
+
id?: number;
|
|
74
|
+
uuid?: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
x?: number;
|
|
77
|
+
y?: number;
|
|
78
|
+
z?: number;
|
|
79
|
+
yaw?: number;
|
|
80
|
+
pitch?: number;
|
|
81
|
+
health?: number;
|
|
82
|
+
food?: number;
|
|
83
|
+
/** survival, creative, adventure or spectator. */
|
|
84
|
+
gameMode?: string;
|
|
85
|
+
dimension?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface MoveControls {
|
|
88
|
+
forward?: boolean;
|
|
89
|
+
back?: boolean;
|
|
90
|
+
left?: boolean;
|
|
91
|
+
right?: boolean;
|
|
92
|
+
jump?: boolean;
|
|
93
|
+
sneak?: boolean;
|
|
94
|
+
sprint?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface BlockPosition {
|
|
97
|
+
x: number;
|
|
98
|
+
y: number;
|
|
99
|
+
z: number;
|
|
100
|
+
}
|
|
101
|
+
export type BlockFace = 'down' | 'up' | 'north' | 'south' | 'west' | 'east';
|
|
102
|
+
export type ClickMode = 'pickup' | 'quick_move' | 'swap' | 'clone' | 'throw' | 'quick_craft' | 'pickup_all';
|
|
103
|
+
export interface WalkResult {
|
|
104
|
+
arrived: boolean;
|
|
105
|
+
/** Why it stopped early: "stuck" or "timeout". */
|
|
106
|
+
reason?: string;
|
|
107
|
+
/** Remaining horizontal distance. */
|
|
108
|
+
distance: number;
|
|
109
|
+
x: number;
|
|
110
|
+
y: number;
|
|
111
|
+
z: number;
|
|
112
|
+
}
|
|
113
|
+
export interface DigResult {
|
|
114
|
+
broken: boolean;
|
|
115
|
+
reason?: string;
|
|
116
|
+
block?: string;
|
|
117
|
+
ticks?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface HitTarget {
|
|
120
|
+
type: 'block' | 'entity' | 'miss';
|
|
121
|
+
x?: number;
|
|
122
|
+
y?: number;
|
|
123
|
+
z?: number;
|
|
124
|
+
face?: BlockFace;
|
|
125
|
+
block?: string;
|
|
126
|
+
entity?: EntityInfo;
|
|
127
|
+
holdTicks?: number;
|
|
128
|
+
}
|
|
129
|
+
export interface BlockInfo extends BlockPosition {
|
|
130
|
+
/** false when the chunk is not loaded on the client. */
|
|
131
|
+
loaded?: boolean;
|
|
132
|
+
id?: string;
|
|
133
|
+
air?: boolean;
|
|
134
|
+
/** Block state properties, e.g. "facing=north,type=single,waterlogged=false". */
|
|
135
|
+
properties?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface ItemInfo {
|
|
138
|
+
id: string;
|
|
139
|
+
count: number;
|
|
140
|
+
name: string;
|
|
141
|
+
damage?: number;
|
|
142
|
+
maxDamage?: number;
|
|
143
|
+
}
|
|
144
|
+
export interface InventoryInfo {
|
|
145
|
+
/** Selected hotbar slot (0-8). */
|
|
146
|
+
selected: number;
|
|
147
|
+
/** Non-empty slots: 0-8 hotbar, 9-35 main, 36-39 armor, 40 offhand. */
|
|
148
|
+
items: (ItemInfo & {
|
|
149
|
+
slot: number;
|
|
150
|
+
})[];
|
|
151
|
+
}
|
|
152
|
+
export interface ContainerInfo {
|
|
153
|
+
/** A container other than the player's own inventory is open. */
|
|
154
|
+
open: boolean;
|
|
155
|
+
containerId?: number;
|
|
156
|
+
/** Menu type, e.g. "minecraft:generic_9x3" for a chest. */
|
|
157
|
+
type?: string | null;
|
|
158
|
+
title?: string;
|
|
159
|
+
/** Total slots; slots 0..containerSlots-1 belong to the container, the rest to the player. */
|
|
160
|
+
size?: number;
|
|
161
|
+
containerSlots?: number;
|
|
162
|
+
/** Non-empty slots (menu slot index; inventorySlot for the player's own slots). */
|
|
163
|
+
items?: (ItemInfo & {
|
|
164
|
+
slot: number;
|
|
165
|
+
inventorySlot?: number;
|
|
166
|
+
})[];
|
|
167
|
+
/** Stack held by the cursor. */
|
|
168
|
+
carried?: ItemInfo;
|
|
169
|
+
}
|
|
170
|
+
export interface GameState {
|
|
171
|
+
ready: boolean;
|
|
172
|
+
headless: boolean;
|
|
173
|
+
inGame: boolean;
|
|
174
|
+
screen?: string | null;
|
|
175
|
+
/** A resource (re)load overlay is showing. */
|
|
176
|
+
loading?: boolean;
|
|
177
|
+
disconnectReason?: string | null;
|
|
178
|
+
fps?: number;
|
|
179
|
+
noRender?: boolean;
|
|
180
|
+
player?: PlayerState;
|
|
181
|
+
}
|
|
182
|
+
export interface EntityInfo {
|
|
183
|
+
id: number;
|
|
184
|
+
uuid: string;
|
|
185
|
+
type: string;
|
|
186
|
+
x?: number;
|
|
187
|
+
y?: number;
|
|
188
|
+
z?: number;
|
|
189
|
+
yaw?: number;
|
|
190
|
+
pitch?: number;
|
|
191
|
+
name?: string;
|
|
192
|
+
customName?: string;
|
|
193
|
+
vehicleId?: number | null;
|
|
194
|
+
invisible?: boolean;
|
|
195
|
+
removed?: boolean;
|
|
196
|
+
}
|
|
197
|
+
export interface EntityQuery {
|
|
198
|
+
/** Only entities within this distance of the player (blocks). */
|
|
199
|
+
radius?: number;
|
|
200
|
+
/** Entity type id, e.g. "minecraft:villager" (the "minecraft:" prefix is optional). */
|
|
201
|
+
type?: string;
|
|
202
|
+
uuid?: string;
|
|
203
|
+
/** Substring match on name or custom name (case-insensitive). */
|
|
204
|
+
name?: string;
|
|
205
|
+
limit?: number;
|
|
206
|
+
includeSelf?: boolean;
|
|
207
|
+
}
|
|
208
|
+
export interface ClientStatus {
|
|
209
|
+
name: string;
|
|
210
|
+
version: string;
|
|
211
|
+
/** Mod loader and its version, e.g. "fabric@0.19.5". */
|
|
212
|
+
loader?: string;
|
|
213
|
+
/** File names of the mods Calcite placed in the mods folder. */
|
|
214
|
+
mods?: string[];
|
|
215
|
+
phase: Phase;
|
|
216
|
+
render: RenderMode;
|
|
217
|
+
headless: boolean;
|
|
218
|
+
account: Account;
|
|
219
|
+
server?: ServerAddress;
|
|
220
|
+
gameDir: string;
|
|
221
|
+
pid?: number;
|
|
222
|
+
java?: string;
|
|
223
|
+
startedAt?: number;
|
|
224
|
+
reconnects: number;
|
|
225
|
+
lastError?: string;
|
|
226
|
+
probeConnected: boolean;
|
|
227
|
+
game?: GameState;
|
|
228
|
+
}
|
|
229
|
+
export declare class CalciteError extends Error {
|
|
230
|
+
readonly code: string;
|
|
231
|
+
constructor(code: string, message: string);
|
|
232
|
+
}
|
|
233
|
+
export declare function parseServer(server: string | ServerAddress): ServerAddress;
|
|
234
|
+
/** Offline username derived from a client name (3-16 chars of [A-Za-z0-9_]). */
|
|
235
|
+
export declare function defaultUsername(name: string): string;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class CalciteError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(code, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.name = 'CalciteError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function parseServer(server) {
|
|
10
|
+
if (typeof server !== 'string')
|
|
11
|
+
return { host: server.host, port: server.port || 25565 };
|
|
12
|
+
const s = server.trim();
|
|
13
|
+
const v6 = /^\[([^\]]+)\](?::(\d+))?$/.exec(s);
|
|
14
|
+
if (v6)
|
|
15
|
+
return { host: v6[1], port: v6[2] ? Number(v6[2]) : 25565 };
|
|
16
|
+
const idx = s.lastIndexOf(':');
|
|
17
|
+
if (idx > 0 && s.indexOf(':') === idx)
|
|
18
|
+
return { host: s.slice(0, idx), port: Number(s.slice(idx + 1)) };
|
|
19
|
+
return { host: s, port: 25565 };
|
|
20
|
+
}
|
|
21
|
+
/** Offline username derived from a client name (3-16 chars of [A-Za-z0-9_]). */
|
|
22
|
+
export function defaultUsername(name) {
|
|
23
|
+
return name.replace(/[^A-Za-z0-9_]/g, '_').slice(0, 16).padEnd(3, '_');
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA+OA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B;IADX,YACW,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;IACzF,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IACxB,MAAM,EAAE,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/C,IAAI,EAAE;QAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IACpE,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxG,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzE,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
/** Package version, read from package.json next to dist/. */
|
|
3
|
+
export const VERSION = (() => {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return '0.0.0';
|
|
9
|
+
}
|
|
10
|
+
})();
|
|
11
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,OAAO,GAAW,CAAC,GAAG,EAAE;IACnC,IAAI,CAAC;QACH,OAAQ,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAyB,CAAC,OAAO,CAAC;IACxH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAC,EAAE,CAAC"}
|
package/dist/zip.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Names of all entries (from the central directory, nothing is extracted). */
|
|
2
|
+
export declare function zipEntries(file: string): Promise<string[]>;
|
|
3
|
+
export declare function zipContains(file: string, entry: string): Promise<boolean>;
|
|
4
|
+
/** Contents of one entry (stored or deflated), or null when the zip has no such entry. */
|
|
5
|
+
export declare function readZipEntry(file: string, entry: string): Promise<Buffer | null>;
|
package/dist/zip.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises';
|
|
2
|
+
import { inflateRawSync } from 'node:zlib';
|
|
3
|
+
async function centralDirectory(handle, file) {
|
|
4
|
+
const { size } = await handle.stat();
|
|
5
|
+
const tailSize = Math.min(size, 65_557);
|
|
6
|
+
const tail = Buffer.alloc(tailSize);
|
|
7
|
+
await handle.read(tail, 0, tailSize, size - tailSize);
|
|
8
|
+
const eocd = tail.lastIndexOf(Buffer.from([0x50, 0x4b, 0x05, 0x06]));
|
|
9
|
+
if (eocd < 0)
|
|
10
|
+
throw new Error(`Not a zip file: ${file}`);
|
|
11
|
+
const cdSize = tail.readUInt32LE(eocd + 12);
|
|
12
|
+
const cdOffset = tail.readUInt32LE(eocd + 16);
|
|
13
|
+
const cd = Buffer.alloc(cdSize);
|
|
14
|
+
await handle.read(cd, 0, cdSize, cdOffset);
|
|
15
|
+
const entries = [];
|
|
16
|
+
for (let p = 0; p + 46 <= cd.length && cd.readUInt32LE(p) === 0x02014b50;) {
|
|
17
|
+
const nameLen = cd.readUInt16LE(p + 28);
|
|
18
|
+
const extraLen = cd.readUInt16LE(p + 30);
|
|
19
|
+
const commentLen = cd.readUInt16LE(p + 32);
|
|
20
|
+
entries.push({
|
|
21
|
+
name: cd.toString('utf8', p + 46, p + 46 + nameLen),
|
|
22
|
+
method: cd.readUInt16LE(p + 10),
|
|
23
|
+
compressedSize: cd.readUInt32LE(p + 20),
|
|
24
|
+
localOffset: cd.readUInt32LE(p + 42),
|
|
25
|
+
});
|
|
26
|
+
p += 46 + nameLen + extraLen + commentLen;
|
|
27
|
+
}
|
|
28
|
+
return entries;
|
|
29
|
+
}
|
|
30
|
+
/** Names of all entries (from the central directory, nothing is extracted). */
|
|
31
|
+
export async function zipEntries(file) {
|
|
32
|
+
const handle = await open(file, 'r');
|
|
33
|
+
try {
|
|
34
|
+
return (await centralDirectory(handle, file)).map((e) => e.name);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
await handle.close();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function zipContains(file, entry) {
|
|
41
|
+
return (await zipEntries(file)).includes(entry);
|
|
42
|
+
}
|
|
43
|
+
/** Contents of one entry (stored or deflated), or null when the zip has no such entry. */
|
|
44
|
+
export async function readZipEntry(file, entry) {
|
|
45
|
+
const handle = await open(file, 'r');
|
|
46
|
+
try {
|
|
47
|
+
const found = (await centralDirectory(handle, file)).find((e) => e.name === entry);
|
|
48
|
+
if (!found)
|
|
49
|
+
return null;
|
|
50
|
+
const header = Buffer.alloc(30);
|
|
51
|
+
await handle.read(header, 0, 30, found.localOffset);
|
|
52
|
+
const dataStart = found.localOffset + 30 + header.readUInt16LE(26) + header.readUInt16LE(28);
|
|
53
|
+
const data = Buffer.alloc(found.compressedSize);
|
|
54
|
+
await handle.read(data, 0, found.compressedSize, dataStart);
|
|
55
|
+
if (found.method === 0)
|
|
56
|
+
return data;
|
|
57
|
+
if (found.method === 8)
|
|
58
|
+
return inflateRawSync(data);
|
|
59
|
+
throw new Error(`Unsupported compression method ${found.method} for ${entry} in ${file}`);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
await handle.close();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=zip.js.map
|
package/dist/zip.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAS3C,KAAK,UA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.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Drive a real Minecraft Java client from code or AI agents: launch, join servers, read client-side entities, chat, run commands and take screenshots. Ships a CLI and an MCP server.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "黑 <b@taboo.sh>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/bkm016/Calcite.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"minecraft",
|
|
14
|
+
"headless",
|
|
15
|
+
"testing",
|
|
16
|
+
"mcp",
|
|
17
|
+
"agent",
|
|
18
|
+
"client",
|
|
19
|
+
"headlessmc"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20.18.1"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"calcite": "dist/cli.js"
|
|
26
|
+
},
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"vendor/calcite-probe.jar",
|
|
38
|
+
"README.md",
|
|
39
|
+
"THIRD_PARTY_NOTICES.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "npm run build:probe && npm run build:ts",
|
|
44
|
+
"build:ts": "tsc -p tsconfig.json",
|
|
45
|
+
"build:probe": "node scripts/build-probe.mjs",
|
|
46
|
+
"test": "npm run build && node --test test/unit.test.mjs && node scripts/test-probe.mjs",
|
|
47
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
48
|
+
"prepack": "npm run build"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
52
|
+
"commander": "^12.1.0",
|
|
53
|
+
"zod": "^3.25.76"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^20.19.43",
|
|
57
|
+
"typescript": "~5.9.3"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
Binary file
|