@useinsider/guido 3.18.2 → 3.18.3-beta.ec88281
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/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
- package/dist/composables/useHttp.js +24 -22
- package/dist/services/templateLibraryApi.js +17 -14
- package/dist/src/utils/genericUtil.d.ts +6 -0
- package/dist/utils/genericUtil.js +45 -39
- package/dist/utils/templatePreparation.js +37 -36
- package/package.json +1 -1
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { useTranslations as
|
|
1
|
+
import { defineComponent as _, ref as c, computed as h, watch as C, toRef as N, nextTick as O } from "vue";
|
|
2
|
+
import b from "../../wrappers/WpDrawer.vue.js";
|
|
3
|
+
import { useTranslations as D } from "../../../composables/useTranslations.js";
|
|
4
4
|
import { useTemplateNameValidator as x } from "../../../composables/validators/saveAsTemplate.js";
|
|
5
5
|
import { useTemplateLibraryApi as B } from "../../../services/templateLibraryApi.js";
|
|
6
|
-
import { useEditorStore as
|
|
7
|
-
import { useSaveAsTemplateStore as
|
|
8
|
-
import { InMultiSelect as
|
|
9
|
-
import { useDebounceFn as
|
|
10
|
-
const
|
|
6
|
+
import { useEditorStore as k } from "../../../stores/editor.js";
|
|
7
|
+
import { useSaveAsTemplateStore as I } from "../../../stores/save-as-template.js";
|
|
8
|
+
import { InMultiSelect as M, InBasicTextInput as V } from "@useinsider/design-system-vue";
|
|
9
|
+
import { useDebounceFn as E } from "../../../node_modules/@vueuse/shared/index.js";
|
|
10
|
+
const J = /* @__PURE__ */ _({
|
|
11
11
|
__name: "SaveAsTemplateDrawer",
|
|
12
|
-
setup(
|
|
13
|
-
const
|
|
12
|
+
setup(R) {
|
|
13
|
+
const s = D(), o = k(), t = I(), { createTemplate: m } = B(), a = c(!1), n = c(!1), r = c(""), f = h(() => ({
|
|
14
14
|
primaryButton: {
|
|
15
15
|
styling: "solid",
|
|
16
16
|
type: "primary",
|
|
17
|
-
labelText:
|
|
17
|
+
labelText: s(a.value ? "newsletter.saving" : "products.save"),
|
|
18
18
|
loadingStatus: a.value,
|
|
19
19
|
disabledStatus: t.skeletonStatus
|
|
20
20
|
},
|
|
21
21
|
cancelOrBackButton: {
|
|
22
22
|
styling: "ghost",
|
|
23
23
|
type: "secondary",
|
|
24
|
-
labelText:
|
|
24
|
+
labelText: s("products.cancel"),
|
|
25
25
|
disabledStatus: a.value
|
|
26
26
|
}
|
|
27
|
-
})),
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
const e =
|
|
31
|
-
return
|
|
32
|
-
}, v =
|
|
33
|
-
t.templateName = e, await
|
|
34
|
-
}, 500),
|
|
35
|
-
|
|
36
|
-
},
|
|
27
|
+
})), p = () => {
|
|
28
|
+
r.value = "", o.isSaveAsTemplateDrawerOpen = !1;
|
|
29
|
+
}, l = async () => {
|
|
30
|
+
const e = N(t, "templateName"), { success: i, errorMessage: A } = await x(e).validate();
|
|
31
|
+
return r.value = A, i;
|
|
32
|
+
}, v = E(async (e) => {
|
|
33
|
+
t.templateName = e, await l();
|
|
34
|
+
}, 500), S = async (e) => {
|
|
35
|
+
n.value = !0, await t.addCategory(e), n.value = !1;
|
|
36
|
+
}, T = (e) => {
|
|
37
37
|
t.selectedCategories = e;
|
|
38
|
-
},
|
|
38
|
+
}, g = (e) => {
|
|
39
39
|
e && (t.selectedCategories = e);
|
|
40
|
-
},
|
|
40
|
+
}, y = () => {
|
|
41
41
|
t.selectedCategories = [];
|
|
42
42
|
}, w = async () => {
|
|
43
|
-
if (a.value = !0, !await
|
|
43
|
+
if (a.value = !0, !await l()) {
|
|
44
44
|
a.value = !1;
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
a.value = !1,
|
|
49
|
-
},
|
|
50
|
-
|
|
47
|
+
const i = await m();
|
|
48
|
+
a.value = !1, i && p();
|
|
49
|
+
}, u = () => {
|
|
50
|
+
O(() => {
|
|
51
51
|
const e = document.querySelector("input#guido__template-name-input");
|
|
52
52
|
e == null || e.focus();
|
|
53
53
|
});
|
|
54
54
|
}, d = async () => {
|
|
55
|
-
t.$reset(), await t.fetchCategories(), t.skeletonStatus = !1,
|
|
55
|
+
t.$reset(), await t.fetchCategories(), t.skeletonStatus = !1, u();
|
|
56
56
|
};
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
}), { __sfc: !0, trans:
|
|
57
|
+
return C(() => o.isSaveAsTemplateDrawerOpen, (e) => {
|
|
58
|
+
e && d();
|
|
59
|
+
}), { __sfc: !0, trans: s, editorStore: o, saveAsTemplateStore: t, createTemplate: m, isSaving: a, isAddingOption: n, templateNameError: r, footerButtonGroupOptions: f, closeModal: p, validateTemplateName: l, handleTemplateName: v, handleAddOption: S, handleCategoryChange: T, handleSelectAllOptions: g, handleResetAllOptions: y, saveTemplate: w, focusToInput: u, initializeDrawer: d, WpDrawer: b, InBasicTextInput: V, InMultiSelect: M };
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
export {
|
|
63
|
-
|
|
63
|
+
J as default
|
|
64
64
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { getCsrfToken as
|
|
2
|
-
import { ref as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
import { getCsrfToken as O } from "../utils/genericUtil.js";
|
|
2
|
+
import { ref as m, computed as T } from "vue";
|
|
3
|
+
const X = (b = {}) => {
|
|
4
|
+
const p = m(!1), a = m(null), u = m(null), g = T(() => p.value), y = T(() => a.value !== null), v = {
|
|
5
5
|
baseURL: "",
|
|
6
6
|
timeout: 1e4,
|
|
7
7
|
retry: 0,
|
|
8
8
|
retryDelay: 1e3,
|
|
9
9
|
headers: {
|
|
10
10
|
"Content-Type": "application/json",
|
|
11
|
-
"X-CSRF-TOKEN":
|
|
11
|
+
"X-CSRF-TOKEN": O(),
|
|
12
|
+
Accept: "application/json",
|
|
13
|
+
"X-Requested-With": "XMLHttpRequest"
|
|
12
14
|
},
|
|
13
15
|
...b
|
|
14
16
|
}, w = (e, s) => {
|
|
@@ -22,22 +24,22 @@ const k = (b = {}) => {
|
|
|
22
24
|
}, e);
|
|
23
25
|
}), x = (e) => new Promise((s) => {
|
|
24
26
|
setTimeout(s, e);
|
|
25
|
-
}), i = async (e, s, t,
|
|
26
|
-
a.value = null,
|
|
27
|
-
const n = { ...v, ...
|
|
27
|
+
}), i = async (e, s, t, L = {}) => {
|
|
28
|
+
a.value = null, p.value = !0, u.value = new AbortController();
|
|
29
|
+
const n = { ...v, ...L }, D = w(s, n.baseURL), c = {
|
|
28
30
|
method: e,
|
|
29
31
|
headers: { ...n.headers },
|
|
30
32
|
signal: u.value.signal,
|
|
31
33
|
...n
|
|
32
34
|
};
|
|
33
35
|
t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
|
|
34
|
-
const E = async (
|
|
36
|
+
const E = async (h = 0) => {
|
|
35
37
|
try {
|
|
36
|
-
const o = [fetch(
|
|
38
|
+
const o = [fetch(D, c)];
|
|
37
39
|
n.timeout && o.push(P(n.timeout));
|
|
38
40
|
const r = await Promise.race(o);
|
|
39
41
|
if (!r.ok) {
|
|
40
|
-
const
|
|
42
|
+
const H = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(H);
|
|
41
43
|
throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
|
|
42
44
|
}
|
|
43
45
|
let f;
|
|
@@ -50,19 +52,19 @@ const k = (b = {}) => {
|
|
|
50
52
|
};
|
|
51
53
|
} catch (o) {
|
|
52
54
|
const r = o instanceof Error && o.name === "AbortError";
|
|
53
|
-
if (
|
|
54
|
-
return await x(n.retryDelay || 1e3), E(
|
|
55
|
+
if (h < (n.retry || 0) && !r)
|
|
56
|
+
return await x(n.retryDelay || 1e3), E(h + 1);
|
|
55
57
|
throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
60
|
try {
|
|
59
61
|
return await E();
|
|
60
62
|
} finally {
|
|
61
|
-
|
|
63
|
+
p.value = !1, u.value = null;
|
|
62
64
|
}
|
|
63
|
-
}, C = (e, s) => i("GET", e, void 0, s),
|
|
65
|
+
}, C = (e, s) => i("GET", e, void 0, s), R = (e, s, t) => i("POST", e, s, t), $ = (e, s, t) => i("PUT", e, s, t), q = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), U = (e) => {
|
|
64
66
|
u.value && u.value.abort(e);
|
|
65
|
-
},
|
|
67
|
+
}, W = () => {
|
|
66
68
|
a.value = null;
|
|
67
69
|
};
|
|
68
70
|
return {
|
|
@@ -73,14 +75,14 @@ const k = (b = {}) => {
|
|
|
73
75
|
// Methods
|
|
74
76
|
request: i,
|
|
75
77
|
get: C,
|
|
76
|
-
post:
|
|
77
|
-
put:
|
|
78
|
-
patch:
|
|
78
|
+
post: R,
|
|
79
|
+
put: $,
|
|
80
|
+
patch: q,
|
|
79
81
|
delete: A,
|
|
80
|
-
cancel:
|
|
81
|
-
clearError:
|
|
82
|
+
cancel: U,
|
|
83
|
+
clearError: W
|
|
82
84
|
};
|
|
83
85
|
};
|
|
84
86
|
export {
|
|
85
|
-
|
|
87
|
+
X as useHttp
|
|
86
88
|
};
|
|
@@ -4,13 +4,14 @@ import { useToaster as C } from "../composables/useToaster.js";
|
|
|
4
4
|
import { useTranslations as h } from "../composables/useTranslations.js";
|
|
5
5
|
import { useLiquidValidator as S } from "../composables/validators/useLiquidValidator.js";
|
|
6
6
|
import { EditorType as v } from "../enums/defaults.js";
|
|
7
|
-
import { ToasterTypeOptions as
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { useSaveAsTemplateStore as
|
|
7
|
+
import { ToasterTypeOptions as x } from "../enums/toaster.js";
|
|
8
|
+
import { useRecommendationExtensionStore as E } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { useSaveAsTemplateStore as N } from "../stores/save-as-template.js";
|
|
10
10
|
import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
|
|
11
|
+
import { isPlainObject as P } from "../utils/genericUtil.js";
|
|
11
12
|
import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
|
|
12
|
-
const
|
|
13
|
-
const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax:
|
|
13
|
+
const B = () => {
|
|
14
|
+
const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax: f } = S(), u = h();
|
|
14
15
|
return {
|
|
15
16
|
getCategories: async () => {
|
|
16
17
|
try {
|
|
@@ -40,10 +41,10 @@ const j = () => {
|
|
|
40
41
|
createTemplate: async () => {
|
|
41
42
|
var e, t, d, y;
|
|
42
43
|
try {
|
|
43
|
-
const { prepareTemplateDetails: i } = A(), s =
|
|
44
|
-
if (p("liquidSyntax") && !await
|
|
44
|
+
const { prepareTemplateDetails: i } = A(), s = N(), a = await i();
|
|
45
|
+
if (p("liquidSyntax") && !await f(a.compiledHtml))
|
|
45
46
|
return !1;
|
|
46
|
-
const
|
|
47
|
+
const T = {
|
|
47
48
|
name: s.getTemplateName,
|
|
48
49
|
categories: s.getSelectedCategoryIds,
|
|
49
50
|
productId: ((t = (e = c.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
|
|
@@ -54,7 +55,7 @@ const j = () => {
|
|
|
54
55
|
unsubscriptionPreferencePageStatus: !1,
|
|
55
56
|
unsubscriptionPreferencePages: [],
|
|
56
57
|
recommendationCampaignUrls: r(
|
|
57
|
-
|
|
58
|
+
E().recommendationCampaignUrls
|
|
58
59
|
),
|
|
59
60
|
recommendationConfigs: r({}),
|
|
60
61
|
isGuido: !0,
|
|
@@ -66,16 +67,18 @@ const j = () => {
|
|
|
66
67
|
css: a.css,
|
|
67
68
|
dynamicContentList: a.dynamicContentList
|
|
68
69
|
})
|
|
69
|
-
}, { data:
|
|
70
|
+
}, { data: g } = await m(
|
|
70
71
|
"/newsletter/template-library/create-template",
|
|
71
|
-
|
|
72
|
+
T
|
|
72
73
|
);
|
|
73
|
-
|
|
74
|
+
if (!P(g))
|
|
75
|
+
throw new Error("Unexpected create-template response");
|
|
76
|
+
return g.type === "alert" ? (l({
|
|
74
77
|
message: u(
|
|
75
78
|
"newsletter.template-library-save-alert",
|
|
76
79
|
{ templateName: s.getTemplateName }
|
|
77
80
|
),
|
|
78
|
-
type:
|
|
81
|
+
type: x.Error
|
|
79
82
|
}), !1) : (l({
|
|
80
83
|
message: u(
|
|
81
84
|
"newsletter.template-library-save-success",
|
|
@@ -90,5 +93,5 @@ const j = () => {
|
|
|
90
93
|
};
|
|
91
94
|
};
|
|
92
95
|
export {
|
|
93
|
-
|
|
96
|
+
B as useTemplateLibraryApi
|
|
94
97
|
};
|
|
@@ -30,3 +30,9 @@ export declare const replaceString: (string?: string, values?: Record<string, st
|
|
|
30
30
|
* a string nor a number becomes ''.
|
|
31
31
|
*/
|
|
32
32
|
export declare const asText: (value: unknown) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Narrows an unknown API value to a plain JSON object. Arrays and exotic
|
|
35
|
+
* objects (Blob, Date, FormData) are rejected, so a response body that useHttp
|
|
36
|
+
* parsed as text or blob can never be read as a JSON payload.
|
|
37
|
+
*/
|
|
38
|
+
export declare const isPlainObject: <T>(value: T) => value is T & Record<string, unknown>;
|
|
@@ -1,69 +1,75 @@
|
|
|
1
|
-
const o = (
|
|
2
|
-
const
|
|
3
|
-
text:
|
|
1
|
+
const o = (a) => {
|
|
2
|
+
const t = a.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((e) => e.trim()), [s] = t, r = {
|
|
3
|
+
text: a.label,
|
|
4
4
|
value: s || ""
|
|
5
5
|
};
|
|
6
|
-
if (
|
|
7
|
-
const [,
|
|
8
|
-
if (
|
|
9
|
-
let n =
|
|
6
|
+
if (t.length >= 2) {
|
|
7
|
+
const [, e, l] = t;
|
|
8
|
+
if (e.startsWith("default:")) {
|
|
9
|
+
let n = e.slice(8).trim();
|
|
10
10
|
n.startsWith('"') && n.endsWith('"') && (n = n.slice(1, -1)), r.fallback = n;
|
|
11
11
|
} else {
|
|
12
|
-
const n =
|
|
13
|
-
n ? r.format = n :
|
|
12
|
+
const n = e.includes("=") ? { key: e.split("=")[0].trim(), value: e.split("=")[1].trim() } : null;
|
|
13
|
+
n ? r.format = n : l || (r.fallback = e), l && (r.fallback = l);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
return r;
|
|
17
|
-
},
|
|
18
|
-
if (
|
|
17
|
+
}, u = (a, c = !1) => a.map((t) => {
|
|
18
|
+
if (t.format)
|
|
19
19
|
return {
|
|
20
|
-
label: `${
|
|
21
|
-
value: `{{${
|
|
20
|
+
label: `${t.text} | ${t.format.key}=${t.format.value}`,
|
|
21
|
+
value: `{{${t.value}|${t.format.key}=${t.format.value}}}`
|
|
22
22
|
};
|
|
23
23
|
if (c) {
|
|
24
|
-
if (!
|
|
24
|
+
if (!t.fallback)
|
|
25
25
|
return {
|
|
26
|
-
label:
|
|
27
|
-
value: `{{ ${
|
|
26
|
+
label: t.text,
|
|
27
|
+
value: `{{ ${t.value} }}`
|
|
28
28
|
};
|
|
29
|
-
const r = !Number.isNaN(Number(
|
|
29
|
+
const r = !Number.isNaN(Number(t.fallback)) && t.fallback.trim() !== "" ? t.fallback : `"${t.fallback}"`;
|
|
30
30
|
return {
|
|
31
|
-
label: `${
|
|
32
|
-
value: `{{ ${
|
|
31
|
+
label: `${t.text} | ${t.fallback}`,
|
|
32
|
+
value: `{{ ${t.value} | default: ${r} }}`
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
return {
|
|
36
|
-
label:
|
|
37
|
-
value:
|
|
36
|
+
label: t.fallback ? `${t.text} | ${t.fallback}` : t.text,
|
|
37
|
+
value: t.fallback ? `{{${t.value}|${t.fallback}}}` : `{{${t.value}}}`
|
|
38
38
|
};
|
|
39
|
-
}), b = (
|
|
40
|
-
const c = [],
|
|
41
|
-
Array.isArray(
|
|
42
|
-
const n = [...
|
|
39
|
+
}), b = (a) => {
|
|
40
|
+
const c = [], t = /* @__PURE__ */ new Set(), s = (e) => {
|
|
41
|
+
Array.isArray(e) && e.forEach((l) => {
|
|
42
|
+
const n = [...l.children ?? [], ...l.select_items ?? []];
|
|
43
43
|
if (n.length > 0) {
|
|
44
44
|
s(n);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const f = l.text || l.tag_text;
|
|
48
|
+
f && l.value && !t.has(l.value) && (t.add(l.value), c.push({ text: f, value: l.value }));
|
|
49
49
|
});
|
|
50
|
-
}, [r] = Object.values(
|
|
50
|
+
}, [r] = Object.values(a ?? {});
|
|
51
51
|
return s(r), c;
|
|
52
|
-
}, i = (
|
|
53
|
-
const s = new Set(
|
|
52
|
+
}, i = (a, c, t = !1) => {
|
|
53
|
+
const s = new Set(a.map((e) => e.value)), r = c.filter((e) => s.has(e.value) ? !1 : (s.add(e.value), !0));
|
|
54
54
|
return [
|
|
55
|
-
...
|
|
56
|
-
...
|
|
55
|
+
...u(a, t),
|
|
56
|
+
...u(r, t)
|
|
57
57
|
];
|
|
58
|
-
},
|
|
59
|
-
var
|
|
60
|
-
return ((
|
|
61
|
-
},
|
|
58
|
+
}, k = () => {
|
|
59
|
+
var a;
|
|
60
|
+
return ((a = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : a.getAttribute("content")) ?? "";
|
|
61
|
+
}, v = (a) => typeof a == "string" ? a : typeof a == "number" ? String(a) : "", y = (a) => {
|
|
62
|
+
if (a === null || typeof a != "object" || Array.isArray(a))
|
|
63
|
+
return !1;
|
|
64
|
+
const c = Object.getPrototypeOf(a);
|
|
65
|
+
return c === Object.prototype || c === null;
|
|
66
|
+
};
|
|
62
67
|
export {
|
|
63
|
-
|
|
68
|
+
v as asText,
|
|
64
69
|
i as buildMergeTagEntries,
|
|
65
|
-
|
|
70
|
+
u as dynamicContentToMergeTags,
|
|
66
71
|
b as flattenDynamicContentList,
|
|
67
|
-
|
|
72
|
+
k as getCsrfToken,
|
|
73
|
+
y as isPlainObject,
|
|
68
74
|
o as mergeTagToDynamicContent
|
|
69
75
|
};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { useActionsApi as k } from "../composables/useActionsApi.js";
|
|
2
2
|
import { useConfig as U } from "../composables/useConfig.js";
|
|
3
3
|
import { useHtmlCompiler as x } from "../composables/useHtmlCompiler.js";
|
|
4
|
-
import { DEFAULT_CURRENCY as m, DEFAULT_NODE_CONFIG as
|
|
5
|
-
import { useRecommendationExtensionStore as
|
|
4
|
+
import { DEFAULT_CURRENCY as m, DEFAULT_NODE_CONFIG as n } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
5
|
+
import { useRecommendationExtensionStore as A } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
6
6
|
import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
|
|
7
|
-
import { DATA_ATTRIBUTES as
|
|
7
|
+
import { DATA_ATTRIBUTES as T } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
8
8
|
import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
9
9
|
import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
|
|
10
10
|
import { useEditorStore as z } from "../stores/editor.js";
|
|
11
|
-
import { useUnsubscribeStore as
|
|
11
|
+
import { useUnsubscribeStore as O } from "../stores/unsubscribe.js";
|
|
12
|
+
import { isPlainObject as _ } from "./genericUtil.js";
|
|
12
13
|
import { assignTrackingIds as v } from "./linkTrackingIds.js";
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
const o =
|
|
14
|
+
function M(l) {
|
|
15
|
+
const i = new DOMParser().parseFromString(l, "text/html").querySelectorAll(`[${T.PAGE_LIST}]`), t = [];
|
|
16
|
+
return i.forEach((c) => {
|
|
17
|
+
const o = c.getAttribute(T.PAGE_LIST);
|
|
17
18
|
o && t.push(...R(o));
|
|
18
19
|
}), [...new Set(t)];
|
|
19
20
|
}
|
|
20
|
-
async function
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
21
|
+
async function q(l) {
|
|
22
|
+
const a = new DOMParser().parseFromString(l, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
23
|
+
if (a.length === 0)
|
|
23
24
|
return;
|
|
24
|
-
const
|
|
25
|
-
|
|
25
|
+
const i = A();
|
|
26
|
+
a.forEach((t) => {
|
|
26
27
|
var r, d, g, f, s, y;
|
|
27
|
-
const
|
|
28
|
+
const c = t.getAttribute("recommendation-id"), o = c ? Number(c) : NaN;
|
|
28
29
|
if (!Number.isFinite(o))
|
|
29
30
|
return;
|
|
30
31
|
const p = t.getAttribute("esd-ext-config");
|
|
@@ -36,21 +37,21 @@ async function M(l) {
|
|
|
36
37
|
} catch {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
|
-
if (!
|
|
40
|
+
if (!_(e))
|
|
40
41
|
return;
|
|
41
42
|
const b = {
|
|
42
43
|
// Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
|
|
43
44
|
// already-saved blocks that never re-run the migrator don't emit a
|
|
44
45
|
// strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
|
|
45
|
-
strategy: L(e.strategy) ||
|
|
46
|
-
strategyId: e.strategyId ??
|
|
47
|
-
language: e.language ??
|
|
48
|
-
size: e.size ??
|
|
46
|
+
strategy: L(e.strategy) || n.strategy,
|
|
47
|
+
strategyId: e.strategyId ?? n.strategyId,
|
|
48
|
+
language: e.language ?? n.language,
|
|
49
|
+
size: e.size ?? n.size,
|
|
49
50
|
// Spread the default arrays so each block gets a fresh reference
|
|
50
51
|
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
51
|
-
productIds: e.productIds ?? [...
|
|
52
|
-
filters: e.filters ?? [...
|
|
53
|
-
shuffleProducts: e.shuffleProducts ??
|
|
52
|
+
productIds: e.productIds ?? [...n.productIds],
|
|
53
|
+
filters: e.filters ?? [...n.filters],
|
|
54
|
+
shuffleProducts: e.shuffleProducts ?? n.shuffleProducts,
|
|
54
55
|
currencyCode: ((r = e.currency) == null ? void 0 : r.code) ?? m.code,
|
|
55
56
|
currencySymbol: ((d = e.currency) == null ? void 0 : d.symbol) ?? m.symbol,
|
|
56
57
|
currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? m.alignment,
|
|
@@ -58,10 +59,10 @@ async function M(l) {
|
|
|
58
59
|
currencyDecimalSeparator: ((s = e.currency) == null ? void 0 : s.decimalSeparator) ?? m.decimalSeparator,
|
|
59
60
|
currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? m.thousandSeparator
|
|
60
61
|
};
|
|
61
|
-
|
|
62
|
+
i.seedBlockUrlConfig(o, b);
|
|
62
63
|
});
|
|
63
64
|
try {
|
|
64
|
-
await
|
|
65
|
+
await i.fetchRecommendationCreateData();
|
|
65
66
|
} catch (t) {
|
|
66
67
|
console.warn(
|
|
67
68
|
"Recommendation reference data pre-load failed; validator will skip the availability check.",
|
|
@@ -69,24 +70,24 @@ async function M(l) {
|
|
|
69
70
|
);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
-
const l = N(), u = z(),
|
|
73
|
+
const te = () => {
|
|
74
|
+
const l = N(), u = z(), a = O(), { getCompiledEmail: i, getTemplateData: t, updateHtmlAndCss: c } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
|
|
74
75
|
return {
|
|
75
76
|
prepareTemplateDetails: async () => {
|
|
76
77
|
let { html: r, css: d, syncModulesIds: g = [] } = await t();
|
|
77
78
|
if (e("linkTrackingIds"))
|
|
78
79
|
try {
|
|
79
80
|
const { html: h, changed: F, nextSeq: H } = v(r, u.trackIdSessionFloor);
|
|
80
|
-
u.trackIdSessionFloor = H, F && (r = h, await
|
|
81
|
+
u.trackIdSessionFloor = H, F && (r = h, await c(h, d));
|
|
81
82
|
} catch (h) {
|
|
82
83
|
console.error("Tracking-id step failed, saving anyway:", h);
|
|
83
84
|
}
|
|
84
|
-
const { html: f, ampHtml: s = "", ampErrors: y = [] } = await
|
|
85
|
+
const { html: f, ampHtml: s = "", ampErrors: y = [] } = await i({
|
|
85
86
|
minimize: !0,
|
|
86
87
|
resetDataSavedFlag: !1
|
|
87
88
|
});
|
|
88
|
-
|
|
89
|
-
const { compiledHtml: I, stats: S, appliedRules: w } = o(f), D = s && p(s).compiledHtml,
|
|
89
|
+
a.selectedUnsubscribePages.length && await a.fetchTemplates(), await q(r);
|
|
90
|
+
const { compiledHtml: I, stats: S, appliedRules: w } = o(f), D = s && p(s).compiledHtml, P = l.getSelectedDynamicContentList, E = A(), C = M(r);
|
|
90
91
|
return console.debug("HTML Compilation Stats:", {
|
|
91
92
|
originalSize: S.originalSize,
|
|
92
93
|
compiledSize: S.compiledSize,
|
|
@@ -94,7 +95,7 @@ const Z = () => {
|
|
|
94
95
|
appliedRules: w,
|
|
95
96
|
executionTime: `${S.executionTime.toFixed(2)}ms`
|
|
96
97
|
}), {
|
|
97
|
-
dynamicContentList:
|
|
98
|
+
dynamicContentList: P,
|
|
98
99
|
compiledHtml: I,
|
|
99
100
|
rawHtml: r,
|
|
100
101
|
css: d,
|
|
@@ -102,18 +103,18 @@ const Z = () => {
|
|
|
102
103
|
ampErrors: y,
|
|
103
104
|
modules: g.map(Number),
|
|
104
105
|
recommendation: {
|
|
105
|
-
campaignUrls:
|
|
106
|
+
campaignUrls: E.recommendationCampaignUrls,
|
|
106
107
|
configs: {}
|
|
107
108
|
},
|
|
108
109
|
unsubscribe: {
|
|
109
|
-
status:
|
|
110
|
-
config:
|
|
110
|
+
status: C.length > 0,
|
|
111
|
+
config: C
|
|
111
112
|
}
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
};
|
|
116
117
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
M as getHtmlReferencedUnsubscribePages,
|
|
119
|
+
te as useTemplatePreparation
|
|
119
120
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.3-beta.ec88281",
|
|
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",
|