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