@veltdev/react 3.0.36 → 3.0.38
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 +116 -24
- package/cjs/index.js.map +1 -1
- package/cjs/types/constants.d.ts +1 -1
- package/cjs/types/hooks/ContactElement.d.ts +2 -2
- package/esm/index.js +116 -24
- package/esm/index.js.map +1 -1
- package/esm/types/constants.d.ts +1 -1
- package/esm/types/hooks/ContactElement.d.ts +2 -2
- package/index.d.ts +2 -2
- package/package.json +1 -1
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 = '3.0.
|
|
143
|
+
var VELT_SDK_VERSION = '3.0.38';
|
|
144
144
|
var VELT_SDK_INIT_EVENT = 'onVeltInit';
|
|
145
145
|
var VELT_TAB_ID = 'veltTabId';
|
|
146
146
|
|
|
@@ -3426,21 +3426,40 @@ function useClient() {
|
|
|
3426
3426
|
}
|
|
3427
3427
|
function useIdentify(user, userOptions) {
|
|
3428
3428
|
var client = useVeltClient().client;
|
|
3429
|
+
// Memoize the identify call
|
|
3430
|
+
var shouldIdentify = React__default["default"].useMemo(function () {
|
|
3431
|
+
return { user: user, userOptions: userOptions };
|
|
3432
|
+
}, [JSON.stringify(user), JSON.stringify(userOptions)]);
|
|
3429
3433
|
React__default["default"].useEffect(function () {
|
|
3430
|
-
|
|
3431
|
-
|
|
3434
|
+
if (client) {
|
|
3435
|
+
client.identify(shouldIdentify.user, shouldIdentify.userOptions);
|
|
3436
|
+
}
|
|
3437
|
+
}, [client, shouldIdentify]);
|
|
3432
3438
|
}
|
|
3433
3439
|
function useSetDocument(documentId, documentMetadata) {
|
|
3434
3440
|
var client = useVeltClient().client;
|
|
3441
|
+
// Memoize the setDocument call
|
|
3442
|
+
var shouldSetDocument = React__default["default"].useMemo(function () {
|
|
3443
|
+
return {
|
|
3444
|
+
documentId: documentId,
|
|
3445
|
+
documentMetadata: documentMetadata
|
|
3446
|
+
};
|
|
3447
|
+
}, [documentId, JSON.stringify(documentMetadata)]);
|
|
3435
3448
|
React__default["default"].useEffect(function () {
|
|
3436
|
-
|
|
3437
|
-
|
|
3449
|
+
if (client) {
|
|
3450
|
+
client.setDocument(shouldSetDocument.documentId, shouldSetDocument.documentMetadata);
|
|
3451
|
+
}
|
|
3452
|
+
}, [client, shouldSetDocument]);
|
|
3438
3453
|
}
|
|
3439
3454
|
function useSetDocumentId(documentId) {
|
|
3440
3455
|
var client = useVeltClient().client;
|
|
3456
|
+
// Memoize the documentId
|
|
3457
|
+
var memoizedDocumentId = React__default["default"].useMemo(function () { return documentId; }, [documentId]);
|
|
3441
3458
|
React__default["default"].useEffect(function () {
|
|
3442
|
-
|
|
3443
|
-
|
|
3459
|
+
if (client) {
|
|
3460
|
+
client.setDocumentId(memoizedDocumentId);
|
|
3461
|
+
}
|
|
3462
|
+
}, [client, memoizedDocumentId]);
|
|
3444
3463
|
}
|
|
3445
3464
|
function useUnsetDocumentId() {
|
|
3446
3465
|
var client = useVeltClient().client;
|
|
@@ -3450,9 +3469,15 @@ function useUnsetDocumentId() {
|
|
|
3450
3469
|
}
|
|
3451
3470
|
function useSetLocation(location, appendLocation) {
|
|
3452
3471
|
var client = useVeltClient().client;
|
|
3472
|
+
// Memoize the setLocation call
|
|
3473
|
+
var shouldSetLocation = React__default["default"].useMemo(function () {
|
|
3474
|
+
return { location: location, appendLocation: appendLocation };
|
|
3475
|
+
}, [JSON.stringify(location), appendLocation]);
|
|
3453
3476
|
React__default["default"].useEffect(function () {
|
|
3454
|
-
|
|
3455
|
-
|
|
3477
|
+
if (client) {
|
|
3478
|
+
client.setLocation(shouldSetLocation.location, shouldSetLocation.appendLocation);
|
|
3479
|
+
}
|
|
3480
|
+
}, [client, shouldSetLocation]);
|
|
3456
3481
|
}
|
|
3457
3482
|
function useVeltInitState() {
|
|
3458
3483
|
var client = useVeltClient().client;
|
|
@@ -3484,31 +3509,59 @@ function useCommentUtils() {
|
|
|
3484
3509
|
function useCommentAnnotations(documentId, location) {
|
|
3485
3510
|
var commentElement = useCommentUtils();
|
|
3486
3511
|
var _a = React__default["default"].useState(undefined), data = _a[0], setData = _a[1];
|
|
3512
|
+
var subscriptionRef = React__default["default"].useRef();
|
|
3513
|
+
// Memoize the inputs
|
|
3514
|
+
var inputs = React__default["default"].useMemo(function () {
|
|
3515
|
+
return { documentId: documentId, location: location };
|
|
3516
|
+
}, [documentId, JSON.stringify(location)]);
|
|
3487
3517
|
React.useEffect(function () {
|
|
3488
3518
|
if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getAllCommentAnnotations))
|
|
3489
3519
|
return;
|
|
3490
|
-
|
|
3520
|
+
// Unsubscribe from the previous subscription if it exists
|
|
3521
|
+
if (subscriptionRef.current) {
|
|
3522
|
+
subscriptionRef.current.unsubscribe();
|
|
3523
|
+
}
|
|
3524
|
+
var subscription = commentElement.getAllCommentAnnotations(inputs.documentId, inputs.location)
|
|
3525
|
+
.subscribe(function (res) {
|
|
3491
3526
|
setData(res);
|
|
3492
3527
|
});
|
|
3528
|
+
// Store the new subscription
|
|
3529
|
+
subscriptionRef.current = subscription;
|
|
3530
|
+
// Cleanup function
|
|
3493
3531
|
return function () {
|
|
3494
|
-
|
|
3532
|
+
if (subscriptionRef.current) {
|
|
3533
|
+
subscriptionRef.current.unsubscribe();
|
|
3534
|
+
}
|
|
3495
3535
|
};
|
|
3496
|
-
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getAllCommentAnnotations]);
|
|
3536
|
+
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getAllCommentAnnotations, inputs]);
|
|
3497
3537
|
return data;
|
|
3498
3538
|
}
|
|
3499
3539
|
function useUnreadCommentCountByAnnotationId(annotationId) {
|
|
3500
3540
|
var commentElement = useCommentUtils();
|
|
3501
3541
|
var _a = React__default["default"].useState({ count: 0 }), data = _a[0], setData = _a[1];
|
|
3542
|
+
var subscriptionRef = React__default["default"].useRef();
|
|
3543
|
+
// Memoize the input
|
|
3544
|
+
var memoizedAnnotationId = React__default["default"].useMemo(function () { return annotationId; }, [annotationId]);
|
|
3502
3545
|
React.useEffect(function () {
|
|
3503
3546
|
if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentCountByAnnotationId))
|
|
3504
3547
|
return;
|
|
3505
|
-
|
|
3548
|
+
// Unsubscribe from the previous subscription if it exists
|
|
3549
|
+
if (subscriptionRef.current) {
|
|
3550
|
+
subscriptionRef.current.unsubscribe();
|
|
3551
|
+
}
|
|
3552
|
+
var subscription = commentElement.getUnreadCommentCountByAnnotationId(memoizedAnnotationId)
|
|
3553
|
+
.subscribe(function (res) {
|
|
3506
3554
|
setData(res);
|
|
3507
3555
|
});
|
|
3556
|
+
// Store the new subscription
|
|
3557
|
+
subscriptionRef.current = subscription;
|
|
3558
|
+
// Cleanup function
|
|
3508
3559
|
return function () {
|
|
3509
|
-
|
|
3560
|
+
if (subscriptionRef.current) {
|
|
3561
|
+
subscriptionRef.current.unsubscribe();
|
|
3562
|
+
}
|
|
3510
3563
|
};
|
|
3511
|
-
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentCountByAnnotationId]);
|
|
3564
|
+
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentCountByAnnotationId, memoizedAnnotationId]);
|
|
3512
3565
|
return data;
|
|
3513
3566
|
}
|
|
3514
3567
|
function useUnreadCommentAnnotationCountOnCurrentDocument() {
|
|
@@ -3544,31 +3597,57 @@ function useUnreadCommentCountOnCurrentDocument() {
|
|
|
3544
3597
|
function useUnreadCommentCountByLocationId(locationId) {
|
|
3545
3598
|
var commentElement = useCommentUtils();
|
|
3546
3599
|
var _a = React__default["default"].useState({ count: 0 }), data = _a[0], setData = _a[1];
|
|
3600
|
+
var subscriptionRef = React__default["default"].useRef();
|
|
3601
|
+
// Memoize the input
|
|
3602
|
+
var memoizedLocationId = React__default["default"].useMemo(function () { return locationId; }, [locationId]);
|
|
3547
3603
|
React.useEffect(function () {
|
|
3548
3604
|
if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentCountByLocationId))
|
|
3549
3605
|
return;
|
|
3550
|
-
|
|
3606
|
+
// Unsubscribe from the previous subscription if it exists
|
|
3607
|
+
if (subscriptionRef.current) {
|
|
3608
|
+
subscriptionRef.current.unsubscribe();
|
|
3609
|
+
}
|
|
3610
|
+
var subscription = commentElement.getUnreadCommentCountByLocationId(memoizedLocationId)
|
|
3611
|
+
.subscribe(function (res) {
|
|
3551
3612
|
setData(res);
|
|
3552
3613
|
});
|
|
3614
|
+
// Store the new subscription
|
|
3615
|
+
subscriptionRef.current = subscription;
|
|
3616
|
+
// Cleanup function
|
|
3553
3617
|
return function () {
|
|
3554
|
-
|
|
3618
|
+
if (subscriptionRef.current) {
|
|
3619
|
+
subscriptionRef.current.unsubscribe();
|
|
3620
|
+
}
|
|
3555
3621
|
};
|
|
3556
|
-
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentCountByLocationId]);
|
|
3622
|
+
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentCountByLocationId, memoizedLocationId]);
|
|
3557
3623
|
return data;
|
|
3558
3624
|
}
|
|
3559
3625
|
function useUnreadCommentAnnotationCountByLocationId(locationId) {
|
|
3560
3626
|
var commentElement = useCommentUtils();
|
|
3561
3627
|
var _a = React__default["default"].useState({ count: 0 }), data = _a[0], setData = _a[1];
|
|
3628
|
+
var subscriptionRef = React__default["default"].useRef();
|
|
3629
|
+
// Memoize the input
|
|
3630
|
+
var memoizedLocationId = React__default["default"].useMemo(function () { return locationId; }, [locationId]);
|
|
3562
3631
|
React.useEffect(function () {
|
|
3563
3632
|
if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentAnnotationCountByLocationId))
|
|
3564
3633
|
return;
|
|
3565
|
-
|
|
3634
|
+
// Unsubscribe from the previous subscription if it exists
|
|
3635
|
+
if (subscriptionRef.current) {
|
|
3636
|
+
subscriptionRef.current.unsubscribe();
|
|
3637
|
+
}
|
|
3638
|
+
var subscription = commentElement.getUnreadCommentAnnotationCountByLocationId(memoizedLocationId)
|
|
3639
|
+
.subscribe(function (res) {
|
|
3566
3640
|
setData(res);
|
|
3567
3641
|
});
|
|
3642
|
+
// Store the new subscription
|
|
3643
|
+
subscriptionRef.current = subscription;
|
|
3644
|
+
// Cleanup function
|
|
3568
3645
|
return function () {
|
|
3569
|
-
|
|
3646
|
+
if (subscriptionRef.current) {
|
|
3647
|
+
subscriptionRef.current.unsubscribe();
|
|
3648
|
+
}
|
|
3570
3649
|
};
|
|
3571
|
-
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentAnnotationCountByLocationId]);
|
|
3650
|
+
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getUnreadCommentAnnotationCountByLocationId, memoizedLocationId]);
|
|
3572
3651
|
return data;
|
|
3573
3652
|
}
|
|
3574
3653
|
function useCommentModeState() {
|
|
@@ -3666,16 +3745,29 @@ function useCommentCopyLinkHandler() {
|
|
|
3666
3745
|
function useCommentAnnotationById(config) {
|
|
3667
3746
|
var commentElement = useCommentUtils();
|
|
3668
3747
|
var _a = React__default["default"].useState(undefined), data = _a[0], setData = _a[1];
|
|
3748
|
+
var subscriptionRef = React__default["default"].useRef();
|
|
3749
|
+
// Memoize the input
|
|
3750
|
+
var memoizedConfig = React__default["default"].useMemo(function () { return config; }, [config.annotationId, config.documentId]);
|
|
3669
3751
|
React.useEffect(function () {
|
|
3670
3752
|
if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getCommentAnnotationById))
|
|
3671
3753
|
return;
|
|
3672
|
-
|
|
3754
|
+
// Unsubscribe from the previous subscription if it exists
|
|
3755
|
+
if (subscriptionRef.current) {
|
|
3756
|
+
subscriptionRef.current.unsubscribe();
|
|
3757
|
+
}
|
|
3758
|
+
var subscription = commentElement.getCommentAnnotationById(memoizedConfig)
|
|
3759
|
+
.subscribe(function (res) {
|
|
3673
3760
|
setData(res);
|
|
3674
3761
|
});
|
|
3762
|
+
// Store the new subscription
|
|
3763
|
+
subscriptionRef.current = subscription;
|
|
3764
|
+
// Cleanup function
|
|
3675
3765
|
return function () {
|
|
3676
|
-
|
|
3766
|
+
if (subscriptionRef.current) {
|
|
3767
|
+
subscriptionRef.current.unsubscribe();
|
|
3768
|
+
}
|
|
3677
3769
|
};
|
|
3678
|
-
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getCommentAnnotationById]);
|
|
3770
|
+
}, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getCommentAnnotationById, memoizedConfig]);
|
|
3679
3771
|
return data;
|
|
3680
3772
|
}
|
|
3681
3773
|
function useCommentSidebarActionButtonClick() {
|