steamworks.js-timmy 0.1.0
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/LICENSE +21 -0
- package/README.md +88 -0
- package/callbacks.d.ts +56 -0
- package/client.d.ts +497 -0
- package/dist/linux64/false +593 -0
- package/dist/linux64/libsteam_api.so +0 -0
- package/dist/linux64/steamworksjs.linux-x64-gnu.node +0 -0
- package/dist/osx/false +593 -0
- package/dist/osx/libsteam_api.dylib +0 -0
- package/dist/osx/steamworksjs.darwin-arm64.node +0 -0
- package/dist/osx/steamworksjs.darwin-x64.node +0 -0
- package/dist/win64/false +593 -0
- package/dist/win64/steam_api64.dll +0 -0
- package/dist/win64/steam_api64.lib +0 -0
- package/dist/win64/steamworksjs.win32-x64-msvc.node +0 -0
- package/index.d.ts +514 -0
- package/index.js +77 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Gabriel Francisco Dos Santos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[](https://github.com/ceifa/steamworks.js/actions/workflows/publish.yml)
|
|
2
|
+
[](https://npmjs.com/package/steamworks.js)
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://discord.gg/H6B7UE7fMY)
|
|
5
|
+
|
|
6
|
+
# Steamworks.js
|
|
7
|
+
|
|
8
|
+
A modern implementation of the Steamworks SDK for HTML/JS and NodeJS based applications.
|
|
9
|
+
|
|
10
|
+
## Why
|
|
11
|
+
|
|
12
|
+
I used [greenworks](https://github.com/greenheartgames/greenworks) for a long time and it's great, but I gave up for the following reasons.
|
|
13
|
+
|
|
14
|
+
* It's not being maintained anymore.
|
|
15
|
+
* It's not up to date.
|
|
16
|
+
* It's not context-aware.
|
|
17
|
+
* You have to build the binaries by yourself.
|
|
18
|
+
* Don't have typescript definitions.
|
|
19
|
+
* The API it's not trustful.
|
|
20
|
+
* The API implement callbacks instead of return flags or promises.
|
|
21
|
+
* I hate C++.
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const steamworks = require('steamworks.js')
|
|
27
|
+
|
|
28
|
+
// You can pass an appId, or don't pass anything and use a steam_appid.txt file
|
|
29
|
+
const client = steamworks.init(480)
|
|
30
|
+
|
|
31
|
+
// Print Steam username
|
|
32
|
+
console.log(client.localplayer.getName())
|
|
33
|
+
|
|
34
|
+
// Tries to activate an achievement
|
|
35
|
+
if (client.achievement.activate('ACHIEVEMENT')) {
|
|
36
|
+
// ...
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
You can refer to the [declarations file](https://github.com/ceifa/steamworks.js/blob/main/client.d.ts) to check the API support and get more detailed documentation of each function.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
To use steamworks.js you don't have to build anything, just install it from npm:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
$: npm i steamworks.js
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Electron
|
|
51
|
+
|
|
52
|
+
Steamworks.js is a native module and cannot be used by default in the renderer process. To enable the usage of native modules on the renderer process, the following configurations should be made on `main.js`:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const mainWindow = new BrowserWindow({
|
|
56
|
+
// ...
|
|
57
|
+
webPreferences: {
|
|
58
|
+
// ...
|
|
59
|
+
contextIsolation: false,
|
|
60
|
+
nodeIntegration: true
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
To make the steam overlay working, call the `electronEnableSteamOverlay` on the end of your `main.js` file:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
require('steamworks.js').electronEnableSteamOverlay()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For the production build, copy the relevant distro files from `sdk/redistributable_bin/{YOUR_DISTRO}` into the root of your build. If you are using electron-forge, look for [#75](https://github.com/ceifa/steamworks.js/issues/75).
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## How to build
|
|
75
|
+
|
|
76
|
+
> 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).
|
|
77
|
+
|
|
78
|
+
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.
|
|
79
|
+
|
|
80
|
+
Install dependencies with `npm install` and then run `npm run build:debug` to build the library.
|
|
81
|
+
|
|
82
|
+
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.
|
|
83
|
+
|
|
84
|
+
### Testing Electron
|
|
85
|
+
|
|
86
|
+
Go to the [test/electron](./test/electron) directory. There, you can run `npm install` and then `npm start` to run the Electron app.
|
|
87
|
+
|
|
88
|
+
Click "activate overlay" to test the overlay.
|
package/callbacks.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import client = require('./client')
|
|
2
|
+
|
|
3
|
+
export const enum ChatMemberStateChange {
|
|
4
|
+
/** This user has joined or is joining the lobby. */
|
|
5
|
+
Entered,
|
|
6
|
+
/** This user has left or is leaving the lobby. */
|
|
7
|
+
Left,
|
|
8
|
+
/** User disconnected without leaving the lobby first. */
|
|
9
|
+
Disconnected,
|
|
10
|
+
/** The user has been kicked. */
|
|
11
|
+
Kicked,
|
|
12
|
+
/** The user has been kicked and banned. */
|
|
13
|
+
Banned,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CallbackReturns {
|
|
17
|
+
[client.callback.SteamCallback.PersonaStateChange]: {
|
|
18
|
+
steam_id: bigint
|
|
19
|
+
flags: { bits: number }
|
|
20
|
+
}
|
|
21
|
+
[client.callback.SteamCallback.SteamServersConnected]: {}
|
|
22
|
+
[client.callback.SteamCallback.SteamServersDisconnected]: {
|
|
23
|
+
reason: number
|
|
24
|
+
}
|
|
25
|
+
[client.callback.SteamCallback.SteamServerConnectFailure]: {
|
|
26
|
+
reason: number
|
|
27
|
+
still_retrying: boolean
|
|
28
|
+
}
|
|
29
|
+
[client.callback.SteamCallback.LobbyDataUpdate]: {
|
|
30
|
+
lobby: bigint
|
|
31
|
+
member: bigint
|
|
32
|
+
success: boolean
|
|
33
|
+
}
|
|
34
|
+
[client.callback.SteamCallback.LobbyChatUpdate]: {
|
|
35
|
+
lobby: bigint
|
|
36
|
+
user_changed: bigint
|
|
37
|
+
making_change: bigint
|
|
38
|
+
member_state_change: ChatMemberStateChange
|
|
39
|
+
}
|
|
40
|
+
[client.callback.SteamCallback.P2PSessionRequest]: {
|
|
41
|
+
remote: bigint
|
|
42
|
+
}
|
|
43
|
+
[client.callback.SteamCallback.P2PSessionConnectFail]: {
|
|
44
|
+
remote: bigint
|
|
45
|
+
error: number
|
|
46
|
+
}
|
|
47
|
+
[client.callback.SteamCallback.GameLobbyJoinRequested]: {
|
|
48
|
+
lobby_steam_id: bigint
|
|
49
|
+
friend_steam_id: bigint
|
|
50
|
+
}
|
|
51
|
+
[client.callback.SteamCallback.MicroTxnAuthorizationResponse]: {
|
|
52
|
+
app_id: number
|
|
53
|
+
order_id: number | bigint
|
|
54
|
+
authorized: boolean
|
|
55
|
+
}
|
|
56
|
+
}
|
package/client.d.ts
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
export declare function init(appId?: number | undefined | null): void
|
|
2
|
+
export declare function restartAppIfNecessary(appId: number): boolean
|
|
3
|
+
export declare function runCallbacks(): void
|
|
4
|
+
export interface PlayerSteamId {
|
|
5
|
+
steamId64: bigint
|
|
6
|
+
steamId32: string
|
|
7
|
+
accountId: number
|
|
8
|
+
}
|
|
9
|
+
export declare namespace achievement {
|
|
10
|
+
export function activate(achievement: string): boolean
|
|
11
|
+
export function isActivated(achievement: string): boolean
|
|
12
|
+
export function clear(achievement: string): boolean
|
|
13
|
+
export function names(): Array<string>
|
|
14
|
+
}
|
|
15
|
+
export declare namespace apps {
|
|
16
|
+
export function isSubscribedApp(appId: number): boolean
|
|
17
|
+
export function isAppInstalled(appId: number): boolean
|
|
18
|
+
export function isDlcInstalled(appId: number): boolean
|
|
19
|
+
export function isSubscribedFromFreeWeekend(): boolean
|
|
20
|
+
export function isVacBanned(): boolean
|
|
21
|
+
export function isCybercafe(): boolean
|
|
22
|
+
export function isLowViolence(): boolean
|
|
23
|
+
export function isSubscribed(): boolean
|
|
24
|
+
export function appBuildId(): number
|
|
25
|
+
export function appInstallDir(appId: number): string
|
|
26
|
+
export function appOwner(): PlayerSteamId
|
|
27
|
+
export function availableGameLanguages(): Array<string>
|
|
28
|
+
export function currentGameLanguage(): string
|
|
29
|
+
export function currentBetaName(): string | null
|
|
30
|
+
}
|
|
31
|
+
export declare namespace auth {
|
|
32
|
+
/**
|
|
33
|
+
* @param steamId64 - The user steam id or game server steam id. Use as NetworkIdentity of the remote system that will authenticate the ticket. If it is peer-to-peer then the user steam ID. If it is a game server, then the game server steam ID may be used if it was obtained from a trusted 3rd party
|
|
34
|
+
* @param timeoutSeconds - The number of seconds to wait for the ticket to be validated. Default value is 10 seconds.
|
|
35
|
+
*/
|
|
36
|
+
export function getSessionTicketWithSteamId(steamId64: bigint, timeoutSeconds?: number | undefined | null): Promise<Ticket>
|
|
37
|
+
/**
|
|
38
|
+
* @param ip - The string of IPv4 or IPv6 address. Use as NetworkIdentity of the remote system that will authenticate the ticket.
|
|
39
|
+
* @param timeoutSeconds - The number of seconds to wait for the ticket to be validated. Default value is 10 seconds.
|
|
40
|
+
*/
|
|
41
|
+
export function getSessionTicketWithIp(ip: string, timeoutSeconds?: number | undefined | null): Promise<Ticket>
|
|
42
|
+
export function getAuthTicketForWebApi(identity: string, timeoutSeconds?: number | undefined | null): Promise<Ticket>
|
|
43
|
+
export class Ticket {
|
|
44
|
+
cancel(): void
|
|
45
|
+
getBytes(): Buffer
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export declare namespace callback {
|
|
49
|
+
export const enum SteamCallback {
|
|
50
|
+
PersonaStateChange = 0,
|
|
51
|
+
SteamServersConnected = 1,
|
|
52
|
+
SteamServersDisconnected = 2,
|
|
53
|
+
SteamServerConnectFailure = 3,
|
|
54
|
+
LobbyDataUpdate = 4,
|
|
55
|
+
LobbyChatUpdate = 5,
|
|
56
|
+
P2PSessionRequest = 6,
|
|
57
|
+
P2PSessionConnectFail = 7,
|
|
58
|
+
GameLobbyJoinRequested = 8,
|
|
59
|
+
MicroTxnAuthorizationResponse = 9
|
|
60
|
+
}
|
|
61
|
+
export function register<C extends keyof import('./callbacks').CallbackReturns>(steamCallback: C, handler: (value: import('./callbacks').CallbackReturns[C]) => void): Handle
|
|
62
|
+
export class Handle {
|
|
63
|
+
disconnect(): void
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export declare namespace cloud {
|
|
67
|
+
export function isEnabledForAccount(): boolean
|
|
68
|
+
export function isEnabledForApp(): boolean
|
|
69
|
+
export function setEnabledForApp(enabled: boolean): void
|
|
70
|
+
export function readFile(name: string): string
|
|
71
|
+
export function writeFile(name: string, content: string): boolean
|
|
72
|
+
export function deleteFile(name: string): boolean
|
|
73
|
+
export function fileExists(name: string): boolean
|
|
74
|
+
export function listFiles(): Array<FileInfo>
|
|
75
|
+
export class FileInfo {
|
|
76
|
+
name: string
|
|
77
|
+
size: bigint
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export declare namespace input {
|
|
81
|
+
export const enum InputType {
|
|
82
|
+
Unknown = 'Unknown',
|
|
83
|
+
SteamController = 'SteamController',
|
|
84
|
+
XBox360Controller = 'XBox360Controller',
|
|
85
|
+
XBoxOneController = 'XBoxOneController',
|
|
86
|
+
GenericGamepad = 'GenericGamepad',
|
|
87
|
+
PS4Controller = 'PS4Controller',
|
|
88
|
+
AppleMFiController = 'AppleMFiController',
|
|
89
|
+
AndroidController = 'AndroidController',
|
|
90
|
+
SwitchJoyConPair = 'SwitchJoyConPair',
|
|
91
|
+
SwitchJoyConSingle = 'SwitchJoyConSingle',
|
|
92
|
+
SwitchProController = 'SwitchProController',
|
|
93
|
+
MobileTouch = 'MobileTouch',
|
|
94
|
+
PS3Controller = 'PS3Controller',
|
|
95
|
+
PS5Controller = 'PS5Controller',
|
|
96
|
+
SteamDeckController = 'SteamDeckController'
|
|
97
|
+
}
|
|
98
|
+
export interface MotionData {
|
|
99
|
+
/** Absolute Rotation (drift) X axis */
|
|
100
|
+
rotQuatX: number
|
|
101
|
+
/** Absolute Rotation (drift) Y axis */
|
|
102
|
+
rotQuatY: number
|
|
103
|
+
/** Absolute Rotation (drift) Z axis */
|
|
104
|
+
rotQuatZ: number
|
|
105
|
+
/** Absolute Rotation (drift) W axis */
|
|
106
|
+
rotQuatW: number
|
|
107
|
+
/** Positional Acceleration X axis */
|
|
108
|
+
posAccelX: number
|
|
109
|
+
/** Positional Acceleration Y axis */
|
|
110
|
+
posAccelY: number
|
|
111
|
+
/** Positional Acceleration Z axis */
|
|
112
|
+
posAccelZ: number
|
|
113
|
+
/** Rotational Velocity X axis */
|
|
114
|
+
rotVelX: number
|
|
115
|
+
/** Rotational Velocity Y axis */
|
|
116
|
+
rotVelY: number
|
|
117
|
+
/** Rotational Velocity Z axis */
|
|
118
|
+
rotVelZ: number
|
|
119
|
+
}
|
|
120
|
+
export interface AnalogActionVector {
|
|
121
|
+
x: number
|
|
122
|
+
y: number
|
|
123
|
+
}
|
|
124
|
+
export function init(): void
|
|
125
|
+
export function getControllers(): Array<Controller>
|
|
126
|
+
export function getActionSet(actionSetName: string): bigint
|
|
127
|
+
export function getDigitalAction(actionName: string): bigint
|
|
128
|
+
export function getAnalogAction(actionName: string): bigint
|
|
129
|
+
export function shutdown(): void
|
|
130
|
+
export class Controller {
|
|
131
|
+
activateActionSet(actionSetHandle: bigint): void
|
|
132
|
+
isDigitalActionPressed(actionHandle: bigint): boolean
|
|
133
|
+
getAnalogActionVector(actionHandle: bigint): AnalogActionVector
|
|
134
|
+
getType(): InputType
|
|
135
|
+
getHandle(): bigint
|
|
136
|
+
/** Gets controller latest data, best use for low latency if you call this all the time */
|
|
137
|
+
runFrame(): void
|
|
138
|
+
/** Gets controller's motion sensors */
|
|
139
|
+
getMotionData(): MotionData | null
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export declare namespace localplayer {
|
|
143
|
+
export function getSteamId(): PlayerSteamId
|
|
144
|
+
export function getName(): string
|
|
145
|
+
export function getLevel(): number
|
|
146
|
+
/** @returns the 2 digit ISO 3166-1-alpha-2 format country code which client is running in, e.g. "US" or "UK". */
|
|
147
|
+
export function getIpCountry(): string
|
|
148
|
+
export function setRichPresence(key: string, value?: string | undefined | null): void
|
|
149
|
+
}
|
|
150
|
+
export declare namespace matchmaking {
|
|
151
|
+
export const enum LobbyType {
|
|
152
|
+
Private = 0,
|
|
153
|
+
FriendsOnly = 1,
|
|
154
|
+
Public = 2,
|
|
155
|
+
Invisible = 3
|
|
156
|
+
}
|
|
157
|
+
export function createLobby(lobbyType: LobbyType, maxMembers: number): Promise<Lobby>
|
|
158
|
+
export function joinLobby(lobbyId: bigint): Promise<Lobby>
|
|
159
|
+
export function getLobbies(): Promise<Array<Lobby>>
|
|
160
|
+
export class Lobby {
|
|
161
|
+
join(): Promise<Lobby>
|
|
162
|
+
leave(): void
|
|
163
|
+
openInviteDialog(): void
|
|
164
|
+
getMemberCount(): bigint
|
|
165
|
+
getMemberLimit(): bigint | null
|
|
166
|
+
getMembers(): Array<PlayerSteamId>
|
|
167
|
+
getOwner(): PlayerSteamId
|
|
168
|
+
setJoinable(joinable: boolean): boolean
|
|
169
|
+
getData(key: string): string | null
|
|
170
|
+
setData(key: string, value: string): boolean
|
|
171
|
+
deleteData(key: string): boolean
|
|
172
|
+
/** Get an object containing all the lobby data */
|
|
173
|
+
getFullData(): Record<string, string>
|
|
174
|
+
/**
|
|
175
|
+
* Merge current lobby data with provided data in a single batch
|
|
176
|
+
* @returns true if all data was set successfully
|
|
177
|
+
*/
|
|
178
|
+
mergeFullData(data: Record<string, string>): boolean
|
|
179
|
+
|
|
180
|
+
id(): BigInt
|
|
181
|
+
idAsU64(): number
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
export declare namespace networking {
|
|
185
|
+
export interface P2PPacket {
|
|
186
|
+
data: Buffer
|
|
187
|
+
size: number
|
|
188
|
+
steamId: PlayerSteamId
|
|
189
|
+
}
|
|
190
|
+
/** The method used to send a packet */
|
|
191
|
+
export const enum SendType {
|
|
192
|
+
/**
|
|
193
|
+
* Send the packet directly over udp.
|
|
194
|
+
*
|
|
195
|
+
* Can't be larger than 1200 bytes
|
|
196
|
+
*/
|
|
197
|
+
Unreliable = 0,
|
|
198
|
+
/**
|
|
199
|
+
* Like `Unreliable` but doesn't buffer packets
|
|
200
|
+
* sent before the connection has started.
|
|
201
|
+
*/
|
|
202
|
+
UnreliableNoDelay = 1,
|
|
203
|
+
/**
|
|
204
|
+
* Reliable packet sending.
|
|
205
|
+
*
|
|
206
|
+
* Can't be larger than 1 megabyte.
|
|
207
|
+
*/
|
|
208
|
+
Reliable = 2,
|
|
209
|
+
/**
|
|
210
|
+
* Like `Reliable` but applies the nagle
|
|
211
|
+
* algorithm to packets being sent
|
|
212
|
+
*/
|
|
213
|
+
ReliableWithBuffering = 3
|
|
214
|
+
}
|
|
215
|
+
export function sendP2PPacket(steamId64: bigint, sendType: SendType, data: Buffer): boolean
|
|
216
|
+
export function isP2PPacketAvailable(): number
|
|
217
|
+
export function readP2PPacket(size: number): P2PPacket
|
|
218
|
+
export function acceptP2PSession(steamId64: bigint): void
|
|
219
|
+
}
|
|
220
|
+
export declare namespace overlay {
|
|
221
|
+
export const enum Dialog {
|
|
222
|
+
Friends = 0,
|
|
223
|
+
Community = 1,
|
|
224
|
+
Players = 2,
|
|
225
|
+
Settings = 3,
|
|
226
|
+
OfficialGameGroup = 4,
|
|
227
|
+
Stats = 5,
|
|
228
|
+
Achievements = 6
|
|
229
|
+
}
|
|
230
|
+
export const enum StoreFlag {
|
|
231
|
+
None = 0,
|
|
232
|
+
AddToCart = 1,
|
|
233
|
+
AddToCartAndShow = 2
|
|
234
|
+
}
|
|
235
|
+
export function activateDialog(dialog: Dialog): void
|
|
236
|
+
export function activateDialogToUser(dialog: Dialog, steamId64: bigint): void
|
|
237
|
+
export function activateInviteDialog(lobbyId: bigint): void
|
|
238
|
+
export function activateToWebPage(url: string): void
|
|
239
|
+
export function activateToStore(appId: number, flag: StoreFlag): void
|
|
240
|
+
}
|
|
241
|
+
export declare namespace stats {
|
|
242
|
+
export function getInt(name: string): number | null
|
|
243
|
+
export function setInt(name: string, value: number): boolean
|
|
244
|
+
export function store(): boolean
|
|
245
|
+
export function resetAll(achievementsToo: boolean): boolean
|
|
246
|
+
}
|
|
247
|
+
export declare namespace utils {
|
|
248
|
+
export function getAppId(): number
|
|
249
|
+
export function getServerRealTime(): number
|
|
250
|
+
export function isSteamRunningOnSteamDeck(): boolean
|
|
251
|
+
export const enum GamepadTextInputMode {
|
|
252
|
+
Normal = 0,
|
|
253
|
+
Password = 1
|
|
254
|
+
}
|
|
255
|
+
export const enum GamepadTextInputLineMode {
|
|
256
|
+
SingleLine = 0,
|
|
257
|
+
MultipleLines = 1
|
|
258
|
+
}
|
|
259
|
+
/** @returns the entered text, or null if cancelled or could not show the input */
|
|
260
|
+
export function showGamepadTextInput(inputMode: GamepadTextInputMode, inputLineMode: GamepadTextInputLineMode, description: string, maxCharacters: number, existingText?: string | undefined | null): Promise<string | null>
|
|
261
|
+
export const enum FloatingGamepadTextInputMode {
|
|
262
|
+
SingleLine = 0,
|
|
263
|
+
MultipleLines = 1,
|
|
264
|
+
Email = 2,
|
|
265
|
+
Numeric = 3
|
|
266
|
+
}
|
|
267
|
+
/** @returns true if the floating keyboard was shown, otherwise, false */
|
|
268
|
+
export function showFloatingGamepadTextInput(keyboardMode: FloatingGamepadTextInputMode, x: number, y: number, width: number, height: number): Promise<boolean>
|
|
269
|
+
}
|
|
270
|
+
export declare namespace workshop {
|
|
271
|
+
export interface UgcResult {
|
|
272
|
+
itemId: bigint
|
|
273
|
+
needsToAcceptAgreement: boolean
|
|
274
|
+
}
|
|
275
|
+
export const enum UgcItemVisibility {
|
|
276
|
+
Public = 0,
|
|
277
|
+
FriendsOnly = 1,
|
|
278
|
+
Private = 2,
|
|
279
|
+
Unlisted = 3
|
|
280
|
+
}
|
|
281
|
+
export interface UgcUpdate {
|
|
282
|
+
title?: string
|
|
283
|
+
description?: string
|
|
284
|
+
changeNote?: string
|
|
285
|
+
previewPath?: string
|
|
286
|
+
contentPath?: string
|
|
287
|
+
tags?: Array<string>
|
|
288
|
+
visibility?: UgcItemVisibility
|
|
289
|
+
}
|
|
290
|
+
export interface InstallInfo {
|
|
291
|
+
folder: string
|
|
292
|
+
sizeOnDisk: bigint
|
|
293
|
+
timestamp: number
|
|
294
|
+
}
|
|
295
|
+
export interface DownloadInfo {
|
|
296
|
+
current: bigint
|
|
297
|
+
total: bigint
|
|
298
|
+
}
|
|
299
|
+
export const enum UpdateStatus {
|
|
300
|
+
Invalid = 0,
|
|
301
|
+
PreparingConfig = 1,
|
|
302
|
+
PreparingContent = 2,
|
|
303
|
+
UploadingContent = 3,
|
|
304
|
+
UploadingPreviewFile = 4,
|
|
305
|
+
CommittingChanges = 5
|
|
306
|
+
}
|
|
307
|
+
export interface UpdateProgress {
|
|
308
|
+
status: UpdateStatus
|
|
309
|
+
progress: bigint
|
|
310
|
+
total: bigint
|
|
311
|
+
}
|
|
312
|
+
export function createItem(appId?: number | undefined | null): Promise<UgcResult>
|
|
313
|
+
export function updateItem(itemId: bigint, updateDetails: UgcUpdate, appId?: number | undefined | null): Promise<UgcResult>
|
|
314
|
+
export function updateItemWithCallback(itemId: bigint, updateDetails: UgcUpdate, appId: number | undefined | null, successCallback: (data: UgcResult) => void, errorCallback: (err: any) => void, progressCallback?: (data: UpdateProgress) => void, progressCallbackIntervalMs?: number | undefined | null): void
|
|
315
|
+
/**
|
|
316
|
+
* Subscribe to a workshop item. It will be downloaded and installed as soon as possible.
|
|
317
|
+
*
|
|
318
|
+
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#SubscribeItem}
|
|
319
|
+
*/
|
|
320
|
+
export function subscribe(itemId: bigint): Promise<void>
|
|
321
|
+
/**
|
|
322
|
+
* Unsubscribe from a workshop item. This will result in the item being removed after the game quits.
|
|
323
|
+
*
|
|
324
|
+
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#UnsubscribeItem}
|
|
325
|
+
*/
|
|
326
|
+
export function unsubscribe(itemId: bigint): Promise<void>
|
|
327
|
+
/**
|
|
328
|
+
* Gets the current state of a workshop item on this client. States can be combined.
|
|
329
|
+
*
|
|
330
|
+
* @returns a number with the current item state, e.g. 9
|
|
331
|
+
* 9 = 1 (The current user is subscribed to this item) + 8 (The item needs an update)
|
|
332
|
+
*
|
|
333
|
+
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#GetItemState}
|
|
334
|
+
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#EItemState}
|
|
335
|
+
*/
|
|
336
|
+
export function state(itemId: bigint): number
|
|
337
|
+
/**
|
|
338
|
+
* Gets info about currently installed content on the disc for workshop item.
|
|
339
|
+
*
|
|
340
|
+
* @returns an object with the the properties {folder, size_on_disk, timestamp}
|
|
341
|
+
*
|
|
342
|
+
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#GetItemInstallInfo}
|
|
343
|
+
*/
|
|
344
|
+
export function installInfo(itemId: bigint): InstallInfo | null
|
|
345
|
+
/**
|
|
346
|
+
* Get info about a pending download of a workshop item.
|
|
347
|
+
*
|
|
348
|
+
* @returns an object with the properties {current, total}
|
|
349
|
+
*
|
|
350
|
+
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#GetItemDownloadInfo}
|
|
351
|
+
*/
|
|
352
|
+
export function downloadInfo(itemId: bigint): DownloadInfo | null
|
|
353
|
+
/**
|
|
354
|
+
* Download or update a workshop item.
|
|
355
|
+
*
|
|
356
|
+
* @param highPriority - If high priority is true, start the download in high priority mode, pausing any existing in-progress Steam downloads and immediately begin downloading this workshop item.
|
|
357
|
+
* @returns true or false
|
|
358
|
+
*
|
|
359
|
+
* {@link https://partner.steamgames.com/doc/api/ISteamUGC#DownloadItem}
|
|
360
|
+
*/
|
|
361
|
+
export function download(itemId: bigint, highPriority: boolean): boolean
|
|
362
|
+
/**
|
|
363
|
+
* Get all subscribed workshop items.
|
|
364
|
+
* @returns an array of subscribed workshop item ids
|
|
365
|
+
*/
|
|
366
|
+
export function getSubscribedItems(): Array<bigint>
|
|
367
|
+
export function deleteItem(itemId: bigint): Promise<void>
|
|
368
|
+
export const enum UGCQueryType {
|
|
369
|
+
RankedByVote = 0,
|
|
370
|
+
RankedByPublicationDate = 1,
|
|
371
|
+
AcceptedForGameRankedByAcceptanceDate = 2,
|
|
372
|
+
RankedByTrend = 3,
|
|
373
|
+
FavoritedByFriendsRankedByPublicationDate = 4,
|
|
374
|
+
CreatedByFriendsRankedByPublicationDate = 5,
|
|
375
|
+
RankedByNumTimesReported = 6,
|
|
376
|
+
CreatedByFollowedUsersRankedByPublicationDate = 7,
|
|
377
|
+
NotYetRated = 8,
|
|
378
|
+
RankedByTotalVotesAsc = 9,
|
|
379
|
+
RankedByVotesUp = 10,
|
|
380
|
+
RankedByTextSearch = 11,
|
|
381
|
+
RankedByTotalUniqueSubscriptions = 12,
|
|
382
|
+
RankedByPlaytimeTrend = 13,
|
|
383
|
+
RankedByTotalPlaytime = 14,
|
|
384
|
+
RankedByAveragePlaytimeTrend = 15,
|
|
385
|
+
RankedByLifetimeAveragePlaytime = 16,
|
|
386
|
+
RankedByPlaytimeSessionsTrend = 17,
|
|
387
|
+
RankedByLifetimePlaytimeSessions = 18,
|
|
388
|
+
RankedByLastUpdatedDate = 19
|
|
389
|
+
}
|
|
390
|
+
export const enum UGCType {
|
|
391
|
+
Items = 0,
|
|
392
|
+
ItemsMtx = 1,
|
|
393
|
+
ItemsReadyToUse = 2,
|
|
394
|
+
Collections = 3,
|
|
395
|
+
Artwork = 4,
|
|
396
|
+
Videos = 5,
|
|
397
|
+
Screenshots = 6,
|
|
398
|
+
AllGuides = 7,
|
|
399
|
+
WebGuides = 8,
|
|
400
|
+
IntegratedGuides = 9,
|
|
401
|
+
UsableInGame = 10,
|
|
402
|
+
ControllerBindings = 11,
|
|
403
|
+
GameManagedItems = 12,
|
|
404
|
+
All = 13
|
|
405
|
+
}
|
|
406
|
+
export const enum UserListType {
|
|
407
|
+
Published = 0,
|
|
408
|
+
VotedOn = 1,
|
|
409
|
+
VotedUp = 2,
|
|
410
|
+
VotedDown = 3,
|
|
411
|
+
Favorited = 4,
|
|
412
|
+
Subscribed = 5,
|
|
413
|
+
UsedOrPlayed = 6,
|
|
414
|
+
Followed = 7
|
|
415
|
+
}
|
|
416
|
+
export const enum UserListOrder {
|
|
417
|
+
CreationOrderAsc = 0,
|
|
418
|
+
CreationOrderDesc = 1,
|
|
419
|
+
TitleAsc = 2,
|
|
420
|
+
LastUpdatedDesc = 3,
|
|
421
|
+
SubscriptionDateDesc = 4,
|
|
422
|
+
VoteScoreDesc = 5,
|
|
423
|
+
ForModeration = 6
|
|
424
|
+
}
|
|
425
|
+
export interface WorkshopItemStatistic {
|
|
426
|
+
numSubscriptions?: bigint
|
|
427
|
+
numFavorites?: bigint
|
|
428
|
+
numFollowers?: bigint
|
|
429
|
+
numUniqueSubscriptions?: bigint
|
|
430
|
+
numUniqueFavorites?: bigint
|
|
431
|
+
numUniqueFollowers?: bigint
|
|
432
|
+
numUniqueWebsiteViews?: bigint
|
|
433
|
+
reportScore?: bigint
|
|
434
|
+
numSecondsPlayed?: bigint
|
|
435
|
+
numPlaytimeSessions?: bigint
|
|
436
|
+
numComments?: bigint
|
|
437
|
+
numSecondsPlayedDuringTimePeriod?: bigint
|
|
438
|
+
numPlaytimeSessionsDuringTimePeriod?: bigint
|
|
439
|
+
}
|
|
440
|
+
export interface WorkshopItem {
|
|
441
|
+
publishedFileId: bigint
|
|
442
|
+
creatorAppId?: number
|
|
443
|
+
consumerAppId?: number
|
|
444
|
+
title: string
|
|
445
|
+
description: string
|
|
446
|
+
owner: PlayerSteamId
|
|
447
|
+
/** Time created in unix epoch seconds format */
|
|
448
|
+
timeCreated: number
|
|
449
|
+
/** Time updated in unix epoch seconds format */
|
|
450
|
+
timeUpdated: number
|
|
451
|
+
/** Time when the user added the published item to their list (not always applicable), provided in Unix epoch format (time since Jan 1st, 1970). */
|
|
452
|
+
timeAddedToUserList: number
|
|
453
|
+
visibility: UgcItemVisibility
|
|
454
|
+
banned: boolean
|
|
455
|
+
acceptedForUse: boolean
|
|
456
|
+
tags: Array<string>
|
|
457
|
+
tagsTruncated: boolean
|
|
458
|
+
url: string
|
|
459
|
+
numUpvotes: number
|
|
460
|
+
numDownvotes: number
|
|
461
|
+
numChildren: number
|
|
462
|
+
previewUrl?: string
|
|
463
|
+
statistics: WorkshopItemStatistic
|
|
464
|
+
}
|
|
465
|
+
export interface WorkshopPaginatedResult {
|
|
466
|
+
items: Array<WorkshopItem | undefined | null>
|
|
467
|
+
returnedResults: number
|
|
468
|
+
totalResults: number
|
|
469
|
+
wasCached: boolean
|
|
470
|
+
}
|
|
471
|
+
export interface WorkshopItemsResult {
|
|
472
|
+
items: Array<WorkshopItem | undefined | null>
|
|
473
|
+
wasCached: boolean
|
|
474
|
+
}
|
|
475
|
+
export interface WorkshopItemQueryConfig {
|
|
476
|
+
cachedResponseMaxAge?: number
|
|
477
|
+
includeMetadata?: boolean
|
|
478
|
+
includeLongDescription?: boolean
|
|
479
|
+
includeAdditionalPreviews?: boolean
|
|
480
|
+
onlyIds?: boolean
|
|
481
|
+
onlyTotal?: boolean
|
|
482
|
+
language?: string
|
|
483
|
+
matchAnyTag?: boolean
|
|
484
|
+
requiredTags?: Array<string>
|
|
485
|
+
excludedTags?: Array<string>
|
|
486
|
+
searchText?: string
|
|
487
|
+
rankedByTrendDays?: number
|
|
488
|
+
}
|
|
489
|
+
export interface AppIDs {
|
|
490
|
+
creator?: number
|
|
491
|
+
consumer?: number
|
|
492
|
+
}
|
|
493
|
+
export function getItem(item: bigint, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopItem | null>
|
|
494
|
+
export function getItems(items: Array<bigint>, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopItemsResult>
|
|
495
|
+
export function getAllItems(page: number, queryType: UGCQueryType, itemType: UGCType, creatorAppId: number, consumerAppId: number, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopPaginatedResult>
|
|
496
|
+
export function getUserItems(page: number, accountId: number, listType: UserListType, itemType: UGCType, sortOrder: UserListOrder, appIds: AppIDs, queryConfig?: WorkshopItemQueryConfig | undefined | null): Promise<WorkshopPaginatedResult>
|
|
497
|
+
}
|