@snippyly/plugin-staging 1.0.50 → 1.0.52
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 +37 -7
package/package.json
CHANGED
package/snippyly.js
CHANGED
|
@@ -14,13 +14,13 @@ const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
var u;v.finalized=!0,v.elementProperties=new Map,v.elementStyles=[],v.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:v}),(null!==(r=globalThis.reactiveElementVersions)&&void 0!==r?r:globalThis.reactiveElementVersions=[]).push("1.3.2");const y=globalThis.trustedTypes,g=y?y.createPolicy("lit-html",{createHTML:t=>t}):void 0,w=`lit$${(Math.random()+"").slice(9)}$`,
|
|
17
|
+
var u;v.finalized=!0,v.elementProperties=new Map,v.elementStyles=[],v.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:v}),(null!==(r=globalThis.reactiveElementVersions)&&void 0!==r?r:globalThis.reactiveElementVersions=[]).push("1.3.2");const y=globalThis.trustedTypes,g=y?y.createPolicy("lit-html",{createHTML:t=>t}):void 0,w=`lit$${(Math.random()+"").slice(9)}$`,m="?"+w,C=`<${m}>`,b=document,f=(t="")=>b.createComment(t),x=t=>null===t||"object"!=typeof t&&"function"!=typeof t,S=Array.isArray,F=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$=/-->/g,k=/>/g,E=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,L=/'/g,M=/"/g,A=/^(?:script|style|textarea|title)$/i,_=(t=>(i,...o)=>({_$litType$:t,strings:i,values:o}))(1),U=Symbol.for("lit-noChange"),j=Symbol.for("lit-nothing"),Z=new WeakMap,V=b.createTreeWalker(b,129,null,!1),B=(t,i)=>{const o=t.length-1,e=[];let s,n=2===i?"<svg>":"",r=F;for(let i=0;i<o;i++){const o=t[i];let l,a,d=-1,c=0;for(;c<o.length&&(r.lastIndex=c,a=r.exec(o),null!==a);)c=r.lastIndex,r===F?"!--"===a[1]?r=$:void 0!==a[1]?r=k:void 0!==a[2]?(A.test(a[2])&&(s=RegExp("</"+a[2],"g")),r=E):void 0!==a[3]&&(r=E):r===E?">"===a[0]?(r=null!=s?s:F,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,l=a[1],r=void 0===a[3]?E:'"'===a[3]?M:L):r===M||r===L?r=E:r===$||r===k?r=F:(r=E,s=void 0);const h=r===E&&t[i+1].startsWith("/>")?" ":"";n+=r===F?o+C:d>=0?(e.push(l),o.slice(0,d)+"$lit$"+o.slice(d)+w+h):o+w+(-2===d?(e.push(void 0),i):h)}const l=n+(t[o]||"<?>")+(2===i?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==g?g.createHTML(l):l,e]};class I{constructor({strings:t,_$litType$:i},o){let e;this.parts=[];let s=0,n=0;const r=t.length-1,l=this.parts,[a,d]=B(t,i);if(this.el=I.createElement(a,o),V.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=V.nextNode())&&l.length<r;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith("$lit$")||i.startsWith(w)){const o=d[n++];if(t.push(i),void 0!==o){const t=e.getAttribute(o.toLowerCase()+"$lit$").split(w),i=/([.?@])?(.*)/.exec(o);l.push({type:1,index:s,name:i[2],strings:t,ctor:"."===i[1]?z:"?"===i[1]?H:"@"===i[1]?P:D})}else l.push({type:6,index:s})}for(const i of t)e.removeAttribute(i)}if(A.test(e.tagName)){const t=e.textContent.split(w),i=t.length-1;if(i>0){e.textContent=y?y.emptyScript:"";for(let o=0;o<i;o++)e.append(t[o],f()),V.nextNode(),l.push({type:2,index:++s});e.append(t[i],f())}}}else if(8===e.nodeType)if(e.data===m)l.push({type:2,index:s});else{let t=-1;for(;-1!==(t=e.data.indexOf(w,t+1));)l.push({type:7,index:s}),t+=w.length-1}s++}}static createElement(t,i){const o=b.createElement("template");return o.innerHTML=t,o}}function O(t,i,o=t,e){var s,n,r,l;if(i===U)return i;let a=void 0!==e?null===(s=o._$Cl)||void 0===s?void 0:s[e]:o._$Cu;const d=x(i)?void 0:i._$litDirective$;return(null==a?void 0:a.constructor)!==d&&(null===(n=null==a?void 0:a._$AO)||void 0===n||n.call(a,!1),void 0===d?a=void 0:(a=new d(t),a._$AT(t,o,e)),void 0!==e?(null!==(r=(l=o)._$Cl)&&void 0!==r?r:l._$Cl=[])[e]=a:o._$Cu=a),void 0!==a&&(i=O(t,a._$AS(t,i.values),a,e)),i}class R{constructor(t,i){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var i;const{el:{content:o},parts:e}=this._$AD,s=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:b).importNode(o,!0);V.currentNode=s;let n=V.nextNode(),r=0,l=0,a=e[0];for(;void 0!==a;){if(r===a.index){let i;2===a.type?i=new T(n,n.nextSibling,this,t):1===a.type?i=new a.ctor(n,a.name,a.strings,this,t):6===a.type&&(i=new K(n,this,t)),this.v.push(i),a=e[++l]}r!==(null==a?void 0:a.index)&&(n=V.nextNode(),r++)}return s}m(t){let i=0;for(const o of this.v)void 0!==o&&(void 0!==o.strings?(o._$AI(t,o,i),i+=o.strings.length-2):o._$AI(t[i])),i++}}class T{constructor(t,i,o,e){var s;this.type=2,this._$AH=j,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=o,this.options=e,this._$Cg=null===(s=null==e?void 0:e.isConnected)||void 0===s||s}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=O(this,t,i),x(t)?t===j||null==t||""===t?(this._$AH!==j&&this._$AR(),this._$AH=j):t!==this._$AH&&t!==U&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var i;return S(t)||"function"==typeof(null===(i=t)||void 0===i?void 0:i[Symbol.iterator])})(t)?this.S(t):this.$(t)}M(t,i=this._$AB){return this._$AA.parentNode.insertBefore(t,i)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.M(t))}$(t){this._$AH!==j&&x(this._$AH)?this._$AA.nextSibling.data=t:this.k(b.createTextNode(t)),this._$AH=t}T(t){var i;const{values:o,_$litType$:e}=t,s="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=I.createElement(e.h,this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===s)this._$AH.m(o);else{const t=new R(s,this),i=t.p(this.options);t.m(o),this.k(i),this._$AH=t}}_$AC(t){let i=Z.get(t.strings);return void 0===i&&Z.set(t.strings,i=new I(t)),i}S(t){S(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let o,e=0;for(const s of t)e===i.length?i.push(o=new T(this.M(f()),this.M(f()),this,this.options)):o=i[e],o._$AI(s),e++;e<i.length&&(this._$AR(o&&o._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var o;for(null===(o=this._$AP)||void 0===o||o.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cg=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class D{constructor(t,i,o,e,s){this.type=1,this._$AH=j,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=s,o.length>2||""!==o[0]||""!==o[1]?(this._$AH=Array(o.length-1).fill(new String),this.strings=o):this._$AH=j}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,o,e){const s=this.strings;let n=!1;if(void 0===s)t=O(this,t,i,0),n=!x(t)||t!==this._$AH&&t!==U,n&&(this._$AH=t);else{const e=t;let r,l;for(t=s[0],r=0;r<s.length-1;r++)l=O(this,e[o+r],i,r),l===U&&(l=this._$AH[r]),n||(n=!x(l)||l!==this._$AH[r]),l===j?t=j:t!==j&&(t+=(null!=l?l:"")+s[r+1]),this._$AH[r]=l}n&&!e&&this.C(t)}C(t){t===j?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class z extends D{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===j?void 0:t}}const N=y?y.emptyScript:"";class H extends D{constructor(){super(...arguments),this.type=4}C(t){t&&t!==j?this.element.setAttribute(this.name,N):this.element.removeAttribute(this.name)}}class P extends D{constructor(t,i,o,e,s){super(t,i,o,e,s),this.type=5}_$AI(t,i=this){var o;if((t=null!==(o=O(this,t,i,0))&&void 0!==o?o:j)===U)return;const e=this._$AH,s=t===j&&e!==j||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,n=t!==j&&(e===j||s);s&&this.element.removeEventListener(this.name,this,e),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,o;"function"==typeof this._$AH?this._$AH.call(null!==(o=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==o?o:this.element,t):this._$AH.handleEvent(t)}}class K{constructor(t,i,o){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=o}get _$AU(){return this._$AM._$AU}_$AI(t){O(this,t)}}const J=window.litHtmlPolyfillSupport;
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
22
|
*/
|
|
23
|
-
var W,G;null==J||J(I,T),(null!==(u=globalThis.litHtmlVersions)&&void 0!==u?u:globalThis.litHtmlVersions=[]).push("2.2.6");class X extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,i;const o=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=o.firstChild),o}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,i,o)=>{var e,s;const n=null!==(e=null==o?void 0:o.renderBefore)&&void 0!==e?e:i;let r=n._$litPart$;if(void 0===r){const t=null!==(s=null==o?void 0:o.renderBefore)&&void 0!==s?s:null;n._$litPart$=r=new T(i.insertBefore(
|
|
23
|
+
var W,G;null==J||J(I,T),(null!==(u=globalThis.litHtmlVersions)&&void 0!==u?u:globalThis.litHtmlVersions=[]).push("2.2.6");class X extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,i;const o=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=o.firstChild),o}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,i,o)=>{var e,s;const n=null!==(e=null==o?void 0:o.renderBefore)&&void 0!==e?e:i;let r=n._$litPart$;if(void 0===r){const t=null!==(s=null==o?void 0:o.renderBefore)&&void 0!==s?s:null;n._$litPart$=r=new T(i.insertBefore(f(),t),t,void 0,null!=o?o:{})}return r._$AI(t),r})(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return U}}X.finalized=!0,X._$litElement$=!0,null===(W=globalThis.litElementHydrateSupport)||void 0===W||W.call(globalThis,{LitElement:X});const q=globalThis.litElementPolyfillSupport;null==q||q({LitElement:X}),(null!==(G=globalThis.litElementVersions)&&void 0!==G?G:globalThis.litElementVersions=[]).push("3.2.0");
|
|
24
24
|
/**
|
|
25
25
|
* @license
|
|
26
26
|
* Copyright 2017 Google LLC
|
|
@@ -355,11 +355,18 @@ const et=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constru
|
|
|
355
355
|
z-index: 99999999;
|
|
356
356
|
margin: ${ut(1.5)};
|
|
357
357
|
margin-bottom: ${ut(3)}; // Added to prevent overlap between plugin UI and webflow badge
|
|
358
|
+
max-width: 100vw !important;
|
|
359
|
+
box-sizing: border-box;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.snippyly-plugin-container * {
|
|
363
|
+
box-sizing: border-box;
|
|
358
364
|
}
|
|
359
365
|
|
|
360
366
|
.toolbar {
|
|
361
367
|
padding: 1em;
|
|
362
368
|
gap: 0.25em;
|
|
369
|
+
max-width: 100vw !important;
|
|
363
370
|
}
|
|
364
371
|
|
|
365
372
|
.action-border {
|
|
@@ -548,6 +555,10 @@ const et=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constru
|
|
|
548
555
|
margin: 0 8px !important;
|
|
549
556
|
}
|
|
550
557
|
|
|
558
|
+
.snippyly-logo {
|
|
559
|
+
cursor: pointer;
|
|
560
|
+
}
|
|
561
|
+
|
|
551
562
|
@media only screen and (max-width: 620px) {
|
|
552
563
|
|
|
553
564
|
.snippyly-plugin-container {
|
|
@@ -564,7 +575,26 @@ const et=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constru
|
|
|
564
575
|
margin-left: 8px;
|
|
565
576
|
}
|
|
566
577
|
}
|
|
567
|
-
`;var wt=function(t,i,o,e){for(var s,n=arguments.length,r=n<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,o):e,l=t.length-1;l>=0;l--)(s=t[l])&&(r=(n<3?s(r):n>3?s(i,o,r):s(i,o))||r);return n>3&&r&&Object.defineProperty(i,o,r),r};let Ct=class extends X{constructor(){super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.isUserGlobalContact=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(t){console.warn("Error in addWindowClickEventListener: ",t)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(t){console.warn("Error in removeWindowClickEventListener: ",t)}},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=()=>{var t;try{const i=new URL(document.location),o=i.searchParams;if(o.has("snippyly_google_token")){const e=JSON.parse(atob(o.get("snippyly_google_token"))),s={},n=(null===(t=e.providerData)||void 0===t?void 0:t.length)?e.providerData[0]:null;s.userId=e.uid,s.name=e.displayName||(null==n?void 0:n.displayName),s.email=e.email||(null==n?void 0:n.email),s.photoUrl=(null==e?void 0:e.photoURL)||(null==n?void 0:n.photoURL),s.contacts=window.SNIPPYLY_USER_CONTACTS||[],ht("snippyly-user",JSON.stringify(s),!0),o.delete("snippyly_google_token"),window.history.replaceState({},document.title,i.href)}o.has("review")?(ht("review","true",!1,"sessionStorage"),"true"!==o.get("review")&&(o.delete("review"),o.append("review","true"),window.history.replaceState({},document.title,i.href)),this.loadPluginUI()):pt("review",!1,"sessionStorage")&&(o.append("review","true"),window.history.replaceState({},document.title,i.href),this.loadPluginUI()),this.setVersionInUrl()}catch(t){console.warn("Error in checkUrl: ",t)}},this.detectVersion=()=>{try{if(this.projectVersionKey){const t=new URL(document.location).searchParams;if(t.get(this.projectVersionKey))this.projectVersion=t.get(this.projectVersionKey);else if(window.snippylyInitialLoadUrl){const t=new URL(window.snippylyInitialLoadUrl).searchParams;t.get(this.projectVersionKey)&&(this.projectVersion=t.get(this.projectVersionKey))}this.projectVersion&&ht("projectVersion",this.projectVersion,!1,"sessionStorage")}}catch(t){console.warn("Error in detectVersion: ",t)}},this.setVersionInUrl=()=>{try{const t=this.projectVersionKey||pt("projectVersionKey",!1,"sessionStorage"),i=this.projectVersion||pt("projectVersion",!1,"sessionStorage");if(t&&i){const o=new URL(document.location),e=o.searchParams;e.get(t)||(e.set(t,i),window.history.replaceState({},document.title,o.href))}}catch(t){console.warn("Error in setVersionInUrl: ",t)}},this.loadPluginUI=()=>{try{if(this.loadPlugin)return this.generateLocation(),void this.setViewMode(this.viewMode);if(this.loadPlugin=!0,!document.querySelector(nt)){const t=document.createElement(nt);null==t||t.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(t)}if(!document.querySelector(rt)){const t=document.createElement(rt);t.setAttribute(ct,"true"),window.document.body.appendChild(t)}if(!document.querySelector(st)){const t=document.createElement(st);window.document.body.appendChild(t)}if(!document.querySelector(lt)){const t=document.createElement(lt);window.document.body.appendChild(t)}if(!document.querySelector(at)){const t=document.createElement(at);window.document.body.appendChild(t)}if(!document.querySelector(dt)){const t=document.createElement(dt);window.document.body.appendChild(t)}((t="",i=!1,o)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))o&&o();else{const e=document.createElement("script");e.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${i?"-staging":""}${t?"@"+t:""}/snippyly.js`,e.id="snippylyScript",e.type="module",document.body.appendChild(e),e.onload=()=>{o&&o()}}})(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.documentId=((t,i=0)=>{try{let o=3735928559^i,e=1103547991^i;for(let i,s=0;s<t.length;s++)i=t.charCodeAt(s),o=Math.imul(o^i,2654435761),e=Math.imul(e^i,1597334677);return o=Math.imul(o^o>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),e=Math.imul(e^e>>>16,2246822507)^Math.imul(o^o>>>13,3266489909),4294967296*(2097151&e)+(o>>>0)}catch(t){return console.warn("Error in cyrb53: ",t),0}})((t=>{let i;return i=t.includes("http")?new URL(t):new URL("http://"+t),i.hostname.replace("www.","")})(window.location.origin))+"",null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(this.documentId+""),this.generateLocation(),this.setLocation(),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.showScreenSizeInfo(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((t=>{this.addCommentMode=t}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableLiveSelection(!0),this.identifySnippyly()}catch(t){console.warn("Error in initializeSnippyly: ",t)}},this.generateLocation=()=>{try{const t=new URL(document.location).searchParams,i=new URL(document.location);i.searchParams.delete("review"),i.searchParams.delete("sreviewId"),i.searchParams.delete("scommentId");const o=t.get("sversion")||this.projectVersion;this.location={url:i.href,version:o}}catch(t){console.warn("Error in generateLocation: ",t)}},this.setLocation=()=>{try{window.Snippyly&&(null===Snippyly||void 0===Snippyly?void 0:Snippyly.setLocation)&&(null===Snippyly||void 0===Snippyly||Snippyly.setLocation(JSON.parse(JSON.stringify(this.location))))}catch(t){console.warn("Error in setLocation: ",t)}},this.identifySnippyly=async()=>{var t;try{this.invalidApiKey=!1;let t={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};if(pt("snippyly-user",!0)){const i=JSON.parse(pt("snippyly-user",!0));(null==i?void 0:i.email)&&(t=i)}t.contacts=window.SNIPPYLY_USER_CONTACTS||[],t.isAnonymous?delete t.groupId:t.groupId=Snippyly.getDocumentId()+"",await Snippyly.identify(t),(null==t?void 0:t.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(t))),this.getComments(),this.checkGlobalUserContact()}catch(i){i&&"string"==typeof i&&(null===(t=null==i?void 0:i.toLowerCase())||void 0===t?void 0:t.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",i)}},this.getComments=()=>{try{this.commentElement&&(this.commentSubscription&&this.commentSubscription.unsubscribe(),this.commentSubscription=this.commentElement.getAllCommentAnnotations(this.documentId).subscribe((t=>{this.comments=t,"All"!==this.viewMode&&(this.viewMode?this.comments=t.filter((t=>{var i;return(null===(i=null==t?void 0:t.location)||void 0===i?void 0:i.view)===this.viewMode})):this.comments=this.comments.filter((t=>{var i;return!(null===(i=null==t?void 0:t.location)||void 0===i?void 0:i.view)})))})))}catch(t){console.warn("Error in getComments: ",t)}},this.checkGlobalUserContact=()=>{try{this.commentElement&&this.commentElement.isUserGlobalContact().subscribe((t=>{!this.isUserGlobalContact&&t&&this.setViewMode("All"),this.isUserGlobalContact=t,t||this.setViewMode(null)}))}catch(t){console.warn("Error in checkGlobalUserContact: ",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{vt("review","sessionStorage"),vt("sreviewId","sessionStorage"),vt("projectVersionKey","sessionStorage"),vt("projectVersion","sessionStorage");const t=new URL(document.location),i=t.searchParams;i.delete("sreviewId"),i.delete("review"),this.projectVersionKey&&i.delete(this.projectVersionKey),this.projectVersion=void 0,this.projectVersionKey=void 0,delete window.snippylyInitialLoadUrl,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(),vt("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,i)=>{try{t.stopPropagation(),this.menuOpenedId===i?this.menuOpenedId=void 0:this.menuOpenedId=i}catch(t){console.warn("Error in toggleMenu: ",t)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(t){console.warn("Error in copyLink: ",t)}},this.setViewMode=t=>{try{this.viewMode=t,t?this.location.view=t:delete this.location.view,this.setLocation(),this.getComments()}catch(t){console.warn("Error in setViewMode: ",t)}},this.setAttribute("snippyly-comment-disabled","true");try{this.expanded=!0,this.detectVersion(),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")}get projectVersionKey(){return this._projectVersionKey}set projectVersionKey(t){try{this._projectVersionKey=t,this.projectVersionKey&&ht("projectVersionKey",this.projectVersionKey,!1,"sessionStorage"),this.detectVersion()}catch(t){console.warn("Error in set projectVersionKey: ",t)}}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(t){this._menuOpenedId=t,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var t,i,o,e,s,n,r;return this.loadPlugin?this.snippylyUser?_`
|
|
578
|
+
|
|
579
|
+
@media only screen and (max-width: 400px) {
|
|
580
|
+
.snippyly-plugin-container .d-xs-none {
|
|
581
|
+
display: none;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.action-text {
|
|
585
|
+
margin-right: 0 !important;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.snippyly-plugin-container svg {
|
|
589
|
+
max-width: 28px !important;
|
|
590
|
+
max-height: 28px !important;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.action-dropdown {
|
|
594
|
+
padding: 0px 2px;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
`;var wt=function(t,i,o,e){for(var s,n=arguments.length,r=n<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,o):e,l=t.length-1;l>=0;l--)(s=t[l])&&(r=(n<3?s(r):n>3?s(i,o,r):s(i,o))||r);return n>3&&r&&Object.defineProperty(i,o,r),r};let mt=class extends X{constructor(){super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.isUserGlobalContact=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(t){console.warn("Error in addWindowClickEventListener: ",t)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(t){console.warn("Error in removeWindowClickEventListener: ",t)}},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=()=>{var t;try{const i=new URL(document.location),o=i.searchParams;if(o.has("snippyly_google_token")){const e=JSON.parse(atob(o.get("snippyly_google_token"))),s={},n=(null===(t=e.providerData)||void 0===t?void 0:t.length)?e.providerData[0]:null;s.userId=e.uid,s.name=e.displayName||(null==n?void 0:n.displayName),s.email=e.email||(null==n?void 0:n.email),s.photoUrl=(null==e?void 0:e.photoURL)||(null==n?void 0:n.photoURL),ht("snippyly-user",JSON.stringify(s),!0),o.delete("snippyly_google_token"),window.history.replaceState({},document.title,i.href)}o.has("review")?(ht("review","true",!1,"sessionStorage"),"true"!==o.get("review")&&(o.delete("review"),o.append("review","true"),window.history.replaceState({},document.title,i.href)),this.loadPluginUI()):pt("review",!1,"sessionStorage")&&(o.append("review","true"),window.history.replaceState({},document.title,i.href),this.loadPluginUI()),this.setVersionInUrl()}catch(t){console.warn("Error in checkUrl: ",t)}},this.detectVersion=()=>{try{if(this.projectVersionKey){const t=new URL(document.location).searchParams;if(t.get(this.projectVersionKey))this.projectVersion=t.get(this.projectVersionKey);else if(window.snippylyInitialLoadUrl){const t=new URL(window.snippylyInitialLoadUrl).searchParams;t.get(this.projectVersionKey)&&(this.projectVersion=t.get(this.projectVersionKey))}this.projectVersion&&ht("projectVersion",this.projectVersion,!1,"sessionStorage")}}catch(t){console.warn("Error in detectVersion: ",t)}},this.setVersionInUrl=()=>{try{const t=this.projectVersionKey||pt("projectVersionKey",!1,"sessionStorage"),i=this.projectVersion||pt("projectVersion",!1,"sessionStorage");if(t&&i){const o=new URL(document.location),e=o.searchParams;e.get(t)||(e.set(t,i),window.history.replaceState({},document.title,o.href))}}catch(t){console.warn("Error in setVersionInUrl: ",t)}},this.loadPluginUI=()=>{try{if(this.loadPlugin)return this.generateLocation(),void this.setViewMode(this.viewMode);if(this.loadPlugin=!0,!document.querySelector(nt)){const t=document.createElement(nt);null==t||t.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(t)}if(!document.querySelector(rt)){const t=document.createElement(rt);t.setAttribute(ct,"true"),window.document.body.appendChild(t)}if(!document.querySelector(st)){const t=document.createElement(st);window.document.body.appendChild(t)}if(!document.querySelector(lt)){const t=document.createElement(lt);window.document.body.appendChild(t)}if(!document.querySelector(at)){const t=document.createElement(at);window.document.body.appendChild(t)}if(!document.querySelector(dt)){const t=document.createElement(dt);window.document.body.appendChild(t)}((t="",i=!1,o)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))o&&o();else{const e=document.createElement("script");e.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${i?"-staging":""}${t?"@"+t:""}/snippyly.js`,e.id="snippylyScript",e.type="module",document.body.appendChild(e),e.onload=()=>{o&&o()}}})(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.documentId=((t,i=0)=>{try{let o=3735928559^i,e=1103547991^i;for(let i,s=0;s<t.length;s++)i=t.charCodeAt(s),o=Math.imul(o^i,2654435761),e=Math.imul(e^i,1597334677);return o=Math.imul(o^o>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),e=Math.imul(e^e>>>16,2246822507)^Math.imul(o^o>>>13,3266489909),4294967296*(2097151&e)+(o>>>0)}catch(t){return console.warn("Error in cyrb53: ",t),0}})((t=>{let i;return i=t.includes("http")?new URL(t):new URL("http://"+t),i.hostname.replace("www.","")})(window.location.origin))+"",null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(this.documentId+""),this.generateLocation(),this.setLocation(),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.showScreenSizeInfo(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((t=>{this.addCommentMode=t}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableLiveSelection(!0),this.identifySnippyly()}catch(t){console.warn("Error in initializeSnippyly: ",t)}},this.generateLocation=()=>{try{const t=new URL(document.location).searchParams,i=new URL(document.location);i.searchParams.delete("review"),i.searchParams.delete("sreviewId"),i.searchParams.delete("scommentId");const o=t.get("sversion")||this.projectVersion;this.location={url:i.href,version:o}}catch(t){console.warn("Error in generateLocation: ",t)}},this.setLocation=()=>{try{window.Snippyly&&(null===Snippyly||void 0===Snippyly?void 0:Snippyly.setLocation)&&(null===Snippyly||void 0===Snippyly||Snippyly.setLocation(JSON.parse(JSON.stringify(this.location))))}catch(t){console.warn("Error in setLocation: ",t)}},this.identifySnippyly=async()=>{var t;try{this.invalidApiKey=!1;let t={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};if(pt("snippyly-user",!0)){const i=JSON.parse(pt("snippyly-user",!0));(null==i?void 0:i.email)&&(t=i)}t.isAnonymous?delete t.groupId:t.groupId=Snippyly.getDocumentId()+"",await Snippyly.identify(t),(null==t?void 0:t.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(t))),this.getComments(),this.checkGlobalUserContact()}catch(i){i&&"string"==typeof i&&(null===(t=null==i?void 0:i.toLowerCase())||void 0===t?void 0:t.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",i)}},this.getComments=()=>{try{this.commentElement&&(this.commentSubscription&&this.commentSubscription.unsubscribe(),this.commentSubscription=this.commentElement.getAllCommentAnnotations(this.documentId).subscribe((t=>{this.comments=t,"All"!==this.viewMode&&(this.viewMode?this.comments=t.filter((t=>{var i;return(null===(i=null==t?void 0:t.location)||void 0===i?void 0:i.view)===this.viewMode})):this.comments=this.comments.filter((t=>{var i;return!(null===(i=null==t?void 0:t.location)||void 0===i?void 0:i.view)})))})))}catch(t){console.warn("Error in getComments: ",t)}},this.checkGlobalUserContact=()=>{try{this.commentElement&&this.commentElement.isUserGlobalContact().subscribe((t=>{!this.isUserGlobalContact&&t&&this.setViewMode("All"),this.isUserGlobalContact=t,t||this.setViewMode(null)}))}catch(t){console.warn("Error in checkGlobalUserContact: ",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{vt("review","sessionStorage"),vt("sreviewId","sessionStorage"),vt("projectVersionKey","sessionStorage"),vt("projectVersion","sessionStorage");const t=new URL(document.location),i=t.searchParams;i.delete("sreviewId"),i.delete("review"),this.projectVersionKey&&i.delete(this.projectVersionKey),this.projectVersion=void 0,this.projectVersionKey=void 0,delete window.snippylyInitialLoadUrl,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(),vt("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,i)=>{try{t.stopPropagation(),this.menuOpenedId===i?this.menuOpenedId=void 0:this.menuOpenedId=i}catch(t){console.warn("Error in toggleMenu: ",t)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(t){console.warn("Error in copyLink: ",t)}},this.setViewMode=t=>{try{this.viewMode=t,t?this.location.view=t:delete this.location.view,this.setLocation(),this.getComments()}catch(t){console.warn("Error in setViewMode: ",t)}},this.setAttribute("snippyly-comment-disabled","true");try{this.expanded=!0,this.detectVersion(),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")}get projectVersionKey(){return this._projectVersionKey}set projectVersionKey(t){try{this._projectVersionKey=t,this.projectVersionKey&&ht("projectVersionKey",this.projectVersionKey,!1,"sessionStorage"),this.detectVersion()}catch(t){console.warn("Error in set projectVersionKey: ",t)}}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(t){this._menuOpenedId=t,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var t,i,o,e,s,n,r;return this.loadPlugin?this.snippylyUser?_`
|
|
568
598
|
<div class="snippyly-plugin-container">
|
|
569
599
|
<div class="toolbar ${et({expanded:this.expanded})}">
|
|
570
600
|
|
|
@@ -576,7 +606,7 @@ const et=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constru
|
|
|
576
606
|
</svg>
|
|
577
607
|
</div>
|
|
578
608
|
|
|
579
|
-
<div class="toolbar-section snippyly-logo">
|
|
609
|
+
<div class="toolbar-section snippyly-logo ${et({"d-xs-none":this.expanded})}" @click=${()=>this.toggleSnippylyPluginToolbar()}>
|
|
580
610
|
<!-- <img class="toolbar-logo"
|
|
581
611
|
src="https://drive.google.com/uc?export=view&id=1x4HyR7dk3bbCXoeWS-Sy8NZ_EI-f6nR2"> -->
|
|
582
612
|
<svg class="toolbar-logo" width="28" height="28" viewBox="0 0 20 20" fill="none"
|
|
@@ -597,7 +627,7 @@ const et=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constru
|
|
|
597
627
|
</div>
|
|
598
628
|
|
|
599
629
|
<!-- divider -->
|
|
600
|
-
<div class="toolbar-section ${et({"d-none":!this.expanded})}">
|
|
630
|
+
<div class="toolbar-section d-xs-none ${et({"d-none":!this.expanded})}">
|
|
601
631
|
<div class="toolbar-divider"></div>
|
|
602
632
|
</div>
|
|
603
633
|
|
|
@@ -797,11 +827,11 @@ const et=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constru
|
|
|
797
827
|
d="M14 23C14 24.1 14.9 25 16 25C17.1 25 18 24.1 18 23C18 21.9 17.1 21 16 21C14.9 21 14 21.9 14 23ZM14 9C14 10.1 14.9 11 16 11C17.1 11 18 10.1 18 9C18 7.9 17.1 7 16 7C14.9 7 14 7.9 14 9ZM14 16C14 17.1 14.9 18 16 18C17.1 18 18 17.1 18 16C18 14.9 17.1 14 16 14C14.9 14 14 14.9 14 16Z" />
|
|
798
828
|
</svg>
|
|
799
829
|
</div>
|
|
800
|
-
<div menu-items>
|
|
830
|
+
<div menu-items class="d-none">
|
|
801
831
|
<div @click=${()=>this.removeSnippyly()}>Exit Review Mode</div>
|
|
802
832
|
</div>
|
|
803
833
|
</snippyly-menu>
|
|
804
834
|
</div>
|
|
805
835
|
</div>
|
|
806
836
|
</div>
|
|
807
|
-
`:_``}};
|
|
837
|
+
`:_``}};mt.styles=[yt,gt],wt([tt()],mt.prototype,"loadPlugin",null),wt([tt()],mt.prototype,"comments",void 0),wt([tt()],mt.prototype,"commentElement",void 0),wt([tt()],mt.prototype,"commentSubscription",void 0),wt([tt()],mt.prototype,"selectionElement",void 0),wt([tt()],mt.prototype,"addCommentMode",void 0),wt([tt()],mt.prototype,"_expanded",void 0),wt([tt()],mt.prototype,"snippylyUser",void 0),wt([Y()],mt.prototype,"apiKey",void 0),wt([tt()],mt.prototype,"staging",void 0),wt([Y()],mt.prototype,"projectVersionKey",null),wt([tt()],mt.prototype,"projectVersion",void 0),wt([tt()],mt.prototype,"_menuOpenedId",void 0),wt([tt()],mt.prototype,"copyLinkTooltip",void 0),wt([tt()],mt.prototype,"invalidApiKey",void 0),wt([tt()],mt.prototype,"documentId",void 0),wt([tt()],mt.prototype,"isUserGlobalContact",void 0),wt([tt()],mt.prototype,"location",void 0),wt([tt()],mt.prototype,"viewMode",void 0),mt=wt([(t=>i=>"function"==typeof i?((t,i)=>(window.customElements.define(t,i),i))(t,i):((t,i)=>{const{kind:o,elements:e}=i;return{kind:o,elements:e,finisher(i){window.customElements.define(t,i)}}})(t,i))("snippyly-plugin")],mt);export{mt as SnippylyPlugin};
|