@useinsider/guido 3.17.0-beta.ea65303 → 3.17.0-beta.eae947f

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 (55) hide show
  1. package/README.md +5 -6
  2. package/dist/@types/config/schemas.js +27 -29
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +76 -78
  5. package/dist/components/organisms/AutoSaveController.vue2.js +8 -9
  6. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  7. package/dist/components/organisms/header/EditorActions.vue2.js +43 -74
  8. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  9. package/dist/components/organisms/header/LeftSlot.vue2.js +12 -16
  10. package/dist/components/wrappers/WpDrawer.vue.js +7 -9
  11. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  12. package/dist/composables/useHtmlCompiler.js +26 -37
  13. package/dist/composables/useHtmlValidator.js +0 -2
  14. package/dist/composables/useSave.js +41 -84
  15. package/dist/composables/validators/useCouponBlockValidator.js +21 -24
  16. package/dist/composables/validators/useUnsubscribeBlockValidator.js +27 -34
  17. package/dist/extensions/Blocks/Items/block.js +98 -49
  18. package/dist/extensions/Blocks/Items/constants/currency.js +11 -0
  19. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
  20. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
  21. package/dist/extensions/Blocks/Items/template.js +153 -152
  22. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +26 -33
  23. package/dist/guido.css +1 -1
  24. package/dist/src/@types/config/schemas.d.ts +0 -4
  25. package/dist/src/components/Guido.vue.d.ts +1 -17
  26. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -17
  27. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -17
  28. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -17
  29. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +3 -4
  30. package/dist/src/composables/useConfig.d.ts +0 -2
  31. package/dist/src/composables/useHtmlValidator.d.ts +0 -21
  32. package/dist/src/composables/useSave.d.ts +1 -6
  33. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
  34. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -10
  35. package/dist/src/extensions/Blocks/Items/block.d.ts +21 -0
  36. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +19 -0
  37. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -5
  38. package/dist/src/stores/config.d.ts +0 -30
  39. package/dist/src/utils/templatePreparation.d.ts +0 -30
  40. package/dist/stores/config.js +22 -39
  41. package/dist/utils/pairProductVariables.js +60 -59
  42. package/dist/utils/templatePreparation.js +25 -28
  43. package/package.json +2 -2
  44. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +0 -20
  45. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +0 -48
  46. package/dist/composables/useSaveValidation.js +0 -279
  47. package/dist/composables/useSaveValidationRollout.js +0 -9
  48. package/dist/enums/save-validation.js +0 -4
  49. package/dist/src/@types/save-validation.d.ts +0 -19
  50. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +0 -2
  51. package/dist/src/composables/useSaveValidation.d.ts +0 -6
  52. package/dist/src/composables/useSaveValidationRollout.d.ts +0 -3
  53. package/dist/src/enums/save-validation.d.ts +0 -27
  54. package/dist/src/stores/save-validation.d.ts +0 -22
  55. package/dist/stores/save-validation.js +0 -30
@@ -15,36 +15,6 @@ import type { SavedTemplateDetails } from '@@/Types/stripo';
15
15
  * same source), so it is reliably present regardless of how the block was added.
16
16
  */
17
17
  export declare function getHtmlReferencedUnsubscribePages(html: string): number[];
