@thomasfarineau/anvil 0.0.2 → 0.0.4

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.
Files changed (45) hide show
  1. package/README.md +21 -191
  2. package/dist/cli.cjs +557 -0
  3. package/package.json +26 -10
  4. package/src/client/config.schema.json +58 -6
  5. package/src/client/index.d.ts +60 -1
  6. package/src/rust/src/lib.rs +633 -21
  7. package/src/template/_gitignore +1 -0
  8. package/src/template/capabilities/default.json +7 -1
  9. package/src/template/config.json +2 -2
  10. package/src/template/frontends/react-js/src/App.jsx +183 -0
  11. package/src/template/frontends/react-js/src/index.html +12 -0
  12. package/src/template/frontends/react-js/src/main.jsx +5 -0
  13. package/src/template/frontends/react-js/vite.config.js +10 -0
  14. package/src/template/frontends/react-ts/src/App.tsx +190 -0
  15. package/src/template/frontends/react-ts/src/index.html +12 -0
  16. package/src/template/frontends/react-ts/src/main.tsx +5 -0
  17. package/src/template/frontends/react-ts/tsconfig.json +14 -0
  18. package/src/template/frontends/react-ts/vite.config.ts +10 -0
  19. package/src/template/frontends/solid-js/src/App.jsx +190 -0
  20. package/src/template/frontends/solid-js/src/index.html +12 -0
  21. package/src/template/frontends/solid-js/src/main.jsx +5 -0
  22. package/src/template/frontends/solid-js/vite.config.js +10 -0
  23. package/src/template/frontends/solid-ts/src/App.tsx +193 -0
  24. package/src/template/frontends/solid-ts/src/index.html +12 -0
  25. package/src/template/frontends/solid-ts/src/main.tsx +5 -0
  26. package/src/template/frontends/solid-ts/tsconfig.json +15 -0
  27. package/src/template/frontends/solid-ts/vite.config.ts +10 -0
  28. package/src/template/{src → frontends/vanilla-js/src}/index.html +110 -178
  29. package/src/template/frontends/vanilla-ts/src/index.html +51 -0
  30. package/src/template/frontends/vanilla-ts/src/main.ts +193 -0
  31. package/src/template/frontends/vanilla-ts/tsconfig.json +13 -0
  32. package/src/template/frontends/vanilla-ts/vite.config.ts +8 -0
  33. package/src/template/frontends/vue-js/src/App.vue +155 -0
  34. package/src/template/frontends/vue-js/src/index.html +12 -0
  35. package/src/template/frontends/vue-js/src/main.js +5 -0
  36. package/src/template/frontends/vue-js/vite.config.js +10 -0
  37. package/src/template/frontends/vue-ts/src/App.vue +158 -0
  38. package/src/template/frontends/vue-ts/src/index.html +12 -0
  39. package/src/template/frontends/vue-ts/src/main.ts +5 -0
  40. package/src/template/frontends/vue-ts/tsconfig.json +13 -0
  41. package/src/template/frontends/vue-ts/vite.config.ts +10 -0
  42. package/src/template/{src → shared}/api.js +38 -1
  43. package/src/template/shared/logo.svg +6 -0
  44. package/src/template/shared/style.css +226 -0
  45. package/src/cli.cjs +0 -352
@@ -4,13 +4,13 @@
4
4
  "title": "Anvil Launcher Config",
5
5
  "description": "Configuration file for an Anvil Minecraft launcher (config.json)",
6
6
  "type": "object",
7
- "required": ["instances"],
7
+ "anyOf": [{ "required": ["instances"] }, { "required": ["anvil-server"] }],
8
8
  "additionalProperties": false,
