@creaditor/web-starterkit 1.0.48 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[2655],{72655(e,t,i){i.r(t),i.d(t,{NextButton:()=>B,PUBLISH_ERROR_EVENT:()=>E,PUBLISH_EVENT:()=>T});var o=i(59929),s=i(86319),n=i(93432),r=i(90090),a=i(86959),l=i(15604),d=i(85274),c=i(26432);const p=`${(0,a.Ay)()?"http://127.0.0.1:8000":"https://studio.creaditor.ai"}/api/seo-generate`;const h=o.qy`
1
+ "use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[2655],{72655(e,t,i){i.r(t),i.d(t,{NextButton:()=>M,PUBLISH_ERROR_EVENT:()=>E,PUBLISH_EVENT:()=>T});var o=i(59929),s=i(86319),n=i(93432),r=i(90090),a=i(86959),l=i(15604),d=i(85274),c=i(26432);const p=`${(0,a.Ay)()?"http://127.0.0.1:8000":"https://studio.creaditor.ai"}/api/seo-generate`;const h=o.qy`
2
2
  <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" aria-hidden="true">
3
3
  <path
4
4
  d="M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z"
@@ -755,7 +755,7 @@
755
755
  animation: shimmer 1.1s ease-in-out infinite; }
756
756
  @media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
757
757
  footer { padding: 14px 20px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid #eef0f3; flex-wrap: wrap; }
758
- `,customElements.get("cdtr-preflight")||customElements.define("cdtr-preflight",L);const P={check:(e,t)=>new Promise((i,o)=>{const n=document.createElement("cdtr-preflight");n.dir=(()=>{const e=s.M.get("theme");if("rtl"===e?.direction||"ltr"===e?.direction)return e.direction;const t=getComputedStyle(document.documentElement).getPropertyValue("--direction-locale").trim();if("rtl"===t||"ltr"===t)return t;const i=String(s.M.get("config","language")||"");return/^(he|ar|fa|ur)/i.test(i)?"rtl":"ltr"})(),n.style.zIndex=String(Number((0,m.A)())+10);(()=>{const t=e.getBoundingClientRect();n.style.top=`${Math.round(t.bottom+8)}px`;const i="rtl"===n.dir?t.left:t.right-290;n.style.left=`${Math.max(8,Math.min(Math.round(i),window.innerWidth-298))}px`})(),n.stage="checking",n.resolve=e=>{n.remove(),i(e)},document.body.appendChild(n);const r=e=>$(_()?0:e);(async()=>{const[e]=await Promise.all([t(),r(700)]);n.htmlBytes=e.htmlBytes;let i=e.findings;const o=(e=>e.filter(e=>e.fix&&C[e.ruleId]))(i);o.length&&(n.stageCount=o.length,n.stage="fixing",await r(1200),o.forEach(w),await $(60),i=(0,b.JT)((0,x.D)(),{channel:(0,x.l)(),htmlBytes:n.htmlBytes}),n.stage="fixed",await r(900)),i.length?(n.findings=i,n.autoFixed=o.length,n.style.top=n.style.left="",n.stage=""):n.resolve("continue")})().catch(e=>{n.remove(),o(e)})})};const T="creaditor:publish",E="creaditor:publish-error",q=async()=>{const e=(0,x.l)(),t=await async function(e){if("newsletter"===e)try{const e=await Promise.race([(0,n.FE)("newsletter"),new Promise(e=>setTimeout(()=>e(void 0),8e3))]);return"string"==typeof e?new Blob([e]).size:void 0}catch{return}}(e);return{findings:(0,b.JT)((0,x.D)(),{channel:e,htmlBytes:t}),htmlBytes:t}};class B extends o.WF{constructor(){super(),this._onAiActivity=e=>{this.aiBusy="thinking"===e.detail?.state},this.preflightOpen=!1,this.channel="",this.isLoading=!1,this.isLocked=!1,this.lockTimer=null}connectedCallback(){super.connectedCallback(),window.addEventListener(g.bm,this._onAiActivity),this.onNextStep||(this.onNextStep=s.M.get("config","onNextStep")),this.onPublish||(this.onPublish=s.M.get("config","onPublish")),this.channel||(this.channel=s.M.get("config","channel")||"")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(g.bm,this._onAiActivity),this.clearTimers()}clearTimers(){this.lockTimer&&(clearTimeout(this.lockTimer),this.lockTimer=null)}async onNextClick(){if(this.isLocked||this.isLoading)return;if(this.preflightOpen)return void document.querySelector("cdtr-preflight")?.expand?.();if("newsletter"!==(0,x.l)())return this.handleClick();let e="continue";this.preflightOpen=!0;try{e=await P.check(this,q)}catch(t){console.warn("[preflight] checks failed",t),e="continue"}finally{this.preflightOpen=!1}"continue"===e&&await this.handleClick()}async handleClick(){if(this.isLocked||this.isLoading||this.aiBusy)return;document.querySelector("cdtr-preflight")?.resolve?.("edit");const e=!!s.M.get("config","access"),t="web"===this.channel,i=e&&t;let o=null;if(t&&(o=await u.open(),!o))return;const a=o?o.seo:null;this.isLoading=!0,this.isLocked=!0;const l=Date.now();this.lockTimer=setTimeout(()=>{this.clearTimers(),this.isLoading=!1,this.isLocked=!1},1e4);try{if(t&&o){let e=!1;try{i&&a&&(await(0,r.YE)({seo:a}),await(0,r.bK)({})),"function"==typeof this.onPublish?e=await this.runHostPublish(this.onPublish,a,i,o):"function"==typeof this.onNextStep&&await this.onNextStep({toHTML:n.FE,toJSON:n.U2,seo:a??void 0})}finally{o.done()}return void(e||(this.emitPublished(i,a),this.celebratePublish(a)))}const e=s.M.get("config","editor","props","onSave"),l=Date.now();"function"==typeof e&&await e({transactions:[],toJson:n.U2,toJSON:n.U2,toHTML:n.FE});const d=Date.now()-l;d<3e3&&await new Promise(e=>setTimeout(e,3e3-d)),"function"==typeof this.onNextStep&&await this.onNextStep({toHTML:n.FE,toJSON:n.U2}),this.emitPublished(i,a)}catch(e){console.error("Error in publish/onNextStep:",e),this.emitPublishError(i,a,e),this.snackbar(s.M.get("lang","publishError")||"Publish failed")}finally{const e=Date.now()-l;e<400&&await new Promise(t=>setTimeout(t,400-e)),this.clearTimers(),this.isLoading=!1,this.isLocked=!1}}runHostPublish(e,t,i,o){return new Promise(a=>{let l=!1;const d=(e,n,r)=>{l||(l=!0,clearTimeout(c),o.done(),e?(this.celebratePublish(t),this.emitPublished(i,t)):(this.snackbar(r||s.M.get("lang","publishError")||"Publish failed"),this.emitPublishError(i,t,n)),a(!0))},c=setTimeout(()=>{l||(console.warn("config.onPublish never signalled completion — finishing the publish without it. Call success() or error() (or return a promise) so the modal can come down."),l=!0,o.done(),a(!1))},6e4),p={title:t.title,description:t.description,keywords:t.keywords},h={loading:function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return o.busy(e)},success:()=>d(!0),confetti:()=>d(!0),error:e=>d(!1,new Error(e||"host publish failed"),e),commands:{patchSite:e=>(0,r.YE)(e??{}),publishSite:e=>(0,r.bK)(e??{}),toHTML:n.FE,toJSON:n.U2}};let u;try{u=e(p,h)}catch(e){return console.error("Error in config.onPublish:",e),void d(!1,e)}u&&"function"==typeof u.then&&Promise.resolve(u).then(()=>d(!0),e=>{console.error("Error in config.onPublish:",e),d(!1,e)})})}snackbar(e){const t=s.M.get("commands");t?.snackbar?.(e)}siteUrl(){const e=s.M.get("app","domains"),t=e?.[0]?.name;if(t)return/^https?:\/\//.test(t)?t:`https://${t}`}emitPublished(e,t){const i={channel:this.channel,selfPublish:e,seo:t??void 0,url:this.siteUrl(),toHTML:n.FE,toJSON:n.U2};window.dispatchEvent(new CustomEvent(T,{detail:i}))}emitPublishError(e,t,i){const o={channel:this.channel,selfPublish:e,seo:t??void 0,error:i};window.dispatchEvent(new CustomEvent(E,{detail:o}))}celebratePublish(e){const t=document.createElement("cdtr-publish-success");e&&(t.seoTitle=e.title,t.seoDescription=e.description);const i=this.siteUrl();i&&(t.url=i),document.body.appendChild(t)}render(){const e=!!s.M.get("config","access");if(!(this.onNextStep||"function"==typeof this.onPublish||"web"===this.channel&&e))return null;const t="web"===this.channel?"publish":"next";return o.qy`
758
+ `,customElements.get("cdtr-preflight")||customElements.define("cdtr-preflight",L);const P={check:(e,t)=>new Promise((i,o)=>{const n=document.createElement("cdtr-preflight");n.dir=(()=>{const e=s.M.get("theme");if("rtl"===e?.direction||"ltr"===e?.direction)return e.direction;const t=getComputedStyle(document.documentElement).getPropertyValue("--direction-locale").trim();if("rtl"===t||"ltr"===t)return t;const i=String(s.M.get("config","language")||"");return/^(he|ar|fa|ur)/i.test(i)?"rtl":"ltr"})(),n.style.zIndex=String(Number((0,m.A)())+10);(()=>{const t=e.getBoundingClientRect();n.style.top=`${Math.round(t.bottom+8)}px`;const i="rtl"===n.dir?t.left:t.right-290;n.style.left=`${Math.max(8,Math.min(Math.round(i),window.innerWidth-298))}px`})(),n.stage="checking",n.resolve=e=>{n.remove(),i(e)},document.body.appendChild(n);const r=e=>$(_()?0:e);(async()=>{const[e]=await Promise.all([t(),r(700)]);n.htmlBytes=e.htmlBytes;let i=e.findings;const o=(e=>e.filter(e=>e.fix&&C[e.ruleId]))(i);o.length&&(n.stageCount=o.length,n.stage="fixing",await r(1200),o.forEach(w),await $(60),i=(0,b.JT)((0,x.D)(),{channel:(0,x.l)(),htmlBytes:n.htmlBytes}),n.stage="fixed",await r(900)),i.length?(n.findings=i,n.autoFixed=o.length,n.style.top=n.style.left="",n.stage=""):n.resolve("continue")})().catch(e=>{n.remove(),o(e)})})};const T="creaditor:publish",E="creaditor:publish-error",q=async()=>{const e=(0,x.l)(),t=await async function(e){if("newsletter"===e)try{const e=await Promise.race([(0,n.FE)("newsletter"),new Promise(e=>setTimeout(()=>e(void 0),8e3))]);return"string"==typeof e?new Blob([e]).size:void 0}catch{return}}(e);return{findings:(0,b.JT)((0,x.D)(),{channel:e,htmlBytes:t}),htmlBytes:t}};class M extends o.WF{constructor(){super(),this._onAiActivity=e=>{this.aiBusy="thinking"===e.detail?.state},this.preflightOpen=!1,this.channel="",this.isLoading=!1,this.isLocked=!1,this.lockTimer=null}connectedCallback(){super.connectedCallback(),window.addEventListener(g.bm,this._onAiActivity),this.onNextStep||(this.onNextStep=s.M.get("config","onNextStep")),this.onPublish||(this.onPublish=s.M.get("config","onPublish")),this.channel||(this.channel=s.M.get("config","channel")||"")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(g.bm,this._onAiActivity),this.clearTimers()}clearTimers(){this.lockTimer&&(clearTimeout(this.lockTimer),this.lockTimer=null)}async onNextClick(){if(this.isLocked||this.isLoading)return;if(this.preflightOpen)return void document.querySelector("cdtr-preflight")?.expand?.();if("newsletter"!==(0,x.l)())return this.handleClick();let e="continue";this.preflightOpen=!0;try{e=await P.check(this,q)}catch(t){console.warn("[preflight] checks failed",t),e="continue"}finally{this.preflightOpen=!1}"continue"===e&&await this.handleClick()}async handleClick(){if(this.isLocked||this.isLoading||this.aiBusy)return;document.querySelector("cdtr-preflight")?.resolve?.("edit");const e=!!s.M.get("config","access"),t="web"===this.channel,i=e&&t;let o=null;if(t&&(o=await u.open(),!o))return;const a=o?o.seo:null;this.isLoading=!0,this.isLocked=!0;const l=Date.now();this.lockTimer=setTimeout(()=>{this.clearTimers(),this.isLoading=!1,this.isLocked=!1},1e4);try{if(t&&o){let e=!1;try{if(i&&a&&(await(0,r.YE)({seo:a}),await(0,r.bK)({})),a){const e=s.M.get("app")||{};s.M.set({app:{...e,seo:{...e.seo||{},...a}}})}"function"==typeof this.onPublish?e=await this.runHostPublish(this.onPublish,a,i,o):"function"==typeof this.onNextStep&&await this.onNextStep({toHTML:n.FE,toJSON:n.U2,seo:a??void 0})}finally{o.done()}return void(e||(this.emitPublished(i,a),this.celebratePublish(a)))}const e=s.M.get("config","editor","props","onSave"),l=Date.now();"function"==typeof e&&await e({transactions:[],toJson:n.U2,toJSON:n.U2,toHTML:n.FE});const d=Date.now()-l;d<3e3&&await new Promise(e=>setTimeout(e,3e3-d)),"function"==typeof this.onNextStep&&await this.onNextStep({toHTML:n.FE,toJSON:n.U2}),this.emitPublished(i,a)}catch(e){console.error("Error in publish/onNextStep:",e),this.emitPublishError(i,a,e),this.snackbar(s.M.get("lang","publishError")||"Publish failed")}finally{const e=Date.now()-l;e<400&&await new Promise(t=>setTimeout(t,400-e)),this.clearTimers(),this.isLoading=!1,this.isLocked=!1}}runHostPublish(e,t,i,o){return new Promise(a=>{let l=!1;const d=(e,n,r)=>{l||(l=!0,clearTimeout(c),o.done(),e?(this.celebratePublish(t),this.emitPublished(i,t)):(this.snackbar(r||s.M.get("lang","publishError")||"Publish failed"),this.emitPublishError(i,t,n)),a(!0))},c=setTimeout(()=>{l||(console.warn("config.onPublish never signalled completion — finishing the publish without it. Call success() or error() (or return a promise) so the modal can come down."),l=!0,o.done(),a(!1))},6e4),p={title:t.title,description:t.description,keywords:t.keywords},h={loading:function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return o.busy(e)},success:()=>d(!0),confetti:()=>d(!0),error:e=>d(!1,new Error(e||"host publish failed"),e),commands:{patchSite:e=>(0,r.YE)(e??{}),publishSite:e=>(0,r.bK)(e??{}),toHTML:n.FE,toJSON:n.U2}};let u;try{u=e(p,h)}catch(e){return console.error("Error in config.onPublish:",e),void d(!1,e)}u&&"function"==typeof u.then&&Promise.resolve(u).then(()=>d(!0),e=>{console.error("Error in config.onPublish:",e),d(!1,e)})})}snackbar(e){const t=s.M.get("commands");t?.snackbar?.(e)}siteUrl(){const e=s.M.get("app","domains"),t=e?.[0]?.name;if(t)return/^https?:\/\//.test(t)?t:`https://${t}`}emitPublished(e,t){const i={channel:this.channel,selfPublish:e,seo:t??void 0,url:this.siteUrl(),toHTML:n.FE,toJSON:n.U2};window.dispatchEvent(new CustomEvent(T,{detail:i}))}emitPublishError(e,t,i){const o={channel:this.channel,selfPublish:e,seo:t??void 0,error:i};window.dispatchEvent(new CustomEvent(E,{detail:o}))}celebratePublish(e){const t=document.createElement("cdtr-publish-success");e&&(t.seoTitle=e.title,t.seoDescription=e.description);const i=this.siteUrl();i&&(t.url=i),document.body.appendChild(t)}render(){const e=!!s.M.get("config","access");if(!(this.onNextStep||"function"==typeof this.onPublish||"web"===this.channel&&e))return null;const t="web"===this.channel?"publish":"next";return o.qy`
759
759
  <paper-button
760
760
  @click=${this.onNextClick}
761
761
  class="next-button"
@@ -770,7 +770,7 @@
770
770
  </div>
771
771
  `}
772
772
  </paper-button>
773
- `}}B.styles=o.AH`
773
+ `}}M.styles=o.AH`
774
774
  :host {
775
775
  display: block;
776
776
  }
@@ -821,4 +821,4 @@
821
821
  opacity: 0;
822
822
  }
823
823
 
824
- `,B.properties={onNextStep:{type:Function},onPublish:{type:Function},channel:{type:String},isLoading:{type:Boolean},isLocked:{type:Boolean},aiBusy:{type:Boolean},lockTimer:{type:Number}},customElements.define("cdtr-next-button",B)}}]);
824
+ `,M.properties={onNextStep:{type:Function},onPublish:{type:Function},channel:{type:String},isLoading:{type:Boolean},isLocked:{type:Boolean},aiBusy:{type:Boolean},lockTimer:{type:Number}},customElements.define("cdtr-next-button",M)}}]);
Binary file