@useinsider/guido 3.4.1-beta.4c96ad0 → 3.4.1-beta.4d7cad6
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.
- package/README.md +2 -0
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +17 -16
- package/dist/config/migrator/itemsBlockMigrator.js +28 -18
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +12 -12
- package/dist/src/stores/config.test.d.ts +1 -0
- package/dist/src/vitest.setup.d.ts +0 -0
- package/dist/stores/config.js +24 -23
- package/dist/utils/templatePreparation.js +51 -43
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
# @useinsider/guido
|
|
10
10
|
|
|
11
|
+
[](http://coverus.internal.dataforce/app/project/github/useinsider/guido)
|
|
12
|
+
|
|
11
13
|
Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, type-safe configuration.
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import {
|
|
1
|
+
import { useConfig as S } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as g } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { CSS_CLASS_RECO_BUTTON as _ } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useRecommendationExtensionStore as q } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
5
|
function y(r, c, e, o, s = "") {
|
|
5
6
|
const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
|
|
6
7
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
@@ -11,7 +12,7 @@ function f(r, c, e, o, s, n) {
|
|
|
11
12
|
const t = r.querySelector("img");
|
|
12
13
|
t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
|
|
13
14
|
const i = r.querySelector("a");
|
|
14
|
-
i && i.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
15
|
+
i && (i.setAttribute("href", `{{${n}${e}_${o}_url}}`), i.classList.add(_));
|
|
15
16
|
break;
|
|
16
17
|
}
|
|
17
18
|
case "productName": {
|
|
@@ -80,7 +81,7 @@ function f(r, c, e, o, s, n) {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function C(r, c, e, o) {
|
|
84
85
|
r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
85
86
|
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
86
87
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
@@ -90,7 +91,7 @@ function q(r, c, e, o) {
|
|
|
90
91
|
});
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function E(r, c, e, o) {
|
|
94
95
|
const s = r.querySelectorAll(".recommendation-product-row");
|
|
95
96
|
if (!s.length)
|
|
96
97
|
return;
|
|
@@ -105,14 +106,14 @@ function w(r, c, e, o) {
|
|
|
105
106
|
});
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
+
function w(r, c, e, o) {
|
|
109
110
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
110
|
-
|
|
111
|
+
E(n, c, e, o);
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
+
function R(r, c, e) {
|
|
114
115
|
const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
|
|
115
|
-
o === "list" ?
|
|
116
|
+
o === "list" ? C(r, c, s, e) : w(r, c, s, e);
|
|
116
117
|
}
|
|
117
118
|
function b(r, c, e) {
|
|
118
119
|
const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
|
|
@@ -130,7 +131,7 @@ function P(r, c) {
|
|
|
130
131
|
}
|
|
131
132
|
return null;
|
|
132
133
|
}
|
|
133
|
-
function
|
|
134
|
+
function T(r) {
|
|
134
135
|
const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
135
136
|
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
|
|
136
137
|
if (n.hasAttribute("width"))
|
|
@@ -152,20 +153,20 @@ function v(r, c) {
|
|
|
152
153
|
return (e ? `${e[0]}
|
|
153
154
|
` : "") + c.documentElement.outerHTML;
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
+
function N(r) {
|
|
156
157
|
const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
157
158
|
if (!o.length)
|
|
158
159
|
return r;
|
|
159
|
-
const { buildCampaignUrl: s } =
|
|
160
|
+
const { buildCampaignUrl: s } = g(), n = q();
|
|
160
161
|
n.recommendationCampaignUrls = {};
|
|
161
|
-
const { isFeatureEnabled: t } =
|
|
162
|
+
const { isFeatureEnabled: t } = S(), i = t("liquidSyntax") ? "reco_" : "";
|
|
162
163
|
return o.forEach((u) => {
|
|
163
164
|
var l, d;
|
|
164
165
|
const p = u.getAttribute("recommendation-id");
|
|
165
|
-
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p),
|
|
166
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), R(u, p, i), T(u));
|
|
166
167
|
}), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
167
168
|
}
|
|
168
169
|
export {
|
|
169
170
|
y as formatPriceVariable,
|
|
170
|
-
|
|
171
|
+
N as prepareRecommendationBlocks
|
|
171
172
|
};
|
|
@@ -155,6 +155,8 @@ class z {
|
|
|
155
155
|
}
|
|
156
156
|
migrate(t) {
|
|
157
157
|
try {
|
|
158
|
+
if (!this.containsItemsBlock(t))
|
|
159
|
+
return t;
|
|
158
160
|
let o = this.removeJinjaConditionals(t);
|
|
159
161
|
o = this.replaceTemplateVariables(o);
|
|
160
162
|
const l = this.parser.parseFromString(o, "text/html"), a = l.querySelectorAll(
|
|
@@ -178,15 +180,15 @@ class z {
|
|
|
178
180
|
originalPriceStyles: e.originalPriceStyles,
|
|
179
181
|
quantityStyles: e.quantityStyles,
|
|
180
182
|
nodeConfig: R(e.configBlockAttributes)
|
|
181
|
-
}),
|
|
183
|
+
}), u = this.parser.parseFromString(
|
|
182
184
|
`<table><tbody><tr>${c}</tr></tbody></table>`,
|
|
183
185
|
"text/html"
|
|
184
186
|
).querySelector("td");
|
|
185
|
-
if (
|
|
187
|
+
if (u && i.parentNode) {
|
|
186
188
|
const p = R(e.configBlockAttributes);
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
189
|
+
u.setAttribute("esd-ext-config", JSON.stringify(p));
|
|
190
|
+
const d = u.querySelector("esd-config-block");
|
|
191
|
+
d && d.remove(), i.parentNode.replaceChild(u, i);
|
|
190
192
|
}
|
|
191
193
|
}), l.documentElement.outerHTML);
|
|
192
194
|
} catch (o) {
|
|
@@ -201,22 +203,22 @@ class z {
|
|
|
201
203
|
*/
|
|
202
204
|
extractConfiguration(t) {
|
|
203
205
|
var C, D, P;
|
|
204
|
-
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD",
|
|
206
|
+
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
|
|
205
207
|
let b;
|
|
206
208
|
S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
207
|
-
const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0,
|
|
209
|
+
const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
208
210
|
return {
|
|
209
211
|
orientation: b,
|
|
210
212
|
itemsType: o,
|
|
211
213
|
itemId: i,
|
|
212
214
|
currencySymbol: c,
|
|
213
|
-
currencyLocation:
|
|
215
|
+
currencyLocation: u,
|
|
214
216
|
formattedPrice: p,
|
|
215
|
-
configBlockAttributes:
|
|
217
|
+
configBlockAttributes: d,
|
|
216
218
|
nameStyles: I,
|
|
217
219
|
buttonStyles: m,
|
|
218
|
-
priceStyles:
|
|
219
|
-
originalPriceStyles:
|
|
220
|
+
priceStyles: k,
|
|
221
|
+
originalPriceStyles: h,
|
|
220
222
|
quantityStyles: L
|
|
221
223
|
};
|
|
222
224
|
}
|
|
@@ -296,6 +298,14 @@ class z {
|
|
|
296
298
|
"data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
|
|
297
299
|
};
|
|
298
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
303
|
+
* in the raw HTML. Used to gate the migration pipeline so non-items templates
|
|
304
|
+
* are returned untouched.
|
|
305
|
+
*/
|
|
306
|
+
containsItemsBlock(t) {
|
|
307
|
+
return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
|
|
308
|
+
}
|
|
299
309
|
/**
|
|
300
310
|
* Removes Jinja2 conditional statements from HTML
|
|
301
311
|
* Handles all items block types:
|
|
@@ -337,18 +347,18 @@ class z {
|
|
|
337
347
|
const [, i, e, c] = n, _ = x[i];
|
|
338
348
|
if (!_)
|
|
339
349
|
return console.warn(`Unknown variable prefix: ${i}`), l;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
350
|
+
const u = q[e];
|
|
351
|
+
if (!u)
|
|
342
352
|
return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
|
|
343
|
-
const { pairsKey: p, defaultKey:
|
|
353
|
+
const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
|
|
344
354
|
if (!y)
|
|
345
355
|
return console.warn(`No data found for: ${p}.${_}`), l;
|
|
346
356
|
if (S) {
|
|
347
|
-
const f = parseInt(c) - 1, m = y[
|
|
348
|
-
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${
|
|
357
|
+
const f = parseInt(c) - 1, m = y[d];
|
|
358
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
|
|
349
359
|
}
|
|
350
|
-
const I = y[
|
|
351
|
-
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${
|
|
360
|
+
const I = y[d];
|
|
361
|
+
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
|
|
352
362
|
});
|
|
353
363
|
}
|
|
354
364
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RecommendationBlockId as s } from "../../constants/blockIds.js";
|
|
2
|
-
import { ATTR_PRODUCT_ATTR as
|
|
2
|
+
import { ATTR_PRODUCT_ATTR as u, CSS_CLASS_RECO_BUTTON as p, ATTR_PRODUCT_BUTTON as m, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as _, ATTR_PRODUCT_IMAGE as x } from "../../constants/selectors.js";
|
|
3
3
|
import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
|
|
4
4
|
import { formatPrice as C } from "../../utils/priceFormatter.js";
|
|
5
5
|
import { CUSTOM_CELL_HTML as R, sanitizeImageUrl as O } from "../utils.js";
|
|
6
6
|
const a = "0 5px", l = "attribute-cell";
|
|
7
|
-
function
|
|
7
|
+
function g() {
|
|
8
8
|
const t = $(), { currencySettings: e } = t.recommendationConfigs;
|
|
9
9
|
return {
|
|
10
10
|
code: e.value,
|
|
@@ -16,7 +16,7 @@ function p() {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function i(t, e = "price") {
|
|
19
|
-
const o =
|
|
19
|
+
const o = g(), n = t[e], d = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
|
|
20
20
|
return C({
|
|
21
21
|
price: d,
|
|
22
22
|
currency: o
|
|
@@ -38,7 +38,7 @@ const S = {
|
|
|
38
38
|
class="esd-block-image product-image"
|
|
39
39
|
align="center"
|
|
40
40
|
esd-extension-block-id="${s.IMAGE}">
|
|
41
|
-
<a target="_blank" href="${t.url}">
|
|
41
|
+
<a target="_blank" href="${t.url}" class="${p}">
|
|
42
42
|
<img
|
|
43
43
|
src="${O(t.image_url)}"
|
|
44
44
|
alt="${t.name}"
|
|
@@ -154,7 +154,7 @@ const S = {
|
|
|
154
154
|
`,
|
|
155
155
|
[h]: (t) => {
|
|
156
156
|
var r, c;
|
|
157
|
-
const e =
|
|
157
|
+
const e = g(), o = ((r = t.original_price) == null ? void 0 : r[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((c = t.price) == null ? void 0 : c[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, d = o > 0 ? Math.round((o - n) / o * 100) : 0, b = d > 0 ? `-${d}%` : "0%";
|
|
158
158
|
return `
|
|
159
159
|
<td class="${l}" style="padding: ${a}; height: 100%;" valign="top">
|
|
160
160
|
<table
|
|
@@ -174,7 +174,7 @@ const S = {
|
|
|
174
174
|
esd-extension-block-id="${s.OMNIBUS_DISCOUNT}">
|
|
175
175
|
<p contenteditable="false" style="font-size: 12px; color: #666666;">
|
|
176
176
|
<span class="omnibus-text-before"></span>
|
|
177
|
-
<span class="omnibus-discount-value">${
|
|
177
|
+
<span class="omnibus-discount-value">${b}</span>
|
|
178
178
|
<span class="omnibus-text-after"></span>
|
|
179
179
|
</p>
|
|
180
180
|
</td>
|
|
@@ -208,7 +208,7 @@ const S = {
|
|
|
208
208
|
">
|
|
209
209
|
<a
|
|
210
210
|
href="#"
|
|
211
|
-
class="es-button ${
|
|
211
|
+
class="es-button ${p}"
|
|
212
212
|
target="_blank"
|
|
213
213
|
style="
|
|
214
214
|
color: rgb(56, 118, 29);
|
|
@@ -249,7 +249,7 @@ const S = {
|
|
|
249
249
|
<tbody>
|
|
250
250
|
<tr valign="top">
|
|
251
251
|
<td
|
|
252
|
-
${
|
|
252
|
+
${u}="${t}"
|
|
253
253
|
class="esd-block-text product-custom-attribute es-p0t es-p0b es-p15l es-p15r"
|
|
254
254
|
align="center"
|
|
255
255
|
esd-extension-block-id="${s.CUSTOM_ATTRIBUTE}">
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RecommendationBlockId as o } from "../../constants/blockIds.js";
|
|
2
|
-
import { ATTR_PRODUCT_ATTR as
|
|
2
|
+
import { ATTR_PRODUCT_ATTR as u, ATTR_PRODUCT_BUTTON as c, CSS_CLASS_RECO_BUTTON as d, ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_OMNIBUS_DISCOUNT as g, ATTR_PRODUCT_OMNIBUS_PRICE as f, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as x, ATTR_PRODUCT_NAME as _ } from "../../constants/selectors.js";
|
|
3
3
|
import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
|
|
4
4
|
import { formatPrice as R } from "../../utils/priceFormatter.js";
|
|
5
|
-
import { CUSTOM_CELL_HTML as O, sanitizeImageUrl as
|
|
6
|
-
function
|
|
5
|
+
import { CUSTOM_CELL_HTML as O, sanitizeImageUrl as $ } from "../utils.js";
|
|
6
|
+
function b() {
|
|
7
7
|
const t = C(), { currencySettings: e } = t.recommendationConfigs;
|
|
8
8
|
return {
|
|
9
9
|
code: e.value,
|
|
@@ -15,7 +15,7 @@ function p() {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
function s(t, e = "price") {
|
|
18
|
-
const n =
|
|
18
|
+
const n = b(), a = t[e], r = (a == null ? void 0 : a[n.code]) ?? Object.values(a ?? {})[0] ?? 0;
|
|
19
19
|
return R({
|
|
20
20
|
price: r,
|
|
21
21
|
currency: n
|
|
@@ -26,18 +26,18 @@ const I = {
|
|
|
26
26
|
* Image cell - left column (120px fixed width)
|
|
27
27
|
* Has recommendation-attribute-row class and data attributes for Card Composition control
|
|
28
28
|
*/
|
|
29
|
-
[
|
|
29
|
+
[p]: (t) => `
|
|
30
30
|
<td
|
|
31
31
|
width="120"
|
|
32
32
|
class="esd-block-image product-image-cell recommendation-attribute-row es-p5"
|
|
33
33
|
esd-extension-block-id="${o.IMAGE}"
|
|
34
|
-
data-attribute-type="${
|
|
34
|
+
data-attribute-type="${p}"
|
|
35
35
|
data-visibility="1"
|
|
36
36
|
align="center"
|
|
37
37
|
valign="middle">
|
|
38
|
-
<a target="_blank" href="${t.url}">
|
|
38
|
+
<a target="_blank" href="${t.url}" class="${d}">
|
|
39
39
|
<img
|
|
40
|
-
src="${
|
|
40
|
+
src="${$(t.image_url)}"
|
|
41
41
|
alt="${t.name}"
|
|
42
42
|
style="display: block; max-width: 100%; height: auto;"
|
|
43
43
|
class="adapt-img product-image">
|
|
@@ -115,7 +115,7 @@ const I = {
|
|
|
115
115
|
*/
|
|
116
116
|
[g]: (t) => {
|
|
117
117
|
var i, l;
|
|
118
|
-
const e =
|
|
118
|
+
const e = b(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, a = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - a) / n * 100) : 0, m = r > 0 ? `-${r}%` : "0%";
|
|
119
119
|
return `
|
|
120
120
|
<tr>
|
|
121
121
|
<td
|
|
@@ -126,7 +126,7 @@ const I = {
|
|
|
126
126
|
align="left">
|
|
127
127
|
<p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">
|
|
128
128
|
<span class="omnibus-text-before"></span>
|
|
129
|
-
<span class="omnibus-discount-value">${
|
|
129
|
+
<span class="omnibus-discount-value">${m}</span>
|
|
130
130
|
<span class="omnibus-text-after"></span>
|
|
131
131
|
</p>
|
|
132
132
|
</td>
|
|
@@ -156,7 +156,7 @@ const I = {
|
|
|
156
156
|
<a
|
|
157
157
|
href="${t.url}"
|
|
158
158
|
target="_blank"
|
|
159
|
-
class="es-button ${
|
|
159
|
+
class="es-button ${d}"
|
|
160
160
|
style="
|
|
161
161
|
color: rgb(56, 118, 29);
|
|
162
162
|
background: rgb(217, 234, 211);
|
|
@@ -182,7 +182,7 @@ const I = {
|
|
|
182
182
|
[O]: (t, e) => `
|
|
183
183
|
<tr>
|
|
184
184
|
<td
|
|
185
|
-
${
|
|
185
|
+
${u}="${t}"
|
|
186
186
|
class="esd-block-text product-custom-attribute"
|
|
187
187
|
esd-extension-block-id="${o.CUSTOM_ATTRIBUTE}"
|
|
188
188
|
align="left">
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
package/dist/stores/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../@types/config/schemas.js";
|
|
2
2
|
import "../@types/config/defaults.js";
|
|
3
|
-
import { parseConfig as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
const
|
|
3
|
+
import { parseConfig as o } from "../@types/config/validator.js";
|
|
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,64 +75,65 @@ const s = o("guido-config", {
|
|
|
75
75
|
* Get the template ID
|
|
76
76
|
*/
|
|
77
77
|
templateId: (i) => {
|
|
78
|
-
var e;
|
|
79
|
-
return ((e = i.config) == null ? void 0 : e.identity.templateId) ?? "";
|
|
78
|
+
var e, t;
|
|
79
|
+
return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.templateId) ?? "";
|
|
80
80
|
},
|
|
81
81
|
/**
|
|
82
82
|
* Get the user ID
|
|
83
83
|
*/
|
|
84
84
|
userId: (i) => {
|
|
85
|
-
var e;
|
|
86
|
-
return ((e = i.config) == null ? void 0 : e.identity.userId) ?? "";
|
|
85
|
+
var e, t;
|
|
86
|
+
return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.userId) ?? "";
|
|
87
87
|
},
|
|
88
88
|
/**
|
|
89
89
|
* Get the variation ID
|
|
90
90
|
*/
|
|
91
91
|
variationId: (i) => {
|
|
92
|
-
var e;
|
|
93
|
-
return ((e = i.config) == null ? void 0 : e.identity.variationId) ?? "";
|
|
92
|
+
var e, t;
|
|
93
|
+
return ((t = (e = i.config) == null ? void 0 : e.identity) == null ? void 0 : t.variationId) ?? "";
|
|
94
94
|
},
|
|
95
95
|
/**
|
|
96
96
|
* Get the partner name
|
|
97
97
|
*/
|
|
98
98
|
partnerName: (i) => {
|
|
99
|
-
var e;
|
|
100
|
-
return ((e = i.config) == null ? void 0 : e.partner.name) ?? "";
|
|
99
|
+
var e, t;
|
|
100
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.name) ?? "";
|
|
101
101
|
},
|
|
102
102
|
/**
|
|
103
103
|
* Get the product type
|
|
104
104
|
*/
|
|
105
105
|
productType: (i) => {
|
|
106
|
-
var e;
|
|
107
|
-
return ((e = i.config) == null ? void 0 : e.partner.productType) ?? 60;
|
|
106
|
+
var e, t;
|
|
107
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.productType) ?? 60;
|
|
108
108
|
},
|
|
109
109
|
/**
|
|
110
110
|
* Get the message type
|
|
111
111
|
*/
|
|
112
112
|
messageType: (i) => {
|
|
113
|
-
var e;
|
|
114
|
-
return ((e = i.config) == null ? void 0 : e.partner.messageType) ?? 1;
|
|
113
|
+
var e, t;
|
|
114
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) ?? 1;
|
|
115
115
|
},
|
|
116
116
|
/**
|
|
117
117
|
* Get the username
|
|
118
118
|
*/
|
|
119
119
|
username: (i) => {
|
|
120
|
-
var e;
|
|
121
|
-
return ((e = i.config) == null ? void 0 : e.partner.username) ?? "Guido User";
|
|
120
|
+
var e, t;
|
|
121
|
+
return ((t = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : t.username) ?? "Guido User";
|
|
122
122
|
},
|
|
123
123
|
/**
|
|
124
124
|
* Check if header should be shown
|
|
125
125
|
*/
|
|
126
126
|
showHeader: (i) => {
|
|
127
|
-
var e;
|
|
128
|
-
return ((e = i.config) == null ? void 0 : e.ui.showHeader) ?? !0;
|
|
127
|
+
var e, t;
|
|
128
|
+
return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
|
|
129
129
|
},
|
|
130
130
|
/**
|
|
131
131
|
* Check if a specific feature is enabled
|
|
132
132
|
*/
|
|
133
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
133
134
|
isFeatureEnabled: (i) => (e) => {
|
|
134
|
-
var t;
|
|
135
|
-
return ((t = i.config) == null ? void 0 : t.features[e]) ?? !0;
|
|
135
|
+
var t, n;
|
|
136
|
+
return ((n = (t = i.config) == null ? void 0 : t.features) == null ? void 0 : n[e]) ?? !0;
|
|
136
137
|
}
|
|
137
138
|
},
|
|
138
139
|
actions: {
|
|
@@ -140,7 +141,7 @@ const s = o("guido-config", {
|
|
|
140
141
|
* Initialize the config store with validated configuration
|
|
141
142
|
*/
|
|
142
143
|
init(i) {
|
|
143
|
-
const e =
|
|
144
|
+
const e = o(i);
|
|
144
145
|
this.config = e, this.initialized = !0;
|
|
145
146
|
},
|
|
146
147
|
/**
|
|
@@ -152,5 +153,5 @@ const s = o("guido-config", {
|
|
|
152
153
|
}
|
|
153
154
|
});
|
|
154
155
|
export {
|
|
155
|
-
|
|
156
|
+
f as useConfigStore
|
|
156
157
|
};
|
|
@@ -1,79 +1,87 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useHtmlCompiler as
|
|
3
|
-
import { DEFAULT_CURRENCY as
|
|
1
|
+
import { useActionsApi as C } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
|
|
3
|
+
import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
4
4
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
import { DATA_ATTRIBUTES as
|
|
6
|
-
import { parsePageList as
|
|
7
|
-
import { useDynamicContentStore as
|
|
8
|
-
import { useUnsubscribeStore as
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
}),
|
|
5
|
+
import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
+
import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
7
|
+
import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
|
|
9
|
+
function E(i, o) {
|
|
10
|
+
const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
|
|
11
|
+
return t.forEach((r) => {
|
|
12
|
+
const a = r.getAttribute(S.PAGE_LIST);
|
|
13
|
+
a && c.push(...D(a));
|
|
14
|
+
}), o.filter((r) => c.includes(r));
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
async function U(i) {
|
|
17
17
|
const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
18
18
|
if (m.length === 0)
|
|
19
19
|
return;
|
|
20
|
-
const
|
|
21
|
-
m.forEach((
|
|
22
|
-
var g, f, u, n,
|
|
23
|
-
const c =
|
|
24
|
-
if (!Number.isFinite(
|
|
20
|
+
const l = b();
|
|
21
|
+
m.forEach((t) => {
|
|
22
|
+
var g, f, u, n, y;
|
|
23
|
+
const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
|
|
24
|
+
if (!Number.isFinite(r))
|
|
25
25
|
return;
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
26
|
+
const a = t.getAttribute("esd-ext-config");
|
|
27
|
+
if (!a)
|
|
28
28
|
return;
|
|
29
29
|
let e;
|
|
30
30
|
try {
|
|
31
|
-
e = JSON.parse(
|
|
31
|
+
e = JSON.parse(a);
|
|
32
32
|
} catch {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
36
36
|
return;
|
|
37
37
|
const p = {
|
|
38
|
-
strategy: e.strategy ??
|
|
39
|
-
language: e.language ??
|
|
40
|
-
size: e.size ??
|
|
38
|
+
strategy: e.strategy ?? s.strategy,
|
|
39
|
+
language: e.language ?? s.language,
|
|
40
|
+
size: e.size ?? s.size,
|
|
41
41
|
// Spread the default arrays so each block gets a fresh reference
|
|
42
42
|
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
43
|
-
productIds: e.productIds ?? [...
|
|
44
|
-
filters: e.filters ?? [...
|
|
45
|
-
shuffleProducts: e.shuffleProducts ??
|
|
46
|
-
currencyCode: ((g = e.currency) == null ? void 0 : g.code) ??
|
|
47
|
-
currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ??
|
|
48
|
-
currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ??
|
|
49
|
-
currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ??
|
|
50
|
-
currencyThousandSeparator: ((
|
|
43
|
+
productIds: e.productIds ?? [...s.productIds],
|
|
44
|
+
filters: e.filters ?? [...s.filters],
|
|
45
|
+
shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
|
|
46
|
+
currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
|
|
47
|
+
currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
|
|
48
|
+
currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
|
|
49
|
+
currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
|
|
50
|
+
currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
l.seedBlockUrlConfig(r, p);
|
|
53
53
|
});
|
|
54
|
+
try {
|
|
55
|
+
await l.fetchRecommendationCreateData();
|
|
56
|
+
} catch (t) {
|
|
57
|
+
console.warn(
|
|
58
|
+
"Recommendation reference data pre-load failed; validator will skip the availability check.",
|
|
59
|
+
t
|
|
60
|
+
);
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
const _ = () => {
|
|
56
|
-
const i =
|
|
64
|
+
const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
|
|
57
65
|
return {
|
|
58
66
|
prepareTemplateDetails: async () => {
|
|
59
|
-
const { html:
|
|
67
|
+
const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
|
|
60
68
|
minimize: !0,
|
|
61
69
|
resetDataSavedFlag: !1
|
|
62
|
-
}), { html: p, css: g, syncModulesIds: f = [] } = await
|
|
63
|
-
|
|
64
|
-
const { compiledHtml: u, stats: n, appliedRules:
|
|
70
|
+
}), { html: p, css: g, syncModulesIds: f = [] } = await l();
|
|
71
|
+
o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
|
|
72
|
+
const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
|
|
65
73
|
return console.debug("HTML Compilation Stats:", {
|
|
66
74
|
originalSize: n.originalSize,
|
|
67
75
|
compiledSize: n.compiledSize,
|
|
68
76
|
reduction: `${n.reductionPercentage.toFixed(2)}%`,
|
|
69
|
-
appliedRules:
|
|
77
|
+
appliedRules: y,
|
|
70
78
|
executionTime: `${n.executionTime.toFixed(2)}ms`
|
|
71
79
|
}), {
|
|
72
80
|
dynamicContentList: h,
|
|
73
81
|
compiledHtml: u,
|
|
74
82
|
rawHtml: p,
|
|
75
83
|
css: g,
|
|
76
|
-
ampHtml:
|
|
84
|
+
ampHtml: a,
|
|
77
85
|
ampErrors: e,
|
|
78
86
|
modules: f.map(Number),
|
|
79
87
|
recommendation: {
|
|
@@ -81,8 +89,8 @@ const _ = () => {
|
|
|
81
89
|
configs: {}
|
|
82
90
|
},
|
|
83
91
|
unsubscribe: {
|
|
84
|
-
status:
|
|
85
|
-
config:
|
|
92
|
+
status: o.unsubscribePagesStatus,
|
|
93
|
+
config: E(u, o.selectedUnsubscribePages)
|
|
86
94
|
}
|
|
87
95
|
};
|
|
88
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.4.1-beta.
|
|
3
|
+
"version": "3.4.1-beta.4d7cad6",
|
|
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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
|
|
25
25
|
"lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
|
|
26
26
|
"type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json",
|
|
27
|
-
"test": "vitest run",
|
|
27
|
+
"test": "vitest run --coverage",
|
|
28
28
|
"test:watch": "vitest",
|
|
29
29
|
"test:visual-update": "npx playwright test --update-snapshots --reporter html",
|
|
30
30
|
"prepare": "husky",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@typescript-eslint/parser": "7.18.0",
|
|
62
62
|
"@useinsider/eslint-config": "1.5.3",
|
|
63
63
|
"@vitejs/plugin-vue2": "2.3.1",
|
|
64
|
+
"@vitest/coverage-v8": "2.1.9",
|
|
64
65
|
"eslint": "8.57.1",
|
|
65
66
|
"eslint-config-airbnb-base": "15.0.0",
|
|
66
67
|
"eslint-config-airbnb-typescript": "18.0.0",
|