@useinsider/guido 3.30.0-beta.a94eba0 → 3.30.0-beta.b189780

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,81 +1,75 @@
1
- import { useConfig as M } from "./useConfig.js";
2
- import { useToaster as A } from "./useToaster.js";
3
- import { useTranslations as T } from "./useTranslations.js";
4
- import { ModuleDynamicContentAttribute as U } from "../enums/dynamic-content.js";
5
- import { ToasterTypeOptions as O } from "../enums/toaster.js";
6
- import { itemsBlockDynamicVariables as S } from "../extensions/Blocks/Items/enums/productEnums.js";
1
+ import { useConfig as h } from "./useConfig.js";
2
+ import { useToaster as v } from "./useToaster.js";
3
+ import { useTranslations as M } from "./useTranslations.js";
4
+ import { ModuleDynamicContentAttribute as T } from "../enums/dynamic-content.js";
5
+ import { ToasterTypeOptions as A } from "../enums/toaster.js";
6
+ import { itemsBlockDynamicVariables as O } from "../extensions/Blocks/Items/enums/productEnums.js";
7
7
  import { useDynamicContentStore as E } from "../stores/dynamic-content.js";
8
- import { useEditorStore as f } from "../stores/editor.js";
9
- import { useModuleDynamicContentStore as F } from "../stores/module-dynamic-content.js";
10
- import { buildDynamicContentLookup as L, convertModuleDynamicContent as _ } from "../utils/dynamicContentConverter.js";
11
- import { stripPendingMarker as k } from "../utils/dynamicContentPendingMarker.js";
12
- import { flattenDynamicContentCandidates as q } from "../utils/genericUtil.js";
13
- import { repairItemsCurrencyAttributes as P } from "../utils/itemsCurrencyRepair.js";
14
- import { convertAllUnsubscribeInModuleHtml as R, convertLegacyUnsubscribeInModuleHtml as H } from "../utils/legacyUnsubscribeConversion.js";
15
- import { extractUsedDynamicContent as N } from "../utils/registerUsedDynamicContent.js";
16
- const I = "dynamic-content.unresolved-attributes-on-drop", $ = /^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/;
17
- let C = 0;
18
- const x = (s) => {
19
- C += 1;
20
- const n = `${Date.now().toString(36)}-${C}`;
21
- return { html: s.replace($, `$1 ${U.Pending}="${n}"`), id: n };
22
- }, z = (s, n) => {
8
+ import { useEditorStore as L } from "../stores/editor.js";
9
+ import { useModuleDynamicContentStore as U } from "../stores/module-dynamic-content.js";
10
+ import { buildDynamicContentLookup as _, convertModuleDynamicContent as F } from "../utils/dynamicContentConverter.js";
11
+ import { stripPendingMarker as P } from "../utils/dynamicContentPendingMarker.js";
12
+ import { flattenDynamicContentCandidates as S } from "../utils/genericUtil.js";
13
+ import { repairItemsCurrencyAttributes as N } from "../utils/itemsCurrencyRepair.js";
14
+ import { convertLegacyUnsubscribeInModuleHtml as R } from "../utils/legacyUnsubscribeConversion.js";
15
+ import { extractUsedDynamicContent as k } from "../utils/registerUsedDynamicContent.js";
16
+ const q = "dynamic-content.unresolved-attributes-on-drop", H = /^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/;
17
+ let y = 0;
18
+ const $ = (s) => {
19
+ y += 1;
20
+ const o = `${Date.now().toString(36)}-${y}`;
21
+ return { html: s.replace(H, `$1 ${T.Pending}="${o}"`), id: o };
22
+ }, I = (s, o) => {
23
23
  try {
24
- const i = N(s, n.map(({ text: m, value: l }) => ({ text: m, value: l })));
24
+ const i = k(s, o.map(({ text: a, value: m }) => ({ text: a, value: m })));
25
25
  i.length > 0 && E().registerDynamicContent(i);
26
26
  } catch (i) {
27
27
  console.error("Failed to register module dynamic content:", i);
28
28
  }
29
- }, oe = () => {
30
- const { template: s, isFeatureEnabled: n } = M(), { showToaster: i } = A(), m = T(), l = (o) => {
29
+ }, re = () => {
30
+ const { template: s, isFeatureEnabled: o } = h(), { showToaster: i } = v(), a = M(), m = (r) => {
31
31
  var u, e;
32
- const r = n("liquidSyntax") ? [] : q((u = s.value) == null ? void 0 : u.dynamicContentList), c = L(r);
33
- return c.size === 0 ? { html: o, unresolved: [], ambiguous: [], candidates: r } : {
34
- ..._(
35
- o,
32
+ const t = o("liquidSyntax") ? [] : S((u = s.value) == null ? void 0 : u.dynamicContentList), c = _(t);
33
+ return c.size === 0 ? { html: r, unresolved: [], ambiguous: [], candidates: t } : {
34
+ ...F(
35
+ r,
36
36
  c,
37
- [...((e = s.value) == null ? void 0 : e.customFieldAttributes) ?? [], ...S]
37
+ [...((e = s.value) == null ? void 0 : e.customFieldAttributes) ?? [], ...O]
38
38
  ),
39
- candidates: r
39
+ candidates: t
40
40
  };
41
41
  };
42
- return { handleModuleAdd: (o, r) => {
42
+ return { handleModuleAdd: (r, t) => {
43
43
  var c, u;
44
44
  try {
45
- if ((o == null ? void 0 : o.action) !== "ADD" && (o == null ? void 0 : o.action) !== "COPY")
45
+ if ((r == null ? void 0 : r.action) !== "ADD" && (r == null ? void 0 : r.action) !== "COPY")
46
46
  return;
47
- const e = (c = r == null ? void 0 : r.getTargetNode) == null ? void 0 : c.call(r), a = (u = e == null ? void 0 : e.getOuterHTML) == null ? void 0 : u.call(e);
48
- if (!e || typeof a != "string")
47
+ const e = (c = t == null ? void 0 : t.getTargetNode) == null ? void 0 : c.call(t), l = (u = e == null ? void 0 : e.getOuterHTML) == null ? void 0 : u.call(e);
48
+ if (!e || typeof l != "string")
49
49
  return;
50
- let t = k(P(a, {
51
- convertToPriceFormat: n("itemsPriceFormatting")
52
- })), b = !1, y = !1;
53
- n("blockUnsubscribeLinks") ? { html: t, converted: y } = R(t) : n("legacyUnsubscribeConversion") && ({ html: t, converted: b } = H(t));
54
- const { html: D, unresolved: v, ambiguous: g, candidates: h } = l(t);
50
+ let n = P(N(l, {
51
+ convertToPriceFormat: o("itemsPriceFormatting")
52
+ })), p = !1;
53
+ o("legacyUnsubscribeConversion") && ({ html: n, converted: p } = R(n));
54
+ const { html: f, unresolved: b, ambiguous: g, candidates: C } = m(n);
55
55
  let d = null;
56
- if (t = D, g.length > 0 && ({ html: t, id: d } = x(t)), t !== a && r.modifyHtml(e).replaceWith(t), z(t, h), b)
56
+ if (n = f, g.length > 0 && ({ html: n, id: d } = $(n)), n !== l && t.modifyHtml(e).replaceWith(n), I(n, C), p)
57
57
  try {
58
- f().isLegacyUnsubscribeModalRequested = !0;
59
- } catch (p) {
60
- console.error("Failed to request the legacy unsubscribe modal:", p);
58
+ L().isLegacyUnsubscribeModalRequested = !0;
59
+ } catch (D) {
60
+ console.error("Failed to request the legacy unsubscribe modal:", D);
61
61
  }
62
- if (y)
63
- try {
64
- f().isSfmcUnsubscribeModalRequested = !0;
65
- } catch (p) {
66
- console.error("Failed to request the SFMC unsubscribe modal:", p);
67
- }
68
- d && F().enqueue({ id: d, items: g }), v.length > 0 && i({
69
- type: O.Warning,
70
- message: m(I)
62
+ d && U().enqueue({ id: d, items: g }), b.length > 0 && i({
63
+ type: A.Warning,
64
+ message: a(q)
71
65
  });
72
66
  } catch (e) {
73
67
  console.error("Failed to repair module on add:", e);
74
68
  }
75
- }, convertDynamicContent: l };
69
+ }, convertDynamicContent: m };
76
70
  };
77
71
  export {
78
- I as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
79
- z as registerUsedAttributes,
80
- oe as useModuleRepair
72
+ q as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
73
+ I as registerUsedAttributes,
74
+ re as useModuleRepair
81
75
  };
@@ -1,52 +1,52 @@
1
- import { useActionsApi as z } from "./useActionsApi.js";
2
- import { useAmbiguousDynamicContent as $ } from "./useAmbiguousDynamicContent.js";
3
- import { useBlocksConfig as G } from "./useBlocksConfig.js";
4
- import { useConfig as X } from "./useConfig.js";
1
+ import { useActionsApi as N } from "./useActionsApi.js";
2
+ import { useAmbiguousDynamicContent as j } from "./useAmbiguousDynamicContent.js";
3
+ import { useBlocksConfig as $ } from "./useBlocksConfig.js";
4
+ import { useConfig as G } from "./useConfig.js";
5
5
  import { useCustomInterfaceAppearance as v } from "./useCustomInterfaceAppearance.js";
6
- import { useFullStoryBridge as J } from "./useFullStoryBridge.js";
7
- import { useModuleRepair as K } from "./useModuleRepair.js";
8
- import { useStripoEventHandler as Q } from "./useStripoEventHandler.js";
9
- import { useStripoNotifications as W } from "./useStripoNotifications.js";
10
- import { useToaster as Y } from "./useToaster.js";
11
- import { localePatch as Z } from "../config/i18n/index.js";
6
+ import { useFullStoryBridge as X } from "./useFullStoryBridge.js";
7
+ import { useModuleRepair as J } from "./useModuleRepair.js";
8
+ import { useStripoEventHandler as K } from "./useStripoEventHandler.js";
9
+ import { useStripoNotifications as Q } from "./useStripoNotifications.js";
10
+ import { useToaster as W } from "./useToaster.js";
11
+ import { localePatch as Y } from "../config/i18n/index.js";
12
12
  import { en as B } from "../config/i18n/en/index.js";
13
- import { ToasterTypeOptions as ee } from "../enums/toaster.js";
14
- import { useStripoApi as te } from "../services/stripoApi.js";
15
- import oe from "../static/styles/customEditorStyle.css.js";
13
+ import { ToasterTypeOptions as Z } from "../enums/toaster.js";
14
+ import { useStripoApi as ee } from "../services/stripoApi.js";
15
+ import te from "../static/styles/customEditorStyle.css.js";
16
16
  import { useEditorStore as F } from "../stores/editor.js";
17
- import { buildMergeTagEntries as re, flattenDynamicContentList as ie } from "../utils/genericUtil.js";
18
- import { getStripoRuntimeBaseUrl as ne } from "../utils/stripoRuntime.js";
19
- let d = null, T = !1;
20
- const Be = (o) => {
21
- const { features: u, template: m, isFeatureEnabled: p } = X(), { handleError: f, showToaster: A } = Y(), { getToken: P, getCustomFonts: U, getSyncModulesStatus: R } = te(), { handleEvent: D } = Q(), { handleModuleAdd: V } = K(), { restorePending: L } = $(), { getStripoBlocksConfig: I } = G(), { getStripoNotifications: O } = W(), g = () => d || (d = new Promise((n, s) => {
17
+ import { buildMergeTagEntries as oe, flattenDynamicContentList as re } from "../utils/genericUtil.js";
18
+ import { getStripoRuntimeBaseUrl as ie } from "../utils/stripoRuntime.js";
19
+ let l = null, T = !1;
20
+ const ve = (t) => {
21
+ const { features: u, template: m, isFeatureEnabled: p } = G(), { handleError: f, showToaster: A } = W(), { getToken: P, getCustomFonts: R, getSyncModulesStatus: D } = ee(), { handleEvent: U } = K(), { handleModuleAdd: V } = J(), { restorePending: I } = j(), { getStripoBlocksConfig: L } = $(), { getStripoNotifications: q } = Q(), g = () => l || (l = new Promise((n, a) => {
22
22
  if (document.getElementById("UiEditorScript")) {
23
23
  n();
24
24
  return;
25
25
  }
26
- const i = ne();
26
+ const i = ie();
27
27
  if (!i) {
28
- s(
28
+ a(
29
29
  new Error("guido.stripo.version is not set in package.json. Please configure the Stripo version.")
30
30
  );
31
31
  return;
32
32
  }
33
- const a = `${i}UIEditor.js`, t = document.createElement("script");
34
- t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
33
+ const s = `${i}UIEditor.js`, o = document.createElement("script");
34
+ o.id = "UiEditorScript", o.type = "module", o.src = s, o.onload = () => {
35
35
  T = !0, n();
36
- }, t.onerror = () => {
37
- t.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
38
- }, document.body.appendChild(t);
39
- }), d.catch(() => {
40
- d = null;
41
- }), d), q = async (n, s, i, a = [], t = !1, c = !1) => {
42
- var b, w, k, _;
43
- const e = F(), { html: S, css: y } = n, { baseBlocks: h, extensions: x } = await I();
44
- o.mark("blocks_config_ready");
45
- const E = ((b = u.value) == null ? void 0 : b.displayConditions) ?? !0, H = ((w = u.value) == null ? void 0 : w.modulesDisabled) ?? !1, C = c || (((k = m.value) == null ? void 0 : k.forceRecreate) ?? !1), M = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
46
- o.setTemplate({ html: S, css: y, forceRecreate: C }), v().importCss(), o.mark("init_editor"), await window.UIEditor.initEditor(
36
+ }, o.onerror = () => {
37
+ o.remove(), a(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
38
+ }, document.body.appendChild(o);
39
+ }), l.catch(() => {
40
+ l = null;
41
+ }), l), x = async (n, a, i, s = [], o = !1, c = !1) => {
42
+ var k, w, b, _;
43
+ const e = F(), { html: S, css: y } = n, { baseBlocks: E, extensions: O } = await L();
44
+ t.mark("blocks_config_ready");
45
+ const h = ((k = u.value) == null ? void 0 : k.displayConditions) ?? !0, H = ((w = u.value) == null ? void 0 : w.modulesDisabled) ?? !1, C = c || (((b = m.value) == null ? void 0 : b.forceRecreate) ?? !1), z = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
46
+ t.setTemplate({ html: S, css: y, forceRecreate: C }), v().importCss(), t.mark("init_editor"), await window.UIEditor.initEditor(
47
47
  document.querySelector("#guido-editor"),
48
48
  {
49
- metadata: s,
49
+ metadata: a,
50
50
  html: S,
51
51
  css: y,
52
52
  forceRecreate: C,
@@ -59,12 +59,12 @@ const Be = (o) => {
59
59
  customAppearanceMergetags: !p("liquidSyntax"),
60
60
  customAppearanceMergetagsBorderColor: "#f1f3fe",
61
61
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
62
- customViewStyles: oe,
63
- conditionsEnabled: E,
64
- customConditionsEnabled: E,
62
+ customViewStyles: te,
63
+ conditionsEnabled: h,
64
+ customConditionsEnabled: h,
65
65
  enableXSSSecurity: !0,
66
66
  modulesDisabled: H,
67
- syncModulesEnabled: t,
67
+ syncModulesEnabled: o,
68
68
  messageSettingsEnabled: !0,
69
69
  displayGmailAnnotations: !0,
70
70
  displayHiddenPreheader: !1,
@@ -74,41 +74,41 @@ const Be = (o) => {
74
74
  copyPasteEnabled: !1,
75
75
  selectElementAfterDrop: !0,
76
76
  sameFontSizeForOutlook: !0,
77
- allowedScriptSourceDomains: M,
78
- ...h ? { baseBlocks: h } : {},
77
+ allowedScriptSourceDomains: z,
78
+ ...E ? { baseBlocks: E } : {},
79
79
  editorFonts: {
80
80
  showDefaultStandardFonts: !0,
81
81
  showDefaultNotStandardFonts: !0,
82
- customFonts: a
82
+ customFonts: s
83
83
  },
84
84
  mergeTags: [
85
85
  {
86
- entries: re(
86
+ entries: oe(
87
87
  i.preselectedDynamicContentList,
88
- ie((_ = m.value) == null ? void 0 : _.dynamicContentList),
88
+ re((_ = m.value) == null ? void 0 : _.dynamicContentList),
89
89
  p("liquidSyntax")
90
90
  )
91
91
  }
92
92
  ],
93
93
  async onTokenRefreshRequest(r) {
94
94
  try {
95
- o.mark("token_start");
96
- const l = await P();
97
- o.mark("token_end"), r(l);
98
- } catch (l) {
99
- f(l, "Failed to refresh token");
95
+ t.mark("token_start");
96
+ const d = await P();
97
+ if (t.mark("token_end"), !d) {
98
+ e.isStripoInitialized || (e.loadingStatus = !1, t.markFailed());
99
+ return;
100
+ }
101
+ r(d);
102
+ } catch (d) {
103
+ f(d, "Failed to refresh token");
100
104
  }
101
105
  },
102
106
  onTemplateLoaded() {
103
107
  try {
104
- const { activateCustomViewStyles: r, updateTimerInClonedTemplate: l } = z(), { injectFullStory: N } = J();
105
- v().importCss(), r(), N(), L(), l(), i.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
106
- try {
107
- e.isUnsubscribeConvertedOnLoad ? (e.hasChanges = !0, e.changeSeq += 1, e.isUnsubscribeConvertedOnLoad = !1) : e.hasChanges = !1;
108
- } catch (j) {
109
- console.error("Failed to settle the change state after template load:", j);
110
- }
111
- }, 1e3), o.markReady();
108
+ const { activateCustomViewStyles: r, updateTimerInClonedTemplate: d } = N(), { injectFullStory: M } = X();
109
+ v().importCss(), r(), M(), I(), d(), i.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
110
+ e.hasChanges = !1;
111
+ }, 1e3), t.markReady();
112
112
  } catch (r) {
113
113
  f(r, "Failed to load custom interface appearance");
114
114
  }
@@ -125,9 +125,9 @@ const Be = (o) => {
125
125
  onDataChanged() {
126
126
  e.hasChanges = !0, e.changeSeq += 1;
127
127
  },
128
- onEvent: D,
128
+ onEvent: U,
129
129
  onModuleAdd: V,
130
- notifications: O(),
130
+ notifications: q(),
131
131
  // Stripo deselects the block on any click outside the canvas, so every surface
132
132
  // that belongs to the block's own flow has to be listed here (SD-153273).
133
133
  ignoreClickOutsideSelectors: [
@@ -137,29 +137,29 @@ const Be = (o) => {
137
137
  ".in-modal-v2-wrapper",
138
138
  ".in-toasts-wrapper"
139
139
  ],
140
- extensions: x,
141
- localePatch: Z
140
+ extensions: O,
141
+ localePatch: Y
142
142
  }
143
143
  );
144
144
  };
145
- return { initPlugin: async (n, s, i, a = !1) => {
146
- const t = F();
145
+ return { initPlugin: async (n, a, i, s = !1) => {
146
+ const o = F();
147
147
  try {
148
- o.mark("plugin_start"), o.setScriptPreloaded(T), await g(), o.mark("script_ready");
148
+ t.mark("plugin_start"), t.setScriptPreloaded(T), await g(), t.mark("script_ready");
149
149
  const [c, e] = await Promise.all([
150
- U(),
151
- R()
150
+ R(),
151
+ D()
152
152
  ]);
153
- o.mark("fonts_sync_ready"), t.syncModulesEnabled = e, await q(n, s, i, c, e, a);
153
+ t.mark("fonts_sync_ready"), o.syncModulesEnabled = e, await x(n, a, i, c, e, s);
154
154
  } catch {
155
- t.loadingStatus = !1, A({
156
- type: ee.Error,
155
+ o.loadingStatus = !1, A({
156
+ type: Z.Error,
157
157
  message: B["An error has occurred. Please report the error code to support."],
158
158
  actionButton: {
159
159
  text: B["Reload page"],
160
160
  onClick: () => window.location.reload()
161
161
  }
162
- }), o.markFailed();
162
+ }), t.markFailed();
163
163
  }
164
164
  }, preloadRuntime: () => {
165
165
  g().catch(() => {
@@ -167,5 +167,5 @@ const Be = (o) => {
167
167
  } };
168
168
  };
169
169
  export {
170
- Be as useStripo
170
+ ve as useStripo
171
171
  };
@@ -5,17 +5,16 @@ import { migrateItemsBlock as g } from "./itemsBlockMigrator.js";
5
5
  import { migrateItemsPriceFormat as n } from "./itemsPriceFormatMigrator.js";
6
6
  import { migrateLegacyUnsubscribeText as p } from "./legacyUnsubscribeTextMigrator.js";
7
7
  import { migrateProductNameLink as f } from "./productNameLinkMigrator.js";
8
- import { migrateRadioButton as s } from "./radioButtonMigrator.js";
9
- import { migrateRecommendation as l } from "./recommendationMigrator.js";
10
- import { migrateRecommendationPartnerScope as b } from "./recommendationPartnerMigrator.js";
11
- import { migrateRecommendationTitle as d } from "./recommendationTitleMigrator.js";
12
- import { migrateSfmcUnsubscribeText as k } from "./sfmcUnsubscribeTextMigrator.js";
13
- import { migrateSocialIcons as u } from "./socialIconMigrator.js";
14
- import { migrateUnsubscribe as x } from "./unsubscribeMigrator.js";
15
- const N = async (t, i = {}, o, r) => {
8
+ import { migrateRadioButton as l } from "./radioButtonMigrator.js";
9
+ import { migrateRecommendation as s } from "./recommendationMigrator.js";
10
+ import { migrateRecommendationPartnerScope as d } from "./recommendationPartnerMigrator.js";
11
+ import { migrateRecommendationTitle as b } from "./recommendationTitleMigrator.js";
12
+ import { migrateSocialIcons as k } from "./socialIconMigrator.js";
13
+ import { migrateUnsubscribe as P } from "./unsubscribeMigrator.js";
14
+ const w = async (t, i = {}, o, r) => {
16
15
  let m = t;
17
- return m = e(m), m = s(m), m = k(m), m = p(m), m = await x(m), m = a(m), m = l(m, i), o && (m = b(m, o)), m = d(m), m = g(m), r != null && r.itemsPriceFormatting && (m = n(m)), m = f(m), m = u(m), m = c(m), m;
16
+ return m = e(m), m = l(m), m = p(m), m = await P(m), m = a(m), m = s(m, i), o && (m = d(m, o)), m = b(m), m = g(m), r != null && r.itemsPriceFormatting && (m = n(m)), m = f(m), m = k(m), m = c(m), m;
18
17
  };
19
18
  export {
20
- N as migrate
19
+ w as migrate
21
20
  };