@colyseus/monitor 0.17.6 → 0.17.8
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/api.cjs +1 -1
- package/build/api.cjs.map +2 -2
- package/build/api.mjs +1 -1
- package/build/api.mjs.map +2 -2
- package/build/ext/Room.cjs +37 -0
- package/build/ext/Room.cjs.map +2 -2
- package/build/ext/Room.mjs +37 -0
- package/build/ext/Room.mjs.map +2 -2
- package/build/static/assets/index-C4SPBCkT.css +1 -0
- package/build/static/assets/index-DsiKUEz6.js +247 -0
- package/build/static/assets/index-DsiKUEz6.js.map +1 -0
- package/build/static/index.html +2 -2
- package/package.json +3 -4
- package/src-backend/api.ts +1 -1
- package/src-backend/ext/Room.ts +40 -0
- package/README.md +0 -57
- package/build/static/assets/index-8wRFHIxm.css +0 -1
- package/build/static/assets/index-BJyvzHj3.js +0 -248
- package/build/static/assets/index-BJyvzHj3.js.map +0 -1
package/build/static/index.html
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
7
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
8
8
|
<title>Colyseus Stats</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-DsiKUEz6.js"></script>
|
|
10
|
+
<link rel="stylesheet" crossorigin href="./assets/index-C4SPBCkT.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colyseus/monitor",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.8",
|
|
4
4
|
"description": "Web Monitoring Panel for Colyseus",
|
|
5
5
|
"input": "./src/index.ts",
|
|
6
6
|
"main": "./build/index.cjs",
|
|
@@ -59,16 +59,15 @@
|
|
|
59
59
|
"history": "^5.3.0",
|
|
60
60
|
"react": "^18.2.0",
|
|
61
61
|
"react-dom": "^18.2.0",
|
|
62
|
-
"
|
|
62
|
+
"json-edit-react": "^1.17.0",
|
|
63
63
|
"react-router-dom": "^4.2.2",
|
|
64
|
-
"react18-json-view": "^0.2.6",
|
|
65
64
|
"typescript": "^5.9.3",
|
|
66
65
|
"vite": "^5.0.11"
|
|
67
66
|
},
|
|
68
67
|
"dependencies": {
|
|
69
68
|
"express": ">=4.16.0",
|
|
70
69
|
"node-os-utils": "^2.0.0",
|
|
71
|
-
"@colyseus/core": "^0.17.
|
|
70
|
+
"@colyseus/core": "^0.17.39"
|
|
72
71
|
},
|
|
73
72
|
"scripts": {
|
|
74
73
|
"start": "vite",
|
package/src-backend/api.ts
CHANGED
|
@@ -82,7 +82,7 @@ export function getAPI (opts: Partial<MonitorOptions>): express.Router {
|
|
|
82
82
|
|
|
83
83
|
try {
|
|
84
84
|
const data = await matchMaker.remoteRoomCall(roomId, method, args);
|
|
85
|
-
res.json(data);
|
|
85
|
+
res.json(data ?? {});
|
|
86
86
|
} catch (e) {
|
|
87
87
|
const message = UNAVAILABLE_ROOM_ERROR.replace("$roomId", roomId);
|
|
88
88
|
res.status(500);
|
package/src-backend/ext/Room.ts
CHANGED
|
@@ -65,3 +65,43 @@ function getStateSize(room) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
+
|
|
69
|
+
function getChild(parent: any, key: string | number) {
|
|
70
|
+
if (typeof parent.at === 'function' && typeof key === 'number') {
|
|
71
|
+
return parent.at(key);
|
|
72
|
+
}
|
|
73
|
+
if (typeof parent.get === 'function') {
|
|
74
|
+
return parent.get(String(key));
|
|
75
|
+
}
|
|
76
|
+
return parent[key];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
(Room.prototype as any)._editStateProperty = async function (path: (string | number)[], value: any) {
|
|
80
|
+
let current = this.state;
|
|
81
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
82
|
+
if (current === null || current === undefined) return;
|
|
83
|
+
current = getChild(current, path[i]);
|
|
84
|
+
}
|
|
85
|
+
if (current === null || current === undefined) return;
|
|
86
|
+
const property = path[path.length - 1];
|
|
87
|
+
if (typeof current.set === 'function') {
|
|
88
|
+
current.set(String(property), value);
|
|
89
|
+
} else {
|
|
90
|
+
current[property] = value;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
(Room.prototype as any)._deleteStateProperty = async function (path: (string | number)[]) {
|
|
95
|
+
let current = this.state;
|
|
96
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
97
|
+
if (current === null || current === undefined) return;
|
|
98
|
+
current = getChild(current, path[i]);
|
|
99
|
+
}
|
|
100
|
+
if (current === null || current === undefined) return;
|
|
101
|
+
const property = path[path.length - 1];
|
|
102
|
+
if (typeof current.delete === 'function') {
|
|
103
|
+
current.delete(String(property));
|
|
104
|
+
} else {
|
|
105
|
+
current[property] = undefined;
|
|
106
|
+
}
|
|
107
|
+
};
|
package/README.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# @colyseus/monitor
|
|
2
|
-
|
|
3
|
-
Web Monitoring Panel for Colyseus.
|
|
4
|
-
|
|
5
|
-
You can use an express middleware to enable authentication on the monitor route, such as `express-basic-middleware`:
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import * as basicAuth from "express-basic-auth";
|
|
9
|
-
|
|
10
|
-
const basicAuthMiddleware = basicAuth({
|
|
11
|
-
// list of users and passwords
|
|
12
|
-
users: {
|
|
13
|
-
"admin": "admin",
|
|
14
|
-
},
|
|
15
|
-
// sends WWW-Authenticate header, which will prompt the user to fill
|
|
16
|
-
// credentials in
|
|
17
|
-
challenge: true
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
app.use("/colyseus", basicAuthMiddleware, monitor());
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Setting custom room listing columns
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
app.use("/colyseus", basicAuthMiddleware, monitor({
|
|
27
|
-
columns: [
|
|
28
|
-
'roomId',
|
|
29
|
-
'name',
|
|
30
|
-
'clients',
|
|
31
|
-
{ metadata: "spectators" }, // display 'spectators' from metadata
|
|
32
|
-
'locked',
|
|
33
|
-
'elapsedTime'
|
|
34
|
-
]
|
|
35
|
-
}));
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
If unspecified, the default room listing columns are: `['roomId', 'name', 'clients', 'maxClients', 'locked', 'elapsedTime']`.
|
|
39
|
-
|
|
40
|
-
## Development
|
|
41
|
-
|
|
42
|
-
Install the dependencies and start the dev-server:
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
npm install
|
|
46
|
-
npm start
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Access the UI on [http://localhost:2567/colyseus](http://localhost:2567/colyseus).
|
|
50
|
-
|
|
51
|
-
## Environment Variables
|
|
52
|
-
|
|
53
|
-
* (optional) `GAME_SERVER_URL`: the URL for colyseus monitor to monitor (example: `server.game.com`), default to current URL (`${window.location.protocol}//${window.location.host}${window.location.pathname}`)
|
|
54
|
-
|
|
55
|
-
## License
|
|
56
|
-
|
|
57
|
-
MIT
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
html,body{margin:0;padding:0}.json-view{display:block;color:#4d4d4d;text-align:left;--json-property: #009033;--json-index: #676dff;--json-number: #676dff;--json-string: #b2762e;--json-boolean: #dc155e;--json-null: #dc155e}.json-view .json-view--property{color:var(--json-property)}.json-view .json-view--index{color:var(--json-index)}.json-view .json-view--number{color:var(--json-number)}.json-view .json-view--string{color:var(--json-string)}.json-view .json-view--boolean{color:var(--json-boolean)}.json-view .json-view--null{color:var(--json-null)}.json-view .jv-indent{padding-left:1em}.json-view .jv-chevron{display:inline-block;vertical-align:-20%;cursor:pointer;opacity:.4;width:1em;height:1em}:is(.json-view .jv-chevron:hover,.json-view .jv-size:hover+.jv-chevron){opacity:.8}.json-view .jv-size{cursor:pointer;opacity:.4;font-size:.875em;font-style:italic;margin-left:.5em;vertical-align:-5%;line-height:1}.json-view :is(.json-view--copy,.json-view--edit),.json-view .json-view--link svg{display:none;width:1em;height:1em;margin-left:.25em;cursor:pointer}.json-view .json-view--input{width:120px;margin-left:.25em;border-radius:4px;border:1px solid currentColor;padding:0 4px;font-size:87.5%;line-height:1.25;background:transparent}.json-view .json-view--deleting{outline:1px solid #da0000;background-color:#da000011;text-decoration-line:line-through}:is(.json-view:hover,.json-view--pair:hover)>:is(.json-view--copy,.json-view--edit),:is(.json-view:hover,.json-view--pair:hover)>.json-view--link svg{display:inline-block}.json-view .jv-button{background:transparent;outline:none;border:none;cursor:pointer;color:inherit}.json-view .cursor-pointer{cursor:pointer}.json-view svg{vertical-align:-10%}.jv-size-chevron~svg{vertical-align:-16%}.json-view_a11y{color:#545454;--json-property: #aa5d00;--json-index: #007299;--json-number: #007299;--json-string: #008000;--json-boolean: #d91e18;--json-null: #d91e18}.json-view_github{color:#005cc5;--json-property: #005cc5;--json-index: #005cc5;--json-number: #005cc5;--json-string: #032f62;--json-boolean: #005cc5;--json-null: #005cc5}.json-view_vscode{color:#005cc5;--json-property: #0451a5;--json-index: #0000ff;--json-number: #0000ff;--json-string: #a31515;--json-boolean: #0000ff;--json-null: #0000ff}.json-view_atom{color:#383a42;--json-property: #e45649;--json-index: #986801;--json-number: #986801;--json-string: #50a14f;--json-boolean: #0184bc;--json-null: #0184bc}.json-view_winter-is-coming{color:#0431fa;--json-property: #3a9685;--json-index: #ae408b;--json-number: #ae408b;--json-string: #8123a9;--json-boolean: #0184bc;--json-null: #0184bc}
|