@colyseus/sdk 0.17.37 → 0.17.39
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 +19 -6
- package/build/HTTP.cjs.map +1 -1
- package/build/HTTP.d.ts +8 -1
- package/build/HTTP.mjs +20 -6
- 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 +98 -7
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +1 -1
- package/package.json +7 -6
- package/src/Client.ts +3 -2
- package/src/HTTP.ts +22 -5
- package/src/fetchXHR.ts +88 -0
- package/src/index.ts +1 -0
- package/dist/colyseus-cocos-creator.js +0 -9668
- package/dist/colyseus-cocos-creator.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchXHR.cjs","sources":["../src/fetchXHR.ts"],"sourcesContent":["/**\n * Minimal fetch-compatible wrapper around XMLHttpRequest.\n * Used as an automatic fallback when globalThis.fetch is unavailable\n * (e.g. Cocos Creator Native).\n */\nexport function xhrFetch(url: string | URL | Request, init?: RequestInit): Promise<Response> {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n const method = init?.method || \"GET\";\n\n xhr.open(method, url.toString());\n xhr.withCredentials = (init?.credentials === \"include\");\n\n // Apply request headers\n if (init?.headers) {\n const headers = (init.headers instanceof Headers)\n ? init.headers\n : new Headers(init.headers as HeadersInit);\n headers.forEach((value, key) => {\n xhr.setRequestHeader(key, value);\n });\n }\n\n xhr.onload = () => {\n // Parse response headers\n const headers = new Headers();\n const rawHeaders = xhr.getAllResponseHeaders().trim();\n if (rawHeaders) {\n for (const line of rawHeaders.split(/[\\r\\n]+/)) {\n const idx = line.indexOf(\": \");\n if (idx > 0) {\n headers.append(line.substring(0, idx), line.substring(idx + 2));\n }\n }\n }\n\n const responseBody = xhr.response ?? xhr.responseText;\n\n resolve(new XHRResponse(responseBody, {\n status: xhr.status,\n statusText: xhr.statusText,\n headers,\n }) as unknown as Response);\n };\n\n xhr.onerror = () => reject(new TypeError(\"Network request failed\"));\n xhr.ontimeout = () => reject(new TypeError(\"Network request timed out\"));\n\n xhr.send(init?.body as XMLHttpRequestBodyInit | null ?? null);\n });\n}\n\n/**\n * Minimal Response-compatible class backed by XHR response data.\n * Implements only the surface used by HTTP.executeRequest().\n */\nclass XHRResponse {\n readonly status: number;\n readonly statusText: string;\n readonly headers: Headers;\n readonly ok: boolean;\n\n private body: any;\n\n constructor(body: any, init: { status: number; statusText: string; headers: Headers }) {\n this.body = body;\n this.status = init.status;\n this.statusText = init.statusText;\n this.headers = init.headers;\n this.ok = init.status >= 200 && init.status < 300;\n }\n\n async json(): Promise<any> {\n return typeof this.body === \"string\"\n ? JSON.parse(this.body)\n : this.body;\n }\n\n async text(): Promise<string> {\n return typeof this.body === \"string\"\n ? this.body\n : JSON.stringify(this.body);\n }\n\n async blob(): Promise<Blob> {\n return new Blob([this.body]);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,GAA2B,EAAE,IAAkB,EAAA;IACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;;AACnC,QAAA,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE;AAChC,QAAA,MAAM,MAAM,GAAG,CAAA,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAJ,IAAI,CAAE,MAAM,KAAI,KAAK;QAEpC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;AAChC,QAAA,GAAG,CAAC,eAAe,IAAI,CAAA,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAJ,IAAI,CAAE,WAAW,MAAK,SAAS,CAAC;;QAGvD,IAAI,IAAI,aAAJ,IAAI,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAJ,IAAI,CAAE,OAAO,EAAE;YACf,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,YA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MLHttpRequest.
|
|
3
|
+
* Used as an automatic fallback when globalThis.fetch is unavailable
|
|
4
|
+
* (e.g. Cocos Creator Native).
|
|
5
|
+
*/
|
|
6
|
+
export declare function xhrFetch(url: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Copyright (c) 2026 Endel Dreyer.
|
|
2
|
+
//
|
|
3
|
+
// This software is released under the MIT License.
|
|
4
|
+
// https://opensource.org/license/MIT
|
|
5
|
+
//
|
|
6
|
+
// colyseus.js@0.17.39
|
|
7
|
+
/**
|
|
8
|
+
* Minimal fetch-compatible wrapper around XMLHttpRequest.
|
|
9
|
+
* Used as an automatic fallback when globalThis.fetch is unavailable
|
|
10
|
+
* (e.g. Cocos Creator Native).
|
|
11
|
+
*/
|
|
12
|
+
function xhrFetch(url, init) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const xhr = new XMLHttpRequest();
|
|
15
|
+
const method = init?.method || "GET";
|
|
16
|
+
xhr.open(method, url.toString());
|
|
17
|
+
xhr.withCredentials = (init?.credentials === "include");
|
|
18
|
+
// Apply request headers
|
|
19
|
+
if (init?.headers) {
|
|
20
|
+
const headers = (init.headers instanceof Headers)
|
|
21
|
+
? init.headers
|
|
22
|
+
: new Headers(init.headers);
|
|
23
|
+
headers.forEach((value, key) => {
|
|
24
|
+
xhr.setRequestHeader(key, value);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
xhr.onload = () => {
|
|
28
|
+
// Parse response headers
|
|
29
|
+
const headers = new Headers();
|
|
30
|
+
const rawHeaders = xhr.getAllResponseHeaders().trim();
|
|
31
|
+
if (rawHeaders) {
|
|
32
|
+
for (const line of rawHeaders.split(/[\r\n]+/)) {
|
|
33
|
+
const idx = line.indexOf(": ");
|
|
34
|
+
if (idx > 0) {
|
|
35
|
+
headers.append(line.substring(0, idx), line.substring(idx + 2));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const responseBody = xhr.response ?? xhr.responseText;
|
|
40
|
+
resolve(new XHRResponse(responseBody, {
|
|
41
|
+
status: xhr.status,
|
|
42
|
+
statusText: xhr.statusText,
|
|
43
|
+
headers,
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
xhr.onerror = () => reject(new TypeError("Network request failed"));
|
|
47
|
+
xhr.ontimeout = () => reject(new TypeError("Network request timed out"));
|
|
48
|
+
xhr.send(init?.body ?? null);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Minimal Response-compatible class backed by XHR response data.
|
|
53
|
+
* Implements only the surface used by HTTP.executeRequest().
|
|
54
|
+
*/
|
|
55
|
+
class XHRResponse {
|
|
56
|
+
status;
|
|
57
|
+
statusText;
|
|
58
|
+
headers;
|
|
59
|
+
ok;
|
|
60
|
+
body;
|
|
61
|
+
constructor(body, init) {
|
|
62
|
+
this.body = body;
|
|
63
|
+
this.status = init.status;
|
|
64
|
+
this.statusText = init.statusText;
|
|
65
|
+
this.headers = init.headers;
|
|
66
|
+
this.ok = init.status >= 200 && init.status < 300;
|
|
67
|
+
}
|
|
68
|
+
async json() {
|
|
69
|
+
return typeof this.body === "string"
|
|
70
|
+
? JSON.parse(this.body)
|
|
71
|
+
: this.body;
|
|
72
|
+
}
|
|
73
|
+
async text() {
|
|
74
|
+
return typeof this.body === "string"
|
|
75
|
+
? this.body
|
|
76
|
+
: JSON.stringify(this.body);
|
|
77
|
+
}
|
|
78
|
+
async blob() {
|
|
79
|
+
return new Blob([this.body]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { xhrFetch };
|
|
84
|
+
//# sourceMappingURL=fetchXHR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchXHR.mjs","sources":["../src/fetchXHR.ts"],"sourcesContent":["/**\n * Minimal fetch-compatible wrapper around XMLHttpRequest.\n * Used as an automatic fallback when globalThis.fetch is unavailable\n * (e.g. Cocos Creator Native).\n */\nexport function xhrFetch(url: string | URL | Request, init?: RequestInit): Promise<Response> {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n const method = init?.method || \"GET\";\n\n xhr.open(method, url.toString());\n xhr.withCredentials = (init?.credentials === \"include\");\n\n // Apply request headers\n if (init?.headers) {\n const headers = (init.headers instanceof Headers)\n ? init.headers\n : new Headers(init.headers as HeadersInit);\n headers.forEach((value, key) => {\n xhr.setRequestHeader(key, value);\n });\n }\n\n xhr.onload = () => {\n // Parse response headers\n const headers = new Headers();\n const rawHeaders = xhr.getAllResponseHeaders().trim();\n if (rawHeaders) {\n for (const line of rawHeaders.split(/[\\r\\n]+/)) {\n const idx = line.indexOf(\": \");\n if (idx > 0) {\n headers.append(line.substring(0, idx), line.substring(idx + 2));\n }\n }\n }\n\n const responseBody = xhr.response ?? xhr.responseText;\n\n resolve(new XHRResponse(responseBody, {\n status: xhr.status,\n statusText: xhr.statusText,\n headers,\n }) as unknown as Response);\n };\n\n xhr.onerror = () => reject(new TypeError(\"Network request failed\"));\n xhr.ontimeout = () => reject(new TypeError(\"Network request timed out\"));\n\n xhr.send(init?.body as XMLHttpRequestBodyInit | null ?? null);\n });\n}\n\n/**\n * Minimal Response-compatible class backed by XHR response data.\n * Implements only the surface used by HTTP.executeRequest().\n */\nclass XHRResponse {\n readonly status: number;\n readonly statusText: string;\n readonly headers: Headers;\n readonly ok: boolean;\n\n private body: any;\n\n constructor(body: any, init: { status: number; statusText: string; headers: Headers }) {\n this.body = body;\n this.status = init.status;\n this.statusText = init.statusText;\n this.headers = init.headers;\n this.ok = init.status >= 200 && init.status < 300;\n }\n\n async json(): Promise<any> {\n return typeof this.body === \"string\"\n ? JSON.parse(this.body)\n : this.body;\n }\n\n async text(): Promise<string> {\n return typeof this.body === \"string\"\n ? this.body\n : JSON.stringify(this.body);\n }\n\n async blob(): Promise<Blob> {\n return new Blob([this.body]);\n }\n}\n"],"names":[],"mappings":";;;;;;AA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AAC,IAAI,KAAK;cACtB,IAAI,CAAC;cACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;IACnC;AAEA,IAAA,MAAM,IAAI,GAAA;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC;AACH;;;;"}
|
package/build/index.cjs
CHANGED
package/build/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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":["registerSerializer","SchemaSerializer","NoneSerializer"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","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":["registerSerializer","SchemaSerializer","NoneSerializer"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBAA,6BAAkB,CAAC,QAAQ,EAAEC,iCAAgB,CAAC;AAC9CD,6BAAkB,CAAC,MAAM,EAAEE,6BAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
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.39 - @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
|
|
@@ -9078,11 +9170,10 @@
|
|
|
9078
9170
|
}
|
|
9079
9171
|
const contentType = raw.headers.get("content-type");
|
|
9080
9172
|
let data;
|
|
9081
|
-
|
|
9082
|
-
if (contentType === null || contentType === void 0 ? void 0 : contentType.indexOf("json")) {
|
|
9173
|
+
if (contentType === null || contentType === void 0 ? void 0 : contentType.includes("json")) {
|
|
9083
9174
|
data = yield raw.json();
|
|
9084
9175
|
}
|
|
9085
|
-
else if (contentType === null || contentType === void 0 ? void 0 : contentType.
|
|
9176
|
+
else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes("text")) {
|
|
9086
9177
|
data = yield raw.text();
|
|
9087
9178
|
}
|
|
9088
9179
|
else {
|
|
@@ -9426,7 +9517,7 @@
|
|
|
9426
9517
|
}
|
|
9427
9518
|
this.http = new HTTP(this, {
|
|
9428
9519
|
headers: (options === null || options === void 0 ? void 0 : options.headers) || {},
|
|
9429
|
-
});
|
|
9520
|
+
}, options === null || options === void 0 ? void 0 : options.fetchFn);
|
|
9430
9521
|
this.auth = new Auth(this.http);
|
|
9431
9522
|
this.urlBuilder = options === null || options === void 0 ? void 0 : options.urlBuilder;
|
|
9432
9523
|
//
|