@thomasfarineau/anvil 0.0.2 → 0.0.3

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 +18 -193
  2. package/dist/cli.cjs +554 -0
  3. package/package.json +19 -6
  4. package/src/client/config.schema.json +24 -1
  5. package/src/client/index.d.ts +36 -0
  6. package/src/rust/src/lib.rs +320 -17
  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 +27 -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
package/README.md CHANGED
@@ -3,29 +3,16 @@
3
3
  <h1>anvil</h1>
4
4
  <p>Build a native Minecraft launcher by writing only HTML.<br>The Rust backend handles everything else.</p>
5
5
 
6
- [![npm](https://img.shields.io/npm/v/%40thomasfarineau%2Fanvil?style=flat-square)](https://www.npmjs.com/package/@thomasfarineau/anvil)
7
- [![release](https://img.shields.io/github/v/release/ThomasFarineau/anvil?style=flat-square)](https://github.com/ThomasFarineau/anvil/releases)
8
- [![license](https://img.shields.io/github/license/ThomasFarineau/anvil?style=flat-square)](./LICENSE)
9
- [![CI](https://img.shields.io/github/actions/workflow/status/ThomasFarineau/anvil/ci.yml?style=flat-square&label=CI)](https://github.com/ThomasFarineau/anvil/actions)
6
+ [![npm](https://img.shields.io/npm/v/%40thomasfarineau%2Fanvil?style=flat-square)](https://www.npmjs.com/package/@thomasfarineau/anvil)
7
+ [![release](https://img.shields.io/github/v/release/ThomasFarineau/anvil?style=flat-square)](https://github.com/ThomasFarineau/anvil/releases)
8
+ [![license](https://img.shields.io/github/license/ThomasFarineau/anvil?style=flat-square)](./LICENSE)
9
+ [![CI](https://img.shields.io/github/actions/workflow/status/ThomasFarineau/anvil/ci.yml?style=flat-square&label=CI)](https://github.com/ThomasFarineau/anvil/actions)
10
+
10
11
  </div>
11
12
 
12
13
  ---
13
14
 
14
- **anvil** is a framework that generates a native Minecraft launcher (Windows · macOS · Linux) from a `config.json` file and an HTML page. The built-in Rust backend takes care of:
15
-
16
- - Downloading and managing Java
17
- - Downloading Minecraft assets (vanilla, Fabric, Forge…)
18
- - Launching the game with session management
19
- - Auto-updates via URL
20
- - App icon generation from your logo
21
-
22
- You only touch the **frontend**.
23
-
24
- ## Prerequisites
25
-
26
- - [Node.js](https://nodejs.org) ≥ 18
27
- - [Rust](https://rustup.rs) (stable)
28
- - [Tauri v2 prerequisites](https://tauri.app/start/prerequisites/) (WebView2 on Windows, Xcode on macOS)
15
+ **anvil** is a framework that generates a native Minecraft launcher (Windows · macOS · Linux) from a `config.json` file and an HTML page. The built-in Rust backend handles Java, Minecraft downloads (vanilla, Fabric, Forge…), mods, launching, sessions, auto-updates and app icons. You only touch the **frontend**.
29
16
 
30
17
  ## Quick start
31
18
 
@@ -36,183 +23,21 @@ npm install
36
23
  npm run dev
37
24
  ```
38
25
 
39
- Or in an existing project:
40
-
41
- ```bash
42
- npm install -D @thomasfarineau/anvil
43
- npx anvil init
44
- npm run dev
45
- ```
46
-
47
- ## Commands
48
-
49
- | Command | Description |
50
- |---|---|
51
- | `npx @thomasfarineau/anvil create <name>` | Scaffold a new project in `<name>/` |
52
- | `npx anvil init` | Initialize anvil in the current folder |
53
- | `npx anvil dev` | Start the launcher in development mode |
54
- | `npx anvil build` | Compile the launcher for distribution |
55
- | `npx anvil update` | Update the Rust backend and `api.js` to the latest version |
56
-
57
- ## Project structure
58
-
59
- ```
60
- my-launcher/
61
- ├── config.json ← launcher configuration
62
- ├── src/
63
- │ ├── index.html ← your interface (HTML/CSS/JS)
64
- │ ├── api.js ← JS ↔ Rust bridge (do not modify)
65
- │ └── logo.svg ← your launcher logo (optional)
66
- └── src-anvil/ ← generated by anvil (do not modify)
67
- ```
68
-
69
- ## config.json
70
-
71
- ```json
72
- {
73
- "$schema": "node_modules/@thomasfarineau/anvil/src/client/config.schema.json",
74
- "identifier": "com.mycompany.launcher",
75
- "app_name": "My Launcher",
76
- "data_folder": ".my-launcher",
77
- "java_version": 21,
78
- "logo": "logo.svg",
79
- "session": "none",
80
- "update_url": "",
81
- "target": "dist",
82
- "window_decorations": true,
83
- "window_resizable": false,
84
- "instances": [
85
- {
86
- "id": "survival",
87
- "name": "Survival",
88
- "mc_version": "1.21.4"
89
- },
90
- {
91
- "id": "modded",
92
- "name": "Modded",
93
- "mc_version": "1.21.4",
94
- "loader": "fabric",
95
- "loader_version": "0.16.9"
96
- }
97
- ]
98
- }
99
- ```
100
-
101
- ### Field reference
102
-
103
- | Field | Type | Description |
104
- |---|---|---|
105
- | `identifier` | `string` | Reverse-domain app identifier (e.g. `com.mycompany.launcher`) |
106
- | `app_name` | `string` | App name shown in the native window and UI |
107
- | `data_folder` | `string` | Sub-folder in `%APPDATA%` / `~/Library` for game data |
108
- | `java_version` | `17` \| `21` | Java version to download automatically |
109
- | `logo` | `string` | Path to the logo (relative to `src/`) — `.svg` or `.png`, auto-converted to app icon |
110
- | `session` | `"none"` \| `"mojang"` \| `"custom"` | Authentication mode |
111
- | `update_url` | `string` | URL of the update manifest (leave empty to disable) |
112
- | `target` | `string` | Output folder for compiled executables (e.g. `dist`) |
113
- | `window_decorations` | `boolean` | Show the native title bar |
114
- | `window_resizable` | `boolean` | Allow the user to resize the window |
115
- | `instances` | `array` | List of available Minecraft instances |
116
-
117
- ### Instance fields
118
-
119
- | Field | Type | Description |
120
- |---|---|---|
121
- | `id` | `string` | Unique identifier (used as the folder name) |
122
- | `name` | `string` | Label shown on the play button |
123
- | `mc_version` | `string` | Minecraft version (e.g. `"1.21.4"`) |
124
- | `loader` | `"fabric"` \| `"forge"` \| `"neoforge"` \| `"quilt"` | Mod loader (optional) |
125
- | `loader_version` | `string` | Mod loader version (e.g. `"0.16.9"`) |
126
- | `server_ip` | `string` | Server IP for auto-connect on launch |
127
- | `server_port` | `number` | Server port (default: `25565`) |
128
-
129
- ## Session
130
-
131
- ### `"none"` — Offline
132
-
133
- The player types their username directly in the UI. No authentication required.
26
+ `create` is interactive: pick **TypeScript** or **JavaScript**, then **Vanilla**, **React**, **Vue** or **Solid**. Skip the prompts with `--template <id>` — see [`examples/`](./examples) for a ready-made project of each template.
134
27
 
135
- ### `"custom"` — External authentication
136
-
137
- Handle authentication on the client side (OAuth, custom API…) and pass the session to anvil:
138
-
139
- ```js
140
- await MC.setSession({
141
- username: 'Steve',
142
- uuid: '...',
143
- access_token: '...',
144
- });
145
-
146
- // To log out:
147
- await MC.clearSession();
148
- ```
149
-
150
- ## JavaScript API
151
-
152
- Import `api.js` in your HTML:
153
-
154
- ```html
155
- <script type="module">
156
- import { MC } from '/api.js';
157
- </script>
158
- ```
159
-
160
- ### Reference
161
-
162
- ```js
163
- // Config & settings
164
- MC.getConfig() // → LauncherConfig
165
- MC.getSettings() // → Settings
166
- MC.saveSettings(settings) // → void
167
- MC.getDefaultDir() // → string (default %APPDATA%/... path)
168
-
169
- // Installation
170
- MC.getInitStatus() // → InitStatus (java_ok, instances[])
171
- MC.runSetup() // → void (starts the download)
172
-
173
- // Game
174
- MC.verify(instanceId) // → void (verifies game files)
175
- MC.play(instanceId) // → void (launches the game)
176
-
177
- // Session (when session: "custom")
178
- MC.setSession({ username, uuid, access_token })
179
- MC.clearSession()
180
-
181
- // Updates
182
- MC.checkUpdate() // → UpdateInfo | null
183
- MC.doUpdate(url) // → void
184
-
185
- // Window
186
- MC.close() // closes the application
187
-
188
- // Events
189
- MC.on.setupProgress(cb) // cb({ step, current, total, label, error })
190
- MC.on.setupDone(cb) // cb()
191
- MC.on.gameStarting(cb) // cb(instanceId)
192
- MC.on.gameOutput(cb) // cb({ instance_id, text, stderr })
193
- MC.on.gameExit(cb) // cb({ instance_id, code })
194
- ```
195
-
196
- ## App icon
197
-
198
- Place your logo in `src/` and set the `logo` field in `config.json`. anvil converts it automatically to all required icon sizes during `init`:
199
-
200
- - `.svg` → converted to PNG via **sharp**, then generated at all sizes
201
- - `.png` → used directly (recommended: 1024×1024)
202
-
203
- ## Build & distribution
204
-
205
- ```bash
206
- npm run build # → anvil build → tauri build
207
- ```
28
+ ## 📖 Documentation
208
29
 
209
- Distribution artifacts are generated in the `target` folder configured in `config.json`:
30
+ Full docs, guides and API reference: **[thomasfarineau.github.io/anvil](https://thomasfarineau.github.io/anvil/)** ([français](https://thomasfarineau.github.io/anvil/fr/))
210
31
 
211
- | Platform | Format |
212
- |---|---|
213
- | Windows | `<name>_<ver>_x64-setup.exe` (NSIS) |
214
- | Linux | `<name>_<ver>_amd64.AppImage` |
215
- | macOS | `<name>_<ver>_x64.dmg` |
32
+ - [Getting started](https://thomasfarineau.github.io/anvil/guide/getting-started)
33
+ - [CLI commands](https://thomasfarineau.github.io/anvil/guide/commands)
34
+ - [Project structure](https://thomasfarineau.github.io/anvil/guide/project-structure)
35
+ - [config.json reference](https://thomasfarineau.github.io/anvil/config/)
36
+ - [Mods per instance](https://thomasfarineau.github.io/anvil/config/mods)
37
+ - [Session (offline / custom auth)](https://thomasfarineau.github.io/anvil/session)
38
+ - [JavaScript API](https://thomasfarineau.github.io/anvil/api)
39
+ - [App icon generation](https://thomasfarineau.github.io/anvil/icons)
40
+ - [Build & distribution](https://thomasfarineau.github.io/anvil/build)
216
41
 
217
42
  ## License
218
43