@snippyly/plugin-staging 1.0.1
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/constants.d.ts +4 -0
- package/constants.d.ts.map +1 -0
- package/constants.js +4 -0
- package/constants.js.map +1 -0
- package/environment.d.ts +3 -0
- package/environment.d.ts.map +1 -0
- package/environment.js +4 -0
- package/environment.js.map +1 -0
- package/package.json +12 -0
- package/snippyly-plugin.d.ts +39 -0
- package/snippyly-plugin.d.ts.map +1 -0
- package/snippyly-plugin.js +543 -0
- package/snippyly-plugin.js.map +1 -0
- package/utils.d.ts +6 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +82 -0
- package/utils.js.map +1 -0
package/constants.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,aAAa,kBAAkB,CAAC"}
|
package/constants.js
ADDED
package/constants.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC","sourcesContent":["export const REVIEW_MODE = 'review-mode';\r\nexport const REVIEW_DOC_ID = 'review-doc-id';\r\nexport const SNIPPYLY_USER = 'snippyly-user';"]}
|
package/environment.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,4CAA4C,CAAC;AAEjF,eAAO,MAAM,oBAAoB,OAAO,CAAC"}
|
package/environment.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,yCAAyC,CAAC;AACjF,kEAAkE;AAClE,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC","sourcesContent":["export const SNIPPYLY_LOGIN_BASE_URL = 'https://snippyly-login-staging.web.app/';\r\n// export const SNIPPYLY_LOGIN_BASE_URL = 'http://127.0.0.1:8080';\r\nexport const SNIPPYLY_SDK_STAGING = true;"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@snippyly/plugin-staging",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "snippyly.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"publish:plugin": "npm version patch && npm publish --access public"
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC"
|
|
12
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class SnippylyPlugin extends LitElement {
|
|
3
|
+
private _loadPlugin;
|
|
4
|
+
get loadPlugin(): boolean;
|
|
5
|
+
set loadPlugin(value: boolean);
|
|
6
|
+
comments: any[];
|
|
7
|
+
commentElement: any;
|
|
8
|
+
private _expanded;
|
|
9
|
+
get expanded(): boolean;
|
|
10
|
+
set expanded(value: boolean);
|
|
11
|
+
snippylyUser: any;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
staging: boolean;
|
|
14
|
+
menuOpenedId?: string;
|
|
15
|
+
copyLinkTooltip: string;
|
|
16
|
+
constructor();
|
|
17
|
+
setWindowEventListner: () => void;
|
|
18
|
+
urlChangeListener: () => void;
|
|
19
|
+
checkUrl: () => void;
|
|
20
|
+
loadPluginUI: () => void;
|
|
21
|
+
initializeSnippyly: () => Promise<void>;
|
|
22
|
+
identifySnippyly: () => Promise<void>;
|
|
23
|
+
getComments: () => void;
|
|
24
|
+
toggleCommentSidebar: () => void;
|
|
25
|
+
toggleSnippylyPluginToolbar: () => void;
|
|
26
|
+
loginWithGoogle: () => void;
|
|
27
|
+
removeSnippyly: () => Promise<void>;
|
|
28
|
+
signOutUser: () => Promise<void>;
|
|
29
|
+
toggleMenu: (id: string) => void;
|
|
30
|
+
copyLink: () => void;
|
|
31
|
+
static styles: import("lit").CSSResult;
|
|
32
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'snippyly-comment-tool': any;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=snippyly-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippyly-plugin.d.ts","sourceRoot":"","sources":["../src/snippyly-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAU5C,qBACa,cAAe,SAAQ,UAAU;IAE1C,OAAO,CAAC,WAAW,CAAS;IAC5B,IACW,UAAU,YAEpB;IACD,IAAW,UAAU,CAAC,KAAK,SAAA,EAO1B;IAEQ,QAAQ,EAAE,GAAG,EAAE,CAAM;IAErB,cAAc,EAAE,GAAG,CAAC;IAG7B,OAAO,CAAC,SAAS,CAAQ;IACzB,IAAW,QAAQ,YAElB;IACD,IAAW,QAAQ,CAAC,KAAK,SAAA,EAOxB;IAEQ,YAAY,EAAE,GAAG,CAAC;IAEf,MAAM,EAAG,MAAM,CAAC;IAEnB,OAAO,UAAwB;IAE/B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,eAAe,SAAe;;IAcvC,qBAAqB,aAKpB;IAED,iBAAiB,aAsBhB;IAED,QAAQ,aAgDP;IAED,YAAY,aAmBX;IAED,kBAAkB,sBAMjB;IAED,gBAAgB,sBAIf;IAED,WAAW,aAMV;IAED,oBAAoB,aAInB;IAED,2BAA2B,aAE1B;IAED,eAAe,aAEd;IAED,cAAc,sBAmBb;IAED,WAAW,sBAMV;IAED,UAAU,OAAQ,MAAM,UAMvB;IAED,QAAQ,aAMP;IAED,OAAgB,MAAM,0BA6NtB;IAES,MAAM;CAsElB;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,uBAAuB,EAAE,GAAG,CAAC;KAChC;CACJ"}
|
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
import { css, html, LitElement } from 'lit';
|
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
10
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
11
|
+
import * as Constants from './constants';
|
|
12
|
+
import { SNIPPYLY_LOGIN_BASE_URL, SNIPPYLY_SDK_STAGING } from './environment';
|
|
13
|
+
import { cyrb53, getLocalStorageData, loadSnippyly, removeLocalStorageData, setLocalStorageData } from './utils';
|
|
14
|
+
let SnippylyPlugin = class SnippylyPlugin extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this._loadPlugin = false;
|
|
18
|
+
this.comments = [];
|
|
19
|
+
this._expanded = true;
|
|
20
|
+
this.staging = SNIPPYLY_SDK_STAGING;
|
|
21
|
+
this.copyLinkTooltip = 'Copy Link';
|
|
22
|
+
this.setWindowEventListner = () => {
|
|
23
|
+
window.addEventListener('locationchange', () => {
|
|
24
|
+
this.checkUrl();
|
|
25
|
+
console.log('location change event', window.location.href);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
this.urlChangeListener = () => {
|
|
29
|
+
const oldPushState = history.pushState;
|
|
30
|
+
history.pushState = function pushState() {
|
|
31
|
+
// eslint-disable-next-line prefer-rest-params
|
|
32
|
+
const ret = oldPushState.apply(this, arguments);
|
|
33
|
+
window.dispatchEvent(new Event('pushstate'));
|
|
34
|
+
window.dispatchEvent(new Event('locationchange'));
|
|
35
|
+
return ret;
|
|
36
|
+
};
|
|
37
|
+
const oldReplaceState = history.replaceState;
|
|
38
|
+
history.replaceState = function replaceState() {
|
|
39
|
+
// eslint-disable-next-line prefer-rest-params
|
|
40
|
+
const ret = oldReplaceState.apply(this, arguments);
|
|
41
|
+
window.dispatchEvent(new Event('replacestate'));
|
|
42
|
+
window.dispatchEvent(new Event('locationchange'));
|
|
43
|
+
return ret;
|
|
44
|
+
};
|
|
45
|
+
window.addEventListener('popstate', () => {
|
|
46
|
+
window.dispatchEvent(new Event('locationchange'));
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
this.checkUrl = () => {
|
|
50
|
+
try {
|
|
51
|
+
console.log('url in checkUrl', window.location.href);
|
|
52
|
+
const url = new URL(document.location);
|
|
53
|
+
const params = url.searchParams;
|
|
54
|
+
if (params.has("snippyly_google_token")) {
|
|
55
|
+
console.log('token', params.get("snippyly_google_token"));
|
|
56
|
+
const user = JSON.parse(atob(params.get("snippyly_google_token")));
|
|
57
|
+
const snippylyUser = {};
|
|
58
|
+
snippylyUser.userId = user.uid;
|
|
59
|
+
snippylyUser.name = user.displayName;
|
|
60
|
+
snippylyUser.email = user.email;
|
|
61
|
+
snippylyUser.photoUrl = user === null || user === void 0 ? void 0 : user.photoURL;
|
|
62
|
+
snippylyUser.contacts = window.SNIPPYLY_USER_CONTACTS || [];
|
|
63
|
+
// localStorage.setItem(Constants.SNIPPYLY_USER, JSON.stringify(snippylyUser))
|
|
64
|
+
setLocalStorageData(Constants.SNIPPYLY_USER, JSON.stringify(snippylyUser), true);
|
|
65
|
+
params.delete("snippyly_google_token");
|
|
66
|
+
window.history.replaceState({}, document.title, url.href);
|
|
67
|
+
}
|
|
68
|
+
if (params.has(Constants.REVIEW_MODE)) {
|
|
69
|
+
// sessionStorage.setItem(Constants.REVIEW_MODE, 'true');
|
|
70
|
+
setLocalStorageData(Constants.REVIEW_MODE, 'true', false, 'sessionStorage');
|
|
71
|
+
if (params.has(Constants.REVIEW_DOC_ID)) {
|
|
72
|
+
this.loadPluginUI();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// generate doc id and set it in params
|
|
76
|
+
const tempUrl = new URL(document.location);
|
|
77
|
+
tempUrl.searchParams.delete(Constants.REVIEW_MODE);
|
|
78
|
+
const docId = cyrb53(tempUrl.href);
|
|
79
|
+
params.append(Constants.REVIEW_DOC_ID, `${docId}`);
|
|
80
|
+
window.history.replaceState({}, document.title, url.href);
|
|
81
|
+
this.loadPluginUI();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// check if review mode is there in session storage
|
|
86
|
+
if (getLocalStorageData(Constants.REVIEW_MODE, false, 'sessionStorage')) {
|
|
87
|
+
const tempUrl = new URL(document.location);
|
|
88
|
+
tempUrl.searchParams.delete(Constants.REVIEW_MODE);
|
|
89
|
+
params.append(Constants.REVIEW_MODE, 'true');
|
|
90
|
+
const docId = cyrb53(tempUrl.href);
|
|
91
|
+
params.append(Constants.REVIEW_DOC_ID, `${docId}`);
|
|
92
|
+
window.history.replaceState({}, document.title, url.href);
|
|
93
|
+
this.loadPluginUI();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
console.warn('Error in checkUrl: ', err);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
this.loadPluginUI = () => {
|
|
102
|
+
this.loadPlugin = true;
|
|
103
|
+
const commentTool = document.createElement('snippyly-comments');
|
|
104
|
+
window.document.body.appendChild(commentTool);
|
|
105
|
+
const commentSidebar = document.createElement('snippyly-comments-sidebar');
|
|
106
|
+
window.document.body.appendChild(commentSidebar);
|
|
107
|
+
const cursorTag = document.createElement('snippyly-cursor');
|
|
108
|
+
window.document.body.appendChild(cursorTag);
|
|
109
|
+
loadSnippyly(undefined, this.staging, () => {
|
|
110
|
+
if (window.Snippyly) {
|
|
111
|
+
console.log('snippyly', Snippyly);
|
|
112
|
+
this.initializeSnippyly();
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
this.initializeSnippyly = async () => {
|
|
117
|
+
await (Snippyly === null || Snippyly === void 0 ? void 0 : Snippyly.init("UnHxMCCFcclkP4bErBL1"));
|
|
118
|
+
this.commentElement = Snippyly === null || Snippyly === void 0 ? void 0 : Snippyly.getCommentElement();
|
|
119
|
+
if (getLocalStorageData(Constants.SNIPPYLY_USER, true)) {
|
|
120
|
+
this.identifySnippyly();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
this.identifySnippyly = async () => {
|
|
124
|
+
this.snippylyUser = JSON.parse(getLocalStorageData(Constants.SNIPPYLY_USER, true));
|
|
125
|
+
await Snippyly.identify(this.snippylyUser);
|
|
126
|
+
this.getComments();
|
|
127
|
+
};
|
|
128
|
+
this.getComments = () => {
|
|
129
|
+
if (this.commentElement) {
|
|
130
|
+
this.commentElement.getAllCommentPinAnnotationsOnCurrentDocument().subscribe((comments) => {
|
|
131
|
+
this.comments = comments;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
this.toggleCommentSidebar = () => {
|
|
136
|
+
if (this.commentElement) {
|
|
137
|
+
this.commentElement.toggleCommentSidebar();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
this.toggleSnippylyPluginToolbar = () => {
|
|
141
|
+
this.expanded = !this.expanded;
|
|
142
|
+
};
|
|
143
|
+
this.loginWithGoogle = () => {
|
|
144
|
+
window.open(`${SNIPPYLY_LOGIN_BASE_URL}?redirect_url=${encodeURIComponent(window.location.href)}`, '_self');
|
|
145
|
+
};
|
|
146
|
+
this.removeSnippyly = async () => {
|
|
147
|
+
try {
|
|
148
|
+
// removeGoogleLoginIframe();
|
|
149
|
+
// const element = document.getElementById('snippylyScript');
|
|
150
|
+
// if (element) {
|
|
151
|
+
// element.remove();
|
|
152
|
+
// }
|
|
153
|
+
// await Snippyly.signOutUser();
|
|
154
|
+
// sessionStorage.removeItem(Constants.REVIEW_MODE);
|
|
155
|
+
removeLocalStorageData(Constants.REVIEW_MODE, 'sessionStorage');
|
|
156
|
+
const url = new URL(document.location);
|
|
157
|
+
const params = url.searchParams;
|
|
158
|
+
params.delete(Constants.REVIEW_DOC_ID);
|
|
159
|
+
params.delete(Constants.REVIEW_MODE);
|
|
160
|
+
window.history.replaceState({}, document.title, url.href);
|
|
161
|
+
window.location.reload();
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
console.warn('Error in removeSnippyly: ', err);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this.signOutUser = async () => {
|
|
168
|
+
await Snippyly.signOutUser();
|
|
169
|
+
removeLocalStorageData(Constants.SNIPPYLY_USER);
|
|
170
|
+
this.snippylyUser = undefined;
|
|
171
|
+
window.open(`${SNIPPYLY_LOGIN_BASE_URL}?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`, '_self');
|
|
172
|
+
// window.location.reload();
|
|
173
|
+
};
|
|
174
|
+
this.toggleMenu = (id) => {
|
|
175
|
+
if (this.menuOpenedId === id) {
|
|
176
|
+
this.menuOpenedId = undefined;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this.menuOpenedId = id;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
this.copyLink = () => {
|
|
183
|
+
navigator.clipboard.writeText(window.location.href);
|
|
184
|
+
this.copyLinkTooltip = 'Copied!';
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
this.copyLinkTooltip = 'Copy Link';
|
|
187
|
+
}, 2000);
|
|
188
|
+
};
|
|
189
|
+
this.expanded = true;
|
|
190
|
+
this.setWindowEventListner();
|
|
191
|
+
this.urlChangeListener();
|
|
192
|
+
this.checkUrl();
|
|
193
|
+
if (SNIPPYLY_SDK_STAGING) {
|
|
194
|
+
console.log('*** Staging Mode ON! ***');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
get loadPlugin() {
|
|
198
|
+
return this._loadPlugin;
|
|
199
|
+
}
|
|
200
|
+
set loadPlugin(value) {
|
|
201
|
+
this._loadPlugin = value;
|
|
202
|
+
if (this.loadPlugin) {
|
|
203
|
+
this.classList.add('visible');
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this.classList.remove('visible');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
get expanded() {
|
|
210
|
+
return this._expanded;
|
|
211
|
+
}
|
|
212
|
+
set expanded(value) {
|
|
213
|
+
this._expanded = value;
|
|
214
|
+
if (this.expanded) {
|
|
215
|
+
this.classList.add('expanded');
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
this.classList.remove('expanded');
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
render() {
|
|
222
|
+
var _a, _b, _c, _d, _e, _f;
|
|
223
|
+
if (!this.loadPlugin) {
|
|
224
|
+
return html ``;
|
|
225
|
+
}
|
|
226
|
+
return html `
|
|
227
|
+
<div class="snippyly-plugin-container">
|
|
228
|
+
<div class="snippyly-btn-container snippyly-menu-trigger ${classMap({ opened: this.menuOpenedId === 'snippylyMenu' })}" id="snippylyMenu" @click=${() => this.toggleMenu("snippylyMenu")}>
|
|
229
|
+
<div class="btn snippyly-btn">
|
|
230
|
+
<svg class="snippyly-logo" width="19" height="18" viewBox="0 0 19 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
231
|
+
<path d="M7.27564 0.223149C6.79031 0.00346224 6.25358 -0.0557657 5.73589 0.0532382C5.21819 0.162242 4.74372 0.434385 4.37475 0.833949C3.99784 1.2249 3.74112 1.72714 3.63818 2.275C3.53523 2.82287 3.59085 3.39088 3.79775 3.90475C3.99487 4.42252 4.33503 4.86527 4.77372 5.17507C5.21241 5.48487 5.72921 5.64732 6.25653 5.64115H8.91823V2.82595C8.92404 2.26743 8.77031 1.72008 8.4772 1.25563C8.1841 0.791185 7.76528 0.431303 7.27564 0.223149Z" fill="#FFCB00"/>
|
|
232
|
+
<path d="M16.9736 3.72115C16.3509 3.06258 15.5579 2.61408 14.6946 2.43229C13.8313 2.25049 12.9365 2.34355 12.1231 2.69972C11.3097 3.05588 10.6143 3.65918 10.1246 4.43343C9.63489 5.20769 9.37289 6.11818 9.37167 7.04995V11.7611H13.8313C14.714 11.771 15.5791 11.4985 16.3131 10.9793C17.0471 10.46 17.616 9.7183 17.9451 8.85115C18.2892 7.9918 18.3806 7.04259 18.2072 6.12744C18.0339 5.21229 17.604 4.3737 16.9736 3.72115Z" fill="#FF7162"/>
|
|
233
|
+
<path d="M14.4933 13.9835C14.2962 13.4652 13.956 13.0218 13.5172 12.7114C13.0783 12.401 12.5612 12.2379 12.0334 12.2435H9.37167V15.0611C9.36611 15.6198 9.52006 16.1671 9.81336 16.6316C10.1067 17.096 10.5256 17.4558 11.0154 17.6639C11.3431 17.8099 11.6949 17.8853 12.0504 17.8859C12.4867 17.8813 12.9153 17.7635 13.2987 17.5429C13.682 17.3223 14.0085 17.0057 14.2496 16.6206C14.4906 16.2356 14.6388 15.7939 14.6813 15.3342C14.7238 14.8745 14.6593 14.4107 14.4933 13.9835Z" fill="#0DCF82"/>
|
|
234
|
+
<path d="M0.351589 9.03355C0.00514201 9.8932 -0.0880133 10.8436 0.0843205 11.7602C0.256654 12.6768 0.686445 13.517 1.31742 14.1708C1.72451 14.6098 2.20989 14.9589 2.74541 15.1979C3.28094 15.4368 3.85595 15.5608 4.4371 15.5628C5.03193 15.5613 5.62062 15.4353 6.16924 15.192C6.9885 14.8437 7.68929 14.2415 8.17981 13.4645C8.67033 12.6874 8.92771 11.7717 8.91823 10.8372V6.12115H4.46544C3.58239 6.11147 2.71718 6.38434 1.98312 6.90402C1.24906 7.4237 0.680388 8.16595 0.351589 9.03355Z" fill="#A259FE"/>
|
|
235
|
+
</svg>
|
|
236
|
+
<svg width="8" height="5" viewBox="0 0 8 5" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
237
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.646 4.354L0.645996 1.354L1.354 0.646004L4 3.293L6.646 0.646004L7.354 1.354L4.354 4.354L4 4.707L3.646 4.354Z" fill="#5B5B5B"/>
|
|
238
|
+
</svg>
|
|
239
|
+
</div>
|
|
240
|
+
<div class="snippyly-menu">
|
|
241
|
+
<div class="menu-item" @click=${() => this.toggleSnippylyPluginToolbar()}>${this.expanded ? 'Hide Toolbar' : 'Show Toolbar'}</div>
|
|
242
|
+
<div class="menu-item" @click=${() => this.removeSnippyly()}>Exit Review Mode</div>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
${this.expanded ?
|
|
246
|
+
html `
|
|
247
|
+
<div class="btn comment-tool-btn ${classMap({ disabled: !((_a = this.snippylyUser) === null || _a === void 0 ? void 0 : _a.userId) })}">
|
|
248
|
+
<snippyly-comment-tool class="custom-tool">
|
|
249
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="btn comment-btn">
|
|
250
|
+
<path d="M1.944 16.75L3.64 13.992L3.927 13.527L3.69 13.034C3.225 12.083 2.993 11.124 3 10C3 6.134 6.134 3 10 3C13.866 3 17 6.134 17 10C17 13.866 13.866 17 10 17C8.86 17.007 7.888 16.768 6.926 16.291L6.658 16.16L6.362 16.197L1.944 16.749V16.75ZM6.487 17.19C7.547 17.708 8.74 18 10 18C14.418 18 18 14.418 18 10C18 5.582 14.418 2 10 2C5.582 2 2 5.582 2 10C2 11.243 2.283 12.419 2.789 13.468L0.672 16.908L0 18L1.272 17.841L6.487 17.189V17.19Z" fill="#5B5B5B"/>
|
|
251
|
+
</svg>
|
|
252
|
+
</snippyly-comment-tool>
|
|
253
|
+
</div>
|
|
254
|
+
${((_b = this.comments) === null || _b === void 0 ? void 0 : _b.length) ?
|
|
255
|
+
html `
|
|
256
|
+
<div class="comments-counter" @click=${() => this.toggleCommentSidebar()}>
|
|
257
|
+
${(_c = this.comments) === null || _c === void 0 ? void 0 : _c.length} ${((_d = this.comments) === null || _d === void 0 ? void 0 : _d.length) === 1 ? 'Comment' : 'Comments'}
|
|
258
|
+
</div>
|
|
259
|
+
` : null}
|
|
260
|
+
<div class="spacer"></div>
|
|
261
|
+
<snippyly-presence max-users="4"></snippyly-presence>
|
|
262
|
+
${!((_e = this.snippylyUser) === null || _e === void 0 ? void 0 : _e.userId) ?
|
|
263
|
+
html `
|
|
264
|
+
<button class="btn primary-btn signin-btn" @click=${() => this.loginWithGoogle()}>
|
|
265
|
+
Sign in
|
|
266
|
+
</button>
|
|
267
|
+
` :
|
|
268
|
+
html `
|
|
269
|
+
<div class="snippyly-btn-container snippyly-menu-trigger">
|
|
270
|
+
<button class="btn primary-btn share-btn" @click=${() => this.copyLink()}>
|
|
271
|
+
Share
|
|
272
|
+
</button>
|
|
273
|
+
<div class="snippyly-menu">
|
|
274
|
+
<div class="menu-item">${this.copyLinkTooltip}</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
<div class="snippyly-btn-container snippyly-menu-trigger profile-img-container ${classMap({ opened: this.menuOpenedId === 'userMenu' })}" id="userMenu" @click=${() => this.toggleMenu("userMenu")}>
|
|
278
|
+
<img src=${(_f = this.snippylyUser) === null || _f === void 0 ? void 0 : _f.photoUrl} class="profile-img" />
|
|
279
|
+
<div class="snippyly-menu">
|
|
280
|
+
<div class="menu-item" @click=${() => this.signOutUser()}>Sign Out</div>
|
|
281
|
+
</div>
|
|
282
|
+
</div>
|
|
283
|
+
`}
|
|
284
|
+
`
|
|
285
|
+
: null}
|
|
286
|
+
</div>
|
|
287
|
+
`;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
SnippylyPlugin.styles = css `
|
|
291
|
+
:host(.visible) {
|
|
292
|
+
display: flex;
|
|
293
|
+
padding: 16px;
|
|
294
|
+
border: 1px solid rgba(0, 0, 0, 0.12);
|
|
295
|
+
background: white;
|
|
296
|
+
border-radius: 8px;
|
|
297
|
+
position: fixed;
|
|
298
|
+
bottom: 0px;
|
|
299
|
+
right: 0px;
|
|
300
|
+
margin: 24px;
|
|
301
|
+
height: 72px;
|
|
302
|
+
box-sizing: border-box;
|
|
303
|
+
align-items: center;
|
|
304
|
+
z-index: 999999995;
|
|
305
|
+
box-shadow: 0 1rem 3rem #0000002d;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
:host(.expanded) {
|
|
309
|
+
min-width: 450px;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.snippyly-plugin-container {
|
|
313
|
+
display: flex;
|
|
314
|
+
align-items: center;
|
|
315
|
+
width: 100%;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.snippyly-btn, .comment-tool-btn {
|
|
319
|
+
height: 28px;
|
|
320
|
+
padding: 8px;
|
|
321
|
+
border-radius: 8px;
|
|
322
|
+
cursor: pointer;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.snippyly-btn:hover, .comment-tool-btn:not(.disabled):hover, .comments-counter:hover {
|
|
326
|
+
background: #f0f0f0;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.snippyly-btn {
|
|
330
|
+
display: flex;
|
|
331
|
+
align-items: center;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.snippyly-logo {
|
|
335
|
+
margin-right: 8px;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.comment-tool-btn, .comment-tool-btn .custom-btn-container {
|
|
339
|
+
display: flex;
|
|
340
|
+
align-items: center;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.comment-tool-btn.disabled, .comment-tool-btn.disabled .btn {
|
|
344
|
+
cursor: not-allowed;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.comment-tool-btn.disabled .comment-btn path {
|
|
348
|
+
fill: #979797;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.comments-counter {
|
|
352
|
+
border: 1px solid #B6B1B1;
|
|
353
|
+
border-radius: 6px;
|
|
354
|
+
padding: 8px;
|
|
355
|
+
cursor: pointer;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.btn {
|
|
359
|
+
cursor: pointer;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.primary-btn {
|
|
363
|
+
height: 36px;
|
|
364
|
+
background: rgb(24, 160, 251);
|
|
365
|
+
border-radius: 6px;
|
|
366
|
+
border: 0;
|
|
367
|
+
box-shadow: none;
|
|
368
|
+
outline: none;
|
|
369
|
+
padding: 0 12px;
|
|
370
|
+
color: white;
|
|
371
|
+
/* margin: 0 12px; */
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.profile-img-container {
|
|
375
|
+
display: flex;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.profile-img {
|
|
379
|
+
width: 36px;
|
|
380
|
+
height: 36px;
|
|
381
|
+
border-radius: 50px;
|
|
382
|
+
cursor: pointer;
|
|
383
|
+
/* margin: 0 12px; */
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.snippyly-plugin-container > * {
|
|
387
|
+
margin: 0 6px;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.snippyly-plugin-container > *:first-child {
|
|
391
|
+
margin-left: 0px !important;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.snippyly-plugin-container > *:last-child {
|
|
395
|
+
margin-right: 0px !important;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.spacer {
|
|
399
|
+
flex: 1 0 auto;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.snippyly-menu-trigger {
|
|
403
|
+
position: relative;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.snippyly-menu {
|
|
407
|
+
position: absolute;
|
|
408
|
+
background: black;
|
|
409
|
+
color: white;
|
|
410
|
+
top: -64px;
|
|
411
|
+
left: 50%;
|
|
412
|
+
white-space: nowrap;
|
|
413
|
+
/* width: 150px; */
|
|
414
|
+
transform: translateX(-50%);
|
|
415
|
+
display: none;
|
|
416
|
+
border-radius: 4px;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.snippyly-menu:after {
|
|
420
|
+
content: '';
|
|
421
|
+
position: absolute;
|
|
422
|
+
display: block;
|
|
423
|
+
width: 0px;
|
|
424
|
+
z-index: 1;
|
|
425
|
+
border-style: solid;
|
|
426
|
+
border-color: rgb(0, 0, 0) transparent;
|
|
427
|
+
border-width: 12px 8px 0px;
|
|
428
|
+
bottom: -12px;
|
|
429
|
+
left: 50%;
|
|
430
|
+
transform: translateX(-50%);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.snippyly-menu-trigger:hover .snippyly-menu, .snippyly-menu-trigger.opened .snippyly-menu {
|
|
434
|
+
display: block;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
:host(.expanded) #snippylyMenu.snippyly-menu-trigger .snippyly-menu:after {
|
|
438
|
+
left: 32px;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
:host(:not(.expanded)) #snippylyMenu.snippyly-menu-trigger .snippyly-menu {
|
|
442
|
+
left: -20px;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
:host(.expanded) #snippylyMenu.snippyly-menu-trigger .snippyly-menu {
|
|
446
|
+
left: 48px;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
#snippylyMenu.snippyly-menu-trigger .snippyly-menu {
|
|
450
|
+
top: -100px;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
:host(:not(.expanded)) #snippylyMenu.snippyly-menu-trigger .snippyly-menu:after {
|
|
454
|
+
left: unset;
|
|
455
|
+
right: 24px;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.menu-item {
|
|
459
|
+
padding: 8px;
|
|
460
|
+
cursor: pointer;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.s-presence-container {
|
|
464
|
+
display: inline-flex;
|
|
465
|
+
flex-direction: row-reverse;
|
|
466
|
+
align-items: center;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.s-presence-avatar {
|
|
470
|
+
position: relative;
|
|
471
|
+
box-shadow: 0px 0px 0px 3px;
|
|
472
|
+
border-radius: 50%;
|
|
473
|
+
overflow: hidden;
|
|
474
|
+
width: 24px;
|
|
475
|
+
height: 24px;
|
|
476
|
+
display: flex;
|
|
477
|
+
align-items: center;
|
|
478
|
+
justify-content: center;
|
|
479
|
+
font-size: 12px;
|
|
480
|
+
// background-color: white;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.s-presence-avatar.more-users {
|
|
484
|
+
background: #4578a7;
|
|
485
|
+
box-shadow: 0px 0px 0px 3px #4578a7;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.s-presence-avatar:not(:last-child):not(.more-users) {
|
|
489
|
+
margin-left: -6px !important;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.s-presence-avatar-image {
|
|
493
|
+
width: 100%;
|
|
494
|
+
height: auto;
|
|
495
|
+
display: block;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.s-presence-avatar-image-small {
|
|
499
|
+
width: 1.6rem;
|
|
500
|
+
height: auto;
|
|
501
|
+
display: block;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.s-presence-avatar-initial {
|
|
505
|
+
color: white;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.away {
|
|
509
|
+
filter: grayscale(1);
|
|
510
|
+
}
|
|
511
|
+
`;
|
|
512
|
+
__decorate([
|
|
513
|
+
state()
|
|
514
|
+
], SnippylyPlugin.prototype, "loadPlugin", null);
|
|
515
|
+
__decorate([
|
|
516
|
+
state()
|
|
517
|
+
], SnippylyPlugin.prototype, "comments", void 0);
|
|
518
|
+
__decorate([
|
|
519
|
+
state()
|
|
520
|
+
], SnippylyPlugin.prototype, "commentElement", void 0);
|
|
521
|
+
__decorate([
|
|
522
|
+
state()
|
|
523
|
+
], SnippylyPlugin.prototype, "_expanded", void 0);
|
|
524
|
+
__decorate([
|
|
525
|
+
state()
|
|
526
|
+
], SnippylyPlugin.prototype, "snippylyUser", void 0);
|
|
527
|
+
__decorate([
|
|
528
|
+
property()
|
|
529
|
+
], SnippylyPlugin.prototype, "apiKey", void 0);
|
|
530
|
+
__decorate([
|
|
531
|
+
state()
|
|
532
|
+
], SnippylyPlugin.prototype, "staging", void 0);
|
|
533
|
+
__decorate([
|
|
534
|
+
state()
|
|
535
|
+
], SnippylyPlugin.prototype, "menuOpenedId", void 0);
|
|
536
|
+
__decorate([
|
|
537
|
+
state()
|
|
538
|
+
], SnippylyPlugin.prototype, "copyLinkTooltip", void 0);
|
|
539
|
+
SnippylyPlugin = __decorate([
|
|
540
|
+
customElement('snippyly-plugin')
|
|
541
|
+
], SnippylyPlugin);
|
|
542
|
+
export { SnippylyPlugin };
|
|
543
|
+
//# sourceMappingURL=snippyly-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippyly-plugin.js","sourceRoot":"","sources":["../src/snippyly-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CA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AAE;8CAAiB;AAEnB;IAAR,KAAK,EAAE;+CAAgC;AAE/B;IAAR,KAAK,EAAE;oDAAuB;AAEtB;IAAR,KAAK,EAAE;uDAA+B;AA1C9B,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAohB1B;SAphBY,cAAc","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { css, html, LitElement } from 'lit';\r\nimport { customElement, property, state } from 'lit/decorators.js';\r\nimport { classMap } from 'lit/directives/class-map.js';\r\nimport * as Constants from './constants';\r\nimport { SNIPPYLY_LOGIN_BASE_URL, SNIPPYLY_SDK_STAGING } from './environment';\r\nimport { cyrb53, getLocalStorageData, loadSnippyly, removeLocalStorageData, setLocalStorageData } from './utils';\r\n\r\n// eslint-disable-next-line no-var\r\ndeclare var Snippyly: unknown | any;\r\n\r\n@customElement('snippyly-plugin')\r\nexport class SnippylyPlugin extends LitElement {\r\n\r\n private _loadPlugin = false;\r\n @state()\r\n public get loadPlugin() {\r\n return this._loadPlugin;\r\n }\r\n public set loadPlugin(value) {\r\n this._loadPlugin = value;\r\n if (this.loadPlugin) {\r\n this.classList.add('visible');\r\n } else {\r\n this.classList.remove('visible');\r\n }\r\n }\r\n\r\n @state() comments: any[] = [];\r\n\r\n @state() commentElement: any;\r\n\r\n @state()\r\n private _expanded = true;\r\n public get expanded() {\r\n return this._expanded;\r\n }\r\n public set expanded(value) {\r\n this._expanded = value;\r\n if (this.expanded) {\r\n this.classList.add('expanded');\r\n } else {\r\n this.classList.remove('expanded');\r\n }\r\n }\r\n\r\n @state() snippylyUser: any;\r\n\r\n @property() apiKey!: string;\r\n\r\n @state() staging = SNIPPYLY_SDK_STAGING;\r\n\r\n @state() menuOpenedId?: string;\r\n\r\n @state() copyLinkTooltip = 'Copy Link';\r\n\r\n constructor() {\r\n super();\r\n this.expanded = true;\r\n this.setWindowEventListner();\r\n this.urlChangeListener();\r\n this.checkUrl();\r\n\r\n if (SNIPPYLY_SDK_STAGING) {\r\n console.log('*** Staging Mode ON! ***');\r\n }\r\n }\r\n\r\n setWindowEventListner = () => {\r\n window.addEventListener('locationchange', () => {\r\n this.checkUrl();\r\n console.log('location change event', window.location.href);\r\n });\r\n }\r\n\r\n urlChangeListener = () => {\r\n const oldPushState = history.pushState;\r\n history.pushState = function pushState() {\r\n // eslint-disable-next-line prefer-rest-params\r\n const ret = oldPushState.apply(this, arguments as never);\r\n window.dispatchEvent(new Event('pushstate'));\r\n window.dispatchEvent(new Event('locationchange'));\r\n return ret;\r\n };\r\n\r\n const oldReplaceState = history.replaceState;\r\n history.replaceState = function replaceState() {\r\n // eslint-disable-next-line prefer-rest-params\r\n const ret = oldReplaceState.apply(this, arguments as never);\r\n window.dispatchEvent(new Event('replacestate'));\r\n window.dispatchEvent(new Event('locationchange'));\r\n return ret;\r\n };\r\n\r\n window.addEventListener('popstate', () => {\r\n window.dispatchEvent(new Event('locationchange'));\r\n });\r\n }\r\n\r\n checkUrl = () => {\r\n try {\r\n console.log('url in checkUrl', window.location.href);\r\n const url = new URL(document.location as unknown as URL);\r\n const params = url.searchParams;\r\n if (params.has(\"snippyly_google_token\")) {\r\n console.log('token', params.get(\"snippyly_google_token\"))\r\n const user = JSON.parse(atob(params.get(\"snippyly_google_token\")!));\r\n const snippylyUser: any = {};\r\n snippylyUser.userId = user.uid;\r\n snippylyUser.name = user.displayName;\r\n snippylyUser.email = user.email;\r\n snippylyUser.photoUrl = user?.photoURL;\r\n snippylyUser.contacts = (window as any).SNIPPYLY_USER_CONTACTS || [];\r\n // localStorage.setItem(Constants.SNIPPYLY_USER, JSON.stringify(snippylyUser))\r\n setLocalStorageData(Constants.SNIPPYLY_USER, JSON.stringify(snippylyUser), true);\r\n params.delete(\"snippyly_google_token\");\r\n window.history.replaceState({}, document.title, url.href);\r\n }\r\n if (params.has(Constants.REVIEW_MODE)) {\r\n // sessionStorage.setItem(Constants.REVIEW_MODE, 'true');\r\n setLocalStorageData(Constants.REVIEW_MODE, 'true', false, 'sessionStorage');\r\n if (params.has(Constants.REVIEW_DOC_ID)) {\r\n this.loadPluginUI();\r\n } else {\r\n // generate doc id and set it in params\r\n const tempUrl = new URL(document.location as unknown as URL);\r\n tempUrl.searchParams.delete(Constants.REVIEW_MODE);\r\n const docId = cyrb53(tempUrl.href);\r\n params.append(Constants.REVIEW_DOC_ID, `${docId}`);\r\n window.history.replaceState({}, document.title, url.href);\r\n this.loadPluginUI();\r\n }\r\n } else {\r\n // check if review mode is there in session storage\r\n if (getLocalStorageData(Constants.REVIEW_MODE, false, 'sessionStorage')) {\r\n const tempUrl = new URL(document.location as unknown as URL);\r\n tempUrl.searchParams.delete(Constants.REVIEW_MODE);\r\n params.append(Constants.REVIEW_MODE, 'true');\r\n const docId = cyrb53(tempUrl.href);\r\n params.append(Constants.REVIEW_DOC_ID, `${docId}`);\r\n window.history.replaceState({}, document.title, url.href);\r\n this.loadPluginUI();\r\n }\r\n }\r\n } catch (err) {\r\n console.warn('Error in checkUrl: ', err);\r\n }\r\n }\r\n\r\n loadPluginUI = () => {\r\n this.loadPlugin = true;\r\n\r\n const commentTool = document.createElement('snippyly-comments');\r\n window.document.body.appendChild(commentTool);\r\n\r\n const commentSidebar = document.createElement('snippyly-comments-sidebar');\r\n window.document.body.appendChild(commentSidebar);\r\n\r\n const cursorTag = document.createElement('snippyly-cursor');\r\n window.document.body.appendChild(cursorTag);\r\n\r\n loadSnippyly(undefined, this.staging, () => {\r\n if ((window as any).Snippyly) {\r\n console.log('snippyly', Snippyly);\r\n this.initializeSnippyly();\r\n }\r\n })\r\n\r\n }\r\n\r\n initializeSnippyly = async () => {\r\n await Snippyly?.init(\"UnHxMCCFcclkP4bErBL1\");\r\n this.commentElement = Snippyly?.getCommentElement();\r\n if (getLocalStorageData(Constants.SNIPPYLY_USER, true)) {\r\n this.identifySnippyly();\r\n }\r\n }\r\n\r\n identifySnippyly = async () => {\r\n this.snippylyUser = JSON.parse(getLocalStorageData(Constants.SNIPPYLY_USER, true)!);\r\n await Snippyly.identify(this.snippylyUser);\r\n this.getComments();\r\n }\r\n\r\n getComments = () => {\r\n if (this.commentElement) {\r\n this.commentElement.getAllCommentPinAnnotationsOnCurrentDocument().subscribe((comments: any) => {\r\n this.comments = comments;\r\n });\r\n }\r\n }\r\n\r\n toggleCommentSidebar = () => {\r\n if (this.commentElement) {\r\n this.commentElement.toggleCommentSidebar();\r\n }\r\n }\r\n\r\n toggleSnippylyPluginToolbar = () => {\r\n this.expanded = !this.expanded;\r\n }\r\n\r\n loginWithGoogle = () => {\r\n window.open(`${SNIPPYLY_LOGIN_BASE_URL}?redirect_url=${encodeURIComponent(window.location.href)}`, '_self')\r\n }\r\n\r\n removeSnippyly = async () => {\r\n try {\r\n // removeGoogleLoginIframe();\r\n // const element = document.getElementById('snippylyScript');\r\n // if (element) {\r\n // element.remove();\r\n // }\r\n // await Snippyly.signOutUser();\r\n // sessionStorage.removeItem(Constants.REVIEW_MODE);\r\n removeLocalStorageData(Constants.REVIEW_MODE, 'sessionStorage');\r\n const url = new URL(document.location as any);\r\n const params = url.searchParams;\r\n params.delete(Constants.REVIEW_DOC_ID);\r\n params.delete(Constants.REVIEW_MODE);\r\n window.history.replaceState({}, document.title, url.href);\r\n window.location.reload();\r\n } catch (err) {\r\n console.warn('Error in removeSnippyly: ', err);\r\n }\r\n }\r\n\r\n signOutUser = async () => {\r\n await Snippyly.signOutUser();\r\n removeLocalStorageData(Constants.SNIPPYLY_USER);\r\n this.snippylyUser = undefined;\r\n window.open(`${SNIPPYLY_LOGIN_BASE_URL}?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`, '_self')\r\n // window.location.reload();\r\n }\r\n\r\n toggleMenu = (id: string) => {\r\n if (this.menuOpenedId === id) {\r\n this.menuOpenedId = undefined;\r\n } else {\r\n this.menuOpenedId = id;\r\n }\r\n }\r\n\r\n copyLink = () => {\r\n navigator.clipboard.writeText(window.location.href);\r\n this.copyLinkTooltip = 'Copied!';\r\n setTimeout(() => {\r\n this.copyLinkTooltip = 'Copy Link';\r\n }, 2000);\r\n }\r\n\r\n static override styles = css`\r\n :host(.visible) {\r\n display: flex;\r\n padding: 16px;\r\n border: 1px solid rgba(0, 0, 0, 0.12);\r\n background: white;\r\n border-radius: 8px;\r\n position: fixed;\r\n bottom: 0px;\r\n right: 0px;\r\n margin: 24px;\r\n height: 72px;\r\n box-sizing: border-box;\r\n align-items: center;\r\n z-index: 999999995;\r\n box-shadow: 0 1rem 3rem #0000002d;\r\n }\r\n\r\n :host(.expanded) {\r\n min-width: 450px;\r\n }\r\n\r\n .snippyly-plugin-container {\r\n display: flex;\r\n align-items: center;\r\n width: 100%;\r\n }\r\n\r\n .snippyly-btn, .comment-tool-btn {\r\n height: 28px;\r\n padding: 8px;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n }\r\n\r\n .snippyly-btn:hover, .comment-tool-btn:not(.disabled):hover, .comments-counter:hover {\r\n background: #f0f0f0;\r\n }\r\n\r\n .snippyly-btn {\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .snippyly-logo {\r\n margin-right: 8px;\r\n }\r\n\r\n .comment-tool-btn, .comment-tool-btn .custom-btn-container {\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .comment-tool-btn.disabled, .comment-tool-btn.disabled .btn {\r\n cursor: not-allowed; \r\n }\r\n\r\n .comment-tool-btn.disabled .comment-btn path {\r\n fill: #979797;\r\n }\r\n\r\n .comments-counter {\r\n border: 1px solid #B6B1B1;\r\n border-radius: 6px;\r\n padding: 8px;\r\n cursor: pointer;\r\n }\r\n\r\n .btn {\r\n cursor: pointer;\r\n }\r\n\r\n .primary-btn {\r\n height: 36px;\r\n background: rgb(24, 160, 251);\r\n border-radius: 6px;\r\n border: 0;\r\n box-shadow: none;\r\n outline: none;\r\n padding: 0 12px;\r\n color: white;\r\n /* margin: 0 12px; */\r\n }\r\n \r\n .profile-img-container {\r\n display: flex;\r\n }\r\n\r\n .profile-img {\r\n width: 36px;\r\n height: 36px;\r\n border-radius: 50px;\r\n cursor: pointer;\r\n /* margin: 0 12px; */\r\n }\r\n\r\n .snippyly-plugin-container > * {\r\n margin: 0 6px;\r\n }\r\n\r\n .snippyly-plugin-container > *:first-child {\r\n margin-left: 0px !important;\r\n }\r\n\r\n .snippyly-plugin-container > *:last-child {\r\n margin-right: 0px !important;\r\n }\r\n\r\n .spacer {\r\n flex: 1 0 auto;\r\n }\r\n\r\n .snippyly-menu-trigger {\r\n position: relative;\r\n }\r\n\r\n .snippyly-menu {\r\n position: absolute;\r\n background: black;\r\n color: white;\r\n top: -64px;\r\n left: 50%;\r\n white-space: nowrap;\r\n /* width: 150px; */\r\n transform: translateX(-50%);\r\n display: none;\r\n border-radius: 4px;\r\n }\r\n\r\n .snippyly-menu:after {\r\n content: '';\r\n position: absolute;\r\n display: block;\r\n width: 0px;\r\n z-index: 1;\r\n border-style: solid;\r\n border-color: rgb(0, 0, 0) transparent;\r\n border-width: 12px 8px 0px;\r\n bottom: -12px;\r\n left: 50%;\r\n transform: translateX(-50%);\r\n }\r\n\r\n .snippyly-menu-trigger:hover .snippyly-menu, .snippyly-menu-trigger.opened .snippyly-menu {\r\n display: block;\r\n }\r\n\r\n :host(.expanded) #snippylyMenu.snippyly-menu-trigger .snippyly-menu:after {\r\n left: 32px;\r\n }\r\n\r\n :host(:not(.expanded)) #snippylyMenu.snippyly-menu-trigger .snippyly-menu {\r\n left: -20px;\r\n }\r\n\r\n :host(.expanded) #snippylyMenu.snippyly-menu-trigger .snippyly-menu {\r\n left: 48px;\r\n }\r\n\r\n #snippylyMenu.snippyly-menu-trigger .snippyly-menu {\r\n top: -100px;\r\n }\r\n\r\n :host(:not(.expanded)) #snippylyMenu.snippyly-menu-trigger .snippyly-menu:after {\r\n left: unset;\r\n right: 24px;\r\n }\r\n\r\n .menu-item {\r\n padding: 8px;\r\n cursor: pointer;\r\n }\r\n\r\n .s-presence-container {\r\n display: inline-flex;\r\n flex-direction: row-reverse;\r\n align-items: center;\r\n }\r\n\r\n .s-presence-avatar {\r\n position: relative;\r\n box-shadow: 0px 0px 0px 3px;\r\n border-radius: 50%;\r\n overflow: hidden;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n font-size: 12px;\r\n // background-color: white;\r\n }\r\n\r\n .s-presence-avatar.more-users {\r\n background: #4578a7;\r\n box-shadow: 0px 0px 0px 3px #4578a7;\r\n }\r\n\r\n .s-presence-avatar:not(:last-child):not(.more-users) {\r\n margin-left: -6px !important;\r\n }\r\n\r\n .s-presence-avatar-image {\r\n width: 100%;\r\n height: auto;\r\n display: block;\r\n }\r\n\r\n .s-presence-avatar-image-small {\r\n width: 1.6rem;\r\n height: auto;\r\n display: block;\r\n }\r\n\r\n .s-presence-avatar-initial {\r\n color: white;\r\n }\r\n\r\n .away {\r\n filter: grayscale(1);\r\n }\r\n `;\r\n\r\n override render() {\r\n if (!this.loadPlugin) {\r\n return html``;\r\n }\r\n return html`\r\n <div class=\"snippyly-plugin-container\">\r\n <div class=\"snippyly-btn-container snippyly-menu-trigger ${classMap({ opened: this.menuOpenedId === 'snippylyMenu' })}\" id=\"snippylyMenu\" @click=${() => this.toggleMenu(\"snippylyMenu\")}>\r\n <div class=\"btn snippyly-btn\">\r\n <svg class=\"snippyly-logo\" width=\"19\" height=\"18\" viewBox=\"0 0 19 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M7.27564 0.223149C6.79031 0.00346224 6.25358 -0.0557657 5.73589 0.0532382C5.21819 0.162242 4.74372 0.434385 4.37475 0.833949C3.99784 1.2249 3.74112 1.72714 3.63818 2.275C3.53523 2.82287 3.59085 3.39088 3.79775 3.90475C3.99487 4.42252 4.33503 4.86527 4.77372 5.17507C5.21241 5.48487 5.72921 5.64732 6.25653 5.64115H8.91823V2.82595C8.92404 2.26743 8.77031 1.72008 8.4772 1.25563C8.1841 0.791185 7.76528 0.431303 7.27564 0.223149Z\" fill=\"#FFCB00\"/>\r\n <path d=\"M16.9736 3.72115C16.3509 3.06258 15.5579 2.61408 14.6946 2.43229C13.8313 2.25049 12.9365 2.34355 12.1231 2.69972C11.3097 3.05588 10.6143 3.65918 10.1246 4.43343C9.63489 5.20769 9.37289 6.11818 9.37167 7.04995V11.7611H13.8313C14.714 11.771 15.5791 11.4985 16.3131 10.9793C17.0471 10.46 17.616 9.7183 17.9451 8.85115C18.2892 7.9918 18.3806 7.04259 18.2072 6.12744C18.0339 5.21229 17.604 4.3737 16.9736 3.72115Z\" fill=\"#FF7162\"/>\r\n <path d=\"M14.4933 13.9835C14.2962 13.4652 13.956 13.0218 13.5172 12.7114C13.0783 12.401 12.5612 12.2379 12.0334 12.2435H9.37167V15.0611C9.36611 15.6198 9.52006 16.1671 9.81336 16.6316C10.1067 17.096 10.5256 17.4558 11.0154 17.6639C11.3431 17.8099 11.6949 17.8853 12.0504 17.8859C12.4867 17.8813 12.9153 17.7635 13.2987 17.5429C13.682 17.3223 14.0085 17.0057 14.2496 16.6206C14.4906 16.2356 14.6388 15.7939 14.6813 15.3342C14.7238 14.8745 14.6593 14.4107 14.4933 13.9835Z\" fill=\"#0DCF82\"/>\r\n <path d=\"M0.351589 9.03355C0.00514201 9.8932 -0.0880133 10.8436 0.0843205 11.7602C0.256654 12.6768 0.686445 13.517 1.31742 14.1708C1.72451 14.6098 2.20989 14.9589 2.74541 15.1979C3.28094 15.4368 3.85595 15.5608 4.4371 15.5628C5.03193 15.5613 5.62062 15.4353 6.16924 15.192C6.9885 14.8437 7.68929 14.2415 8.17981 13.4645C8.67033 12.6874 8.92771 11.7717 8.91823 10.8372V6.12115H4.46544C3.58239 6.11147 2.71718 6.38434 1.98312 6.90402C1.24906 7.4237 0.680388 8.16595 0.351589 9.03355Z\" fill=\"#A259FE\"/>\r\n </svg>\r\n <svg width=\"8\" height=\"5\" viewBox=\"0 0 8 5\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M3.646 4.354L0.645996 1.354L1.354 0.646004L4 3.293L6.646 0.646004L7.354 1.354L4.354 4.354L4 4.707L3.646 4.354Z\" fill=\"#5B5B5B\"/>\r\n </svg>\r\n </div>\r\n <div class=\"snippyly-menu\">\r\n <div class=\"menu-item\" @click=${() => this.toggleSnippylyPluginToolbar()}>${this.expanded ? 'Hide Toolbar' : 'Show Toolbar'}</div>\r\n <div class=\"menu-item\" @click=${() => this.removeSnippyly()}>Exit Review Mode</div>\r\n </div>\r\n </div>\r\n ${this.expanded ?\r\n html`\r\n <div class=\"btn comment-tool-btn ${classMap({ disabled: !this.snippylyUser?.userId })}\">\r\n <snippyly-comment-tool class=\"custom-tool\">\r\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" class=\"btn comment-btn\">\r\n <path d=\"M1.944 16.75L3.64 13.992L3.927 13.527L3.69 13.034C3.225 12.083 2.993 11.124 3 10C3 6.134 6.134 3 10 3C13.866 3 17 6.134 17 10C17 13.866 13.866 17 10 17C8.86 17.007 7.888 16.768 6.926 16.291L6.658 16.16L6.362 16.197L1.944 16.749V16.75ZM6.487 17.19C7.547 17.708 8.74 18 10 18C14.418 18 18 14.418 18 10C18 5.582 14.418 2 10 2C5.582 2 2 5.582 2 10C2 11.243 2.283 12.419 2.789 13.468L0.672 16.908L0 18L1.272 17.841L6.487 17.189V17.19Z\" fill=\"#5B5B5B\"/>\r\n </svg>\r\n </snippyly-comment-tool>\r\n </div>\r\n ${this.comments?.length ?\r\n html`\r\n <div class=\"comments-counter\" @click=${() => this.toggleCommentSidebar()}>\r\n ${this.comments?.length} ${this.comments?.length === 1 ? 'Comment' : 'Comments'}\r\n </div>\r\n ` : null\r\n }\r\n <div class=\"spacer\"></div>\r\n <snippyly-presence max-users=\"4\"></snippyly-presence>\r\n ${!this.snippylyUser?.userId ?\r\n html`\r\n <button class=\"btn primary-btn signin-btn\" @click=${() => this.loginWithGoogle()}>\r\n Sign in\r\n </button>\r\n ` :\r\n html`\r\n <div class=\"snippyly-btn-container snippyly-menu-trigger\">\r\n <button class=\"btn primary-btn share-btn\" @click=${() => this.copyLink()}>\r\n Share\r\n </button>\r\n <div class=\"snippyly-menu\">\r\n <div class=\"menu-item\">${this.copyLinkTooltip}</div>\r\n </div>\r\n </div>\r\n <div class=\"snippyly-btn-container snippyly-menu-trigger profile-img-container ${classMap({ opened: this.menuOpenedId === 'userMenu' })}\" id=\"userMenu\" @click=${() => this.toggleMenu(\"userMenu\")}>\r\n <img src=${this.snippylyUser?.photoUrl} class=\"profile-img\" />\r\n <div class=\"snippyly-menu\">\r\n <div class=\"menu-item\" @click=${() => this.signOutUser()}>Sign Out</div>\r\n </div>\r\n </div>\r\n `\r\n }\r\n `\r\n : null\r\n }\r\n </div>\r\n `\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n 'snippyly-comment-tool': any;\r\n }\r\n}"]}
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const cyrb53: (str: string, seed?: number) => number;
|
|
2
|
+
export declare const loadSnippyly: (version: string | undefined, staging: boolean | undefined, callback: Function) => void;
|
|
3
|
+
export declare const setLocalStorageData: (key: string, value: string, encrypted?: boolean, storageType?: 'localStorage' | 'sessionStorage') => void;
|
|
4
|
+
export declare const getLocalStorageData: (key: string, encrypted?: boolean, storageType?: 'localStorage' | 'sessionStorage') => string | null;
|
|
5
|
+
export declare const removeLocalStorageData: (key: string, storageType?: 'localStorage' | 'sessionStorage') => void;
|
|
6
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/utils.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,QAAS,MAAM,0BAgBjC,CAAC;AAEF,eAAO,MAAM,YAAY,wEAAmD,QAAQ,SAmBnF,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAS,MAAM,SAAS,MAAM,qCAAkC,cAAc,GAAG,gBAAgB,SAWhI,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAS,MAAM,qCAAkC,cAAc,GAAG,gBAAgB,kBAajH,CAAA;AAED,eAAO,MAAM,sBAAsB,QAAS,MAAM,gBAAe,cAAc,GAAG,gBAAgB,SAUjG,CAAA"}
|
package/utils.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export const cyrb53 = (str, seed = 0) => {
|
|
2
|
+
try {
|
|
3
|
+
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
4
|
+
for (let i = 0, ch; i < str.length; i++) {
|
|
5
|
+
ch = str.charCodeAt(i);
|
|
6
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
7
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
8
|
+
}
|
|
9
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
10
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
11
|
+
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
console.warn('Error in cyrb53: ', err);
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const loadSnippyly = (version = 'latest', staging = false, callback) => {
|
|
19
|
+
console.log('load snippyly called');
|
|
20
|
+
const existingScript = document.getElementById('snippylyScript');
|
|
21
|
+
if (!existingScript) {
|
|
22
|
+
const script = document.createElement('script');
|
|
23
|
+
script.src = `https://cdn.jsdelivr.net/npm/@snippyly/sdk${staging ? '-staging' : ''}@${version || 'latest'}/snippyly.js`;
|
|
24
|
+
script.id = 'snippylyScript';
|
|
25
|
+
script.type = 'module';
|
|
26
|
+
document.body.appendChild(script);
|
|
27
|
+
script.onload = () => {
|
|
28
|
+
if (callback) {
|
|
29
|
+
callback();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (callback) {
|
|
35
|
+
callback();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const setLocalStorageData = (key, value, encrypted = false, storageType = 'localStorage') => {
|
|
40
|
+
try {
|
|
41
|
+
const data = encrypted ? btoa(value) : value;
|
|
42
|
+
if (storageType === 'localStorage') {
|
|
43
|
+
localStorage.setItem(key, data);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
sessionStorage.setItem(key, data);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.warn('Error in setLocalStorage: ', err);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export const getLocalStorageData = (key, encrypted = false, storageType = 'localStorage') => {
|
|
54
|
+
try {
|
|
55
|
+
let data = null;
|
|
56
|
+
if (storageType === 'localStorage') {
|
|
57
|
+
data = localStorage.getItem(key);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
data = sessionStorage.getItem(key);
|
|
61
|
+
}
|
|
62
|
+
return (data && encrypted) ? atob(data) : data;
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
console.warn('Error in getLocalStorage: ', err);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export const removeLocalStorageData = (key, storageType = 'localStorage') => {
|
|
70
|
+
try {
|
|
71
|
+
if (storageType === 'localStorage') {
|
|
72
|
+
localStorage.removeItem(key);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
sessionStorage.removeItem(key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
console.warn('Error in removeLocalStorageData: ', err);
|
|
80
|
+
}
|
|
81
|
+
};
|
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AC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;SACrC;KACJ;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;KACnD;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,SAAS,GAAG,KAAK,EAAE,cAAiD,cAAc,EAAE,EAAE;IACnI,IAAI;QACA,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,WAAW,KAAK,cAAc,EAAE;YAChC,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SACpC;aAAM;YACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SACtC;QACD,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAClD;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;KACf;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAE,cAAiD,cAAc,EAAE,EAAE;IACnH,IAAI;QACA,IAAI,WAAW,KAAK,cAAc,EAAE;YAChC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAChC;aAAM;YACH,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAClC;KACJ;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;KAC1D;AACL,CAAC,CAAA","sourcesContent":["export const cyrb53 = (str: string, seed = 0) => {\r\n try {\r\n let h1 = 0xdeadbeef ^ seed,\r\n h2 = 0x41c6ce57 ^ seed;\r\n for (let i = 0, ch; i < str.length; i++) {\r\n ch = str.charCodeAt(i);\r\n h1 = Math.imul(h1 ^ ch, 2654435761);\r\n h2 = Math.imul(h2 ^ ch, 1597334677);\r\n }\r\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);\r\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);\r\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\r\n } catch (err) {\r\n console.warn('Error in cyrb53: ', err);\r\n return 0;\r\n }\r\n};\r\n\r\nexport const loadSnippyly = (version = 'latest', staging = false, callback: Function) => {\r\n console.log('load snippyly called')\r\n const existingScript = document.getElementById('snippylyScript');\r\n if (!existingScript) {\r\n const script = document.createElement('script');\r\n script.src = `https://cdn.jsdelivr.net/npm/@snippyly/sdk${staging ? '-staging' : ''}@${version || 'latest'}/snippyly.js`;\r\n script.id = 'snippylyScript';\r\n script.type = 'module';\r\n document.body.appendChild(script);\r\n script.onload = () => {\r\n if (callback) {\r\n callback();\r\n }\r\n };\r\n } else {\r\n if (callback) {\r\n callback();\r\n }\r\n }\r\n};\r\n\r\nexport const setLocalStorageData = (key: string, value: string, encrypted = false, storageType: 'localStorage' | 'sessionStorage' = 'localStorage') => {\r\n try {\r\n const data = encrypted ? btoa(value) : value;\r\n if (storageType === 'localStorage') {\r\n localStorage.setItem(key, data);\r\n } else {\r\n sessionStorage.setItem(key, data);\r\n }\r\n } catch (err) {\r\n console.warn('Error in setLocalStorage: ', err);\r\n }\r\n}\r\n\r\nexport const getLocalStorageData = (key: string, encrypted = false, storageType: 'localStorage' | 'sessionStorage' = 'localStorage') => {\r\n try {\r\n let data = null;\r\n if (storageType === 'localStorage') {\r\n data = localStorage.getItem(key);\r\n } else {\r\n data = sessionStorage.getItem(key);\r\n }\r\n return (data && encrypted) ? atob(data) : data;\r\n } catch (err) {\r\n console.warn('Error in getLocalStorage: ', err);\r\n return null;\r\n }\r\n}\r\n\r\nexport const removeLocalStorageData = (key: string, storageType: 'localStorage' | 'sessionStorage' = 'localStorage') => {\r\n try {\r\n if (storageType === 'localStorage') {\r\n localStorage.removeItem(key);\r\n } else {\r\n sessionStorage.removeItem(key);\r\n }\r\n } catch (err) {\r\n console.warn('Error in removeLocalStorageData: ', err);\r\n }\r\n}"]}
|