@veltdev/react 1.0.140 → 1.0.142

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,3 +1,3 @@
1
- export declare const VELT_SDK_VERSION = "1.0.157";
1
+ export declare const VELT_SDK_VERSION = "1.0.159";
2
2
  export declare const VELT_SDK_INIT_EVENT = "onVeltInit";
3
3
  export declare const VELT_TAB_ID = "veltTabId";
@@ -1,6 +1,9 @@
1
- import { EditorAccessTimer, LiveStateSyncElement, User, UserEditorAccess } from "@veltdev/types";
1
+ import { EditorAccessTimer, LiveStateSyncElement, ServerConnectionState, User, UserEditorAccess } from "@veltdev/types";
2
+ declare class LiveStateDataConfig {
3
+ listenToNewChangesOnly?: boolean;
4
+ }
2
5
  export declare function useLiveStateSyncUtils(): LiveStateSyncElement | undefined;
3
- export declare function useLiveStateData(liveStateDataId?: string, listenToNewChangesOnly?: boolean): any;
6
+ export declare function useLiveStateData(liveStateDataId?: string, liveStateDataConfig?: LiveStateDataConfig): any;
4
7
  export declare function useSetLiveStateData(liveStateDataId: string, liveStateData: any): any;
5
8
  export declare function useUserEditorState(): UserEditorAccess | null;
6
9
  export declare function useEditor(): User | null;
@@ -9,8 +12,10 @@ export declare function useEditorAccessRequestHandler(): {
9
12
  requestStatus: string;
10
13
  requestedBy: User;
11
14
  } | null;
15
+ export declare function useServerConnectionStateChangeHandler(): ServerConnectionState | undefined;
12
16
  export declare function useLiveState<T>(liveStateDataId: string, initialValue?: any, options?: {
13
17
  syncDuration?: number;
14
18
  resetLiveState?: boolean;
15
19
  listenToNewChangesOnly?: boolean;
16
- }): [T, (value: T) => void];
20
+ }): [T, (value: T) => void, ServerConnectionState | undefined];
21
+ export {};
@@ -2,7 +2,7 @@ export { useSetLocation, useSetDocumentId, useUnsetDocumentId, useIdentify, useC
2
2
  export { useCommentUtils, useCommentAnnotations, useCommentAddHandler, useCommentModeState, useCommentUpdateHandler, useCommentDialogSidebarClickHandler, useCommentSelectionChangeHandler, } from './CommentElement';
3
3
  export { useCursorUtils, useCursorUsers, } from './CursorElement';
4
4
  export { useHuddleUtils, } from './HuddleElement';
5
- export { useLiveStateSyncUtils, useLiveStateData, useSetLiveStateData, useUserEditorState, useEditor, useEditorAccessTimer, useEditorAccessRequestHandler, useLiveState, } from './LiveStateSyncElement';
5
+ export { useLiveStateSyncUtils, useLiveStateData, useSetLiveStateData, useUserEditorState, useEditor, useEditorAccessTimer, useEditorAccessRequestHandler, useServerConnectionStateChangeHandler, 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
@@ -132,7 +132,7 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
132
132
  }
133
133
  };
134
134
 
135
- var VELT_SDK_VERSION = '1.0.157';
135
+ var VELT_SDK_VERSION = '1.0.159';
136
136
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
137
137
  var VELT_TAB_ID = 'veltTabId';
138
138
 
@@ -2336,13 +2336,13 @@ function useLiveStateSyncUtils() {
2336
2336
  }, [client, setLiveStateSyncElement, liveStateSyncElement]);
2337
2337
  return liveStateSyncElement;
2338
2338
  }
2339
- function useLiveStateData(liveStateDataId, listenToNewChangesOnly) {
2339
+ function useLiveStateData(liveStateDataId, liveStateDataConfig) {
2340
2340
  var liveStateSyncElement = useLiveStateSyncUtils();
2341
2341
  var _a = React.useState(), data = _a[0], setData = _a[1];
2342
2342
  useEffect(function () {
2343
2343
  if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData))
2344
2344
  return;
2345
- var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, listenToNewChangesOnly).subscribe(function (res) {
2345
+ var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, liveStateDataConfig).subscribe(function (res) {
2346
2346
  setData(res);
2347
2347
  });
2348
2348
  return function () {
@@ -2419,9 +2419,25 @@ function useEditorAccessRequestHandler() {
2419
2419
  }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isEditorAccessRequested]);
2420
2420
  return data;
2421
2421
  }
