@salla.sa/twilight-bundles 0.1.32 → 0.1.34

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.
@@ -20,4 +20,4 @@
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const Ut={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:K},Ot=(n=Ut,t,e)=>{const{kind:s,metadata:i}=e;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),s==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(e.name,n),s==="accessor"){const{name:o}=e;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,a,n)},init(l){return l!==void 0&&this.C(o,void 0,n,l),l}}}if(s==="setter"){const{name:o}=e;return function(l){const a=this[o];t.call(this,l),this.requestUpdate(o,a,n)}}throw Error("Unsupported decorator location: "+s)};function z(n){return(t,e)=>typeof e=="object"?Ot(n,t,e):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(n,t,e)}class y{static onBundlesReady(){return y.makeSureSallaIsReady().then(()=>Salla.event.onlyWhen("twilight-bundles::initiated")).then(()=>Salla.lang.onLoaded())}static async initializeSalla(){if(Salla.status==="ready"){salla.log("Salla is ready");return}const t=document.currentScript||document.querySelector('script[src*="twilight-bundles.js"]'),e=t==null?void 0:t.hasAttribute("demo-mode");let s=t==null?void 0:t.getAttribute("store-id"),i=JSON.parse((t==null?void 0:t.getAttribute("config"))||"false");return e||i||s?(s=s||"1510890315",i=i||await y.getStoreSettings(s),Salla.init(i||{debug:!0,store:{id:s}})):Salla.onReady()}static async getStoreSettings(t){let e=Salla.storage.session.get(`store-settings-${t}`);return e||(e=(await fetch("https://api.salla.dev/store/v1/store/settings",{headers:{"store-identifier":t}}).then(s=>s.json())).data,Salla.storage.session.set(`store-settings-${t}`,e),e)}static makeSureSallaIsReady(){return window.Salla?Promise.resolve(y.initializeSalla()):new Promise((t,e)=>{let s;const i=setTimeout(()=>{window.clearInterval(s),e(new Error("Timeout: Salla object not found after 10 seconds"))},1e4);s=window.setInterval(()=>{window.Salla&&(window.clearInterval(s),clearTimeout(i),t(y.initializeSalla()))},50)})}}var Rt=Object.defineProperty,L=(n,t,e,s)=>{for(var i=void 0,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=o(t,e,i)||i);return i&&Rt(t,e,i),i};const F=class F extends M{constructor(){super(...arguments),this.key="",this.data={},this.imports={},this.shadowRootMode="open"}createRenderRoot(){return this.shadowRootMode!==!1?this.attachShadow({mode:this.shadowRootMode||"closed"}):this}static register(t){const e={component:this,dynamicTagName:`${t}-${Math.random().toString(36).substring(2,8)}`};return y.onBundlesReady().then(()=>Salla.bundles.registerComponent(t,e))}};F.styles=pt`:host { display: block; }`;let v=F;L([z()],v.prototype,"key");L([z()],v.prototype,"data");L([z()],v.prototype,"imports");L([z()],v.prototype,"shadowRootMode");class Ht extends HTMLElement{connectedCallback(){var e;let t=(e=this.getAttribute("component-name"))==null?void 0:e.replace(/^salla-/,"");if(!t)return Salla.error("Component name is required",this),Promise.resolve();this.innerHTML=`<!-- Loading ${t} -->`,this.removeAttribute("component-name"),Salla.bundles.renderCustomComponentDom(`salla-${t}`,this)}}class Nt{constructor(){this.components=new Map,this.pendingComponents=[],this.initialized=!1,Salla.onReady().then(()=>{if(Salla.bundles){Salla.log("TwilightBundles is already initialized");return}this.init(),Salla.bundles=this,Salla.event.emit("twilight-bundles::initiated"),this.registerCustomComponents()})}async init(){this.initialized||(this.initialized=!0)}registerCustomComponents(){var t;HTMLElement.registerSallaComponent=function(e){Salla.bundles.registerComponent(e,{component:this,dynamicTagName:`${e}-${Math.random().toString(36).substring(2,8)}`})},(t=window.customComponents)==null||t.forEach(e=>{const s=document.createElement("script");s.type="module",s.src=e,document.head.appendChild(s)})}renderCustomComponentDom(t,e){salla.log("Rendering custom component",t),e.getAttribute("component-name");const s=this.components.get(t);return s?this.renderDynamicCustomComponentDom(s.dynamicTagName,e):this.pendingComponents.push({tagName:t,component:e})}renderDynamicCustomComponentDom(t,e){const s=document.createElement(t);Array.from(e.attributes).forEach(i=>s.setAttribute(i.name,i.value||"")),e.before(s),e.remove()}registerComponent(t,e){if(this.components.has(t))return console.warn(`Component ${t} is already registered into the this.components map. Skipping.`);if(!e.dynamicTagName)return console.warn(`Component ${t} is missing dynamicTagName. Skipping.`);if(!e.component)return console.warn(`Component ${t} is missing component. Skipping.`);if(window.customElements.get(e.dynamicTagName))return console.warn(`Component ${e.dynamicTagName} is already registered into the window custom elements. Skipping.`);window.customElements.define(e.dynamicTagName,e.component),this.components.set(t,e),Salla.log("Component registered:",e.dynamicTagName);const s=this.pendingComponents.filter(i=>i.tagName===t);s.length&&(s.forEach(i=>{this.renderDynamicCustomComponentDom(e.dynamicTagName,i.component)}),this.pendingComponents=this.pendingComponents.filter(i=>i.tagName!==t),Salla.log("Pending Components rendered:",t,e.dynamicTagName))}renderSharedAssests(...t){const e={sallaicons:`<link rel="stylesheet" href="${Salla.url.cdn("fonts/sallaicons.css")}">`};return t.map(s=>e[s]||"").join("")}}y.makeSureSallaIsReady().then(()=>new Nt).then(()=>window.customElements.get("salla-custom-component")||window.customElements.define("salla-custom-component",Ht));exports.SallaComponent=v;
23
+ */const Ut={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:K},Ot=(n=Ut,t,e)=>{const{kind:s,metadata:i}=e;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),s==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(e.name,n),s==="accessor"){const{name:o}=e;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,a,n)},init(l){return l!==void 0&&this.C(o,void 0,n,l),l}}}if(s==="setter"){const{name:o}=e;return function(l){const a=this[o];t.call(this,l),this.requestUpdate(o,a,n)}}throw Error("Unsupported decorator location: "+s)};function z(n){return(t,e)=>typeof e=="object"?Ot(n,t,e):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(n,t,e)}class y{static onBundlesReady(){return y.makeSureSallaIsReady().then(()=>Salla.event.onlyWhen("twilight-bundles::initiated")).then(()=>Salla.lang.onLoaded())}static async initializeSalla(){if(Salla.status==="ready"){salla.log("Salla is ready");return}const t=document.currentScript||document.querySelector('script[src*="twilight-bundles.js"]'),e=t==null?void 0:t.hasAttribute("demo-mode");let s=t==null?void 0:t.getAttribute("store-id"),i=JSON.parse((t==null?void 0:t.getAttribute("config"))||"false");return e||i||s?(s=s||"1510890315",i=i||await y.getStoreSettings(s),Salla.init(i||{debug:!0,store:{id:s}})):Salla.onReady()}static async getStoreSettings(t){let e=Salla.storage.session.get(`store-settings-${t}`);return e||(e=(await fetch("https://api.salla.dev/store/v1/store/settings",{headers:{"store-identifier":t}}).then(s=>s.json())).data,Salla.storage.session.set(`store-settings-${t}`,e),e)}static makeSureSallaIsReady(){return window.Salla?Promise.resolve(y.initializeSalla()):new Promise((t,e)=>{let s;const i=setTimeout(()=>{window.clearInterval(s),e(new Error("Timeout: Salla object not found after 10 seconds"))},1e4);s=window.setInterval(()=>{window.Salla&&(window.clearInterval(s),clearTimeout(i),t(y.initializeSalla()))},50)})}}var Rt=Object.defineProperty,L=(n,t,e,s)=>{for(var i=void 0,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=o(t,e,i)||i);return i&&Rt(t,e,i),i};const F=class F extends M{constructor(){super(...arguments),this.key="",this.data={},this.imports={},this.shadowRootMode="open"}createRenderRoot(){return this.shadowRootMode!==!1?this.attachShadow({mode:this.shadowRootMode||"closed"}):this}static register(t){const e={component:this,dynamicTagName:`${t}-${Math.random().toString(36).substring(2,8)}`};return y.onBundlesReady().then(()=>Salla.bundles.registerComponent(t,e))}};F.styles=pt`:host { display: block; }`;let v=F;L([z()],v.prototype,"key");L([z()],v.prototype,"data");L([z()],v.prototype,"imports");L([z()],v.prototype,"shadowRootMode");class Ht extends HTMLElement{connectedCallback(){var e;let t=(e=this.getAttribute("component-name"))==null?void 0:e.replace(/^salla-/,"");if(!t)return Salla.error("Component name is required",this),Promise.resolve();this.innerHTML=`<!-- Loading ${t} -->`,this.removeAttribute("component-name"),Salla.bundles.renderCustomComponentDom(`salla-${t}`,this)}}class Nt{constructor(){this.components=new Map,this.pendingComponents=[],this.initialized=!1,Salla.onReady().then(()=>{if(Salla.bundles){Salla.log("TwilightBundles is already initialized");return}this.init(),Salla.bundles=this,Salla.event.emit("twilight-bundles::initiated"),this.registerCustomComponents()})}async init(){this.initialized||(this.initialized=!0)}registerCustomComponents(){HTMLElement.registerSallaComponent=function(t){Salla.bundles.registerComponent(t,{component:this,dynamicTagName:`${t}-${Math.random().toString(36).substring(2,8)}`})},this.injectBundleScript(window.customComponents)}injectBundleScript(t){t.forEach(e=>{if(document.querySelector(`script[src="${e}"]`)){Salla.log("Script already exists",e);return}const s=document.createElement("script");s.type="module",s.src=e,document.head.appendChild(s)})}renderCustomComponentDom(t,e){Salla.log("Rendering custom component",t);const s=this.components.get(t);if(s)return this.renderDynamicCustomComponentDom(s.dynamicTagName,e);this.pendingComponents.push({tagName:t,component:e});const i=e.getAttribute("assets");i&&this.injectBundleScript(i.split(","))}renderDynamicCustomComponentDom(t,e){const s=document.createElement(t);Array.from(e.attributes).forEach(i=>s.setAttribute(i.name,i.value||"")),e.before(s),e.remove()}registerComponent(t,e){if(this.components.has(t))return console.warn(`Component ${t} is already registered into the this.components map. Skipping.`);if(!e.dynamicTagName)return console.warn(`Component ${t} is missing dynamicTagName. Skipping.`);if(!e.component)return console.warn(`Component ${t} is missing component. Skipping.`);if(window.customElements.get(e.dynamicTagName))return console.warn(`Component ${e.dynamicTagName} is already registered into the window custom elements. Skipping.`);window.customElements.define(e.dynamicTagName,e.component),this.components.set(t,e),Salla.log("Component registered:",e.dynamicTagName);const s=this.pendingComponents.filter(i=>i.tagName===t);s.length&&(s.forEach(i=>{this.renderDynamicCustomComponentDom(e.dynamicTagName,i.component)}),this.pendingComponents=this.pendingComponents.filter(i=>i.tagName!==t),Salla.log("Pending Components rendered:",t,e.dynamicTagName))}renderSharedAssests(...t){const e={sallaicons:`<link rel="stylesheet" href="${Salla.url.cdn("fonts/sallaicons.css")}">`};return t.map(s=>e[s]||"").join("")}}y.makeSureSallaIsReady().then(()=>new Nt).then(()=>window.customElements.get("salla-custom-component")||window.customElements.define("salla-custom-component",Ht));exports.SallaComponent=v;
@@ -284,7 +284,7 @@ v.elementStyles = [], v.shadowRootOptions = { mode: "open" }, v[P("elementProper
284
284
  * Copyright 2017 Google LLC
285
285
  * SPDX-License-Identifier: BSD-3-Clause
286
286
  */
287
- const T = globalThis, D = T.trustedTypes, tt = D ? D.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, lt = "$lit$", $ = `lit$${Math.random().toFixed(9).slice(2)}$`, ht = "?" + $, vt = `<${ht}>`, S = document, x = () => S.createComment(""), U = (n) => n === null || typeof n != "object" && typeof n != "function", Z = Array.isArray, wt = (n) => Z(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", B = `[
287
+ const T = globalThis, D = T.trustedTypes, tt = D ? D.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, lt = "$lit$", $ = `lit$${Math.random().toFixed(9).slice(2)}$`, ht = "?" + $, vt = `<${ht}>`, S = document, M = () => S.createComment(""), U = (n) => n === null || typeof n != "object" && typeof n != "function", Z = Array.isArray, wt = (n) => Z(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", B = `[
288
288
  \f\r]`, C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, et = /-->/g, st = />/g, g = RegExp(`>|${B}(?:([^\\s"'>=/]+)(${B}*=${B}*(?:[^
289
289
  \f\r"'\`<>=]|("|')|))|$)`, "g"), it = /'/g, nt = /"/g, ct = /^(?:script|style|textarea|title)$/i, w = Symbol.for("lit-noChange"), d = Symbol.for("lit-nothing"), ot = /* @__PURE__ */ new WeakMap(), _ = S.createTreeWalker(S, 129);
290
290
  function dt(n, t) {
@@ -317,14 +317,14 @@ class R {
317
317
  if (i.nodeType === 1) {
318
318
  if (i.hasAttributes()) for (const h of i.getAttributeNames()) if (h.endsWith(lt)) {
319
319
  const p = u[o++], m = i.getAttribute(h).split($), H = /([.?@])?(.*)/.exec(p);
320
- a.push({ type: 1, index: r, name: H[2], strings: m, ctor: H[1] === "." ? Ct : H[1] === "?" ? Pt : H[1] === "@" ? Tt : z }), i.removeAttribute(h);
320
+ a.push({ type: 1, index: r, name: H[2], strings: m, ctor: H[1] === "." ? Ct : H[1] === "?" ? Pt : H[1] === "@" ? Tt : j }), i.removeAttribute(h);
321
321
  } else h.startsWith($) && (a.push({ type: 6, index: r }), i.removeAttribute(h));
322
322
  if (ct.test(i.tagName)) {
323
323
  const h = i.textContent.split($), p = h.length - 1;
324
324
  if (p > 0) {
325
325
  i.textContent = D ? D.emptyScript : "";
326
- for (let m = 0; m < p; m++) i.append(h[m], x()), _.nextNode(), a.push({ type: 2, index: ++r });
327
- i.append(h[p], x());
326
+ for (let m = 0; m < p; m++) i.append(h[m], M()), _.nextNode(), a.push({ type: 2, index: ++r });
327
+ i.append(h[p], M());
328
328
  }
329
329
  }
330
330
  } else if (i.nodeType === 8) if (i.data === ht) a.push({ type: 2, index: r });
@@ -364,7 +364,7 @@ class Et {
364
364
  for (; a !== void 0; ) {
365
365
  if (o === a.index) {
366
366
  let c;
367
- a.type === 2 ? c = new O(r, r.nextSibling, this, t) : a.type === 1 ? c = new a.ctor(r, a.name, a.strings, this, t) : a.type === 6 && (c = new Mt(r, this, t)), this._$AV.push(c), a = s[++l];
367
+ a.type === 2 ? c = new O(r, r.nextSibling, this, t) : a.type === 1 ? c = new a.ctor(r, a.name, a.strings, this, t) : a.type === 6 && (c = new xt(r, this, t)), this._$AV.push(c), a = s[++l];
368
368
  }
369
369
  o !== (a == null ? void 0 : a.index) && (r = _.nextNode(), o++);
370
370
  }
@@ -423,7 +423,7 @@ class O {
423
423
  Z(this._$AH) || (this._$AH = [], this._$AR());
424
424
  const e = this._$AH;
425
425
  let s, i = 0;
426
- for (const r of t) i === e.length ? e.push(s = new O(this.O(x()), this.O(x()), this, this.options)) : s = e[i], s._$AI(r), i++;
426
+ for (const r of t) i === e.length ? e.push(s = new O(this.O(M()), this.O(M()), this, this.options)) : s = e[i], s._$AI(r), i++;
427
427
  i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
428
428
  }
429
429
  _$AR(t = this._$AA.nextSibling, e) {
@@ -438,7 +438,7 @@ class O {
438
438
  this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
439
439
  }
440
440
  }
441
- class z {
441
+ class j {
442
442
  get tagName() {
443
443
  return this.element.tagName;
444
444
  }
@@ -463,7 +463,7 @@ class z {
463
463
  t === d ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
464
464
  }
465
465
  }
466
- class Ct extends z {
466
+ class Ct extends j {
467
467
  constructor() {
468
468
  super(...arguments), this.type = 3;
469
469
  }
@@ -471,7 +471,7 @@ class Ct extends z {
471
471
  this.element[this.name] = t === d ? void 0 : t;
472
472
  }
473
473
  }
474
- class Pt extends z {
474
+ class Pt extends j {
475
475
  constructor() {
476
476
  super(...arguments), this.type = 4;
477
477
  }
@@ -479,7 +479,7 @@ class Pt extends z {
479
479
  this.element.toggleAttribute(this.name, !!t && t !== d);
480
480
  }
481
481
  }
482
- class Tt extends z {
482
+ class Tt extends j {
483
483
  constructor(t, e, s, i, r) {
484
484
  super(t, e, s, i, r), this.type = 5;
485
485
  }
@@ -493,7 +493,7 @@ class Tt extends z {
493
493
  typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
494
494
  }
495
495
  }
496
- class Mt {
496
+ class xt {
497
497
  constructor(t, e, s) {
498
498
  this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
499
499
  }
@@ -506,12 +506,12 @@ class Mt {
506
506
  }
507
507
  const q = T.litHtmlPolyfillSupport;
508
508
  q == null || q(R, O), (T.litHtmlVersions ?? (T.litHtmlVersions = [])).push("3.3.1");
509
- const xt = (n, t, e) => {
509
+ const Mt = (n, t, e) => {
510
510
  const s = (e == null ? void 0 : e.renderBefore) ?? t;
511
511
  let i = s._$litPart$;
512
512
  if (i === void 0) {
513
513
  const r = (e == null ? void 0 : e.renderBefore) ?? null;
514
- s._$litPart$ = i = new O(t.insertBefore(x(), r), r, void 0, e ?? {});
514
+ s._$litPart$ = i = new O(t.insertBefore(M(), r), r, void 0, e ?? {});
515
515
  }
516
516
  return i._$AI(n), i;
517
517
  };
@@ -521,7 +521,7 @@ const xt = (n, t, e) => {
521
521
  * SPDX-License-Identifier: BSD-3-Clause
522
522
  */
523
523
  const A = globalThis;
524
- class M extends v {
524
+ class x extends v {
525
525
  constructor() {
526
526
  super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
527
527
  }
@@ -532,7 +532,7 @@ class M extends v {
532
532
  }
533
533
  update(t) {
534
534
  const e = this.render();
535
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = xt(e, this.renderRoot, this.renderOptions);
535
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Mt(e, this.renderRoot, this.renderOptions);
536
536
  }
537
537
  connectedCallback() {
538
538
  var t;
@@ -547,9 +547,9 @@ class M extends v {
547
547
  }
548
548
  }
549
549
  var rt;
550
- M._$litElement$ = !0, M.finalized = !0, (rt = A.litElementHydrateSupport) == null || rt.call(A, { LitElement: M });
550
+ x._$litElement$ = !0, x.finalized = !0, (rt = A.litElementHydrateSupport) == null || rt.call(A, { LitElement: x });
551
551
  const W = A.litElementPolyfillSupport;
552
- W == null || W({ LitElement: M });
552
+ W == null || W({ LitElement: x });
553
553
  (A.litElementVersions ?? (A.litElementVersions = [])).push("4.2.1");
554
554
  /**
555
555
  * @license
@@ -577,7 +577,7 @@ const Ut = { attribute: !0, type: String, converter: k, reflect: !1, hasChanged:
577
577
  }
578
578
  throw Error("Unsupported decorator location: " + s);
579
579
  };
580
- function j(n) {
580
+ function z(n) {
581
581
  return (t, e) => typeof e == "object" ? Rt(n, t, e) : ((s, i, r) => {
582
582
  const o = i.hasOwnProperty(r);
583
583
  return i.constructor.createProperty(r, s), o ? Object.getOwnPropertyDescriptor(i, r) : void 0;
@@ -620,7 +620,7 @@ var Ot = Object.defineProperty, L = (n, t, e, s) => {
620
620
  (o = n[r]) && (i = o(t, e, i) || i);
621
621
  return i && Ot(t, e, i), i;
622
622
  };
623
- const F = class F extends M {
623
+ const F = class F extends x {
624
624
  constructor() {
625
625
  super(...arguments), this.key = "", this.data = {}, this.imports = {}, this.shadowRootMode = "open";
626
626
  }
@@ -638,16 +638,16 @@ const F = class F extends M {
638
638
  F.styles = pt`:host { display: block; }`;
639
639
  let E = F;
640
640
  L([
641
- j()
641
+ z()
642
642
  ], E.prototype, "key");
643
643
  L([
644
- j()
644
+ z()
645
645
  ], E.prototype, "data");
646
646
  L([
647
- j()
647
+ z()
648
648
  ], E.prototype, "imports");
649
649
  L([
650
- j()
650
+ z()
651
651
  ], E.prototype, "shadowRootMode");
652
652
  class Ht extends HTMLElement {
653
653
  connectedCallback() {
@@ -672,13 +672,19 @@ class Nt {
672
672
  this.initialized || (this.initialized = !0);
673
673
  }
674
674
  registerCustomComponents() {
675
- var t;
676
- HTMLElement.registerSallaComponent = function(e) {
677
- Salla.bundles.registerComponent(e, {
675
+ HTMLElement.registerSallaComponent = function(t) {
676
+ Salla.bundles.registerComponent(t, {
678
677
  component: this,
679
- dynamicTagName: `${e}-${Math.random().toString(36).substring(2, 8)}`
678
+ dynamicTagName: `${t}-${Math.random().toString(36).substring(2, 8)}`
680
679
  });
681
- }, (t = window.customComponents) == null || t.forEach((e) => {
680
+ }, this.injectBundleScript(window.customComponents);
681
+ }
682
+ injectBundleScript(t) {
683
+ t.forEach((e) => {
684
+ if (document.querySelector(`script[src="${e}"]`)) {
685
+ Salla.log("Script already exists", e);
686
+ return;
687
+ }
682
688
  const s = document.createElement("script");
683
689
  s.type = "module", s.src = e, document.head.appendChild(s);
684
690
  });
@@ -688,9 +694,13 @@ class Nt {
688
694
  * and replaces it with the actual component
689
695
  */
690
696
  renderCustomComponentDom(t, e) {
691
- salla.log("Rendering custom component", t), e.getAttribute("component-name");
697
+ Salla.log("Rendering custom component", t);
692
698
  const s = this.components.get(t);
693
- return s ? this.renderDynamicCustomComponentDom(s.dynamicTagName, e) : this.pendingComponents.push({ tagName: t, component: e });
699
+ if (s)
700
+ return this.renderDynamicCustomComponentDom(s.dynamicTagName, e);
701
+ this.pendingComponents.push({ tagName: t, component: e });
702
+ const i = e.getAttribute("assets");
703
+ i && this.injectBundleScript(i.split(","));
694
704
  }
695
705
  renderDynamicCustomComponentDom(t, e) {
696
706
  const s = document.createElement(t);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-bundles",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "SDK for Salla Twilight Bundles - Develop and build custom components for Salla platform",
5
5
  "type": "module",
6
6
  "main": "./dist/twilight-bundles.js",