@hagicode/steamworks.js 0.1.6-dev.9 → 0.2.1-dev.1

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 CHANGED
@@ -2,22 +2,28 @@
2
2
  [![npm](https://img.shields.io/npm/v/@hagicode/steamworks.js.svg)](https://npmjs.com/package/@hagicode/steamworks.js)
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
5
- # Steamworks.js
5
+ # Steamworks.js (HagiCode fork)
6
6
 
7
- A modern implementation of the Steamworks SDK for HTML/JS and NodeJS based applications.
7
+ Node.js and Electron bindings for the Steamworks SDK, maintained as a personal fork of [ceifa/steamworks.js](https://github.com/ceifa/steamworks.js).
8
8
 
9
- ## Why
9
+ Introduction, guides and agent skills: **https://steamworks.hagicode.com/**
10
10
 
11
- I used [greenworks](https://github.com/greenheartgames/greenworks) for a long time and it's great, but I gave up for the following reasons.
11
+ ## About this fork
12
12
 
13
- * It's not being maintained anymore.
14
- * It's not up to date.
15
- * It's not context-aware.
16
- * You have to build the binaries by yourself.
17
- * Don't have typescript definitions.
18
- * The API it's not trustful.
19
- * The API implement callbacks instead of return flags or promises.
20
- * I hate C++.
13
+ This project is a fork of the upstream [steamworks.js](https://github.com/ceifa/steamworks.js) (Node/Electron bindings) and, through the `vendor/steamworks-rs` submodule, of [steamworks-rs](https://github.com/Noxime/steamworks-rs) (the Rust bindings it is built on). The Rust side lives in [HagiCode-org/steamworks-rs](https://github.com/HagiCode-org/steamworks-rs).
14
+
15
+ It exists for my own development work, not as a general replacement for upstream. It is shaped around two needs:
16
+
17
+ * **Working well with coding agents.** The repository carries agent guidance (`AGENTS.md`), task-oriented skills for Steam Workshop work (`steamworks-js/` and the `steamworks-workshop-*` folders), and a documentation site built from this README and those skills.
18
+ * **Covering the Steamworks features my projects use.** Steam Workshop (UGC) is the most complete area: creating items of any file type, publishing and updating them (additional previews and videos, preview-only and content-only updates, metadata, key-value tags, content descriptors, known game versions, per-language titles and descriptions), item and app dependencies, and the logged-in user's votes, favorites and playtime tracking. Beyond Workshop it covers friends, stats and leaderboards, networking sockets/messages/utils, the server browser, timeline, screenshots and Remote Play.
19
+
20
+ What that means in practice:
21
+
22
+ * The npm package is [`@hagicode/steamworks.js`](https://npmjs.com/package/@hagicode/steamworks.js), not the unscoped `steamworks.js`, and it is released on its own schedule.
23
+ * Changes follow what I need, so there is no promise of staying in step with upstream. If you want the general-purpose library, use upstream.
24
+ * Upstream's history is kept. All credit for the original design and implementation goes to the upstream authors, and the MIT license with the original copyright notice (Gabriel Francisco Dos Santos) is kept in [LICENSE](./LICENSE). The Steamworks SDK files bundled through `vendor/steamworks-rs` are not covered by that license and remain under Valve's terms.
25
+
26
+ Bug reports and pull requests are still welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md).
21
27
 
22
28
  ## API
23
29
 
@@ -38,6 +44,38 @@ if (client.achievement.activate('ACHIEVEMENT')) {
38
44
 
39
45
  You can refer to the [declarations file](https://github.com/HagiCode-org/steamworks.js/blob/main/client.d.ts) to check the API support and get more detailed documentation of each function.
40
46
 
47
+ ### What is covered
48
+
49
+ Every namespace below is on the client returned by `init()`. Every function, with its parameters, return value and failure cases, is in the [API reference](https://steamworks.hagicode.com/api/), which is rendered from the JSDoc in `client.d.ts`. Most calls need a running, logged-in Steam client. Anything marked **unverified** has not been run against a live client yet.
50
+
51
+ | Area | Namespaces | Where to read more |
52
+ | --- | --- | --- |
53
+ | Steam Workshop (UGC) | `workshop` | The Workshop sections below, and the agent skills for publishing, updating, querying and client state |
54
+ | Friends and identity | `friends`, `localplayer`, `auth` | [Friends](#friends); the API reference for the rest |
55
+ | Stats, achievements, leaderboards | `stats`, `achievement`, `leaderboard` | [Stats, Achievements and Leaderboards](#stats-achievements-and-leaderboards) |
56
+ | Networking | `networking`, `networkingSockets`, `networkingMessages`, `networkingUtils` | [Networking](#networking-networking-and-the-new-namespaces) |
57
+ | Servers, lobbies, Remote Play | `matchmaking`, `matchmakingServers`, `remotePlay` | [Server Browser, Timeline, Screenshots and Remote Play](#server-browser-timeline-screenshots-and-remote-play); lobbies are in the API reference |
58
+ | Timeline and screenshots | `timeline`, `screenshots` | Same section |
59
+ | App, overlay, input, cloud, utilities | `apps`, `overlay`, `input`, `cloud`, `utils`, `callback` | [Supplemental Functions](#supplemental-functions); the API reference for the rest |
60
+
61
+ What the Workshop namespace can do today:
62
+
63
+ * **Read**: `getItem`, `getItems`, `getAllItems`, `getUserItems`, with additional previews, supported game versions and dependency links on request.
64
+ * **Create and update**: `createItem` (any `WorkshopFileType`), `updateItem` and its preview-only and content-only helpers, with title and description per language, tags, visibility, metadata, key-value tags, content descriptors, screenshots, YouTube videos and game-version ranges.
65
+ * **Dependencies**: required items (`addDependency`, `removeDependency`) and required apps (`addAppDependency`, `removeAppDependency`, `getAppDependencies`).
66
+ * **The logged-in user**: subscribe, download and install info, votes, favorites and playtime tracking.
67
+
68
+ ### Not in scope: remote_storage publish and screenshots tagging
69
+
70
+ These two parts of the SDK are deliberately not wrapped. This section records the decision and its reasons, so the question is not reopened without new facts. The public API did not change for it: `client.d.ts` has no remote_storage publish function and no screenshots tagging function.
71
+
72
+ | Feature | Decision | Checked in the code or SDK headers | Reason | Unverified |
73
+ | --- | --- | --- | --- | --- |
74
+ | `remote_storage` publish (`PublishWorkshopFile`) | Exclude | The SDK header declares `PublishWorkshopFile` with the other remote storage calls. Nothing in this repository wraps or calls it. | The UGC calls this binding already wraps (`createItem`, `updateItem`, the dependency and preview calls) cover publishing. A second publish route would need its own tests and skill. | Whether Steam still accepts this route for current accounts. |
75
+ | Screenshots tagging (`TagPublishedFile`) | Defer | The header declares `TagPublishedFile` on `ISteamScreenshots`. The `screenshots` namespace only hooks the screenshot hotkey. | The call needs a screenshot handle from the hooked hotkey flow. Without a use case in this repository, a wrapper would ship untested. Reopen it when a consumer needs it. | Whether a tag call succeeds and shows on the item page. It needs a running client. |
76
+
77
+ Recommendation: keep both out of the public API. When screenshots tagging is needed, start with a live check on a private test item.
78
+
41
79
  ## Installation
42
80
 
43
81
  To use steamworks.js you don't have to build anything, just install it from npm:
@@ -46,9 +84,11 @@ To use steamworks.js you don't have to build anything, just install it from npm:
46
84
  npm i @hagicode/steamworks.js
47
85
  ```
48
86
 
49
- ### Migration from `steamworks.js`
87
+ Guides and agent skills are on the documentation site at https://steamworks.hagicode.com/. To try the latest build from `main`, install the `dev` dist-tag: `npm i @hagicode/steamworks.js@dev`.
88
+
89
+ ### Migration from upstream `steamworks.js`
50
90
 
51
- If you were using the unscoped `steamworks.js` package, update your `package.json`:
91
+ If you were using the unscoped upstream `steamworks.js` package and want this fork instead, update your `package.json`:
52
92
 
53
93
  ```json
54
94
  {
@@ -86,7 +126,7 @@ For the production build, copy the relevant distro files from `sdk/redistributab
86
126
 
87
127
  ## How to build
88
128
 
89
- > You **only** need to build if you are going to change something on steamworks.js code, if you are looking to just consume the library or use it in your game, refer to the [installation section](#installation).
129
+ > You **only** need to build if you are going to change something on this fork's code. If you just want to use the library in your game, see the [installation section](#installation).
90
130
 
91
131
  Make sure you have the latest [node.js](https://nodejs.org/en/), [Rust](https://www.rust-lang.org/tools/install) and [Clang](https://rust-lang.github.io/rust-bindgen/requirements.html). We also need [Steam](https://store.steampowered.com/about/) installed and running.
92
132
 
@@ -108,7 +148,7 @@ git submodule update --init --recursive
108
148
 
109
149
  Install dependencies with `pnpm install` and then run `pnpm run build:debug` to build the library.
110
150
 
111
- There is no way to build for all targets easily. The good news is that you don't need to. You can develop and test on your current target, and open a PR. When the code is merged to main, a github action will build for all targets and publish a new version.
151
+ There is no easy way to build for all targets locally, and you do not need to. Develop and test on your current target. When the code is merged to `main`, a GitHub Action builds every target and publishes a `dev` build.
112
152
 
113
153
  ### Testing Electron
114
154
 
@@ -164,6 +204,35 @@ await client.workshop.updateItemContent(itemId, '/abs/path/mod-folder', appId, '
164
204
  - Title, description, tags and visibility are not sent, so they stay as they are. To change them together with a file, keep using `updateItem`.
165
205
  - Neither helper reports upload progress. For a large content upload use `updateItemWithCallback`.
166
206
 
207
+ ### Creating items and the new update fields
208
+
209
+ `createItem(appId?, fileType?)` creates an empty item. Without `fileType` it is a `Community` item, as before. The `WorkshopFileType` values are `Community`, `Art`, `Screenshot`, `Video`, `Collection`, `WebGuide` and `IntegratedGuide`.
210
+
211
+ `updateItem` accepts these optional fields. A field left out keeps the item's current value:
212
+
213
+ - `additionalPreviewVideos`: YouTube video IDs, 11 characters each, not URLs. A malformed ID rejects with the entry named, before anything is sent. Whether Steam shows a video added this way is **unverified** until a live run.
214
+ - `metadata`: a developer metadata string.
215
+ - `keyValueTags`: `{ clear?, remove?, add? }`, applied in the order clear, remove, add. `add` takes `{ key, value }` pairs and `remove` takes keys.
216
+ - `contentDescriptors`: `{ remove?, add? }` of `WorkshopContentDescriptor` values, removals first. Only the five SDK values exist, so any other number is refused.
217
+
218
+ ```js
219
+ const steamworks = require('steamworks.js')
220
+ const client = steamworks.init(appId)
221
+ const { WorkshopFileType, WorkshopContentDescriptor } = client.workshop
222
+
223
+ const created = await client.workshop.createItem(appId, 1) // 1 = WorkshopFileType.Art
224
+ await client.workshop.updateItem(created.itemId, {
225
+ metadata: 'v2',
226
+ keyValueTags: { clear: true, add: [{ key: 'mode', value: 'hard' }] },
227
+ contentDescriptors: { add: [5] }, // 5 = WorkshopContentDescriptor.AnyMatureContent
228
+ additionalPreviewVideos: ['dQw4w9WgXcQ'],
229
+ }, appId)
230
+ ```
231
+
232
+ - Each of these calls changes the item on Steam. Confirm the item and the change first.
233
+ - The typings expose no read for an item's metadata, key-value tags or content descriptors, so after a write only the Steam result code can be checked.
234
+ - `workshop.py upload` sends `--file-type` and the YouTube videos listed in `workshop.json`. It does not send metadata, key-value tags or content descriptors; those are steamworks.js calls only.
235
+
167
236
  ## Workshop Item Dependencies
168
237
 
169
238
  A Workshop item can require another item, so Steam installs the required item along with it. `addDependency` and `removeDependency` take the parent and the child as `bigint` ids and resolve with the Steam result code. `1` means OK. Any other code is a Steam failure reason, and it arrives as a resolved number, not a rejection.
@@ -188,6 +257,60 @@ const removed = await client.workshop.removeDependency(modId, requiredId)
188
257
  - Both calls need a running, logged-in Steam client, and the parent must be an item the logged-in account owns.
189
258
  - An id that is negative or does not fit in 64 bits rejects before any Steam call. A failed call with no completion also rejects, and the error says the outcome is unknown, so check the item before retrying.
190
259
 
260
+ ### App dependencies
261
+
262
+ An item can also require an app, such as a DLC. `addAppDependency(itemId, appId)` and `removeAppDependency(itemId, appId)` resolve with the Steam result code, the same way as the item calls above.
263
+
264
+ `getAppDependencies(itemId)` resolves with `{ result, appIds, totalAppDependencies }`. Steam sends the list in pages of up to 32, and the binding collects them until the reported total is reached. If `appIds` is shorter than `totalAppDependencies`, the list is incomplete. The paging follows the SDK header, and it is **unverified** against a live Steam client.
265
+
266
+ ## Workshop User Actions
267
+
268
+ These calls act for the logged-in user on Steam, so they change that user's state and not only the item. Each one resolves when Steam confirms it. `getUserItemVote` is the only one that reads.
269
+
270
+ ```js
271
+ const steamworks = require('steamworks.js')
272
+ const client = steamworks.init(appId)
273
+
274
+ await client.workshop.setUserItemVote(itemId, true) // vote up; false votes down
275
+ const vote = await client.workshop.getUserItemVote(itemId) // { votedUp, votedDown, skipped }
276
+
277
+ await client.workshop.addItemToFavorites(itemId) // appId defaults to the client's app
278
+ await client.workshop.removeItemFromFavorites(itemId)
279
+
280
+ await client.workshop.startPlaytimeTracking([itemId]) // the list must not be empty
281
+ await client.workshop.stopPlaytimeTracking([itemId])
282
+ ```
283
+
284
+ - Item ID 0, a negative id and an empty playtime list are refused before any Steam call.
285
+ - Start and stop playtime tracking in pairs. The SDK header describes these calls as tracking the user's playtime for the listed items; that behavior is **unverified** against a live client.
286
+ - These calls need a running, logged-in Steam client.
287
+
288
+ ## Workshop Known Game Versions
289
+
290
+ An item can declare the game versions (Steam branches such as `open_beta` or `public`) it is valid for. Every item returned by a query carries those ranges in `supportedGameVersions`, and `updateItem` changes them with `requiredGameVersionMin` and `requiredGameVersionMax`:
291
+
292
+ ```js
293
+ const steamworks = require('steamworks.js')
294
+ const client = steamworks.init(appId)
295
+
296
+ // read: one entry per range; an open end is left out (undefined)
297
+ const item = await client.workshop.getItem(itemId)
298
+ console.log(item.supportedGameVersions) // e.g. [{ minBranch: 'open_beta', maxBranch: 'open_beta' }, { minBranch: 'public' }]
299
+
300
+ // change: valid for open_beta and every branch published after it; the content is sent in the same update
301
+ await client.workshop.updateItem(itemId, {
302
+ contentPath: '/abs/path/mod-folder',
303
+ requiredGameVersionMin: 'open_beta',
304
+ requiredGameVersionMax: '',
305
+ }, appId)
306
+ ```
307
+
308
+ - `supportedGameVersions` comes with items from `getItem`, `getItems`, `getAllItems` and `getUserItems`. It is an empty list when Steam returns no range for the item.
309
+ - Both change fields are optional. Setting one changes that end, and the other end is left open. Leaving both out keeps the range as it is.
310
+ - Pass both as `""` to make the item valid for every game version again.
311
+ - Steam applies the range only when the same update changes the item's content, so send `contentPath` with it. Otherwise Steam does not apply the range.
312
+ - Changing the range needs a running, logged-in Steam client and an item the logged-in account owns.
313
+
191
314
  ## Workshop Multilingual Support
192
315
 
193
316
  Steamworks.js supports localized content for Steam Workshop items. You can update the title and description for different languages using the `language` parameter.
@@ -470,9 +593,10 @@ client.cloud.setSyncPlatforms('save.json', 0 /* SyncPlatform.None */)
470
593
 
471
594
  ## Release Process
472
595
 
473
- This project uses automated release management:
596
+ This fork has its own release line and publishes to npm as `@hagicode/steamworks.js`. It does not follow upstream's release numbers. Releases are automated:
474
597
 
475
- - **Pre-releases**: Automatically created on each push to the `main` branch for testing
476
- - **Official releases**: Created when a version tag is pushed (e.g., `v1.2.3`)
598
+ - **Dev builds**: Every push to the `main` branch publishes a build to the npm `dev` dist-tag for testing
599
+ - **Release drafts**: Every push to `main` updates one draft GitHub release for the next `vX.Y.Z`, drafted by [hagi-release-drafter](https://github.com/HagiCode-org/hagi-release-drafter). It is never published automatically
600
+ - **Official releases**: Publish the draft in the GitHub UI. That creates the `vX.Y.Z` tag, and the tag publishes the npm `latest` version
477
601
 
478
- Release notes are automatically generated from commit messages. See [CONTRIBUTING.md](./CONTRIBUTING.md) for the commit message format.
602
+ Release notes are automatically generated from Conventional Commit messages. See [CONTRIBUTING.md](./CONTRIBUTING.md) for the commit message format.