2422
+ function useServerConnectionStateChangeHandler() {
2423
+ var liveStateSyncElement = useLiveStateSyncUtils();
2424
+ var _a = React.useState(), data = _a[0], setData = _a[1];
2425
+ useEffect(function () {
2426
+ if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.onServerConnectionStateChange))
2427
+ return;
2428
+ var subscription = liveStateSyncElement.onServerConnectionStateChange().subscribe(function (res) {
2429
+ setData(res);
2430
+ });
2431
+ return function () {
2432
+ subscription.unsubscribe();
2433
+ };
2434
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.onServerConnectionStateChange]);
2435
+ return data;
2436
+ }
2422
2437
  function useLiveState(liveStateDataId, initialValue, options) {
2423
2438
  var liveStateSyncElement = useLiveStateSyncUtils();
2424
2439
  var client = useVeltClient().client;
2440
+ var serverConnectionState = useServerConnectionStateChangeHandler();
2425
2441
  var _a = React.useState(null), documentId = _a[0], setDocumentId = _a[1];
2426
2442
  var _b = React.useState(null), user = _b[0], setUser = _b[1];
2427
2443
  var _c = React.useState(initialValue), data = _c[0], setData = _c[1];
@@ -2451,7 +2467,7 @@ function useLiveState(liveStateDataId, initialValue, options) {
2451
2467
  }
2452
2468
  });
2453
2469
  }
2454
- var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, options === null || options === void 0 ? void 0 : options.listenToNewChangesOnly).subscribe(function (res) {
2470
+ var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, { listenToNewChangesOnly: options === null || options === void 0 ? void 0 : options.listenToNewChangesOnly }).subscribe(function (res) {
2455
2471
  setData(res);
2456
2472
  });
2457
2473
  return function () {
@@ -2485,7 +2501,7 @@ function useLiveState(liveStateDataId, initialValue, options) {
2485
2501
  liveStateSyncElement.setLiveStateData(liveStateDataId, value);
2486
2502
  }
2487
2503
  });
2488
- return [data, setDataFunction];
2504
+ return [data, setDataFunction, serverConnectionState];
2489
2505
  }
2490
2506
 
2491
2507
  function usePresenceUtils() {
@@ -2780,5 +2796,5 @@ var logLiveState = function (action, liveStateDataId) {
2780
2796
  }
2781
2797
  };
2782
2798
 
