@strifeapp/strife 0.4.0-alpha → 0.6.0-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.
@@ -0,0 +1,2 @@
1
+ import{u as e,p as t}from'./index-CeeeslUB.js';class n extends HTMLAnchorElement{constructor(){super(),this.tabIndex=0}connectedCallback(){this._cleanup=e(this,(e=>this.render(e)))}disconnectedCallback(){this._cleanup?.()}render(e){if(e){this.href=e.href;const t=this.childNodes;if(0===t.length)this.textContent=e.text;else for(const n of t)n.nodeType===Node.TEXT_NODE&&(n.nodeValue=e.text);'_blank'===e.target&&(this.target=e.target)}}}customElements.define('str-anchor',n,{extends:'a'});class s extends HTMLPictureElement{constructor(){super(),this.sources=[...this.querySelectorAll('source')],this.image=this.querySelector('img')}connectedCallback(){this._cleanup=e(this,(e=>this.render(e)))}disconnectedCallback(){this._cleanup?.()}render(e){let t=!1;this.sources.forEach((n=>{n.srcset=e?.[n.dataset?.propertyMedia]?.source?.url||'',n.srcset&&(t=!0)})),t?(this.image.src=this.image.currentSrc,this.image.classList.remove('str-empty')):(this.image.src='',this.image.classList.add('str-empty'))}}customElements.define('str-picture',s,{extends:'picture'});class c extends HTMLImageElement{constructor(){super()}connectedCallback(){this._cleanup=e(this,(e=>this.render(e)))}disconnectedCallback(){this._cleanup?.()}render(e){this.src=e?.source?.url||'',this.src?this.classList.remove('str-empty'):this.classList.add('str-empty')}}customElements.define('str-img',c,{extends:'img'});class a extends HTMLTimeElement{constructor(){super(),this.tabIndex=0}connectedCallback(){this._cleanup=e(this,(e=>this.render(e)))}disconnectedCallback(){this._cleanup?.()}render(e){e&&(this.textContent=((e,t)=>{if(!t)return e;const n=new Date(e);if(isNaN(n))return'Invalid Date';const s=n.getFullYear(),c=String(s).slice(-2),a=String(n.getMonth()+1).padStart(2,'0'),l=new Intl.DateTimeFormat('en-US',{month:'short'}).format(n),d={yyyy:s,yy:c,MMMM:new Intl.DateTimeFormat('en-US',{month:'long'}).format(n),MMM:l,MM:a,dd:String(n.getDate()).padStart(2,'0'),d:String(n.getDate()),hh:String(n.getHours()).padStart(2,'0'),mm:String(n.getMinutes()).padStart(2,'0'),ss:String(n.getSeconds()).padStart(2,'0')},i=new RegExp(Object.keys(d).join('|'),'g');return t.replace(i,(e=>d[e]))})(e,this.dataset.format))}}customElements.define('str-time',a,{extends:'time'});const l=t=>e(t,(e=>{d(t,e)})),d=(e,t)=>{e.textContent=t};customElements.define('str-address',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'address'}),customElements.define('str-p',class extends HTMLParagraphElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'p'}),customElements.define('str-span',class extends HTMLSpanElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'span'}),customElements.define('str-strong',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'strong'}),customElements.define('str-h1',class extends HTMLHeadingElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'h1'}),customElements.define('str-h2',class extends HTMLHeadingElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'h2'}),customElements.define('str-h3',class extends HTMLHeadingElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'h3'}),customElements.define('str-h4',class extends HTMLHeadingElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'h4'}),customElements.define('str-h5',class extends HTMLHeadingElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'h5'}),customElements.define('str-h6',class extends HTMLHeadingElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'h6'}),customElements.define('str-abbr',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'abbr'}),customElements.define('str-b',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'b'}),customElements.define('str-button',class extends HTMLButtonElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'button'}),customElements.define('str-cite',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'cite'}),customElements.define('str-code',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'code'}),customElements.define('str-dfn',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'dfn'}),customElements.define('str-em',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'em'}),customElements.define('str-i',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'i'}),customElements.define('str-label',class extends HTMLLabelElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'label'}),customElements.define('str-mark',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'mark'}),customElements.define('str-q',class extends HTMLQuoteElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'q'}),customElements.define('str-sub',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'sub'}),customElements.define('str-sup',class extends HTMLElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'sup'}),customElements.define('str-td',class extends HTMLTableCellElement{connectedCallback(){this._cleanup=l(this)}disconnectedCallback(){this._cleanup?.()}render(e){d(this,e)}},{extends:'td'});const i=t=>e(t,((e,n)=>{r(t,e,n)})),r=(e,t,n)=>{o(e,t,n)},o=(e,n,s)=>{let c=e.dataset.type||null;switch(c||(c=((e,t)=>{const n=t?.templates?.find((e=>e.collection===t.model?.['@metadata']?.['@collection']));let s=e;e?.includes('.')&&(s=e.split('.')[0]);const c=n?.editors?.find((e=>e.editor.propertyName===s)),a=c?.editor.type;if(e!==s)switch(a){case'chapters':const[n,a]=e.split('.').slice(1);if(!t.draft)return void console.warn('No draft value found in context ',t);const l=t.draft[s]?.[Number(n)];if(!l)return;const d=t.templates.find((e=>e.normalizedName===l['@strife']?.template)),i=d?.editors?.find((e=>e.editor.propertyName===a));return i?.editor.type;case'collection':const[r,o]=e.split('.').slice(1),h=t?.templates?.find((e=>e.collection===t.iterate?.['@metadata']?.['@collection'])),m=h?.editors?.find((e=>e.editor.propertyName===o));return m?.editor.type;case'content-template':const[u]=e.split('.').slice(1),p=t?.templates?.find((e=>e.normalizedName?.toLowerCase()===c.editor.attributes?.templateId?.toLowerCase()||e.id?.toLowerCase()===c.editor.attributes?.templateId?.toLowerCase())),b=p?.editors?.find((e=>e.editor.propertyName===u));return b?.editor.type}return a})(e.dataset.field,s)),e.innerHTML='',c){case'collection':((e,n,s)=>{n.documents&&n.documents.forEach(((n,c)=>{const a=e.dataset.field.lastIndexOf('.'),l=e.dataset.field.substring(a+1);let d=document.getElementById(`collection_${l}`).content;e.appendChild(d.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach((a=>{const l=a.dataset.field;a.dataset.field=`${e.dataset.field}.${c}.${l}`,'function'==typeof a.render?a.render(t(l,n),{...s,iterate:n}):console.warn(`Field ${a.dataset.field} (${a.tagName}) does not have a render method.`)}))}))})(e,n,s);break;case'chapters':((e,n,s)=>{n&&n.forEach(((n,c)=>{let a=document.getElementById(n['@strife'].template);if(!a)return void console.warn('Template not found for chapter:',n['@strife'].template);let l=a.content.cloneNode(!0);l.querySelectorAll('*').forEach((e=>{[...e.attributes].forEach((s=>{if(s.name.startsWith('data-prop-')){const c=s.name.replace('data-prop-',''),a=t(c,n);a&&e.setAttribute(s.name,a)}}))})),e.appendChild(l),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach(((a,l)=>{const d=a.dataset.field;a.dataset.field=`${e.dataset.field}.${c}.${d}`,'function'==typeof a.render?a.render(t(d,n),s):console.warn(`Field ${a.dataset.field} (${a.tagName}) does not have a render method.`)}))}))})(e,n,s);break;case'html':e.innerHTML=n;break;case'text':e.textContent=n;break;case'multi-input':((e,t,n)=>{const s=e.dataset.field.lastIndexOf('.'),c=e.dataset.field.substring(s+1);t&&Array.isArray(t)&&t.forEach((t=>{let n=document.getElementById(`multiinput_${c}`);if(n){let s=n.content.cloneNode(!0);const c=s.querySelector('[data-value]');c&&(c.textContent=t),e.appendChild(s)}}))})(e,n);break;case'assets':((e,t,n)=>{const s=e.dataset.field.lastIndexOf('.'),c=e.dataset.field.substring(s+1);t&&Array.isArray(t)&&t.forEach((t=>{let n=document.getElementById(`assets_${c}`);if(n){let s=n.content.cloneNode(!0);const c=s.querySelector('[data-name]');c&&(c.textContent=t.name);const a=s.querySelector('[data-original]');a&&(a.textContent=t.original);const l=s.querySelector('[data-thumbnail]');l&&(l.textContent=t.thumbnail);const d=s.querySelector('[data-size]');d&&(d.textContent=t.size),e.appendChild(s)}}))})(e,n);break;default:e.innerHTML=`<p>Unsupported container type: ${c} for ${e.tagName} and field ${e.dataset.field}</p>`}};customElements.define('str-div',class extends HTMLDivElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'div'}),customElements.define('str-ul',class extends HTMLUListElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'ul'}),customElements.define('str-ol',class extends HTMLOListElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'ol'}),customElements.define('str-section',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'section'}),customElements.define('str-header',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'header'}),customElements.define('str-footer',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'footer'}),customElements.define('str-nav',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'nav'}),customElements.define('str-article',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'article'}),customElements.define('str-main',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'main'}),customElements.define('str-aside',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'aside'}),customElements.define('str-blockquote',class extends HTMLElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'blockquote'}),customElements.define('str-tbody',class extends HTMLTableSectionElement{connectedCallback(){this._cleanup=i(this)}disconnectedCallback(){this._cleanup?.()}render(e,t){r(this,e,t)}},{extends:'tbody'});
2
+ //# sourceMappingURL=index-B3kA76r9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B3kA76r9.js","sources":["../composition/anchor/index.js","../composition/picture/index.js","../composition/img/index.js","../composition/time/index.js","../../../functions/formatDate.js","../composition/text/index.js","../composition/container/render/renderChapters.js","../composition/container/index.js","../../../functions/getTypeByContext.js","../composition/container/render/renderCollection.js","../composition/container/render/renderMultiInput.js","../composition/container/render/renderAssets.js"],"sourcesContent":["import { useState } from '../../strife.js';\n\n/**\n * Client components is responsible for:\n * 1️⃣ Reacting to state changes and if needed, update the live preview.\n * 2️⃣ Send an edit signal to Wieldy with an object that is used as input parameters for the editor. The parameters are not fixed but some are e.g. status, editorName, label and tmpl\n */\n\nclass AnchorElement extends HTMLAnchorElement {\n constructor() {\n super();\n\n this.tabIndex = 0;\n }\n\n connectedCallback() {\n this._cleanup = useState(this, (state) => this.render(state));\n }\n\n disconnectedCallback() {\n this._cleanup?.();\n }\n\n render(value) {\n if (value) {\n this.href = value.href;\n const nodes = this.childNodes;\n if (nodes.length === 0) {\n this.textContent = value.text;\n } else {\n for (const node of nodes) {\n if (node.nodeType === Node.TEXT_NODE) {\n node.nodeValue = value.text;\n }\n }\n }\n if (value.target === '_blank') {\n this.target = value.target;\n }\n }\n }\n}\ncustomElements.define('str-anchor', AnchorElement, { extends: 'a' });\n","import { useState } from '../../strife.js';\n\nclass PictureElement extends HTMLPictureElement {\n constructor() {\n super();\n this.sources = [...this.querySelectorAll('source')];\n this.image = this.querySelector('img');\n }\n\n connectedCallback() {\n this._cleanup = useState(this, (state) => this.render(state));\n }\n\n disconnectedCallback() {\n this._cleanup?.();\n }\n\n render(state) {\n let hasValue = false;\n this.sources.forEach((source) => {\n source.srcset = state?.[source.dataset?.propertyMedia]?.source?.url || '';\n if (source.srcset) {\n hasValue = true;\n }\n });\n if (hasValue) {\n this.image.src = this.image.currentSrc;\n this.image.classList.remove('str-empty');\n } else {\n this.image.src = '';\n this.image.classList.add('str-empty');\n }\n }\n}\ncustomElements.define('str-picture', PictureElement, { extends: 'picture' });\n","import { useState } from '../../strife.js';\n\nclass ImageElement extends HTMLImageElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n this._cleanup = useState(this, (state) => this.render(state));\n }\n\n disconnectedCallback() {\n this._cleanup?.();\n }\n\n render(value) {\n this.src = value?.source?.url || '';\n if (this.src) {\n this.classList.remove('str-empty');\n } else {\n this.classList.add('str-empty');\n }\n }\n}\ncustomElements.define('str-img', ImageElement, { extends: 'img' });\n","import { useState } from '../../strife.js';\nimport { formatDate } from '../../../../functions/index.js';\n\n/**\n * Client components is responsible for:\n * 1️⃣ Reacting to state changes and if needed, update the live preview.\n * 2️⃣ Send an edit signal to Wieldy with an object that is used as input parameters for the editor. The parameters are not fixed but some are e.g. status, editorName, label and tmpl\n */\n\nclass TimeElement extends HTMLTimeElement {\n constructor() {\n super();\n\n this.tabIndex = 0;\n }\n\n connectedCallback() {\n this._cleanup = useState(this, (state) => this.render(state));\n }\n\n disconnectedCallback() {\n this._cleanup?.();\n }\n\n render(value) {\n if (value) {\n this.textContent = formatDate(value, this.dataset.format);\n }\n }\n}\ncustomElements.define('str-time', TimeElement, { extends: 'time' });\n","export const formatDate = (inputDate, format) => {\n if (!format) {\n return inputDate;\n }\n\n const date = new Date(inputDate);\n if (isNaN(date)) {\n return \"Invalid Date\";\n }\n\n const year = date.getFullYear();\n const shortYear = String(year).slice(-2);\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const shortMonth = new Intl.DateTimeFormat('en-US', { month: 'short' }).format(date);\n const fullMonth = new Intl.DateTimeFormat('en-US', { month: 'long' }).format(date);\n const day = String(date.getDate()).padStart(2, '0');\n const shortDay = String(date.getDate());\n const hours = String(date.getHours()).padStart(2, '0');\n const minutes = String(date.getMinutes()).padStart(2, '0');\n const seconds = String(date.getSeconds()).padStart(2, '0');\n\n const replacements = {\n 'yyyy': year,\n 'yy': shortYear,\n 'MMMM': fullMonth,\n 'MMM': shortMonth,\n 'MM': month,\n 'dd': day,\n 'd': shortDay,\n 'hh': hours,\n 'mm': minutes,\n 'ss': seconds,\n };\n\n const regex = new RegExp(Object.keys(replacements).join('|'), 'g');\n\n return format.replace(regex, match => replacements[match]);\n}","import { useState } from '../../strife.js';\n\nconst init = (host) => {\n return useState(host, (state) => {\n render(host, state);\n });\n};\n\nconst render = (host, state) => {\n host.textContent = state;\n};\n\ncustomElements.define(\n 'str-address',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'address' },\n);\n\ncustomElements.define(\n 'str-p',\n class extends HTMLParagraphElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n {\n extends: 'p',\n },\n);\n\ncustomElements.define(\n 'str-span',\n class extends HTMLSpanElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'span' },\n);\n\ncustomElements.define(\n 'str-strong',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'strong' },\n);\n\ncustomElements.define(\n 'str-h1',\n class extends HTMLHeadingElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'h1' },\n);\ncustomElements.define(\n 'str-h2',\n class extends HTMLHeadingElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n {\n extends: 'h2',\n },\n);\ncustomElements.define(\n 'str-h3',\n class extends HTMLHeadingElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n {\n extends: 'h3',\n },\n);\ncustomElements.define(\n 'str-h4',\n class extends HTMLHeadingElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n {\n extends: 'h4',\n },\n);\ncustomElements.define(\n 'str-h5',\n class extends HTMLHeadingElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n {\n extends: 'h5',\n },\n);\ncustomElements.define(\n 'str-h6',\n class extends HTMLHeadingElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n {\n extends: 'h6',\n },\n);\ncustomElements.define(\n 'str-abbr',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'abbr' }\n);\ncustomElements.define(\n 'str-b',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'b' }\n);\ncustomElements.define(\n 'str-button',\n class extends HTMLButtonElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'button' }\n);\ncustomElements.define(\n 'str-cite',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'cite' }\n);\ncustomElements.define(\n 'str-code',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'code' }\n);\ncustomElements.define(\n 'str-dfn',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'dfn' }\n);\ncustomElements.define(\n 'str-em',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'em' }\n);\ncustomElements.define(\n 'str-i',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'i' }\n);\ncustomElements.define(\n 'str-label',\n class extends HTMLLabelElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'label' }\n);\ncustomElements.define(\n 'str-mark',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'mark' }\n);\ncustomElements.define(\n 'str-q',\n class extends HTMLQuoteElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'q' }\n);\ncustomElements.define(\n 'str-sub',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'sub' }\n);\ncustomElements.define(\n 'str-sup',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'sup' }\n);\ncustomElements.define(\n 'str-td',\n class extends HTMLTableCellElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state) {\n render(this, state);\n }\n },\n { extends: 'td' }\n);","import { propertyStringToValue } from '../../../../../functions/index.js';\n\nexport const renderChapters = (host, state, context) => {\n if (!state) {\n return;\n }\n state.forEach((chapter, index) => {\n let template = document.getElementById(chapter['@strife'].template);\n\n if (!template) {\n console.warn('Template not found for chapter:', chapter['@strife'].template);\n return;\n }\n\n let templateContent = template.content;\n\n let clone = templateContent.cloneNode(true);\n\n // Check and update data-prop attributes with current values\n clone.querySelectorAll('*').forEach((el) => {\n [...el.attributes].forEach((attr) => {\n if (attr.name.startsWith('data-prop-')) {\n const prop = attr.name.replace('data-prop-', '');\n const value = propertyStringToValue(prop, chapter);\n if (value) el.setAttribute(attr.name, value);\n }\n });\n });\n\n host.appendChild(clone);\n\n const components = host.querySelectorAll(`[is^=\"str-\"]:not([data-field^=\"${host.dataset.field}.\"])`);\n\n components.forEach((component, idx) => {\n const field = component.dataset.field;\n component.dataset.field = `${host.dataset.field}.${index}.${field}`;\n if (typeof component.render !== 'function') {\n console.warn(`Field ${component.dataset.field} (${component.tagName}) does not have a render method.`);\n return;\n }\n component.render(propertyStringToValue(field, chapter), context);\n });\n });\n};\n","import { useState } from '../../strife.js';\nimport { renderChapters, renderCollection, renderMultiInput, renderAssets } from './render/index.js';\nimport { getTypeByContext } from '../../../../functions/index.js';\n\nconst init = (host) => {\n return useState(host, (state, context) => {\n render(host, state, context);\n });\n};\n\nconst render = (host, state, context) => {\n // Fallback for browsers that don't support this API:\n if (true || !document.startViewTransition) {\n updateDOM(host, state, context);\n } else {\n // With a transition:\n document.startViewTransition(() => {\n updateDOM(host, state, context);\n });\n }\n};\n\nconst updateDOM = (host, state, context) => {\n let type = host.dataset.type || null;\n if (!type) {\n type = getTypeByContext(host.dataset.field, context);\n }\n host.innerHTML = '';\n switch (type) {\n case 'collection':\n renderCollection(host, state, context);\n break;\n case 'chapters':\n renderChapters(host, state, context);\n break;\n case 'html':\n host.innerHTML = state;\n break;\n case 'text':\n host.textContent = state;\n break;\n case 'multi-input':\n renderMultiInput(host, state, context);\n break;\n case 'assets':\n renderAssets(host, state, context);\n break;\n default:\n host.innerHTML = `<p>Unsupported container type: ${type} for ${host.tagName} and field ${host.dataset.field}</p>`;\n break;\n }\n};\n\ncustomElements.define(\n 'str-div',\n class extends HTMLDivElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'div' },\n);\n\ncustomElements.define(\n 'str-ul',\n class extends HTMLUListElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'ul' },\n);\n\ncustomElements.define(\n 'str-ol',\n class extends HTMLOListElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'ol' },\n);\n\ncustomElements.define(\n 'str-section',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'section' },\n);\n\ncustomElements.define(\n 'str-header',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'header' },\n);\n\ncustomElements.define(\n 'str-footer',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'footer' },\n);\n\ncustomElements.define(\n 'str-nav',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'nav' },\n);\n\ncustomElements.define(\n 'str-article',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'article' },\n);\n\ncustomElements.define(\n 'str-main',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'main' },\n);\n\ncustomElements.define(\n 'str-aside',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'aside' },\n);\n\ncustomElements.define(\n 'str-blockquote',\n class extends HTMLElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'blockquote' },\n);\n\ncustomElements.define(\n 'str-tbody',\n class extends HTMLTableSectionElement {\n connectedCallback() {\n this._cleanup = init(this);\n }\n disconnectedCallback() {\n this._cleanup?.();\n }\n render(state, context) {\n render(this, state, context);\n }\n },\n { extends: 'tbody' },\n);\n","export const getTypeByContext = (field, context) => {\n const documentTemplate = context?.templates?.find(\n (template) => template.collection === context.model?.['@metadata']?.['@collection'],\n );\n let originProperty = field;\n if (field?.includes('.')) {\n originProperty = field.split('.')[0];\n }\n\n const templateEditorForProperty = documentTemplate?.editors?.find((e) => e.editor.propertyName === originProperty);\n const originType = templateEditorForProperty?.editor.type;\n\n if (field !== originProperty) {\n switch (originType) {\n case 'chapters':\n const [chapterIndex, chapterField] = field.split('.').slice(1);\n if (!context.draft) {\n console.warn('No draft value found in context ', context);\n return undefined;\n }\n const chapter = context.draft[originProperty]?.[Number(chapterIndex)];\n if (!chapter) return undefined;\n const chapterContentTemplate = context.templates.find(\n (template) => template.normalizedName === chapter['@strife']?.template,\n );\n const chapterEditorForProperty = chapterContentTemplate?.editors?.find(\n (e) => e.editor.propertyName === chapterField,\n );\n return chapterEditorForProperty?.editor.type;\n case 'collection':\n const [collectionIndex, collectionField] = field.split('.').slice(1);\n const collectionTemplate = context?.templates?.find(\n (template) => template.collection === context.iterate?.['@metadata']?.['@collection'],\n );\n const collectionEditorForProperty = collectionTemplate?.editors?.find(\n (e) => e.editor.propertyName === collectionField,\n );\n return collectionEditorForProperty?.editor.type;\n case 'content-template':\n const [contentTemplateField] = field.split('.').slice(1);\n const contentTemplate = context?.templates?.find(\n (template) =>\n template.normalizedName?.toLowerCase() ===\n templateEditorForProperty.editor.attributes?.templateId?.toLowerCase() ||\n template.id?.toLowerCase() === templateEditorForProperty.editor.attributes?.templateId?.toLowerCase(),\n );\n const contentTemplateEditorForProperty = contentTemplate?.editors?.find(\n (e) => e.editor.propertyName === contentTemplateField,\n );\n return contentTemplateEditorForProperty?.editor.type;\n }\n }\n\n return originType;\n};\n","import { propertyStringToValue } from '../../../../../functions/index.js';\n\nexport const renderCollection = (host, state, context) => {\n if (state.documents) {\n state.documents.forEach((doc, index) => {\n const lastIndex = host.dataset.field.lastIndexOf(\".\");\n const field = host.dataset.field.substring(lastIndex + 1);\n let template = document.getElementById(`collection_${field}`);\n\n let templateContent = template.content;\n\n host.appendChild(templateContent.cloneNode(true));\n\n const components = host.querySelectorAll(`[is^=\"str-\"]:not([data-field^=\"${host.dataset.field}.\"])`);\n\n components.forEach((component) => {\n const field = component.dataset.field;\n component.dataset.field = `${host.dataset.field}.${index}.${field}`;\n if (typeof component.render !== 'function') {\n console.warn(`Field ${component.dataset.field} (${component.tagName}) does not have a render method.`);\n return;\n }\n component.render(propertyStringToValue(field, doc), {...context, iterate: doc});\n });\n });\n }\n};\n","export const renderMultiInput = (host, state, context) => {\n const lastIndex = host.dataset.field.lastIndexOf('.');\n const field = host.dataset.field.substring(lastIndex + 1);\n if (state && Array.isArray(state)) {\n state.forEach((value) => {\n let template = document.getElementById(`multiinput_${field}`);\n if (template) {\n let clone = template.content.cloneNode(true);\n const dataValueHolder = clone.querySelector(`[data-value]`);\n if (dataValueHolder) {\n dataValueHolder.textContent = value;\n }\n host.appendChild(clone);\n }\n });\n }\n};\n","export const renderAssets = (host, state, context) => {\n const lastIndex = host.dataset.field.lastIndexOf('.');\n const field = host.dataset.field.substring(lastIndex + 1);\n if (state && Array.isArray(state)) {\n state.forEach((value) => {\n let template = document.getElementById(`assets_${field}`);\n if (template) {\n let clone = template.content.cloneNode(true);\n\n const nameHolder = clone.querySelector(`[data-name]`);\n if (nameHolder) {\n nameHolder.textContent = value.name;\n }\n\n const originalHolder = clone.querySelector(`[data-original]`);\n if (originalHolder) {\n originalHolder.textContent = value.original;\n }\n\n const thumbnailHolder = clone.querySelector(`[data-thumbnail]`);\n if (thumbnailHolder) {\n thumbnailHolder.textContent = value.thumbnail;\n }\n\n const sizeHolder = clone.querySelector(`[data-size]`);\n if (sizeHolder) {\n sizeHolder.textContent = value.size;\n }\n\n host.appendChild(clone);\n }\n });\n }\n};\n"],"names":["AnchorElement","HTMLAnchorElement","constructor","super","this","tabIndex","connectedCallback","_cleanup","useState","state","render","disconnectedCallback","value","href","nodes","childNodes","length","textContent","text","node","nodeType","Node","TEXT_NODE","nodeValue","target","customElements","define","extends","PictureElement","HTMLPictureElement","sources","querySelectorAll","image","querySelector","hasValue","forEach","source","srcset","dataset","propertyMedia","url","src","currentSrc","classList","remove","add","ImageElement","HTMLImageElement","TimeElement","HTMLTimeElement","inputDate","format","date","Date","isNaN","year","getFullYear","shortYear","String","slice","month","getMonth","padStart","shortMonth","Intl","DateTimeFormat","replacements","yyyy","yy","MMMM","MMM","MM","dd","getDate","d","hh","getHours","mm","getMinutes","ss","getSeconds","regex","RegExp","Object","keys","join","replace","match","formatDate","init","host","HTMLElement","HTMLParagraphElement","HTMLSpanElement","HTMLHeadingElement","HTMLButtonElement","HTMLLabelElement","HTMLQuoteElement","HTMLTableCellElement","context","updateDOM","type","field","documentTemplate","templates","find","template","collection","model","originProperty","includes","split","templateEditorForProperty","editors","e","editor","propertyName","originType","chapterIndex","chapterField","draft","console","warn","chapter","Number","chapterContentTemplate","normalizedName","chapterEditorForProperty","collectionIndex","collectionField","collectionTemplate","iterate","collectionEditorForProperty","contentTemplateField","contentTemplate","toLowerCase","attributes","templateId","id","contentTemplateEditorForProperty","getTypeByContext","innerHTML","documents","doc","index","lastIndex","lastIndexOf","substring","templateContent","document","getElementById","content","appendChild","cloneNode","component","propertyStringToValue","tagName","renderCollection","clone","el","attr","name","startsWith","prop","setAttribute","idx","renderChapters","Array","isArray","dataValueHolder","renderMultiInput","nameHolder","originalHolder","original","thumbnailHolder","thumbnail","sizeHolder","size","renderAssets","HTMLDivElement","HTMLUListElement","HTMLOListElement","HTMLTableSectionElement"],"mappings":"+CAQA,MAAMA,UAAsBC,kBAC1B,WAAAC,GACEC,QAEAC,KAAKC,SAAW,CAClB,CAEA,iBAAAC,GACEF,KAAKG,SAAWC,EAASJ,MAAOK,GAAUL,KAAKM,OAAOD,IACxD,CAEA,oBAAAE,GACEP,KAAKG,YACP,CAEA,MAAAG,CAAOE,GACL,GAAIA,EAAO,CACTR,KAAKS,KAAOD,EAAMC,KAClB,MAAMC,EAAQV,KAAKW,WACnB,GAAqB,IAAjBD,EAAME,OACRZ,KAAKa,YAAcL,EAAMM,UAEzB,IAAK,MAAMC,KAAQL,EACbK,EAAKC,WAAaC,KAAKC,YACzBH,EAAKI,UAAYX,EAAMM,MAIR,WAAjBN,EAAMY,SACRpB,KAAKoB,OAASZ,EAAMY,OAExB,CACF,EAEFC,eAAeC,OAAO,aAAc1B,EAAe,CAAE2B,QAAS,MCxC9D,MAAMC,UAAuBC,mBAC3B,WAAA3B,GACEC,QACAC,KAAK0B,QAAU,IAAI1B,KAAK2B,iBAAiB,WACzC3B,KAAK4B,MAAQ5B,KAAK6B,cAAc,MAClC,CAEA,iBAAA3B,GACEF,KAAKG,SAAWC,EAASJ,MAAOK,GAAUL,KAAKM,OAAOD,IACxD,CAEA,oBAAAE,GACEP,KAAKG,YACP,CAEA,MAAAG,C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ACA,cAAciE,YACZ,iBAAArF,GACEF,KAAKG,SAAWkF,EAAKrF,KACvB,CACA,oBAAAO,GACEP,KAAKG,YACP,CACA,MAAAG,CAAOD,EAAO0F,GACZzF,EAAON,KAAMK,EAAO0F,EACtB,GAEF,CAAExE,QAAS,YAGbF,eAAeC,OACb,WACA,cAAciE,YACZ,iBAAArF,GACEF,KAAKG,SAAWkF,EAAKrF,KACvB,CACA,oBAAAO,GACEP,KAAKG,YACP,CACA,MAAAG,CAAOD,EAAO0F,GACZzF,EAAON,KAAMK,EAAO0F,EACtB,GAEF,CAAExE,QAAS,SAGbF,eAAeC,OACb,YACA,cAAciE,YACZ,iBAAArF,GACEF,KAAKG,SAAWkF,EAAKrF,KACvB,CACA,oBAAAO,GACEP,KAAKG,YACP,CACA,MAAAG,CAAOD,EAAO0F,GACZzF,EAAON,KAAMK,EAAO0F,EACtB,GAEF,CAAExE,QAAS,UAGbF,eAAeC,OACb,iBACA,cAAciE,YACZ,iBAAArF,GACEF,KAAKG,SAAWkF,EAAKrF,KACvB,CACA,oBAAAO,GACEP,KAAKG,YACP,CACA,MAAAG,CAAOD,EAAO0F,GACZzF,EAAON,KAAMK,EAAO0F,EACtB,GAEF,CAAExE,QAAS,eAGbF,eAAeC,OACb,YACA,cAAc4J,wBACZ,iBAAAhL,GACEF,KAAKG,SAAWkF,EAAKrF,KACvB,CACA,oBAAAO,GACEP,KAAKG,YACP,CACA,MAAAG,CAAOD,EAAO0F,GACZzF,EAAON,KAAMK,EAAO0F,EACtB,GAEF,CAAExE,QAAS"}
@@ -0,0 +1,2 @@
1
+ const e=1,t=2,n=4,a=8;class s extends MessageChannel{static _instanceCache;#e=crypto.randomUUID();#t=[];#n;#a=null;#s=null;static get instance(){return this._instanceCache||(this._instanceCache=new s),this._instanceCache}constructor(){super(),window.__strifeInstances?(window.__strifeInstances++,console.warn(`[${window.name}] ⚠️ MULTIPLE SubscribableChannel instances detected (${window.__strifeInstances})!`),console.warn(`[${window.name}] 🔄 Please do a HARD REFRESH (Cmd+Shift+R / Ctrl+Shift+R) to clear cached SDK code`)):window.__strifeInstances=1,this.#n=new BroadcastChannel('app.broadcast')}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((()=>{try{window.top.postMessage({cmd:t,context:{name:window.name,height:document.body.scrollHeight,path:window.location.pathname}},'*',[this.port2])}catch(e){console.error(`[${window.name}] ❌ Failed to send HSHK:`,e),this.readyReject(e)}})),document.readyState){case'loading':case'interactive':document.onreadystatechange=()=>{'complete'===document.readyState&&this.readyResolve()};break;case'complete':this.readyResolve()}}subscribe(e){if('function'!=typeof e)throw new Error('messageHandler must be a function!');if(this.#t.push(e),null===this.#a){this.#a=e=>{try{for(const t of this.#t)try{t(e)}catch(e){console.error(`[${window.name}] Error in subscriber:`,e)}}catch(e){console.error(`[${window.name}] Error in handleMessage:`,e)}},this.#s=e=>{try{this.#n.postMessage({...e.data,_sourceInstanceId:this.#e,_sourceType:'iframe',_sourceName:window.name})}catch(e){console.error(`[${window.name}] Error in handleBroadcastMessage:`,e)}};const e=e=>{try{if(e.data._sourceInstanceId===this.#e)return;const{_sourceInstanceId:t,_sourceType:n,_sourceName:a,...s}=e.data;if(s.sync&&Array.isArray(s.sync)){const e=s.sync.filter((e=>!e.currentPath||e.currentPath===window.location.pathname));if(0===e.length)return;s.sync=e}const o={...e,data:s};for(const e of this.#t)try{e(o)}catch(e){console.error(`[${window.name}] Error in subscriber:`,e)}}catch(e){console.error(`[${window.name}] Error in handleBroadcastReceived:`,e)}};this.#n.addEventListener('message',e),this.port1.addEventListener('message',this.#a)}return()=>{const t=this.#t.indexOf(e);t>-1&&this.#t.splice(t,1)}}send(e){this.port1.postMessage(e),this.#n.postMessage({...e,_sourceInstanceId:this.#e,_sourceType:'iframe',_sourceName:window.name})}onConnected(e){return e}}const o=(e,t)=>e?.split('.').reduce(((e,t)=>e?.[t]),t),r=['|','-','–','—',':'],i={SEO:{TITLE:{MISSING:'titleMissing',LENGTH:'titleLength',SEPARATORS:'titleSeparators',SEGMENTS:'titleSegments'},META_DESCRIPTION:{MISSING:'metaDescriptionMissing',LENGTH:'metaDescriptionLength'},KEYWORDS:{COUNT:'keywordCount',DENSITY:'keywordDensity',TITLE:'keywordTitle',META_DESCRIPTION:'keywordMetaDescription',URL:'keywordUrl',HEADINGS:'keywordHeadings',FIRST_PARAGRAPH:'keyword1stParagraph',DISTINCT:'keywordDistinct'}},CONTENT:{PARAGRAPH_TOO_LONG:'contentParagraphTooLong',SENTENCE_TOO_LONG:'contentSentenceTooLong',LIX:'contentLix',FLESCH_EASE:'contentFleschEase',FLESCH_KINCAID:'contentFleschKincaid',GUNNING_FOG:'contentGunningFog',COLEMAN_LIAU:'contentColemanLiau',LONG_WORDS:'contentLongWords',COMPLEX_WORDS:'contentComplexWords',AVERAGE_WORDS_PER_SENTENCE:'contentAverageWordsPerSentence'}};function c(e){const t={};t[i.SEO.TITLE.MISSING]={value:0===e.length},t[i.SEO.TITLE.LENGTH]={value:e.length};const n=function(e){const t=r.find((t=>e.includes(t)));return t?{hasSeparator:!0,segments:e.split(t).map((e=>e.trim())),separator:t}:{hasSeparator:!1,segments:[e],separator:null}}(e);return t[i.SEO.TITLE.SEPARATORS]={value:n.hasSeparator},t[i.SEO.TITLE.SEGMENTS]={value:n.segments.length},t}function l(e){const t={};return t[i.SEO.META_DESCRIPTION.MISSING]={value:0===e.length},t[i.SEO.META_DESCRIPTION.LENGTH]={value:e.length},t}function d(e){return e.toLowerCase().replace(/[.,/#!$%^&*;:{}=\-_`~()]/g,'').replace(/\s+/g,' ').trim()}function h(e,t){const n=d(e),a=d(t),s=n.split(' '),o=a.split(' '),r=[];if(1===o.length){const t=new RegExp(`\\b${i=a,i.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')}\\b`,'gi');return e.match(t)||[]}var i;for(let t=0;t<=s.length-o.length;t++){if(s.slice(t,t+o.length).join(' ')===a){const n=e.split(/\s+/).slice(t,t+o.length).join(' ');r.push(n)}}return r}function u(e,t){let n={};if(!t.trim())return n;const a=t.split(',').map((e=>e.trim())).filter((e=>e.length>0));return a.forEach(((t,a)=>{const s=function(e,t){const n=e.body.textContent||'',a=d(n).split(/\s+/).length,s=h(n,t),o=s.length,r=t.split(/\s+/).length,i=o*r/a*100,c=e.querySelector('title')?.textContent||'',l=h(c,t).length>0,u=e.querySelector('p')?.textContent||'',E=h(u,t).length>0,S=Array.from(e.querySelectorAll('h1')).reduce(((e,n)=>e+h(n.textContent||'',t).length),0),m=Array.from(e.querySelectorAll('h2')).reduce(((e,n)=>e+h(n.textContent||'',t).length),0),g=Array.from(e.querySelectorAll('h3')).reduce(((e,n)=>e+h(n.textContent||'',t).length),0),p=e.querySelector('meta[name="description"]')?.getAttribute('content')||'',f=h(p,t).length>0,O=e.location?.pathname||'',T=d(t).replace(/\s+/g,'-'),w=d(O).includes(T);return{density:i,count:o,inTitle:l,inFirstParagraph:E,inHeadings:{h1:S,h2:m,h3:g},inMetaDescription:f,inUrl:w,occurrences:s}}(e,t);!function(e,t,n){e[i.SEO.KEYWORDS.COUNT]||(e[i.SEO.KEYWORDS.COUNT]=[]);e[i.SEO.KEYWORDS.COUNT].push({value:t.count,additional:{keyword:n}}),e[i.SEO.KEYWORDS.DENSITY]||(e[i.SEO.KEYWORDS.DENSITY]=[]);e[i.SEO.KEYWORDS.DENSITY].push({value:t.density,additional:{keyword:n}}),e[i.SEO.KEYWORDS.TITLE]||(e[i.SEO.KEYWORDS.TITLE]=[]);e[i.SEO.KEYWORDS.TITLE].push({value:t.inTitle,additional:{keyword:n}}),e[i.SEO.KEYWORDS.HEADINGS]||(e[i.SEO.KEYWORDS.HEADINGS]=[]);e[i.SEO.KEYWORDS.HEADINGS].push({value:t.inHeadings.h1+t.inHeadings.h2+t.inHeadings.h3,additional:{keyword:n}}),e[i.SEO.KEYWORDS.FIRST_PARAGRAPH]||(e[i.SEO.KEYWORDS.FIRST_PARAGRAPH]=[]);e[i.SEO.KEYWORDS.FIRST_PARAGRAPH].push({value:t.inFirstParagraph,additional:{keyword:n}}),e[i.SEO.KEYWORDS.META_DESCRIPTION]||(e[i.SEO.KEYWORDS.META_DESCRIPTION]=[]);e[i.SEO.KEYWORDS.META_DESCRIPTION].push({value:t.inMetaDescription,additional:{keyword:n}}),e[i.SEO.KEYWORDS.URL]||(e[i.SEO.KEYWORDS.URL]=[]);e[i.SEO.KEYWORDS.URL].push({value:t.inUrl,additional:{keyword:n}})}(n,s,t)})),a.length>1&&function(e,t){e[i.SEO.KEYWORDS.DISTINCT]||(e[i.SEO.KEYWORDS.DISTINCT]=[]);const n=[];for(let a=0;a<t.length;a++)for(let s=a+1;s<t.length;s++){const o=E(t[a],t[s]);o>.3&&e[i.SEO.KEYWORDS.DISTINCT].push({value:0===n.length,additional:{similarities:[t[a],t[s],o]}})}}(n,a),n}function E(e,t){const n=new Set(e.toLowerCase().split(' ')),a=new Set(t.toLowerCase().split(' ')),s=new Set([...n].filter((e=>a.has(e)))),o=new Set([...n,...a]);return s.size/o.size}function S(e,t){const n=e.split(/\s+/).filter((e=>e.length>0)),a=e.split(/[.!?]+/).filter((e=>e.trim().length>0)),s=function(e){const t=e.toLowerCase().split(/\s+/);return t.reduce(((e,t)=>e+m(t)),0)}(e),o=n.filter((e=>m(e)>2)).length,r=n.length,i=a.length,c=r/i,l=s/r,d=e.replace(/\s/g,'').length/r,h=function(e){const t=e.split(/\s+/).filter((e=>e.length>0)),n=e.split(/[.!?]+/).filter((e=>e.trim().length>0)),a=t.filter((e=>e.length>6)).length;return t.length/n.length+100*a/t.length}(e);return{fleschEase:206.835-1.015*c-84.6*l,fleschKincaid:.39*c+11.8*l-15.59,gunningFog:.4*(c+o/r*100),colemanLiau:100*d*.0588-i/r*100*.296-15.8,averageWordsPerSentence:c,averageSyllablesPerWord:l,totalWords:r,totalSentences:i,complexWords:o,lix:h,longWords:n.filter((e=>e.length>15)).length}}function m(e){if((e=e.toLowerCase().replace(/[^a-z]/g,'')).length<=3)return 1;const t=(e=(e=e.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,'')).replace(/^y/,'')).match(/[aeiouy]{1,2}/g);return t?t.length:1}function g(e){const t={},n=e.documentElement.lang.toLowerCase().split('-')[0]||'en',a=e.querySelectorAll('p');if(0===a.length)return;const s=[],o=[];for(const[e,t]of Array.from(a).entries()){const n=t.textContent?.trim()||'';if(0===n.length)continue;n.split(/\s+/).filter((e=>e.length>0)).length>40&&s.push(e+1);const a=n.split(/[.!?]+/).filter((e=>e.trim().length>0));for(const t of a){t.trim().split(/\s+/).length>20&&o.push(e+1)}}s.length>0&&(t[i.CONTENT.PARAGRAPH_TOO_LONG]={value:!0,additional:s}),o.length>0&&(t[i.CONTENT.SENTENCE_TOO_LONG]={value:!0,additional:o});const r=S(Array.from(a).map((e=>e.textContent?.trim())).filter(Boolean).join(' '));return'sv'===n?t[i.CONTENT.LIX]={value:r.lix}:(t[i.CONTENT.FLESCH_EASE]={value:r.fleschEase},t[i.CONTENT.FLESCH_KINCAID]={value:r.fleschKincaid},t[i.CONTENT.GUNNING_FOG]={value:r.gunningFog},t[i.CONTENT.COLEMAN_LIAU]={value:r.colemanLiau}),t[i.CONTENT.AVERAGE_WORDS_PER_SENTENCE]={value:r.averageWordsPerSentence,additional:r.totalSentences},'sv'===n?t[i.CONTENT.LONG_WORDS]={value:r.longWords,additional:r.totalWords}:t[i.CONTENT.COMPLEX_WORDS]={value:r.complexWords,additional:r.totalWords},t}const p=4,f=8,O=32,T=64;let w;const N=e=>{e?.bucket?.insightsEnabled&&(clearTimeout(w),w=setTimeout((()=>(e=>{const t=e.draft??e.model,a=document.querySelector('title')?.textContent??'',o=document.querySelector('meta[name="description"]')?.getAttribute('content')||'',r=t?.serp?.keywords??'',i={seo:{title:c(a),metaDescription:l(o),keywords:u(document,r)},content:g(document)};s.instance.send({cmd:n,updates:[{action:T,context:{name:window.name,timeStamp:(new Date).toJSON(),insights:i}}]})})(e)),1e3))};let I=!1,y={},R={},C=[];const D=[],_=({data:e})=>{try{e.cmd===a&&e.sync.forEach((e=>{if(e.currentPath===window.location.pathname)switch(e.action){case f:D.forEach((({self:t,handler:n})=>{const a=(e.data.placeholders??[]).find((e=>e.propertyName===t.dataset.field));a&&(t.dataset.placeholder=a.placeholder)})),C=[...e.data?.placeholder??[]],e.context&&(R={...e.context}),N(R);break;case O:const t=e.data?.change;t?D.forEach((({self:n,handler:a})=>{t.name===n.dataset.field&&a(t.value,e.context)})):e.data?.state&&D.forEach((({self:t,handler:n})=>{const a=o(t.dataset.field,e.data.state);void 0!==a&&n(a,e.context)})),e.data?.state&&(y={...e.data.state},I=!0),e.context&&(R={...e.context}),N(R)}}))}catch(e){console.error(e)}},A=(e,t)=>{const n={self:e,handler:t};if(D.push(n),I){const n=o(e.dataset.field,y);void 0!==n&&t(n,R)}if(C.length){const t=C.find((t=>t.propertyName===e.dataset.field));t&&(e.dataset.placeholder=t.placeholder||'')}return()=>{const e=D.indexOf(n);e>-1&&D.splice(e,1)}},L=e=>{if('function'!=typeof e)throw new Error('messageHandler must be a function!');return I&&e(y),s.instance.subscribe((t=>{try{if(t.data.cmd===a)for(const n of t.data.sync)n.action!==O||e(n.data.state)}catch(e){console.error('Error in messageHandler:',e)}}))},b=()=>{const e=((e,t)=>{let n;return function(...a){clearTimeout(n),n=setTimeout((()=>e.apply(this,a)),t)}})((()=>{s.instance.send({cmd:n,updates:[{action:p,context:{name:window.name,height:document.body.scrollHeight}}]})}),100);new ResizeObserver((t=>{for(let n of t)n.target===document.body&&e()})).observe(document.body)};'undefined'!=typeof document&&document.addEventListener('DOMContentLoaded',(e=>{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-B3kA76r9.js'),s.instance.invoke(),s.instance.subscribe(_),b()})),performance.mark('mark-1');export{o as p,L as s,A as u};
2
+ //# sourceMappingURL=index-CeeeslUB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CeeeslUB.js","sources":["../cmd.js","../subscribableChannel.js","../../../functions/propertyStringToValue.js","../insights/constants.js","../insights/analyzers/seoAnalyzer.js","../insights/analyzers/titleAnalyzer.js","../insights/analyzers/keywordAnalyzer.js","../insights/analyzers/contentAnalyzer.js","../action.js","../insights/index.js","../strife.js","../index.js"],"sourcesContent":["const CMD = {\n // HSHK: 1,\n // EU: 2,\n // SYNC: 4,\n // CONNECT: 8,\n\n CONNECT: 1,\n HSHK: 2,\n EU: 4,\n SYNC: 8,\n};\n\nexport default CMD;\n","import CMD from './cmd.js';\n\nconst CHANNEL_NAME = 'app.broadcast';\n\nexport default class SubscribableChannel extends MessageChannel {\n static _instanceCache;\n #instanceId = crypto.randomUUID(); // Unique ID per iframe\n #subscribers = []; // Track all subscriber handlers\n #broadcastChannel;\n #handleMessage = null;\n #handleBroadcastMessage = null;\n\n static get instance() {\n if (!this._instanceCache) {\n this._instanceCache = new SubscribableChannel();\n }\n\n return this._instanceCache;\n }\n\n constructor() {\n super(); // Initialize MessageChannel (port1, port2)\n\n // Check for stale instances (HMR/cache issue detection)\n if (window.__strifeInstances) {\n window.__strifeInstances++;\n console.warn(`[${window.name}] ⚠️ MULTIPLE SubscribableChannel instances detected (${window.__strifeInstances})!`);\n console.warn(`[${window.name}] 🔄 Please do a HARD REFRESH (Cmd+Shift+R / Ctrl+Shift+R) to clear cached SDK code`);\n } else {\n window.__strifeInstances = 1;\n }\n\n // BroadcastChannel for iframe-to-iframe communication (same origin)\n this.#broadcastChannel = new BroadcastChannel(CHANNEL_NAME);\n }\n\n /**\n * Initialize the channel - send HSHK to parent with port2\n */\n invoke() {\n // Listen for CONNECT acknowledgment from parent on port1\n const handleConnect = (event) => {\n if (event.data.cmd === CMD.CONNECT) {\n this.onConnected(event);\n }\n };\n this.port1.addEventListener('message', handleConnect, {\n once: true,\n });\n this.port1.start();\n\n this._ready = new Promise((resolve, reject) => {\n this.readyResolve = resolve;\n this.readyReject = reject;\n });\n\n // Wait for document ready, then send HSHK to parent\n this._ready.then(() => {\n try {\n window.top.postMessage(\n {\n cmd: CMD.HSHK,\n context: {\n name: window.name,\n height: document.body.scrollHeight,\n path: window.location.pathname\n }\n },\n '*', // targetOrigin (parent's origin)\n [this.port2] // Transfer port2 to parent\n );\n } catch (error) {\n console.error(`[${window.name}] ❌ Failed to send HSHK:`, error);\n this.readyReject(error);\n }\n });\n\n switch (document.readyState) {\n case 'loading':\n case 'interactive': {\n document.onreadystatechange = () => {\n if (document.readyState === 'complete') {\n this.readyResolve();\n }\n };\n break;\n }\n case 'complete':\n this.readyResolve();\n break;\n }\n }\n\n /**\n * Subscribe to messages from parent or other iframes\n * @param {Function} messageHandler - Called when a message is received\n * @returns {Function} Unsubscribe function\n */\n subscribe(messageHandler) {\n if (typeof messageHandler !== 'function') {\n throw new Error('messageHandler must be a function!');\n }\n\n // Add this handler to the subscribers list\n this.#subscribers.push(messageHandler);\n\n // Set up listeners ONLY ONCE on first subscription\n if (this.#handleMessage === null) {\n // Handler for messages from parent via MessageChannel port1\n this.#handleMessage = (event) => {\n try {\n // Call ALL subscribers\n for (const subscriber of this.#subscribers) {\n try {\n subscriber(event);\n } catch (error) {\n console.error(`[${window.name}] Error in subscriber:`, error);\n }\n }\n } catch (error) {\n console.error(`[${window.name}] Error in handleMessage:`, error);\n }\n };\n\n // Forward messages from parent to sibling iframes via BroadcastChannel\n this.#handleBroadcastMessage = (event) => {\n try {\n // Tag with instance ID before broadcasting\n this.#broadcastChannel.postMessage({\n ...event.data,\n _sourceInstanceId: this.#instanceId,\n _sourceType: 'iframe',\n _sourceName: window.name\n });\n } catch (error) {\n console.error(`[${window.name}] Error in handleBroadcastMessage:`, error);\n }\n };\n\n // Handler for messages from sibling iframes via BroadcastChannel\n const handleBroadcastReceived = (event) => {\n try {\n const isSelf = event.data._sourceInstanceId === this.#instanceId;\n\n // Skip messages from self\n if (isSelf) {\n return;\n }\n\n // Prepare clean data (remove metadata)\n const { _sourceInstanceId, _sourceType, _sourceName, ...data } = event.data;\n\n // Filter sync updates by current path if applicable\n if (data.sync && Array.isArray(data.sync)) {\n const filteredSync = data.sync.filter(update => {\n // If update specifies a path, only process if it matches our current path\n if (update.currentPath) {\n return update.currentPath === window.location.pathname;\n }\n // No path specified, process it\n return true;\n });\n\n // If no updates match our path, skip this message entirely\n if (filteredSync.length === 0) {\n return;\n }\n\n // Replace sync array with filtered version\n data.sync = filteredSync;\n }\n\n const cleanEvent = { ...event, data };\n\n // Call ALL subscribers with the filtered data\n for (const subscriber of this.#subscribers) {\n try {\n subscriber(cleanEvent);\n } catch (error) {\n console.error(`[${window.name}] Error in subscriber:`, error);\n }\n }\n } catch (error) {\n console.error(`[${window.name}] Error in handleBroadcastReceived:`, error);\n }\n };\n\n // Add listeners ONCE\n this.#broadcastChannel.addEventListener('message', handleBroadcastReceived);\n this.port1.addEventListener('message', this.#handleMessage);\n\n // INTENTIONALLY DISABLED: This line caused 3× message amplification (67% excess handler calls)\n //\n // Architecture Decision:\n // Parent messages are now sent directly to ALL iframes via their individual MessageChannel\n // ports (see MessageService.postMessage). BroadcastChannel is ONLY for iframe-to-iframe\n // communication (e.g., height updates), not for forwarding parent messages.\n //\n // The Problem (when enabled):\n // 1. Parent sends SYNC to Desktop iframe via MessageChannel\n // 2. Desktop's handleBroadcastMessage forwards to BroadcastChannel\n // 3. Desktop receives its OWN broadcast (in addition to the direct message)\n // 4. Result: Each iframe processes parent messages 3× (1 direct + 2 sibling broadcasts)\n //\n // DO NOT re-enable without solving the amplification issue.\n //\n // this.port1.addEventListener('message', this.#handleBroadcastMessage);\n }\n\n // Return unsubscribe function\n return () => {\n const index = this.#subscribers.indexOf(messageHandler);\n if (index > -1) {\n this.#subscribers.splice(index, 1);\n }\n };\n }\n\n /**\n * Send a message to parent and siblings\n * @param {Object} payload - Message to send\n */\n send(payload) {\n // Send to parent via MessageChannel port1\n this.port1.postMessage(payload);\n\n // Also broadcast to siblings via BroadcastChannel (tagged with instanceId)\n this.#broadcastChannel.postMessage({\n ...payload,\n _sourceInstanceId: this.#instanceId,\n _sourceType: 'iframe',\n _sourceName: window.name\n });\n }\n\n onConnected(event) {\n return event;\n }\n}\n","export const propertyStringToValue = (propertyString, model) => {\n return propertyString?.split('.').reduce((a, b) => a?.[b], model);\n};","export const TITLE_SEPARATORS = ['|', '-', '–', '—', ':'];\nexport const BRAND_POSITION_END = 'end';\n\nexport const SEO_RULES = {\n TITLE_LENGTH: {\n MIN: 50,\n MAX: 60\n },\n META_DESCRIPTION_LENGTH: {\n MIN: 120,\n MAX: 155\n }\n};\n\nexport const INSIGHTS_IMPACT = {\n ERROR: 'error',\n WARN: 'warn',\n SUCCESS: 'success',\n INFO: 'info'\n};\n\nexport const INSIGHTS_METRICS = {\n SEO: {\n TITLE: {\n MISSING: 'titleMissing',\n LENGTH: 'titleLength',\n SEPARATORS: 'titleSeparators',\n SEGMENTS: 'titleSegments',\n },\n META_DESCRIPTION: {\n MISSING: 'metaDescriptionMissing',\n LENGTH: 'metaDescriptionLength',\n },\n KEYWORDS: {\n COUNT: 'keywordCount',\n DENSITY: 'keywordDensity',\n TITLE: 'keywordTitle',\n META_DESCRIPTION: 'keywordMetaDescription',\n URL: 'keywordUrl',\n HEADINGS: 'keywordHeadings',\n FIRST_PARAGRAPH: 'keyword1stParagraph',\n DISTINCT: 'keywordDistinct',\n },\n },\n CONTENT: {\n PARAGRAPH_TOO_LONG: 'contentParagraphTooLong',\n SENTENCE_TOO_LONG: 'contentSentenceTooLong',\n LIX: 'contentLix',\n FLESCH_EASE: 'contentFleschEase',\n FLESCH_KINCAID: 'contentFleschKincaid',\n GUNNING_FOG: 'contentGunningFog',\n COLEMAN_LIAU: 'contentColemanLiau',\n LONG_WORDS: 'contentLongWords',\n COMPLEX_WORDS: 'contentComplexWords',\n AVERAGE_WORDS_PER_SENTENCE: 'contentAverageWordsPerSentence',\n },\n}\n\n\n// TITLE_MISSING: 'titleMissing',\n// TITLE_LENGTH: 'titleLength',\n// TITLE_SEPARATORS: 'titleSeparators',\n// TITLE_SEGMENTS: 'titleSegments',\n// META_DESCRIPTION_MISSING: 'metaDescriptionMissing',\n// META_DESCRIPTION_LENGTH: 'metaDescriptionLength',\n// KEYWORD_COUNT: 'keywordCount',\n// KEYWORD_DENSITY: 'keywordDensity',\n// KEYWORD_TITLE: 'keywordTitle',\n// KEYWORD_META_DESCRIPTION: 'keywordMetaDescription',\n// KEYWORD_URL: 'keywordUrl',\n// KEYWORD_HEADINGS: 'keywordHeadings',\n// KEYWORD_1ST_PARAGRAPH: 'keyword1stParagraph',\n// KEYWORD_DISTINCT: 'keywordDistinct',\n// CONTENT_PARAGRAPH_TOO_LONG: 'contentParagraphTooLong',\n// CONTENT_SENTENCE_TOO_LONG: 'contentSentenceTooLong',\n// CONTENT_LIX: 'contentLix',\n// CONTENT_FLESCH_EASE: 'contentFleschEase',\n// CONTENT_FLESCH_KINCAID: 'contentFleschKincaid',\n// CONTENT_GUNNING_FOG: 'contentGunningFog',\n// CONTENT_COLEMAN_LIAU: 'contentColemanLiau',\n// CONTENT_LONG_WORDS: 'contentLongWords',\n// CONTENT_COMPLEX_WORDS: 'contentComplexWords',\n// CONTENT_AVERAGE_WORDS_PER_SENTENCE: 'contentAverageWordsPerSentence',","import { INSIGHTS_METRICS } from '../constants.js';\nimport { analyzeTitleFormat } from './titleAnalyzer.js';\n\nexport function analyzeTitle(title) {\n const results = {};\n\n results[INSIGHTS_METRICS.SEO.TITLE.MISSING] = { value: title.length === 0 };\n results[INSIGHTS_METRICS.SEO.TITLE.LENGTH] = { value: title.length };\n\n // Format analysis\n const titleAnalysis = analyzeTitleFormat(title);\n\n results[INSIGHTS_METRICS.SEO.TITLE.SEPARATORS] = { value: titleAnalysis.hasSeparator };\n results[INSIGHTS_METRICS.SEO.TITLE.SEGMENTS] = { value: titleAnalysis.segments.length };\n\n return results;\n}\n\nexport function analyzeMetaDescription(metaDescription) {\n const results = {};\n\n results[INSIGHTS_METRICS.SEO.META_DESCRIPTION.MISSING] = { value: metaDescription.length === 0 };\n results[INSIGHTS_METRICS.SEO.META_DESCRIPTION.LENGTH] = { value: metaDescription.length };\n\n return results;\n}","import { TITLE_SEPARATORS } from '../constants.js';\n\nexport function analyzeTitleFormat(title) {\n const usedSeparator = TITLE_SEPARATORS.find(sep => title.includes(sep));\n\n if (!usedSeparator) {\n return {\n hasSeparator: false,\n segments: [title],\n separator: null\n };\n }\n\n const segments = title.split(usedSeparator).map(s => s.trim());\n return {\n hasSeparator: true,\n segments,\n separator: usedSeparator\n };\n}","import { INSIGHTS_METRICS } from '../constants.js';\n\nfunction escapeRegExp(string) {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction normalizeText(text) {\n return text\n .toLowerCase()\n .replace(/[.,/#!$%^&*;:{}=\\-_`~()]/g, '') // Remove punctuation\n .replace(/\\s+/g, ' ') // Normalize whitespace\n .trim();\n}\n\nfunction findKeywordOccurrences(text, keyword) {\n const normalizedText = normalizeText(text);\n const normalizedKeyword = normalizeText(keyword);\n const words = normalizedText.split(' ');\n const keywordWords = normalizedKeyword.split(' ');\n const occurrences = [];\n\n if (keywordWords.length === 1) {\n const regex = new RegExp(`\\\\b${escapeRegExp(normalizedKeyword)}\\\\b`, 'gi');\n const matches = text.match(regex);\n return matches || [];\n }\n\n for (let i = 0; i <= words.length - keywordWords.length; i++) {\n const possibleMatch = words.slice(i, i + keywordWords.length).join(' ');\n if (possibleMatch === normalizedKeyword) {\n const originalTextMatch = text\n .split(/\\s+/)\n .slice(i, i + keywordWords.length)\n .join(' ');\n occurrences.push(originalTextMatch);\n }\n }\n\n return occurrences;\n}\n\nfunction countKeywordInText(text, keyword) {\n return findKeywordOccurrences(text, keyword).length;\n}\n\nexport function analyzeKeywordUsage(document, keywordsInput) {\n let results = {};\n\n if (!keywordsInput.trim()) {\n return results;\n }\n\n const keywords = keywordsInput\n .split(',')\n .map((k) => k.trim())\n .filter((k) => k.length > 0);\n\n keywords.forEach((keyword, index) => {\n const analysis = analyzeKeyword(document, keyword);\n displayResults(results, analysis, keyword);\n });\n\n if (keywords.length > 1) {\n analyzeKeywordRelationships(results, keywords);\n }\n\n return results;\n}\n\nfunction analyzeKeyword(document, keyword) {\n const bodyText = document.body.textContent || '';\n const wordCount = normalizeText(bodyText).split(/\\s+/).length;\n const occurrences = findKeywordOccurrences(bodyText, keyword);\n const keywordCount = occurrences.length;\n const keywordWordCount = keyword.split(/\\s+/).length;\n const density = ((keywordCount * keywordWordCount) / wordCount) * 100;\n\n const title = document.querySelector('title')?.textContent || '';\n const inTitle = findKeywordOccurrences(title, keyword).length > 0;\n\n const firstParagraph = document.querySelector('p')?.textContent || '';\n const inFirstParagraph = findKeywordOccurrences(firstParagraph, keyword).length > 0;\n\n const h1Count = Array.from(document.querySelectorAll('h1')).reduce(\n (count, el) => count + findKeywordOccurrences(el.textContent || '', keyword).length,\n 0,\n );\n const h2Count = Array.from(document.querySelectorAll('h2')).reduce(\n (count, el) => count + findKeywordOccurrences(el.textContent || '', keyword).length,\n 0,\n );\n const h3Count = Array.from(document.querySelectorAll('h3')).reduce(\n (count, el) => count + findKeywordOccurrences(el.textContent || '', keyword).length,\n 0,\n );\n\n const metaDescription = document.querySelector('meta[name=\"description\"]')?.getAttribute('content') || '';\n const inMetaDescription = findKeywordOccurrences(metaDescription, keyword).length > 0;\n\n const url = document.location?.pathname || '';\n const urlKeyword = normalizeText(keyword).replace(/\\s+/g, '-');\n const inUrl = normalizeText(url).includes(urlKeyword);\n\n return {\n density,\n count: keywordCount,\n inTitle,\n inFirstParagraph,\n inHeadings: { h1: h1Count, h2: h2Count, h3: h3Count },\n inMetaDescription,\n inUrl,\n occurrences,\n };\n}\n\nfunction displayResults(results, analysis, keyword) {\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.COUNT]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.COUNT] = [];\n }\n results[INSIGHTS_METRICS.SEO.KEYWORDS.COUNT].push({ value: analysis.count, additional: { keyword } });\n\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.DENSITY]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.DENSITY] = [];\n }\n results[INSIGHTS_METRICS.SEO.KEYWORDS.DENSITY].push({ value: analysis.density, additional: { keyword } });\n\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.TITLE]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.TITLE] = [];\n }\n results[INSIGHTS_METRICS.SEO.KEYWORDS.TITLE].push({ value: analysis.inTitle, additional: { keyword } });\n\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.HEADINGS]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.HEADINGS] = [];\n }\n results[INSIGHTS_METRICS.SEO.KEYWORDS.HEADINGS].push({\n value: analysis.inHeadings.h1 + analysis.inHeadings.h2 + analysis.inHeadings.h3,\n additional: { keyword },\n });\n\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.FIRST_PARAGRAPH]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.FIRST_PARAGRAPH] = [];\n }\n results[INSIGHTS_METRICS.SEO.KEYWORDS.FIRST_PARAGRAPH].push({ value: analysis.inFirstParagraph, additional: { keyword } });\n\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.META_DESCRIPTION]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.META_DESCRIPTION] = [];\n }\n results[INSIGHTS_METRICS.SEO.KEYWORDS.META_DESCRIPTION].push({\n value: analysis.inMetaDescription,\n additional: { keyword },\n });\n\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.URL]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.URL] = [];\n }\n results[INSIGHTS_METRICS.SEO.KEYWORDS.URL].push({ value: analysis.inUrl, additional: { keyword } });\n}\n\nfunction analyzeKeywordRelationships(results, keywords) {\n if (!results[INSIGHTS_METRICS.SEO.KEYWORDS.DISTINCT]) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.DISTINCT] = [];\n }\n const similarities = [];\n\n for (let i = 0; i < keywords.length; i++) {\n for (let j = i + 1; j < keywords.length; j++) {\n const similarity = calculateSimilarity(keywords[i], keywords[j]);\n if (similarity > 0.3) {\n results[INSIGHTS_METRICS.SEO.KEYWORDS.DISTINCT].push({\n value: similarities.length === 0,\n additional: { similarities: [keywords[i], keywords[j], similarity] },\n });\n }\n }\n }\n}\n\nfunction calculateSimilarity(str1, str2) {\n const set1 = new Set(str1.toLowerCase().split(' '));\n const set2 = new Set(str2.toLowerCase().split(' '));\n const intersection = new Set([...set1].filter((x) => set2.has(x)));\n const union = new Set([...set1, ...set2]);\n return intersection.size / union.size;\n}\n","import { INSIGHTS_METRICS } from \"../constants.js\";\n\nfunction calculateMetrics(text, language) {\n const words = text.split(/\\s+/).filter(word => word.length > 0);\n const sentences = text.split(/[.!?]+/).filter(sentence => sentence.trim().length > 0);\n const totalSyllables = countSyllables(text);\n const complexWords = words.filter(word => countWordSyllables(word) > 2).length;\n\n const totalWords = words.length;\n const totalSentences = sentences.length;\n const averageWordsPerSentence = totalWords / totalSentences;\n const averageSyllablesPerWord = totalSyllables / totalWords;\n const chars = text.replace(/\\s/g, '').length;\n const averageCharsPerWord = chars / totalWords;\n\n const lix = calculateLIX(text);\n const longWords = words.filter(word => word.length > 15).length;\n\n return {\n fleschEase: 206.835 - (1.015 * averageWordsPerSentence) - (84.6 * averageSyllablesPerWord),\n fleschKincaid: (0.39 * averageWordsPerSentence) + (11.8 * averageSyllablesPerWord) - 15.59,\n gunningFog: 0.4 * (averageWordsPerSentence + 100 * (complexWords / totalWords)),\n colemanLiau: (0.0588 * (averageCharsPerWord * 100)) - (0.296 * (totalSentences / totalWords * 100)) - 15.8,\n averageWordsPerSentence,\n averageSyllablesPerWord,\n totalWords,\n totalSentences,\n complexWords,\n lix,\n longWords\n };\n}\n\nfunction countSyllables(text) {\n const words = text.toLowerCase().split(/\\s+/);\n return words.reduce((total, word) => {\n return total + countWordSyllables(word);\n }, 0);\n}\n\nfunction countWordSyllables(word) {\n word = word.toLowerCase().replace(/[^a-z]/g, '');\n if (word.length <= 3) return 1;\n\n word = word.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '');\n word = word.replace(/^y/, '');\n const syllables = word.match(/[aeiouy]{1,2}/g);\n return syllables ? syllables.length : 1;\n}\n\nfunction calculateLIX(text) {\n const words = text.split(/\\s+/).filter(word => word.length > 0);\n const sentences = text.split(/[.!?]+/).filter(sentence => sentence.trim().length > 0);\n const longWords = words.filter(word => word.length > 6).length;\n\n return (words.length / sentences.length) + (longWords * 100 / words.length);\n}\n\nexport function analyzeContent(document) {\n const results = {};\n\n const language = document.documentElement.lang.toLowerCase().split('-')[0] || 'en';\n\n const paragraphs = document.querySelectorAll('p');\n if (paragraphs.length === 0) {\n return;\n }\n\n // Analyze each paragraph individually\n const tooLongParagraphs = [];\n const tooLongSentences = [];\n for (const [index, paragraph] of Array.from(paragraphs).entries()) {\n const text = paragraph.textContent?.trim() || '';\n if (text.length === 0) continue;\n\n const words = text.split(/\\s+/).filter(word => word.length > 0);\n if (words.length > 40) {\n tooLongParagraphs.push(index + 1);\n }\n\n const sentences = text.split(/[.!?]+/).filter(sentence => sentence.trim().length > 0);\n for (const sentence of sentences) {\n const sentenceWords = sentence.trim().split(/\\s+/).length;\n if (sentenceWords > 20) {\n tooLongSentences.push(index + 1);\n }\n }\n }\n\n if (tooLongParagraphs.length > 0) {\n results[INSIGHTS_METRICS.CONTENT.PARAGRAPH_TOO_LONG] = {value: true, additional: tooLongParagraphs};\n }\n if (tooLongSentences.length > 0) {\n results[INSIGHTS_METRICS.CONTENT.SENTENCE_TOO_LONG] = {value: true, additional: tooLongSentences};\n }\n\n // Analyze overall content\n const fullText = Array.from(paragraphs)\n .map(p => p.textContent?.trim())\n .filter(Boolean)\n .join(' ');\n\n const metrics = calculateMetrics(fullText, language);\n\n if (language === 'sv') {\n results[INSIGHTS_METRICS.CONTENT.LIX] = {value: metrics.lix};\n } else {\n results[INSIGHTS_METRICS.CONTENT.FLESCH_EASE] = {value: metrics.fleschEase};\n results[INSIGHTS_METRICS.CONTENT.FLESCH_KINCAID] = {value: metrics.fleschKincaid};\n results[INSIGHTS_METRICS.CONTENT.GUNNING_FOG] = {value: metrics.gunningFog};\n results[INSIGHTS_METRICS.CONTENT.COLEMAN_LIAU] = {value: metrics.colemanLiau};\n }\n\n results[INSIGHTS_METRICS.CONTENT.AVERAGE_WORDS_PER_SENTENCE] = {value: metrics.averageWordsPerSentence, additional: metrics.totalSentences};\n\n if (language === 'sv') {\n results[INSIGHTS_METRICS.CONTENT.LONG_WORDS] = {value: metrics.longWords, additional: metrics.totalWords};\n } else {\n results[INSIGHTS_METRICS.CONTENT.COMPLEX_WORDS] = {value: metrics.complexWords, additional: metrics.totalWords};\n }\n\n return results;\n}\n","// const ACTION = {\n// NONE: 8,\n// EDIT: 16,\n// RESET: 32,\n// INIT: 64,\n// SYNC: 128,\n// STATE: 256,\n// FOCUS: 512,\n// };\n\nconst PREVIEWACTION = {\n SYNC: 4,\n INIT: 8,\n FOCUS: 16,\n UPDATE: 32,\n INSIGHTS: 64,\n};\n\nexport default PREVIEWACTION;\n","import SubscribableChannel from '../subscribableChannel.js';\nimport * as analyzers from './analyzers/index.js';\nimport CMD from '../cmd.js';\nimport PREVIEWACTION from '../action.js';\n\nlet insightsTimeout;\n\nconst sendInsights = (context) => {\n const model = context.draft ?? context.model;\n const title = document.querySelector('title')?.textContent ?? '';\n const metaDesc = document.querySelector('meta[name=\"description\"]')?.getAttribute('content') || '';\n const keywords = model?.serp?.keywords ?? '';\n\n const insights = {\n seo: {\n title: analyzers.analyzeTitle(title),\n metaDescription: analyzers.analyzeMetaDescription(metaDesc),\n keywords: analyzers.analyzeKeywordUsage(document, keywords),\n },\n content: analyzers.analyzeContent(document),\n };\n\n const messageChannel = SubscribableChannel.instance;\n messageChannel.send({\n cmd: CMD.EU,\n updates: [\n { action: PREVIEWACTION.INSIGHTS, context: { name: window.name, timeStamp: new Date().toJSON(), insights } },\n ],\n });\n};\n\nexport const runInsights = (context) => {\n if (!context?.bucket?.insightsEnabled) {\n return;\n }\n clearTimeout(insightsTimeout);\n insightsTimeout = setTimeout(() => sendInsights(context), 1000);\n};\n","import SubscribableChannel from './subscribableChannel.js';\nimport { propertyStringToValue } from '../../functions/propertyStringToValue.js';\nimport { runInsights } from './insights/index.js';\nimport CMD from './cmd.js';\nimport PREVIEWACTION from './action.js';\n\nlet stateInitialized = false;\nlet state = {};\nlet context = {};\nlet placeholders = [];\n\nconst handlers = [];\n\nconst defaultHandler = ({ data }) => {\n try {\n if (data.cmd === CMD.SYNC) {\n data.sync.forEach((update) => {\n if (update.currentPath !== window.location.pathname) {\n return;\n }\n\n switch (update.action) {\n case PREVIEWACTION.INIT:\n handlers.forEach(({ self, handler }) => {\n // Init placeholders\n const currentUpdate = (update.data.placeholders ?? []).find((d) => d.propertyName === self.dataset.field);\n if (currentUpdate) {\n self.dataset.placeholder = currentUpdate.placeholder;\n }\n });\n placeholders = [...(update.data?.placeholder ?? [])];\n if (update.context) {\n context = { ...update.context };\n }\n runInsights(context);\n break;\n case PREVIEWACTION.UPDATE:\n const change = update.data?.change;\n if (change) {\n //If change is provided, only update the field that changed\n handlers.forEach(({ self, handler }) => {\n if (change.name === self.dataset.field) {\n handler(change.value, update.context);\n }\n });\n } else if (update.data?.state) {\n //If only state is provided, update all fields\n handlers.forEach(({ self, handler }) => {\n const value = propertyStringToValue(self.dataset.field, update.data.state);\n if (value !== undefined) {\n handler(value, update.context);\n }\n });\n }\n\n if (update.data?.state) {\n state = { ...update.data.state };\n stateInitialized = true;\n }\n if (update.context) {\n context = { ...update.context };\n }\n runInsights(context);\n break;\n case PREVIEWACTION.FOCUS:\n break;\n }\n });\n }\n } catch (error) {\n console.error(error);\n }\n};\n\nconst useState = (self, handler) => {\n const entry = { self, handler };\n handlers.push(entry);\n\n //If state is already initialized, call handler with current state to initialize with current state\n if (stateInitialized) {\n const value = propertyStringToValue(self.dataset.field, state);\n if (value !== undefined) {\n handler(value, context);\n }\n }\n if (placeholders.length) {\n const placeholderValue = placeholders.find((d) => d.propertyName === self.dataset.field);\n if (placeholderValue) {\n self.dataset.placeholder = placeholderValue.placeholder || '';\n }\n }\n\n // Return cleanup function for disconnectedCallback\n return () => {\n const idx = handlers.indexOf(entry);\n if (idx > -1) handlers.splice(idx, 1);\n };\n};\n\nconst subscribe = (messageHandler) => {\n if (typeof messageHandler !== 'function') {\n throw new Error('messageHandler must be a function!');\n }\n\n const handleMessage = (event) => {\n try {\n // Filter out sync messages containing state updates\n if (event.data.cmd === CMD.SYNC) {\n for (const update of event.data.sync) {\n if (update.action === PREVIEWACTION.UPDATE) {\n messageHandler(update.data.state);\n continue;\n }\n }\n }\n } catch (error) {\n console.error('Error in messageHandler:', error);\n }\n };\n\n //If state is already initialized, call handler with current state to initialize with current state\n if (stateInitialized) {\n messageHandler(state);\n }\n\n return SubscribableChannel.instance.subscribe(handleMessage);\n};\n\nconst initResizeObserver = () => {\n const debounce = (func, wait) => {\n let timeout;\n return function (...args) {\n clearTimeout(timeout);\n timeout = setTimeout(() => func.apply(this, args), wait);\n };\n };\n const sendHeightUpdate = () => {\n const messageChannel = SubscribableChannel.instance;\n messageChannel.send({\n cmd: CMD.EU,\n updates: [{ action: PREVIEWACTION.SYNC, context: { name: window.name, height: document.body.scrollHeight } }],\n });\n };\n const debouncedSendHeightUpdate = debounce(sendHeightUpdate, 100);\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (let entry of entries) {\n if (entry.target === document.body) {\n debouncedSendHeightUpdate();\n }\n }\n });\n\n resizeObserver.observe(document.body);\n};\n\nif (typeof document !== 'undefined') {\n document.addEventListener('DOMContentLoaded', (evt) => {\n performance.mark('mark-2');\n\n performance.measure('Import elements started', 'mark-1', 'mark-2');\n\n console.debug(\n `${performance.now().toFixed(1)}ms: [${window.name}] Import elements started after ${performance\n\n .getEntriesByName('Import elements started')[0]\n .duration.toFixed(1)}ms`,\n );\n\n import('./composition/index.js');\n\n SubscribableChannel.instance.invoke();\n\n SubscribableChannel.instance.subscribe(defaultHandler);\n\n //Add resize observer on document.body to send height to messageChannel\n\n initResizeObserver();\n });\n}\n\nexport { useState, subscribe };\n","import { subscribe, useState } from './strife.js';\n\nperformance.mark('mark-1');\n\nexport { subscribe, useState };\n"],"names":["CMD","SubscribableChannel","MessageChannel","static","instanceId","crypto","randomUUID","subscribers","broadcastChannel","handleMessage","handleBroadcastMessage","instance","this","_instanceCache","constructor","super","window","__strifeInstances","console","warn","name","BroadcastChannel","invoke","port1","addEventListener","event","data","cmd","onConnected","once","start","_ready","Promise","resolve","reject","readyResolve","readyReject","then","top","postMessage","context","height","document","body","scrollHeight","path","location","pathname","port2","error","readyState","onreadystatechange","subscribe","messageHandler","Error","push","subscriber","_sourceInstanceId","_sourceType","_sourceName","handleBroadcastReceived","sync","Array","isArray","filteredSync","filter","update","currentPath","length","cleanEvent","index","indexOf","splice","send","payload","propertyStringToValue","propertyString","model","split","reduce","a","b","TITLE_SEPARATORS","INSIGHTS_METRICS","SEO","TITLE","MISSING","LENGTH","SEPARATORS","SEGMENTS","META_DESCRIPTION","KEYWORDS","COUNT","DENSITY","URL","HEADINGS","FIRST_PARAGRAPH","DISTINCT","CONTENT","PARAGRAPH_TOO_LONG","SENTENCE_TOO_LONG","LIX","FLESCH_EASE","FLESCH_KINCAID","GUNNING_FOG","COLEMAN_LIAU","LONG_WORDS","COMPLEX_WORDS","AVERAGE_WORDS_PER_SENTENCE","analyzeTitle","title","results","value","titleAnalysis","usedSeparator","find","sep","includes","hasSeparator","segments","map","s","trim","separator","analyzeTitleFormat","analyzeMetaDescription","metaDescription","normalizeText","text","toLowerCase","replace","findKeywordOccurrences","keyword","normalizedText","normalizedKeyword","words","keywordWords","occurrences","regex","RegExp","string","match","i","slice","join","originalTextMatch","analyzeKeywordUsage","keywordsInput","keywords","k","forEach","analysis","bodyText","textContent","wordCount","keywordCount","keywordWordCount","density","querySelector","inTitle","firstParagraph","inFirstParagraph","h1Count","from","querySelectorAll","count","el","h2Count","h3Count","getAttribute","inMetaDescription","url","urlKeyword","inUrl","inHeadings","h1","h2","h3","analyzeKeyword","additional","displayResults","similarities","j","similarity","calculateSimilarity","analyzeKeywordRelationships","str1","str2","set1","Set","set2","intersection","x","has","union","size","calculateMetrics","language","word","sentences","sentence","totalSyllables","total","countWordSyllables","countSyllables","complexWords","totalWords","totalSentences","averageWordsPerSentence","averageSyllablesPerWord","averageCharsPerWord","lix","longWords","calculateLIX","fleschEase","fleschKincaid","gunningFog","colemanLiau","syllables","analyzeContent","documentElement","lang","paragraphs","tooLongParagraphs","tooLongSentences","paragraph","entries","metrics","p","Boolean","PREVIEWACTION","insightsTimeout","runInsights","bucket","insightsEnabled","clearTimeout","setTimeout","draft","metaDesc","serp","insights","seo","analyzers.analyzeTitle","analyzers.analyzeMetaDescription","analyzers.analyzeKeywordUsage","content","analyzers.analyzeContent","updates","action","timeStamp","Date","toJSON","sendInsights","stateInitialized","state","placeholders","handlers","defaultHandler","self","handler","currentUpdate","d","propertyName","dataset","field","placeholder","change","undefined","useState","entry","placeholderValue","idx","initResizeObserver","debouncedSendHeightUpdate","func","wait","timeout","args","apply","debounce","ResizeObserver","target","observe","evt","performance","mark","measure","debug","now","toFixed","getEntriesByName","duration","import"],"mappings":"AAAA,MAAMA,EAMK,EANLA,EAOE,EAPFA,EAQA,EARAA,EASE,ECLO,MAAMC,UAA4BC,eAC/CC,sBACAC,GAAcC,OAAOC,aACrBC,GAAe,GACfC,GACAC,GAAiB,KACjBC,GAA0B,KAE1B,mBAAWC,GAKT,OAJKC,KAAKC,iBACRD,KAAKC,eAAiB,IAAIZ,GAGrBW,KAAKC,cACd,CAEA,WAAAC,GACEC,QAGIC,OAAOC,mBACTD,OAAOC,oBACPC,QAAQC,KAAK,IAAIH,OAAOI,8DAA8D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,GAAGH,YAAYI,MAAMC,QAAQ,UAAUjR,OAAOI,uCAAuCwQ,YAElFM,iBAAiB,2BAA2B,GAC5CC,SAASF,QAAQ,QAGtBG,OAAO,uBAEPnS,EAAoBU,SAASW,SAE7BrB,EAAoBU,SAASyC,UAAU6M,GAIvCe,GAAoB,IC/KxBY,YAAYC,KAAK"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{s as subscribe,u as useState}from'./index-7b7c7ddf.js';
1
+ export{s as subscribe,u as useState}from'./index-CeeeslUB.js';
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@strifeapp/strife",
3
- "version": "0.4.0-alpha",
3
+ "version": "0.6.0-alpha",
4
4
  "description": "The Strife Client SDK for Strife Live Preview",
5
+ "type": "module",
5
6
  "keywords": [],
6
7
  "files": [
7
8
  "dist"
@@ -15,13 +16,11 @@
15
16
  "clean": "rimraf dist"
16
17
  },
17
18
  "devDependencies": {
18
- "acorn-import-assertions": "^1.8.0",
19
+ "@rollup/plugin-terser": "^0.4.0",
19
20
  "cssnano": "^6.0.1",
20
21
  "postcss": "^8.4.31",
21
22
  "postcss-cli": "^10.1.0",
22
- "rimraf": "^5.0.5",
23
- "rollup": "^2.64.0",
24
- "rollup-plugin-import-assert": "^2.1.0",
25
- "rollup-plugin-terser": "^7.0.2"
23
+ "rimraf": "^6.1.3",
24
+ "rollup": "^4.0.0"
26
25
  }
27
26
  }
