@colyseus/sdk 0.17.22 → 0.17.24

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 +3 -1
  10. package/build/HTTP.cjs.map +1 -1
  11. package/build/HTTP.d.ts +15 -10
  12. package/build/HTTP.mjs +3 -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 +3 -1
  43. package/dist/colyseus-cocos-creator.js.map +1 -1
  44. package/dist/colyseus.js +3 -1
  45. package/dist/colyseus.js.map +1 -1
  46. package/dist/debug.js +3 -1
  47. package/dist/debug.js.map +1 -1
  48. package/package.json +1 -1
  49. package/src/HTTP.ts +19 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/sdk",
3
- "version": "0.17.22",
3
+ "version": "0.17.24",
4
4
  "description": "Colyseus Multiplayer SDK for JavaScript/TypeScript",
5
5
  "author": "Endel Dreyer",
6
6
  "license": "MIT",
package/src/HTTP.ts CHANGED
@@ -243,11 +243,20 @@ 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;
249
255
 
250
256
  private sdk: ColyseusSDK;
257
+
258
+ // alias "del()" to "delete()"
259
+ public del = this.delete;
251
260
 
252
261
  constructor(sdk: ColyseusSDK, baseOptions: FetchRequestOptions) {
253
262
  this.sdk = sdk;
@@ -282,7 +291,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
282
291
  ? FetchRequestOptions<any, any, any>
283
292
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
284
293
  ): Promise<
285
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
294
+ FetchResponse<InferReturnType<R, OPT, K>>
286
295
  >;
287
296
 
288
297
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -297,7 +306,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
297
306
  ? FetchRequestOptions<any, any, any>
298
307
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
299
308
  ): Promise<
300
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
309
+ FetchResponse<InferReturnType<R, OPT, K>>
301
310
  >;
302
311
 
303
312
  get(path: any, options?: any): Promise<any> {
@@ -316,7 +325,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
316
325
  ? FetchRequestOptions<any, any, any>
317
326
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>)
318
327
  ): Promise<
319
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
328
+ FetchResponse<InferReturnType<R, OPT, K>>
320
329
  >;
321
330
 
322
331
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -331,7 +340,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
331
340
  ? FetchRequestOptions<any, any, any>
332
341
  : FetchRequestOptions<C["body"], C["query"], C["params"]>)
333
342
  ): Promise<
334
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
343
+ FetchResponse<InferReturnType<R, OPT, K>>
335
344
  >;
336
345
 
337
346
  post(path: any, options?: any): Promise<any> {
@@ -350,7 +359,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
350
359
  ? FetchRequestOptions<any, any, any>
351
360
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
352
361
  ): Promise<
353
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
362
+ FetchResponse<InferReturnType<R, OPT, K>>
354
363
  >;
355
364
 
356
365
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -365,7 +374,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
365
374
  ? FetchRequestOptions<any, any, any>
366
375
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
367
376
  ): Promise<
368
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
377
+ FetchResponse<InferReturnType<R, OPT, K>>
369
378
  >;
370
379
 
371
380
  delete(path: any, options?: any): Promise<any> {
@@ -384,7 +393,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
384
393
  ? FetchRequestOptions<any, any, any>
385
394
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
386
395
  ): Promise<
387
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
396
+ FetchResponse<InferReturnType<R, OPT, K>>
388
397
  >;
389
398
 
390
399
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -399,7 +408,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
399
408
  ? FetchRequestOptions<any, any, any>
400
409
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
401
410
  ): Promise<
402
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
411
+ FetchResponse<InferReturnType<R, OPT, K>>
403
412
  >;
404
413
 
405
414
  patch(path: any, options?: any): Promise<any> {
@@ -418,7 +427,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
418
427
  ? FetchRequestOptions<any, any, any>
419
428
  : WithRequired<FetchRequestOptions<C["body"], C["query"], C["params"]>, keyof RequiredOptionKeys<C>>
420
429
  ): Promise<
421
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
430
+ FetchResponse<InferReturnType<R, OPT, K>>
422
431
  >;
423
432
 
424
433
  // Overload for endpoints WITHOUT required fields (permissive when R is 'any')
@@ -433,7 +442,7 @@ export class HTTP<R extends Router | Router["endpoints"]> {
433
442
  ? FetchRequestOptions<any, any, any>
434
443
  : FetchRequestOptions<C["body"], C["query"], C["params"]>
435
444
  ): Promise<
436
- FetchResponse<Awaited<ReturnType<OPT[K] extends Endpoint ? OPT[K] : never>>>
445
+ FetchResponse<InferReturnType<R, OPT, K>>
437
446
  >;
438
447
 
439
448
  put(path: any, options?: any): Promise<any> {