@strifeapp/strife 0.2.6-alpha → 0.2.8-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/dist/index-a5c03c15.js +2 -0
- package/dist/index-a5c03c15.js.map +1 -0
- package/dist/index-e24587fc.js +2 -0
- package/dist/index-e24587fc.js.map +1 -0
- package/dist/index.css +37 -0
- package/dist/index.js +1 -1
- package/package.json +3 -2
- package/dist/index-da8605cc.js +0 -2
- package/dist/index-da8605cc.js.map +0 -1
- package/dist/index-db580a61.js +0 -2
- package/dist/index-db580a61.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as e,i as t,r as s,a as n,b as d,C as i,A as l,S as a}from'./index-e24587fc.js';class c 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)}}}customElements.define('str-anchor',c,{extends:'a'}),customElements.define('str-picture',class extends HTMLPictureElement{_currentSrc;constructor(){super(),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})),this._initied=new Promise(((e,t)=>{this.loadedResolve=e,this.loadedReject=t}))}connectedCallback(){}init(){this.initPreview(),e(this,(e=>{this.render(e)}))}initPreview(){t(this),this.image.addEventListener('load',(e=>{this.loadedResolve()}),{once:!0})}render(e){this._initied.then((()=>{s(this,e)}))}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(),e(this,(e=>{this.render(e)}))}initPreview(){n(this),this.addEventListener('load',(e=>{this.loadedResolve()}),{once:!0})}render(e){this._loaded.then((()=>{d(this,e)}))}disconnectedCallback(){}},{extends:'img'});class r 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(),d=String(n).slice(-2),i=String(s.getMonth()+1).padStart(2,'0'),l=new Intl.DateTimeFormat('en-US',{month:'short'}).format(s),a={yyyy:n,yy:d,MMMM:new Intl.DateTimeFormat('en-US',{month:'long'}).format(s),MMM:l,MM:i,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')},c=new RegExp(Object.keys(a).join('|'),'g');return t.replace(c,(e=>a[e]))})(e,this.dataset.format))}}customElements.define('str-time',r,{extends:'time'});const o=t=>{e(t,(e=>{m(t,e)}))},m=(e,t)=>{e.textContent=t};customElements.define('str-address',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'address'}),customElements.define('str-p',class extends HTMLParagraphElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'p'}),customElements.define('str-span',class extends HTMLSpanElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'span'}),customElements.define('str-strong',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'strong'}),customElements.define('str-h1',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'h1'}),customElements.define('str-h2',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'h2'}),customElements.define('str-h3',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'h3'}),customElements.define('str-h4',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'h4'}),customElements.define('str-h5',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'h5'}),customElements.define('str-h6',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'h6'}),customElements.define('str-abbr',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'abbr'}),customElements.define('str-b',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'b'}),customElements.define('str-button',class extends HTMLButtonElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'button'}),customElements.define('str-cite',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'cite'}),customElements.define('str-code',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'code'}),customElements.define('str-dfn',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'dfn'}),customElements.define('str-em',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'em'}),customElements.define('str-i',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'i'}),customElements.define('str-label',class extends HTMLLabelElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'label'}),customElements.define('str-mark',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'mark'}),customElements.define('str-q',class extends HTMLQuoteElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'q'}),customElements.define('str-sub',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'sub'}),customElements.define('str-sup',class extends HTMLElement{connectedCallback(){o(this)}render(e){m(this,e)}},{extends:'sup'});let h=null;const u=t=>{h=a.instance,e(t,((e,s)=>{E(t,e,s)})),h.send({cmd:i.EU,updates:[{action:l.INIT,context:{propertyName:t.dataset.field}}]})},E=(e,t,s)=>{document.startViewTransition?document.startViewTransition((()=>{x(e,t,s)})):x(e,t,s)},x=(e,t,s)=>{const n=((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 d=s?.editors.find((e=>e.editor.propertyName===n)),i=d?.editor.type;if(e!==n)switch(i){case'chapters':const[s,i]=e.split('.').slice(1),l=t.model[n][Number(s)],a=t.templates.find((e=>e.normalizedName===l['@strife']?.template)),c=a?.editors.find((e=>e.editor.propertyName===i));return c?.editor.type;case'collection':const[r,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),E=t.templates.find((e=>e.normalizedName===d.editor.attributes.templateId)),x=E?.editors.find((e=>e.editor.propertyName===u));return x?.editor.type}return i})(e.dataset.field,s);switch(e.innerHTML='',n){case'collection':((e,t,s)=>{t.documents&&t.documents.forEach(((t,n)=>{let d=document.getElementById(`collection_${e.dataset.field}`).content;e.appendChild(d.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach((d=>{const i=d.dataset.field;var l,a;d.dataset.field=`${e.dataset.field}.${n}.${i}`,d.render((l=i,a=t,l?.split('.').reduce(((e,t)=>e?.[t]),a)),{templates:s.templates,model:s.model,iterate:t})}))}))})(e,t,s);break;case'chapters':((e,t,s)=>{t.forEach(((t,n)=>{let d=document.getElementById(t['@strife'].template).content;e.appendChild(d.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach(((d,i)=>{const l=d.dataset.field;d.dataset.field=`${e.dataset.field}.${n}.${l}`,d.render(t[l],s)}))}))})(e,t,s);break;case'html':e.innerHTML=t;break;case'text':e.textContent=t;break;default:e.innerHTML=`<p>Unsupported container type: ${n} for ${e.tagName}</p>`}switch(n){case'collection':case'chapters':setTimeout((()=>{h.send({cmd:i.EU,updates:[{action:l.SYNC,context:{name:window.name,height:document.body.scrollHeight}}]})}),300)}};customElements.define('str-div',class extends HTMLDivElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'div'}),customElements.define('str-ul',class extends HTMLUListElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'ul'}),customElements.define('str-ol',class extends HTMLOListElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'ol'}),customElements.define('str-section',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'section'}),customElements.define('str-header',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'header'}),customElements.define('str-footer',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'footer'}),customElements.define('str-nav',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'nav'}),customElements.define('str-article',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'article'}),customElements.define('str-main',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'main'}),customElements.define('str-aside',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'aside'}),customElements.define('str-blockquote',class extends HTMLElement{connectedCallback(){u(this)}render(e,t){E(this,e,t)}},{extends:'blockquote'});
|
|
2
|
+
//# sourceMappingURL=index-a5c03c15.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-a5c03c15.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={CONNECT:1,HSHK:2,EU:4,SYNC:8},t={NONE:8,EDIT:16,RESET:32,INIT:64,SYNC:128,STATE:256};class s extends MessageChannel{static _instanceCache;static get instance(){return this._instanceCache||(this._instanceCache=new s),this._instanceCache}invoke(){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 HSHK FROM SDK IN WINDOW ${window.name}`),window.top.postMessage({cmd:e.HSHK,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)}},r=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',r),()=>{this.broadcastChannel.removeEventListener('message',t),this.port1.removeEventListener('message',t),this.port1.removeEventListener('message',r),this.port1.close(),s._instanceCache=null}}send(e){this.port1.postMessage(e),this.broadcastChannel.postMessage(e)}onConnected(e){return e}}const r=r=>{if('function'!=typeof r)throw new Error('messageHandler must be a function!');return s.instance.subscribe((s=>{try{if(s.data.cmd===e.SYNC)for(const e of s.data.sync)e.action!==t.STATE||r(e.state)}catch(e){console.error('Error in messageHandler:',e)}}))},i=(e,t)=>{if(t&&t.source&&t.source.crop){const s=e.offsetWidth/t.width,r=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,a=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*a+'%'),e.style.setProperty('--img-previewing-position',`${r}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')},a=e=>{e.classList.add('previewing'),e.src||e.classList.add('previewing--empty'),e.style.width=e.width+'px',e.style.height=e.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=d},n=e=>{const t=e.querySelector('img'),s=[...e.querySelectorAll('source')],r=s.find((e=>{if(t.currentSrc){const s=new URL(o(t.currentSrc)),r=new URL(o(e.srcset));return s.href===r.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=d,s.forEach((e=>{e.srcset=d})))},o=e=>e.startsWith('http://')||e.startsWith('https://')?e:'https:'+e,c=(e,t)=>{const s=e.querySelector('img'),r=s.dataset?.propertyMedia;r&&t?i(s,t[r]):console.warn('No property media found on picture element',window.name,s)},d='https://cdn.strife.app/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png',p=[],h=({data:r})=>{try{if(r.cmd===e.SYNC){r.sync.forEach((e=>{switch(e.action){case t.INIT:p.forEach((({self:t,handler:s})=>{const r=e.data.find((e=>e.propertyName===t.dataset.field));e.currentPath===window.location.pathname&&r&&(t.dataset.placeholder=r.placeholder)}));break;case t.EDIT:case t.RESET:p.forEach((({self:s,handler:r})=>{if(e.currentPath===window.location.pathname&&(e.action===t.RESET||e.data.some((e=>e.name===s.dataset.field)))){const t=e.data.findIndex((e=>e.name===s.dataset.field));t>=0&&r(e.data[t].value,e.context)}}))}}));s.instance.send({cmd:e.EU,updates:[{action:t.SYNC,context:{name:window.name,height:document.body.scrollHeight}}]})}}catch(e){console.error(e)}},l=(e,t)=>p.push({self:e,handler:t}),m=()=>{'undefined'!=typeof window&&window.top!==window.self&&(import('./index-a5c03c15.js'),s.instance.invoke(),s.instance.subscribe(h))};export{t as A,e as C,s as S,a,i as b,m as c,n as i,c as r,r as s,l as u};
|
|
2
|
+
//# sourceMappingURL=index-e24587fc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-e24587fc.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--str-placeholder-text-opacity: 0.3;
|
|
3
|
+
--str-placeholder-background-color: #0099ff;
|
|
4
|
+
--str-placeholder-background-opacity: 0.8;
|
|
5
|
+
}
|
|
6
|
+
img.previewing {
|
|
7
|
+
--img-previewing-url: '';
|
|
8
|
+
--img-previewing-size: 100%;
|
|
9
|
+
--img-previewing-position: 0px 0px;
|
|
10
|
+
background-image: var(--img-previewing-url);
|
|
11
|
+
background-repeat: no-repeat;
|
|
12
|
+
background-position: var(--img-previewing-position);
|
|
13
|
+
background-size: var(--img-previewing-size);
|
|
14
|
+
}
|
|
15
|
+
img.previewing.previewing--empty {
|
|
16
|
+
background-image: repeating-linear-gradient(45deg, var(--str-placeholder-background-color) 0, transparent 1px, transparent 0, transparent 50%);
|
|
17
|
+
background-repeat: repeat;
|
|
18
|
+
background-position: 0 0;
|
|
19
|
+
background-size: 15px 15px;
|
|
20
|
+
outline: solid 1px var(--str-placeholder-background-color);
|
|
21
|
+
opacity: var(--str-placeholder-background-opacity);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
:where([is^="str-h"]:empty, [is^="str-textarea"]:empty, [is^="str-address"]:empty, [is^="str-anchor"]:empty, [is^="str-p"]:empty)::before {
|
|
27
|
+
color: inherit;
|
|
28
|
+
|
|
29
|
+
opacity: var(--str-placeholder-text-opacity);
|
|
30
|
+
|
|
31
|
+
content: attr(data-placeholder);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
::view-transition-old(root),
|
|
35
|
+
::view-transition-new(root) {
|
|
36
|
+
animation-duration: 0.5s;
|
|
37
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{a as initImage,i as initPicture,c as ready,b as renderImage,r as renderPicture,s as subscribe,u as useState}from'./index-e24587fc.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.
|
|
3
|
+
"version": "0.2.8-alpha",
|
|
4
4
|
"description": "The Strife SDK for JavaScript.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"unpkg": "dist/index.js",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "npx rollup -c -i index.js -d dist",
|
|
14
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
14
|
+
"prepublishOnly": "npm run clean && npm run build && npm run copy",
|
|
15
|
+
"copy": "cp ./composition/index.css ./dist/index.css",
|
|
15
16
|
"clean": "rimraf dist"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
package/dist/index-da8605cc.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e={CONNECT:1,HSHK:2,EU:4,SYNC:8},t={NONE:8,EDIT:16,RESET:32,INIT:64,SYNC:128,STATE:256};class a extends MessageChannel{static _instanceCache;static get instance(){return this._instanceCache||(this._instanceCache=new a),this._instanceCache}invoke(){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 HSHK FROM SDK IN WINDOW ${window.name}`),window.top.postMessage({cmd:e.HSHK,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)}},s=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',s),()=>{this.broadcastChannel.removeEventListener('message',t),this.port1.removeEventListener('message',t),this.port1.removeEventListener('message',s),this.port1.close(),a._instanceCache=null}}send(e){this.port1.postMessage(e),this.broadcastChannel.postMessage(e)}onConnected(e){return e}}const s=s=>{if('function'!=typeof s)throw new Error('messageHandler must be a function!');return a.instance.subscribe((a=>{try{if(a.data.cmd===e.SYNC)for(const e of a.data.sync)e.action!==t.STATE||s(e.state)}catch(e){console.error('Error in messageHandler:',e)}}))},n=[],o=({data:s})=>{try{if(s.cmd===e.SYNC){s.sync.forEach((e=>{switch(e.action){case t.INIT:n.forEach((({self:t,handler:a})=>{const s=e.data.find((e=>e.propertyName===t.dataset.field));e.currentPath===window.location.pathname&&s&&(t.dataset.placeholder=s.placeholder)}));break;case t.EDIT:case t.RESET:n.forEach((({self:a,handler:s})=>{if(e.currentPath===window.location.pathname&&(e.action===t.RESET||e.data.some((e=>e.name===a.dataset.field)))){const t=e.data.findIndex((e=>e.name===a.dataset.field));t>=0&&s(e.data[t].value,e.context)}}))}}));a.instance.send({cmd:e.EU,updates:[{action:t.SYNC,context:{name:window.name,height:document.body.scrollHeight}}]})}}catch(e){console.error(e)}},r=(e,t)=>n.push({self:e,handler:t}),c=()=>{'undefined'!=typeof window&&window.top!==window.self&&import('./index-db580a61.js').then((()=>{a.instance.invoke(),a.instance.subscribe(o)}))};export{t as A,e as C,a as S,c as r,s,r as u};
|
|
2
|
-
//# sourceMappingURL=index-da8605cc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-da8605cc.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index-db580a61.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{u as e,S as t,C as s,A as i}from'./index-da8605cc.js';const n=new CSSStyleSheet;n.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 r 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)}}}customElements.define('str-anchor',r,{extends:'a'});const a='https://cdn.strife.app/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png',d=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(),e(this,(e=>{this.render(e)}))}initPreview(){this._currentSrc=this.sources.find((e=>{if(this.image.currentSrc){const t=new URL(d(this.image.currentSrc)),s=new URL(d(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=a,this.sources.forEach((e=>{e.srcset=a})),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,i=this.image.offsetHeight/2-e[this._propertyMedia].source.originalHeight*(e[this._propertyMedia].source.crop.zoom*t)*e[this._propertyMedia].source.crop.focusY,n=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*n+'%'),this.image.style.setProperty('--img-previewing-position',`${s}px ${i}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(),e(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,i=this.offsetHeight/2-e.source.originalHeight*(e.source.crop.zoom*t)*e.source.crop.focusY,n=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*n+'%'),this.style.setProperty('--img-previewing-position',`${s}px ${i}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 c 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 i=s.getFullYear(),n=String(i).slice(-2),r=String(s.getMonth()+1).padStart(2,'0'),a=new Intl.DateTimeFormat('en-US',{month:'short'}).format(s),d={yyyy:i,yy:n,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')},c=new RegExp(Object.keys(d).join('|'),'g');return t.replace(c,(e=>d[e]))})(e,this.dataset.format))}}customElements.define('str-time',c,{extends:'time'});const o=t=>{e(t,(e=>{l(t,e)}))},l=(e,t)=>{e.textContent=t};customElements.define('str-address',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'address'}),customElements.define('str-p',class extends HTMLParagraphElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'p'}),customElements.define('str-span',class extends HTMLSpanElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'span'}),customElements.define('str-strong',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'strong'}),customElements.define('str-h1',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'h1'}),customElements.define('str-h2',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'h2'}),customElements.define('str-h3',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'h3'}),customElements.define('str-h4',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'h4'}),customElements.define('str-h5',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'h5'}),customElements.define('str-h6',class extends HTMLHeadingElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'h6'}),customElements.define('str-abbr',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'abbr'}),customElements.define('str-b',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'b'}),customElements.define('str-button',class extends HTMLButtonElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'button'}),customElements.define('str-cite',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'cite'}),customElements.define('str-code',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'code'}),customElements.define('str-dfn',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'dfn'}),customElements.define('str-em',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'em'}),customElements.define('str-i',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'i'}),customElements.define('str-label',class extends HTMLLabelElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'label'}),customElements.define('str-mark',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'mark'}),customElements.define('str-q',class extends HTMLQuoteElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'q'}),customElements.define('str-sub',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'sub'}),customElements.define('str-sup',class extends HTMLElement{connectedCallback(){o(this)}render(e){l(this,e)}},{extends:'sup'});const h=t.instance,m=t=>{e(t,((e,s)=>{p(t,e,s)})),h.send({cmd:s.EU,updates:[{action:i.INIT,context:{propertyName:t.dataset.field}}]})},p=(e,t,s)=>{document.startViewTransition?document.startViewTransition((()=>{u(e,t,s)})):u(e,t,s)},u=(e,t,n)=>{const r=((e,t)=>{t.iterate||t.model;var s=t.templates.find((e=>e.collection===t.model['@metadata']['@collection']));let i=e;e.includes('.')&&(i=e.split('.')[0]);const n=s?.editors.find((e=>e.editor.propertyName===i)),r=n?.editor.type;if(e!==i)switch(r){case'chapters':const[s,r]=e.split('.').slice(1),a=t.model[i][Number(s)],d=t.templates.find((e=>e.normalizedName===a['@strife']?.template)),c=d?.editors.find((e=>e.editor.propertyName===r));return c?.editor.type;case'collection':const[o,l]=e.split('.').slice(1),h=t.templates.find((e=>e.collection===t.iterate['@metadata']['@collection'])),m=h?.editors.find((e=>e.editor.propertyName===l));return m?.editor.type;case'content-template':const[p]=e.split('.').slice(1),u=t.templates.find((e=>e.normalizedName===n.editor.attributes.templateId)),g=u?.editors.find((e=>e.editor.propertyName===p));return g?.editor.type}return r})(e.dataset.field,n);switch(e.innerHTML='',r){case'collection':((e,t,s)=>{t.documents&&t.documents.forEach(((t,i)=>{let n=document.getElementById(`collection_${e.dataset.field}`).content;e.appendChild(n.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach((n=>{const r=n.dataset.field;var a,d;n.dataset.field=`${e.dataset.field}.${i}.${r}`,n.render((a=r,d=t,a?.split('.').reduce(((e,t)=>e?.[t]),d)),{templates:s.templates,model:s.model,iterate:t})}))}))})(e,t,n);break;case'chapters':((e,t,s)=>{t.forEach(((t,i)=>{let n=document.getElementById(t['@strife'].template).content;e.appendChild(n.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach(((n,r)=>{const a=n.dataset.field;n.dataset.field=`${e.dataset.field}.${i}.${a}`,n.render(t[a],s)}))}))})(e,t,n);break;case'html':e.innerHTML=t;break;case'text':e.textContent=t;break;default:e.innerHTML=`<p>Unsupported container type: ${r} for ${e.tagName}</p>`}switch(r){case'collection':case'chapters':setTimeout((()=>{h.send({cmd:s.EU,updates:[{action:i.SYNC,context:{name:window.name,height:document.body.scrollHeight}}]})}),300)}};customElements.define('str-div',class extends HTMLDivElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'div'}),customElements.define('str-ul',class extends HTMLUListElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'ul'}),customElements.define('str-ol',class extends HTMLOListElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'ol'}),customElements.define('str-section',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'section'}),customElements.define('str-header',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'header'}),customElements.define('str-footer',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'footer'}),customElements.define('str-nav',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'nav'}),customElements.define('str-article',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'article'}),customElements.define('str-main',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'main'}),customElements.define('str-aside',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'aside'}),customElements.define('str-blockquote',class extends HTMLElement{connectedCallback(){m(this)}render(e,t){p(this,e,t)}},{extends:'blockquote'}),document.adoptedStyleSheets=[n];
|
|
2
|
-
//# sourceMappingURL=index-db580a61.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-db580a61.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|