@useinsider/guido 3.27.1-beta.ee576ab → 3.28.0-beta.fdbde3f

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.
Files changed (29) hide show
  1. package/README.md +10 -5
  2. package/dist/components/Guido.vue.js +7 -7
  3. package/dist/components/Guido.vue2.js +86 -83
  4. package/dist/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue.js +24 -0
  5. package/dist/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue2.js +59 -0
  6. package/dist/composables/useAmbiguousDynamicContent.js +72 -0
  7. package/dist/composables/useHtmlCompiler.js +16 -15
  8. package/dist/composables/useModuleRepair.js +63 -32
  9. package/dist/composables/useStripo.js +44 -43
  10. package/dist/config/compiler/htmlCompilerRules.js +16 -6
  11. package/dist/config/migrator/itemsBlockMigrator.js +220 -178
  12. package/dist/enums/dynamic-content.js +4 -0
  13. package/dist/guido.css +1 -1
  14. package/dist/package.json.js +4 -4
  15. package/dist/src/@types/generic.d.ts +7 -0
  16. package/dist/src/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue.d.ts +2 -0
  17. package/dist/src/composables/useAmbiguousDynamicContent.d.ts +7 -0
  18. package/dist/src/composables/useModuleRepair.d.ts +6 -0
  19. package/dist/src/enums/dynamic-content.d.ts +3 -0
  20. package/dist/src/stores/module-dynamic-content.d.ts +30 -0
  21. package/dist/src/utils/dynamicContentConverter.d.ts +20 -18
  22. package/dist/src/utils/dynamicContentPendingMarker.d.ts +2 -0
  23. package/dist/src/utils/genericUtil.d.ts +4 -8
  24. package/dist/stores/module-dynamic-content.js +20 -0
  25. package/dist/utils/dynamicContentConverter.js +41 -27
  26. package/dist/utils/dynamicContentPendingMarker.js +6 -0
  27. package/dist/utils/genericUtil.js +39 -39
  28. package/dist/utils/templatePreparation.js +9 -9
  29. package/package.json +1 -1
@@ -1,44 +1,75 @@
1
- import { useConfig as f } from "./useConfig.js";
2
- import { useToaster as d } from "./useToaster.js";
3
- import { useTranslations as C } from "./useTranslations.js";
4
- import { ToasterTypeOptions as T } from "../enums/toaster.js";
5
- import { useEditorStore as h } from "../stores/editor.js";
6
- import { buildDynamicContentLookup as v, convertModuleDynamicContent as D } from "../utils/dynamicContentConverter.js";
7
- import { flattenDynamicContentList as L } from "../utils/genericUtil.js";
8
- import { repairItemsCurrencyAttributes as M } from "../utils/itemsCurrencyRepair.js";
9
- import { convertLegacyUnsubscribeInModuleHtml as O } from "../utils/legacyUnsubscribeConversion.js";
10
- const E = "dynamic-content.unresolved-attributes-on-drop", S = () => {
11
- const { template: p, isFeatureEnabled: n } = f(), { showToaster: y } = d(), b = C();
12
- return { handleModuleAdd: (t, r) => {
13
- var c, i, l;
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
+ import { useDynamicContentStore as E } from "../stores/dynamic-content.js";
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
+ try {
24
+ const i = k(s, o.map(({ text: a, value: m }) => ({ text: a, value: m })));
25
+ i.length > 0 && E().registerDynamicContent(i);
26
+ } catch (i) {
27
+ console.error("Failed to register module dynamic content:", i);
28
+ }
29
+ }, re = () => {
30
+ const { template: s, isFeatureEnabled: o } = h(), { showToaster: i } = v(), a = M(), m = (r) => {
31
+ var u, e;
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
+ c,
37
+ [...((e = s.value) == null ? void 0 : e.customFieldAttributes) ?? [], ...O]
38
+ ),
39
+ candidates: t
40
+ };
41
+ };
42
+ return { handleModuleAdd: (r, t) => {
43
+ var c, u;
14
44
  try {
15
- if ((t == null ? void 0 : t.action) !== "ADD" && (t == null ? void 0 : t.action) !== "COPY")
45
+ if ((r == null ? void 0 : r.action) !== "ADD" && (r == null ? void 0 : r.action) !== "COPY")
16
46
  return;
17
- const e = (c = r == null ? void 0 : r.getTargetNode) == null ? void 0 : c.call(r), s = (i = e == null ? void 0 : e.getOuterHTML) == null ? void 0 : i.call(e);
18
- if (!e || typeof s != "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")
19
49
  return;
20
- let o = M(s, {
21
- convertToPriceFormat: n("itemsPriceFormatting")
22
- }), u = !1;
23
- n("legacyUnsubscribeConversion") && ({ html: o, converted: u } = O(o));
24
- const m = v(L((l = p.value) == null ? void 0 : l.dynamicContentList));
25
- let a = [];
26
- if (m.size > 0 && ({ html: o, unresolved: a } = D(o, m, n("liquidSyntax"))), o !== s && r.modifyHtml(e).replaceWith(o), u)
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
+ let d = null;
56
+ if (n = f, g.length > 0 && ({ html: n, id: d } = $(n)), n !== l && t.modifyHtml(e).replaceWith(n), I(n, C), p)
27
57
  try {
28
- h().isLegacyUnsubscribeModalRequested = !0;
29
- } catch (g) {
30
- console.error("Failed to request the legacy unsubscribe modal:", g);
58
+ L().isLegacyUnsubscribeModalRequested = !0;
59
+ } catch (D) {
60
+ console.error("Failed to request the legacy unsubscribe modal:", D);
31
61
  }
32
- a.length > 0 && y({
33
- type: T.Warning,
34
- message: b(E)
62
+ d && U().enqueue({ id: d, items: g }), b.length > 0 && i({
63
+ type: A.Warning,
64
+ message: a(q)
35
65
  });
36
66
  } catch (e) {
37
67
  console.error("Failed to repair module on add:", e);
38
68
  }
39
- } };
69
+ }, convertDynamicContent: m };
40
70
  };
