@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
package/src/hub/debug.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Automated Design Corp. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Debug Logging Utility for CoreStream/Hub Communication
|
|
5
|
+
*
|
|
6
|
+
* This utility provides debug logging that won't be stripped by production builds.
|
|
7
|
+
* It uses console.warn/console.error which are typically preserved, and stores
|
|
8
|
+
* logs in a buffer that can be inspected from the browser console.
|
|
9
|
+
*
|
|
10
|
+
* Usage in browser console:
|
|
11
|
+
* window.__AUTOCORE_DEBUG__.enable() - Enable debug logging
|
|
12
|
+
* window.__AUTOCORE_DEBUG__.disable() - Disable debug logging
|
|
13
|
+
* window.__AUTOCORE_DEBUG__.logs - View all logged messages
|
|
14
|
+
* window.__AUTOCORE_DEBUG__.clear() - Clear log buffer
|
|
15
|
+
* window.__AUTOCORE_DEBUG__.dump() - Dump all logs to console
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface DebugLogEntry {
|
|
19
|
+
timestamp: number;
|
|
20
|
+
source: string;
|
|
21
|
+
level: "info" | "warn" | "error" | "send" | "recv";
|
|
22
|
+
message: string;
|
|
23
|
+
data?: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface DebugState {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
logs: DebugLogEntry[];
|
|
29
|
+
maxLogs: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Global state - attached to window for browser console access
|
|
33
|
+
const state: DebugState = {
|
|
34
|
+
enabled: true, // Start enabled for debugging
|
|
35
|
+
logs: [],
|
|
36
|
+
maxLogs: 1000,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Format timestamp as HH:MM:SS.mmm
|
|
40
|
+
function formatTime(ts: number): string {
|
|
41
|
+
const d = new Date(ts);
|
|
42
|
+
return d.toTimeString().slice(0, 8) + "." + String(d.getMilliseconds()).padStart(3, "0");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Format log entry for console output
|
|
46
|
+
function formatEntry(entry: DebugLogEntry): string {
|
|
47
|
+
return `[${formatTime(entry.timestamp)}] [${entry.source}] ${entry.message}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Add a log entry
|
|
51
|
+
function addLog(
|
|
52
|
+
source: string,
|
|
53
|
+
level: DebugLogEntry["level"],
|
|
54
|
+
message: string,
|
|
55
|
+
data?: unknown
|
|
56
|
+
): void {
|
|
57
|
+
const entry: DebugLogEntry = {
|
|
58
|
+
timestamp: Date.now(),
|
|
59
|
+
source,
|
|
60
|
+
level,
|
|
61
|
+
message,
|
|
62
|
+
data,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Add to buffer (with size limit)
|
|
66
|
+
state.logs.push(entry);
|
|
67
|
+
if (state.logs.length > state.maxLogs) {
|
|
68
|
+
state.logs.shift();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Output to console if enabled
|
|
72
|
+
if (state.enabled) {
|
|
73
|
+
const formatted = formatEntry(entry);
|
|
74
|
+
const style = getLogStyle(level);
|
|
75
|
+
|
|
76
|
+
switch (level) {
|
|
77
|
+
case "error":
|
|
78
|
+
console.error(`%c${formatted}`, style, data !== undefined ? data : "");
|
|
79
|
+
break;
|
|
80
|
+
case "warn":
|
|
81
|
+
console.warn(`%c${formatted}`, style, data !== undefined ? data : "");
|
|
82
|
+
break;
|
|
83
|
+
case "send":
|
|
84
|
+
console.warn(`%c>>> ${formatted}`, style, data !== undefined ? data : "");
|
|
85
|
+
break;
|
|
86
|
+
case "recv":
|
|
87
|
+
console.warn(`%c<<< ${formatted}`, style, data !== undefined ? data : "");
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
console.warn(`%c${formatted}`, style, data !== undefined ? data : "");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Get console style for log level
|
|
96
|
+
function getLogStyle(level: DebugLogEntry["level"]): string {
|
|
97
|
+
switch (level) {
|
|
98
|
+
case "error":
|
|
99
|
+
return "color: #ff4444; font-weight: bold;";
|
|
100
|
+
case "warn":
|
|
101
|
+
return "color: #ffaa00;";
|
|
102
|
+
case "send":
|
|
103
|
+
return "color: #44ff44;"; // Green for outgoing
|
|
104
|
+
case "recv":
|
|
105
|
+
return "color: #4444ff;"; // Blue for incoming
|
|
106
|
+
default:
|
|
107
|
+
return "color: #888888;";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Public debug API
|
|
112
|
+
export const debug = {
|
|
113
|
+
/** Log an info message */
|
|
114
|
+
info(source: string, message: string, data?: unknown): void {
|
|
115
|
+
addLog(source, "info", message, data);
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
/** Log a warning message */
|
|
119
|
+
warn(source: string, message: string, data?: unknown): void {
|
|
120
|
+
addLog(source, "warn", message, data);
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
/** Log an error message */
|
|
124
|
+
error(source: string, message: string, data?: unknown): void {
|
|
125
|
+
addLog(source, "error", message, data);
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/** Log an outgoing message (to server) */
|
|
129
|
+
send(source: string, message: string, data?: unknown): void {
|
|
130
|
+
addLog(source, "send", message, data);
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/** Log an incoming message (from server) */
|
|
134
|
+
recv(source: string, message: string, data?: unknown): void {
|
|
135
|
+
addLog(source, "recv", message, data);
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/** Check if debug is enabled */
|
|
139
|
+
isEnabled(): boolean {
|
|
140
|
+
return state.enabled;
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Browser console API
|
|
145
|
+
const consoleAPI = {
|
|
146
|
+
enable(): void {
|
|
147
|
+
state.enabled = true;
|
|
148
|
+
console.warn("%c[AutoCore Debug] Logging ENABLED", "color: #44ff44; font-weight: bold;");
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
disable(): void {
|
|
152
|
+
state.enabled = false;
|
|
153
|
+
console.warn("%c[AutoCore Debug] Logging DISABLED", "color: #ff4444; font-weight: bold;");
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
get logs(): DebugLogEntry[] {
|
|
157
|
+
return [...state.logs];
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
clear(): void {
|
|
161
|
+
state.logs = [];
|
|
162
|
+
console.warn("%c[AutoCore Debug] Logs cleared", "color: #ffaa00;");
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
dump(): void {
|
|
166
|
+
console.group("[AutoCore Debug] Full Log Dump");
|
|
167
|
+
for (const entry of state.logs) {
|
|
168
|
+
const formatted = formatEntry(entry);
|
|
169
|
+
switch (entry.level) {
|
|
170
|
+
case "send":
|
|
171
|
+
console.log(`%c>>> ${formatted}`, "color: #44ff44;", entry.data);
|
|
172
|
+
break;
|
|
173
|
+
case "recv":
|
|
174
|
+
console.log(`%c<<< ${formatted}`, "color: #4444ff;", entry.data);
|
|
175
|
+
break;
|
|
176
|
+
case "error":
|
|
177
|
+
console.log(`%c${formatted}`, "color: #ff4444;", entry.data);
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
console.log(formatted, entry.data);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
console.groupEnd();
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/** Filter logs by source */
|
|
187
|
+
filterBySource(source: string): DebugLogEntry[] {
|
|
188
|
+
return state.logs.filter((e) => e.source.includes(source));
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/** Filter logs by level */
|
|
192
|
+
filterByLevel(level: DebugLogEntry["level"]): DebugLogEntry[] {
|
|
193
|
+
return state.logs.filter((e) => e.level === level);
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
/** Get only send/recv messages */
|
|
197
|
+
getMessages(): DebugLogEntry[] {
|
|
198
|
+
return state.logs.filter((e) => e.level === "send" || e.level === "recv");
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// Attach to window for browser console access
|
|
203
|
+
if (typeof window !== "undefined") {
|
|
204
|
+
(window as unknown as { __AUTOCORE_DEBUG__: typeof consoleAPI }).__AUTOCORE_DEBUG__ = consoleAPI;
|
|
205
|
+
console.warn(
|
|
206
|
+
"%c[AutoCore Debug] Debug utility loaded. Access via window.__AUTOCORE_DEBUG__",
|
|
207
|
+
"color: #44ff44; font-weight: bold;"
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export default debug;
|
package/src/hub/index.ts
CHANGED
|
@@ -2,68 +2,78 @@
|
|
|
2
2
|
* Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
|
|
3
3
|
* Created Date: 2024-01-16 21:07:29
|
|
4
4
|
* -----
|
|
5
|
-
* Last Modified:
|
|
5
|
+
* Last Modified: 2026-01-29 09:34:39
|
|
6
6
|
* Modified By: ADC
|
|
7
7
|
* -----
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
console.log("[hub/index.ts] Module loading...");
|
|
12
|
+
|
|
11
13
|
import { HubBase as Hub } from './HubBase';
|
|
12
14
|
import { HubTauri } from './HubTauri';
|
|
13
15
|
import { HubWebSocket } from "./HubWebSocket";
|
|
14
|
-
import {HubSimulate} from "./HubSimulate"
|
|
15
|
-
import {
|
|
16
|
+
import { HubSimulate } from "./HubSimulate";
|
|
17
|
+
import { getDebugPanel } from "./DebugPanel";
|
|
16
18
|
|
|
19
|
+
console.log("[hub/index.ts] Imports complete");
|
|
17
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Singleton hub instance.
|
|
23
|
+
* This ensures all components share the same connection to the backend.
|
|
24
|
+
*/
|
|
18
25
|
let hubInstance: Hub | null = null;
|
|
19
26
|
|
|
20
27
|
/**
|
|
21
|
-
* Creates
|
|
22
|
-
*
|
|
28
|
+
* Creates or returns the singleton Hub connection to the backend.
|
|
29
|
+
*
|
|
30
|
+
* The hub type is determined automatically:
|
|
31
|
+
* - If running in Tauri: HubTauri (direct Rust IPC)
|
|
32
|
+
* - Otherwise: HubWebSocket (WebSocket to autocore-server)
|
|
33
|
+
*
|
|
34
|
+
* @returns Hub The singleton hub instance
|
|
23
35
|
*/
|
|
24
36
|
export function createHub(): Hub {
|
|
37
|
+
console.log("[HUB] createHub() called");
|
|
38
|
+
const panel = getDebugPanel();
|
|
39
|
+
panel.log("info", "createHub", `called (hasInstance: ${!!hubInstance})`);
|
|
25
40
|
|
|
26
41
|
if (!hubInstance) {
|
|
27
|
-
if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
|
|
28
|
-
|
|
42
|
+
if (typeof window !== 'undefined' && (window as any).__TAURI__ !== undefined && (window as any).__TAURI__ !== null) {
|
|
43
|
+
panel.log("info", "createHub", "Creating HubTauri instance");
|
|
29
44
|
hubInstance = new HubTauri();
|
|
30
45
|
} else {
|
|
31
|
-
|
|
46
|
+
panel.log("info", "createHub", "Creating HubWebSocket instance");
|
|
32
47
|
hubInstance = new HubWebSocket();
|
|
33
48
|
}
|
|
49
|
+
} else {
|
|
50
|
+
panel.log("info", "createHub", "Returning existing hub instance");
|
|
34
51
|
}
|
|
35
52
|
return hubInstance;
|
|
36
|
-
|
|
37
|
-
// if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
|
|
38
|
-
// // Standalone Tauri application
|
|
39
|
-
// console.log("HUB: Starting link to Tauri backend.");
|
|
40
|
-
// return new HubTauri();
|
|
41
|
-
// }
|
|
42
|
-
// // else if (
|
|
43
|
-
// // window.location.port !== undefined
|
|
44
|
-
// // && window.location.port.length > 0
|
|
45
|
-
// // && window.location.port !== '80'
|
|
46
|
-
// // && window.location.port !== '8080'
|
|
47
|
-
// // && window.location.port !== '443'
|
|
48
|
-
// // ) {
|
|
49
|
-
|
|
50
|
-
// // // We're loaded in some development environment
|
|
51
|
-
// // console.log("HUB: Starting HUB SIMULATOR.");
|
|
52
|
-
// // return new HubSimulate();
|
|
53
|
+
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Returns the current hub instance, or null if not yet created.
|
|
57
|
+
* Useful for checking if a hub exists without creating one.
|
|
58
|
+
*/
|
|
59
|
+
export function getHubInstance(): Hub | null {
|
|
60
|
+
return hubInstance;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Resets the singleton hub instance.
|
|
65
|
+
* This should only be used for testing or when intentionally reconnecting.
|
|
66
|
+
*/
|
|
67
|
+
export function resetHub(): void {
|
|
68
|
+
hubInstance = null;
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
// Export HubBase for convenience to save importing throughout the application.
|
|
72
|
+
export { HubBase as Hub } from './HubBase';
|
|
73
|
+
export { HubTauri };
|
|
74
|
+
export { HubWebSocket };
|
|
75
|
+
export { HubSimulate };
|
|
62
76
|
|
|
63
|
-
// Export
|
|
64
|
-
|
|
65
|
-
export {
|
|
66
|
-
export {HubTauri}
|
|
67
|
-
export {HubWebSocket}
|
|
68
|
-
export {HubSimulate}
|
|
69
|
-
export type {CommandMessage, CommandMessageResult}
|
|
77
|
+
// Export CommandMessage types
|
|
78
|
+
export type { CommandMessage } from './CommandMessage';
|
|
79
|
+
export { MessageType } from './CommandMessage';
|
package/tsconfig.json
CHANGED
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
"target": "ES2020", // Set the JavaScript language version for emitted JavaScript and include compatible library declarations
|
|
4
|
+
"outDir": "./dist", // Specify an output folder for all emitted files
|
|
5
|
+
"useDefineForClassFields": true, // Use 'define' semantics for class fields (as opposed to 'set')
|
|
6
|
+
// Specify a set of compiled-in library files to be included in the compilation context
|
|
7
|
+
"lib": [
|
|
8
|
+
"ES2020",
|
|
9
|
+
"DOM",
|
|
10
|
+
"DOM.Iterable"
|
|
11
|
+
],
|
|
12
|
+
"module": "ESNext", // Specify what module code is generated (here, it's the latest module standard)
|
|
13
|
+
"declaration": true, // Generate the types files (*.d.ts)
|
|
14
|
+
"skipLibCheck": true, // Skip type checking of declaration files (*.d.ts)
|
|
15
|
+
/* Bundler mode */
|
|
16
|
+
"moduleResolution": "bundler", // "node", // Choose the module resolution strategy: 'node' for Node.js
|
|
17
|
+
"allowSyntheticDefaultImports": true, // Allow default imports from modules with no default export
|
|
18
|
+
"resolveJsonModule": true, // Include modules imported with '.json' extension
|
|
19
|
+
"isolatedModules": true, // Ensure each file can be safely transpiled without relying on other imports
|
|
20
|
+
"noEmit": false, // Do not emit outputs (if set to true, no files are emitted)
|
|
21
|
+
"jsx": "react-jsx", // Specify JSX code generation: 'preserve', 'react', or 'react-jsx' (new transform)
|
|
22
|
+
/* Linting */
|
|
23
|
+
"strict": true, // Enable all strict type checking options
|
|
24
|
+
"noUnusedLocals": true, // Report errors on unused locals
|
|
25
|
+
"noUnusedParameters": true, // Report errors on unused parameters
|
|
26
|
+
"noFallthroughCasesInSwitch": true, // Report errors for fallthrough cases in switch statement
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
/* publish doc along with js code to help with auto-completion */
|
|
29
|
+
"declarationMap": true, // nice for “go to definition”
|
|
30
|
+
"emitDeclarationOnly": false, // we want JS + types (default is fine)
|
|
31
|
+
"removeComments": false, // JS comments: optional; .d.ts will still carry JSDoc
|
|
32
|
+
"stripInternal": true, // hides /** @internal */ APIs from .d.ts (optional)
|
|
33
|
+
|
|
34
|
+
/* helpful for cross-platform support */
|
|
35
|
+
"forceConsistentCasingInFileNames": true,
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
"rootDir" : "src",
|
|
40
|
+
"verbatimModuleSyntax": true, // This keeps import/export syntax intact and avoids synthetic re-exports TS sometimes injects:
|
|
27
41
|
},
|
|
28
|
-
"include": [
|
|
29
|
-
|
|
42
|
+
"include": [
|
|
43
|
+
"src"
|
|
44
|
+
], // Specify file glob patterns to include in the program
|
|
45
|
+
"exclude": [ // Specify file globa patterns to exclude from compilation
|
|
30
46
|
"node_modules",
|
|
31
47
|
"dist"
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
]
|
|
49
|
+
}
|