@adcops/autocore-react 3.0.40 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/additional-docs/AutoCoreTagContext.md +441 -0
- package/additional-docs/react_performance_notes.md +94 -0
- package/dist/assets/BlocklyLogo.d.ts +1 -0
- package/dist/assets/BlocklyLogo.d.ts.map +1 -0
- package/dist/assets/Distance.d.ts +1 -0
- package/dist/assets/Distance.d.ts.map +1 -0
- package/dist/assets/JogLong.d.ts +1 -0
- package/dist/assets/JogLong.d.ts.map +1 -0
- package/dist/assets/JogMedium.d.ts +1 -0
- package/dist/assets/JogMedium.d.ts.map +1 -0
- package/dist/assets/JogShort.d.ts +1 -0
- package/dist/assets/JogShort.d.ts.map +1 -0
- package/dist/assets/PythonLogo.d.ts +1 -0
- package/dist/assets/PythonLogo.d.ts.map +1 -0
- package/dist/assets/Rotation3D.d.ts +1 -0
- package/dist/assets/Rotation3D.d.ts.map +1 -0
- package/dist/assets/RotationCcw.d.ts +1 -0
- package/dist/assets/RotationCcw.d.ts.map +1 -0
- package/dist/assets/RotationCcwA.d.ts +1 -0
- package/dist/assets/RotationCcwA.d.ts.map +1 -0
- package/dist/assets/RotationCcwB.d.ts +1 -0
- package/dist/assets/RotationCcwB.d.ts.map +1 -0
- package/dist/assets/RotationCcwC.d.ts +1 -0
- package/dist/assets/RotationCcwC.d.ts.map +1 -0
- package/dist/assets/RotationCw.d.ts +1 -0
- package/dist/assets/RotationCw.d.ts.map +1 -0
- package/dist/assets/RotationCwA.d.ts +1 -0
- package/dist/assets/RotationCwA.d.ts.map +1 -0
- package/dist/assets/RotationCwB.d.ts +1 -0
- package/dist/assets/RotationCwB.d.ts.map +1 -0
- package/dist/assets/RotationCwC.d.ts +1 -0
- package/dist/assets/RotationCwC.d.ts.map +1 -0
- package/dist/assets/Run.d.ts +1 -0
- package/dist/assets/Run.d.ts.map +1 -0
- package/dist/assets/Speed.d.ts +1 -0
- package/dist/assets/Speed.d.ts.map +1 -0
- package/dist/assets/SpeedFast.d.ts +1 -0
- package/dist/assets/SpeedFast.d.ts.map +1 -0
- package/dist/assets/SpeedMedium.d.ts +1 -0
- package/dist/assets/SpeedMedium.d.ts.map +1 -0
- package/dist/assets/SpeedNone.d.ts +1 -0
- package/dist/assets/SpeedNone.d.ts.map +1 -0
- package/dist/assets/SpeedSlow.d.ts +1 -0
- package/dist/assets/SpeedSlow.d.ts.map +1 -0
- package/dist/assets/Walk.d.ts +1 -0
- package/dist/assets/Walk.d.ts.map +1 -0
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/components/AutoCoreDevPanel.d.ts +144 -0
- package/dist/components/AutoCoreDevPanel.d.ts.map +1 -0
- package/dist/components/AutoCoreDevPanel.js +1 -0
- package/dist/components/BlocklyEditor.d.ts +1 -0
- package/dist/components/BlocklyEditor.d.ts.map +1 -0
- package/dist/components/BlocklyEditor.js +1 -1
- package/dist/components/CodeEditor.d.ts +2 -1
- package/dist/components/CodeEditor.d.ts.map +1 -0
- package/dist/components/CodeEditor.js +1 -1
- package/dist/components/FileList.d.ts +1 -0
- package/dist/components/FileList.d.ts.map +1 -0
- package/dist/components/FileList.js +1 -1
- package/dist/components/FileSelect.d.ts +1 -0
- package/dist/components/FileSelect.d.ts.map +1 -0
- package/dist/components/FileSelect.js +1 -1
- package/dist/components/FitText.d.ts +1 -0
- package/dist/components/FitText.d.ts.map +1 -0
- package/dist/components/FitText.js +1 -1
- package/dist/components/Indicator.d.ts +2 -1
- package/dist/components/Indicator.d.ts.map +1 -0
- package/dist/components/Indicator.js +1 -1
- package/dist/components/IndicatorButton.d.ts +2 -1
- package/dist/components/IndicatorButton.d.ts.map +1 -0
- package/dist/components/IndicatorButton.js +1 -1
- package/dist/components/IndicatorRect.d.ts +2 -1
- package/dist/components/IndicatorRect.d.ts.map +1 -0
- package/dist/components/JogPanel.d.ts +1 -0
- package/dist/components/JogPanel.d.ts.map +1 -0
- package/dist/components/Lamp.d.ts +2 -1
- package/dist/components/Lamp.d.ts.map +1 -0
- package/dist/components/Lamp.js +1 -1
- package/dist/components/Osk.d.ts +1 -0
- package/dist/components/Osk.d.ts.map +1 -0
- package/dist/components/Osk.js +1 -1
- package/dist/components/OskDialog.d.ts +1 -0
- package/dist/components/OskDialog.d.ts.map +1 -0
- package/dist/components/ProgressBarWithValue.d.ts +1 -0
- package/dist/components/ProgressBarWithValue.d.ts.map +1 -0
- package/dist/components/ProgressBarWithValue.js +1 -1
- package/dist/components/TextInput.d.ts +62 -103
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +1 -1
- package/dist/components/ToggleGroup.d.ts +2 -1
- package/dist/components/ToggleGroup.d.ts.map +1 -0
- package/dist/components/ToggleGroup.js +1 -1
- package/dist/components/ValueDisplay.d.ts +3 -2
- package/dist/components/ValueDisplay.d.ts.map +1 -0
- package/dist/components/ValueDisplay.js +1 -1
- package/dist/components/ValueIndicator.d.ts +2 -1
- package/dist/components/ValueIndicator.d.ts.map +1 -0
- package/dist/components/ValueIndicator.js +1 -1
- package/dist/components/ValueInput.d.ts +2 -1
- package/dist/components/ValueInput.d.ts.map +1 -0
- package/dist/components/ValueInput.js +1 -1
- package/dist/core/ActionMode.d.ts +1 -0
- package/dist/core/ActionMode.d.ts.map +1 -0
- package/dist/core/AutoCoreTagContext.d.ts +98 -0
- package/dist/core/AutoCoreTagContext.d.ts.map +1 -0
- package/dist/core/AutoCoreTagContext.js +1 -0
- package/dist/core/AutoCoreTagTypes.d.ts +283 -0
- package/dist/core/AutoCoreTagTypes.d.ts.map +1 -0
- package/dist/core/AutoCoreTagTypes.js +1 -0
- package/dist/core/CoreStreamTypes.d.ts +345 -0
- package/dist/core/CoreStreamTypes.d.ts.map +1 -0
- package/dist/core/CoreStreamTypes.js +1 -0
- package/dist/core/EventEmitterContext.d.ts +113 -202
- package/dist/core/EventEmitterContext.d.ts.map +1 -0
- package/dist/core/EventEmitterContext.js +1 -1
- package/dist/core/IndicatorButtonState.d.ts +1 -0
- package/dist/core/IndicatorButtonState.d.ts.map +1 -0
- package/dist/core/IndicatorColor.d.ts +1 -0
- package/dist/core/IndicatorColor.d.ts.map +1 -0
- package/dist/core/MaskPatterns.d.ts +1 -0
- package/dist/core/MaskPatterns.d.ts.map +1 -0
- package/dist/core/NumerableTypes.d.ts +1 -0
- package/dist/core/NumerableTypes.d.ts.map +1 -0
- package/dist/core/NumerableTypes.js +1 -1
- package/dist/core/PositionContext.d.ts +1 -1
- package/dist/core/PositionContext.d.ts.map +1 -0
- package/dist/core/UniqueId.d.ts +1 -0
- package/dist/core/UniqueId.d.ts.map +1 -0
- package/dist/core/ValueSimulator.d.ts +2 -1
- package/dist/core/ValueSimulator.d.ts.map +1 -0
- package/dist/core/ValueSimulator.js +1 -1
- package/dist/core/hoc.d.ts +1 -0
- package/dist/core/hoc.d.ts.map +1 -0
- package/dist/core/hoc.js +1 -1
- package/dist/hooks/adsHooks.d.ts +1 -0
- package/dist/hooks/adsHooks.d.ts.map +1 -0
- package/dist/hooks/adsHooks.js +1 -1
- package/dist/hooks/commandHooks.d.ts +4 -3
- package/dist/hooks/commandHooks.d.ts.map +1 -0
- package/dist/hooks/commandHooks.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAutoCoreTag.d.ts +26 -0
- package/dist/hooks/useAutoCoreTag.d.ts.map +1 -0
- package/dist/hooks/useAutoCoreTag.js +1 -0
- package/dist/hooks/useScaledValue.d.ts +1 -0
- package/dist/hooks/useScaledValue.d.ts.map +1 -0
- package/dist/hooks/useScaledValue.js +1 -1
- package/dist/hub/CommandMessage.d.ts +19 -9
- package/dist/hub/CommandMessage.d.ts.map +1 -0
- package/dist/hub/CommandMessage.js +1 -1
- package/dist/hub/DebugPanel.d.ts +31 -0
- package/dist/hub/DebugPanel.d.ts.map +1 -0
- package/dist/hub/DebugPanel.js +1 -0
- package/dist/hub/HubBase.d.ts +85 -130
- package/dist/hub/HubBase.d.ts.map +1 -0
- package/dist/hub/HubBase.js +1 -1
- package/dist/hub/HubSimulate.d.ts +42 -8
- package/dist/hub/HubSimulate.d.ts.map +1 -0
- package/dist/hub/HubSimulate.js +1 -1
- package/dist/hub/HubTauri.d.ts +25 -60
- package/dist/hub/HubTauri.d.ts.map +1 -0
- package/dist/hub/HubTauri.js +1 -1
- package/dist/hub/HubWebSocket.d.ts +34 -17
- package/dist/hub/HubWebSocket.d.ts.map +1 -0
- package/dist/hub/HubWebSocket.js +1 -1
- package/dist/hub/debug.d.ts +23 -0
- package/dist/hub/debug.d.ts.map +1 -0
- package/dist/hub/debug.js +1 -0
- package/dist/hub/index.d.ts +20 -4
- package/dist/hub/index.d.ts.map +1 -0
- package/dist/hub/index.js +1 -1
- package/package.json +32 -27
- package/readme.md +193 -22
- package/src/components/AutoCoreDevPanel.tsx +414 -0
- package/src/components/CodeEditor.tsx +2 -2
- package/src/components/FileList.tsx +7 -6
- package/src/components/FileSelect.tsx +2 -1
- package/src/components/Indicator.tsx +2 -2
- package/src/components/IndicatorButton.tsx +2 -2
- package/src/components/IndicatorRect.tsx +2 -2
- package/src/components/Lamp.tsx +3 -3
- package/src/components/TextInput.tsx +159 -240
- package/src/components/ToggleGroup.tsx +3 -3
- package/src/components/ValueDisplay.tsx +4 -4
- package/src/components/ValueIndicator.tsx +2 -2
- package/src/components/ValueInput.tsx +2 -2
- package/src/core/ActionMode.ts +1 -1
- package/src/core/AutoCoreTagContext.tsx +615 -0
- package/src/core/AutoCoreTagTypes.ts +334 -0
- package/src/core/CoreStreamTypes.ts +512 -0
- package/src/core/EventEmitterContext.tsx +257 -281
- package/src/core/IndicatorButtonState.ts +1 -1
- package/src/core/ValueSimulator.ts +2 -2
- package/src/core/hoc.tsx +1 -1
- package/src/hooks/adsHooks.tsx +21 -22
- package/src/hooks/commandHooks.tsx +23 -19
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useAutoCoreTag.ts +103 -0
- package/src/hooks/useScaledValue.tsx +1 -1
- package/src/hub/CommandMessage.ts +71 -19
- package/src/hub/DebugPanel.ts +280 -0
- package/src/hub/HubBase.ts +147 -223
- package/src/hub/HubSimulate.ts +93 -24
- package/src/hub/HubTauri.ts +87 -96
- package/src/hub/HubWebSocket.ts +133 -158
- package/src/hub/debug.ts +211 -0
- package/src/hub/index.ts +49 -39
- package/tsconfig.json +43 -28
- package/docs/classes/components_BlocklyEditor.BlocklyEditor.html +0 -124
- package/docs/classes/components_CodeEditor.CodeEditor.html +0 -128
- package/docs/classes/components_JogPanel.JogPanel.html +0 -138
- package/docs/classes/components_Lamp.Lamp.html +0 -105
- package/docs/classes/components_TextInput.TextInput.html +0 -115
- package/docs/classes/components_ValueIndicator.ValueIndicator.html +0 -119
- package/docs/classes/components_ValueInput.ValueInput.html +0 -113
- package/docs/classes/hub_HubWebSocket.HubWebSocket.html +0 -106
- package/docs/enums/components_JogPanel.JogDistanceAction.html +0 -5
- package/docs/enums/components_JogPanel.JogPanelAction.html +0 -18
- package/docs/enums/components_JogPanel.JogSpeedAction.html +0 -5
- package/docs/enums/core_ActionMode.ActionMode.html +0 -6
- package/docs/enums/core_IndicatorColor.IndicatorColor.html +0 -23
- package/docs/functions/assets_BlocklyLogo.default.html +0 -1
- package/docs/functions/assets_Distance.default.html +0 -1
- package/docs/functions/assets_JogLong.default.html +0 -1
- package/docs/functions/assets_JogMedium.default.html +0 -1
- package/docs/functions/assets_JogShort.default.html +0 -1
- package/docs/functions/assets_PythonLogo.default.html +0 -1
- package/docs/functions/assets_Rotation3D.default.html +0 -1
- package/docs/functions/assets_RotationCcw.default.html +0 -1
- package/docs/functions/assets_RotationCcwA.default.html +0 -1
- package/docs/functions/assets_RotationCcwB.default.html +0 -1
- package/docs/functions/assets_RotationCcwC.default.html +0 -1
- package/docs/functions/assets_RotationCw.default.html +0 -1
- package/docs/functions/assets_RotationCwA.default.html +0 -1
- package/docs/functions/assets_RotationCwB.default.html +0 -1
- package/docs/functions/assets_RotationCwC.default.html +0 -1
- package/docs/functions/assets_Run.default.html +0 -1
- package/docs/functions/assets_Speed.default.html +0 -1
- package/docs/functions/assets_SpeedFast.default.html +0 -1
- package/docs/functions/assets_SpeedMedium.default.html +0 -1
- package/docs/functions/assets_SpeedNone.default.html +0 -1
- package/docs/functions/assets_SpeedSlow.default.html +0 -1
- package/docs/functions/assets_Walk.default.html +0 -1
- package/docs/functions/components_BlocklyEditor.createCustomToolbox.html +0 -6
- package/docs/functions/components_FileList.FileList.html +0 -21
- package/docs/functions/components_FitText.FitText.html +0 -8
- package/docs/functions/components_ToggleGroup.ToggleGroup.html +0 -5
- package/docs/interfaces/components_JogPanel.JogPanelButtonDefinition.html +0 -5
- package/docs/interfaces/components_ToggleGroup.ToggleGroupProps.html +0 -618
- package/docs/interfaces/core_IndicatorButtonState.IndicatorButtonState.html +0 -10
- package/docs/interfaces/hub_CommandMessage.CommandMessage.html +0 -6
- package/docs/interfaces/hub_CommandMessage.CommandMessageResult.html +0 -4
- package/docs/modules/assets.html +0 -23
- package/docs/modules/assets_BlocklyLogo.html +0 -2
- package/docs/modules/assets_Distance.html +0 -2
- package/docs/modules/assets_JogLong.html +0 -2
- package/docs/modules/assets_JogMedium.html +0 -2
- package/docs/modules/assets_JogShort.html +0 -2
- package/docs/modules/assets_PythonLogo.html +0 -2
- package/docs/modules/assets_Rotation3D.html +0 -2
- package/docs/modules/assets_RotationCcw.html +0 -2
- package/docs/modules/assets_RotationCcwA.html +0 -2
- package/docs/modules/assets_RotationCcwB.html +0 -2
- package/docs/modules/assets_RotationCcwC.html +0 -2
- package/docs/modules/assets_RotationCw.html +0 -2
- package/docs/modules/assets_RotationCwA.html +0 -2
- package/docs/modules/assets_RotationCwB.html +0 -2
- package/docs/modules/assets_RotationCwC.html +0 -2
- package/docs/modules/assets_Run.html +0 -2
- package/docs/modules/assets_Speed.html +0 -2
- package/docs/modules/assets_SpeedFast.html +0 -2
- package/docs/modules/assets_SpeedMedium.html +0 -2
- package/docs/modules/assets_SpeedNone.html +0 -2
- package/docs/modules/assets_SpeedSlow.html +0 -2
- package/docs/modules/assets_Walk.html +0 -2
- package/docs/modules/components_BlocklyEditor.html +0 -5
- package/docs/modules/components_CodeEditor.html +0 -3
- package/docs/modules/components_FileList.html +0 -3
- package/docs/modules/components_FitText.html +0 -3
- package/docs/modules/components_JogPanel.html +0 -9
- package/docs/modules/components_Lamp.html +0 -4
- package/docs/modules/components_TextInput.html +0 -2
- package/docs/modules/components_ToggleGroup.html +0 -6
- package/docs/modules/components_ValueIndicator.html +0 -4
- package/docs/modules/components_ValueInput.html +0 -2
- package/docs/modules/core_ActionMode.html +0 -2
- package/docs/modules/core_IndicatorButtonState.html +0 -2
- package/docs/modules/core_IndicatorColor.html +0 -2
- package/docs/modules/hub_CommandMessage.html +0 -3
- package/docs/modules/hub_HubWebSocket.html +0 -2
- package/docs/types/components_IndicatorButton.IndicatorButtonOptionsType.html +0 -1
- package/docs/variables/components_BlocklyEditor.StandardToolbox.html +0 -1
- package/docs/variables/components_JogPanel.DefaultLinearJogButtons.html +0 -2
- package/docs/variables/components_JogPanel.DefaultRotationJogButtons.html +0 -2
|
@@ -1,235 +1,170 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview EventEmitterContext - Global Event Bus for AutoCore React Applications
|
|
3
|
+
*
|
|
4
|
+
* The EventEmitterContext provides a comprehensive event-driven communication system for React applications,
|
|
5
|
+
* enabling seamless interaction between components and backend services. It serves as the foundational layer
|
|
6
|
+
* for AutoCore's real-time data flow and component communication architecture.
|
|
7
|
+
*
|
|
8
|
+
* ## Core Features
|
|
9
|
+
*
|
|
10
|
+
* - **Global Event Bus**: Publish and subscribe to events across all components.
|
|
11
|
+
* - **Backend Integration**: Direct communication with AutoCore server via Hub abstraction.
|
|
12
|
+
* - **Type-Safe Subscriptions**: Strongly-typed event handling with automatic cleanup.
|
|
13
|
+
* - **Performance Optimized**: Uses stable context values and direct callbacks to avoid global re-renders.
|
|
14
|
+
* - **Connection Management**: Automatic reconnection and state synchronization.
|
|
15
|
+
*
|
|
16
|
+
* ## Architecture
|
|
17
|
+
*
|
|
18
|
+
* The system consists of three main components:
|
|
19
|
+
* 1. **EventEmitterProvider**: React context provider that manages global state and event routing.
|
|
20
|
+
* 2. **Hub**: Abstraction layer for backend communication (WebSocket, HTTP, etc.).
|
|
21
|
+
* 3. **Subscription Manager**: Handles event routing and lifecycle management.
|
|
22
|
+
*
|
|
23
|
+
* ## Performance Notes
|
|
24
|
+
*
|
|
25
|
+
* To ensure high performance with high-frequency data (e.g., 50Hz sensor updates):
|
|
26
|
+
* 1. **No State Updates on Dispatch**: The `dispatch` function does NOT update React state. It calls listeners directly.
|
|
27
|
+
* This prevents the entire component tree from re-rendering on every message.
|
|
28
|
+
* 2. **Stable Context Value**: The `contextValue` object is memoized and rarely changes.
|
|
29
|
+
* 3. **Direct Subscriptions**: Components subscribe via `useEffect` and receive updates via callbacks, not props.
|
|
30
|
+
*
|
|
31
|
+
* @module core/EventEmitterContext
|
|
32
|
+
* @version 3.0.42
|
|
33
|
+
* @author Automated Design Corp.
|
|
34
|
+
*/
|
|
35
|
+
import React from "react";
|
|
36
|
+
import type { ReactNode } from "react";
|
|
2
37
|
import { Hub } from "../hub";
|
|
3
|
-
import {
|
|
38
|
+
import type { CommandMessage } from "../hub";
|
|
39
|
+
import { MessageType } from "../hub/CommandMessage";
|
|
4
40
|
export { Hub };
|
|
5
41
|
/**
|
|
6
|
-
* Represents an event
|
|
42
|
+
* Represents an active event subscription.
|
|
7
43
|
*/
|
|
8
44
|
export interface Subscription {
|
|
9
|
-
/** ID of the subscription used for unsubscription. */
|
|
45
|
+
/** Unique ID of the subscription used for unsubscription. */
|
|
10
46
|
id: number;
|
|
11
|
-
/** Callback function. */
|
|
47
|
+
/** Callback function to execute when the event fires. */
|
|
12
48
|
callback: React.Dispatch<any>;
|
|
13
49
|
}
|
|
14
50
|
/**
|
|
15
|
-
* Represents the
|
|
51
|
+
* Represents the internal state of the EventEmitter.
|
|
52
|
+
* Mostly used for debugging and dev tools inspection.
|
|
16
53
|
*/
|
|
17
54
|
export interface State {
|
|
18
55
|
/**
|
|
19
|
-
* The optional data payload of the event.
|
|
56
|
+
* The optional data payload of the last event (DEBUGGING ONLY).
|
|
57
|
+
* Note: This is no longer updated in production for performance reasons.
|
|
20
58
|
*/
|
|
21
59
|
eventData?: any;
|
|
22
|
-
/**
|
|
60
|
+
/** Active subscriptions grouped by topic. */
|
|
23
61
|
subscriptions: Record<string, Subscription[]>;
|
|
24
62
|
/** Tracks the next subscription ID that will be assigned. */
|
|
25
63
|
nextSubscriptionId: number;
|
|
26
64
|
}
|
|
27
65
|
/**
|
|
28
|
-
* An action event published by the EventEmitterContext.
|
|
29
|
-
* the topic identifying the event and the optional payload, which is
|
|
30
|
-
* a value of any type.
|
|
66
|
+
* An action event published by the EventEmitterContext.
|
|
31
67
|
*/
|
|
32
68
|
export interface Action {
|
|
33
|
-
/**
|
|
34
|
-
* The topic or identifier of the event.
|
|
35
|
-
*/
|
|
69
|
+
/** The topic or identifier of the event. */
|
|
36
70
|
topic: string;
|
|
37
|
-
/**
|
|
38
|
-
* The optional data payload associated with the event.
|
|
39
|
-
*/
|
|
71
|
+
/** The optional data payload associated with the event. */
|
|
40
72
|
payload?: any;
|
|
41
73
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Type declaration for the EventEmitter dispatch function, which
|
|
44
|
-
* publishes an Action globally throughout the EventEmitterContext.
|
|
45
|
-
*/
|
|
46
74
|
export type EmitterDispatchFunction = (action: Action) => void;
|
|
47
75
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
export type EmitterSubscribeFunction = (action: Action) => void;
|
|
52
|
-
/**
|
|
53
|
-
* Type declaration for the EventEmitter unsubscribe function, which
|
|
54
|
-
* receives an Action on a specific topic broadcast through the EventEmitterContext.
|
|
55
|
-
*/
|
|
56
|
-
export type EmitterUnsubscribeFunction = (action: Action) => void;
|
|
57
|
-
/**
|
|
58
|
-
* Defines the context for an event emitter used throughout a front-end application to manage and dispatch events.
|
|
59
|
-
* This interface includes methods for managing the application's state, handling global actions, communicating with the back end,
|
|
60
|
-
* subscribing to and unsubscribing from events, and accessing a global hub for event publishing and subscription management.
|
|
61
|
-
* It serves as a central point for event-driven interactions within the application, facilitating communication between
|
|
62
|
-
* components and the back end, as well as among components themselves.
|
|
76
|
+
* Defines the context for the global event emitter.
|
|
77
|
+
* Provides methods for dispatching events, subscribing to topics, and communicating with the backend.
|
|
63
78
|
*/
|
|
64
79
|
export interface EventEmitterContextType {
|
|
65
80
|
/**
|
|
66
|
-
* The current state of the event emitter
|
|
81
|
+
* The current state of the event emitter (mostly for debugging).
|
|
67
82
|
*/
|
|
68
83
|
state: State;
|
|
69
84
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
85
|
+
* Dispatch an action globally throughout the front-end.
|
|
86
|
+
* Triggers callbacks for all subscribers of the topic.
|
|
87
|
+
*
|
|
88
|
+
* @param action The action to dispatch.
|
|
89
|
+
*/
|
|
90
|
+
dispatch: EmitterDispatchFunction;
|
|
91
|
+
/**
|
|
92
|
+
* Send a message to the backend (Low-level).
|
|
93
|
+
*
|
|
94
|
+
* @param topic The FQDN of the resource (e.g., "ads.plc1.gio.bControlPowerOk")
|
|
95
|
+
* @param messageType The action to perform (Read, Write, Subscribe, etc.)
|
|
96
|
+
* @param payload Optional data payload
|
|
97
|
+
* @returns Promise resolving to the CommandMessage response
|
|
98
|
+
*/
|
|
99
|
+
invoke(topic: string, messageType: MessageType, payload?: object): Promise<CommandMessage>;
|
|
100
|
+
/**
|
|
101
|
+
* Read a value from the backend.
|
|
102
|
+
*
|
|
103
|
+
* @param topic The FQDN of the resource to read
|
|
104
|
+
* @param payload Optional additional parameters
|
|
105
|
+
* @returns Promise resolving to the CommandMessage response with the value in `data`
|
|
106
|
+
*/
|
|
107
|
+
read(topic: string, payload?: object): Promise<CommandMessage>;
|
|
108
|
+
/**
|
|
109
|
+
* Write a value to the backend.
|
|
72
110
|
*
|
|
73
|
-
* @param
|
|
111
|
+
* @param topic The FQDN of the resource to write
|
|
112
|
+
* @param value The value to write
|
|
113
|
+
* @returns Promise resolving to the CommandMessage response
|
|
74
114
|
*/
|
|
75
|
-
|
|
115
|
+
write(topic: string, value: any): Promise<CommandMessage>;
|
|
76
116
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
117
|
+
* Subscribe to value changes on the backend.
|
|
118
|
+
*
|
|
119
|
+
* Tells the server to start broadcasting updates for a specific topic.
|
|
120
|
+
* Also registers a mapping between the local `tagName` and the remote `topic` (FQDN)
|
|
121
|
+
* in the Hub, so that incoming broadcasts are routed correctly.
|
|
122
|
+
*
|
|
123
|
+
* @param tagName The local tag name to map the topic to
|
|
124
|
+
* @param topic The FQDN of the resource to watch
|
|
125
|
+
* @param payload Optional subscription parameters (e.g., update rate)
|
|
126
|
+
* @returns Promise resolving to the CommandMessage response
|
|
79
127
|
*/
|
|
80
|
-
|
|
128
|
+
serverSubscribe(tagName: string, topic: string, payload?: object): Promise<CommandMessage>;
|
|
81
129
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
130
|
+
* Unsubscribe from value changes on the backend.
|
|
131
|
+
*
|
|
132
|
+
* @param tagName The local tag name to stop watching
|
|
133
|
+
* @param payload Optional parameters
|
|
134
|
+
* @returns Promise resolving to the CommandMessage response
|
|
135
|
+
*/
|
|
136
|
+
serverUnsubscribe(tagName: string, payload?: object): Promise<CommandMessage>;
|
|
137
|
+
/**
|
|
138
|
+
* Subscribe to **local** frontend events.
|
|
139
|
+
*
|
|
140
|
+
* This registers a callback to listen for events dispatched on the local event bus.
|
|
141
|
+
* This includes both locally dispatched events AND broadcast messages received
|
|
142
|
+
* from the server (which the Hub dispatches to the local bus).
|
|
143
|
+
*
|
|
144
|
+
* @param topic The subscription topic (or tagName).
|
|
84
145
|
* @param callback The callback to signal.
|
|
85
146
|
* @returns number Subscription ID used to unsubscribe later.
|
|
86
147
|
*/
|
|
87
148
|
subscribe: (topic: string, callback: React.Dispatch<any>) => number;
|
|
88
149
|
/**
|
|
89
|
-
* Unsubscribe
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
150
|
+
* Unsubscribe from **local** frontend events.
|
|
151
|
+
*
|
|
152
|
+
* @param subscriptionId The id returned by the subscribe method.
|
|
92
153
|
*/
|
|
93
154
|
unsubscribe: (subscriptionId: number) => void;
|
|
94
155
|
/**
|
|
95
|
-
* Global hub for
|
|
96
|
-
* data with the backend.
|
|
156
|
+
* Global hub instance for backend communication.
|
|
97
157
|
*/
|
|
98
158
|
hub: Hub | null;
|
|
99
159
|
/**
|
|
100
160
|
* Retrieves the current subscriptions. Used for debugging purposes.
|
|
101
|
-
* @param topic Optional. The topic to retrieve subscriptions for. If omitted, returns all subscriptions.
|
|
102
|
-
* @returns An object containing the current subscriptions, optionally filtered by topic.
|
|
103
161
|
*/
|
|
104
162
|
getSubscriptions: (topic?: string) => Record<string, Subscription[]> | Subscription[];
|
|
105
163
|
/**
|
|
106
|
-
* Returns true if the Hub
|
|
107
|
-
* @returns boolean
|
|
164
|
+
* Returns true if the Hub is connected to the backend.
|
|
108
165
|
*/
|
|
109
166
|
isConnected: () => boolean;
|
|
110
167
|
}
|
|
111
|
-
/**
|
|
112
|
-
* A global context for managing event emission and subscription.
|
|
113
|
-
*
|
|
114
|
-
* Creates a React context for the EventEmitter system, providing a structured way to manage events and data flow
|
|
115
|
-
* in a React application. It serves as a global event bus that components can subscribe to or emit events, allowing for
|
|
116
|
-
* a loosely coupled architecture. Additionally, it provides a mechanism for invoking backend functions and managing
|
|
117
|
-
* subscriptions, making it easier to integrate React components with backend services.
|
|
118
|
-
*
|
|
119
|
-
* The context includes several key functionalities:
|
|
120
|
-
* - `state`: Maintains the current state of subscriptions and their identifiers.
|
|
121
|
-
* - `dispatch`: Allows components to emit events with specific topics and payloads, which can be listened to by other components.
|
|
122
|
-
* - `subscribe`: Enables components to listen to specific topics and react to those events by providing a callback function.
|
|
123
|
-
* - `unsubscribe`: Provides a way for components to stop listening to events, helping prevent memory leaks and unnecessary updates.
|
|
124
|
-
* - `invoke`: Facilitates calling backend functions with specific arguments and handling their responses asynchronously.
|
|
125
|
-
* - `getSubscriptions`: Offers insight into current active subscriptions, useful for debugging purposes.
|
|
126
|
-
*
|
|
127
|
-
* This context is essential for applications that require a high degree of inter-component communication or need to
|
|
128
|
-
* interact with a backend efficiently.
|
|
129
|
-
*
|
|
130
|
-
* For more information, see [Additional Documentation](../additional-docs/GlobalEventEmitter.md).
|
|
131
|
-
*
|
|
132
|
-
* ## Usage
|
|
133
|
-
*
|
|
134
|
-
* The entire application should be wrapped in the EventEmitterProvider.
|
|
135
|
-
*
|
|
136
|
-
* App.tsx
|
|
137
|
-
* ```
|
|
138
|
-
* import { EventEmitterProvider } from "@adcops/autocore-react/core/EventEmitterContext.js";
|
|
139
|
-
* function App() {
|
|
140
|
-
*
|
|
141
|
-
* return(
|
|
142
|
-
* <EventEmitterProvider>
|
|
143
|
-
* <PrimeReactProvider>
|
|
144
|
-
* <main>
|
|
145
|
-
* <section>
|
|
146
|
-
* <ContentView />
|
|
147
|
-
* </section>
|
|
148
|
-
* </main>
|
|
149
|
-
* </PrimeReactProvider>
|
|
150
|
-
* </EventEmitterProvider>
|
|
151
|
-
* );
|
|
152
|
-
*
|
|
153
|
-
* }
|
|
154
|
-
*
|
|
155
|
-
* ```
|
|
156
|
-
*
|
|
157
|
-
* ### Catching and receiving events
|
|
158
|
-
* The EventEmitterContext creates an appropriate instance of the hub, which is derived from HubBase.
|
|
159
|
-
* That hub can be used to publish and subscribe to
|
|
160
|
-
* topics globally in the front-end, regardless of being connected to any backend.
|
|
161
|
-
* Usage within a component is simple.
|
|
162
|
-
*
|
|
163
|
-
* ```
|
|
164
|
-
* const {dispatch, subscribe, unsubscribe} = useContext(EventEmitterContext);
|
|
165
|
-
* const [controlPower, setControlPower] = useState(false);
|
|
166
|
-
* useEffect(() => {
|
|
167
|
-
* const unsubscribeControlPower = subscribe('value-simulator-bBit1', (value) => {
|
|
168
|
-
* setControlPower(value);
|
|
169
|
-
* });
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* return () => {
|
|
173
|
-
* unsubscribe(unsubscribeControlPower);
|
|
174
|
-
* }
|
|
175
|
-
* }, [] );
|
|
176
|
-
*
|
|
177
|
-
* const onPbPressed = () => {
|
|
178
|
-
* let count = 1;
|
|
179
|
-
* dispatch({
|
|
180
|
-
* topic: "my-awesome-topic",
|
|
181
|
-
* payload: count
|
|
182
|
-
* });
|
|
183
|
-
* }
|
|
184
|
-
*
|
|
185
|
-
* ```
|
|
186
|
-
* The hub should also be used for invoking events in the backend.
|
|
187
|
-
* This example will call the function "update_count" in the backend, passing
|
|
188
|
-
* the expected argument "count". Details of the interaction between the Hub and
|
|
189
|
-
* the backend will be handled by the appropriate HubBase sub-class, and should
|
|
190
|
-
* be transparent to the front end.
|
|
191
|
-
*
|
|
192
|
-
* ```
|
|
193
|
-
* const {invoke} = useContext(EventEmitterContext);
|
|
194
|
-
* const incrementCount = () => {
|
|
195
|
-
* count += 1;
|
|
196
|
-
* invoke('update_count', {"count": count});
|
|
197
|
-
* };
|
|
198
|
-
*
|
|
199
|
-
* Subscribing to a topic is simple. The type of value received is specific
|
|
200
|
-
* to the topic.
|
|
201
|
-
*
|
|
202
|
-
* Example: Listen to an event 'xarm-position':
|
|
203
|
-
* ```
|
|
204
|
-
* const {subscribe, unsubscribe} = useContext(EventEmitterContext);
|
|
205
|
-
* useEffect(() => {
|
|
206
|
-
* const unsubscripeMp = subscribe('xarm-position', (value) => {
|
|
207
|
-
* // The publisher sent a JSON object of 3D position values.
|
|
208
|
-
* setX(value.x);
|
|
209
|
-
* setY(value.y);
|
|
210
|
-
* setZ(value.z);
|
|
211
|
-
* setA(value.roll);
|
|
212
|
-
* setB(value.yaw);
|
|
213
|
-
* setC(value.pitch);
|
|
214
|
-
* });
|
|
215
|
-
*
|
|
216
|
-
* return () => {
|
|
217
|
-
* unsubscribe(unsubscripeMp);
|
|
218
|
-
* }
|
|
219
|
-
*
|
|
220
|
-
* }, [] );
|
|
221
|
-
*
|
|
222
|
-
* ```
|
|
223
|
-
*
|
|
224
|
-
* For applications that need to access the instance of the hub, get the current instance
|
|
225
|
-
* from the EventEmitterContext:
|
|
226
|
-
*
|
|
227
|
-
* ```
|
|
228
|
-
* const {hub} = useContext(EventEmitterContext);
|
|
229
|
-
* * ```
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*/
|
|
233
168
|
export declare const EventEmitterContext: React.Context<EventEmitterContextType>;
|
|
234
169
|
/**
|
|
235
170
|
* A React component that provides the EventEmitterContext to its children.
|
|
@@ -238,32 +173,8 @@ export declare const EventEmitterContext: React.Context<EventEmitterContextType>
|
|
|
238
173
|
* with the event emitter.
|
|
239
174
|
*
|
|
240
175
|
* @param children The child components to be wrapped in the context.
|
|
241
|
-
*
|
|
242
|
-
* ## Usage
|
|
243
|
-
*
|
|
244
|
-
* The entire application should be wrapped in the EventEmitterProvider.
|
|
245
|
-
*
|
|
246
|
-
* App.tsx
|
|
247
|
-
* ```
|
|
248
|
-
* import { EventEmitterProvider } from "@adcops/autocore-react/core/EventEmitterContext.js";
|
|
249
|
-
* function App() {
|
|
250
|
-
*
|
|
251
|
-
* return(
|
|
252
|
-
* <EventEmitterProvider>
|
|
253
|
-
* <PrimeReactProvider>
|
|
254
|
-
* <main>
|
|
255
|
-
* <section>
|
|
256
|
-
* <ContentView />
|
|
257
|
-
* </section>
|
|
258
|
-
* </main>
|
|
259
|
-
* </PrimeReactProvider>
|
|
260
|
-
* </EventEmitterProvider>
|
|
261
|
-
* );
|
|
262
|
-
*
|
|
263
|
-
* }
|
|
264
|
-
*
|
|
265
|
-
* ```
|
|
266
176
|
*/
|
|
267
177
|
export declare const EventEmitterProvider: React.FC<{
|
|
268
178
|
children: ReactNode;
|
|
269
179
|
}>;
|
|
180
|
+
//# sourceMappingURL=EventEmitterContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEmitterContext.d.ts","sourceRoot":"","sources":["../../src/core/EventEmitterContext.tsx"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAON,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAa,GAAG,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,CAAC;AAEf;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,yDAAyD;IACzD,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAE9C,6DAA6D;IAC7D,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;;;;OAKG;IACH,QAAQ,EAAE,uBAAuB,CAAC;IAElC;;;;;;;OAOG;IACH,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE/D;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE1D;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3F;;;;;;OAMG;IACH,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE9E;;;;;;;;;;OAUG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC;IAEpE;;;;OAIG;IACH,WAAW,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9C;;OAEG;IACH,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAEhB;;OAEG;IACH,gBAAgB,EAAE,CAChB,KAAK,CAAC,EAAE,MAAM,KACX,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,YAAY,EAAE,CAAC;IAErD;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC;CAC5B;AAaD,eAAO,MAAM,mBAAmB,wCAa9B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CAsLlE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{createContext,useState,useMemo,useCallback,useRef,useEffect}from"react";import{createHub,Hub}from"../hub";export{Hub};
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import React,{createContext,useState,useMemo,useCallback,useRef,useEffect}from"react";import{createHub,Hub}from"../hub";import{MessageType}from"../hub/CommandMessage";export{Hub};const placeholderResponse={data:{},success:!1,error_message:"Context not initialized",transaction_id:0,timecode:0,topic:"",message_type:MessageType.NoOp};export const EventEmitterContext=createContext({state:{subscriptions:{},nextSubscriptionId:1},dispatch:()=>{},subscribe:()=>0,unsubscribe:()=>{},invoke:async()=>placeholderResponse,read:async()=>placeholderResponse,write:async()=>placeholderResponse,serverSubscribe:async(e,t,s)=>placeholderResponse,serverUnsubscribe:async(e,t)=>placeholderResponse,hub:null,getSubscriptions:()=>[],isConnected:()=>!1});export const EventEmitterProvider=({children:e})=>{const[t,s]=useState({subscriptions:{},nextSubscriptionId:1}),r=useMemo(()=>createHub(),[]),c=useRef(1),n=useRef({});useEffect(()=>{s(e=>({...e,subscriptions:{...n.current},nextSubscriptionId:c.current}))},[]);const o=useCallback(e=>{const{topic:t,payload:s}=e,r=n.current[t]?.slice()??[];for(const e of r)try{e.callback(s)}catch(e){}},[]),u=useCallback((e,t)=>{const r=c.current++,o={id:r,callback:t},u=[...n.current[e]??[],o];return n.current={...n.current,[e]:u},s(e=>({...e,subscriptions:{...n.current},nextSubscriptionId:c.current})),r},[]),i=useCallback(e=>{const t={};for(const[s,r]of Object.entries(n.current)){const c=r.filter(t=>t.id!==e);c.length>0&&(t[s]=c)}n.current=t,s(e=>({...e,subscriptions:{...t}}))},[]);useEffect(()=>()=>{n.current={},c.current=1},[]),import.meta&&import.meta.hot&&import.meta.hot.dispose(()=>{n.current={},c.current=1});const a=useCallback((e,t,s)=>r.invoke(e,t,s),[r]),b=useCallback((e,t)=>r.read(e,t),[r]),l=useCallback((e,t)=>r.write(e,t),[r]),p=useCallback((e,t,s)=>r.subscribe(e,t,s),[r]),d=useCallback((e,t)=>r.unsubscribe(e,t),[r]),m=useCallback(()=>r.isConnected(),[r]),f=useMemo(()=>({state:t,dispatch:o,subscribe:u,unsubscribe:i,invoke:a,read:b,write:l,serverSubscribe:p,serverUnsubscribe:d,hub:r,getSubscriptions:e=>e?n.current[e]??[]:n.current,isConnected:m}),[t,r,o,u,i,a,b,l,p,d,m]);return useEffect(()=>{r.setContext(f)},[r,f]),_jsx(EventEmitterContext.Provider,{value:f,children:e})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndicatorButtonState.d.ts","sourceRoot":"","sources":["../../src/core/IndicatorButtonState.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAEzC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAG,OAAO,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndicatorColor.d.ts","sourceRoot":"","sources":["../../src/core/IndicatorColor.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,oBAAY,cAAc;IACtB,8CAA8C;IAC9C,cAAc,UAAU;IACxB,+EAA+E;IAC/E,WAAW,UAAiB;IAC5B,kCAAkC;IAClC,YAAY,SAAS;IACrB,uDAAuD;IACvD,YAAY,QAAQ;IACpB,8DAA8D;IAC9D,eAAe,WAAW;IAC1B,sDAAsD;IACtD,cAAc,QAAgB;IAC9B,yDAAyD;IACzD,gBAAgB,WAAkB;IAClC,wFAAwF;IACxF,gBAAgB,UAAU;IAC1B,4DAA4D;IAC5D,mBAAmB,SAAS;IAC5B,+DAA+D;IAC/D,aAAa,SAAS;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaskPatterns.d.ts","sourceRoot":"","sources":["../../src/core/MaskPatterns.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC1B;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAIH;;OAEG;;CAEG,CAAC;AAIX;;GAEG;AACH,eAAO,MAAM,sBAAsB;IAC/B,iCAAiC;;IAEjC,+CAA+C;;IAE/C,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;IAEzD,yDAAyD;;CAGnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumerableTypes.d.ts","sourceRoot":"","sources":["../../src/core/NumerableTypes.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,KAAK,wBAAwB,CAAC,CAAC,IAAI,CAAC,SAAS;IAC3C,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;CAC/B,GACG,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,GAC/D,CAAC,SAAS;IACR,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;CAC/B,GACD,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,GAC1C,CAAC,SAAS;IACR,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;CAC/B,GACD,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,GACrB,GAAG,CAAC;AAER;;;;GAIG;AACH,KAAK,oBAAoB,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,GAEtE;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;CAAE,GACpE,KAAK,CAAC;AAEV;;;GAGG;AACH,KAAK,qBAAqB,GAAG,oBAAoB,CAAC,OAAO,MAAM,CAAC,CAAC;AAGjE;;;;GAIG;AACH,KAAK,4BAA4B,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,4BAA4B,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{format}from"numerable";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
/**
|
|
3
2
|
* Interface representing the position and scale context of a component within its parent container.
|
|
4
3
|
*
|
|
@@ -36,3 +35,4 @@ export interface IPositionContext {
|
|
|
36
35
|
*/
|
|
37
36
|
export declare const DimensionsContext: import("react").Context<IPositionContext>;
|
|
38
37
|
export default DimensionsContext;
|
|
38
|
+
//# sourceMappingURL=PositionContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PositionContext.d.ts","sourceRoot":"","sources":["../../src/core/PositionContext.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAE/B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,2CAI5B,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
package/dist/core/UniqueId.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniqueId.d.ts","sourceRoot":"","sources":["../../src/core/UniqueId.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,IAAK,MAAM,CAElC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmitterDispatchFunction } from "./EventEmitterContext";
|
|
1
|
+
import type { EmitterDispatchFunction } from "./EventEmitterContext";
|
|
2
2
|
/**
|
|
3
3
|
* Generates values for simulating data into an HMI.
|
|
4
4
|
* Used for demonstration and development testing.
|
|
@@ -69,3 +69,4 @@ export declare class ValueSimulator {
|
|
|
69
69
|
protected updateTopic(topic: string, value: any): void;
|
|
70
70
|
}
|
|
71
71
|
export default ValueSimulator;
|
|
72
|
+
//# sourceMappingURL=ValueSimulator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValueSimulator.d.ts","sourceRoot":"","sources":["../../src/core/ValueSimulator.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGrE;;;GAGG;AACH,qBAAa,cAAc;IAEvB,SAAS,CAAC,KAAK,EAAE,OAAO,CAAS;IACjC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAQ;IAEhC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAK;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAK;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAK;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAK;IAE7B,SAAS,CAAC,KAAK,EAAE,MAAM,CAAK;IAC5B,SAAS,CAAC,KAAK,EAAE,MAAM,CAAK;IAC5B,SAAS,CAAC,KAAK,EAAE,MAAM,CAAK;IAC5B,SAAS,CAAC,KAAK,EAAE,MAAM,CAAK;IAE5B,SAAS,CAAC,iBAAiB,EAAG,OAAO,CAAQ;IAC7C,SAAS,CAAC,iBAAiB,EAAG,OAAO,CAAQ;IAC7C,SAAS,CAAC,iBAAiB,EAAG,OAAO,CAAQ;IAC7C,SAAS,CAAC,iBAAiB,EAAG,OAAO,CAAQ;IAE7C,SAAS,CAAC,UAAU,EAAG,MAAM,CAA+B;IAC5D,SAAS,CAAC,UAAU,EAAG,MAAM,CAA+B;IAC5D,SAAS,CAAC,UAAU,EAAG,MAAM,CAAsC;IACnE,SAAS,CAAC,UAAU,EAAG,MAAM,CAAsC;IAEnE,SAAS,CAAC,UAAU,EAAE,MAAM,CAAK;IAEjC,SAAS,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAE5C;;;OAGG;gBACS,QAAQ,EAAE,uBAAuB;IAI7C;;OAEG;IACH,KAAK;IAWL;;OAEG;IACH,IAAI;IAQJ;;OAEG;IACH,SAAS,CAAC,MAAM;IA+BhB;;;;;;OAMG;IACH,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAYzF;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAOnG;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;CAQlD;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export class ValueSimulator{constructor(i){Object.defineProperty(this,"bBit1",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"bBit2",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"iRamp1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iRamp2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fRamp1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fRamp2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iSin1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iSin2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fSin1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fSin2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iRamp1DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"iRamp2DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"fRamp1DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"fRamp2DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"iSin1Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2}),Object.defineProperty(this,"iSin2Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2}),Object.defineProperty(this,"fSin1Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2/10}),Object.defineProperty(this,"fSin2Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2/10}),Object.defineProperty(this,"intervalId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"dispatch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.dispatch=i}start(){0===this.intervalId&&(this.intervalId=setInterval((
|
|
1
|
+
export class ValueSimulator{constructor(i){Object.defineProperty(this,"bBit1",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"bBit2",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"iRamp1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iRamp2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fRamp1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fRamp2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iSin1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iSin2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fSin1",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"fSin2",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"iRamp1DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"iRamp2DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"fRamp1DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"fRamp2DirectionUp",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"iSin1Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2}),Object.defineProperty(this,"iSin2Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2}),Object.defineProperty(this,"fSin1Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2/10}),Object.defineProperty(this,"fSin2Angle",{enumerable:!0,configurable:!0,writable:!0,value:Math.random()*Math.PI*2/10}),Object.defineProperty(this,"intervalId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"dispatch",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.dispatch=i}start(){0===this.intervalId&&(this.intervalId=setInterval(()=>this.update(),1e3))}stop(){0!==this.intervalId&&(clearInterval(this.intervalId),this.intervalId=0)}update(){this.bBit1=!this.bBit1,this.bBit2=!this.bBit2,[this.iRamp1,this.iRamp1DirectionUp]=this.updateRamp(this.iRamp1,this.iRamp1DirectionUp,32767),[this.iRamp2,this.iRamp2DirectionUp]=this.updateRamp(this.iRamp2,this.iRamp2DirectionUp,32767),[this.fRamp1,this.fRamp1DirectionUp]=this.updateRamp(this.fRamp1,this.fRamp1DirectionUp,3276.7),[this.fRamp2,this.fRamp2DirectionUp]=this.updateRamp(this.fRamp2,this.fRamp2DirectionUp,3276.7),[this.iSin1,this.iSin1Angle]=this.updateSin(this.iSin1,this.iSin1Angle,Math.PI/180,32767),[this.iSin2,this.iSin2Angle]=this.updateSin(this.iSin2,this.iSin2Angle,Math.PI/180,32767),[this.fSin1,this.fSin1Angle]=this.updateSin(this.fSin1,this.fSin1Angle,Math.PI/180,3276.7),[this.fSin2,this.fSin2Angle]=this.updateSin(this.fSin2,this.fSin2Angle,Math.PI/180,3276.7),this.updateTopic("value-simulator-bBit1",this.bBit1),this.updateTopic("value-simulator-bBit2",this.bBit2),this.updateTopic("value-simulator-iRamp1",this.iRamp1),this.updateTopic("value-simulator-iRamp2",this.iRamp2),this.updateTopic("value-simulator-fRamp1",this.fRamp1),this.updateTopic("value-simulator-fRamp2",this.fRamp2),this.updateTopic("value-simulator-iSin1",this.iSin1),this.updateTopic("value-simulator-iSin2",this.iSin2),this.updateTopic("value-simulator-fSin1",this.fSin1),this.updateTopic("value-simulator-fSin2",this.fSin2)}updateRamp(i,e,t){if(e){if(++i>=t)return[i,!1]}else if(--i<=0)return[i,!0];return[i,e]}updateSin(i,e,t,a){return e+=t,[Math.sin(e)*a,e]}updateTopic(i,e){this.dispatch({topic:i,payload:e})}}export default ValueSimulator;
|
package/dist/core/hoc.d.ts
CHANGED
|
@@ -29,3 +29,4 @@ export type HocAddSubscriptionProps = {
|
|
|
29
29
|
* @returns A component that subscribes to the given topic and updates its specified prop with the received data.
|
|
30
30
|
*/
|
|
31
31
|
export declare function hocAddSubscription<P extends HocAddSubscriptionProps>(WrappedComponent: React.ComponentType<P>, topic: string, propName: keyof P): (props: Omit<P, keyof HocAddSubscriptionProps>) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
//# sourceMappingURL=hoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hoc.d.ts","sourceRoot":"","sources":["../../src/core/hoc.tsx"],"names":[],"mappings":"AASA;;;;;;;;;;;GAWG;AAGH,OAAO,KAA0C,MAAM,OAAO,CAAC;AAG/D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAClC,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,mGAAmG;IACnG,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,uBAAuB,EAChE,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACxC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,CAAC,IAED,OAAO,IAAI,CAAC,CAAC,EAAE,MAAM,uBAAuB,CAAC,6CAchE"}
|
package/dist/core/hoc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import{EventEmitterContext}from"./EventEmitterContext";export function hocAddSubscription(t,e,r){return function(n){const[o,s]=useState(),{subscribe:u,unsubscribe:
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import React,{useState,useEffect,useContext}from"react";import{EventEmitterContext}from"./EventEmitterContext";export function hocAddSubscription(t,e,r){return function(n){const[o,s]=useState(),{subscribe:u,unsubscribe:c}=useContext(EventEmitterContext);useEffect(()=>{const t=u(e,s);return()=>c(t)},[e,u,c]);return _jsx(t,{...n,...{[r]:o}})}}
|
package/dist/hooks/adsHooks.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adsHooks.d.ts","sourceRoot":"","sources":["../../src/hooks/adsHooks.tsx"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,qBAAqB,GAC9B,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,SAuDnC,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,IAIjC,OAAO,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,mBAQ1D;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAGnD,MAAM,mBAc1C;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CActE"}
|
package/dist/hooks/adsHooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext,useRef,useEffect,useCallback}from"react";import{EventEmitterContext}from"../core/EventEmitterContext";function sleep(e){return new Promise(
|
|
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
|
|
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
|
|
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,4 +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
|
|
145
|
+
export declare function useTapValue(domain: string, symbolName: string): () => Promise<void>;
|
|
146
|
+
//# sourceMappingURL=commandHooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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(
|
|
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){}}}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AACnF,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BaseContextValue, TagConfig, TagValueMap } from "../core/AutoCoreTagTypes";
|
|
2
|
+
export declare function makeAutoCoreTagHooks<Spec extends readonly TagConfig[]>(Context: React.Context<BaseContextValue<TagValueMap<Spec>>>, tags: Spec): {
|
|
3
|
+
readonly useAutoCoreTag: <K extends Spec[number]["tagName"]>(tagName: K) => {
|
|
4
|
+
readonly value: TagValueMap<Spec>[K];
|
|
5
|
+
readonly rawValue: unknown;
|
|
6
|
+
readonly write: (displayValue: TagValueMap<Spec>[K]) => Promise<void>;
|
|
7
|
+
readonly tap: () => Promise<void>;
|
|
8
|
+
readonly isLoading: boolean;
|
|
9
|
+
};
|
|
10
|
+
readonly useAutoCoreTags: <K extends Spec[number]["tagName"]>(tagNames: readonly K[]) => {
|
|
11
|
+
readonly values: { [P in K]: TagValueMap<Spec>[P]; };
|
|
12
|
+
readonly rawValues: { [P_1 in K]: unknown; };
|
|
13
|
+
readonly write: (tagName: K, value: TagValueMap<Spec>[K]) => Promise<void>;
|
|
14
|
+
readonly isLoading: boolean;
|
|
15
|
+
};
|
|
16
|
+
readonly useAutoCoreSelect: <R>(selector: (all: Readonly<Partial<TagValueMap<Spec>>>) => R, deps?: any[]) => {
|
|
17
|
+
readonly selected: R;
|
|
18
|
+
readonly isLoading: boolean;
|
|
19
|
+
};
|
|
20
|
+
readonly useScales: () => {
|
|
21
|
+
readonly scales: Record<string, import("../core/AutoCoreTagTypes").ScaleConfig>;
|
|
22
|
+
readonly updateScale: (scaleName: string, newScale: number, newLabel: string) => Promise<void>;
|
|
23
|
+
readonly getScale: (scaleName: string) => import("../core/AutoCoreTagTypes").ScaleConfig;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useAutoCoreTag.d.ts.map
|