@adcops/autocore-react 3.1.1 → 3.3.5
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/react_performance_notes.md +94 -0
- package/dist/components/AutoCoreDevPanel.d.ts.map +1 -1
- package/dist/components/AutoCoreDevPanel.js +1 -1
- package/dist/components/FileList.d.ts.map +1 -1
- package/dist/components/FileList.js +1 -1
- package/dist/components/FileSelect.d.ts.map +1 -1
- package/dist/components/FileSelect.js +1 -1
- package/dist/core/AutoCoreTagContext.d.ts +59 -185
- package/dist/core/AutoCoreTagContext.d.ts.map +1 -1
- package/dist/core/AutoCoreTagContext.js +1 -1
- package/dist/core/AutoCoreTagTypes.d.ts +127 -6
- package/dist/core/AutoCoreTagTypes.d.ts.map +1 -1
- 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 +91 -473
- package/dist/core/EventEmitterContext.d.ts.map +1 -1
- package/dist/core/EventEmitterContext.js +1 -1
- package/dist/hooks/adsHooks.d.ts.map +1 -1
- package/dist/hooks/adsHooks.js +1 -1
- package/dist/hooks/commandHooks.d.ts +3 -3
- package/dist/hooks/commandHooks.d.ts.map +1 -1
- package/dist/hooks/commandHooks.js +1 -1
- package/dist/hooks/useAutoCoreTag.js +1 -1
- package/dist/hub/CommandMessage.d.ts +18 -9
- package/dist/hub/CommandMessage.d.ts.map +1 -1
- 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 +83 -129
- package/dist/hub/HubBase.d.ts.map +1 -1
- package/dist/hub/HubBase.js +1 -1
- package/dist/hub/HubSimulate.d.ts +41 -8
- package/dist/hub/HubSimulate.d.ts.map +1 -1
- package/dist/hub/HubSimulate.js +1 -1
- package/dist/hub/HubTauri.d.ts +24 -60
- package/dist/hub/HubTauri.d.ts.map +1 -1
- package/dist/hub/HubTauri.js +1 -1
- package/dist/hub/HubWebSocket.d.ts +33 -17
- package/dist/hub/HubWebSocket.d.ts.map +1 -1
- 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 +19 -4
- package/dist/hub/index.d.ts.map +1 -1
- package/dist/hub/index.js +1 -1
- package/package.json +8 -4
- package/src/components/AutoCoreDevPanel.tsx +14 -11
- package/src/components/FileList.tsx +5 -4
- package/src/components/FileSelect.tsx +2 -1
- package/src/core/ActionMode.ts +1 -1
- package/src/core/AutoCoreTagContext.tsx +247 -330
- package/src/core/AutoCoreTagTypes.ts +236 -104
- package/src/core/CoreStreamTypes.ts +512 -0
- package/src/core/EventEmitterContext.tsx +182 -520
- package/src/core/IndicatorButtonState.ts +1 -1
- 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 +2 -2
- 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 +118 -140
- package/src/hub/debug.ts +211 -0
- package/src/hub/index.ts +49 -39
- package/docs/.nojekyll +0 -1
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -134
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1633
- package/docs/classes/components_CodeEditor.CodeEditor.html +0 -135
- package/docs/classes/components_Indicator.Indicator.html +0 -122
- package/docs/classes/components_IndicatorRect.IndicatorRect.html +0 -121
- package/docs/classes/components_JogPanel.JogPanel.html +0 -136
- package/docs/classes/components_Lamp.Lamp.html +0 -122
- package/docs/classes/components_OskDialog.OskDialog.html +0 -125
- package/docs/classes/components_TextInput.TextInput.html +0 -125
- package/docs/classes/components_ValueDisplay.ValueDisplay.html +0 -148
- package/docs/classes/components_ValueIndicator.ValueIndicator.html +0 -126
- package/docs/classes/core_ValueSimulator.ValueSimulator.html +0 -51
- package/docs/classes/hub_HubBase.HubBase.html +0 -106
- package/docs/classes/hub_HubSimulate.HubSimulate.html +0 -75
- package/docs/classes/hub_HubTauri.HubTauri.html +0 -93
- package/docs/classes/hub_HubWebSocket.HubWebSocket.html +0 -112
- package/docs/documents/core_AutoCoreTagContext.AutoCoreTagContext.html +0 -148
- 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.html +0 -1
- package/docs/functions/assets.Distance.html +0 -1
- package/docs/functions/assets.JogLong.html +0 -1
- package/docs/functions/assets.JogMedium.html +0 -1
- package/docs/functions/assets.JogShort.html +0 -1
- package/docs/functions/assets.PythonLogo.html +0 -1
- package/docs/functions/assets.Rotation3D.html +0 -1
- package/docs/functions/assets.RotationCcw.html +0 -1
- package/docs/functions/assets.RotationCcwA.html +0 -1
- package/docs/functions/assets.RotationCcwB.html +0 -1
- package/docs/functions/assets.RotationCcwC.html +0 -1
- package/docs/functions/assets.RotationCw.html +0 -1
- package/docs/functions/assets.RotationCwA.html +0 -1
- package/docs/functions/assets.RotationCwB.html +0 -1
- package/docs/functions/assets.RotationCwC.html +0 -1
- package/docs/functions/assets.Run.html +0 -1
- package/docs/functions/assets.Speed.html +0 -1
- package/docs/functions/assets.SpeedFast.html +0 -1
- package/docs/functions/assets.SpeedMedium.html +0 -1
- package/docs/functions/assets.SpeedNone.html +0 -1
- package/docs/functions/assets.SpeedSlow.html +0 -1
- package/docs/functions/assets.Walk.html +0 -1
- package/docs/functions/components_BlocklyEditor.createCustomToolbox.html +0 -6
- package/docs/functions/core_UniqueId.UniqueId.html +0 -9
- package/docs/functions/core_hoc.hocAddSubscription.html +0 -6
- package/docs/functions/hooks_adsHooks.useAdsRegisterSymbols.html +0 -16
- package/docs/functions/hooks_adsHooks.useAdsTapValue.html +0 -8
- package/docs/functions/hooks_adsHooks.useAdsWriteScaledValue.html +0 -18
- package/docs/functions/hooks_adsHooks.useAdsWriteValue.html +0 -9
- package/docs/functions/hooks_commandHooks.useRegisterSymbols.html +0 -16
- package/docs/functions/hooks_commandHooks.useTapValue.html +0 -10
- package/docs/functions/hooks_commandHooks.useWriteScaledValue.html +0 -18
- package/docs/functions/hooks_commandHooks.useWriteValue.html +0 -11
- package/docs/functions/hooks_useAutoCoreTag.ts.makeAutoCoreTagHooks.html +0 -12
- package/docs/functions/hooks_useScaledValue.useScaledValue.html +0 -18
- package/docs/functions/hub.createHub.html +0 -3
- package/docs/hierarchy.html +0 -1
- package/docs/index.html +0 -148
- package/docs/interfaces/components_IndicatorButton.IndicatorButtonProps.html +0 -654
- package/docs/interfaces/components_IndicatorRect.IndicatorRectProps.html +0 -37
- package/docs/interfaces/components_JogPanel.JogPanelButtonDefinition.html +0 -5
- package/docs/interfaces/components_ToggleGroup.ToggleGroupProps.html +0 -644
- package/docs/interfaces/core_AutoCoreTagTypes.BaseContextValue.html +0 -12
- package/docs/interfaces/core_AutoCoreTagTypes.ScaleConfig.html +0 -13
- package/docs/interfaces/core_EventEmitterContext.Action.html +0 -8
- package/docs/interfaces/core_EventEmitterContext.EventEmitterContextType.html +0 -33
- package/docs/interfaces/core_EventEmitterContext.State.html +0 -8
- package/docs/interfaces/core_EventEmitterContext.Subscription.html +0 -6
- package/docs/interfaces/core_IndicatorButtonState.IndicatorButtonState.html +0 -10
- package/docs/interfaces/core_PositionContext.IPositionContext.html +0 -17
- package/docs/interfaces/hub_CommandMessage.CommandMessage.html +0 -6
- package/docs/interfaces/hub_CommandMessage.CommandMessageResult.html +0 -4
- package/docs/modules/assets.html +0 -1
- package/docs/modules/assets_BlocklyLogo.html +0 -1
- package/docs/modules/assets_Distance.html +0 -1
- package/docs/modules/assets_JogLong.html +0 -1
- package/docs/modules/assets_JogMedium.html +0 -1
- package/docs/modules/assets_JogShort.html +0 -1
- package/docs/modules/assets_PythonLogo.html +0 -1
- package/docs/modules/assets_Rotation3D.html +0 -1
- package/docs/modules/assets_RotationCcw.html +0 -1
- package/docs/modules/assets_RotationCcwA.html +0 -1
- package/docs/modules/assets_RotationCcwB.html +0 -1
- package/docs/modules/assets_RotationCcwC.html +0 -1
- package/docs/modules/assets_RotationCw.html +0 -1
- package/docs/modules/assets_RotationCwA.html +0 -1
- package/docs/modules/assets_RotationCwB.html +0 -1
- package/docs/modules/assets_RotationCwC.html +0 -1
- package/docs/modules/assets_Run.html +0 -1
- package/docs/modules/assets_Speed.html +0 -1
- package/docs/modules/assets_SpeedFast.html +0 -1
- package/docs/modules/assets_SpeedMedium.html +0 -1
- package/docs/modules/assets_SpeedNone.html +0 -1
- package/docs/modules/assets_SpeedSlow.html +0 -1
- package/docs/modules/assets_Walk.html +0 -1
- package/docs/modules/components_AutoCoreDevPanel.html +0 -20
- package/docs/modules/components_BlocklyEditor.html +0 -1
- package/docs/modules/components_CodeEditor.html +0 -1
- package/docs/modules/components_FileList.html +0 -1
- package/docs/modules/components_FileSelect.html +0 -1
- package/docs/modules/components_FitText.html +0 -1
- package/docs/modules/components_Indicator.html +0 -1
- package/docs/modules/components_IndicatorButton.html +0 -1
- package/docs/modules/components_IndicatorRect.html +0 -1
- package/docs/modules/components_JogPanel.html +0 -1
- package/docs/modules/components_Lamp.html +0 -1
- package/docs/modules/components_Osk.html +0 -1
- package/docs/modules/components_OskDialog.html +0 -1
- package/docs/modules/components_ProgressBarWithValue.html +0 -1
- package/docs/modules/components_TextInput.html +0 -1
- package/docs/modules/components_ToggleGroup.html +0 -1
- package/docs/modules/components_ValueDisplay.html +0 -1
- package/docs/modules/components_ValueIndicator.html +0 -1
- package/docs/modules/components_ValueInput.html +0 -1
- package/docs/modules/core_ActionMode.html +0 -1
- package/docs/modules/core_AutoCoreTagContext.html +0 -11
- package/docs/modules/core_AutoCoreTagTypes.html +0 -1
- package/docs/modules/core_EventEmitterContext.html +0 -53
- package/docs/modules/core_IndicatorButtonState.html +0 -1
- package/docs/modules/core_IndicatorColor.html +0 -1
- package/docs/modules/core_MaskPatterns.html +0 -1
- package/docs/modules/core_NumerableTypes.html +0 -1
- package/docs/modules/core_PositionContext.html +0 -1
- package/docs/modules/core_UniqueId.html +0 -1
- package/docs/modules/core_ValueSimulator.html +0 -1
- package/docs/modules/core_hoc.html +0 -1
- package/docs/modules/hooks.html +0 -1
- package/docs/modules/hooks_adsHooks.html +0 -1
- package/docs/modules/hooks_commandHooks.html +0 -1
- package/docs/modules/hooks_useAutoCoreTag.ts.html +0 -52
- package/docs/modules/hooks_useScaledValue.html +0 -1
- package/docs/modules/hub.html +0 -1
- package/docs/modules/hub_CommandMessage.html +0 -1
- package/docs/modules/hub_HubBase.html +0 -1
- package/docs/modules/hub_HubSimulate.html +0 -1
- package/docs/modules/hub_HubTauri.html +0 -1
- package/docs/modules/hub_HubWebSocket.html +0 -1
- package/docs/modules.html +0 -23
- package/docs/types/components_IndicatorButton.IndicatorButtonOptionsType.html +0 -1
- package/docs/types/core_AutoCoreTagTypes.ExtractByTag.html +0 -2
- package/docs/types/core_AutoCoreTagTypes.PrimitiveKind.html +0 -1
- package/docs/types/core_AutoCoreTagTypes.TagConfig.html +0 -16
- package/docs/types/core_AutoCoreTagTypes.TagValueMap.html +0 -1
- package/docs/types/core_AutoCoreTagTypes.TagValueOf.html +0 -1
- package/docs/types/core_EventEmitterContext.EmitterDispatchFunction.html +0 -3
- package/docs/types/core_EventEmitterContext.EmitterSubscribeFunction.html +0 -3
- package/docs/types/core_EventEmitterContext.EmitterUnsubscribeFunction.html +0 -3
- package/docs/types/core_NumerableTypes.NumerableFormatOptions.html +0 -4
- package/docs/types/core_hoc.HocAddSubscriptionProps.html +0 -6
- package/docs/variables/components_AutoCoreDevPanel.AutoCoreDevPanel.html +0 -43
- package/docs/variables/components_BlocklyEditor.BlocklyEditor.html +0 -13
- package/docs/variables/components_BlocklyEditor.StandardToolbox.html +0 -1
- package/docs/variables/components_FileList.FileList.html +0 -23
- package/docs/variables/components_FileSelect.FileSelect.html +0 -1
- package/docs/variables/components_FitText.FitText.html +0 -4
- package/docs/variables/components_IndicatorButton.IndicatorButton.html +0 -1
- package/docs/variables/components_JogPanel.DefaultLinearJogButtons.html +0 -2
- package/docs/variables/components_JogPanel.DefaultRotationJogButtons.html +0 -2
- package/docs/variables/components_Osk.Osk.html +0 -1
- package/docs/variables/components_ProgressBarWithValue.ProgressBarWithValue.html +0 -1
- package/docs/variables/components_ToggleGroup.ToggleGroup.html +0 -1
- package/docs/variables/components_ValueInput.ValueInput.html +0 -4
- package/docs/variables/core_AutoCoreTagContext.AutoCoreTagContext.html +0 -1
- package/docs/variables/core_AutoCoreTagContext.AutoCoreTagProvider.html +0 -7
- package/docs/variables/core_EventEmitterContext.EventEmitterContext.html +0 -64
- package/docs/variables/core_EventEmitterContext.EventEmitterProvider.html +0 -10
- package/docs/variables/core_MaskPatterns.PrimeReactMaskPatterns.html +0 -14
- package/docs/variables/core_MaskPatterns.RegExMaskPatterns.html +0 -15
- package/docs/variables/core_PositionContext.DimensionsContext.html +0 -6
- package/docs/variables/hooks_useScaledValue.kMillimeters2Inches.html +0 -2
- package/docs/variables/hooks_useScaledValue.kNewtons2Pounds.html +0 -2
package/dist/hub/HubTauri.d.ts
CHANGED
|
@@ -1,75 +1,35 @@
|
|
|
1
1
|
import { HubBase } from './HubBase';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CommandMessage } from "./CommandMessage";
|
|
3
|
+
import { MessageType } from "./CommandMessage";
|
|
3
4
|
/**
|
|
4
5
|
* Hub for integrating with the Tauri backend.
|
|
5
6
|
*
|
|
6
|
-
* The
|
|
7
|
+
* The Tauri backend is expected to broadcast messages on the event
|
|
7
8
|
* name: 'autocore://broadcast_event'
|
|
8
9
|
*
|
|
9
10
|
* This hub will capture those messages and dispatch them globally to any
|
|
10
11
|
* listeners in the web app.
|
|
11
12
|
*
|
|
13
|
+
* ## Usage Examples
|
|
12
14
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* const {subscribe, unsubscribe} = useContext(EventEmitterContext);
|
|
16
|
-
* useEffect(() => {
|
|
17
|
-
* const unsubscripeMp = subscribe('xarm-position', (value) => {
|
|
18
|
-
* // The rust backend sent a JSON object of 3D position values.
|
|
19
|
-
* setX(value.x);
|
|
20
|
-
* setY(value.y);
|
|
21
|
-
* setZ(value.z);
|
|
22
|
-
* setA(value.roll);
|
|
23
|
-
* setB(value.yaw);
|
|
24
|
-
* setC(value.pitch);
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* return () => {
|
|
28
|
-
* unsubscribe(unsubscripeMp);
|
|
29
|
-
* }
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { hub } = useContext(EventEmitterContext);
|
|
30
17
|
*
|
|
31
|
-
*
|
|
18
|
+
* // Read a value
|
|
19
|
+
* const result = await hub.read("ads.plc1.gio.bControlPowerOk");
|
|
32
20
|
*
|
|
33
|
-
*
|
|
21
|
+
* // Write a value
|
|
22
|
+
* await hub.write("ads.plc1.gio.nSetpoint", 100);
|
|
34
23
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* the expected argument "count".
|
|
38
|
-
* ```
|
|
39
|
-
* const {invoke} = useContext(EventEmitterContext);
|
|
40
|
-
* const incrementCount = () => {
|
|
41
|
-
* count += 1;
|
|
42
|
-
* invoke('update_count', {"count": count});
|
|
43
|
-
* };
|
|
24
|
+
* // Subscribe to changes
|
|
25
|
+
* await hub.subscribe("modbus.holding_registers.5");
|
|
44
26
|
* ```
|
|
45
27
|
*
|
|
46
|
-
*
|
|
47
|
-
* topics in the front-end, without need of interacting with the Tauri backed.
|
|
28
|
+
* The hub can also publish/subscribe to frontend-only events:
|
|
48
29
|
*
|
|
30
|
+
* ```typescript
|
|
31
|
+
* hub.publish("ui/panel-opened", { panelId: "settings" });
|
|
49
32
|
* ```
|
|
50
|
-
* const {dispatch, subscribe, unsubscribe} = useContext(EventEmitterContext);
|
|
51
|
-
* const [controlPower, setControlPower] = useState(false);
|
|
52
|
-
* useEffect(() => {
|
|
53
|
-
* const unsubscribeControlPower = subscribe('value-simulator-bBit1', (value) => {
|
|
54
|
-
* setControlPower(value);
|
|
55
|
-
* });
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* return () => {
|
|
59
|
-
* unsubscribe(unsubscribeControlPower);
|
|
60
|
-
* }
|
|
61
|
-
* }, [] );
|
|
62
|
-
*
|
|
63
|
-
* const onPbPressed = () => {
|
|
64
|
-
* let count = 1;
|
|
65
|
-
* dispatch({
|
|
66
|
-
* topic: "my-awesome-topic",
|
|
67
|
-
* payload: count
|
|
68
|
-
* });
|
|
69
|
-
* }
|
|
70
|
-
*
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
33
|
*/
|
|
74
34
|
export declare class HubTauri extends HubBase {
|
|
75
35
|
/**
|
|
@@ -77,12 +37,16 @@ export declare class HubTauri extends HubBase {
|
|
|
77
37
|
*/
|
|
78
38
|
constructor();
|
|
79
39
|
/**
|
|
80
|
-
*
|
|
40
|
+
* Send a message to the Tauri backend.
|
|
41
|
+
*
|
|
42
|
+
* The topic and messageType are passed to a generic Tauri command handler
|
|
43
|
+
* that routes the request appropriately.
|
|
81
44
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @
|
|
45
|
+
* @param topic The FQDN of the resource (e.g., "ads.plc1.gio.bControlPowerOk")
|
|
46
|
+
* @param messageType The action to perform (Read, Write, Subscribe, etc.)
|
|
47
|
+
* @param payload Optional data payload (e.g., value to write)
|
|
48
|
+
* @returns Promise<CommandMessage> The response from the backend
|
|
85
49
|
*/
|
|
86
|
-
invoke(
|
|
50
|
+
invoke(topic: string, messageType: MessageType, payload?: object): Promise<CommandMessage>;
|
|
87
51
|
}
|
|
88
52
|
//# sourceMappingURL=HubTauri.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HubTauri.d.ts","sourceRoot":"","sources":["../../src/hub/HubTauri.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HubTauri.d.ts","sourceRoot":"","sources":["../../src/hub/HubTauri.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,QAAS,SAAQ,OAAO;IAEjC;;OAEG;;IA6BH;;;;;;;;;;OAUG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CA8C7F"}
|
package/dist/hub/HubTauri.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HubBase}from"./HubBase";import{
|
|
1
|
+
import{HubBase}from"./HubBase";import{invoke as tauriInvoke}from"@tauri-apps/api/core";import{listen}from"@tauri-apps/api/event";import{MessageType}from"./CommandMessage";export class HubTauri extends HubBase{constructor(){super(),this.setIsConnected(!0),listen("autocore://broadcast_event",e=>{let o=JSON.parse(e.payload);void 0!==o.topic&&null!==o.topic&&(void 0!==o.payload&&null!==o.payload?this.publish(o.topic,o.payload):this.publish(o.topic,void 0))})}invoke(e,o,s){const t={topic:e,message_type:o,...s??{}};return new Promise((o,s)=>{tauriInvoke("autocore_invoke",t).then(s=>{if(s&&"object"==typeof s&&"topic"in s)o(s);else{const t={transaction_id:0,timecode:Date.now(),topic:e,message_type:MessageType.Response,data:s,success:!0,error_message:""};o(t)}}).catch(o=>{const t={transaction_id:0,timecode:Date.now(),topic:e,message_type:MessageType.Response,data:null,success:!1,error_message:o?.toString()||"Unknown error"};s(t)})})}}
|
|
@@ -1,34 +1,50 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @module hub/HubWebSocket
|
|
2
3
|
*
|
|
3
|
-
*
|
|
4
|
-
* The result field of CommandMessages used for broadcast must have
|
|
5
|
-
* success set to true, and must contain the field "topic." The topic field, along
|
|
6
|
-
* with the domain field of the CommandMessage will be combined for the topic used
|
|
7
|
-
* by the websocket client.
|
|
4
|
+
* Implementation of `HubBase` using standard WebSockets.
|
|
8
5
|
*
|
|
9
|
-
*
|
|
6
|
+
* ## Functionality
|
|
10
7
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* - **Transport**: Connects to `ws://host:port/ws/` (or `wss://`).
|
|
9
|
+
* - **Request/Response**: Correlates requests to responses using `transaction_id`.
|
|
10
|
+
* - **Broadcasts**: Handles unsolicited messages (subscriptions) and routes them via `HubBase.publish`.
|
|
11
|
+
* - **Binary Data**: Handles `FILE_DOWNLOAD` events by decoding Base64 payloads into Blobs.
|
|
12
|
+
*
|
|
13
|
+
* ## Protocol
|
|
14
|
+
*
|
|
15
|
+
* Messages are JSON-serialized `CommandMessage` objects.
|
|
16
|
+
* - **Requests**: Client sends `message_type` (Read/Write/etc) + `transaction_id`.
|
|
17
|
+
* - **Responses**: Server replies with same `transaction_id` + `success`/`data`.
|
|
18
|
+
* - **Broadcasts**: Server sends `message_type: Broadcast` + `topic` (FQDN) + `data`.
|
|
13
19
|
*/
|
|
14
20
|
import { HubBase } from './HubBase';
|
|
15
|
-
import
|
|
21
|
+
import { MessageType, type CommandMessage } from "./CommandMessage";
|
|
22
|
+
/**
|
|
23
|
+
* WebSocket implementation of the Hub communication layer.
|
|
24
|
+
*/
|
|
16
25
|
export declare class HubWebSocket extends HubBase {
|
|
17
26
|
private socket;
|
|
18
27
|
private requestId;
|
|
28
|
+
/**
|
|
29
|
+
* Map of pending Transaction ID -> Promise Resolvers.
|
|
30
|
+
* Used to match asynchronous WebSocket responses to their original requests.
|
|
31
|
+
*/
|
|
19
32
|
private pendingRequests;
|
|
20
33
|
/**
|
|
21
|
-
*
|
|
34
|
+
* Initializes the WebSocket connection immediately.
|
|
22
35
|
*/
|
|
23
36
|
constructor();
|
|
24
37
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
38
|
+
* Sends a command to the server via WebSocket.
|
|
39
|
+
*
|
|
40
|
+
* Wraps the operation in a Promise that resolves when the server replies
|
|
41
|
+
* with a matching `transaction_id`.
|
|
42
|
+
*/
|
|
43
|
+
invoke: (topic: string, messageType: MessageType, payload?: object) => Promise<CommandMessage>;
|
|
44
|
+
/**
|
|
45
|
+
* Processes messages that are not responses to a specific request.
|
|
46
|
+
* Usually these are subscription updates (Broadcasts).
|
|
30
47
|
*/
|
|
31
|
-
invoke: (domain: string, fname: string, payload?: object) => Promise<CommandMessageResult>;
|
|
32
48
|
handleUnsolicitedMessage: (msg: CommandMessage) => void;
|
|
33
49
|
disconnect: () => void;
|
|
34
50
|
protected emit: (eventName: string, payload?: object) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HubWebSocket.d.ts","sourceRoot":"","sources":["../../src/hub/HubWebSocket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HubWebSocket.d.ts","sourceRoot":"","sources":["../../src/hub/HubWebSocket.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA+DpE;;GAEG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACrC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,SAAS,CAAK;IAEtB;;;OAGG;IACH,OAAO,CAAC,eAAe,CAAoC;IAE3D;;OAEG;;IA4FH;;;;;OAKG;IACH,MAAM,GAAI,OAAO,MAAM,EAAE,aAAa,WAAW,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,cAAc,CAAC,CAqB5F;IAED;;;OAGG;IACH,wBAAwB,GAAI,KAAK,cAAc,UAO9C;IAED,UAAU,QAAO,IAAI,CAEpB;IAED,SAAS,CAAC,IAAI,GAAI,WAAW,MAAM,EAAE,UAAU,MAAM,KAAG,IAAI,CAE3D;CACJ"}
|
package/dist/hub/HubWebSocket.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HubBase}from"./HubBase";function b64toBlob(e,t="application/octet-stream",s=512){const n=atob(e),o=[];for(let e=0;e<n.length;e+=s){const t=n.slice(e,e+s),
|
|
1
|
+
import{HubBase}from"./HubBase";import{MessageType}from"./CommandMessage";import{getDebugPanel}from"./DebugPanel";function b64toBlob(e,t="application/octet-stream",s=512){const n=atob(e),o=[];for(let e=0;e<n.length;e+=s){const t=n.slice(e,e+s),a=new Array(t.length);for(let e=0;e<t.length;e++)a[e]=t.charCodeAt(e);const i=new Uint8Array(a);o.push(i.buffer)}return new Blob(o,{type:t})}function downloadBlob(e,t){const s=window.URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(s)}export class HubWebSocket extends HubBase{constructor(){super(),Object.defineProperty(this,"socket",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"requestId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pendingRequests",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"invoke",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,s)=>new Promise((n,o)=>{const a=++this.requestId;this.pendingRequests.set(a,{resolve:n,reject:o});const i={transaction_id:a,topic:e,data:s||{},timecode:Date.now(),message_type:t,success:!1,error_message:""};getDebugPanel().messageSent(MessageType[t],e,a),this.socket.send(JSON.stringify(i))})}),Object.defineProperty(this,"handleUnsolicitedMessage",{enumerable:!0,configurable:!0,writable:!0,value:e=>{e.message_type==MessageType.Broadcast&&e.topic.length>1&&this.publish(e.topic,e.data)}}),Object.defineProperty(this,"disconnect",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.socket.close()}}),Object.defineProperty(this,"emit",{enumerable:!0,configurable:!0,writable:!0,value:(e,t)=>{this.socket.send(JSON.stringify({eventName:e,payload:t}))}}),getDebugPanel().hubCreated();const e=window.location.hostname,t=window.location.port,s=`${"https:"===window.location.protocol?"wss://":"ws://"}${e}${t?":"+t:""}/ws/`;this.socket=new WebSocket(s);let n=this;this.socket.onopen=function(){getDebugPanel().wsOpened(s),n.publish("HUB/connected",!0),n.setIsConnected(!0)},this.socket.onmessage=e=>{const t=JSON.parse(e.data);if(getDebugPanel().messageReceived(MessageType[t.message_type]||String(t.message_type),t.topic,t.transaction_id),t.transaction_id&&this.pendingRequests.has(t.transaction_id)){const{resolve:e,reject:s}=this.pendingRequests.get(t.transaction_id);if("FILE_DOWNLOAD"===t.topic&&void 0!==t.data.file_name&&null!==t.data.file_name&&t.data.file_name.length>0){let n=t.data.file_name.split("/");const o=n[n.length-1];if(t.success){downloadBlob(b64toBlob(t.data),o),t.data=o,e(t)}else s(new Error(t.error_message))}else t.success?e(t):s(new Error(t.error_message));this.pendingRequests.delete(t.transaction_id)}else this.handleUnsolicitedMessage(t)},this.socket.onerror=e=>{getDebugPanel().wsError(String(e))},this.socket.onclose=e=>{n.setIsConnected(!1),getDebugPanel().wsClosed(e.code,e.reason||"No reason")}}}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface DebugLogEntry {
|
|
2
|
+
timestamp: number;
|
|
3
|
+
source: string;
|
|
4
|
+
level: "info" | "warn" | "error" | "send" | "recv";
|
|
5
|
+
message: string;
|
|
6
|
+
data?: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare const debug: {
|
|
9
|
+
/** Log an info message */
|
|
10
|
+
info(source: string, message: string, data?: unknown): void;
|
|
11
|
+
/** Log a warning message */
|
|
12
|
+
warn(source: string, message: string, data?: unknown): void;
|
|
13
|
+
/** Log an error message */
|
|
14
|
+
error(source: string, message: string, data?: unknown): void;
|
|
15
|
+
/** Log an outgoing message (to server) */
|
|
16
|
+
send(source: string, message: string, data?: unknown): void;
|
|
17
|
+
/** Log an incoming message (from server) */
|
|
18
|
+
recv(source: string, message: string, data?: unknown): void;
|
|
19
|
+
/** Check if debug is enabled */
|
|
20
|
+
isEnabled(): boolean;
|
|
21
|
+
};
|
|
22
|
+
export default debug;
|
|
23
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/hub/debug.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAwFD,eAAO,MAAM,KAAK;IAChB,0BAA0B;iBACb,MAAM,WAAW,MAAM,SAAS,OAAO,GAAG,IAAI;IAI3D,4BAA4B;iBACf,MAAM,WAAW,MAAM,SAAS,OAAO,GAAG,IAAI;IAI3D,2BAA2B;kBACb,MAAM,WAAW,MAAM,SAAS,OAAO,GAAG,IAAI;IAI5D,0CAA0C;iBAC7B,MAAM,WAAW,MAAM,SAAS,OAAO,GAAG,IAAI;IAI3D,4CAA4C;iBAC/B,MAAM,WAAW,MAAM,SAAS,OAAO,GAAG,IAAI;IAI3D,gCAAgC;iBACnB,OAAO;CAGrB,CAAC;AAqEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const state={enabled:!0,logs:[],maxLogs:1e3};function formatTime(e){const t=new Date(e);return t.toTimeString().slice(0,8)+"."+String(t.getMilliseconds()).padStart(3,"0")}function formatEntry(e){return`[${formatTime(e.timestamp)}] [${e.source}] ${e.message}`}function addLog(e,t,o,s){const r={timestamp:Date.now(),source:e,level:t,message:o,data:s};if(state.logs.push(r),state.logs.length>state.maxLogs&&state.logs.shift(),state.enabled){formatEntry(r),getLogStyle(t);t}}function getLogStyle(e){switch(e){case"error":return"color: #ff4444; font-weight: bold;";case"warn":return"color: #ffaa00;";case"send":return"color: #44ff44;";case"recv":return"color: #4444ff;";default:return"color: #888888;"}}export const debug={info(e,t,o){addLog(e,"info",t,o)},warn(e,t,o){addLog(e,"warn",t,o)},error(e,t,o){addLog(e,"error",t,o)},send(e,t,o){addLog(e,"send",t,o)},recv(e,t,o){addLog(e,"recv",t,o)},isEnabled:()=>state.enabled};const consoleAPI={enable(){state.enabled=!0},disable(){state.enabled=!1},get logs(){return[...state.logs]},clear(){state.logs=[]},dump(){for(const e of state.logs){formatEntry(e);e.level}},filterBySource:e=>state.logs.filter(t=>t.source.includes(e)),filterByLevel:e=>state.logs.filter(t=>t.level===e),getMessages:()=>state.logs.filter(e=>"send"===e.level||"recv"===e.level)};"undefined"!=typeof window&&(window.__AUTOCORE_DEBUG__=consoleAPI);export default debug;
|
package/dist/hub/index.d.ts
CHANGED
|
@@ -2,15 +2,30 @@ import { HubBase as Hub } from './HubBase';
|
|
|
2
2
|
import { HubTauri } from './HubTauri';
|
|
3
3
|
import { HubWebSocket } from "./HubWebSocket";
|
|
4
4
|
import { HubSimulate } from "./HubSimulate";
|
|
5
|
-
import type { CommandMessage, CommandMessageResult } from './CommandMessage';
|
|
6
5
|
/**
|
|
7
|
-
* Creates
|
|
8
|
-
*
|
|
6
|
+
* Creates or returns the singleton Hub connection to the backend.
|
|
7
|
+
*
|
|
8
|
+
* The hub type is determined automatically:
|
|
9
|
+
* - If running in Tauri: HubTauri (direct Rust IPC)
|
|
10
|
+
* - Otherwise: HubWebSocket (WebSocket to autocore-server)
|
|
11
|
+
*
|
|
12
|
+
* @returns Hub The singleton hub instance
|
|
9
13
|
*/
|
|
10
14
|
export declare function createHub(): Hub;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current hub instance, or null if not yet created.
|
|
17
|
+
* Useful for checking if a hub exists without creating one.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getHubInstance(): Hub | null;
|
|
20
|
+
/**
|
|
21
|
+
* Resets the singleton hub instance.
|
|
22
|
+
* This should only be used for testing or when intentionally reconnecting.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resetHub(): void;
|
|
11
25
|
export { HubBase as Hub } from './HubBase';
|
|
12
26
|
export { HubTauri };
|
|
13
27
|
export { HubWebSocket };
|
|
14
28
|
export { HubSimulate };
|
|
15
|
-
export type { CommandMessage
|
|
29
|
+
export type { CommandMessage } from './CommandMessage';
|
|
30
|
+
export { MessageType } from './CommandMessage';
|
|
16
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/hub/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hub/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hub/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAW5C;;;;;;;;GAQG;AACH,wBAAgB,SAAS,IAAI,GAAG,CAiB/B;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,GAAG,GAAG,IAAI,CAE3C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,IAAI,CAE/B;AAGD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,CAAC;AAGvB,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/hub/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HubBase as Hub}from"./HubBase";import{HubTauri}from"./HubTauri";import{HubWebSocket}from"./HubWebSocket";import{HubSimulate}from"./HubSimulate";let hubInstance=null;export function createHub(){return hubInstance
|
|
1
|
+
import{HubBase as Hub}from"./HubBase";import{HubTauri}from"./HubTauri";import{HubWebSocket}from"./HubWebSocket";import{HubSimulate}from"./HubSimulate";import{getDebugPanel}from"./DebugPanel";let hubInstance=null;export function createHub(){const e=getDebugPanel();return e.log("info","createHub",`called (hasInstance: ${!!hubInstance})`),hubInstance?e.log("info","createHub","Returning existing hub instance"):"undefined"!=typeof window&&void 0!==window.__TAURI__&&null!==window.__TAURI__?(e.log("info","createHub","Creating HubTauri instance"),hubInstance=new HubTauri):(e.log("info","createHub","Creating HubWebSocket instance"),hubInstance=new HubWebSocket),hubInstance}export function getHubInstance(){return hubInstance}export function resetHub(){hubInstance=null}export{HubBase as Hub}from"./HubBase";export{HubTauri};export{HubWebSocket};export{HubSimulate};export{MessageType}from"./CommandMessage";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adcops/autocore-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.5",
|
|
4
4
|
"description": "A React component library for industrial user interfaces.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@monaco-editor/react": "^4.7.0",
|
|
54
|
-
"@tauri-apps/api": "^
|
|
54
|
+
"@tauri-apps/api": "^2.9.1",
|
|
55
55
|
"clsx": "^2.1.1",
|
|
56
56
|
"numerable": "^0.3.15",
|
|
57
57
|
"react-blockly": "^8.1.2",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@svgr/cli": "^8.1.0",
|
|
73
|
-
"@types/react": "^18",
|
|
74
|
-
"@types/react-dom": "^18.
|
|
73
|
+
"@types/react": "^18.2.15",
|
|
74
|
+
"@types/react-dom": "^18.2.7",
|
|
75
75
|
"@types/react-transition-group": "^4.4.12",
|
|
76
76
|
"primereact": "^10.9.7",
|
|
77
77
|
"rimraf": "^6.0.1",
|
|
@@ -95,6 +95,10 @@
|
|
|
95
95
|
"./themes/*": {
|
|
96
96
|
"import": "./dist/themes/*",
|
|
97
97
|
"types": "./dist/themes/*.d.ts"
|
|
98
|
+
},
|
|
99
|
+
"./hub/*": {
|
|
100
|
+
"import": "./dist/hub/*",
|
|
101
|
+
"types": "./dist/hub/*.d.ts"
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (C) 2025 Automated Design Corp.. All Rights Reserved.
|
|
3
3
|
* Created Date: 2025-09-05 08:06:09
|
|
4
4
|
* -----
|
|
5
|
-
* Last Modified:
|
|
5
|
+
* Last Modified: 2026-01-20 06:09:05
|
|
6
6
|
* -----
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
@@ -93,6 +93,9 @@ import React, { useContext, useMemo, useState, useCallback } from "react";
|
|
|
93
93
|
import type { TagConfig } from "../core/AutoCoreTagTypes";
|
|
94
94
|
import { AutoCoreTagContext } from "../core/AutoCoreTagContext";
|
|
95
95
|
|
|
96
|
+
/** Extract domain (first segment) from FQDN */
|
|
97
|
+
const getDomain = (fqdn: string): string => fqdn.split('.')[0];
|
|
98
|
+
|
|
96
99
|
/**
|
|
97
100
|
* Props for the AutoCoreDevPanel component.
|
|
98
101
|
*/
|
|
@@ -167,8 +170,8 @@ export const AutoCoreDevPanel: React.FC<AutoCoreDevPanelProps> = ({
|
|
|
167
170
|
|
|
168
171
|
const rows = useMemo(() => {
|
|
169
172
|
return tags.map((tag) => {
|
|
170
|
-
const display = values[tag.
|
|
171
|
-
const raw = rawValues[tag.
|
|
173
|
+
const display = values[tag.fqdn];
|
|
174
|
+
const raw = rawValues[tag.fqdn];
|
|
172
175
|
const scaleName = tag.scale ?? "";
|
|
173
176
|
const s = scaleName ? scales[scaleName] : undefined;
|
|
174
177
|
return {
|
|
@@ -192,7 +195,7 @@ export const AutoCoreDevPanel: React.FC<AutoCoreDevPanelProps> = ({
|
|
|
192
195
|
}, []);
|
|
193
196
|
|
|
194
197
|
const commit = useCallback(async (tag: TagConfig) => {
|
|
195
|
-
const tagName = tag.
|
|
198
|
+
const tagName = tag.fqdn;
|
|
196
199
|
const buf = editBuf[tagName];
|
|
197
200
|
|
|
198
201
|
try {
|
|
@@ -282,15 +285,15 @@ export const AutoCoreDevPanel: React.FC<AutoCoreDevPanelProps> = ({
|
|
|
282
285
|
</thead>
|
|
283
286
|
<tbody>
|
|
284
287
|
{rows.map(({ tag, display, raw, scaleName, factor, label }) => {
|
|
285
|
-
const buf = editBuf[tag.
|
|
286
|
-
const err = errors[tag.
|
|
288
|
+
const buf = editBuf[tag.fqdn] ?? "";
|
|
289
|
+
const err = errors[tag.fqdn];
|
|
287
290
|
|
|
288
291
|
return (
|
|
289
|
-
<tr key={tag.
|
|
292
|
+
<tr key={tag.fqdn}>
|
|
290
293
|
<Td mono>{tag.tagName}</Td>
|
|
291
294
|
<Td mono>{tag.valueType}</Td>
|
|
292
|
-
<Td mono>{tag.
|
|
293
|
-
<Td mono>{tag.
|
|
295
|
+
<Td mono>{getDomain(tag.fqdn)}</Td>
|
|
296
|
+
<Td mono>{tag.fqdn}</Td>
|
|
294
297
|
<Td mono>{fmt(display)}</Td>
|
|
295
298
|
<Td mono>{fmt(raw)}</Td>
|
|
296
299
|
<Td mono>{scaleName ? `${scaleName} ×${factor ?? 1}` : "—"}</Td>
|
|
@@ -299,7 +302,7 @@ export const AutoCoreDevPanel: React.FC<AutoCoreDevPanelProps> = ({
|
|
|
299
302
|
<InputForTag
|
|
300
303
|
tag={tag}
|
|
301
304
|
buf={buf}
|
|
302
|
-
setBuf={(v) => setBuf(tag.
|
|
305
|
+
setBuf={(v) => setBuf(tag.fqdn, v)}
|
|
303
306
|
onKeyDown={(e) => onKeyDownCommit(e, tag)}
|
|
304
307
|
/>
|
|
305
308
|
{err && <div style={{ color: "#dc2626", marginTop: 4 }}>{err}</div>}
|
|
@@ -308,7 +311,7 @@ export const AutoCoreDevPanel: React.FC<AutoCoreDevPanelProps> = ({
|
|
|
308
311
|
<div style={{ display: "flex", gap: 6 }}>
|
|
309
312
|
<button onClick={() => commit(tag)}>Write</button>
|
|
310
313
|
{tag.valueType === "boolean" && (
|
|
311
|
-
<button onClick={() => tap(tag.
|
|
314
|
+
<button onClick={() => tap(tag.fqdn as any)}>TAP</button>
|
|
312
315
|
)}
|
|
313
316
|
</div>
|
|
314
317
|
</Td>
|
|
@@ -24,6 +24,7 @@ import { confirmPopup } from 'primereact/confirmpopup';
|
|
|
24
24
|
import { FileUpload, type FileUploadHandlerEvent} from 'primereact/fileupload';
|
|
25
25
|
|
|
26
26
|
import { EventEmitterContext } from '../core/EventEmitterContext';
|
|
27
|
+
import { MessageType } from '../hub/CommandMessage';
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -148,7 +149,7 @@ export const FileList: React.FC<FileListProps> = ({
|
|
|
148
149
|
const listFiles = async () => {
|
|
149
150
|
try {
|
|
150
151
|
const args = subdir !== undefined ? { "subdir": subdir } : {};
|
|
151
|
-
let res = await invoke(domain
|
|
152
|
+
let res = await invoke(`${domain}.list_files`, MessageType.Request, args);
|
|
152
153
|
|
|
153
154
|
let items = [];
|
|
154
155
|
for (let i = 0; i < res.data.length; ++i) {
|
|
@@ -179,7 +180,7 @@ export const FileList: React.FC<FileListProps> = ({
|
|
|
179
180
|
let target = makeTargetName(file.name);
|
|
180
181
|
|
|
181
182
|
try {
|
|
182
|
-
await invoke(domain
|
|
183
|
+
await invoke(`${domain}.download_file`, MessageType.Request, { file_name: target });
|
|
183
184
|
if (onSuccess)
|
|
184
185
|
onSuccess(`Downloaded file: ${file.name}`);
|
|
185
186
|
} catch (error) {
|
|
@@ -199,7 +200,7 @@ export const FileList: React.FC<FileListProps> = ({
|
|
|
199
200
|
let target = makeTargetName(file_name);
|
|
200
201
|
|
|
201
202
|
try {
|
|
202
|
-
await invoke(domain
|
|
203
|
+
await invoke(`${domain}.delete_file`, MessageType.Request, { file_name: target });
|
|
203
204
|
if (onSuccess)
|
|
204
205
|
onSuccess(`Deleted file: ${file_name}`);
|
|
205
206
|
|
|
@@ -253,7 +254,7 @@ export const FileList: React.FC<FileListProps> = ({
|
|
|
253
254
|
const base64String = arrayBufferToBase64(arrayBuffer);
|
|
254
255
|
|
|
255
256
|
try {
|
|
256
|
-
await invoke(domain
|
|
257
|
+
await invoke(`${domain}.write_file`, MessageType.Request, { file_name: target, value: base64String, options: { "base64": true } });
|
|
257
258
|
|
|
258
259
|
if (onSuccess)
|
|
259
260
|
onSuccess(`Uploaded file ${file.name}`);
|
|
@@ -14,6 +14,7 @@ import { Column } from 'primereact/column';
|
|
|
14
14
|
import { Button } from 'primereact/button';
|
|
15
15
|
|
|
16
16
|
import { EventEmitterContext } from "../core/EventEmitterContext";
|
|
17
|
+
import { MessageType } from '../hub/CommandMessage';
|
|
17
18
|
|
|
18
19
|
type FileSelectProps = {
|
|
19
20
|
domain?: string,
|
|
@@ -54,7 +55,7 @@ export const FileSelect: React.FC<FileSelectProps> = ({
|
|
|
54
55
|
args = subdir ? { "subdir": subdir } : {};
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
const res = await invoke(domain
|
|
58
|
+
const res = await invoke(`${domain}.list_files`, MessageType.Request, args);
|
|
58
59
|
const items = res.data.map((item: string, index: number) => ({
|
|
59
60
|
id: index + 1,
|
|
60
61
|
name: item
|