@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.
- package/cjs/index.js +24 -6
- package/cjs/index.js.map +1 -1
- package/cjs/types/constants.d.ts +2 -1
- package/cjs/types/hooks/LiveStateSyncElement.d.ts +8 -3
- package/cjs/types/hooks/index.d.ts +1 -1
- package/esm/index.js +24 -7
- package/esm/index.js.map +1 -1
- package/esm/types/constants.d.ts +2 -1
- package/esm/types/hooks/LiveStateSyncElement.d.ts +8 -3
- package/esm/types/hooks/index.d.ts +1 -1
- package/index.d.ts +8 -4
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -140,8 +140,9 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
|
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
var VELT_SDK_VERSION = '1.0.
|
|
143
|
+
var VELT_SDK_VERSION = '1.0.158';
|
|
144
144
|
var VELT_SDK_INIT_EVENT = 'onVeltInit';
|
|
145
|
+
var VELT_TAB_ID = 'veltTabId';
|
|
145
146
|
|
|
146
147
|
var SnippylyProvider = function (props) {
|
|
147
148
|
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;
|
|
@@ -2343,13 +2344,13 @@ function useLiveStateSyncUtils() {
|
|
|
2343
2344
|
}, [client, setLiveStateSyncElement, liveStateSyncElement]);
|
|
2344
2345
|
return liveStateSyncElement;
|
|
2345
2346
|
}
|
|
2346
|
-
function useLiveStateData(liveStateDataId,
|
|
2347
|
+
function useLiveStateData(liveStateDataId, liveStateDataConfig) {
|
|
2347
2348
|
var liveStateSyncElement = useLiveStateSyncUtils();
|
|
2348
2349
|
var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
|
|
2349
2350
|
React.useEffect(function () {
|
|
2350
2351
|
if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData))
|
|
2351
2352
|
return;
|
|
2352
|
-
var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId,
|
|
2353
|
+
var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, liveStateDataConfig).subscribe(function (res) {
|
|
2353
2354
|
setData(res);
|
|
2354
2355
|
});
|
|
2355
2356
|
return function () {
|
|
@@ -2426,9 +2427,25 @@ function useEditorAccessRequestHandler() {
|
|
|
2426
2427
|
}, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isEditorAccessRequested]);
|
|
2427
2428
|
return data;
|
|
2428
2429
|
}
|
|
2430
|
+
function useServerConnectionStateChangeHandler() {
|
|
2431
|
+
var liveStateSyncElement = useLiveStateSyncUtils();
|
|
2432
|
+
var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
|
|
2433
|
+
React.useEffect(function () {
|
|
2434
|
+
if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.onServerConnectionStateChange))
|
|
2435
|
+
return;
|
|
2436
|
+
var subscription = liveStateSyncElement.onServerConnectionStateChange().subscribe(function (res) {
|
|
2437
|
+
setData(res);
|
|
2438
|
+
});
|
|
2439
|
+
return function () {
|
|
2440
|
+
subscription.unsubscribe();
|
|
2441
|
+
};
|
|
2442
|
+
}, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.onServerConnectionStateChange]);
|
|
2443
|
+
return data;
|
|
2444
|
+
}
|
|
2429
2445
|
function useLiveState(liveStateDataId, initialValue, options) {
|
|
2430
2446
|
var liveStateSyncElement = useLiveStateSyncUtils();
|
|
2431
2447
|
var client = useVeltClient().client;
|
|
2448
|
+
var serverConnectionState = useServerConnectionStateChangeHandler();
|
|
2432
2449
|
var _a = React__default["default"].useState(null), documentId = _a[0], setDocumentId = _a[1];
|
|
2433
2450
|
var _b = React__default["default"].useState(null), user = _b[0], setUser = _b[1];
|
|
2434
2451
|
var _c = React__default["default"].useState(initialValue), data = _c[0], setData = _c[1];
|
|
@@ -2458,7 +2475,7 @@ function useLiveState(liveStateDataId, initialValue, options) {
|
|
|
2458
2475
|
}
|
|
2459
2476
|
});
|
|
2460
2477
|
}
|
|
2461
|
-
var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, options === null || options === void 0 ? void 0 : options.listenToNewChangesOnly).subscribe(function (res) {
|
|
2478
|
+
var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId, { listenToNewChangesOnly: options === null || options === void 0 ? void 0 : options.listenToNewChangesOnly }).subscribe(function (res) {
|
|
2462
2479
|
setData(res);
|
|
2463
2480
|
});
|
|
2464
2481
|
return function () {
|
|
@@ -2492,7 +2509,7 @@ function useLiveState(liveStateDataId, initialValue, options) {
|
|
|
2492
2509
|
liveStateSyncElement.setLiveStateData(liveStateDataId, value);
|
|
2493
2510
|
}
|
|
2494
2511
|
});
|
|
2495
|
-
return [data, setDataFunction];
|
|
2512
|
+
return [data, setDataFunction, serverConnectionState];
|
|
2496
2513
|
}
|
|
2497
2514
|
|
|
2498
2515
|
function usePresenceUtils() {
|
|
@@ -2698,7 +2715,7 @@ function useAutocompleteChipClick() {
|
|
|
2698
2715
|
|
|
2699
2716
|
var sessionId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
2700
2717
|
var getSessionId = function () {
|
|
2701
|
-
return sessionId;
|
|
2718
|
+
return (sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem(VELT_TAB_ID)) || sessionId;
|
|
2702
2719
|
};
|
|
2703
2720
|
var VELT_DEFAULT_LIVE_STATE_ID = 'velt-default-redux-live-state';
|
|
2704
2721
|
var createLiveStateMiddleware = function (config) {
|
|
@@ -2869,6 +2886,7 @@ exports.usePresenceUsers = usePresenceUsers;
|
|
|
2869
2886
|
exports.usePresenceUtils = usePresenceUtils;
|
|
2870
2887
|
exports.useRecorderAddHandler = useRecorderAddHandler;
|
|
2871
2888
|
exports.useRecorderUtils = useRecorderUtils;
|
|
2889
|
+
exports.useServerConnectionStateChangeHandler = useServerConnectionStateChangeHandler;
|
|
2872
2890
|
exports.useSetDocumentId = useSetDocumentId;
|
|
2873
2891
|
exports.useSetLiveStateData = useSetLiveStateData;
|
|
2874
2892
|
exports.useSetLocation = useSetLocation;
|