@veltdev/react 1.0.139 → 1.0.141

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,2 +1,3 @@
1
- export declare const VELT_SDK_VERSION = "1.0.156";
1
+ export declare const VELT_SDK_VERSION = "1.0.158";
2
2
  export declare const VELT_SDK_INIT_EVENT = "onVeltInit";
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,8 +132,9 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
132
132
  }
133
133
  };
134
134
 
135
- var VELT_SDK_VERSION = '1.0.156';
135
+ var VELT_SDK_VERSION = '1.0.158';
136
136
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
137
+ var VELT_TAB_ID = 'veltTabId';
137
138
 
138
139
  var SnippylyProvider = function (props) {
139
140
  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;
@@ -2335,13 +2336,13 @@ function useLiveStateSyncUtils() {
2335
2336
  }, [client, setLiveStateSyncElement, liveStateSyncElement]);
2336
2337
  return liveStateSyncElement;
2337
2338
  }
2338
- function useLiveStateData(liveStateDataId, listenToNewChangesOnly) {
2339
+ function useLiveStateData(liveStateDataId, liveStateDataConfig) {
2339
2340
  var liveStateSyncElement = useLiveStateSyncUtils();
2340
2341
  var _a = React.useState(), data = _a[0], setData = _a[1];
2341
2342
  useEffect(function () {
2342
2343
  if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData))
2343
2344
  return;
2344
- var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, listenToNewChangesOnly).subscribe(function (res) {
2345
+ var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, liveStateDataConfig).subscribe(function (res) {
2345
2346
  setData(res);
2346
2347
  });
2347
2348
  return function () {
@@ -2418,9 +2419,25 @@ function useEditorAccessRequestHandler() {
2418
2419
  }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isEditorAccessRequested]);
2419
2420
  return data;
2420
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
+ }
2421
2437
  function useLiveState(liveStateDataId, initialValue, options) {
2422
2438
  var liveStateSyncElement = useLiveStateSyncUtils();
2423
2439
  var client = useVeltClient().client;
2440
+ var serverConnectionState = useServerConnectionStateChangeHandler();
2424
2441
  var _a = React.useState(null), documentId = _a[0], setDocumentId = _a[1];
2425
2442
  var _b = React.useState(null), user = _b[0], setUser = _b[1];
2426
2443
  var _c = React.useState(initialValue), data = _c[0], setData = _c[1];
@@ -2450,7 +2467,7 @@ function useLiveState(liveStateDataId, initialValue, options) {
2450
2467
  }
2451
2468
  });
2452
2469
  }
2453
- 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) {
2454
2471
  setData(res);
2455
2472
  });
2456
2473
  return function () {
@@ -2484,7 +2501,7 @@ function useLiveState(liveStateDataId, initialValue, options) {
2484
2501
  liveStateSyncElement.setLiveStateData(liveStateDataId, value);
2485
2502
  }
2486
2503
  });
2487
- return [data, setDataFunction];
2504
+ return [data, setDataFunction, serverConnectionState];
2488
2505
  }
2489
2506
 
2490
2507
  function usePresenceUtils() {
@@ -2690,7 +2707,7 @@ function useAutocompleteChipClick() {
2690
2707
 
2691
2708
  var sessionId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
2692
2709
  var getSessionId = function () {
2693
- return sessionId;
2710
+ return (sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem(VELT_TAB_ID)) || sessionId;
2694
2711
  };
2695
2712
  var VELT_DEFAULT_LIVE_STATE_ID = 'velt-default-redux-live-state';
2696
2713
  var createLiveStateMiddleware = function (config) {
@@ -2779,5 +2796,5 @@ var logLiveState = function (action, liveStateDataId) {
2779
2796
  }
2780
2797
  };
2781
2798
 
2782
- 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 };
2783
2800
  //# sourceMappingURL=index.js.map