@useinsider/guido 3.4.1-beta.ea1fec9 → 3.4.1-beta.eea26a5

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,33 +1,35 @@
1
- import { useStripoApi as i } from "../services/stripoApi.js";
1
+ import { useStripoApi as c } from "../services/stripoApi.js";
2
2
  import { useEditorStore as u } from "../stores/editor.js";
3
3
  import { useOnboardingStore as l } from "../stores/onboarding.js";
4
4
  import { useUnsubscribeStore as b } from "../stores/unsubscribe.js";
5
5
  const v = () => {
6
- const { updateSyncModule: d, getSyncModule: r } = i(), n = u(), s = b(), a = {
6
+ const { updateSyncModule: r, getSyncModule: a } = c(), t = u(), s = b(), i = {
7
7
  block_dropped: ({ blockName: e }) => {
8
8
  if (e === "BLOCK_TEXT") {
9
- const o = l(), t = !o.shouldShowOnboarding("textBlockOnboarding"), c = o.isActive("textBlockOnboarding");
10
- if (t || c)
9
+ const o = l(), n = !o.shouldShowOnboarding("textBlockOnboarding"), d = o.isActive("textBlockOnboarding");
10
+ if (n || d)
11
11
  return;
12
12
  o.start("textBlockOnboarding");
13
13
  }
14
14
  },
15
15
  module_saved: async (e) => {
16
- n.syncModulesEnabled && (console.debug("[module_saved] Saved module data:", e), await d(e));
16
+ t.syncModulesEnabled && (console.debug("[module_saved] Saved module data:", e), await r(e));
17
17
  },
18
18
  module_dropped: async (e) => {
19
- if (!n.syncModulesEnabled)
19
+ if (!t.syncModulesEnabled)
20
20
  return;
21
- const { moduleId: o } = e, t = await r(o);
22
- console.debug("[module_dropped] Sync module data:", t), t.unsubscriptionPreferencePages.length && await s.fetchTemplates();
21
+ const { moduleId: o } = e, n = await a(o);
22
+ console.debug("[module_dropped] Sync module data:", n), n.unsubscriptionPreferencePages.length && (await s.fetchTemplates(), s.addUnsubscribePages(
23
+ n.unsubscriptionPreferencePages.map((d) => d.id)
24
+ ));
23
25
  },
24
26
  module_updated: async (e) => {
25
- n.syncModulesEnabled && (console.debug("[module_updated] Updated module data:", e), await d(e));
27
+ t.syncModulesEnabled && (console.debug("[module_updated] Updated module data:", e), await r(e));
26
28
  }
27
29
  };
28
30
  return { handleEvent: async (e, o) => {
29
- const t = a[e];
30
- console.debug("Stripo Event: ", e, o), t && await t(o);
31
+ const n = i[e];
32
+ console.debug("Stripo Event: ", e, o), n && await n(o);
31
33
  } };
32
34
  };
33
35
  export {
@@ -1,91 +1,85 @@
1
- var f = Object.defineProperty;
2
- var I = (o, t, e) => t in o ? f(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var T = (o, t, e) => I(o, typeof t != "symbol" ? t + "" : t, e);
4
- import y from "../../extensions/Blocks/Checkbox/template.js";
5
- const _ = /font-weight\s*:\s*[^;]*;?/gi, x = /font-style\s*:\s*[^;]*;?/gi, b = /;\s*;/g, d = /^;|;$/g, S = /display\s*:\s*inline/gi, A = /display\s*:/i, L = /font-weight\s*:\s*bold/i, R = /font-style\s*:\s*italic/i, $ = /^<(?:strong|b)\b/i, k = /^<(?:em|i)\b/i;
6
- class O {
1
+ var x = Object.defineProperty;
2
+ var y = (s, t, e) => t in s ? x(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var m = (s, t, e) => y(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import b from "../../extensions/Blocks/Checkbox/template.js";
5
+ class f {
7
6
  constructor() {
8
- T(this, "parser");
7
+ m(this, "parser");
9
8
  this.parser = new DOMParser();
10
9
  }
11
10
  migrate(t) {
12
11
  try {
13
- const e = this.parser.parseFromString(t, "text/html"), l = e.querySelectorAll("td.checkbox-block");
14
- if (l.length === 0)
15
- return t;
16
- let s = !1;
17
- return l.forEach((r) => {
12
+ const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
13
+ return i.length === 0 ? t : (i.forEach((r) => {
18
14
  if (r.classList.contains("checkbox-block-v2"))
19
15
  return;
20
- const i = r.getAttribute("id"), n = this.extractTextFromElement(r, "ins-title"), m = this.extractTextFromElement(r, "ins-description"), c = this.buildTextBlock(n), a = this.buildTextBlock(m), p = y.replace("{-{-TITLE-}-}", c).replace("{-{-DESCRIPTION-}-}", a), u = this.parser.parseFromString(
21
- `<table id="tempDoc"><tbody><tr>${p}</tr></tbody></table>`,
16
+ const n = r.getAttribute("id"), l = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.buildTextBlock(l), p = this.buildTextBlock(c), g = b.replace("{-{-TITLE-}-}", a).replace("{-{-DESCRIPTION-}-}", p), o = this.parser.parseFromString(
17
+ `<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
22
18
  "text/html"
23
19
  ).querySelector(".checkbox-block-v2");
24
- u && r.parentNode && (u.setAttribute("id", i || ""), r.parentNode.replaceChild(u, r), s = !0);
25
- }), s ? e.documentElement.outerHTML : t;
20
+ o && r.parentNode && (o.setAttribute("id", n || ""), r.parentNode.replaceChild(o, r));
21
+ }), e.documentElement.outerHTML);
26
22
  } catch (e) {
27
23
  return console.error("CheckboxMigrator failed:", e), t;
28
24
  }
29
25
  }
30
26
  extractTextFromElement(t, e) {
31
- var c, a;
32
- const l = e === "ins-title" ? "Title" : "Description", s = t.querySelector(`.${e}`);
33
- if (!s)
27
+ var o, d;
28
+ const i = t.querySelector(`.${e}`);
29
+ if (!i)
34
30
  return {
35
- paragraphs: [{ innerHtml: l, isBold: !1, isItalic: !1, styles: "" }],
31
+ text: e === "ins-title" ? "Title" : "Description",
32
+ isBold: !1,
33
+ isItalic: !1,
36
34
  align: "left",
37
- classList: ""
35
+ styles: ""
38
36
  };
39
- const r = Array.from(s.querySelectorAll("p")), i = s.getAttribute("align") || ((c = r[0]) == null ? void 0 : c.getAttribute("align")) || "left", n = s.getAttribute("class") || "";
40
- return r.length === 0 ? {
41
- paragraphs: [{
42
- innerHtml: ((a = s.textContent) == null ? void 0 : a.trim()) || l,
37
+ const r = i.querySelector("p");
38
+ if (!r)
39
+ return {
40
+ text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
43
41
  isBold: !1,
44
42
  isItalic: !1,
43
+ align: i.getAttribute("align") || "left",
45
44
  styles: ""
46
- }],
47
- align: i,
48
- classList: ""
49
- } : { paragraphs: r.map((p) => {
50
- const g = p.getAttribute("style") || "", u = L.test(g) || !!p.querySelector("b, strong"), h = R.test(g) || !!p.querySelector("i, em"), E = this.removeFontEmphasisProperties(g);
51
- return {
52
- // Legacy parity: empty <p> → fallback placeholder; <p><br></p> is not empty.
53
- innerHtml: p.innerHTML.trim() || l,
54
- isBold: u,
55
- isItalic: h,
56
- styles: this.convertInlineToBlock(E)
57
45
  };
58
- }), align: i, classList: n };
46
+ const n = ((d = r.textContent) == null ? void 0 : d.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), u = this.convertInlineToBlock(g);
47
+ return {
48
+ text: n,
49
+ isBold: a,
50
+ isItalic: p,
51
+ align: c,
52
+ styles: u
53
+ };
59
54
  }
60
55
  buildTextBlock(t) {
61
- const e = t.align ? ` align="${t.align}"` : "", l = t.paragraphs.map((s, r) => {
62
- const i = r + 1;
63
- let n = s.innerHtml;
64
- const m = s.isBold && !$.test(n), c = s.isItalic && !k.test(n);
65
- m && c ? n = `<strong path="${i},0"><em path="${i},0,0">${n}</em></strong>` : m ? n = `<strong path="${i},0">${n}</strong>` : c && (n = `<em path="${i},0">${n}</em>`);
66
- const a = s.styles ? ` style="${s.styles.replaceAll('"', "'")}"` : "";
67
- return `<p path="${i}"${a}>${n}</p>`;
68
- }).join(`
69
- `);
56
+ let e = t.text;
57
+ t.isBold && t.isItalic ? e = `<strong path="1,0"><em path="1,0,0">${e}</em></strong>` : t.isBold ? e = `<strong path="1,0">${e}</strong>` : t.isItalic && (e = `<em path="1,0">${e}</em>`);
58
+ const i = t.align ? ` align="${t.align}"` : "", r = t.styles ? ` style="${t.styles}"` : "";
70
59
  return `
71
- <td class="esd-block-text ${t.classList}" ${e}>
72
- ${l}
60
+ <td class="esd-block-text" ${i}>
61
+ <p path="1" ${r}>
62
+ ${e}
63
+ </p>
73
64
  </td>
74
65
  `;
75
66
  }
76
- removeFontEmphasisProperties(t) {
77
- return t ? t.replace(_, "").replace(x, "").replace(b, ";").replace(d, "").trim() : "";
67
+ removeStyleProperties(t, e) {
68
+ return t ? e.reduce((r, n) => {
69
+ const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
70
+ return r.replace(l, "");
71
+ }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
78
72
  }
79
73
  convertInlineToBlock(t) {
80
74
  if (!t)
81
75
  return "";
82
- let e = t.replace(S, "display: block");
83
- return A.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(b, ";").replace(d, "").trim();
76
+ let e = t.replace(/display\s*:\s*inline/gi, "display: block");
77
+ return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
84
78
  }
85
79
  }
86
- function N(o) {
87
- return new O().migrate(o);
80
+ function k(s) {
81
+ return new f().migrate(s);
88
82
  }
89
83
  export {
90
- N as migrateCheckbox
84
+ k as migrateCheckbox
91
85
  };
@@ -1,109 +1,109 @@
1
- var S = Object.defineProperty;
2
- var I = (p, t, e) => t in p ? S(p, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[t] = e;
3
- var y = (p, t, e) => I(p, typeof t != "symbol" ? t + "" : t, e);
4
- import R from "../../extensions/Blocks/RadioButton/template.js";
5
- const L = /font-weight\s*:\s*[^;]*;?/gi, _ = /font-style\s*:\s*[^;]*;?/gi, f = /;\s*;/g, E = /^;|;$/g, x = /display\s*:\s*inline/gi, A = /display\s*:/i, B = /font-weight\s*:\s*bold/i, $ = /font-style\s*:\s*italic/i, N = /^<(?:strong|b)\b/i, O = /^<(?:em|i)\b/i;
6
- class H {
1
+ var x = Object.defineProperty;
2
+ var T = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var b = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
+ import S from "../../extensions/Blocks/RadioButton/template.js";
5
+ class B {
7
6
  constructor() {
8
- y(this, "parser");
7
+ b(this, "parser");
9
8
  this.parser = new DOMParser();
10
9
  }
11
- migrate(t) {
10
+ migrate(e) {
12
11
  try {
13
- const e = this.parser.parseFromString(t, "text/html"), o = e.querySelectorAll("td.radio-button-block"), n = e.querySelectorAll("td.radio-button-v2");
14
- if (o.length === 0 && n.length === 0)
15
- return t;
16
- let i = !1;
17
- return o.forEach((r) => {
12
+ const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.radio-button-block"), i = t.querySelectorAll("td.radio-button-v2");
13
+ if (s.length === 0 && i.length === 0)
14
+ return e;
15
+ let o = !1;
16
+ return s.forEach((r) => {
18
17
  if (r.classList.contains("radio-button-v2"))
19
18
  return;
20
- const s = r.getAttribute("id"), c = this.extractTextFromElement(r, "ins-title"), u = this.extractTextFromElement(r, "ins-description"), l = this.extractTextFromElement(r, "ins-subscribe"), a = this.extractTextFromElement(r, "ins-unsubscribe"), d = this.buildTextBlock(c), m = this.buildTextBlock(u), T = this.buildTextBlock({ ...l, classList: "" }), b = this.buildTextBlock({ ...a, classList: "" }), h = R.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", T).replace("{-{-NO-}-}", b), g = this.parser.parseFromString(
19
+ const n = r.getAttribute("id"), a = this.extractTextFromElement(r, "ins-title"), g = this.extractTextFromElement(r, "ins-description"), c = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), p = this.buildTextBlock(a), d = this.buildTextBlock(g), y = this.buildTextBlock({ ...c, classList: "" }), f = this.buildTextBlock({ ...u, classList: "" }), h = S.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", y).replace("{-{-NO-}-}", f), m = this.parser.parseFromString(
21
20
  `<table id="tempDoc"><tbody><tr>${h}</tr></tbody></table>`,
22
21
  "text/html"
23
22
  ).querySelector(".radio-button-v2");
24
- g && r.parentNode && (g.setAttribute("id", s || ""), r.parentNode.replaceChild(g, r), i = !0);
25
- }), i = this.healRadioButtonV2(e) || i, i ? e.documentElement.outerHTML : t;
26
- } catch (e) {
27
- return console.error("RadioButtonMigrator failed:", e), t;
23
+ m && r.parentNode && (m.setAttribute("id", n || ""), r.parentNode.replaceChild(m, r), o = !0);
24
+ }), o = this.healRadioButtonV2(t) || o, o ? t.documentElement.outerHTML : e;
25
+ } catch (t) {
26
+ return console.error("RadioButtonMigrator failed:", t), e;
28
27
  }
29
28
  }
30
- healRadioButtonV2(t) {
31
- let e = !1;
32
- return t.querySelectorAll("td.radio-button-v2").forEach((o) => {
33
- var m;
34
- o.classList.contains("radio-button-block") || (o.classList.add("radio-button-block"), e = !0);
35
- const n = o.querySelector("input#radioYes"), i = o.querySelector("input#radioNo");
36
- if (!n || !i)
29
+ healRadioButtonV2(e) {
30
+ let t = !1;
31
+ return e.querySelectorAll("td.radio-button-v2").forEach((s) => {
32
+ var d;
33
+ s.classList.contains("radio-button-block") || (s.classList.add("radio-button-block"), t = !0);
34
+ const i = s.querySelector("input#radioYes"), o = s.querySelector("input#radioNo");
35
+ if (!i || !o)
37
36
  return;
38
- const r = ((m = n.parentElement) == null ? void 0 : m.querySelector(":scope > p")) || null;
39
- if (!r && !n.hasAttribute("align"))
37
+ const r = ((d = i.parentElement) == null ? void 0 : d.querySelector(":scope > p")) || null;
38
+ if (!r && !i.hasAttribute("align"))
40
39
  return;
41
- const s = n.closest("tr"), c = i.closest("tr");
42
- if (!s || !c || s === c || !s.parentNode)
40
+ const n = i.closest("tr"), a = o.closest("tr");
41
+ if (!n || !a || n === a || !n.parentNode)
43
42
  return;
44
- const u = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", l = c.cloneNode(!0), a = l.querySelector("input#radioNo"), d = l.querySelector("p");
45
- a && (a.setAttribute("id", "radioYes"), a.removeAttribute("align")), d && (d.innerHTML = u), s.parentNode.replaceChild(l, s), e = !0;
46
- }), e;
43
+ const g = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", c = a.cloneNode(!0), u = c.querySelector("input#radioNo"), p = c.querySelector("p");
44
+ u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), p && (p.innerHTML = g), n.parentNode.replaceChild(c, n), t = !0;
45
+ }), t;
47
46
  }
48
- extractTextFromElement(t, e) {
49
- var u, l;
50
- const o = e === "ins-title" ? "Title" : "Description", n = t.querySelector(`.${e}`);
51
- if (!n)
47
+ extractTextFromElement(e, t) {
48
+ var d, y;
49
+ const s = e.querySelector(`.${t}`);
50
+ if (!s)
52
51
  return {
53
- paragraphs: [{ innerHtml: o, isBold: !1, isItalic: !1, styles: "" }],
52
+ text: t === "ins-title" ? "Title" : "Description",
53
+ isBold: !1,
54
+ isItalic: !1,
54
55
  align: "left",
56
+ styles: "",
55
57
  classList: ""
56
58
  };
57
- const i = Array.from(n.querySelectorAll("p")), r = n.getAttribute("align") || ((u = i[0]) == null ? void 0 : u.getAttribute("align")) || "left", s = n.getAttribute("class") || "";
58
- return i.length === 0 ? {
59
- paragraphs: [{
60
- innerHtml: ((l = n.textContent) == null ? void 0 : l.trim()) || o,
59
+ const i = s.querySelector("p");
60
+ if (!i)
61
+ return {
62
+ text: ((d = s.textContent) == null ? void 0 : d.trim()) || (t === "ins-title" ? "Title" : "Description"),
61
63
  isBold: !1,
62
64
  isItalic: !1,
63
- styles: ""
64
- }],
65
- align: r,
66
- classList: ""
67
- } : { paragraphs: i.map((a) => {
68
- const d = a.getAttribute("style") || "", m = B.test(d) || !!a.querySelector("b, strong"), T = $.test(d) || !!a.querySelector("i, em"), b = this.removeFontEmphasisProperties(d);
69
- return {
70
- // Legacy parity: empty <p> → fallback placeholder; <p><br></p> is not empty.
71
- innerHtml: a.innerHTML.trim() || o,
72
- isBold: m,
73
- isItalic: T,
74
- styles: this.convertInlineToBlock(b)
65
+ align: s.getAttribute("align") || "left",
66
+ styles: "",
67
+ classList: ""
75
68
  };
76
- }), align: r, classList: s };
69
+ const o = ((y = i.textContent) == null ? void 0 : y.trim()) || (t === "ins-title" ? "Title" : "Description"), r = i.getAttribute("style") || "", n = s.getAttribute("align") || i.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(r) || !!i.querySelector("b, strong"), g = /font-style\s*:\s*italic/i.test(r) || !!i.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(c), p = s.getAttribute("class") || "";
70
+ return {
71
+ text: o,
72
+ isBold: a,
73
+ isItalic: g,
74
+ align: n,
75
+ styles: u,
76
+ classList: p
77
+ };
77
78
  }
78
- buildTextBlock(t) {
79
- const e = t.align ? ` align="${t.align}"` : "", o = t.paragraphs.map((n, i) => {
80
- const r = i + 1;
81
- let s = n.innerHtml;
82
- const c = n.isBold && !N.test(s), u = n.isItalic && !O.test(s);
83
- c && u ? s = `<strong path="${r},0"><em path="${r},0,0">${s}</em></strong>` : c ? s = `<strong path="${r},0">${s}</strong>` : u && (s = `<em path="${r},0">${s}</em>`);
84
- const l = n.styles ? ` style="${n.styles.replaceAll('"', "'")}"` : "";
85
- return `<p path="${r}"${l}>${s}</p>`;
86
- }).join(`
87
- `);
79
+ buildTextBlock(e) {
80
+ let t = e.text;
81
+ e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
82
+ const s = e.align ? ` align="${e.align}"` : "", i = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
88
83
  return `
89
- <td class="esd-block-text ${t.classList}" ${e}>
90
- ${o}
84
+ <td class="esd-block-text ${e.classList}" ${s}>
85
+ <p path="1" ${i}>
86
+ ${t}
87
+ </p>
91
88
  </td>
92
89
  `;
93
90
  }
94
- removeFontEmphasisProperties(t) {
95
- return t ? t.replace(L, "").replace(_, "").replace(f, ";").replace(E, "").trim() : "";
91
+ removeStyleProperties(e, t) {
92
+ return e ? t.reduce((i, o) => {
93
+ const r = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
94
+ return i.replace(r, "");
95
+ }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
96
96
  }
97
- convertInlineToBlock(t) {
98
- if (!t)
97
+ convertInlineToBlock(e) {
98
+ if (!e)
99
99
  return "";
100
- let e = t.replace(x, "display: block");
101
- return A.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(f, ";").replace(E, "").trim();
100
+ let t = e.replace(/display\s*:\s*inline/gi, "display: block");
101
+ return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
102
102
  }
103
103
  }
104
- function C(p) {
105
- return new H().migrate(p);
104
+ function L(l) {
105
+ return new B().migrate(l);
106
106
  }
107
107
  export {
108
- C as migrateRadioButton
108
+ L as migrateRadioButton
109
109
  };
@@ -1,87 +1,79 @@
1
- import { useActionsApi as C } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { useActionsApi as T } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as C } from "../composables/useHtmlCompiler.js";
3
+ import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
9
- function E(i, o) {
10
- const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
11
- return t.forEach((r) => {
12
- const a = r.getAttribute(S.PAGE_LIST);
13
- a && c.push(...D(a));
14
- }), o.filter((r) => c.includes(r));
5
+ import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as P } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as D } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as E } from "../stores/unsubscribe.js";
9
+ function U(i, r) {
10
+ const s = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), c = [];
11
+ return s.forEach((t) => {
12
+ const o = t.getAttribute(y.PAGE_LIST);
13
+ o && c.push(...P(o));
14
+ }), r.filter((t) => c.includes(t));
15
15
  }
16
- async function U(i) {
16
+ function F(i) {
17
17
  const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
18
18
  if (m.length === 0)
19
19
  return;
20
- const l = b();
21
- m.forEach((t) => {
22
- var g, f, u, n, y;
23
- const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
24
- if (!Number.isFinite(r))
20
+ const d = b();
21
+ m.forEach((s) => {
22
+ var g, f, u, n, S;
23
+ const c = s.getAttribute("recommendation-id"), t = c ? Number(c) : NaN;
24
+ if (!Number.isFinite(t))
25
25
  return;
26
- const a = t.getAttribute("esd-ext-config");
27
- if (!a)
26
+ const o = s.getAttribute("esd-ext-config");
27
+ if (!o)
28
28
  return;
29
29
  let e;
30
30
  try {
31
- e = JSON.parse(a);
31
+ e = JSON.parse(o);
32
32
  } catch {
33
33
  return;
34
34
  }
35
35
  if (!e || typeof e != "object" || Array.isArray(e))
36
36
  return;
37
37
  const p = {
38
- strategy: e.strategy ?? s.strategy,
39
- language: e.language ?? s.language,
40
- size: e.size ?? s.size,
38
+ strategy: e.strategy ?? a.strategy,
39
+ language: e.language ?? a.language,
40
+ size: e.size ?? a.size,
41
41
  // Spread the default arrays so each block gets a fresh reference
42
42
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...s.productIds],
44
- filters: e.filters ?? [...s.filters],
45
- shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
46
- currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
47
- currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
48
- currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
49
- currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
50
- currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
43
+ productIds: e.productIds ?? [...a.productIds],
44
+ filters: e.filters ?? [...a.filters],
45
+ shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
46
+ currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? l.code,
47
+ currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? l.alignment,
48
+ currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? l.decimalCount,
49
+ currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? l.decimalSeparator,
50
+ currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? l.thousandSeparator
51
51
  };
52
- l.seedBlockUrlConfig(r, p);
52
+ d.seedBlockUrlConfig(t, p);
53
53
  });
54
- try {
55
- await l.fetchRecommendationCreateData();
56
- } catch (t) {
57
- console.warn(
58
- "Recommendation reference data pre-load failed; validator will skip the availability check.",
59
- t
60
- );
61
- }
62
54
  }
63
55
  const _ = () => {
64
- const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
56
+ const i = D(), r = E(), { getCompiledEmail: m, getTemplateData: d } = T(), { compileHtml: s } = C();
65
57
  return {
66
58
  prepareTemplateDetails: async () => {
67
- const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
59
+ const { html: t, ampHtml: o = "", ampErrors: e = [] } = await m({
68
60
  minimize: !0,
69
61
  resetDataSavedFlag: !1
70
- }), { html: p, css: g, syncModulesIds: f = [] } = await l();
71
- o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
72
- const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
62
+ }), { html: p, css: g, syncModulesIds: f = [] } = await d();
63
+ r.selectedUnsubscribePages.length && await r.fetchTemplates(), F(p);
64
+ const { compiledHtml: u, stats: n, appliedRules: S } = s(t), h = i.getSelectedDynamicContentList, A = b();
73
65
  return console.debug("HTML Compilation Stats:", {
74
66
  originalSize: n.originalSize,
75
67
  compiledSize: n.compiledSize,
76
68
  reduction: `${n.reductionPercentage.toFixed(2)}%`,
77
- appliedRules: y,
69
+ appliedRules: S,
78
70
  executionTime: `${n.executionTime.toFixed(2)}ms`
79
71
  }), {
80
72
  dynamicContentList: h,
81
73
  compiledHtml: u,
82
74
  rawHtml: p,
83
75
  css: g,
84
- ampHtml: a,
76
+ ampHtml: o,
85
77
  ampErrors: e,
86
78
  modules: f.map(Number),
87
79
  recommendation: {
@@ -89,8 +81,8 @@ const _ = () => {
89
81
  configs: {}
90
82
  },
91
83
  unsubscribe: {
92
- status: o.unsubscribePagesStatus,
93
- config: E(u, o.selectedUnsubscribePages)
84
+ status: r.unsubscribePagesStatus,
85
+ config: U(u, r.selectedUnsubscribePages)
94
86
  }
95
87
  };
96
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.4.1-beta.ea1fec9",
3
+ "version": "3.4.1-beta.eea26a5",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",