@veltdev/react 1.0.68 → 1.0.70

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.
@@ -1,7 +1,8 @@
1
+ import { RecorderElement } from "@veltdev/types";
1
2
  /**
2
3
  * @beta This hook is in beta
3
4
  */
4
- export declare function useRecorderUtils(): any | undefined;
5
+ export declare function useRecorderUtils(): RecorderElement | undefined;
5
6
  /**
6
7
  * @beta This hook is in beta
7
8
  */
@@ -1,4 +1,5 @@
1
+ import { RewriterElement } from "@veltdev/types";
1
2
  /**
2
3
  * @beta This hook is in beta
3
4
  */
4
- export declare function useAIRewriterUtils(): any | undefined;
5
+ export declare function useAIRewriterUtils(): RewriterElement | undefined;
@@ -1,4 +1,5 @@
1
+ import { SelectionElement } from "@veltdev/types";
1
2
  /**
2
3
  * @beta This hook is in beta
3
4
  */
4
- export declare function useLiveSelectionUtils(): any | undefined;
5
+ export declare function useLiveSelectionUtils(): SelectionElement | undefined;
@@ -1,9 +1,9 @@
1
- import { Location } from "@veltdev/types";
1
+ import { Location, TagAnnotation, TagElement } from "@veltdev/types";
2
2
  /**
3
3
  * @beta This hook is in beta
4
4
  */
5
- export declare function useTagUtils(): any | undefined;
5
+ export declare function useTagUtils(): TagElement | undefined;
6
6
  /**
7
7
  * @beta This hook is in beta
8
8
  */
9
- export declare function useTagAnnotations(documentId?: string, location?: Location): any;
9
+ export declare function useTagAnnotations(documentId?: string, location?: Location): TagAnnotation[] | null;
@@ -2,7 +2,7 @@ export { useAddLocation, useSetLocation, useSetDocumentId, useIdentify, useClien
2
2
  export { useCommentUtils, useCommentAnnotations, useCommentAddHandler, useCommentModeState, useCommentUpdateHandler, useCommentDialogSidebarClickHandler, } from './CommentElement';
3
3
  export { useCursorUtils, useCursorUsers, } from './CursorElement';
4
4
  export { useHuddleUtils, } from './HuddleElement';
5
- export { useLiveStateSyncUtils, useLiveStateData, useSetLiveStateData, useUserEditorState, useEditor, useEditorAccessRequestHandler, } from './LiveStateSyncElement';
5
+ export { useLiveStateSyncUtils, useLiveStateData, useSetLiveStateData, useUserEditorState, useEditor, useEditorAccessRequestHandler, useLiveState, } from './LiveStateSyncElement';
6
6
  export { usePresenceUtils, usePresenceUsers, } from './PresenceElement';
7
7
  export { useRecorderUtils, useRecorderAddHandler, } from './RecorderElement';
8
8
  export { useAIRewriterUtils, } from './RewriterElement';
package/esm/index.js CHANGED
@@ -86,7 +86,7 @@ var loadVelt = function (callback, version, staging) {
86
86
  }
87
87
  };
88
88
 
89
- var VELT_SDK_VERSION = '1.0.83';
89
+ var VELT_SDK_VERSION = '1.0.87';
90
90
 
