@veltdev/react 4.0.0-beta.1 → 4.0.0-beta.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/cjs/index.js CHANGED
@@ -140,7 +140,7 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
140
140
  }
141
141
  };
142
142
 
143
- var VELT_SDK_VERSION = '4.0.0-beta.1';
143
+ var VELT_SDK_VERSION = '4.0.0-beta.2';
144
144
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
145
145
  var VELT_TAB_ID = 'veltTabId';
146
146
 
@@ -4384,6 +4384,25 @@ function useSetDocumentId(documentId) {
4384
4384
  }
4385
4385
  }, [client, memoizedDocumentId]);
4386
4386
  }
4387
+ function useSetDocuments() {
4388
+ var client = useVeltClient().client;
4389
+ var _a = React__default["default"].useState(undefined), data = _a[0], setData = _a[1];
4390
+ // Memoize the setDocuments call
4391
+ var memoizedData = React__default["default"].useMemo(function () {
4392
+ return data;
4393
+ }, [JSON.stringify(data === null || data === void 0 ? void 0 : data.documents), JSON.stringify(data === null || data === void 0 ? void 0 : data.options)]);
4394
+ React__default["default"].useEffect(function () {
4395
+ var _a;
4396
+ if (client && ((_a = memoizedData === null || memoizedData === void 0 ? void 0 : memoizedData.documents) === null || _a === void 0 ? void 0 : _a.length)) {
4397
+ client.setDocuments(memoizedData.documents, memoizedData.options);
4398
+ }
4399
+ }, [client === null || client === void 0 ? void 0 : client.setDocuments, memoizedData]);
4400
+ return {
4401
+ setDocuments: function (documents, options) {
4402
+ setData({ documents: documents, options: options });
4403
+ }
4404
+ };
4405
+ }
4387
4406
  function useUnsetDocumentId() {
4388
4407
  var client = useVeltClient().client;
4389
4408
  React__default["default"].useEffect(function () {
@@ -4817,6 +4836,66 @@ function useDeleteCommentAnnotation() {
4817
4836
  }
4818
4837
  };
4819
4838
  }
4839
+ function useGetCommentAnnotations(getCommentAnnotationsRequest) {
4840
+ var commentElement = useCommentUtils();
4841
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
4842
+ var subscriptionRef = React.useRef();
4843
+ // Memoize the inputs
4844
+ var memoizedData = React.useMemo(function () {
4845
+ return getCommentAnnotationsRequest;
4846
+ }, [JSON.stringify(getCommentAnnotationsRequest)]);
4847
+ React.useEffect(function () {
4848
+ if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getCommentAnnotations))
4849
+ return;
4850
+ // Unsubscribe from the previous subscription if it exists
4851
+ if (subscriptionRef.current) {
4852
+ subscriptionRef.current.unsubscribe();
4853
+ }
4854
+ var subscription = commentElement.getCommentAnnotations(memoizedData)
4855
+ .subscribe(function (res) {
4856
+ setData(res);
4857
+ });
4858
+ // Store the new subscription
4859
+ subscriptionRef.current = subscription;
4860
+ // Cleanup function
4861
+ return function () {
4862
+ if (subscriptionRef.current) {
4863
+ subscriptionRef.current.unsubscribe();
4864
+ }
4865
+ };
4866
+ }, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getCommentAnnotations, memoizedData]);
4867
+ return data;
4868
+ }
4869
+ function useCommentAnnotationsCount(getCommentAnnotationsCountRequest) {
4870
+ var commentElement = useCommentUtils();
4871
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
4872
+ var subscriptionRef = React.useRef();
4873
+ // Memoize the inputs
4874
+ var memoizedData = React.useMemo(function () {
4875
+ return getCommentAnnotationsCountRequest;
4876
+ }, [JSON.stringify(getCommentAnnotationsCountRequest)]);
4877
+ React.useEffect(function () {
4878
+ if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getCommentAnnotationsCount))
4879
+ return;
4880
+ // Unsubscribe from the previous subscription if it exists
4881
+ if (subscriptionRef.current) {
4882
+ subscriptionRef.current.unsubscribe();
4883
+ }
4884
+ var subscription = commentElement.getCommentAnnotationsCount(memoizedData)
4885
+ .subscribe(function (res) {
4886
+ setData(res);
4887
+ });
4888
+ // Store the new subscription
4889
+ subscriptionRef.current = subscription;
4890
+ // Cleanup function
4891
+ return function () {
4892
+ if (subscriptionRef.current) {
4893
+ subscriptionRef.current.unsubscribe();
4894
+ }
4895
+ };
4896
+ }, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getCommentAnnotationsCount, memoizedData]);
4897
+ return data;
4898
+ }
4820
4899
  function useAssignUser() {
4821
4900
  var commentElement = useCommentUtils();
4822
4901
  return {
@@ -5852,6 +5931,7 @@ exports.useCommentActionCallback = useCommentActionCallback;
5852
5931
  exports.useCommentAddHandler = useCommentAddHandler;
5853
5932
  exports.useCommentAnnotationById = useCommentAnnotationById;
5854
5933
  exports.useCommentAnnotations = useCommentAnnotations;
5934
+ exports.useCommentAnnotationsCount = useCommentAnnotationsCount;
5855
5935
  exports.useCommentCopyLinkHandler = useCommentCopyLinkHandler;
5856
5936
  exports.useCommentDialogSidebarClickHandler = useCommentDialogSidebarClickHandler;
5857
5937
  exports.useCommentEventCallback = useCommentEventCallback;
@@ -5877,6 +5957,7 @@ exports.useEditorAccessRequestHandler = useEditorAccessRequestHandler;
5877
5957
  exports.useEditorAccessTimer = useEditorAccessTimer;
5878
5958
  exports.useGetAttachment = useGetAttachment;
5879
5959
  exports.useGetComment = useGetComment;
5960
+ exports.useGetCommentAnnotations = useGetCommentAnnotations;
5880
5961
  exports.useGetLink = useGetLink;
5881
5962
  exports.useGetRecording = useGetRecording;
5882
5963
  exports.useHuddleUtils = useHuddleUtils;
@@ -5898,6 +5979,7 @@ exports.useResolveCommentAnnotation = useResolveCommentAnnotation;
5898
5979
  exports.useServerConnectionStateChangeHandler = useServerConnectionStateChangeHandler;
5899
5980
  exports.useSetDocument = useSetDocument;
5900
5981
  exports.useSetDocumentId = useSetDocumentId;
5982
+ exports.useSetDocuments = useSetDocuments;
5901
5983
  exports.useSetLiveStateData = useSetLiveStateData;
5902
5984
  exports.useSetLocation = useSetLocation;
5903
5985
  exports.useSubscribeCommentAnnotation = useSubscribeCommentAnnotation;