@hagicode/steamworks.js 0.1.6-dev.33 → 0.1.6-dev.35

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
@@ -44,6 +44,17 @@ if (client.achievement.activate('ACHIEVEMENT')) {
44
44
 
45
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.
46
46
 
47
+ ### Not in scope: remote_storage publish and screenshots tagging
48
+
49
+ 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.
50
+
51
+ | Feature | Decision | Checked in the code or SDK headers | Reason | Unverified |
52
+ | --- | --- | --- | --- | --- |
53
+ | `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. |
54
+ | 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. |
55
+
56
+ Recommendation: keep both out of the public API. When screenshots tagging is needed, start with a live check on a private test item.
57
+
47
58
  ## Installation
48
59
 
49
60
  To use steamworks.js you don't have to build anything, just install it from npm:
@@ -172,6 +183,35 @@ await client.workshop.updateItemContent(itemId, '/abs/path/mod-folder', appId, '
172
183
  - Title, description, tags and visibility are not sent, so they stay as they are. To change them together with a file, keep using `updateItem`.
173
184
  - Neither helper reports upload progress. For a large content upload use `updateItemWithCallback`.
174
185
 
186
+ ### Creating items and the new update fields
187
+
188
+ `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`.
189
+
190
+ `updateItem` accepts these optional fields. A field left out keeps the item's current value:
191
+
192
+ - `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.
193
+ - `metadata`: a developer metadata string.
194
+ - `keyValueTags`: `{ clear?, remove?, add? }`, applied in the order clear, remove, add. `add` takes `{ key, value }` pairs and `remove` takes keys.
195
+ - `contentDescriptors`: `{ remove?, add? }` of `WorkshopContentDescriptor` values, removals first. Only the five SDK values exist, so any other number is refused.
196
+
197
+ ```js
198
+ const steamworks = require('steamworks.js')
199
+ const client = steamworks.init(appId)
200
+ const { WorkshopFileType, WorkshopContentDescriptor } = client.workshop
201
+
202
+ const created = await client.workshop.createItem(appId, 1) // 1 = WorkshopFileType.Art
203
+ await client.workshop.updateItem(created.itemId, {
204
+ metadata: 'v2',
205
+ keyValueTags: { clear: true, add: [{ key: 'mode', value: 'hard' }] },
206
+ contentDescriptors: { add: [5] }, // 5 = WorkshopContentDescriptor.AnyMatureContent
207
+ additionalPreviewVideos: ['dQw4w9WgXcQ'],
208
+ }, appId)
209
+ ```
210
+
211
+ - Each of these calls changes the item on Steam. Confirm the item and the change first.
212
+ - 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.
213
+ - `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.
214
+
175
215
  ## Workshop Item Dependencies
176
216
 
177
217
  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.
@@ -196,6 +236,34 @@ const removed = await client.workshop.removeDependency(modId, requiredId)
196
236
  - Both calls need a running, logged-in Steam client, and the parent must be an item the logged-in account owns.
197
237
  - 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.
198
238
 
239
+ ### App dependencies
240
+
241
+ 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.
242
+
243
+ `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.
244
+
245
+ ## Workshop User Actions
246
+
247
+ 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.
248
+
249
+ ```js
250
+ const steamworks = require('steamworks.js')
251
+ const client = steamworks.init(appId)
252
+
253
+ await client.workshop.setUserItemVote(itemId, true) // vote up; false votes down
254
+ const vote = await client.workshop.getUserItemVote(itemId) // { votedUp, votedDown, skipped }
255
+
256
+ await client.workshop.addItemToFavorites(itemId) // appId defaults to the client's app
257
+ await client.workshop.removeItemFromFavorites(itemId)
258
+
259
+ await client.workshop.startPlaytimeTracking([itemId]) // the list must not be empty
260
+ await client.workshop.stopPlaytimeTracking([itemId])
261
+ ```
262
+
263
+ - Item ID 0, a negative id and an empty playtime list are refused before any Steam call.
264
+ - 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.
265
+ - These calls need a running, logged-in Steam client.
266
+
199
267
  ## Workshop Known Game Versions
200
268
 
201
269
  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`:
package/client.d.ts CHANGED
@@ -890,6 +890,43 @@ export declare namespace workshop {
890
890
  Private = 2,
891
891
  Unlisted = 3
892
892
  }
893
+ /** Workshop file types for `createItem`. Omitting the argument keeps `Community`. */
894
+ export const enum WorkshopFileType {
895
+ Community = 0,
896
+ Art = 1,
897
+ Screenshot = 2,
898
+ Video = 3,
899
+ Collection = 4,
900
+ WebGuide = 5,
901
+ IntegratedGuide = 6
902
+ }
903
+ /** Steam's community content descriptors. The values are the SDK's own IDs. */
904
+ export const enum WorkshopContentDescriptor {
905
+ NudityOrSexualContent = 1,
906
+ FrequentViolenceOrGore = 2,
907
+ AdultOnlySexualContent = 3,
908
+ GratuitousSexualContent = 4,
909
+ AnyMatureContent = 5
910
+ }
911
+ /** One key-value tag, stored on the item as `key=value`. */
912
+ export interface KeyValueTag {
913
+ key: string
914
+ value: string
915
+ }
916
+ /** Key-value tag changes. They are applied in the order clear, remove, add. */
917
+ export interface KeyValueTagsUpdate {
918
+ /** Removes every key-value tag of the item first. */
919
+ clear?: boolean
920
+ /** Keys whose values are all removed. */
921
+ remove?: Array<string>
922
+ /** Pairs added after the removals. */
923
+ add?: Array<KeyValueTag>
924
+ }
925
+ /** Content descriptor changes. Removals are applied before additions. */
926
+ export interface ContentDescriptorsUpdate {
927
+ remove?: Array<WorkshopContentDescriptor>
928
+ add?: Array<WorkshopContentDescriptor>
929
+ }
893
930
  export interface UgcUpdate {
894
931
  title?: string
895
932
  description?: string
@@ -912,6 +949,14 @@ export declare namespace workshop {
912
949
  requiredGameVersionMin?: string
913
950
  /** Newest game version (Steam branch) the item is valid for; see `requiredGameVersionMin`. */
914
951
  requiredGameVersionMax?: string
952
+ /** YouTube video IDs (11 characters each) added as video previews. Checked before submission. */
953
+ additionalPreviewVideos?: Array<string>
954
+ /** Developer metadata set on the item. Left unchanged when omitted. */
955
+ metadata?: string
956
+ /** Key-value tag changes, applied in the order clear, remove, add. */
957
+ keyValueTags?: KeyValueTagsUpdate
958
+ /** Content descriptor changes, applied as removals then additions. */
959
+ contentDescriptors?: ContentDescriptorsUpdate
915
960
  }
916
961
  export interface InstallInfo {
917
962
  folder: string
@@ -935,7 +980,13 @@ export declare namespace workshop {
935
980
  progress: bigint
936
981
  total: bigint
937
982
  }
938
- export function createItem(appId?: number | undefined | null): Promise<UgcResult>
983
+ /**
984
+ * Creates an empty Workshop item. The file type defaults to `Community`; `Art` creates an Artwork item.
985
+ *
986
+ * @param appId - defaults to the app id the client was initialized with
987
+ * @param fileType - the Workshop file type; omitted keeps `Community`
988
+ */
989
+ export function createItem(appId?: number | undefined | null, fileType?: WorkshopFileType | undefined | null): Promise<UgcResult>
939
990
  export function updateItem(itemId: bigint, updateDetails: UgcUpdate, appId?: number | undefined | null): Promise<UgcResult>
940
991
  /**
941
992
  * Replace only the main preview image of a Workshop item.
@@ -1026,6 +1077,89 @@ export declare namespace workshop {
1026
1077
  * code (`1` is OK), with the same validation and rejection rules as `addDependency`.
1027
1078
  */
1028
1079
  export function removeDependency(parentId: bigint, childId: bigint): Promise<number>
1080
+ /** The user's vote on a Workshop item, as Steam reports it. */
1081
+ export interface UserItemVoteState {
1082
+ votedUp: boolean
1083
+ votedDown: boolean
1084
+ /** The user has neither voted up nor down. */
1085
+ skipped: boolean
1086
+ }
1087
+ /**
1088
+ * The app dependencies of a Workshop item. When `appIds` is shorter than
1089
+ * `totalAppDependencies`, the list is incomplete.
1090
+ */
1091
+ export interface AppDependencies {
1092
+ /** Steam result code; `1` is OK. */
1093
+ result: number
1094
+ appIds: Array<number>
1095
+ totalAppDependencies: number
1096
+ }
1097
+ /**
1098
+ * Votes for (`voteUp` true) or against a Workshop item as the current user.
1099
+ *
1100
+ * **Changes the user's vote on Steam.** Resolves when Steam confirms the vote.
1101
+ *
1102
+ * @param itemId - the Workshop item
1103
+ * @param voteUp - true to vote up, false to vote down
1104
+ */
1105
+ export function setUserItemVote(itemId: bigint, voteUp: boolean): Promise<void>
1106
+ /** Reads the current user's vote on a Workshop item. Read-only. */
1107
+ export function getUserItemVote(itemId: bigint): Promise<UserItemVoteState>
1108
+ /**
1109
+ * Adds a Workshop item to the current user's favorites.
1110
+ *
1111
+ * **Changes the user's favorites on Steam.**
1112
+ *
1113
+ * @param itemId - the Workshop item
1114
+ * @param appId - defaults to the app id the client was initialized with
1115
+ */
1116
+ export function addItemToFavorites(itemId: bigint, appId?: number | undefined | null): Promise<void>
1117
+ /**
1118
+ * Removes a Workshop item from the current user's favorites.
1119
+ *
1120
+ * **Changes the user's favorites on Steam.**
1121
+ *
1122
+ * @param itemId - the Workshop item
1123
+ * @param appId - defaults to the app id the client was initialized with
1124
+ */
1125
+ export function removeItemFromFavorites(itemId: bigint, appId?: number | undefined | null): Promise<void>
1126
+ /**
1127
+ * Starts playtime tracking for Workshop items. The list must not be empty.
1128
+ *
1129
+ * **Changes the user's playtime records on Steam.**
1130
+ *
1131
+ * @param itemIds - the Workshop items
1132
+ */
1133
+ export function startPlaytimeTracking(itemIds: Array<bigint>): Promise<void>
1134
+ /**
1135
+ * Stops playtime tracking for Workshop items. The list must not be empty.
1136
+ *
1137
+ * **Changes the user's playtime records on Steam.**
1138
+ *
1139
+ * @param itemIds - the Workshop items
1140
+ */
1141
+ export function stopPlaytimeTracking(itemIds: Array<bigint>): Promise<void>
1142
+ /**
1143
+ * Adds `appId` as an app dependency of a Workshop item (for example a DLC the item needs).
1144
+ * Resolves with the Steam result code, where `1` is OK. A non-OK code resolves rather than rejects.
1145
+ *
1146
+ * **Changes the item's remote state.**
1147
+ */
1148
+ export function addAppDependency(itemId: bigint, appId: number): Promise<number>
1149
+ /**
1150
+ * Removes `appId` from the app dependencies of a Workshop item. Resolves with the Steam result code
1151
+ * (`1` is OK), with the same rules as `addAppDependency`.
1152
+ *
1153
+ * **Changes the item's remote state.**
1154
+ */
1155
+ export function removeAppDependency(itemId: bigint, appId: number): Promise<number>
1156
+ /**
1157
+ * Reads every app dependency of a Workshop item. Steam sends them in pages; they are collected
1158
+ * until the reported total is reached. Read-only.
1159
+ *
1160
+ * Not verified against a live Steam client: see the paging note in steamworks-rs.
1161
+ */
1162
+ export function getAppDependencies(itemId: bigint): Promise<AppDependencies>
1029
1163
  export const enum UGCQueryType {
1030
1164
  RankedByVote = 0,
1031
1165
  RankedByPublicationDate = 1,
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/HagiCode-org/steamworks.js/issues"
16
16
  },
17
- "version": "0.1.6-dev.33",
17
+ "version": "0.1.6-dev.35",
18
18
  "main": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "napi": {