@useinsider/guido 3.18.2-beta.fc246a7 → 3.18.2-beta.ff43aaa

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,30 +1,31 @@
1
1
  import { useActionsApi as k } from "../composables/useActionsApi.js";
2
2
  import { useConfig as U } from "../composables/useConfig.js";
3
3
  import { useHtmlCompiler as x } from "../composables/useHtmlCompiler.js";
4
- import { DEFAULT_CURRENCY as m, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
- import { useRecommendationExtensionStore as T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { DEFAULT_CURRENCY as m, DEFAULT_NODE_CONFIG as n } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
+ import { useRecommendationExtensionStore as A } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
6
  import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
7
- import { DATA_ATTRIBUTES as C } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
+ import { DATA_ATTRIBUTES as T } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
8
  import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
9
  import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
10
10
  import { useEditorStore as z } from "../stores/editor.js";
11
- import { useUnsubscribeStore as _ } from "../stores/unsubscribe.js";
11
+ import { useUnsubscribeStore as O } from "../stores/unsubscribe.js";
12
+ import { isPlainObject as _ } from "./genericUtil.js";
12
13
  import { assignTrackingIds as v } from "./linkTrackingIds.js";
13
- function O(l) {
14
- const c = new DOMParser().parseFromString(l, "text/html").querySelectorAll(`[${C.PAGE_LIST}]`), t = [];
15
- return c.forEach((i) => {
16
- const o = i.getAttribute(C.PAGE_LIST);
14
+ function M(l) {
15
+ const i = new DOMParser().parseFromString(l, "text/html").querySelectorAll(`[${T.PAGE_LIST}]`), t = [];
16
+ return i.forEach((c) => {
17
+ const o = c.getAttribute(T.PAGE_LIST);
17
18
  o && t.push(...R(o));
18
19
  }), [...new Set(t)];
19
20
  }
20
- async function M(l) {
21
- const n = new DOMParser().parseFromString(l, "text/html").querySelectorAll(".recommendation-block-v2");
22
- if (n.length === 0)
21
+ async function q(l) {
22
+ const a = new DOMParser().parseFromString(l, "text/html").querySelectorAll(".recommendation-block-v2");
23
+ if (a.length === 0)
23
24
  return;
24
- const c = T();
25
- n.forEach((t) => {
25
+ const i = A();
26
+ a.forEach((t) => {
26
27
  var r, d, g, f, s, y;
27
- const i = t.getAttribute("recommendation-id"), o = i ? Number(i) : NaN;
28
+ const c = t.getAttribute("recommendation-id"), o = c ? Number(c) : NaN;
28
29
  if (!Number.isFinite(o))
29
30
  return;
30
31
  const p = t.getAttribute("esd-ext-config");
@@ -36,21 +37,21 @@ async function M(l) {
36
37
  } catch {
37
38
  return;
38
39
  }
39
- if (!e || typeof e != "object" || Array.isArray(e))
40
+ if (!_(e))
40
41
  return;
41
42
  const b = {
42
43
  // Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
43
44
  // already-saved blocks that never re-run the migrator don't emit a
44
45
  // strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
45
- strategy: L(e.strategy) || a.strategy,
46
- strategyId: e.strategyId ?? a.strategyId,
47
- language: e.language ?? a.language,
48
- size: e.size ?? a.size,
46
+ strategy: L(e.strategy) || n.strategy,
47
+ strategyId: e.strategyId ?? n.strategyId,
48
+ language: e.language ?? n.language,
49
+ size: e.size ?? n.size,
49
50
  // Spread the default arrays so each block gets a fresh reference
50
51
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
51
- productIds: e.productIds ?? [...a.productIds],
52
- filters: e.filters ?? [...a.filters],
53
- shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
52
+ productIds: e.productIds ?? [...n.productIds],
53
+ filters: e.filters ?? [...n.filters],
54
+ shuffleProducts: e.shuffleProducts ?? n.shuffleProducts,
54
55
  currencyCode: ((r = e.currency) == null ? void 0 : r.code) ?? m.code,
55
56
  currencySymbol: ((d = e.currency) == null ? void 0 : d.symbol) ?? m.symbol,
56
57
  currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? m.alignment,
@@ -58,10 +59,10 @@ async function M(l) {
58
59
  currencyDecimalSeparator: ((s = e.currency) == null ? void 0 : s.decimalSeparator) ?? m.decimalSeparator,
59
60
  currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? m.thousandSeparator
60
61
  };
61
- c.seedBlockUrlConfig(o, b);
62
+ i.seedBlockUrlConfig(o, b);
62
63
  });
63
64
  try {
64
- await c.fetchRecommendationCreateData();
65
+ await i.fetchRecommendationCreateData();
65
66
  } catch (t) {
66
67
  console.warn(
67
68
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -69,24 +70,24 @@ async function M(l) {
69
70
  );
70
71
  }
71
72
  }
72
- const Z = () => {
73
- const l = N(), u = z(), n = _(), { getCompiledEmail: c, getTemplateData: t, updateHtmlAndCss: i } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
73
+ const te = () => {
74
+ const l = N(), u = z(), a = O(), { getCompiledEmail: i, getTemplateData: t, updateHtmlAndCss: c } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
74
75
  return {
75
76
  prepareTemplateDetails: async () => {
76
77
  let { html: r, css: d, syncModulesIds: g = [] } = await t();
77
78
  if (e("linkTrackingIds"))
78
79
  try {
79
80
  const { html: h, changed: F, nextSeq: H } = v(r, u.trackIdSessionFloor);
80
- u.trackIdSessionFloor = H, F && (r = h, await i(h, d));
81
+ u.trackIdSessionFloor = H, F && (r = h, await c(h, d));
81
82
  } catch (h) {
82
83
  console.error("Tracking-id step failed, saving anyway:", h);
83
84
  }
84
- const { html: f, ampHtml: s = "", ampErrors: y = [] } = await c({
85
+ const { html: f, ampHtml: s = "", ampErrors: y = [] } = await i({
85
86
  minimize: !0,
86
87
  resetDataSavedFlag: !1
87
88
  });
88
- n.selectedUnsubscribePages.length && await n.fetchTemplates(), await M(r);
89
- const { compiledHtml: I, stats: S, appliedRules: w } = o(f), D = s && p(s).compiledHtml, E = l.getSelectedDynamicContentList, P = T(), A = O(r);
89
+ a.selectedUnsubscribePages.length && await a.fetchTemplates(), await q(r);
90
+ const { compiledHtml: I, stats: S, appliedRules: w } = o(f), D = s && p(s).compiledHtml, P = l.getSelectedDynamicContentList, E = A(), C = M(r);
90
91
  return console.debug("HTML Compilation Stats:", {
91
92
  originalSize: S.originalSize,
92
93
  compiledSize: S.compiledSize,
@@ -94,7 +95,7 @@ const Z = () => {
94
95
  appliedRules: w,
95
96
  executionTime: `${S.executionTime.toFixed(2)}ms`
96
97
  }), {
97
- dynamicContentList: E,
98
+ dynamicContentList: P,
98
99
  compiledHtml: I,
99
100
  rawHtml: r,
100
101
  css: d,
@@ -102,18 +103,18 @@ const Z = () => {
102
103
  ampErrors: y,
103
104
  modules: g.map(Number),
104
105
  recommendation: {
105
- campaignUrls: P.recommendationCampaignUrls,
106
+ campaignUrls: E.recommendationCampaignUrls,
106
107
  configs: {}
107
108
  },
108
109
  unsubscribe: {
109
- status: A.length > 0,
110
- config: A
110
+ status: C.length > 0,
111
+ config: C
111
112
  }
112
113
  };
113
114
  }
114
115
  };
115
116
  };
116
117
  export {
117
- O as getHtmlReferencedUnsubscribePages,
118
- Z as useTemplatePreparation
118
+ M as getHtmlReferencedUnsubscribePages,
119
+ te as useTemplatePreparation
119
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.18.2-beta.fc246a7",
3
+ "version": "3.18.2-beta.ff43aaa",
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",
@@ -1,20 +0,0 @@
1
- import { SETTINGS_ENUMS as r } from "../enums/settingsEnums.js";
2
- const I = "130px", L = "100%", R = (e) => e === r.ORIENTATION.HORIZONTAL ? I : L, n = {
3
- VERTICAL: "es-p5b es-p5t",
4
- HORIZONTAL: "es-p5l es-p5r"
5
- }, o = "data-items-cell-pad", d = (e) => `${o}="${e ? "v" : "h"}"`, t = (e) => e ? ` ${n.VERTICAL}` : ` ${n.HORIZONTAL}`, E = (e, A) => {
6
- if (!e.includes(o))
7
- return e;
8
- const T = A ? n.HORIZONTAL : n.VERTICAL, s = A ? n.VERTICAL : n.HORIZONTAL, c = A ? "v" : "h";
9
- return e.includes(T) ? e.replace(T, s).replace(new RegExp(`${o}="[hv]"`), `${o}="${c}"`) : e;
10
- };
11
- export {
12
- n as BLOCK_CELL_PADDING,
13
- o as BLOCK_CELL_PAD_ATTR,
14
- I as NAME_HORIZONTAL_MAX_WIDTH,
15
- L as NAME_VERTICAL_MAX_WIDTH,
16
- d as blockCellPadMarker,
17
- t as blockCellPaddingFor,
18
- R as nameMaxWidthFor,
19
- E as reorientBlockCellPadding
20
- };
@@ -1,44 +0,0 @@
1
- /**
2
- * Single owner for the Items card orientation-dependent layout contract (SD-149368).
3
- *
4
- * Two things depend on a card's orientation and are written across several layers:
5
- *
6
- * 1. Name column width — a horizontal card lays the name in a narrow side-by-side
7
- * column, so it is capped; a vertical card gives it a full-width row.
8
- * 2. Block-cell padding — the collapsible price / original-price block-cell carries its
9
- * own inter-cell spacing (horizontal cards pad left/right, vertical cards pad
10
- * top/bottom) so a hidden element removes its own spacing instead of leaving a gap.
11
- *
12
- * Every layer that writes these — template render, layouts/horizontal.html,
13
- * NameTrimmingControl (trimming toggle) and settingsControl (orientation change) — MUST
14
- * derive them here, or a migrated / re-toggled card silently drifts out of sync with
15
- * freshly generated markup (convention B1: cross-layer literals live in one module).
16
- */
17
- export declare const NAME_HORIZONTAL_MAX_WIDTH = "130px";
18
- export declare const NAME_VERTICAL_MAX_WIDTH = "100%";
19
- /** Name max-width for a card orientation. Non-horizontal (incl. undefined) → full width. */
20
- export declare const nameMaxWidthFor: (orientation?: string) => string;
21
- /** Orientation-dependent inter-cell padding classes for a collapsible block-cell. */
22
- export declare const BLOCK_CELL_PADDING: {
23
- readonly VERTICAL: "es-p5b es-p5t";
24
- readonly HORIZONTAL: "es-p5l es-p5r";
25
- };
26
- /**
27
- * Attribute the block-cell carries to mark its LAYOUT-owned padding orientation ('v'|'h').
28
- * The orientation toggle keys off this marker so it only ever rewrites the padding the
29
- * layout itself baked — a user's own es-p* padding classes are never matched or clobbered
30
- * (SD-149368 F1), and a cell without the marker is left untouched rather than mis-swapped.
31
- */
32
- export declare const BLOCK_CELL_PAD_ATTR = "data-items-cell-pad";
33
- /** Marker attribute (`data-items-cell-pad="v|h"`) for a block-cell in the given orientation. */
34
- export declare const blockCellPadMarker: (isVertical: boolean) => string;
35
- /** Padding classes (leading space included) for a block-cell in the given orientation. */
36
- export declare const blockCellPaddingFor: (isVertical: boolean) => string;
37
- /**
38
- * Rewrites a block-cell's LAYOUT-owned padding classes to the target orientation, keyed off
39
- * the BLOCK_CELL_PAD_ATTR marker. The orientation-change rebuild re-injects existing cells
40
- * via getOuterHTML(), which still carry the previous orientation's padding — swap only the
41
- * layout pair (and flip the marker) so price/original-price cells stay padded after a toggle
42
- * (SD-149368 F3), while a user's own padding and any unmarked cell are left alone (F1).
43
- */
44
- export declare const reorientBlockCellPadding: (html: string, toVertical: boolean) => string;