@veltdev/react 4.5.0-beta.1 → 4.5.0-beta.3

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.5.0-beta.1';
143
+ var VELT_SDK_VERSION = '4.5.0-beta.3';
144
144
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
145
145
  var VELT_TAB_ID = 'veltTabId';
146
146
 
@@ -531,7 +531,7 @@ var SnippylyHuddleTool = function (props) {
531
531
  };
532
532
 
533
533
  var SnippylyPresence = function (props) {
534
- var maxUsers = props.maxUsers, inactivityTime = props.inactivityTime, documentParams = props.documentParams, location = props.location, locationId = props.locationId, self = props.self, onPresenceUserClick = props.onPresenceUserClick, onUsersChanged = props.onUsersChanged, onPresenceUserChange = props.onPresenceUserChange, disableFlockNavigation = props.disableFlockNavigation, defaultFlockNavigation = props.defaultFlockNavigation, onNavigate = props.onNavigate, flockMode = props.flockMode, shadowDom = props.shadowDom;
534
+ var maxUsers = props.maxUsers, inactivityTime = props.inactivityTime, offlineInactivityTime = props.offlineInactivityTime, documentParams = props.documentParams, location = props.location, locationId = props.locationId, self = props.self, onPresenceUserClick = props.onPresenceUserClick, onUsersChanged = props.onUsersChanged, onPresenceUserChange = props.onPresenceUserChange, disableFlockNavigation = props.disableFlockNavigation, defaultFlockNavigation = props.defaultFlockNavigation, onNavigate = props.onNavigate, flockMode = props.flockMode, shadowDom = props.shadowDom;
535
535
  var ref = React.useRef();
536
536
  var onUsersChangedRef = React.useRef(onUsersChanged);
537
537
  var onPresenceUserChangeRef = React.useRef(onPresenceUserChange);
@@ -586,7 +586,7 @@ var SnippylyPresence = function (props) {
586
586
  }
587
587
  };
588
588
  }, []);
589
- return (React__default["default"].createElement("velt-presence", { ref: ref, "flock-mode": [true, false].includes(flockMode) ? (flockMode ? 'true' : 'false') : undefined, "max-users": maxUsers, "inactivity-time": inactivityTime, "document-params": (typeof documentParams === 'object') ? JSON.stringify(documentParams) : (documentParams ? documentParams : undefined), "disable-flock-navigation": [true, false].includes(disableFlockNavigation) ? (disableFlockNavigation ? 'true' : 'false') : undefined, "default-flock-navigation": [true, false].includes(defaultFlockNavigation) ? (defaultFlockNavigation ? 'true' : 'false') : undefined, self: [true, false].includes(self) ? (self ? 'true' : 'false') : undefined, location: (typeof location === 'object') ? JSON.stringify(location) : (location ? location : undefined), "location-id": locationId, "shadow-dom": [true, false].includes(shadowDom) ? (shadowDom ? 'true' : 'false') : undefined }));
589
+ return (React__default["default"].createElement("velt-presence", { ref: ref, "flock-mode": [true, false].includes(flockMode) ? (flockMode ? 'true' : 'false') : undefined, "max-users": maxUsers, "inactivity-time": inactivityTime, "offline-inactivity-time": offlineInactivityTime, "document-params": (typeof documentParams === 'object') ? JSON.stringify(documentParams) : (documentParams ? documentParams : undefined), "disable-flock-navigation": [true, false].includes(disableFlockNavigation) ? (disableFlockNavigation ? 'true' : 'false') : undefined, "default-flock-navigation": [true, false].includes(defaultFlockNavigation) ? (defaultFlockNavigation ? 'true' : 'false') : undefined, self: [true, false].includes(self) ? (self ? 'true' : 'false') : undefined, location: (typeof location === 'object') ? JSON.stringify(location) : (location ? location : undefined), "location-id": locationId, "shadow-dom": [true, false].includes(shadowDom) ? (shadowDom ? 'true' : 'false') : undefined }));
590
590
  };
591
591
 
