@snippyly/plugin-staging 1.0.22 → 1.0.23

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/snippyly.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snippyly/plugin-staging",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "",
5
5
  "main": "snippyly.js",
6
6
  "scripts": {
package/snippyly.js CHANGED
@@ -55,7 +55,7 @@ const ei=1;
55
55
  */
56
56
  const ni=(i=>(...t)=>({_$litDirective$:i,values:t}))(class extends class{constructor(i){}get _$AU(){return this._$AM._$AU}_$AT(i,t,e){this._$Ct=i,this._$AM=t,this._$Ci=e}_$AS(i,t){return this.update(i,t)}update(i,t){return this.render(...t)}}{constructor(i){var t;if(super(i),i.type!==ei||"class"!==i.name||(null===(t=i.strings)||void 0===t?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(i){return" "+Object.keys(i).filter((t=>i[t])).join(" ")+" "}update(i,[t]){var e,n;if(void 0===this.et){this.et=new Set,void 0!==i.strings&&(this.st=new Set(i.strings.join(" ").split(/\s/).filter((i=>""!==i))));for(const i in t)t[i]&&!(null===(e=this.st)||void 0===e?void 0:e.has(i))&&this.et.add(i);return this.render(t)}const s=i.element.classList;this.et.forEach((i=>{i in t||(s.remove(i),this.et.delete(i))}));for(const i in t){const e=!!t[i];e===this.et.has(i)||(null===(n=this.st)||void 0===n?void 0:n.has(i))||(e?(s.add(i),this.et.add(i)):(s.remove(i),this.et.delete(i)))}return U}}),si="snippyly-cursor",oi="snippyly-comments",ri="snippyly-comments-sidebar",li="enable-url-navigation",ai=(i,t=0)=>{try{let e=3735928559^t,n=1103547991^t;for(let t,s=0;s<i.length;s++)t=i.charCodeAt(s),e=Math.imul(e^t,2654435761),n=Math.imul(n^t,1597334677);return e=Math.imul(e^e>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),4294967296*(2097151&n)+(e>>>0)}catch(i){return console.warn("Error in cyrb53: ",i),0}},hi=(i,t,e=!1,n="localStorage")=>{try{const s=e?btoa(t):t;"localStorage"===n?localStorage.setItem(i,s):sessionStorage.setItem(i,s)}catch(i){console.warn("Error in setLocalStorage: ",i)}},di=(i,t=!1,e="localStorage")=>{try{let n=null;return n="localStorage"===e?localStorage.getItem(i):sessionStorage.getItem(i),n&&t?atob(n):n}catch(i){return console.warn("Error in getLocalStorage: ",i),null}},ci=(i,t="localStorage")=>{try{"localStorage"===t?localStorage.removeItem(i):sessionStorage.removeItem(i)}catch(i){console.warn("Error in removeLocalStorageData: ",i)}},pi=(...i)=>{if(i)switch(i.length){case 1:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1))`;case 2:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[1]}rem * var(--snippyly-base-rem-unit, 1))`;case 3:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[1]}rem * var(--snippyly-base-rem-unit, 1))
57
57
  calc(${i[2]}rem * var(--snippyly-base-rem-unit, 1))`;case 4:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[1]}rem * var(--snippyly-base-rem-unit, 1))
58
- calc(${i[2]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[3]}rem * var(--snippyly-base-rem-unit, 1))`}return s`0`};var ui=function(i,t,e,n){for(var s,o=arguments.length,r=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n,l=i.length-1;l>=0;l--)(s=i[l])&&(r=(o<3?s(r):o>3?s(t,e,r):s(t,e))||r);return o>3&&r&&Object.defineProperty(t,e,r),r};let yi=class extends G{constructor(){super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(i){console.warn("Error in addWindowClickEventListener: ",i)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(i){console.warn("Error in removeWindowClickEventListener: ",i)}},this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(i){console.warn("Error in setWindowEventListner: ",i)}},this.urlChangeListener=()=>{try{const i=history.pushState;history.pushState=function(){const t=i.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),t};const t=history.replaceState;history.replaceState=function(){const i=t.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),i},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(i){console.warn("Error in urlChangeListener: ",i)}},this.checkUrl=()=>{try{const i=new URL(document.location),t=i.searchParams;if(t.has("snippyly_google_token")){const e=JSON.parse(atob(t.get("snippyly_google_token"))),n={};n.userId=e.uid,n.name=e.displayName,n.email=e.email,n.photoUrl=null==e?void 0:e.photoURL,n.contacts=window.SNIPPYLY_USER_CONTACTS||[],hi("snippyly-user",JSON.stringify(n),!0),t.delete("snippyly_google_token"),window.history.replaceState({},document.title,i.href)}if(t.has("review"))if(hi("review","true",!1,"sessionStorage"),t.has("sreviewId"))hi("sreviewId",t.get("sreviewId")||"",!1,"sessionStorage"),this.loadPluginUI();else{let e=di("sreviewId",!1,"sessionStorage");e||(e=ai(window.location.origin)+"",hi("sreviewId",`${e}`,!1,"sessionStorage")),t.append("sreviewId",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}else if(di("review",!1,"sessionStorage")){t.append("review","true");let e=di("sreviewId",!1,"sessionStorage");e||(e=ai(window.location.origin)+"",hi("sreviewId",`${e}`,!1,"sessionStorage")),t.append("sreviewId",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}}catch(i){console.warn("Error in checkUrl: ",i)}},this.loadPluginUI=()=>{try{if(this.loadPlugin)return;if(this.loadPlugin=!0,!document.querySelector(oi)){const i=document.createElement(oi);null==i||i.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(i)}if(!document.querySelector(ri)){const i=document.createElement(ri);i.setAttribute(li,"true"),window.document.body.appendChild(i)}if(!document.querySelector(si)){const i=document.createElement(si);window.document.body.appendChild(i)}((i="",t=!1,e)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))e&&e();else{const n=document.createElement("script");n.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${t?"-staging":""}${i?"@"+i:""}/snippyly.js`,n.id="snippylyScript",n.type="module",document.body.appendChild(n),n.onload=()=>{e&&e()}}})(void 0,this.staging,(()=>{window.Snippyly&&this.initializeSnippyly()}))}catch(i){console.warn("Error in loadPluginUI: ",i)}},this.initializeSnippyly=async()=>{try{await(null===Snippyly||void 0===Snippyly?void 0:Snippyly.init(this.apiKey));const i=new URL(document.location).searchParams;if(i.has("sreviewId")){null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(i.get("sreviewId"));const t=new URL(document.location);t.searchParams.delete("review"),t.searchParams.delete("sreviewId"),t.searchParams.delete("scommentId"),null===Snippyly||void 0===Snippyly||Snippyly.setLocation({url:t.href})}this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),this.commentElement&&(this.commentElement.enableTextComments(!0),this.commentElement.enableSignInButton(!0),this.commentElement.enableAttachment(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((i=>{this.addCommentMode=i}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableSelections(!0),this.identifySnippyly()}catch(i){console.warn("Error in initializeSnippyly: ",i)}},this.identifySnippyly=async()=>{var i;try{this.invalidApiKey=!1;let i={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};di("snippyly-user",!0)&&(i=JSON.parse(di("snippyly-user",!0))),i.contacts=window.SNIPPYLY_USER_CONTACTS||[],await Snippyly.identify(i),(null==i?void 0:i.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(i))),this.getComments()}catch(t){t&&"string"==typeof t&&(null===(i=null==t?void 0:t.toLowerCase())||void 0===i?void 0:i.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{if(this.commentElement){const i=new URL(document.location).searchParams;this.commentElement.getAllCommentAnnotations(i.get("sreviewId")).subscribe((i=>{this.comments=i}))}}catch(i){console.warn("Error in getComments: ",i)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(i){console.warn("Error in toggleCommentSidebar: ",i)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(i){console.warn("Error in toggleSnippylyPluginToolbar: ",i)}},this.loginWithGoogle=()=>{try{window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in loginWithGoogle: ",i)}},this.removeSnippyly=async()=>{try{ci("review","sessionStorage"),ci("sreviewId","sessionStorage");const i=new URL(document.location),t=i.searchParams;t.delete("sreviewId"),t.delete("review"),window.history.replaceState({},document.title,i.href),window.location.reload()}catch(i){console.warn("Error in removeSnippyly: ",i)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),ci("snippyly-user"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in signOutUser: ",i)}},this.toggleMenu=(i,t)=>{try{i.stopPropagation(),this.menuOpenedId===t?this.menuOpenedId=void 0:this.menuOpenedId=t}catch(i){console.warn("Error in toggleMenu: ",i)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(i){console.warn("Error in copyLink: ",i)}},this.setAttribute("snippyly-comment-disabled","true");try{this.expanded=!0,this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(i){console.warn("Error in constructor: ",i)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(i){this._loadPlugin=i,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(i){this._expanded=i,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(i){this._menuOpenedId=i,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var i,t,e,n,s,o,r,l,a,h,d,c;return this.loadPlugin?I`
58
+ calc(${i[2]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[3]}rem * var(--snippyly-base-rem-unit, 1))`}return s`0`};var ui=function(i,t,e,n){for(var s,o=arguments.length,r=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n,l=i.length-1;l>=0;l--)(s=i[l])&&(r=(o<3?s(r):o>3?s(t,e,r):s(t,e))||r);return o>3&&r&&Object.defineProperty(t,e,r),r};let yi=class extends G{constructor(){super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(i){console.warn("Error in addWindowClickEventListener: ",i)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(i){console.warn("Error in removeWindowClickEventListener: ",i)}},this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(i){console.warn("Error in setWindowEventListner: ",i)}},this.urlChangeListener=()=>{try{const i=history.pushState;history.pushState=function(){const t=i.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),t};const t=history.replaceState;history.replaceState=function(){const i=t.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),i},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(i){console.warn("Error in urlChangeListener: ",i)}},this.checkUrl=()=>{try{const i=new URL(document.location),t=i.searchParams;if(t.has("snippyly_google_token")){const e=JSON.parse(atob(t.get("snippyly_google_token"))),n={};n.userId=e.uid,n.name=e.displayName,n.email=e.email,n.photoUrl=null==e?void 0:e.photoURL,n.contacts=window.SNIPPYLY_USER_CONTACTS||[],hi("snippyly-user",JSON.stringify(n),!0),t.delete("snippyly_google_token"),window.history.replaceState({},document.title,i.href)}if(t.has("review"))if(hi("review","true",!1,"sessionStorage"),t.has("sreviewId"))hi("sreviewId",t.get("sreviewId")||"",!1,"sessionStorage"),this.loadPluginUI();else{let e=di("sreviewId",!1,"sessionStorage");e||(e=ai(window.location.origin)+"",hi("sreviewId",`${e}`,!1,"sessionStorage")),t.append("sreviewId",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}else if(di("review",!1,"sessionStorage")){t.append("review","true");let e=di("sreviewId",!1,"sessionStorage");e||(e=ai(window.location.origin)+"",hi("sreviewId",`${e}`,!1,"sessionStorage")),t.append("sreviewId",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}}catch(i){console.warn("Error in checkUrl: ",i)}},this.loadPluginUI=()=>{try{if(this.loadPlugin)return;if(this.loadPlugin=!0,!document.querySelector(oi)){const i=document.createElement(oi);null==i||i.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(i)}if(!document.querySelector(ri)){const i=document.createElement(ri);i.setAttribute(li,"true"),window.document.body.appendChild(i)}if(!document.querySelector(si)){const i=document.createElement(si);window.document.body.appendChild(i)}((i="",t=!1,e)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))e&&e();else{const n=document.createElement("script");n.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${t?"-staging":""}${i?"@"+i:""}/snippyly.js`,n.id="snippylyScript",n.type="module",document.body.appendChild(n),n.onload=()=>{e&&e()}}})(void 0,this.staging,(()=>{window.Snippyly&&this.initializeSnippyly()}))}catch(i){console.warn("Error in loadPluginUI: ",i)}},this.initializeSnippyly=async()=>{try{await(null===Snippyly||void 0===Snippyly?void 0:Snippyly.init(this.apiKey));const i=new URL(document.location).searchParams;if(i.has("sreviewId")){null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(i.get("sreviewId"));const t=new URL(document.location);t.searchParams.delete("review"),t.searchParams.delete("sreviewId"),t.searchParams.delete("scommentId"),null===Snippyly||void 0===Snippyly||Snippyly.setLocation({url:t.href})}this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),this.commentElement&&(this.commentElement.enableTextComments(!0),this.commentElement.enableSignInButton(!0),this.commentElement.enableAttachment(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((i=>{this.addCommentMode=i}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableLiveSelection(!0),this.identifySnippyly()}catch(i){console.warn("Error in initializeSnippyly: ",i)}},this.identifySnippyly=async()=>{var i;try{this.invalidApiKey=!1;let i={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};di("snippyly-user",!0)&&(i=JSON.parse(di("snippyly-user",!0))),i.contacts=window.SNIPPYLY_USER_CONTACTS||[],await Snippyly.identify(i),(null==i?void 0:i.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(i))),this.getComments()}catch(t){t&&"string"==typeof t&&(null===(i=null==t?void 0:t.toLowerCase())||void 0===i?void 0:i.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{if(this.commentElement){const i=new URL(document.location).searchParams;this.commentElement.getAllCommentAnnotations(i.get("sreviewId")).subscribe((i=>{this.comments=i}))}}catch(i){console.warn("Error in getComments: ",i)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(i){console.warn("Error in toggleCommentSidebar: ",i)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(i){console.warn("Error in toggleSnippylyPluginToolbar: ",i)}},this.loginWithGoogle=()=>{try{window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in loginWithGoogle: ",i)}},this.removeSnippyly=async()=>{try{ci("review","sessionStorage"),ci("sreviewId","sessionStorage");const i=new URL(document.location),t=i.searchParams;t.delete("sreviewId"),t.delete("review"),window.history.replaceState({},document.title,i.href),window.location.reload()}catch(i){console.warn("Error in removeSnippyly: ",i)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),ci("snippyly-user"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in signOutUser: ",i)}},this.toggleMenu=(i,t)=>{try{i.stopPropagation(),this.menuOpenedId===t?this.menuOpenedId=void 0:this.menuOpenedId=t}catch(i){console.warn("Error in toggleMenu: ",i)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(i){console.warn("Error in copyLink: ",i)}},this.setAttribute("snippyly-comment-disabled","true");try{this.expanded=!0,this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(i){console.warn("Error in constructor: ",i)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(i){this._loadPlugin=i,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(i){this._expanded=i,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(i){this._menuOpenedId=i,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var i,t,e,n,s,o,r,l,a,h,d,c;return this.loadPlugin?I`
59
59
  <div class="snippyly-plugin-container ${ni({expanded:this.expanded,active:null===(i=this.snippylyUser)||void 0===i?void 0:i.userId,"comment-mode-enabled":this.addCommentMode})}">
60
60
  <div class="snippyly-logo-container snippyly-menu-trigger" @click=${()=>this.toggleSnippylyPluginToolbar()}>
61
61
  ${this.expanded?null:I`