@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.
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 +8 -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 +1 @@
1
- import{useContext,useRef,useEffect,useCallback}from"react";import{EventEmitterContext}from"../core/EventEmitterContext";function sleep(e){return new Promise(t=>setTimeout(t,e))}export const useAdsRegisterSymbols=(e,t,n={})=>{const{invoke:r,subscribe:s,unsubscribe:o,isConnected:u}=useContext(EventEmitterContext),c=useRef([]),a=useRef(!0);return useEffect(()=>{a.current=!0;const i=async()=>{for(const[o,u]of Object.entries(t))try{const t=n[o]?{symbol_name:u,options:n[o]}:{symbol_name:u};await r("ADS","register_symbol",t);const i=s(`ADS/${u}`,t=>{if(a.current){const n=e[o];n&&n(t.value)}});c.current.push(i)}catch(e){}await r("ADS","refresh",{})};if(u())i();else{let e=s("HUB/connected",()=>{i(),o(e)});c.current.push(e)}return()=>{a.current=!1,c.current.forEach(e=>o(e)),c.current=[]}},[]),null};export function useAdsWriteValue(e){const{invoke:t}=useContext(EventEmitterContext);return async n=>{try{await t("ADS","write_value",{symbol_name:e,value:n})}catch(e){}}}export function useAdsWriteScaledValue(e,t,n){const{invoke:r}=useContext(EventEmitterContext);return useCallback(async s=>{const o=(s-n)/t;try{await r("ADS","write_value",{symbol_name:e,value:o})}catch(e){}},[e,t,n,r])}export function useAdsTapValue(e){const{invoke:t}=useContext(EventEmitterContext),n="write_value";return async()=>{try{await t("ADS",n,{symbol_name:e,value:!0}),await sleep(300),await t("ADS",n,{symbol_name:e,value:!1})}catch(e){}}}
1
+ import{useContext,useRef,useEffect,useCallback}from"react";import{EventEmitterContext}from"../core/EventEmitterContext";import{MessageType}from"../hub/CommandMessage";function sleep(e){return new Promise(t=>setTimeout(t,e))}export const useAdsRegisterSymbols=(e,t,n={})=>{const{invoke:s,subscribe:r,unsubscribe:o,isConnected:c}=useContext(EventEmitterContext),u=useRef([]),a=useRef(!0);return useEffect(()=>{a.current=!0;const i=async()=>{for(const[o,c]of Object.entries(t))try{const t=n[o]?{symbol_name:c,options:n[o]}:{symbol_name:c};await s("ADS.register_symbol",MessageType.Request,t);const i=r(`ADS/${c}`,t=>{if(a.current){const n=e[o];n&&n(t.value)}});u.current.push(i)}catch(e){}await s("ADS.refresh",MessageType.Request,{})};if(c())i();else{let e=r("HUB/connected",()=>{i(),o(e)});u.current.push(e)}return()=>{a.current=!1,u.current.forEach(e=>o(e)),u.current=[]}},[]),null};export function useAdsWriteValue(e){const{write:t}=useContext(EventEmitterContext);return async n=>{try{await t(`ADS.${e}`,n)}catch(e){}}}export function useAdsWriteScaledValue(e,t,n){const{write:s}=useContext(EventEmitterContext);return useCallback(async r=>{const o=(r-n)/t;try{await s(`ADS.${e}`,o)}catch(e){}},[e,t,n,s])}export function useAdsTapValue(e){const{write:t}=useContext(EventEmitterContext);return async()=>{try{const n=`ADS.${e}`;await t(n,!0),await sleep(300),await t(n,!1)}catch(e){}}}
@@ -65,7 +65,7 @@ export declare const useRegisterSymbols: (domain: string, setters: Record<string
65
65
  * );
66
66
  * };
67
67
  */
68
- export declare function useWriteValue(domain: string, symbolName: string, fname?: string): (value: object | boolean | number | string) => Promise<void>;
68
+ export declare function useWriteValue(domain: string, symbolName: string): (value: object | boolean | number | string) => Promise<void>;
69
69
  /**
70
70
  * useWriteScaledValue is a custom React hook that enables writing scaled numerical values to the autocore backend system.
71
71
  * It applies a specified scale and offset to a numeric value before sending it over the websocket connection.
@@ -114,7 +114,7 @@ export declare function useWriteValue(domain: string, symbolName: string, fname?
114
114
  * converts it to millimeters using the current `scale`, and writes the result to a backend symbol. The `scale` and `offset` can be adjusted
115
115
  * dynamically if needed, for instance, based on user selection or other external configurations.
116
116
  */
117
- export declare function useWriteScaledValue(domain: string, symbolName: string, scale: number, offset: number, fname?: string): (value: number) => Promise<void>;
117
+ export declare function useWriteScaledValue(domain: string, symbolName: string, scale: number, offset: number): (value: number) => Promise<void>;
118
118
  /**
119
119
  * Custom hook to send a "tap" action, which sends true followed by false after a short delay,
120
120
  * to a specified symbol in the backend. This is used to simulate a button tap or momentary switch.
@@ -142,5 +142,5 @@ export declare function useWriteScaledValue(domain: string, symbolName: string,
142
142
  * };
143
143
  * ```
144
144
  */
145
- export declare function useTapValue(domain: string, symbolName: string, fname?: string): () => Promise<void>;
145
+ export declare function useTapValue(domain: string, symbolName: string): () => Promise<void>;
146
146
  //# sourceMappingURL=commandHooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandHooks.d.ts","sourceRoot":"","sources":["../../src/hooks/commandHooks.tsx"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,kBAAkB,GAC3B,QAAS,MAAM,EACf,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,EAC7C,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,UAAS,MAAM,CAAC,MAAM,EAAE,EAAE,CAAM,SAiEnC,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAG,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAG,MAAsB,IAI/E,OAAO,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,mBAO1D;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAG,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,MAAsB,WAGjG,MAAM,mBAa1C;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAG,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAG,MAAsB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAYpH"}
