@useinsider/guido 3.15.0 → 3.16.0-beta.0faee0c

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 (81) hide show
  1. package/dist/@types/config/schemas.js +108 -92
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +78 -75
  4. package/dist/composables/useActionsApi.js +30 -22
  5. package/dist/composables/useEmailTemplateApplier.js +25 -23
  6. package/dist/composables/useHtmlValidator.js +108 -106
  7. package/dist/composables/useStripo.js +30 -29
  8. package/dist/composables/useTimerClone.js +21 -19
  9. package/dist/config/i18n/en/labels.json.js +7 -3
  10. package/dist/config/migrator/checkboxMigrator.js +20 -19
  11. package/dist/config/migrator/radioButtonMigrator.js +26 -25
  12. package/dist/config/migrator/recommendation/compositionMapper.js +26 -23
  13. package/dist/config/migrator/recommendation/htmlBuilder.js +156 -155
  14. package/dist/extensions/Blocks/Checkbox/constants/controlIds.js +4 -0
  15. package/dist/extensions/Blocks/Checkbox/constants/selectors.js +6 -0
  16. package/dist/extensions/Blocks/Checkbox/controls/blockBackground/index.js +10 -0
  17. package/dist/extensions/Blocks/Checkbox/extension.js +6 -5
  18. package/dist/extensions/Blocks/Checkbox/settingsPanel.js +15 -14
  19. package/dist/extensions/Blocks/Checkbox/template.js +10 -9
  20. package/dist/extensions/Blocks/Items/block.js +44 -42
  21. package/dist/extensions/Blocks/Items/template.js +86 -86
  22. package/dist/extensions/Blocks/RadioButton/constants/controlIds.js +4 -0
  23. package/dist/extensions/Blocks/RadioButton/constants/selectors.js +6 -0
  24. package/dist/extensions/Blocks/RadioButton/controls/blockBackground/index.js +10 -0
  25. package/dist/extensions/Blocks/RadioButton/extension.js +5 -4
  26. package/dist/extensions/Blocks/RadioButton/settingsPanel.js +12 -11
  27. package/dist/extensions/Blocks/RadioButton/template.js +16 -9
  28. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +18 -15
  29. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +5 -9
  30. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +363 -322
  31. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +8 -8
  32. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +271 -231
  33. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +98 -113
  34. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +21 -0
  35. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +16 -16
  36. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +16 -16
  37. package/dist/extensions/Blocks/Recommendation/templates/utils.js +120 -120
  38. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +55 -54
  39. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +89 -0
  40. package/dist/extensions/Blocks/common-control.js +42 -35
  41. package/dist/extensions/Blocks/controlFactories.js +117 -115
  42. package/dist/guido.css +1 -1
  43. package/dist/library.js +11 -7
  44. package/dist/node_modules/valibot/dist/index.js +230 -216
  45. package/dist/public/trackingIds.js +8 -0
  46. package/dist/src/@types/config/schemas.d.ts +20 -0
  47. package/dist/src/composables/useActionsApi.d.ts +1 -1
  48. package/dist/src/composables/useConfig.d.ts +4 -0
  49. package/dist/src/composables/useHtmlValidator.d.ts +3 -2
  50. package/dist/src/config/migrator/recommendation/types.d.ts +1 -0
  51. package/dist/src/extensions/Blocks/Checkbox/constants/controlIds.d.ts +7 -0
  52. package/dist/src/extensions/Blocks/Checkbox/constants/index.d.ts +10 -0
  53. package/dist/src/extensions/Blocks/Checkbox/constants/selectors.d.ts +16 -0
  54. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +14 -0
  55. package/dist/src/extensions/Blocks/RadioButton/constants/controlIds.d.ts +7 -0
  56. package/dist/src/extensions/Blocks/RadioButton/constants/index.d.ts +10 -0
  57. package/dist/src/extensions/Blocks/RadioButton/constants/selectors.d.ts +16 -0
  58. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +14 -0
  59. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  60. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -0
  61. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +27 -5
  62. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -2
  63. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -0
  64. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -11
  65. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +47 -0
  66. package/dist/src/extensions/Blocks/_Boilerplate/constants/controlIds.d.ts +7 -0
  67. package/dist/src/extensions/Blocks/_Boilerplate/constants/index.d.ts +10 -0
  68. package/dist/src/extensions/Blocks/_Boilerplate/constants/selectors.d.ts +16 -0
  69. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +14 -0
  70. package/dist/src/extensions/Blocks/common-control.d.ts +3 -1
  71. package/dist/src/library.d.ts +1 -0
  72. package/dist/src/public/trackingIds.d.ts +9 -0
  73. package/dist/src/stores/config.d.ts +36 -0
  74. package/dist/src/stores/editor.d.ts +25 -0
  75. package/dist/src/utils/linkTrackingIds.d.ts +30 -0
  76. package/dist/stores/editor.js +4 -1
  77. package/dist/stores/onboarding.js +11 -7
  78. package/dist/utils/linkTrackingIds.js +56 -0
  79. package/dist/utils/pairProductVariables.js +105 -99
  80. package/dist/utils/templatePreparation.js +72 -61
  81. package/package.json +5 -1
