@useinsider/guido 3.9.1-beta.c521c3a → 3.9.1-beta.de8e72f

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.
@@ -1,84 +1,85 @@
1
- import { productPairs as q } from "../extensions/Blocks/Items/enums/productEnums.js";
2
- import { DefaultConfigValues as N } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
- function W(M) {
4
- const S = M.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), g = new DOMParser().parseFromString(S, "text/html"), m = q.PAIRS_FOR_EXTENSION;
5
- Object.entries(m).forEach(([r, f]) => {
6
- g.querySelectorAll(".ins-product-td").forEach((c) => {
7
- const A = c.getAttribute("data-number") || "1", C = c.getAttribute("data-type") || "CART_ITEMS";
8
- c.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
9
- var F, I, w;
10
- const $ = e.getAttribute("data-type") || C, u = e.getAttribute("data-number") || A, d = f[$];
11
- if (d)
1
+ import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
2
+ function q(w) {
3
+ const y = w.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), T = new DOMParser().parseFromString(y, "text/html"), C = L.PAIRS_FOR_EXTENSION;
4
+ Object.entries(C).forEach(([r, f]) => {
5
+ T.querySelectorAll(".ins-product-td").forEach((o) => {
6
+ const A = o.getAttribute("data-number") || "1", b = o.getAttribute("data-type") || "CART_ITEMS";
7
+ o.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
8
+ var k, F, I;
9
+ const $ = e.getAttribute("data-type") || b, d = e.getAttribute("data-number") || A, u = f[$];
10
+ if (u)
12
11
  switch (r) {
13
12
  case "imageSrc": {
14
13
  let t = null, i = null;
15
14
  if (e.tagName === "IMG" ? (t = e, i = t.closest("a")) : (t = e.querySelector("img"), i = e.querySelector("a") || e.closest("a")), !t)
16
15
  break;
17
- const a = d.DEFAULT, s = d.ATTR;
16
+ const a = u.DEFAULT, s = u.ATTR;
18
17
  if (a && t.src) {
19
- const o = t.src;
18
+ const c = t.src;
20
19
  a.some((h) => {
21
- const l = h.split("/").pop() || "", b = o.split("/").pop() || "";
22
- return o.includes(h) || o.includes(l) || b === l;
23
- }) && (t.src = `{{${s}_${u}}}`);
20
+ const l = h.split("/").pop() || "", g = c.split("/").pop() || "";
21
+ return c.includes(h) || c.includes(l) || g === l;
22
+ }) && (t.src = `{{${s}_${d}}}`);
24
23
  }
25
- const n = (I = (F = m.name) == null ? void 0 : F[$]) == null ? void 0 : I.ATTR;
26
- if (n && t.setAttribute("alt", `{{${n}_${u}}}`), i) {
27
- const o = (w = m.itemLink) == null ? void 0 : w[$];
28
- if (o) {
29
- const E = o.HREF, h = o.DEFAULT_HREF || "#!", l = i.href;
30
- (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${u}}}`);
24
+ const n = (F = (k = C.name) == null ? void 0 : k[$]) == null ? void 0 : F.ATTR;
25
+ if (n && t.setAttribute("alt", `{{${n}_${d}}}`), i) {
26
+ const c = (I = C.itemLink) == null ? void 0 : I[$];
27
+ if (c) {
28
+ const E = c.HREF, h = c.DEFAULT_HREF || "#!", l = i.href;
29
+ (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${d}}}`);
31
30
  }
32
31
  }
33
32
  break;
34
33
  }
35
34
  case "name": {
36
- const t = d, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
37
- e.textContent && (e.textContent = `{{${i}_${u}}}`);
35
+ const t = u, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
36
+ e.textContent && (e.textContent = `{{${i}_${d}}}`);
38
37
  const n = e.closest("a") || (e.tagName === "A" ? e : null);
39
38
  if (n && s) {
40
- const o = n.href, E = `${window.location.href}${a}`;
41
- (o === E || o.endsWith(a)) && (n.href = `{{${s}_${u}}}`);
39
+ const c = n.href, E = `${window.location.href}${a}`;
40
+ (c === E || c.endsWith(a)) && (n.href = `{{${s}_${d}}}`);
42
41
  }
43
42
  break;
44
43
  }
45
44
  case "price":
46
45
  case "originalPrice": {
47
- const t = d, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", o = e.getAttribute("data-curency") || "before";
46
+ const t = u, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", c = e.getAttribute("data-curency") || "before";
48
47
  let E;
49
48
  n ? E = s ? t.SINGLE_PRICE_FORMATTED : t.SINGLE_PRICE : E = s ? t.PRICE_FORMATTED : t.PRICE;
50
49
  const h = t.CURRENCY;
51
- let l = `{{${E}_${u}}}`;
52
- const b = (e.getAttribute("data-currency_symbol") || "").trim(), x = b !== "" && b !== N.productPriceCurrencySymbolControlValue;
53
- let T = "";
54
- x ? T = b : h && (T = `{{${h}_${u}}}`), T && (l = o === "after" ? `${l} ${T}` : `${T} ${l}`), e.textContent = l;
50
+ let l = `{{${E}_${d}}}`;
51
+ if (h) {
52
+ const g = `{{${h}_${d}}}`;
53
+ l = c === "after" ? `${l} ${g}` : `${g} ${l}`;
54
+ }
55
+ e.textContent = l;
55
56
  break;
56
57
  }
57
58
  case "quantity": {
58
- const t = d, i = t.ATTR, a = t.DEFAULT;
59
- e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${u}}}`);
59
+ const t = u, i = t.ATTR, a = t.DEFAULT;
60
+ e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${d}}}`);
60
61
  break;
61
62
  }
62
63
  case "button": {
63
- const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
64
+ const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
64
65
  if (s) {
65
- const n = s.href || "", o = `${window.location.href}${a}`;
66
- (n === "" || n === "#" || n === o || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${u}}}`);
66
+ const n = s.href || "", c = `${window.location.href}${a}`;
67
+ (n === "" || n === "#" || n === c || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${d}}}`);
67
68
  }
68
69
  break;
69
70
  }
