@adcops/autocore-react 3.1.1 → 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.
Files changed (252) hide show
  1. package/additional-docs/react_performance_notes.md +94 -0
  2. package/dist/components/AutoCoreDevPanel.d.ts.map +1 -1
  3. package/dist/components/AutoCoreDevPanel.js +1 -1
  4. package/dist/components/FileList.d.ts.map +1 -1
  5. package/dist/components/FileList.js +1 -1
  6. package/dist/components/FileSelect.d.ts.map +1 -1
  7. package/dist/components/FileSelect.js +1 -1
  8. package/dist/core/AutoCoreTagContext.d.ts +59 -185
  9. package/dist/core/AutoCoreTagContext.d.ts.map +1 -1
  10. package/dist/core/AutoCoreTagContext.js +1 -1
  11. package/dist/core/AutoCoreTagTypes.d.ts +127 -6
  12. package/dist/core/AutoCoreTagTypes.d.ts.map +1 -1
  13. package/dist/core/CoreStreamTypes.d.ts +345 -0
  14. package/dist/core/CoreStreamTypes.d.ts.map +1 -0
  15. package/dist/core/CoreStreamTypes.js +1 -0
  16. package/dist/core/EventEmitterContext.d.ts +91 -473
  17. package/dist/core/EventEmitterContext.d.ts.map +1 -1
  18. package/dist/core/EventEmitterContext.js +1 -1
  19. package/dist/hooks/adsHooks.d.ts.map +1 -1
  20. package/dist/hooks/adsHooks.js +1 -1
  21. package/dist/hooks/commandHooks.d.ts +3 -3
  22. package/dist/hooks/commandHooks.d.ts.map +1 -1
  23. package/dist/hooks/commandHooks.js +1 -1
  24. package/dist/hooks/useAutoCoreTag.js +1 -1
  25. package/dist/hub/CommandMessage.d.ts +18 -9
  26. package/dist/hub/CommandMessage.d.ts.map +1 -1
  27. package/dist/hub/CommandMessage.js +1 -1
  28. package/dist/hub/DebugPanel.d.ts +31 -0
  29. package/dist/hub/DebugPanel.d.ts.map +1 -0
  30. package/dist/hub/DebugPanel.js +1 -0
  31. package/dist/hub/HubBase.d.ts +83 -129
  32. package/dist/hub/HubBase.d.ts.map +1 -1
  33. package/dist/hub/HubBase.js +1 -1
  34. package/dist/hub/HubSimulate.d.ts +41 -8
  35. package/dist/hub/HubSimulate.d.ts.map +1 -1
  36. package/dist/hub/HubSimulate.js +1 -1
  37. package/dist/hub/HubTauri.d.ts +24 -60
  38. package/dist/hub/HubTauri.d.ts.map +1 -1
  39. package/dist/hub/HubTauri.js +1 -1
  40. package/dist/hub/HubWebSocket.d.ts +33 -17
  41. package/dist/hub/HubWebSocket.d.ts.map +1 -1
  42. package/dist/hub/HubWebSocket.js +1 -1
  43. package/dist/hub/debug.d.ts +23 -0
  44. package/dist/hub/debug.d.ts.map +1 -0
  45. package/dist/hub/debug.js +1 -0
  46. package/dist/hub/index.d.ts +19 -4
  47. package/dist/hub/index.d.ts.map +1 -1
  48. package/dist/hub/index.js +1 -1
  49. package/package.json +4 -4
  50. package/src/components/AutoCoreDevPanel.tsx +14 -11
  51. package/src/components/FileList.tsx +5 -4
  52. package/src/components/FileSelect.tsx +2 -1
  53. package/src/core/ActionMode.ts +1 -1
  54. package/src/core/AutoCoreTagContext.tsx +247 -330
  55. package/src/core/AutoCoreTagTypes.ts +236 -104
  56. package/src/core/CoreStreamTypes.ts +512 -0
  57. package/src/core/EventEmitterContext.tsx +182 -520
  58. package/src/core/IndicatorButtonState.ts +1 -1
  59. package/src/core/hoc.tsx +1 -1
  60. package/src/hooks/adsHooks.tsx +21 -22
  61. package/src/hooks/commandHooks.tsx +23 -19
  62. package/src/hooks/index.ts +1 -1
  63. package/src/hooks/useAutoCoreTag.ts +2 -2
  64. package/src/hooks/useScaledValue.tsx +1 -1
  65. package/src/hub/CommandMessage.ts +71 -19
  66. package/src/hub/DebugPanel.ts +280 -0
  67. package/src/hub/HubBase.ts +147 -223
  68. package/src/hub/HubSimulate.ts +93 -24
  69. package/src/hub/HubTauri.ts +87 -96
  70. package/src/hub/HubWebSocket.ts +118 -140
  71. package/src/hub/debug.ts +211 -0
  72. package/src/hub/index.ts +49 -39
  73. package/docs/.nojekyll +0 -1
  74. package/docs/assets/hierarchy.js +0 -1
  75. package/docs/assets/highlight.css +0 -134
  76. package/docs/assets/icons.js +0 -18
  77. package/docs/assets/icons.svg +0 -1
  78. package/docs/assets/main.js +0 -60
  79. package/docs/assets/navigation.js +0 -1
  80. package/docs/assets/search.js +0 -1
  81. package/docs/assets/style.css +0 -1633
  82. package/docs/classes/components_CodeEditor.CodeEditor.html +0 -135
  83. package/docs/classes/components_Indicator.Indicator.html +0 -122
  84. package/docs/classes/components_IndicatorRect.IndicatorRect.html +0 -121
  85. package/docs/classes/components_JogPanel.JogPanel.html +0 -136
  86. package/docs/classes/components_Lamp.Lamp.html +0 -122
  87. package/docs/classes/components_OskDialog.OskDialog.html +0 -125
  88. package/docs/classes/components_TextInput.TextInput.html +0 -125
  89. package/docs/classes/components_ValueDisplay.ValueDisplay.html +0 -148
  90. package/docs/classes/components_ValueIndicator.ValueIndicator.html +0 -126
  91. package/docs/classes/core_ValueSimulator.ValueSimulator.html +0 -51
  92. package/docs/classes/hub_HubBase.HubBase.html +0 -106
  93. package/docs/classes/hub_HubSimulate.HubSimulate.html +0 -75
  94. package/docs/classes/hub_HubTauri.HubTauri.html +0 -93
  95. package/docs/classes/hub_HubWebSocket.HubWebSocket.html +0 -112
  96. package/docs/documents/core_AutoCoreTagContext.AutoCoreTagContext.html +0 -148
  97. package/docs/enums/components_JogPanel.JogDistanceAction.html +0 -5
  98. package/docs/enums/components_JogPanel.JogPanelAction.html +0 -18
  99. package/docs/enums/components_JogPanel.JogSpeedAction.html +0 -5
  100. package/docs/enums/core_ActionMode.ActionMode.html +0 -6
  101. package/docs/enums/core_IndicatorColor.IndicatorColor.html +0 -23
  102. package/docs/functions/assets.BlocklyLogo.html +0 -1
  103. package/docs/functions/assets.Distance.html +0 -1
  104. package/docs/functions/assets.JogLong.html +0 -1
  105. package/docs/functions/assets.JogMedium.html +0 -1
  106. package/docs/functions/assets.JogShort.html +0 -1
  107. package/docs/functions/assets.PythonLogo.html +0 -1
  108. package/docs/functions/assets.Rotation3D.html +0 -1
  109. package/docs/functions/assets.RotationCcw.html +0 -1
  110. package/docs/functions/assets.RotationCcwA.html +0 -1
  111. package/docs/functions/assets.RotationCcwB.html +0 -1
  112. package/docs/functions/assets.RotationCcwC.html +0 -1
  113. package/docs/functions/assets.RotationCw.html +0 -1
  114. package/docs/functions/assets.RotationCwA.html +0 -1
  115. package/docs/functions/assets.RotationCwB.html +0 -1
  116. package/docs/functions/assets.RotationCwC.html +0 -1
  117. package/docs/functions/assets.Run.html +0 -1
  118. package/docs/functions/assets.Speed.html +0 -1
  119. package/docs/functions/assets.SpeedFast.html +0 -1
  120. package/docs/functions/assets.SpeedMedium.html +0 -1
  121. package/docs/functions/assets.SpeedNone.html +0 -1
  122. package/docs/functions/assets.SpeedSlow.html +0 -1
  123. package/docs/functions/assets.Walk.html +0 -1
  124. package/docs/functions/components_BlocklyEditor.createCustomToolbox.html +0 -6
  125. package/docs/functions/core_UniqueId.UniqueId.html +0 -9
  126. package/docs/functions/core_hoc.hocAddSubscription.html +0 -6
  127. package/docs/functions/hooks_adsHooks.useAdsRegisterSymbols.html +0 -16
  128. package/docs/functions/hooks_adsHooks.useAdsTapValue.html +0 -8
  129. package/docs/functions/hooks_adsHooks.useAdsWriteScaledValue.html +0 -18
  130. package/docs/functions/hooks_adsHooks.useAdsWriteValue.html +0 -9
  131. package/docs/functions/hooks_commandHooks.useRegisterSymbols.html +0 -16
  132. package/docs/functions/hooks_commandHooks.useTapValue.html +0 -10
  133. package/docs/functions/hooks_commandHooks.useWriteScaledValue.html +0 -18
  134. package/docs/functions/hooks_commandHooks.useWriteValue.html +0 -11
  135. package/docs/functions/hooks_useAutoCoreTag.ts.makeAutoCoreTagHooks.html +0 -12
  136. package/docs/functions/hooks_useScaledValue.useScaledValue.html +0 -18
  137. package/docs/functions/hub.createHub.html +0 -3
  138. package/docs/hierarchy.html +0 -1
  139. package/docs/index.html +0 -148
  140. package/docs/interfaces/components_IndicatorButton.IndicatorButtonProps.html +0 -654
  141. package/docs/interfaces/components_IndicatorRect.IndicatorRectProps.html +0 -37
  142. package/docs/interfaces/components_JogPanel.JogPanelButtonDefinition.html +0 -5
  143. package/docs/interfaces/components_ToggleGroup.ToggleGroupProps.html +0 -644
  144. package/docs/interfaces/core_AutoCoreTagTypes.BaseContextValue.html +0 -12
  145. package/docs/interfaces/core_AutoCoreTagTypes.ScaleConfig.html +0 -13
  146. package/docs/interfaces/core_EventEmitterContext.Action.html +0 -8
  147. package/docs/interfaces/core_EventEmitterContext.EventEmitterContextType.html +0 -33
  148. package/docs/interfaces/core_EventEmitterContext.State.html +0 -8
  149. package/docs/interfaces/core_EventEmitterContext.Subscription.html +0 -6
  150. package/docs/interfaces/core_IndicatorButtonState.IndicatorButtonState.html +0 -10
  151. package/docs/interfaces/core_PositionContext.IPositionContext.html +0 -17
  152. package/docs/interfaces/hub_CommandMessage.CommandMessage.html +0 -6
  153. package/docs/interfaces/hub_CommandMessage.CommandMessageResult.html +0 -4
  154. package/docs/modules/assets.html +0 -1
  155. package/docs/modules/assets_BlocklyLogo.html +0 -1
  156. package/docs/modules/assets_Distance.html +0 -1
  157. package/docs/modules/assets_JogLong.html +0 -1
  158. package/docs/modules/assets_JogMedium.html +0 -1
  159. package/docs/modules/assets_JogShort.html +0 -1
  160. package/docs/modules/assets_PythonLogo.html +0 -1
  161. package/docs/modules/assets_Rotation3D.html +0 -1
  162. package/docs/modules/assets_RotationCcw.html +0 -1
  163. package/docs/modules/assets_RotationCcwA.html +0 -1
  164. package/docs/modules/assets_RotationCcwB.html +0 -1
  165. package/docs/modules/assets_RotationCcwC.html +0 -1
  166. package/docs/modules/assets_RotationCw.html +0 -1
  167. package/docs/modules/assets_RotationCwA.html +0 -1
  168. package/docs/modules/assets_RotationCwB.html +0 -1
  169. package/docs/modules/assets_RotationCwC.html +0 -1
  170. package/docs/modules/assets_Run.html +0 -1
  171. package/docs/modules/assets_Speed.html +0 -1
  172. package/docs/modules/assets_SpeedFast.html +0 -1
  173. package/docs/modules/assets_SpeedMedium.html +0 -1
  174. package/docs/modules/assets_SpeedNone.html +0 -1
  175. package/docs/modules/assets_SpeedSlow.html +0 -1
  176. package/docs/modules/assets_Walk.html +0 -1
  177. package/docs/modules/components_AutoCoreDevPanel.html +0 -20
  178. package/docs/modules/components_BlocklyEditor.html +0 -1
  179. package/docs/modules/components_CodeEditor.html +0 -1
  180. package/docs/modules/components_FileList.html +0 -1
  181. package/docs/modules/components_FileSelect.html +0 -1
  182. package/docs/modules/components_FitText.html +0 -1
  183. package/docs/modules/components_Indicator.html +0 -1
  184. package/docs/modules/components_IndicatorButton.html +0 -1
  185. package/docs/modules/components_IndicatorRect.html +0 -1
  186. package/docs/modules/components_JogPanel.html +0 -1
  187. package/docs/modules/components_Lamp.html +0 -1
  188. package/docs/modules/components_Osk.html +0 -1
  189. package/docs/modules/components_OskDialog.html +0 -1
  190. package/docs/modules/components_ProgressBarWithValue.html +0 -1
  191. package/docs/modules/components_TextInput.html +0 -1
  192. package/docs/modules/components_ToggleGroup.html +0 -1
  193. package/docs/modules/components_ValueDisplay.html +0 -1
  194. package/docs/modules/components_ValueIndicator.html +0 -1
  195. package/docs/modules/components_ValueInput.html +0 -1
  196. package/docs/modules/core_ActionMode.html +0 -1
  197. package/docs/modules/core_AutoCoreTagContext.html +0 -11
  198. package/docs/modules/core_AutoCoreTagTypes.html +0 -1
  199. package/docs/modules/core_EventEmitterContext.html +0 -53
  200. package/docs/modules/core_IndicatorButtonState.html +0 -1
  201. package/docs/modules/core_IndicatorColor.html +0 -1
  202. package/docs/modules/core_MaskPatterns.html +0 -1
  203. package/docs/modules/core_NumerableTypes.html +0 -1
  204. package/docs/modules/core_PositionContext.html +0 -1
  205. package/docs/modules/core_UniqueId.html +0 -1
  206. package/docs/modules/core_ValueSimulator.html +0 -1
  207. package/docs/modules/core_hoc.html +0 -1
  208. package/docs/modules/hooks.html +0 -1
  209. package/docs/modules/hooks_adsHooks.html +0 -1
  210. package/docs/modules/hooks_commandHooks.html +0 -1
  211. package/docs/modules/hooks_useAutoCoreTag.ts.html +0 -52
  212. package/docs/modules/hooks_useScaledValue.html +0 -1
  213. package/docs/modules/hub.html +0 -1
  214. package/docs/modules/hub_CommandMessage.html +0 -1
  215. package/docs/modules/hub_HubBase.html +0 -1
  216. package/docs/modules/hub_HubSimulate.html +0 -1
  217. package/docs/modules/hub_HubTauri.html +0 -1
  218. package/docs/modules/hub_HubWebSocket.html +0 -1
  219. package/docs/modules.html +0 -23
  220. package/docs/types/components_IndicatorButton.IndicatorButtonOptionsType.html +0 -1
  221. package/docs/types/core_AutoCoreTagTypes.ExtractByTag.html +0 -2
  222. package/docs/types/core_AutoCoreTagTypes.PrimitiveKind.html +0 -1
  223. package/docs/types/core_AutoCoreTagTypes.TagConfig.html +0 -16
  224. package/docs/types/core_AutoCoreTagTypes.TagValueMap.html +0 -1
  225. package/docs/types/core_AutoCoreTagTypes.TagValueOf.html +0 -1
  226. package/docs/types/core_EventEmitterContext.EmitterDispatchFunction.html +0 -3
  227. package/docs/types/core_EventEmitterContext.EmitterSubscribeFunction.html +0 -3
  228. package/docs/types/core_EventEmitterContext.EmitterUnsubscribeFunction.html +0 -3
  229. package/docs/types/core_NumerableTypes.NumerableFormatOptions.html +0 -4
  230. package/docs/types/core_hoc.HocAddSubscriptionProps.html +0 -6
  231. package/docs/variables/components_AutoCoreDevPanel.AutoCoreDevPanel.html +0 -43
  232. package/docs/variables/components_BlocklyEditor.BlocklyEditor.html +0 -13
  233. package/docs/variables/components_BlocklyEditor.StandardToolbox.html +0 -1
  234. package/docs/variables/components_FileList.FileList.html +0 -23
  235. package/docs/variables/components_FileSelect.FileSelect.html +0 -1
  236. package/docs/variables/components_FitText.FitText.html +0 -4
  237. package/docs/variables/components_IndicatorButton.IndicatorButton.html +0 -1
  238. package/docs/variables/components_JogPanel.DefaultLinearJogButtons.html +0 -2
  239. package/docs/variables/components_JogPanel.DefaultRotationJogButtons.html +0 -2
  240. package/docs/variables/components_Osk.Osk.html +0 -1
  241. package/docs/variables/components_ProgressBarWithValue.ProgressBarWithValue.html +0 -1
  242. package/docs/variables/components_ToggleGroup.ToggleGroup.html +0 -1
  243. package/docs/variables/components_ValueInput.ValueInput.html +0 -4
  244. package/docs/variables/core_AutoCoreTagContext.AutoCoreTagContext.html +0 -1
  245. package/docs/variables/core_AutoCoreTagContext.AutoCoreTagProvider.html +0 -7
  246. package/docs/variables/core_EventEmitterContext.EventEmitterContext.html +0 -64
  247. package/docs/variables/core_EventEmitterContext.EventEmitterProvider.html +0 -10
  248. package/docs/variables/core_MaskPatterns.PrimeReactMaskPatterns.html +0 -14
  249. package/docs/variables/core_MaskPatterns.RegExMaskPatterns.html +0 -15
  250. package/docs/variables/core_PositionContext.DimensionsContext.html +0 -6
  251. package/docs/variables/hooks_useScaledValue.kMillimeters2Inches.html +0 -2
  252. package/docs/variables/hooks_useScaledValue.kNewtons2Pounds.html +0 -2
