@veltdev/react 5.0.2-beta.5 → 5.0.2-beta.7

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
@@ -212,13 +212,13 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain, integ
212
212
  };
213
213
  };
214
214
 
215
- var VELT_SDK_VERSION = '5.0.2-beta.5';
215
+ var VELT_SDK_VERSION = '5.0.2-beta.7';
216
216
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
217
217
  var VELT_TAB_ID = 'veltTabId';
218
218
  // integrity map for the Velt SDK
219
219
  // Note: generate integrity hashes with: https://www.srihash.org/
220
220
  var INTEGRITY_MAP = {
221
- '5.0.2-beta.5': 'sha384-luyy1vWtVn6u4OutxwI4nu8zboJAmYuZda0QZOJka5s9n1ajaFdXwsyapSWWGdYp',
221
+ '5.0.2-beta.7': 'sha384-8mbjmJB1g3Fdai99VmPR35vyIISB8MDHxlJSOSGi4G3lkxmv9GFEZhkOEwEg2D9S',
222
222
  };
223
223
 
224
224
  var validProps = ['veltIf', 'veltClass', 'className', 'variant'];
@@ -9553,6 +9553,48 @@ function useCrdtEventCallback(action) {
9553
9553
  return data;
9554
9554
  }
9555
9555
 
9556
+ function useActivityUtils() {
9557
+ var _a = React__default["default"].useState(), activityElement = _a[0], setActivityElement = _a[1];
9558
+ var client = useVeltClient().client;
9559
+ React__default["default"].useEffect(function () {
9560
+ if (!client || activityElement)
9561
+ return;
9562
+ var loadedActivityElement = client.getActivityElement();
9563
+ setActivityElement(loadedActivityElement);
9564
+ }, [client, setActivityElement, activityElement]);
9565
+ return activityElement;
9566
+ }
9567
+ function useAllActivities(config) {
9568
+ var activityElement = useActivityUtils();
9569
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
9570
+ var subscriptionRef = React.useRef();
9571
+ // Memoize the inputs
9572
+ var memoizedConfig = React__default["default"].useMemo(function () {
9573
+ return config;
9574
+ }, [JSON.stringify(config)]);
9575
+ React__default["default"].useEffect(function () {
9576
+ if (!activityElement)
9577
+ return;
9578
+ // Unsubscribe from the previous subscription if it exists
9579
+ if (subscriptionRef.current) {
9580
+ subscriptionRef.current.unsubscribe();
9581
+ }
9582
+ var subscription = activityElement.getAllActivities(memoizedConfig)
9583
+ .subscribe(function (activities) {
9584
+ setData(activities);
9585
+ });
9586
+ // Store the new subscription
9587
+ subscriptionRef.current = subscription;
9588
+ // Cleanup function
9589
+ return function () {
9590
+ if (subscriptionRef.current) {
9591
+ subscriptionRef.current.unsubscribe();
9592
+ }
9593
+ };
9594
+ }, [activityElement === null || activityElement === void 0 ? void 0 : activityElement.getAllActivities, memoizedConfig]);
9595
+ return data;
9596
+ }
9597
+
9556
9598
  var sessionId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
9557
9599
  var getSessionId = function () {
9558
9600
  return (sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem(VELT_TAB_ID)) || sessionId;
@@ -9977,10 +10019,12 @@ exports.VeltViewAnalytics = VeltViewAnalytics;
9977
10019
  exports.VeltWireframe = VeltWireframe;
9978
10020
  exports.createLiveStateMiddleware = createLiveStateMiddleware;
9979
10021
  exports.useAIRewriterUtils = useAIRewriterUtils;
10022
+ exports.useActivityUtils = useActivityUtils;
9980
10023
  exports.useAddAttachment = useAddAttachment;
9981
10024
  exports.useAddComment = useAddComment;
9982
10025
  exports.useAddCommentAnnotation = useAddCommentAnnotation;
9983
10026
  exports.useAddReaction = useAddReaction;
10027
+ exports.useAllActivities = useAllActivities;
9984
10028
  exports.useApproveCommentAnnotation = useApproveCommentAnnotation;
9985
10029
  exports.useAssignUser = useAssignUser;
9986
10030
  exports.useAutocompleteChipClick = useAutocompleteChipClick;