@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.
@@ -1,64 +1,64 @@
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";
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 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__ */ _({
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(R) {
13
- const s = D(), o = k(), t = I(), { createTemplate: m } = B(), a = c(!1), n = c(!1), r = c(""), f = h(() => ({
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: s(a.value ? "newsletter.saving" : "products.save"),
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: s("products.cancel"),
24
+ labelText: o("products.cancel"),
25
25
  disabledStatus: a.value
26
26
  }
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) => {
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
- }, g = (e) => {
38
+ }, S = (e) => {
39
39
  e && (t.selectedCategories = e);
40
- }, y = () => {
40
+ }, T = () => {
41
41
  t.selectedCategories = [];
42
42
  }, w = async () => {
43
- if (a.value = !0, !await l()) {
43
+ if (a.value = !0, !await i()) {
44
44
  a.value = !1;
45
45
  return;
46
46
  }
47
- const i = await m();
48
- a.value = !1, i && p();
49
- }, u = () => {
50
- O(() => {
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, u();
55
+ t.$reset(), await t.fetchCategories(), t.skeletonStatus = !1, p();
56
56
  };
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 };
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
- J as default
63
+ H as default
64
64
  };
@@ -1,16 +1,14 @@
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 = {
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": O(),
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, L = {}) => {
28
- a.value = null, p.value = !0, u.value = new AbortController();
29
- const n = { ...v, ...L }, D = w(s, n.baseURL), c = {
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 (h = 0) => {
34
+ const E = async (m = 0) => {
37
35
  try {
38
- const o = [fetch(D, c)];
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 H = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(H);
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 (h < (n.retry || 0) && !r)
56
- return await x(n.retryDelay || 1e3), E(h + 1);
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
- p.value = !1, u.value = null;
61
+ h.value = !1, u.value = null;
64
62
  }
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) => {
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
- }, W = () => {
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: R,
79
- put: $,
80
- patch: q,
76
+ post: $,
77
+ put: R,
78
+ patch: U,
81
79
  delete: A,
82
- cancel: U,
83
- clearError: W
80
+ cancel: W,
81
+ clearError: q
84
82
  };
85
83
  };
86
84
  export {
87
- X as useHttp
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 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";
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 B = () => {
14
- const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax: f } = S(), u = h();
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 = N(), a = await i();
45
- if (p("liquidSyntax") && !await f(a.compiledHtml))
43
+ const { prepareTemplateDetails: i } = A(), s = E(), a = await i();
44
+ if (p("liquidSyntax") && !await g(a.compiledHtml))
46
45
  return !1;
47
- const T = {
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
- E().recommendationCampaignUrls
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: g } = await m(
69
+ }, { data: { type: T } } = await m(
71
70
  "/newsletter/template-library/create-template",
72
- T
71
+ f
73
72
  );
74
- if (!P(g))
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: x.Error
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
- B as useTemplateLibraryApi
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
- import { formatToLiquidFilter as b, quoteArgument as y, liquidFilterToFormat as h } from "./liquidDynamicContent.js";
2
- const g = (t) => {
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: l || ""
4
+ value: s || ""
16
5
  };
17
- if (e.length >= 2) {
18
- const [, a, n] = e;
19
- if (a.startsWith(c))
20
- s.fallback = f(a);
21
- else {
22
- const o = h(a) ?? g(a);
23
- o ? s.format = o : n || (s.fallback = a), n && (s.fallback = f(n));
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 s;
27
- }, p = (t) => {
28
- const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : y(t);
29
- return e === null ? null : `${c} ${e}`;
30
- }, v = (t) => {
31
- const r = t.format ? b(t.format) : null, e = t.fallback ? p(t.fallback) : null, l = [t.value, r, e].filter(Boolean);
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: [t.text, r, e && t.fallback].filter(Boolean).join(" | "),
34
- value: `{{ ${l.join(" | ")} }}`
36
+ label: a.fallback ? `${a.text} | ${a.fallback}` : a.text,
37
+ value: a.fallback ? `{{${a.value}|${a.fallback}}}` : `{{${a.value}}}`
35
38
  };
36
- }, i = (t, r = !1) => t.map((e) => r ? v(e) : e.format ? {
37
- label: `${e.text} | ${e.format.key}=${e.format.value}`,
38
- value: `{{${e.value}|${e.format.key}=${e.format.value}}}`
39
- } : {
40
- label: e.fallback ? `${e.text} | ${e.fallback}` : e.text,
41
- value: e.fallback ? `{{${e.value}|${e.fallback}}}` : `{{${e.value}}}`
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 = n.text || n.tag_text;
51
- u && n.value && !e.has(n.value) && (e.add(n.value), r.push({ text: u, value: n.value }));
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
- }, [s] = Object.values(t ?? {});
54
- return l(s), r;
55
- }, d = (t, r, e = !1) => {
56
- const l = new Set(t.map((a) => a.value)), s = r.filter((a) => l.has(a.value) ? !1 : (l.add(a.value), !0));
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
- ...i(t, e),
59
- ...i(s, e)
55
+ ...f(t, a),
56
+ ...f(r, a)
60
57
  ];
61
- }, F = () => {
58
+ }, v = () => {
62
59
  var t;
63
60
  return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
64
- }, T = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", x = (t) => {
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
- T as asText,
72
- d as buildMergeTagEntries,
73
- i as dynamicContentToMergeTags,
74
- $ as flattenDynamicContentList,
75
- F as getCsrfToken,
76
- x as isPlainObject,
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 n } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
- import { useRecommendationExtensionStore as A } from "../extensions/Blocks/Recommendation/store/recommendation.js";
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 T } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
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 O } from "../stores/unsubscribe.js";
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 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);
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 q(l) {
22
- const a = new DOMParser().parseFromString(l, "text/html").querySelectorAll(".recommendation-block-v2");
23
- if (a.length === 0)
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 i = A();
26
- a.forEach((t) => {
24
+ const c = T();
25
+ n.forEach((t) => {
27
26
  var r, d, g, f, s, y;
28
- const c = t.getAttribute("recommendation-id"), o = c ? Number(c) : NaN;
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 (!_(e))
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) || n.strategy,
47
- strategyId: e.strategyId ?? n.strategyId,
48
- language: e.language ?? n.language,
49
- size: e.size ?? n.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 ?? [...n.productIds],
53
- filters: e.filters ?? [...n.filters],
54
- shuffleProducts: e.shuffleProducts ?? n.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
- i.seedBlockUrlConfig(o, b);
61
+ c.seedBlockUrlConfig(o, b);
63
62
  });
64
63
  try {
65
- await i.fetchRecommendationCreateData();
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 te = () => {
74
- const l = N(), u = z(), a = O(), { getCompiledEmail: i, getTemplateData: t, updateHtmlAndCss: c } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
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 c(h, d));
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 i({
84
+ const { html: f, ampHtml: s = "", ampErrors: y = [] } = await c({
86
85
  minimize: !0,
87
86
  resetDataSavedFlag: !1
88
87
  });
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);
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: P,
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: E.recommendationCampaignUrls,
105
+ campaignUrls: P.recommendationCampaignUrls,
107
106
  configs: {}
108
107
  },
109
108
  unsubscribe: {
110
- status: C.length > 0,
111
- config: C
109
+ status: A.length > 0,
110
+ config: A
112
111
  }
113
112
  };
114
113
  }
115
114
  };
116
115
  };
117
116
  export {
118
- M as getHtmlReferencedUnsubscribePages,
119
- te as useTemplatePreparation
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-beta.ff43aaa",
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
- };