@@ -1,75 +1,35 @@
1
1
  import { HubBase } from './HubBase';
2
- import type { CommandMessageResult } from "./CommandMessage";
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 tauri backend is expected to broadcast messages on the event
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
- * Example: Listen to an event 'xarm-position':
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
- * The hub should also be used for invoking events in the Tauri backend.
36
- * This example will call the function "update_count" in the rust backend, passing
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
- * Of course, like any class derived from HubBase, the hub can be used to publish and subscribe to
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
- * Invoke a method in the rust backend.
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 fname method name
83
- * @param payload Optional data payload
84
- * @returns The return value of the backend method.
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(domain: string, fname: string, payload?: object | undefined): Promise<CommandMessageResult>;
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":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,qBAAa,QAAS,SAAQ,OAAO;IAEjC;;OAEG;;IAgCH;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAG,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAkBtG"}
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"}
@@ -1 +1 @@
1
- import{HubBase}from"./HubBase";import{event,invoke}from"@tauri-apps/api";export class HubTauri extends HubBase{constructor(){super(),event.listen("autocore://broadcast_event",o=>{let e=JSON.parse(o.payload);void 0!==e.topic&&null!==e.topic&&(void 0!==e.payload&&null!==e.payload?this.publish(e.topic,e.payload):this.publish(e.topic,void 0))})}invoke(o,e,i){if(null!=i){return invoke(`${o}_${e}`,i)}return invoke(e)}}
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
- /** @file
1
+ /**
2
+ * @module hub/HubWebSocket
2
3
  *
3
- * ## broadcast messages
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
- * broadcast topic = `${CommandMessage.domain}/${CommandMessage.result["topic"]}
6
+ * ## Functionality
10
7
  *
11
- * So, to subscribe to a broadcast topic for GM.fReal that is served by the ADS client, the
12
- * topic will be: "ADS/GM.fReal"
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 type { CommandMessage, CommandMessageResult } from "./CommandMessage";
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
- * Constructor. Creates and attempts to make the Websocket connection.
34
+ * Initializes the WebSocket connection immediately.
22
35
  */
