@useinsider/guido 3.18.1-beta.4ee2462 → 3.18.1-beta.4fbee43

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.
@@ -23,14 +23,14 @@ import { PricePlacementControl as E } from "./pricePlacement.js";
23
23
  import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
24
24
  import { ProductCountControl as k } from "./productCount.js";
25
25
  import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
26
- import { ProductLayoutControl as D } from "./productLayout.js";
26
+ import { ProductLayoutControl as F } from "./productLayout.js";
27
27
  import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
28
- import { ShuffleControl as F } from "./shuffle.js";
28
+ import { ShuffleControl as D } from "./shuffle.js";
29
29
  import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
30
30
  import { StrategyControl as w } from "./strategy.js";
31
31
  import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
32
32
  import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
33
- import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
33
+ import { adjustProductsToSize as kt, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
34
34
  import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
35
35
  const $ = "ui-elements-recommendation-block";
36
36
  class at extends N {
@@ -39,8 +39,6 @@ class at extends N {
39
39
  n(this, "store", R());
40
40
  n(this, "storeUnsubscription", () => {
41
41
  });
42
- // blockId -> fingerprint of the node config as it looked at the last sync.
43
- n(this, "syncedConfigs", /* @__PURE__ */ new Map());
44
42
  // A config change waiting to reach the node config. Deferred so it can ride the
45
43
  // re-render's single apply() — one user action must cost one undo press.
46
44
  n(this, "pendingNodeConfigWrite", null);
@@ -120,7 +118,7 @@ class at extends N {
120
118
  return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
121
119
  var o;
122
120
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
123
- }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new D(), this.filtersControl = new S(), this.shuffleControl = new F(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
121
+ }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
124
122
  e && (e.api = this.api);
125
123
  }), `
126
124
  <div class="recommendation-controls-container">
@@ -200,11 +198,19 @@ class at extends N {
200
198
  * fingerprint diff on this hook is the only way to notice (SD-149105).
201
199
  * An unchanged fingerprint means the move came from us, so runtime store
202
200
  * edits are never clobbered (SD-141049).
201
+ *
202
+ * The fingerprint is kept on the block's own store state so deleting the
203
+ * block drops it with the state it describes. A control-owned memo outlived
204
+ * that state and made a re-dropped saved module keep the defaults its wiped
205
+ * state was rebuilt with (SD-150347).
203
206
  */
204
207
  _syncNodeConfigIfChanged(t) {
205
208
  this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
206
- const e = JSON.stringify(c.getConfig(this.currentNode)), o = this.syncedConfigs.get(t);
207
- this.syncedConfigs.set(t, e), o !== e && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
209
+ const e = this.store.blockStates[t];
210
+ if (!e)
211
+ return;
212
+ const o = JSON.stringify(c.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
213
+ e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
208
214
  }
209
215
  _capturePendingNodeConfigWrite() {
210
216
  const t = this.store.currentRecommendationId;
@@ -430,16 +436,16 @@ export {
430
436
  Tt as PRODUCT_LAYOUT_CONTROL_ID,
431
437
  E as PricePlacementControl,
432
438
  k as ProductCountControl,
433
- D as ProductLayoutControl,
439
+ F as ProductLayoutControl,
434
440
  at as RecommendationBlockControl,
435
441
  St as SHUFFLE_CONTROL_ID,
436
442
  Lt as STRATEGY_CONTROL_ID,
437
- F as ShuffleControl,
443
+ D as ShuffleControl,
438
444
  w as StrategyControl,
439
445
  kt as adjustProductsToSize,
440
- Dt as formatProductPrice,
446
+ Ft as formatProductPrice,
441
447
  v as getBlockElement,
442
- Ft as getCardComposition,
448
+ Dt as getCardComposition,
443
449
  wt as getCurrentLayout,
444
450
  At as getMainContainerTbody,
445
451
  x as isPartnerManagedBlock,
@@ -1,7 +1,7 @@
1
1
  import { getRecommendationFeedSourceMaps as b, getOperatorOptions as G, PriceAttributes as v } from "../../../../enums/extensions/recommendationBlock.js";
2
2
  import { useRecommendationApi as D } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as P } from "../../../../stores/config.js";
4
- import { defineStore as F } from "pinia";
3
+ import { useConfigStore as F } from "../../../../stores/config.js";
4
+ import { defineStore as P } from "pinia";
5
5
  import "../constants/selectors.js";
6
6
  import { DEFAULT_MOBILE_CARDS_IN_ROW as _, DEFAULT_CARDS_IN_ROW as U } from "../constants/layout.js";
7
7
  import { DEFAULT_NODE_CONFIG as N, EXCLUDED_ALGORITHM_IDS as L } from "../constants/defaultConfig.js";
@@ -12,7 +12,7 @@ import { sanitizeProductIds as A } from "../utils/productIds.js";
12
12
  import { isFilterValid as B } from "../validation/filterSchema.js";
13
13
  import { isConfigValid as M } from "../validation/requiredFields.js";
14
14
  const u = D();
15
- let f = null, h = null, g = null, S = null;
15
+ let f = null, g = null, h = null, S = null;
16
16
  const p = /* @__PURE__ */ new Map();
17
17
  function w() {
18
18
  return {
@@ -56,7 +56,8 @@ function C() {
56
56
  removeStrategyModalStatus: !1,
57
57
  filterGroup: 1,
58
58
  isInitialized: !1,
59
- filterSnapshot: null
59
+ filterSnapshot: null,
60
+ syncedConfigFingerprint: null
60
61
  };
61
62
  }
62
63
  const z = () => ({
@@ -71,7 +72,7 @@ const z = () => ({
71
72
  blockStates: {},
72
73
  currentRecommendationId: null,
73
74
  configVersion: 0
74
- }), Y = F("guidoRecommendationExtension", {
75
+ }), Y = P("guidoRecommendationExtension", {
75
76
  state: () => z(),
76
77
  getters: {
77
78
  // ====================================================================
@@ -241,7 +242,7 @@ const z = () => ({
241
242
  const r = (o, c) => o === "." || o === "," || o === " " ? o : c, n = {
242
243
  name: e.currencyCode,
243
244
  value: e.currencyCode,
244
- symbol: e.currencyCode,
245
+ symbol: e.currencySymbol,
245
246
  alignment: e.currencyAlignment === "before" ? "0" : "1",
246
247
  decimalCount: String(e.currencyDecimalCount),
247
248
  decimalSeparator: r(e.currencyDecimalSeparator, ","),
@@ -412,18 +413,18 @@ const z = () => ({
412
413
  },
413
414
  async fetchRecommendationFilters() {
414
415
  if (!Object.keys(this.filterList).length) {
415
- if (h) {
416
- await h;
416
+ if (g) {
417
+ await g;
417
418
  return;
418
419
  }
419
- h = (async () => {
420
+ g = (async () => {
420
421
  const t = await u.fetchRecommendationFilters();
421
422
  this.filterList = t;
422
423
  })();
423
424
  try {
424
- await h;
425
+ await g;
425
426
  } finally {
426
- h = null;
427
+ g = null;
427
428
  }
428
429
  }
429
430
  },
@@ -505,21 +506,21 @@ const z = () => ({
505
506
  // ====================================================================
506
507
  async fetchRecommendationProducts() {
507
508
  if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
508
- if (g) {
509
- await g;
509
+ if (h) {
510
+ await h;
510
511
  return;
511
512
  }
512
- g = this._doFetchProducts();
513
+ h = this._doFetchProducts();
513
514
  try {
514
- await g;
515
+ await h;
515
516
  } finally {
516
- g = null;
517
+ h = null;
517
518
  }
518
519
  }
519
520
  },
520
521
  async _doFetchProducts() {
521
522
  var d;
522
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = P();
523
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = F();
523
524
  if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
524
525
  await this._doFetchStrategyProducts(t);
525
526
  return;
@@ -20,7 +20,6 @@ export * from './utils';
20
20
  export declare class RecommendationBlockControl extends CommonControl {
21
21
  private store;
22
22
  private storeUnsubscription;
23
- private syncedConfigs;
24
23
  private pendingNodeConfigWrite;
25
24
  private pendingConfigFlushTimer;
26
25
  private algorithmControl;
@@ -64,6 +63,11 @@ export declare class RecommendationBlockControl extends CommonControl {
64
63
  * fingerprint diff on this hook is the only way to notice (SD-149105).
65
64
  * An unchanged fingerprint means the move came from us, so runtime store
66
65
  * edits are never clobbered (SD-141049).
66
+ *
67
+ * The fingerprint is kept on the block's own store state so deleting the
68
+ * block drops it with the state it describes. A control-owned memo outlived
69
+ * that state and made a re-dropped saved module keep the defaults its wiped
70
+ * state was rebuilt with (SD-150347).
67
71
  */
68
72
  private _syncNodeConfigIfChanged;
69
73
  private _capturePendingNodeConfigWrite;
@@ -41,6 +41,16 @@ interface PerBlockState {
41
41
  isInitialized: boolean;
42
42
  /** Snapshot of filters taken when the drawer opens, used to revert on cancel */
43
43
  filterSnapshot: Filter[] | null;
44
+ /**
45
+ * Fingerprint of the node config as this block's state last adopted it.
46
+ *
47
+ * Lives here, not on the control, because it is a claim ABOUT this state —
48
+ * "the store already holds that node config". Held on the control it
49
+ * outlived the state it described: `removeBlockState` tore the state down
50
+ * while the fingerprint survived, so re-dropping a saved module under the
51
+ * same id skipped the re-sync and kept the defaults (SD-150347).
52
+ */
53
+ syncedConfigFingerprint: string | null;
44
54
  }
45
55
  /**
46
56
  * Persisted-config subset used by `seedBlockUrlConfig` to reconstruct
@@ -57,6 +67,8 @@ export interface PerBlockUrlConfig {
57
67
  filters: Filter[];
58
68
  shuffleProducts: boolean;
59
69
  currencyCode: string;
70
+ /** The displayed symbol, which is not the code — a TRY block shows `₺`. */
71
+ currencySymbol: string;
60
72
  currencyAlignment: 'before' | 'after';
61
73
  currencyDecimalCount: number;
62
74
  currencyDecimalSeparator: string;
@@ -1,30 +1,30 @@
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 d, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
- import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.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";
6
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";
7
+ import { DATA_ATTRIBUTES as C } 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
11
  import { useUnsubscribeStore as _ } from "../stores/unsubscribe.js";
12
12
  import { assignTrackingIds as v } from "./linkTrackingIds.js";
13
- function O(m) {
14
- const i = new DOMParser().parseFromString(m, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
15
- return i.forEach((s) => {
16
- const o = s.getAttribute(A.PAGE_LIST);
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);
17
17
  o && t.push(...R(o));
18
18
  }), [...new Set(t)];
19
19
  }
20
- async function M(m) {
21
- const n = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
20
+ async function M(l) {
21
+ const n = new DOMParser().parseFromString(l, "text/html").querySelectorAll(".recommendation-block-v2");
22
22
  if (n.length === 0)
23
23
  return;
24
- const i = C();
24
+ const c = T();
25
25
  n.forEach((t) => {
26
- var r, l, g, f, c;
27
- const s = t.getAttribute("recommendation-id"), o = s ? Number(s) : NaN;
26
+ var r, d, g, f, s, y;
27
+ const i = t.getAttribute("recommendation-id"), o = i ? Number(i) : NaN;
28
28
  if (!Number.isFinite(o))
29
29
  return;
30
30
  const p = t.getAttribute("esd-ext-config");
@@ -38,7 +38,7 @@ async function M(m) {
38
38
  }
39
39
  if (!e || typeof e != "object" || Array.isArray(e))
40
40
  return;
41
- const h = {
41
+ const b = {
42
42
  // Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
43
43
  // already-saved blocks that never re-run the migrator don't emit a
44
44
  // strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
@@ -51,16 +51,17 @@ async function M(m) {
51
51
  productIds: e.productIds ?? [...a.productIds],
52
52
  filters: e.filters ?? [...a.filters],
53
53
  shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
54
- currencyCode: ((r = e.currency) == null ? void 0 : r.code) ?? d.code,
55
- currencyAlignment: ((l = e.currency) == null ? void 0 : l.alignment) ?? d.alignment,
56
- currencyDecimalCount: ((g = e.currency) == null ? void 0 : g.decimalCount) ?? d.decimalCount,
57
- currencyDecimalSeparator: ((f = e.currency) == null ? void 0 : f.decimalSeparator) ?? d.decimalSeparator,
58
- currencyThousandSeparator: ((c = e.currency) == null ? void 0 : c.thousandSeparator) ?? d.thousandSeparator
54
+ currencyCode: ((r = e.currency) == null ? void 0 : r.code) ?? m.code,
55
+ currencySymbol: ((d = e.currency) == null ? void 0 : d.symbol) ?? m.symbol,
56
+ currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? m.alignment,
57
+ currencyDecimalCount: ((f = e.currency) == null ? void 0 : f.decimalCount) ?? m.decimalCount,
58
+ currencyDecimalSeparator: ((s = e.currency) == null ? void 0 : s.decimalSeparator) ?? m.decimalSeparator,
59
+ currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? m.thousandSeparator
59
60
  };
60
- i.seedBlockUrlConfig(o, h);
61
+ c.seedBlockUrlConfig(o, b);
61
62
  });
62
63
  try {
63
- await i.fetchRecommendationCreateData();
64
+ await c.fetchRecommendationCreateData();
64
65
  } catch (t) {
65
66
  console.warn(
66
67
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -69,44 +70,44 @@ async function M(m) {
69
70
  }
70
71
  }
71
72
  const Z = () => {
72
- const m = N(), u = z(), n = _(), { getCompiledEmail: i, getTemplateData: t, updateHtmlAndCss: s } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
73
+ const l = N(), u = z(), n = _(), { getCompiledEmail: c, getTemplateData: t, updateHtmlAndCss: i } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
73
74
  return {
74
75
  prepareTemplateDetails: async () => {
75
- let { html: r, css: l, syncModulesIds: g = [] } = await t();
76
+ let { html: r, css: d, syncModulesIds: g = [] } = await t();
76
77
  if (e("linkTrackingIds"))
77
78
  try {
78
- const { html: S, changed: F, nextSeq: H } = v(r, u.trackIdSessionFloor);
79
- u.trackIdSessionFloor = H, F && (r = S, await s(S, l));
80
- } catch (S) {
81
- console.error("Tracking-id step failed, saving anyway:", S);
79
+ const { html: h, changed: F, nextSeq: H } = v(r, u.trackIdSessionFloor);
80
+ u.trackIdSessionFloor = H, F && (r = h, await i(h, d));
81
+ } catch (h) {
82
+ console.error("Tracking-id step failed, saving anyway:", h);
82
83
  }
83
- const { html: f, ampHtml: c = "", ampErrors: T = [] } = await i({
84
+ const { html: f, ampHtml: s = "", ampErrors: y = [] } = await c({
84
85
  minimize: !0,
85
86
  resetDataSavedFlag: !1
86
87
  });
87
88
  n.selectedUnsubscribePages.length && await n.fetchTemplates(), await M(r);
88
- const { compiledHtml: I, stats: y, appliedRules: w } = o(f), D = c && p(c).compiledHtml, E = m.getSelectedDynamicContentList, P = C(), b = O(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
90
  return console.debug("HTML Compilation Stats:", {
90
- originalSize: y.originalSize,
91
- compiledSize: y.compiledSize,
92
- reduction: `${y.reductionPercentage.toFixed(2)}%`,
91
+ originalSize: S.originalSize,
92
+ compiledSize: S.compiledSize,
93
+ reduction: `${S.reductionPercentage.toFixed(2)}%`,
93
94
  appliedRules: w,
94
- executionTime: `${y.executionTime.toFixed(2)}ms`
95
+ executionTime: `${S.executionTime.toFixed(2)}ms`
95
96
  }), {
96
97
  dynamicContentList: E,
97
98
  compiledHtml: I,
98
99
  rawHtml: r,
99
- css: l,
100
+ css: d,
100
101
  ampHtml: D,
101
- ampErrors: T,
102
+ ampErrors: y,
102
103
  modules: g.map(Number),
103
104
  recommendation: {
104
105
  campaignUrls: P.recommendationCampaignUrls,
105
106
  configs: {}
106
107
  },
107
108
  unsubscribe: {
108
- status: b.length > 0,
109
- config: b
109
+ status: A.length > 0,
110
+ config: A
110
111
  }
111
112
  };
112
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.18.1-beta.4ee2462",
3
+ "version": "3.18.1-beta.4fbee43",
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",