2783
- export { SnippylyArrowTool as VeltArrowTool, SnippylyArrows as VeltArrows, VeltAutocomplete, VeltAutocompleteChipTooltipWireframe, VeltAutocompleteOptionWireframe, VeltChartComment, SnippylyCommentBubble as VeltCommentBubble, VeltCommentBubbleWireframe, VeltCommentDialogOptionsDropdownContentWireframe, VeltCommentDialogOptionsDropdownTriggerWireframe, VeltCommentDialogPriorityDropdownContentWireframe, VeltCommentDialogPriorityDropdownTriggerWireframe, VeltCommentDialogStatusDropdownContentWireframe, VeltCommentDialogStatusDropdownTriggerWireframe, VeltCommentDialogWireframe, VeltCommentPinWireframe, VeltCommentPlayerTimeline, VeltCommentThread, SnippylyCommentTool as VeltCommentTool, VeltCommentToolWireframe, SnippylyComments as VeltComments, SnippylyCommentsSidebar as VeltCommentsSidebar, VeltCommentsSidebarWireframe, SnippylyCursor as VeltCursor, VeltHighChartComments, SnippylyHuddle as VeltHuddle, SnippylyHuddleTool as VeltHuddleTool, VeltNivoChartComments, VeltNotificationsHistoryPanel, VeltNotificationsPanel, VeltNotificationsTool, SnippylyPresence as VeltPresence, SnippylyProvider as VeltProvider, VeltReactionPinTooltipWireframe, VeltReactionPinWireframe, VeltReactionToolWireframe, VeltReactionsPanelWireframe, SnippylyRecorderControlPanel as VeltRecorderControlPanel, SnippylyRecorderNotes as VeltRecorderNotes, SnippylyRecorderPlayer as VeltRecorderPlayer, SnippylyRecorderTool as VeltRecorderTool, SnippylySidebarButton as VeltSidebarButton, VeltSidebarButtonWireframe, SnippylyTagTool as VeltTagTool, SnippylyTags as VeltTags, VeltTextCommentToolWireframe, VeltTextCommentToolbar as VeltTextCommentToolbarWireframe, SnippylyUserInviteTool as VeltUserInviteTool, SnippylyUserRequestTool as VeltUserRequestTool, VeltUserSelectorDropdown as VeltUserSelectorDropdownWireframe, VeltVideoPlayer, VeltViewAnalytics, VeltWireframe, createLiveStateMiddleware, useAIRewriterUtils, useAutocompleteChipClick, useAutocompleteUtils, useClient, useCommentAddHandler, useCommentAnnotations, useCommentDialogSidebarClickHandler, useCommentModeState, useCommentSelectionChangeHandler, useCommentUpdateHandler, useCommentUtils, useCursorUsers, useCursorUtils, useEditor, useEditorAccessRequestHandler, useEditorAccessTimer, useHuddleUtils, useIdentify, useLiveSelectionUtils, useLiveState, useLiveStateData, useLiveStateSyncUtils, useNotificationUtils, useNotificationsData, usePresenceUsers, usePresenceUtils, useRecorderAddHandler, useRecorderUtils, useSetDocumentId, useSetLiveStateData, useSetLocation, useTagAnnotations, useTagUtils, useUniqueViewsByDate, useUniqueViewsByUser, useUnsetDocumentId, useUserEditorState, useVeltClient, useVeltInitState, useViewsUtils };
2799
+ export { SnippylyArrowTool as VeltArrowTool, SnippylyArrows as VeltArrows, VeltAutocomplete, VeltAutocompleteChipTooltipWireframe, VeltAutocompleteOptionWireframe, VeltChartComment, SnippylyCommentBubble as VeltCommentBubble, VeltCommentBubbleWireframe, VeltCommentDialogOptionsDropdownContentWireframe, VeltCommentDialogOptionsDropdownTriggerWireframe, VeltCommentDialogPriorityDropdownContentWireframe, VeltCommentDialogPriorityDropdownTriggerWireframe, VeltCommentDialogStatusDropdownContentWireframe, VeltCommentDialogStatusDropdownTriggerWireframe, VeltCommentDialogWireframe, VeltCommentPinWireframe, VeltCommentPlayerTimeline, VeltCommentThread, SnippylyCommentTool as VeltCommentTool, VeltCommentToolWireframe, SnippylyComments as VeltComments, SnippylyCommentsSidebar as VeltCommentsSidebar, VeltCommentsSidebarWireframe, SnippylyCursor as VeltCursor, VeltHighChartComments, SnippylyHuddle as VeltHuddle, SnippylyHuddleTool as VeltHuddleTool, VeltNivoChartComments, VeltNotificationsHistoryPanel, VeltNotificationsPanel, VeltNotificationsTool, SnippylyPresence as VeltPresence, SnippylyProvider as VeltProvider, VeltReactionPinTooltipWireframe, VeltReactionPinWireframe, VeltReactionToolWireframe, VeltReactionsPanelWireframe, SnippylyRecorderControlPanel as VeltRecorderControlPanel, SnippylyRecorderNotes as VeltRecorderNotes, SnippylyRecorderPlayer as VeltRecorderPlayer, SnippylyRecorderTool as VeltRecorderTool, SnippylySidebarButton as VeltSidebarButton, VeltSidebarButtonWireframe, SnippylyTagTool as VeltTagTool, SnippylyTags as VeltTags, VeltTextCommentToolWireframe, VeltTextCommentToolbar as VeltTextCommentToolbarWireframe, SnippylyUserInviteTool as VeltUserInviteTool, SnippylyUserRequestTool as VeltUserRequestTool, VeltUserSelectorDropdown as VeltUserSelectorDropdownWireframe, VeltVideoPlayer, VeltViewAnalytics, VeltWireframe, createLiveStateMiddleware, useAIRewriterUtils, useAutocompleteChipClick, useAutocompleteUtils, useClient, useCommentAddHandler, useCommentAnnotations, useCommentDialogSidebarClickHandler, useCommentModeState, useCommentSelectionChangeHandler, useCommentUpdateHandler, useCommentUtils, useCursorUsers, useCursorUtils, useEditor, useEditorAccessRequestHandler, useEditorAccessTimer, useHuddleUtils, useIdentify, useLiveSelectionUtils, useLiveState, useLiveStateData, useLiveStateSyncUtils, useNotificationUtils, useNotificationsData, usePresenceUsers, usePresenceUtils, useRecorderAddHandler, useRecorderUtils, useServerConnectionStateChangeHandler, useSetDocumentId, useSetLiveStateData, useSetLocation, useTagAnnotations, useTagUtils, useUniqueViewsByDate, useUniqueViewsByUser, useUnsetDocumentId, useUserEditorState, useVeltClient, useVeltInitState, useViewsUtils };
2784
2800
  //# sourceMappingURL=index.js.map