steamworks-ffi-node 0.7.0 → 0.7.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.
Files changed (42) hide show
  1. package/README.md +15 -4
  2. package/dist/internal/SteamCloudManager.d.ts +86 -1
  3. package/dist/internal/SteamCloudManager.d.ts.map +1 -1
  4. package/dist/internal/SteamCloudManager.js +142 -0
  5. package/dist/internal/SteamCloudManager.js.map +1 -1
  6. package/dist/internal/SteamLibraryLoader.d.ts +13 -0
  7. package/dist/internal/SteamLibraryLoader.d.ts.map +1 -1
  8. package/dist/internal/SteamLibraryLoader.js +22 -0
  9. package/dist/internal/SteamLibraryLoader.js.map +1 -1
  10. package/dist/internal/SteamScreenshotManager.d.ts +327 -0
  11. package/dist/internal/SteamScreenshotManager.d.ts.map +1 -0
  12. package/dist/internal/SteamScreenshotManager.js +459 -0
  13. package/dist/internal/SteamScreenshotManager.js.map +1 -0
  14. package/dist/internal/SteamWorkshopManager.d.ts +24 -0
  15. package/dist/internal/SteamWorkshopManager.d.ts.map +1 -1
  16. package/dist/internal/SteamWorkshopManager.js +74 -0
  17. package/dist/internal/SteamWorkshopManager.js.map +1 -1
  18. package/dist/internal/callbackTypes/SteamCallbackIds.d.ts +2 -0
  19. package/dist/internal/callbackTypes/SteamCallbackIds.d.ts.map +1 -1
  20. package/dist/internal/callbackTypes/SteamCallbackIds.js +3 -1
  21. package/dist/internal/callbackTypes/SteamCallbackIds.js.map +1 -1
  22. package/dist/internal/callbackTypes/SteamCallbackTypes.d.ts +9 -0
  23. package/dist/internal/callbackTypes/SteamCallbackTypes.d.ts.map +1 -1
  24. package/dist/steam.d.ts +40 -0
  25. package/dist/steam.d.ts.map +1 -1
  26. package/dist/steam.js +4 -0
  27. package/dist/steam.js.map +1 -1
  28. package/dist/types/cloud.d.ts +11 -11
  29. package/dist/types/cloud.d.ts.map +1 -1
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/index.js +2 -0
  33. package/dist/types/index.js.map +1 -1
  34. package/dist/types/screenshots.d.ts +63 -0
  35. package/dist/types/screenshots.d.ts.map +1 -0
  36. package/dist/types/screenshots.js +44 -0
  37. package/dist/types/screenshots.js.map +1 -0
  38. package/dist/types/workshop.d.ts +8 -0
  39. package/dist/types/workshop.d.ts.map +1 -1
  40. package/dist/types/workshop.js.map +1 -1
  41. package/docs/README.md +20 -4
  42. package/package.json +3 -1
