@syncify/cli 1.0.0-unstable.2 → 1.0.0-unstable.3
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/dist/cli.js +119 -112
- package/dist/index.d.ts +225 -128
- package/dist/syncify.js +10769 -6211
- package/hot.js.liquid +2 -2
- package/package.json +34 -31
- package/readme.md +67 -21
- package/scripts/postinstall.js +9 -0
- package/scripts/postuninstall.js +104 -0
- package/scripts/postversion.js +4 -1
- package/scripts/prepublish.js +63 -0
package/hot.js.liquid
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{%- liquid
|
2
2
|
# !! SYNCIFY HOT CLIENT - DO NOT EDIT FILE !!
|
3
|
-
# v0.
|
3
|
+
# v0.6.0
|
4
4
|
# inject@options
|
5
5
|
echo '<style id="syncify-hot-style">'
|
6
6
|
if no-preview-bar
|
@@ -10,5 +10,5 @@
|
|
10
10
|
echo '</style>'
|
11
11
|
-%}
|
12
12
|
<script id="syncify-hot-client">
|
13
|
-
var de=11;function ge(r,s){var a=s.attributes,o,t,h,g,T;if(!(s.nodeType===de||r.nodeType===de)){for(var E=a.length-1;E>=0;E--)o=a[E],t=o.name,h=o.namespaceURI,g=o.value,h?(t=o.localName||t,T=r.getAttributeNS(h,t),T!==g&&(o.prefix==="xmlns"&&(t=o.name),r.setAttributeNS(h,t,g))):(T=r.getAttribute(t),T!==g&&r.setAttribute(t,g));for(var H=r.attributes,A=H.length-1;A>=0;A--)o=H[A],t=o.name,h=o.namespaceURI,h?(t=o.localName||t,s.hasAttributeNS(h,t)||r.removeAttributeNS(h,t)):s.hasAttribute(t)||r.removeAttribute(t)}}var ae,ve="http://www.w3.org/1999/xhtml",N=typeof document>"u"?void 0:document,be=!!N&&"content"in N.createElement("template"),we=!!N&&N.createRange&&"createContextualFragment"in N.createRange();function Te(r){var s=N.createElement("template");return s.innerHTML=r,s.content.childNodes[0]}function Se(r){ae||(ae=N.createRange(),ae.selectNode(N.body));var s=ae.createContextualFragment(r);return s.childNodes[0]}function Oe(r){var s=N.createElement("body");return s.innerHTML=r,s.childNodes[0]}function $e(r){return r=r.trim(),be?Te(r):we?Se(r):Oe(r)}function le(r,s){var a=r.nodeName,o=s.nodeName,t,h;return a===o?!0:(t=a.charCodeAt(0),h=o.charCodeAt(0),t<=90&&h>=97?a===o.toUpperCase():h<=90&&t>=97?o===a.toUpperCase():!1)}function Ee(r,s){return!s||s===ve?N.createElement(r):N.createElementNS(s,r)}function Ae(r,s){for(var a=r.firstChild;a;){var o=a.nextSibling;s.appendChild(a),a=o}return s}function ue(r,s,a){r[a]!==s[a]&&(r[a]=s[a],r[a]?r.setAttribute(a,""):r.removeAttribute(a))}var fe={OPTION:function(r,s){var a=r.parentNode;if(a){var o=a.nodeName.toUpperCase();o==="OPTGROUP"&&(a=a.parentNode,o=a&&a.nodeName.toUpperCase()),o==="SELECT"&&!a.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!s.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),a.selectedIndex=-1)}ue(r,s,"selected")},INPUT:function(r,s){ue(r,s,"checked"),ue(r,s,"disabled"),r.value!==s.value&&(r.value=s.value),s.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,s){var a=s.value;r.value!==a&&(r.value=a);var o=r.firstChild;if(o){var t=o.nodeValue;if(t==a||!a&&t==r.placeholder)return;o.nodeValue=a}},SELECT:function(r,s){if(!s.hasAttribute("multiple")){for(var a=-1,o=0,t=r.firstChild,h,g;t;)if(g=t.nodeName&&t.nodeName.toUpperCase(),g==="OPTGROUP")h=t,t=h.firstChild;else{if(g==="OPTION"){if(t.hasAttribute("selected")){a=o;break}o++}t=t.nextSibling,!t&&h&&(t=h.nextSibling,h=null)}r.selectedIndex=a}}},oe=1,me=11,he=3,pe=8;function V(){}function xe(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function De(r){return function(a,o,t){if(t||(t={}),typeof o=="string")if(a.nodeName==="#document"||a.nodeName==="HTML"||a.nodeName==="BODY"){var h=o;o=N.createElement("html"),o.innerHTML=h}else o=$e(o);else o.nodeType===me&&(o=o.firstElementChild);var g=t.getNodeKey||xe,T=t.onBeforeNodeAdded||V,E=t.onNodeAdded||V,H=t.onBeforeElUpdated||V,A=t.onElUpdated||V,U=t.onBeforeNodeDiscarded||V,_=t.onNodeDiscarded||V,q=t.onBeforeElChildrenUpdated||V,j=t.skipFromChildren||V,te=t.addChild||function(u,d){return u.appendChild(d)},z=t.childrenOnly===!0,I=Object.create(null),W=[];function G(u){W.push(u)}function ne(u,d){if(u.nodeType===oe)for(var b=u.firstChild;b;){var m=void 0;d&&(m=g(b))?G(m):(_(b),b.firstChild&&ne(b,d)),b=b.nextSibling}}function Y(u,d,b){U(u)!==!1&&(d&&d.removeChild(u),_(u),ne(u,b))}function ie(u){if(u.nodeType===oe||u.nodeType===me)for(var d=u.firstChild;d;){var b=g(d);b&&(I[b]=d),ie(d),d=d.nextSibling}}ie(a);function J(u){E(u);for(var d=u.firstChild;d;){var b=d.nextSibling,m=g(d);if(m){var y=I[m];y&&le(d,y)?(d.parentNode.replaceChild(y,d),x(y,d)):J(d)}else J(d);d=b}}function w(u,d,b){for(;d;){var m=d.nextSibling;(b=g(d))?G(b):Y(d,u,!0),d=m}}function x(u,d,b){var m=g(d);if(m&&delete I[m],!b){var y=H(u,d);if(y===!1||(y instanceof HTMLElement&&(u=y,ie(u)),r(u,d),A(u),q(u,d)===!1))return}u.nodeName!=="TEXTAREA"?Z(u,d):fe.TEXTAREA(u,d)}function Z(u,d){var b=j(u,d),m=d.firstChild,y=u.firstChild,R,L,M,e,n;e:for(;m;){for(e=m.nextSibling,R=g(m);!b&&y;){if(M=y.nextSibling,m.isSameNode&&m.isSameNode(y)){m=e,y=M;continue e}L=g(y);var l=y.nodeType,i=void 0;if(l===m.nodeType&&(l===oe?(R?R!==L&&((n=I[R])?M===n?i=!1:(u.insertBefore(n,y),L?G(L):Y(y,u,!0),y=n,L=g(y)):i=!1):L&&(i=!1),i=i!==!1&&le(y,m),i&&x(y,m)):(l===he||l==pe)&&(i=!0,y.nodeValue!==m.nodeValue&&(y.nodeValue=m.nodeValue))),i){m=e,y=M;continue e}L?G(L):Y(y,u,!0),y=M}if(R&&(n=I[R])&&le(n,m))b||te(u,n),x(n,m);else{var c=T(m);c!==!1&&(c&&(m=c),m.actualize&&(m=m.actualize(u.ownerDocument||N)),te(u,m),J(m))}m=e,y=M}w(u,y,L);var v=fe[u.nodeName];v&&v(u,d)}var S=a,K=S.nodeType,re=o.nodeType;if(!z){if(K===oe)re===oe?le(a,o)||(_(a),S=Ae(a,Ee(o.nodeName,o.namespaceURI))):S=o;else if(K===he||K===pe){if(re===K)return S.nodeValue!==o.nodeValue&&(S.nodeValue=o.nodeValue),S;S=o}}if(S===o)_(a);else{if(o.isSameNode&&o.isSameNode(S))return;if(x(S,o,z),W)for(var Q=0,se=W.length;Q<se;Q++){var F=I[W[Q]];F&&Y(F,F.parentNode,!1)}}return!z&&S!==a&&a.parentNode&&(S.actualize&&(S=S.actualize(a.ownerDocument||N)),a.parentNode.replaceChild(S,a)),S}}var Ne=De(ge),ce=Ne;function ye(r){let s={customElementDefine:customElements.define,customElementsGet:customElements.get,querySelector:Document.prototype.querySelector,querySelectorAll:Document.prototype.querySelectorAll,getElementsByTagName:Document.prototype.getElementsByTagName,matches:Element.prototype.matches,closest:Element.prototype.closest},a=(t=10,h)=>(h=h||"",t?a(--t,"abcdefghiklmnopqrstuvwxyz".charAt(Math.floor(Math.random()*60))+h):h);function o(t){return r.has(t)?r.get(t):t}Document.prototype.querySelector=function(t){return s.querySelector.call(this,o(t))},Document.prototype.querySelectorAll=function(t){return s.querySelectorAll.call(this,o(t))},Document.prototype.getElementsByName=function(t){return s.getElementsByTagName.call(this,o(t))},Element.prototype.matches=function(t){return s.matches.call(this,o(t))},Element.prototype.closest=function(t){return s.closest.call(this,o(t))},customElements.get=function(t){return s.customElementsGet.call(customElements,o(t))},customElements.define=function(t,h,g){if(r.has(t)){let T=`${t}-${a()}`,E=r.get(t);s.customElementDefine.call(customElements,T,h,g),document.body.querySelectorAll(E).forEach(H=>{console.info(`HOT: Web Component '${t}' was refined to ${T} (refresh to reset)`);let A=document.createElement(T);A.innerHTML=H.innerHTML,H.replaceWith(A)}),r.set(t,T)}else console.warn(`HOT: Web component '${t}' will be monkey patched during HOT Mode.`),s.customElementDefine.call(customElements,t,h,g),r.set(t,t)}}(function(s){if(!document)return;window.syncify||(window.syncify=Object.create(null),window.syncify.version="0.4.9");let a=new Map,o=[],t={"no-preview-bar":!1,"no-checkout-preloads":!1,"no-perfkit":!1,"no-shopify-features":!1,"no-trekkie":!1,"no-web-pixels-manager":!1},h=!1,g={},T=!1,E=NaN,H=0,A,U,_=s.label,q=s.method,j=`http://localhost:${s.server}/`,te=`ws://localhost:${s.socket}/ws`;Object.defineProperty(window.syncify,"options",{get(){return s},set(e){for(let n in s)n in s&&(s[n]=e[n],n==="server"?j=`http://localhost:${s[n]}/`:n==="socket"?te=`ws://localhost:${s.socket}/ws`:n==="label"?_=s[n]:n==="method"?q=s[n]:n==="flags"&&Object.assign(t,s[n]))}});let z={onBeforeNodeDiscarded(e){return!(e.id==="syncify-hot-label"||e.id==="syncify-hot-style")},onBeforeElUpdated(e,n){return!(e.id==="syncify-hot-label"||e.id==="syncify-hot-style"||e.tagName==="SCRIPT"&&e.hasAttribute("src")&&e.getAttribute("src").startsWith(j)||e.tagName==="LINK"&&e.hasAttribute("href")&&e.getAttribute("href").startsWith(j)||e.tagName!=="SCRIPT"&&e.isEqualNode(n))}},I=e=>`url("data:image/svg+xml,%3Csvg%20fill%3D%22currentColor%22%20width%3D%2212px%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2092%2092%22%3E%3Cpath%20d%3D%22M45.6607%200h45.62v26.07h-45.62c-5.1825.0079-10.1505%202.0703-13.8151%205.7349-3.6647%203.6646-5.7269%208.6326-5.7349%2013.8152-.0768%204.8168%201.7153%209.4761%205%2013H1.76071c-1.191519-4.2298-1.7839619-8.6057-1.76001194-13%200-5.9896%201.17974194-11.9206%203.47186194-17.4543%202.29212-5.5336%205.65171-10.5616%209.88704-14.7969%204.2353-4.23528%209.2633-7.59491%2014.7969-9.88703C33.6902%201.18976%2039.6211.0100098%2045.6107.0100098L45.6607%200Zm0%2091.23H.050716V65.17H45.6607c5.1826-.0079%2010.1506-2.0702%2013.8152-5.7348s5.7269-8.6326%205.7348-13.8151c.0769-4.8169-1.7152-9.4762-5-13h29.32c1.1916%204.2297%201.784%208.6057%201.7601%2013%20.0013%205.9912-1.1779%2011.924-3.47%2017.4595-2.2922%205.5355-5.6525%2010.5651-9.8889%2014.8016-4.2365%204.2364-9.2661%207.5967-14.8016%209.8889-5.5355%202.2921-11.4683%203.4713-17.4596%203.47l-.01-.0101Z%22%20fill%3D%22%23${e}%22%2F%3E%3C%2Fsvg%3E")`;function W(e,n,l){let i=document.createElement(e);return i.className=n,l&&Object.assign(i.style,l),i}function G(e){requestAnimationFrame(()=>{e.body.querySelector("#preview-bar-iframe").remove(),e.documentElement.style.removeProperty("padding-bottom")});let n=[];if(t["no-trekkie"]&&n.push("script[src*=syncify\\.myshopify\\.com\\/cdn\\/s\\/trekkie\\.storefront]"),t["no-web-pixels-manager"]&&n.push("script[src*=syncify\\.myshopify\\.com\\/cdn\\/wpm\\/]","script#web-pixels-manager-setup"),t["no-perfkit"]&&n.push("script[src*=syncify\\.myshopify\\.com\\/cdn\\/shopifycloud\\/perf-kit\\/]"),t["no-checkout-preloads"]&&n.push("script[src*=\\/checkouts\\/internal\\/preloads\\.js]"),t["no-shopify-features"]&&n.push("script#shopify-features",'script[data-source-attribution="shopify.loadfeatures"]'),n.length===0)return;let l=e.head.querySelectorAll(n.join());l&&l.forEach(i=>{i.remove(),i.src.indexOf("/cdn/wpm")>-1?console.error(`HOT --no-web-pixels-manager: ${i.src} (BLOCKED)`):i.id==="web-pixels-manager-setup"?console.error(`HOT --no-web-pixels-manager: ${i.id} (BLOCKED)`):i.id==="shopify-features"?console.error(`HOT --no-shopify-features: ${i.id} (BLOCKED)`):i.src.indexOf("/perf-kit")>-1?console.error(`HOT --no-perf-kit: ${i.src} (BLOCKED)`):i.src.indexOf("/trekkie")>-1?console.error(`HOT --no-trekkie: ${i.src} (BLOCKED)`):i.src.indexOf("/checkouts/internal")>-1?console.error(`HOT --no-checkout-preloads: ${i.src} (BLOCKED)`):i.hasAttribute("data-source-attribution")?console.error(`HOT --no-source-attribution: ${i.getAttribute("data-source-attribution")} (BLOCKED)`):i.src.indexOf("/storefront/bars")>-1&&console.error(`HOT --no-preview-bar: ${i.src} (BLOCKED)`)})}function ne(e,n){for(let[l,i]of n)e.addEventListener(l,i)}function Y(e,n){for(let[l,i]of n)e.removeEventListener(l,i)}function ie(e){let n=!1,l,i,c=()=>{let p=e.getBoundingClientRect(),f="6px",$="0px",k={top:p.top<=6,bottom:p.bottom>=window.innerHeight-6,left:p.left<=6,right:p.right>=window.innerWidth-6},P;k.top&&k.left?P=`${$} ${f} ${f} ${f}`:k.top&&k.right?P=`${f} ${$} ${f} ${f}`:k.bottom&&k.left?P=`${f} ${f} ${f} ${$}`:k.bottom&&k.right?P=`${f} ${f} ${$} ${f}`:k.top?P=`${$} ${$} ${f} ${f}`:k.bottom?P=`${f} ${f} ${$} ${$}`:k.left?P=`${$} ${f} ${f} ${$}`:k.right?P=`${f} ${$} ${$} ${f}`:P=`${f} ${f} ${f} ${f}`,e.querySelector("span").style.borderRadius=P},v=(p,f)=>{let $=e.getBoundingClientRect();e.style.left=`${Math.min(Math.max(p,0),window.innerWidth-$.width)}px`,e.style.top=`${Math.min(Math.max(f,0),window.innerHeight-$.height)}px`,c()},O=()=>{e.style.visibility="hidden";let p=e.getBoundingClientRect(),f=(window.innerWidth-p.width)/2,$=window.innerHeight-p.height;v(f,$),e.style.visibility="visible"},D=p=>{let f=e.getBoundingClientRect();l=(p.touches?p.touches[0].clientX:p.clientX)-f.left,i=(p.touches?p.touches[0].clientY:p.clientY)-f.top,n=p.target===e||e.contains(p.target)},C=p=>{n&&(p.preventDefault(),v((p.touches?p.touches[0].clientX:p.clientX)-l,(p.touches?p.touches[0].clientY:p.clientY)-i))},ee=()=>{n=!1},X=[["mousedown",D],["mousemove",C],["mouseup",ee],["touchstart",D],["touchmove",C],["touchend",ee]];ne(document,X),ne(e,X.filter(([p])=>p!=="mousemove"&&p!=="touchmove"));let B=()=>O();return window.addEventListener("resize",B),requestAnimationFrame(()=>O()),()=>{Y(document,X),window.removeEventListener("resize",B)}}function J(){return U="{%-if template.directory-%}{{-template.directory-}}/{%-endif-%}{{-template.name-}}",U}let w=function(){let e,n;return{get node(){return e},mount:i=>{if(e instanceof Element&&i.contains(e))return;let c=W("div","sy__hot-label");e=W("span","sy__hot-label-inner",{backgroundImage:I("4DBB73")}),window.syncify&&typeof window.syncify.style!="object"&&(window.syncify.style=Object.create(null),window.syncify.style.parent=v=>Object.assign(c.style,v),window.syncify.style.label=v=>Object.assign(e,v)),e.innerText=q?"HOT":"LIVE",c.id="syncify-hot-label",c.style.visibility="hidden",c.appendChild(e),_&&(n=ie(c),i.append(c))},event(i,c){i!==void 0&&(c?e.style.setProperty("font-size",c):e.style.removeProperty("font-size"),e.innerText=i)},unmount(){n(),e.remove(),e=void 0}}}(),x=function(e){let n=null;return{start:()=>{e.push(performance.now())},stop:()=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>{w.event(q==="hot"?"HOT":"LIVE"),n=null},6e3);let l=performance.now()-e.pop();if(l<1e3)return`${l.toFixed(0)}ms`;let i=l/1e3;if(i<60)return`${i.toFixed(0)}s ${+l.toFixed(0).slice(1)}ms`;let c=(i/60).toFixed(0);return`${c}m ${i-60*Number(c)}s ${+l.toFixed(0).slice(1)}ms`}}}([]),Z=function(e){return{list(){return{map:Object.keys(e).length>0?e:null,alias:g}},get(n){if(n in e)return document.body.querySelectorAll(e[n].join(","));if(U in g&&n in g[U]){let l=[];for(let i=0,c=g[U][n].length,v="";i<c;i++)v=g[U][n][i],v in e&&l.push(...e[v]);if(l.length>0)return document.body.querySelectorAll(l.join(","))}return null},load:(n=document.body)=>{e={};let l=n.querySelectorAll(".shopify-section");if(!l)return null;for(let i=0,c=l.length;i<c;i++){let{id:v}=l[i],O=/[0-9]+_{2}[\w-]+$/.exec(v),D;if(O!==null)D=O[0].slice(O[0].indexOf("__")+2);else if(v.startsWith("shopify-section-"))D=v.slice(16);else{window.syncify.errors.push({title:"Unknown Section",description:`Syncify encountered an issue mapping the section id: ${v}`,group:"section"});continue}let C=`#${v}`;D in e?e[D].indexOf(C)<0&&e[D].push(C):e[D]=[C]}return e}}}({});function S(e){let n=e.lastIndexOf("/")+1,l=e.indexOf("?",n);return(l>-1?e.substring(n,l):e.substring(n))+"?v="+Date.now()}function K(e,n){return typeof n!="string"?!1:e.slice(e.lastIndexOf("/")+1).startsWith(n)}function re(e,n){let l=e.querySelectorAll("link[rel=stylesheet]");for(let i=0,c=l.length;i<c;i++){let v=l[i],O=v.getAttribute("href");K(O,n)&&v.setAttribute("href",j+S(O))}return e}function Q(e,n){let l=e.querySelectorAll("script[src]"),i=[];for(let c=0,v=l.length;c<v;c++){let O=l[c],D=O.getAttribute("src");if(K(D,n)){let C=new Promise((ee,X)=>{let B=document.createElement("script");B.setAttribute("src",j+S(D));let p=Array.from(O.attributes);for(let f of p)f.nodeName!=="src"&&B.setAttribute(f.nodeName,f.nodeValue);B.onload=()=>ee(D),B.onerror=f=>{console.error("HOT Script failed to reload:",f),X(new Error("HOT Script Error"))},O.replaceWith(B)});i.push(C)}}return i}function se(e=document){return re(e),Promise.allSettled(Q(e))}function F(e,n){return new Promise(function(l,i){let c=new XMLHttpRequest;c.responseType=n,c.open("GET",e,!0),c.setRequestHeader("x-syncify-hot","true"),c.onload=()=>l(c.response),c.onerror=()=>i(c.statusText),c.send()})}let u=()=>F(location.href,"document").then(e=>{se(e).then(()=>{ce(document.body,e.body,z),Z.load(document.body),w.mount(document.body)})});function d(){if(T!==!0){if(H>1e3){A=void 0,L(),console.warn("HOT Reconnection could not be established and process was killed");return}A=new WebSocket(te),b(A)}}function b(e){isNaN(E)||clearTimeout(E),e.addEventListener("close",()=>{H===0&&console.warn("HOT Reconnection will continue to be attempted until a hard-refresh"),H>0||w.event("DISCONNECTED","10px"),T=!1,H++,E=setTimeout(d,2500)}),e.addEventListener("open",()=>{T?(x.start(),w.event("Reconnecting"),u().then(()=>{w.event(`Reconnected in ${x.stop()}`),T=!0,R()})):(T=!0,w.event(q==="hot"?"HOT":"LIVE"),R())});let n=q==="hot"?"HOT ":"LIVE ";e.addEventListener("message",function({data:l}){if(l==="reload")return w.event("Refresh"),top.location.reload();if(l==="replace")return x.start(),w.event(`${n} RELOAD`),isNaN(E)||clearTimeout(E),u().then(()=>{w.event(`Reloaded in ${x.stop()}`),E=NaN});if(l.startsWith("alias|"))g=JSON.parse(l.slice(6));else{if(x.start(),q==="live")return F(location.href,"document").then(i=>{document.body.replaceWith(i.body),w.mount(document.body),w.event(`Reloaded in ${x.stop()}`),E=NaN});{let[i,c,v]=l.split(",");if(i==="section"){let O=Z.get(c);if(O===null){m(()=>w.event(`Reloaded in ${x.stop()}`));return}O.length>1?w.event(`${O.length} ${n}Sections`):w.event(`${n}Section`);let D=`${location.pathname}?sections=${c}`;return F(D,"json").then(C=>{O.forEach(ee=>{ce(ee,C[c],{childrenOnly:!0,onBeforeElUpdated:(X,B)=>!X.isEqualNode(B)})}),w.event(`Reloaded in ${x.stop()}`)}).catch(C=>{o.push({title:"XHR Error fetching section",description:`Section with id: ${c} failed to return a response from Shopify`,group:"sections"}),console.error("SYNCIFY: ",C)})}else i==="script"?(w.event(`${n}JavaScript: ${c}`),Promise.allSettled(Q(document,c)).then(()=>{e.send(v),w.event(`Reloaded in ${x.stop()}`)})):i==="stylesheet"&&(w.event(`${n}Stylesheet: ${c}`),re(document,c),e.send(v),w.event(`Reloaded in ${x.stop()}`))}}})}function m(e){F(location.href,"document").then(n=>{se(n).then(()=>{ce(document.body,n.body,z),typeof e=="function"&&e(document)})})}function y(){return top.location.reload()}function R(e){A.send("ROUTE:"+JSON.stringify(e||{url:location.href,template:J()}))}function L(){let e=document.body;return h&&(h=!1,A&&(T=!1,A.close()),w.unmount()),e}function M(e){if(document.readyState!=="complete")setTimeout(()=>M(e),25);else{let n=h?L():document.body;typeof e=="object"&&(window.syncify.options=e),Z.load(n),w.mount(n),h=!0,d()}}Object.defineProperties(window.syncify,{isReady:{get(){return h}},isConnected:{get(){return T}},errors:{get(){return o}},WebC:{get(){return a}},template:{get(){return U}},connect:{value:M},disconnect:{value:L},sections:{value:Z},route:{value:R},assets:{value:se},refresh:{value:y},reload:{value:m}}),document.addEventListener("readystatechange",function(){J(),this.readyState==="interactive"?ye(a):this.readyState==="complete"&&G(this)}),M()})({method:"{{method|default:'hot'}}",server:+"{{server|default:41001}}",socket:+"{{socket|default:51001}}",label:!0,flags:{"no-preview-bar":!0,"no-web-pixels-manager":!0,"no-shopify-features":!0,"no-trekkie":!0,"no-perfkit":!0,"no-checkout-preloads":!0}});
|
13
|
+
var pe=11;function Se(r,o){var a=o.attributes,s,t,m,g,E;if(!(o.nodeType===pe||r.nodeType===pe)){for(var A=a.length-1;A>=0;A--)s=a[A],t=s.name,m=s.namespaceURI,g=s.value,m?(t=s.localName||t,E=r.getAttributeNS(m,t),E!==g&&(s.prefix==="xmlns"&&(t=s.name),r.setAttributeNS(m,t,g))):(E=r.getAttribute(t),E!==g&&r.setAttribute(t,g));for(var D=r.attributes,x=D.length-1;x>=0;x--)s=D[x],t=s.name,m=s.namespaceURI,m?(t=s.localName||t,o.hasAttributeNS(m,t)||r.removeAttributeNS(m,t)):o.hasAttribute(t)||r.removeAttribute(t)}}var fe,Te="http://www.w3.org/1999/xhtml",N=typeof document>"u"?void 0:document,$e=!!N&&"content"in N.createElement("template"),Ee=!!N&&N.createRange&&"createContextualFragment"in N.createRange();function Oe(r){var o=N.createElement("template");return o.innerHTML=r,o.content.childNodes[0]}function Ae(r){fe||(fe=N.createRange(),fe.selectNode(N.body));var o=fe.createContextualFragment(r);return o.childNodes[0]}function De(r){var o=N.createElement("body");return o.innerHTML=r,o.childNodes[0]}function Ne(r){return r=r.trim(),$e?Oe(r):Ee?Ae(r):De(r)}function de(r,o){var a=r.nodeName,s=o.nodeName,t,m;return a===s?!0:(t=a.charCodeAt(0),m=s.charCodeAt(0),t<=90&&m>=97?a===s.toUpperCase():m<=90&&t>=97?s===a.toUpperCase():!1)}function xe(r,o){return!o||o===Te?N.createElement(r):N.createElementNS(o,r)}function He(r,o){for(var a=r.firstChild;a;){var s=a.nextSibling;o.appendChild(a),a=s}return o}function me(r,o,a){r[a]!==o[a]&&(r[a]=o[a],r[a]?r.setAttribute(a,""):r.removeAttribute(a))}var ye={OPTION:function(r,o){var a=r.parentNode;if(a){var s=a.nodeName.toUpperCase();s==="OPTGROUP"&&(a=a.parentNode,s=a&&a.nodeName.toUpperCase()),s==="SELECT"&&!a.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!o.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),a.selectedIndex=-1)}me(r,o,"selected")},INPUT:function(r,o){me(r,o,"checked"),me(r,o,"disabled"),r.value!==o.value&&(r.value=o.value),o.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,o){var a=o.value;r.value!==a&&(r.value=a);var s=r.firstChild;if(s){var t=s.nodeValue;if(t==a||!a&&t==r.placeholder)return;s.nodeValue=a}},SELECT:function(r,o){if(!o.hasAttribute("multiple")){for(var a=-1,s=0,t=r.firstChild,m,g;t;)if(g=t.nodeName&&t.nodeName.toUpperCase(),g==="OPTGROUP")m=t,t=m.firstChild;else{if(g==="OPTION"){if(t.hasAttribute("selected")){a=s;break}s++}t=t.nextSibling,!t&&m&&(t=m.nextSibling,m=null)}r.selectedIndex=a}}},se=1,ve=11,ge=3,be=8;function K(){}function Le(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function ke(r){return function(a,s,t){if(t||(t={}),typeof s=="string")if(a.nodeName==="#document"||a.nodeName==="HTML"||a.nodeName==="BODY"){var m=s;s=N.createElement("html"),s.innerHTML=m}else s=Ne(s);else s.nodeType===ve&&(s=s.firstElementChild);var g=t.getNodeKey||Le,E=t.onBeforeNodeAdded||K,A=t.onNodeAdded||K,D=t.onBeforeElUpdated||K,x=t.onElUpdated||K,q=t.onBeforeNodeDiscarded||K,k=t.onNodeDiscarded||K,ae=t.onBeforeElChildrenUpdated||K,V=t.skipFromChildren||K,Y=t.addChild||function(l,c){return l.appendChild(c)},Q=t.childrenOnly===!0,F=Object.create(null),ee=[];function X(l){ee.push(l)}function le(l,c){if(l.nodeType===se)for(var S=l.firstChild;S;){var p=void 0;c&&(p=g(S))?X(p):(k(S),S.firstChild&&le(S,c)),S=S.nextSibling}}function z(l,c,S){q(l)!==!1&&(c&&c.removeChild(l),k(l),le(l,S))}function re(l){if(l.nodeType===se||l.nodeType===ve)for(var c=l.firstChild;c;){var S=g(c);S&&(F[S]=c),re(c),c=c.nextSibling}}re(a);function ie(l){A(l);for(var c=l.firstChild;c;){var S=c.nextSibling,p=g(c);if(p){var y=F[p];y&&de(c,y)?(c.parentNode.replaceChild(y,c),b(y,c)):ie(c)}else ie(c);c=S}}function ce(l,c,S){for(;c;){var p=c.nextSibling;(S=g(c))?X(S):z(c,l,!0),c=p}}function b(l,c,S){var p=g(c);if(p&&delete F[p],!S){var y=D(l,c);if(y===!1||(y instanceof HTMLElement&&(l=y,re(l)),r(l,c),x(l),ae(l,c)===!1))return}l.nodeName!=="TEXTAREA"?H(l,c):ye.TEXTAREA(l,c)}function H(l,c){var S=V(l,c),p=c.firstChild,y=l.firstChild,_,L,M,j,B;e:for(;p;){for(j=p.nextSibling,_=g(p);!S&&y;){if(M=y.nextSibling,p.isSameNode&&p.isSameNode(y)){p=j,y=M;continue e}L=g(y);var ne=y.nodeType,I=void 0;if(ne===p.nodeType&&(ne===se?(_?_!==L&&((B=F[_])?M===B?I=!1:(l.insertBefore(B,y),L?X(L):z(y,l,!0),y=B,L=g(y)):I=!1):L&&(I=!1),I=I!==!1&&de(y,p),I&&b(y,p)):(ne===ge||ne==be)&&(I=!0,y.nodeValue!==p.nodeValue&&(y.nodeValue=p.nodeValue))),I){p=j,y=M;continue e}L?X(L):z(y,l,!0),y=M}if(_&&(B=F[_])&&de(B,p))S||Y(l,B),b(B,p);else{var e=E(p);e!==!1&&(e&&(p=e),p.actualize&&(p=p.actualize(l.ownerDocument||N)),Y(l,p),ie(p))}p=j,y=M}ce(l,y,L);var n=ye[l.nodeName];n&&n(l,c)}var T=a,G=T.nodeType,oe=s.nodeType;if(!Q){if(G===se)oe===se?de(a,s)||(k(a),T=He(a,xe(s.nodeName,s.namespaceURI))):T=s;else if(G===ge||G===be){if(oe===G)return T.nodeValue!==s.nodeValue&&(T.nodeValue=s.nodeValue),T;T=s}}if(T===s)k(a);else{if(s.isSameNode&&s.isSameNode(T))return;if(b(T,s,Q),ee)for(var te=0,ue=ee.length;te<ue;te++){var J=F[ee[te]];J&&z(J,J.parentNode,!1)}}return!Q&&T!==a&&a.parentNode&&(T.actualize&&(T=T.actualize(a.ownerDocument||N)),a.parentNode.replaceChild(T,a)),T}}var Ce=ke(Se),he=Ce;function we(r){let o={customElementDefine:customElements.define,customElementsGet:customElements.get,querySelector:Document.prototype.querySelector,querySelectorAll:Document.prototype.querySelectorAll,getElementsByTagName:Document.prototype.getElementsByTagName,matches:Element.prototype.matches,closest:Element.prototype.closest},a=(t=10,m)=>(m=m||"",t?a(--t,"abcdefghiklmnopqrstuvwxyz".charAt(Math.floor(Math.random()*60))+m):m);function s(t){return r.has(t)?r.get(t):t}Document.prototype.querySelector=function(t){return o.querySelector.call(this,s(t))},Document.prototype.querySelectorAll=function(t){return o.querySelectorAll.call(this,s(t))},Document.prototype.getElementsByName=function(t){return o.getElementsByTagName.call(this,s(t))},Element.prototype.matches=function(t){return o.matches.call(this,s(t))},Element.prototype.closest=function(t){return o.closest.call(this,s(t))},customElements.get=function(t){return o.customElementsGet.call(customElements,s(t))},customElements.define=function(t,m,g){if(r.has(t)){let E=`${t}-${a()}`,A=r.get(t);o.customElementDefine.call(customElements,E,m,g),document.body.querySelectorAll(A).forEach(D=>{console.info(`HOT: Web Component '${t}' was refined to ${E} (refresh to reset)`);let x=document.createElement(E);x.innerHTML=D.innerHTML,D.replaceWith(x)}),r.set(t,E)}else console.warn(`HOT: Web component '${t}' will be monkey patched during HOT Mode.`),o.customElementDefine.call(customElements,t,m,g),r.set(t,t)}}(function(o){if(!document)return;window.Syncify||(window.Syncify=Object.create(null),window.Syncify.version="0.6.0");let a=[],s=new Map,t={reload:new Set,morph:new Set,assets:new Set},m={"no-preview-bar":!1,"no-checkout-preloads":!1,"no-perfkit":!1,"no-shopify-features":!1,"no-trekkie":!1,"no-web-pixels-manager":!1},g=!1,E={},A=!1,D=NaN,x=0,q,k,ae=o.label,V=o.method,Y=`http://localhost:${o.server}/`,Q=`ws://localhost:${o.socket}/ws`;Object.defineProperty(window.Syncify,"options",{get(){return o},set(e){for(let n in o)n in o&&(o[n]=e[n],n==="server"?Y=`http://localhost:${o[n]}/`:n==="socket"?Q=`ws://localhost:${o.socket}/ws`:n==="label"?ae=o[n]:n==="method"?V=o[n]:n==="flags"&&Object.assign(m,o[n]))}});let F={onBeforeNodeDiscarded(e){return!(e.id==="syncify-hot-label"||e.id==="syncify-hot-style")},onBeforeElUpdated(e,n){return!(e.id==="syncify-hot-label"||e.id==="syncify-hot-style"||e.tagName==="SCRIPT"&&e.hasAttribute("src")&&e.getAttribute("src").startsWith(Y)||e.tagName==="LINK"&&e.hasAttribute("href")&&e.getAttribute("href").startsWith(Y)||e.tagName!=="SCRIPT"&&e.isEqualNode(n))}},ee=e=>`url("data:image/svg+xml,%3Csvg%20fill%3D%22currentColor%22%20width%3D%2212px%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2092%2092%22%3E%3Cpath%20d%3D%22M45.6607%200h45.62v26.07h-45.62c-5.1825.0079-10.1505%202.0703-13.8151%205.7349-3.6647%203.6646-5.7269%208.6326-5.7349%2013.8152-.0768%204.8168%201.7153%209.4761%205%2013H1.76071c-1.191519-4.2298-1.7839619-8.6057-1.76001194-13%200-5.9896%201.17974194-11.9206%203.47186194-17.4543%202.29212-5.5336%205.65171-10.5616%209.88704-14.7969%204.2353-4.23528%209.2633-7.59491%2014.7969-9.88703C33.6902%201.18976%2039.6211.0100098%2045.6107.0100098L45.6607%200Zm0%2091.23H.050716V65.17H45.6607c5.1826-.0079%2010.1506-2.0702%2013.8152-5.7348s5.7269-8.6326%205.7348-13.8151c.0769-4.8169-1.7152-9.4762-5-13h29.32c1.1916%204.2297%201.784%208.6057%201.7601%2013%20.0013%205.9912-1.1779%2011.924-3.47%2017.4595-2.2922%205.5355-5.6525%2010.5651-9.8889%2014.8016-4.2365%204.2364-9.2661%207.5967-14.8016%209.8889-5.5355%202.2921-11.4683%203.4713-17.4596%203.47l-.01-.0101Z%22%20fill%3D%22%23${e}%22%2F%3E%3C%2Fsvg%3E")`;function X(e,n,u){let i=document.createElement(e);return i.className=n,u&&Object.assign(i.style,u),i}function le(e){requestAnimationFrame(()=>{e.body.querySelector("#PBarNextFrameWrapper").remove(),e.documentElement.style.removeProperty("padding-bottom")});let n=[];if(m["no-trekkie"]&&n.push("script[src*=syncify\\.myshopify\\.com\\/cdn\\/s\\/trekkie\\.storefront]"),m["no-web-pixels-manager"]&&n.push("script[src*=syncify\\.myshopify\\.com\\/cdn\\/wpm\\/]","script#web-pixels-manager-setup"),m["no-perfkit"]&&n.push("script[src*=syncify\\.myshopify\\.com\\/cdn\\/shopifycloud\\/perf-kit\\/]"),m["no-checkout-preloads"]&&n.push("script[src*=\\/checkouts\\/internal\\/preloads\\.js]"),m["no-shopify-features"]&&n.push("script#shopify-features",'script[data-source-attribution="shopify.loadfeatures"]'),n.length===0)return;let u=e.head.querySelectorAll(n.join());u&&u.forEach(i=>{i.remove(),i.src.indexOf("/cdn/wpm")>-1?console.error(`HOT --no-web-pixels-manager: ${i.src} (BLOCKED)`):i.id==="web-pixels-manager-setup"?console.error(`HOT --no-web-pixels-manager: ${i.id} (BLOCKED)`):i.id==="shopify-features"?console.error(`HOT --no-shopify-features: ${i.id} (BLOCKED)`):i.src.indexOf("/perf-kit")>-1?console.error(`HOT --no-perf-kit: ${i.src} (BLOCKED)`):i.src.indexOf("/trekkie")>-1?console.error(`HOT --no-trekkie: ${i.src} (BLOCKED)`):i.src.indexOf("/checkouts/internal")>-1?console.error(`HOT --no-checkout-preloads: ${i.src} (BLOCKED)`):i.hasAttribute("data-source-attribution")?console.error(`HOT --no-source-attribution: ${i.getAttribute("data-source-attribution")} (BLOCKED)`):i.src.indexOf("/storefront/bars")>-1&&console.error(`HOT --no-preview-bar: ${i.src} (BLOCKED)`)})}function z(e,n){for(let[u,i]of n)e.addEventListener(u,i)}function re(e,n){for(let[u,i]of n)e.removeEventListener(u,i)}function ie(e){let n=!1,u,i,f=()=>{let d=e.getBoundingClientRect(),h="6px",w="0px",R={top:d.top<=6,bottom:d.bottom>=window.innerHeight-6,left:d.left<=6,right:d.right>=window.innerWidth-6},P;R.top&&R.left?P=`${w} ${h} ${h} ${h}`:R.top&&R.right?P=`${h} ${w} ${h} ${h}`:R.bottom&&R.left?P=`${h} ${h} ${h} ${w}`:R.bottom&&R.right?P=`${h} ${h} ${w} ${h}`:R.top?P=`${w} ${w} ${h} ${h}`:R.bottom?P=`${h} ${h} ${w} ${w}`:R.left?P=`${w} ${h} ${h} ${w}`:R.right?P=`${h} ${w} ${w} ${h}`:P=`${h} ${h} ${h} ${h}`,e.querySelector("span").style.borderRadius=P},v=(d,h)=>{let w=e.getBoundingClientRect();e.style.left=`${Math.min(Math.max(d,0),window.innerWidth-w.width)}px`,e.style.top=`${Math.min(Math.max(h,0),window.innerHeight-w.height)}px`,f()},O=()=>{e.style.visibility="hidden";let d=e.getBoundingClientRect(),h=(window.innerWidth-d.width)/2,w=window.innerHeight-d.height;v(h,w),e.style.visibility="visible"},$=d=>{let h=e.getBoundingClientRect();u=(d.touches?d.touches[0].clientX:d.clientX)-h.left,i=(d.touches?d.touches[0].clientY:d.clientY)-h.top,n=d.target===e||e.contains(d.target)},C=d=>{n&&(d.preventDefault(),v((d.touches?d.touches[0].clientX:d.clientX)-u,(d.touches?d.touches[0].clientY:d.clientY)-i))},W=()=>{n=!1},U=[["pointerdown",$],["pointermove",C],["pointerup",W],["touchstart",$],["touchmove",C],["touchend",W]];z(document,U),z(e,U.filter(([d])=>d!=="mousemove"&&d!=="touchmove"));let Z=()=>O();return window.addEventListener("resize",Z),requestAnimationFrame(()=>O()),()=>{re(document,U),window.removeEventListener("resize",Z)}}function ce(){return k="{%-if template.directory-%}{{-template.directory-}}/{%-endif-%}{{-template.name-}}",k}let b=function(){let e,n;return{get node(){return e},mount:i=>{if(e instanceof Element&&i.contains(e))return;let f=X("div","sy__hot-label");e=X("span","sy__hot-label-inner",{backgroundImage:ee("4DBB73")}),window.Syncify&&typeof window.Syncify.style!="object"&&(window.Syncify.style=Object.create(null),window.Syncify.style.parent=v=>Object.assign(f.style,v),window.Syncify.style.label=v=>Object.assign(e,v)),e.innerText=V?"HOT":"LIVE",f.id="syncify-hot-label",f.style.visibility="hidden",f.appendChild(e),ae&&(n=ie(f),i.append(f))},event(i,f){i!==void 0&&(f?e.style.setProperty("font-size",f):e.style.removeProperty("font-size"),e.innerText=i)},unmount(){n(),e.remove(),e=void 0}}}(),H=function(e){let n=null;return{start:()=>{e.push(performance.now())},stop:()=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>{b.event(V==="hot"?"HOT":"LIVE"),n=null},6e3);let u=performance.now()-e.pop();if(u<1e3)return`${u.toFixed(0)}ms`;let i=u/1e3;if(i<60)return`${i.toFixed(0)}s ${+u.toFixed(0).slice(1)}ms`;let f=(i/60).toFixed(0);return`${f}m ${i-60*Number(f)}s ${+u.toFixed(0).slice(1)}ms`}}}([]),T=function(e){return{list(){return{map:Object.keys(e).length>0?e:null,alias:E}},get(n){if(n in e)return document.body.querySelectorAll(e[n].join(","));if(k in E&&n in E[k]){let u=[];for(let i=0,f=E[k][n].length,v="";i<f;i++)v=E[k][n][i],v in e&&u.push(...e[v]);if(u.length>0)return document.body.querySelectorAll(u.join(","))}return null},load:(n=document.body)=>{e={};let u=n.querySelectorAll(".shopify-section");if(!u)return null;for(let i=0,f=u.length;i<f;i++){let{id:v}=u[i],O=/[0-9]+_{2}[\w-]+$/.exec(v),$;if(O!==null)$=O[0].slice(O[0].indexOf("__")+2);else if(v.startsWith("shopify-section-"))$=v.slice(16);else{window.Syncify.errors.push({title:"Unknown Section",description:`Syncify encountered an issue mapping the section id: ${v}`,group:"section"});continue}let C=`#${v}`;$ in e?e[$].indexOf(C)<0&&e[$].push(C):e[$]=[C]}return e}}}({});function G(e){let n=e.lastIndexOf("/")+1,u=e.indexOf("?",n);return(u>-1?e.substring(n,u):e.substring(n))+"?v="+Date.now()}function oe(e,n){return typeof n!="string"?!1:e.slice(e.lastIndexOf("/")+1).startsWith(n)}function te(e,n){let u=e.querySelectorAll("link[rel=stylesheet]");for(let i=0,f=u.length;i<f;i++){let v=u[i],O=v.getAttribute("href");if(oe(O,n)){let $=Y+G(O);for(let C of t.assets)if(C("stylesheet",$)===!1){console.log("SYNCIFY: Stylesheet reload was cancelled by onAsset hook");return}v.setAttribute("href",$)}}return e}function ue(e,n){let u=e.querySelectorAll("script[src]"),i=[];for(let f=0,v=u.length;f<v;f++){let O=u[f],$=O.getAttribute("src");if(oe($,n)){let C=new Promise((W,U)=>{let Z=Y+G($);for(let w of t.assets)if(w("script",Z)===!1){console.log("SYNCIFY: Script reload was cancelled by onAsset hook");return}let d=document.createElement("script");d.setAttribute("src",Z);let h=Array.from(O.attributes);for(let w of h)w.nodeName!=="src"&&d.setAttribute(w.nodeName,w.nodeValue);d.onload=()=>W($),d.onerror=w=>{console.error("SYNCIFY: HOT Script failed to reload:",w),U(new Error("HOT Script Error"))},O.replaceWith(d)});i.push(C)}}return i}function J(e=document){return te(e),Promise.allSettled(ue(e))}function l(e,n){return new Promise(function(u,i){let f=new XMLHttpRequest;f.responseType=n,f.open("GET",e,!0),f.setRequestHeader("x-syncify-hot","true"),f.onload=()=>u(f.response),f.onerror=()=>i(f.statusText),f.send()})}let c=()=>l(location.href,"document").then(e=>{J(e).then(()=>{let n=document.body;he(n,e.body,F),T.load(document.body),b.mount(document.body)})});function S(){if(A!==!0){if(x>1e3){q=void 0,M(),console.warn("HOT Reconnection could not be established and process was killed");return}q=new WebSocket(Q),p(q)}}function p(e){isNaN(D)||clearTimeout(D),e.addEventListener("close",()=>{x===0&&console.warn("HOT Reconnection will continue to be attempted until a hard-refresh"),x>0||b.event("DISCONNECTED","10px"),A=!1,x++,D=setTimeout(S,2500)}),e.addEventListener("open",()=>{A?(H.start(),b.event("Reconnecting"),c().then(()=>{b.event(`Reconnected in ${H.stop()}`),A=!0,L()})):(A=!0,b.event(V==="hot"?"HOT":"LIVE"),L())});let n=V==="hot"?"HOT ":"LIVE ";function u(){for(let i of t.reload)i(window.Syncify)}e.addEventListener("message",function({data:i}){if(i==="reload")return b.event("Refresh"),top.location.reload();if(i==="replace")return H.start(),b.event(`${n} RELOAD`),isNaN(D)||clearTimeout(D),c().then(()=>{b.event(`Reloaded in ${H.stop()}`),D=NaN,u()});if(i.startsWith("alias|"))E=JSON.parse(i.slice(6));else{if(H.start(),V==="live")return l(location.href,"document").then(f=>{document.body.replaceWith(f.body),b.mount(document.body),b.event(`Reloaded in ${H.stop()}`),D=NaN,u()});{let[f,v,O]=i.split(",");if(f==="section"){let $=T.get(v);if($===null){y(()=>b.event(`Reloaded in ${H.stop()}`));return}$.length>1?b.event(`${$.length} ${n}Sections`):b.event(`${n}Section`);let C=`${location.pathname}?sections=${v}`,W=!1;return l(C,"json").then(U=>{$.forEach(Z=>{he(Z,U[v],{childrenOnly:!0,onBeforeElUpdated:(d,h)=>{if(d.isEqualNode(h))return!1;if(t.morph.size>0){for(let w of t.morph)if(w(d,h)===!1)return!1}return!0}})}),b.event(`Reloaded in ${H.stop()}`)}).catch(U=>{W||(W=!0),a.push({title:"XHR Error fetching section",description:`Section with id: ${v} failed to return a response from Shopify`,group:"sections"}),console.error("SYNCIFY: ",U)}).finally(()=>{W?y(()=>{b.event(`Reloaded in ${H.stop()}`),u()}):u()})}else f==="script"?(b.event(`${n}JavaScript: ${v}`),Promise.allSettled(ue(document,v)).then(()=>{e.send(O),b.event(`Reloaded in ${H.stop()}`)}).finally(()=>u())):f==="stylesheet"&&(b.event(`${n}Stylesheet: ${v}`),te(document,v),e.send(O),b.event(`Reloaded in ${H.stop()}`))}}})}function y(e){l(location.href,"document").then(n=>{J(n).then(()=>{he(document.body,n.body,F),typeof e=="function"&&e(document)})})}function _(){return top.location.reload()}function L(e){q.send("ROUTE:"+JSON.stringify(e||{url:location.href,template:ce()}))}function M(){let e=document.body;return g&&(g=!1,q&&(A=!1,q.close()),b.unmount()),e}function j(e){if(document.readyState!=="complete")setTimeout(()=>j(e),25);else{let n=g?M():document.body;typeof e=="object"&&(window.Syncify.options=e),T.load(n),b.mount(n),g=!0,S()}}function B(e){t.reload.has(e)?console.warn("SYNCIFY: Duplicated onReload hook signature"):t.reload.add(e)}function ne(e){t.morph.has(e)?console.warn("SYNCIFY: Duplicated onMorph hook signature"):t.morph.add(e)}function I(e){t.assets.has(e)?console.warn("SYNCIFY: Duplicated onAsset hook signature"):t.assets.add(e)}Object.defineProperties(window.Syncify,{isReady:{get(){return g}},isConnected:{get(){return A}},errors:{get(){return a}},WebC:{get(){return s}},hooks:{get(){return t}},template:{get(){return k}},connect:{value:j},disconnect:{value:M},sections:{value:T},route:{value:L},assets:{value:J},refresh:{value:_},reload:{value:y},onAsset:{value:I},onMorph:{value:ne},onReload:{value:B}}),document.addEventListener("readystatechange",function(){ce(),this.readyState==="interactive"?we(s):this.readyState==="complete"&&le(this)}),j()})({method:"{{method|default:'hot'}}",server:+"{{server|default:41001}}",socket:+"{{socket|default:51001}}",label:!0,flags:{"no-preview-bar":!0,"no-web-pixels-manager":!0,"no-shopify-features":!0,"no-trekkie":!0,"no-perfkit":!0,"no-checkout-preloads":!0}});
|
14
14
|
</script>
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "1.0.0-unstable.
|
2
|
+
"version": "1.0.0-unstable.3",
|
3
3
|
"name": "@syncify/cli",
|
4
4
|
"description": "The new generation build tool for Shopify theme development.",
|
5
5
|
"license": "Apache-2.0",
|
@@ -59,11 +59,10 @@
|
|
59
59
|
"prettier": "@syncify/prettier-config",
|
60
60
|
"dependencies": {
|
61
61
|
"@parcel/watcher": "^2.5.1",
|
62
|
-
"@tailwindcss/postcss": "^4.
|
62
|
+
"@tailwindcss/postcss": "^4.1.7",
|
63
63
|
"adm-zip": "^0.5.16",
|
64
64
|
"cbor": "^10.0.3",
|
65
65
|
"clean-css": "^5.3.3",
|
66
|
-
"enquirer": "^2.4.1",
|
67
66
|
"esbuild": "v0.25.2",
|
68
67
|
"fast-glob": "^3.3.3",
|
69
68
|
"fs-extra": "^11.3.0",
|
@@ -73,35 +72,36 @@
|
|
73
72
|
"markdown-it": "^14.1.0",
|
74
73
|
"node-notifier": "^10.0.1",
|
75
74
|
"postcss": "^8.5.3",
|
76
|
-
"sass-embedded": "^1.
|
77
|
-
"smol-toml": "^1.3.
|
75
|
+
"sass-embedded": "^1.89.0",
|
76
|
+
"smol-toml": "^1.3.4",
|
78
77
|
"svgo": "^3.3.2",
|
79
|
-
"xior": "^0.7.
|
78
|
+
"xior": "^0.7.8",
|
79
|
+
"@syncify/uws": "^0.1.3",
|
80
80
|
"@syncify/acquire": "^0.0.6",
|
81
|
-
"@syncify/turndown": "^0.2.1",
|
82
81
|
"@syncify/json": "^0.1.1",
|
83
|
-
"@syncify/
|
82
|
+
"@syncify/turndown": "^0.2.2"
|
84
83
|
},
|
85
84
|
"devDependencies": {
|
86
85
|
"@ava/typescript": "^5.0.0",
|
87
|
-
"@changesets/cli": "^2.
|
88
|
-
"@graphql-codegen/cli": "^5.0.
|
86
|
+
"@changesets/cli": "^2.29.4",
|
87
|
+
"@graphql-codegen/cli": "^5.0.6",
|
89
88
|
"@graphql-codegen/introspection": "^4.0.3",
|
90
|
-
"@graphql-codegen/typescript": "^4.1.
|
91
|
-
"@graphql-codegen/typescript-operations": "^4.
|
89
|
+
"@graphql-codegen/typescript": "^4.1.6",
|
90
|
+
"@graphql-codegen/typescript-operations": "^4.6.1",
|
92
91
|
"@liquify/schema": "^0.9.10",
|
93
|
-
"@shopify/api-codegen-preset": "^1.1.
|
92
|
+
"@shopify/api-codegen-preset": "^1.1.7",
|
94
93
|
"@types/adm-zip": "^0.5.7",
|
95
94
|
"@types/fs-extra": "^11.0.4",
|
96
95
|
"@types/html-minifier-terser": "^7.0.2",
|
97
96
|
"@types/js-yaml": "^4.0.9",
|
98
|
-
"@types/node": "^22.
|
97
|
+
"@types/node": "^22.15.18",
|
99
98
|
"@types/node-notifier": "^8.0.5",
|
100
99
|
"@types/write-file-atomic": "^4.0.3",
|
101
100
|
"anymatch": "^3.1.3",
|
102
|
-
"ava": "^6.
|
101
|
+
"ava": "^6.3.0",
|
103
102
|
"concurrently": "^9.1.2",
|
104
|
-
"dotenv": "^16.
|
103
|
+
"dotenv": "^16.5.0",
|
104
|
+
"enquirer": "^2.4.1",
|
105
105
|
"eslint": "^9.17.0",
|
106
106
|
"gqlmin": "^0.2.2",
|
107
107
|
"p-map": "^7.0.3",
|
@@ -115,18 +115,18 @@
|
|
115
115
|
"typescript": "^5.7.2",
|
116
116
|
"write-file-atomic": "^6.0.0",
|
117
117
|
"write-package": "^7.1.0",
|
118
|
-
"@syncify/
|
119
|
-
"@syncify/
|
118
|
+
"@syncify/config": "^0.0.8",
|
119
|
+
"@syncify/ansi": "^0.4.0",
|
120
|
+
"@syncify/codegen": "^0.0.1",
|
120
121
|
"@syncify/glue": "^0.0.1",
|
121
|
-
"@syncify/config": "^0.
|
122
|
+
"@syncify/eslint-config": "^0.1.1",
|
122
123
|
"@syncify/kill": "^0.0.5",
|
123
124
|
"@syncify/tests": "^0.0.1",
|
124
|
-
"@syncify/
|
125
|
-
"@syncify/
|
125
|
+
"@syncify/codeframe": "^0.0.2",
|
126
|
+
"@syncify/types": "^0.1.0",
|
127
|
+
"@syncify/prettier-config": "^0.1.0",
|
126
128
|
"@syncify/update": "^0.0.3",
|
127
|
-
"@syncify/timer": "^0.0.4"
|
128
|
-
"@syncify/types": "^0.0.9",
|
129
|
-
"@syncify/prettier-config": "^0.1.0"
|
129
|
+
"@syncify/timer": "^0.0.4"
|
130
130
|
},
|
131
131
|
"peerDependenciesMeta": {
|
132
132
|
"tailwindcss": {
|
@@ -135,7 +135,7 @@
|
|
135
135
|
},
|
136
136
|
"scripts": {
|
137
137
|
"sy": "./bin/cli.js",
|
138
|
-
"dev": "pnpm tsup
|
138
|
+
"dev": "pnpm tsup",
|
139
139
|
"build": "pnpm --shell-mode \"./build.sh\"",
|
140
140
|
"@cli": "tsup",
|
141
141
|
"@utils": "pnpm -F @syncify/utils",
|
@@ -149,18 +149,21 @@
|
|
149
149
|
"@glue": "pnpm -F @syncify/glue",
|
150
150
|
"@hot": "pnpm -F @syncify/hot",
|
151
151
|
"@ansi": "pnpm -F @syncify/ansi",
|
152
|
+
"@tests": "pnpm -F @syncify/tests",
|
152
153
|
"@turndown": "pnpm -F @syncify/turndown",
|
153
154
|
"@json": "pnpm -F @syncify/json",
|
154
155
|
"@timer": "pnpm -F @syncify/timer",
|
155
156
|
"@uws": "pnpm -F @syncify/uws",
|
156
|
-
"t:bulk-add": "tests --bulk-add snippets",
|
157
|
-
"t:bulk-remove": "tests --bulk-remove
|
157
|
+
"t:bulk-add": "tests --dir e2e/project/source/snippets --bulk-add snippets",
|
158
|
+
"t:bulk-remove": "tests --dir e2e/project/source/snippets --bulk-remove",
|
158
159
|
"codegen": "graphql-codegen",
|
159
160
|
"introspect": "graphql-codegen --introspect",
|
160
|
-
"publish:
|
161
|
-
"publish:
|
162
|
-
"publish:
|
161
|
+
"publish:npm": "node scripts/prepublish.js",
|
162
|
+
"publish:stable": "node scripts/prepublish.js --tag latest",
|
163
|
+
"publish:next": "pnpm version prerelease --preid next && node scripts/prepublish.js --tag next --no-git-checks",
|
164
|
+
"publish:unstable": "pnpm version prerelease --no-git-checks --preid unstable --tag unstable",
|
163
165
|
"postinstall": "node scripts/postinstall.js",
|
164
|
-
"postversion": "node scripts/postversion.js"
|
166
|
+
"postversion": "node scripts/postversion.js",
|
167
|
+
"postuninstall": "node scripts/postuninstall.js"
|
165
168
|
}
|
166
169
|
}
|
package/readme.md
CHANGED
@@ -7,7 +7,7 @@ width="270px">
|
|
7
7
|
</p>
|
8
8
|
<h1></h1>
|
9
9
|
|
10
|
-
Syncify is a specialized tool designed for Shopify theme development. It offers an array of features that significantly enhance productivity, integration and workflow on the Shopify platform. Created to address the
|
10
|
+
Syncify is a specialized tool designed for Shopify theme development. It offers an array of features that significantly enhance productivity, integration and workflow on the Shopify platform. Created to address the mediocrity of OSS (theme dev) offerings from the Shopify team, Syncify delivers a sophisticated, high-performance, and customizable toolkit that streamlines workflows and integrates with modern tooling.
|
11
11
|
|
12
12
|
<h4>
|
13
13
|
Read Documentation ➠ https://syncify.sh
|
@@ -17,19 +17,19 @@ Syncify is a specialized tool designed for Shopify theme development. It offers
|
|
17
17
|
|
18
18
|
If you are seeking a tool that has considered requirement factors across the modern Shopify Theme Development ecosystem, and would like a solution that produces performance-focused optimizations at the development process level with features designed for the complexities of modern e-commerce, see the below core capabilities offerred by Syncify:
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
<i><strong>✓ <samp>Custom input → output directory structures for tailored project organization.</samp></strong></i><br>
|
21
|
+
<i><strong>✓ <samp>Compiling TypeScript, JavaScript, TSX, and JSX to support modern web development practices</samp></strong></i><br>
|
22
|
+
<i><strong>✓ <samp>Tailwind, PostCSS, and SASS stylesheet support for advanced CSS management</samp></strong></i><br>
|
23
|
+
<i><strong>✓ <samp>Terse minification of Markup and Liquid to optimize performance</samp></strong></i><br>
|
24
|
+
<i><strong>✓ <samp>Static pages with Markdown → Markup transformation for content creation flexibility</samp></strong></i><br>
|
25
|
+
<i><strong>✓ <samp>Metafield, Redirects, and Navigation synchronization for seamless data management</samp></strong></i><br>
|
26
|
+
<i><strong>✓ <samp>Version Controlled theme distribution ensuring consistency and traceability</samp></strong></i><br>
|
27
|
+
<i><strong>✓ <samp>Shared Schemas as a superset implementation for enhanced data modeling</samp></strong></i><br>
|
28
|
+
<i><strong>✓ <samp>Frontmatter controlled liquid level configuration to fine-tune template behavior</samp></strong></i><br>
|
29
|
+
<i><strong>✓ <samp>SVG transform and sprite generation processing for efficient icon and graphic handling</samp></strong></i><br>
|
30
|
+
<i><strong>✓ <samp>Multistore and theme parallel synchronization to manage multiple storefronts</samp></strong></i><br>
|
31
|
+
<i><strong>✓ <samp>Websocket HOT Reloads with CFH control and morphing for real-time development feedback</samp></strong></i><br>
|
32
|
+
<i><strong>✓ <samp>Git-based automations with CI baked integrations for streamlined development workflows</samp></strong></i><br>
|
33
33
|
|
34
34
|
<h1></h1>
|
35
35
|
|
@@ -39,7 +39,7 @@ The [Syncify Straps](https://github.com/SyncifyCLI) github organization provides
|
|
39
39
|
|
40
40
|
### Editor Intergration
|
41
41
|
|
42
|
-
For an integrated development experience in your text editor, please consider using the [VSCode Liquid](https://github.com/panoply/vscode-liquid) extension which has built-in support for Syncify. VSCode Liquid is
|
42
|
+
For an integrated development experience in your text editor, please consider using the [VSCode Liquid](https://github.com/panoply/vscode-liquid) extension which has built-in support for Syncify. VSCode Liquid is an independent alternative to the Shopify backed extension.
|
43
43
|
|
44
44
|
### Getting Help?
|
45
45
|
|
@@ -56,7 +56,7 @@ You can install Syncify as a development dependency or globally. There are a cou
|
|
56
56
|
|
57
57
|
<h3> GLOBAL INSTALL ⮂ SY CLI BINARY </h3>
|
58
58
|
|
59
|
-
Install Syncify globally to make the CLI binary available system-wide so you can use commands anywhere on your computer. The <a href="/packages/config/">@syncify/config</a> package can be leveraged on a per-project basis along side global installations for configuration file TypeScript support.
|
59
|
+
Install Syncify globally to make the CLI binary available system-wide so you can use commands anywhere on your computer. The <a href="https://github.com/panoply/syncify/tree/next/packages/config/packages/config">@syncify/config</a> package can be leveraged on a per-project basis along side global installations for configuration file TypeScript support.
|
60
60
|
|
61
61
|
<br>
|
62
62
|
</td></tr></table>
|
@@ -68,7 +68,7 @@ Install Syncify globally to make the CLI binary available system-wide so you can
|
|
68
68
|
The most stable and latest version of Syncify is available for consumption via the [NPM Registry](https://www.npmjs.com/package/@syncify/cli).
|
69
69
|
|
70
70
|
```bash
|
71
|
-
|
71
|
+
pnpm add @syncify/cli --global
|
72
72
|
```
|
73
73
|
|
74
74
|
## Nightly Release
|
@@ -76,9 +76,52 @@ $ pnpm add @syncify/cli --global
|
|
76
76
|
The nightly releases of Syncify can be installed using the `@next` version tag via NPM, code is on [next](https://github.com/panoply/syncify/tree/next) branch.
|
77
77
|
|
78
78
|
```bash
|
79
|
-
|
79
|
+
pnpm add @syncify/cli@next --global
|
80
80
|
```
|
81
81
|
|
82
|
+
## Unstable Release
|
83
|
+
|
84
|
+
The unstable releases of Syncify can be installed using the `@unstable` version tag via NPM, code is on [unstable](https://github.com/panoply/syncify/tree/unstable) branch.
|
85
|
+
|
86
|
+
```bash
|
87
|
+
pnpm add @syncify/cli@unstable --global
|
88
|
+
```
|
89
|
+
|
90
|
+
# Packages
|
91
|
+
|
92
|
+
This repository hosts a collection of sub-packages available for download through the NPM Registry. Each package includes a detailed **readme** that provides comprehensive insights into its specific use cases, functionality, and implementation details. All packages can be used standalone, independently of the Syncify CLI.
|
93
|
+
|
94
|
+
- [@syncify/acquire](https://github.com/panoply/syncify/tree/next/packages/acquire)
|
95
|
+
- [@syncify/ansi](https://github.com/panoply/syncify/tree/next/packages/ansi)
|
96
|
+
- [@syncify/codeframe](https://github.com/panoply/syncify/tree/next/packages/codeframe)
|
97
|
+
- [@syncify/codegen](https://github.com/panoply/syncify/tree/next/packages/codegen)
|
98
|
+
- [@syncify/config](https://github.com/panoply/syncify/tree/next/packages/config)
|
99
|
+
- [@syncify/glue](https://github.com/panoply/syncify/tree/next/packages/glue)
|
100
|
+
- [@syncify/hot](https://github.com/panoply/syncify/tree/next/packages/hot)
|
101
|
+
- [@syncify/json](https://github.com/panoply/syncify/tree/next/packages/json)
|
102
|
+
- [@syncify/kill](https://github.com/panoply/syncify/tree/next/packages/kill)
|
103
|
+
- [@syncify/schema](https://github.com/panoply/syncify/tree/next/packages/schema)
|
104
|
+
- [@syncify/tests](https://github.com/panoply/syncify/tree/next/packages/tests)
|
105
|
+
- [@syncify/timer](https://github.com/panoply/syncify/tree/next/packages/timer)
|
106
|
+
- [@syncify/turndown](https://github.com/panoply/syncify/tree/next/packages/turndown)
|
107
|
+
- [@syncify/types](https://github.com/panoply/syncify/tree/next/packages/types)
|
108
|
+
- [@syncify/update](https://github.com/panoply/syncify/tree/next/packages/update)
|
109
|
+
- [@syncify/uws](https://github.com/panoply/syncify/tree/next/packages/uws)
|
110
|
+
|
111
|
+
<details>
|
112
|
+
<summary>
|
113
|
+
Config Packages
|
114
|
+
</summary>
|
115
|
+
<p>
|
116
|
+
|
117
|
+
- [@syncify/eslint-config](https://github.com/panoply/syncify/tree/next/configs/eslint-config)
|
118
|
+
- [@syncify/prettier-config](https://github.com/panoply/syncify/tree/next/configs/prettier-config)
|
119
|
+
- [@syncify/stylelint-config](https://github.com/panoply/syncify/tree/next/configs/stylelint-config)
|
120
|
+
- [@syncify/tsconfig](https://github.com/panoply/syncify/tree/next/configs/tsconfig)
|
121
|
+
|
122
|
+
</p>
|
123
|
+
</details>
|
124
|
+
|
82
125
|
# Contributing
|
83
126
|
|
84
127
|
Contributions are welcome! This project is a monorepo managed with [pnpm](https://pnpm.js.org/) and [changesets](https://github.com/changesets). Dependencies follow the [workspace protocol](https://pnpm.io/workspaces#workspace-protocol-workspace), ensuring a symlinked structure with pnpm managing NPM registry versions. The [packages](/packages/) directory contains modules consumed by the core [syncify](/syncify/) module. To contribute bug fixes or enhancements, you'll need to fork or clone the entire project. Development is designed for use with [VS Code](https://code.visualstudio.com/), and maintaining consistency within this setup is encouraged.
|
@@ -153,16 +196,19 @@ pnpm build # Build production bundles for all modules and pack
|
|
153
196
|
### Targeting (Workspace Root)
|
154
197
|
|
155
198
|
```bash
|
199
|
+
pnpm @docs <cmd> # Targets the documentation SSG directory
|
156
200
|
pnpm @acquire <cmd> # Targets the @syncify/acquire acquire config bundle
|
157
201
|
pnpm @ansi <cmd> # Targets the @syncify/ansi CLI enhancement package
|
158
202
|
pnpm @config <cmd> # Targets the @syncify/config configuration package
|
159
203
|
pnpm @glue <cmd> # Targets the @syncify/glue Glue utility package
|
160
204
|
pnpm @codframe <cmd> # Targets the @syncify/codeframe Codeframe CLI package
|
205
|
+
pnpm @codegen <cmd> # Targets the @syncify/codegen Codegen generator helper
|
161
206
|
pnpm @hot <cmd> # Targets the @syncify/hot HOT Reloading client
|
162
207
|
pnpm @json <cmd> # Targets the @syncify/json JSON parser and differ
|
163
208
|
pnpm @kill <cmd> # Targets the @syncify/kill process kill package
|
164
209
|
pnpm @turndown <cmd> # Targets the @syncify/turndown reversed markdown parser
|
165
210
|
pnpm @timer <cmd> # Targets the @syncify/timer timing utility
|
211
|
+
pnpm @tests <cmd> # Targets the @syncify/tests internal test utility
|
166
212
|
pnpm @update <cmd> # Targets the @syncify/update version check utility
|
167
213
|
pnpm @uws <cmd> # Targets the @syncify/uws uWebsockets repackage
|
168
214
|
pnpm @cli <cmd> # Targets the @syncify/cli package (main package)
|
@@ -172,7 +218,7 @@ pnpm @cli <cmd> # Targets the @syncify/cli package (main package)
|
|
172
218
|
|
173
219
|
Syncify does not use Shopify OSS offerrings, you will find zero `@shopify/*` projects in the codebase. Interfacing with the Shopify API is handled with a custom client. The client is extensively typed and the TypeScript definitions are generated using [codegen](https://the-guild.dev/graphql/codegen). The repository comes with definitions and introspection included so there is no need to pull or regenerate.
|
174
220
|
|
175
|
-
# Author /
|
221
|
+
# Author / Licensing
|
176
222
|
|
177
223
|
Syncify was created and is maintained by [Νικολας Σαββιδης](https://github.com/panoply). Shopify has no affiliation with this project and does not fund Syncify; it is a completely independent solution. Choosing to leverage Syncify helps keep these independent projects alive and sends a clear message to Shopify that the community drives innovation.
|
178
224
|
|
@@ -181,9 +227,9 @@ Syncify was created and is maintained by [Νικολας Σαββιδης](https
|
|
181
227
|
Special thanks to the talented developers who have contributed to Syncify. This project has been in development for several years, and without these individuals, it wouldn't have progressed this far.
|
182
228
|
|
183
229
|
- [Kim Skinner](https://github.com/WolfGreyDev)
|
184
|
-
- [Mansedan](https://github.com/webdeveman)
|
185
230
|
- [Taksh](https://github.com/taksh108)
|
186
|
-
- [
|
231
|
+
- [Mansedan](https://github.com/webdeveman)
|
232
|
+
- [David Warrington](https://ellodave.dev)
|
187
233
|
|
188
234
|
### Donate / Sponsor
|
189
235
|
|
package/scripts/postinstall.js
CHANGED
@@ -33,6 +33,7 @@
|
|
33
33
|
const syncifyDir = path.join(os.homedir(), '.syncify');
|
34
34
|
const keychainFile = path.join(syncifyDir, '.keychain');
|
35
35
|
const versionsFile = path.join(syncifyDir, '.version');
|
36
|
+
const projectsFile = path.join(syncifyDir, '.projects');
|
36
37
|
const notifyIconFile = path.join(syncifyDir, 'icon.png');
|
37
38
|
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
38
39
|
|
@@ -65,6 +66,14 @@
|
|
65
66
|
hasNewline = 2;
|
66
67
|
}
|
67
68
|
|
69
|
+
// Lets create the .syncify/.projects file if it does not exist
|
70
|
+
if (!fs.existsSync(projectsFile)) {
|
71
|
+
logName();
|
72
|
+
fs.writeFileSync(projectsFile, '{}');
|
73
|
+
console.log(` ${created} ${gray(projectsFile)}`);
|
74
|
+
hasNewline = 2;
|
75
|
+
}
|
76
|
+
|
68
77
|
// Lets copy the notifier icon if it does not exist
|
69
78
|
if (!fs.existsSync(notifyIconFile)) {
|
70
79
|
logName();
|
@@ -0,0 +1,104 @@
|
|
1
|
+
// This script uses conditional logic to work in both CJS and ESM environments
|
2
|
+
(async () => {
|
3
|
+
|
4
|
+
let fs;
|
5
|
+
let path;
|
6
|
+
let os;
|
7
|
+
|
8
|
+
if (typeof require === 'function') {
|
9
|
+
|
10
|
+
// CommonJS environment
|
11
|
+
fs = require('fs');
|
12
|
+
path = require('path');
|
13
|
+
os = require('os');
|
14
|
+
|
15
|
+
} else {
|
16
|
+
|
17
|
+
// ES Module environment
|
18
|
+
({ default: fs } = await import('fs'));
|
19
|
+
({ default: path } = await import('path'));
|
20
|
+
({ default: os } = await import('os'));
|
21
|
+
|
22
|
+
}
|
23
|
+
|
24
|
+
const gray = (text) => `\x1b[0;90m${text}\x1b[0m`;
|
25
|
+
|
26
|
+
// Read and check syncify projects
|
27
|
+
const syncifyDir = path.join(os.homedir(), '.syncify');
|
28
|
+
const projectsFile = path.join(syncifyDir, '.projects');
|
29
|
+
const keychainFile = path.join(syncifyDir, '.keychain');
|
30
|
+
|
31
|
+
const projects = fs.existsSync(projectsFile) ? JSON.parse(fs.readFileSync(projectsFile).toString()) : {};
|
32
|
+
const keychain = fs.existsSync(projectsFile) ? JSON.parse(fs.readFileSync(keychainFile).toString()) : {};
|
33
|
+
const newKeychain = fs.existsSync(projectsFile) ? JSON.parse(fs.readFileSync(keychainFile).toString()) : {};
|
34
|
+
const keychainKeys = Object.keys(keychain);
|
35
|
+
const projectEntries = Object.entries(projects);
|
36
|
+
|
37
|
+
let updateKeychain = false;
|
38
|
+
let updateProjects = false;
|
39
|
+
|
40
|
+
if (projectEntries.length > 0) {
|
41
|
+
for (const [ dir, hash ] of projectEntries) {
|
42
|
+
if (!fs.existsSync(dir)) {
|
43
|
+
|
44
|
+
const cache = path.join(syncifyDir, hash);
|
45
|
+
|
46
|
+
if (keychainKeys.length > 0) {
|
47
|
+
keychainKeys.forEach(k => {
|
48
|
+
Object.keys(keychain[k]).forEach(v => {
|
49
|
+
|
50
|
+
const updated = keychain[k][v].projects.filter(t => {
|
51
|
+
if (t !== hash) return true;
|
52
|
+
if (!updateKeychain) updateKeychain = true;
|
53
|
+
return false;
|
54
|
+
});
|
55
|
+
|
56
|
+
if (updated.length === 0) {
|
57
|
+
delete newKeychain[k][v];
|
58
|
+
} else if (k in newKeychain && v in newKeychain[k]) {
|
59
|
+
newKeychain[k][v].projects = updated;
|
60
|
+
}
|
61
|
+
|
62
|
+
});
|
63
|
+
});
|
64
|
+
}
|
65
|
+
|
66
|
+
if (fs.existsSync(cache)) {
|
67
|
+
|
68
|
+
fs.rmdirSync(cache, { recursive: true });
|
69
|
+
|
70
|
+
delete projects[dir];
|
71
|
+
|
72
|
+
if (!updateProjects) {
|
73
|
+
console.log(' ');
|
74
|
+
updateProjects = true;
|
75
|
+
}
|
76
|
+
|
77
|
+
console.log(` deleted${gray(':')} ${gray(hash)}`);
|
78
|
+
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
if (updateKeychain) {
|
85
|
+
fs.writeFileSync(keychainFile, JSON.stringify(newKeychain));
|
86
|
+
}
|
87
|
+
|
88
|
+
if (updateProjects) {
|
89
|
+
|
90
|
+
if (Object.keys(projects).length === 0) {
|
91
|
+
fs.rmdirSync(syncifyDir, { recursive: true });
|
92
|
+
} else {
|
93
|
+
fs.writeFileSync(projectsFile, JSON.stringify(projects));
|
94
|
+
}
|
95
|
+
|
96
|
+
console.log(' ');
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
})().catch(err => {
|
101
|
+
|
102
|
+
console.error('𐄂 syncify postuninstall:', err);
|
103
|
+
|
104
|
+
});
|
package/scripts/postversion.js
CHANGED
@@ -21,10 +21,13 @@
|
|
21
21
|
|
22
22
|
}
|
23
23
|
|
24
|
+
const green = (text) => `\x1b[1;32m${text}\x1b[0m`;
|
25
|
+
const gray = (text) => `\x1b[0;90m${text}\x1b[0m`;
|
26
|
+
const whiteBold = (text) => `\x1b[1;37m${text}\x1b[0m`;
|
27
|
+
|
24
28
|
// Read package.json for version information
|
25
29
|
const cwd = process.cwd();
|
26
30
|
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
27
|
-
const gray = (text) => `\x1b[0;90m${text}\x1b[0m`;
|
28
31
|
|
29
32
|
// Files to be generated
|
30
33
|
const syncifyDir = path.join(os.homedir(), '.syncify');
|
@@ -0,0 +1,63 @@
|
|
1
|
+
const { execSync } = require('child_process');
|
2
|
+
const os = require('os');
|
3
|
+
const path = require('path');
|
4
|
+
|
5
|
+
const fs = require('fs-extra');
|
6
|
+
|
7
|
+
async function publishWithoutDevDeps () {
|
8
|
+
const srcDir = process.cwd();
|
9
|
+
const tempDir = path.join(os.tmpdir(), `syncify-publish-${Date.now()}`);
|
10
|
+
const args = process.argv.slice(2).join(' '); // Capture CLI arguments (e.g., --tag latest)
|
11
|
+
|
12
|
+
try {
|
13
|
+
// Read package.json
|
14
|
+
const packageJson = await fs.readJson(path.join(srcDir, 'package.json'));
|
15
|
+
|
16
|
+
// Create temporary directory
|
17
|
+
await fs.ensureDir(tempDir);
|
18
|
+
|
19
|
+
// Copy files specified in the 'files' field
|
20
|
+
const filesToCopy = packageJson.files || [
|
21
|
+
'dist',
|
22
|
+
'scripts/postinstall.js',
|
23
|
+
'scripts/postuninstall.js',
|
24
|
+
'scripts/postversion.js',
|
25
|
+
'hot.js.liquid',
|
26
|
+
'LICENCE',
|
27
|
+
'package.json',
|
28
|
+
'readme.md'
|
29
|
+
];
|
30
|
+
for (const file of filesToCopy) {
|
31
|
+
const srcPath = path.join(srcDir, file);
|
32
|
+
const destPath = path.join(tempDir, file);
|
33
|
+
if (await fs.pathExists(srcPath)) {
|
34
|
+
await fs.copy(srcPath, destPath, { recursive: true });
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
// Ensure package.json is copied
|
39
|
+
await fs.copy(path.join(srcDir, 'package.json'), path.join(tempDir, 'package.json'));
|
40
|
+
|
41
|
+
// Remove devDependencies from temporary package.json
|
42
|
+
const tempPackageJson = await fs.readJson(path.join(tempDir, 'package.json'));
|
43
|
+
delete tempPackageJson.devDependencies;
|
44
|
+
await fs.writeJson(path.join(tempDir, 'package.json'), tempPackageJson, { spaces: 2 });
|
45
|
+
|
46
|
+
// Copy icon.png for prepublishOnly
|
47
|
+
await fs.copy(path.join(srcDir, 'assets', 'icon.png'), path.join(tempDir, 'icon.png'));
|
48
|
+
|
49
|
+
// Publish from temporary directory
|
50
|
+
console.log('Publishing from temporary directory...');
|
51
|
+
execSync(`pnpm publish --access public ${args} --dry-run`, { cwd: tempDir, stdio: 'inherit' });
|
52
|
+
|
53
|
+
console.log('Published successfully!');
|
54
|
+
} catch (err) {
|
55
|
+
console.error('Error during publish:', err);
|
56
|
+
process.exit(1);
|
57
|
+
} finally {
|
58
|
+
// Clean up temporary directory
|
59
|
+
await fs.remove(tempDir);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
publishWithoutDevDeps();
|