@snippyly/plugin-staging 1.0.924 → 1.0.925
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-live.min.js +1 -1
- package/snippyly-toolbar.js +169 -164
- package/snippyly-toolbar.min.js +168 -163
- package/snippyly.js +1 -1
- package/snippyly.min.js +1 -1
package/package.json
CHANGED
package/snippyly-live.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t){const e="1.0.
|
|
1
|
+
!function(t){const e="1.0.783",n=["review","feedback"],i="sf_review",r=["invalid","expired","revoked","exhausted","origin-mismatch","disabled","not-found","rate-limited","internal"],o=["invalid","expired","revoked","exhausted"];async function s(t,e,n){try{const i=await t.fetchFn(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{subEventType:e,...n}})});if(!i||!i.ok)return{kind:"transport"};let r;try{r=await i.json()}catch(t){return{kind:"transport"}}const o=r&&"object"==typeof r?r.result:void 0;if(null==o||"object"!=typeof o)return{kind:"transport"};const s=o.error;return s&&"object"==typeof s?{kind:"error",code:a(s.code)}:{kind:"ok",result:o}}catch(t){return{kind:"transport"}}}function a(t){try{return"string"==typeof t&&r.includes(t)?t:"internal"}catch(t){return"internal"}}const c="superflow-live",d="Superflow",l="Continue to request changes on this site",h="Continue",u="Continuing...",f="Not now",p="This link has expired.",v="Send me a fresh one",w="Sending...",y="Check your email.",g="Could not send. Try again.";function b(t,e,n={}){const i=t.createElement(e);return n.className&&(i.className=n.className),void 0!==n.text&&(i.textContent=n.text),n.testId&&i.setAttribute("data-testid",n.testId),n.attrs&&Object.keys(n.attrs).forEach((t=>i.setAttribute(t,n.attrs[t]))),i}function m(t,e,n,i="sf-btn"){return b(t,"button",{className:i,text:e,testId:n,attrs:{type:"button"}})}class x{constructor(t){this.host=null,this.root=null,this.warned=new Set,this.deps=t,this.api=function(t){const e=t.origin;return{redeemLiveReviewToken:n=>s(t,"redeemLiveReviewToken",{token:n,origin:e,userAgent:t.userAgent}),requestFreshLink:n=>s(t,"requestFreshLink",{token:n,origin:e})}}({fetchFn:t.fetchFn,endpoint:t.endpoint,origin:this.origin(),userAgent:t.userAgent})}async start(){var t;try{const{doc:e,win:n}=this.deps;if(e.querySelector(c))return"skipped";const r=new URLSearchParams((null===(t=n.location)||void 0===t?void 0:t.search)||"").get(i);return r?(this.showPrompt(r),"prompt"):"none"}catch(t){return this.warn("start failed, drawing nothing",t),"none"}}showPrompt(t){try{const e=this.deps.doc,n=this.ensureRoot(),i=b(e,"div",{className:"sf-ui sf-card-box",testId:"sf-live-prompt",attrs:{role:"dialog"}});i.appendChild(b(e,"div",{className:"sf-brand",text:d})),i.appendChild(b(e,"div",{text:l,attrs:{style:"margin-top:6px"}}));const r=b(e,"div",{className:"sf-row"}),o=m(e,h,"sf-live-continue"),s=m(e,f,"sf-live-not-now","sf-btn sf-btn--ghost");r.appendChild(o),r.appendChild(s),i.appendChild(r),o.addEventListener("click",(()=>{this.redeem(t,i,o)})),s.addEventListener("click",(()=>{this.dismissPrompt(i)})),n.appendChild(i)}catch(t){this.warn("showPrompt failed",t)}}dismissPrompt(t){try{t.remove(),this.teardownIfEmpty()}catch(t){this.warn("dismissPrompt failed",t)}}async redeem(t,e,n){try{if(n.disabled)return;n.disabled=!0,n.textContent=u;const i=await this.api.redeemLiveReviewToken(t);if("ok"===i.kind)return void this.acceptGrant(i.result.session,e);if("error"===i.kind&&o.includes(i.code))return void this.showExpired(t,e);e.remove(),this.teardownIfEmpty(),this.warn(`redeem refused (${"error"===i.kind?i.code:"transport"})`)}catch(t){this.warn("redeem failed",t),e.remove(),this.teardownIfEmpty()}}acceptGrant(t,e){try{if("string"!=typeof t||!t)return this.warn("redeem answered without a session"),e.remove(),void this.teardownIfEmpty();if(!this.storeSession(t))return e.remove(),void this.teardownIfEmpty();this.clearStoredToolbarFlags(),this.stripTokenFromLocation(),e.remove(),this.teardownIfEmpty(),this.reload()}catch(t){this.warn("acceptGrant failed",t)}}showExpired(t,e){try{const n=this.deps.doc;!function(t){for(;t.firstChild;)t.removeChild(t.firstChild)}(e),e.setAttribute("data-testid","sf-live-expired"),e.appendChild(b(n,"div",{className:"sf-brand",text:d}));const i=b(n,"div",{text:p,testId:"sf-live-expired-line",attrs:{style:"margin-top:6px"}});e.appendChild(i);const r=b(n,"div",{className:"sf-row"}),o=m(n,v,"sf-live-fresh-link");r.appendChild(o),e.appendChild(r),o.addEventListener("click",(()=>{this.requestFreshLink(t,i,o)}))}catch(t){this.warn("showExpired failed",t)}}async requestFreshLink(t,e,n){try{if(n.disabled)return;n.disabled=!0,n.textContent=w;const i=await this.api.requestFreshLink(t);if("ok"===i.kind&&i.result&&i.result.sent)return e.textContent=y,void n.remove();e.textContent=g,n.disabled=!1,n.textContent=v}catch(t){this.warn("requestFreshLink failed",t),e.textContent=g,n.disabled=!1,n.textContent=v}}ensureRoot(){if(this.root)return this.root;const t=this.deps.doc,e=b(t,c,{attrs:{"data-sf-live":this.deps.version}});e.style.cssText="position:absolute;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483577;";const n=e.attachShadow({mode:"open"}),i=t.createElement("style");return this.deps.nonce&&(i.nonce=this.deps.nonce),i.textContent='\n:host { all: initial; }\n* { box-sizing: border-box; }\n.sf-ui {\n font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;\n font-size: 14px;\n line-height: 1.4;\n color: #16202a;\n -webkit-font-smoothing: antialiased;\n}\n/*\n * The prompt and expired cards sit above the bottom-right corner, where site\n * builders put their own badge ("Made in Framer" is about 56px tall at a 16px\n * offset, Webflow\'s about 50px): 96px keeps the card\'s buttons clear of both.\n */\n.sf-card-box {\n position: fixed;\n right: 16px;\n bottom: 96px;\n width: 300px;\n max-width: calc(100vw - 32px);\n background: #fff;\n border: 1px solid #e3e8ee;\n border-radius: 10px;\n box-shadow: 0 8px 24px rgba(22, 32, 42, 0.16);\n padding: 14px 16px;\n}\n.sf-brand {\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n color: #5b6b7a;\n}\n.sf-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }\n.sf-btn {\n font: inherit;\n font-weight: 600;\n border: 1px solid #16202a;\n border-radius: 8px;\n background: #16202a;\n color: #fff;\n padding: 7px 12px;\n cursor: pointer;\n}\n.sf-btn:disabled { opacity: 0.6; cursor: default; }\n.sf-btn--ghost { background: #fff; color: #16202a; }\n',n.appendChild(i),(t.documentElement||t.body).appendChild(e),this.host=e,this.root=n,n}origin(){var t;try{return(null===(t=this.deps.win.location)||void 0===t?void 0:t.origin)||""}catch(t){return""}}storeSession(t){try{return this.deps.storage?(this.deps.storage.setItem("_sfls",t),!0):(this.warn("could not store the live session (no storage)"),!1)}catch(t){return this.warn("could not store the live session",t),!1}}clearStoredToolbarFlags(){try{if(!this.deps.storage)return;for(const t of n)this.deps.storage.removeItem(t)}catch(t){this.warn("could not clear the stored review flags",t)}}teardownIfEmpty(){try{this.host&&this.root&&this.root.children.length<=1&&(this.host.remove(),this.host=null,this.root=null)}catch(t){this.warn("teardownIfEmpty failed",t)}}stripTokenFromLocation(){var t;try{const e=this.deps.win,n=(null===(t=e.location)||void 0===t?void 0:t.href)||"",r=function(t){try{const e=new URL(t);return e.searchParams.delete(i),e.toString()}catch(e){return t}}(n);r!==n&&e.history&&"function"==typeof e.history.replaceState&&e.history.replaceState(e.history.state,"",r)}catch(t){this.warn("could not strip the token from the URL",t)}}reload(){try{this.deps.reload()}catch(t){this.warn("could not reload the page",t)}}warn(t,e){try{if(this.warned.has(t))return;this.warned.add(t),void 0===e?console.warn(`[superflow live] ${t}`):console.warn(`[superflow live] ${t}:`,e)}catch(t){}}}function k(t){const n=t;try{return n.SuperflowLive||(n.SuperflowLive={version:e,ready:!1}),n.SuperflowLive}catch(t){return console.warn("[superflow live] registerLiveBundle failed:",t),{version:e,ready:!1}}}function L(t){try{const e=t.getElementById("superflowToolbarScript");if(!e||!e.src)return{apiKey:null,projectId:null};const n=new URL(e.src).searchParams;return{apiKey:n.get("apiKey"),projectId:n.get("projectId")}}catch(t){return{apiKey:null,projectId:null}}}function I(t){try{const e=t.currentScript;return e&&(e.nonce||e.getAttribute("nonce"))||null}catch(t){return null}}const S=k(window),T=L(document);(function(t){try{return new x(t).start()}catch(t){return console.warn("[superflow live] runLive failed, drawing nothing:",t),Promise.resolve("none")}})({win:window,doc:document,storage:function(t){try{return t.localStorage||null}catch(t){return null}}(window),fetchFn:(t,e)=>window.fetch(t,e),reload:()=>window.location.reload(),endpoint:"https://us-central1-snipply-sdk-staging.cloudfunctions.net/anonymoushandler",staging:!0,nonce:I(document),version:e,apiKey:T.apiKey,projectId:T.projectId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:""}).then((()=>{S.ready=!0})).catch((t=>{console.warn("[superflow live] runLive failed:",t),S.ready=!0})),t.currentScriptNonce=I,t.readInstallParams=L,t.registerLiveBundle=k}({});
|