@strifeapp/strife 0.2.17-alpha → 0.2.19-alpha

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.
@@ -1,2 +1,2 @@
1
- const e=1,t=2,a=4,n=8,s=16,o=32,r=64,c=128,i=256;class d extends MessageChannel{static _instanceCache;static get instance(){return this._instanceCache||(this._instanceCache=new d),this._instanceCache}invoke(){switch(this.port1.addEventListener('message',(t=>{t.data.cmd===e&&this.onConnected(t)}),{once:!0}),this.port1.start(),this._ready=new Promise(((e,t)=>{this.readyResolve=e,this.readyReject=t})),this._ready.then((()=>{console.log(`SENDING HSHK FROM SDK IN WINDOW ${window.name}`),window.top.postMessage({cmd:t,context:{name:window.name,height:document.body.scrollHeight}},'*',[this.port2])})),document.readyState){case'loading':case'interactive':document.onreadystatechange=()=>{'complete'===document.readyState&&this.readyResolve()};break;case'complete':this.readyResolve()}}constructor(){super(),this.broadcastChannel=new BroadcastChannel('app.broadcast')}subscribe(e){if('function'!=typeof e)throw new Error('messageHandler must be a function!');const t=t=>{try{e(t)}catch(e){console.error('Error in messageHandler:',e)}},a=e=>{try{this.broadcastChannel.postMessage(e.data)}catch(e){console.error('Error in messageHandler:',e)}};return this.broadcastChannel.addEventListener('message',t),this.port1.addEventListener('message',t),this.port1.addEventListener('message',a),()=>{console.log('unsubscribing '+window.name),this.broadcastChannel.removeEventListener('message',t),this.port1.removeEventListener('message',t),this.port1.removeEventListener('message',a),this.port1.close(),d._instanceCache=null}}send(e){this.port1.postMessage(e),this.broadcastChannel.postMessage(e)}onConnected(e){return e}}const m=e=>{if('function'!=typeof e)throw new Error('messageHandler must be a function!');console.log('subscribing: '+window.name);return d.instance.subscribe((t=>{try{if(t.data.cmd===n)for(const a of t.data.sync)a.action!==i||e(a.state)}catch(e){console.error('Error in messageHandler:',e)}}))},l=(e,t)=>e?.split('.').reduce(((e,t)=>e?.[t]),t);let h=!1,p={},u={},f=[],w=null;const g=[],b=({data:e})=>{try{e.cmd===n&&e.sync.forEach((e=>{switch(e.action){case r:g.forEach((({self:t,handler:a})=>{const n=e.data.find((e=>e.propertyName===t.dataset.field));e.currentPath===window.location.pathname&&n&&(t.dataset.placeholder=n.placeholder)})),f=[...e.data];break;case s:case o:g.forEach((({self:t,handler:a})=>{if(e.currentPath===window.location.pathname&&(e.action===o||e.data.some((e=>e.name===t.dataset.field)))){const n=e.data.findIndex((e=>e.name===t.dataset.field));n>=0&&a(e.data[n].value,e.context)}}));break;case i:p={...e.state},u={...e.context},h=!0}}))}catch(e){console.error(e)}},y=(e,t)=>{if(g.push({self:e,handler:t}),h){const a=l(e.dataset.field,p);void 0!==a&&t(a,u)}if(f.length){const t=f.find((t=>t.propertyName===e.dataset.field));t&&(e.dataset.placeholder=t.placeholder||'')}},v=()=>{'undefined'!=typeof window&&window.top!==window.self&&(performance.mark('mark-2'),performance.measure('Import elements started','mark-1','mark-2'),console.debug(`${performance.now().toFixed(1)}ms: [${window.name}] Import elements started after ${performance.getEntriesByName('Import elements started')[0].duration.toFixed(1)}ms`),import('./index-b52aa541.js'),d.instance.invoke(),d.instance.subscribe(b))};document.addEventListener('strife.render',(e=>{w&&clearTimeout(w),w=setTimeout((()=>{d.instance.send({cmd:a,updates:[{action:c,context:{name:window.name,height:document.body.scrollHeight}}]})}),100)})),performance.mark('mark-1');export{l as p,v as r,m as s,y as u};
2
- //# sourceMappingURL=index-49d1445f.js.map
1
+ const e=1,t=2,a=4,n=8,s=16,o=32,r=64,c=128,i=256;class d extends MessageChannel{static _instanceCache;static get instance(){return this._instanceCache||(this._instanceCache=new d),this._instanceCache}invoke(){switch(this.port1.addEventListener('message',(t=>{t.data.cmd===e&&this.onConnected(t)}),{once:!0}),this.port1.start(),this._ready=new Promise(((e,t)=>{this.readyResolve=e,this.readyReject=t})),this._ready.then((()=>{console.log(`SENDING HSHK FROM SDK IN WINDOW ${window.name}`),window.top.postMessage({cmd:t,context:{name:window.name,height:document.body.scrollHeight}},'*',[this.port2])})),document.readyState){case'loading':case'interactive':document.onreadystatechange=()=>{'complete'===document.readyState&&this.readyResolve()};break;case'complete':this.readyResolve()}}constructor(){super(),this.broadcastChannel=new BroadcastChannel('app.broadcast')}subscribe(e){if('function'!=typeof e)throw new Error('messageHandler must be a function!');const t=t=>{try{e(t)}catch(e){console.error('Error in messageHandler:',e)}},a=e=>{try{this.broadcastChannel.postMessage(e.data)}catch(e){console.error('Error in messageHandler:',e)}};return this.broadcastChannel.addEventListener('message',t),this.port1.addEventListener('message',t),this.port1.addEventListener('message',a),()=>{console.log('unsubscribing '+window.name),this.broadcastChannel.removeEventListener('message',t),this.port1.removeEventListener('message',t),this.port1.removeEventListener('message',a),this.port1.close(),d._instanceCache=null}}send(e){this.port1.postMessage(e),this.broadcastChannel.postMessage(e)}onConnected(e){return e}}const m=e=>{if('function'!=typeof e)throw new Error('messageHandler must be a function!');console.log('subscribing: '+window.name);return d.instance.subscribe((t=>{try{if(t.data.cmd===n)for(const a of t.data.sync)a.action!==i||e(a.state)}catch(e){console.error('Error in messageHandler:',e)}}))},l=(e,t)=>e?.split('.').reduce(((e,t)=>e?.[t]),t);let h=!1,p={},f={},u=[],w=null;const g=[],b=({data:e})=>{try{e.cmd===n&&e.sync.forEach((e=>{switch(e.action){case r:g.forEach((({self:t,handler:a})=>{const n=e.data.find((e=>e.propertyName===t.dataset.field));e.currentPath===window.location.pathname&&n&&(t.dataset.placeholder=n.placeholder)})),u=[...e.data];break;case s:case o:g.forEach((({self:t,handler:a})=>{if(e.currentPath===window.location.pathname&&(e.action===o||e.data.some((e=>e.name===t.dataset.field)))){const n=e.data.findIndex((e=>e.name===t.dataset.field));n>=0&&a(e.data[n].value,e.context)}}));break;case i:p={...e.state},f={...e.context},h=!0}}))}catch(e){console.error(e)}},y=(e,t)=>{if(g.push({self:e,handler:t}),h){const a=l(e.dataset.field,p);void 0!==a&&t(a,f)}if(u.length){const t=u.find((t=>t.propertyName===e.dataset.field));t&&(e.dataset.placeholder=t.placeholder||'')}},v=()=>{'undefined'!=typeof window&&window.top!==window.self&&(performance.mark('mark-2'),performance.measure('Import elements started','mark-1','mark-2'),console.debug(`${performance.now().toFixed(1)}ms: [${window.name}] Import elements started after ${performance.getEntriesByName('Import elements started')[0].duration.toFixed(1)}ms`),import('./index-97b0d2f2.js'),d.instance.invoke(),d.instance.subscribe(b))};document.addEventListener('strife.render',(e=>{w&&clearTimeout(w),w=setTimeout((()=>{d.instance.send({cmd:a,updates:[{action:c,context:{name:window.name,height:document.body.scrollHeight}}]})}),100)})),performance.mark('mark-1');export{l as p,v as r,m as s,y as u};
2
+ //# sourceMappingURL=index-4fbb1371.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-4fbb1371.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{u as e,p as t}from'./index-49d1445f.js';class s extends HTMLAnchorElement{constructor(){super(),this.tabIndex=0}connectedCallback(){e(this,(e=>this.render(e)))}render(e){if(e){this.href=e.href;const t=this.childNodes;if(0===t.length)this.textContent=e.text;else for(const s of t)s.nodeType===Node.TEXT_NODE&&(s.nodeValue=e.text);'_blank'===e.target&&(this.target=e.target),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0}))}}}customElements.define('str-anchor',s,{extends:'a'});const n=e=>e.startsWith('http://')||e.startsWith('https://')?e:'https:'+e,i='https://cdn.strife.app/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png',r=e=>{const t=e.querySelector('img');if(t.classList.contains('previewing'))return;const s=[...e.querySelectorAll('source')],r=s.find((e=>{if(t.currentSrc){const s=new URL(n(t.currentSrc)),i=new URL(n(e.srcset));return s.href===i.href}return window.matchMedia(e.media).matches}));r&&(t.dataset.propertyMedia=r.dataset?.propertyMedia,!t.currentSrc&&r.width&&r.height&&t.classList.add('previewing--empty'),t.classList.add('previewing'),t.style.maxWidth='100%',t.style.width=r.width+'px',t.style.aspectRatio=r.width/r.height,t.style.setProperty('--img-previewing-url',`url(${t.currentSrc||r.srcset})`),t.style.setProperty('--img-previewing-size','100%'),t.style.setProperty('--img-previewing-position','0px,0px'),t.src=i,s.forEach((e=>{e.srcset=i})))},d=e=>{e.classList.contains('previewing')||(e.classList.add('previewing'),e.src||e.classList.add('previewing--empty'),e.style.width=e.getAttribute('width')+'px',e.style.height=e.getAttribute('height')+'px',e.style.setProperty('--img-previewing-url',`url(${e.src})`),e.style.setProperty('--img-previewing-size','100%'),e.style.setProperty('--img-previewing-position','0px,0px'),e.src=i)},c=(e,t,s)=>{if(e instanceof HTMLImageElement)if(s.iterate)e.src=t.source.url,e.classList.remove('previewing'),e.classList.remove('previewing--empty');else if(t&&t.source&&t.source.crop){d(e);const s=e.offsetWidth/t.width,n=e.offsetWidth/2-t.source.originalWidth*(t.source.crop.zoom*s)*t.source.crop.focusX,i=e.offsetHeight/2-t.source.originalHeight*(t.source.crop.zoom*s)*t.source.crop.focusY,r=t.source.originalWidth/e.offsetWidth*(t.source.crop.zoom*s);e.style.setProperty('--img-previewing-url',`url(${t.source.originalPreview})`),e.style.setProperty('--img-previewing-size',100*r+'%'),e.style.setProperty('--img-previewing-position',`${n}px ${i}px`),t.source.originalPreview?e.classList.remove('previewing--empty'):e.classList.add('previewing--empty')}else t&&t.draft?(e.style.setProperty('--img-previewing-url',`url(${t.draft+'?cb='+Date.now()})`),e.style.setProperty('--img-previewing-size','100%'),e.style.setProperty('--img-previewing-position','0px,0px'),e.classList.remove('previewing--empty')):e.classList.add('previewing--empty')};customElements.define('str-picture',class extends HTMLPictureElement{_currentSrc;constructor(){super(),this._initied=new Promise(((e,t)=>{this.loadedResolve=e,this.loadedReject=t})),this.image=this.querySelector('img'),this.tabIndex=0,this.image.complete?this.init():(this.image.addEventListener('load',(e=>{this.init()}),{once:!0}),this.image.addEventListener('error',(e=>{this.init()}),{once:!0}))}connectedCallback(){}init(){this.initPreview(),e(this,((e,t)=>{this.render(e,t)}))}initPreview(){r(this),this.loadedResolve()}render(e,t){this._initied.then((()=>{((e,t,s)=>{if(!(e instanceof HTMLPictureElement))return;r(e);const n=e.querySelector('img'),i=n.dataset?.propertyMedia;i&&t?c(n,t[i],s):i||console.warn('No property media found on picture element',window.name,n)})(this,e,t),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0}))}))}disconnectedCallback(){}},{extends:'picture'}),customElements.define('str-img',class extends HTMLImageElement{constructor(){super(),this._loaded=new Promise(((e,t)=>{this.loadedResolve=e,this.loadedReject=t})),this.complete?this.init():(this.addEventListener('load',(e=>{this.init()}),{once:!0}),this.addEventListener('error',(e=>{this.init()}),{once:!0}))}connectedCallback(){}init(){this.initPreview(),e(this,((e,t)=>{this.render(e,t)}))}initPreview(){d(this),this.addEventListener('load',(e=>{this.loadedResolve()}),{once:!0})}render(e,t){this._loaded.then((()=>{c(this,e,t),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0}))}))}disconnectedCallback(){}},{extends:'img'});class l extends HTMLTimeElement{constructor(){super(),this.tabIndex=0}connectedCallback(){e(this,(e=>this.render(e)))}render(e){e&&(this.textContent=((e,t)=>{if(!t)return e;const s=new Date(e);if(isNaN(s))return'Invalid Date';const n=s.getFullYear(),i=String(n).slice(-2),r=String(s.getMonth()+1).padStart(2,'0'),d=new Intl.DateTimeFormat('en-US',{month:'short'}).format(s),c={yyyy:n,yy:i,MMMM:new Intl.DateTimeFormat('en-US',{month:'long'}).format(s),MMM:d,MM:r,dd:String(s.getDate()).padStart(2,'0'),d:String(s.getDate()),hh:String(s.getHours()).padStart(2,'0'),mm:String(s.getMinutes()).padStart(2,'0'),ss:String(s.getSeconds()).padStart(2,'0')},l=new RegExp(Object.keys(c).join('|'),'g');return t.replace(l,(e=>c[e]))})(e,this.dataset.format),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0})))}}customElements.define('str-time',l,{extends:'time'});const a=t=>{e(t,(e=>{o(t,e)}))},o=(e,t)=>{e.textContent=t,document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:e,value:t},composed:!0,bubbles:!0}))};customElements.define('str-address',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'address'}),customElements.define('str-p',class extends HTMLParagraphElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'p'}),customElements.define('str-span',class extends HTMLSpanElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'span'}),customElements.define('str-strong',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'strong'}),customElements.define('str-h1',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h1'}),customElements.define('str-h2',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h2'}),customElements.define('str-h3',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h3'}),customElements.define('str-h4',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h4'}),customElements.define('str-h5',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h5'}),customElements.define('str-h6',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h6'}),customElements.define('str-abbr',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'abbr'}),customElements.define('str-b',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'b'}),customElements.define('str-button',class extends HTMLButtonElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'button'}),customElements.define('str-cite',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'cite'}),customElements.define('str-code',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'code'}),customElements.define('str-dfn',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'dfn'}),customElements.define('str-em',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'em'}),customElements.define('str-i',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'i'}),customElements.define('str-label',class extends HTMLLabelElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'label'}),customElements.define('str-mark',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'mark'}),customElements.define('str-q',class extends HTMLQuoteElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'q'}),customElements.define('str-sub',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'sub'}),customElements.define('str-sup',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'sup'}),customElements.define('str-td',class extends HTMLTableCellElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'td'});const m=t=>{e(t,((e,s)=>{h(t,e,s)}))},h=(e,t,s)=>{u(e,t,s)},u=(e,s,n)=>{const i=((e,t)=>{var s=t.templates.find((e=>e.collection===t.model['@metadata']['@collection']));let n=e;e.includes('.')&&(n=e.split('.')[0]);const i=s?.editors.find((e=>e.editor.propertyName===n)),r=i?.editor.type;if(e!==n)switch(r){case'chapters':const[s,r]=e.split('.').slice(1);t.draft||console.warn('No draft value found in context ',t);const d=t.draft[n][Number(s)],c=t.templates.find((e=>e.normalizedName===d['@strife']?.template)),l=c?.editors.find((e=>e.editor.propertyName===r));return l?.editor.type;case'collection':const[a,o]=e.split('.').slice(1),m=t.templates.find((e=>e.collection===t.iterate['@metadata']['@collection'])),h=m?.editors.find((e=>e.editor.propertyName===o));return h?.editor.type;case'content-template':const[u]=e.split('.').slice(1),p=t.templates.find((e=>e.normalizedName===i.editor.attributes.templateId)),f=p?.editors.find((e=>e.editor.propertyName===u));return f?.editor.type}return r})(e.dataset.field,n);switch(e.innerHTML='',i){case'collection':((e,s,n)=>{s.documents&&s.documents.forEach(((s,i)=>{const r=e.dataset.field.lastIndexOf('.'),d=e.dataset.field.substring(r+1);let c=document.getElementById(`collection_${d}`).content;e.appendChild(c.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach((r=>{const d=r.dataset.field;r.dataset.field=`${e.dataset.field}.${i}.${d}`,r.render(t(d,s),{...n,iterate:s})}))}))})(e,s,n);break;case'chapters':((e,t,s)=>{t.forEach(((t,n)=>{let i=document.getElementById(t['@strife'].template).content;e.appendChild(i.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach(((i,r)=>{const d=i.dataset.field;i.dataset.field=`${e.dataset.field}.${n}.${d}`,i.render(t[d],s)}))}))})(e,s,n);break;case'html':e.innerHTML=s;break;case'text':e.textContent=s;break;case'multi-input':((e,t,s)=>{const n=e.dataset.field.lastIndexOf('.'),i=e.dataset.field.substring(n+1);t&&Array.isArray(t)&&t.forEach(((t,s)=>{let n=document.getElementById(`multiinput_${i}`);if(n){let s=n.content;s.querySelector('[data-value]').textContent=t,e.appendChild(s.cloneNode(!0))}}))})(e,s);break;default:e.innerHTML=`<p>Unsupported container type: ${i} for ${e.tagName}</p>`}document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:e,value:s},composed:!0,bubbles:!0}))};customElements.define('str-div',class extends HTMLDivElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'div'}),customElements.define('str-ul',class extends HTMLUListElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'ul'}),customElements.define('str-ol',class extends HTMLOListElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'ol'}),customElements.define('str-section',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'section'}),customElements.define('str-header',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'header'}),customElements.define('str-footer',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'footer'}),customElements.define('str-nav',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'nav'}),customElements.define('str-article',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'article'}),customElements.define('str-main',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'main'}),customElements.define('str-aside',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'aside'}),customElements.define('str-blockquote',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'blockquote'}),customElements.define('str-tbody',class extends HTMLTableSectionElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'tbody'});
2
- //# sourceMappingURL=index-b52aa541.js.map
1
+ import{u as e,p as t}from'./index-4fbb1371.js';class s extends HTMLAnchorElement{constructor(){super(),this.tabIndex=0}connectedCallback(){e(this,(e=>this.render(e)))}render(e){if(e){this.href=e.href;const t=this.childNodes;if(0===t.length)this.textContent=e.text;else for(const s of t)s.nodeType===Node.TEXT_NODE&&(s.nodeValue=e.text);'_blank'===e.target&&(this.target=e.target),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0}))}}}customElements.define('str-anchor',s,{extends:'a'});const n=e=>e.startsWith('http://')||e.startsWith('https://')?e:'https:'+e,i='https://cdn.strife.app/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png',r=e=>{const t=e.querySelector('img');if(t.classList.contains('previewing'))return;const s=[...e.querySelectorAll('source')],r=s.find((e=>{if(t.currentSrc){const s=new URL(n(t.currentSrc)),i=new URL(n(e.srcset));return s.href===i.href}return window.matchMedia(e.media).matches}));r&&(t.dataset.propertyMedia=r.dataset?.propertyMedia,!t.currentSrc&&r.width&&r.height&&t.classList.add('previewing--empty'),t.classList.add('previewing'),t.style.maxWidth='100%',t.style.width=r.width+'px',t.style.aspectRatio=r.width/r.height,t.style.setProperty('--img-previewing-url',`url(${t.currentSrc||r.srcset})`),t.style.setProperty('--img-previewing-size','100%'),t.style.setProperty('--img-previewing-position','0px,0px'),t.src=i,s.forEach((e=>{e.srcset=i})))},d=e=>{e.classList.contains('previewing')||(e.classList.add('previewing'),e.src||e.classList.add('previewing--empty'),e.style.width=e.getAttribute('width')+'px',e.style.height=e.getAttribute('height')+'px',e.style.setProperty('--img-previewing-url',`url(${e.src})`),e.style.setProperty('--img-previewing-size','100%'),e.style.setProperty('--img-previewing-position','0px,0px'),e.src=i)},c=(e,t,s)=>{if(e instanceof HTMLImageElement)if(s.iterate)e.src=t.source.url,e.classList.remove('previewing'),e.classList.remove('previewing--empty');else if(t&&t.source&&t.source.crop){d(e);const s=e.offsetWidth/t.width,n=e.offsetWidth/2-t.source.originalWidth*(t.source.crop.zoom*s)*t.source.crop.focusX,i=e.offsetHeight/2-t.source.originalHeight*(t.source.crop.zoom*s)*t.source.crop.focusY,r=t.source.originalWidth/e.offsetWidth*(t.source.crop.zoom*s);e.style.setProperty('--img-previewing-url',`url(${t.source.originalPreview})`),e.style.setProperty('--img-previewing-size',100*r+'%'),e.style.setProperty('--img-previewing-position',`${n}px ${i}px`),t.source.originalPreview?e.classList.remove('previewing--empty'):e.classList.add('previewing--empty')}else t&&t.draft?(e.style.setProperty('--img-previewing-url',`url(${t.draft+'?cb='+Date.now()})`),e.style.setProperty('--img-previewing-size','100%'),e.style.setProperty('--img-previewing-position','0px,0px'),e.classList.remove('previewing--empty')):e.classList.add('previewing--empty')};customElements.define('str-picture',class extends HTMLPictureElement{_currentSrc;constructor(){super(),this._initied=new Promise(((e,t)=>{this.loadedResolve=e,this.loadedReject=t})),this.image=this.querySelector('img'),this.tabIndex=0,this.image.complete?this.init():(this.image.addEventListener('load',(e=>{this.init()}),{once:!0}),this.image.addEventListener('error',(e=>{this.init()}),{once:!0}))}connectedCallback(){}init(){this.initPreview(),e(this,((e,t)=>{this.render(e,t)}))}initPreview(){r(this),this.loadedResolve()}render(e,t){this._initied.then((()=>{((e,t,s)=>{if(!(e instanceof HTMLPictureElement))return;r(e);const n=e.querySelector('img'),i=n.dataset?.propertyMedia;i&&t?c(n,t[i],s):i||console.warn('No property media found on picture element',window.name,n)})(this,e,t),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0}))}))}disconnectedCallback(){}},{extends:'picture'}),customElements.define('str-img',class extends HTMLImageElement{constructor(){super(),this._loaded=new Promise(((e,t)=>{this.loadedResolve=e,this.loadedReject=t})),this.complete?this.init():(this.addEventListener('load',(e=>{this.init()}),{once:!0}),this.addEventListener('error',(e=>{this.init()}),{once:!0}))}connectedCallback(){}init(){this.initPreview(),e(this,((e,t)=>{this.render(e,t)}))}initPreview(){d(this),this.addEventListener('load',(e=>{this.loadedResolve()}),{once:!0})}render(e,t){this._loaded.then((()=>{c(this,e,t),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0}))}))}disconnectedCallback(){}},{extends:'img'});class l extends HTMLTimeElement{constructor(){super(),this.tabIndex=0}connectedCallback(){e(this,(e=>this.render(e)))}render(e){e&&(this.textContent=((e,t)=>{if(!t)return e;const s=new Date(e);if(isNaN(s))return'Invalid Date';const n=s.getFullYear(),i=String(n).slice(-2),r=String(s.getMonth()+1).padStart(2,'0'),d=new Intl.DateTimeFormat('en-US',{month:'short'}).format(s),c={yyyy:n,yy:i,MMMM:new Intl.DateTimeFormat('en-US',{month:'long'}).format(s),MMM:d,MM:r,dd:String(s.getDate()).padStart(2,'0'),d:String(s.getDate()),hh:String(s.getHours()).padStart(2,'0'),mm:String(s.getMinutes()).padStart(2,'0'),ss:String(s.getSeconds()).padStart(2,'0')},l=new RegExp(Object.keys(c).join('|'),'g');return t.replace(l,(e=>c[e]))})(e,this.dataset.format),document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:this,value:e},composed:!0,bubbles:!0})))}}customElements.define('str-time',l,{extends:'time'});const a=t=>{e(t,(e=>{o(t,e)}))},o=(e,t)=>{e.textContent=t,document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:e,value:t},composed:!0,bubbles:!0}))};customElements.define('str-address',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'address'}),customElements.define('str-p',class extends HTMLParagraphElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'p'}),customElements.define('str-span',class extends HTMLSpanElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'span'}),customElements.define('str-strong',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'strong'}),customElements.define('str-h1',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h1'}),customElements.define('str-h2',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h2'}),customElements.define('str-h3',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h3'}),customElements.define('str-h4',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h4'}),customElements.define('str-h5',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h5'}),customElements.define('str-h6',class extends HTMLHeadingElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'h6'}),customElements.define('str-abbr',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'abbr'}),customElements.define('str-b',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'b'}),customElements.define('str-button',class extends HTMLButtonElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'button'}),customElements.define('str-cite',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'cite'}),customElements.define('str-code',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'code'}),customElements.define('str-dfn',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'dfn'}),customElements.define('str-em',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'em'}),customElements.define('str-i',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'i'}),customElements.define('str-label',class extends HTMLLabelElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'label'}),customElements.define('str-mark',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'mark'}),customElements.define('str-q',class extends HTMLQuoteElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'q'}),customElements.define('str-sub',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'sub'}),customElements.define('str-sup',class extends HTMLElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'sup'}),customElements.define('str-td',class extends HTMLTableCellElement{connectedCallback(){a(this)}render(e){o(this,e)}},{extends:'td'});const m=t=>{e(t,((e,s)=>{h(t,e,s)}))},h=(e,t,s)=>{u(e,t,s)},u=(e,s,n)=>{const i=((e,t)=>{var s=t.templates.find((e=>e.collection===t.model['@metadata']['@collection']));let n=e;e.includes('.')&&(n=e.split('.')[0]);const i=s?.editors.find((e=>e.editor.propertyName===n)),r=i?.editor.type;if(e!==n)switch(r){case'chapters':const[s,r]=e.split('.').slice(1);t.draft||console.warn('No draft value found in context ',t);const d=t.draft[n][Number(s)],c=t.templates.find((e=>e.normalizedName===d['@strife']?.template)),l=c?.editors.find((e=>e.editor.propertyName===r));return l?.editor.type;case'collection':const[a,o]=e.split('.').slice(1),m=t.templates.find((e=>e.collection===t.iterate['@metadata']['@collection'])),h=m?.editors.find((e=>e.editor.propertyName===o));return h?.editor.type;case'content-template':const[u]=e.split('.').slice(1),p=t.templates.find((e=>e.normalizedName===i.editor.attributes.templateId)),f=p?.editors.find((e=>e.editor.propertyName===u));return f?.editor.type}return r})(e.dataset.field,n);switch(e.innerHTML='',i){case'collection':((e,s,n)=>{s.documents&&s.documents.forEach(((s,i)=>{const r=e.dataset.field.lastIndexOf('.'),d=e.dataset.field.substring(r+1);let c=document.getElementById(`collection_${d}`).content;e.appendChild(c.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach((r=>{const d=r.dataset.field;r.dataset.field=`${e.dataset.field}.${i}.${d}`,r.render(t(d,s),{...n,iterate:s})}))}))})(e,s,n);break;case'chapters':((e,s,n)=>{s.forEach(((s,i)=>{let r=document.getElementById(s['@strife'].template).content;e.appendChild(r.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach(((r,d)=>{const c=r.dataset.field;r.dataset.field=`${e.dataset.field}.${i}.${c}`,r.render(t(c,s),n)}))}))})(e,s,n);break;case'html':e.innerHTML=s;break;case'text':e.textContent=s;break;case'multi-input':((e,t,s)=>{const n=e.dataset.field.lastIndexOf('.'),i=e.dataset.field.substring(n+1);t&&Array.isArray(t)&&t.forEach(((t,s)=>{let n=document.getElementById(`multiinput_${i}`);if(n){let s=n.content;s.querySelector('[data-value]').textContent=t,e.appendChild(s.cloneNode(!0))}}))})(e,s);break;default:e.innerHTML=`<p>Unsupported container type: ${i} for ${e.tagName}</p>`}document.dispatchEvent(new CustomEvent('strife.render',{detail:{host:e,value:s},composed:!0,bubbles:!0}))};customElements.define('str-div',class extends HTMLDivElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'div'}),customElements.define('str-ul',class extends HTMLUListElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'ul'}),customElements.define('str-ol',class extends HTMLOListElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'ol'}),customElements.define('str-section',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'section'}),customElements.define('str-header',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'header'}),customElements.define('str-footer',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'footer'}),customElements.define('str-nav',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'nav'}),customElements.define('str-article',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'article'}),customElements.define('str-main',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'main'}),customElements.define('str-aside',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'aside'}),customElements.define('str-blockquote',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'blockquote'}),customElements.define('str-tbody',class extends HTMLTableSectionElement{connectedCallback(){m(this)}render(e,t){h(this,e,t)}},{extends:'tbody'});
2
+ //# sourceMappingURL=index-97b0d2f2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-97b0d2f2.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{r as ready,s as subscribe,u as useState}from'./index-49d1445f.js';
1
+ export{r as ready,s as subscribe,u as useState}from'./index-4fbb1371.js';
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strifeapp/strife",
3
- "version": "0.2.17-alpha",
3
+ "version": "0.2.19-alpha",
4
4
  "description": "The Strife Client SDK for Strife Live Preview",
5
5
  "keywords": [],
6
6
  "files": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-49d1445f.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-b52aa541.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}