@strifeapp/strife 0.0.6-preview.1 → 0.0.6-preview.12

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.
Files changed (2) hide show
  1. package/dist/index.esm.js +1 -1
  2. package/package.json +11 -10
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from'https://cdn.skypack.dev/showdown';const t={HSHK:1,EU:2,SYNC:4,CONNECT:8};class n extends MessageChannel{constructor(){super(),this.broadcastChannel=new BroadcastChannel('app.broadcast');this.port1.addEventListener('message',(e=>{e.data.cmd===t.CONNECT&&this.onConnected(e)}),{once:!0}),this.port1.start(),console.log(`SENDING MESSAGE FROM SDK IN WINDOW ${window.name}`),window.top.postMessage({cmd:t.HSHK,context:window.name},'*',[this.port2])}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 n;const r={NONE:8,EDIT:16};let a;const o=new Promise((e=>{a=e})),c=()=>(s.onConnected=e=>a([e,s]),o),i=async(e,n)=>(o.then((([s,a])=>{a.subscribe((({data:s})=>{s.cmd===t.SYNC&&s.sync.forEach((t=>{t.propertyName===e.dataset.propertyName&&t.currentPath===window.location.pathname&&n(t.data[e.dataset.propertyName])}))}));const o=e.dataset.editorName??Object.getPrototypeOf(Object.getPrototypeOf(e)).constructor.name.replace(/([A-Z][a-z])/g,'-$1').concat('-Editor').toLowerCase();return['click'].forEach((n=>{e.addEventListener(n,(n=>{n.preventDefault(),n.stopPropagation(),n.currentTarget instanceof HTMLAnchorElement&&n.altKey?window.location.href=n.currentTarget.href:a.send({cmd:t.EU,updates:[{lastUserInteraction:(new Date).toJSON(),action:r.EDIT,origin:window.location.origin,currentPath:window.location.pathname,propertyName:e.dataset.propertyName,editorName:o,placeholder:e.ariaPlaceholder}]})}))})),[s,a]}),(e=>{console.error(e)})),o);class l extends HTMLHeadingElement{constructor(){super(),this.tabIndex=0}connectedCallback(){i(this,(e=>this.textContent=e))}}customElements.define('strife-h1-cpnt',l,{extends:'h1'}),customElements.define('strife-h2-cpnt',class extends l{},{extends:'h2'}),customElements.define('strife-h3-cpnt',class extends l{},{extends:'h3'}),customElements.define('strife-h4-cpnt',class extends l{},{extends:'h4'}),customElements.define('strife-h5-cpnt',class extends l{},{extends:'h5'}),customElements.define('strife-h6-cpnt',class extends l{},{extends:'h6'});class d extends HTMLElement{constructor(){super(),this.tabIndex=0}async connectedCallback(){i(this,(e=>this.textContent=e))}}customElements.define('strife-address-cpnt',d,{extends:'address'});class h extends HTMLAnchorElement{constructor(){super(),this.tabIndex=0}async connectedCallback(){i(this,(e=>this.href=e))}}customElements.define('strife-anchor-cpnt',h,{extends:'a'}),customElements.define('strife-markdown-cpnt',class extends HTMLDivElement{constructor(){super();const t={p:this.querySelector('p')?.classList.value},n=Object.keys(t).map((e=>({type:'output',regex:new RegExp(`<${e}(.*)>`,'g'),replace:`<${e} class="${t[e]}" $1>`})));this.converter=new e.Converter({extensions:[...n]}),this.tabIndex=0}async connectedCallback(){i(this,(e=>{this.innerHTML=this.converter.makeHtml(e)}))}},{extends:'div'}),customElements.define('strife-picture-cpnt',class extends HTMLPictureElement{constructor(){super(),this.image=this.querySelector('img'),this.sources=[...this.querySelectorAll('source, img')],this.tabIndex=0}connectedCallback(){i(this,(e=>{this.sources.forEach((t=>{this.render(t,e)}))}))}render(e,t,n){let s=e.src||e.srcset;s.startsWith('?')&&(s='https://strife.app/placeholder.png'+s);let r=new URL(s);const a=this.getTransformations(r);if(n)for(const[e,t]of n.entries())a.set(e,t);r=new URL(t),r.searchParams.set('tr',[...a].map((e=>e.join('-')))),e instanceof HTMLImageElement?e.src=r.href:e instanceof HTMLSourceElement&&(e.srcset=r.href)}getTransformations(e){return e.searchParams.has('tr')?new Map(e.searchParams.get('tr').split(',').map((e=>[...e.split('-')]))||null):new Map}disconnectedCallback(){}},{extends:'picture'}),customElements.define('strife-img-cpnt',class extends HTMLImageElement{constructor(){super(),this.tabIndex=0}connectedCallback(){i(this,(e=>{this.render(this,e)}))}render(e,t,n){let s=e.src||e.srcset;s.startsWith('?')&&(s='https://strife.app/placeholder.png'+s);let r=new URL(s);const a=this.getTransformations(r);if(n)for(const[e,t]of n.entries())a.set(e,t);r=new URL(t),r.searchParams.set('tr',[...a].map((e=>e.join('-')))),e instanceof HTMLImageElement?e.src=r.href:e instanceof HTMLSourceElement&&(e.srcset=r.href)}getTransformations(e){return e.searchParams.has('tr')?new Map(e.searchParams.get('tr').split(',').map((e=>[...e.split('-')]))||null):new Map}disconnectedCallback(){}},{extends:'img'}),customElements.define('strife-blocks-cpnt',class extends HTMLDivElement{constructor(){super(),this.tabIndex=0}connectedCallback(){i(this,(e=>this.textContent=e))}},{extends:'div'});const p=new CSSStyleSheet;p.replaceSync('[is]:defined {\n position: relative;\n\n outline-width: 0;\n outline-style: var(--outline-style, solid);\n outline-color: var(--outline-color, #027bd2);\n\n transition: outline-width 50ms ease;\n}\n\n[is]:defined:hover {\n cursor: pointer;\n}\n[is]:defined:hover,\n[is]:defined:focus,\n[is]:defined:active {\n outline-width: var(--outline-width, 1px);\n}\n\n[is]:empty:not(img) {\n outline-width: var(--outline-width, 1px);\n}\n\n[is]:empty:not(img)::before {\n opacity: 0.5;\n\n content: attr(aria-placeholder);\n -webkit-text-fill-color:#fff;\n}\n\nimg:not([src^="http"]) {\n contain: content;\n\n outline: var(--outline-style, solid) var(--outline-width, 1px) var(--outline-color, #027bd2);\n /* content-visibility: hidden; */\n}\n\nimg:not([src^="http"])::before {\n position: absolute;\n\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n\n background: currentColor;\n\n content: attr(aria-placeholder);\n -webkit-text-fill-color:#fff;\n}'),document.adoptedStyleSheets=[p];export{r as ACTION,t as CMD,c as default,i as useState};
1
+ const e={HSHK:1,EU:2,SYNC:4,CONNECT:8};class t extends MessageChannel{constructor(){super(),this.broadcastChannel=new BroadcastChannel('app.broadcast');this.port1.addEventListener('message',(t=>{t.data.cmd===e.CONNECT&&this.onConnected(t)}),{once:!0}),this.port1.start(),console.log(`SENDING MESSAGE FROM SDK IN WINDOW ${window.name}`),window.top.postMessage({cmd:e.HSHK,context:window.name},'*',[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)}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 i={NONE:8,EDIT:16},r=()=>s,n=[];s.subscribe((({data:t})=>{try{t.cmd===e.SYNC?t.sync.forEach((e=>{n.forEach((({self:t,handler:s})=>{if(e.currentPath===window.location.pathname){const i=c(t.dataset.propertyName,e.data);i&&s(i)}}))})):t.cmd===e.EU&&t.action===i.FOCUS&&t.updates.forEach((e=>{n.forEach((({self:t})=>{e.propertyName===t.dataset.propertyName&&e.currentPath===window.location.pathname&&t.scrollIntoView({behavior:'smooth',block:'center'})}))}))}catch(e){console.error(e)}}));const o=(t,r)=>{n.push({self:t,handler:r});try{const r=t.closest('[is=str-template-cpnt]')||t;['click'].forEach((t=>{r.addEventListener(t,(t=>{t.preventDefault(),t.stopPropagation(),console.log(r),t.currentTarget instanceof HTMLAnchorElement&&t.altKey?window.location.href=t.currentTarget.href:s.send({cmd:e.EU,updates:[{lastUserInteraction:(new Date).toJSON(),action:i.EDIT,origin:window.location.origin,currentPath:window.location.pathname,propertyName:r.dataset.propertyName,attributes:[...r.attributes].filter((e=>e.name.includes('property')||e.name.includes('editor')||e.name.includes('template'))).map((e=>({name:e.name,value:e.value}))),placeholder:r.ariaPlaceholder}]})}))}))}catch(e){if(!(e instanceof TypeError))throw e;console.debug('Editor can not be found')}return s},c=(e,t)=>e.split('.').reduce(((e,t)=>e?.[t]),t),a=new CSSStyleSheet;a.replaceSync('[is]:not([is=\'str-template-cpnt\'] [is]):hover {\n outline: solid 1px #0099ff;\n cursor: pointer;\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}\n');class h extends HTMLHeadingElement{constructor(){super(),this.tabIndex=0}connectedCallback(){o(this,(e=>this.textContent=e))}}customElements.define('str-h1-cpnt',h,{extends:'h1'}),customElements.define('str-h2-cpnt',class extends h{},{extends:'h2'}),customElements.define('str-h3-cpnt',class extends h{},{extends:'h3'}),customElements.define('str-h4-cpnt',class extends h{},{extends:'h4'}),customElements.define('str-h5-cpnt',class extends h{},{extends:'h5'}),customElements.define('str-h6-cpnt',class extends h{},{extends:'h6'});class d extends HTMLElement{constructor(){super(),this.tabIndex=0}async connectedCallback(){o(this,(e=>this.textContent=e))}}customElements.define('str-address-cpnt',d,{extends:'address'});class p extends HTMLAnchorElement{constructor(){super(),this.tabIndex=0}async connectedCallback(){o(this,(e=>this.href=e))}}customElements.define('str-anchor-cpnt',p,{extends:'a'}),customElements.define('str-picture-cpnt',class extends HTMLPictureElement{_propertyMedia;_currentSrc;constructor(){super(),this.image=this.querySelector('img'),this.sources=[...this.querySelectorAll('source')],this.tabIndex=0}connectedCallback(){this.initPreview(),o(this,(e=>{this.render(this,e)}))}initPreview(){this._currentSrc=this.sources.find((e=>{if(this.image.currentSrc)return e.srcset===this.image.currentSrc;return window.matchMedia(e.media).matches})),this._currentSrc&&(this._propertyMedia=this._currentSrc.dataset?.propertyMedia,!this.image.currentSrc&&this._currentSrc.width&&this._currentSrc.height&&(this.image.width=this._currentSrc.width,this.image.height=this._currentSrc.height)),this.image.classList.add('previewing'),this.image.style.maxWidth=this.image.width+'px',this.image.style.maxHeight=this.image.height+'px',this.image.style.setProperty('--img-previewing-url',`url(${this.image.currentSrc})`),this.image.style.setProperty('--img-previewing-size','100%'),this.image.style.setProperty('--img-previewing-position','0px,0px'),this.image.src='https://images.nimbleinitiatives.com/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png',this.sources.forEach((e=>{e.srcset='https://images.nimbleinitiatives.com/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png'}))}render(e,t,s){if(this._propertyMedia&&t&&t[this._propertyMedia]&&t[this._propertyMedia].source&&t[this._propertyMedia].source.crop){const e=this.image.offsetWidth/t[this._propertyMedia].width,s=this.image.offsetWidth/2-t[this._propertyMedia].source.originalWidth*(t[this._propertyMedia].source.crop.zoom*e)*t[this._propertyMedia].source.crop.focusX,i=this.image.offsetHeight/2-t[this._propertyMedia].source.originalHeight*(t[this._propertyMedia].source.crop.zoom*e)*t[this._propertyMedia].source.crop.focusY,r=t[this._propertyMedia].source.originalWidth/this.image.offsetWidth*(t[this._propertyMedia].source.crop.zoom*e);this.image.style.setProperty('--img-previewing-url',`url(${t[this._propertyMedia].source.originalPreview})`),this.image.style.setProperty('--img-previewing-size',100*r+'%'),this.image.style.setProperty('--img-previewing-position',`${s}px ${i}px`)}}disconnectedCallback(){}},{extends:'picture'}),customElements.define('str-img-cpnt',class extends HTMLImageElement{constructor(){super(),this.tabIndex=0}connectedCallback(){this.initPreview(),o(this,(e=>{this.render(this,e)}))}initPreview(){this.classList.add('previewing'),this.style.width=this.getAttribute('width')+'px',this.style.height=this.getAttribute('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://images.nimbleinitiatives.com/AS3SX_-B59mU1hdDS7B_YfI5Lu9Ut-kLpdaAhraKgy4/w:1/h:1/aHR0cHM6Ly9zdHJpZmUuYi1jZG4ubmV0L3RyYW5zcGFyZW50MXgxLnBuZw.png'}render(e,t,s){if(t&&t.source){const e=this.offsetWidth/t.width,s=this.offsetWidth/2-t.source.originalWidth*(t.source.crop.zoom*e)*t.source.crop.focusX,i=this.offsetHeight/2-t.source.originalHeight*(t.source.crop.zoom*e)*t.source.crop.focusY,r=t.source.originalWidth/this.offsetWidth*(t.source.crop.zoom*e);this.style.setProperty('--img-previewing-url',`url(${t.source.originalPreview})`),this.style.setProperty('--img-previewing-size',100*r+'%'),this.style.setProperty('--img-previewing-position',`${s}px ${i}px`)}}disconnectedCallback(){}},{extends:'img'}),customElements.define('strife-blocks-cpnt',class extends HTMLDivElement{constructor(){super(),this.tabIndex=0}connectedCallback(){o(this,(e=>this.textContent=e))}},{extends:'div'});class l extends HTMLElement{constructor(){super(),this.tabIndex=0}async connectedCallback(){o(this,(e=>this.textContent=e))}}customElements.define('str-strong-cpnt',l,{extends:'strong'});class m extends HTMLElement{constructor(){super(),this.tabIndex=0}connectedCallback(){o(this)}}customElements.define('str-template-cpnt',m),customElements.define('str-textarea-cpnt',class extends HTMLDivElement{constructor(){super(),this.tabIndex=0}async connectedCallback(){o(this,(e=>{this.innerHTML=e}))}},{extends:'div'}),document.adoptedStyleSheets=[a];export{i as ACTION,e as CMD,r as default,o as useState};
2
2
  //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@strifeapp/strife",
3
- "version": "0.0.6-preview.1",
3
+ "version": "0.0.6-preview.12",
4
4
  "keywords": [],
5
- "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git://github.com/wieldyapp/wieldy.git"
8
+ },
6
9
  "files": [
7
10
  "dist"
8
11
  ],
@@ -10,15 +13,13 @@
10
13
  "module": "dist/index.esm.js",
11
14
  "unpkg": "dist/index.esm.js",
12
15
  "scripts": {
13
-
16
+ "prepublishOnly": "npm --no-git-tag-version version --preid=preview",
17
+ "postversion": "npx rollup -c -i index.js -o dist/index.esm.js"
14
18
  },
15
19
  "devDependencies": {
16
- "rollup": "^2.58.0",
17
- "rollup-plugin-import-assert": "^1.1.1",
18
- "rollup-plugin-terser": "^7.0.2"
19
- },
20
- "dependencies": {
21
- "acorn-import-assertions": "^1.8.0",
22
- "string-to-template-literal": "^2.0.0"
20
+ "rollup": "^2.64.0",
21
+ "rollup-plugin-import-assert": "^2.1.0",
22
+ "rollup-plugin-terser": "^7.0.2",
23
+ "acorn-import-assertions": "^1.8.0"
23
24
  }
24
25
  }