@snippyly/plugin 1.0.2 → 1.0.5

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 CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
- "name": "@snippyly/plugin",
3
- "version": "1.0.2",
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"
2
+ "name": "@snippyly/plugin",
3
+ "version": "1.0.5",
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
12
  }
package/snippyly.js CHANGED
@@ -1 +1,333 @@
1
- import*as ui from"./plugin-ui.js";import*as Constants from"./constants.js";import{cyrb53}from"./utils.js";const checkUrl=()=>{try{var t=new URL(document.location);const n=t.searchParams;if(n.has(Constants.REVIEW_MODE))if(sessionStorage.setItem(Constants.REVIEW_MODE,!0),n.has(Constants.REVIEW_DOC_ID))loadPluginUI();else{const a=new URL(document.location);a.searchParams.delete(Constants.REVIEW_MODE);var e=cyrb53(a.href);n.append(Constants.REVIEW_DOC_ID,e),window.history.replaceState({},document.title,t.href),checkUrl()}else sessionStorage.getItem(Constants.REVIEW_MODE)&&(n.append(Constants.REVIEW_MODE,!0),window.history.replaceState({},document.title,t.href),checkUrl())}catch(t){console.warn("Error in checkUrl: ",t)}},loadPluginUI=()=>{try{document.querySelector("snippyly-plugin")?ui.setDocumentId():ui.addSnippylyCdn()}catch(t){console.warn("Error in loadPluginUI: ",t)}};(()=>{let e=history.pushState,n=(history.pushState=function(){var t=e.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),t},history.replaceState);history.replaceState=function(){var t=n.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),t},window.addEventListener("popstate",()=>{window.dispatchEvent(new Event("locationchange"))})})(),checkUrl(),window.addEventListener("locationchange",()=>{checkUrl()});
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new Map;class e{constructor(t,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let i=s.get(this.cssText);return t&&void 0===i&&(s.set(this.cssText,i=new CSSStyleSheet),i.replaceSync(this.cssText)),i}toString(){return this.cssText}}const n=t?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let s="";for(const i of t.cssRules)s+=i.cssText;return(t=>new e("string"==typeof t?t:t+"",i))(s)})(t):t
7
+ /**
8
+ * @license
9
+ * Copyright 2017 Google LLC
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ */;var o;const l=window.trustedTypes,r=l?l.emptyScript:"",h=window.reactiveElementPolyfillSupport,a={toAttribute(t,i){switch(i){case Boolean:t=t?r:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},d=(t,i)=>i!==t&&(i==i||t==t),c={attribute:!0,type:String,converter:a,reflect:!1,hasChanged:d};class p extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var i;null!==(i=this.l)&&void 0!==i||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,s)=>{const e=this._$Eh(s,i);void 0!==e&&(this._$Eu.set(e,s),t.push(e))})),t}static createProperty(t,i=c){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e)}}static getPropertyDescriptor(t,i,s){return{get(){return this[i]},set(e){const n=this[t];this[i]=e,this.requestUpdate(t,n,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||c}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const s of i)this.createProperty(s,t[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)i.unshift(n(t))}else void 0!==t&&i.push(n(t));return i}static _$Eh(t,i){const s=i.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var i,s;(null!==(i=this._$Eg)&&void 0!==i?i:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.call(t))}removeController(t){var i;null===(i=this._$Eg)||void 0===i||i.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Et.set(i,this[i]),delete this[i])}))}createRenderRoot(){var i;const s=null!==(i=this.shadowRoot)&&void 0!==i?i:this.attachShadow(this.constructor.shadowRootOptions);return((i,s)=>{t?i.adoptedStyleSheets=s.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):s.forEach((t=>{const s=document.createElement("style"),e=window.litNonce;void 0!==e&&s.setAttribute("nonce",e),s.textContent=t.cssText,i.appendChild(s)}))})(s,this.constructor.elementStyles),s}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}))}attributeChangedCallback(t,i,s){this._$AK(t,s)}_$ES(t,i,s=c){var e,n;const o=this.constructor._$Eh(t,s);if(void 0!==o&&!0===s.reflect){const l=(null!==(n=null===(e=s.converter)||void 0===e?void 0:e.toAttribute)&&void 0!==n?n:a.toAttribute)(i,s.type);this._$Ei=t,null==l?this.removeAttribute(o):this.setAttribute(o,l),this._$Ei=null}}_$AK(t,i){var s,e,n;const o=this.constructor,l=o._$Eu.get(t);if(void 0!==l&&this._$Ei!==l){const t=o.getPropertyOptions(l),r=t.converter,h=null!==(n=null!==(e=null===(s=r)||void 0===s?void 0:s.fromAttribute)&&void 0!==e?e:"function"==typeof r?r:null)&&void 0!==n?n:a.fromAttribute;this._$Ei=l,this[l]=h(i,t.type),this._$Ei=null}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||d)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):e=!1),!this.isUpdatePending&&e&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,i)=>this[i]=t)),this._$Et=void 0);let i=!1;const s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(s)):this._$EU()}catch(t){throw i=!1,this._$EU(),t}i&&this._$AE(s)}willUpdate(t){}_$AE(t){var i;null===(i=this._$Eg)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$ES(i,this[i],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}
12
+ /**
13
+ * @license
14
+ * Copyright 2017 Google LLC
15
+ * SPDX-License-Identifier: BSD-3-Clause
16
+ */
17
+ var u;p.finalized=!0,p.elementProperties=new Map,p.elementStyles=[],p.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:p}),(null!==(o=globalThis.reactiveElementVersions)&&void 0!==o?o:globalThis.reactiveElementVersions=[]).push("1.3.2");const v=globalThis.trustedTypes,y=v?v.createPolicy("lit-html",{createHTML:t=>t}):void 0,g=`lit$${(Math.random()+"").slice(9)}$`,m="?"+g,w=`<${m}>`,f=document,b=(t="")=>f.createComment(t),x=t=>null===t||"object"!=typeof t&&"function"!=typeof t,C=Array.isArray,S=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$=/-->/g,k=/>/g,M=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,_=/'/g,L=/"/g,E=/^(?:script|style|textarea|title)$/i,A=(t=>(i,...s)=>({_$litType$:t,strings:i,values:s}))(1),U=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),O=new WeakMap,B=f.createTreeWalker(f,129,null,!1),R=(t,i)=>{const s=t.length-1,e=[];let n,o=2===i?"<svg>":"",l=S;for(let i=0;i<s;i++){const s=t[i];let r,h,a=-1,d=0;for(;d<s.length&&(l.lastIndex=d,h=l.exec(s),null!==h);)d=l.lastIndex,l===S?"!--"===h[1]?l=$:void 0!==h[1]?l=k:void 0!==h[2]?(E.test(h[2])&&(n=RegExp("</"+h[2],"g")),l=M):void 0!==h[3]&&(l=M):l===M?">"===h[0]?(l=null!=n?n:S,a=-1):void 0===h[1]?a=-2:(a=l.lastIndex-h[2].length,r=h[1],l=void 0===h[3]?M:'"'===h[3]?L:_):l===L||l===_?l=M:l===$||l===k?l=S:(l=M,n=void 0);const c=l===M&&t[i+1].startsWith("/>")?" ":"";o+=l===S?s+w:a>=0?(e.push(r),s.slice(0,a)+"$lit$"+s.slice(a)+g+c):s+g+(-2===a?(e.push(void 0),i):c)}const r=o+(t[s]||"<?>")+(2===i?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==y?y.createHTML(r):r,e]};class j{constructor({strings:t,_$litType$:i},s){let e;this.parts=[];let n=0,o=0;const l=t.length-1,r=this.parts,[h,a]=R(t,i);if(this.el=j.createElement(h,s),B.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(e=B.nextNode())&&r.length<l;){if(1===e.nodeType){if(e.hasAttributes()){const t=[];for(const i of e.getAttributeNames())if(i.endsWith("$lit$")||i.startsWith(g)){const s=a[o++];if(t.push(i),void 0!==s){const t=e.getAttribute(s.toLowerCase()+"$lit$").split(g),i=/([.?@])?(.*)/.exec(s);r.push({type:1,index:n,name:i[2],strings:t,ctor:"."===i[1]?H:"?"===i[1]?F:"@"===i[1]?V:Z})}else r.push({type:6,index:n})}for(const i of t)e.removeAttribute(i)}if(E.test(e.tagName)){const t=e.textContent.split(g),i=t.length-1;if(i>0){e.textContent=v?v.emptyScript:"";for(let s=0;s<i;s++)e.append(t[s],b()),B.nextNode(),r.push({type:2,index:++n});e.append(t[i],b())}}}else if(8===e.nodeType)if(e.data===m)r.push({type:2,index:n});else{let t=-1;for(;-1!==(t=e.data.indexOf(g,t+1));)r.push({type:7,index:n}),t+=g.length-1}n++}}static createElement(t,i){const s=f.createElement("template");return s.innerHTML=t,s}}function N(t,i,s=t,e){var n,o,l,r;if(i===U)return i;let h=void 0!==e?null===(n=s._$Cl)||void 0===n?void 0:n[e]:s._$Cu;const a=x(i)?void 0:i._$litDirective$;return(null==h?void 0:h.constructor)!==a&&(null===(o=null==h?void 0:h._$AO)||void 0===o||o.call(h,!1),void 0===a?h=void 0:(h=new a(t),h._$AT(t,s,e)),void 0!==e?(null!==(l=(r=s)._$Cl)&&void 0!==l?l:r._$Cl=[])[e]=h:s._$Cu=h),void 0!==h&&(i=N(t,h._$AS(t,i.values),h,e)),i}class z{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:s},parts:e}=this._$AD,n=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:f).importNode(s,!0);B.currentNode=n;let o=B.nextNode(),l=0,r=0,h=e[0];for(;void 0!==h;){if(l===h.index){let i;2===h.type?i=new P(o,o.nextSibling,this,t):1===h.type?i=new h.ctor(o,h.name,h.strings,this,t):6===h.type&&(i=new D(o,this,t)),this.v.push(i),h=e[++r]}l!==(null==h?void 0:h.index)&&(o=B.nextNode(),l++)}return n}m(t){let i=0;for(const s of this.v)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class P{constructor(t,i,s,e){var n;this.type=2,this._$AH=T,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cg=null===(n=null==e?void 0:e.isConnected)||void 0===n||n}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=N(this,t,i),x(t)?t===T||null==t||""===t?(this._$AH!==T&&this._$AR(),this._$AH=T):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 C(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!==T&&x(this._$AH)?this._$AA.nextSibling.data=t:this.k(f.createTextNode(t)),this._$AH=t}T(t){var i;const{values:s,_$litType$:e}=t,n="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=j.createElement(e.h,this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===n)this._$AH.m(s);else{const t=new z(n,this),i=t.p(this.options);t.m(s),this.k(i),this._$AH=t}}_$AC(t){let i=O.get(t.strings);return void 0===i&&O.set(t.strings,i=new j(t)),i}S(t){C(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const n of t)e===i.length?i.push(s=new P(this.M(b()),this.M(b()),this,this.options)):s=i[e],s._$AI(n),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.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 Z{constructor(t,i,s,e,n){this.type=1,this._$AH=T,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=T}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const n=this.strings;let o=!1;if(void 0===n)t=N(this,t,i,0),o=!x(t)||t!==this._$AH&&t!==U,o&&(this._$AH=t);else{const e=t;let l,r;for(t=n[0],l=0;l<n.length-1;l++)r=N(this,e[s+l],i,l),r===U&&(r=this._$AH[l]),o||(o=!x(r)||r!==this._$AH[l]),r===T?t=T:t!==T&&(t+=(null!=r?r:"")+n[l+1]),this._$AH[l]=r}o&&!e&&this.C(t)}C(t){t===T?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class H extends Z{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===T?void 0:t}}const I=v?v.emptyScript:"";class F extends Z{constructor(){super(...arguments),this.type=4}C(t){t&&t!==T?this.element.setAttribute(this.name,I):this.element.removeAttribute(this.name)}}class V extends Z{constructor(t,i,s,e,n){super(t,i,s,e,n),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=N(this,t,i,0))&&void 0!==s?s:T)===U)return;const e=this._$AH,n=t===T&&e!==T||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,o=t!==T&&(e===T||n);n&&this.element.removeEventListener(this.name,this,e),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class D{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){N(this,t)}}const J=window.litHtmlPolyfillSupport;
18
+ /**
19
+ * @license
20
+ * Copyright 2017 Google LLC
21
+ * SPDX-License-Identifier: BSD-3-Clause
22
+ */
23
+ var K,X;null==J||J(j,P),(null!==(u=globalThis.litHtmlVersions)&&void 0!==u?u:globalThis.litHtmlVersions=[]).push("2.2.6");class q extends p{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,i;const s=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=s.firstChild),s}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,i,s)=>{var e,n;const o=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:i;let l=o._$litPart$;if(void 0===l){const t=null!==(n=null==s?void 0:s.renderBefore)&&void 0!==n?n:null;o._$litPart$=l=new P(i.insertBefore(b(),t),t,void 0,null!=s?s:{})}return l._$AI(t),l})(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}}q.finalized=!0,q._$litElement$=!0,null===(K=globalThis.litElementHydrateSupport)||void 0===K||K.call(globalThis,{LitElement:q});const W=globalThis.litElementPolyfillSupport;null==W||W({LitElement:q}),(null!==(X=globalThis.litElementVersions)&&void 0!==X?X:globalThis.litElementVersions=[]).push("3.2.0");
24
+ /**
25
+ * @license
26
+ * Copyright 2017 Google LLC
27
+ * SPDX-License-Identifier: BSD-3-Clause
28
+ */
29
+ const G=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(s){s.createProperty(i.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:i.key,initializer(){"function"==typeof i.initializer&&(this[i.key]=i.initializer.call(this))},finisher(s){s.createProperty(i.key,t)}};
30
+ /**
31
+ * @license
32
+ * Copyright 2017 Google LLC
33
+ * SPDX-License-Identifier: BSD-3-Clause
34
+ */function Q(t){return(i,s)=>void 0!==s?((t,i,s)=>{i.constructor.createProperty(s,t)})(t,i,s):G(t,i)
35
+ /**
36
+ * @license
37
+ * Copyright 2017 Google LLC
38
+ * SPDX-License-Identifier: BSD-3-Clause
39
+ */}function Y(t){return Q({...t,state:!0})}
40
+ /**
41
+ * @license
42
+ * Copyright 2021 Google LLC
43
+ * SPDX-License-Identifier: BSD-3-Clause
44
+ */var tt;null===(tt=window.HTMLSlotElement)||void 0===tt||tt.prototype.assignedElements;
45
+ /**
46
+ * @license
47
+ * Copyright 2017 Google LLC
48
+ * SPDX-License-Identifier: BSD-3-Clause
49
+ */
50
+ const it=1;
51
+ /**
52
+ * @license
53
+ * Copyright 2018 Google LLC
54
+ * SPDX-License-Identifier: BSD-3-Clause
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}},lt=(t,i="localStorage")=>{try{"localStorage"===i?localStorage.removeItem(t):sessionStorage.removeItem(t)}catch(t){console.warn("Error in removeLocalStorageData: ",t)}};var rt=function(t,i,s,e){for(var n,o=arguments.length,l=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,r=t.length-1;r>=0;r--)(n=t[r])&&(l=(o<3?n(l):o>3?n(i,s,l):n(i,s))||l);return o>3&&l&&Object.defineProperty(i,s,l),l};let ht=class extends q{constructor(){super(),this._loadPlugin=!1,this.comments=[],this._expanded=!0,this.staging=false,this.copyLinkTooltip="Copy Link",this.setWindowEventListner=()=>{window.addEventListener("locationchange",(()=>{this.checkUrl()}))},this.urlChangeListener=()=>{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"))}))},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=()=>{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()}))},this.initializeSnippyly=async()=>{await(null===Snippyly||void 0===Snippyly?void 0:Snippyly.init("UnHxMCCFcclkP4bErBL1")),this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),ot("snippyly-user",!0)&&this.identifySnippyly()},this.identifySnippyly=async()=>{this.snippylyUser=JSON.parse(ot("snippyly-user",!0)),await Snippyly.identify(this.snippylyUser),this.getComments()},this.getComments=()=>{this.commentElement&&this.commentElement.getAllCommentPinAnnotationsOnCurrentDocument().subscribe((t=>{this.comments=t}))},this.toggleCommentSidebar=()=>{this.commentElement&&this.commentElement.toggleCommentSidebar()},this.toggleSnippylyPluginToolbar=()=>{this.expanded=!this.expanded},this.loginWithGoogle=()=>{window.open(`https://snippyly-login.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")},this.removeSnippyly=async()=>{try{lt("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()=>{await Snippyly.signOutUser(),lt("snippyly-user"),this.snippylyUser=void 0,window.open(`https://snippyly-login.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")},this.toggleMenu=t=>{this.menuOpenedId===t?this.menuOpenedId=void 0:this.menuOpenedId=t},this.copyLink=()=>{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)},this.expanded=!0,this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl()}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
+ <div class="snippyly-plugin-container">
58
+ <div class="snippyly-btn-container snippyly-menu-trigger ${st({opened:"snippylyMenu"===this.menuOpenedId})}" id="snippylyMenu" @click=${()=>this.toggleMenu("snippylyMenu")}>
59
+ <div class="btn snippyly-btn">
60
+ <svg class="snippyly-logo" width="19" height="18" viewBox="0 0 19 18" fill="none" xmlns="http://www.w3.org/2000/svg">
61
+ <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"/>
62
+ <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"/>
63
+ <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"/>
64
+ <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"/>
65
+ </svg>
66
+ <svg width="8" height="5" viewBox="0 0 8 5" fill="none" xmlns="http://www.w3.org/2000/svg">
67
+ <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"/>
68
+ </svg>
69
+ </div>
70
+ <div class="snippyly-menu">
71
+ <div class="menu-item" @click=${()=>this.toggleSnippylyPluginToolbar()}>${this.expanded?"Hide Toolbar":"Show Toolbar"}</div>
72
+ <div class="menu-item" @click=${()=>this.removeSnippyly()}>Exit Review Mode</div>
73
+ </div>
74
+ </div>
75
+ ${this.expanded?A`
76
+ <div class="btn comment-tool-btn ${st({disabled:!(null===(t=this.snippylyUser)||void 0===t?void 0:t.userId)})}">
77
+ <snippyly-comment-tool class="custom-tool">
78
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="btn comment-btn">
79
+ <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"/>
80
+ </svg>
81
+ </snippyly-comment-tool>
82
+ </div>
83
+ ${(null===(i=this.comments)||void 0===i?void 0:i.length)?A`
84
+ <div class="comments-counter" @click=${()=>this.toggleCommentSidebar()}>
85
+ ${null===(s=this.comments)||void 0===s?void 0:s.length} ${1===(null===(e=this.comments)||void 0===e?void 0:e.length)?"Comment":"Comments"}
86
+ </div>
87
+ `:null}
88
+ <div class="spacer"></div>
89
+ <snippyly-presence max-users="4"></snippyly-presence>
90
+ ${(null===(n=this.snippylyUser)||void 0===n?void 0:n.userId)?A`
91
+ <div class="snippyly-btn-container snippyly-menu-trigger">
92
+ <button class="btn primary-btn share-btn" @click=${()=>this.copyLink()}>
93
+ Share
94
+ </button>
95
+ <div class="snippyly-menu">
96
+ <div class="menu-item">${this.copyLinkTooltip}</div>
97
+ </div>
98
+ </div>
99
+ <div class="snippyly-btn-container snippyly-menu-trigger profile-img-container ${st({opened:"userMenu"===this.menuOpenedId})}" id="userMenu" @click=${()=>this.toggleMenu("userMenu")}>
100
+ <img src=${null===(o=this.snippylyUser)||void 0===o?void 0:o.photoUrl} class="profile-img" />
101
+ <div class="snippyly-menu">
102
+ <div class="menu-item" @click=${()=>this.signOutUser()}>Sign Out</div>
103
+ </div>
104
+ </div>
105
+ `:A`
106
+ <button class="btn primary-btn signin-btn" @click=${()=>this.loginWithGoogle()}>
107
+ Sign in
108
+ </button>
109
+ `}
110
+ `:null}
111
+ </div>
112
+ `:A``}};ht.styles=((t,...s)=>{const n=1===t.length?t[0]:s.reduce(((i,s,e)=>i+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[e+1]),t[0]);return new e(n,i)})`
113
+ :host(.visible) {
114
+ display: flex;
115
+ padding: 16px;
116
+ border: 1px solid rgba(0, 0, 0, 0.12);
117
+ background: white;
118
+ border-radius: 8px;
119
+ position: fixed;
120
+ bottom: 0px;
121
+ right: 0px;
122
+ margin: 24px;
123
+ height: 72px;
124
+ box-sizing: border-box;
125
+ align-items: center;
126
+ z-index: 999999995;
127
+ box-shadow: 0 1rem 3rem #0000002d;
128
+ }
129
+
130
+ :host(.expanded) {
131
+ min-width: 450px;
132
+ }
133
+
134
+ .snippyly-plugin-container {
135
+ display: flex;
136
+ align-items: center;
137
+ width: 100%;
138
+ }
139
+
140
+ .snippyly-btn, .comment-tool-btn {
141
+ height: 28px;
142
+ padding: 8px;
143
+ border-radius: 8px;
144
+ cursor: pointer;
145
+ }
146
+
147
+ .snippyly-btn:hover, .comment-tool-btn:not(.disabled):hover, .comments-counter:hover {
148
+ background: #f0f0f0;
149
+ }
150
+
151
+ .snippyly-btn {
152
+ display: flex;
153
+ align-items: center;
154
+ }
155
+
156
+ .snippyly-logo {
157
+ margin-right: 8px;
158
+ }
159
+
160
+ .comment-tool-btn, .comment-tool-btn .custom-btn-container {
161
+ display: flex;
162
+ align-items: center;
163
+ }
164
+
165
+ .comment-tool-btn.disabled, .comment-tool-btn.disabled .btn {
166
+ cursor: not-allowed;
167
+ }
168
+
169
+ .comment-tool-btn.disabled .comment-btn path {
170
+ fill: #979797;
171
+ }
172
+
173
+ .comments-counter {
174
+ border: 1px solid #B6B1B1;
175
+ border-radius: 6px;
176
+ padding: 8px;
177
+ cursor: pointer;
178
+ }
179
+
180
+ .btn {
181
+ cursor: pointer;
182
+ }
183
+
184
+ .primary-btn {
185
+ height: 36px;
186
+ background: rgb(24, 160, 251);
187
+ border-radius: 6px;
188
+ border: 0;
189
+ box-shadow: none;
190
+ outline: none;
191
+ padding: 0 12px;
192
+ color: white;
193
+ /* margin: 0 12px; */
194
+ }
195
+
196
+ .profile-img-container {
197
+ display: flex;
198
+ }
199
+
200
+ .profile-img {
201
+ width: 36px;
202
+ height: 36px;
203
+ border-radius: 50px;
204
+ cursor: pointer;
205
+ /* margin: 0 12px; */
206
+ }
207
+
208
+ .snippyly-plugin-container > * {
209
+ margin: 0 6px;
210
+ }
211
+
212
+ .snippyly-plugin-container > *:first-child {
213
+ margin-left: 0px !important;
214
+ }
215
+
216
+ .snippyly-plugin-container > *:last-child {
217
+ margin-right: 0px !important;
218
+ }
219
+
220
+ .spacer {
221
+ flex: 1 0 auto;
222
+ }
223
+
224
+ .snippyly-menu-trigger {
225
+ position: relative;
226
+ }
227
+
228
+ .snippyly-menu {
229
+ position: absolute;
230
+ background: black;
231
+ color: white;
232
+ top: -64px;
233
+ left: 50%;
234
+ white-space: nowrap;
235
+ /* width: 150px; */
236
+ transform: translateX(-50%);
237
+ display: none;
238
+ border-radius: 4px;
239
+ }
240
+
241
+ .snippyly-menu:after {
242
+ content: '';
243
+ position: absolute;
244
+ display: block;
245
+ width: 0px;
246
+ z-index: 1;
247
+ border-style: solid;
248
+ border-color: rgb(0, 0, 0) transparent;
249
+ border-width: 8px 8px 0px;
250
+ bottom: -8px;
251
+ left: 50%;
252
+ transform: translateX(-50%);
253
+ }
254
+
255
+ .snippyly-menu-trigger:hover .snippyly-menu, .snippyly-menu-trigger.opened .snippyly-menu {
256
+ display: block;
257
+ }
258
+
259
+ :host(.expanded) #snippylyMenu.snippyly-menu-trigger .snippyly-menu:after {
260
+ left: 32px;
261
+ }
262
+
263
+ :host(:not(.expanded)) #snippylyMenu.snippyly-menu-trigger .snippyly-menu {
264
+ left: 0px;
265
+ }
266
+
267
+ :host(.expanded) #snippylyMenu.snippyly-menu-trigger .snippyly-menu {
268
+ left: 48px;
269
+ }
270
+
271
+ #snippylyMenu.snippyly-menu-trigger .snippyly-menu {
272
+ top: -94px;
273
+ }
274
+
275
+ :host(:not(.expanded)) #snippylyMenu.snippyly-menu-trigger .snippyly-menu:after {
276
+ left: unset;
277
+ right: 24px;
278
+ }
279
+
280
+ .menu-item {
281
+ padding: 8px;
282
+ cursor: pointer;
283
+ }
284
+
285
+ .s-presence-container {
286
+ display: inline-flex;
287
+ flex-direction: row-reverse;
288
+ align-items: center;
289
+ }
290
+
291
+ .s-presence-avatar {
292
+ position: relative;
293
+ box-shadow: 0px 0px 0px 3px;
294
+ border-radius: 50%;
295
+ overflow: hidden;
296
+ width: 24px;
297
+ height: 24px;
298
+ display: flex;
299
+ align-items: center;
300
+ justify-content: center;
301
+ font-size: 12px;
302
+ // background-color: white;
303
+ }
304
+
305
+ .s-presence-avatar.more-users {
306
+ background: #4578a7;
307
+ box-shadow: 0px 0px 0px 3px #4578a7;
308
+ }
309
+
310
+ .s-presence-avatar:not(:last-child):not(.more-users) {
311
+ margin-left: -6px !important;
312
+ }
313
+
314
+ .s-presence-avatar-image {
315
+ width: 100%;
316
+ height: auto;
317
+ display: block;
318
+ }
319
+
320
+ .s-presence-avatar-image-small {
321
+ width: 1.6rem;
322
+ height: auto;
323
+ display: block;
324
+ }
325
+
326
+ .s-presence-avatar-initial {
327
+ color: white;
328
+ }
329
+
330
+ .away {
331
+ filter: grayscale(1);
332
+ }
333
+ `,rt([Y()],ht.prototype,"loadPlugin",null),rt([Y()],ht.prototype,"comments",void 0),rt([Y()],ht.prototype,"commentElement",void 0),rt([Y()],ht.prototype,"_expanded",void 0),rt([Y()],ht.prototype,"snippylyUser",void 0),rt([Q()],ht.prototype,"apiKey",void 0),rt([Y()],ht.prototype,"staging",void 0),rt([Y()],ht.prototype,"menuOpenedId",void 0),rt([Y()],ht.prototype,"copyLinkTooltip",void 0),ht=rt([(t=>i=>"function"==typeof i?((t,i)=>(window.customElements.define(t,i),i))(t,i):((t,i)=>{const{kind:s,elements:e}=i;return{kind:s,elements:e,finisher(i){window.customElements.define(t,i)}}})(t,i))("snippyly-plugin")],ht);export{ht as SnippylyPlugin};
package/constants.js DELETED
@@ -1,158 +0,0 @@
1
- const REVIEW_MODE="review-mode",REVIEW_DOC_ID="review-doc-id",TAGS={SNIPPYLY_PLUGIN:"snippyly-plugin",SNIPPYLY_ROOT:"snippyly-root",SNIPPYLY_PRESENCE:"snippyly-presence",SNIPPYLY_CURSOR:"snippyly-cursor",SNIPPYLY_COMMENT_TOOL:"snippyly-comment-tool",SNIPPYLY_COMMENTS:"snippyly-comments",SNIPPYLY_TEXT_HIGHLIGHT:"snippyly-text-highlight",SNIPPYLY_COMMENTS_SIDEBAR:"snippyly-comments-sidebar"},ICONS={GOOGLE:`
2
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
3
- <g transform="matrix(1, 0, 0, 1, 27.009001, -39.238998)">
4
- <path fill="#4285F4" d="M -3.264 51.509 C -3.264 50.719 -3.334 49.969 -3.454 49.239 L -14.754 49.239 L -14.754 53.749 L -8.284 53.749 C -8.574 55.229 -9.424 56.479 -10.684 57.329 L -10.684 60.329 L -6.824 60.329 C -4.564 58.239 -3.264 55.159 -3.264 51.509 Z"/>
5
- <path fill="#34A853" d="M -14.754 63.239 C -11.514 63.239 -8.804 62.159 -6.824 60.329 L -10.684 57.329 C -11.764 58.049 -13.134 58.489 -14.754 58.489 C -17.884 58.489 -20.534 56.379 -21.484 53.529 L -25.464 53.529 L -25.464 56.619 C -23.494 60.539 -19.444 63.239 -14.754 63.239 Z"/>
6
- <path fill="#FBBC05" d="M -21.484 53.529 C -21.734 52.809 -21.864 52.039 -21.864 51.239 C -21.864 50.439 -21.724 49.669 -21.484 48.949 L -21.484 45.859 L -25.464 45.859 C -26.284 47.479 -26.754 49.299 -26.754 51.239 C -26.754 53.179 -26.284 54.999 -25.464 56.619 L -21.484 53.529 Z"/>
7
- <path fill="#EA4335" d="M -14.754 43.989 C -12.984 43.989 -11.404 44.599 -10.154 45.789 L -6.734 42.369 C -8.804 40.429 -11.514 39.239 -14.754 39.239 C -19.444 39.239 -23.494 41.939 -25.464 45.859 L -21.484 48.949 C -20.534 46.099 -17.884 43.989 -14.754 43.989 Z"/>
8
- </g>
9
- </svg>
10
- `,PIN:`
11
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-geo-alt-fill" viewBox="0 0 16 16">
12
- <path d="M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10zm0-7a3 3 0 1 1 0-6 3 3 0 0 1 0 6z"></path>
13
- </svg>
14
- `,SHARE:`
15
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
16
- class="bi bi-share-fill" viewBox="0 0 16 16">
17
- <path
18
- d="M11 2.5a2.5 2.5 0 1 1 .603 1.628l-6.718 3.12a2.499 2.499 0 0 1 0 1.504l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.256l6.718-3.12A2.5 2.5 0 0 1 11 2.5z" />
19
- </svg>
20
- `,SIGNOUT:`
21
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
22
- <path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0v2z"/>
23
- <path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3z"/>
24
- </svg>
25
- `,CLOSE:`
26
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
27
- <path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>
28
- </svg>
29
- `,TRASH:`
30
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16">
31
- <path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1H2.5zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zM8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5zm3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0z"/>
32
- </svg>
33
- `,SNIPPYLY:`
34
- <svg xmlns="http://www.w3.org/2000/svg" width="150" height="150" viewBox="0 0 165 150" fill="none">
35
- <path d="M64.1815 1.85957C59.9002 0.028852 55.1655 -0.464714 50.5987 0.443652C46.0319 1.35202 41.8464 3.61987 38.5915 6.94957C35.2666 10.2075 33.002 14.3928 32.0939 18.9584C31.1858 23.5239 31.6764 28.2573 33.5015 32.5396C35.2405 36.8543 38.2411 40.5439 42.111 43.1256C45.9809 45.7073 50.5398 47.061 55.1915 47.0096H78.6715V23.5496C78.7227 18.8952 77.3666 14.334 74.781 10.4636C72.1954 6.59321 68.5008 3.59419 64.1815 1.85957V1.85957Z" fill="#FFCB00"/>
36
- <path d="M149.732 31.0096C144.239 25.5215 137.243 21.784 129.627 20.2691C122.012 18.7541 114.118 19.5296 106.943 22.4977C99.7679 25.4657 93.6332 30.4932 89.3133 36.9453C84.9935 43.3974 82.6823 50.9849 82.6715 58.7496V98.0096H122.012C129.799 98.0918 137.43 95.8208 143.905 91.4939C150.38 87.167 155.398 80.9859 158.301 73.7596C161.337 66.5983 162.143 58.6883 160.614 51.062C159.085 43.4358 155.293 36.4476 149.732 31.0096V31.0096Z" fill="#FF7162"/>
37
- <path d="M127.852 116.53C126.113 112.21 123.112 108.515 119.241 105.928C115.369 103.341 110.807 101.983 106.152 102.03H82.6715V125.51C82.6225 130.165 83.9806 134.726 86.5679 138.596C89.1552 142.467 92.8511 145.465 97.1715 147.2C100.062 148.415 103.166 149.044 106.302 149.05C110.151 149.01 113.931 148.029 117.313 146.191C120.695 144.353 123.575 141.714 125.702 138.505C127.828 135.296 129.136 131.616 129.51 127.785C129.885 123.954 129.316 120.089 127.852 116.53V116.53Z" fill="#0DCF82"/>
38
- <path d="M3.10152 75.2796C0.0453598 82.4433 -0.776403 90.363 0.743827 98.0016C2.26406 105.64 6.05543 112.642 11.6215 118.09C15.2126 121.748 19.4944 124.658 24.2185 126.649C28.9425 128.64 34.0149 129.674 39.1415 129.69C44.3888 129.678 49.5819 128.628 54.4215 126.6C61.6486 123.697 67.8306 118.68 72.1576 112.204C76.4847 105.729 78.7551 98.0973 78.6715 90.3096V51.0096H39.3915C31.6018 50.9289 23.9694 53.2029 17.4939 57.5335C11.0185 61.8641 6.002 68.0496 3.10152 75.2796V75.2796Z" fill="#A259FE"/>
39
- </svg>
40
- `},styles=`
41
- .snippyly-plugin-container {
42
- display: flex;
43
- border: 1px solid lightgrey;
44
- border-radius: 8px;
45
- position: fixed;
46
- bottom: 0;
47
- right: 0;
48
- margin: 24px;
49
- min-height: 48px;
50
- align-items: center;
51
- z-index: 999999999;
52
- background: white;
53
- }
54
-
55
- .snippyly-feature-block {
56
- padding: 8px;
57
- cursor: pointer;
58
- display: flex;
59
- align-items: center;
60
- }
61
-
62
- #snippylyPlugin .snippyly-feature-block.snippyly-toggle-btn {
63
- display: none;
64
- }
65
-
66
- #snippylyPlugin.show .snippyly-feature-block {
67
- display: flex;
68
- }
69
-
70
- #snippylyPlugin.show .snippyly-feature-block.snippyly-toggle-btn {
71
- display: none;
72
- }
73
-
74
- #snippylyPlugin.hide .snippyly-feature-block {
75
- display: none !important;
76
- }
77
-
78
- #snippylyPlugin.hide .snippyly-feature-block.snippyly-toggle-btn {
79
- display: flex !important;
80
- }
81
-
82
- .snippyly-feature-block.disabled {
83
- cursor: not-allowed;
84
- }
85
-
86
- .snippyly-feature-block.comment-btn:not(.disabled):hover svg {
87
- fill: #a259fe;
88
- }
89
-
90
- .snippyly-feature-block.share-btn:hover svg {
91
- fill: rgb(13, 207, 130);
92
- }
93
-
94
- .snippyly-feature-block.close-btn:hover svg {
95
- fill: rgb(255, 113, 98);
96
- }
97
-
98
- .snippyly-feature-block.remove-btn:hover svg {
99
- fill: red;
100
- }
101
-
102
- .snippyly-feature-block svg {
103
- height: 24px;
104
- width: 24px;
105
- }
106
-
107
- .snippyly-feature-block img {
108
- height: 28px;
109
- width: 28px;
110
- border-radius: 100px;
111
- }
112
-
113
- /* The snackbar - position it at the bottom and in the middle of the screen */
114
- #snackbar {
115
- visibility: hidden; /* Hidden by default. Visible on click */
116
- min-width: 250px; /* Set a default minimum width */
117
- margin-left: -125px; /* Divide value of min-width by 2 */
118
- background-color: #333; /* Black background color */
119
- color: #fff; /* White text color */
120
- text-align: center; /* Centered text */
121
- border-radius: 2px; /* Rounded borders */
122
- padding: 16px; /* Padding */
123
- position: fixed; /* Sit on top of the screen */
124
- z-index: 1; /* Add a z-index if needed */
125
- left: 50%; /* Center the snackbar */
126
- bottom: 30px; /* 30px from the bottom */
127
- }
128
-
129
- /* Show the snackbar when clicking on a button (class added with JavaScript) */
130
- #snackbar.show {
131
- visibility: visible; /* Show the snackbar */
132
- /* Add animation: Take 0.5 seconds to fade in and out the snackbar.
133
- However, delay the fade out process for 2.5 seconds */
134
- -webkit-animation: fadein 0.5s, fadeout 0.5s 1.6s;
135
- animation: fadein 0.5s, fadeout 0.5s 1.6s;
136
- }
137
-
138
- /* Animations to fade the snackbar in and out */
139
- @-webkit-keyframes fadein {
140
- from {bottom: 0; opacity: 0;}
141
- to {bottom: 30px; opacity: 1;}
142
- }
143
-
144
- @keyframes fadein {
145
- from {bottom: 0; opacity: 0;}
146
- to {bottom: 30px; opacity: 1;}
147
- }
148
-
149
- @-webkit-keyframes fadeout {
150
- from {bottom: 30px; opacity: 1;}
151
- to {bottom: 0; opacity: 0;}
152
- }
153
-
154
- @keyframes fadeout {
155
- from {bottom: 30px; opacity: 1;}
156
- to {bottom: 0; opacity: 0;}
157
- }
158
- `;export{REVIEW_MODE,REVIEW_DOC_ID,TAGS,ICONS,styles};
package/firebase.js DELETED
@@ -1 +0,0 @@
1
- import{initializeApp}from"https://www.gstatic.com/firebasejs/9.8.3/firebase-app.js";import{getAuth,onAuthStateChanged,signOut}from"https://www.gstatic.com/firebasejs/9.8.3/firebase-auth.js";const firebaseConfig={apiKey:"AIzaSyAzcW2n1JhY_zhkXmuFcwe550AkwmYeJ0w",authDomain:"snipply-sdk-staging.firebaseapp.com",projectId:"snipply-sdk-staging",storageBucket:"snipply-sdk-staging.appspot.com",messagingSenderId:"877538579326",appId:"1:877538579326:web:f793f73f2b7dc770c4992f"},app=initializeApp(firebaseConfig),auth=getAuth(app),getUser=t=>{onAuthStateChanged(auth,t)},signOutUser=()=>{signOut(auth)};export{getUser,signOutUser};
package/plugin-ui.js DELETED
@@ -1,3 +0,0 @@
1
- import*as firebase from"./firebase.js";import*as Constants from"./constants.js";let snippylyUser,commentBtnTool,commentBtn,shareBtn,loginBtn,logoutBtn,closeBtn,removeBtn,snippylyBtn,snackbar;const initializeSnippyly=async()=>{try{window.SNIPPYLY_API_KEY?window.Snippyly&&(await Snippyly.init(window.SNIPPYLY_API_KEY),Snippyly.getCommentElement().enableTextComments(!0),Snippyly.getCommentElement().enableSignInButton(!0),setDocumentId(),getUser(),addPluginUI()):console.warn("Snippyly api key is not added.")}catch(e){console.warn("Error in initializeSnippyly: ",e)}},addPluginUI=()=>{try{const t=document.createElement("snippyly-plugin"),s=(t.attachShadow({mode:"open"}),t.shadowRoot),o=document.createElement("div"),i=(o.id="snippylyPlugin",o.classList.add("snippyly-plugin-container","show"),commentBtnTool=document.createElement("snippyly-comment-tool"),(commentBtn=document.createElement("div")).classList.add("snippyly-feature-block","comment-btn","disabled"),commentBtn.innerHTML=Constants.ICONS.PIN,commentBtnTool.appendChild(commentBtn),(shareBtn=document.createElement("div")).classList.add("snippyly-feature-block","share-btn"),shareBtn.addEventListener("click",()=>{navigator.clipboard.writeText(window.location.href),showSnackbar("Link copied!")}),shareBtn.innerHTML=Constants.ICONS.SHARE,(loginBtn=document.createElement("div")).classList.add("snippyly-feature-block"),loginBtn.addEventListener("click",()=>{snippylyUser?.userId||loginWithGoogle()}),loginBtn.innerHTML=Constants.ICONS.GOOGLE,(logoutBtn=document.createElement("div")).classList.add("snippyly-feature-block"),logoutBtn.style.display="none",logoutBtn.addEventListener("click",()=>{snippylyUser?.userId&&signOutUser()}),logoutBtn.innerHTML=Constants.ICONS.SIGNOUT,(closeBtn=document.createElement("div")).classList.add("snippyly-feature-block","close-btn"),closeBtn.addEventListener("click",()=>{const e=s.getElementById("snippylyPlugin");e&&(e.classList.contains("show")?(e.classList.remove("show"),e.classList.add("hide")):(e.classList.remove("hide"),e.classList.add("show")))}),closeBtn.innerHTML=Constants.ICONS.CLOSE,(removeBtn=document.createElement("div")).classList.add("snippyly-feature-block","remove-btn"),removeBtn.addEventListener("click",()=>{removeSnippyly()}),removeBtn.innerHTML=Constants.ICONS.TRASH,(snippylyBtn=document.createElement("div")).classList.add("snippyly-feature-block","snippyly-toggle-btn"),snippylyBtn.addEventListener("click",()=>{const e=s.getElementById("snippylyPlugin");e&&(e.classList.contains("show")?(e.classList.remove("show"),e.classList.add("hide")):(e.classList.remove("hide"),e.classList.add("show")))}),snippylyBtn.innerHTML=Constants.ICONS.SNIPPYLY,(snackbar=document.createElement("div")).id="snackbar",o.appendChild(commentBtnTool),o.appendChild(shareBtn),o.appendChild(loginBtn),o.appendChild(logoutBtn),o.appendChild(closeBtn),o.appendChild(removeBtn),o.appendChild(snippylyBtn),o.appendChild(snackbar),window.document.body.appendChild(t),document.createElement("style")),l=(i.innerHTML=Constants.styles,s.appendChild(i),s.appendChild(o),document.createElement("snippyly-comments"));l.addEventListener("signIn",()=>{loginWithGoogle()}),document.body.appendChild(l);var e=document.createElement("snippyly-comments-sidebar"),n=(document.body.appendChild(e),document.createElement("snippyly-cursor"));document.body.appendChild(n)}catch(e){console.warn("Error in addPluginUI: ",e)}},addSnippylyCdn=()=>{try{if(document.getElementById("snippylyScript"))initializeSnippyly&&initializeSnippyly();else{const t=document.createElement("script");var e=window.SNIPPYLY_VERSION||"latest",n=!!window.SNIPPYLY_STAGING;t.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${n?"-staging":""}@${e}/snippyly.js`,t.id="snippylyScript",t.type="module",document.body.appendChild(t),t.onload=()=>{initializeSnippyly&&initializeSnippyly()}}}catch(e){console.warn("Error in addSnippylyCdn: ",e)}},setDocumentId=()=>{try{const e=new URL(document.location).searchParams;e.has(Constants.REVIEW_DOC_ID)&&Snippyly.setDocumentId(e.get(Constants.REVIEW_DOC_ID))}catch(e){console.warn("Error in setDocumentId: ",e)}},getUser=()=>{try{firebase.getUser(e=>{try{console.log("get user",e),e?snippylyUser?.userId||((snippylyUser={}).userId=e.uid,snippylyUser.name=e.displayName,snippylyUser.email=e.email,snippylyUser.photoUrl=e?.photoURL,snippylyUser.contacts=window.SNIPPYLY_USER_CONTACTS||[],identifyUser()):disableButtons()}catch(e){console.warn("Error in getUser callback: ",e)}})}catch(e){console.warn("Error in getUser: ",e)}},loginWithGoogle=()=>{showGoogleLogin()},signOutUser=()=>{try{Snippyly.signOutUser(),firebase.signOutUser(),snippylyUser={},showUser()}catch(e){console.warn("Error in signOutUser: ",e)}},identifyUser=async()=>{try{snippylyUser?.userId&&(await Snippyly.identify(snippylyUser),showUser(),enableButtons())}catch(e){console.warn("Error in identifyUser: ",e)}},showUser=()=>{try{snippylyUser?.userId?(loginBtn.innerHTML=`
2
- <img src="${snippylyUser?.photoUrl}" title="${snippylyUser?.name}" class="user-profile-img" />
3
- `,logoutBtn.style.display="flex"):(loginBtn.innerHTML=Constants.ICONS.GOOGLE,logoutBtn.style.display="none")}catch(e){console.warn("Error in showUser: ",e)}},enableButtons=()=>{commentBtn.classList.remove("disabled")},disableButtons=()=>{commentBtn.classList.add("disabled")},showSnackbar=e=>{try{snackbar.innerText=e,snackbar.className="show",setTimeout(()=>{snackbar.className=snackbar.className.replace("show","")},2e3)}catch(e){console.warn("Error in showSnackbar: ",e)}},showGoogleLogin=()=>{removeGoogleLoginIframe();const e=document.createElement("iframe");e.style.display="none",e.id="googleLoginIframe",e.src="https://firebasestorage.googleapis.com/v0/b/snipply-sdk-staging.appspot.com/o/google-login.html?alt=media&token=5f8904c6-60fb-4417-a666-5df9b07b1f7c",document.body.appendChild(e)},removeGoogleLoginIframe=()=>{const e=document.getElementById("googleLoginIframe");e&&e.remove()},removeSnippyly=()=>{try{removeGoogleLoginIframe();const n=document.getElementById("snippylyScript");n&&n.remove(),sessionStorage.removeItem(Constants.REVIEW_MODE);var e=new URL(document.location);const t=e.searchParams;t.delete(Constants.REVIEW_DOC_ID),t.delete(Constants.REVIEW_MODE),window.history.replaceState({},document.title,e.href),window.location.reload()}catch(e){console.warn("Error in removeSnippyly: ",e)}};window.addEventListener("message",e=>{try{var n,t=JSON.parse(e.data);t&&"snippylyGoogleLogin"===t.type&&(console.log("user in plugin",t.user),(n=t.user)&&((snippylyUser={}).userId=n.uid,snippylyUser.name=n.displayName,snippylyUser.email=n.email,snippylyUser.photoUrl=n?.photoURL,snippylyUser.contacts=window.SNIPPYLY_USER_CONTACTS||[],identifyUser()),removeGoogleLoginIframe())}catch(e){}});export{initializeSnippyly,addPluginUI,addSnippylyCdn,setDocumentId};
package/utils.js DELETED
@@ -1 +0,0 @@
1
- const cyrb53=(a,t=0)=>{try{let h=3735928559^t,l=1103547991^t;for(let t=0,r;t<a.length;t++)r=a.charCodeAt(t),h=Math.imul(h^r,2654435761),l=Math.imul(l^r,1597334677);return h=Math.imul(h^h>>>16,2246822507)^Math.imul(l^l>>>13,3266489909),4294967296*(2097151&(l=Math.imul(l^l>>>16,2246822507)^Math.imul(h^h>>>13,3266489909)))+(h>>>0)}catch(t){return Console.catch("Error in cyrb53: ",t),0}};export{cyrb53};