@rpgjs/testing 4.3.0 → 5.0.0-alpha.26
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.ts +249 -0
- package/dist/index.js +344 -0
- package/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_di@2.6.0/node_modules/@signe/di/dist/index.js +366 -0
- package/dist/node_modules/.pnpm/@signe_di@2.6.0/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/setup.d.ts +0 -0
- package/dist/setup.js +32 -0
- package/dist/setup.js.map +1 -0
- package/package.json +22 -23
- package/src/index.ts +650 -225
- package/src/setup.ts +34 -0
- package/tsconfig.json +16 -24
- package/vite.config.ts +40 -0
- package/CHANGELOG.md +0 -174
- package/LICENSE +0 -19
- package/lib/index.d.ts +0 -144
- package/lib/index.js +0 -186
- package/lib/index.js.map +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Provider } from '@signe/di';
|
|
2
|
+
import { RpgClientEngine, RpgClient } from '@rpgjs/client';
|
|
3
|
+
import { RpgServer, RpgPlayer } from '@rpgjs/server';
|
|
4
|
+
/**
|
|
5
|
+
* Provides a default map loader for testing environments
|
|
6
|
+
*
|
|
7
|
+
* This function returns a `provideLoadMap` provider that creates mock maps
|
|
8
|
+
* with default dimensions (1024x768) and a minimal component. It's automatically
|
|
9
|
+
* used by `testing()` if no custom `provideLoadMap` is provided in `clientConfig.providers`.
|
|
10
|
+
*
|
|
11
|
+
* @returns A provider function that can be used with `provideLoadMap`
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Used automatically by testing()
|
|
15
|
+
* const fixture = await testing([myModule])
|
|
16
|
+
*
|
|
17
|
+
* // Or use directly in clientConfig
|
|
18
|
+
* const fixture = await testing([myModule], {
|
|
19
|
+
* providers: [provideTestingLoadMap()]
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function provideTestingLoadMap(): {
|
|
24
|
+
provide: string;
|
|
25
|
+
useFactory: (context: import('@rpgjs/client').Context) => void;
|
|
26
|
+
}[];
|
|
27
|
+
/**
|
|
28
|
+
* Testing utility function to set up server and client instances for unit testing
|
|
29
|
+
*
|
|
30
|
+
* This function creates a test environment with both server and client instances,
|
|
31
|
+
* allowing you to test player interactions, server hooks, and game mechanics.
|
|
32
|
+
*
|
|
33
|
+
* @param modules - Array of modules that can be either:
|
|
34
|
+
* - Direct module objects: { server: RpgServer, client: RpgClient }
|
|
35
|
+
* - Providers returned by createModule(): Provider[] with meta.server/client and useValue
|
|
36
|
+
* @param clientConfig - Optional client configuration
|
|
37
|
+
* @param serverConfig - Optional server configuration
|
|
38
|
+
* @returns Testing fixture with createClient method
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Using direct modules
|
|
42
|
+
* const fixture = await testing([{
|
|
43
|
+
* server: serverModule,
|
|
44
|
+
* client: clientModule
|
|
45
|
+
* }])
|
|
46
|
+
*
|
|
47
|
+
* // Using createModule
|
|
48
|
+
* const myModule = createModule('MyModule', [{
|
|
49
|
+
* server: serverModule,
|
|
50
|
+
* client: clientModule
|
|
51
|
+
* }])
|
|
52
|
+
* const fixture = await testing(myModule)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function testing(modules?: ({
|
|
56
|
+
server?: RpgServer;
|
|
57
|
+
client?: RpgClient;
|
|
58
|
+
} | Provider)[], clientConfig?: any, serverConfig?: any): Promise<{
|
|
59
|
+
createClient(): Promise<{
|
|
60
|
+
socket: any;
|
|
61
|
+
client: RpgClientEngine<any>;
|
|
62
|
+
readonly playerId: string;
|
|
63
|
+
readonly player: RpgPlayer;
|
|
64
|
+
/**
|
|
65
|
+
* Wait for player to be on a specific map
|
|
66
|
+
*
|
|
67
|
+
* This utility function waits for the `onJoinMap` hook to be triggered
|
|
68
|
+
* when the player joins the expected map, or throws an error if the timeout is exceeded.
|
|
69
|
+
*
|
|
70
|
+
* ## Design
|
|
71
|
+
*
|
|
72
|
+
* Uses RxJS to listen for map change events emitted by `onJoinMap`. The function:
|
|
73
|
+
* 1. Checks if the player is already on the expected map
|
|
74
|
+
* 2. Subscribes to the `mapChangeSubject` observable
|
|
75
|
+
* 3. Filters events to match the expected map ID
|
|
76
|
+
* 4. Uses `race` operator with a timer to implement timeout handling
|
|
77
|
+
* 5. Resolves with the player when the map change event is received
|
|
78
|
+
*
|
|
79
|
+
* @param expectedMapId - The expected map ID (without 'map-' prefix, e.g. 'map1')
|
|
80
|
+
* @param timeout - Maximum time to wait in milliseconds (default: 5000)
|
|
81
|
+
* @returns Promise that resolves when player is on the expected map
|
|
82
|
+
* @throws Error if timeout is exceeded
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const client = await fixture.createClient()
|
|
86
|
+
* await client.waitForMapChange('map1')
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
waitForMapChange(expectedMapId: string, timeout?: number): Promise<RpgPlayer>;
|
|
90
|
+
/**
|
|
91
|
+
* Manually trigger a game tick for processing inputs and physics
|
|
92
|
+
*
|
|
93
|
+
* This method is a convenience wrapper around the exported nextTick() function.
|
|
94
|
+
*
|
|
95
|
+
* @param timestamp - Optional timestamp to use for the tick (default: Date.now())
|
|
96
|
+
* @returns Promise that resolves when the tick is complete
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const client = await fixture.createClient()
|
|
101
|
+
*
|
|
102
|
+
* // Manually advance the game by one tick
|
|
103
|
+
* await client.nextTick()
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
nextTick(timestamp?: number): Promise<void>;
|
|
107
|
+
}>;
|
|
108
|
+
readonly server: any;
|
|
109
|
+
/**
|
|
110
|
+
* Clear all server, client instances and reset the DOM
|
|
111
|
+
*
|
|
112
|
+
* This method should be called in afterEach to clean up test state.
|
|
113
|
+
* It destroys all created client instances, clears the server, and resets the DOM.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const fixture = await testing([myModule])
|
|
118
|
+
*
|
|
119
|
+
* afterEach(() => {
|
|
120
|
+
* fixture.clear()
|
|
121
|
+
* })
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
clear(): Promise<void>;
|
|
125
|
+
applySyncToClient(): Promise<void>;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Clear all caches and reset test state
|
|
129
|
+
*
|
|
130
|
+
* This function should be called after the end of each test to clean up
|
|
131
|
+
* all server and client instances, clear caches, and reset the DOM.
|
|
132
|
+
*
|
|
133
|
+
* ## Design
|
|
134
|
+
*
|
|
135
|
+
* Cleans up all created fixtures, client engines, server instances, and resets
|
|
136
|
+
* the DOM to a clean state. This ensures no state leaks between tests.
|
|
137
|
+
*
|
|
138
|
+
* @returns void
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* import { clear } from '@rpgjs/testing'
|
|
143
|
+
*
|
|
144
|
+
* afterEach(() => {
|
|
145
|
+
* clear()
|
|
146
|
+
* })
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare function clear(): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Manually trigger a game tick for processing inputs and physics
|
|
152
|
+
*
|
|
153
|
+
* This function allows you to manually advance the game by one tick.
|
|
154
|
+
* It performs the following operations:
|
|
155
|
+
* 1. On server: processes pending inputs and advances physics
|
|
156
|
+
* 2. Server sends data to client
|
|
157
|
+
* 3. Client retrieves data and performs inputs (move, etc.) and server reconciliation
|
|
158
|
+
* 4. A tick is performed on the client
|
|
159
|
+
* 5. A tick is performed on VueJS (if Vue is used)
|
|
160
|
+
*
|
|
161
|
+
* @param client - The RpgClientEngine instance
|
|
162
|
+
* @param timestamp - Optional timestamp to use for the tick (default: Date.now())
|
|
163
|
+
* @returns Promise that resolves when the tick is complete
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { nextTick } from '@rpgjs/testing'
|
|
168
|
+
*
|
|
169
|
+
* const client = await fixture.createClient()
|
|
170
|
+
*
|
|
171
|
+
* // Manually advance the game by one tick
|
|
172
|
+
* await nextTick(client.client, Date.now())
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare function nextTick(client: RpgClientEngine, timestamp?: number): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Wait for synchronization to complete on the client
|
|
178
|
+
*
|
|
179
|
+
* This function waits for the client to receive and process synchronization data
|
|
180
|
+
* from the server. It monitors the `playersReceived$` and `eventsReceived$` observables
|
|
181
|
+
* in the RpgClientEngine to determine when synchronization is complete.
|
|
182
|
+
*
|
|
183
|
+
* ## Design
|
|
184
|
+
*
|
|
185
|
+
* - Uses `combineLatest` to wait for both `playersReceived$` and `eventsReceived$` to be `true`
|
|
186
|
+
* - Filters to only proceed when both are `true`
|
|
187
|
+
* - Includes a timeout to prevent waiting indefinitely
|
|
188
|
+
* - Resets the observables to `false` before waiting to ensure we catch the next sync
|
|
189
|
+
*
|
|
190
|
+
* @param client - The RpgClientEngine instance
|
|
191
|
+
* @param timeout - Maximum time to wait in milliseconds (default: 1000ms)
|
|
192
|
+
* @returns Promise that resolves when synchronization is complete
|
|
193
|
+
* @throws Error if timeout is exceeded
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* import { waitForSync } from '@rpgjs/testing'
|
|
198
|
+
*
|
|
199
|
+
* const client = await fixture.createClient()
|
|
200
|
+
*
|
|
201
|
+
* // Wait for sync to complete
|
|
202
|
+
* await waitForSync(client.client)
|
|
203
|
+
*
|
|
204
|
+
* // Now you can safely test client-side state
|
|
205
|
+
* expect(client.client.sceneMap.players()).toBeDefined()
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export declare function waitForSync(client: RpgClientEngine, timeout?: number): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Wait for complete synchronization cycle (server sync + client receive)
|
|
211
|
+
*
|
|
212
|
+
* This function performs a complete synchronization cycle:
|
|
213
|
+
* 1. Triggers a game tick using `nextTick()` which calls `syncChanges()` on all players
|
|
214
|
+
* 2. Waits for the client to receive and process the synchronization data
|
|
215
|
+
*
|
|
216
|
+
* This is useful when you need to ensure that server-side changes are fully
|
|
217
|
+
* synchronized to the client before testing client-side state.
|
|
218
|
+
*
|
|
219
|
+
* ## Design
|
|
220
|
+
*
|
|
221
|
+
* - Calls `nextTick()` to trigger server-side sync
|
|
222
|
+
* - Waits for client to receive sync data using `waitForSync()`
|
|
223
|
+
* - Ensures complete synchronization cycle is finished
|
|
224
|
+
*
|
|
225
|
+
* @param player - The RpgPlayer instance (optional, will sync all players if not provided)
|
|
226
|
+
* @param client - The RpgClientEngine instance
|
|
227
|
+
* @param timeout - Maximum time to wait in milliseconds (default: 1000ms)
|
|
228
|
+
* @returns Promise that resolves when synchronization is complete
|
|
229
|
+
* @throws Error if timeout is exceeded
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* import { waitForSyncComplete } from '@rpgjs/testing'
|
|
234
|
+
*
|
|
235
|
+
* const client = await fixture.createClient()
|
|
236
|
+
* const player = client.player
|
|
237
|
+
*
|
|
238
|
+
* // Make a server-side change
|
|
239
|
+
* player.addItem('potion', 5)
|
|
240
|
+
*
|
|
241
|
+
* // Wait for sync to complete
|
|
242
|
+
* await waitForSyncComplete(player, client.client)
|
|
243
|
+
*
|
|
244
|
+
* // Now you can safely test client-side state
|
|
245
|
+
* const clientPlayer = client.client.sceneMap.players()[player.id]
|
|
246
|
+
* expect(clientPlayer.items()).toBeDefined()
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export declare function waitForSyncComplete(player: RpgPlayer | null, client: RpgClientEngine, timeout?: number): Promise<void>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { mergeConfig } from './node_modules/.pnpm/@signe_di@2.6.0/node_modules/@signe/di/dist/index.js';
|
|
2
|
+
import { provideLoadMap, LoadMapToken, startGame, provideRpg, provideClientGlobalConfig, provideClientModules, inject, WebSocketToken, RpgClientEngine, clearInject } from '@rpgjs/client';
|
|
3
|
+
import { createServer, provideServerModules, clearInject as clearInject$1 } from '@rpgjs/server';
|
|
4
|
+
import { h, Container } from 'canvasengine';
|
|
5
|
+
import { Subject, filter, take, map, timer, switchMap, throwError, firstValueFrom, race, combineLatest } from 'rxjs';
|
|
6
|
+
|
|
7
|
+
function provideTestingLoadMap() {
|
|
8
|
+
return provideLoadMap((id) => {
|
|
9
|
+
return {
|
|
10
|
+
id,
|
|
11
|
+
data: {
|
|
12
|
+
width: 1024,
|
|
13
|
+
height: 768,
|
|
14
|
+
hitboxes: [],
|
|
15
|
+
params: {}
|
|
16
|
+
},
|
|
17
|
+
component: h(Container),
|
|
18
|
+
width: 1024,
|
|
19
|
+
height: 768
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function normalizeModules(modules) {
|
|
24
|
+
if (!modules || modules.length === 0) {
|
|
25
|
+
return { serverModules: [], clientModules: [] };
|
|
26
|
+
}
|
|
27
|
+
const isProviderArray = modules.some(
|
|
28
|
+
(item) => item && typeof item === "object" && "meta" in item && "useValue" in item
|
|
29
|
+
);
|
|
30
|
+
const serverModules = [];
|
|
31
|
+
const clientModules = [];
|
|
32
|
+
if (!isProviderArray) {
|
|
33
|
+
modules.forEach((module) => {
|
|
34
|
+
if (module && typeof module === "object") {
|
|
35
|
+
if (module.server) {
|
|
36
|
+
serverModules.push(module.server);
|
|
37
|
+
}
|
|
38
|
+
if (module.client) {
|
|
39
|
+
clientModules.push(module.client);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return { serverModules, clientModules };
|
|
44
|
+
}
|
|
45
|
+
const seenUseValues = /* @__PURE__ */ new Set();
|
|
46
|
+
modules.forEach((provider) => {
|
|
47
|
+
if (!provider || typeof provider !== "object" || !("meta" in provider) || !("useValue" in provider)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const { useValue } = provider;
|
|
51
|
+
if (seenUseValues.has(useValue)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (useValue && typeof useValue === "object" && ("server" in useValue || "client" in useValue)) {
|
|
55
|
+
seenUseValues.add(useValue);
|
|
56
|
+
if (useValue.server) {
|
|
57
|
+
serverModules.push(useValue.server);
|
|
58
|
+
}
|
|
59
|
+
if (useValue.client) {
|
|
60
|
+
clientModules.push(useValue.client);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return { serverModules, clientModules };
|
|
65
|
+
}
|
|
66
|
+
const globalFixtures = [];
|
|
67
|
+
async function testing(modules = [], clientConfig = {}, serverConfig = {}) {
|
|
68
|
+
const { serverModules, clientModules } = normalizeModules(modules);
|
|
69
|
+
const mapChangeSubject = new Subject();
|
|
70
|
+
const serverClass = createServer({
|
|
71
|
+
...serverConfig,
|
|
72
|
+
providers: [
|
|
73
|
+
provideServerModules([
|
|
74
|
+
...serverModules,
|
|
75
|
+
{
|
|
76
|
+
player: {
|
|
77
|
+
onJoinMap(player, map2) {
|
|
78
|
+
const mapId = map2?.id;
|
|
79
|
+
if (mapId) {
|
|
80
|
+
mapChangeSubject.next({ mapId, player });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]),
|
|
86
|
+
...serverConfig.providers || []
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
const hasLoadMap = clientConfig.providers?.some((provider) => {
|
|
90
|
+
if (Array.isArray(provider)) {
|
|
91
|
+
return provider.some((p) => p?.provide === LoadMapToken);
|
|
92
|
+
}
|
|
93
|
+
return provider?.provide === LoadMapToken;
|
|
94
|
+
}) || false;
|
|
95
|
+
await startGame(
|
|
96
|
+
mergeConfig(
|
|
97
|
+
{
|
|
98
|
+
...clientConfig,
|
|
99
|
+
providers: [
|
|
100
|
+
provideClientGlobalConfig({}),
|
|
101
|
+
...hasLoadMap ? [] : [provideTestingLoadMap()],
|
|
102
|
+
// Add only if not already provided
|
|
103
|
+
provideClientModules(clientModules),
|
|
104
|
+
...clientConfig.providers || []
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
providers: [provideRpg(serverClass, { env: { TEST: "true" } })]
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
const websocket = inject(WebSocketToken);
|
|
113
|
+
const clientEngine = inject(RpgClientEngine);
|
|
114
|
+
return {
|
|
115
|
+
async createClient() {
|
|
116
|
+
return {
|
|
117
|
+
socket: websocket.getSocket(),
|
|
118
|
+
client: clientEngine,
|
|
119
|
+
get playerId() {
|
|
120
|
+
return Object.keys(websocket.getServer().subRoom.players())[0];
|
|
121
|
+
},
|
|
122
|
+
get player() {
|
|
123
|
+
return websocket.getServer().subRoom.players()[this.playerId];
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Wait for player to be on a specific map
|
|
127
|
+
*
|
|
128
|
+
* This utility function waits for the `onJoinMap` hook to be triggered
|
|
129
|
+
* when the player joins the expected map, or throws an error if the timeout is exceeded.
|
|
130
|
+
*
|
|
131
|
+
* ## Design
|
|
132
|
+
*
|
|
133
|
+
* Uses RxJS to listen for map change events emitted by `onJoinMap`. The function:
|
|
134
|
+
* 1. Checks if the player is already on the expected map
|
|
135
|
+
* 2. Subscribes to the `mapChangeSubject` observable
|
|
136
|
+
* 3. Filters events to match the expected map ID
|
|
137
|
+
* 4. Uses `race` operator with a timer to implement timeout handling
|
|
138
|
+
* 5. Resolves with the player when the map change event is received
|
|
139
|
+
*
|
|
140
|
+
* @param expectedMapId - The expected map ID (without 'map-' prefix, e.g. 'map1')
|
|
141
|
+
* @param timeout - Maximum time to wait in milliseconds (default: 5000)
|
|
142
|
+
* @returns Promise that resolves when player is on the expected map
|
|
143
|
+
* @throws Error if timeout is exceeded
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const client = await fixture.createClient()
|
|
147
|
+
* await client.waitForMapChange('map1')
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
async waitForMapChange(expectedMapId, timeout = 5e3) {
|
|
151
|
+
const currentMap = this.player.getCurrentMap();
|
|
152
|
+
if (currentMap?.id === expectedMapId) {
|
|
153
|
+
return this.player;
|
|
154
|
+
}
|
|
155
|
+
const mapChange$ = mapChangeSubject.pipe(
|
|
156
|
+
filter((event) => event.mapId === expectedMapId),
|
|
157
|
+
take(1),
|
|
158
|
+
map((event) => event.player)
|
|
159
|
+
);
|
|
160
|
+
const timeout$ = timer(timeout).pipe(
|
|
161
|
+
take(1),
|
|
162
|
+
switchMap(() => {
|
|
163
|
+
const currentMap2 = this.player.getCurrentMap();
|
|
164
|
+
return throwError(() => new Error(
|
|
165
|
+
`Timeout: Player did not reach map ${expectedMapId} within ${timeout}ms. Current map: ${currentMap2?.id || "null"}`
|
|
166
|
+
));
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
try {
|
|
170
|
+
const result = await firstValueFrom(race([mapChange$, timeout$]));
|
|
171
|
+
return result;
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (error instanceof Error) {
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
const currentMap2 = this.player.getCurrentMap();
|
|
177
|
+
throw new Error(
|
|
178
|
+
`Timeout: Player did not reach map ${expectedMapId} within ${timeout}ms. Current map: ${currentMap2?.id || "null"}`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
/**
|
|
183
|
+
* Manually trigger a game tick for processing inputs and physics
|
|
184
|
+
*
|
|
185
|
+
* This method is a convenience wrapper around the exported nextTick() function.
|
|
186
|
+
*
|
|
187
|
+
* @param timestamp - Optional timestamp to use for the tick (default: Date.now())
|
|
188
|
+
* @returns Promise that resolves when the tick is complete
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const client = await fixture.createClient()
|
|
193
|
+
*
|
|
194
|
+
* // Manually advance the game by one tick
|
|
195
|
+
* await client.nextTick()
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
async nextTick(timestamp) {
|
|
199
|
+
return nextTick(this.client);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
get server() {
|
|
204
|
+
return websocket.getServer();
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* Clear all server, client instances and reset the DOM
|
|
208
|
+
*
|
|
209
|
+
* This method should be called in afterEach to clean up test state.
|
|
210
|
+
* It destroys all created client instances, clears the server, and resets the DOM.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* const fixture = await testing([myModule])
|
|
215
|
+
*
|
|
216
|
+
* afterEach(() => {
|
|
217
|
+
* fixture.clear()
|
|
218
|
+
* })
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
clear() {
|
|
222
|
+
return clear();
|
|
223
|
+
},
|
|
224
|
+
async applySyncToClient() {
|
|
225
|
+
this.server.subRoom.applySyncToClient();
|
|
226
|
+
await waitForSync(clientEngine);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
async function clear() {
|
|
231
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
232
|
+
for (const client of globalFixtures) {
|
|
233
|
+
try {
|
|
234
|
+
if (client.clientEngine && typeof client.clientEngine.clear === "function") {
|
|
235
|
+
client.clientEngine.clear();
|
|
236
|
+
}
|
|
237
|
+
const serverMap = client.server?.subRoom;
|
|
238
|
+
if (serverMap && typeof serverMap.clear === "function") {
|
|
239
|
+
serverMap.clear();
|
|
240
|
+
}
|
|
241
|
+
} catch (error) {
|
|
242
|
+
console.warn("Error during cleanup:", error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
globalFixtures.length = 0;
|
|
246
|
+
try {
|
|
247
|
+
clearInject();
|
|
248
|
+
} catch (error) {
|
|
249
|
+
console.warn("Error clearing client inject:", error);
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
clearInject$1();
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.warn("Error clearing server inject:", error);
|
|
255
|
+
}
|
|
256
|
+
if (typeof window !== "undefined" && window.document) {
|
|
257
|
+
window.document.body.innerHTML = `<div id="rpg"></div>`;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function nextTick(client, timestamp) {
|
|
261
|
+
if (!client) {
|
|
262
|
+
throw new Error("nextTick: client parameter is required");
|
|
263
|
+
}
|
|
264
|
+
const delta = 16;
|
|
265
|
+
const websocket = client.webSocket;
|
|
266
|
+
if (!websocket) {
|
|
267
|
+
throw new Error("nextTick: websocket not found in client");
|
|
268
|
+
}
|
|
269
|
+
const server = websocket.getServer();
|
|
270
|
+
if (!server) {
|
|
271
|
+
throw new Error("nextTick: server not found");
|
|
272
|
+
}
|
|
273
|
+
const serverMap = server.subRoom;
|
|
274
|
+
if (!serverMap) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
for (const player of serverMap.getPlayers()) {
|
|
278
|
+
if (player.pendingInputs && player.pendingInputs.length > 0) {
|
|
279
|
+
await serverMap.processInput(player.id);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (typeof serverMap.runFixedTicks === "function") {
|
|
283
|
+
serverMap.runFixedTicks(delta);
|
|
284
|
+
}
|
|
285
|
+
for (const player of serverMap.getPlayers()) {
|
|
286
|
+
if (player && typeof player.syncChanges === "function") {
|
|
287
|
+
player.syncChanges();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
291
|
+
const sceneMap = client.sceneMap;
|
|
292
|
+
if (sceneMap && typeof sceneMap.stepPredictionTick === "function") {
|
|
293
|
+
sceneMap.stepPredictionTick();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async function waitForSync(client, timeout = 1e3) {
|
|
297
|
+
if (!client) {
|
|
298
|
+
throw new Error("waitForSync: client parameter is required");
|
|
299
|
+
}
|
|
300
|
+
const playersReceived$ = client.playersReceived$;
|
|
301
|
+
const eventsReceived$ = client.eventsReceived$;
|
|
302
|
+
if (!playersReceived$ || !eventsReceived$) {
|
|
303
|
+
throw new Error(
|
|
304
|
+
"waitForSync: playersReceived$ or eventsReceived$ not found in client"
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
const playersAlreadyTrue = playersReceived$.getValue ? playersReceived$.getValue() === true : false;
|
|
308
|
+
const eventsAlreadyTrue = eventsReceived$.getValue ? eventsReceived$.getValue() === true : false;
|
|
309
|
+
if (playersAlreadyTrue && eventsAlreadyTrue) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
playersReceived$.next(false);
|
|
313
|
+
eventsReceived$.next(false);
|
|
314
|
+
const syncComplete$ = combineLatest([
|
|
315
|
+
playersReceived$.pipe(filter((received) => received === true)),
|
|
316
|
+
eventsReceived$.pipe(filter((received) => received === true))
|
|
317
|
+
]).pipe(take(1));
|
|
318
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
319
|
+
setTimeout(() => {
|
|
320
|
+
reject(
|
|
321
|
+
new Error(
|
|
322
|
+
`waitForSync: Timeout after ${timeout}ms. Synchronization did not complete.`
|
|
323
|
+
)
|
|
324
|
+
);
|
|
325
|
+
}, timeout);
|
|
326
|
+
});
|
|
327
|
+
await Promise.race([firstValueFrom(syncComplete$), timeoutPromise]);
|
|
328
|
+
}
|
|
329
|
+
async function waitForSyncComplete(player, client, timeout = 1e3) {
|
|
330
|
+
if (!client) {
|
|
331
|
+
throw new Error("waitForSyncComplete: client parameter is required");
|
|
332
|
+
}
|
|
333
|
+
const playersReceived$ = client.playersReceived$;
|
|
334
|
+
const eventsReceived$ = client.eventsReceived$;
|
|
335
|
+
if (playersReceived$ && eventsReceived$) {
|
|
336
|
+
playersReceived$.next(false);
|
|
337
|
+
eventsReceived$.next(false);
|
|
338
|
+
}
|
|
339
|
+
await nextTick(client);
|
|
340
|
+
await waitForSync(client, timeout);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export { clear, nextTick, provideTestingLoadMap, testing, waitForSync, waitForSyncComplete };
|
|
344
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { mergeConfig, Provider } from \"@signe/di\";\nimport {\n provideRpg,\n startGame,\n provideClientModules,\n provideLoadMap,\n provideClientGlobalConfig,\n inject,\n WebSocketToken,\n AbstractWebsocket,\n RpgClientEngine,\n RpgClient,\n LoadMapToken,\n} from \"@rpgjs/client\";\nimport {\n createServer,\n provideServerModules,\n RpgServer,\n RpgPlayer,\n} from \"@rpgjs/server\";\nimport { h, Container } from \"canvasengine\";\nimport { clearInject as clearClientInject } from \"@rpgjs/client\";\nimport { clearInject as clearServerInject } from \"@rpgjs/server\";\nimport { combineLatest, filter, take, firstValueFrom, Subject, map, throwError, race, timer, switchMap } from \"rxjs\";\n\n/**\n * Provides a default map loader for testing environments\n *\n * This function returns a `provideLoadMap` provider that creates mock maps\n * with default dimensions (1024x768) and a minimal component. It's automatically\n * used by `testing()` if no custom `provideLoadMap` is provided in `clientConfig.providers`.\n *\n * @returns A provider function that can be used with `provideLoadMap`\n * @example\n * ```ts\n * // Used automatically by testing()\n * const fixture = await testing([myModule])\n *\n * // Or use directly in clientConfig\n * const fixture = await testing([myModule], {\n * providers: [provideTestingLoadMap()]\n * })\n * ```\n */\nexport function provideTestingLoadMap() {\n return provideLoadMap((id: string) => {\n return {\n id,\n data: {\n width: 1024,\n height: 768,\n hitboxes: [],\n params: {},\n },\n component: h(Container),\n width: 1024,\n height: 768,\n };\n });\n}\n\n/**\n * Normalizes modules input to extract server/client modules from createModule providers or direct module objects\n *\n * @param modules - Array of modules that can be either:\n * - Direct module objects: { server: RpgServer, client: RpgClient }\n * - Providers returned by createModule(): Provider[] with meta.server/client and useValue\n * @returns Object with separate arrays for server and client modules\n * @example\n * ```ts\n * // Direct modules\n * normalizeModules([{ server: serverModule, client: clientModule }])\n *\n * // createModule providers\n * const providers = createModule('MyModule', [{ server: serverModule, client: clientModule }])\n * normalizeModules(providers)\n * ```\n */\nfunction normalizeModules(modules: any[]): {\n serverModules: RpgServer[];\n clientModules: RpgClient[];\n} {\n if (!modules || modules.length === 0) {\n return { serverModules: [], clientModules: [] };\n }\n\n // Check if first item is a provider (has meta and useValue properties)\n const isProviderArray = modules.some(\n (item: any) =>\n item && typeof item === \"object\" && \"meta\" in item && \"useValue\" in item\n );\n\n const serverModules: RpgServer[] = [];\n const clientModules: RpgClient[] = [];\n\n if (!isProviderArray) {\n // Direct module objects, extract server and client separately\n modules.forEach((module: any) => {\n if (module && typeof module === \"object\") {\n if (module.server) {\n serverModules.push(module.server);\n }\n if (module.client) {\n clientModules.push(module.client);\n }\n }\n });\n return { serverModules, clientModules };\n }\n\n // Extract modules from createModule providers\n // createModule returns providers where useValue contains the original { server, client } object\n // We need to group providers by their useValue to reconstruct the original modules\n const seenUseValues = new Set<any>();\n\n modules.forEach((provider: any) => {\n if (\n !provider ||\n typeof provider !== \"object\" ||\n !(\"meta\" in provider) ||\n !(\"useValue\" in provider)\n ) {\n return;\n }\n\n const { useValue } = provider;\n\n // Skip if we've already processed this useValue (same module, different provider for server/client)\n if (seenUseValues.has(useValue)) {\n return;\n }\n\n // Check if useValue has server or client properties (it's a module object)\n if (\n useValue &&\n typeof useValue === \"object\" &&\n (\"server\" in useValue || \"client\" in useValue)\n ) {\n seenUseValues.add(useValue);\n if (useValue.server) {\n serverModules.push(useValue.server);\n }\n if (useValue.client) {\n clientModules.push(useValue.client);\n }\n }\n });\n\n return { serverModules, clientModules };\n}\n\n// Global storage for all created fixtures and clients (for clear() function)\nconst globalFixtures: Array<{\n context: any;\n clientEngine: RpgClientEngine;\n websocket: AbstractWebsocket;\n server?: any;\n}> = [];\n\n\n/**\n * Testing utility function to set up server and client instances for unit testing\n *\n * This function creates a test environment with both server and client instances,\n * allowing you to test player interactions, server hooks, and game mechanics.\n *\n * @param modules - Array of modules that can be either:\n * - Direct module objects: { server: RpgServer, client: RpgClient }\n * - Providers returned by createModule(): Provider[] with meta.server/client and useValue\n * @param clientConfig - Optional client configuration\n * @param serverConfig - Optional server configuration\n * @returns Testing fixture with createClient method\n * @example\n * ```ts\n * // Using direct modules\n * const fixture = await testing([{\n * server: serverModule,\n * client: clientModule\n * }])\n *\n * // Using createModule\n * const myModule = createModule('MyModule', [{\n * server: serverModule,\n * client: clientModule\n * }])\n * const fixture = await testing(myModule)\n * ```\n */\nexport async function testing(\n modules: ({ server?: RpgServer; client?: RpgClient } | Provider)[] = [],\n clientConfig: any = {},\n serverConfig: any = {}\n) {\n // Normalize modules to extract server/client from providers if needed\n const { serverModules, clientModules } = normalizeModules(modules as any[]);\n\n // Subject to emit map change events when onJoinMap is triggered\n const mapChangeSubject = new Subject<{ mapId: string; player: RpgPlayer }>();\n\n const serverClass = createServer({\n ...serverConfig,\n providers: [\n provideServerModules([\n ...serverModules,\n {\n player: {\n onJoinMap(player: RpgPlayer, map: any) {\n // Emit map change event to RxJS Subject\n const mapId = map?.id;\n if (mapId) {\n mapChangeSubject.next({ mapId, player });\n }\n }\n }\n },\n ]),\n ...(serverConfig.providers || []),\n ],\n });\n\n // Check if LoadMapToken is already provided in clientConfig.providers\n // (provideLoadMap returns an array with LoadMapToken)\n const hasLoadMap =\n clientConfig.providers?.some((provider: any) => {\n if (Array.isArray(provider)) {\n return provider.some((p: any) => p?.provide === LoadMapToken);\n }\n return provider?.provide === LoadMapToken;\n }) || false;\n\n await startGame(\n mergeConfig(\n {\n ...clientConfig,\n providers: [\n provideClientGlobalConfig({}),\n ...(hasLoadMap ? [] : [provideTestingLoadMap()]), // Add only if not already provided\n provideClientModules(clientModules),\n ...(clientConfig.providers || []),\n ],\n },\n {\n providers: [provideRpg(serverClass, { env: { TEST: \"true\" } })],\n }\n )\n );\n const websocket = inject<AbstractWebsocket>(WebSocketToken) as any;\n const clientEngine = inject<RpgClientEngine>(RpgClientEngine);\n\n return {\n async createClient() {\n return {\n socket: websocket.getSocket(),\n client: clientEngine,\n get playerId() {\n return Object.keys(websocket.getServer().subRoom.players())[0];\n },\n get player(): RpgPlayer {\n return websocket.getServer().subRoom.players()[this.playerId] as RpgPlayer;\n },\n /**\n * Wait for player to be on a specific map\n *\n * This utility function waits for the `onJoinMap` hook to be triggered\n * when the player joins the expected map, or throws an error if the timeout is exceeded.\n *\n * ## Design\n *\n * Uses RxJS to listen for map change events emitted by `onJoinMap`. The function:\n * 1. Checks if the player is already on the expected map\n * 2. Subscribes to the `mapChangeSubject` observable\n * 3. Filters events to match the expected map ID\n * 4. Uses `race` operator with a timer to implement timeout handling\n * 5. Resolves with the player when the map change event is received\n *\n * @param expectedMapId - The expected map ID (without 'map-' prefix, e.g. 'map1')\n * @param timeout - Maximum time to wait in milliseconds (default: 5000)\n * @returns Promise that resolves when player is on the expected map\n * @throws Error if timeout is exceeded\n * @example\n * ```ts\n * const client = await fixture.createClient()\n * await client.waitForMapChange('map1')\n * ```\n */\n async waitForMapChange(\n expectedMapId: string,\n timeout = 5000\n ): Promise<RpgPlayer> {\n // Check if already on the expected map\n const currentMap = this.player.getCurrentMap();\n if (currentMap?.id === expectedMapId) {\n return this.player;\n }\n\n // Create observable that filters map changes for the expected map ID\n const mapChange$ = mapChangeSubject.pipe(\n filter((event) => event.mapId === expectedMapId),\n take(1),\n map((event) => event.player)\n );\n\n // Create timeout observable that throws an error\n const timeout$ = timer(timeout).pipe(\n take(1),\n switchMap(() => {\n const currentMap = this.player.getCurrentMap();\n return throwError(() => new Error(\n `Timeout: Player did not reach map ${expectedMapId} within ${timeout}ms. ` +\n `Current map: ${currentMap?.id || \"null\"}`\n ));\n })\n );\n\n // Race between map change and timeout\n try {\n const result = await firstValueFrom(race([mapChange$, timeout$]));\n return result as RpgPlayer;\n } catch (error) {\n if (error instanceof Error) {\n throw error;\n }\n const currentMap = this.player.getCurrentMap();\n throw new Error(\n `Timeout: Player did not reach map ${expectedMapId} within ${timeout}ms. ` +\n `Current map: ${currentMap?.id || \"null\"}`\n );\n }\n },\n /**\n * Manually trigger a game tick for processing inputs and physics\n *\n * This method is a convenience wrapper around the exported nextTick() function.\n *\n * @param timestamp - Optional timestamp to use for the tick (default: Date.now())\n * @returns Promise that resolves when the tick is complete\n *\n * @example\n * ```ts\n * const client = await fixture.createClient()\n *\n * // Manually advance the game by one tick\n * await client.nextTick()\n * ```\n */\n async nextTick(timestamp?: number): Promise<void> {\n return nextTick(this.client, timestamp);\n },\n };\n },\n get server() {\n return websocket.getServer();\n },\n /**\n * Clear all server, client instances and reset the DOM\n *\n * This method should be called in afterEach to clean up test state.\n * It destroys all created client instances, clears the server, and resets the DOM.\n *\n * @example\n * ```ts\n * const fixture = await testing([myModule])\n *\n * afterEach(() => {\n * fixture.clear()\n * })\n * ```\n */\n clear() {\n return clear();\n },\n async applySyncToClient() {\n this.server.subRoom.applySyncToClient();\n await waitForSync(clientEngine);\n },\n };\n}\n\n/**\n * Clear all caches and reset test state\n *\n * This function should be called after the end of each test to clean up\n * all server and client instances, clear caches, and reset the DOM.\n *\n * ## Design\n *\n * Cleans up all created fixtures, client engines, server instances, and resets\n * the DOM to a clean state. This ensures no state leaks between tests.\n *\n * @returns void\n *\n * @example\n * ```ts\n * import { clear } from '@rpgjs/testing'\n *\n * afterEach(() => {\n * clear()\n * })\n * ```\n */\nexport async function clear(): Promise<void> {\n\n // Wait for the next tick to ensure all promises are resolved\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n // Clean up all created client and server instances from all fixtures\n for (const client of globalFixtures) {\n try {\n // Clear client engine\n if (\n client.clientEngine &&\n typeof (client.clientEngine as any).clear === \"function\"\n ) {\n (client.clientEngine as any).clear();\n }\n\n // Clear server map (subRoom)\n const serverMap = client.server?.subRoom as any;\n if (serverMap && typeof serverMap.clear === \"function\") {\n serverMap.clear();\n }\n } catch (error) {\n // Silently ignore cleanup errors\n console.warn(\"Error during cleanup:\", error);\n }\n }\n\n // Clear the global fixtures array\n globalFixtures.length = 0;\n\n // Clear client context injection\n try {\n clearClientInject();\n } catch (error) {\n console.warn(\"Error clearing client inject:\", error);\n }\n\n // Clear server context injection\n try {\n clearServerInject();\n } catch (error) {\n console.warn(\"Error clearing server inject:\", error);\n }\n\n // Reset DOM\n if (typeof window !== \"undefined\" && window.document) {\n window.document.body.innerHTML = `<div id=\"rpg\"></div>`;\n }\n}\n\n/**\n * Manually trigger a game tick for processing inputs and physics\n *\n * This function allows you to manually advance the game by one tick.\n * It performs the following operations:\n * 1. On server: processes pending inputs and advances physics\n * 2. Server sends data to client\n * 3. Client retrieves data and performs inputs (move, etc.) and server reconciliation\n * 4. A tick is performed on the client\n * 5. A tick is performed on VueJS (if Vue is used)\n *\n * @param client - The RpgClientEngine instance\n * @param timestamp - Optional timestamp to use for the tick (default: Date.now())\n * @returns Promise that resolves when the tick is complete\n *\n * @example\n * ```ts\n * import { nextTick } from '@rpgjs/testing'\n *\n * const client = await fixture.createClient()\n *\n * // Manually advance the game by one tick\n * await nextTick(client.client, Date.now())\n * ```\n */\nexport async function nextTick(\n client: RpgClientEngine,\n timestamp?: number\n): Promise<void> {\n if (!client) {\n throw new Error(\"nextTick: client parameter is required\");\n }\n\n const tickTimestamp = timestamp ?? Date.now();\n const delta = 16; // 16ms for 60fps\n\n // Get server instance from client context\n const websocket = (client as any).webSocket;\n if (!websocket) {\n throw new Error(\"nextTick: websocket not found in client\");\n }\n\n const server = websocket.getServer();\n if (!server) {\n throw new Error(\"nextTick: server not found\");\n }\n\n // Get server map (subRoom)\n const serverMap = server.subRoom as any;\n if (!serverMap) {\n return;\n }\n\n // 1. On server: Process inputs for all players\n for (const player of serverMap.getPlayers()) {\n if (player.pendingInputs && player.pendingInputs.length > 0) {\n await serverMap.processInput(player.id);\n }\n }\n\n // 2. Run physics tick on server map\n if (typeof serverMap.runFixedTicks === \"function\") {\n serverMap.runFixedTicks(delta);\n }\n\n // 3. Server sends data to client - trigger sync for all players\n // The sync is triggered by calling syncChanges() on each player\n for (const player of serverMap.getPlayers()) {\n if (player && typeof (player as any).syncChanges === \"function\") {\n (player as any).syncChanges();\n }\n }\n\n // 4. Client retrieves data and performs reconciliation\n // The sync data will be received by the client through the websocket\n // We need to wait a bit for the sync data to be processed\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n // 5. Run physics tick on client map (performs client-side prediction)\n const sceneMap = (client as any).sceneMap;\n if (sceneMap && typeof sceneMap.stepPredictionTick === \"function\") {\n sceneMap.stepPredictionTick();\n }\n\n // 6. Trigger VueJS tick if Vue is used (handled by CanvasEngine internally)\n // CanvasEngine handles this automatically through its tick system\n}\n\n/**\n * Wait for synchronization to complete on the client\n *\n * This function waits for the client to receive and process synchronization data\n * from the server. It monitors the `playersReceived$` and `eventsReceived$` observables\n * in the RpgClientEngine to determine when synchronization is complete.\n *\n * ## Design\n *\n * - Uses `combineLatest` to wait for both `playersReceived$` and `eventsReceived$` to be `true`\n * - Filters to only proceed when both are `true`\n * - Includes a timeout to prevent waiting indefinitely\n * - Resets the observables to `false` before waiting to ensure we catch the next sync\n *\n * @param client - The RpgClientEngine instance\n * @param timeout - Maximum time to wait in milliseconds (default: 1000ms)\n * @returns Promise that resolves when synchronization is complete\n * @throws Error if timeout is exceeded\n *\n * @example\n * ```ts\n * import { waitForSync } from '@rpgjs/testing'\n *\n * const client = await fixture.createClient()\n *\n * // Wait for sync to complete\n * await waitForSync(client.client)\n *\n * // Now you can safely test client-side state\n * expect(client.client.sceneMap.players()).toBeDefined()\n * ```\n */\nexport async function waitForSync(\n client: RpgClientEngine,\n timeout: number = 1000\n): Promise<void> {\n if (!client) {\n throw new Error(\"waitForSync: client parameter is required\");\n }\n\n // Access private observables via type assertion\n const playersReceived$ = (client as any).playersReceived$ as any;\n const eventsReceived$ = (client as any).eventsReceived$ as any;\n\n if (!playersReceived$ || !eventsReceived$) {\n throw new Error(\n \"waitForSync: playersReceived$ or eventsReceived$ not found in client\"\n );\n }\n\n // Check if observables are already true - if so, sync has already arrived, don't reset\n const playersAlreadyTrue = playersReceived$.getValue\n ? playersReceived$.getValue() === true\n : false;\n const eventsAlreadyTrue = eventsReceived$.getValue\n ? eventsReceived$.getValue() === true\n : false;\n\n // If both observables are already true, sync has already completed - return immediately\n if (playersAlreadyTrue && eventsAlreadyTrue) {\n return;\n }\n\n // Reset observables to false to ensure we catch the next sync\n // Note: This is only needed when waitForSync is called standalone.\n // When called from waitForSyncComplete, observables are already reset before nextTick\n playersReceived$.next(false);\n eventsReceived$.next(false);\n\n // Wait for both observables to be true\n const syncComplete$ = combineLatest([\n playersReceived$.pipe(filter((received) => received === true)),\n eventsReceived$.pipe(filter((received) => received === true)),\n ]).pipe(take(1));\n\n // Create a timeout promise\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(() => {\n reject(\n new Error(\n `waitForSync: Timeout after ${timeout}ms. Synchronization did not complete.`\n )\n );\n }, timeout);\n });\n\n // Race between sync completion and timeout\n await Promise.race([firstValueFrom(syncComplete$), timeoutPromise]);\n}\n\n/**\n * Wait for complete synchronization cycle (server sync + client receive)\n *\n * This function performs a complete synchronization cycle:\n * 1. Triggers a game tick using `nextTick()` which calls `syncChanges()` on all players\n * 2. Waits for the client to receive and process the synchronization data\n *\n * This is useful when you need to ensure that server-side changes are fully\n * synchronized to the client before testing client-side state.\n *\n * ## Design\n *\n * - Calls `nextTick()` to trigger server-side sync\n * - Waits for client to receive sync data using `waitForSync()`\n * - Ensures complete synchronization cycle is finished\n *\n * @param player - The RpgPlayer instance (optional, will sync all players if not provided)\n * @param client - The RpgClientEngine instance\n * @param timeout - Maximum time to wait in milliseconds (default: 1000ms)\n * @returns Promise that resolves when synchronization is complete\n * @throws Error if timeout is exceeded\n *\n * @example\n * ```ts\n * import { waitForSyncComplete } from '@rpgjs/testing'\n *\n * const client = await fixture.createClient()\n * const player = client.player\n *\n * // Make a server-side change\n * player.addItem('potion', 5)\n *\n * // Wait for sync to complete\n * await waitForSyncComplete(player, client.client)\n *\n * // Now you can safely test client-side state\n * const clientPlayer = client.client.sceneMap.players()[player.id]\n * expect(clientPlayer.items()).toBeDefined()\n * ```\n */\nexport async function waitForSyncComplete(\n player: RpgPlayer | null,\n client: RpgClientEngine,\n timeout: number = 1000\n): Promise<void> {\n if (!client) {\n throw new Error(\"waitForSyncComplete: client parameter is required\");\n }\n\n // Reset observables BEFORE calling nextTick to ensure we catch the sync that will be sent\n // This prevents race condition where sync arrives before we start waiting\n const playersReceived$ = (client as any).playersReceived$ as any;\n const eventsReceived$ = (client as any).eventsReceived$ as any;\n if (playersReceived$ && eventsReceived$) {\n playersReceived$.next(false);\n eventsReceived$.next(false);\n }\n\n // Trigger sync by calling nextTick (which calls syncChanges on all players)\n await nextTick(client);\n\n // Wait for client to receive and process the sync\n await waitForSync(client, timeout);\n}\n"],"names":["map","currentMap","clearClientInject","clearServerInject"],"mappings":";;;;;;AA4CO,SAAS,qBAAA,GAAwB;AACtC,EAAA,OAAO,cAAA,CAAe,CAAC,EAAA,KAAe;AACpC,IAAA,OAAO;AAAA,MACL,EAAA;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,KAAA,EAAO,IAAA;AAAA,QACP,MAAA,EAAQ,GAAA;AAAA,QACR,UAAU,EAAC;AAAA,QACX,QAAQ;AAAC,OACX;AAAA,MACA,SAAA,EAAW,EAAE,SAAS,CAAA;AAAA,MACtB,KAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ;AAAA,KACV;AAAA,EACF,CAAC,CAAA;AACH;AAmBA,SAAS,iBAAiB,OAAA,EAGxB;AACA,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,MAAA,KAAW,CAAA,E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