18
- /**
19
- * Hydrates the recommendation extension store from the persisted `esd-ext-config`
20
- * JSON blob on each `.recommendation-block-v2` element in the raw editor HTML.
21
- *
22
- * Why this runs before `compileHtml`:
23
- * The HTML compiler's `prepareRecommendationBlocks` rule asks
24
- * `useRecommendation.buildCampaignUrl(id)` to assemble each block's API URL
25
- * from `blockStates[id].recommendationConfigs`. That Pinia entry is normally
26
- * populated by `RecommendationBlockControl._syncNodeConfigToStore`, which
27
- * only fires when the user *selects* the block. Saving without ever
28
- * selecting a migrated block would otherwise build the URL from empty/
29
- * default state and the campaign URL would not be saved.
30
- *
31
- * Why we read raw HTML, not compiled HTML:
32
- * Stripo's `compileEmail()` strips editor-only attributes (`esd-*`) from the
33
- * compiled output, so `esd-ext-config` is gone by the time the compiler
34
- * pipeline sees the HTML. The raw HTML from `getTemplateData()` preserves
35
- * the attribute as the migrator wrote it.
36
- *
37
- * Reference data pre-load:
38
- * When the template has recommendation blocks, this also pre-loads the
39
- * shared reference data (languages / currency list) so the save-time
40
- * required-fields validator can check each block's locale and currency
41
- * against the partner's real options. Best-effort — on a fetch failure the
42
- * validator degrades to its empty-list guard (`requiredFields.ts`) instead
43
- * of blocking the save or stranding the Save button.
44
- */
45
- declare function hydrateRecommendationStoreFromRawHtml(rawHtml: string): Promise<void>;
46
18
  export declare const useTemplatePreparation: () => {
47
19
  prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
48
- hydrateRecommendationStore: typeof hydrateRecommendationStoreFromRawHtml;
49
20
  };
50
- export {};
@@ -1,8 +1,8 @@
1
- import { MessageType as r } from "../@types/config/schemas.js";
1
+ import "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
3
  import { parseConfig as o } from "../@types/config/validator.js";
4
- import { defineStore as a } from "pinia";
5
- const u = a("guido-config", {
4
+ import { defineStore as r } from "pinia";
5
+ const f = r("guido-config", {
6
6
  state: () => ({
7
7
  initialized: !1,
8
8
  config: null
@@ -75,74 +75,57 @@ const u = a("guido-config", {
75
75
  * Get the template ID
76
76
  */
77
77
  templateId: (i) => {
78
- var e, t;
79
- return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.templateId) ?? "";
78
+ var e, n;
79
+ return ((n = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : n.templateId) ?? "";
80
80
  },
81
81
  /**
82
82
  * Get the user ID
83
83
  */
84
84
  userId: (i) => {
85
- var e, t;
86
- return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.userId) ?? "";
85
+ var e, n;
86
+ return ((n = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : n.userId) ?? "";
87
87
  },
88
88
  /**
89
89
  * Get the variation ID
90
90
  */
91
91
  variationId: (i) => {
92
- var e, t;
93
- return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.variationId) ?? "";
92
+ var e, n;
93
+ return ((n = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : n.variationId) ?? "";
94
94
  },
95
95
  /**
96
96
  * Get the partner name
97
97
  */
98
98
  partnerName: (i) => {
99
- var e, t;
100
- return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.name) ?? "";
99
+ var e, n;
100
+ return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.name) ?? "";
101
101
  },
102
102
  /**
103
103
  * Get the product type
104
104
  */
105
105
  productType: (i) => {
106
- var e, t;
107
- return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.productType) ?? 60;
106
+ var e, n;
107
+ return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.productType) ?? 60;
108
108
  },
109
109
  /**
110
110
  * Get the message type
111
111
  */
112
112
  messageType: (i) => {
113
- var e, t;
114
- return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) ?? 1;
115
- },
116
- /**
117
- * Transactional campaigns keep the hard save block. Reactive getter, so
118
- * consumers stay safe in setup where a raw config read snapshots null (SD-147945).
119
- */
120
- isTransactional() {
121
- return this.messageType === r.TRANSACTIONAL;
122
- },
123
- /**
124
- * Soft-save policy: may the editor persist a template with validation errors?
125
- * Default true (host sets features.allowSaveWithErrors=false for transactional +
126
- * unsub). Reactive getter defaulting true — reading via isFeatureEnabled would
127
- * floor to false pre-init and momentarily hide the soft-save option (SD-147430).
128
- */
129
- allowSaveWithErrors() {
130
- var i;
131
- return ((i = this.features) == null ? void 0 : i.allowSaveWithErrors) ?? !0;
113
+ var e, n;
114
+ return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.messageType) ?? 1;
132
115
  },
133
116
  /**
134
117
  * Get the username
135
118
  */
136
119
  username: (i) => {
137
- var e, t;
138
- return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.username) ?? "Guido User";
120
+ var e, n;
121
+ return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.username) ?? "Guido User";
139
122
  },
