@colyseus/sdk 0.17.39 → 0.17.41
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 +1 -1
- package/build/Client.mjs +1 -1
- package/build/Connection.cjs +1 -1
- package/build/Connection.mjs +1 -1
- package/build/HTTP.cjs +1 -1
- package/build/HTTP.cjs.map +1 -1
- package/build/HTTP.d.ts +8 -5
- package/build/HTTP.mjs +1 -1
- 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 +70 -44
- package/build/debug.cjs.map +1 -1
- package/build/debug.mjs +70 -44
- package/build/debug.mjs.map +1 -1
- package/build/errors/Errors.cjs +1 -1
- package/build/errors/Errors.mjs +1 -1
- package/build/fetchXHR.cjs +1 -1
- package/build/fetchXHR.mjs +1 -1
- package/build/index.cjs +1 -1
- package/build/index.mjs +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 +1 -1
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +70 -44
- package/dist/debug.js.map +1 -1
- package/package.json +4 -4
- package/src/HTTP.ts +29 -34
- package/src/debug.ts +69 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colyseus/sdk",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.41",
|
|
4
4
|
"description": "Colyseus Multiplayer SDK for JavaScript/TypeScript",
|
|
5
5
|
"author": "Endel Dreyer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@colyseus/schema": "^4.0.7",
|
|
56
56
|
"tslib": "^2.1.0",
|
|
57
57
|
"ws": "^8.13.0",
|
|
58
|
-
"@colyseus/
|
|
59
|
-
"@colyseus/
|
|
58
|
+
"@colyseus/shared-types": "^0.17.6",
|
|
59
|
+
"@colyseus/better-call": "^1.3.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"typescript": "^5.9.3",
|
|
83
83
|
"vite": "^5.0.11",
|
|
84
84
|
"vitest": "^2.1.1",
|
|
85
|
-
"@colyseus/core": "^0.17.
|
|
85
|
+
"@colyseus/core": "^0.17.41"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@colyseus/core": "0.17.x"
|
package/src/HTTP.ts
CHANGED
|
@@ -30,27 +30,7 @@ type HasRequired<
|
|
|
30
30
|
query?: any;
|
|
31
31
|
params?: any;
|
|
32
32
|
},
|
|
33
|
-
> = T
|
|
34
|
-
? HasRequiredKeys<T["body"]> extends true
|
|
35
|
-
? true
|
|
36
|
-
: T["query"] extends object
|
|
37
|
-
? HasRequiredKeys<T["query"]> extends true
|
|
38
|
-
? true
|
|
39
|
-
: T["params"] extends object
|
|
40
|
-
? HasRequiredKeys<T["params"]>
|
|
41
|
-
: false
|
|
42
|
-
: T["params"] extends object
|
|
43
|
-
? HasRequiredKeys<T["params"]>
|
|
44
|
-
: false
|
|
45
|
-
: T["query"] extends object
|
|
46
|
-
? HasRequiredKeys<T["query"]> extends true
|
|
47
|
-
? true
|
|
48
|
-
: T["params"] extends object
|
|
49
|
-
? HasRequiredKeys<T["params"]>
|
|
50
|
-
: false
|
|
51
|
-
: T["params"] extends object
|
|
52
|
-
? HasRequiredKeys<T["params"]>
|
|
53
|
-
: false;
|
|
33
|
+
> = keyof RequiredOptionKeys<T> extends never ? false : true;
|
|
54
34
|
|
|
55
35
|
type InferContext<T> = T extends (ctx: infer Ctx) => any
|
|
56
36
|
? Ctx extends object
|
|
@@ -87,27 +67,42 @@ type MethodOptions<API, M extends HTTPMethod> = API extends { [key: string]: inf
|
|
|
87
67
|
: {}
|
|
88
68
|
: {};
|
|
89
69
|
|
|
70
|
+
// When the endpoint didn't declare a schema, better-call infers:
|
|
71
|
+
// - body: `any`
|
|
72
|
+
// - query: `Record<string, any> | undefined`
|
|
73
|
+
// - params: `Record<string, any> | undefined` (no `:param` in path)
|
|
74
|
+
// Under `strictNullChecks: false`, `undefined extends T` is vacuously true and
|
|
75
|
+
// `undefined extends object` is also true, so the previous `extends object`
|
|
76
|
+
// guard wrongly classified these undeclared slots as required. The checks
|
|
77
|
+
// below use `IsAny` for body and `string extends keyof NonNullable<…>` to
|
|
78
|
+
// detect the fallback index signature — both are immune to null-check mode.
|
|
79
|
+
type IsUndeclaredSchema<T> = [T] extends [never]
|
|
80
|
+
? true
|
|
81
|
+
: string extends keyof NonNullable<T> ? true : false;
|
|
82
|
+
|
|
90
83
|
export type RequiredOptionKeys<
|
|
91
84
|
C extends {
|
|
92
85
|
body?: any;
|
|
93
86
|
query?: any;
|
|
94
87
|
params?: any;
|
|
95
88
|
},
|
|
96
|
-
> = (C["body"] extends
|
|
97
|
-
?
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
(C["query"] extends object
|
|
102
|
-
? HasRequiredKeys<C["query"]> extends true
|
|
103
|
-
? { query: true }
|
|
89
|
+
> = (IsAny<C["body"]> extends true
|
|
90
|
+
? {}
|
|
91
|
+
: NonNullable<C["body"]> extends object
|
|
92
|
+
? HasRequiredKeys<NonNullable<C["body"]>> extends true
|
|
93
|
+
? { body: true }
|
|
104
94
|
: {}
|
|
105
|
-
: {}) &
|
|
106
|
-
(C["
|
|
107
|
-
?
|
|
95
|
+
: { body: true }) &
|
|
96
|
+
(IsUndeclaredSchema<C["query"]> extends true
|
|
97
|
+
? {}
|
|
98
|
+
: HasRequiredKeys<NonNullable<C["query"]>> extends true
|
|
99
|
+
? { query: true }
|
|
100
|
+
: {}) &
|
|
101
|
+
(IsUndeclaredSchema<C["params"]> extends true
|
|
102
|
+
? {}
|
|
103
|
+
: HasRequiredKeys<NonNullable<C["params"]>> extends true
|
|
108
104
|
? { params: true }
|
|
109
|
-
: {}
|
|
110
|
-
: {});
|
|
105
|
+
: {});
|
|
111
106
|
|
|
112
107
|
|
|
113
108
|
type CommonHeaders = {
|
package/src/debug.ts
CHANGED
|
@@ -92,6 +92,19 @@ const BASE_MODAL_ZINDEX = 10000;
|
|
|
92
92
|
// Load preferences on script load
|
|
93
93
|
loadPreferences();
|
|
94
94
|
|
|
95
|
+
// Shadow DOM root — isolates all debug UI from page-level CSS.
|
|
96
|
+
// Every SDK element is appended here so page rules like `canvas { width: 100vw }`
|
|
97
|
+
// can't reach (or stretch) the debug panel's sparklines, logo, menu, or modals.
|
|
98
|
+
let _debugShadowRoot: ShadowRoot | null = null;
|
|
99
|
+
function getDebugRoot(): ShadowRoot {
|
|
100
|
+
if (_debugShadowRoot) return _debugShadowRoot;
|
|
101
|
+
const host = document.createElement('div');
|
|
102
|
+
host.id = 'colyseus-debug-shadow-host';
|
|
103
|
+
_debugShadowRoot = host.attachShadow({ mode: 'open' });
|
|
104
|
+
document.body.appendChild(host);
|
|
105
|
+
return _debugShadowRoot;
|
|
106
|
+
}
|
|
107
|
+
|
|
95
108
|
// Function to select a modal (bring to front)
|
|
96
109
|
function selectModal(modal) {
|
|
97
110
|
if (!modal) return;
|
|
@@ -106,8 +119,9 @@ function selectModal(modal) {
|
|
|
106
119
|
modalStack.push(modal);
|
|
107
120
|
|
|
108
121
|
// Update z-indexes for all modals based on their position in stack
|
|
122
|
+
var root = getDebugRoot();
|
|
109
123
|
modalStack.forEach((m, i) => {
|
|
110
|
-
if (
|
|
124
|
+
if (root.contains(m)) {
|
|
111
125
|
m.style.zIndex = (BASE_MODAL_ZINDEX + i).toString();
|
|
112
126
|
}
|
|
113
127
|
});
|
|
@@ -126,7 +140,7 @@ document.addEventListener('keydown', function(e) {
|
|
|
126
140
|
if (e.key === 'Escape' && modalStack.length > 0) {
|
|
127
141
|
// Get the most recent modal (top of stack)
|
|
128
142
|
const topModal = modalStack[modalStack.length - 1];
|
|
129
|
-
if (topModal &&
|
|
143
|
+
if (topModal && getDebugRoot().contains(topModal)) {
|
|
130
144
|
topModal.remove();
|
|
131
145
|
}
|
|
132
146
|
}
|
|
@@ -405,7 +419,7 @@ function initialize() {
|
|
|
405
419
|
icon.insertAdjacentHTML('beforeend', logoIcon);
|
|
406
420
|
|
|
407
421
|
container.appendChild(icon);
|
|
408
|
-
|
|
422
|
+
getDebugRoot().appendChild(container);
|
|
409
423
|
|
|
410
424
|
// Create menu first
|
|
411
425
|
createMenu(container);
|
|
@@ -549,7 +563,8 @@ function createMenu(logoContainer) {
|
|
|
549
563
|
}
|
|
550
564
|
|
|
551
565
|
var styleId = 'latency-slider-style';
|
|
552
|
-
var
|
|
566
|
+
var root = getDebugRoot();
|
|
567
|
+
var existingStyle = root.getElementById(styleId);
|
|
553
568
|
if (existingStyle) {
|
|
554
569
|
existingStyle.remove();
|
|
555
570
|
}
|
|
@@ -569,7 +584,7 @@ function createMenu(logoContainer) {
|
|
|
569
584
|
border: none;
|
|
570
585
|
}
|
|
571
586
|
`;
|
|
572
|
-
|
|
587
|
+
root.appendChild(style);
|
|
573
588
|
}
|
|
574
589
|
|
|
575
590
|
// Initialize slider color
|
|
@@ -615,11 +630,11 @@ function createMenu(logoContainer) {
|
|
|
615
630
|
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
|
|
616
631
|
}
|
|
617
632
|
`;
|
|
618
|
-
|
|
633
|
+
getDebugRoot().appendChild(style);
|
|
619
634
|
|
|
620
635
|
// Function to update container border color
|
|
621
636
|
function updateContainerBackgroundColor() {
|
|
622
|
-
var container =
|
|
637
|
+
var container = getDebugRoot().getElementById('debug-logo-container');
|
|
623
638
|
if (container) {
|
|
624
639
|
// Update to normal state (hover handlers will update on hover)
|
|
625
640
|
container.style.borderColor = getBorderColor(preferences.latencySimulation.delay, 0.7);
|
|
@@ -688,7 +703,7 @@ function createMenu(logoContainer) {
|
|
|
688
703
|
});
|
|
689
704
|
menu.appendChild(settingsOption);
|
|
690
705
|
|
|
691
|
-
|
|
706
|
+
getDebugRoot().appendChild(menu);
|
|
692
707
|
|
|
693
708
|
// Toggle menu on logo click
|
|
694
709
|
var menuVisible = false;
|
|
@@ -710,9 +725,15 @@ function createMenu(logoContainer) {
|
|
|
710
725
|
}
|
|
711
726
|
});
|
|
712
727
|
|
|
713
|
-
// Close menu when clicking outside
|
|
728
|
+
// Close menu when clicking outside.
|
|
729
|
+
// Because menu/logo live inside a shadow root, event.target is retargeted
|
|
730
|
+
// to the shadow host for document-level listeners, so we walk the composed
|
|
731
|
+
// path to see whether the real click target was inside the menu or logo.
|
|
714
732
|
document.addEventListener('click', function(e) {
|
|
715
|
-
|
|
733
|
+
var path = typeof e.composedPath === 'function' ? e.composedPath() : [e.target as EventTarget];
|
|
734
|
+
var clickedInsideMenu = path.indexOf(menu) !== -1;
|
|
735
|
+
var clickedInsideLogo = path.indexOf(logoContainer) !== -1;
|
|
736
|
+
if (menuVisible && !clickedInsideMenu && !clickedInsideLogo) {
|
|
716
737
|
menuVisible = false;
|
|
717
738
|
menu.style.display = 'none';
|
|
718
739
|
if (hostUpdateInterval) {
|
|
@@ -726,7 +747,7 @@ function createMenu(logoContainer) {
|
|
|
726
747
|
// Create and open Settings modal
|
|
727
748
|
function openSettingsModal() {
|
|
728
749
|
// Remove existing modal if present
|
|
729
|
-
var existingModal =
|
|
750
|
+
var existingModal = getDebugRoot().getElementById('debug-settings-modal');
|
|
730
751
|
if (existingModal) {
|
|
731
752
|
existingModal.remove();
|
|
732
753
|
}
|
|
@@ -935,7 +956,7 @@ function openSettingsModal() {
|
|
|
935
956
|
modal.appendChild(hideContainer);
|
|
936
957
|
|
|
937
958
|
overlay.appendChild(modal);
|
|
938
|
-
|
|
959
|
+
getDebugRoot().appendChild(overlay);
|
|
939
960
|
|
|
940
961
|
// Mark as selected modal when opened
|
|
941
962
|
selectModal(overlay);
|
|
@@ -977,7 +998,7 @@ function openSendMessagesModal(uniquePanelId) {
|
|
|
977
998
|
}
|
|
978
999
|
|
|
979
1000
|
// Remove existing modal if present
|
|
980
|
-
var existingModal =
|
|
1001
|
+
var existingModal = getDebugRoot().getElementById('debug-send-messages-modal');
|
|
981
1002
|
if (existingModal) {
|
|
982
1003
|
existingModal.remove();
|
|
983
1004
|
}
|
|
@@ -1422,7 +1443,7 @@ function openSendMessagesModal(uniquePanelId) {
|
|
|
1422
1443
|
formContainer.appendChild(sendButton);
|
|
1423
1444
|
|
|
1424
1445
|
modal.appendChild(formContainer);
|
|
1425
|
-
|
|
1446
|
+
getDebugRoot().appendChild(modal);
|
|
1426
1447
|
}
|
|
1427
1448
|
|
|
1428
1449
|
// Create and open State Inspector modal
|
|
@@ -1436,7 +1457,7 @@ function openStateInspectorModal(uniquePanelId) {
|
|
|
1436
1457
|
var room = debugInfo.room;
|
|
1437
1458
|
|
|
1438
1459
|
// Remove existing modal if present
|
|
1439
|
-
var existingModal =
|
|
1460
|
+
var existingModal = getDebugRoot().getElementById('debug-state-inspector-modal');
|
|
1440
1461
|
if (existingModal) {
|
|
1441
1462
|
existingModal.remove();
|
|
1442
1463
|
}
|
|
@@ -1873,7 +1894,7 @@ function openStateInspectorModal(uniquePanelId) {
|
|
|
1873
1894
|
}
|
|
1874
1895
|
|
|
1875
1896
|
modal.appendChild(contentContainer);
|
|
1876
|
-
|
|
1897
|
+
getDebugRoot().appendChild(modal);
|
|
1877
1898
|
|
|
1878
1899
|
// Drag and resize state variables
|
|
1879
1900
|
var isDragging = false;
|
|
@@ -2095,9 +2116,10 @@ function openStateInspectorModal(uniquePanelId) {
|
|
|
2095
2116
|
|
|
2096
2117
|
// Apply panel position based on current setting
|
|
2097
2118
|
function applyPanelPosition() {
|
|
2098
|
-
var
|
|
2099
|
-
var
|
|
2100
|
-
var
|
|
2119
|
+
var root = getDebugRoot();
|
|
2120
|
+
var logoContainer = root.getElementById('debug-logo-container');
|
|
2121
|
+
var menu = root.getElementById('debug-menu');
|
|
2122
|
+
var panels = root.querySelectorAll('[id^="debug-panel-"]');
|
|
2101
2123
|
|
|
2102
2124
|
var positions = {
|
|
2103
2125
|
'bottom-right': { bottom: '14px', right: '14px', top: 'auto', left: 'auto' },
|
|
@@ -2139,9 +2161,10 @@ function hidePanelsForSession() {
|
|
|
2139
2161
|
panelsHidden = true;
|
|
2140
2162
|
savePreferences(); // Save the hidden state
|
|
2141
2163
|
|
|
2142
|
-
var
|
|
2143
|
-
var
|
|
2144
|
-
var
|
|
2164
|
+
var root = getDebugRoot();
|
|
2165
|
+
var logoContainer = root.getElementById('debug-logo-container');
|
|
2166
|
+
var menu = root.getElementById('debug-menu');
|
|
2167
|
+
var panels = root.querySelectorAll('[id^="debug-panel-"]') as NodeListOf<HTMLElement>;
|
|
2145
2168
|
|
|
2146
2169
|
if (logoContainer) {
|
|
2147
2170
|
logoContainer.style.display = 'none';
|
|
@@ -2170,7 +2193,7 @@ function formatBytes(bytes) {
|
|
|
2170
2193
|
// Helper function to create debug panel for a room
|
|
2171
2194
|
function createDebugPanel(uniquePanelId, debugInfo) {
|
|
2172
2195
|
// Check if panel already exists
|
|
2173
|
-
var existingPanel =
|
|
2196
|
+
var existingPanel = getDebugRoot().getElementById('debug-panel-' + uniquePanelId);
|
|
2174
2197
|
if (existingPanel) {
|
|
2175
2198
|
return existingPanel;
|
|
2176
2199
|
}
|
|
@@ -2327,11 +2350,12 @@ function createDebugPanel(uniquePanelId, debugInfo) {
|
|
|
2327
2350
|
}
|
|
2328
2351
|
|
|
2329
2352
|
// Inject CSS animation if not already present
|
|
2330
|
-
|
|
2353
|
+
var pulseRoot = getDebugRoot();
|
|
2354
|
+
if (!pulseRoot.getElementById('debug-pulse-animation')) {
|
|
2331
2355
|
var style = document.createElement('style');
|
|
2332
2356
|
style.id = 'debug-pulse-animation';
|
|
2333
2357
|
style.textContent = '@keyframes debug-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }';
|
|
2334
|
-
|
|
2358
|
+
pulseRoot.appendChild(style);
|
|
2335
2359
|
}
|
|
2336
2360
|
|
|
2337
2361
|
// Apply initial style
|
|
@@ -2394,11 +2418,12 @@ function createDebugPanel(uniquePanelId, debugInfo) {
|
|
|
2394
2418
|
panel.appendChild(content);
|
|
2395
2419
|
panel.appendChild(actionsContainer);
|
|
2396
2420
|
|
|
2397
|
-
// Prepend panel
|
|
2398
|
-
|
|
2399
|
-
|
|
2421
|
+
// Prepend panel inside the shadow root so new panels appear first
|
|
2422
|
+
var root = getDebugRoot();
|
|
2423
|
+
if (root.firstChild) {
|
|
2424
|
+
root.insertBefore(panel, root.firstChild);
|
|
2400
2425
|
} else {
|
|
2401
|
-
|
|
2426
|
+
root.appendChild(panel);
|
|
2402
2427
|
}
|
|
2403
2428
|
|
|
2404
2429
|
return panel;
|
|
@@ -2408,7 +2433,7 @@ function createDebugPanel(uniquePanelId, debugInfo) {
|
|
|
2408
2433
|
function repositionDebugPanels() {
|
|
2409
2434
|
if (panelsHidden) return;
|
|
2410
2435
|
|
|
2411
|
-
var panels = Array.from(
|
|
2436
|
+
var panels = Array.from(getDebugRoot().querySelectorAll('[id^="debug-panel-"]') as NodeListOf<HTMLElement>)
|
|
2412
2437
|
.filter(function(panel: HTMLElement) { return panel.style.display !== 'none'; })
|
|
2413
2438
|
.reverse(); // Reverse to get oldest first (since new panels are prepended)
|
|
2414
2439
|
|
|
@@ -2457,36 +2482,37 @@ function repositionDebugPanels() {
|
|
|
2457
2482
|
|
|
2458
2483
|
// Update debug panel content
|
|
2459
2484
|
function updateDebugPanel(uniquePanelId, debugInfo) {
|
|
2485
|
+
var root = getDebugRoot();
|
|
2460
2486
|
var contentId = 'debug-content-' + uniquePanelId;
|
|
2461
2487
|
var panelId = 'debug-panel-' + uniquePanelId;
|
|
2462
2488
|
var titleId = 'debug-title-' + uniquePanelId;
|
|
2463
|
-
var content =
|
|
2464
|
-
var panel =
|
|
2465
|
-
var title =
|
|
2489
|
+
var content = root.getElementById(contentId);
|
|
2490
|
+
var panel = root.getElementById(panelId);
|
|
2491
|
+
var title = root.getElementById(titleId);
|
|
2466
2492
|
|
|
2467
2493
|
if (!content || !panel) {
|
|
2468
2494
|
// Only create if panel doesn't exist
|
|
2469
2495
|
if (!panel) {
|
|
2470
2496
|
createDebugPanel(uniquePanelId, debugInfo);
|
|
2471
|
-
content =
|
|
2472
|
-
title =
|
|
2497
|
+
content = root.getElementById(contentId);
|
|
2498
|
+
title = root.getElementById(titleId);
|
|
2473
2499
|
repositionDebugPanels();
|
|
2474
2500
|
} else {
|
|
2475
|
-
content =
|
|
2476
|
-
title =
|
|
2501
|
+
content = root.getElementById(contentId);
|
|
2502
|
+
title = root.getElementById(titleId);
|
|
2477
2503
|
}
|
|
2478
2504
|
}
|
|
2479
2505
|
|
|
2480
2506
|
// Update title with room name only (roomId and sessionId are in tooltip)
|
|
2481
|
-
var titleTextEl =
|
|
2507
|
+
var titleTextEl = root.getElementById('debug-title-text-' + uniquePanelId);
|
|
2482
2508
|
var roomNameEl = titleTextEl?.querySelector('.debug-room-name');
|
|
2483
2509
|
if (roomNameEl) roomNameEl.textContent = debugInfo.roomName;
|
|
2484
|
-
|
|
2510
|
+
root.getElementById('debug-tooltip-' + uniquePanelId).innerHTML = '<div><strong>Room ID:</strong> ' + debugInfo.roomId + '</div><div><strong>Session ID:</strong> ' + debugInfo.sessionId + '</div>';
|
|
2485
2511
|
|
|
2486
2512
|
// Update ping in header
|
|
2487
2513
|
var pingDisplay = debugInfo.pingMs !== null ? debugInfo.pingMs + 'ms' : '--';
|
|
2488
2514
|
var pingColor = debugInfo.pingMs !== null ? (debugInfo.pingMs < 100 ? '#22c55e' : debugInfo.pingMs < 200 ? '#eab308' : '#ef4444') : '#888';
|
|
2489
|
-
var pingElement =
|
|
2515
|
+
var pingElement = root.getElementById('debug-ping-' + uniquePanelId);
|
|
2490
2516
|
if (pingElement) {
|
|
2491
2517
|
pingElement.textContent = pingDisplay;
|
|
2492
2518
|
pingElement.style.color = pingColor;
|
|
@@ -2516,7 +2542,7 @@ function updateDebugPanel(uniquePanelId, debugInfo) {
|
|
|
2516
2542
|
|
|
2517
2543
|
// Draw graph on canvas
|
|
2518
2544
|
function drawGraph(canvasId, data, color) {
|
|
2519
|
-
var canvas =
|
|
2545
|
+
var canvas = getDebugRoot().getElementById(canvasId) as HTMLCanvasElement;
|
|
2520
2546
|
if (!canvas) return;
|
|
2521
2547
|
|
|
2522
2548
|
var ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
@@ -2702,7 +2728,7 @@ function applyMonkeyPatches() {
|
|
|
2702
2728
|
debugInfo.messageTypes = messageTypes;
|
|
2703
2729
|
|
|
2704
2730
|
// Show/hide message button based on message types availability
|
|
2705
|
-
var messageBtnElement =
|
|
2731
|
+
var messageBtnElement = getDebugRoot().getElementById('debug-message-btn-' + uniquePanelId);
|
|
2706
2732
|
if (messageBtnElement) {
|
|
2707
2733
|
messageBtnElement.style.display = messageTypes ? 'flex' : 'none';
|
|
2708
2734
|
}
|
|
@@ -2834,7 +2860,7 @@ function applyMonkeyPatches() {
|
|
|
2834
2860
|
debugInfo.pingInterval = null;
|
|
2835
2861
|
}
|
|
2836
2862
|
roomDebugInfo.delete(uniquePanelId);
|
|
2837
|
-
var panel =
|
|
2863
|
+
var panel = getDebugRoot().getElementById('debug-panel-' + uniquePanelId);
|
|
2838
2864
|
if (panel) {
|
|
2839
2865
|
panel.remove();
|
|
2840
2866
|
repositionDebugPanels();
|