@useinsider/guido 3.24.0-beta.82c2d5e → 3.24.0-beta.89982ef

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 (84) hide show
  1. package/README.md +1 -9
  2. package/dist/@types/config/schemas.js +37 -37
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +4 -4
  5. package/dist/components/Guido.vue2.js +82 -80
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +17 -0
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +41 -0
  8. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +81 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +17 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +45 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +36 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +63 -0
  14. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  15. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  16. package/dist/composables/useBlocksConfig.js +31 -20
  17. package/dist/composables/useDisplayConditions.js +117 -0
  18. package/dist/composables/useModuleRepair.js +23 -32
  19. package/dist/composables/useTranslations.js +2 -1
  20. package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
  21. package/dist/config/compiler/utils/recommendationCompilerUtils.js +67 -64
  22. package/dist/config/migrator/index.js +9 -10
  23. package/dist/enums/academy.js +2 -2
  24. package/dist/enums/display-condition.js +12 -0
  25. package/dist/extensions/DisplayConditions/bridge.js +25 -0
  26. package/dist/extensions/DisplayConditions/constants.js +26 -0
  27. package/dist/extensions/DisplayConditions/control.js +215 -0
  28. package/dist/extensions/DisplayConditions/display-conditions.css.js +226 -0
  29. package/dist/extensions/DisplayConditions/extension.js +28 -0
  30. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  31. package/dist/extensions/DisplayConditions/library.js +30 -0
  32. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  33. package/dist/extensions/LinkTracking/extension.js +17 -0
  34. package/dist/extensions/LinkTracking/writer.js +41 -0
  35. package/dist/guido.css +1 -1
  36. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  37. package/dist/node_modules/valibot/dist/index.js +297 -261
  38. package/dist/package.json.js +1 -1
  39. package/dist/services/displayConditionApi.js +39 -0
  40. package/dist/src/@types/config/schemas.d.ts +4 -4
  41. package/dist/src/@types/display-condition.d.ts +61 -0
  42. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  43. package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +18 -0
  44. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  45. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  46. package/dist/src/composables/useConfig.d.ts +2 -2
  47. package/dist/src/composables/useDisplayConditions.d.ts +18 -0
  48. package/dist/src/composables/useModuleRepair.d.ts +11 -2
  49. package/dist/src/enums/academy.d.ts +1 -1
  50. package/dist/src/enums/display-condition.d.ts +15 -0
  51. package/dist/src/extensions/DisplayConditions/bridge.d.ts +7 -0
  52. package/dist/src/extensions/DisplayConditions/constants.d.ts +23 -0
  53. package/dist/src/extensions/DisplayConditions/control.d.ts +25 -0
  54. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  55. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  56. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  57. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  58. package/dist/src/extensions/LinkTracking/extension.d.ts +2 -0
  59. package/dist/src/extensions/LinkTracking/writer.d.ts +13 -0
  60. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  61. package/dist/src/services/displayConditionApi.d.ts +8 -0
  62. package/dist/src/stores/config.d.ts +167 -20
  63. package/dist/src/stores/display-condition.d.ts +86 -0
  64. package/dist/src/stores/editor.d.ts +0 -27
  65. package/dist/src/utils/displayCondition.d.ts +11 -0
  66. package/dist/src/utils/linkTrackingIds.d.ts +22 -5
  67. package/dist/src/utils/protectTableText.d.ts +2 -0
  68. package/dist/static/styles/variables.css.js +1 -0
  69. package/dist/stores/config.js +13 -6
  70. package/dist/stores/display-condition.js +29 -0
  71. package/dist/stores/editor.js +0 -1
  72. package/dist/utils/displayCondition.js +29 -0
  73. package/dist/utils/linkTrackingIds.js +82 -48
  74. package/dist/utils/pairProductVariables.js +30 -29
  75. package/dist/utils/protectTableText.js +22 -0
  76. package/dist/utils/templatePreparation.js +67 -57
  77. package/package.json +1 -1
  78. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +0 -17
  79. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +0 -30
  80. package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +0 -16
  81. package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +0 -1
  82. package/dist/src/utils/legacyUnsubscribeConversion.d.ts +0 -10
  83. package/dist/utils/legacyUnsubscribeConversion.js +0 -49
  84. /package/dist/src/components/organisms/{unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts → display-conditions/DisplayConditionCreateDrawer.vue.d.ts} +0 -0
@@ -2,34 +2,35 @@ import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extens
2
2
  import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
3
3
  import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