592
592
  var SnippylyRecorderControlPanel = function (props) {
@@ -6377,6 +6377,33 @@ function useLiveState(liveStateDataId, initialValue, options) {
6377
6377
  return [data, setDataFunction, serverConnectionState];
6378
6378
  }
6379
6379
 
6380
+ function useLiveStateSyncEventCallback(action) {
6381
+ var liveStateSyncElement = useLiveStateSyncUtils();
6382
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
6383
+ var subscriptionRef = React.useRef(null);
6384
+ var memoizedAction = React.useMemo(function () { return action; }, [action]);
6385
+ React.useEffect(function () {
6386
+ var _a;
6387
+ if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.on))
6388
+ return;
6389
+ if (subscriptionRef.current) {
6390
+ subscriptionRef.current.unsubscribe();
6391
+ }
6392
+ var subscription = (_a = liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.on(memoizedAction)) === null || _a === void 0 ? void 0 : _a.subscribe(function (data) {
6393
+ setData(data);
6394
+ });
6395
+ // Store the new subscription
6396
+ subscriptionRef.current = subscription;
6397
+ // Cleanup function
6398
+ return function () {
6399
+ if (subscriptionRef.current) {
6400
+ subscriptionRef.current.unsubscribe();
6401
+ }
6402
+ };
6403
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.on, memoizedAction]);
6404
+ return data;
6405
+ }
6406
+
6380
6407
  function usePresenceUtils() {
6381
6408
  var _a = React__default["default"].useState(), presenceElement = _a[0], setPresenceElement = _a[1];
6382
6409
  var client = useVeltClient().client;
@@ -6404,6 +6431,33 @@ function usePresenceUsers() {
6404
6431
  return data;
6405
6432
  }
6406
6433
 
6434
+ function usePresenceEventCallback(action) {
6435
+ var presenceElement = usePresenceUtils();
6436
+ var _a = React.useState(null), data = _a[0], setData = _a[1];
6437
+ var subscriptionRef = React.useRef(null);
6438
+ var memoizedAction = React.useMemo(function () { return action; }, [action]);
6439
+ React.useEffect(function () {
6440
+ var _a;
6441
+ if (!(presenceElement === null || presenceElement === void 0 ? void 0 : presenceElement.on))
6442
+ return;
6443
+ if (subscriptionRef.current) {
6444
+ subscriptionRef.current.unsubscribe();
6445
+ }
6446
+ var subscription = (_a = presenceElement === null || presenceElement === void 0 ? void 0 : presenceElement.on(memoizedAction)) === null || _a === void 0 ? void 0 : _a.subscribe(function (data) {
6447
+ setData(data);
6448
+ });
6449
+ // Store the new subscription
6450
+ subscriptionRef.current = subscription;
6451
+ // Cleanup function
6452
+ return function () {
6453
+ if (subscriptionRef.current) {
6454
+ subscriptionRef.current.unsubscribe();
6455
+ }
6456
+ };
6457
+ }, [presenceElement === null || presenceElement === void 0 ? void 0 : presenceElement.on, memoizedAction]);
6458
+ return data;
6459
+ }
6460
+
6407
6461
  function useRecorderUtils() {
6408
6462
  var _a = React__default["default"].useState(), recorderElement = _a[0], setRecorderElement = _a[1];
6409
6463
  var client = useVeltClient().client;
@@ -7041,9 +7095,11 @@ exports.useLiveSelectionDataHandler = useLiveSelectionDataHandler;
7041
7095
  exports.useLiveSelectionUtils = useLiveSelectionUtils;
7042
7096
  exports.useLiveState = useLiveState;
7043
7097
  exports.useLiveStateData = useLiveStateData;
7098
+ exports.useLiveStateSyncEventCallback = useLiveStateSyncEventCallback;
7044
7099
  exports.useLiveStateSyncUtils = useLiveStateSyncUtils;
7045
7100
  exports.useNotificationUtils = useNotificationUtils;
7046
7101
  exports.useNotificationsData = useNotificationsData;
7102
+ exports.usePresenceEventCallback = usePresenceEventCallback;
7047
7103
  exports.usePresenceUsers = usePresenceUsers;
7048
7104
  exports.usePresenceUtils = usePresenceUtils;
7049
7105
  exports.useRecorderAddHandler = useRecorderAddHandler;