@colyseus/monitor 0.16.4 → 0.16.6
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/ext/Room.mjs +2 -22
- package/build/ext/Room.mjs.map +1 -1
- package/build/index.js +3 -3
- package/build/index.js.map +2 -2
- package/build/index.mjs +1 -2
- package/build/index.mjs.map +2 -2
- package/build/static/bundle.js +20 -20
- package/build/static/bundle.js.map +1 -1
- package/build.mjs +1 -2
- package/package.json +2 -2
- package/src-backend/index.ts +3 -1
package/build/ext/Room.mjs
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
1
|
// src-backend/ext/Room.ts
|
|
22
2
|
import { Room } from "@colyseus/core";
|
|
23
3
|
function getStateSize(room) {
|
|
@@ -40,7 +20,7 @@ Room.prototype.getRoomListData = async function() {
|
|
|
40
20
|
const elapsedTime = this.clock.elapsedTime;
|
|
41
21
|
const locked = this.locked;
|
|
42
22
|
const data = this.getAvailableData();
|
|
43
|
-
return
|
|
23
|
+
return { ...data, locked, elapsedTime, stateSize };
|
|
44
24
|
};
|
|
45
25
|
Room.prototype.getInspectData = async function() {
|
|
46
26
|
const state = this.state;
|
|
@@ -52,7 +32,7 @@ Room.prototype.getInspectData = async function() {
|
|
|
52
32
|
elapsedTime: roomElapsedTime - client._joinedAt
|
|
53
33
|
}));
|
|
54
34
|
const locked = this.locked;
|
|
55
|
-
return
|
|
35
|
+
return { ...data, locked, clients, state, stateSize };
|
|
56
36
|
};
|
|
57
37
|
Room.prototype._forceClientDisconnect = async function(sessionId) {
|
|
58
38
|
for (let i = 0; i < this.clients.length; i++) {
|
package/build/ext/Room.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src-backend/ext/Room.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Monkey-patch Colyseus' default behaviour\n//\nimport { Room, Client, ClientPrivate } from \"@colyseus/core\";\n\nfunction getStateSize(room) {\n // TODO: `Serializer<T>` should provide a method for this (e.g. `serializer.hasState()`)\n const hasState = (\n room._serializer.encoder || // schema v3\n room._serializer.state || // schema v2\n room._serializer.previousState // legacy-fossil-delta\n );\n const fullState = hasState && room._serializer.getFullState();\n return fullState && (fullState.byteLength || fullState.length) || 0;\n}\n\n(<any>Room.prototype).getAvailableData = function () {\n return {\n clients: this.clients.length,\n maxClients: this.maxClients,\n metadata: this.metadata,\n roomId: this.roomId,\n };\n};\n\n(<any>Room.prototype).getRoomListData = async function () {\n const stateSize = getStateSize(this);\n const elapsedTime = this.clock.elapsedTime;\n const locked = this.locked;\n const data = this.getAvailableData();\n\n return { ...data, locked, elapsedTime, stateSize };\n};\n\n(<any>Room.prototype).getInspectData = async function () {\n const state = this.state;\n const stateSize = getStateSize(this);\n const roomElapsedTime = this.clock.elapsedTime;\n\n const data = this.getAvailableData();\n const clients = this.clients.map((client: Client & ClientPrivate) => ({\n sessionId: client.sessionId,\n elapsedTime: roomElapsedTime - client._joinedAt\n }));\n const locked = this.locked;\n\n return { ...data, locked, clients, state, stateSize };\n};\n\n// Actions\n(<any>Room.prototype)._forceClientDisconnect = async function (sessionId) {\n for (let i = 0; i < this.clients.length; i++) {\n if (this.clients[i].sessionId === sessionId) {\n this.clients[i].leave();\n break;\n }\n }\n};\n\n(<any>Room.prototype)._sendMessageToClient = async function (sessionId, type, data) {\n for (let i = 0; i < this.clients.length; i++) {\n if (this.clients[i].sessionId === sessionId) {\n this.clients[i].send(type, data);\n break;\n }\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAGA,SAAS,YAAmC;AAE5C,SAAS,aAAa,MAAM;AAExB,QAAM,WACJ,KAAK,YAAY;AAAA,EACjB,KAAK,YAAY;AAAA,EACjB,KAAK,YAAY;AAEnB,QAAM,YAAY,YAAY,KAAK,YAAY,aAAa;AAC5D,SAAO,cAAc,UAAU,cAAc,UAAU,WAAW;AACtE;AAEM,KAAK,UAAW,mBAAmB,WAAY;AACjD,SAAO;AAAA,IACH,SAAS,KAAK,QAAQ;AAAA,IACtB,YAAY,KAAK;AAAA,IACjB,UAAU,KAAK;AAAA,IACf,QAAQ,KAAK;AAAA,EACjB;AACJ;AAEM,KAAK,UAAW,kBAAkB,iBAAkB;AACtD,QAAM,YAAY,aAAa,IAAI;AACnC,QAAM,cAAc,KAAK,MAAM;AAC/B,QAAM,SAAS,KAAK;AACpB,QAAM,OAAO,KAAK,iBAAiB;AAEnC,SAAO,EAAE,GAAG,MAAM,QAAQ,aAAa,UAAU;AACrD;AAEM,KAAK,UAAW,iBAAiB,iBAAkB;AACrD,QAAM,QAAQ,KAAK;AACnB,QAAM,YAAY,aAAa,IAAI;AACnC,QAAM,kBAAkB,KAAK,MAAM;AAEnC,QAAM,OAAO,KAAK,iBAAiB;AACnC,QAAM,UAAU,KAAK,QAAQ,IAAI,CAAC,YAAoC;AAAA,IAClE,WAAW,OAAO;AAAA,IAClB,aAAa,kBAAkB,OAAO;AAAA,EAC1C,EAAE;AACF,QAAM,SAAS,KAAK;AAEpB,SAAO,EAAE,GAAG,MAAM,QAAQ,SAAS,OAAO,UAAU;AACxD;AAGM,KAAK,UAAW,yBAAyB,eAAgB,WAAW;AACtE,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK;AAC1C,QAAI,KAAK,QAAQ,CAAC,EAAE,cAAc,WAAW;AACzC,WAAK,QAAQ,CAAC,EAAE,MAAM;AACtB;AAAA,IACJ;AAAA,EACJ;AACJ;AAEM,KAAK,UAAW,uBAAuB,eAAgB,WAAW,MAAM,MAAM;AAChF,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK;AAC1C,QAAI,KAAK,QAAQ,CAAC,EAAE,cAAc,WAAW;AACzC,WAAK,QAAQ,CAAC,EAAE,KAAK,MAAM,IAAI;AAC/B;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/index.js
CHANGED
|
@@ -25,11 +25,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var
|
|
29
|
-
__export(
|
|
28
|
+
var index_exports = {};
|
|
29
|
+
__export(index_exports, {
|
|
30
30
|
monitor: () => monitor
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
33
|
var import_express = __toESM(require("express"));
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_api = require("./api.js");
|
package/build/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src-backend/index.ts"],
|
|
4
|
-
"sourcesContent": ["import express from 'express';\nimport path from 'path';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AACpB,kBAAiB;
|
|
4
|
+
"sourcesContent": ["import express from 'express';\nimport path from 'path';\n\n// required for ESM support. (esbuild uses it)\nimport { fileURLToPath } from 'url';\n\nimport { getAPI } from './api.js';\nimport './ext/Room.js';\n\nconst frontendDirectory = path.resolve(__dirname, \"..\", \"build\", \"static\");\n\nexport interface MonitorOptions {\n columns: Array<\n 'roomId' |\n 'name' |\n 'clients' |\n 'maxClients' |\n 'locked' |\n 'elapsedTime' |\n { metadata: string } |\n 'processId' |\n \"publicAddress\"\n >\n}\n\n/**\n * TODO: expose the `router` instead on next major version.\n */\nexport function monitor (opts: Partial<MonitorOptions> = {}): express.Router {\n const router = express.Router();\n router.use(express.static(frontendDirectory));\n router.use('/api', getAPI(opts));\n return router;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AACpB,kBAAiB;AAKjB,iBAAuB;AACvB,kBAAO;AAEP,MAAM,oBAAoB,YAAAA,QAAK,QAAQ,WAAW,MAAM,SAAS,QAAQ;AAmBlE,SAAS,QAAS,OAAgC,CAAC,GAAmB;AACzE,QAAM,SAAS,eAAAC,QAAQ,OAAO;AAC9B,SAAO,IAAI,eAAAA,QAAQ,OAAO,iBAAiB,CAAC;AAC5C,SAAO,IAAI,YAAQ,mBAAO,IAAI,CAAC;AAC/B,SAAO;AACX;",
|
|
6
6
|
"names": ["path", "express"]
|
|
7
7
|
}
|
package/build/index.mjs
CHANGED
|
@@ -4,8 +4,7 @@ import path from "path";
|
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { getAPI } from "./api.mjs";
|
|
6
6
|
import "./ext/Room.mjs";
|
|
7
|
-
var
|
|
8
|
-
var frontendDirectory = path.resolve(path.dirname(fileURLToPath(import_meta.url)), "..", "build", "static");
|
|
7
|
+
var frontendDirectory = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "build", "static");
|
|
9
8
|
function monitor(opts = {}) {
|
|
10
9
|
const router = express.Router();
|
|
11
10
|
router.use(express.static(frontendDirectory));
|
package/build/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src-backend/index.ts"],
|
|
4
|
-
"sourcesContent": ["import express from 'express';\nimport path from 'path';\
|
|
5
|
-
"mappings": ";AAAA,OAAO,aAAa;AACpB,OAAO,UAAU;
|
|
4
|
+
"sourcesContent": ["import express from 'express';\nimport path from 'path';\n\n// required for ESM support. (esbuild uses it)\nimport { fileURLToPath } from 'url';\n\nimport { getAPI } from './api.js';\nimport './ext/Room.js';\n\nconst frontendDirectory = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"..\", \"build\", \"static\");\n\nexport interface MonitorOptions {\n columns: Array<\n 'roomId' |\n 'name' |\n 'clients' |\n 'maxClients' |\n 'locked' |\n 'elapsedTime' |\n { metadata: string } |\n 'processId' |\n \"publicAddress\"\n >\n}\n\n/**\n * TODO: expose the `router` instead on next major version.\n */\nexport function monitor (opts: Partial<MonitorOptions> = {}): express.Router {\n const router = express.Router();\n router.use(express.static(frontendDirectory));\n router.use('/api', getAPI(opts));\n return router;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,aAAa;AACpB,OAAO,UAAU;AAGjB,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AACvB,OAAO;AAEP,IAAM,oBAAoB,KAAK,QAAQ,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,MAAM,SAAS,QAAQ;AAmBrG,SAAS,QAAS,OAAgC,CAAC,GAAmB;AACzE,QAAM,SAAS,QAAQ,OAAO;AAC9B,SAAO,IAAI,QAAQ,OAAO,iBAAiB,CAAC;AAC5C,SAAO,IAAI,QAAQ,OAAO,IAAI,CAAC;AAC/B,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|