steamworks-ffi-node 0.1.1 → 0.2.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 +63 -129
- package/THIRD_PARTY_LICENSES.md +24 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +1 -1
- package/dist/internal/SteamAPICore.d.ts +46 -0
- package/dist/internal/SteamAPICore.d.ts.map +1 -0
- package/dist/internal/SteamAPICore.js +185 -0
- package/dist/internal/SteamAPICore.js.map +1 -0
- package/dist/internal/SteamAchievementManager.d.ts +117 -0
- package/dist/internal/SteamAchievementManager.d.ts.map +1 -0
- package/dist/internal/SteamAchievementManager.js +673 -0
- package/dist/internal/SteamAchievementManager.js.map +1 -0
- package/dist/internal/SteamLibraryLoader.d.ts +52 -0
- package/dist/internal/SteamLibraryLoader.d.ts.map +1 -0
- package/dist/internal/SteamLibraryLoader.js +134 -0
- package/dist/internal/SteamLibraryLoader.js.map +1 -0
- package/dist/steam.d.ts +88 -30
- package/dist/steam.d.ts.map +1 -1
- package/dist/steam.js +126 -316
- package/dist/steam.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -4,39 +4,46 @@ A production-ready TypeScript/JavaScript wrapper for the Steamworks SDK using Ko
|
|
|
4
4
|
|
|
5
5
|
> ✅ **No C++ Compilation Required**: Uses Koffi FFI for seamless installation without Visual Studio Build Tools!
|
|
6
6
|
|
|
7
|
+
> 🎉 **NEW: 100% Achievement API Coverage** - All 20 Steam achievement functions now implemented! See [Complete Achievement Manager Documentation](https://github.com/ArtyProf/steamworks-ffi-node/blob/main/docs/AchievementManager.md)
|
|
8
|
+
|
|
7
9
|
## 🎯 Features
|
|
8
10
|
|
|
11
|
+
- **Complete Achievement API**: 100% coverage of Steam Achievement functionality (20/20 functions)
|
|
12
|
+
- ✅ Core operations (get, unlock, clear, check status)
|
|
13
|
+
- ✅ Visual features (icons, progress notifications)
|
|
14
|
+
- ✅ Progress tracking (get limits for progress bars)
|
|
15
|
+
- ✅ Friend comparisons (see friend achievements)
|
|
16
|
+
- ✅ Global statistics (unlock percentages, popularity sorting)
|
|
17
|
+
- ✅ Testing tools (reset stats/achievements)
|
|
9
18
|
- **Real Steam Integration**: Direct FFI calls to Steamworks C++ SDK
|
|
10
19
|
- **Cross-Platform**: Windows, macOS, and Linux support
|
|
20
|
+
- **Batteries Included**: All Steamworks redistributables bundled - no SDK download needed!
|
|
11
21
|
- **Electron Ready**: Perfect for Electron applications
|
|
12
|
-
- **Production Ready**: Full Steam client connection and API access
|
|
13
22
|
- **TypeScript Support**: Complete TypeScript definitions included
|
|
14
|
-
- **
|
|
23
|
+
- **No C++ Compilation**: Uses Koffi FFI for seamless installation
|
|
15
24
|
|
|
16
25
|
## 🚀 Quick Start
|
|
17
26
|
|
|
18
|
-
### Prerequisites
|
|
19
|
-
|
|
20
|
-
**Before using, you need:**
|
|
21
|
-
|
|
22
|
-
1. **Steamworks SDK**: Download from [Steam Partner Portal](https://partner.steamgames.com/) and place in `steamworks_sdk/` directory
|
|
23
|
-
|
|
24
|
-
2. **Steam Client**: Must be running and logged in for real integration
|
|
25
|
-
|
|
26
27
|
### Installation
|
|
27
28
|
|
|
28
29
|
```bash
|
|
29
|
-
# Install
|
|
30
|
-
npm install
|
|
31
|
-
|
|
32
|
-
# Build TypeScript
|
|
33
|
-
npm run build
|
|
30
|
+
# Install the package - includes all Steam redistributables!
|
|
31
|
+
npm install steamworks-ffi-node
|
|
34
32
|
```
|
|
35
33
|
|
|
34
|
+
### Setup
|
|
35
|
+
|
|
36
|
+
1. **Create `steam_appid.txt`** in your project root:
|
|
37
|
+
```bash
|
|
38
|
+
echo "480" > steam_appid.txt # Use 480 for testing, or your Steam App ID
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. **Make sure Steam is running** and you're logged in
|
|
42
|
+
|
|
36
43
|
### Basic Usage
|
|
37
44
|
|
|
38
45
|
```typescript
|
|
39
|
-
import Steam from 'steamworks-ffi';
|
|
46
|
+
import Steam from 'steamworks-ffi-node';
|
|
40
47
|
|
|
41
48
|
// Initialize real Steam connection
|
|
42
49
|
const steam = Steam.getInstance();
|
|
@@ -62,7 +69,7 @@ steam.shutdown();
|
|
|
62
69
|
### JavaScript (CommonJS)
|
|
63
70
|
|
|
64
71
|
```javascript
|
|
65
|
-
const Steam = require('steamworks-ffi').default;
|
|
72
|
+
const Steam = require('steamworks-ffi-node').default;
|
|
66
73
|
|
|
67
74
|
async function example() {
|
|
68
75
|
const steam = Steam.getInstance();
|
|
@@ -84,67 +91,19 @@ async function example() {
|
|
|
84
91
|
example();
|
|
85
92
|
```
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Steam Class
|
|
90
|
-
|
|
91
|
-
#### `Steam.getInstance()`
|
|
92
|
-
Get the singleton Steam instance.
|
|
94
|
+
### Testing with Spacewar
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
#### `shutdown(): void`
|
|
99
|
-
Shutdown the Steam API and cleanup resources.
|
|
100
|
-
|
|
101
|
-
#### `getStatus(): SteamStatus`
|
|
102
|
-
Get current Steam status information.
|
|
103
|
-
|
|
104
|
-
### Achievement Methods
|
|
105
|
-
|
|
106
|
-
#### `getAllAchievements(): Promise<SteamAchievement[]>`
|
|
107
|
-
Get all available achievements for the app.
|
|
108
|
-
|
|
109
|
-
#### `unlockAchievement(apiName: string): Promise<boolean>`
|
|
110
|
-
Unlock a specific achievement.
|
|
111
|
-
|
|
112
|
-
#### `clearAchievement(apiName: string): Promise<boolean>`
|
|
113
|
-
Clear/reset an achievement (for testing).
|
|
114
|
-
|
|
115
|
-
#### `isAchievementUnlocked(apiName: string): Promise<boolean>`
|
|
116
|
-
Check if an achievement is unlocked.
|
|
117
|
-
|
|
118
|
-
#### `getAchievement(apiName: string): Promise<SteamAchievement | null>`
|
|
119
|
-
Get details for a specific achievement.
|
|
120
|
-
|
|
121
|
-
#### `getTotalCount(): Promise<number>`
|
|
122
|
-
Get total number of achievements.
|
|
96
|
+
For immediate testing, use Spacewar (App ID 480):
|
|
97
|
+
- Free Steam app for testing Steamworks features
|
|
98
|
+
- Add to Steam library: `steam://install/480` or search "Spacewar" in Steam
|
|
99
|
+
- Launch it once, then you can test with App ID 480
|
|
123
100
|
|
|
124
|
-
|
|
125
|
-
Get number of unlocked achievements.
|
|
101
|
+
## 📚 API Documentation
|
|
126
102
|
|
|
127
|
-
###
|
|
103
|
+
### Documentation
|
|
128
104
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
apiName: string; // Internal achievement ID
|
|
132
|
-
displayName: string; // User-friendly name
|
|
133
|
-
description: string; // Achievement description
|
|
134
|
-
unlocked: boolean; // Whether it's unlocked
|
|
135
|
-
unlockTime: number; // Unix timestamp of unlock (0 if locked)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
interface SteamInitOptions {
|
|
139
|
-
appId: number; // Your Steam Application ID
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
interface SteamStatus {
|
|
143
|
-
initialized: boolean; // Whether Steam API is initialized
|
|
144
|
-
appId: number; // Current app ID
|
|
145
|
-
steamId: string; // Current user's Steam ID
|
|
146
|
-
}
|
|
147
|
-
```
|
|
105
|
+
- **[SteamAPICore Documentation](https://github.com/ArtyProf/steamworks-ffi-node/blob/main/docs/SteamAPICore.md)** - Initialization, lifecycle management, callbacks
|
|
106
|
+
- **[Achievement Manager API](https://github.com/ArtyProf/steamworks-ffi-node/blob/main/docs/AchievementManager.md)** - Complete achievement functionality (20 functions)
|
|
148
107
|
|
|
149
108
|
## 🎮 Real Steam Integration
|
|
150
109
|
|
|
@@ -173,12 +132,12 @@ await steam.unlockAchievement('YOUR_ACHIEVEMENT');
|
|
|
173
132
|
|
|
174
133
|
## 🖥️ Electron Integration
|
|
175
134
|
|
|
176
|
-
For Electron applications,
|
|
135
|
+
For Electron applications, use it in your main process:
|
|
177
136
|
|
|
178
137
|
```typescript
|
|
179
138
|
// main.ts
|
|
180
139
|
import { app } from 'electron';
|
|
181
|
-
import Steam from 'steamworks-ffi';
|
|
140
|
+
import Steam from 'steamworks-ffi-node';
|
|
182
141
|
|
|
183
142
|
app.whenReady().then(() => {
|
|
184
143
|
const steam = Steam.getInstance();
|
|
@@ -196,71 +155,46 @@ app.on('before-quit', () => {
|
|
|
196
155
|
});
|
|
197
156
|
```
|
|
198
157
|
|
|
199
|
-
## 🏗️ Production Setup
|
|
200
|
-
|
|
201
|
-
### Steamworks SDK Setup
|
|
202
|
-
|
|
203
|
-
1. **Download SDK**: Get from [Steam Partner Portal](https://partner.steamgames.com/)
|
|
204
|
-
2. **Extract to project**:
|
|
205
|
-
```
|
|
206
|
-
steamworks_sdk/
|
|
207
|
-
├── public/steam/ # Header files
|
|
208
|
-
└── redistributable_bin/ # Native libraries
|
|
209
|
-
├── win64/steam_api64.dll
|
|
210
|
-
├── osx/libsteam_api.dylib
|
|
211
|
-
└── linux64/libsteam_api.so
|
|
212
|
-
```
|
|
213
|
-
3. **Get Steam App ID**: Register your game on Steamworks
|
|
214
|
-
4. **Create steam_appid.txt**: File with your App ID in project root
|
|
215
|
-
|
|
216
|
-
### Testing Setup
|
|
217
|
-
|
|
218
|
-
For immediate testing, use Spacewar (App ID 480):
|
|
219
|
-
- Free Steam app for testing
|
|
220
|
-
- Add to Steam library: steam://install/480
|
|
221
|
-
- Requires Steam client running and logged in
|
|
222
|
-
|
|
223
158
|
## 🔧 Requirements
|
|
224
159
|
|
|
225
|
-
### Development
|
|
226
160
|
- **Node.js**: 18+
|
|
227
|
-
- **TypeScript**: 5.0+ (optional)
|
|
228
|
-
- **Visual Studio Build Tools**: C++ workload required
|
|
229
|
-
- **Python**: For native module compilation
|
|
230
|
-
|
|
231
|
-
### Runtime
|
|
232
161
|
- **Steam Client**: Must be running and logged in
|
|
233
|
-
- **
|
|
234
|
-
- **
|
|
162
|
+
- **Steam App ID**: Get yours at [Steamworks Partner](https://partner.steamgames.com/)
|
|
163
|
+
- **steam_appid.txt**: Create in your project root with your App ID
|
|
235
164
|
|
|
236
165
|
### Platform Support
|
|
237
|
-
- ✅ **Windows**: steam_api64.dll / steam_api.dll
|
|
238
|
-
- ✅ **macOS**: libsteam_api.dylib
|
|
239
|
-
- ✅ **Linux**: libsteam_api.so
|
|
166
|
+
- ✅ **Windows**: Included (steam_api64.dll / steam_api.dll)
|
|
167
|
+
- ✅ **macOS**: Included (libsteam_api.dylib)
|
|
168
|
+
- ✅ **Linux**: Included (libsteam_api.so)
|
|
240
169
|
|
|
241
|
-
|
|
170
|
+
All redistributable binaries are included in the package - no manual SDK download required!
|
|
242
171
|
|
|
243
|
-
|
|
244
|
-
# 1. Setup environment
|
|
245
|
-
npm run setup
|
|
172
|
+
## 🔧 Troubleshooting
|
|
246
173
|
|
|
247
|
-
|
|
248
|
-
|
|
174
|
+
### "SteamAPI_Init failed"
|
|
175
|
+
- ❌ Steam client not running → **Solution**: Start Steam and log in
|
|
176
|
+
- ❌ `steam_appid.txt` missing → **Solution**: Create file in project root with your App ID
|
|
177
|
+
- ❌ Invalid App ID → **Solution**: Use 480 for testing, or your registered App ID
|
|
249
178
|
|
|
250
|
-
|
|
251
|
-
npm
|
|
179
|
+
### "Cannot find module 'steamworks-ffi-node'"
|
|
180
|
+
- ❌ Package not installed → **Solution**: Run `npm install steamworks-ffi-node`
|
|
252
181
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
182
|
+
### Achievement operations not working
|
|
183
|
+
- ❌ Not initialized → **Solution**: Call `steam.init({ appId })` first
|
|
184
|
+
- ❌ No achievements configured → **Solution**: Configure achievements in Steamworks Partner site
|
|
185
|
+
- ❌ Using Spacewar → **Note**: Spacewar may not have achievements, use your own App ID
|
|
256
186
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
**"SteamAPI_Init failed"**: Make sure Steam client is running
|
|
261
|
-
**Build errors**: Install Visual Studio C++ Build Tools
|
|
262
|
-
**"Missing VC++ toolset"**: Add C++ workload in VS Installer
|
|
187
|
+
### Electron-specific issues
|
|
188
|
+
- ❌ Initialized in renderer → **Solution**: Only initialize in main process
|
|
189
|
+
- ❌ Not cleaning up → **Solution**: Call `shutdown()` in `before-quit` event
|
|
263
190
|
|
|
264
191
|
## 📄 License
|
|
265
192
|
|
|
266
|
-
MIT License - see LICENSE file for details.
|
|
193
|
+
MIT License - see LICENSE file for details.
|
|
194
|
+
|
|
195
|
+
### Steamworks SDK Redistributables
|
|
196
|
+
|
|
197
|
+
This package includes redistributable binaries from the Steamworks SDK (© Valve Corporation).
|
|
198
|
+
These are distributed under the Steamworks SDK Access Agreement in accordance with Section 1.1(b).
|
|
199
|
+
|
|
200
|
+
See [THIRD_PARTY_LICENSES.md](https://github.com/ArtyProf/steamworks-ffi-node/blob/main/THIRD_PARTY_LICENSES.md) for full details.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Third-Party Licenses
|
|
2
|
+
|
|
3
|
+
## Steamworks SDK Redistributables
|
|
4
|
+
|
|
5
|
+
This package includes redistributable binaries from the Steamworks SDK.
|
|
6
|
+
|
|
7
|
+
**Copyright**: © Valve Corporation. All rights reserved.
|
|
8
|
+
|
|
9
|
+
**License**: These redistributables are distributed under the Steamworks SDK Access Agreement.
|
|
10
|
+
|
|
11
|
+
The Steamworks SDK redistributables are provided by Valve Corporation and are subject to the Steamworks SDK Access Agreement available at:
|
|
12
|
+
https://partner.steamgames.com/documentation/sdk_access_agreement
|
|
13
|
+
|
|
14
|
+
### Included Components:
|
|
15
|
+
- `steamworks_sdk/redistributable_bin/` - Platform-specific Steam API libraries
|
|
16
|
+
- Windows: steam_api64.dll, steam_api.dll
|
|
17
|
+
- macOS: libsteam_api.dylib
|
|
18
|
+
- Linux: libsteam_api.so
|
|
19
|
+
|
|
20
|
+
These files are distributed in accordance with Section 1.1(b) of the Steamworks SDK Access Agreement, which permits reproduction and distribution of SDK Redistributables in object code form along with licensee software.
|
|
21
|
+
|
|
22
|
+
## Package License
|
|
23
|
+
|
|
24
|
+
The wrapper code in this package (excluding Steamworks SDK redistributables) is licensed under the MIT License. See LICENSE file for details.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SteamworksSDK from './steam';
|
|
2
|
-
import { SteamAchievement, SteamInitOptions, SteamStatus } from './types';
|
|
3
|
-
export { SteamAchievement, SteamInitOptions, SteamStatus };
|
|
2
|
+
import { SteamAchievement, SteamInitOptions, SteamStatus, AchievementProgressLimits, UserAchievement, AchievementGlobalStats, AchievementWithIcon } from './types';
|
|
3
|
+
export { SteamAchievement, SteamInitOptions, SteamStatus, AchievementProgressLimits, UserAchievement, AchievementGlobalStats, AchievementWithIcon };
|
|
4
4
|
export default SteamworksSDK;
|
|
5
5
|
export { SteamworksSDK as Steam };
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,SAAS,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACpB,CAAC;AAGF,eAAe,aAAa,CAAC;AAG7B,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,22 +8,4 @@ const steam_1 = __importDefault(require("./steam"));
|
|
|
8
8
|
exports.Steam = steam_1.default;
|
|
9
9
|
// Export main Steam class
|
|
10
10
|
exports.default = steam_1.default;
|
|
11
|
-
// Example usage (commented out)
|
|
12
|
-
/*
|
|
13
|
-
// Initialize Steam
|
|
14
|
-
const steam = SteamFFI.getInstance();
|
|
15
|
-
const initialized = steam.init({ appId: 480 }); // Steam's test app
|
|
16
|
-
|
|
17
|
-
if (initialized) {
|
|
18
|
-
// Get achievements
|
|
19
|
-
steam.getAllAchievements().then(achievements => {
|
|
20
|
-
console.log('Achievements:', achievements);
|
|
21
|
-
|
|
22
|
-
if (achievements.length > 0) {
|
|
23
|
-
// Unlock first achievement
|
|
24
|
-
steam.unlockAchievement(achievements[0].apiName);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
*/
|
|
29
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAoC;AA0BV,gBA1BnB,eAAa,CA0BW;AAJ/B,0BAA0B;AAC1B,kBAAe,eAAa,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SteamInitOptions, SteamStatus } from '../types';
|
|
2
|
+
import { SteamLibraryLoader } from './SteamLibraryLoader';
|
|
3
|
+
/**
|
|
4
|
+
* Core Steam API initialization and lifecycle management
|
|
5
|
+
*/
|
|
6
|
+
export declare class SteamAPICore {
|
|
7
|
+
private libraryLoader;
|
|
8
|
+
private initialized;
|
|
9
|
+
private appId;
|
|
10
|
+
private userStatsInterface;
|
|
11
|
+
private userInterface;
|
|
12
|
+
constructor(libraryLoader: SteamLibraryLoader);
|
|
13
|
+
/**
|
|
14
|
+
* Initialize Steam API
|
|
15
|
+
*/
|
|
16
|
+
init(options: SteamInitOptions): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Shutdown Steam API
|
|
19
|
+
*/
|
|
20
|
+
shutdown(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get current Steam status
|
|
23
|
+
*/
|
|
24
|
+
getStatus(): SteamStatus;
|
|
25
|
+
/**
|
|
26
|
+
* Run Steam callbacks to process pending events
|
|
27
|
+
*/
|
|
28
|
+
runCallbacks(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Check if Steam client is running
|
|
31
|
+
*/
|
|
32
|
+
isSteamRunning(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if initialized
|
|
35
|
+
*/
|
|
36
|
+
isInitialized(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get UserStats interface pointer
|
|
39
|
+
*/
|
|
40
|
+
getUserStatsInterface(): any;
|
|
41
|
+
/**
|
|
42
|
+
* Get User interface pointer
|
|
43
|
+
*/
|
|
44
|
+
getUserInterface(): any;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=SteamAPICore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SteamAPICore.d.ts","sourceRoot":"","sources":["../../src/internal/SteamAPICore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,aAAa,CAAa;gBAEtB,aAAa,EAAE,kBAAkB;IAI7C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;IAmExC;;OAEG;IACH,QAAQ,IAAI,IAAI;IAWhB;;OAEG;IACH,SAAS,IAAI,WAAW;IAmBxB;;OAEG;IACH,YAAY,IAAI,IAAI;IAUpB;;OAEG;IACH,cAAc,IAAI,OAAO;IAYzB;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,qBAAqB,IAAI,GAAG;IAI5B;;OAEG;IACH,gBAAgB,IAAI,GAAG;CAGxB"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SteamAPICore = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Core Steam API initialization and lifecycle management
|
|
41
|
+
*/
|
|
42
|
+
class SteamAPICore {
|
|
43
|
+
constructor(libraryLoader) {
|
|
44
|
+
this.initialized = false;
|
|
45
|
+
this.appId = 0;
|
|
46
|
+
this.userStatsInterface = null;
|
|
47
|
+
this.userInterface = null;
|
|
48
|
+
this.libraryLoader = libraryLoader;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Initialize Steam API
|
|
52
|
+
*/
|
|
53
|
+
init(options) {
|
|
54
|
+
try {
|
|
55
|
+
this.appId = options.appId;
|
|
56
|
+
// Set Steam App ID in environment
|
|
57
|
+
process.env.SteamAppId = this.appId.toString();
|
|
58
|
+
// Also create steam_appid.txt file (Steam requirement)
|
|
59
|
+
const appIdFilePath = path.join(process.cwd(), 'steam_appid.txt');
|
|
60
|
+
fs.writeFileSync(appIdFilePath, this.appId.toString());
|
|
61
|
+
console.log(`[Steamworks] Loading Steamworks SDK for App ID: ${this.appId}`);
|
|
62
|
+
// Load the library
|
|
63
|
+
this.libraryLoader.load();
|
|
64
|
+
console.log('[Steamworks] Initializing Steam API...');
|
|
65
|
+
// Initialize Steam API
|
|
66
|
+
const initResult = this.libraryLoader.SteamAPI_Init();
|
|
67
|
+
if (!initResult) {
|
|
68
|
+
throw new Error('SteamAPI_Init() failed. Make sure Steam client is running and you\'re logged in.');
|
|
69
|
+
}
|
|
70
|
+
// Check if Steam is running
|
|
71
|
+
const steamRunning = this.libraryLoader.SteamAPI_IsSteamRunning();
|
|
72
|
+
if (!steamRunning) {
|
|
73
|
+
console.warn('[Steamworks] WARNING: Steam client might not be running properly');
|
|
74
|
+
}
|
|
75
|
+
// Get UserStats interface
|
|
76
|
+
this.userStatsInterface = this.libraryLoader.SteamAPI_SteamUserStats_v013();
|
|
77
|
+
if (!this.userStatsInterface || this.userStatsInterface === null) {
|
|
78
|
+
throw new Error('Failed to get SteamUserStats interface');
|
|
79
|
+
}
|
|
80
|
+
// Get User interface
|
|
81
|
+
this.userInterface = this.libraryLoader.SteamAPI_SteamUser_v023();
|
|
82
|
+
// Request current stats from Steam servers
|
|
83
|
+
console.log('[Steamworks] Requesting current stats from Steam...');
|
|
84
|
+
const statsRequested = this.libraryLoader.SteamAPI_ISteamUserStats_RequestCurrentStats(this.userStatsInterface, 0);
|
|
85
|
+
if (!statsRequested) {
|
|
86
|
+
console.warn('[Steamworks] WARNING: Failed to request current stats from Steam servers');
|
|
87
|
+
}
|
|
88
|
+
// Run callbacks to process any pending Steam events
|
|
89
|
+
this.runCallbacks();
|
|
90
|
+
this.initialized = true;
|
|
91
|
+
console.log('[Steamworks] Steam API initialized successfully!');
|
|
92
|
+
console.log(`[Steamworks] Connected to Steam for App ID: ${this.appId}`);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error('[Steamworks] ERROR: Failed to initialize Steam API:', error.message);
|
|
97
|
+
console.error('[Steamworks] Make sure:');
|
|
98
|
+
console.error(' 1. Steam client is running and you\'re logged in');
|
|
99
|
+
console.error(' 2. Steamworks redistributable binaries are available');
|
|
100
|
+
console.error(' 3. App ID is valid and game is in your library');
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Shutdown Steam API
|
|
106
|
+
*/
|
|
107
|
+
shutdown() {
|
|
108
|
+
if (this.libraryLoader.isLoaded() && this.initialized) {
|
|
109
|
+
console.log('[Steamworks] Shutting down Steam API...');
|
|
110
|
+
this.libraryLoader.SteamAPI_Shutdown();
|
|
111
|
+
this.initialized = false;
|
|
112
|
+
this.userStatsInterface = null;
|
|
113
|
+
this.userInterface = null;
|
|
114
|
+
console.log('[Steamworks] Steam API shutdown complete');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get current Steam status
|
|
119
|
+
*/
|
|
120
|
+
getStatus() {
|
|
121
|
+
let steamId = '0';
|
|
122
|
+
if (this.initialized && this.userInterface && this.userInterface !== null) {
|
|
123
|
+
try {
|
|
124
|
+
const steamIdNum = this.libraryLoader.SteamAPI_ISteamUser_GetSteamID(this.userInterface);
|
|
125
|
+
steamId = steamIdNum.toString();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.warn('Failed to get Steam ID:', error.message);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
initialized: this.initialized,
|
|
133
|
+
appId: this.appId,
|
|
134
|
+
steamId
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Run Steam callbacks to process pending events
|
|
139
|
+
*/
|
|
140
|
+
runCallbacks() {
|
|
141
|
+
if (this.initialized && this.libraryLoader.isLoaded()) {
|
|
142
|
+
try {
|
|
143
|
+
this.libraryLoader.SteamAPI_RunCallbacks();
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.warn('Warning: Error running Steam callbacks:', error.message);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if Steam client is running
|
|
152
|
+
*/
|
|
153
|
+
isSteamRunning() {
|
|
154
|
+
if (this.initialized && this.libraryLoader.isLoaded()) {
|
|
155
|
+
try {
|
|
156
|
+
return this.libraryLoader.SteamAPI_IsSteamRunning();
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
console.warn('Warning: Error checking if Steam is running:', error.message);
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Check if initialized
|
|
167
|
+
*/
|
|
168
|
+
isInitialized() {
|
|
169
|
+
return this.initialized;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get UserStats interface pointer
|
|
173
|
+
*/
|
|
174
|
+
getUserStatsInterface() {
|
|
175
|
+
return this.userStatsInterface;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get User interface pointer
|
|
179
|
+
*/
|
|
180
|
+
getUserInterface() {
|
|
181
|
+
return this.userInterface;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.SteamAPICore = SteamAPICore;
|
|
185
|
+
//# sourceMappingURL=SteamAPICore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SteamAPICore.js","sourceRoot":"","sources":["../../src/internal/SteamAPICore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAI7B;;GAEG;AACH,MAAa,YAAY;IAOvB,YAAY,aAAiC;QALrC,gBAAW,GAAY,KAAK,CAAC;QAC7B,UAAK,GAAW,CAAC,CAAC;QAClB,uBAAkB,GAAQ,IAAI,CAAC;QAC/B,kBAAa,GAAQ,IAAI,CAAC;QAGhC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAyB;QAC5B,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAE3B,kCAAkC;YAClC,OAAO,CAAC,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YAE/C,uDAAuD;YACvD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAA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