@useinsider/guido 3.21.2 → 3.22.0-beta.0951deb

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.
Files changed (71) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +41 -39
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +6 -6
  5. package/dist/components/Guido.vue2.js +81 -79
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
  8. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  14. package/dist/composables/useActionsApi.js +22 -21
  15. package/dist/composables/useBlocksConfig.js +32 -24
  16. package/dist/composables/useDisplayConditions.js +102 -0
  17. package/dist/composables/useFullStoryBridge.js +10 -9
  18. package/dist/composables/useSave.js +75 -68
  19. package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
  20. package/dist/config/migrator/fullStoryScriptMigrator.js +5 -0
  21. package/dist/config/migrator/index.js +11 -10
  22. package/dist/enums/academy.js +1 -0
  23. package/dist/enums/display-condition.js +12 -0
  24. package/dist/extensions/DisplayConditions/bridge.js +17 -0
  25. package/dist/extensions/DisplayConditions/constants.js +17 -0
  26. package/dist/extensions/DisplayConditions/control.js +178 -0
  27. package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
  28. package/dist/extensions/DisplayConditions/extension.js +28 -0
  29. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  30. package/dist/extensions/DisplayConditions/library.js +27 -0
  31. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  32. package/dist/guido.css +1 -1
  33. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  34. package/dist/node_modules/valibot/dist/index.js +297 -261
  35. package/dist/services/displayConditionApi.js +39 -0
  36. package/dist/services/templateLibraryApi.js +36 -31
  37. package/dist/src/@types/config/schemas.d.ts +4 -0
  38. package/dist/src/@types/display-condition.d.ts +59 -0
  39. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  40. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
  41. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  42. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  43. package/dist/src/composables/useConfig.d.ts +2 -0
  44. package/dist/src/composables/useDisplayConditions.d.ts +16 -0
  45. package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
  46. package/dist/src/config/migrator/fullStoryScriptMigrator.d.ts +1 -0
  47. package/dist/src/enums/academy.d.ts +1 -0
  48. package/dist/src/enums/display-condition.d.ts +15 -0
  49. package/dist/src/extensions/DisplayConditions/bridge.d.ts +6 -0
  50. package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
  51. package/dist/src/extensions/DisplayConditions/control.d.ts +23 -0
  52. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  53. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  54. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  55. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  56. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  57. package/dist/src/services/displayConditionApi.d.ts +8 -0
  58. package/dist/src/stores/config.d.ts +166 -0
  59. package/dist/src/stores/display-condition.d.ts +81 -0
  60. package/dist/src/utils/displayCondition.d.ts +10 -0
  61. package/dist/src/utils/fullStoryScripts.d.ts +6 -0
  62. package/dist/src/utils/protectTableText.d.ts +2 -0
  63. package/dist/src/utils/templatePreparation.d.ts +2 -1
  64. package/dist/stores/config.js +13 -6
  65. package/dist/stores/display-condition.js +28 -0
  66. package/dist/utils/displayCondition.js +26 -0
  67. package/dist/utils/fullStoryScripts.js +8 -0
  68. package/dist/utils/pairProductVariables.js +99 -90
  69. package/dist/utils/protectTableText.js +22 -0
  70. package/dist/utils/templatePreparation.js +30 -30
  71. package/package.json +1 -1