140
123
  /**
141
124
  * Check if header should be shown
142
125
  */
143
126
  showHeader: (i) => {
144
- var e, t;
145
- return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
127
+ var e, n;
128
+ return ((n = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : n.showHeader) ?? !0;
146
129
  },
147
130
  /**
148
131
  * Check if a specific feature is enabled.
@@ -151,8 +134,8 @@ const u = a("guido-config", {
151
134
  */
152
135
  // eslint-disable-next-line @stylistic/max-len
153
136
  isFeatureEnabled: (i) => (e) => {
154
- var t, n;
155
- return ((n = (t = i.config) == null ? void 0 : t.features) == null ? void 0 : n[e]) ?? !1;
137
+ var n, t;
138
+ return ((t = (n = i.config) == null ? void 0 : n.features) == null ? void 0 : t[e]) ?? !1;
156
139
  }
157
140
  },
158
141
  actions: {
@@ -172,5 +155,5 @@ const u = a("guido-config", {
172
155
  }
173
156
  });
174
157
  export {
175
- u as useConfigStore
158
+ f as useConfigStore
176
159
  };
@@ -1,82 +1,83 @@
1
+ import { ITEMS_CURRENCY_ATTR as N } from "../extensions/Blocks/Items/constants/currency.js";
1
2
  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";
3
+ import { DefaultConfigValues as G } from "../extensions/Blocks/Items/enums/settingsEnums.js";
4
+ import { escapeReplacement as X } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
5
  import { preserveTextStyles as F } from "./preserveTextStyles.js";
5
- import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
6
+ import { unwrapProductNameLinks as Y } from "./unwrapProductNameLink.js";
6
7
  const x = {
7
8
  CART_ITEMS: "ins_apr",
8
9
  BROWSED_ITEMS: "browsed_item",
9
10
  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, $));
