@@ -49,11 +49,17 @@
|
|
49
49
|
|
50
50
|
|
51
51
|
/** Set false to prevent overlay messages from being shown */
|
52
|
-
export function
|
52
|
+
export function setAllowBalloonMessages(allow: boolean) {
|
53
53
|
hide = !allow;
|
54
54
|
if (allow) console.error = patchedConsoleError;
|
55
55
|
else console.error = originalConsoleError;
|
56
56
|
}
|
57
|
+
/**
|
58
|
+
* @deprecated Use {@link setAllowBalloonMessages} instead
|
59
|
+
*/
|
60
|
+
export function setAllowOverlayMessages(allow: boolean) {
|
61
|
+
return setAllowBalloonMessages(allow);
|
62
|
+
}
|
57
63
|
|
58
64
|
export function makeErrorsVisibleForDevelopment() {
|
59
65
|
if (hide) return;
|
@@ -134,8 +140,12 @@
|
|
134
140
|
// return "";
|
135
141
|
// }
|
136
142
|
|
137
|
-
|
143
|
+
/**
|
144
|
+
*
|
145
|
+
*/
|
146
|
+
const currentMessages = new Map<string, Function>();
|
138
147
|
|
148
|
+
|
139
149
|
function showMessage(type: LogType, element: HTMLElement, msg: string | null | undefined) {
|
140
150
|
if (msg === null || msg === undefined) return;
|
141
151
|
|
@@ -146,19 +156,37 @@
|
|
146
156
|
}
|
147
157
|
// truncate long messages before they go into the cache/set
|
148
158
|
if (msg.length > 400) msg = msg.substring(0, 400) + "...";
|
149
|
-
|
150
|
-
|
159
|
+
|
160
|
+
const key = msg;
|
161
|
+
|
162
|
+
if (currentMessages.has(key)) {
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
151
166
|
const msgcontainer = getMessageContainer(type, msg);
|
152
167
|
container.prepend(msgcontainer);
|
153
168
|
|
154
|
-
const
|
155
|
-
|
156
|
-
currentMessages.delete(_msg);
|
169
|
+
const removeFunction = () => {
|
170
|
+
currentMessages.delete(key);
|
157
171
|
returnMessageContainer(msgcontainer);
|
158
|
-
}
|
172
|
+
};
|
173
|
+
currentMessages.set(key, removeFunction);
|
174
|
+
|
175
|
+
setTimeout(removeFunction, 10_000);
|
159
176
|
}
|
160
177
|
|
178
|
+
/**
|
179
|
+
* Clear all overlay messages from the screen
|
180
|
+
*/
|
181
|
+
export function clearMessages() {
|
182
|
+
if (debug) console.log("Clearing messages");
|
183
|
+
for (const cur of currentMessages.values()) {
|
184
|
+
cur?.call(cur);
|
185
|
+
}
|
186
|
+
currentMessages.clear();
|
187
|
+
}
|
161
188
|
|
189
|
+
|
162
190
|
const logsContainerStyles = `
|
163
191
|
|
164
192
|
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');
|
@@ -222,6 +250,7 @@
|
|
222
250
|
flex-direction: column;
|
223
251
|
color: white;
|
224
252
|
overflow: auto;
|
253
|
+
word-break: break-word;
|
225
254
|
`
|
226
255
|
if (domElement.shadowRoot)
|
227
256
|
domElement.shadowRoot.appendChild(container);
|
@@ -238,18 +267,6 @@
|
|
238
267
|
const typeSymbol = Symbol("logtype");
|
239
268
|
const containerCache = new Map<LogType, HTMLElement[]>();
|
240
269
|
|
241
|
-
/**
|
242
|
-
* Clear all messages from the overlay
|
243
|
-
*/
|
244
|
-
export function clearMessages() {
|
245
|
-
const array = Array.from(containerCache.values());
|
246
|
-
for (const cache of array) {
|
247
|
-
for (const container of cache) {
|
248
|
-
returnMessageContainer(container);
|
249
|
-
}
|
250
|
-
}
|
251
|
-
}
|
252
|
-
|
253
270
|
function returnMessageContainer(container: HTMLElement) {
|
254
271
|
container.remove();
|
255
272
|
const type = container[typeSymbol];
|
@@ -1,10 +1,17 @@
|
|
1
1
|
import { isLocalNetwork } from "../engine_networking_utils.js";
|
2
2
|
import { getParam } from "../engine_utils.js";
|
3
3
|
import { showDebugConsole } from "./debug_console.js";
|
4
|
-
import { addLog, clearMessages,LogType, setAllowOverlayMessages } from "./debug_overlay.js";
|
4
|
+
import { addLog, clearMessages, LogType, setAllowOverlayMessages, setAllowBalloonMessages } from "./debug_overlay.js";
|
5
5
|
|
6
6
|
export { showDebugConsole }
|
7
|
-
export {
|
7
|
+
export {
|
8
|
+
clearMessages as clearBalloonMessages,
|
9
|
+
/** @deprecated use clearBalloonMessages instead */
|
10
|
+
clearMessages as clearOverlayMessages,
|
11
|
+
LogType,
|
12
|
+
setAllowOverlayMessages,
|
13
|
+
setAllowBalloonMessages,
|
14
|
+
};
|
8
15
|
export { enableSpatialConsole } from "./debug_spatial_console.js";
|
9
16
|
|
10
17
|
const noDevLogs = getParam("nodevlogs");
|