@useinsider/guido 3.6.0 → 3.7.0

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 (37) hide show
  1. package/README.md +14 -0
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +75 -72
  4. package/dist/components/organisms/header/EditorActions.vue.js +1 -1
  5. package/dist/components/organisms/header/EditorActions.vue2.js +6 -6
  6. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  7. package/dist/components/organisms/header/LeftSlot.vue2.js +9 -9
  8. package/dist/composables/useActionsApi.js +16 -15
  9. package/dist/composables/useHtmlCompiler.js +40 -22
  10. package/dist/composables/useRecommendation.js +34 -33
  11. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +127 -123
  12. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +51 -47
  13. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +12 -11
  14. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +46 -46
  15. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -9
  16. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +35 -29
  17. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +28 -28
  18. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +8 -8
  19. package/dist/extensions/Blocks/Recommendation/templates/utils.js +56 -49
  20. package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +21 -0
  21. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +17 -17
  22. package/dist/guido.css +1 -1
  23. package/dist/src/components/Guido.vue.d.ts +1 -0
  24. package/dist/src/composables/useHtmlCompiler.d.ts +1 -0
  25. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +7 -0
  26. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  27. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +8 -0
  28. package/dist/src/extensions/Blocks/Recommendation/templates/utils.test.d.ts +1 -0
  29. package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +7 -0
  30. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.test.d.ts +1 -0
  31. package/dist/src/utils/ampErrorFilter.d.ts +2 -0
  32. package/dist/src/utils/ampErrorFilter.test.d.ts +1 -0
  33. package/dist/src/utils/templatePreparation.d.ts +16 -0
  34. package/dist/src/utils/templatePreparation.test.d.ts +1 -0
  35. package/dist/utils/ampErrorFilter.js +8 -0
  36. package/dist/utils/templatePreparation.js +59 -58
  37. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ export declare const AMP_ERROR_WHITELISTED_TOKENS: string[];
2
+ export declare const filterAmpErrors: (ampErrors: string[]) => string[];
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,20 @@
1
1
  import type { SavedTemplateDetails } from '@@/Types/stripo';
2
+ /**
3
+ * Collects every unsubscribe page id referenced by the unsubscribe blocks
4
+ * present in the email HTML, deduped.
5
+ *
6
+ * The email's unsubscribe link is variation-scoped on the backend, which
7
+ * resolves the page to render from the page ids the FE persists for that
8
+ * variation. Those ids must reflect the blocks actually in the email — not a
9
+ * UI-only selection store — otherwise a block that entered the editor by any
10
+ * path other than the page-selection UI (e.g. a dropped saved module) sends an
11
+ * empty association and the backend falls back to the default page.
12
+ *
13
+ * Read from raw editor HTML: the `data-unsubscribe-page-list` attribute lives
14
+ * on the block node there (the save-time sync-module extractor relies on the
15
+ * same source), so it is reliably present regardless of how the block was added.
16
+ */
17
+ export declare function getHtmlReferencedUnsubscribePages(html: string): number[];
2
18
  export declare const useTemplatePreparation: () => {
3
19
  prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
4
20
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { MERGE_TAGS as t } from "../enums/unsubscribe.js";
2
+ const E = Object.values(t), c = (r) => r.filter(
3
+ (e) => !E.some((o) => e.includes(o))
4
+ );
5
+ export {
6
+ E as AMP_ERROR_WHITELISTED_TOKENS,
7
+ c as filterAmpErrors
8
+ };
@@ -1,58 +1,58 @@
1
- import { useActionsApi as C } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { useActionsApi as P } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as w } from "../composables/useHtmlCompiler.js";
3
+ import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as i } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
9
- function E(i, o) {
10
- const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
11
- return t.forEach((r) => {
12
- const a = r.getAttribute(S.PAGE_LIST);
13
- a && c.push(...D(a));
14
- }), o.filter((r) => c.includes(r));
5
+ import { DATA_ATTRIBUTES as h } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as E } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as H } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as U } from "../stores/unsubscribe.js";
9
+ function F(s) {
10
+ const o = new DOMParser().parseFromString(s, "text/html").querySelectorAll(`[${h.PAGE_LIST}]`), t = [];
11
+ return o.forEach((n) => {
12
+ const a = n.getAttribute(h.PAGE_LIST);
13
+ a && t.push(...E(a));
14
+ }), [...new Set(t)];
15
15
  }