11
+ }, O = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
12
+ function v(S, I, b) {
13
+ let h = I;
14
+ for (; h > 0 && /\s/.test(S[h - 1]); )
15
+ h -= 1;
16
+ return b.some((P) => S.endsWith(P, h));
16
17
  }
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) => {
18
+ function Z(S) {
19
+ const I = O(S), b = new DOMParser().parseFromString(I, "text/html");
20
+ Y(b);
21
+ const h = L.PAIRS_FOR_EXTENSION;
22
+ Object.entries(h).forEach(([n, d]) => {
23
+ b.querySelectorAll(".ins-product-td").forEach((r) => {
23
24
  const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
24
25
  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)
26
+ var $, H, D;
27
+ const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, u = d[g];
28
+ if (u)
28
29
  switch (n) {
29
30
  case "imageSrc": {
30
31
  let e = null, s = null;
31
32
  if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
32
33
  break;
33
- const a = f.DEFAULT, l = f.ATTR;
34
+ const a = u.DEFAULT, l = u.ATTR;
34
35
  if (a && e.src) {
35
36
  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;
37
+ a.some((_) => {
38
+ const f = _.split("/").pop() || "", C = i.split("/").pop() || "";
39
+ return i.includes(_) || i.includes(f) || C === f;
39
40
  }) && (e.src = `{{${l}_${o}}}`);
40
41
  }
41
- const c = (P = (T = $.name) == null ? void 0 : T[R]) == null ? void 0 : P.ATTR;
42
+ const c = (H = ($ = h.name) == null ? void 0 : $[g]) == null ? void 0 : H.ATTR;
42
43
  if (c && e.setAttribute("alt", `{{${c}_${o}}}`), s) {
43
- const i = (D = $.itemLink) == null ? void 0 : D[R];
44
+ const i = (D = h.itemLink) == null ? void 0 : D[g];
44
45
  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}}}`);
46
+ const R = i.HREF, _ = i.DEFAULT_HREF || "#!", f = s.href;
47
+ (f === "#" || f === "" || f.endsWith("#!") || f.endsWith(_) || f === `${window.location.href}${_}` || !f || f === window.location.href) && (s.href = `{{${R}_${o}}}`);
47
48
  }
48
49
  }
49
50
  break;
50
51
  }
51
52
  case "name": {
52
- const e = f, s = e.ATTR, a = e.DEFAULT_HREF || "#!", l = e.HREF;
53
+ const e = u, s = e.ATTR, a = e.DEFAULT_HREF || "#!", l = e.HREF;
53
54
  t.textContent && (t.innerHTML = F(t, `{{${s}_${o}}}`));
54
55
  const c = t.closest("a") || (t.tagName === "A" ? t : null);
55
56
  if (c && l) {
56
- const i = c.href, _ = `${window.location.href}${a}`;
57
- (i === _ || i.endsWith(a)) && (c.href = `{{${l}_${o}}}`);
57
+ const i = c.href, R = `${window.location.href}${a}`;
58
+ (i === R || i.endsWith(a)) && (c.href = `{{${l}_${o}}}`);
58
59
  }
59
60
  break;
60
61
  }
61
62
  case "price":
62
63
  case "originalPrice": {
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);
64
+ const e = u, s = t.getAttribute("data-formated"), a = t.getAttribute("data-single_price"), l = s === "true", c = a === "true", i = t.getAttribute(N.POSITION) || "before";
65
+ let R;
66
+ c ? R = l ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : R = l ? e.PRICE_FORMATTED : e.PRICE;
67
+ const _ = e.CURRENCY;
68
+ let f = `{{${R}_${o}}}`;
69
+ const C = (t.getAttribute(N.SYMBOL) || "").trim(), V = C !== "" && C !== G.productPriceCurrencySymbolControlValue;
70
+ let y = "";
71
+ V ? y = C : _ && (y = `{{${_}_${o}}}`), y && (f = i === "after" ? `${f} ${y}` : `${y} ${f}`), t.innerHTML = F(t, f);
71
72
  break;
72
73
  }
73
74
  case "quantity": {
74
- const e = f, s = e.ATTR, a = e.DEFAULT;
75
+ const e = u, s = e.ATTR, a = e.DEFAULT;
75
76
  t.textContent && t.textContent.trim() === a && (t.innerHTML = F(t, `{{${s}_${o}}}`));
76
77
  break;
77
78
  }
78
79
  case "button": {
79
- const e = f, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t.tagName === "A" ? t : t.querySelector("a");
80
+ const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t.tagName === "A" ? t : t.querySelector("a");
80
81
  if (l) {
81
82
  const c = l.href || "", i = `${window.location.href}${a}`;
82
83
  (c === "" || c === "#" || c === i || c.endsWith(a) || c.endsWith("#!") || c === window.location.href) && (l.href = `{{${s}_${o}}}`);
@@ -84,7 +85,7 @@ function J(S) {
84
85
  break;
85
86
  }
86
87
  case "itemLink": {
87
- const e = f, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t;
88
+ const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t;
88
89
  if (l.href) {
89
90
  const c = l.href, i = `${window.location.href}${a}`;
90
91
  (c === i || c.endsWith(a)) && (l.href = `{{${s}_${o}}}`);
@@ -92,8 +93,8 @@ function J(S) {
92
93
  break;
93
94
  }
94
95
  default: {
95
- if ("ATTR" in f) {
96
- const e = f.ATTR;
96
+ if ("ATTR" in u) {
97
+ const e = u.ATTR;
97
98
  t.textContent && (t.innerHTML = F(t, `{{${e}_${o}}}`));
98
99
  }
99
100
  break;
@@ -102,9 +103,9 @@ function J(S) {
102
103
  });
103
104
  });
104
105
  });
105
- const I = H.match(/<!DOCTYPE[^>]*>/i), O = I ? `${I[0]}
106
- ` : "", q = g.querySelectorAll(".ins-product-td"), M = [];
107
- q.forEach((n) => {
106
+ const P = I.match(/<!DOCTYPE[^>]*>/i), q = P ? `${P[0]}
107
+ ` : "", U = b.querySelectorAll(".ins-product-td"), M = [];
108
+ U.forEach((n) => {
108
109
  const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
109
110
  M.push({
110
111
  element: n,
@@ -113,16 +114,16 @@ function J(S) {
113
114
  number: p
114
115
  });
115
116
  });
116
- let A = O + g.documentElement.outerHTML;
117
+ let A = q + b.documentElement.outerHTML;
117
118
  M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
118
119
  const r = x[d], E = r ? `${r}_total_product_kind` : "";
119
120
  if (E) {
120
- const h = parseInt(p) - 1, o = `${`{% if ${E} > ${h} %}`}${n}{% endif %}`;
121
- A = A.replace(n, G(o));
121
+ const T = parseInt(p) - 1, o = `${`{% if ${E} > ${T} %}`}${n}{% endif %}`;
122
+ A = A.replace(n, X(o));
122
123
  }
123
124
  });
124
- const U = g.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
125
- return U.forEach((n) => {
125
+ const W = b.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
126
+ return W.forEach((n) => {
126
127
  var t;
127
128
  const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
128
129
  if (!d || !x[p])
@@ -131,20 +132,20 @@ function J(S) {
131
132
  if (!r || k.has(r))
132
133
  return;
133
134
  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);
135
+ const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), T = w.get(E) ?? { number: d, type: p, wrap: [] };
136
+ T.wrap.push(m !== "false"), w.set(E, T);
136
137
  }), w.forEach(({ number: n, type: d, wrap: p }, r) => {
137
138
  if (r.includes("{% if") || !p.some(Boolean))
138
139
  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);
140
+ const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T, O(T)];
141
+ let g = "", o = 0, u = 0, $ = A.indexOf(r);
142
+ for (; $ !== -1; ) {
143
+ const H = p[u] === !0 && !v(A, $, t);
144
+ g += A.slice(o, $) + (H ? `${T}${r}{% endif %}` : r), o = $ + r.length, u += 1, $ = A.indexOf(r, o);
144
145
  }
145
- A = R + A.slice(o);
146
+ A = g + A.slice(o);
146
147
  }), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
147
148
  }
148
149
  export {
149
- J as pairProductVariables
150
+ Z as pairProductVariables
150
151
  };
@@ -1,27 +1,27 @@
1
- import { useActionsApi as R } from "../composables/useActionsApi.js";
1
+ import { useActionsApi as k } from "../composables/useActionsApi.js";
2
2
  import { useConfig as U } from "../composables/useConfig.js";
3
3
  import { useHtmlCompiler as x } from "../composables/useHtmlCompiler.js";
4
4
  import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
- import { useRecommendationExtensionStore as T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
6
  import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
7
7
  import { DATA_ATTRIBUTES as A } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
- import { parsePageList as N } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
- import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
10
- import { useEditorStore as _ } from "../stores/editor.js";
11
- import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
12
- import { assignTrackingIds as O } from "./linkTrackingIds.js";
13
- function M(m) {
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
14
  const n = new DOMParser().parseFromString(m, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
15
15
  return n.forEach((i) => {
16
16
  const o = i.getAttribute(A.PAGE_LIST);
17
- o && t.push(...N(o));
17
+ o && t.push(...R(o));
18
18
  }), [...new Set(t)];
19
19
  }
20
- async function C(m) {
20
+ async function M(m) {
21
21
  const a = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
22
22
  if (a.length === 0)
23
23
  return;
24
- const n = T();
24
+ const n = C();
25
25
  a.forEach((t) => {
26
26
  var r, l, g, f, c;
27
27
  const i = t.getAttribute("recommendation-id"), o = i ? Number(i) : NaN;
@@ -68,39 +68,39 @@ async function C(m) {
68
68
  }
69
69
  }
70
70
  const Z = () => {
71
- const m = z(), u = _(), a = v(), { getCompiledEmail: n, getTemplateData: t, updateHtmlAndCss: i } = R(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
71
+ const m = N(), u = z(), a = _(), { getCompiledEmail: n, getTemplateData: t, updateHtmlAndCss: i } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
72
72
  return {
73
73
  prepareTemplateDetails: async () => {
74
74
  let { html: r, css: l, syncModulesIds: g = [] } = await t();
75
75
  if (e("linkTrackingIds"))
76
76
  try {
77
- const { html: y, changed: I, nextSeq: k } = O(r, u.trackIdSessionFloor);
78
- u.trackIdSessionFloor = k, I && (r = y, await i(y, l));
77
+ const { html: y, changed: H, nextSeq: I } = v(r, u.trackIdSessionFloor);
78
+ u.trackIdSessionFloor = I, H && (r = y, await i(y, l));
79
79
  } catch (y) {
80
80
  console.error("Tracking-id step failed, saving anyway:", y);
81
81
  }
82
- const { html: f, ampHtml: c = "", ampErrors: w = [] } = await n({
82
+ const { html: f, ampHtml: c = "", ampErrors: T = [] } = await n({
83
83
  minimize: !0,
84
84
  resetDataSavedFlag: !1
85
85
  });
86
- a.selectedUnsubscribePages.length && await a.fetchTemplates(), await C(r);
87
- const { compiledHtml: D, stats: S, appliedRules: E } = o(f), P = c && p(c).compiledHtml, F = m.getSelectedDynamicContentList, H = T(), b = M(r);
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);
88
88
  return console.debug("HTML Compilation Stats:", {
89
89
  originalSize: S.originalSize,
90
90
  compiledSize: S.compiledSize,
91
91
  reduction: `${S.reductionPercentage.toFixed(2)}%`,
92
- appliedRules: E,
92
+ appliedRules: D,
93
93
  executionTime: `${S.executionTime.toFixed(2)}ms`
94
94
  }), {
95
- dynamicContentList: F,
96
- compiledHtml: D,
95
+ dynamicContentList: P,
96
+ compiledHtml: w,
97
97
  rawHtml: r,
98
98
  css: l,
99
- ampHtml: P,
100
- ampErrors: w,
99
+ ampHtml: E,
100
+ ampErrors: T,
101
101
  modules: g.map(Number),
102
102
  recommendation: {
103
- campaignUrls: H.recommendationCampaignUrls,
103
+ campaignUrls: F.recommendationCampaignUrls,
104
104
  configs: {}
105
105
  },
106
106
  unsubscribe: {
@@ -108,13 +108,10 @@ const Z = () => {
108
108
  config: b
109
109
  }
110
110
  };
111
- },
112
- // Exposed so the back/test validate-only path can seed the reco store the
113
- // same way a full save does (required-field findings depend on it).
114
- hydrateRecommendationStore: C
111
+ }
115
112
  };
116
113
  };
117
114
  export {
118
- M as getHtmlReferencedUnsubscribePages,
115
+ O as getHtmlReferencedUnsubscribePages,
119
116
  Z as useTemplatePreparation
120
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.17.0-beta.ea65303",
3
+ "version": "3.17.0-beta.eae947f",
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",
@@ -25,7 +25,7 @@
25
25
  "start": "vite",
26
26
  "build": "vite build && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.app.json",
27
27
  "preview": "vite preview",
28
- "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
28
+ "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && npm run type-check",
29
29
  "lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
30
30
  "lint:e2e-quality": "node scripts/lint-e2e-quality.mjs",
31
31
  "lint:e2e-quality:ci": "node scripts/lint-e2e-quality.mjs --ci",
@@ -1,20 +0,0 @@
1
- import a from "./ValidationErrorDrawer.vue2.js";
2
- /* empty css */
3
- import s from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var i = function() {
5
- var r = this, o = r._self._c, t = r._self._setupProxy;
6
- return o(t.WpDrawer, { attrs: { id: "guido__validation-error-drawer", size: "small", "footer-button-group-options": t.footerButtonGroupOptions, status: t.store.isDrawerOpen, "title-text": t.titleText }, on: { onCloseEvent: t.handleClose, primaryButtonEvent: t.handleClose, secondaryButtonEvent: t.handleSaveAndContinue } }, [o("div", { staticClass: "d-f f-d-c validation-error-list" }, r._l(t.rows, function(e, n) {
7
- return o("div", { key: n, staticClass: "d-f a-i-c validation-error-row" }, [o(t.InIcons, { staticClass: "validation-error-row__icon i-c-12", attrs: { name: "filled-caution-triangle" } }), o("span", { staticClass: "validation-error-row__text" }, [r._v(r._s(e))])], 1);
8
- }), 0)]);
9
- }, l = [], _ = /* @__PURE__ */ s(
10
- a,
11
- i,
12
- l,
13
- !1,
14
- null,
15
- "30d2e1f9"
16
- );
17
- const p = _.exports;
18
- export {
19
- p as default
20
- };
@@ -1,48 +0,0 @@
1
- import { defineComponent as m, ref as p, computed as a } from "vue";
2
- import f from "../../wrappers/WpDrawer.vue.js";
3
- import { useSave as S } from "../../../composables/useSave.js";
4
- import { useTranslations as v } from "../../../composables/useTranslations.js";
5
- import { useConfigStore as g } from "../../../stores/config.js";
6
- import { useEditorStore as y } from "../../../stores/editor.js";
7
- import { useSaveValidationStore as h } from "../../../stores/save-validation.js";
8
- import { InIcons as w } from "@useinsider/design-system-vue";
9
- const I = /* @__PURE__ */ m({
10
- __name: "ValidationErrorDrawer",
11
- setup(_) {
12
- const r = v(), e = h(), n = y(), s = g(), { saveWithErrors: i } = S(), o = p(!1), l = a(() => `${r("email-editor.validation-errors")} (${e.errorCount})`), u = a(() => {
13
- const t = {
14
- primaryButton: {
15
- styling: "solid",
16
- type: "primary",
17
- labelText: r("email-editor.update-design")
18
- }
19
- };
20
- return s.allowSaveWithErrors && e.intent !== "test" && (t.secondaryButton = {
21
- styling: "solid",
22
- type: "subtle-primary",
23
- labelText: r("email-editor.save-and-continue"),
24
- loadingStatus: o.value
25
- }), t;
26
- }), d = a(() => e.errors.map((t) => {
27
- const c = t.detail ? ` (${t.detail})` : "";
28
- return `${t.message}${c}`;
29
- }));
30
- return { __sfc: !0, trans: r, store: e, editorStore: n, configStore: s, saveWithErrors: i, isSaving: o, titleText: l, footerButtonGroupOptions: u, rows: d, handleClose: () => {
31
- e.isDrawerOpen && e.close();
32
- }, handleSaveAndContinue: async () => {
33
- if (!o.value) {
34
- o.value = !0, n.loadingStatus = !0;
35
- try {
36
- await i() ? e.close() : n.loadingStatus = !1;
37
- } catch (t) {
38
- console.warn("Soft-save failed; keeping the drawer open.", t), n.loadingStatus = !1;
39
- } finally {
40
- o.value = !1;
41
- }
42
- }
43
- }, WpDrawer: f, InIcons: w };
44
- }
45
- });
46
- export {
47
- I as default
48
- };