@useinsider/guido 3.23.0-beta.ff29317 → 3.24.0-beta.0abeefe

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 (72) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +39 -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 +98 -92
  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/useTranslations.js +2 -1
  19. package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
  20. package/dist/config/compiler/utils/recommendationCompilerUtils.js +67 -64
  21. package/dist/enums/academy.js +1 -0
  22. package/dist/enums/display-condition.js +12 -0
  23. package/dist/extensions/DisplayConditions/bridge.js +25 -0
  24. package/dist/extensions/DisplayConditions/constants.js +26 -0
  25. package/dist/extensions/DisplayConditions/control.js +215 -0
  26. package/dist/extensions/DisplayConditions/display-conditions.css.js +226 -0
  27. package/dist/extensions/DisplayConditions/extension.js +28 -0
  28. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  29. package/dist/extensions/DisplayConditions/library.js +30 -0
  30. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  31. package/dist/extensions/LinkTracking/extension.js +17 -0
  32. package/dist/extensions/LinkTracking/writer.js +41 -0
  33. package/dist/guido.css +1 -1
  34. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  35. package/dist/node_modules/valibot/dist/index.js +297 -261
  36. package/dist/package.json.js +6 -6
  37. package/dist/services/displayConditionApi.js +39 -0
  38. package/dist/src/@types/config/schemas.d.ts +4 -0
  39. package/dist/src/@types/display-condition.d.ts +60 -0
  40. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  41. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
  42. package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +18 -0
  43. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  44. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  45. package/dist/src/composables/useConfig.d.ts +2 -0
  46. package/dist/src/composables/useDisplayConditions.d.ts +18 -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 +7 -0
  50. package/dist/src/extensions/DisplayConditions/constants.d.ts +23 -0
  51. package/dist/src/extensions/DisplayConditions/control.d.ts +25 -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/extensions/LinkTracking/extension.d.ts +2 -0
  57. package/dist/src/extensions/LinkTracking/writer.d.ts +13 -0
  58. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  59. package/dist/src/services/displayConditionApi.d.ts +8 -0
  60. package/dist/src/stores/config.d.ts +167 -0
  61. package/dist/src/stores/display-condition.d.ts +84 -0
  62. package/dist/src/utils/displayCondition.d.ts +11 -0
  63. package/dist/src/utils/linkTrackingIds.d.ts +22 -5
  64. package/dist/src/utils/protectTableText.d.ts +2 -0
  65. package/dist/stores/config.js +13 -6
  66. package/dist/stores/display-condition.js +29 -0
  67. package/dist/utils/displayCondition.js +26 -0
  68. package/dist/utils/linkTrackingIds.js +82 -48
  69. package/dist/utils/pairProductVariables.js +30 -29
  70. package/dist/utils/protectTableText.js +22 -0
  71. package/dist/utils/templatePreparation.js +67 -57
  72. package/package.json +1 -1