1
+ {"version":3,"file":"commandHooks.d.ts","sourceRoot":"","sources":["../../src/hooks/commandHooks.tsx"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,kBAAkB,GAC3B,QAAS,MAAM,EACf,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,EAC7C,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,UAAS,MAAM,CAAC,MAAM,EAAE,EAAE,CAAM,SAgEnC,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,IAI9C,OAAO,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,mBAQ1D;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAGhE,MAAM,mBAc1C;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAcnF"}
@@ -1 +1 @@
1
- import{useContext,useRef,useEffect,useCallback}from"react";import{EventEmitterContext}from"../core/EventEmitterContext";function sleep(e){return new Promise(t=>setTimeout(t,e))}export const useRegisterSymbols=(e,t,n,r={})=>{const{subscribe:o,unsubscribe:u,isConnected:s,invoke:c}=useContext(EventEmitterContext),a=useRef([]),i=useRef(!0);return useEffect(()=>{i.current=!0;const r=async()=>{for(const[r,u]of Object.entries(n))try{const n=o(`${e}/${u}`,e=>{if(i.current){const n=t[r];n&&n(e.value)}});a.current.push(n),await c(e,"refresh",{topic:`${u}`})}catch(e){}};if(s())r();else{let e=o("HUB/connected",()=>{setTimeout(()=>{r(),u(e)},500)});a.current.push(e)}return()=>{i.current=!1,a.current.forEach(e=>u(e)),a.current=[]}},[]),null};export function useWriteValue(e,t,n="write_value"){const{invoke:r}=useContext(EventEmitterContext);return async o=>{try{await r(e,n,{topic:t,value:o})}catch(e){}}}export function useWriteScaledValue(e,t,n,r,o="write_value"){const{invoke:u}=useContext(EventEmitterContext);return useCallback(async s=>{const c=(s-r)/n;try{await u(e,o,{symbol_name:t,value:c})}catch(e){}},[t,n,r,u])}export function useTapValue(e,t,n="write_value"){const{invoke:r}=useContext(EventEmitterContext);return async()=>{try{await r(e,n,{symbol_name:t,value:!0}),await sleep(300),await r(e,n,{symbol_name:t,value:!1})}catch(e){}}}
1
+ import{useContext,useRef,useEffect,useCallback}from"react";import{EventEmitterContext}from"../core/EventEmitterContext";import{MessageType}from"../hub/CommandMessage";function sleep(e){return new Promise(t=>setTimeout(t,e))}export const useRegisterSymbols=(e,t,n,r={})=>{const{subscribe:s,unsubscribe:c,isConnected:o,invoke:u}=useContext(EventEmitterContext),a=useRef([]),i=useRef(!0);return useEffect(()=>{i.current=!0;const r=async()=>{for(const[r,c]of Object.entries(n))try{const n=s(`${e}/${c}`,e=>{if(i.current){const n=t[r];n&&n(e.value)}});a.current.push(n),await u(`${e}.${c}`,MessageType.Request,{action:"refresh"})}catch(e){}};if(o())r();else{let e=s("HUB/connected",()=>{setTimeout(()=>{r(),c(e)},500)});a.current.push(e)}return()=>{i.current=!1,a.current.forEach(e=>c(e)),a.current=[]}},[]),null};export function useWriteValue(e,t){const{write:n}=useContext(EventEmitterContext);return async r=>{try{await n(`${e}.${t}`,r)}catch(e){}}}export function useWriteScaledValue(e,t,n,r){const{write:s}=useContext(EventEmitterContext);return useCallback(async c=>{const o=(c-r)/n;try{await s(`${e}.${t}`,o)}catch(e){}},[e,t,n,r,s])}export function useTapValue(e,t){const{write:n}=useContext(EventEmitterContext);return async()=>{try{const r=`${e}.${t}`;await n(r,!0),await sleep(300),await n(r,!1)}catch(e){}}}
@@ -1 +1 @@
1
- import{useCallback,useContext,useMemo}from"react";export function makeAutoCoreTagHooks(e,a){return{useAutoCoreTag:t=>{const{values:s,rawValues:u,isLoading:o,write:r,tap:n}=useContext(e),l=(e=>a.find(a=>a.tagName===e))(t);if(!l)throw new Error(`useAutoCoreTag: unknown tagName '${String(t)}'`);const i=useCallback(e=>r(t,e),[r,t]),c=useCallback(()=>n?.(t),[n,t]);return{value:s[t],rawValue:u[t],write:i,tap:c,isLoading:o}},useAutoCoreTags:a=>{const{values:t,rawValues:s,isLoading:u,write:o}=useContext(e);return{values:useMemo(()=>Object.fromEntries(a.map(e=>[e,t[e]])),[t,a]),rawValues:useMemo(()=>Object.fromEntries(a.map(e=>[e,s[e]])),[s,a]),write:useCallback(async(e,a)=>{await o(e,a)},[o]),isLoading:u}},useAutoCoreSelect:(a,t=[])=>{const{values:s,isLoading:u}=useContext(e);return{selected:useMemo(()=>a(s),[s,...t]),isLoading:u}},useScales:()=>{const{scales:a,updateScale:t}=useContext(e),s=useCallback(e=>a[e],[a]);return{scales:a,updateScale:t,getScale:s}}}}
1
+ import{useCallback,useContext,useMemo}from"react";export function makeAutoCoreTagHooks(e,a){return{useAutoCoreTag:s=>{const{values:t,rawValues:u,isLoading:o,write:r,tap:n}=useContext(e),l=(e=>a.find(a=>a.fqdn===e))(s);if(!l)throw new Error(`useAutoCoreTag: unknown tagName '${String(s)}'`);const i=useCallback(e=>r(s,e),[r,s]),c=useCallback(()=>n?.(s),[n,s]);return{value:t[s],rawValue:u[s],write:i,tap:c,isLoading:o}},useAutoCoreTags:a=>{const{values:s,rawValues:t,isLoading:u,write:o}=useContext(e);return{values:useMemo(()=>Object.fromEntries(a.map(e=>[e,s[e]])),[s,a]),rawValues:useMemo(()=>Object.fromEntries(a.map(e=>[e,t[e]])),[t,a]),write:useCallback(async(e,a)=>{await o(e,a)},[o]),isLoading:u}},useAutoCoreSelect:(a,s=[])=>{const{values:t,isLoading:u}=useContext(e);return{selected:useMemo(()=>a(t),[t,...s]),isLoading:u}},useScales:()=>{const{scales:a,updateScale:s}=useContext(e),t=useCallback(e=>a[e],[a]);return{scales:a,updateScale:s,getScale:t}}}}
@@ -1,13 +1,22 @@
1
- export interface CommandMessageResult {
2
- data: any;
3
- success: boolean;
4
- error_message: string;
1
+ export declare enum MessageType {
2
+ NoOp = 0,
3
+ Response = 1,
4
+ Read = 2,
5
+ Write = 3,
6
+ Subscribe = 4,
7
+ Unsubscribe = 5,
8
+ Broadcast = 6,
9
+ Heartbeat = 7,
10
+ Control = 8,
11
+ Request = 10
5
12
  }
6
13
  export interface CommandMessage {
7
- request_id: number;
8
- domain: string;
9
- fname: string;
10
- args?: any;
11
- result?: CommandMessageResult;
14
+ transaction_id: number;
15
+ timecode: number;
16
+ topic: string;
17
+ message_type: MessageType;
18
+ data?: any;
19
+ success: boolean;
20
+ error_message: string;
12
21
  }
13
22
  //# sourceMappingURL=CommandMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandMessage.d.ts","sourceRoot":"","sources":["../../src/hub/CommandMessage.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,oBAAoB;IAEjC,IAAI,EAAE,GAAG,CAAC;IAEV,OAAO,EAAG,OAAO,CAAC;IAElB,aAAa,EAAE,MAAM,CAAC;CACzB;AAID,MAAM,WAAW,cAAc;IAG3B,UAAU,EAAE,MAAM,CAAC;IAEnB,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX,MAAM,CAAC,EAAE,oBAAoB,CAAC;CACjC"}
1
+ {"version":3,"file":"CommandMessage.d.ts","sourceRoot":"","sources":["../../src/hub/CommandMessage.ts"],"names":[],"mappings":"AAuBA,oBAAY,WAAW;IAEnB,IAAI,IAAI;IAGR,QAAQ,IAAI;IAGZ,IAAI,IAAI;IAGR,KAAK,IAAI;IAGT,SAAS,IAAI;IAGb,WAAW,IAAI;IAGf,SAAS,IAAI;IAGb,SAAS,IAAI;IAGb,OAAO,IAAI;IAGX,OAAO,KAAK;CACf;AAMD,MAAM,WAAW,cAAc;IAG3B,cAAc,EAAE,MAAM,CAAC;IAIvB,QAAQ,EAAE,MAAM,CAAC;IAKjB,KAAK,EAAE,MAAM,CAAC;IAGd,YAAY,EAAE,WAAW,CAAC;IAK1B,IAAI,CAAC,EAAE,GAAG,CAAC;IAIX,OAAO,EAAE,OAAO,CAAC;IAGjB,aAAa,EAAE,MAAM,CAAC;CAEzB"}
@@ -1 +1 @@
1
- export{};
1
+ export var MessageType;!function(e){e[e.NoOp=0]="NoOp",e[e.Response=1]="Response",e[e.Read=2]="Read",e[e.Write=3]="Write",e[e.Subscribe=4]="Subscribe",e[e.Unsubscribe=5]="Unsubscribe",e[e.Broadcast=6]="Broadcast",e[e.Heartbeat=7]="Heartbeat",e[e.Control=8]="Control",e[e.Request=10]="Request"}(MessageType||(MessageType={}));
@@ -0,0 +1,31 @@
1
+ interface DebugLog {
2
+ time: string;
3
+ type: "info" | "warn" | "error" | "send" | "recv";
4
+ source: string;
5
+ message: string;
6
+ }
7
+ declare class DebugPanel {
8
+ private container;
9
+ private logContainer;
10
+ private statsContainer;
11
+ private logs;
12
+ private maxLogs;
13
+ private stats;
14
+ constructor();
15
+ private injectPanel;
16
+ private setupElements;
17
+ private updateStats;
18
+ log(type: DebugLog["type"], source: string, message: string): void;
19
+ private renderLogs;
20
+ hubCreated(): void;
21
+ connectCalled(socketState: string): void;
22
+ wsOpened(url: string): void;
23
+ wsClosed(code: number, reason: string): void;
24
+ wsError(error: string): void;
25
+ messageSent(type: string, command: string, requestId: number): void;
26
+ messageReceived(type: string, command: string, requestId?: number): void;
27
+ updateState(state: string): void;
28
+ }
29
+ export declare function getDebugPanel(): DebugPanel;
30
+ export default getDebugPanel;
31
+ //# sourceMappingURL=DebugPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DebugPanel.d.ts","sourceRoot":"","sources":["../../src/hub/DebugPanel.ts"],"names":[],"mappings":"AAWA,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,UAAU;IACd,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,OAAO,CAAO;IAGtB,OAAO,CAAC,KAAK,CASX;;IAOF,OAAO,CAAC,WAAW;IA2FnB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,WAAW;IAsBnB,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAyBlE,OAAO,CAAC,UAAU;IAgBlB,UAAU,IAAI,IAAI;IAMlB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAOxC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAO3B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAO5C,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM5B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAMnE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAMxE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAIjC;AAKD,wBAAgB,aAAa,IAAI,UAAU,CAO1C;AAKD,eAAe,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ class DebugPanel{constructor(){Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"logContainer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"statsContainer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"logs",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"maxLogs",{enumerable:!0,configurable:!0,writable:!0,value:100}),Object.defineProperty(this,"stats",{enumerable:!0,configurable:!0,writable:!0,value:{hubInstancesCreated:0,connectCalls:0,wsOpened:0,wsClosed:0,wsErrors:0,messagesSent:0,messagesReceived:0,currentState:"unknown"}}),this.injectPanel(),this.log("info","DebugPanel","Debug panel initialized")}injectPanel(){const e=document.getElementById("autocore-debug-panel");e&&e.remove(),this.container=document.createElement("div"),this.container.id="autocore-debug-panel",this.container.innerHTML='\n <style>\n #autocore-debug-panel {\n position: fixed;\n bottom: 10px;\n right: 10px;\n width: 400px;\n max-height: 300px;\n background: rgba(0, 0, 0, 0.9);\n color: #0f0;\n font-family: monospace;\n font-size: 11px;\n border: 1px solid #0f0;\n border-radius: 4px;\n z-index: 99999;\n overflow: hidden;\n }\n #autocore-debug-panel .header {\n background: #0f0;\n color: #000;\n padding: 4px 8px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n justify-content: space-between;\n }\n #autocore-debug-panel .stats {\n padding: 4px 8px;\n border-bottom: 1px solid #0f0;\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 2px;\n }\n #autocore-debug-panel .stats span {\n color: #fff;\n }\n #autocore-debug-panel .stats .value {\n color: #ff0;\n }\n #autocore-debug-panel .logs {\n max-height: 180px;\n overflow-y: auto;\n padding: 4px;\n }\n #autocore-debug-panel .log-entry {\n margin: 1px 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n #autocore-debug-panel .log-entry.info { color: #888; }\n #autocore-debug-panel .log-entry.warn { color: #fa0; }\n #autocore-debug-panel .log-entry.error { color: #f44; }\n #autocore-debug-panel .log-entry.send { color: #4f4; }\n #autocore-debug-panel .log-entry.recv { color: #44f; }\n #autocore-debug-panel .state-connected { color: #4f4 !important; }\n #autocore-debug-panel .state-disconnected { color: #f44 !important; }\n #autocore-debug-panel .state-connecting { color: #fa0 !important; }\n </style>\n <div class="header">\n <span>AutoCore Debug</span>\n <span id="debug-toggle">[_]</span>\n </div>\n <div id="debug-content">\n <div class="stats" id="debug-stats"></div>\n <div class="logs" id="debug-logs"></div>\n </div>\n ',document.body?(document.body.appendChild(this.container),this.setupElements()):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.container),this.setupElements()})}setupElements(){this.statsContainer=document.getElementById("debug-stats"),this.logContainer=document.getElementById("debug-logs");const e=document.getElementById("debug-toggle"),t=document.getElementById("debug-content");e?.addEventListener("click",()=>{t&&(t.style.display="none"===t.style.display?"block":"none",e.textContent="none"===t.style.display?"[+]":"[_]")}),this.updateStats()}updateStats(){if(!this.statsContainer)return;const e="OPEN"===this.stats.currentState?"state-connected":"CONNECTING"===this.stats.currentState?"state-connecting":"state-disconnected";this.statsContainer.innerHTML=`\n <div><span>Hub Instances:</span> <span class="value">${this.stats.hubInstancesCreated}</span></div>\n <div><span>connect() calls:</span> <span class="value">${this.stats.connectCalls}</span></div>\n <div><span>WS Opened:</span> <span class="value">${this.stats.wsOpened}</span></div>\n <div><span>WS Closed:</span> <span class="value">${this.stats.wsClosed}</span></div>\n <div><span>WS Errors:</span> <span class="value">${this.stats.wsErrors}</span></div>\n <div><span>Msgs Sent:</span> <span class="value">${this.stats.messagesSent}</span></div>\n <div><span>Msgs Recv:</span> <span class="value">${this.stats.messagesReceived}</span></div>\n <div><span>WS State:</span> <span class="value ${e}">${this.stats.currentState}</span></div>\n `}log(e,t,n){const s=(new Date).toTimeString().slice(0,8),a={time:s,type:e,source:t,message:n};this.logs.push(a),this.logs.length>this.maxLogs&&this.logs.shift();this.renderLogs()}renderLogs(){this.logContainer&&(this.logContainer.innerHTML=this.logs.slice(-50).map(e=>`<div class="log-entry ${e.type}">[${e.time}] ${e.source}: ${e.message}</div>`).join(""),this.logContainer.scrollTop=this.logContainer.scrollHeight)}hubCreated(){this.stats.hubInstancesCreated++,this.log("warn","Hub",`NEW INSTANCE CREATED (total: ${this.stats.hubInstancesCreated})`),this.updateStats()}connectCalled(e){this.stats.connectCalls++,this.stats.currentState=e,this.log("info","Hub",`connect() called (socket state: ${e})`),this.updateStats()}wsOpened(e){this.stats.wsOpened++,this.stats.currentState="OPEN",this.log("info","WS",`OPENED: ${e}`),this.updateStats()}wsClosed(e,t){this.stats.wsClosed++,this.stats.currentState="CLOSED",this.log("warn","WS",`CLOSED: code=${e}, reason=${t}`),this.updateStats()}wsError(e){this.stats.wsErrors++,this.log("error","WS",`ERROR: ${e}`),this.updateStats()}messageSent(e,t,n){this.stats.messagesSent++,this.log("send","WS",`>>> ${e}/${t} (id=${n})`),this.updateStats()}messageReceived(e,t,n){this.stats.messagesReceived++,this.log("recv","WS",`<<< ${e}/${t} (id=${n??"none"})`),this.updateStats()}updateState(e){this.stats.currentState=e,this.updateStats()}}let debugPanel=null;export function getDebugPanel(){return debugPanel||(debugPanel=new DebugPanel,window.__AUTOCORE_DEBUG_PANEL__=debugPanel),debugPanel}getDebugPanel();export default getDebugPanel;
@@ -1,182 +1,136 @@
1
1
  import type { EventEmitterContextType } from '../core/EventEmitterContext';
2
- import type { CommandMessageResult } from "./CommandMessage";
2
+ import type { CommandMessage } from "./CommandMessage";
3
+ import { MessageType } from "./CommandMessage";
3
4
  /**
4
- * Base class for the interface for the IPC to the backend,
5
- * which may be websockets, MQTT, the Tauri API,
6
- * or something else.
5
+ * @class HubBase
6
+ * @abstract
7
7
  *
8
- * The EventEmitterContext should generate the hub automatically.
8
+ * Abstract base class that defines the interface for communicating with the AutoCore backend.
9
+ * Implementations (like `HubWebSocket` or `HubTauri`) handle the specific transport mechanics.
9
10
  *
10
- * # Usage
11
- * The hub can be used to publish and subscribe to
12
- * topics in the front-end, regardless of being connected to any backend.
11
+ * ## Core Responsibilities
13
12
  *
14
- * ```
15
- * const {dispatch, subscribe, unsubscribe} = useContext(EventEmitterContext);
16
- * const [controlPower, setControlPower] = useState(false);
17
- * useEffect(() => {
18
- * const unsubscribeControlPower = subscribe('value-simulator-bBit1', (value) => {
19
- * setControlPower(value);
20
- * });
21
- *
22
- *
23
- * return () => {
24
- * unsubscribe(unsubscribeControlPower);
25
- * }
26
- * }, [] );
27
- *
28
- * const onPbPressed = () => {
29
- * let count = 1;
30
- * dispatch({
31
- * topic: "my-awesome-topic",
32
- * payload: count
33
- * });
34
- * }
35
- *
36
- * ```
37
- * The hub should also be used for invoking events in the backend.
38
- * This example will call the function "update_count" in the backend, passing
39
- * the expected argument "count". Details of the interaction between the Hub and
40
- * the backend will be handled by the appropriate HubBase sub-class, and should
41
- * be transparent to the front end.
42
- *
43
- * ```
44
- * const {invoke} = useContext(EventEmitterContext);
45
- * const incrementCount = () => {
46
- * count += 1;
47
- * invoke('update_count', {"count": count});
48
- * };
49
- *
50
- * Subscribing to a topic is simple. The type of value received is specific
51
- * to the topic.
13
+ * 1. **Transport Abstraction**: Provides a unified API (`read`, `write`, `subscribe`) regardless of
14
+ * underlying transport (WS, IPC, etc.).
15
+ * 2. **Topic Mapping**: Maintains a bidirectional mapping between local `tagName` (UI friendly)
16
+ * and backend `FQDN` (Fully Qualified Domain Name).
17
+ * - `tagName`: "motorsEnable"
18
+ * - `FQDN`: "ADS.Main.bMotorsEnable"
19
+ * 3. **Event Dispatching**: Routes incoming messages from the backend to the `EventEmitterContext`.
52
20
  *
53
- * Example: Listen to an event 'xarm-position':
54
- * ```
55
- * const {subscribe, unsubscribe} = useContext(EventEmitterContext);
56
- * useEffect(() => {
57
- * const unsubscripeMp = subscribe('xarm-position', (value) => {
58
- * // The publisher sent a JSON object of 3D position values.
59
- * setX(value.x);
60
- * setY(value.y);
61
- * setZ(value.z);
62
- * setA(value.roll);
63
- * setB(value.yaw);
64
- * setC(value.pitch);
65
- * });
66
- *
67
- * return () => {
68
- * unsubscribe(unsubscripeMp);
69
- * }
21
+ * ## Usage
70
22
  *
71
- * }, [] );
23
+ * The `Hub` is typically accessed via the `EventEmitterContext`:
72
24
  *
25
+ * ```typescript
26
+ * const { hub } = useContext(EventEmitterContext);
27
+ * await hub.write("ADS.Main.nSpeed", 500);
73
28
  * ```
74
- *
75
29
  */
76
30
  export declare abstract class HubBase {
31
+ /** Maps local tag names to backend FQDNs. */
77
32
  protected localTopicToBackendTopicMap: Map<string, string>;
33
+ /** Maps backend FQDNs to local tag names. */
78
34
  protected backendTopicToLocalMap: Map<string, string>;
79
- protected localFNameToBackendFNameMap: Map<string, string>;
80
- protected backendFNameToLocalFNameMap: Map<string, string>;
35
+ /** Reference to the global event emitter for dispatching incoming messages. */
81
36
  protected context: EventEmitterContextType | null;
37
+ /** Connection state tracker. */
82
38
  protected isConnected_: boolean;
83
39
  /**
84
40
  * Constructor
85
41
  */
86
42
  constructor();
87
43
  /**
88
- * Set the EventEmitterContext for this instance of the Hub. The EventEmitterContext
89
- * should handle this as part of the initialization sequence. Because React can
90
- * sometimes make (and destroy) multiple copies of the EventEmitterContext, it's important
91
- * that the context be stored in the instance this way so that the HubBase can properly target
92
- * right context.
44
+ * Links this Hub instance with the React application's Event Context.
93
45
  *
94
- * If this context is not sent, no events will be emitted from the backend to the front end,
95
- * and global events in the interface may not work.
46
+ * This connection allows the Hub to "push" messages into the React app by calling `context.dispatch()`.
47
+ * This is called automatically by `EventEmitterProvider` on initialization.
96
48
  *
49
+ * @param context The React context instance.
97
50
  */
98
51
  setContext(context: EventEmitterContextType | null): void;
99
52
  /**
100
- * Invoke/send a message to the back end.
101
- * This does NOT get published to the front end.
53
+ * Sends a raw command message to the backend.
54
+ *
55
+ * @param topic The resource identifier (FQDN).
56
+ * @param messageType The operation to perform (Read, Write, etc.).
57
+ * @param payload The data payload.
58
+ * @returns A Promise that resolves with the server's response.
102
59
  */
103
- abstract invoke(domain: string, fname: string, payload?: object): Promise<CommandMessageResult>;
60
+ abstract invoke(topic: string, messageType: MessageType, payload?: object): Promise<CommandMessage>;
104
61
  /**
105
- * Allos the derived class to set whether the hub is connected to its source.
106
- * @param s boolean
62
+ * Request the current value of a resource.
63
+ *
64
+ * @param topic FQDN of the resource.
107
65
  */
108
- protected setIsConnected: (s: boolean) => void;
66
+ read(topic: string, payload?: object): Promise<CommandMessage>;
109
67
  /**
110
- * Returns true if the Hub is connected to its source.
68
+ * Write a new value to a resource.
69
+ *
70
+ * @param topic FQDN of the resource.
71
+ * @param value The value to write.
111
72
  */
112
- isConnected: () => boolean;
73
+ write(topic: string, value: any): Promise<CommandMessage>;
113
74
  /**
114
- * Convenience function to invoke a command with an optional topic and optional value.
115
- * This will invoke the specified command in the backend. It does not broadcast the
116
- * value within the local frontend.
117
- * @param domain string The domain of the command that will be invoked.
118
- * @param fname string Function name
119
- * @param topic string Topic
120
- * @param value any data payload
75
+ * Subscribe to updates for a specific resource.
76
+ *
77
+ * Registers a mapping so that when the server sends updates for `topic` (FQDN),
78
+ * the Hub will translate it to `tagName` before dispatching to the UI.
79
+ *
80
+ * @param tagName The local alias for this resource (e.g., "position").
81
+ * @param topic The backend FQDN (e.g., "ADS.Main.fPos").
82
+ * @param payload Optional subscription parameters (rate, deadband).
121
83
  */
122
- invokeTopic(domain: string, fname: string, topic: string | null, value?: any): Promise<CommandMessageResult>;
84
+ subscribe(tagName: string, topic: string, payload?: object): Promise<CommandMessage>;
123
85
  /**
124
- * Pubish a topic throughout the web app using the
125
- * Global EventEmitterContext. This will broadcast within the local frontend.
126
- * This does NOT get relayed to the backend.
86
+ * Unsubscribe from updates.
87
+ *
88
+ * Uses the `tagName` to look up the FQDN and send the unsubscribe command.
89
+ * Also removes the local mapping.
90
+ *
91
+ * @param tagName The local alias to unsubscribe.
127
92
  */
128
- publish(topic: string, data: any | undefined): void;
93
+ unsubscribe(/* topic: string,*/ tagName: string, payload?: object): Promise<CommandMessage>;
129
94
  /**
130
- * Map a local topic to a topic in the backend.
131
- * @param localTopic string
132
- * @param backendTopic string
95
+ * Send a generic request (custom command).
133
96
  */
134
- mapTopic(localTopic: string, backendTopic: string): void;
97
+ request(topic: string, payload?: object): Promise<CommandMessage>;
135
98
  /**
136
- * Unmap a local topic.
137
- * @param localTopic string
99
+ * Update internal connection state.
138
100
  */
139
- unmapTopic(localTopic: string): void;
101
+ protected setIsConnected: (s: boolean) => void;
140
102
  /**
141
- * Map a local function name, as would be sent to the invoke method, to a
142
- * function name in the backend.
143
- * @param localFName string
144
- * @param backendFName string
103
+ * Check if currently connected to backend.
145
104
  */
146
- mapFName(localFName: string, backendFName: string): void;
105
+ isConnected: () => boolean;
147
106
  /**
148
- * Unmap a local function name.
149
- * @param localFName string
107
+ * Dispatches an event to the React application.
108
+ *
109
+ * 1. Translates the `topic` (potentially an FQDN) to a local `tagName` if a mapping exists.
110
+ * 2. Calls `context.dispatch()` to notify local subscribers.
111
+ *
112
+ * This is the bridge between the backend transport and the frontend UI components.
113
+ *
114
+ * @param topic The topic from the message (usually FQDN).
115
+ * @param data The data payload.
150
116
  */
151
- unmapFName(localFName: string): void;
117
+ publish(topic: string, data: any | undefined): void;
152
118
  /**
153
- * Convert a local topic to a backend topic. If a mapping isn't
154
- * registered, the local topic is returned.
155
- * @param localTopic local topic name
156
- * @returns string
119
+ * Registers a mapping between a local name and a backend FQDN.
157
120
  */
158
- toBackendTopic(localTopic: string): string;
121
+ mapTopic(localTopic: string, backendTopic: string): void;
159
122
  /**
160
- * Convert a local function name to a backend function name. If a mapping isn't
161
- * registered, the local FName is returned.
162
- * @param localTopic local function name
163
- * @returns string
123
+ * Removes a mapping.
164
124
  */
165
- toBackendFName(localFName: string): string;
125
+ unmapTopic(localTopic: string): void;
166
126
  /**
167
- * Convert a backend topic to a local topic. If a mapping isn't
168
- * registered, the backend topic is returned.
169
- * @param backendTopic backend topic name
170
- * @returns string
127
+ * Translates Local Name -> Backend FQDN.
171
128
  */
172
- toLocalTopic(backendTopic: string): string;
129
+ toBackendTopic(localTopic: string): string;
173
130
  /**
174
- * Convert a backend function name to a local function name. If a mapping isn't
175
- * registered, the backend function name is returned.
176
- * @param backendTopic backend function name
177
- * @returns string
131
+ * Translates Backend FQDN -> Local Name.
178
132
  */
179
- toLocalFName(backendTopic: string): string;
133
+ toLocalTopic(backendTopic: string): string;
180
134
  }
181
135
  export default HubBase;
182
136
  //# sourceMappingURL=HubBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HubBase.d.ts","sourceRoot":"","sources":["../../src/hub/HubBase.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,8BAAsB,OAAO;IAEzB,SAAS,CAAC,2BAA2B,EAAG,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAA4B;IACtF,SAAS,CAAC,sBAAsB,EAAG,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAA4B;IACjF,SAAS,CAAC,2BAA2B,EAAG,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAA4B;IACtF,SAAS,CAAC,2BAA2B,EAAG,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAA4B;IAEtF,SAAS,CAAC,OAAO,EAAG,uBAAuB,GAAG,IAAI,CAAQ;IAE1D,SAAS,CAAC,YAAY,EAAG,OAAO,CAAS;IAGzC;;OAEG;;IAKH;;;;;;;;;;OAUG;IACH,UAAU,CAAC,OAAO,EAAG,uBAAuB,GAAG,IAAI;IAInD;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAG,MAAM,GAAI,OAAO,CAAC,oBAAoB,CAAC;IAGjG;;;OAGG;IACH,SAAS,CAAC,cAAc,GAAI,GAAI,OAAO,UAEtC;IAED;;OAEG;IACH,WAAW,QAAQ,OAAO,CAEzB;IAED;;;;;;;;OAQG;IACH,WAAW,CAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAG,MAAM,EAAE,KAAK,EAAG,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,EAAG,GAAG,GAAK,OAAO,CAAC,oBAAoB,CAAC;IAQlH;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAG,MAAM,EAAE,IAAI,EAAG,GAAG,GAAG,SAAS,GAAI,IAAI;IAWtD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAG,MAAM,EAAE,YAAY,EAAE,MAAM,GAAK,IAAI;IAK3D;;;OAGG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAI,IAAI;IAYrC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAG,MAAM,EAAE,YAAY,EAAE,MAAM,GAAK,IAAI;IAK3D;;;OAGG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAI,IAAI;IAYrC;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAG,MAAM,GAAI,MAAM;IAa5C;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAG,MAAM,GAAI,MAAM;IAc5C;;;;;OAKG;IACH,YAAY,CAAC,YAAY,EAAG,MAAM,GAAI,MAAM;IAc5C;;;;;OAKG;IACH,YAAY,CAAC,YAAY,EAAG,MAAM,GAAI,MAAM;CAc/C;AAGD,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"HubBase.d.ts","sourceRoot":"","sources":["../../src/hub/HubBase.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,OAAO;IAEzB,6CAA6C;IAC7C,SAAS,CAAC,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAA6B;IAEvF,6CAA6C;IAC7C,SAAS,CAAC,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAA6B;IAElF,+EAA+E;IAC/E,SAAS,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAAQ;IAEzD,gCAAgC;IAChC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAS;IAGxC;;OAEG;;IAKH;;;;;;;OAOG;IACH,UAAU,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI;IAQlD;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMnG;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAI9D;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC;IAIzD;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAG,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAKrF;;;;;;;OAOG;IACH,WAAW,CAAE,mBAAmB,CAAC,OAAO,EAAG,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAM7F;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAQjE;;OAEG;IACH,SAAS,CAAC,cAAc,GAAI,GAAG,OAAO,UAErC;IAED;;OAEG;IACH,WAAW,QAAO,OAAO,CAExB;IAMD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAcnD;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAKxD;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAWpC;;OAEG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAK1C;;OAEG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;CAI7C;AAGD,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- export class HubBase{constructor(){Object.defineProperty(this,"localTopicToBackendTopicMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"backendTopicToLocalMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"localFNameToBackendFNameMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"backendFNameToLocalFNameMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isConnected_",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"setIsConnected",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.isConnected_=e}}),Object.defineProperty(this,"isConnected",{enumerable:!0,configurable:!0,writable:!0,value:()=>this.isConnected_})}setContext(e){this.context=e}invokeTopic(e,a,o,c){const t={topic:o,data:c};return this.invoke(e,a,t)}publish(e,a){const o=this.toLocalTopic(e);this.context?.dispatch({topic:o,payload:a})}mapTopic(e,a){this.localTopicToBackendTopicMap.set(e,a),this.backendTopicToLocalMap.set(a,e)}unmapTopic(e){if(this.localTopicToBackendTopicMap.has(e)){const a=this.localTopicToBackendTopicMap.get(e);this.localTopicToBackendTopicMap.delete(e),null!=a&&this.backendTopicToLocalMap.has(a)&&this.backendTopicToLocalMap.delete(a)}}mapFName(e,a){this.localFNameToBackendFNameMap.set(e,a),this.backendFNameToLocalFNameMap.set(a,e)}unmapFName(e){if(this.localFNameToBackendFNameMap.has(e)){const a=this.localFNameToBackendFNameMap.get(e);this.localFNameToBackendFNameMap.delete(e),null!=a&&this.backendFNameToLocalFNameMap.has(a)&&this.backendFNameToLocalFNameMap.delete(a)}}toBackendTopic(e){if(this.localTopicToBackendTopicMap.has(e)){const a=this.localTopicToBackendTopicMap.get(e);return null!=a?a:e}return e}toBackendFName(e){if(this.localFNameToBackendFNameMap.has(e)){const a=this.localFNameToBackendFNameMap.get(e);return null!=a?a:e}return e}toLocalTopic(e){if(this.backendTopicToLocalMap.has(e)){const a=this.backendTopicToLocalMap.get(e);return null!=a?a:e}return e}toLocalFName(e){if(this.backendFNameToLocalFNameMap.has(e)){const a=this.backendFNameToLocalFNameMap.get(e);return null!=a?a:e}return e}}export default HubBase;
1
+ import{MessageType}from"./CommandMessage";export class HubBase{constructor(){Object.defineProperty(this,"localTopicToBackendTopicMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"backendTopicToLocalMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isConnected_",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"setIsConnected",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.isConnected_=e}}),Object.defineProperty(this,"isConnected",{enumerable:!0,configurable:!0,writable:!0,value:()=>this.isConnected_})}setContext(e){this.context=e}read(e,t){return this.invoke(e,MessageType.Read,t)}write(e,t){return this.invoke(e,MessageType.Write,{value:t})}subscribe(e,t,i){return this.mapTopic(e,t),this.invoke(t,MessageType.Subscribe,i)}unsubscribe(e,t){const i=this.toBackendTopic(e);return this.unmapTopic(e),this.invoke(i,MessageType.Unsubscribe,t)}request(e,t){return this.invoke(e,MessageType.Request,t)}publish(e,t){const i=this.toLocalTopic(e);this.context?.dispatch({topic:i,payload:t})}mapTopic(e,t){this.localTopicToBackendTopicMap.set(e,t),this.backendTopicToLocalMap.set(t,e)}unmapTopic(e){if(this.localTopicToBackendTopicMap.has(e)){const t=this.localTopicToBackendTopicMap.get(e);this.localTopicToBackendTopicMap.delete(e),null!=t&&this.backendTopicToLocalMap.has(t)&&this.backendTopicToLocalMap.delete(t)}}toBackendTopic(e){return this.localTopicToBackendTopicMap.get(e)??e}toLocalTopic(e){return this.backendTopicToLocalMap.get(e)??e}}export default HubBase;
@@ -1,22 +1,55 @@
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
- * Hub for simulating functionality when no backend is present.
5
+ * Hub for simulating backend functionality when no actual backend is present.
6
+ *
7
+ * Useful for development, testing, and demos without a running autocore-server.
8
+ * The simulator echoes back requests as successful responses after a configurable delay.
9
+ *
10
+ * ## Usage Examples
11
+ *
12
+ * ```typescript
13
+ * const { hub } = useContext(EventEmitterContext);
14
+ *
15
+ * // Read returns the topic as the "value"
16
+ * const result = await hub.read("ads.plc1.gio.bControlPowerOk");
17
+ * console.log(result.data); // { value: "ads.plc1.gio.bControlPowerOk" }
18
+ *
19
+ * // Write echoes back the written value
20
+ * await hub.write("ads.plc1.gio.nSetpoint", 100);
21
+ * ```
5
22
  */
6
23
  export declare class HubSimulate extends HubBase {
24
+ private responseDelay;
7
25
  /**
8
26
  * Constructor
27
+ * @param responseDelay Simulated response delay in milliseconds (default: 20ms)
9
28
  */
10
- constructor();
29
+ constructor(responseDelay?: number);
11
30
  /**
12
- * Invoke a method in the Socket.IO backend and wait for acknowledgment.
31
+ * Simulate sending a message to a backend.
13
32
  *
14
- * @param fname method name
33
+ * For Read operations, returns the topic as the value.
34
+ * For Write operations, echoes back the payload.
35
+ * For all operations, returns a successful response after the configured delay.
36
+ *
37
+ * @param topic The FQDN of the resource
38
+ * @param messageType The action to perform
15
39
  * @param payload Optional data payload
16
- * @param timeout Timeout in milliseconds after which the promise is rejected if no response is received.
17
- * @returns A Promise that resolves to the response from the backend or rejects if a timeout occurs.
40
+ * @returns Promise<CommandMessage> A simulated successful response
41
+ */
42
+ invoke(topic: string, messageType: MessageType, payload?: object): Promise<CommandMessage>;
43
+ /**
44
+ * Simulate a broadcast from the "backend".
45
+ *
46
+ * This is useful for testing subscription handlers.
47
+ *
48
+ * @param topic The topic to broadcast on
49
+ * @param data The data to broadcast
50
+ * @param delay Optional delay before broadcasting (default: 0ms)
18
51
  */
19
- invoke(domain: string, fname: string, payload?: object, timeout?: number): Promise<CommandMessageResult>;
52
+ simulateBroadcast(topic: string, data: any, delay?: number): void;
20
53
  }
21
54
  export default HubSimulate;
22
55
  //# sourceMappingURL=HubSimulate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HubSimulate.d.ts","sourceRoot":"","sources":["../../src/hub/HubSimulate.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D;;GAEG;AACH,qBAAa,WAAY,SAAQ,OAAO;IAEpC;;OAEG;;IAKH;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAmB/G;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"HubSimulate.d.ts","sourceRoot":"","sources":["../../src/hub/HubSimulate.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,WAAY,SAAQ,OAAO;IAEpC,OAAO,CAAC,aAAa,CAAS;IAE9B;;;OAGG;gBACS,aAAa,GAAE,MAAW;IAMtC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAgD1F;;;;;;;;OAQG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,GAAE,MAAU,GAAG,IAAI;CAKvE;AAED,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- import{HubBase}from"./HubBase";export class HubSimulate extends HubBase{constructor(){super()}invoke(e,s,r,t=20){return new Promise((e,s)=>{setTimeout(()=>{e({data:r,error_message:"",success:!0})},t)})}}export default HubSimulate;
1
+ import{HubBase}from"./HubBase";import{MessageType}from"./CommandMessage";export class HubSimulate extends HubBase{constructor(e=20){super(),Object.defineProperty(this,"responseDelay",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.responseDelay=e,this.setIsConnected(!0)}invoke(e,s,a){return new Promise(t=>{setTimeout(()=>{let r;switch(s){case MessageType.Read:r={value:e,simulated:!0};break;case MessageType.Write:r={written:!0,...a};break;case MessageType.Subscribe:r={subscribed:!0,topic:e};break;case MessageType.Unsubscribe:r={unsubscribed:!0,topic:e};break;default:r=a??{}}const i={transaction_id:0,timecode:Date.now(),topic:e,message_type:MessageType.Response,data:r,success:!0,error_message:""};t(i)},this.responseDelay)})}simulateBroadcast(e,s,a=0){setTimeout(()=>{this.publish(e,s)},a)}}export default HubSimulate;