@veltdev/react 4.6.7 → 4.6.9
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 +43 -2
- package/cjs/index.js.map +1 -1
- package/cjs/types/constants.d.ts +1 -1
- package/cjs/types/hooks/CrdtActions.d.ts +2 -0
- package/cjs/types/hooks/CrdtElement.d.ts +2 -0
- package/cjs/types/hooks/index.d.ts +2 -0
- package/esm/index.js +42 -3
- package/esm/index.js.map +1 -1
- package/esm/types/constants.d.ts +1 -1
- package/esm/types/hooks/CrdtActions.d.ts +2 -0
- package/esm/types/hooks/CrdtElement.d.ts +2 -0
- package/esm/types/hooks/index.d.ts +2 -0
- package/index.d.ts +6 -2
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -145,13 +145,13 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain, integ
|
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
var VELT_SDK_VERSION = '4.6.
|
|
148
|
+
var VELT_SDK_VERSION = '4.6.9';
|
|
149
149
|
var VELT_SDK_INIT_EVENT = 'onVeltInit';
|
|
150
150
|
var VELT_TAB_ID = 'veltTabId';
|
|
151
151
|
// integrity map for the Velt SDK
|
|
152
152
|
// Note: generate integrity hashes with: https://www.srihash.org/
|
|
153
153
|
var INTEGRITY_MAP = {
|
|
154
|
-
'4.6.
|
|
154
|
+
'4.6.9': 'sha384-hC0faXaN+Z6kIhO87PDhqL+ARcdgmD1FdpLB9amziTOoZ3G2cIZmcwReBVK5Y7hf',
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
var validProps = ['veltIf', 'veltClass', 'className', 'variant'];
|
|
@@ -7906,6 +7906,45 @@ function useContactList() {
|
|
|
7906
7906
|
return data;
|
|
7907
7907
|
}
|
|
7908
7908
|
|
|
7909
|
+
function useCrdtUtils() {
|
|
7910
|
+
var _a = React__default["default"].useState(), crdtElement = _a[0], setCrdtElement = _a[1];
|
|
7911
|
+
var client = useVeltClient().client;
|
|
7912
|
+
React__default["default"].useEffect(function () {
|
|
7913
|
+
if (!client || crdtElement)
|
|
7914
|
+
return;
|
|
7915
|
+
var loadedCrdtElement = client.getCrdtElement();
|
|
7916
|
+
setCrdtElement(loadedCrdtElement);
|
|
7917
|
+
}, [client, setCrdtElement, crdtElement]);
|
|
7918
|
+
return crdtElement;
|
|
7919
|
+
}
|
|
7920
|
+
|
|
7921
|
+
function useCrdtEventCallback(action) {
|
|
7922
|
+
var crdtElement = useCrdtUtils();
|
|
7923
|
+
var _a = React.useState(null), data = _a[0], setData = _a[1];
|
|
7924
|
+
var subscriptionRef = React.useRef(null);
|
|
7925
|
+
var memoizedAction = React.useMemo(function () { return action; }, [action]);
|
|
7926
|
+
React.useEffect(function () {
|
|
7927
|
+
var _a;
|
|
7928
|
+
if (!(crdtElement === null || crdtElement === void 0 ? void 0 : crdtElement.on))
|
|
7929
|
+
return;
|
|
7930
|
+
if (subscriptionRef.current) {
|
|
7931
|
+
subscriptionRef.current.unsubscribe();
|
|
7932
|
+
}
|
|
7933
|
+
var subscription = (_a = crdtElement === null || crdtElement === void 0 ? void 0 : crdtElement.on(memoizedAction)) === null || _a === void 0 ? void 0 : _a.subscribe(function (data) {
|
|
7934
|
+
setData(data);
|
|
7935
|
+
});
|
|
7936
|
+
// Store the new subscription
|
|
7937
|
+
subscriptionRef.current = subscription;
|
|
7938
|
+
// Cleanup function
|
|
7939
|
+
return function () {
|
|
7940
|
+
if (subscriptionRef.current) {
|
|
7941
|
+
subscriptionRef.current.unsubscribe();
|
|
7942
|
+
}
|
|
7943
|
+
};
|
|
7944
|
+
}, [crdtElement === null || crdtElement === void 0 ? void 0 : crdtElement.on, memoizedAction]);
|
|
7945
|
+
return data;
|
|
7946
|
+
}
|
|
7947
|
+
|
|
7909
7948
|
var sessionId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
7910
7949
|
var getSessionId = function () {
|
|
7911
7950
|
return (sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem(VELT_TAB_ID)) || sessionId;
|
|
@@ -8167,6 +8206,8 @@ exports.useContactList = useContactList;
|
|
|
8167
8206
|
exports.useContactSelected = useContactSelected;
|
|
8168
8207
|
exports.useContactUtils = useContactUtils;
|
|
8169
8208
|
exports.useCopyLink = useCopyLink;
|
|
8209
|
+
exports.useCrdtEventCallback = useCrdtEventCallback;
|
|
8210
|
+
exports.useCrdtUtils = useCrdtUtils;
|
|
8170
8211
|
exports.useCurrentUser = useCurrentUser;
|
|
8171
8212
|
exports.useCurrentUserPermissions = useCurrentUserPermissions;
|
|
8172
8213
|
exports.useCursorUsers = useCursorUsers;
|