@colyseus/core 0.15.15-preview.0 → 0.15.15

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/Utils.mjs DELETED
@@ -1,76 +0,0 @@
1
- import nanoid from "nanoid";
2
- import { debugAndPrintError } from "./Debug";
3
- import { EventEmitter } from "events";
4
- const REMOTE_ROOM_SHORT_TIMEOUT = Number(process.env.COLYSEUS_PRESENCE_SHORT_TIMEOUT || 2e3);
5
- function generateId(length = 9) {
6
- return nanoid(length);
7
- }
8
- const signals = ["SIGINT", "SIGTERM", "SIGUSR2"];
9
- function registerGracefulShutdown(callback) {
10
- process.on("uncaughtException", (err) => {
11
- debugAndPrintError(err);
12
- callback(err);
13
- });
14
- signals.forEach((signal) => process.once(signal, () => callback()));
15
- }
16
- function retry(cb, maxRetries = 3, errorWhiteList = [], retries = 0) {
17
- return new Promise((resolve, reject) => {
18
- cb().then(resolve).catch((e) => {
19
- if (errorWhiteList.indexOf(e.constructor) !== -1 && retries++ < maxRetries) {
20
- setTimeout(() => {
21
- retry(cb, maxRetries, errorWhiteList, retries).then(resolve).catch((e2) => reject(e2));
22
- }, Math.floor(Math.random() * Math.pow(2, retries) * 400));
23
- } else {
24
- reject(e);
25
- }
26
- });
27
- });
28
- }
29
- class Deferred {
30
- constructor() {
31
- this.promise = new Promise((resolve, reject) => {
32
- this.resolve = resolve;
33
- this.reject = reject;
34
- });
35
- }
36
- then(func) {
37
- return this.promise.then.apply(this.promise, arguments);
38
- }
39
- catch(func) {
40
- return this.promise.catch(func);
41
- }
42
- }
43
- function spliceOne(arr, index) {
44
- if (index === -1 || index >= arr.length) {
45
- return false;
46
- }
47
- const len = arr.length - 1;
48
- for (let i = index; i < len; i++) {
49
- arr[i] = arr[i + 1];
50
- }
51
- arr.length = len;
52
- return true;
53
- }
54
- function merge(a, ...objs) {
55
- for (let i = 0, len = objs.length; i < len; i++) {
56
- const b = objs[i];
57
- for (const key in b) {
58
- if (b.hasOwnProperty(key)) {
59
- a[key] = b[key];
60
- }
61
- }
62
- }
63
- return a;
64
- }
65
- class DummyServer extends EventEmitter {
66
- }
67
- export {
68
- Deferred,
69
- DummyServer,
70
- REMOTE_ROOM_SHORT_TIMEOUT,
71
- generateId,
72
- merge,
73
- registerGracefulShutdown,
74
- retry,
75
- spliceOne
76
- };
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/Utils.ts"],
4
- "sourcesContent": ["import nanoid from 'nanoid';\n\nimport { debugAndPrintError } from './Debug';\nimport { EventEmitter } from \"events\";\nimport { ServerOpts, Socket } from \"net\";\n\n// remote room call timeouts\nexport const REMOTE_ROOM_SHORT_TIMEOUT = Number(process.env.COLYSEUS_PRESENCE_SHORT_TIMEOUT || 2000);\n\nexport function generateId(length: number = 9) {\n return nanoid(length);\n}\n\n//\n// nodemon sends SIGUSR2 before reloading\n// (https://github.com/remy/nodemon#controlling-shutdown-of-your-script)\n//\nconst signals: NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGUSR2'];\n\nexport function registerGracefulShutdown(callback: (err?: Error) => void) {\n /**\n * Gracefully shutdown on uncaught errors\n */\n process.on('uncaughtException', (err) => {\n debugAndPrintError(err);\n callback(err);\n });\n\n signals.forEach((signal) =>\n process.once(signal, () => callback()));\n}\n\nexport function retry<T = any>(\n cb: Function,\n maxRetries: number = 3,\n errorWhiteList: any[] = [],\n retries: number = 0,\n) {\n return new Promise<T>((resolve, reject) => {\n cb()\n .then(resolve)\n .catch((e) => {\n if (\n errorWhiteList.indexOf(e.constructor) !== -1 &&\n retries++ < maxRetries\n ) {\n setTimeout(() => {\n retry<T>(cb, maxRetries, errorWhiteList, retries).\n then(resolve).\n catch((e2) => reject(e2));\n }, Math.floor(Math.random() * Math.pow(2, retries) * 400));\n\n } else {\n reject(e);\n }\n });\n });\n}\n\nexport class Deferred<T= any> {\n public promise: Promise<T>;\n\n public resolve: Function;\n public reject: Function;\n\n constructor() {\n this.promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n\n public then(func: (value: T) => any) {\n return this.promise.then.apply(this.promise, arguments);\n }\n\n public catch(func: (value: any) => any) {\n return this.promise.catch(func);\n }\n\n}\n\nexport function spliceOne(arr: any[], index: number): boolean {\n // manually splice availableRooms array\n // http://jsperf.com/manual-splice\n if (index === -1 || index >= arr.length) {\n return false;\n }\n\n const len = arr.length - 1;\n\n for (let i = index; i < len; i++) {\n arr[i] = arr[i + 1];\n }\n\n arr.length = len;\n\n return true;\n}\n\nexport function merge(a: any, ...objs: any[]): any {\n for (let i = 0, len = objs.length; i < len; i++) {\n const b = objs[i];\n for (const key in b) {\n if (b.hasOwnProperty(key)) {\n a[key] = b[key];\n }\n }\n }\n return a;\n}\n\nexport declare interface DummyServer {\n constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);\n\n listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;\n close(callback?: (err?: Error) => void): this;\n}\n\nexport class DummyServer extends EventEmitter {}\n\n"],
5
- "mappings": "AAAA,OAAO,YAAY;AAEnB,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAItB,MAAM,4BAA4B,OAAO,QAAQ,IAAI,mCAAmC,GAAI;AAE5F,SAAS,WAAW,SAAiB,GAAG;AAC7C,SAAO,OAAO,MAAM;AACtB;AAMA,MAAM,UAA4B,CAAC,UAAU,WAAW,SAAS;AAE1D,SAAS,yBAAyB,UAAiC;AAIxE,UAAQ,GAAG,qBAAqB,CAAC,QAAQ;AACvC,uBAAmB,GAAG;AACtB,aAAS,GAAG;AAAA,EACd,CAAC;AAED,UAAQ,QAAQ,CAAC,WACf,QAAQ,KAAK,QAAQ,MAAM,SAAS,CAAC,CAAC;AAC1C;AAEO,SAAS,MACd,IACA,aAAqB,GACrB,iBAAwB,CAAC,GACzB,UAAkB,GAClB;AACA,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,OAAG,EACA,KAAK,OAAO,EACZ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6
- "names": []
7
- }
package/build/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export type Type<T> = new (...args: any[]) => T;
package/build/types.js DELETED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/types.ts"],
4
- "sourcesContent": ["export type Type<T> = new (...args: any[]) => T;\n"],
5
- "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
- "names": []
7
- }
package/build/types.mjs DELETED
File without changes
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }