colyseus.js
Advanced tools
Comparing version 0.16.0-preview.13 to 0.16.0-preview.14
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -11,2 +11,3 @@ | ||
var Auth = require('./Auth.js'); | ||
var discord = require('./3rd_party/discord.js'); | ||
@@ -30,4 +31,5 @@ var _a; | ||
var Client = /** @class */ (function () { | ||
function Client(settings) { | ||
function Client(settings, customURLBuilder) { | ||
if (settings === void 0) { settings = DEFAULT_ENDPOINT; } | ||
var _a, _b; | ||
if (typeof (settings) === "string") { | ||
@@ -67,2 +69,12 @@ // | ||
this.auth = new Auth.Auth(this.http); | ||
this.urlBuilder = customURLBuilder; | ||
// | ||
// Discord Embedded SDK requires a custom URL builder | ||
// | ||
if (!this.urlBuilder && | ||
typeof (window) !== "undefined" && | ||
((_b = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname) === null || _b === void 0 ? void 0 : _b.includes("discordsays.com"))) { | ||
this.urlBuilder = discord.discordURLBuilder; | ||
console.log("Colyseus SDK: Discord Embedded SDK detected. Using custom URL builder."); | ||
} | ||
} | ||
@@ -270,3 +282,6 @@ Client.prototype.joinOrCreate = function (roomName, options, rootSchema) { | ||
} | ||
return "".concat(endpoint, "/").concat(room.processId, "/").concat(room.roomId, "?").concat(params.join('&')); | ||
var endpointURL = "".concat(endpoint, "/").concat(room.processId, "/").concat(room.roomId, "?").concat(params.join('&')); | ||
return (this.urlBuilder) | ||
? this.urlBuilder(new URL(endpointURL)) | ||
: endpointURL; | ||
}; | ||
@@ -276,3 +291,6 @@ Client.prototype.getHttpEndpoint = function (segments) { | ||
var path = segments.startsWith("/") ? segments : "/".concat(segments); | ||
return "".concat((this.settings.secure) ? "https" : "http", "://").concat(this.settings.hostname).concat(this.getEndpointPort()).concat(this.settings.pathname).concat(path); | ||
var endpointURL = "".concat((this.settings.secure) ? "https" : "http", "://").concat(this.settings.hostname).concat(this.getEndpointPort()).concat(this.settings.pathname).concat(path); | ||
return (this.urlBuilder) | ||
? this.urlBuilder(new URL(endpointURL)) | ||
: endpointURL; | ||
}; | ||
@@ -279,0 +297,0 @@ Client.prototype.getEndpointPort = function () { |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -12,2 +12,3 @@ | ||
var schema = require('@colyseus/schema'); | ||
var SchemaSerializer = require('./serializer/SchemaSerializer.js'); | ||
var ServerError = require('./errors/ServerError.js'); | ||
@@ -130,2 +131,6 @@ var msgpackr = require('@colyseus/msgpackr'); | ||
this.onMessageHandlers.events = {}; | ||
if (this.serializer instanceof SchemaSerializer.SchemaSerializer) { | ||
// Remove callback references | ||
this.serializer.decoder.root.callbacks = {}; | ||
} | ||
}; | ||
@@ -132,0 +137,0 @@ Room.prototype.onMessageCallback = function (event) { |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -9,3 +9,3 @@ | ||
function getStateCallbacks(room) { | ||
return schema.getStateCallbacks(room['serializer'].decoder); | ||
return schema.getDecoderStateCallbacks(room['serializer'].decoder); | ||
} | ||
@@ -12,0 +12,0 @@ var SchemaSerializer = /** @class */ (function () { |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// colyseus.js@0.16.0-preview.13 | ||
// colyseus.js@0.16.0-preview.14 | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -21,3 +21,4 @@ import { Room, RoomAvailable } from './Room'; | ||
protected settings: EndpointSettings; | ||
constructor(settings?: string | EndpointSettings); | ||
protected urlBuilder: (url: URL) => string; | ||
constructor(settings?: string | EndpointSettings, customURLBuilder?: (url: URL) => string); | ||
joinOrCreate<T>(roomName: string, options?: JoinOptions, rootSchema?: SchemaConstructor<T>): Promise<Room<T>>; | ||
@@ -24,0 +25,0 @@ create<T>(roomName: string, options?: JoinOptions, rootSchema?: SchemaConstructor<T>): Promise<Room<T>>; |
@@ -18,2 +18,3 @@ "use strict"; | ||
const Auth_1 = require("./Auth"); | ||
const discord_1 = require("./3rd_party/discord"); | ||
class MatchMakeError extends Error { | ||
@@ -33,3 +34,4 @@ constructor(message, code) { | ||
class Client { | ||
constructor(settings = DEFAULT_ENDPOINT) { | ||
constructor(settings = DEFAULT_ENDPOINT, customURLBuilder) { | ||
var _a, _b; | ||
if (typeof (settings) === "string") { | ||
@@ -69,2 +71,12 @@ // | ||
this.auth = new Auth_1.Auth(this.http); | ||
this.urlBuilder = customURLBuilder; | ||
// | ||
// Discord Embedded SDK requires a custom URL builder | ||
// | ||
if (!this.urlBuilder && | ||
typeof (window) !== "undefined" && | ||
((_b = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname) === null || _b === void 0 ? void 0 : _b.includes("discordsays.com"))) { | ||
this.urlBuilder = discord_1.discordURLBuilder; | ||
console.log("Colyseus SDK: Discord Embedded SDK detected. Using custom URL builder."); | ||
} | ||
} | ||
@@ -205,7 +217,13 @@ joinOrCreate(roomName, options = {}, rootSchema) { | ||
} | ||
return `${endpoint}/${room.processId}/${room.roomId}?${params.join('&')}`; | ||
const endpointURL = `${endpoint}/${room.processId}/${room.roomId}?${params.join('&')}`; | ||
return (this.urlBuilder) | ||
? this.urlBuilder(new URL(endpointURL)) | ||
: endpointURL; | ||
} | ||
getHttpEndpoint(segments = '') { | ||
const path = segments.startsWith("/") ? segments : `/${segments}`; | ||
return `${(this.settings.secure) ? "https" : "http"}://${this.settings.hostname}${this.getEndpointPort()}${this.settings.pathname}${path}`; | ||
const endpointURL = `${(this.settings.secure) ? "https" : "http"}://${this.settings.hostname}${this.getEndpointPort()}${this.settings.pathname}${path}`; | ||
return (this.urlBuilder) | ||
? this.urlBuilder(new URL(endpointURL)) | ||
: endpointURL; | ||
} | ||
@@ -212,0 +230,0 @@ getEndpointPort() { |
@@ -12,2 +12,3 @@ "use strict"; | ||
const schema_1 = require("@colyseus/schema"); | ||
const SchemaSerializer_1 = require("./serializer/SchemaSerializer"); | ||
const ServerError_1 = require("./errors/ServerError"); | ||
@@ -124,2 +125,6 @@ const msgpackr_1 = require("@colyseus/msgpackr"); | ||
this.onMessageHandlers.events = {}; | ||
if (this.serializer instanceof SchemaSerializer_1.SchemaSerializer) { | ||
// Remove callback references | ||
this.serializer.decoder.root.callbacks = {}; | ||
} | ||
} | ||
@@ -126,0 +131,0 @@ onMessageCallback(event) { |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
export type SchemaConstructor<T = Schema> = new (...args: any[]) => T; | ||
export declare function getStateCallbacks<T extends Schema>(room: Room<T>): import("@colyseus/schema/lib/decoder/strategy/StateCallbacks").GetCallbackProxy; | ||
export declare function getStateCallbacks<T extends Schema>(room: Room<T>): import("@colyseus/schema").GetCallbackProxy; | ||
export declare class SchemaSerializer<T extends Schema = any> implements Serializer<T> { | ||
@@ -9,0 +9,0 @@ state: T; |
@@ -6,3 +6,3 @@ "use strict"; | ||
function getStateCallbacks(room) { | ||
return (0, schema_1.getStateCallbacks)(room['serializer'].decoder); | ||
return (0, schema_1.getDecoderStateCallbacks)(room['serializer'].decoder); | ||
} | ||
@@ -9,0 +9,0 @@ exports.getStateCallbacks = getStateCallbacks; |
{ | ||
"name": "colyseus.js", | ||
"version": "0.16.0-preview.13", | ||
"version": "0.16.0-preview.14", | ||
"description": "Colyseus Multiplayer SDK for JavaScript/TypeScript", | ||
@@ -62,3 +62,3 @@ "author": "Endel Dreyer", | ||
"@colyseus/msgpackr": "^1.10.5", | ||
"@colyseus/schema": "^3.0.0-alpha.0", | ||
"@colyseus/schema": "^3.0.0-alpha.19", | ||
"httpie": "^2.0.0-next.13", | ||
@@ -65,0 +65,0 @@ "tslib": "^2.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2780251
156
23033
+ Added@colyseus/schema@3.0.16(transitive)
- Removed@colyseus/schema@3.0.17(transitive)