@@ -0,0 +1,327 @@
1
+ import { SteamLibraryLoader } from './SteamLibraryLoader';
2
+ import { SteamAPICore } from './SteamAPICore';
3
+ import { ScreenshotHandle, EVRScreenshotType } from '../types';
4
+ /**
5
+ * Manager for Steam Screenshots API operations
6
+ *
7
+ * The SteamScreenshotManager provides functionality to capture screenshots,
8
+ * add them to the user's Steam screenshot library, and tag them with metadata
9
+ * like location, users, and Workshop items.
10
+ *
11
+ * Screenshots can be captured in two ways:
12
+ * 1. **Overlay capture**: Using `triggerScreenshot()` to have Steam capture the screen
13
+ * 2. **Manual capture**: Your game captures the image and uses `writeScreenshot()` or
14
+ * `addScreenshotToLibrary()` to add it
15
+ *
16
+ * @remarks
17
+ * The manual capture methods work without the overlay, making them suitable for
18
+ * headless or non-graphical environments. The overlay-based `triggerScreenshot()`
19
+ * requires the Steam overlay to be available.
20
+ *
21
+ * @example Basic screenshot capture
22
+ * ```typescript
23
+ * const steam = SteamworksSDK.getInstance();
24
+ * steam.init({ appId: 480 });
25
+ *
26
+ * // Add a screenshot from a file
27
+ * const handle = steam.screenshots.addScreenshotToLibrary(
28
+ * '/path/to/screenshot.jpg',
29
+ * null, // No thumbnail - Steam will generate one
30
+ * 1920,
31
+ * 1080
32
+ * );
33
+ *
34
+ * if (handle !== INVALID_SCREENSHOT_HANDLE) {
35
+ * // Tag the screenshot with location
36
+ * steam.screenshots.setLocation(handle, 'Level 1 - Boss Fight');
37
+ * }
38
+ * ```
39
+ *
40
+ * @example Hook screenshots for custom handling
41
+ * ```typescript
42
+ * // Tell Steam your app handles screenshots
43
+ * steam.screenshots.hookScreenshots(true);
44
+ *
45
+ * // Now when user presses screenshot key, you get a callback
46
+ * // and should call writeScreenshot() or addScreenshotToLibrary()
47
+ * ```
48
+ *
49
+ * @see {@link https://partner.steamgames.com/doc/api/ISteamScreenshots ISteamScreenshots Documentation}
50
+ */
51
+ export declare class SteamScreenshotManager {
52
+ /** Steam library loader for FFI function calls */
53
+ private libraryLoader;
54
+ /** Steam API core for initialization and callback management */
55
+ private apiCore;
56
+ /** Cached screenshots interface pointer */
57
+ private screenshotsInterface;
58
+ /**
59
+ * Creates a new SteamScreenshotManager instance
60
+ *
61
+ * @param libraryLoader - The Steam library loader for FFI calls
62
+ * @param apiCore - The Steam API core for lifecycle management
63
+ */
64
+ constructor(libraryLoader: SteamLibraryLoader, apiCore: SteamAPICore);
65
+ /**
66
+ * Gets the ISteamScreenshots interface pointer
67
+ *
68
+ * @returns The interface pointer or null if not available
69
+ */
70
+ private getScreenshotsInterface;
71
+ /**
72
+ * Writes a screenshot to the user's Steam screenshot library from raw RGB data
73
+ *
74
+ * @param rgbData - Buffer containing raw RGB pixel data (no alpha channel)
75
+ * @param width - Width of the image in pixels
76
+ * @param height - Height of the image in pixels
77
+ * @returns Screenshot handle, or INVALID_SCREENSHOT_HANDLE on failure
78
+ *
79
+ * @remarks
80
+ * - The image data must be in RGB format (3 bytes per pixel)
81
+ * - The buffer size should be width * height * 3 bytes
82
+ * - This method works without the overlay
83
+ * - The returned handle can be used to tag the screenshot
84
+ *
85
+ * @example Write raw RGB data as screenshot
86
+ * ```typescript
87
+ * // Assume you have raw RGB pixel data from your renderer
88
+ * const width = 1920;
89
+ * const height = 1080;
90
+ * const rgbData = Buffer.alloc(width * height * 3);
91
+ *
92
+ * // Fill rgbData with your screenshot pixels...
93
+ *
94
+ * const handle = steam.screenshots.writeScreenshot(rgbData, width, height);
95
+ *
96
+ * if (handle !== INVALID_SCREENSHOT_HANDLE) {
97
+ * console.log('Screenshot saved with handle:', handle);
98
+ * steam.screenshots.setLocation(handle, 'My Game Location');
99
+ * }
100
+ * ```
101
+ */
102
+ writeScreenshot(rgbData: Buffer, width: number, height: number): ScreenshotHandle;
103
+ /**
104
+ * Adds a screenshot to the user's Steam library from a file on disk
105
+ *
106
+ * @param filename - Path to the screenshot file (JPEG, TGA, or PNG)
107
+ * @param thumbnailFilename - Path to thumbnail file (200px wide), or null for auto-generation
108
+ * @param width - Width of the image in pixels
109
+ * @param height - Height of the image in pixels
110
+ * @returns Screenshot handle, or INVALID_SCREENSHOT_HANDLE on failure
111
+ *
112
+ * @remarks
113
+ * - Supported formats: JPEG, TGA, PNG
114
+ * - If thumbnail is provided, it must be 200 pixels wide with same aspect ratio
115
+ * - If thumbnail is null, Steam will generate one when the screenshot is uploaded
116
+ * - This method works without the overlay
117
+ *
118
+ * @example Add screenshot from file
119
+ * ```typescript
120
+ * // Add a screenshot without custom thumbnail
121
+ * const handle = steam.screenshots.addScreenshotToLibrary(
122
+ * '/path/to/screenshot.png',
123
+ * null,
124
+ * 1920,
125
+ * 1080
126
+ * );
127
+ *
128
+ * // Add with custom thumbnail
129
+ * const handle2 = steam.screenshots.addScreenshotToLibrary(
130
+ * '/path/to/screenshot.jpg',
131
+ * '/path/to/thumb.jpg',
132
+ * 2560,
133
+ * 1440
134
+ * );
135
+ *
136
+ * if (handle !== INVALID_SCREENSHOT_HANDLE) {
137
+ * steam.screenshots.setLocation(handle, 'Epic Boss Battle');
138
+ * }
139
+ * ```
140
+ */
141
+ addScreenshotToLibrary(filename: string, thumbnailFilename: string | null, width: number, height: number): ScreenshotHandle;
142
+ /**
143
+ * Triggers the Steam overlay to take a screenshot
144
+ *
145
+ * @remarks
146
+ * - If screenshots are hooked via `hookScreenshots(true)`, this sends a
147
+ * ScreenshotRequested_t callback instead and your game should capture
148
+ * the screenshot manually
149
+ * - Requires the Steam overlay to be available
150
+ * - This is equivalent to the user pressing the screenshot hotkey
151
+ *
152
+ * @example Trigger overlay screenshot
153
+ * ```typescript
154
+ * // Simple screenshot button in your game
155
+ * function onScreenshotButtonClick() {
156
+ * steam.screenshots.triggerScreenshot();
157
+ * }
158
+ * ```
159
+ */
160
+ triggerScreenshot(): void;
161
+ /**
162
+ * Toggles whether your game handles screenshots or Steam does
163
+ *
164
+ * @param hook - True to handle screenshots yourself, false to let Steam handle them
165
+ *
166
+ * @remarks
167
+ * When hooked:
168
+ * - Steam will NOT automatically capture screenshots when user presses hotkey
169
+ * - Instead, your game receives a ScreenshotRequested_t callback
170
+ * - Your game should then call `writeScreenshot()` or `addScreenshotToLibrary()`
171
+ *
172
+ * This is useful when:
173
+ * - You want to add custom overlays/HUD to screenshots
174
+ * - You want to capture from a specific render target
175
+ * - You need to post-process screenshots before saving
176
+ *
177
+ * @example Hook screenshots for custom capture
178
+ * ```typescript
179
+ * // Tell Steam we'll handle screenshots
180
+ * steam.screenshots.hookScreenshots(true);
181
+ *
182
+ * // Later, in your screenshot callback handler:
183
+ * function onScreenshotRequested() {
184
+ * // Capture from your render target
185
+ * const rgbData = myRenderer.captureScreen();
186
+ *
187
+ * // Add to Steam library
188
+ * const handle = steam.screenshots.writeScreenshot(rgbData, 1920, 1080);
189
+ * steam.screenshots.setLocation(handle, getCurrentMapName());
190
+ * }
191
+ * ```
192
+ */
193
+ hookScreenshots(hook: boolean): void;
194
+ /**
195
+ * Checks if screenshots are currently hooked by your game
196
+ *
197
+ * @returns True if your game is handling screenshots, false if Steam handles them
198
+ *
199
+ * @example Check hook status
200
+ * ```typescript
201
+ * if (steam.screenshots.isScreenshotsHooked()) {
202
+ * console.log('Game is handling screenshots');
203
+ * } else {
204
+ * console.log('Steam overlay handles screenshots');
205
+ * }
206
+ * ```
207
+ */
208
+ isScreenshotsHooked(): boolean;
209
+ /**
210
+ * Sets the location metadata for a screenshot
211
+ *
212
+ * @param handle - Screenshot handle from writeScreenshot or addScreenshotToLibrary
213
+ * @param location - Location string (e.g., map name, level name)
214
+ * @returns True if location was set successfully
215
+ *
216
+ * @remarks
217
+ * The location is displayed in the Steam screenshot viewer and helps users
218
+ * remember where screenshots were taken.
219
+ *
220
+ * @example Tag screenshot with location
221
+ * ```typescript
222
+ * const handle = steam.screenshots.addScreenshotToLibrary(
223
+ * '/path/to/screenshot.jpg',
224
+ * null,
225
+ * 1920,
226
+ * 1080
227
+ * );
228
+ *
229
+ * if (handle !== INVALID_SCREENSHOT_HANDLE) {
230
+ * steam.screenshots.setLocation(handle, 'World 3 - Lava Caves');
231
+ * steam.screenshots.setLocation(handle, 'Boss: Fire Dragon');
232
+ * }
233
+ * ```
234
+ */
235
+ setLocation(handle: ScreenshotHandle, location: string): boolean;
236
+ /**
237
+ * Tags a Steam user as being visible in the screenshot
238
+ *
239
+ * @param handle - Screenshot handle from writeScreenshot or addScreenshotToLibrary
240
+ * @param steamId - Steam ID of the user to tag (as BigInt)
241
+ * @returns True if user was tagged successfully
242
+ *
243
+ * @remarks
244
+ * - You can tag up to 32 users per screenshot
245
+ * - Tagged users will see the screenshot in their profile
246
+ * - Users can untag themselves from screenshots
247
+ *
248
+ * @example Tag friends in screenshot
249
+ * ```typescript
250
+ * const handle = steam.screenshots.addScreenshotToLibrary(
251
+ * '/path/to/group_photo.jpg',
252
+ * null,
253
+ * 1920,
254
+ * 1080
255
+ * );
256
+ *
257
+ * if (handle !== INVALID_SCREENSHOT_HANDLE) {
258
+ * // Tag all friends visible in the screenshot
259
+ * const friends = steam.friends.getAllFriends();
260
+ * for (const friend of friends.slice(0, 5)) {
261
+ * steam.screenshots.tagUser(handle, friend.steamId);
262
+ * }
263
+ * }
264
+ * ```
265
+ */
266
+ tagUser(handle: ScreenshotHandle, steamId: bigint): boolean;
267
+ /**
268
+ * Tags a Workshop item as being visible in the screenshot
269
+ *
270
+ * @param handle - Screenshot handle from writeScreenshot or addScreenshotToLibrary
271
+ * @param publishedFileId - Workshop item ID to tag (as BigInt)
272
+ * @returns True if item was tagged successfully
273
+ *
274
+ * @remarks
275
+ * - You can tag up to 32 Workshop items per screenshot
276
+ * - Useful for showing mods/custom content in screenshots
277
+ * - Tagged items will show the screenshot on their Workshop page
278
+ *
279
+ * @example Tag Workshop items in screenshot
280
+ * ```typescript
281
+ * const handle = steam.screenshots.addScreenshotToLibrary(
282
+ * '/path/to/modded_screenshot.jpg',
283
+ * null,
284
+ * 1920,
285
+ * 1080
286
+ * );
287
+ *
288
+ * if (handle !== INVALID_SCREENSHOT_HANDLE) {
289
+ * // Tag the Workshop mods visible in this screenshot
290
+ * const modId = BigInt('123456789');
291
+ * steam.screenshots.tagPublishedFile(handle, modId);
292
+ *
293
+ * // Set location too
294
+ * steam.screenshots.setLocation(handle, 'Custom Map: Epic Arena');
295
+ * }
296
+ * ```
297
+ */
298
+ tagPublishedFile(handle: ScreenshotHandle, publishedFileId: bigint): boolean;
299
+ /**
300
+ * Adds a VR screenshot to the user's Steam library from files on disk
301
+ *
302
+ * @param type - The type of VR screenshot
303
+ * @param filename - Path to the normal 2D image for library view (JPEG, TGA, or PNG)
304
+ * @param vrFilename - Path to the VR-specific image matching the type
305
+ * @returns Screenshot handle, or INVALID_SCREENSHOT_HANDLE on failure
306
+ *
307
+ * @remarks
308
+ * - Supported formats: JPEG, TGA, PNG
309
+ * - The filename is used for the library thumbnail view
310
+ * - The vrFilename should contain the appropriate VR format for the type
311
+ *
312
+ * @example Add VR screenshot
313
+ * ```typescript
314
+ * const handle = steam.screenshots.addVRScreenshotToLibrary(
315
+ * EVRScreenshotType.Stereo,
316
+ * '/path/to/preview.jpg',
317
+ * '/path/to/stereo_screenshot.jpg'
318
+ * );
319
+ *
320
+ * if (handle !== INVALID_SCREENSHOT_HANDLE) {
321
+ * steam.screenshots.setLocation(handle, 'VR Level - Space Station');
322
+ * }
323
+ * ```
324
+ */
325
+ addVRScreenshotToLibrary(type: EVRScreenshotType, filename: string, vrFilename: string): ScreenshotHandle;
326
+ }
327
+ //# sourceMappingURL=SteamScreenshotManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SteamScreenshot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