@useinsider/guido 3.20.0 → 3.20.1-beta.5e7765e

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 (33) hide show
  1. package/dist/config/compiler/itemsCompilerRules.js +21 -5
  2. package/dist/config/compiler/utils/itemsCompilerUtils.js +64 -17
  3. package/dist/config/migrator/itemsBlockMigrator.js +112 -108
  4. package/dist/extensions/Blocks/Items/block.js +78 -67
  5. package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
  6. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
  7. package/dist/extensions/Blocks/Recommendation/block.js +51 -44
  8. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +103 -91
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +90 -73
  10. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
  11. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +122 -90
  12. package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
  13. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
  14. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
  15. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +46 -25
  16. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +40 -17
  17. package/dist/extensions/Blocks/Unsubscribe/block.js +82 -83
  18. package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +10 -0
  19. package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
  20. package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
  21. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +2 -0
  22. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -0
  23. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
  24. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +18 -5
  25. package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
  26. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
  27. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
  28. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
  29. package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +0 -2
  30. package/dist/src/utils/liquidProtection.d.ts +3 -0
  31. package/dist/utils/liquidProtection.js +5 -0
  32. package/dist/utils/templatePreparation.js +61 -85
  33. package/package.json +1 -1
@@ -1,123 +1,99 @@
1
- import { useActionsApi as k } from "../composables/useActionsApi.js";
2
- import { useConfig as N } from "../composables/useConfig.js";
3
- import { useHtmlCompiler as U } from "../composables/useHtmlCompiler.js";
4
- import { RRS_CONFIG_VERSION as x, DEFAULT_CURRENCY as m, DEFAULT_NODE_CONFIG as n } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
- import { useRecommendationExtensionStore as w } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
- import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
7
- import { DATA_ATTRIBUTES as A } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
- import { parsePageList as z } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
- import { useDynamicContentStore as O } from "../stores/dynamic-content.js";
10
- import { useEditorStore as _ } from "../stores/editor.js";
11
- import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
12
- import { isPlainObject as B } from "./genericUtil.js";
13
- import { assignTrackingIds as G } from "./linkTrackingIds.js";
14
- function M(l) {
15
- const i = new DOMParser().parseFromString(l, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
16
- return i.forEach((c) => {
17
- const r = c.getAttribute(A.PAGE_LIST);
18
- r && t.push(...z(r));
19
- }), [...new Set(t)];
1
+ import { useActionsApi as D } from "../composables/useActionsApi.js";
2
+ import { useConfig as E } from "../composables/useConfig.js";
3
+ import { useHtmlCompiler as F } from "../composables/useHtmlCompiler.js";
4
+ import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { toBlockUrlConfig as I } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
+ import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
+ import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
+ import { useDynamicContentStore as U } from "../stores/dynamic-content.js";
9
+ import { useEditorStore as L } from "../stores/editor.js";
10
+ import { useUnsubscribeStore as N } from "../stores/unsubscribe.js";
11
+ import { isPlainObject as v } from "./genericUtil.js";
12
+ import { assignTrackingIds as z } from "./linkTrackingIds.js";
13
+ function M(n) {
14
+ const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
15
+ return r.forEach((i) => {
16
+ const t = i.getAttribute(g.PAGE_LIST);
17
+ t && e.push(...R(t));
18
+ }), [...new Set(e)];
20
19
  }
21
- async function I(l) {
22
- const a = new DOMParser().parseFromString(l, "text/html").querySelectorAll(".recommendation-block-v2");
23
- if (a.length === 0)
20
+ async function S(n) {
21
+ const o = new DOMParser().parseFromString(n, "text/html").querySelectorAll(".recommendation-block-v2");
22
+ if (o.length === 0)
24
23
  return;
25
- const i = w();
26
- a.forEach((t) => {
27
- var d, g, f, s, y, S;
28
- const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
29
- if (!Number.isFinite(r))
24
+ const r = b();
25
+ o.forEach((e) => {
26
+ const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
27
+ if (!Number.isFinite(t))
30
28
  return;
31
- const p = t.getAttribute("esd-ext-config");
32
- if (!p)
29
+ const m = e.getAttribute("esd-ext-config");
30
+ if (!m)
33
31
  return;
34
- let e;
32
+ let a;
35
33
  try {
36
- e = JSON.parse(p);
34
+ a = JSON.parse(m);
37
35
  } catch {
38
36
  return;
39
37
  }
40
- if (!B(e))
41
- return;
42
- const C = !!e.strategyId || (e.configVersion ?? 0) >= x, o = {
43
- // Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
44
- // already-saved blocks that never re-run the migrator don't emit a
45
- // strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
46
- strategy: L(e.strategy) || (C ? "" : n.strategy),
47
- strategyId: e.strategyId ?? n.strategyId,
48
- language: e.language ?? n.language,
49
- size: e.size ?? n.size,
50
- // Spread the default arrays so each block gets a fresh reference
51
- // 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,
55
- currencyCode: ((d = e.currency) == null ? void 0 : d.code) ?? m.code,
56
- currencySymbol: ((g = e.currency) == null ? void 0 : g.symbol) ?? m.symbol,
57
- currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? m.alignment,
58
- currencyDecimalCount: ((s = e.currency) == null ? void 0 : s.decimalCount) ?? m.decimalCount,
59
- currencyDecimalSeparator: ((y = e.currency) == null ? void 0 : y.decimalSeparator) ?? m.decimalSeparator,
60
- currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? m.thousandSeparator
61
- };
62
- i.seedBlockUrlConfig(r, o);
38
+ v(a) && r.seedBlockUrlConfig(t, I(a));
63
39
  });
64
40
  try {
65
- await i.fetchRecommendationCreateData();
66
- } catch (t) {
41
+ await r.fetchRecommendationCreateData();
42
+ } catch (e) {
67
43
  console.warn(
68
44
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
69
- t
45
+ e
70
46
  );
71
47
  }
72
48
  }
73
- const re = () => {
74
- const l = O(), u = _(), a = v(), { getCompiledEmail: i, getTemplateData: t, updateHtmlAndCss: c } = k(), { compileHtml: r, compileAmpHtml: p } = U(), { isFeatureEnabled: e } = N();
49
+ const Y = () => {
50
+ const n = U(), c = L(), o = N(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = D(), { compileHtml: t, compileAmpHtml: m } = F(), { isFeatureEnabled: a } = E();
75
51
  return {
76
52
  prepareTemplateDetails: async () => {
77
- let { html: o, css: d, syncModulesIds: g = [] } = await t();
78
- if (e("linkTrackingIds"))
53
+ let { html: s, css: u, syncModulesIds: h = [] } = await e();
54
+ if (a("linkTrackingIds"))
79
55
  try {
80
- const { html: b, changed: R, nextSeq: H } = G(o, u.trackIdSessionFloor);
81
- u.trackIdSessionFloor = H, R && (o = b, await c(b, d));
82
- } catch (b) {
83
- console.error("Tracking-id step failed, saving anyway:", b);
56
+ const { html: d, changed: P, nextSeq: x } = z(s, c.trackIdSessionFloor);
57
+ c.trackIdSessionFloor = x, P && (s = d, await i(d, u));
58
+ } catch (d) {
59
+ console.error("Tracking-id step failed, saving anyway:", d);
84
60
  }
85
- const { html: f, ampHtml: s = "", ampErrors: y = [] } = await i({
61
+ const { html: y, ampHtml: p = "", ampErrors: T = [] } = await r({
86
62
  minimize: !0,
87
63
  resetDataSavedFlag: !1
88
64
  });
89
- a.selectedUnsubscribePages.length && await a.fetchTemplates(), await I(o);
90
- const { compiledHtml: S, stats: h, appliedRules: D } = r(f), E = s && p(s).compiledHtml, P = l.getSelectedDynamicContentList, F = w(), T = M(o);
65
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
66
+ const { compiledHtml: A, stats: l, appliedRules: w } = t(y), C = p && m(p).compiledHtml, H = n.getSelectedDynamicContentList, k = b(), f = M(s);
91
67
  return console.debug("HTML Compilation Stats:", {
92
- originalSize: h.originalSize,
93
- compiledSize: h.compiledSize,
94
- reduction: `${h.reductionPercentage.toFixed(2)}%`,
95
- appliedRules: D,
96
- executionTime: `${h.executionTime.toFixed(2)}ms`
68
+ originalSize: l.originalSize,
69
+ compiledSize: l.compiledSize,
70
+ reduction: `${l.reductionPercentage.toFixed(2)}%`,
71
+ appliedRules: w,
72
+ executionTime: `${l.executionTime.toFixed(2)}ms`
97
73
  }), {
98
- dynamicContentList: P,
99
- compiledHtml: S,
100
- rawHtml: o,
101
- css: d,
102
- ampHtml: E,
103
- ampErrors: y,
104
- modules: g.map(Number),
74
+ dynamicContentList: H,
75
+ compiledHtml: A,
76
+ rawHtml: s,
77
+ css: u,
78
+ ampHtml: C,
79
+ ampErrors: T,
80
+ modules: h.map(Number),
105
81
  recommendation: {
106
- campaignUrls: F.recommendationCampaignUrls,
82
+ campaignUrls: k.recommendationCampaignUrls,
107
83
  configs: {}
108
84
  },
109
85
  unsubscribe: {
110
- status: T.length > 0,
111
- config: T
86
+ status: f.length > 0,
87
+ config: f
112
88
  }
113
89
  };
114
90
  },
115
91
  // Exposed so the back/test validate-only path can seed the reco store the
116
92
  // same way a full save does (required-field findings depend on it).
117
- hydrateRecommendationStore: I
93
+ hydrateRecommendationStore: S
118
94
  };
119
95
  };
120
96
  export {
121
97
  M as getHtmlReferencedUnsubscribePages,
122
- re as useTemplatePreparation
98
+ Y as useTemplatePreparation
123
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.20.0",
3
+ "version": "3.20.1-beta.5e7765e",
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",