@innovastudio/contentbuilder-runtime 1.0.10 → 1.0.11
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.
|
@@ -10776,23 +10776,24 @@ class vn {
|
|
|
10776
10776
|
openLightbox(e, t, i) {
|
|
10777
10777
|
let n = [], s = 0;
|
|
10778
10778
|
if (t) {
|
|
10779
|
-
const
|
|
10780
|
-
let
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
}),
|
|
10784
|
-
let
|
|
10785
|
-
|
|
10786
|
-
href:
|
|
10787
|
-
}), e ===
|
|
10779
|
+
const o = t.closest("[data-gallery]");
|
|
10780
|
+
let c = [];
|
|
10781
|
+
o ? c = o.querySelectorAll(".is-lightbox") : document.querySelectorAll(".is-lightbox,.block-click").forEach((d) => {
|
|
10782
|
+
d.closest("[data-gallery]") || c.push(d);
|
|
10783
|
+
}), c.forEach((u, d) => {
|
|
10784
|
+
let l = u.getAttribute("href");
|
|
10785
|
+
l || (l = u.getAttribute("data-modal-url")), n.push({
|
|
10786
|
+
href: l
|
|
10787
|
+
}), e === l && (s = d);
|
|
10788
10788
|
});
|
|
10789
10789
|
}
|
|
10790
|
-
|
|
10790
|
+
const r = document.activeElement;
|
|
10791
|
+
r?.blur(), n.length > 0 ? (this.glightbox.setElements(n), this.glightbox.openAt(s)) : (this.glightbox.setElements([
|
|
10791
10792
|
{
|
|
10792
10793
|
href: e
|
|
10793
10794
|
}
|
|
10794
10795
|
]), this.glightbox.open()), this.glightbox.on("close", () => {
|
|
10795
|
-
this.refreshLightbox(i);
|
|
10796
|
+
this.refreshLightbox(i), r?.focus();
|
|
10796
10797
|
});
|
|
10797
10798
|
}
|
|
10798
10799
|
destroy() {
|
|
@@ -508,4 +508,4 @@ ${q.data}
|
|
|
508
508
|
`}}this.tokenInput+=y,this.tokenOutput+=k}return!0}catch(l){return l.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",l),!1}}async assistant(e,t,i,n){this.controller=new AbortController,this.signal=this.controller.signal;let s=.6,r=.9,o=1;n||(n=[]);let c=this.settings.model;n.length>0&&(c=this.settings.model2);const u={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:s,topP:r,num:o,model:c,customData:this.settings.customData};try{let d={"Content-Type":"application/json",...this.settings.headers},h=await(await fetch(this.settings.assistantUrl,{signal:this.signal,method:"POST",headers:d,body:JSON.stringify(u)})).json();return h.error?(console.log(`Error:
|
|
509
509
|
`+h.error),!1):(h.usage&&(this.tokenInput+=h.usage.prompt_tokens,this.tokenOutput+=h.usage.completion_tokens),h.answer.content[0].text.value)}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}async assistantStream(e,t,i,n,s){this.controller=new AbortController,this.signal=this.controller.signal;let r=.6,o=.9,c=1;n||(n=[]);const u={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:r,topP:o,num:c,model:this.settings.model,customData:this.settings.customData};try{let d={"Content-Type":"application/json",...this.settings.headers};const l=await fetch(this.settings.assistantStreamUrl,{signal:this.signal,method:"POST",headers:d,body:JSON.stringify(u)});if(!l.ok)return console.error("Error:",l.statusText),!1;const h=l.body.getReader(),p=new TextDecoder;let b="",w=!1;for(;!w;){const{done:_,value:g}=await h.read();if(w=_,w)break;const v=p.decode(g,{stream:!0});b+=v;const f=b.split(`
|
|
510
510
|
`);b="";for(const m of f)if(m.trim()!=="")if(m.startsWith("data:")){const y=m.slice(5).trim();y==="[DONE]"&&this.settings.consoleLog&&console.log("Stream completed.");try{const k=JSON.parse(y);if(k.choices&&k.choices[0].delta&&k.choices[0].delta.content){const x=k.choices[0].delta.content;s&&s(x)}}catch{b+=m+`
|
|
511
|
-
`}}else{const y=JSON.parse(m);this.tokenInput+=y.prompt_tokens,this.tokenOutput+=y.completion_tokens;break}}return!0}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}hexToRgb(e){const t=e.replace("#",""),i=parseInt(t,16),n=i>>16&255,s=i>>8&255,r=i&255;return{red:n,green:s,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,t){e&&t&&e.insertAdjacentHTML("beforeend",t)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(t=>{t.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(t=>{t.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const t=e.querySelector(".submit-container"),i=this.getScrollableParent(t);i?i.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let t=this.settings.lang[e];return t||e}}class mn{constructor(e={}){const t={skin:"light"};this.settings={...t,...e},window.Glide=Rs,window.FormViewer=gn}init(){const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(i=>{const n=s=>{let r=i.getAttribute("href")||i.getAttribute("data-modal-url");this.openLightbox(r,i,e),s.preventDefault(),s.stopImmediatePropagation()};i.addEventListener("click",n),i._lightboxHandler=n})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new jt(e),window.GLightbox=jt.default}openLightbox(e,t,i){let n=[],s=0;if(t){const
|
|
511
|
+
`}}else{const y=JSON.parse(m);this.tokenInput+=y.prompt_tokens,this.tokenOutput+=y.completion_tokens;break}}return!0}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}hexToRgb(e){const t=e.replace("#",""),i=parseInt(t,16),n=i>>16&255,s=i>>8&255,r=i&255;return{red:n,green:s,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,t){e&&t&&e.insertAdjacentHTML("beforeend",t)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(t=>{t.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(t=>{t.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const t=e.querySelector(".submit-container"),i=this.getScrollableParent(t);i?i.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let t=this.settings.lang[e];return t||e}}class mn{constructor(e={}){const t={skin:"light"};this.settings={...t,...e},window.Glide=Rs,window.FormViewer=gn}init(){const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(i=>{const n=s=>{let r=i.getAttribute("href")||i.getAttribute("data-modal-url");this.openLightbox(r,i,e),s.preventDefault(),s.stopImmediatePropagation()};i.addEventListener("click",n),i._lightboxHandler=n})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new jt(e),window.GLightbox=jt.default}openLightbox(e,t,i){let n=[],s=0;if(t){const o=t.closest("[data-gallery]");let c=[];o?c=o.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(d=>{d.closest("[data-gallery]")||c.push(d)}),c.forEach((u,d)=>{let l=u.getAttribute("href");l||(l=u.getAttribute("data-modal-url")),n.push({href:l}),e===l&&(s=d)})}const r=document.activeElement;r?.blur(),n.length>0?(this.glightbox.setElements(n),this.glightbox.openAt(s)):(this.glightbox.setElements([{href:e}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(i),r?.focus()})}destroy(){this.glightbox&&(this.glightbox.destroy(),this.glightbox=null),document.querySelectorAll(".is-lightbox,.block-click").forEach(t=>{t._lightboxHandler&&(t.removeEventListener("click",t._lightboxHandler),delete t._lightboxHandler)})}}return mn})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innovastudio/contentbuilder-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.11",
|
|
5
5
|
"description": "Runtime libraries for ContentBuilder generated content",
|
|
6
6
|
"main": "dist/contentbuilder-runtime.esm.js",
|
|
7
7
|
"module": "dist/contentbuilder-runtime.esm.js",
|