@websimai/socket-types 0.0.5 → 0.0.7
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/dist/index.d.mts +57 -57
- package/package.json +5 -8
package/dist/index.d.mts
CHANGED
|
@@ -50,17 +50,17 @@ interface QueryAPI<T extends readonly KeyValue[] = readonly KeyValue[]> extends
|
|
|
50
50
|
//#region src/websim-socket-party.d.ts
|
|
51
51
|
interface WebsimSocketParty {
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
* Object containing the client ID, avatar URL, and username of this connected client.
|
|
54
|
+
*/
|
|
55
55
|
readonly client: {
|
|
56
56
|
readonly id: string;
|
|
57
57
|
readonly avatarUrl: `https://${string}/${string}`;
|
|
58
58
|
readonly username: string;
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
* Object containing all connected peers, including this client.
|
|
62
|
+
* This is always up-to-date.
|
|
63
|
+
*/
|
|
64
64
|
readonly peers: {
|
|
65
65
|
readonly [id: string]: {
|
|
66
66
|
readonly avatarUrl: `https://${string}/${string}`;
|
|
@@ -71,27 +71,27 @@ interface WebsimSocketParty {
|
|
|
71
71
|
};
|
|
72
72
|
subscribe(callback: (peers: Peers) => void): () => void;
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
* Object containing the current presence state of all connected peers, including this client.
|
|
75
|
+
* This is always up-to-date after initialization.
|
|
76
|
+
*/
|
|
77
77
|
readonly presence: KeyValue;
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
* Updates the current client's presence state.
|
|
80
|
+
* @param presence The new presence state to set.
|
|
81
|
+
*/
|
|
82
82
|
updatePresence<TPresence extends KeyValue>(presence: TPresence): void;
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
* Subscribe to presence updates from all peers.
|
|
85
|
+
* @param callback Function to call when presence changes.
|
|
86
|
+
* @returns Function to unsubscribe.
|
|
87
|
+
*/
|
|
88
88
|
subscribePresence<TPresence extends KeyValue>(callback: (presence: {
|
|
89
89
|
[clientId: string]: TPresence;
|
|
90
90
|
}) => void): () => void;
|
|
91
91
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
* Object containing the current room-wide state.
|
|
93
|
+
* This is always up-to-date.
|
|
94
|
+
*/
|
|
95
95
|
readonly roomState: KeyValue;
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
@@ -122,69 +122,69 @@ declare class WebsimSocketClass {
|
|
|
122
122
|
collection<$Type extends string>($type: $Type): CollectionAPI<$Type>;
|
|
123
123
|
readonly clientId: string;
|
|
124
124
|
/**
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
* Object containing information about the connected client and their peers.
|
|
126
|
+
*/
|
|
127
127
|
readonly party: WebsimSocketParty;
|
|
128
128
|
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
* Legacy event handler for changes in connected peers.
|
|
130
|
+
* @param peers An object with client IDs as keys, each containing the client's avatar URL and username.
|
|
131
|
+
*/
|
|
132
132
|
onPeersChanged: ((peers: Peers) => any) | null;
|
|
133
133
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
* Initialize the WebSocket connection.
|
|
135
|
+
* @returns A promise that resolves when initialization is complete.
|
|
136
|
+
*/
|
|
137
137
|
initialize(): Promise<void>;
|
|
138
138
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
* Request a presence update from a specific client.
|
|
140
|
+
* @param clientId The ID of the client to request an update from.
|
|
141
|
+
* @param update The update to request.
|
|
142
|
+
*/
|
|
143
143
|
requestPresenceUpdate(clientId: string, update: KeyValue): void;
|
|
144
144
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
* Subscribe to presence update requests from other clients.
|
|
146
|
+
* @param callback Function to call when a presence update is requested.
|
|
147
|
+
* @returns Function to unsubscribe.
|
|
148
|
+
*/
|
|
149
149
|
subscribePresenceUpdateRequests<UpdateRequest extends KeyValue>(callback: (updateRequest: UpdateRequest, fromClientId: string) => void): () => void;
|
|
150
150
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
* Updates the room-wide state. This merges with existing state.
|
|
152
|
+
* @param delta The new state to merge with current room state.
|
|
153
|
+
*/
|
|
154
154
|
updateRoomState<Delta extends KeyValue>(delta: Delta): void;
|
|
155
155
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
* Subscribe to room state updates.
|
|
157
|
+
* @param callback Function to call when room state changes.
|
|
158
|
+
* @returns Function to unsubscribe.
|
|
159
|
+
*/
|
|
160
160
|
subscribeRoomState<RoomState extends KeyValue>(callback: (state: RoomState) => void): () => void;
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
* Object containing the current presence state of all connected peers, including this client.
|
|
163
|
+
* This is always up-to-date after initialization.
|
|
164
|
+
*/
|
|
165
165
|
readonly presence: {
|
|
166
166
|
[clientId: string]: KeyValue;
|
|
167
167
|
};
|
|
168
168
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
* Object containing the current room-wide state.
|
|
170
|
+
* This is always up-to-date.
|
|
171
|
+
*/
|
|
172
172
|
readonly roomState: KeyValue;
|
|
173
173
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
* Object containing all connected peers, including this client.
|
|
175
|
+
* This is always up-to-date.
|
|
176
|
+
*/
|
|
177
177
|
readonly peers: Peers;
|
|
178
178
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
* Updates the current client's presence state.
|
|
180
|
+
* @param presence The new presence state to set.
|
|
181
|
+
*/
|
|
182
182
|
updatePresence<Presence extends KeyValue>(presence: Presence): void;
|
|
183
183
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
* Subscribe to presence updates from all peers.
|
|
185
|
+
* @param callback Function to call when presence changes.
|
|
186
|
+
* @returns Function to unsubscribe.
|
|
187
|
+
*/
|
|
188
188
|
subscribePresence<Presence extends KeyValue>(callback: (presence: {
|
|
189
189
|
[clientId: string]: Presence;
|
|
190
190
|
}) => void): () => void;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websimai/socket-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Type declarations for the `WebsimSocket` class",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"author": "
|
|
6
|
+
"author": "gameroman",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -20,21 +20,18 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "bunx --bun tsdown",
|
|
23
|
-
"
|
|
23
|
+
"prepublishOnly": "bun run build"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist/**/*",
|
|
27
|
-
"README.md"
|
|
28
|
-
"LICENSE"
|
|
27
|
+
"README.md"
|
|
29
28
|
],
|
|
30
|
-
"main": "./dist/index.mjs",
|
|
31
|
-
"module": "./dist/index.mjs",
|
|
32
29
|
"types": "./dist/index.d.mts",
|
|
33
30
|
"exports": {
|
|
34
31
|
".": "./dist/index.mjs",
|
|
35
32
|
"./package.json": "./package.json"
|
|
36
33
|
},
|
|
37
34
|
"devDependencies": {
|
|
38
|
-
"tsdown": "^0.
|
|
35
|
+
"tsdown": "^0.20.1"
|
|
39
36
|
}
|
|
40
37
|
}
|