41
71
  export {
42
- E as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
43
- S as useModuleRepair
72
+ q as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
73
+ I as registerUsedAttributes,
74
+ re as useModuleRepair
44
75
  };
@@ -1,51 +1,52 @@
1
- import { useActionsApi as N } from "./useActionsApi.js";
2
- import { useBlocksConfig as j } from "./useBlocksConfig.js";
3
- import { useConfig as z } from "./useConfig.js";
1
+ import { useActionsApi as j } from "./useActionsApi.js";
2
+ import { useAmbiguousDynamicContent as z } from "./useAmbiguousDynamicContent.js";
3
+ import { useBlocksConfig as $ } from "./useBlocksConfig.js";
4
+ import { useConfig as G } from "./useConfig.js";
4
5
  import { useCustomInterfaceAppearance as v } from "./useCustomInterfaceAppearance.js";
5
- import { useFullStoryBridge as $ } from "./useFullStoryBridge.js";
6
- import { useModuleRepair as G } from "./useModuleRepair.js";
7
- import { useStripoEventHandler as X } from "./useStripoEventHandler.js";
8
- import { useStripoNotifications as J } from "./useStripoNotifications.js";
9
- import { useToaster as K } from "./useToaster.js";
10
- import { localePatch as Q } 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";
11
12
  import { en as B } from "../config/i18n/en/index.js";
12
- import { ToasterTypeOptions as W } from "../enums/toaster.js";
13
- import { useStripoApi as Y } from "../services/stripoApi.js";
14
- import Z 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";
15
16
  import { useEditorStore as T } from "../stores/editor.js";
16
- import { buildMergeTagEntries as ee, flattenDynamicContentList as te } from "../utils/genericUtil.js";
17
- import { getStripoRuntimeBaseUrl as oe } from "../utils/stripoRuntime.js";
17
+ import { buildMergeTagEntries as oe, flattenDynamicContentList as re } from "../utils/genericUtil.js";
18
+ import { getStripoRuntimeBaseUrl as ie } from "../utils/stripoRuntime.js";
18
19
  let d = null, F = !1;