4
  import { preserveTextStyles as L } from "./preserveTextStyles.js";
5
- import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
5
+ import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
6
+ import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
6
7
  const q = {
7
8
  CART_ITEMS: "ins_apr",
8
9
  BROWSED_ITEMS: "browsed_item",
9
10
  PURCHASED_ITEMS: "purchased_item"
10
11
  }, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
- function v($, C, A) {
12
+ function Q($, C, A) {
12
13
  let d = C;
13
14
  for (; d > 0 && /\s/.test($[d - 1]); )
14
15
  d -= 1;
15
16
  return A.some((E) => $.endsWith(E, d));
16
17
  }
17
- const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
18
- function Q($, C) {
18
+ const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
19
+ function J($, C) {
19
20
  var d;
20
21
  const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
21
22
  for (let E = A.nextNode(); E; E = A.nextNode())
22
- (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(j, (k, P) => `${P}href="${C}"`));
23
+ (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
23
24
  }
24
- function et($) {
25
- const C = W($), A = new DOMParser().parseFromString(C, "text/html");
26
- X(A);
25
+ function ot($) {
26
+ const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
27
+ j(A);
27
28
  const d = M.PAIRS_FOR_EXTENSION;
28
29
  Object.entries(d).forEach(([o, p]) => {
29
30
  A.querySelectorAll(".ins-product-td").forEach((r) => {
30
31
  const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
31
32
  r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
32
- var S, I, O, x;
33
+ var b, I, D, O;
33
34
  const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
34
35
  if (f)
35
36
  switch (o) {
@@ -45,12 +46,12 @@ function et($) {
45
46
  return a.includes(g) || a.includes(u) || H === u;
46
47
  }) && (e.src = `{{${c}_${n}}}`);
47
48
  }
48
- const i = (I = (S = d.name) == null ? void 0 : S[m]) == null ? void 0 : I.ATTR;
49
+ const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
49
50
  if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
50
- const a = (O = d.itemLink) == null ? void 0 : O[m];
51
+ const a = (D = d.itemLink) == null ? void 0 : D[m];
51
52
  if (a) {
52
- const b = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
53
- (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${b}_${n}}}`);
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}}}`);
54
55
  }
55
56
  }
56
57
  break;
@@ -60,25 +61,25 @@ function et($) {
60
61
  t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
61
62
  const i = t.closest("a") || (t.tagName === "A" ? t : null);
62
63
  if (i && c) {
63
- const a = i.href, b = `${window.location.href}${l}`;
64
- (a === b || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
64
+ const a = i.href, S = `${window.location.href}${l}`;
65
+ (a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
65
66
  }
66
67
  break;
67
68
  }
68
69
  case "price":
69
70
  case "originalPrice": {
70
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";
71
- let b;
72
- i ? b = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : b = c ? e.PRICE_FORMATTED : e.PRICE;
72
+ let S;
73
+ i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
73
74
  const g = e.CURRENCY;
74
- let u = `{{${b}_${n}}}`;
75
+ let u = `{{${S}_${n}}}`;
75
76
  const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
76
77
  let F = "";
77
78
  G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
78
79
  break;
79
80
  }
80
81
  case "quantity": {
81
- const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (x = t.textContent) == null ? void 0 : x.trim();
82
+ const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
82
83
  c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
83
84
  break;
84
85
  }
@@ -88,7 +89,7 @@ function et($) {
88
89
  const i = c.href || "", a = `${window.location.href}${l}`;
89
90
  (i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
90
91
  }
91
- Q(t, `{{${s}_${n}}}`);
92
+ J(t, `{{${s}_${n}}}`);
92
93
  break;
93
94
  }
94
95
  case "itemLink": {
@@ -129,30 +130,30 @@ function et($) {
129
130
  h = h.replace(o, B(n));
130
131
  }
131
132
  });
132
- const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set();
133
+ const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
133
134
  return V.forEach((o) => {
134
135
  var t;
135
136
  const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
136
137
  if (!p || !q[T])
137
138
  return;
138
139
  const r = o.closest(".product-original-price-class");
139
- if (!r || D.has(r))
140
+ if (!r || x.has(r))
140
141
  return;
141
- D.add(r);
142
+ x.add(r);
142
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: [] };
143
144
  R.wrap.push(y !== "false"), w.set(_, R);
144
145
  }), w.forEach(({ number: o, type: p, wrap: T }, r) => {
145
146
  if (r.includes("{% if") || !T.some(Boolean))
146
147
  return;
147
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)];
148
- let m = "", n = 0, f = 0, S = h.indexOf(r);
149
- for (; S !== -1; ) {
150
- const I = T[f] === !0 && !v(h, S, t);
151
- m += h.slice(n, S) + (I ? `${R}${r}{% endif %}` : r), n = S + r.length, f += 1, S = h.indexOf(r, n);
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);
152
153
  }
153
154
  h = m + h.slice(n);
154
- }), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
155
+ }), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
155
156
  }
