@snippyly/plugin-staging 1.0.5 → 1.0.6
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/package.json +1 -1
- package/snippyly.js +1 -1
package/package.json
CHANGED
package/snippyly.js
CHANGED
|
@@ -53,7 +53,7 @@ const it=1;
|
|
|
53
53
|
* Copyright 2018 Google LLC
|
|
54
54
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
55
55
|
*/
|
|
56
|
-
const st=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}{constructor(t){var i;if(super(t),t.type!==it||"class"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((i=>t[i])).join(" ")+" "}update(t,[i]){var s,e;if(void 0===this.et){this.et=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!(null===(s=this.st)||void 0===s?void 0:s.has(t))&&this.et.add(t);return this.render(i)}const n=t.element.classList;this.et.forEach((t=>{t in i||(n.remove(t),this.et.delete(t))}));for(const t in i){const s=!!i[t];s===this.et.has(t)||(null===(e=this.st)||void 0===e?void 0:e.has(t))||(s?(n.add(t),this.et.add(t)):(n.remove(t),this.et.delete(t)))}return U}}),et=(t,i=0)=>{try{let s=3735928559^i,e=1103547991^i;for(let i,n=0;n<t.length;n++)i=t.charCodeAt(n),s=Math.imul(s^i,2654435761),e=Math.imul(e^i,1597334677);return s=Math.imul(s^s>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),e=Math.imul(e^e>>>16,2246822507)^Math.imul(s^s>>>13,3266489909),4294967296*(2097151&e)+(s>>>0)}catch(t){return console.warn("Error in cyrb53: ",t),0}},nt=(t,i,s=!1,e="localStorage")=>{try{const n=s?btoa(i):i;"localStorage"===e?localStorage.setItem(t,n):sessionStorage.setItem(t,n)}catch(t){console.warn("Error in setLocalStorage: ",t)}},ot=(t,i=!1,s="localStorage")=>{try{let e=null;return e="localStorage"===s?localStorage.getItem(t):sessionStorage.getItem(t),e&&i?atob(e):e}catch(t){return console.warn("Error in getLocalStorage: ",t),null}},rt=(t,i="localStorage")=>{try{"localStorage"===i?localStorage.removeItem(t):sessionStorage.removeItem(t)}catch(t){console.warn("Error in removeLocalStorageData: ",t)}};var lt=function(t,i,s,e){for(var n,o=arguments.length,r=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,l=t.length-1;l>=0;l--)(n=t[l])&&(r=(o<3?n(r):o>3?n(i,s,r):n(i,s))||r);return o>3&&r&&Object.defineProperty(i,s,r),r};let ht=class extends X{constructor(){super(),this._loadPlugin=!1,this.comments=[],this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(t){console.warn("Error in setWindowEventListner: ",t)}},this.urlChangeListener=()=>{try{const t=history.pushState;history.pushState=function(){const i=t.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),i};const i=history.replaceState;history.replaceState=function(){const t=i.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),t},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(t){console.warn("Error in urlChangeListener: ",t)}},this.checkUrl=()=>{try{const t=new URL(document.location),i=t.searchParams;if(i.has("snippyly_google_token")){const s=JSON.parse(atob(i.get("snippyly_google_token"))),e={};e.userId=s.uid,e.name=s.displayName,e.email=s.email,e.photoUrl=null==s?void 0:s.photoURL,e.contacts=window.SNIPPYLY_USER_CONTACTS||[],nt("snippyly-user",JSON.stringify(e),!0),i.delete("snippyly_google_token"),window.history.replaceState({},document.title,t.href)}if(i.has("review-mode"))if(nt("review-mode","true",!1,"sessionStorage"),i.has("review-doc-id"))this.loadPluginUI();else{const s=new URL(document.location);s.searchParams.delete("review-mode");const e=et(s.href);i.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,t.href),this.loadPluginUI()}else if(ot("review-mode",!1,"sessionStorage")){const s=new URL(document.location);s.searchParams.delete("review-mode"),i.append("review-mode","true");const e=et(s.href);i.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,t.href),this.loadPluginUI()}}catch(t){console.warn("Error in checkUrl: ",t)}},this.loadPluginUI=()=>{try{this.loadPlugin=!0;const t=document.createElement("snippyly-comments");window.document.body.appendChild(t);const i=document.createElement("snippyly-comments-sidebar");window.document.body.appendChild(i);const s=document.createElement("snippyly-cursor");window.document.body.appendChild(s),((t="latest",i=!1,s)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))s&&s();else{const e=document.createElement("script");e.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${i?"-staging":""}@${t||"latest"}/snippyly.js`,e.id="snippylyScript",e.type="module",document.body.appendChild(e),e.onload=()=>{s&&s()}}})(void 0,this.staging,(()=>{window.Snippyly&&this.initializeSnippyly()}))}catch(t){console.warn("Error in loadPluginUI: ",t)}},this.initializeSnippyly=async()=>{try{await(null===Snippyly||void 0===Snippyly?void 0:Snippyly.init(this.apiKey)),this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),ot("snippyly-user",!0)&&this.identifySnippyly()}catch(t){console.warn("Error in initializeSnippyly: ",t)}},this.identifySnippyly=async()=>{try{this.snippylyUser=JSON.parse(ot("snippyly-user",!0)),await Snippyly.identify(this.snippylyUser),this.getComments()}catch(t){console.warn("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{this.commentElement&&this.commentElement.getAllCommentPinAnnotationsOnCurrentDocument().subscribe((t=>{this.comments=t}))}catch(t){console.warn("Error in getComments: ",t)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(t){console.warn("Error in toggleCommentSidebar: ",t)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(t){console.warn("Error in toggleSnippylyPluginToolbar: ",t)}},this.loginWithGoogle=()=>{try{window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in loginWithGoogle: ",t)}},this.removeSnippyly=async()=>{try{rt("review-mode","sessionStorage");const t=new URL(document.location),i=t.searchParams;i.delete("review-doc-id"),i.delete("review-mode"),window.history.replaceState({},document.title,t.href),window.location.reload()}catch(t){console.warn("Error in removeSnippyly: ",t)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),rt("snippyly-user"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in signOutUser: ",t)}},this.toggleMenu=t=>{try{this.menuOpenedId===t?this.menuOpenedId=void 0:this.menuOpenedId=t}catch(t){console.warn("Error in toggleMenu: ",t)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(t){console.warn("Error in copyLink: ",t)}};try{this.expanded=!0,this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(t){console.warn("Error in constructor: ",t)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(t){this._loadPlugin=t,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(t){this._expanded=t,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}render(){var t,i,s,e,n,o;return this.loadPlugin?A`
|
|
56
|
+
const st=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}{constructor(t){var i;if(super(t),t.type!==it||"class"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((i=>t[i])).join(" ")+" "}update(t,[i]){var s,e;if(void 0===this.et){this.et=new Set,void 0!==t.strings&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!(null===(s=this.st)||void 0===s?void 0:s.has(t))&&this.et.add(t);return this.render(i)}const n=t.element.classList;this.et.forEach((t=>{t in i||(n.remove(t),this.et.delete(t))}));for(const t in i){const s=!!i[t];s===this.et.has(t)||(null===(e=this.st)||void 0===e?void 0:e.has(t))||(s?(n.add(t),this.et.add(t)):(n.remove(t),this.et.delete(t)))}return U}}),et=(t,i=0)=>{try{let s=3735928559^i,e=1103547991^i;for(let i,n=0;n<t.length;n++)i=t.charCodeAt(n),s=Math.imul(s^i,2654435761),e=Math.imul(e^i,1597334677);return s=Math.imul(s^s>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),e=Math.imul(e^e>>>16,2246822507)^Math.imul(s^s>>>13,3266489909),4294967296*(2097151&e)+(s>>>0)}catch(t){return console.warn("Error in cyrb53: ",t),0}},nt=(t,i,s=!1,e="localStorage")=>{try{const n=s?btoa(i):i;"localStorage"===e?localStorage.setItem(t,n):sessionStorage.setItem(t,n)}catch(t){console.warn("Error in setLocalStorage: ",t)}},ot=(t,i=!1,s="localStorage")=>{try{let e=null;return e="localStorage"===s?localStorage.getItem(t):sessionStorage.getItem(t),e&&i?atob(e):e}catch(t){return console.warn("Error in getLocalStorage: ",t),null}},rt=(t,i="localStorage")=>{try{"localStorage"===i?localStorage.removeItem(t):sessionStorage.removeItem(t)}catch(t){console.warn("Error in removeLocalStorageData: ",t)}};var lt=function(t,i,s,e){for(var n,o=arguments.length,r=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,l=t.length-1;l>=0;l--)(n=t[l])&&(r=(o<3?n(r):o>3?n(i,s,r):n(i,s))||r);return o>3&&r&&Object.defineProperty(i,s,r),r};let ht=class extends X{constructor(){super(),this._loadPlugin=!1,this.comments=[],this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(t){console.warn("Error in setWindowEventListner: ",t)}},this.urlChangeListener=()=>{try{const t=history.pushState;history.pushState=function(){const i=t.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),i};const i=history.replaceState;history.replaceState=function(){const t=i.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),t},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(t){console.warn("Error in urlChangeListener: ",t)}},this.checkUrl=()=>{try{const t=new URL(document.location),i=t.searchParams;if(i.has("snippyly_google_token")){const s=JSON.parse(atob(i.get("snippyly_google_token"))),e={};e.userId=s.uid,e.name=s.displayName,e.email=s.email,e.photoUrl=null==s?void 0:s.photoURL,e.contacts=window.SNIPPYLY_USER_CONTACTS||[],nt("snippyly-user",JSON.stringify(e),!0),i.delete("snippyly_google_token"),window.history.replaceState({},document.title,t.href)}if(i.has("review-mode"))if(nt("review-mode","true",!1,"sessionStorage"),i.has("review-doc-id"))this.loadPluginUI();else{const s=new URL(document.location);s.searchParams.delete("review-mode");const e=et(s.href);i.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,t.href),this.loadPluginUI()}else if(ot("review-mode",!1,"sessionStorage")){const s=new URL(document.location);s.searchParams.delete("review-mode"),i.append("review-mode","true");const e=et(s.href);i.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,t.href),this.loadPluginUI()}}catch(t){console.warn("Error in checkUrl: ",t)}},this.loadPluginUI=()=>{try{this.loadPlugin=!0;const t=document.createElement("snippyly-comments");window.document.body.appendChild(t);const i=document.createElement("snippyly-comments-sidebar");window.document.body.appendChild(i);const s=document.createElement("snippyly-cursor");window.document.body.appendChild(s),((t="latest",i=!1,s)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))s&&s();else{const e=document.createElement("script");e.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${i?"-staging":""}@${t||"latest"}/snippyly.js`,e.id="snippylyScript",e.type="module",document.body.appendChild(e),e.onload=()=>{s&&s()}}})(void 0,this.staging,(()=>{window.Snippyly&&this.initializeSnippyly()}))}catch(t){console.warn("Error in loadPluginUI: ",t)}},this.initializeSnippyly=async()=>{try{await(null===Snippyly||void 0===Snippyly?void 0:Snippyly.init(this.apiKey)),this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),this.commentElement&&this.commentElement.enableTextComments(!0),ot("snippyly-user",!0)&&this.identifySnippyly()}catch(t){console.warn("Error in initializeSnippyly: ",t)}},this.identifySnippyly=async()=>{try{this.snippylyUser=JSON.parse(ot("snippyly-user",!0)),await Snippyly.identify(this.snippylyUser),this.getComments()}catch(t){console.warn("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{this.commentElement&&this.commentElement.getAllCommentPinAnnotationsOnCurrentDocument().subscribe((t=>{this.comments=t}))}catch(t){console.warn("Error in getComments: ",t)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(t){console.warn("Error in toggleCommentSidebar: ",t)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(t){console.warn("Error in toggleSnippylyPluginToolbar: ",t)}},this.loginWithGoogle=()=>{try{window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in loginWithGoogle: ",t)}},this.removeSnippyly=async()=>{try{rt("review-mode","sessionStorage");const t=new URL(document.location),i=t.searchParams;i.delete("review-doc-id"),i.delete("review-mode"),window.history.replaceState({},document.title,t.href),window.location.reload()}catch(t){console.warn("Error in removeSnippyly: ",t)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),rt("snippyly-user"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in signOutUser: ",t)}},this.toggleMenu=t=>{try{this.menuOpenedId===t?this.menuOpenedId=void 0:this.menuOpenedId=t}catch(t){console.warn("Error in toggleMenu: ",t)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(t){console.warn("Error in copyLink: ",t)}};try{this.expanded=!0,this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(t){console.warn("Error in constructor: ",t)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(t){this._loadPlugin=t,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(t){this._expanded=t,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}render(){var t,i,s,e,n,o;return this.loadPlugin?A`
|
|
57
57
|
<div class="snippyly-plugin-container">
|
|
58
58
|
<div class="snippyly-btn-container snippyly-menu-trigger ${st({opened:"snippylyMenu"===this.menuOpenedId})}" id="snippylyMenu" @click=${()=>this.toggleMenu("snippylyMenu")}>
|
|
59
59
|
<div class="btn snippyly-btn">
|