@strifeapp/strife 0.2.1-alpha → 0.2.2-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.
- package/package.json +1 -1
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
package/package.json
CHANGED
package/dist/index.esm.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e={CONNECT:1,HSHK:2,EU:4,SYNC:8};class t extends MessageChannel{constructor(){super(),this.broadcastChannel=new BroadcastChannel('app.broadcast');switch(this.port1.addEventListener('message',(t=>{t.data.cmd===e.CONNECT&&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 MESSAGE FROM SDK IN WINDOW ${window.name}`),window.top.postMessage({cmd:e.HSHK,context:{name:window.name,height:document.body.scrollHeight}},'*',[this.port2])})),window.addEventListener('beforeunload',(()=>{console.log('unload'),this.send({foo:'bar'})})),window.addEventListener('click',(()=>{this.send({cmd:e.EU,updates:[{action:'click',lastUserInteraction:(new Date).valueOf(),context:window.name}]})}),!1),document.readyState){case'loading':case'interactive':document.onreadystatechange=()=>{'complete'===document.readyState&&this.readyResolve()};break;case'complete':this.readyResolve()}}subscribe(e){if(null==e)throw new Error('Parameter can not be null!');this.broadcastChannel.addEventListener('message',e),this.port1.addEventListener('message',e),this.port1.addEventListener('message',(e=>this.broadcastChannel.postMessage(e.data)))}send(e){this.port1.postMessage(e),this.broadcastChannel.postMessage(e)}onConnected(e){return e}}var s=new t;const n={NONE:8,EDIT:16,RESET:32,INIT:64,SYNC:128},i=()=>s,r=[];s.subscribe((({data:t})=>{try{t.cmd===e.SYNC?(t.sync.forEach((e=>{switch(e.action){case n.INIT:r.forEach((({self:t,handler:s})=>{const n=e.data.find((e=>e.propertyName===t.dataset.field));e.currentPath===window.location.pathname&&n&&(t.dataset.placeholder=n.placeholder)}));break;case n.EDIT:case n.RESET:r.forEach((({self:t,handler:s})=>{if(e.currentPath===window.location.pathname&&(e.action===n.RESET||e.data.some((e=>e.name===t.dataset.field)))){const n=e.data.findIndex((e=>e.name===t.dataset.field));n>=0&&s(e.data[n].value,e.context)}}))}})),s.send({cmd:e.EU,updates:[{action:n.SYNC,context:{name:window.name,height:document.body.scrollHeight}}]})):t.cmd===e.EU&&t.action===n.FOCUS&&t.updates.forEach((e=>{r.forEach((({self:t})=>{e.propertyName===t.dataset.field&&e.currentPath===window.location.pathname&&t.scrollIntoView({behavior:'smooth',block:'center'})}))}))}catch(e){console.error(e)}}));const a=(e,t)=>(r.push({self:e,handler:t}),s),o=new CSSStyleSheet;o.replaceSync(':root {\n --str-placeholder-text-opacity: 0.3;\n --str-placeholder-background-color: #0099ff;\n --str-placeholder-background-opacity: 0.8;\n}\nimg.previewing {\n --img-previewing-url: \'\';\n --img-previewing-size: 100%;\n --img-previewing-position: 0px 0px;\n background-image: var(--img-previewing-url);\n background-repeat: no-repeat;\n background-position: var(--img-previewing-position);\n background-size: var(--img-previewing-size);\n}\nimg.previewing.previewing--empty {\n background-image: repeating-linear-gradient(45deg, var(--str-placeholder-background-color) 0, transparent 1px, transparent 0, transparent 50%);\n background-repeat: repeat;\n background-position: 0 0;\n background-size: 15px 15px;\n outline: solid 1px var(--str-placeholder-background-color);\n opacity: var(--str-placeholder-background-opacity);\n}\n\n\n\n:where([is^="str-h"]:empty, [is^="str-textarea"]:empty, [is^="str-address"]:empty, [is^="str-anchor"]:empty, [is^="str-p"]:empty)::before {\n color: inherit;\n\n opacity: var(--str-placeholder-text-opacity);\n\n content: attr(data-placeholder);\n}\n\n::view-transition-old(root),\n::view-transition-new(root) {\n animation-duration: 0.5s;\n}');class d extends HTMLAnchorElement{constructor(){super(),this.tabIndex=0}connectedCallback(){a(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)}}}customElements.define('str-anchor',d,{extends:'a'});const c='https://cdn.strife.app/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png',l=e=>e.startsWith('http://')||e.startsWith('https://')?e:'https:'+e;customElements.define('str-picture',class extends HTMLPictureElement{_propertyMedia;_currentSrc;constructor(){super(),this.image=this.querySelector('img'),this.sources=[...this.querySelectorAll('source')],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})),this._initied=new Promise(((e,t)=>{this.loadedResolve=e,this.loadedReject=t}))}connectedCallback(){}init(){this.initPreview(),a(this,(e=>{this.render(e)}))}initPreview(){this._currentSrc=this.sources.find((e=>{if(this.image.currentSrc){const t=new URL(l(this.image.currentSrc)),s=new URL(l(e.srcset));return t.href===s.href}return window.matchMedia(e.media).matches})),this._currentSrc&&(this._propertyMedia=this._currentSrc.dataset?.propertyMedia,this.offsetWidth,this._currentSrc.width,!this.image.currentSrc&&this._currentSrc.width&&this._currentSrc.height&&this.image.classList.add('previewing--empty'),this.image.classList.add('previewing'),this.image.style.maxWidth='100%',this.image.style.width=this._currentSrc.width+'px',this.image.style.aspectRatio=this._currentSrc.width/this._currentSrc.height,this.image.style.setProperty('--img-previewing-url',`url(${this.image.currentSrc||this._currentSrc.srcset})`),this.image.style.setProperty('--img-previewing-size','100%'),this.image.style.setProperty('--img-previewing-position','0px,0px'),this.image.src=c,this.sources.forEach((e=>{e.srcset=c})),this.image.addEventListener('load',(e=>{this.loadedResolve()}),{once:!0}))}render(e){this._initied.then((()=>{if(this._propertyMedia&&e&&e[this._propertyMedia]&&e[this._propertyMedia].source&&e[this._propertyMedia].source.crop){const t=this.image.offsetWidth/e[this._propertyMedia].width,s=this.image.offsetWidth/2-e[this._propertyMedia].source.originalWidth*(e[this._propertyMedia].source.crop.zoom*t)*e[this._propertyMedia].source.crop.focusX,n=this.image.offsetHeight/2-e[this._propertyMedia].source.originalHeight*(e[this._propertyMedia].source.crop.zoom*t)*e[this._propertyMedia].source.crop.focusY,i=e[this._propertyMedia].source.originalWidth/this.image.offsetWidth*(e[this._propertyMedia].source.crop.zoom*t);this.image.style.setProperty('--img-previewing-url',`url(${e[this._propertyMedia].source.originalPreview})`),this.image.style.setProperty('--img-previewing-size',100*i+'%'),this.image.style.setProperty('--img-previewing-position',`${s}px ${n}px`),e[this._propertyMedia].source.originalPreview?this.image.classList.remove('previewing--empty'):this.image.classList.add('previewing--empty')}}))}disconnectedCallback(){}},{extends:'picture'}),customElements.define('str-img',class extends HTMLImageElement{constructor(){super(),this.tabIndex=0,this.complete?this.init():(this.addEventListener('load',(e=>{this.init()}),{once:!0}),this.addEventListener('error',(e=>{this.init()}),{once:!0})),this._loaded=new Promise(((e,t)=>{this.loadedResolve=e,this.loadedReject=t}))}connectedCallback(){}init(){this.initPreview(),a(this,(e=>{this.render(e)}))}initPreview(){this.classList.add('previewing'),this.src||this.classList.add('previewing--empty'),this.style.width=this.width+'px',this.style.height=this.height+'px',this.style.setProperty('--img-previewing-url',`url(${this.src})`),this.style.setProperty('--img-previewing-size','100%'),this.style.setProperty('--img-previewing-position','0px,0px'),this.src='https://cdn.strife.app/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png',this.addEventListener('load',(e=>{this.loadedResolve()}),{once:!0})}render(e){this._loaded.then((()=>{if(e&&e.source&&e.source.crop){const t=this.offsetWidth/e.width,s=this.offsetWidth/2-e.source.originalWidth*(e.source.crop.zoom*t)*e.source.crop.focusX,n=this.offsetHeight/2-e.source.originalHeight*(e.source.crop.zoom*t)*e.source.crop.focusY,i=e.source.originalWidth/this.offsetWidth*(e.source.crop.zoom*t);this.style.setProperty('--img-previewing-url',`url(${e.source.originalPreview})`),this.style.setProperty('--img-previewing-size',100*i+'%'),this.style.setProperty('--img-previewing-position',`${s}px ${n}px`),e.source.originalPreview?this.classList.remove('previewing--empty'):this.classList.add('previewing--empty')}else e&&e.draft?(this.style.setProperty('--img-previewing-url',`url(${e.draft+'?cb='+Date.now()})`),this.style.setProperty('--img-previewing-size','100%'),this.style.setProperty('--img-previewing-position','0px,0px'),this.classList.remove('previewing--empty')):this.classList.add('previewing--empty')}))}disconnectedCallback(){}},{extends:'img'});class h extends HTMLTimeElement{constructor(){super(),this.tabIndex=0}connectedCallback(){a(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'),a=new Intl.DateTimeFormat('en-US',{month:'short'}).format(s),o={yyyy:n,yy:i,MMMM:new Intl.DateTimeFormat('en-US',{month:'long'}).format(s),MMM:a,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')},d=new RegExp(Object.keys(o).join('|'),'g');return t.replace(d,(e=>o[e]))})(e,this.dataset.format))}}customElements.define('str-time',h,{extends:'time'});const m=e=>{a(e,(t=>{p(e,t)}))},p=(e,t)=>{e.textContent=t};customElements.define('str-address',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'address'}),customElements.define('str-p',class extends HTMLParagraphElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'p'}),customElements.define('str-span',class extends HTMLSpanElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'span'}),customElements.define('str-strong',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'strong'}),customElements.define('str-h1',class extends HTMLHeadingElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'h1'}),customElements.define('str-h2',class extends HTMLHeadingElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'h2'}),customElements.define('str-h3',class extends HTMLHeadingElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'h3'}),customElements.define('str-h4',class extends HTMLHeadingElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'h4'}),customElements.define('str-h5',class extends HTMLHeadingElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'h5'}),customElements.define('str-h6',class extends HTMLHeadingElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'h6'}),customElements.define('str-abbr',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'abbr'}),customElements.define('str-b',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'b'}),customElements.define('str-button',class extends HTMLButtonElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'button'}),customElements.define('str-cite',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'cite'}),customElements.define('str-code',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'code'}),customElements.define('str-dfn',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'dfn'}),customElements.define('str-em',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'em'}),customElements.define('str-i',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'i'}),customElements.define('str-label',class extends HTMLLabelElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'label'}),customElements.define('str-mark',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'mark'}),customElements.define('str-q',class extends HTMLQuoteElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'q'}),customElements.define('str-sub',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'sub'}),customElements.define('str-sup',class extends HTMLElement{connectedCallback(){m(this)}render(e){p(this,e)}},{extends:'sup'});const u=t=>{a(t,((e,s)=>{g(t,e,s)})),s.send({cmd:e.EU,updates:[{action:n.INIT,context:{propertyName:t.dataset.field}}]})},g=(e,t,s)=>{document.startViewTransition?document.startViewTransition((()=>{f(e,t,s)})):f(e,t,s)},f=(t,i,r)=>{const a=((e,t)=>{t.iterate||t.model;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),a=t.model[n][Number(s)],o=t.templates.find((e=>e.normalizedName===a['@strife']?.template))?.editors.find((e=>e.editor.propertyName===r));return o?.editor.type;case'collection':const[d,c]=e.split('.').slice(1),l=t.templates.find((e=>e.collection===t.iterate['@metadata']['@collection']))?.editors.find((e=>e.editor.propertyName===c));return l?.editor.type;case'content-template':const[h]=e.split('.').slice(1),m=t.templates.find((e=>e.normalizedName===i.editor.attributes.templateId))?.editors.find((e=>e.editor.propertyName===h));return m?.editor.type}return r})(t.dataset.field,r);switch(t.innerHTML='',a){case'collection':((e,t,s)=>{t.documents&&t.documents.forEach(((t,n)=>{let i=document.getElementById(`collection_${e.dataset.field}`).content;e.appendChild(i.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach((i=>{const r=i.dataset.field;var a;i.dataset.field=`${e.dataset.field}.${n}.${r}`,i.render((a=t,r?.split('.').reduce(((e,t)=>e?.[t]),a)),{templates:s.templates,model:s.model,iterate:t})}))}))})(t,i,r);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 a=i.dataset.field;i.dataset.field=`${e.dataset.field}.${n}.${a}`,i.render(t[a],s)}))}))})(t,i,r);break;case'html':t.innerHTML=i;break;case'text':t.textContent=i;break;default:t.innerHTML=`<p>Unsupported container type: ${a} for ${t.tagName}</p>`}switch(a){case'collection':case'chapters':setTimeout((()=>{s.send({cmd:e.EU,updates:[{action:n.SYNC,context:{name:window.name,height:document.body.scrollHeight}}]})}),300)}};customElements.define('str-div',class extends HTMLDivElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'div'}),customElements.define('str-ul',class extends HTMLUListElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'ul'}),customElements.define('str-ol',class extends HTMLOListElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'ol'}),customElements.define('str-section',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'section'}),customElements.define('str-header',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'header'}),customElements.define('str-footer',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'footer'}),customElements.define('str-nav',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'nav'}),customElements.define('str-article',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'article'}),customElements.define('str-main',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'main'}),customElements.define('str-aside',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'aside'}),customElements.define('str-blockquote',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){g(this,e,t)}},{extends:'blockquote'}),document.adoptedStyleSheets=[o];export{n as ACTION,e as CMD,i as default,a as useState};
|
|
2
|
-
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|