@veltdev/react 4.5.9 → 4.6.0-beta.1

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/cjs/index.js CHANGED
@@ -145,13 +145,13 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain, integ
145
145
  }
146
146
  };
147
147
 
148
- var VELT_SDK_VERSION = '4.5.9';
148
+ var VELT_SDK_VERSION = '4.6.0-beta.1';
149
149
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
150
150
  var VELT_TAB_ID = 'veltTabId';
151
151
  // integrity map for the Velt SDK
152
152
  // Note: generate integrity hashes with: https://www.srihash.org/
153
153
  var INTEGRITY_MAP = {
154
- '4.5.9': 'sha384-dBr6zZx7nOz3mb9LWGSL9Oq67bjc55OcjEBXvUvKpLSDcc/QMohP7bn+KcBaPXZw',
154
+ '4.6.0-beta.1': 'sha384-JTbW/nmhPvyQyQBXASPMBZ93/7NqYXcqb2pIV9ejr6jQHNQpSMR8rihlSRyZuorA',
155
155
  };
156
156
 
157
157
  var SnippylyProvider = function (props) {
@@ -6163,6 +6163,32 @@ function useUiState() {
6163
6163
  setUiState: setUiState
6164
6164
  };
6165
6165
  }
6166
+ function useHeartbeat(heartbeatConfig) {
6167
+ var client = useVeltClient().client;
6168
+ var _a = React__default["default"].useState({ data: null }), data = _a[0], setData = _a[1];
6169
+ var memoizedConfig = React__default["default"].useMemo(function () { return heartbeatConfig; }, [JSON.stringify(heartbeatConfig)]);
6170
+ var subscriptionRef = React__default["default"].useRef();
6171
+ React__default["default"].useEffect(function () {
6172
+ if (!(client === null || client === void 0 ? void 0 : client.getHeartbeat))
6173
+ return;
6174
+ // Unsubscribe from the previous subscription if it exists
6175
+ if (subscriptionRef.current) {
6176
+ subscriptionRef.current.unsubscribe();
6177
+ }
6178
+ var subscription = client.getHeartbeat(memoizedConfig).subscribe(function (res) {
6179
+ setData(res);
6180
+ });
6181
+ // Store the new subscription
6182
+ subscriptionRef.current = subscription;
6183
+ // Cleanup function
6184
+ return function () {
6185
+ if (subscriptionRef.current) {
6186
+ subscriptionRef.current.unsubscribe();
6187
+ }
6188
+ };
6189
+ }, [client === null || client === void 0 ? void 0 : client.getHeartbeat, memoizedConfig]);
6190
+ return data;
6191
+ }
6166
6192
 
6167
6193
  function useCommentUtils() {
6168
6194
  var _a = React__default["default"].useState(), commentElement = _a[0], setCommentElement = _a[1];
@@ -8023,6 +8049,7 @@ exports.useGetComment = useGetComment;
8023
8049
  exports.useGetCommentAnnotations = useGetCommentAnnotations;
8024
8050
  exports.useGetLink = useGetLink;
8025
8051
  exports.useGetRecording = useGetRecording;
8052
+ exports.useHeartbeat = useHeartbeat;
8026
8053
  exports.useHuddleUtils = useHuddleUtils;
8027
8054
  exports.useIdentify = useIdentify;
8028
8055
  exports.useLiveSelectionDataHandler = useLiveSelectionDataHandler;