@colyseus/sdk 0.17.38 → 0.17.40
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 +2 -2
- package/build/Client.cjs.map +1 -1
- package/build/Client.d.ts +2 -1
- package/build/Client.mjs +2 -2
- package/build/Client.mjs.map +1 -1
- package/build/Connection.cjs +1 -1
- package/build/Connection.mjs +1 -1
- package/build/HTTP.cjs +17 -3
- package/build/HTTP.cjs.map +1 -1
- package/build/HTTP.d.ts +16 -6
- package/build/HTTP.mjs +18 -3
- package/build/HTTP.mjs.map +1 -1
- package/build/Room.cjs +1 -1
- package/build/Room.mjs +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 +1 -1
- package/build/errors/Errors.mjs +1 -1
- package/build/fetchXHR.cjs +91 -0
- package/build/fetchXHR.cjs.map +1 -0
- package/build/fetchXHR.d.ts +6 -0
- package/build/fetchXHR.mjs +84 -0
- package/build/fetchXHR.mjs.map +1 -0
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.mjs +1 -1
- 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.js +96 -4
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +1 -1
- package/package.json +6 -5
- package/src/Client.ts +3 -2
- package/src/HTTP.ts +49 -36
- package/src/fetchXHR.ts +88 -0
- package/src/index.ts +1 -0
- package/dist/colyseus-cocos-creator.js +0 -9667
- package/dist/colyseus-cocos-creator.js.map +0 -1
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './legacy';
|
|
2
2
|
export { ColyseusSDK, Client, type JoinOptions, type EndpointSettings, type ClientOptions, type ISeatReservation as SeatReservation } from './Client.ts';
|
|
3
|
+
export { type FetchFn } from './HTTP.ts';
|
|
3
4
|
export { Room, type RoomAvailable } from './Room.ts';
|
|
4
5
|
export { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from "./Auth.ts";
|
|
5
6
|
export { ServerError, AbortError, MatchMakeError } from './errors/Errors.ts';
|
package/build/index.mjs
CHANGED
package/build/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import './legacy';\n\nexport { ColyseusSDK, Client, type JoinOptions, type EndpointSettings, type ClientOptions, type ISeatReservation as SeatReservation } from './Client.ts';\nexport { Room, type RoomAvailable } from './Room.ts';\nexport { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from \"./Auth.ts\";\nexport { ServerError, AbortError, MatchMakeError } from './errors/Errors.ts';\nexport { CloseCode, ErrorCode, Protocol } from '@colyseus/shared-types'; // convenience re-export / backwards compatibility\nexport type { InferRoomConstructor } from './core/utils.ts';\n\n/*\n * Serializers\n */\nimport { SchemaSerializer, getStateCallbacks } from \"./serializer/SchemaSerializer.ts\";\nimport { NoneSerializer } from \"./serializer/NoneSerializer.ts\";\nimport { registerSerializer } from './serializer/Serializer.ts';\nexport { Callbacks } from \"@colyseus/schema\";\n\nexport { registerSerializer, SchemaSerializer, getStateCallbacks };\nregisterSerializer('schema', SchemaSerializer);\nregisterSerializer('none', NoneSerializer);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import './legacy';\n\nexport { ColyseusSDK, Client, type JoinOptions, type EndpointSettings, type ClientOptions, type ISeatReservation as SeatReservation } from './Client.ts';\nexport { type FetchFn } from './HTTP.ts';\nexport { Room, type RoomAvailable } from './Room.ts';\nexport { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from \"./Auth.ts\";\nexport { ServerError, AbortError, MatchMakeError } from './errors/Errors.ts';\nexport { CloseCode, ErrorCode, Protocol } from '@colyseus/shared-types'; // convenience re-export / backwards compatibility\nexport type { InferRoomConstructor } from './core/utils.ts';\n\n/*\n * Serializers\n */\nimport { SchemaSerializer, getStateCallbacks } from \"./serializer/SchemaSerializer.ts\";\nimport { NoneSerializer } from \"./serializer/NoneSerializer.ts\";\nimport { registerSerializer } from './serializer/Serializer.ts';\nexport { Callbacks } from \"@colyseus/schema\";\n\nexport { registerSerializer, SchemaSerializer, getStateCallbacks };\nregisterSerializer('schema', SchemaSerializer);\nregisterSerializer('none', NoneSerializer);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,CAAC;AAC9C,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC;;;;"}
|
package/build/legacy.cjs
CHANGED
package/build/legacy.mjs
CHANGED
package/dist/colyseus.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.40 - @colyseus/schema 4.0.13
|
|
7
7
|
(function (global, factory) {
|
|
8
8
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
9
9
|
typeof define === 'function' && define.amd ? define('@colyseus/sdk', ['exports'], factory) :
|
|
@@ -8943,6 +8943,85 @@
|
|
|
8943
8943
|
}
|
|
8944
8944
|
}
|
|
8945
8945
|
|
|
8946
|
+
/**
|
|
8947
|
+
* Minimal fetch-compatible wrapper around XMLHttpRequest.
|
|
8948
|
+
* Used as an automatic fallback when globalThis.fetch is unavailable
|
|
8949
|
+
* (e.g. Cocos Creator Native).
|
|
8950
|
+
*/
|
|
8951
|
+
function xhrFetch(url, init) {
|
|
8952
|
+
return new Promise((resolve, reject) => {
|
|
8953
|
+
var _a;
|
|
8954
|
+
const xhr = new XMLHttpRequest();
|
|
8955
|
+
const method = (init === null || init === void 0 ? void 0 : init.method) || "GET";
|
|
8956
|
+
xhr.open(method, url.toString());
|
|
8957
|
+
xhr.withCredentials = ((init === null || init === void 0 ? void 0 : init.credentials) === "include");
|
|
8958
|
+
// Apply request headers
|
|
8959
|
+
if (init === null || init === void 0 ? void 0 : init.headers) {
|
|
8960
|
+
const headers = (init.headers instanceof Headers)
|
|
8961
|
+
? init.headers
|
|
8962
|
+
: new Headers(init.headers);
|
|
8963
|
+
headers.forEach((value, key) => {
|
|
8964
|
+
xhr.setRequestHeader(key, value);
|
|
8965
|
+
});
|
|
8966
|
+
}
|
|
8967
|
+
xhr.onload = () => {
|
|
8968
|
+
var _a;
|
|
8969
|
+
// Parse response headers
|
|
8970
|
+
const headers = new Headers();
|
|
8971
|
+
const rawHeaders = xhr.getAllResponseHeaders().trim();
|
|
8972
|
+
if (rawHeaders) {
|
|
8973
|
+
for (const line of rawHeaders.split(/[\r\n]+/)) {
|
|
8974
|
+
const idx = line.indexOf(": ");
|
|
8975
|
+
if (idx > 0) {
|
|
8976
|
+
headers.append(line.substring(0, idx), line.substring(idx + 2));
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
}
|
|
8980
|
+
const responseBody = (_a = xhr.response) !== null && _a !== void 0 ? _a : xhr.responseText;
|
|
8981
|
+
resolve(new XHRResponse(responseBody, {
|
|
8982
|
+
status: xhr.status,
|
|
8983
|
+
statusText: xhr.statusText,
|
|
8984
|
+
headers,
|
|
8985
|
+
}));
|
|
8986
|
+
};
|
|
8987
|
+
xhr.onerror = () => reject(new TypeError("Network request failed"));
|
|
8988
|
+
xhr.ontimeout = () => reject(new TypeError("Network request timed out"));
|
|
8989
|
+
xhr.send((_a = init === null || init === void 0 ? void 0 : init.body) !== null && _a !== void 0 ? _a : null);
|
|
8990
|
+
});
|
|
8991
|
+
}
|
|
8992
|
+
/**
|
|
8993
|
+
* Minimal Response-compatible class backed by XHR response data.
|
|
8994
|
+
* Implements only the surface used by HTTP.executeRequest().
|
|
8995
|
+
*/
|
|
8996
|
+
class XHRResponse {
|
|
8997
|
+
constructor(body, init) {
|
|
8998
|
+
this.body = body;
|
|
8999
|
+
this.status = init.status;
|
|
9000
|
+
this.statusText = init.statusText;
|
|
9001
|
+
this.headers = init.headers;
|
|
9002
|
+
this.ok = init.status >= 200 && init.status < 300;
|
|
9003
|
+
}
|
|
9004
|
+
json() {
|
|
9005
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9006
|
+
return typeof this.body === "string"
|
|
9007
|
+
? JSON.parse(this.body)
|
|
9008
|
+
: this.body;
|
|
9009
|
+
});
|
|
9010
|
+
}
|
|
9011
|
+
text() {
|
|
9012
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9013
|
+
return typeof this.body === "string"
|
|
9014
|
+
? this.body
|
|
9015
|
+
: JSON.stringify(this.body);
|
|
9016
|
+
});
|
|
9017
|
+
}
|
|
9018
|
+
blob() {
|
|
9019
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9020
|
+
return new Blob([this.body]);
|
|
9021
|
+
});
|
|
9022
|
+
}
|
|
9023
|
+
}
|
|
9024
|
+
|
|
8946
9025
|
function isJSONSerializable(value) {
|
|
8947
9026
|
if (value === undefined) {
|
|
8948
9027
|
return false;
|
|
@@ -8998,11 +9077,24 @@
|
|
|
8998
9077
|
return `${path}${queryParamString}`;
|
|
8999
9078
|
}
|
|
9000
9079
|
class HTTP {
|
|
9001
|
-
constructor(sdk, baseOptions) {
|
|
9080
|
+
constructor(sdk, baseOptions, fetchFn) {
|
|
9002
9081
|
// alias "del()" to "delete()"
|
|
9003
9082
|
this.del = this.delete;
|
|
9004
9083
|
this.sdk = sdk;
|
|
9005
9084
|
this.options = baseOptions;
|
|
9085
|
+
this._fetchFn = fetchFn;
|
|
9086
|
+
}
|
|
9087
|
+
/**
|
|
9088
|
+
* Lazily resolve the fetch implementation.
|
|
9089
|
+
* Falls back to XMLHttpRequest when fetch is unavailable (e.g. Cocos Creator Native).
|
|
9090
|
+
*/
|
|
9091
|
+
get fetchFn() {
|
|
9092
|
+
if (!this._fetchFn) {
|
|
9093
|
+
this._fetchFn = (typeof (globalThis.fetch) !== 'undefined')
|
|
9094
|
+
? globalThis.fetch.bind(globalThis)
|
|
9095
|
+
: xhrFetch;
|
|
9096
|
+
}
|
|
9097
|
+
return this._fetchFn;
|
|
9006
9098
|
}
|
|
9007
9099
|
request(method, path, options) {
|
|
9008
9100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -9063,7 +9155,7 @@
|
|
|
9063
9155
|
const url = getURLWithQueryParams(this.sdk['getHttpEndpoint'](path.toString()), mergedOptions);
|
|
9064
9156
|
let raw;
|
|
9065
9157
|
try {
|
|
9066
|
-
raw = yield
|
|
9158
|
+
raw = yield this.fetchFn(url, mergedOptions);
|
|
9067
9159
|
}
|
|
9068
9160
|
catch (err) {
|
|
9069
9161
|
// If it's an AbortError, re-throw as-is
|
|
@@ -9425,7 +9517,7 @@
|
|
|
9425
9517
|
}
|
|
9426
9518
|
this.http = new HTTP(this, {
|
|
9427
9519
|
headers: (options === null || options === void 0 ? void 0 : options.headers) || {},
|
|
9428
|
-
});
|
|
9520
|
+
}, options === null || options === void 0 ? void 0 : options.fetchFn);
|
|
9429
9521
|
this.auth = new Auth(this.http);
|
|
9430
9522
|
this.urlBuilder = options === null || options === void 0 ? void 0 : options.urlBuilder;
|
|
9431
9523
|
//
|