91
91
  var SnippylyProvider = function (props) {
92
92
  var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, language = props.language, translations = props.translations, autoTranslation = props.autoTranslation, onClientLoad = props.onClientLoad, children = props.children;
@@ -585,7 +585,7 @@ function useCursorUtils() {
585
585
  */
586
586
  function useCursorUsers() {
587
587
  var cursorElement = useCursorUtils();
588
- var _a = React.useState(), data = _a[0], setData = _a[1];
588
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
589
589
  useEffect(function () {
590
590
  if (!cursorElement)
591
591
  return;
@@ -662,7 +662,7 @@ function useSetLiveStateData(liveStateDataId, liveStateData) {
662
662
  */
663
663
  function useUserEditorState() {
664
664
  var liveStateSyncElement = useLiveStateSyncUtils();
665
- var _a = React.useState(), data = _a[0], setData = _a[1];
665
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
666
666
  useEffect(function () {
667
667
  if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isUserEditor))
668
668
  return;
@@ -680,7 +680,7 @@ function useUserEditorState() {
680
680
  */
681
681
  function useEditor() {
682
682
  var liveStateSyncElement = useLiveStateSyncUtils();
683
- var _a = React.useState(), data = _a[0], setData = _a[1];
683
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
684
684
  useEffect(function () {
685
685
  if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getEditor))
686
686
  return;
@@ -698,7 +698,7 @@ function useEditor() {
698
698
  */
699
699
  function useEditorAccessRequestHandler() {
700
700
  var liveStateSyncElement = useLiveStateSyncUtils();
701
- var _a = React.useState(), data = _a[0], setData = _a[1];
701
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
702
702
  useEffect(function () {
703
703
  if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isEditorAccessRequested))
704
704
  return;
@@ -711,6 +711,50 @@ function useEditorAccessRequestHandler() {
711
711
  }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isEditorAccessRequested]);
712
712
  return data;
713
713
  }
714
+ /**
715
+ * @beta This hook is in beta
716
+ */
717
+ function useLiveState(liveStateDataId, initialValue, debounceTime) {
718
+ if (debounceTime === void 0) { debounceTime = 50; }
719
+ var liveStateSyncElement = useLiveStateSyncUtils();
720
+ var _a = React.useState(initialValue), data = _a[0], setData = _a[1];
721
+ useEffect(function () {
722
+ if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData))
723
+ return;
724
+ var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId).subscribe(function (res) {
725
+ setData(res);
726
+ });
727
+ return function () {
728
+ subscription.unsubscribe();
729
+ };
730
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData]);
731
+ var useDebounce = function (callback) {
732
+ var callbackRef = useRef(callback);
733
+ var timerRef = useRef(null);
734
+ useEffect(function () {
735
+ callbackRef.current = callback;
736
+ });
737
+ var debounce = function (value, delay) {
738
+ if (timerRef.current) {
739
+ clearTimeout(timerRef.current);
740
+ }
741
+ timerRef.current = setTimeout(function () {
742
+ callbackRef.current(value);
743
+ }, delay);
744
+ };
745
+ return debounce;
746
+ };
747
+ var setDataFunction = function (value) {
748
+ setData(value);
749
+ debouncedOnInput(value, debounceTime); // default 50ms debounce time
750
+ };
751
+ var debouncedOnInput = useDebounce(function (value) {
752
+ if (liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData) {
753
+ liveStateSyncElement.setLiveStateData(liveStateDataId, value);
754
+ }
755
+ });
756
+ return [data, setDataFunction];
757
+ }
714
758
 
715
759
  /**
716
760
  * @beta This hook is in beta
@@ -731,7 +775,7 @@ function usePresenceUtils() {
731
775
  */
732
776
  function usePresenceUsers() {
733
777
  var presenceElement = usePresenceUtils();
734
- var _a = React.useState(), data = _a[0], setData = _a[1];
778
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
735
779
  useEffect(function () {
736
780
  if (!presenceElement)
737
781
  return;
@@ -827,7 +871,7 @@ function useTagUtils() {
827
871
  */
828
872
  function useTagAnnotations(documentId, location) {
829
873
  var tagElement = useTagUtils();
830
- var _a = React.useState(), data = _a[0], setData = _a[1];
874
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
831
875
  useEffect(function () {
832
876
  if (!tagElement)
833
877
  return;
@@ -841,5 +885,5 @@ function useTagAnnotations(documentId, location) {
841
885
  return data;
842
886
  }
843
887
 
844
- export { SnippylyArrowTool as VeltArrowTool, SnippylyArrows as VeltArrows, SnippylyCommentBubble as VeltCommentBubble, VeltCommentPlayerTimeline, SnippylyCommentTool as VeltCommentTool, SnippylyComments as VeltComments, SnippylyCommentsSidebar as VeltCommentsSidebar, SnippylyCursor as VeltCursor, SnippylyHuddle as VeltHuddle, SnippylyHuddleTool as VeltHuddleTool, SnippylyPresence as VeltPresence, SnippylyProvider as VeltProvider, SnippylyRecorderControlPanel as VeltRecorderControlPanel, SnippylyRecorderNotes as VeltRecorderNotes, SnippylyRecorderPlayer as VeltRecorderPlayer, SnippylyRecorderTool as VeltRecorderTool, SnippylySidebarButton as VeltSidebarButton, SnippylyTagTool as VeltTagTool, SnippylyTags as VeltTags, SnippylyUserInviteTool as VeltUserInviteTool, SnippylyUserRequestTool as VeltUserRequestTool, VeltVideoPlayer, useAIRewriterUtils, useAddLocation, useClient, useCommentAddHandler, useCommentAnnotations, useCommentDialogSidebarClickHandler, useCommentModeState, useCommentUpdateHandler, useCommentUtils, useCursorUsers, useCursorUtils, useEditor, useEditorAccessRequestHandler, useHuddleUtils, useIdentify, useLiveSelectionUtils, useLiveStateData, useLiveStateSyncUtils, usePresenceUsers, usePresenceUtils, useRecorderAddHandler, useRecorderUtils, useSetDocumentId, useSetLiveStateData, useSetLocation, useTagAnnotations, useTagUtils, useUserEditorState, useVeltClient };
888
+ export { SnippylyArrowTool as VeltArrowTool, SnippylyArrows as VeltArrows, SnippylyCommentBubble as VeltCommentBubble, VeltCommentPlayerTimeline, SnippylyCommentTool as VeltCommentTool, SnippylyComments as VeltComments, SnippylyCommentsSidebar as VeltCommentsSidebar, SnippylyCursor as VeltCursor, SnippylyHuddle as VeltHuddle, SnippylyHuddleTool as VeltHuddleTool, SnippylyPresence as VeltPresence, SnippylyProvider as VeltProvider, SnippylyRecorderControlPanel as VeltRecorderControlPanel, SnippylyRecorderNotes as VeltRecorderNotes, SnippylyRecorderPlayer as VeltRecorderPlayer, SnippylyRecorderTool as VeltRecorderTool, SnippylySidebarButton as VeltSidebarButton, SnippylyTagTool as VeltTagTool, SnippylyTags as VeltTags, SnippylyUserInviteTool as VeltUserInviteTool, SnippylyUserRequestTool as VeltUserRequestTool, VeltVideoPlayer, useAIRewriterUtils, useAddLocation, useClient, useCommentAddHandler, useCommentAnnotations, useCommentDialogSidebarClickHandler, useCommentModeState, useCommentUpdateHandler, useCommentUtils, useCursorUsers, useCursorUtils, useEditor, useEditorAccessRequestHandler, useHuddleUtils, useIdentify, useLiveSelectionUtils, useLiveState, useLiveStateData, useLiveStateSyncUtils, usePresenceUsers, usePresenceUtils, useRecorderAddHandler, useRecorderUtils, useSetDocumentId, useSetLiveStateData, useSetLocation, useTagAnnotations, useTagUtils, useUserEditorState, useVeltClient };
845
889
  //# sourceMappingURL=index.js.map