@adcops/autocore-react 3.0.40 → 3.3.2
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/additional-docs/AutoCoreTagContext.md +441 -0
- package/additional-docs/react_performance_notes.md +94 -0
- package/dist/assets/BlocklyLogo.d.ts +1 -0
- package/dist/assets/BlocklyLogo.d.ts.map +1 -0
- package/dist/assets/Distance.d.ts +1 -0
- package/dist/assets/Distance.d.ts.map +1 -0
- package/dist/assets/JogLong.d.ts +1 -0
- package/dist/assets/JogLong.d.ts.map +1 -0
- package/dist/assets/JogMedium.d.ts +1 -0
- package/dist/assets/JogMedium.d.ts.map +1 -0
- package/dist/assets/JogShort.d.ts +1 -0
- package/dist/assets/JogShort.d.ts.map +1 -0
- package/dist/assets/PythonLogo.d.ts +1 -0
- package/dist/assets/PythonLogo.d.ts.map +1 -0
- package/dist/assets/Rotation3D.d.ts +1 -0
- package/dist/assets/Rotation3D.d.ts.map +1 -0
- package/dist/assets/RotationCcw.d.ts +1 -0
- package/dist/assets/RotationCcw.d.ts.map +1 -0
- package/dist/assets/RotationCcwA.d.ts +1 -0
- package/dist/assets/RotationCcwA.d.ts.map +1 -0
- package/dist/assets/RotationCcwB.d.ts +1 -0
- package/dist/assets/RotationCcwB.d.ts.map +1 -0
- package/dist/assets/RotationCcwC.d.ts +1 -0
- package/dist/assets/RotationCcwC.d.ts.map +1 -0
- package/dist/assets/RotationCw.d.ts +1 -0
- package/dist/assets/RotationCw.d.ts.map +1 -0
- package/dist/assets/RotationCwA.d.ts +1 -0
- package/dist/assets/RotationCwA.d.ts.map +1 -0
- package/dist/assets/RotationCwB.d.ts +1 -0
- package/dist/assets/RotationCwB.d.ts.map +1 -0
- package/dist/assets/RotationCwC.d.ts +1 -0
- package/dist/assets/RotationCwC.d.ts.map +1 -0
- package/dist/assets/Run.d.ts +1 -0
- package/dist/assets/Run.d.ts.map +1 -0
- package/dist/assets/Speed.d.ts +1 -0
- package/dist/assets/Speed.d.ts.map +1 -0
- package/dist/assets/SpeedFast.d.ts +1 -0
- package/dist/assets/SpeedFast.d.ts.map +1 -0
- package/dist/assets/SpeedMedium.d.ts +1 -0
- package/dist/assets/SpeedMedium.d.ts.map +1 -0
- package/dist/assets/SpeedNone.d.ts +1 -0
- package/dist/assets/SpeedNone.d.ts.map +1 -0
- package/dist/assets/SpeedSlow.d.ts +1 -0
- package/dist/assets/SpeedSlow.d.ts.map +1 -0
- package/dist/assets/Walk.d.ts +1 -0
- package/dist/assets/Walk.d.ts.map +1 -0
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/components/AutoCoreDevPanel.d.ts +144 -0
- package/dist/components/AutoCoreDevPanel.d.ts.map +1 -0
- package/dist/components/AutoCoreDevPanel.js +1 -0
- package/dist/components/BlocklyEditor.d.ts +1 -0
- package/dist/components/BlocklyEditor.d.ts.map +1 -0
- package/dist/components/BlocklyEditor.js +1 -1
- package/dist/components/CodeEditor.d.ts +2 -1
- package/dist/components/CodeEditor.d.ts.map +1 -0
- package/dist/components/CodeEditor.js +1 -1
- package/dist/components/FileList.d.ts +1 -0
- package/dist/components/FileList.d.ts.map +1 -0
- package/dist/components/FileList.js +1 -1
- package/dist/components/FileSelect.d.ts +1 -0
- package/dist/components/FileSelect.d.ts.map +1 -0
- package/dist/components/FileSelect.js +1 -1
- package/dist/components/FitText.d.ts +1 -0
- package/dist/components/FitText.d.ts.map +1 -0
- package/dist/components/FitText.js +1 -1
- package/dist/components/Indicator.d.ts +2 -1
- package/dist/components/Indicator.d.ts.map +1 -0
- package/dist/components/Indicator.js +1 -1
- package/dist/components/IndicatorButton.d.ts +2 -1
- package/dist/components/IndicatorButton.d.ts.map +1 -0
- package/dist/components/IndicatorButton.js +1 -1
- package/dist/components/IndicatorRect.d.ts +2 -1
- package/dist/components/IndicatorRect.d.ts.map +1 -0
- package/dist/components/JogPanel.d.ts +1 -0
- package/dist/components/JogPanel.d.ts.map +1 -0
- package/dist/components/Lamp.d.ts +2 -1
- package/dist/components/Lamp.d.ts.map +1 -0
- package/dist/components/Lamp.js +1 -1
- package/dist/components/Osk.d.ts +1 -0
- package/dist/components/Osk.d.ts.map +1 -0
- package/dist/components/Osk.js +1 -1
- package/dist/components/OskDialog.d.ts +1 -0
- package/dist/components/OskDialog.d.ts.map +1 -0
- package/dist/components/ProgressBarWithValue.d.ts +1 -0
- package/dist/components/ProgressBarWithValue.d.ts.map +1 -0
- package/dist/components/ProgressBarWithValue.js +1 -1
- package/dist/components/TextInput.d.ts +62 -103
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +1 -1
- package/dist/components/ToggleGroup.d.ts +2 -1
- package/dist/components/ToggleGroup.d.ts.map +1 -0
- package/dist/components/ToggleGroup.js +1 -1
- package/dist/components/ValueDisplay.d.ts +3 -2
- package/dist/components/ValueDisplay.d.ts.map +1 -0
- package/dist/components/ValueDisplay.js +1 -1
- package/dist/components/ValueIndicator.d.ts +2 -1
- package/dist/components/ValueIndicator.d.ts.map +1 -0
- package/dist/components/ValueIndicator.js +1 -1
- package/dist/components/ValueInput.d.ts +2 -1
- package/dist/components/ValueInput.d.ts.map +1 -0
- package/dist/components/ValueInput.js +1 -1
- package/dist/core/ActionMode.d.ts +1 -0
- package/dist/core/ActionMode.d.ts.map +1 -0
- package/dist/core/AutoCoreTagContext.d.ts +98 -0
- package/dist/core/AutoCoreTagContext.d.ts.map +1 -0
- package/dist/core/AutoCoreTagContext.js +1 -0
- package/dist/core/AutoCoreTagTypes.d.ts +283 -0
- package/dist/core/AutoCoreTagTypes.d.ts.map +1 -0
- package/dist/core/AutoCoreTagTypes.js +1 -0
- package/dist/core/CoreStreamTypes.d.ts +345 -0
- package/dist/core/CoreStreamTypes.d.ts.map +1 -0
- package/dist/core/CoreStreamTypes.js +1 -0
- package/dist/core/EventEmitterContext.d.ts +113 -202
- package/dist/core/EventEmitterContext.d.ts.map +1 -0
- package/dist/core/EventEmitterContext.js +1 -1
- package/dist/core/IndicatorButtonState.d.ts +1 -0
- package/dist/core/IndicatorButtonState.d.ts.map +1 -0
- package/dist/core/IndicatorColor.d.ts +1 -0
- package/dist/core/IndicatorColor.d.ts.map +1 -0
- package/dist/core/MaskPatterns.d.ts +1 -0
- package/dist/core/MaskPatterns.d.ts.map +1 -0
- package/dist/core/NumerableTypes.d.ts +1 -0
- package/dist/core/NumerableTypes.d.ts.map +1 -0
- package/dist/core/NumerableTypes.js +1 -1
- package/dist/core/PositionContext.d.ts +1 -1
- package/dist/core/PositionContext.d.ts.map +1 -0
- package/dist/core/UniqueId.d.ts +1 -0
- package/dist/core/UniqueId.d.ts.map +1 -0
- package/dist/core/ValueSimulator.d.ts +2 -1
- package/dist/core/ValueSimulator.d.ts.map +1 -0
- package/dist/core/ValueSimulator.js +1 -1
- package/dist/core/hoc.d.ts +1 -0
- package/dist/core/hoc.d.ts.map +1 -0
- package/dist/core/hoc.js +1 -1
- package/dist/hooks/adsHooks.d.ts +1 -0
- package/dist/hooks/adsHooks.d.ts.map +1 -0
- package/dist/hooks/adsHooks.js +1 -1
- package/dist/hooks/commandHooks.d.ts +4 -3
- package/dist/hooks/commandHooks.d.ts.map +1 -0
- package/dist/hooks/commandHooks.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAutoCoreTag.d.ts +26 -0
- package/dist/hooks/useAutoCoreTag.d.ts.map +1 -0
- package/dist/hooks/useAutoCoreTag.js +1 -0
- package/dist/hooks/useScaledValue.d.ts +1 -0
- package/dist/hooks/useScaledValue.d.ts.map +1 -0
- package/dist/hooks/useScaledValue.js +1 -1
- package/dist/hub/CommandMessage.d.ts +19 -9
- package/dist/hub/CommandMessage.d.ts.map +1 -0
- package/dist/hub/CommandMessage.js +1 -1
- package/dist/hub/DebugPanel.d.ts +31 -0
- package/dist/hub/DebugPanel.d.ts.map +1 -0
- package/dist/hub/DebugPanel.js +1 -0
- package/dist/hub/HubBase.d.ts +85 -130
- package/dist/hub/HubBase.d.ts.map +1 -0
- package/dist/hub/HubBase.js +1 -1
- package/dist/hub/HubSimulate.d.ts +42 -8
- package/dist/hub/HubSimulate.d.ts.map +1 -0
- package/dist/hub/HubSimulate.js +1 -1
- package/dist/hub/HubTauri.d.ts +25 -60
- package/dist/hub/HubTauri.d.ts.map +1 -0
- package/dist/hub/HubTauri.js +1 -1
- package/dist/hub/HubWebSocket.d.ts +34 -17
- package/dist/hub/HubWebSocket.d.ts.map +1 -0
- package/dist/hub/HubWebSocket.js +1 -1
- package/dist/hub/debug.d.ts +23 -0
- package/dist/hub/debug.d.ts.map +1 -0
- package/dist/hub/debug.js +1 -0
- package/dist/hub/index.d.ts +20 -4
- package/dist/hub/index.d.ts.map +1 -0
- package/dist/hub/index.js +1 -1
- package/package.json +32 -27
- package/readme.md +193 -22
- package/src/components/AutoCoreDevPanel.tsx +414 -0
- package/src/components/CodeEditor.tsx +2 -2
- package/src/components/FileList.tsx +7 -6
- package/src/components/FileSelect.tsx +2 -1
- package/src/components/Indicator.tsx +2 -2
- package/src/components/IndicatorButton.tsx +2 -2
- package/src/components/IndicatorRect.tsx +2 -2
- package/src/components/Lamp.tsx +3 -3
- package/src/components/TextInput.tsx +159 -240
- package/src/components/ToggleGroup.tsx +3 -3
- package/src/components/ValueDisplay.tsx +4 -4
- package/src/components/ValueIndicator.tsx +2 -2
- package/src/components/ValueInput.tsx +2 -2
- package/src/core/ActionMode.ts +1 -1
- package/src/core/AutoCoreTagContext.tsx +615 -0
- package/src/core/AutoCoreTagTypes.ts +334 -0
- package/src/core/CoreStreamTypes.ts +512 -0
- package/src/core/EventEmitterContext.tsx +257 -281
- package/src/core/IndicatorButtonState.ts +1 -1
- package/src/core/ValueSimulator.ts +2 -2
- package/src/core/hoc.tsx +1 -1
- package/src/hooks/adsHooks.tsx +21 -22
- package/src/hooks/commandHooks.tsx +23 -19
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useAutoCoreTag.ts +103 -0
- package/src/hooks/useScaledValue.tsx +1 -1
- package/src/hub/CommandMessage.ts +71 -19
- package/src/hub/DebugPanel.ts +280 -0
- package/src/hub/HubBase.ts +147 -223
- package/src/hub/HubSimulate.ts +93 -24
- package/src/hub/HubTauri.ts +87 -96
- package/src/hub/HubWebSocket.ts +133 -158
- package/src/hub/debug.ts +211 -0
- package/src/hub/index.ts +49 -39
- package/tsconfig.json +43 -28
- package/docs/classes/components_BlocklyEditor.BlocklyEditor.html +0 -124
- package/docs/classes/components_CodeEditor.CodeEditor.html +0 -128
- package/docs/classes/components_JogPanel.JogPanel.html +0 -138
- package/docs/classes/components_Lamp.Lamp.html +0 -105
- package/docs/classes/components_TextInput.TextInput.html +0 -115
- package/docs/classes/components_ValueIndicator.ValueIndicator.html +0 -119
- package/docs/classes/components_ValueInput.ValueInput.html +0 -113
- package/docs/classes/hub_HubWebSocket.HubWebSocket.html +0 -106
- package/docs/enums/components_JogPanel.JogDistanceAction.html +0 -5
- package/docs/enums/components_JogPanel.JogPanelAction.html +0 -18
- package/docs/enums/components_JogPanel.JogSpeedAction.html +0 -5
- package/docs/enums/core_ActionMode.ActionMode.html +0 -6
- package/docs/enums/core_IndicatorColor.IndicatorColor.html +0 -23
- package/docs/functions/assets_BlocklyLogo.default.html +0 -1
- package/docs/functions/assets_Distance.default.html +0 -1
- package/docs/functions/assets_JogLong.default.html +0 -1
- package/docs/functions/assets_JogMedium.default.html +0 -1
- package/docs/functions/assets_JogShort.default.html +0 -1
- package/docs/functions/assets_PythonLogo.default.html +0 -1
- package/docs/functions/assets_Rotation3D.default.html +0 -1
- package/docs/functions/assets_RotationCcw.default.html +0 -1
- package/docs/functions/assets_RotationCcwA.default.html +0 -1
- package/docs/functions/assets_RotationCcwB.default.html +0 -1
- package/docs/functions/assets_RotationCcwC.default.html +0 -1
- package/docs/functions/assets_RotationCw.default.html +0 -1
- package/docs/functions/assets_RotationCwA.default.html +0 -1
- package/docs/functions/assets_RotationCwB.default.html +0 -1
- package/docs/functions/assets_RotationCwC.default.html +0 -1
- package/docs/functions/assets_Run.default.html +0 -1
- package/docs/functions/assets_Speed.default.html +0 -1
- package/docs/functions/assets_SpeedFast.default.html +0 -1
- package/docs/functions/assets_SpeedMedium.default.html +0 -1
- package/docs/functions/assets_SpeedNone.default.html +0 -1
- package/docs/functions/assets_SpeedSlow.default.html +0 -1
- package/docs/functions/assets_Walk.default.html +0 -1
- package/docs/functions/components_BlocklyEditor.createCustomToolbox.html +0 -6
- package/docs/functions/components_FileList.FileList.html +0 -21
- package/docs/functions/components_FitText.FitText.html +0 -8
- package/docs/functions/components_ToggleGroup.ToggleGroup.html +0 -5
- package/docs/interfaces/components_JogPanel.JogPanelButtonDefinition.html +0 -5
- package/docs/interfaces/components_ToggleGroup.ToggleGroupProps.html +0 -618
- package/docs/interfaces/core_IndicatorButtonState.IndicatorButtonState.html +0 -10
- package/docs/interfaces/hub_CommandMessage.CommandMessage.html +0 -6
- package/docs/interfaces/hub_CommandMessage.CommandMessageResult.html +0 -4
- package/docs/modules/assets.html +0 -23
- package/docs/modules/assets_BlocklyLogo.html +0 -2
- package/docs/modules/assets_Distance.html +0 -2
- package/docs/modules/assets_JogLong.html +0 -2
- package/docs/modules/assets_JogMedium.html +0 -2
- package/docs/modules/assets_JogShort.html +0 -2
- package/docs/modules/assets_PythonLogo.html +0 -2
- package/docs/modules/assets_Rotation3D.html +0 -2
- package/docs/modules/assets_RotationCcw.html +0 -2
- package/docs/modules/assets_RotationCcwA.html +0 -2
- package/docs/modules/assets_RotationCcwB.html +0 -2
- package/docs/modules/assets_RotationCcwC.html +0 -2
- package/docs/modules/assets_RotationCw.html +0 -2
- package/docs/modules/assets_RotationCwA.html +0 -2
- package/docs/modules/assets_RotationCwB.html +0 -2
- package/docs/modules/assets_RotationCwC.html +0 -2
- package/docs/modules/assets_Run.html +0 -2
- package/docs/modules/assets_Speed.html +0 -2
- package/docs/modules/assets_SpeedFast.html +0 -2
- package/docs/modules/assets_SpeedMedium.html +0 -2
- package/docs/modules/assets_SpeedNone.html +0 -2
- package/docs/modules/assets_SpeedSlow.html +0 -2
- package/docs/modules/assets_Walk.html +0 -2
- package/docs/modules/components_BlocklyEditor.html +0 -5
- package/docs/modules/components_CodeEditor.html +0 -3
- package/docs/modules/components_FileList.html +0 -3
- package/docs/modules/components_FitText.html +0 -3
- package/docs/modules/components_JogPanel.html +0 -9
- package/docs/modules/components_Lamp.html +0 -4
- package/docs/modules/components_TextInput.html +0 -2
- package/docs/modules/components_ToggleGroup.html +0 -6
- package/docs/modules/components_ValueIndicator.html +0 -4
- package/docs/modules/components_ValueInput.html +0 -2
- package/docs/modules/core_ActionMode.html +0 -2
- package/docs/modules/core_IndicatorButtonState.html +0 -2
- package/docs/modules/core_IndicatorColor.html +0 -2
- package/docs/modules/hub_CommandMessage.html +0 -3
- package/docs/modules/hub_HubWebSocket.html +0 -2
- package/docs/types/components_IndicatorButton.IndicatorButtonOptionsType.html +0 -1
- package/docs/variables/components_BlocklyEditor.StandardToolbox.html +0 -1
- package/docs/variables/components_JogPanel.DefaultLinearJogButtons.html +0 -2
- package/docs/variables/components_JogPanel.DefaultRotationJogButtons.html +0 -2
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Automated Design Corp. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* DebugPanel - Injects a visible debug panel directly into the DOM
|
|
5
|
+
*
|
|
6
|
+
* This bypasses React entirely to show real-time debug info about
|
|
7
|
+
* WebSocket connections and Hub instances.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
console.log("[DebugPanel.ts] Module loading...");
|
|
11
|
+
|
|
12
|
+
interface DebugLog {
|
|
13
|
+
time: string;
|
|
14
|
+
type: "info" | "warn" | "error" | "send" | "recv";
|
|
15
|
+
source: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class DebugPanel {
|
|
20
|
+
private container: HTMLDivElement | null = null;
|
|
21
|
+
private logContainer: HTMLDivElement | null = null;
|
|
22
|
+
private statsContainer: HTMLDivElement | null = null;
|
|
23
|
+
private logs: DebugLog[] = [];
|
|
24
|
+
private maxLogs = 100;
|
|
25
|
+
|
|
26
|
+
// Stats
|
|
27
|
+
private stats = {
|
|
28
|
+
hubInstancesCreated: 0,
|
|
29
|
+
connectCalls: 0,
|
|
30
|
+
wsOpened: 0,
|
|
31
|
+
wsClosed: 0,
|
|
32
|
+
wsErrors: 0,
|
|
33
|
+
messagesSent: 0,
|
|
34
|
+
messagesReceived: 0,
|
|
35
|
+
currentState: "unknown",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
constructor() {
|
|
39
|
+
this.injectPanel();
|
|
40
|
+
this.log("info", "DebugPanel", "Debug panel initialized");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private injectPanel(): void {
|
|
44
|
+
// Check for existing panel and remove it (handles HMR/StrictMode)
|
|
45
|
+
const existing = document.getElementById("autocore-debug-panel");
|
|
46
|
+
if (existing) {
|
|
47
|
+
existing.remove();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Create container
|
|
51
|
+
this.container = document.createElement("div");
|
|
52
|
+
this.container.id = "autocore-debug-panel";
|
|
53
|
+
this.container.innerHTML = `
|
|
54
|
+
<style>
|
|
55
|
+
#autocore-debug-panel {
|
|
56
|
+
position: fixed;
|
|
57
|
+
bottom: 10px;
|
|
58
|
+
right: 10px;
|
|
59
|
+
width: 400px;
|
|
60
|
+
max-height: 300px;
|
|
61
|
+
background: rgba(0, 0, 0, 0.9);
|
|
62
|
+
color: #0f0;
|
|
63
|
+
font-family: monospace;
|
|
64
|
+
font-size: 11px;
|
|
65
|
+
border: 1px solid #0f0;
|
|
66
|
+
border-radius: 4px;
|
|
67
|
+
z-index: 99999;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
}
|
|
70
|
+
#autocore-debug-panel .header {
|
|
71
|
+
background: #0f0;
|
|
72
|
+
color: #000;
|
|
73
|
+
padding: 4px 8px;
|
|
74
|
+
font-weight: bold;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
display: flex;
|
|
77
|
+
justify-content: space-between;
|
|
78
|
+
}
|
|
79
|
+
#autocore-debug-panel .stats {
|
|
80
|
+
padding: 4px 8px;
|
|
81
|
+
border-bottom: 1px solid #0f0;
|
|
82
|
+
display: grid;
|
|
83
|
+
grid-template-columns: 1fr 1fr;
|
|
84
|
+
gap: 2px;
|
|
85
|
+
}
|
|
86
|
+
#autocore-debug-panel .stats span {
|
|
87
|
+
color: #fff;
|
|
88
|
+
}
|
|
89
|
+
#autocore-debug-panel .stats .value {
|
|
90
|
+
color: #ff0;
|
|
91
|
+
}
|
|
92
|
+
#autocore-debug-panel .logs {
|
|
93
|
+
max-height: 180px;
|
|
94
|
+
overflow-y: auto;
|
|
95
|
+
padding: 4px;
|
|
96
|
+
}
|
|
97
|
+
#autocore-debug-panel .log-entry {
|
|
98
|
+
margin: 1px 0;
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
text-overflow: ellipsis;
|
|
102
|
+
}
|
|
103
|
+
#autocore-debug-panel .log-entry.info { color: #888; }
|
|
104
|
+
#autocore-debug-panel .log-entry.warn { color: #fa0; }
|
|
105
|
+
#autocore-debug-panel .log-entry.error { color: #f44; }
|
|
106
|
+
#autocore-debug-panel .log-entry.send { color: #4f4; }
|
|
107
|
+
#autocore-debug-panel .log-entry.recv { color: #44f; }
|
|
108
|
+
#autocore-debug-panel .state-connected { color: #4f4 !important; }
|
|
109
|
+
#autocore-debug-panel .state-disconnected { color: #f44 !important; }
|
|
110
|
+
#autocore-debug-panel .state-connecting { color: #fa0 !important; }
|
|
111
|
+
</style>
|
|
112
|
+
<div class="header">
|
|
113
|
+
<span>AutoCore Debug</span>
|
|
114
|
+
<span id="debug-toggle">[_]</span>
|
|
115
|
+
</div>
|
|
116
|
+
<div id="debug-content">
|
|
117
|
+
<div class="stats" id="debug-stats"></div>
|
|
118
|
+
<div class="logs" id="debug-logs"></div>
|
|
119
|
+
</div>
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
// Wait for DOM ready
|
|
123
|
+
if (document.body) {
|
|
124
|
+
document.body.appendChild(this.container);
|
|
125
|
+
this.setupElements();
|
|
126
|
+
} else {
|
|
127
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
128
|
+
document.body.appendChild(this.container!);
|
|
129
|
+
this.setupElements();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private setupElements(): void {
|
|
135
|
+
this.statsContainer = document.getElementById("debug-stats") as HTMLDivElement;
|
|
136
|
+
this.logContainer = document.getElementById("debug-logs") as HTMLDivElement;
|
|
137
|
+
|
|
138
|
+
// Toggle button
|
|
139
|
+
const toggle = document.getElementById("debug-toggle");
|
|
140
|
+
const content = document.getElementById("debug-content");
|
|
141
|
+
toggle?.addEventListener("click", () => {
|
|
142
|
+
if (content) {
|
|
143
|
+
content.style.display = content.style.display === "none" ? "block" : "none";
|
|
144
|
+
toggle.textContent = content.style.display === "none" ? "[+]" : "[_]";
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
this.updateStats();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private updateStats(): void {
|
|
152
|
+
if (!this.statsContainer) return;
|
|
153
|
+
|
|
154
|
+
const stateClass =
|
|
155
|
+
this.stats.currentState === "OPEN"
|
|
156
|
+
? "state-connected"
|
|
157
|
+
: this.stats.currentState === "CONNECTING"
|
|
158
|
+
? "state-connecting"
|
|
159
|
+
: "state-disconnected";
|
|
160
|
+
|
|
161
|
+
this.statsContainer.innerHTML = `
|
|
162
|
+
<div><span>Hub Instances:</span> <span class="value">${this.stats.hubInstancesCreated}</span></div>
|
|
163
|
+
<div><span>connect() calls:</span> <span class="value">${this.stats.connectCalls}</span></div>
|
|
164
|
+
<div><span>WS Opened:</span> <span class="value">${this.stats.wsOpened}</span></div>
|
|
165
|
+
<div><span>WS Closed:</span> <span class="value">${this.stats.wsClosed}</span></div>
|
|
166
|
+
<div><span>WS Errors:</span> <span class="value">${this.stats.wsErrors}</span></div>
|
|
167
|
+
<div><span>Msgs Sent:</span> <span class="value">${this.stats.messagesSent}</span></div>
|
|
168
|
+
<div><span>Msgs Recv:</span> <span class="value">${this.stats.messagesReceived}</span></div>
|
|
169
|
+
<div><span>WS State:</span> <span class="value ${stateClass}">${this.stats.currentState}</span></div>
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
log(type: DebugLog["type"], source: string, message: string): void {
|
|
174
|
+
const time = new Date().toTimeString().slice(0, 8);
|
|
175
|
+
const entry: DebugLog = { time, type, source, message };
|
|
176
|
+
|
|
177
|
+
this.logs.push(entry);
|
|
178
|
+
if (this.logs.length > this.maxLogs) {
|
|
179
|
+
this.logs.shift();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Also log to console
|
|
183
|
+
const prefix = `[${time}] [${source}]`;
|
|
184
|
+
switch (type) {
|
|
185
|
+
case "error":
|
|
186
|
+
console.error(prefix, message);
|
|
187
|
+
break;
|
|
188
|
+
case "warn":
|
|
189
|
+
console.warn(prefix, message);
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
console.log(prefix, message);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
this.renderLogs();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private renderLogs(): void {
|
|
199
|
+
if (!this.logContainer) return;
|
|
200
|
+
|
|
201
|
+
this.logContainer.innerHTML = this.logs
|
|
202
|
+
.slice(-50) // Show last 50
|
|
203
|
+
.map(
|
|
204
|
+
(log) =>
|
|
205
|
+
`<div class="log-entry ${log.type}">[${log.time}] ${log.source}: ${log.message}</div>`
|
|
206
|
+
)
|
|
207
|
+
.join("");
|
|
208
|
+
|
|
209
|
+
// Auto-scroll to bottom
|
|
210
|
+
this.logContainer.scrollTop = this.logContainer.scrollHeight;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Stat update methods
|
|
214
|
+
hubCreated(): void {
|
|
215
|
+
this.stats.hubInstancesCreated++;
|
|
216
|
+
this.log("warn", "Hub", `NEW INSTANCE CREATED (total: ${this.stats.hubInstancesCreated})`);
|
|
217
|
+
this.updateStats();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
connectCalled(socketState: string): void {
|
|
221
|
+
this.stats.connectCalls++;
|
|
222
|
+
this.stats.currentState = socketState;
|
|
223
|
+
this.log("info", "Hub", `connect() called (socket state: ${socketState})`);
|
|
224
|
+
this.updateStats();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
wsOpened(url: string): void {
|
|
228
|
+
this.stats.wsOpened++;
|
|
229
|
+
this.stats.currentState = "OPEN";
|
|
230
|
+
this.log("info", "WS", `OPENED: ${url}`);
|
|
231
|
+
this.updateStats();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
wsClosed(code: number, reason: string): void {
|
|
235
|
+
this.stats.wsClosed++;
|
|
236
|
+
this.stats.currentState = "CLOSED";
|
|
237
|
+
this.log("warn", "WS", `CLOSED: code=${code}, reason=${reason}`);
|
|
238
|
+
this.updateStats();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
wsError(error: string): void {
|
|
242
|
+
this.stats.wsErrors++;
|
|
243
|
+
this.log("error", "WS", `ERROR: ${error}`);
|
|
244
|
+
this.updateStats();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
messageSent(type: string, command: string, requestId: number): void {
|
|
248
|
+
this.stats.messagesSent++;
|
|
249
|
+
this.log("send", "WS", `>>> ${type}/${command} (id=${requestId})`);
|
|
250
|
+
this.updateStats();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
messageReceived(type: string, command: string, requestId?: number): void {
|
|
254
|
+
this.stats.messagesReceived++;
|
|
255
|
+
this.log("recv", "WS", `<<< ${type}/${command} (id=${requestId ?? "none"})`);
|
|
256
|
+
this.updateStats();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
updateState(state: string): void {
|
|
260
|
+
this.stats.currentState = state;
|
|
261
|
+
this.updateStats();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Create singleton and expose globally
|
|
266
|
+
let debugPanel: DebugPanel | null = null;
|
|
267
|
+
|
|
268
|
+
export function getDebugPanel(): DebugPanel {
|
|
269
|
+
if (!debugPanel) {
|
|
270
|
+
debugPanel = new DebugPanel();
|
|
271
|
+
// Expose globally for console access
|
|
272
|
+
(window as any).__AUTOCORE_DEBUG_PANEL__ = debugPanel;
|
|
273
|
+
}
|
|
274
|
+
return debugPanel;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Auto-initialize on import
|
|
278
|
+
getDebugPanel();
|
|
279
|
+
|
|
280
|
+
export default getDebugPanel;
|