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