@colyseus/sdk 0.17.16 → 0.17.18
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/build/3rd_party/discord.cjs +1 -1
- package/build/3rd_party/discord.mjs +1 -1
- package/build/Auth.cjs +1 -1
- package/build/Auth.mjs +1 -1
- package/build/Client.cjs +20 -26
- package/build/Client.cjs.map +1 -1
- package/build/Client.d.ts +0 -4
- package/build/Client.mjs +22 -28
- package/build/Client.mjs.map +1 -1
- package/build/Connection.cjs +1 -1
- package/build/Connection.mjs +1 -1
- package/build/HTTP.cjs +20 -19
- package/build/HTTP.cjs.map +1 -1
- package/build/HTTP.d.ts +2 -18
- package/build/HTTP.mjs +19 -18
- package/build/HTTP.mjs.map +1 -1
- package/build/Protocol.cjs +1 -1
- package/build/Protocol.mjs +1 -1
- package/build/Room.cjs +1 -1
- package/build/Room.cjs.map +1 -1
- package/build/Room.d.ts +6 -5
- package/build/Room.mjs +1 -1
- package/build/Room.mjs.map +1 -1
- package/build/Storage.cjs +1 -1
- package/build/Storage.mjs +1 -1
- package/build/core/nanoevents.cjs +1 -1
- package/build/core/nanoevents.mjs +1 -1
- package/build/core/signal.cjs +1 -1
- package/build/core/signal.mjs +1 -1
- package/build/core/utils.cjs +1 -1
- package/build/core/utils.mjs +1 -1
- package/build/debug.cjs +1 -1
- package/build/debug.mjs +1 -1
- package/build/errors/Errors.cjs +17 -2
- package/build/errors/Errors.cjs.map +1 -1
- package/build/errors/Errors.d.ts +15 -2
- package/build/errors/Errors.mjs +22 -3
- package/build/errors/Errors.mjs.map +1 -1
- package/build/index.cjs +3 -2
- package/build/index.cjs.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.mjs +3 -3
- package/build/index.mjs.map +1 -1
- package/build/legacy.cjs +1 -1
- package/build/legacy.mjs +1 -1
- package/build/serializer/NoneSerializer.cjs +1 -1
- package/build/serializer/NoneSerializer.mjs +1 -1
- package/build/serializer/SchemaSerializer.cjs +1 -1
- package/build/serializer/SchemaSerializer.mjs +1 -1
- package/build/serializer/Serializer.cjs +1 -1
- package/build/serializer/Serializer.mjs +1 -1
- package/build/transport/H3Transport.cjs +1 -1
- package/build/transport/H3Transport.mjs +1 -1
- package/build/transport/WebSocketTransport.cjs +1 -1
- package/build/transport/WebSocketTransport.mjs +1 -1
- package/dist/colyseus-cocos-creator.js +61 -44
- package/dist/colyseus-cocos-creator.js.map +1 -1
- package/dist/colyseus.js +61 -44
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +54 -44
- package/dist/debug.js.map +1 -1
- package/package.json +3 -3
- package/src/Client.ts +20 -28
- package/src/HTTP.ts +20 -40
- package/src/Room.ts +11 -10
- package/src/errors/Errors.ts +33 -11
- package/src/index.ts +2 -2
package/dist/debug.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.18
|
|
7
7
|
(function (sharedTypes, schema, msgpackr, NodeWebSocket) {
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
@@ -411,10 +411,16 @@
|
|
|
411
411
|
};
|
|
412
412
|
|
|
413
413
|
class ServerError extends Error {
|
|
414
|
-
constructor(code, message) {
|
|
414
|
+
constructor(code, message, opts) {
|
|
415
415
|
super(message);
|
|
416
416
|
this.name = "ServerError";
|
|
417
417
|
this.code = code;
|
|
418
|
+
if (opts) {
|
|
419
|
+
this.headers = opts.headers;
|
|
420
|
+
this.status = opts.status;
|
|
421
|
+
this.response = opts.response;
|
|
422
|
+
this.data = opts.data;
|
|
423
|
+
}
|
|
418
424
|
}
|
|
419
425
|
}
|
|
420
426
|
class AbortError extends Error {
|
|
@@ -423,6 +429,14 @@
|
|
|
423
429
|
this.name = "AbortError";
|
|
424
430
|
}
|
|
425
431
|
}
|
|
432
|
+
class MatchMakeError extends Error {
|
|
433
|
+
constructor(message, code) {
|
|
434
|
+
super(message);
|
|
435
|
+
this.code = code;
|
|
436
|
+
this.name = "MatchMakeError";
|
|
437
|
+
Object.setPrototypeOf(this, MatchMakeError.prototype);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
426
440
|
|
|
427
441
|
class H3TransportTransport {
|
|
428
442
|
constructor(events) {
|
|
@@ -1305,7 +1319,7 @@
|
|
|
1305
1319
|
}
|
|
1306
1320
|
executeRequest(method, path, requestOptions) {
|
|
1307
1321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1308
|
-
var _a;
|
|
1322
|
+
var _a, _b, _c;
|
|
1309
1323
|
//
|
|
1310
1324
|
// FIXME: if FormData is provided, merging "baseOptions.body" with
|
|
1311
1325
|
// "options.body" will not work as intended
|
|
@@ -1340,9 +1354,9 @@
|
|
|
1340
1354
|
body,
|
|
1341
1355
|
method });
|
|
1342
1356
|
const url = getURLWithQueryParams(this.sdk['getHttpEndpoint'](path.toString()), mergedOptions);
|
|
1343
|
-
let
|
|
1357
|
+
let raw;
|
|
1344
1358
|
try {
|
|
1345
|
-
|
|
1359
|
+
raw = yield fetch(url, mergedOptions);
|
|
1346
1360
|
}
|
|
1347
1361
|
catch (err) {
|
|
1348
1362
|
// If it's an AbortError, re-throw as-is
|
|
@@ -1351,35 +1365,36 @@
|
|
|
1351
1365
|
}
|
|
1352
1366
|
// Re-throw with network error code at top level (e.g. ECONNREFUSED)
|
|
1353
1367
|
const networkError = new ServerError(((_a = err.cause) === null || _a === void 0 ? void 0 : _a.code) || err.code, err.message);
|
|
1368
|
+
networkError.response = raw;
|
|
1354
1369
|
networkError.cause = err.cause;
|
|
1355
1370
|
throw networkError;
|
|
1356
1371
|
}
|
|
1357
|
-
const contentType =
|
|
1372
|
+
const contentType = raw.headers.get("content-type");
|
|
1358
1373
|
let data;
|
|
1359
|
-
let error = null;
|
|
1360
1374
|
// TODO: improve content-type detection here!
|
|
1361
1375
|
if (contentType === null || contentType === void 0 ? void 0 : contentType.indexOf("json")) {
|
|
1362
|
-
data = yield
|
|
1376
|
+
data = yield raw.json();
|
|
1363
1377
|
}
|
|
1364
1378
|
else if (contentType === null || contentType === void 0 ? void 0 : contentType.indexOf("text")) {
|
|
1365
|
-
data = yield
|
|
1379
|
+
data = yield raw.text();
|
|
1366
1380
|
}
|
|
1367
1381
|
else {
|
|
1368
|
-
data = yield
|
|
1382
|
+
data = yield raw.blob();
|
|
1369
1383
|
}
|
|
1370
|
-
if (!
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1384
|
+
if (!raw.ok) {
|
|
1385
|
+
throw new ServerError((_b = data.code) !== null && _b !== void 0 ? _b : raw.status, (_c = data.message) !== null && _c !== void 0 ? _c : raw.statusText, {
|
|
1386
|
+
headers: raw.headers,
|
|
1387
|
+
status: raw.status,
|
|
1388
|
+
response: raw,
|
|
1389
|
+
data
|
|
1390
|
+
});
|
|
1374
1391
|
}
|
|
1375
1392
|
return {
|
|
1376
|
-
|
|
1377
|
-
headers: response.headers,
|
|
1393
|
+
raw,
|
|
1378
1394
|
data,
|
|
1379
|
-
|
|
1380
|
-
status:
|
|
1381
|
-
statusText:
|
|
1382
|
-
response,
|
|
1395
|
+
headers: raw.headers,
|
|
1396
|
+
status: raw.status,
|
|
1397
|
+
statusText: raw.statusText,
|
|
1383
1398
|
};
|
|
1384
1399
|
});
|
|
1385
1400
|
}
|
|
@@ -1657,14 +1672,6 @@
|
|
|
1657
1672
|
}
|
|
1658
1673
|
|
|
1659
1674
|
var _a;
|
|
1660
|
-
class MatchMakeError extends Error {
|
|
1661
|
-
constructor(message, code) {
|
|
1662
|
-
super(message);
|
|
1663
|
-
this.code = code;
|
|
1664
|
-
this.name = "MatchMakeError";
|
|
1665
|
-
Object.setPrototypeOf(this, MatchMakeError.prototype);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
1675
|
// - React Native does not provide `window.location`
|
|
1669
1676
|
// - Cocos Creator (Native) does not provide `window.location.hostname`
|
|
1670
1677
|
const DEFAULT_ENDPOINT = (typeof (window) !== "undefined" && typeof ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname) !== "undefined")
|
|
@@ -1844,24 +1851,27 @@
|
|
|
1844
1851
|
}
|
|
1845
1852
|
createMatchMakeRequest(method_1, roomName_1) {
|
|
1846
1853
|
return __awaiter(this, arguments, void 0, function* (method, roomName, options = {}, rootSchema) {
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
//
|
|
1857
|
-
|
|
1854
|
+
try {
|
|
1855
|
+
const httpResponse = yield this.http.post(`/matchmake/${method}/${roomName}`, {
|
|
1856
|
+
headers: {
|
|
1857
|
+
'Accept': 'application/json',
|
|
1858
|
+
'Content-Type': 'application/json'
|
|
1859
|
+
},
|
|
1860
|
+
body: options
|
|
1861
|
+
});
|
|
1862
|
+
const response = httpResponse.data;
|
|
1863
|
+
// forward reconnection token during "reconnect" methods.
|
|
1864
|
+
if (method === "reconnect") {
|
|
1865
|
+
response.reconnectionToken = options.reconnectionToken;
|
|
1866
|
+
}
|
|
1867
|
+
return yield this.consumeSeatReservation(response, rootSchema);
|
|
1858
1868
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1869
|
+
catch (error) {
|
|
1870
|
+
if (error instanceof ServerError) {
|
|
1871
|
+
throw new MatchMakeError(error.message, error.code);
|
|
1872
|
+
}
|
|
1873
|
+
throw error;
|
|
1863
1874
|
}
|
|
1864
|
-
return yield this.consumeSeatReservation(response, rootSchema);
|
|
1865
1875
|
});
|
|
1866
1876
|
}
|
|
1867
1877
|
createRoom(roomName, rootSchema) {
|