16
- async function U(i) {
17
- const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
16
+ async function R(s) {
17
+ const m = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
18
18
  if (m.length === 0)
19
19
  return;
20
- const l = b();
20
+ const o = b();
21
21
  m.forEach((t) => {
22
- var g, f, u, n, y;
23
- const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
24
- if (!Number.isFinite(r))
22
+ var c, p, g, f, r;
23
+ const n = t.getAttribute("recommendation-id"), a = n ? Number(n) : NaN;
24
+ if (!Number.isFinite(a))
25
25
  return;
26
- const a = t.getAttribute("esd-ext-config");
27
- if (!a)
26
+ const d = t.getAttribute("esd-ext-config");
27
+ if (!d)
28
28
  return;
29
29
  let e;
30
30
  try {
31
- e = JSON.parse(a);
31
+ e = JSON.parse(d);
32
32
  } catch {
33
33
  return;
34
34
  }
35
35
  if (!e || typeof e != "object" || Array.isArray(e))
36
36
  return;
37
- const p = {
38
- strategy: e.strategy ?? s.strategy,
39
- language: e.language ?? s.language,
40
- size: e.size ?? s.size,
37
+ const y = {
38
+ strategy: e.strategy ?? i.strategy,
39
+ language: e.language ?? i.language,
40
+ size: e.size ?? i.size,
41
41
  // Spread the default arrays so each block gets a fresh reference
42
42
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...s.productIds],
44
- filters: e.filters ?? [...s.filters],
45
- shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
46
- currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
47
- currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
48
- currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
49
- currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
50
- currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
43
+ productIds: e.productIds ?? [...i.productIds],
44
+ filters: e.filters ?? [...i.filters],
45
+ shuffleProducts: e.shuffleProducts ?? i.shuffleProducts,
46
+ currencyCode: ((c = e.currency) == null ? void 0 : c.code) ?? l.code,
47
+ currencyAlignment: ((p = e.currency) == null ? void 0 : p.alignment) ?? l.alignment,
48
+ currencyDecimalCount: ((g = e.currency) == null ? void 0 : g.decimalCount) ?? l.decimalCount,
49
+ currencyDecimalSeparator: ((f = e.currency) == null ? void 0 : f.decimalSeparator) ?? l.decimalSeparator,
50
+ currencyThousandSeparator: ((r = e.currency) == null ? void 0 : r.thousandSeparator) ?? l.thousandSeparator
51
51
  };
52
- l.seedBlockUrlConfig(r, p);
52
+ o.seedBlockUrlConfig(a, y);
53
53
  });
54
54
  try {
55
- await l.fetchRecommendationCreateData();
55
+ await o.fetchRecommendationCreateData();
56
56
  } catch (t) {
57
57
  console.warn(
58
58
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -60,42 +60,43 @@ async function U(i) {
60
60
  );
61
61
  }
62
62
  }
63
- const _ = () => {
64
- const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
63
+ const v = () => {
64
+ const s = H(), u = U(), { getCompiledEmail: m, getTemplateData: o } = P(), { compileHtml: t, compileAmpHtml: n } = w();
65
65
  return {
66
66
  prepareTemplateDetails: async () => {
67
- const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
67
+ const { html: d, ampHtml: e = "", ampErrors: y = [] } = await m({
68
68
  minimize: !0,
69
69
  resetDataSavedFlag: !1
70
- }), { html: p, css: g, syncModulesIds: f = [] } = await l();
71
- o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
72
- const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
70
+ }), { html: c, css: p, syncModulesIds: g = [] } = await o();
71
+ u.selectedUnsubscribePages.length && await u.fetchTemplates(), await R(c);
72
+ const { compiledHtml: f, stats: r, appliedRules: A } = t(d), C = e && n(e).compiledHtml, T = s.getSelectedDynamicContentList, D = b(), S = F(c);
73
73
  return console.debug("HTML Compilation Stats:", {
74
- originalSize: n.originalSize,
75
- compiledSize: n.compiledSize,
76
- reduction: `${n.reductionPercentage.toFixed(2)}%`,
77
- appliedRules: y,
78
- executionTime: `${n.executionTime.toFixed(2)}ms`
74
+ originalSize: r.originalSize,
75
+ compiledSize: r.compiledSize,
76
+ reduction: `${r.reductionPercentage.toFixed(2)}%`,
77
+ appliedRules: A,
78
+ executionTime: `${r.executionTime.toFixed(2)}ms`
79
79
  }), {
80
- dynamicContentList: h,
81
- compiledHtml: u,
82
- rawHtml: p,
83
- css: g,
84
- ampHtml: a,
85
- ampErrors: e,
86
- modules: f.map(Number),
80
+ dynamicContentList: T,
81
+ compiledHtml: f,
82
+ rawHtml: c,
83
+ css: p,
84
+ ampHtml: C,
85
+ ampErrors: y,
86
+ modules: g.map(Number),
87
87
  recommendation: {
88
- campaignUrls: A.recommendationCampaignUrls,
88
+ campaignUrls: D.recommendationCampaignUrls,
89
89
  configs: {}
90
90
  },
91
91
  unsubscribe: {
92
- status: o.unsubscribePagesStatus,
93
- config: E(u, o.selectedUnsubscribePages)
92
+ status: S.length > 0,
93
+ config: S
94
94
  }
95
95
  };
96
96
  }
97
97
  };
98
98
  };
99
99
  export {
100
- _ as useTemplatePreparation
100
+ F as getHtmlReferencedUnsubscribePages,
101
+ v as useTemplatePreparation
101
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
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",