@@ -1,56 +1,90 @@
1
- const g = "data-ins-track-id", $ = "data-ins-track-seq", E = `(?:[^>"']|"[^"]*"|'[^']*')*`, f = new RegExp(`<a\\b${E}>`, "gi"), b = new RegExp(`<body\\b${E}>`, "i"), N = new RegExp(`<html\\b${E}>`, "i"), I = new RegExp(`\\b${g}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), S = new RegExp(`\\b${$}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", _ = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), w = /^[1-9][0-9]{0,14}$/, k = 999999999999999;
2
- function m(e) {
3
- const n = Number(e);
4
- return Number.isSafeInteger(n) && n > 0 ? n : 0;
5
- }
6
- function M(e) {
7
- var a;
8
- const n = (s) => {
1
+ const A = "data-ins-track-id", E = "data-ins-track-seq", g = `(?:[^>"']|"[^"]*"|'[^']*')*`, R = new RegExp(`<a\\b${g}>`, "gi"), _ = new RegExp(`<body\\b${g}>`, "i"), l = new RegExp(`<html\\b${g}>`, "i"), m = new RegExp(`\\b${A}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", d = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), I = /^[1-9][0-9]{0,14}$/, S = 999999999999999;
2
+ function $(e) {
3
+ const t = m.exec(e), n = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
4
+ return { attrMatch: t, rawValue: n };
5
+ }
6
+ function k(e) {
7
+ const t = Number(e);
8
+ return Number.isSafeInteger(t) && t > 0 ? t : 0;
9
+ }
10
+ function N(e) {
11
+ var s;
12
+ const t = (o) => {
9
13
  var r;
10
- const o = (r = s.exec(e)) == null ? void 0 : r[0];
11
- return o ? S.exec(o) : null;
12
- }, t = n(b) ?? n(N), c = (t == null ? void 0 : t[1]) ?? (t == null ? void 0 : t[2]) ?? (t == null ? void 0 : t[3]) ?? ((a = _.exec(e)) == null ? void 0 : a[1]) ?? "";
13
- return m(c);
14
- }
15
- function P(e, n = 0) {
16
- let t = 0;
17
- [...e.matchAll(f)].forEach(([a]) => {
18
- const s = I.exec(a), o = s ? s[1] ?? s[2] ?? s[3] ?? "" : "";
19
- w.test(o) && (t = Math.max(t, Number(o)));
14
+ const a = (r = o.exec(e)) == null ? void 0 : r[0];
15
+ return a ? f.exec(a) : null;
16
+ }, n = t(_) ?? t(l), c = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((s = d.exec(e)) == null ? void 0 : s[1]) ?? "";
17
+ return k(c);
18
+ }
19
+ function K(e, t = 0) {
20
+ let n = 0;
21
+ [...e.matchAll(R)].forEach(([s]) => {
22
+ const { rawValue: o } = $(s);
23
+ I.test(o) && (n = Math.max(n, Number(o)));
20
24
  });
21
- const c = Number.isSafeInteger(n) && n > 0 ? n : 0;
22
- return Math.max(M(e), t, c);
25
+ const c = Number.isSafeInteger(t) && t > 0 ? t : 0;
26
+ return Math.max(N(e), n, c);
23
27
  }
24
- function q(e, n) {
25
- const t = `${$}="${n}"`, c = b.exec(e) ?? N.exec(e);
28
+ function M(e, t) {
29
+ const n = `${E}="${t}"`, c = _.exec(e) ?? l.exec(e);
26
30
  if (c) {
27
- const [s] = c, o = S.exec(s), r = o ? s.replace(o[0], t) : s.replace(/\/?>$/, (T) => ` ${t}${T}`);
28
- return e.slice(0, c.index) + r + e.slice(c.index + s.length);
31
+ const [o] = c, a = f.exec(o), r = a ? o.replace(a[0], n) : o.replace(/\/?>$/, (i) => ` ${n}${i}`);
32
+ return e.slice(0, c.index) + r + e.slice(c.index + o.length);
29
33
  }
30
- const a = `<!--${p}:${n}-->`;
31
- return _.test(e) ? e.replace(_, a) : `${a}${e}`;
32
- }
33
- function D(e, n, t) {
34
- const c = `${g}="${t}"`;
35
- return n ? e.replace(n[0], c) : e.replace(/^<a\b/i, (a) => `${a} ${c}`);
36
- }
37
- function C(e, n = 0) {
38
- const t = /* @__PURE__ */ new Set();
39
- let c = 0;
40
- const a = [...e.matchAll(f)].map((i) => {
41
- const [l] = i, u = I.exec(l), R = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
42
- let x = null;
43
- return w.test(R) && !t.has(Number(R)) && (x = Number(R), t.add(x), c = Math.max(c, x)), { index: i.index, tag: l, attrMatch: u, id: x };
44
- }), s = M(e), o = Number.isSafeInteger(n) && n > 0 && n < k ? n : 0;
45
- let r = Math.max(s, c, o), T = "", d = 0, A = !1;
46
- return a.forEach((i) => {
47
- T += e.slice(d, i.index), i.id === null ? (r += 1, T += D(i.tag, i.attrMatch, r), A = !0) : T += i.tag, d = i.index + i.tag.length;
48
- }), T += e.slice(d), r > 0 && s !== r && (T = q(T, r), A = !0), { html: T, changed: A, nextSeq: r };
34
+ const s = `<!--${p}:${t}-->`;
35
+ return d.test(e) ? e.replace(d, s) : `${s}${e}`;
36
+ }
37
+ function q(e, t, n) {
38
+ const c = `${A}="${n}"`;
39
+ return t ? e.replace(t[0], c) : e.replace(/^<a\b/i, (s) => `${s} ${c}`);
40
+ }
41
+ function w(e, t, n = 0) {
42
+ const c = /* @__PURE__ */ new Set();
43
+ let s = 0;
44
+ const o = e.map((u) => {
45
+ if (u !== null && I.test(u) && !c.has(Number(u))) {
46
+ const T = Number(u);
47
+ return c.add(T), s = Math.max(s, T), T;
48
+ }
49
+ return null;
50
+ }), a = Number.isSafeInteger(n) && n > 0 && n < S ? n : 0;
51
+ let r = Math.max(t, s, a);
52
+ const i = /* @__PURE__ */ new Map();
53
+ o.forEach((u, T) => {
54
+ u === null && (r += 1, i.set(T, r));
55
+ });
56
+ const x = r > 0 && t !== r;
57
+ return { assignments: i, nextSeq: r, seqChanged: x, changed: i.size > 0 || x };
58
+ }
59
+ function b(e) {
60
+ return [...e.matchAll(R)].map((t) => {
61
+ const [n] = t;
62
+ return { index: t.index, tag: n, ...$(n) };
63
+ });
64
+ }
65
+ const C = /<!--[\s\S]*?-->/g;
66
+ function P(e, t = 0) {
67
+ const n = b(e), c = n.map((a) => a.rawValue), s = [...e.matchAll(C)].map((a) => [a.index, a.index + a[0].length]), o = n.map(({ index: a }) => s.some(([r, i]) => a > r && a < i));
68
+ return { anchorIds: c, inComment: o, plan: w(c, N(e), t) };
69
+ }
70
+ function D(e, { plan: t }) {
71
+ let n = "", c = 0;
72
+ return b(e).forEach((s, o) => {
73
+ const a = t.assignments.get(o);
74
+ n += e.slice(c, s.index), n += a === void 0 ? s.tag : q(s.tag, s.attrMatch, a), c = s.index + s.tag.length;
75
+ }), n += e.slice(c), t.seqChanged ? M(n, t.nextSeq) : n;
76
+ }
77
+ function O(e, t = 0) {
78
+ const n = P(e, t), { changed: c, nextSeq: s } = n.plan;
79
+ return { html: c ? D(e, n) : e, changed: c, nextSeq: s };
49
80
  }
50
81
  export {
51
- g as TRACK_ID_ATTRIBUTE,
52
- $ as TRACK_SEQ_ATTRIBUTE,
53
- C as assignTrackingIds,
54
- P as readTrackFloor,
55
- M as readTrackSeq
82
+ A as TRACK_ID_ATTRIBUTE,
83
+ E as TRACK_SEQ_ATTRIBUTE,
84
+ O as assignTrackingIds,
85
+ P as planDocumentTrackingIds,
86
+ w as planTrackingIds,
87
+ K as readTrackFloor,
88
+ N as readTrackSeq,
89
+ D as renderTrackingIdPlan
56
90
  };
@@ -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.23.0-beta.ff29317",
3
+ "version": "3.24.0-beta.0abeefe",
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",