@veltdev/react 1.0.70 → 1.0.72
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 +95 -4
- package/cjs/index.js.map +1 -1
- package/cjs/types/components/SnippylyComments/SnippylyComments.d.ts +1 -0
- package/cjs/types/constants.d.ts +2 -1
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/redux/index.d.ts +1 -0
- package/cjs/types/redux/veltLiveStateSynceMiddleware.d.ts +8 -0
- package/esm/index.js +95 -5
- package/esm/index.js.map +1 -1
- package/esm/types/components/SnippylyComments/SnippylyComments.d.ts +1 -0
- package/esm/types/constants.d.ts +2 -1
- package/esm/types/index.d.ts +1 -0
- package/esm/types/redux/index.d.ts +1 -0
- package/esm/types/redux/veltLiveStateSynceMiddleware.d.ts +8 -0
- package/index.d.ts +10 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -23,6 +23,17 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
23
23
|
PERFORMANCE OF THIS SOFTWARE.
|
|
24
24
|
***************************************************************************** */
|
|
25
25
|
|
|
26
|
+
var __assign = function() {
|
|
27
|
+
__assign = Object.assign || function __assign(t) {
|
|
28
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29
|
+
s = arguments[i];
|
|
30
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
};
|
|
34
|
+
return __assign.apply(this, arguments);
|
|
35
|
+
};
|
|
36
|
+
|
|
26
37
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
27
38
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
39
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -94,7 +105,8 @@ var loadVelt = function (callback, version, staging) {
|
|
|
94
105
|
}
|
|
95
106
|
};
|
|
96
107
|
|
|
97
|
-
var VELT_SDK_VERSION = '1.0.
|
|
108
|
+
var VELT_SDK_VERSION = '1.0.89';
|
|
109
|
+
var VELT_SDK_INIT_EVENT = 'onVeltInit';
|
|
98
110
|
|
|
99
111
|
var SnippylyProvider = function (props) {
|
|
100
112
|
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;
|
|
@@ -107,7 +119,7 @@ var SnippylyProvider = function (props) {
|
|
|
107
119
|
}
|
|
108
120
|
}, []);
|
|
109
121
|
var initVelt = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
110
|
-
var velt;
|
|
122
|
+
var velt, event;
|
|
111
123
|
var _a, _b;
|
|
112
124
|
return __generator(this, function (_c) {
|
|
113
125
|
switch (_c.label) {
|
|
@@ -164,6 +176,8 @@ var SnippylyProvider = function (props) {
|
|
|
164
176
|
if (documentId) {
|
|
165
177
|
velt === null || velt === void 0 ? void 0 : velt.setDocumentId(documentId);
|
|
166
178
|
}
|
|
179
|
+
event = new CustomEvent(VELT_SDK_INIT_EVENT, { detail: velt });
|
|
180
|
+
window.dispatchEvent(event);
|
|
167
181
|
return [2 /*return*/];
|
|
168
182
|
}
|
|
169
183
|
});
|
|
@@ -178,7 +192,7 @@ var SnippylyCommentBubble = function (props) {
|
|
|
178
192
|
};
|
|
179
193
|
|
|
180
194
|
var SnippylyComments = function (props) {
|
|
181
|
-
var autoCategorize = props.autoCategorize, streamViewContainerId = props.streamViewContainerId, onSignIn = props.onSignIn, onUpgrade = props.onUpgrade, textMode = props.textMode, popoverMode = props.popoverMode, popoverTriangleComponent = props.popoverTriangleComponent, floatingCommentDialog = props.floatingCommentDialog, moderatorMode = props.moderatorMode, streamMode = props.streamMode, signInButton = props.signInButton, upgradeButton = props.upgradeButton, attachments = props.attachments, recordings = props.recordings, reactions = props.reactions, deviceInfo = props.deviceInfo, commentIndex = props.commentIndex, dialogOnHover = props.dialogOnHover, dialogOnTargetElementClick = props.dialogOnTargetElementClick, priority = props.priority, inboxMode = props.inboxMode, suggestionMode = props.suggestionMode, mobileMode = props.mobileMode, inlineCommentMode = props.inlineCommentMode, privateCommentMode = props.privateCommentMode, minimap = props.minimap, persistentCommentMode = props.persistentCommentMode, ghostComments = props.ghostComments, ghostCommentsIndicator = props.ghostCommentsIndicator, commentsOnDom = props.commentsOnDom, commentTool = props.commentTool, sidebarButtonOnCommentDialog = props.sidebarButtonOnCommentDialog, scrollToComponent = props.scrollToComponent, userMentions = props.userMentions, deleteOnBackspace = props.deleteOnBackspace, allowedElementIds = props.allowedElementIds, onCommentAdd = props.onCommentAdd, onCommentUpdate = props.onCommentUpdate, onCommentAccept = props.onCommentAccept, onCommentReject = props.onCommentReject, onSidebarButtonOnCommentDialogClick = props.onSidebarButtonOnCommentDialogClick, customStatus = props.customStatus, customPriority = props.customPriority, customCategory = props.customCategory, status = props.status, resolveButton = props.resolveButton, darkMode = props.darkMode, onCustomPinInject = props.onCustomPinInject, children = props.children;
|
|
195
|
+
var autoCategorize = props.autoCategorize, streamViewContainerId = props.streamViewContainerId, onSignIn = props.onSignIn, onUpgrade = props.onUpgrade, textMode = props.textMode, popoverMode = props.popoverMode, popoverTriangleComponent = props.popoverTriangleComponent, floatingCommentDialog = props.floatingCommentDialog, moderatorMode = props.moderatorMode, streamMode = props.streamMode, signInButton = props.signInButton, upgradeButton = props.upgradeButton, attachments = props.attachments, recordings = props.recordings, reactions = props.reactions, deviceInfo = props.deviceInfo, commentIndex = props.commentIndex, dialogOnHover = props.dialogOnHover, dialogOnTargetElementClick = props.dialogOnTargetElementClick, priority = props.priority, inboxMode = props.inboxMode, suggestionMode = props.suggestionMode, mobileMode = props.mobileMode, inlineCommentMode = props.inlineCommentMode, privateCommentMode = props.privateCommentMode, minimap = props.minimap, persistentCommentMode = props.persistentCommentMode, ghostComments = props.ghostComments, ghostCommentsIndicator = props.ghostCommentsIndicator, commentsOnDom = props.commentsOnDom, commentTool = props.commentTool, sidebarButtonOnCommentDialog = props.sidebarButtonOnCommentDialog, scrollToComponent = props.scrollToComponent, userMentions = props.userMentions, deleteOnBackspace = props.deleteOnBackspace, hotkey = props.hotkey, allowedElementIds = props.allowedElementIds, onCommentAdd = props.onCommentAdd, onCommentUpdate = props.onCommentUpdate, onCommentAccept = props.onCommentAccept, onCommentReject = props.onCommentReject, onSidebarButtonOnCommentDialogClick = props.onSidebarButtonOnCommentDialogClick, customStatus = props.customStatus, customPriority = props.customPriority, customCategory = props.customCategory, status = props.status, resolveButton = props.resolveButton, darkMode = props.darkMode, onCustomPinInject = props.onCustomPinInject, children = props.children;
|
|
182
196
|
var ref = React.useRef();
|
|
183
197
|
React.useEffect(function () {
|
|
184
198
|
if (ref.current) {
|
|
@@ -225,7 +239,7 @@ var SnippylyComments = function (props) {
|
|
|
225
239
|
});
|
|
226
240
|
}
|
|
227
241
|
}, []);
|
|
228
|
-
return (React__default["default"].createElement("velt-comments", { ref: ref, "auto-categorize": [true, false].includes(autoCategorize) ? (autoCategorize ? 'true' : 'false') : undefined, "data-stream-view-container-id": streamViewContainerId, "text-mode": [true, false].includes(textMode) ? (textMode ? 'true' : 'false') : undefined, "popover-mode": [true, false].includes(popoverMode) ? (popoverMode ? 'true' : 'false') : undefined, "popover-triangle-component": [true, false].includes(popoverTriangleComponent) ? (popoverTriangleComponent ? 'true' : 'false') : undefined, "floating-comment-dialog": [true, false].includes(floatingCommentDialog) ? (floatingCommentDialog ? 'true' : 'false') : undefined, "moderator-mode": [true, false].includes(moderatorMode) ? (moderatorMode ? 'true' : 'false') : undefined, "stream-mode": [true, false].includes(streamMode) ? (streamMode ? 'true' : 'false') : undefined, "sign-in-button": [true, false].includes(signInButton) ? (signInButton ? 'true' : 'false') : undefined, "upgrade-button": [true, false].includes(upgradeButton) ? (upgradeButton ? 'true' : 'false') : undefined, attachments: [true, false].includes(attachments) ? (attachments ? 'true' : 'false') : undefined, recordings: recordings, reactions: [true, false].includes(reactions) ? (reactions ? 'true' : 'false') : undefined, "device-info": [true, false].includes(deviceInfo) ? (deviceInfo ? 'true' : 'false') : undefined, "comment-index": [true, false].includes(commentIndex) ? (commentIndex ? 'true' : 'false') : undefined, "dialog-on-hover": [true, false].includes(dialogOnHover) ? (dialogOnHover ? 'true' : 'false') : undefined, "dialog-on-target-element-click": [true, false].includes(dialogOnTargetElementClick) ? (dialogOnTargetElementClick ? 'true' : 'false') : undefined, priority: [true, false].includes(priority) ? (priority ? 'true' : 'false') : undefined, status: [true, false].includes(status) ? (status ? 'true' : 'false') : undefined, "resolve-button": [true, false].includes(resolveButton) ? (resolveButton ? 'true' : 'false') : undefined, "inbox-mode": [true, false].includes(inboxMode) ? (inboxMode ? 'true' : 'false') : undefined, "suggestion-mode": [true, false].includes(suggestionMode) ? (suggestionMode ? 'true' : 'false') : undefined, "mobile-mode": [true, false].includes(mobileMode) ? (mobileMode ? 'true' : 'false') : undefined, "inline-comment-mode": [true, false].includes(inlineCommentMode) ? (inlineCommentMode ? 'true' : 'false') : undefined, "private-comment-mode": [true, false].includes(privateCommentMode) ? (privateCommentMode ? 'true' : 'false') : undefined, minimap: [true, false].includes(minimap) ? (minimap ? 'true' : 'false') : undefined, "persistent-comment-mode": [true, false].includes(persistentCommentMode) ? (persistentCommentMode ? 'true' : 'false') : undefined, "ghost-comments": [true, false].includes(ghostComments) ? (ghostComments ? 'true' : 'false') : undefined, "ghost-comments-indicator": [true, false].includes(ghostCommentsIndicator) ? (ghostCommentsIndicator ? 'true' : 'false') : undefined, "comments-on-dom": [true, false].includes(commentsOnDom) ? (commentsOnDom ? 'true' : 'false') : undefined, "comment-tool": [true, false].includes(commentTool) ? (commentTool ? 'true' : 'false') : undefined, "sidebar-button-on-comment-dialog": [true, false].includes(sidebarButtonOnCommentDialog) ? (sidebarButtonOnCommentDialog ? 'true' : 'false') : undefined, "scroll-to-component": [true, false].includes(scrollToComponent) ? (scrollToComponent ? 'true' : 'false') : undefined, "user-mentions": [true, false].includes(userMentions) ? (userMentions ? 'true' : 'false') : undefined, "delete-on-backspace": [true, false].includes(deleteOnBackspace) ? (deleteOnBackspace ? 'true' : 'false') : undefined, "allowed-element-ids": JSON.stringify(allowedElementIds), "custom-status": JSON.stringify(customStatus), "custom-priority": JSON.stringify(customPriority), "custom-category": JSON.stringify(customCategory), "dark-mode": [true, false].includes(darkMode) ? (darkMode ? 'true' : 'false') : undefined }, children));
|
|
242
|
+
return (React__default["default"].createElement("velt-comments", { ref: ref, "auto-categorize": [true, false].includes(autoCategorize) ? (autoCategorize ? 'true' : 'false') : undefined, "data-stream-view-container-id": streamViewContainerId, "text-mode": [true, false].includes(textMode) ? (textMode ? 'true' : 'false') : undefined, "popover-mode": [true, false].includes(popoverMode) ? (popoverMode ? 'true' : 'false') : undefined, "popover-triangle-component": [true, false].includes(popoverTriangleComponent) ? (popoverTriangleComponent ? 'true' : 'false') : undefined, "floating-comment-dialog": [true, false].includes(floatingCommentDialog) ? (floatingCommentDialog ? 'true' : 'false') : undefined, "moderator-mode": [true, false].includes(moderatorMode) ? (moderatorMode ? 'true' : 'false') : undefined, "stream-mode": [true, false].includes(streamMode) ? (streamMode ? 'true' : 'false') : undefined, "sign-in-button": [true, false].includes(signInButton) ? (signInButton ? 'true' : 'false') : undefined, "upgrade-button": [true, false].includes(upgradeButton) ? (upgradeButton ? 'true' : 'false') : undefined, attachments: [true, false].includes(attachments) ? (attachments ? 'true' : 'false') : undefined, recordings: recordings, reactions: [true, false].includes(reactions) ? (reactions ? 'true' : 'false') : undefined, "device-info": [true, false].includes(deviceInfo) ? (deviceInfo ? 'true' : 'false') : undefined, "comment-index": [true, false].includes(commentIndex) ? (commentIndex ? 'true' : 'false') : undefined, "dialog-on-hover": [true, false].includes(dialogOnHover) ? (dialogOnHover ? 'true' : 'false') : undefined, "dialog-on-target-element-click": [true, false].includes(dialogOnTargetElementClick) ? (dialogOnTargetElementClick ? 'true' : 'false') : undefined, priority: [true, false].includes(priority) ? (priority ? 'true' : 'false') : undefined, status: [true, false].includes(status) ? (status ? 'true' : 'false') : undefined, "resolve-button": [true, false].includes(resolveButton) ? (resolveButton ? 'true' : 'false') : undefined, "inbox-mode": [true, false].includes(inboxMode) ? (inboxMode ? 'true' : 'false') : undefined, "suggestion-mode": [true, false].includes(suggestionMode) ? (suggestionMode ? 'true' : 'false') : undefined, "mobile-mode": [true, false].includes(mobileMode) ? (mobileMode ? 'true' : 'false') : undefined, "inline-comment-mode": [true, false].includes(inlineCommentMode) ? (inlineCommentMode ? 'true' : 'false') : undefined, "private-comment-mode": [true, false].includes(privateCommentMode) ? (privateCommentMode ? 'true' : 'false') : undefined, minimap: [true, false].includes(minimap) ? (minimap ? 'true' : 'false') : undefined, "persistent-comment-mode": [true, false].includes(persistentCommentMode) ? (persistentCommentMode ? 'true' : 'false') : undefined, "ghost-comments": [true, false].includes(ghostComments) ? (ghostComments ? 'true' : 'false') : undefined, "ghost-comments-indicator": [true, false].includes(ghostCommentsIndicator) ? (ghostCommentsIndicator ? 'true' : 'false') : undefined, "comments-on-dom": [true, false].includes(commentsOnDom) ? (commentsOnDom ? 'true' : 'false') : undefined, "comment-tool": [true, false].includes(commentTool) ? (commentTool ? 'true' : 'false') : undefined, "sidebar-button-on-comment-dialog": [true, false].includes(sidebarButtonOnCommentDialog) ? (sidebarButtonOnCommentDialog ? 'true' : 'false') : undefined, "scroll-to-component": [true, false].includes(scrollToComponent) ? (scrollToComponent ? 'true' : 'false') : undefined, "user-mentions": [true, false].includes(userMentions) ? (userMentions ? 'true' : 'false') : undefined, "delete-on-backspace": [true, false].includes(deleteOnBackspace) ? (deleteOnBackspace ? 'true' : 'false') : undefined, hotkey: [true, false].includes(hotkey) ? (hotkey ? 'true' : 'false') : undefined, "allowed-element-ids": JSON.stringify(allowedElementIds), "custom-status": JSON.stringify(customStatus), "custom-priority": JSON.stringify(customPriority), "custom-category": JSON.stringify(customCategory), "dark-mode": [true, false].includes(darkMode) ? (darkMode ? 'true' : 'false') : undefined }, children));
|
|
229
243
|
};
|
|
230
244
|
|
|
231
245
|
var SnippylyCommentsSidebar = function (props) {
|
|
@@ -893,6 +907,82 @@ function useTagAnnotations(documentId, location) {
|
|
|
893
907
|
return data;
|
|
894
908
|
}
|
|
895
909
|
|
|
910
|
+
var sessionId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
911
|
+
var getSessionId = function () {
|
|
912
|
+
return sessionId;
|
|
913
|
+
};
|
|
914
|
+
var VELT_DEFAULT_LIVE_STATE_ID = 'velt-default-redux-live-state';
|
|
915
|
+
var createLiveStateMiddleware = function (config) {
|
|
916
|
+
if (config === void 0) { config = {}; }
|
|
917
|
+
var _a = config.allowedActionTypes, allowedActionTypes = _a === void 0 ? new Set() : _a, // Set of allowed action types for sync
|
|
918
|
+
_b = config.disabledActionTypes, // Set of allowed action types for sync
|
|
919
|
+
disabledActionTypes = _b === void 0 ? new Set() : _b, // Set of disabled action types for sync
|
|
920
|
+
_c = config.allowAction, // Set of disabled action types for sync
|
|
921
|
+
allowAction = _c === void 0 ? function () { return true; } : _c, // Callback to decide if an action should sync with live state
|
|
922
|
+
_d = config.liveStateDataId, // Callback to decide if an action should sync with live state
|
|
923
|
+
liveStateDataId = _d === void 0 ? VELT_DEFAULT_LIVE_STATE_ID : _d;
|
|
924
|
+
if (!liveStateDataId) {
|
|
925
|
+
liveStateDataId = VELT_DEFAULT_LIVE_STATE_ID;
|
|
926
|
+
}
|
|
927
|
+
return function (store) {
|
|
928
|
+
var isSdkInitialized = false;
|
|
929
|
+
var getDataSubscriptionSet = false;
|
|
930
|
+
var setupGetDataSubscription = function () {
|
|
931
|
+
var _a;
|
|
932
|
+
if (!getDataSubscriptionSet) {
|
|
933
|
+
getDataSubscriptionSet = true;
|
|
934
|
+
var liveStateSyncElement = (_a = window.Velt) === null || _a === void 0 ? void 0 : _a.getLiveStateSyncElement();
|
|
935
|
+
liveStateSyncElement.getLiveStateData(liveStateDataId).subscribe(function (data) {
|
|
936
|
+
// Dispatch action to update local state, marking it as remote
|
|
937
|
+
if (data) {
|
|
938
|
+
var sessionId_1 = getSessionId();
|
|
939
|
+
if (data.id === sessionId_1) {
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
else {
|
|
943
|
+
store.dispatch(__assign(__assign({}, data.action), { isRemote: true }));
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
var veltSdkInitializedListener = function () {
|
|
950
|
+
isSdkInitialized = true;
|
|
951
|
+
setupGetDataSubscription();
|
|
952
|
+
// Remove the event listener after it's triggered
|
|
953
|
+
window.removeEventListener(VELT_SDK_INIT_EVENT, veltSdkInitializedListener);
|
|
954
|
+
};
|
|
955
|
+
// Add the event listener for the veltSdkInitialized event
|
|
956
|
+
window.addEventListener(VELT_SDK_INIT_EVENT, veltSdkInitializedListener);
|
|
957
|
+
return function (next) { return function (action) {
|
|
958
|
+
// Always process the action locally
|
|
959
|
+
var result = next(action);
|
|
960
|
+
// Decide whether to sync this action with Firebase
|
|
961
|
+
if (isSdkInitialized && !action.isRemote && allowAction(action) && !disabledActionTypes.has(action.type) && (allowedActionTypes.size === 0 || allowedActionTypes.has(action.type))) {
|
|
962
|
+
logLiveState(action, liveStateDataId);
|
|
963
|
+
}
|
|
964
|
+
return result;
|
|
965
|
+
}; };
|
|
966
|
+
};
|
|
967
|
+
};
|
|
968
|
+
var logLiveState = function (action, liveStateDataId) {
|
|
969
|
+
var _a;
|
|
970
|
+
if (window.Velt) {
|
|
971
|
+
var sessionId_2 = getSessionId();
|
|
972
|
+
var liveStateElement = (_a = window === null || window === void 0 ? void 0 : window.Velt) === null || _a === void 0 ? void 0 : _a.getLiveStateSyncElement();
|
|
973
|
+
if (liveStateElement === null || liveStateElement === void 0 ? void 0 : liveStateElement.setLiveStateData) {
|
|
974
|
+
liveStateElement.setLiveStateData(liveStateDataId, {
|
|
975
|
+
id: sessionId_2,
|
|
976
|
+
action: action
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
liveStateElement.setLiveStateData(liveStateDataId, {
|
|
980
|
+
id: sessionId_2,
|
|
981
|
+
action: action
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
|
|
896
986
|
exports.VeltArrowTool = SnippylyArrowTool;
|
|
897
987
|
exports.VeltArrows = SnippylyArrows;
|
|
898
988
|
exports.VeltCommentBubble = SnippylyCommentBubble;
|
|
@@ -915,6 +1005,7 @@ exports.VeltTags = SnippylyTags;
|
|
|
915
1005
|
exports.VeltUserInviteTool = SnippylyUserInviteTool;
|
|
916
1006
|
exports.VeltUserRequestTool = SnippylyUserRequestTool;
|
|
917
1007
|
exports.VeltVideoPlayer = VeltVideoPlayer;
|
|
1008
|
+
exports.createLiveStateMiddleware = createLiveStateMiddleware;
|
|
918
1009
|
exports.useAIRewriterUtils = useAIRewriterUtils;
|
|
919
1010
|
exports.useAddLocation = useAddLocation;
|
|
920
1011
|
exports.useClient = useClient;
|