19
- const ke = (t) => {
20
- const { features: u, template: m, isFeatureEnabled: p } = z(), { handleError: f, showToaster: A } = K(), { getToken: P, getCustomFonts: R, getSyncModulesStatus: U } = Y(), { handleEvent: V } = X(), { handleModuleAdd: D } = G(), { getStripoBlocksConfig: I } = j(), { getStripoNotifications: L } = J(), g = () => d || (d = new Promise((n, a) => {
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 } = z(), { getStripoBlocksConfig: L } = $(), { getStripoNotifications: q } = Q(), g = () => d || (d = new Promise((n, s) => {
21
22
  if (document.getElementById("UiEditorScript")) {
22
23
  n();
23
24
  return;
24
25
  }
25
- const i = oe();
26
+ const i = ie();
26
27
  if (!i) {
27
- a(
28
+ s(
28
29
  new Error("guido.stripo.version is not set in package.json. Please configure the Stripo version.")
29
30
  );
30
31
  return;
31
32
  }
32
- const s = `${i}UIEditor.js`, e = document.createElement("script");
33
- e.id = "UiEditorScript", e.type = "module", e.src = s, e.onload = () => {
33
+ const a = `${i}UIEditor.js`, e = document.createElement("script");
34
+ e.id = "UiEditorScript", e.type = "module", e.src = a, e.onload = () => {
34
35
  F = !0, n();
35
36
  }, e.onerror = () => {
36
- e.remove(), a(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
37
+ e.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
37
38
  }, document.body.appendChild(e);
38
39
  }), d.catch(() => {
39
40
  d = null;
40
- }), d), q = async (n, a, i, s = [], e = !1, c = !1) => {
41
+ }), d), x = async (n, s, i, a = [], e = !1, c = !1) => {
41
42
  var w, k, b, _;
42
- const o = T(), { html: S, css: y } = n, { baseBlocks: E, extensions: x } = await I();
43
+ const o = T(), { html: S, css: y } = n, { baseBlocks: E, extensions: O } = await L();
43
44
  t.mark("blocks_config_ready");
44
- const h = ((w = u.value) == null ? void 0 : w.displayConditions) ?? !0, O = ((k = u.value) == null ? void 0 : k.modulesDisabled) ?? !1, C = c || (((b = m.value) == null ? void 0 : b.forceRecreate) ?? !1), H = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
45
+ const h = ((w = u.value) == null ? void 0 : w.displayConditions) ?? !0, H = ((k = u.value) == null ? void 0 : k.modulesDisabled) ?? !1, C = c || (((b = m.value) == null ? void 0 : b.forceRecreate) ?? !1), M = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
45
46
  t.setTemplate({ html: S, css: y, forceRecreate: C }), v().importCss(), t.mark("init_editor"), await window.UIEditor.initEditor(
46
47
  document.querySelector("#guido-editor"),
47
48
  {
48
- metadata: a,
49
+ metadata: s,
49
50
  html: S,
50
51
  css: y,
51
52
  forceRecreate: C,
@@ -58,11 +59,11 @@ const ke = (t) => {
58
59
  customAppearanceMergetags: !p("liquidSyntax"),
59
60
  customAppearanceMergetagsBorderColor: "#f1f3fe",
60
61
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
61
- customViewStyles: Z,
62
+ customViewStyles: te,
62
63
  conditionsEnabled: h,
63
64
  customConditionsEnabled: h,
64
65
  enableXSSSecurity: !0,
65
- modulesDisabled: O,
66
+ modulesDisabled: H,
66
67
  syncModulesEnabled: e,
67
68
  messageSettingsEnabled: !0,
68
69
  displayGmailAnnotations: !0,
@@ -73,18 +74,18 @@ const ke = (t) => {
73
74
  copyPasteEnabled: !1,
74
75
  selectElementAfterDrop: !0,
75
76
  sameFontSizeForOutlook: !0,
76
- allowedScriptSourceDomains: H,
77
+ allowedScriptSourceDomains: M,
77
78
  ...E ? { baseBlocks: E } : {},
78
79
  editorFonts: {
79
80
  showDefaultStandardFonts: !0,
80
81
  showDefaultNotStandardFonts: !0,
81
- customFonts: s
82
+ customFonts: a
82
83
  },
83
84
  mergeTags: [
84
85
  {
85
- entries: ee(
86
+ entries: oe(
86
87
  i.preselectedDynamicContentList,
87
- te((_ = m.value) == null ? void 0 : _.dynamicContentList),
88
+ re((_ = m.value) == null ? void 0 : _.dynamicContentList),
88
89
  p("liquidSyntax")
89
90
  )
90
91
  }
@@ -100,8 +101,8 @@ const ke = (t) => {
100
101
  },
101
102
  onTemplateLoaded() {
102
103
  try {
103
- const { activateCustomViewStyles: r, updateTimerInClonedTemplate: l } = N(), { injectFullStory: M } = $();
104
- v().importCss(), r(), M(), l(), i.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
104
+ const { activateCustomViewStyles: r, updateTimerInClonedTemplate: l } = j(), { injectFullStory: N } = X();
105
+ v().importCss(), r(), N(), I(), l(), i.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
105
106
  o.hasChanges = !1;
106
107
  }, 1e3), t.markReady();
107
108
  } catch (r) {
@@ -120,9 +121,9 @@ const ke = (t) => {
120
121
  onDataChanged() {
121
122
  o.hasChanges = !0, o.changeSeq += 1;
122
123
  },
123
- onEvent: V,
124
- onModuleAdd: D,
125
- notifications: L(),
124
+ onEvent: U,
125
+ onModuleAdd: V,
126
+ notifications: q(),
126
127
  // Stripo deselects the block on any click outside the canvas, so every surface
127
128
  // that belongs to the block's own flow has to be listed here (SD-153273).
128
129
  ignoreClickOutsideSelectors: [
@@ -132,23 +133,23 @@ const ke = (t) => {
132
133
  ".in-modal-v2-wrapper",
133
134
  ".in-toasts-wrapper"
134
135
  ],
135
- extensions: x,
136
- localePatch: Q
136
+ extensions: O,
137
+ localePatch: Y
137
138
  }
138
139
  );
139
140
  };
140
- return { initPlugin: async (n, a, i, s = !1) => {
141
+ return { initPlugin: async (n, s, i, a = !1) => {
141
142
  const e = T();
142
143
  try {
143
144
  t.mark("plugin_start"), t.setScriptPreloaded(F), await g(), t.mark("script_ready");
144
145
  const [c, o] = await Promise.all([
145
146
  R(),
146
- U()
147
+ D()
147
148
  ]);
148
- t.mark("fonts_sync_ready"), e.syncModulesEnabled = o, await q(n, a, i, c, o, s);
149
+ t.mark("fonts_sync_ready"), e.syncModulesEnabled = o, await x(n, s, i, c, o, a);
149
150
  } catch {
150
151
  e.loadingStatus = !1, A({
151
- type: W.Error,
152
+ type: Z.Error,
152
153
  message: B["An error has occurred. Please report the error code to support."],
153
154
  actionButton: {
154
155
  text: B["Reload page"],
@@ -162,5 +163,5 @@ const ke = (t) => {
162
163
  } };
163
164
  };
164
165
  export {
165
- ke as useStripo
166
+ ve as useStripo
166
167
  };
@@ -1,6 +1,7 @@
1
- import { stripFontTags as c } from "../../utils/stripFontTags.js";
2
- import { trimHrefWhitespace as l } from "../../utils/trimHrefWhitespace.js";
3
- const f = [
1
+ import { PENDING_MARKER_PATTERN as c } from "../../utils/dynamicContentPendingMarker.js";
2
+ import { stripFontTags as l } from "../../utils/stripFontTags.js";
3
+ import { trimHrefWhitespace as d } from "../../utils/trimHrefWhitespace.js";
4
+ const y = [
4
5
  {
5
6
  id: "fix-url-encoding-start",
6
7
  description: "Replace {%22 with %7B%22 to fix URL encoding",
@@ -59,14 +60,14 @@ const f = [
59
60
  id: "strip-font-tags",
60
61
  description: 'Unwrap browser-translate-injected <font dir="auto"> tags, keeping inner content; other <font> elements are left intact.',
61
62
  type: "custom",
62
- processor: (e) => c(e),
63
+ processor: (e) => l(e),
63
64
  priority: 15
64
65
  },
65
66
  {
66
67
  id: "trim-href-whitespace",
67
68
  description: "Trim leading/trailing whitespace and &nbsp; from every href value",
68
69
  type: "custom",
69
- processor: (e) => l(e),
70
+ processor: (e) => d(e),
70
71
  priority: 16
71
72
  },
72
73
  {
@@ -183,6 +184,15 @@ const f = [
183
184
  flags: "g",
184
185
  priority: 45
185
186
  },
187
+ {
188
+ id: "remove-dc-pending-marker",
189
+ description: "Strip the editor-only pending dynamic-content choice marker from compiled output",
190
+ type: "regex",
191
+ pattern: c,
192
+ replacement: "",
193
+ flags: "g",
194
+ priority: 46
195
+ },
186
196
  {
187
197
  id: "remove-script-tags",
188
198
  // SD-145051: parity with HB HtmlCleaner.removeUnsafeHtmlTags — strip <script> from
@@ -208,5 +218,5 @@ const f = [
208
218
  }
209
219
  ];
210
220
  export {
211
- f as defaultHtmlCompilerRules
221
+ y as defaultHtmlCompilerRules
212
222
  };