70
71
  case "itemLink": {
71
- const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
72
+ const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
72
73
  if (s.href) {
73
- const n = s.href, o = `${window.location.href}${a}`;
74
- (n === o || n.endsWith(a)) && (s.href = `{{${i}_${u}}}`);
74
+ const n = s.href, c = `${window.location.href}${a}`;
75
+ (n === c || n.endsWith(a)) && (s.href = `{{${i}_${d}}}`);
75
76
  }
76
77
  break;
77
78
  }
78
79
  default: {
79
- if ("ATTR" in d) {
80
- const t = d.ATTR;
81
- e.textContent && (e.textContent = `{{${t}_${u}}}`);
80
+ if ("ATTR" in u) {
81
+ const t = u.ATTR;
82
+ e.textContent && (e.textContent = `{{${t}_${d}}}`);
82
83
  }
83
84
  break;
84
85
  }
@@ -86,48 +87,48 @@ function W(M) {
86
87
  });
87
88
  });
88
89
  });
89
- const H = S.match(/<!DOCTYPE[^>]*>/i), P = H ? `${H[0]}
90
- ` : "", D = g.querySelectorAll(".ins-product-td"), k = [];
91
- D.forEach((r) => {
92
- const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", c = r.getAttribute("data-nodup"), A = r.outerHTML;
93
- k.push({
90
+ const S = y.match(/<!DOCTYPE[^>]*>/i), M = S ? `${S[0]}
91
+ ` : "", P = T.querySelectorAll(".ins-product-td"), H = [];
92
+ P.forEach((r) => {
93
+ const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", o = r.getAttribute("data-nodup"), A = r.outerHTML;
94
+ H.push({
94
95
  element: r,
95
96
  outerHtml: A,
96
97
  type: f,
97
98
  number: p,
98
- nodup: c || void 0
99
+ nodup: o || void 0
99
100
  });
100
101
  });
101
- let _ = P + g.documentElement.outerHTML;
102
- k.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
103
- let c = "";
102
+ let _ = M + T.documentElement.outerHTML;
103
+ H.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
104
+ let o = "";
104
105
  switch (f) {
105
106
  case "CART_ITEMS":
106
- c = "ins_apr_total_product_kind";
107
+ o = "ins_apr_total_product_kind";
107
108
  break;
108
109
  case "BROWSED_ITEMS":
109
- c = "browsed_item_total_product_kind";
110
+ o = "browsed_item_total_product_kind";
110
111
  break;
111
112
  case "PURCHASED_ITEMS":
112
- c = "purchased_item_total_product_kind";
113
+ o = "purchased_item_total_product_kind";
113
114
  break;
114
115
  }
115
- if (c) {
116
- const C = parseInt(p) - 1, $ = `${`{% if ${c} > ${C} %}`}${r}{% endif %}`;
116
+ if (o) {
117
+ const b = parseInt(p) - 1, $ = `${`{% if ${o} > ${b} %}`}${r}{% endif %}`;
117
118
  _ = _.replace(r, $);
118
119
  }
119
120
  });
120
- const L = g.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), y = [];
121
- return L.forEach((r) => {
121
+ const D = T.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
122
+ return D.forEach((r) => {
122
123
  const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
123
124
  if (!f || p !== "CART_ITEMS")
124
125
  return;
125
- const c = r.closest(".product-original-price-class");
126
- if (c) {
127
- const A = c.outerHTML;
128
- y.some((R) => R.tdOuterHtml === A) || y.push({ tdOuterHtml: A, number: f });
126
+ const o = r.closest(".product-original-price-class");
127
+ if (o) {
128
+ const A = o.outerHTML;
129
+ R.some((m) => m.tdOuterHtml === A) || R.push({ tdOuterHtml: A, number: f });
129
130
  }
130
- }), y.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
131
+ }), R.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
131
132
  const p = `{% if ins_apr_price_${f} != ins_apr_originalprice_${f} %}`;
132
133
  if (!_.includes(p) && !r.includes("{% if")) {
133
134
  const A = `${p}${r}{% endif %}`;
@@ -136,5 +137,5 @@ function W(M) {
136
137
  }), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
137
138
  }
138
139
  export {
139
- W as pairProductVariables
140
+ q as pairProductVariables
140
141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.9.1-beta.c521c3a",
3
+ "version": "3.9.1-beta.de8e72f",
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,34 +0,0 @@
1
- import { useToaster as m } from "../composables/useToaster.js";
2
- import { useTranslations as c } from "../composables/useTranslations.js";
3
- import { BLANK_TEMPLATE_HTML_URL as T, BLANK_TEMPLATE_CSS_URL as i } from "../enums/defaults.js";
4
- import { ToasterTypeOptions as p } from "../enums/toaster.js";
5
- const a = 3, f = 1e3;
6
- let s = null;
7
- const u = (e) => new Promise((t) => {
8
- setTimeout(t, e);
9
- }), n = async (e) => {
10
- const t = await fetch(e);
11
- if (!t.ok)
12
- throw new Error(`Blank template request failed: ${t.status}`);
13
- return t.text();
14
- }, k = () => {
15
- const { showToaster: e } = m(), t = c();
16
- return { getBlankTemplate: async () => {
17
- if (s)
18
- return s;
19
- for (let r = 1; r <= a; r++)
20
- try {
21
- const [o, l] = await Promise.all([
22
- n(T),
23
- n(i)
24
- ]);
25
- return s = { html: o, css: l }, s;
26
- } catch (o) {
27
- console.error(`Failed to fetch blank template (attempt ${r}/${a}):`, o), r < a && await u(r * f);
28
- }
29
- return e({ type: p.Alert, message: t("errors-pages.undefined-response") }), { html: "", css: "" };
30
- } };
31
- };
32
- export {
33
- k as useBlankTemplate
34
- };
@@ -1,11 +0,0 @@
1
- import type { Template } from '@@/Types/stripo';
2
- /**
3
- * Fetches the blank starter template (html + css) from the email CDN — the single
4
- * source of truth shared with email-fe. Retries a few times, caches the result for
5
- * the session, and on persistent failure returns an empty template (the editor still
6
- * opens) plus a toaster. Kept separate from stripoApi: this is a CDN asset fetch, not
7
- * a Stripo backend call.
8
- */
9
- export declare const useBlankTemplate: () => {
10
- getBlankTemplate: () => Promise<Template>;
11
- };