@colyseus/sdk 0.17.40 → 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.mjs +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/debug.js +70 -44
- package/dist/debug.js.map +1 -1
- package/package.json +3 -3
- package/src/debug.ts +69 -43
package/build/errors/Errors.cjs
CHANGED
package/build/errors/Errors.mjs
CHANGED
package/build/fetchXHR.cjs
CHANGED
package/build/fetchXHR.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.41
|
|
7
7
|
/**
|
|
8
8
|
* Minimal fetch-compatible wrapper around XMLHttpRequest.
|
|
9
9
|
* Used as an automatic fallback when globalThis.fetch is unavailable
|
package/build/index.cjs
CHANGED
package/build/index.mjs
CHANGED
package/build/legacy.cjs
CHANGED
package/build/legacy.mjs
CHANGED
package/dist/colyseus.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.41 - @colyseus/schema 4.0.13
|
|
7
7
|
(function (global, factory) {
|
|
8
8
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
9
9
|
typeof define === 'function' && define.amd ? define('@colyseus/sdk', ['exports'], factory) :
|
package/dist/debug.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// This software is released under the MIT License.
|
|
4
4
|
// https://opensource.org/license/MIT
|
|
5
5
|
//
|
|
6
|
-
// colyseus.js@0.17.
|
|
6
|
+
// colyseus.js@0.17.41
|
|
7
7
|
(function (Client_ts, sharedTypes) {
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
@@ -86,6 +86,19 @@
|
|
|
86
86
|
const BASE_MODAL_ZINDEX = 10000;
|
|
87
87
|
// Load preferences on script load
|
|
88
88
|
loadPreferences();
|
|
89
|
+
// Shadow DOM root — isolates all debug UI from page-level CSS.
|
|
90
|
+
// Every SDK element is appended here so page rules like `canvas { width: 100vw }`
|
|
91
|
+
// can't reach (or stretch) the debug panel's sparklines, logo, menu, or modals.
|
|
92
|
+
let _debugShadowRoot = null;
|
|
93
|
+
function getDebugRoot() {
|
|
94
|
+
if (_debugShadowRoot)
|
|
95
|
+
return _debugShadowRoot;
|
|
96
|
+
const host = document.createElement('div');
|
|
97
|
+
host.id = 'colyseus-debug-shadow-host';
|
|
98
|
+
_debugShadowRoot = host.attachShadow({ mode: 'open' });
|
|
99
|
+
document.body.appendChild(host);
|
|
100
|
+
return _debugShadowRoot;
|
|
101
|
+
}
|
|
89
102
|
// Function to select a modal (bring to front)
|
|
90
103
|
function selectModal(modal) {
|
|
91
104
|
if (!modal)
|
|
@@ -98,8 +111,9 @@
|
|
|
98
111
|
// Add to end of stack (most recent)
|
|
99
112
|
modalStack.push(modal);
|
|
100
113
|
// Update z-indexes for all modals based on their position in stack
|
|
114
|
+
var root = getDebugRoot();
|
|
101
115
|
modalStack.forEach((m, i) => {
|
|
102
|
-
if (
|
|
116
|
+
if (root.contains(m)) {
|
|
103
117
|
m.style.zIndex = (BASE_MODAL_ZINDEX + i).toString();
|
|
104
118
|
}
|
|
105
119
|
});
|
|
@@ -116,7 +130,7 @@
|
|
|
116
130
|
if (e.key === 'Escape' && modalStack.length > 0) {
|
|
117
131
|
// Get the most recent modal (top of stack)
|
|
118
132
|
const topModal = modalStack[modalStack.length - 1];
|
|
119
|
-
if (topModal &&
|
|
133
|
+
if (topModal && getDebugRoot().contains(topModal)) {
|
|
120
134
|
topModal.remove();
|
|
121
135
|
}
|
|
122
136
|
}
|
|
@@ -366,7 +380,7 @@
|
|
|
366
380
|
// Use insertAdjacentHTML for better Safari compatibility with SVG
|
|
367
381
|
icon.insertAdjacentHTML('beforeend', logoIcon);
|
|
368
382
|
container.appendChild(icon);
|
|
369
|
-
|
|
383
|
+
getDebugRoot().appendChild(container);
|
|
370
384
|
// Create menu first
|
|
371
385
|
createMenu(container);
|
|
372
386
|
// Apply initial position after menu is created
|
|
@@ -493,7 +507,8 @@
|
|
|
493
507
|
gradient = `linear-gradient(to right, #00c800 0%, ${yellowColor} ${yellowPercent}%, ${color} ${valuePercent}%, #333 ${valuePercent}%, #333 100%)`;
|
|
494
508
|
}
|
|
495
509
|
var styleId = 'latency-slider-style';
|
|
496
|
-
var
|
|
510
|
+
var root = getDebugRoot();
|
|
511
|
+
var existingStyle = root.getElementById(styleId);
|
|
497
512
|
if (existingStyle) {
|
|
498
513
|
existingStyle.remove();
|
|
499
514
|
}
|
|
@@ -513,7 +528,7 @@
|
|
|
513
528
|
border: none;
|
|
514
529
|
}
|
|
515
530
|
`;
|
|
516
|
-
|
|
531
|
+
root.appendChild(style);
|
|
517
532
|
}
|
|
518
533
|
// Initialize slider color
|
|
519
534
|
updateSliderColor(parseInt(latencySlider.value));
|
|
@@ -557,10 +572,10 @@
|
|
|
557
572
|
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
|
|
558
573
|
}
|
|
559
574
|
`;
|
|
560
|
-
|
|
575
|
+
getDebugRoot().appendChild(style);
|
|
561
576
|
// Function to update container border color
|
|
562
577
|
function updateContainerBackgroundColor() {
|
|
563
|
-
var container =
|
|
578
|
+
var container = getDebugRoot().getElementById('debug-logo-container');
|
|
564
579
|
if (container) {
|
|
565
580
|
// Update to normal state (hover handlers will update on hover)
|
|
566
581
|
container.style.borderColor = getBorderColor(preferences.latencySimulation.delay, 0.7);
|
|
@@ -620,7 +635,7 @@
|
|
|
620
635
|
openSettingsModal();
|
|
621
636
|
});
|
|
622
637
|
menu.appendChild(settingsOption);
|
|
623
|
-
|
|
638
|
+
getDebugRoot().appendChild(menu);
|
|
624
639
|
// Toggle menu on logo click
|
|
625
640
|
var menuVisible = false;
|
|
626
641
|
var hostUpdateInterval = null;
|
|
@@ -640,9 +655,15 @@
|
|
|
640
655
|
}
|
|
641
656
|
}
|
|
642
657
|
});
|
|
643
|
-
// Close menu when clicking outside
|
|
658
|
+
// Close menu when clicking outside.
|
|
659
|
+
// Because menu/logo live inside a shadow root, event.target is retargeted
|
|
660
|
+
// to the shadow host for document-level listeners, so we walk the composed
|
|
661
|
+
// path to see whether the real click target was inside the menu or logo.
|
|
644
662
|
document.addEventListener('click', function (e) {
|
|
645
|
-
|
|
663
|
+
var path = typeof e.composedPath === 'function' ? e.composedPath() : [e.target];
|
|
664
|
+
var clickedInsideMenu = path.indexOf(menu) !== -1;
|
|
665
|
+
var clickedInsideLogo = path.indexOf(logoContainer) !== -1;
|
|
666
|
+
if (menuVisible && !clickedInsideMenu && !clickedInsideLogo) {
|
|
646
667
|
menuVisible = false;
|
|
647
668
|
menu.style.display = 'none';
|
|
648
669
|
if (hostUpdateInterval) {
|
|
@@ -655,7 +676,7 @@
|
|
|
655
676
|
// Create and open Settings modal
|
|
656
677
|
function openSettingsModal() {
|
|
657
678
|
// Remove existing modal if present
|
|
658
|
-
var existingModal =
|
|
679
|
+
var existingModal = getDebugRoot().getElementById('debug-settings-modal');
|
|
659
680
|
if (existingModal) {
|
|
660
681
|
existingModal.remove();
|
|
661
682
|
}
|
|
@@ -834,7 +855,7 @@
|
|
|
834
855
|
hideContainer.appendChild(hideButton);
|
|
835
856
|
modal.appendChild(hideContainer);
|
|
836
857
|
overlay.appendChild(modal);
|
|
837
|
-
|
|
858
|
+
getDebugRoot().appendChild(overlay);
|
|
838
859
|
// Mark as selected modal when opened
|
|
839
860
|
selectModal(overlay);
|
|
840
861
|
// Update close button to cleanup from modal stack
|
|
@@ -869,7 +890,7 @@
|
|
|
869
890
|
return;
|
|
870
891
|
}
|
|
871
892
|
// Remove existing modal if present
|
|
872
|
-
var existingModal =
|
|
893
|
+
var existingModal = getDebugRoot().getElementById('debug-send-messages-modal');
|
|
873
894
|
if (existingModal) {
|
|
874
895
|
existingModal.remove();
|
|
875
896
|
}
|
|
@@ -1267,7 +1288,7 @@
|
|
|
1267
1288
|
});
|
|
1268
1289
|
formContainer.appendChild(sendButton);
|
|
1269
1290
|
modal.appendChild(formContainer);
|
|
1270
|
-
|
|
1291
|
+
getDebugRoot().appendChild(modal);
|
|
1271
1292
|
}
|
|
1272
1293
|
// Create and open State Inspector modal
|
|
1273
1294
|
function openStateInspectorModal(uniquePanelId) {
|
|
@@ -1279,7 +1300,7 @@
|
|
|
1279
1300
|
}
|
|
1280
1301
|
var room = debugInfo.room;
|
|
1281
1302
|
// Remove existing modal if present
|
|
1282
|
-
var existingModal =
|
|
1303
|
+
var existingModal = getDebugRoot().getElementById('debug-state-inspector-modal');
|
|
1283
1304
|
if (existingModal) {
|
|
1284
1305
|
existingModal.remove();
|
|
1285
1306
|
}
|
|
@@ -1669,7 +1690,7 @@
|
|
|
1669
1690
|
*/
|
|
1670
1691
|
};
|
|
1671
1692
|
modal.appendChild(contentContainer);
|
|
1672
|
-
|
|
1693
|
+
getDebugRoot().appendChild(modal);
|
|
1673
1694
|
// Drag and resize state variables
|
|
1674
1695
|
var isDragging = false;
|
|
1675
1696
|
var dragStartX = 0;
|
|
@@ -1874,9 +1895,10 @@
|
|
|
1874
1895
|
}
|
|
1875
1896
|
// Apply panel position based on current setting
|
|
1876
1897
|
function applyPanelPosition() {
|
|
1877
|
-
var
|
|
1878
|
-
var
|
|
1879
|
-
var
|
|
1898
|
+
var root = getDebugRoot();
|
|
1899
|
+
var logoContainer = root.getElementById('debug-logo-container');
|
|
1900
|
+
var menu = root.getElementById('debug-menu');
|
|
1901
|
+
var panels = root.querySelectorAll('[id^="debug-panel-"]');
|
|
1880
1902
|
var positions = {
|
|
1881
1903
|
'bottom-right': { bottom: '14px', right: '14px', top: 'auto', left: 'auto' },
|
|
1882
1904
|
'bottom-left': { bottom: '14px', left: '14px', top: 'auto', right: 'auto' },
|
|
@@ -1912,9 +1934,10 @@
|
|
|
1912
1934
|
function hidePanelsForSession() {
|
|
1913
1935
|
panelsHidden = true;
|
|
1914
1936
|
savePreferences(); // Save the hidden state
|
|
1915
|
-
var
|
|
1916
|
-
var
|
|
1917
|
-
var
|
|
1937
|
+
var root = getDebugRoot();
|
|
1938
|
+
var logoContainer = root.getElementById('debug-logo-container');
|
|
1939
|
+
var menu = root.getElementById('debug-menu');
|
|
1940
|
+
var panels = root.querySelectorAll('[id^="debug-panel-"]');
|
|
1918
1941
|
if (logoContainer) {
|
|
1919
1942
|
logoContainer.style.display = 'none';
|
|
1920
1943
|
}
|
|
@@ -1941,7 +1964,7 @@
|
|
|
1941
1964
|
// Helper function to create debug panel for a room
|
|
1942
1965
|
function createDebugPanel(uniquePanelId, debugInfo) {
|
|
1943
1966
|
// Check if panel already exists
|
|
1944
|
-
var existingPanel =
|
|
1967
|
+
var existingPanel = getDebugRoot().getElementById('debug-panel-' + uniquePanelId);
|
|
1945
1968
|
if (existingPanel) {
|
|
1946
1969
|
return existingPanel;
|
|
1947
1970
|
}
|
|
@@ -2070,11 +2093,12 @@
|
|
|
2070
2093
|
labelSpan.textContent = 'Reconnecting...';
|
|
2071
2094
|
}
|
|
2072
2095
|
// Inject CSS animation if not already present
|
|
2073
|
-
|
|
2096
|
+
var pulseRoot = getDebugRoot();
|
|
2097
|
+
if (!pulseRoot.getElementById('debug-pulse-animation')) {
|
|
2074
2098
|
var style = document.createElement('style');
|
|
2075
2099
|
style.id = 'debug-pulse-animation';
|
|
2076
2100
|
style.textContent = '@keyframes debug-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }';
|
|
2077
|
-
|
|
2101
|
+
pulseRoot.appendChild(style);
|
|
2078
2102
|
}
|
|
2079
2103
|
// Apply initial style
|
|
2080
2104
|
applyNormalStyle();
|
|
@@ -2132,12 +2156,13 @@
|
|
|
2132
2156
|
panel.appendChild(title);
|
|
2133
2157
|
panel.appendChild(content);
|
|
2134
2158
|
panel.appendChild(actionsContainer);
|
|
2135
|
-
// Prepend panel
|
|
2136
|
-
|
|
2137
|
-
|
|
2159
|
+
// Prepend panel inside the shadow root so new panels appear first
|
|
2160
|
+
var root = getDebugRoot();
|
|
2161
|
+
if (root.firstChild) {
|
|
2162
|
+
root.insertBefore(panel, root.firstChild);
|
|
2138
2163
|
}
|
|
2139
2164
|
else {
|
|
2140
|
-
|
|
2165
|
+
root.appendChild(panel);
|
|
2141
2166
|
}
|
|
2142
2167
|
return panel;
|
|
2143
2168
|
}
|
|
@@ -2145,7 +2170,7 @@
|
|
|
2145
2170
|
function repositionDebugPanels() {
|
|
2146
2171
|
if (panelsHidden)
|
|
2147
2172
|
return;
|
|
2148
|
-
var panels = Array.from(
|
|
2173
|
+
var panels = Array.from(getDebugRoot().querySelectorAll('[id^="debug-panel-"]'))
|
|
2149
2174
|
.filter(function (panel) { return panel.style.display !== 'none'; })
|
|
2150
2175
|
.reverse(); // Reverse to get oldest first (since new panels are prepended)
|
|
2151
2176
|
// Calculate logoIcon container width: 22px width + 10px padding on each side = 42px
|
|
@@ -2187,35 +2212,36 @@
|
|
|
2187
2212
|
}
|
|
2188
2213
|
// Update debug panel content
|
|
2189
2214
|
function updateDebugPanel(uniquePanelId, debugInfo) {
|
|
2215
|
+
var root = getDebugRoot();
|
|
2190
2216
|
var contentId = 'debug-content-' + uniquePanelId;
|
|
2191
2217
|
var panelId = 'debug-panel-' + uniquePanelId;
|
|
2192
2218
|
var titleId = 'debug-title-' + uniquePanelId;
|
|
2193
|
-
var content =
|
|
2194
|
-
var panel =
|
|
2195
|
-
var title =
|
|
2219
|
+
var content = root.getElementById(contentId);
|
|
2220
|
+
var panel = root.getElementById(panelId);
|
|
2221
|
+
var title = root.getElementById(titleId);
|
|
2196
2222
|
if (!content || !panel) {
|
|
2197
2223
|
// Only create if panel doesn't exist
|
|
2198
2224
|
if (!panel) {
|
|
2199
2225
|
createDebugPanel(uniquePanelId, debugInfo);
|
|
2200
|
-
content =
|
|
2201
|
-
title =
|
|
2226
|
+
content = root.getElementById(contentId);
|
|
2227
|
+
title = root.getElementById(titleId);
|
|
2202
2228
|
repositionDebugPanels();
|
|
2203
2229
|
}
|
|
2204
2230
|
else {
|
|
2205
|
-
content =
|
|
2206
|
-
title =
|
|
2231
|
+
content = root.getElementById(contentId);
|
|
2232
|
+
title = root.getElementById(titleId);
|
|
2207
2233
|
}
|
|
2208
2234
|
}
|
|
2209
2235
|
// Update title with room name only (roomId and sessionId are in tooltip)
|
|
2210
|
-
var titleTextEl =
|
|
2236
|
+
var titleTextEl = root.getElementById('debug-title-text-' + uniquePanelId);
|
|
2211
2237
|
var roomNameEl = titleTextEl === null || titleTextEl === void 0 ? void 0 : titleTextEl.querySelector('.debug-room-name');
|
|
2212
2238
|
if (roomNameEl)
|
|
2213
2239
|
roomNameEl.textContent = debugInfo.roomName;
|
|
2214
|
-
|
|
2240
|
+
root.getElementById('debug-tooltip-' + uniquePanelId).innerHTML = '<div><strong>Room ID:</strong> ' + debugInfo.roomId + '</div><div><strong>Session ID:</strong> ' + debugInfo.sessionId + '</div>';
|
|
2215
2241
|
// Update ping in header
|
|
2216
2242
|
var pingDisplay = debugInfo.pingMs !== null ? debugInfo.pingMs + 'ms' : '--';
|
|
2217
2243
|
var pingColor = debugInfo.pingMs !== null ? (debugInfo.pingMs < 100 ? '#22c55e' : debugInfo.pingMs < 200 ? '#eab308' : '#ef4444') : '#888';
|
|
2218
|
-
var pingElement =
|
|
2244
|
+
var pingElement = root.getElementById('debug-ping-' + uniquePanelId);
|
|
2219
2245
|
if (pingElement) {
|
|
2220
2246
|
pingElement.textContent = pingDisplay;
|
|
2221
2247
|
pingElement.style.color = pingColor;
|
|
@@ -2241,7 +2267,7 @@
|
|
|
2241
2267
|
}
|
|
2242
2268
|
// Draw graph on canvas
|
|
2243
2269
|
function drawGraph(canvasId, data, color) {
|
|
2244
|
-
var canvas =
|
|
2270
|
+
var canvas = getDebugRoot().getElementById(canvasId);
|
|
2245
2271
|
if (!canvas)
|
|
2246
2272
|
return;
|
|
2247
2273
|
var ctx = canvas.getContext('2d');
|
|
@@ -2403,7 +2429,7 @@
|
|
|
2403
2429
|
room.onMessage('__playground_message_types', (messageTypes) => {
|
|
2404
2430
|
debugInfo.messageTypes = messageTypes;
|
|
2405
2431
|
// Show/hide message button based on message types availability
|
|
2406
|
-
var messageBtnElement =
|
|
2432
|
+
var messageBtnElement = getDebugRoot().getElementById('debug-message-btn-' + uniquePanelId);
|
|
2407
2433
|
if (messageBtnElement) {
|
|
2408
2434
|
messageBtnElement.style.display = messageTypes ? 'flex' : 'none';
|
|
2409
2435
|
}
|
|
@@ -2537,7 +2563,7 @@
|
|
|
2537
2563
|
debugInfo.pingInterval = null;
|
|
2538
2564
|
}
|
|
2539
2565
|
roomDebugInfo.delete(uniquePanelId);
|
|
2540
|
-
var panel =
|
|
2566
|
+
var panel = getDebugRoot().getElementById('debug-panel-' + uniquePanelId);
|
|
2541
2567
|
if (panel) {
|
|
2542
2568
|
panel.remove();
|
|
2543
2569
|
repositionDebugPanels();
|