@useinsider/guido 3.15.0-beta.36d3655 → 3.15.0-beta.e9014b0

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,7 +1,7 @@
1
- import { filterAmpErrors as T } from "../utils/ampErrorFilter.js";
1
+ import { filterAmpErrors as w } from "../utils/ampErrorFilter.js";
2
2
  import { useToaster as A } from "./useToaster.js";
3
- const p = 1e4, D = () => {
4
- const { handleError: r } = A(), l = (t = {}) => new Promise((e, a) => {
3
+ const D = () => {
4
+ const { handleError: n } = A(), s = (t = {}) => new Promise((e, a) => {
5
5
  const o = { ...{
6
6
  minimize: !0,
7
7
  utmEntity: {
@@ -21,29 +21,29 @@ const p = 1e4, D = () => {
21
21
  forceAmp: !1,
22
22
  resetDataSavedFlag: !1,
23
23
  disableLineHeightsReplace: !0
24
- }, ...t }, n = {
25
- callback: (m, d, c, u, w) => {
26
- m ? a(m) : e({
27
- html: d,
28
- ampHtml: c,
29
- ampErrors: T(u ?? []),
30
- displayConditions: w
24
+ }, ...t }, l = {
25
+ callback: (r, p, d, c, u) => {
26
+ r ? a(r) : e({
27
+ html: p,
28
+ ampHtml: d,
29
+ ampErrors: w(c ?? []),
30
+ displayConditions: u
31
31
  });
32
32
  },
33
33
  ...o
34
34
  };
35
- window.StripoEditorApi.actionsApi.compileEmail(n);
35
+ window.StripoEditorApi.actionsApi.compileEmail(l);
36
36
  });
37
37
  return {
38
- getCompiledEmail: l,
38
+ getCompiledEmail: s,
39
39
  getTemplateData: () => new Promise((t) => {
40
- const e = ({ html: a, css: i, width: o, height: s, utmParams: n, syncModulesIds: m }) => t({
40
+ const e = ({ html: a, css: i, width: o, height: m, utmParams: l, syncModulesIds: r }) => t({
41
41
  html: a,
42
42
  css: i,
43
43
  width: o,
44
- height: s,
45
- utmParams: n,
46
- syncModulesIds: m
44
+ height: m,
45
+ utmParams: l,
46
+ syncModulesIds: r
47
47
  });
48
48
  window.StripoEditorApi.actionsApi.getTemplateData(e);
49
49
  }),
@@ -57,7 +57,7 @@ const p = 1e4, D = () => {
57
57
  displayConditions: a,
58
58
  ampHtml: i = "",
59
59
  ampErrors: o = []
60
- } = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
60
+ } = await s({ minimize: !1, resetDataSavedFlag: !1, ...t });
61
61
  return {
62
62
  html: e,
63
63
  ampHtml: i,
@@ -65,7 +65,7 @@ const p = 1e4, D = () => {
65
65
  displayConditions: a
66
66
  };
67
67
  } catch (e) {
68
- return r(e, "Error loading preview"), {
68
+ return n(e, "Error loading preview"), {
69
69
  html: "",
70
70
  ampHtml: "",
71
71
  ampErrors: [],
@@ -81,27 +81,19 @@ const p = 1e4, D = () => {
81
81
  }
82
82
  try {
83
83
  window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
84
- i ? (r(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
84
+ i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
85
85
  });
86
86
  } catch (i) {
87
- r(i, "Failed to call updateTimerInClonedTemplate"), t(null);
87
+ n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
88
88
  }
89
89
  }),
90
90
  updateHtmlAndCss: (t, e) => {
91
- const { actionsApi: a } = window.StripoEditorApi;
92
- return new Promise((i, o) => {
93
- const s = new Error(
94
- `updateHtmlAndCss did not report completion within ${p}ms`
95
- ), n = setTimeout(() => o(s), p);
96
- a.updateHtmlAndCss(t, e, () => {
97
- clearTimeout(n), i();
98
- });
99
- });
91
+ window.StripoEditorApi.actionsApi.updateHtmlAndCss(t, e);
100
92
  },
101
93
  editorSave: () => new Promise((t) => {
102
94
  window.StripoEditorApi.actionsApi.save((e) => {
103
95
  if (e) {
104
- r(e, "Failed to save template"), t(!1);
96
+ n(e, "Failed to save template"), t(!1);
105
97
  return;
106
98
  }
107
99
  t(!0);
@@ -1,57 +1,55 @@
1
- import { useActionsApi as C } from "./useActionsApi.js";
2
- import { useConfig as h } from "./useConfig.js";
3
- import { useToaster as D } from "./useToaster.js";
1
+ import { useActionsApi as d } from "./useActionsApi.js";
2
+ import { useConfig as D } from "./useConfig.js";
3
+ import { useToaster as h } from "./useToaster.js";
4
4
  import { useTranslations as E } from "./useTranslations.js";
5
5
  import { ToasterTypeOptions as f } from "../enums/toaster.js";
6
6
  import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
7
- import { flattenDynamicContentList as w } from "../utils/genericUtil.js";
8
- import { extractUsedDynamicContent as S } from "../utils/registerUsedDynamicContent.js";
9
- import { ref as O } from "vue";
10
- const U = 250, o = O({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
11
- const { updateHtmlAndCss: r } = C(), { showToaster: m } = D(), y = E(), { template: T } = h(), d = A(), g = (e, t) => {
7
+ import { flattenDynamicContentList as S } from "../utils/genericUtil.js";
8
+ import { extractUsedDynamicContent as O } from "../utils/registerUsedDynamicContent.js";
9
+ import { ref as U } from "vue";
10
+ const w = 250, o = U({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
11
+ const { updateHtmlAndCss: c } = d(), { showToaster: m } = h(), y = E(), { template: T } = D(), v = A(), g = (e, t) => {
12
12
  const a = y(e);
13
13
  return a === e ? t : a;
14
- }, v = (e) => {
14
+ }, C = (e) => {
15
15
  o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
16
16
  }, l = (e, t, a) => {
17
- var c;
17
+ var n;
18
18
  o.value = { ...o.value, [e]: "applying" };
19
19
  try {
20
- r(t, a).catch((n) => {
21
- console.warn("Editor did not acknowledge the template apply.", n);
22
- }), o.value = { ...o.value, [e]: "applied" };
20
+ c(t, a), o.value = { ...o.value, [e]: "applied" };
23
21
  try {
24
- const n = w((c = T.value) == null ? void 0 : c.dynamicContentList), i = S(t, n);
25
- i.length > 0 && d.registerDynamicContent(i);
22
+ const r = S((n = T.value) == null ? void 0 : n.dynamicContentList), p = O(t, r);
23
+ p.length > 0 && v.registerDynamicContent(p);
26
24
  } catch {
27
25
  }
28
26
  u.get(e) !== t && (u.set(e, t), m({
29
27
  type: f.Success,
30
28
  message: g("newsletter.ai-template-applied", "Template applied to the editor")
31
29
  }));
32
- } catch (n) {
30
+ } catch (r) {
33
31
  o.value = { ...o.value, [e]: "failed" }, m({
34
32
  type: f.Error,
35
- message: n instanceof Error ? n.message : "Failed to apply template"
33
+ message: r instanceof Error ? r.message : "Failed to apply template"
36
34
  });
37
35
  }
38
- }, p = (e) => {
36
+ }, i = (e) => {
39
37
  const t = s[e];
40
38
  t && (clearTimeout(t), delete s[e]);
41
39
  };
42
- return { applyStatus: o, markPending: v, applyTemplate: (e, t) => {
43
- t.html && (p(e), l(e, t.html, t.css ?? ""));
40
+ return { applyStatus: o, markPending: C, applyTemplate: (e, t) => {
41
+ t.html && (i(e), l(e, t.html, t.css ?? ""));
44
42
  }, applyTemplateDebounced: (e, t) => {
45
43
  if (!t.html)
46
44
  return;
47
- p(e);
48
- const { html: a } = t, c = t.css ?? "";
45
+ i(e);
46
+ const { html: a } = t, n = t.css ?? "";
49
47
  s[e] = setTimeout(() => {
50
- delete s[e], l(e, a, c);
51
- }, U);
48
+ delete s[e], l(e, a, n);
49
+ }, w);
52
50
  } };
53
51
  }, G = () => {
54
- Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((r) => delete s[r]), o.value = {};
52
+ Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((c) => delete s[c]), o.value = {};
55
53
  };
56
54
  export {
57
55
  G as resetEmailTemplateApplier,
@@ -1,11 +1,11 @@
1
1
  import { useActionsApi as f } from "./useActionsApi.js";
2
- import { useHttp as H } from "./useHttp.js";
3
- import { useToaster as h } from "./useToaster.js";
4
- import { useStripoApi as k } from "../services/stripoApi.js";
5
- const S = () => {
6
- const { handleError: c } = h(), { getToken: l } = k(), { post: p } = H(), { updateHtmlAndCss: u } = f(), s = (t) => /esd-timer-id="(\d+)"/.test(t), i = async (t, e) => {
2
+ import { useHttp as w } from "./useHttp.js";
3
+ import { useToaster as H } from "./useToaster.js";
4
+ import { useStripoApi as y } from "../services/stripoApi.js";
5
+ const O = () => {
6
+ const { handleError: c } = H(), { getToken: u } = y(), { post: d } = w(), { updateHtmlAndCss: l } = f(), s = (t) => /esd-timer-id="(\d+)"/.test(t), i = async (t, e) => {
7
7
  try {
8
- return (await p(
8
+ return (await d(
9
9
  "https://plugins.stripo.email/api/v1/timers/clone",
10
10
  { html: t },
11
11
  {
@@ -25,31 +25,29 @@ const S = () => {
25
25
  cloneTimersOnSave: async (t) => {
26
26
  if (!s(t))
27
27
  return t;
28
- const e = await l();
28
+ const e = await u();
29
29
  return e && await i(t, e) || t;
30
30
  },
31
31
  updateTimersOnLoad: async (t) => {
32
- var e, r, n, d;
32
+ var e, r, o, m;
33
33
  try {
34
- const o = (r = (e = window.UIEditor) == null ? void 0 : e.getHtml) == null ? void 0 : r.call(e);
35
- if (!o || !s(o))
34
+ const n = (r = (e = window.UIEditor) == null ? void 0 : e.getHtml) == null ? void 0 : r.call(e);
35
+ if (!n || !s(n))
36
36
  return;
37
- const m = await t();
38
- if (!m)
37
+ const p = await t();
38
+ if (!p)
39
39
  return;
40
- const a = await i(o, m);
41
- if (!a || a === o)
40
+ const a = await i(n, p);
41
+ if (!a || a === n)
42
42
  return;
43
- const T = ((d = (n = window.UIEditor) == null ? void 0 : n.getCss) == null ? void 0 : d.call(n)) || "";
44
- u(a, T).catch((w) => {
45
- console.warn("Editor did not acknowledge the timer-block update.", w);
46
- });
47
- } catch (o) {
48
- c(o, "Failed to update timer blocks");
43
+ const T = ((m = (o = window.UIEditor) == null ? void 0 : o.getCss) == null ? void 0 : m.call(o)) || "";
44
+ l(a, T);
45
+ } catch (n) {
46
+ c(n, "Failed to update timer blocks");
49
47
  }
50
48
  }
51
49
  };
52
50
  };
53
51
  export {
54
- S as useTimerClone
52
+ O as useTimerClone
55
53
  };
@@ -1,16 +1,15 @@
1
- import { migrateCheckbox as i } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as a } from "./couponBlockMigrator.js";
1
+ import { migrateCheckbox as t } from "./checkboxMigrator.js";
2
+ import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
3
3
  import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
4
- import { migrateProductNameLink as c } from "./productNameLinkMigrator.js";
5
- import { migrateRadioButton as g } from "./radioButtonMigrator.js";
6
- import { migrateRecommendation as n } from "./recommendationMigrator.js";
7
- import { migrateSocialIcons as f } from "./socialIconMigrator.js";
8
- import { migrateTrackIds as p } from "./trackIdMigrator.js";
9
- import { migrateUnsubscribe as k } from "./unsubscribeMigrator.js";
10
- const R = async (o, t = {}, m = {}) => {
11
- let r = o;
12
- return r = i(r), r = g(r), r = await k(r), r = a(r), r = n(r, t), r = e(r), r = c(r), r = f(r), m.linkTrackingIds && (r = p(r, m.trackIdFloor)), r;
4
+ import { migrateProductNameLink as a } from "./productNameLinkMigrator.js";
5
+ import { migrateRadioButton as c } from "./radioButtonMigrator.js";
6
+ import { migrateRecommendation as g } from "./recommendationMigrator.js";
7
+ import { migrateSocialIcons as n } from "./socialIconMigrator.js";
8
+ import { migrateUnsubscribe as p } from "./unsubscribeMigrator.js";
9
+ const x = async (r, o = {}) => {
10
+ let m = r;
11
+ return m = t(m), m = c(m), m = await p(m), m = i(m), m = g(m, o), m = e(m), m = a(m), m = n(m), m;
13
12
  };
14
13
  export {
15
- R as migrate
14
+ x as migrate
16
15
  };
@@ -1,12 +1,12 @@
1
- import { BlockId as f } from "../../../enums/block.js";
2
- import { useOnboardingStore as g } from "../../../stores/onboarding.js";
3
- import { getMigrationBannerHtml as y } from "../../../utils/migrationBannerHtml.js";
4
- import { Block as I, BlockCompositionType as C, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { SETTINGS_ENUMS as d, DefaultConfigValues as m } from "./enums/settingsEnums.js";
6
- import { getDefaultTemplate as b } from "./template.js";
7
- import { getItemsBlockContainer as l, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
- const p = f.Items;
9
- class O extends I {
1
+ import { BlockId as g } from "../../../enums/block.js";
2
+ import { useOnboardingStore as y } from "../../../stores/onboarding.js";
3
+ import { getMigrationBannerHtml as I } from "../../../utils/migrationBannerHtml.js";
4
+ import { Block as C, BlockCompositionType as b, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { SETTINGS_ENUMS as l, DefaultConfigValues as d } from "./enums/settingsEnums.js";
6
+ import { getDefaultTemplate as h } from "./template.js";
7
+ import { getItemsBlockContainer as u, getItemsBlockConfig as f, deriveItemNumber as D, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
+ const p = g.Items;
9
+ class E extends C {
10
10
  getId() {
11
11
  return p;
12
12
  }
@@ -14,7 +14,7 @@ class O extends I {
14
14
  return "items-icon";
15
15
  }
16
16
  getBlockCompositionType() {
17
- return C.CONTAINER;
17
+ return b.CONTAINER;
18
18
  }
19
19
  getName() {
20
20
  return this.api.translate("Items");
@@ -23,20 +23,20 @@ class O extends I {
23
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
24
24
  }
25
25
  getSettingsPanelTitleHtml() {
26
- return y(
26
+ return I(
27
27
  p,
28
28
  this.api.translate("Items"),
29
29
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
30
30
  );
31
31
  }
32
32
  getTemplate() {
33
- return b({
34
- orientation: d.ORIENTATION.VERTICAL,
35
- itemsType: d.ITEMS_TYPE.CART_ITEMS,
33
+ return h({
34
+ orientation: l.ORIENTATION.VERTICAL,
35
+ itemsType: l.ITEMS_TYPE.CART_ITEMS,
36
36
  itemId: "{{Abandoned Cart Item (1) Url}}",
37
- currencySymbol: m.productPriceCurrencySymbolControlValue,
38
- currencyLocation: m.productPriceCurrencyLocationControlValue,
39
- formattedPrice: m.productPriceFormattedControlValue === "1"
37
+ currencySymbol: d.productPriceCurrencySymbolControlValue,
38
+ currencyLocation: d.productPriceCurrencyLocationControlValue,
39
+ formattedPrice: d.productPriceFormattedControlValue === "1"
40
40
  });
41
41
  }
42
42
  allowInnerBlocksDND() {
@@ -45,23 +45,23 @@ class O extends I {
45
45
  canBeSavedAsModule() {
46
46
  return !0;
47
47
  }
48
- onCreated(e) {
49
- const t = this.api.getDocumentModifier(), o = this.api.getDocumentRootCssNode();
50
- o.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(o).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
- const i = l(e);
52
- if (!i)
48
+ onCreated(n) {
49
+ const t = this.api.getDocumentModifier(), a = this.api.getDocumentRootCssNode();
50
+ a.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(a).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
+ const e = u(n);
52
+ if (!e)
53
53
  return;
54
- const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(e);
55
- if (n != null && n.initialized)
56
- if (s)
57
- n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(i).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
54
+ const o = e.getNodeConfig(), r = o && Object.keys(o).length > 0, i = f(n);
55
+ if (i != null && i.initialized)
56
+ if (r)
57
+ i.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...i, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
58
58
  else {
59
- const a = this.api.getDocumentModifier();
60
- a.modifyHtml(i).setNodeConfig(n), this._stampProductTdDomAttributes(i, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
59
+ const s = this.api.getDocumentModifier();
60
+ s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
61
61
  }
62
62
  else {
63
- const a = N();
64
- this.api.getDocumentModifier().modifyHtml(i).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), g().startOnboarding("itemsOnboarding");
63
+ const s = N(), m = this.api.getDocumentModifier();
64
+ m.modifyHtml(e).setNodeConfig(s), this._stampProductTdDomAttributes(e, s, m, !0), m.apply(new c("Initialize Items block with default configuration")), y().startOnboarding("itemsOnboarding");
65
65
  }
66
66
  }
67
67
  /**
@@ -70,18 +70,18 @@ class O extends I {
70
70
  * into nodeConfig, so without this a reused module would reset to defaults.
71
71
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
72
72
  */
73
- onDocumentChanged(e) {
74
- const t = l(e);
73
+ onDocumentChanged(n) {
74
+ const t = u(n);
75
75
  if (!t)
76
76
  return;
77
- const o = t.getNodeConfig();
78
- if (o && Object.keys(o).length > 0)
77
+ const a = t.getNodeConfig();
78
+ if (a && Object.keys(a).length > 0)
79
79
  return;
80
- const r = u(e);
81
- if (!(r != null && r.initialized))
80
+ const o = f(n);
81
+ if (!(o != null && o.initialized))
82
82
  return;
83
- const s = this.api.getDocumentModifier();
84
- s.modifyHtml(t).setNodeConfig(r), this._stampProductTdDomAttributes(t, r, s), s.apply(new c("Recover Items block config from saved module"));
83
+ const r = this.api.getDocumentModifier();
84
+ r.modifyHtml(t).setNodeConfig(o), this._stampProductTdDomAttributes(t, o, r), r.apply(new c("Recover Items block config from saved module"));
85
85
  }
86
86
  /**
87
87
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -91,12 +91,14 @@ class O extends I {
91
91
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
92
92
  * relies on this td-level fallback in pairProductVariables.
93
93
  */
94
- _stampProductTdDomAttributes(e, t, o) {
95
- const i = h(t.itemsSelectValue, t.type);
96
- o.modifyHtml(e).setAttribute("data-type", t.type), o.modifyHtml(e).setAttribute("data-number", i), o.modifyHtml(e).setAttribute("data-nodup", String(t.priceHideDiscount));
94
+ _stampProductTdDomAttributes(n, t, a, e = !1) {
95
+ const o = D(t.itemsSelectValue, t.type), r = (i, s) => {
96
+ e && n.getAttribute(i) || a.modifyHtml(n).setAttribute(i, s);
97
+ };
98
+ r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
97
99
  }
98
100
  }
99
101
  export {
100
102
  p as BLOCK_ID,
101
- O as ItemsBlock
103
+ E as ItemsBlock
102
104
  };