23
36
  constructor();
24
37
  /**
25
- * Invoke a command in the remote webserver.
26
- * @param domain The domain of the Servelet supplying the functionality.
27
- * @param fname The name of the command to execute.
28
- * @param payload The arguments of the command.
29
- * @returns Promise<CommandMessageResult>
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":"AASA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AA8F7E,qBAAa,YAAa,SAAQ,OAAO;IACrC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,eAAe,CAAoC;IAE3D;;OAEG;;IAgGH;;;;;;OAMG;IACH,MAAM,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,oBAAoB,CAAC,CAgBxF;IAED,wBAAwB,GAAI,KAAK,cAAc,UAiB9C;IAED,UAAU,QAAO,IAAI,CAEpB;IAED,SAAS,CAAC,IAAI,GAAI,WAAW,MAAM,EAAE,UAAU,MAAM,KAAG,IAAI,CAE3D;CACJ"}
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"}
@@ -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),r=new Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);const i=new Uint8Array(r);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 r=++this.requestId;this.pendingRequests.set(r,{resolve:n,reject:o});let i={request_id:r,domain:e,fname:t,args:s,result:void 0};this.socket.send(JSON.stringify(i))})}),Object.defineProperty(this,"handleUnsolicitedMessage",{enumerable:!0,configurable:!0,writable:!0,value:e=>{if("BROADCAST"===e.fname&&e.domain.length>=1&&void 0!==e.result&&null!==e.result&&void 0!==e.result.data&&null!==e.result.data){let t=`${e.domain}/${e.result.data.topic}`;this.publish(t,e.result.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}))}});const e=window.location.hostname;let t;const s=`${"https:"===window.location.protocol?"wss://":"ws://"}${e}${t?":"+t:""}/ws/`;this.socket=new WebSocket(s);let n=this;this.socket.onopen=function(){n.publish("HUB/connected",!0),n.setIsConnected(!0)},this.socket.onmessage=e=>{const t=JSON.parse(e.data);if(t.request_id&&this.pendingRequests.has(t.request_id)){const{resolve:e,reject:s}=this.pendingRequests.get(t.request_id);if("FILE_DOWNLOAD"===t.fname&&void 0!==t.args.file_name&&null!==t.args.file_name&&t.args.file_name.length>0){let n=t.args.file_name.split("/");const o=n[n.length-1];if(t.result&&t.result.success){downloadBlob(b64toBlob(t.result.data),o),t.result.data=o,e(t.result)}else s(new Error(t.result?.error_message))}else t.result?.success?e(t.result):s(new Error(t.result?.error_message));this.pendingRequests.delete(t.request_id)}else this.handleUnsolicitedMessage(t)},this.socket.onerror=e=>{},this.socket.onclose=()=>{n.setIsConnected(!1)}}}
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;
@@ -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 a connection to the backend.
8
- * @returns Hub
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, CommandMessageResult };
29
+ export type { CommandMessage } from './CommandMessage';
30
+ export { MessageType } from './CommandMessage';
16
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hub/index.ts"],"names":[],"mappings":"AAUA,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,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7E;;;GAGG;AACH,wBAAgB,SAAS,IAAI,GAAG,CAoC/B;AAKD,OAAO,EAAC,OAAO,IAAI,GAAG,EAAC,MAAM,WAAW,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,CAAA;AACjB,OAAO,EAAC,YAAY,EAAC,CAAA;AACrB,OAAO,EAAC,WAAW,EAAC,CAAA;AACpB,YAAY,EAAC,cAAc,EAAE,oBAAoB,EAAC,CAAA"}
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||(hubInstance=void 0!==window.__TAURI__&&null!==window.__TAURI__?new HubTauri:new HubWebSocket),hubInstance}export{HubBase as Hub}from"./HubBase";export{HubTauri};export{HubWebSocket};export{HubSimulate};
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.1.1",
3
+ "version": "3.3.2",
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": "^1.6.0",
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.3.7",
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",
@@ -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: 2025-09-10 11:15:10
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.tagName];
171
- const raw = rawValues[tag.tagName];
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.tagName;
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.tagName] ?? "";
286
- const err = errors[tag.tagName];
288
+ const buf = editBuf[tag.fqdn] ?? "";
289
+ const err = errors[tag.fqdn];
287
290
 
288
291
  return (
289
- <tr key={tag.tagName}>
292
+ <tr key={tag.fqdn}>
290
293
  <Td mono>{tag.tagName}</Td>
291
294
  <Td mono>{tag.valueType}</Td>
292
- <Td mono>{tag.domain}</Td>
293
- <Td mono>{tag.symbolName}</Td>
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.tagName, v)}
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.tagName as any)}>TAP</button>
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, "list_files", args);
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, "download_file", { file_name: target });
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, "delete_file", { file_name: target });
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, "write_file", { file_name: target, value: base64String, options :{"base64" : true} });
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, "list_files", args);
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
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
3
  * Created Date: 2024-03-12 10:28:38
4
4
  * -----
5
- * Last Modified: 2024-03-12 10:28:47
5
+ * Last Modified: 2026-01-29 09:31:30
6
6
  * -----
7
7
  *
8
8
  */