@@ -1,88 +1,100 @@
1
- import { productPairs as q } from "../extensions/Blocks/Items/enums/productEnums.js";
2
- import { DefaultConfigValues as O } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
- import { preserveTextStyles as C } from "./preserveTextStyles.js";
4
- import { unwrapProductNameLinks as U } from "./unwrapProductNameLink.js";
5
- function Y(L) {
6
- const H = L.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), b = new DOMParser().parseFromString(H, "text/html");
7
- U(b);
8
- const R = q.PAIRS_FOR_EXTENSION;
9
- Object.entries(R).forEach(([r, u]) => {
10
- b.querySelectorAll(".ins-product-td").forEach((l) => {
11
- const h = l.getAttribute("data-number") || "1", $ = l.getAttribute("data-type") || "CART_ITEMS";
12
- l.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
13
- var F, I, w;
14
- const T = t.getAttribute("data-type") || $, f = t.getAttribute("data-number") || h, d = u[T];
15
- if (d)
16
- switch (r) {
1
+ import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
2
+ import { DefaultConfigValues as V } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
+ import { escapeReplacement as G } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
+ import { preserveTextStyles as F } from "./preserveTextStyles.js";
5
+ import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
6
+ const x = {
7
+ CART_ITEMS: "ins_apr",
8
+ BROWSED_ITEMS: "browsed_item",
9
+ PURCHASED_ITEMS: "purchased_item"
10
+ }, N = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
+ function v(S, H, g) {
12
+ let $ = H;
13
+ for (; $ > 0 && /\s/.test(S[$ - 1]); )
14
+ $ -= 1;
15
+ return g.some((I) => S.endsWith(I, $));
16
+ }
17
+ function J(S) {
18
+ const H = N(S), g = new DOMParser().parseFromString(H, "text/html");
19
+ X(g);
20
+ const $ = L.PAIRS_FOR_EXTENSION;
21
+ Object.entries($).forEach(([n, d]) => {
22
+ g.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 T, P, D;
26
+ const R = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, f = d[R];
27
+ if (f)
28
+ switch (n) {
17
29
  case "imageSrc": {
18
- let e = null, c = null;
19
- if (t.tagName === "IMG" ? (e = t, c = e.closest("a")) : (e = t.querySelector("img"), c = t.querySelector("a") || t.closest("a")), !e)
30
+ let e = null, s = null;
31
+ if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
20
32
  break;
21
- const i = d.DEFAULT, a = d.ATTR;
22
- if (i && e.src) {
23
- const o = e.src;
24
- i.some((E) => {
25
- const s = E.split("/").pop() || "", g = o.split("/").pop() || "";
26
- return o.includes(E) || o.includes(s) || g === s;
27
- }) && (e.src = `{{${a}_${f}}}`);
33
+ const a = f.DEFAULT, l = f.ATTR;
34
+ if (a && e.src) {
35
+ const i = e.src;
36
+ a.some((b) => {
37
+ const u = b.split("/").pop() || "", y = i.split("/").pop() || "";
38
+ return i.includes(b) || i.includes(u) || y === u;
39
+ }) && (e.src = `{{${l}_${o}}}`);
28
40
  }
29
- const n = (I = (F = R.name) == null ? void 0 : F[T]) == null ? void 0 : I.ATTR;
30
- if (n && e.setAttribute("alt", `{{${n}_${f}}}`), c) {
31
- const o = (w = R.itemLink) == null ? void 0 : w[T];
32
- if (o) {
33
- const A = o.HREF, E = o.DEFAULT_HREF || "#!", s = c.href;
34
- (s === "#" || s === "" || s.endsWith("#!") || s.endsWith(E) || s === `${window.location.href}${E}` || !s || s === window.location.href) && (c.href = `{{${A}_${f}}}`);
41
+ const c = (P = (T = $.name) == null ? void 0 : T[R]) == null ? void 0 : P.ATTR;
42
+ if (c && e.setAttribute("alt", `{{${c}_${o}}}`), s) {
43
+ const i = (D = $.itemLink) == null ? void 0 : D[R];
44
+ if (i) {
45
+ const _ = i.HREF, b = i.DEFAULT_HREF || "#!", u = s.href;
46
+ (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(b) || u === `${window.location.href}${b}` || !u || u === window.location.href) && (s.href = `{{${_}_${o}}}`);
35
47
  }
36
48
  }
37
49
  break;
38
50
  }
39
51
  case "name": {
40
- const e = d, c = e.ATTR, i = e.DEFAULT_HREF || "#!", a = e.HREF;
41
- t.textContent && (t.innerHTML = C(t, `{{${c}_${f}}}`));
42
- const n = t.closest("a") || (t.tagName === "A" ? t : null);
43
- if (n && a) {
44
- const o = n.href, A = `${window.location.href}${i}`;
45
- (o === A || o.endsWith(i)) && (n.href = `{{${a}_${f}}}`);
52
+ const e = f, s = e.ATTR, a = e.DEFAULT_HREF || "#!", l = e.HREF;
53
+ t.textContent && (t.innerHTML = F(t, `{{${s}_${o}}}`));
54
+ const c = t.closest("a") || (t.tagName === "A" ? t : null);
55
+ if (c && l) {
56
+ const i = c.href, _ = `${window.location.href}${a}`;
57
+ (i === _ || i.endsWith(a)) && (c.href = `{{${l}_${o}}}`);
46
58
  }
47
59
  break;
48
60
  }
49
61
  case "price":
50
62
  case "originalPrice": {
51
- const e = d, c = t.getAttribute("data-formated"), i = t.getAttribute("data-single_price"), a = c === "true", n = i === "true", o = t.getAttribute("data-curency") || "before";
52
- let A;
53
- n ? A = a ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : A = a ? e.PRICE_FORMATTED : e.PRICE;
54
- const E = e.CURRENCY;
55
- let s = `{{${A}_${f}}}`;
56
- const g = (t.getAttribute("data-currency_symbol") || "").trim(), N = g !== "" && g !== O.productPriceCurrencySymbolControlValue;
57
- let m = "";
58
- N ? m = g : E && (m = `{{${E}_${f}}}`), m && (s = o === "after" ? `${s} ${m}` : `${m} ${s}`), t.innerHTML = C(t, s);
63
+ const e = f, s = t.getAttribute("data-formated"), a = t.getAttribute("data-single_price"), l = s === "true", c = a === "true", i = t.getAttribute("data-curency") || "before";
64
+ let _;
65
+ c ? _ = l ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : _ = l ? e.PRICE_FORMATTED : e.PRICE;
66
+ const b = e.CURRENCY;
67
+ let u = `{{${_}_${o}}}`;
68
+ const y = (t.getAttribute("data-currency_symbol") || "").trim(), W = y !== "" && y !== V.productPriceCurrencySymbolControlValue;
69
+ let C = "";
70
+ W ? C = y : b && (C = `{{${b}_${o}}}`), C && (u = i === "after" ? `${u} ${C}` : `${C} ${u}`), t.innerHTML = F(t, u);
59
71
  break;
60
72
  }
61
73
  case "quantity": {
62
- const e = d, c = e.ATTR, i = e.DEFAULT;
63
- t.textContent && t.textContent.trim() === i && (t.innerHTML = C(t, `{{${c}_${f}}}`));
74
+ const e = f, s = e.ATTR, a = e.DEFAULT;
75
+ t.textContent && t.textContent.trim() === a && (t.innerHTML = F(t, `{{${s}_${o}}}`));
64
76
  break;
65
77
  }
66
78
  case "button": {
67
- const e = d, c = e.HREF, i = e.DEFAULT_HREF || "#!", a = t.tagName === "A" ? t : t.querySelector("a");
68
- if (a) {
69
- const n = a.href || "", o = `${window.location.href}${i}`;
70
- (n === "" || n === "#" || n === o || n.endsWith(i) || n.endsWith("#!") || n === window.location.href) && (a.href = `{{${c}_${f}}}`);
79
+ const e = f, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t.tagName === "A" ? t : t.querySelector("a");
80
+ if (l) {
81
+ const c = l.href || "", i = `${window.location.href}${a}`;
82
+ (c === "" || c === "#" || c === i || c.endsWith(a) || c.endsWith("#!") || c === window.location.href) && (l.href = `{{${s}_${o}}}`);
71
83
  }
72
84
  break;
73
85
  }
74
86
  case "itemLink": {
75
- const e = d, c = e.HREF, i = e.DEFAULT_HREF || "#!", a = t;
76
- if (a.href) {
77
- const n = a.href, o = `${window.location.href}${i}`;
78
- (n === o || n.endsWith(i)) && (a.href = `{{${c}_${f}}}`);
87
+ const e = f, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t;
88
+ if (l.href) {
89
+ const c = l.href, i = `${window.location.href}${a}`;
90
+ (c === i || c.endsWith(a)) && (l.href = `{{${s}_${o}}}`);
79
91
  }
80
92
  break;
81
93
  }
82
94
  default: {
83
- if ("ATTR" in d) {
84
- const e = d.ATTR;
85
- t.textContent && (t.innerHTML = C(t, `{{${e}_${f}}}`));
95
+ if ("ATTR" in f) {
96
+ const e = f.ATTR;
97
+ t.textContent && (t.innerHTML = F(t, `{{${e}_${o}}}`));
86
98
  }
87
99
  break;
88
100
  }
@@ -90,55 +102,49 @@ function Y(L) {
90
102
  });
91
103
  });
92
104
  });
93
- const k = H.match(/<!DOCTYPE[^>]*>/i), P = k ? `${k[0]}
94
- ` : "", D = b.querySelectorAll(".ins-product-td"), M = [];
95
- D.forEach((r) => {
96
- const u = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", l = r.outerHTML;
105
+ const I = H.match(/<!DOCTYPE[^>]*>/i), O = I ? `${I[0]}
106
+ ` : "", q = g.querySelectorAll(".ins-product-td"), M = [];
107
+ q.forEach((n) => {
108
+ const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
97
109
  M.push({
98
- element: r,
99
- outerHtml: l,
100
- type: u,
110
+ element: n,
111
+ outerHtml: r,
112
+ type: d,
101
113
  number: p
102
114
  });
103
115
  });
104
- let _ = P + b.documentElement.outerHTML;
105
- M.reverse().forEach(({ outerHtml: r, type: u, number: p }) => {
106
- let l = "";
107
- switch (u) {
108
- case "CART_ITEMS":
109
- l = "ins_apr_total_product_kind";
110
- break;
111
- case "BROWSED_ITEMS":
112
- l = "browsed_item_total_product_kind";
113
- break;
114
- case "PURCHASED_ITEMS":
115
- l = "purchased_item_total_product_kind";
116
- break;
117
- }
118
- if (l) {
119
- const $ = parseInt(p) - 1, T = `${`{% if ${l} > ${$} %}`}${r}{% endif %}`;
120
- _ = _.replace(r, T);
116
+ let A = O + g.documentElement.outerHTML;
117
+ M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
118
+ const r = x[d], E = r ? `${r}_total_product_kind` : "";
119
+ if (E) {
120
+ const h = parseInt(p) - 1, o = `${`{% if ${E} > ${h} %}`}${n}{% endif %}`;
121
+ A = A.replace(n, G(o));
121
122
  }
122
123
  });
123
- const x = b.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), S = [];
124
- return x.forEach((r) => {
125
- var $;
126
- const u = r.getAttribute("data-number"), p = r.getAttribute("data-type");
127
- if (!u || p !== "CART_ITEMS" || (($ = r.closest(".ins-product-td")) == null ? void 0 : $.getAttribute("data-nodup")) === "false")
124
+ const U = g.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
125
+ return U.forEach((n) => {
126
+ var t;
127
+ const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
128
+ if (!d || !x[p])
128
129
  return;
129
- const h = r.closest(".product-original-price-class");
130
- if (h) {
131
- const y = h.outerHTML;
132
- S.some((T) => T.tdOuterHtml === y) || S.push({ tdOuterHtml: y, number: u });
133
- }
134
- }), S.reverse().forEach(({ tdOuterHtml: r, number: u }) => {
135
- const p = `{% if ins_apr_price_${u} != ins_apr_originalprice_${u} %}`;
136
- if (!_.includes(p) && !r.includes("{% if")) {
137
- const h = `${p}${r}{% endif %}`;
138
- _ = _.replace(r, h);
130
+ const r = n.closest(".product-original-price-class");
131
+ if (!r || k.has(r))
132
+ return;
133
+ k.add(r);
134
+ const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), h = w.get(E) ?? { number: d, type: p, wrap: [] };
135
+ h.wrap.push(m !== "false"), w.set(E, h);
136
+ }), w.forEach(({ number: n, type: d, wrap: p }, r) => {
137
+ if (r.includes("{% if") || !p.some(Boolean))
138
+ return;
139
+ const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, h = `{% if ${E}_${n} != ${m}_${n} %}`, t = [h, N(h)];
140
+ let R = "", o = 0, f = 0, T = A.indexOf(r);
141
+ for (; T !== -1; ) {
142
+ const P = p[f] === !0 && !v(A, T, t);
143
+ R += A.slice(o, T) + (P ? `${h}${r}{% endif %}` : r), o = T + r.length, f += 1, T = A.indexOf(r, o);
139
144
  }
140
- }), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
145
+ A = R + A.slice(o);
146
+ }), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
141
147
  }
142
148
  export {
143
- Y as pairProductVariables
149
+ J as pairProductVariables
144
150
  };
@@ -1,62 +1,65 @@
1
- import { useActionsApi as P } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as w } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as i } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
- import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { mapLegacyStrategy as E } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
6
- import { DATA_ATTRIBUTES as h } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
- import { parsePageList as H } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
- import { useDynamicContentStore as U } from "../stores/dynamic-content.js";
9
- import { useUnsubscribeStore as F } from "../stores/unsubscribe.js";
10
- function L(s) {
11
- const o = new DOMParser().parseFromString(s, "text/html").querySelectorAll(`[${h.PAGE_LIST}]`), t = [];
12
- return o.forEach((a) => {
13
- const n = a.getAttribute(h.PAGE_LIST);
14
- n && t.push(...H(n));
1
+ import { useActionsApi as k } from "../composables/useActionsApi.js";
2
+ import { useConfig as U } from "../composables/useConfig.js";
3
+ import { useHtmlCompiler as x } from "../composables/useHtmlCompiler.js";
4
+ import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
+ import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
+ import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
7
+ import { DATA_ATTRIBUTES as A } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
+ import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
+ import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
10
+ import { useEditorStore as z } from "../stores/editor.js";
11
+ import { useUnsubscribeStore as _ } from "../stores/unsubscribe.js";
12
+ import { assignTrackingIds as v } from "./linkTrackingIds.js";
13
+ function O(m) {
14
+ const n = new DOMParser().parseFromString(m, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
15
+ return n.forEach((i) => {
16
+ const o = i.getAttribute(A.PAGE_LIST);
17
+ o && t.push(...R(o));
15
18
  }), [...new Set(t)];
16
19
  }
17
- async function R(s) {
18
- const m = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
19
- if (m.length === 0)
20
+ async function M(m) {
21
+ const a = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
22
+ if (a.length === 0)
20
23
  return;
21
- const o = b();
22
- m.forEach((t) => {
23
- var c, p, g, f, r;
24
- const a = t.getAttribute("recommendation-id"), n = a ? Number(a) : NaN;
25
- if (!Number.isFinite(n))
24
+ const n = C();
25
+ a.forEach((t) => {
26
+ var r, l, g, f, c;
27
+ const i = t.getAttribute("recommendation-id"), o = i ? Number(i) : NaN;
28
+ if (!Number.isFinite(o))
26
29
  return;
27
- const d = t.getAttribute("esd-ext-config");
28
- if (!d)
30
+ const p = t.getAttribute("esd-ext-config");
31
+ if (!p)
29
32
  return;
30
33
  let e;
31
34
  try {
32
- e = JSON.parse(d);
35
+ e = JSON.parse(p);
33
36
  } catch {
34
37
  return;
35
38
  }
36
39
  if (!e || typeof e != "object" || Array.isArray(e))
37
40
  return;
38
- const y = {
41
+ const h = {
39
42
  // Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
40
43
  // already-saved blocks that never re-run the migrator don't emit a
41
44
  // strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
42
- strategy: E(e.strategy) || i.strategy,
43
- language: e.language ?? i.language,
44
- size: e.size ?? i.size,
45
+ strategy: L(e.strategy) || s.strategy,
46
+ language: e.language ?? s.language,
47
+ size: e.size ?? s.size,
45
48
  // Spread the default arrays so each block gets a fresh reference
46
49
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
47
- productIds: e.productIds ?? [...i.productIds],
48
- filters: e.filters ?? [...i.filters],
49
- shuffleProducts: e.shuffleProducts ?? i.shuffleProducts,
50
- currencyCode: ((c = e.currency) == null ? void 0 : c.code) ?? l.code,
51
- currencyAlignment: ((p = e.currency) == null ? void 0 : p.alignment) ?? l.alignment,
52
- currencyDecimalCount: ((g = e.currency) == null ? void 0 : g.decimalCount) ?? l.decimalCount,
53
- currencyDecimalSeparator: ((f = e.currency) == null ? void 0 : f.decimalSeparator) ?? l.decimalSeparator,
54
- currencyThousandSeparator: ((r = e.currency) == null ? void 0 : r.thousandSeparator) ?? l.thousandSeparator
50
+ productIds: e.productIds ?? [...s.productIds],
51
+ filters: e.filters ?? [...s.filters],
52
+ shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
53
+ currencyCode: ((r = e.currency) == null ? void 0 : r.code) ?? d.code,
54
+ currencyAlignment: ((l = e.currency) == null ? void 0 : l.alignment) ?? d.alignment,
55
+ currencyDecimalCount: ((g = e.currency) == null ? void 0 : g.decimalCount) ?? d.decimalCount,
56
+ currencyDecimalSeparator: ((f = e.currency) == null ? void 0 : f.decimalSeparator) ?? d.decimalSeparator,
57
+ currencyThousandSeparator: ((c = e.currency) == null ? void 0 : c.thousandSeparator) ?? d.thousandSeparator
55
58
  };
56
- o.seedBlockUrlConfig(n, y);
59
+ n.seedBlockUrlConfig(o, h);
57
60
  });
58
61
  try {
59
- await o.fetchRecommendationCreateData();
62
+ await n.fetchRecommendationCreateData();
60
63
  } catch (t) {
61
64
  console.warn(
62
65
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -64,43 +67,51 @@ async function R(s) {
64
67
  );
65
68
  }
66
69
  }
67
- const G = () => {
68
- const s = U(), u = F(), { getCompiledEmail: m, getTemplateData: o } = P(), { compileHtml: t, compileAmpHtml: a } = w();
70
+ const Z = () => {
71
+ const m = N(), u = z(), a = _(), { getCompiledEmail: n, getTemplateData: t, updateHtmlAndCss: i } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
69
72
  return {
70
73
  prepareTemplateDetails: async () => {
71
- const { html: d, ampHtml: e = "", ampErrors: y = [] } = await m({
74
+ let { html: r, css: l, syncModulesIds: g = [] } = await t();
75
+ if (e("linkTrackingIds"))
76
+ try {
77
+ const { html: y, changed: H, nextSeq: I } = v(r, u.trackIdSessionFloor);
78
+ u.trackIdSessionFloor = I, H && (r = y, await i(y, l));
79
+ } catch (y) {
80
+ console.error("Tracking-id step failed, saving anyway:", y);
81
+ }
82
+ const { html: f, ampHtml: c = "", ampErrors: T = [] } = await n({
72
83
  minimize: !0,
73
84
  resetDataSavedFlag: !1
74
- }), { html: c, css: p, syncModulesIds: g = [] } = await o();
75
- u.selectedUnsubscribePages.length && await u.fetchTemplates(), await R(c);
76
- const { compiledHtml: f, stats: r, appliedRules: A } = t(d), C = e && a(e).compiledHtml, T = s.getSelectedDynamicContentList, D = b(), S = L(c);
85
+ });
86
+ a.selectedUnsubscribePages.length && await a.fetchTemplates(), await M(r);
87
+ const { compiledHtml: w, stats: S, appliedRules: D } = o(f), E = c && p(c).compiledHtml, P = m.getSelectedDynamicContentList, F = C(), b = O(r);
77
88
  return console.debug("HTML Compilation Stats:", {
78
- originalSize: r.originalSize,
79
- compiledSize: r.compiledSize,
80
- reduction: `${r.reductionPercentage.toFixed(2)}%`,
81
- appliedRules: A,
82
- executionTime: `${r.executionTime.toFixed(2)}ms`
89
+ originalSize: S.originalSize,
90
+ compiledSize: S.compiledSize,
91
+ reduction: `${S.reductionPercentage.toFixed(2)}%`,
92
+ appliedRules: D,
93
+ executionTime: `${S.executionTime.toFixed(2)}ms`
83
94
  }), {
84
- dynamicContentList: T,
85
- compiledHtml: f,
86
- rawHtml: c,
87
- css: p,
88
- ampHtml: C,
89
- ampErrors: y,
95
+ dynamicContentList: P,
96
+ compiledHtml: w,
97
+ rawHtml: r,
98
+ css: l,
99
+ ampHtml: E,
100
+ ampErrors: T,
90
101
  modules: g.map(Number),
91
102
  recommendation: {
92
- campaignUrls: D.recommendationCampaignUrls,
103
+ campaignUrls: F.recommendationCampaignUrls,
93
104
  configs: {}
94
105
  },
95
106
  unsubscribe: {
96
- status: S.length > 0,
97
- config: S
107
+ status: b.length > 0,
108
+ config: b
98
109
  }
99
110
  };
100
111
  }
101
112
  };
102
113
  };
103
114
  export {
104
- L as getHtmlReferencedUnsubscribePages,
105
- G as useTemplatePreparation
115
+ O as getHtmlReferencedUnsubscribePages,
116
+ Z as useTemplatePreparation
106
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.15.0",
3
+ "version": "3.16.0-beta.0faee0c",
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",
@@ -14,6 +14,10 @@
14
14
  "types": "./dist/components/Guido.vue.d.ts",
15
15
  "require": "./dist/components/Guido.vue.js"
16
16
  },
17
+ "./tracking-ids": {
18
+ "types": "./dist/src/public/trackingIds.d.ts",
19
+ "import": "./dist/public/trackingIds.js"
20
+ },
17
21
  "./style": "./dist/guido.css"
18
22
  },
19
23
  "scripts": {