@@ -1,100 +1,109 @@
1
- import { ITEMS_CURRENCY_ATTR as x, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
2
- import { productPairs as w } from "../extensions/Blocks/Items/enums/productEnums.js";
3
- import { escapeReplacement as X } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
- import { preserveTextStyles as P } from "./preserveTextStyles.js";
5
- import { unwrapProductNameLinks as v } from "./unwrapProductNameLink.js";
6
- const O = {
1
+ import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
2
+ import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
3
+ import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
+ import { preserveTextStyles as L } from "./preserveTextStyles.js";
5
+ import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
6
+ import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
7
+ const q = {
7
8
  CART_ITEMS: "ins_apr",
8
9
  BROWSED_ITEMS: "browsed_item",
9
10
  PURCHASED_ITEMS: "purchased_item"
10
- }, q = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
- function B(S, y, b) {
12
- let h = y;
13
- for (; h > 0 && /\s/.test(S[h - 1]); )
14
- h -= 1;
15
- return b.some((I) => S.endsWith(I, h));
11
+ }, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
12
+ function Q($, C, A) {
13
+ let d = C;
14
+ for (; d > 0 && /\s/.test($[d - 1]); )
15
+ d -= 1;
16
+ return A.some((E) => $.endsWith(E, d));
16
17
  }
17
- function Z(S) {
18
- const y = q(S), b = new DOMParser().parseFromString(y, "text/html");
19
- v(b);
20
- const h = w.PAIRS_FOR_EXTENSION;
21
- Object.entries(h).forEach(([n, d]) => {
22
- b.querySelectorAll(".ins-product-td").forEach((r) => {
23
- const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
24
- r.querySelectorAll(`[product-attr="${n}"]`).forEach((t) => {
25
- var $, F, D, N;
26
- const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, f = d[g];
18
+ const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
19
+ function J($, C) {
20
+ var d;
21
+ const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
22
+ for (let E = A.nextNode(); E; E = A.nextNode())
23
+ (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
24
+ }
25
+ function ot($) {
26
+ const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
27
+ j(A);
28
+ const d = M.PAIRS_FOR_EXTENSION;
29
+ Object.entries(d).forEach(([o, p]) => {
30
+ A.querySelectorAll(".ins-product-td").forEach((r) => {
31
+ const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
32
+ r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
33
+ var b, I, D, O;
34
+ const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
27
35
  if (f)
28
- switch (n) {
36
+ switch (o) {
29
37
  case "imageSrc": {
30
- let e = null, a = null;
31
- if (t.tagName === "IMG" ? (e = t, a = e.closest("a")) : (e = t.querySelector("img"), a = t.querySelector("a") || t.closest("a")), !e)
38
+ let e = null, s = null;
39
+ if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
32
40
  break;
33
41
  const l = f.DEFAULT, c = f.ATTR;
34
42
  if (l && e.src) {
35
- const s = e.src;
36
- l.some((R) => {
37
- const u = R.split("/").pop() || "", H = s.split("/").pop() || "";
38
- return s.includes(R) || s.includes(u) || H === u;
39
- }) && (e.src = `{{${c}_${o}}}`);
43
+ const a = e.src;
44
+ l.some((g) => {
45
+ const u = g.split("/").pop() || "", H = a.split("/").pop() || "";
46
+ return a.includes(g) || a.includes(u) || H === u;
47
+ }) && (e.src = `{{${c}_${n}}}`);
40
48
  }
41
- const i = (F = ($ = h.name) == null ? void 0 : $[g]) == null ? void 0 : F.ATTR;
42
- if (i && e.setAttribute("alt", `{{${i}_${o}}}`), a) {
43
- const s = (D = h.itemLink) == null ? void 0 : D[g];
44
- if (s) {
45
- const _ = s.HREF, R = s.DEFAULT_HREF || "#!", u = a.href;
46
- (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(R) || u === `${window.location.href}${R}` || !u || u === window.location.href) && (a.href = `{{${_}_${o}}}`);
49
+ const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
50
+ if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
51
+ const a = (D = d.itemLink) == null ? void 0 : D[m];
52
+ if (a) {
53
+ const S = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
54
+ (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${S}_${n}}}`);
47
55
  }
48
56
  }
49
57
  break;
50
58
  }
51
59
  case "name": {
52
- const e = f, a = e.ATTR, l = e.DEFAULT_HREF || "#!", c = e.HREF;
53
- t.textContent && (t.innerHTML = P(t, `{{${a}_${o}}}`));
60
+ const e = f, s = e.ATTR, l = e.DEFAULT_HREF || "#!", c = e.HREF;
61
+ t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
54
62
  const i = t.closest("a") || (t.tagName === "A" ? t : null);
55
63
  if (i && c) {
56
- const s = i.href, _ = `${window.location.href}${l}`;
57
- (s === _ || s.endsWith(l)) && (i.href = `{{${c}_${o}}}`);
64
+ const a = i.href, S = `${window.location.href}${l}`;
65
+ (a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
58
66
  }
59
67
  break;
60
68
  }
61
69
  case "price":
62
70
  case "originalPrice": {
63
- const e = f, a = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = a === "true", i = l === "true", s = t.getAttribute(x.POSITION) || "before";
64
- let _;
65
- i ? _ = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : _ = c ? e.PRICE_FORMATTED : e.PRICE;
66
- const R = e.CURRENCY;
67
- let u = `{{${_}_${o}}}`;
68
- const H = (t.getAttribute(x.SYMBOL) || "").trim(), G = Y(H);
69
- let C = "";
70
- G ? C = H : R && (C = `{{${R}_${o}}}`), C && (u = s === "after" ? `${u} ${C}` : `${C} ${u}`), t.innerHTML = P(t, u);
71
+ const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
72
+ let S;
73
+ i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
74
+ const g = e.CURRENCY;
75
+ let u = `{{${S}_${n}}}`;
76
+ const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
77
+ let F = "";
78
+ G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
71
79
  break;
72
80
  }
73
81
  case "quantity": {
74
- const e = f, a = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (N = t.textContent) == null ? void 0 : N.trim();
75
- c && l.includes(c) && (t.innerHTML = P(t, `{{${a}_${o}}}`));
82
+ const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
83
+ c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
76
84
  break;
77
85
  }
78
86
  case "button": {
79
- const e = f, a = e.HREF, l = e.DEFAULT_HREF || "#!", c = t.tagName === "A" ? t : t.querySelector("a");
87
+ const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t.tagName === "A" ? t : t.querySelector("a");
80
88
  if (c) {
81
- const i = c.href || "", s = `${window.location.href}${l}`;
82
- (i === "" || i === "#" || i === s || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${a}_${o}}}`);
89
+ const i = c.href || "", a = `${window.location.href}${l}`;
90
+ (i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
83
91
  }
92
+ J(t, `{{${s}_${n}}}`);
84
93
  break;
85
94
  }
86
95
  case "itemLink": {
87
- const e = f, a = e.HREF, l = e.DEFAULT_HREF || "#!", c = t;
96
+ const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t;
88
97
  if (c.href) {
89
- const i = c.href, s = `${window.location.href}${l}`;
90
- (i === s || i.endsWith(l)) && (c.href = `{{${a}_${o}}}`);
98
+ const i = c.href, a = `${window.location.href}${l}`;
99
+ (i === a || i.endsWith(l)) && (c.href = `{{${s}_${n}}}`);
91
100
  }
92
101
  break;
93
102
  }
94
103
  default: {
95
104
  if ("ATTR" in f) {
96
105
  const e = f.ATTR;
97
- t.textContent && (t.innerHTML = P(t, `{{${e}_${o}}}`));
106
+ t.textContent && (t.innerHTML = L(t, `{{${e}_${n}}}`));
98
107
  }
99
108
  break;
100
109
  }
@@ -102,49 +111,49 @@ function Z(S) {
102
111
  });
103
112
  });
104
113
  });
105
- const I = y.match(/<!DOCTYPE[^>]*>/i), U = I ? `${I[0]}
106
- ` : "", W = b.querySelectorAll(".ins-product-td"), M = [];
107
- W.forEach((n) => {
108
- const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
109
- M.push({
110
- element: n,
114
+ const E = C.match(/<!DOCTYPE[^>]*>/i), k = E ? `${E[0]}
115
+ ` : "", P = A.querySelectorAll(".ins-product-td"), N = [];
116
+ P.forEach((o) => {
117
+ const p = o.getAttribute("data-type") || "CART_ITEMS", T = o.getAttribute("data-number") || "1", r = o.outerHTML;
118
+ N.push({
119
+ element: o,
111
120
  outerHtml: r,
112
- type: d,
113
- number: p
121
+ type: p,
122
+ number: T
114
123
  });
115
124
  });
116
- let A = U + b.documentElement.outerHTML;
117
- M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
118
- const r = O[d], E = r ? `${r}_total_product_kind` : "";
119
- if (E) {
120
- const T = parseInt(p) - 1, o = `${`{% if ${E} > ${T} %}`}${n}{% endif %}`;
121
- A = A.replace(n, X(o));
125
+ let h = k + A.documentElement.outerHTML;
126
+ N.reverse().forEach(({ outerHtml: o, type: p, number: T }) => {
127
+ const r = q[p], _ = r ? `${r}_total_product_kind` : "";
128
+ if (_) {
129
+ const R = parseInt(T) - 1, n = `${`{% if ${_} > ${R} %}`}${o}{% endif %}`;
130
+ h = h.replace(o, B(n));
122
131
  }
123
132
  });
124
- const V = b.querySelectorAll('[product-attr="originalPrice"][data-type]'), L = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
125
- return V.forEach((n) => {
133
+ const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
134
+ return V.forEach((o) => {
126
135
  var t;
127
- const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
128
- if (!d || !O[p])
136
+ const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
137
+ if (!p || !q[T])
129
138
  return;
130
- const r = n.closest(".product-original-price-class");
131
- if (!r || k.has(r))
139
+ const r = o.closest(".product-original-price-class");
140
+ if (!r || x.has(r))
132
141
  return;
133
- k.add(r);
134
- const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), T = L.get(E) ?? { number: d, type: p, wrap: [] };
135
- T.wrap.push(m !== "false"), L.set(E, T);
136
- }), L.forEach(({ number: n, type: d, wrap: p }, r) => {
137
- if (r.includes("{% if") || !p.some(Boolean))
142
+ x.add(r);
143
+ const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
144
+ R.wrap.push(y !== "false"), w.set(_, R);
145
+ }), w.forEach(({ number: o, type: p, wrap: T }, r) => {
146
+ if (r.includes("{% if") || !T.some(Boolean))
138
147
  return;
139
- const E = w.PAIRS_FOR_EXTENSION.price[d].PRICE, m = w.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T, q(T)];
140
- let g = "", o = 0, f = 0, $ = A.indexOf(r);
141
- for (; $ !== -1; ) {
142
- const F = p[f] === !0 && !B(A, $, t);
143
- g += A.slice(o, $) + (F ? `${T}${r}{% endif %}` : r), o = $ + r.length, f += 1, $ = A.indexOf(r, o);
148
+ const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
149
+ let m = "", n = 0, f = 0, b = h.indexOf(r);
150
+ for (; b !== -1; ) {
151
+ const I = T[f] === !0 && !Q(h, b, t);
152
+ m += h.slice(n, b) + (I ? `${R}${r}{% endif %}` : r), n = b + r.length, f += 1, b = h.indexOf(r, n);
144
153
  }
145
- A = g + A.slice(o);
146
- }), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
154
+ h = m + h.slice(n);
155
+ }), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
147
156
  }
148
157
  export {
149
- Z as pairProductVariables
158
+ ot as pairProductVariables
150
159
  };
@@ -0,0 +1,22 @@
1
+ const c = "guido-table-text:", l = new RegExp(`<!--${c}([A-Za-z0-9+/=]*)-->`, "g"), i = /<!--[\s\S]*?-->|\{%[\s\S]*?%\}|<[a-zA-Z/!?](?:[^>"']|"[^"]*"|'[^']*')*>|[^<{]+|[<{]/g, o = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr"]), T = /* @__PURE__ */ new Set([...o, "td", "th", "caption"]), d = (s) => btoa(unescape(encodeURIComponent(s))), f = (s) => decodeURIComponent(escape(atob(s))), p = (s) => {
2
+ const e = /^<(\/?)([a-zA-Z][\w-]*)/.exec(s);
3
+ return { name: e ? e[2].toLowerCase() : "", closing: e ? e[1] === "/" : !1 };
4
+ };
5
+ function u(s) {
6
+ const e = [];
7
+ let a = !1;
8
+ return s.replace(i, (t) => {
9
+ if (t.startsWith("<!--") || t.startsWith("{%"))
10
+ return t;
11
+ if (t.length > 1 && t.startsWith("<")) {
12
+ const { name: n, closing: r } = p(t);
13
+ return a = T.has(n), a && (r ? e.includes(n) && e.splice(e.lastIndexOf(n)) : e.push(n)), t;
14
+ }
15
+ return a && o.has(e[e.length - 1] ?? "") && t.trim() ? `<!--${c}${d(t)}-->` : t;
16
+ });
17
+ }
18
+ const E = (s) => s.replace(l, (e, a) => f(a));
19
+ export {
20
+ u as protectTableText,
21
+ E as restoreTableText
22
+ };
@@ -1,20 +1,20 @@
1
- import { useActionsApi as D } from "../composables/useActionsApi.js";
2
- import { useConfig as E } from "../composables/useConfig.js";
3
- import { useHtmlCompiler as F } from "../composables/useHtmlCompiler.js";
1
+ import { useActionsApi as E } from "../composables/useActionsApi.js";
2
+ import { useConfig as F } from "../composables/useConfig.js";
3
+ import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { toBlockUrlConfig as I } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
5
+ import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
6
  import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
- import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
- import { useDynamicContentStore as U } from "../stores/dynamic-content.js";
9
- import { useEditorStore as L } from "../stores/editor.js";
10
- import { useUnsubscribeStore as N } from "../stores/unsubscribe.js";
11
- import { isPlainObject as v } from "./genericUtil.js";
12
- import { assignTrackingIds as z } from "./linkTrackingIds.js";
13
- function M(n) {
7
+ import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
+ import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
9
+ import { useEditorStore as N } from "../stores/editor.js";
10
+ import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
11
+ import { isPlainObject as z } from "./genericUtil.js";
12
+ import { assignTrackingIds as M } from "./linkTrackingIds.js";
13
+ function O(n) {
14
14
  const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
15
15
  return r.forEach((i) => {
16
16
  const t = i.getAttribute(g.PAGE_LIST);
17
- t && e.push(...R(t));
17
+ t && e.push(...U(t));
18
18
  }), [...new Set(e)];
19
19
  }
20
20
  async function S(n) {
@@ -35,7 +35,7 @@ async function S(n) {
35
35
  } catch {
36
36
  return;
37
37
  }
38
- v(a) && r.seedBlockUrlConfig(t, I(a));
38
+ z(a) && r.seedBlockUrlConfig(t, R(a));
39
39
  });
40
40
  try {
41
41
  await r.fetchRecommendationCreateData();
@@ -46,40 +46,40 @@ async function S(n) {
46
46
  );
47
47
  }
48
48
  }
49
- const Y = () => {
50
- const n = U(), c = L(), o = N(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = D(), { compileHtml: t, compileAmpHtml: m } = F(), { isFeatureEnabled: a } = E();
49
+ const Z = () => {
50
+ const n = L(), c = N(), o = v(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = E(), { compileHtml: t, compileAmpHtml: m } = I(), { isFeatureEnabled: a } = F();
51
51
  return {
52
- prepareTemplateDetails: async () => {
53
- let { html: s, css: u, syncModulesIds: h = [] } = await e();
52
+ prepareTemplateDetails: async (h) => {
53
+ let { html: s, css: u, syncModulesIds: y = [] } = h ?? await e();
54
54
  if (a("linkTrackingIds"))
55
55
  try {
56
- const { html: d, changed: P, nextSeq: x } = z(s, c.trackIdSessionFloor);
57
- c.trackIdSessionFloor = x, P && (s = d, await i(d, u));
56
+ const { html: d, changed: x, nextSeq: D } = M(s, c.trackIdSessionFloor);
57
+ c.trackIdSessionFloor = D, x && (s = d, await i(d, u));
58
58
  } catch (d) {
59
59
  console.error("Tracking-id step failed, saving anyway:", d);
60
60
  }
61
- const { html: y, ampHtml: p = "", ampErrors: T = [] } = await r({
61
+ const { html: T, ampHtml: p = "", ampErrors: A = [] } = await r({
62
62
  minimize: !0,
63
63
  resetDataSavedFlag: !1
64
64
  });
65
65
  o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
66
- const { compiledHtml: A, stats: l, appliedRules: w } = t(y), C = p && m(p).compiledHtml, H = n.getSelectedDynamicContentList, k = b(), f = M(s);
66
+ const { compiledHtml: w, stats: l, appliedRules: C } = t(T), H = p && m(p).compiledHtml, k = n.getSelectedDynamicContentList, P = b(), f = O(s);
67
67
  return console.debug("HTML Compilation Stats:", {
68
68
  originalSize: l.originalSize,
69
69
  compiledSize: l.compiledSize,
70
70
  reduction: `${l.reductionPercentage.toFixed(2)}%`,
71
- appliedRules: w,
71
+ appliedRules: C,
72
72
  executionTime: `${l.executionTime.toFixed(2)}ms`
73
73
  }), {
74
- dynamicContentList: H,
75
- compiledHtml: A,
74
+ dynamicContentList: k,
75
+ compiledHtml: w,
76
76
  rawHtml: s,
77
77
  css: u,
78
- ampHtml: C,
79
- ampErrors: T,
80
- modules: h.map(Number),
78
+ ampHtml: H,
79
+ ampErrors: A,
80
+ modules: y.map(Number),
81
81
  recommendation: {
82
- campaignUrls: k.recommendationCampaignUrls,
82
+ campaignUrls: P.recommendationCampaignUrls,
83
83
  configs: {}
84
84
  },
85
85
  unsubscribe: {
@@ -94,6 +94,6 @@ const Y = () => {
94
94
  };
95
95
  };
96
96
  export {
97
- M as getHtmlReferencedUnsubscribePages,
98
- Y as useTemplatePreparation
97
+ O as getHtmlReferencedUnsubscribePages,
98
+ Z as useTemplatePreparation
99
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.21.2",
3
+ "version": "3.22.0-beta.0951deb",
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",