9
9
  "properties": {
10
10
  "$schema": {
11
11
  "type": "string",
12
12
  "description": "JSON schema URL for validation",
13
- "default": "./node_modules/anvil/src/client/config.schema.json"
13
+ "default": "./node_modules/@thomasfarineau/anvil/src/client/config.schema.json"
14
14
  },
15
15
  "identifier": {
16
16
  "type": "string",
@@ -48,10 +48,20 @@
48
48
  },
49
49
  "session": {
50
50
  "type": "string",
51
- "enum": ["none", "mojang", "custom"],
52
- "description": "Authentication mode. 'none': offline. 'custom': client calls MC.setSession() before launch.",
51
+ "enum": ["none", "mojang", "custom", "anvil-session"],
52
+ "description": "Authentication mode. 'none': offline. 'custom': client calls MC.setSession() before launch. 'anvil-session': login (username/password/2FA) handled by the anvil-server declared in 'anvil-server'.",
53
53
  "default": "none"
54
54
  },
55
+ "anvil-server": {
56
+ "type": "string",
57
+ "description": "Base URL of an anvil-server instance (e.g. https://mods.example.com). When set, the launcher fetches the list of enabled instances from this server at startup (the 'instances' field becomes unnecessary), and 'anvil-session' authentication is validated against it.",
58
+ "default": ""
59
+ },
60
+ "anvil-key": {
61
+ "type": "string",
62
+ "description": "API key generated in the anvil-server web UI (Clés API). Required to query the server: instance list, sessions and file downloads are refused without a valid key.",
63
+ "default": ""
64
+ },
55
65
  "window_decorations": {
56
66
  "type": "boolean",
57
67
  "description": "Show native window title bar and borders",
@@ -64,11 +74,11 @@
64
74
  },
65
75
  "instances": {
66
76
  "type": "array",
67
- "description": "List of Minecraft instances available in the launcher",
77
+ "description": "List of Minecraft instances available in the launcher. Ignored (replaced) when 'anvil-server' is set: the server's enabled instances are used instead.",
68
78
  "minItems": 1,
69
79
  "items": {
70
80
  "type": "object",
71
- "required": ["id", "name", "mc_version"],
81
+ "required": ["id"],
72
82
  "additionalProperties": false,
73
83
  "properties": {
74
84
  "id": {
@@ -105,6 +115,48 @@
105
115
  "maximum": 65535,
106
116
  "description": "Server port",
107
117
  "default": 25565
118
+ },
119
+ "mods": {
120
+ "type": "array",
121
+ "description": "Mods downloaded into this instance's mods/ folder during setup",
122
+ "items": {
123
+ "type": "object",
124
+ "required": ["url"],
125
+ "additionalProperties": false,
126
+ "properties": {
127
+ "name": {
128
+ "type": "string",
129
+ "description": "Display name of the mod"
130
+ },
131
+ "url": {
132
+ "type": "string",
133
+ "description": "Direct download URL of the mod .jar"
134
+ },
135
+ "file_name": {
136
+ "type": "string",
137
+ "description": "Target file name in mods/ (defaults to the URL basename)"
138
+ }
139
+ }
140
+ }
141
+ },
142
+ "files": {
143
+ "type": "array",
144
+ "description": "Extra files (mod configs, options.txt…) downloaded into the instance folder during setup. Always overwritten: the source (usually an anvil-server) is authoritative.",
145
+ "items": {
146
+ "type": "object",
147
+ "required": ["path", "url"],
148
+ "additionalProperties": false,
149
+ "properties": {
150
+ "path": {
151
+ "type": "string",
152
+ "description": "Relative target path inside the instance folder (e.g. \"config/mymod.toml\")"
153
+ },
154
+ "url": {
155
+ "type": "string",
156
+ "description": "Direct download URL of the file"
157
+ }
158
+ }
159
+ }
108
160
  }
109
161
  }
110
162
  }
@@ -1,3 +1,14 @@
1
+ export interface ModConfig {
2
+ url: string;
3
+ name?: string;
4
+ file_name?: string;
5
+ }
6
+
7
+ export interface FileConfig {
8
+ path: string;
9
+ url: string;
10
+ }
11
+
1
12
  export interface InstanceConfig {
2
13
  id: string;
3
14
  name: string;
@@ -6,6 +17,8 @@ export interface InstanceConfig {
6
17
  loader_version: string;
7
18
  server_ip: string;
8
19
  server_port: number;
20
+ mods: ModConfig[];
21
+ files: FileConfig[];
9
22
  }
10
23
 
11
24
  export interface LauncherConfig {
@@ -16,9 +29,11 @@ export interface LauncherConfig {
16
29
  java_version: number;
17
30
  update_url: string;
18
31
  logo: string;
19
- session: 'none' | 'mojang' | 'custom';
32
+ session: 'none' | 'mojang' | 'custom' | 'anvil-session';
20
33
  window_decorations: boolean;
21
34
  window_resizable: boolean;
35
+ 'anvil-server': string;
36
+ 'anvil-key': string;
22
37
  instances: InstanceConfig[];
23
38
  }
24
39
 
@@ -38,6 +53,7 @@ export interface InstanceStatus {
38
53
  id: string;
39
54
  name: string;
40
55
  installed: boolean;
56
+ running: boolean;
41
57
  }
42
58
 
43
59
  export interface InitStatus {
@@ -46,6 +62,14 @@ export interface InitStatus {
46
62
  instances: InstanceStatus[];
47
63
  }
48
64
 
65
+ export interface ModInfo {
66
+ file_name: string;
67
+ name: string;
68
+ enabled: boolean;
69
+ size: number;
70
+ managed: boolean;
71
+ }
72
+
49
73
  export interface SetupProgress {
50
74
  step: string;
51
75
  current: number;
@@ -71,20 +95,55 @@ export interface UpdateInfo {
71
95
  notes: string;
72
96
  }
73
97
 
98
+ export interface AnvilLoginResult {
99
+ status: 'ok' | 'totp_required';
100
+ username: string;
101
+ uuid: string;
102
+ }
103
+
74
104
  export declare const MC: {
75
105
  getConfig(): Promise<LauncherConfig>;
76
106
  getSettings(): Promise<Settings>;
77
107
  saveSettings(s: Settings): Promise<void>;
78
108
  getDefaultDir(): Promise<string>;
109
+ getVersion(): Promise<string>;
79
110
  getInitStatus(): Promise<InitStatus>;
80
111
  runSetup(): Promise<void>;
81
112
  verify(instanceId: string): Promise<void>;
82
113
  play(instanceId: string): Promise<void>;
114
+ stop(instanceId: string): Promise<void>;
115
+ getRunning(): Promise<string[]>;
116
+ isRunning(instanceId: string): Promise<boolean>;
117
+ mods: {
118
+ list(instanceId: string): Promise<ModInfo[]>;
119
+ add(
120
+ instanceId: string,
121
+ url: string,
122
+ fileName?: string | null,
123
+ ): Promise<ModInfo>;
124
+ remove(instanceId: string, fileName: string): Promise<void>;
125
+ enable(instanceId: string, fileName: string): Promise<void>;
126
+ disable(instanceId: string, fileName: string): Promise<void>;
127
+ openFolder(instanceId: string): Promise<void>;
128
+ };
129
+ openInstanceFolder(instanceId: string): Promise<void>;
83
130
  checkUpdate(): Promise<UpdateInfo | null>;
84
131
  doUpdate(url: string): Promise<void>;
85
132
  setSession(session: CustomSession): Promise<void>;
86
133
  clearSession(): Promise<void>;
134
+ anvilSession: {
135
+ login(
136
+ username: string,
137
+ password: string,
138
+ code?: string | null,
139
+ ): Promise<AnvilLoginResult>;
140
+ restore(): Promise<AnvilLoginResult | null>;
141
+ logout(): Promise<void>;
142
+ };
87
143
  close(): Promise<void>;
144
+ minimize(): Promise<void>;
145
+ toggleMaximize(): Promise<void>;
146
+ startDrag(): Promise<void>;
88
147
  on: {
89
148
  setupProgress(cb: (p: SetupProgress) => void): Promise<() => void>;
90
149
  setupDone(cb: () => void): Promise<() => void>;