156
157
  export {
157
- et as pairProductVariables
158
+ ot as pairProductVariables
158
159
  };
@@ -0,0 +1,22 @@
1
+ const n = "guido-table-text:", i = new RegExp(`<!--${n}([A-Za-z0-9+/=]*)-->`, "g"), T = /<!--[\s\S]*?-->|\{%[\s\S]*?%\}|<[a-zA-Z/!?](?:[^>"']|"[^"]*"|'[^']*')*>|[^<{]+|[<{]/g, o = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr", "colgroup"]), r = /* @__PURE__ */ new Set(["col"]), f = /* @__PURE__ */ new Set([...o, ...r, "td", "th", "caption"]), p = (s) => btoa(unescape(encodeURIComponent(s))), u = (s) => decodeURIComponent(escape(atob(s))), d = (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 E(s) {
6
+ const e = [];
7
+ let a = !1;
8
+ return s.replace(T, (t) => {
9
+ if (t.startsWith("<!--") || t.startsWith("{%"))
10
+ return t;
11
+ if (t.length > 1 && t.startsWith("<")) {
12
+ const { name: c, closing: l } = d(t);
13
+ return a = f.has(c), !a || r.has(c) || (l ? e.includes(c) && e.splice(e.lastIndexOf(c)) : e.push(c)), t;
14
+ }
15
+ return a && o.has(e[e.length - 1] ?? "") && t.trim() ? `<!--${n}${p(t)}-->` : t;
16
+ });
17
+ }
18
+ const g = (s) => s.replace(i, (e, a) => u(a));
19
+ export {
20
+ E as protectTableText,
21
+ g as restoreTableText
22
+ };
@@ -1,44 +1,45 @@
1
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
- import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
- import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
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
- const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
15
- return r.forEach((i) => {
16
- const t = i.getAttribute(g.PAGE_LIST);
17
- t && e.push(...U(t));
2
+ import { useConfig as R } from "../composables/useConfig.js";
3
+ import { useHtmlCompiler as U } from "../composables/useHtmlCompiler.js";
4
+ import { useRecommendationExtensionStore as k } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { toBlockUrlConfig as L } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
+ import { DATA_ATTRIBUTES as b } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
+ import { parsePageList as v } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
+ import { writeTrackingIdsInPlace as N } from "../extensions/LinkTracking/writer.js";
9
+ import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
10
+ import { useEditorStore as q } from "../stores/editor.js";
11
+ import { useUnsubscribeStore as M } from "../stores/unsubscribe.js";
12
+ import { isPlainObject as O } from "./genericUtil.js";
13
+ import { planDocumentTrackingIds as T, renderTrackingIdPlan as B } from "./linkTrackingIds.js";
14
+ function _(c) {
15
+ const i = new DOMParser().parseFromString(c, "text/html").querySelectorAll(`[${b.PAGE_LIST}]`), e = [];
16
+ return i.forEach((s) => {
17
+ const o = s.getAttribute(b.PAGE_LIST);
18
+ o && e.push(...v(o));
18
19
  }), [...new Set(e)];
19
20
  }
20
- async function S(n) {
21
- const o = new DOMParser().parseFromString(n, "text/html").querySelectorAll(".recommendation-block-v2");
22
- if (o.length === 0)
21
+ async function w(c) {
22
+ const a = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
23
+ if (a.length === 0)
23
24
  return;
24
- const r = b();
25
- o.forEach((e) => {
26
- const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
27
- if (!Number.isFinite(t))
25
+ const i = k();
26
+ a.forEach((e) => {
27
+ const s = e.getAttribute("recommendation-id"), o = s ? Number(s) : NaN;
28
+ if (!Number.isFinite(o))
28
29
  return;
29
- const m = e.getAttribute("esd-ext-config");
30
- if (!m)
30
+ const l = e.getAttribute("esd-ext-config");
31
+ if (!l)
31
32
  return;
32
- let a;
33
+ let m;
33
34
  try {
34
- a = JSON.parse(m);
35
+ m = JSON.parse(l);
35
36
  } catch {
36
37
  return;
37
38
  }
38
- z(a) && r.seedBlockUrlConfig(t, R(a));
39
+ O(m) && i.seedBlockUrlConfig(o, L(m));
39
40
  });
40
41
  try {
41
- await r.fetchRecommendationCreateData();
42
+ await i.fetchRecommendationCreateData();
42
43
  } catch (e) {
43
44
  console.warn(
44
45
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -46,54 +47,63 @@ async function S(n) {
46
47
  );
47
48
  }
48
49
  }
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();
50
+ const oe = () => {
51
+ const c = z(), n = q(), a = M(), { getCompiledEmail: i, getTemplateData: e, updateHtmlAndCss: s } = E(), { compileHtml: o, compileAmpHtml: l } = U(), { isFeatureEnabled: m } = R();
51
52
  return {
52
- prepareTemplateDetails: async (h) => {
53
- let { html: s, css: u, syncModulesIds: y = [] } = h ?? await e();
54
- if (a("linkTrackingIds"))
53
+ prepareTemplateDetails: async (y) => {
54
+ let { html: r, css: u, syncModulesIds: g = [] } = y ?? await e();
55
+ if (m("linkTrackingIds"))
55
56
  try {
56
- const { html: d, changed: x, nextSeq: D } = M(s, c.trackIdSessionFloor);
57
- c.trackIdSessionFloor = D, x && (s = d, await i(d, u));
58
- } catch (d) {
59
- console.error("Tracking-id step failed, saving anyway:", d);
57
+ let t = T(r, n.trackIdSessionFloor);
58
+ n.trackIdSessionFloor = t.plan.nextSeq;
59
+ let p = t.plan.changed;
60
+ if (p && N(t)) {
61
+ const h = await e().catch((x) => (console.warn(
62
+ "Tracking-id re-read failed, saving the planned ids without a replacement:",
63
+ x
64
+ ), null));
65
+ h ? ({ html: r, css: u, syncModulesIds: g = [] } = h, t = T(r, n.trackIdSessionFloor), n.trackIdSessionFloor = t.plan.nextSeq, p = t.plan.changed) : p = !1;
66
+ }
67
+ t.plan.changed && (r = B(r, t)), p && await s(r, u);
68
+ } catch (t) {
69
+ console.error("Tracking-id step failed, saving anyway:", t);
60
70
  }
61
- const { html: T, ampHtml: p = "", ampErrors: A = [] } = await r({
71
+ const { html: A, ampHtml: f = "", ampErrors: P = [] } = await i({
62
72
  minimize: !0,
63
73
  resetDataSavedFlag: !1
64
74
  });
65
- o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
66
- const { compiledHtml: w, stats: l, appliedRules: C } = t(T), H = p && m(p).compiledHtml, k = n.getSelectedDynamicContentList, P = b(), f = O(s);
75
+ a.selectedUnsubscribePages.length && await a.fetchTemplates(), await w(r);
76
+ const { compiledHtml: C, stats: d, appliedRules: I } = o(A), H = f && l(f).compiledHtml, D = c.getSelectedDynamicContentList, F = k(), S = _(r);
67
77
  return console.debug("HTML Compilation Stats:", {
68
- originalSize: l.originalSize,
69
- compiledSize: l.compiledSize,
70
- reduction: `${l.reductionPercentage.toFixed(2)}%`,
71
- appliedRules: C,
72
- executionTime: `${l.executionTime.toFixed(2)}ms`
78
+ originalSize: d.originalSize,
79
+ compiledSize: d.compiledSize,
80
+ reduction: `${d.reductionPercentage.toFixed(2)}%`,
81
+ appliedRules: I,
82
+ executionTime: `${d.executionTime.toFixed(2)}ms`
73
83
  }), {
74
- dynamicContentList: k,
75
- compiledHtml: w,
76
- rawHtml: s,
84
+ dynamicContentList: D,
85
+ compiledHtml: C,
86
+ rawHtml: r,
77
87
  css: u,
78
88
  ampHtml: H,
79
- ampErrors: A,
80
- modules: y.map(Number),
89
+ ampErrors: P,
90
+ modules: g.map(Number),
81
91
  recommendation: {
82
- campaignUrls: P.recommendationCampaignUrls,
92
+ campaignUrls: F.recommendationCampaignUrls,
83
93
  configs: {}
84
94
  },
85
95
  unsubscribe: {
86
- status: f.length > 0,
87
- config: f
96
+ status: S.length > 0,
97
+ config: S
88
98
  }
89
99
  };
90
100
  },
91
101
  // Exposed so the back/test validate-only path can seed the reco store the
92
102
  // same way a full save does (required-field findings depend on it).
93
- hydrateRecommendationStore: S
103
+ hydrateRecommendationStore: w
94
104
  };
95
105
  };
96
106
  export {
97
- O as getHtmlReferencedUnsubscribePages,
98
- Z as useTemplatePreparation
107
+ _ as getHtmlReferencedUnsubscribePages,
108
+ oe as useTemplatePreparation
99
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.24.0-beta.82c2d5e",
3
+ "version": "3.24.0-beta.89982ef",
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",
@@ -1,17 +0,0 @@
1
- import s from "./LegacyUnsubscribeConvertedModal.vue2.js";
2
- import r from "../../../_virtual/_plugin-vue2_normalizer.js";
3
- var n = function() {
4
- var o = this, t = o._self._c, e = o._self._setupProxy;
5
- return e.isVisible ? t(e.WpModal, { attrs: { id: "guido__legacy-unsubscribe-converted-modal", "close-on-outside-click": !1, "footer-button-options": e.footerButtonOptions, title: e.trans("email-editor.legacy-unsubscribe-converted-modal-title") }, on: { close: e.close, "primary-action": e.close, "secondary-action": e.openAcademy } }, [t("p", [o._v(o._s(e.trans("email-editor.legacy-unsubscribe-converted-modal-message")))])]) : o._e();
6
- }, a = [], c = /* @__PURE__ */ r(
7
- s,
8
- n,
9
- a,
10
- !1,
11
- null,
12
- null
13
- );
14
- const d = c.exports;
15
- export {
16
- d as default
17
- };
@@ -1,30 +0,0 @@
1
- import { defineComponent as n, computed as t } from "vue";
2
- import i from "../../wrappers/WpModal.vue.js";
3
- import { useTranslations as a } from "../../../composables/useTranslations.js";
4
- import { ACADEMY_LINKS as c } from "../../../enums/academy.js";
5
- import { useEditorStore as p } from "../../../stores/editor.js";
6
- const L = /* @__PURE__ */ n({
7
- __name: "LegacyUnsubscribeConvertedModal",
8
- setup(d) {
9
- const o = a(), e = p(), r = t(
10
- () => e.isLegacyUnsubscribeModalRequested && e.isStripoInitialized
11
- ), s = t(() => ({
12
- secondaryButton: {
13
- type: "subtle-primary",
14
- labelText: o("email-editor.legacy-unsubscribe-converted-modal-visit-academy")
15
- },
16
- primaryButton: {
17
- type: "primary",
18
- labelText: o("action-builder.ok")
19
- }
20
- }));
21
- return { __sfc: !0, trans: o, editorStore: e, isVisible: r, footerButtonOptions: s, close: () => {
22
- e.isLegacyUnsubscribeModalRequested = !1;
23
- }, openAcademy: () => {
24
- window.open(c.LEGACY_UNSUBSCRIBE_MODULE, "_blank", "noopener,noreferrer");
25
- }, WpModal: i };
26
- }
27
- });
28
- export {
29
- L as default
30
- };
@@ -1,16 +0,0 @@
1
- import { useConfigStore as o } from "../../stores/config.js";
2
- import { useEditorStore as s } from "../../stores/editor.js";
3
- import { hasLegacyUnsubscribeClass as c, convertLegacyUnsubscribeInDocumentHtml as i } from "../../utils/legacyUnsubscribeConversion.js";
4
- const b = (e) => {
5
- try {
6
- if (!c(e) || !o().isFeatureEnabled("legacyUnsubscribeConversion"))
7
- return e;
8
- const { html: r, converted: t } = i(e);
9
- return t && (s().isLegacyUnsubscribeModalRequested = !0), r;
10
- } catch (r) {
11
- return console.error("LegacyUnsubscribeTextMigrator failed:", r), e;
12
- }
13
- };
14
- export {
15
- b as migrateLegacyUnsubscribeText
16
- };
@@ -1 +0,0 @@
1
- export declare const migrateLegacyUnsubscribeText: (html: string) => string;
@@ -1,10 +0,0 @@
1
- export declare const LEGACY_UNSUBSCRIBE_SELECTOR = "td.unsubscribe-block";
2
- export declare const LEGACY_UNSUBSCRIBE_LINK_SELECTORS: readonly ["a.unsubscribe-link", "a[href*=\"unsubscribe\"]"];
3
- export interface LegacyUnsubscribeConversionResult {
4
- html: string;
5
- converted: boolean;
6
- }
7
- export declare const hasLegacyUnsubscribeClass: (html: string) => boolean;
8
- export declare const convertLinklessLegacyUnsubscribeBlocks: (root: ParentNode) => number;
9
- export declare const convertLegacyUnsubscribeInModuleHtml: (html: string) => LegacyUnsubscribeConversionResult;
10
- export declare const convertLegacyUnsubscribeInDocumentHtml: (html: string) => LegacyUnsubscribeConversionResult;
@@ -1,49 +0,0 @@
1
- import { protectLiquid as a, restoreLiquid as u } from "./liquidProtection.js";
2
- const b = "td.unsubscribe-block", l = ["a.unsubscribe-link", 'a[href*="unsubscribe"]'], d = "esd-block-text", m = [
3
- "unsubscribe-block",
4
- "esd-extension",
5
- "esd-extension-block",
6
- "esd-unsubscribe-block",
7
- "esd-block-unsubscribe"
8
- ], L = "esd-extension-block-id", S = "data-unsubscribe-", E = "address,article,aside,blockquote,center,details,dialog,dir,div,dd,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,listing,main,menu,nav,ol,p,plaintext,pre,search,section,summary,table,ul,xmp", f = new RegExp(`class\\s*=\\s*(?:["'][^"']*)?(?<![\\w-])unsubscribe-block(?![\\w-])`, "i"), p = (e) => typeof e == "string" && f.test(e), y = (e) => l.some((t) => e.querySelector(t) !== null), g = (e) => {
9
- e.classList.remove(...m), e.classList.add(d), e.removeAttribute(L), Array.from(e.attributes).filter(({ name: t }) => t.startsWith(S)).forEach(({ name: t }) => e.removeAttribute(t)), e.querySelector(E) || (e.innerHTML = `<p path="1">${e.innerHTML}</p>`);
10
- }, h = (e) => {
11
- const t = Array.from(e.querySelectorAll(b)).filter((r) => !y(r));
12
- return t.forEach(g), t.length;
13
- }, v = (e) => {
14
- const t = e.trimStart(), r = new DOMParser();
15
- return /^<t[dh][\s>]/i.test(t) ? r.parseFromString(`<table><tbody><tr>${e}</tr></tbody></table>`, "text/html").querySelector("tr") : /^<tr[\s>]/i.test(t) ? r.parseFromString(`<table><tbody>${e}</tbody></table>`, "text/html").querySelector("tbody") : /^<table[\s>]/i.test(t) ? r.parseFromString(e, "text/html").body : (console.debug("[LegacyUnsubscribeConversion] Skipped module with a non-table root"), null);
16
- }, c = (e) => {
17
- const t = e.search(/<html[\s>]/i), r = [...e.matchAll(/<\/html\s*>/gi)].at(-1), s = (r == null ? void 0 : r.index) === void 0 ? -1 : r.index + r[0].length;
18
- return t < 0 || s <= t ? { head: "", root: e, tail: "" } : { head: e.slice(0, t), root: e.slice(t, s), tail: e.slice(s) };
19
- }, i = (e, t, r, s) => {
20
- if (!p(e))
21
- return { html: e, converted: !1 };
22
- try {
23
- const o = a(e), n = t(o);
24
- return !n || h(n) === 0 ? { html: e, converted: !1 } : { html: u(r(n, o)), converted: !0 };
25
- } catch (o) {
26
- return console.error(`Failed to convert legacy unsubscribe blocks in ${s}:`, o), { html: e, converted: !1 };
27
- }
28
- }, C = (e) => i(
29
- e,
30
- v,
31
- (t) => t.innerHTML,
32
- "module"
33
- ), _ = (e) => i(
34
- e,
35
- (t) => new DOMParser().parseFromString(c(t).root, "text/html"),
36
- (t, r) => {
37
- const { head: s, tail: o } = c(r);
38
- return `${s}${t.documentElement.outerHTML}${o}`;
39
- },
40
- "document"
41
- );
42
- export {
43
- l as LEGACY_UNSUBSCRIBE_LINK_SELECTORS,
44
- b as LEGACY_UNSUBSCRIBE_SELECTOR,
45
- _ as convertLegacyUnsubscribeInDocumentHtml,
46
- C as convertLegacyUnsubscribeInModuleHtml,
47
- h as convertLinklessLegacyUnsubscribeBlocks,
48
- p as hasLegacyUnsubscribeClass
49
- };