@@ -1,2 +0,0 @@
1
- import{u as e,p as t}from'./index-7b7c7ddf.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)}}}customElements.define('str-anchor',s,{extends:'a'});class n extends HTMLPictureElement{constructor(){super(),this.sources=[...this.querySelectorAll('source')],this.image=this.querySelector('img')}connectedCallback(){e(this,(e=>this.render(e)))}render(e){let t=!1;this.sources.forEach((s=>{s.srcset=e?.[s.dataset?.propertyMedia]?.source?.url||'',s.srcset&&(t=!0)})),t?(this.image.src=this.image.currentSrc,this.image.classList.remove('str-empty')):(this.image.src='',this.image.classList.add('str-empty'))}}customElements.define('str-picture',n,{extends:'picture'});class d extends HTMLImageElement{constructor(){super()}connectedCallback(){e(this,(e=>this.render(e)))}render(e){this.src=e?.source?.url||'',this.src?this.classList.remove('str-empty'):this.classList.add('str-empty')}}customElements.define('str-img',d,{extends:'img'});class a 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),a=String(s.getMonth()+1).padStart(2,'0'),l=new Intl.DateTimeFormat('en-US',{month:'short'}).format(s),c={yyyy:n,yy:d,MMMM:new Intl.DateTimeFormat('en-US',{month:'long'}).format(s),MMM:l,MM:a,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')},r=new RegExp(Object.keys(c).join('|'),'g');return t.replace(r,(e=>c[e]))})(e,this.dataset.format))}}customElements.define('str-time',a,{extends:'time'});const l=t=>{e(t,(e=>{c(t,e)}))},c=(e,t)=>{e.textContent=t};customElements.define('str-address',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'address'}),customElements.define('str-p',class extends HTMLParagraphElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'p'}),customElements.define('str-span',class extends HTMLSpanElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'span'}),customElements.define('str-strong',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'strong'}),customElements.define('str-h1',class extends HTMLHeadingElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'h1'}),customElements.define('str-h2',class extends HTMLHeadingElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'h2'}),customElements.define('str-h3',class extends HTMLHeadingElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'h3'}),customElements.define('str-h4',class extends HTMLHeadingElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'h4'}),customElements.define('str-h5',class extends HTMLHeadingElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'h5'}),customElements.define('str-h6',class extends HTMLHeadingElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'h6'}),customElements.define('str-abbr',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'abbr'}),customElements.define('str-b',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'b'}),customElements.define('str-button',class extends HTMLButtonElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'button'}),customElements.define('str-cite',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'cite'}),customElements.define('str-code',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'code'}),customElements.define('str-dfn',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'dfn'}),customElements.define('str-em',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'em'}),customElements.define('str-i',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'i'}),customElements.define('str-label',class extends HTMLLabelElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'label'}),customElements.define('str-mark',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'mark'}),customElements.define('str-q',class extends HTMLQuoteElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'q'}),customElements.define('str-sub',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'sub'}),customElements.define('str-sup',class extends HTMLElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'sup'}),customElements.define('str-td',class extends HTMLTableCellElement{connectedCallback(){l(this)}render(e){c(this,e)}},{extends:'td'});const r=t=>{e(t,((e,s)=>{i(t,e,s)}))},i=(e,t,s)=>{o(e,t,s)},o=(e,s,n)=>{let d=e.dataset.type||null;switch(d||(d=((e,t)=>{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)),a=d?.editor.type;if(e!==n)switch(a){case'chapters':const[s,a]=e.split('.').slice(1);t.draft||console.warn('No draft value found in context ',t);const l=t.draft[n][Number(s)],c=t.templates.find((e=>e.normalizedName===l['@strife']?.template)),r=c?.editors.find((e=>e.editor.propertyName===a));return r?.editor.type;case'collection':const[i,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),f=t.templates.find((e=>e.normalizedName===d.editor.attributes.templateId)),x=f?.editors.find((e=>e.editor.propertyName===u));return x?.editor.type}return a})(e.dataset.field,n)),e.innerHTML='',d){case'collection':((e,s,n)=>{s.documents&&s.documents.forEach(((s,d)=>{const a=e.dataset.field.lastIndexOf('.'),l=e.dataset.field.substring(a+1);let c=document.getElementById(`collection_${l}`).content;e.appendChild(c.cloneNode(!0)),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach((a=>{const l=a.dataset.field;a.dataset.field=`${e.dataset.field}.${d}.${l}`,a.render(t(l,s),{...n,iterate:s})}))}))})(e,s,n);break;case'chapters':((e,s,n)=>{s&&s.forEach(((s,d)=>{let a=document.getElementById(s['@strife'].template).content.cloneNode(!0);a.querySelectorAll('*').forEach((e=>{[...e.attributes].forEach((n=>{if(n.name.startsWith('data-prop-')){const d=n.name.replace('data-prop-',''),a=t(d,s);a&&e.setAttribute(n.name,a)}}))})),e.appendChild(a),e.querySelectorAll(`[is^="str-"]:not([data-field^="${e.dataset.field}."])`).forEach(((a,l)=>{const c=a.dataset.field;a.dataset.field=`${e.dataset.field}.${d}.${c}`,a.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('.'),d=e.dataset.field.substring(n+1);t&&Array.isArray(t)&&t.forEach(((t,s)=>{let n=document.getElementById(`multiinput_${d}`);if(n){let s=n.content;s.querySelector('[data-value]').textContent=t,e.appendChild(s.cloneNode(!0))}}))})(e,s);break;case'assets':((e,t,s)=>{const n=e.dataset.field.lastIndexOf('.'),d=e.dataset.field.substring(n+1);t&&Array.isArray(t)&&t.forEach(((t,s)=>{let n=document.getElementById(`assets_${d}`);if(n){let s=n.content;const d=s.querySelector('[data-name]');d&&(d.textContent=t.name);const a=s.querySelector('[data-original]');a&&(a.textContent=t.original);const l=s.querySelector('[data-thumbnail]');l&&(l.textContent=t.thumbnail);const c=s.querySelector('[data-size]');c&&(c.textContent=t.size),e.appendChild(s.cloneNode(!0))}}))})(e,s);break;default:e.innerHTML=`<p>Unsupported container type: ${d} for ${e.tagName}</p>`}};customElements.define('str-div',class extends HTMLDivElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'div'}),customElements.define('str-ul',class extends HTMLUListElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'ul'}),customElements.define('str-ol',class extends HTMLOListElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'ol'}),customElements.define('str-section',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'section'}),customElements.define('str-header',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'header'}),customElements.define('str-footer',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'footer'}),customElements.define('str-nav',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'nav'}),customElements.define('str-article',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'article'}),customElements.define('str-main',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'main'}),customElements.define('str-aside',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'aside'}),customElements.define('str-blockquote',class extends HTMLElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'blockquote'}),customElements.define('str-tbody',class extends HTMLTableSectionElement{connectedCallback(){r(this)}render(e,t){i(this,e,t)}},{extends:'tbody'});
2
- //# sourceMappingURL=index-5a5f910d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-5a5f910d.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- const e=1,t=2,a=4,s=8;class n extends MessageChannel{static _instanceCache;static get instance(){return this._instanceCache||(this._instanceCache=new n),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(),n._instanceCache=null}}send(e){this.port1.postMessage(e),this.broadcastChannel.postMessage(e)}onConnected(e){return e}}const o=(e,t)=>e?.split('.').reduce(((e,t)=>e?.[t]),t),r=4,c=8,d=32;let i=!1,h={},l={},m=[];const p=[],f=({data:e})=>{try{e.cmd===s&&e.sync.forEach((e=>{if(e.currentPath===window.location.pathname)switch(e.action){case c:p.forEach((({self:t,handler:a})=>{const s=(e.data.placeholders??[]).find((e=>e.propertyName===t.dataset.field));s&&(t.dataset.placeholder=s.placeholder)})),m=[...e.data?.placeholder??[]];break;case d:const t=e.data?.change;t?p.forEach((({self:a,handler:s})=>{t.name===a.dataset.field&&s(t.value,e.context)})):e.data?.state&&p.forEach((({self:t,handler:a})=>{const s=o(t.dataset.field,e.data.state);void 0!==s&&a(s,e.context)})),e.data?.state&&(h={...e.data.state},i=!0),e.context&&(l={...e.context})}}))}catch(e){console.error(e)}},u=(e,t)=>{if(p.push({self:e,handler:t}),i){const a=o(e.dataset.field,h);void 0!==a&&t(a,l)}if(m.length){const t=m.find((t=>t.propertyName===e.dataset.field));t&&(e.dataset.placeholder=t.placeholder||'')}},g=e=>{if('function'!=typeof e)throw new Error('messageHandler must be a function!');return i&&e(h),n.instance.subscribe((t=>{try{if(t.data.cmd===s)for(const a of t.data.sync)a.action!==d||e(a.data.state)}catch(e){console.error('Error in messageHandler:',e)}}))},y=()=>{const e=((e,t)=>{let a;return function(...s){clearTimeout(a),a=setTimeout((()=>e.apply(this,s)),t)}})((()=>{n.instance.send({cmd:a,updates:[{action:r,context:{name:window.name,height:document.body.scrollHeight}}]})}),100);new ResizeObserver((t=>{for(let a of t)a.target===document.body&&e()})).observe(document.body)};'undefined'!=typeof document&&document.addEventListener('DOMContentLoaded',(e=>{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-5a5f910d.js'),n.instance.invoke(),n.instance.subscribe(f),y()})),performance.mark('mark-1');export{o as p,g as s,u};
2
- //# sourceMappingURL=index-7b7c7ddf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-7b7c7ddf.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}