@colyseus/sdk 0.17.21 → 0.17.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/build/3rd_party/discord.cjs +1 -1
  2. package/build/3rd_party/discord.mjs +1 -1
  3. package/build/Auth.cjs +1 -1
  4. package/build/Auth.mjs +1 -1
  5. package/build/Client.cjs +1 -1
  6. package/build/Client.mjs +1 -1
  7. package/build/Connection.cjs +1 -1
  8. package/build/Connection.mjs +1 -1
  9. package/build/HTTP.cjs +1 -1
  10. package/build/HTTP.cjs.map +1 -1
  11. package/build/HTTP.d.ts +11 -10
  12. package/build/HTTP.mjs +1 -1
  13. package/build/HTTP.mjs.map +1 -1
  14. package/build/Room.cjs +1 -1
  15. package/build/Room.mjs +1 -1
  16. package/build/Storage.cjs +1 -1
  17. package/build/Storage.mjs +1 -1
  18. package/build/core/nanoevents.cjs +1 -1
  19. package/build/core/nanoevents.mjs +1 -1
  20. package/build/core/signal.cjs +1 -1
  21. package/build/core/signal.mjs +1 -1
  22. package/build/core/utils.cjs +1 -1
  23. package/build/core/utils.mjs +1 -1
  24. package/build/debug.cjs +1 -1
  25. package/build/debug.mjs +1 -1
  26. package/build/errors/Errors.cjs +1 -1
  27. package/build/errors/Errors.mjs +1 -1
  28. package/build/index.cjs +1 -1
  29. package/build/index.mjs +1 -1
  30. package/build/legacy.cjs +1 -1
  31. package/build/legacy.mjs +1 -1
  32. package/build/serializer/NoneSerializer.cjs +1 -1
  33. package/build/serializer/NoneSerializer.mjs +1 -1
  34. package/build/serializer/SchemaSerializer.cjs +1 -1
  35. package/build/serializer/SchemaSerializer.mjs +1 -1
  36. package/build/serializer/Serializer.cjs +1 -1
  37. package/build/serializer/Serializer.mjs +1 -1
  38. package/build/transport/H3Transport.cjs +1 -1
  39. package/build/transport/H3Transport.mjs +1 -1
  40. package/build/transport/WebSocketTransport.cjs +1 -1
  41. package/build/transport/WebSocketTransport.mjs +1 -1
  42. package/dist/colyseus-cocos-creator.js +1 -1
  43. package/dist/colyseus-cocos-creator.js.map +1 -1
  44. package/dist/colyseus.js +1 -1
  45. package/dist/colyseus.js.map +1 -1
  46. package/dist/debug.js +1 -1
  47. package/dist/debug.js.map +1 -1
  48. package/package.json +4 -4
  49. package/src/HTTP.ts +16 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/sdk",
3
- "version": "0.17.21",
3
+ "version": "0.17.23",
4
4
  "description": "Colyseus Multiplayer SDK for JavaScript/TypeScript",
5
5
  "author": "Endel Dreyer",
6
6
  "license": "MIT",
@@ -55,8 +55,8 @@
55
55
  "@colyseus/schema": "^4.0.4",
56
56
  "tslib": "^2.1.0",
57
57
  "ws": "^8.13.0",
58
- "@colyseus/shared-types": "^0.17.3",
59
- "@colyseus/better-call": "^1.2.0"
58
+ "@colyseus/shared-types": "^0.17.4",
59
+ "@colyseus/better-call": "^1.2.1"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@rollup/plugin-alias": "^5.1.1",
@@ -82,7 +82,7 @@
82
82
  "typescript": "^5.9.3",
83
83
  "vite": "^5.0.11",
84
84
  "vitest": "^2.1.1",
85
- "@colyseus/core": "^0.17.21"
85
+ "@colyseus/core": "^0.17.22"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "@colyseus/core": "0.17.x"
package/src/HTTP.ts CHANGED
@@ -243,6 +243,12 @@ type InferredAPI<R> = R extends { endpoints: Record<string, Endpoint> }
243
243
  ? WithoutServerOnly<R["endpoints"]>
244
244
  : WithoutServerOnly<R & Record<string, Endpoint>>;
245
245
 
246
+ // Helper type to resolve return type, returning 'any' when R is untyped
247
+ type InferReturnType<R, OPT, K extends keyof OPT> =
248
+ IsAnyOrAnyIndexed<R> extends true
249
+ ? any
250
+ : Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>;
251
+
246
252
  export class HTTP<R extends Router | Router["endpoints"]> {
247
253
  public authToken: string | undefined;
248
254
  public options: FetchRequestOptions;
@@ -282,7 +288,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
282
288
  ? FetchRequestOptions<any, any, any>
283
289
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
284
290
  ): Promise<
285
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
291
+ FetchResponse<InferReturnType<R, OPT, K>>
286
292
  >;
287
293
 
288
294
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -297,7 +303,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
297
303
  ? FetchRequestOptions<any, any, any>
298
304
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
299
305
  ): Promise<
300
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
306
+ FetchResponse<InferReturnType<R, OPT, K>>
301
307
  >;
302
308
 
303
309
  get(path: any, options?: any): Promise<any> {
@@ -316,7 +322,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
316
322
  ? FetchRequestOptions<any, any, any>
317
323
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>)
318
324
  ): Promise<
319
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
325
+ FetchResponse<InferReturnType<R, OPT, K>>
320
326
  >;
321
327
 
322
328
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -331,7 +337,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
331
337
  ? FetchRequestOptions<any, any, any>
332
338
  : FetchRequestOptions<C["body"], C["query"], C["params"]>)
333
339
  ): Promise<
334
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
340
+ FetchResponse<InferReturnType<R, OPT, K>>
335
341
  >;
336
342
 
337
343
  post(path: any, options?: any): Promise<any> {
@@ -350,7 +356,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
350
356
  ? FetchRequestOptions<any, any, any>
351
357
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
352
358
  ): Promise<
353
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
359
+ FetchResponse<InferReturnType<R, OPT, K>>
354
360
  >;
355
361
 
356
362
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -365,7 +371,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
365
371
  ? FetchRequestOptions<any, any, any>
366
372
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
367
373
  ): Promise<
368
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
374
+ FetchResponse<InferReturnType<R, OPT, K>>
369
375
  >;
370
376
 
371
377
  delete(path: any, options?: any): Promise<any> {
@@ -384,7 +390,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
384
390
  ? FetchRequestOptions<any, any, any>
385
391
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
386
392
  ): Promise<
387
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
393
+ FetchResponse<InferReturnType<R, OPT, K>>
388
394
  >;
389
395
 
390
396
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -399,7 +405,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
399
405
  ? FetchRequestOptions<any, any, any>
400
406
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
401
407
  ): Promise<
402
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
408
+ FetchResponse<InferReturnType<R, OPT, K>>
403
409
  >;
404
410
 
405
411
  patch(path: any, options?: any): Promise<any> {
@@ -418,7 +424,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
418
424
  ? FetchRequestOptions<any, any, any>
419
425
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
420
426
  ): Promise<
421
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
427
+ FetchResponse<InferReturnType<R, OPT, K>>
422
428
  >;
423
429
 
424
430
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -433,7 +439,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
433
439
  ? FetchRequestOptions<any, any, any>
434
440
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
435
441
  ): Promise<
436
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
442
+ FetchResponse<InferReturnType<R, OPT, K>>
437
443
  >;
438
444
 
439
445
  put(path: any, options?: any): Promise<any> {