@useinsider/guido 3.17.0-beta.0b3f301 → 3.17.0-beta.238e3b9

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.
package/README.md CHANGED
@@ -634,16 +634,16 @@ toaster fires (useful before the host has wired the catalog).
634
634
 
635
635
  ```bash
636
636
  # Install
637
- bun install
637
+ npm install
638
638
 
639
639
  # Start dev server
640
- bun start
640
+ npm start
641
641
 
642
642
  # Build
643
- bun run build
643
+ npm run build
644
644
 
645
645
  # Lint & type-check
646
- bun run lint
646
+ npm run lint
647
647
  ```
648
648
 
649
649
  ### Environment Variables
@@ -661,7 +661,7 @@ VITE_STRIPO_USER=your_user
661
661
 
662
662
  ```bash
663
663
  # Build the package
664
- bun run build
664
+ npm run build
665
665
 
666
666
  # Create tarball
667
667
  npm pack
@@ -1,59 +1,69 @@
1
- var C = Object.defineProperty;
2
- var g = (d, c, t) => c in d ? C(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
3
- var n = (d, c, t) => g(d, typeof c != "symbol" ? c + "" : c, t);
1
+ var m = Object.defineProperty;
2
+ var C = (h, l, t) => l in h ? m(h, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[l] = t;
3
+ var r = (h, l, t) => C(h, typeof l != "symbol" ? l + "" : l, t);
4
4
  import { useConfig as p } from "../../../../../composables/useConfig.js";
5
- import { CommonControl as y } from "../../../common-control.js";
5
+ import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as N } from "../../../common-control.js";
6
7
  import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
7
- import { RecommendationConfigService as m } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as N } from "../../store/recommendation.js";
9
- import { AlgorithmControl as I } from "./algorithm.js";
10
- import { ALGORITHM_CONTROL_ID as it } from "./algorithm.js";
11
- import { CurrencyControl as R } from "./currency.js";
12
- import { CURRENCY_CONTROL_ID as at } from "./currency.js";
13
- import { FiltersControl as b } from "./filters.js";
14
- import { FILTERS_CONTROL_ID as lt } from "./filters.js";
15
- import { LayoutOrientationControl as T } from "./layoutOrientation.js";
16
- import { LAYOUT_ORIENTATION_CONTROL_ID as dt } from "./layoutOrientation.js";
8
+ import { RecommendationConfigService as c } from "../../services/configService.js";
9
+ import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
10
+ import { AlgorithmControl as R } from "./algorithm.js";
11
+ import { ALGORITHM_CONTROL_ID as at } from "./algorithm.js";
12
+ import { CurrencyControl as b } from "./currency.js";
13
+ import { CURRENCY_CONTROL_ID as ct } from "./currency.js";
14
+ import { FiltersControl as T } from "./filters.js";
15
+ import { FILTERS_CONTROL_ID as dt } from "./filters.js";
16
+ import { LayoutOrientationControl as P } from "./layoutOrientation.js";
17
+ import { LAYOUT_ORIENTATION_CONTROL_ID as ft } from "./layoutOrientation.js";
17
18
  import { LocaleControl as S } from "./locale.js";
18
- import { LOCALE_CONTROL_ID as ht } from "./locale.js";
19
+ import { LOCALE_CONTROL_ID as mt } from "./locale.js";
19
20
  import { PricePlacementControl as O } from "./pricePlacement.js";
20
- import { PRICE_PLACEMENT_CONTROL_ID as Ct } from "./pricePlacement.js";
21
- import { ProductCountControl as P } from "./productCount.js";
22
- import { PRODUCT_COUNT_CONTROL_ID as pt } from "./productCount.js";
23
- import { ProductLayoutControl as L } from "./productLayout.js";
24
- import { PRODUCT_LAYOUT_CONTROL_ID as _t } from "./productLayout.js";
21
+ import { PRICE_PLACEMENT_CONTROL_ID as pt } from "./pricePlacement.js";
22
+ import { ProductCountControl as L } from "./productCount.js";
23
+ import { PRODUCT_COUNT_CONTROL_ID as Nt } from "./productCount.js";
24
+ import { ProductLayoutControl as E } from "./productLayout.js";
25
+ import { PRODUCT_LAYOUT_CONTROL_ID as It } from "./productLayout.js";
25
26
  import { ShuffleControl as k } from "./shuffle.js";
26
- import { SHUFFLE_CONTROL_ID as It } from "./shuffle.js";
27
- import { StrategyControl as E } from "./strategy.js";
28
- import { STRATEGY_CONTROL_ID as bt } from "./strategy.js";
29
- import { setCurrencyAttributes as D, getBlockElement as B, isPartnerManagedBlock as w, updateProductContentInPlace as A, regenerateProductRowsWithStyles as v } from "./utils.js";
30
- import { adjustProductsToSize as St, formatProductPrice as Ot, getCardComposition as Pt, getCurrentLayout as Lt, regenerateMobileProductRows as kt, updatePricesInPlace as Et, updateSingleProductContent as Dt } from "./utils.js";
31
- import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
32
- const x = "recommendation-id", F = "ui-elements-recommendation-block";
33
- class ot extends y {
27
+ import { SHUFFLE_CONTROL_ID as bt } from "./shuffle.js";
28
+ import { StrategyControl as D } from "./strategy.js";
29
+ import { STRATEGY_CONTROL_ID as Pt } from "./strategy.js";
30
+ import { setCurrencyAttributes as F, getBlockElement as w, isPartnerManagedBlock as A, updateProductContentInPlace as v, regenerateProductRowsWithStyles as x } from "./utils.js";
31
+ import { adjustProductsToSize as Ot, formatProductPrice as Lt, getCardComposition as Et, getCurrentLayout as kt, regenerateMobileProductRows as Dt, updatePricesInPlace as Ft, updateSingleProductContent as wt } from "./utils.js";
32
+ import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
33
+ const B = "recommendation-id", U = "ui-elements-recommendation-block";
34
+ class rt extends N {
34
35
  constructor() {
35
36
  super(...arguments);
36
- n(this, "store", N());
37
- n(this, "storeUnsubscription", () => {
37
+ r(this, "store", I());
38
+ r(this, "storeUnsubscription", () => {
38
39
  });
39
- n(this, "syncedBlockIds", /* @__PURE__ */ new Set());
40
+ // blockId -> fingerprint of the node config as it looked at the last sync.
41
+ r(this, "syncedConfigs", /* @__PURE__ */ new Map());
42
+ // A config change waiting to reach the node config. Deferred so it can ride the
43
+ // re-render's single apply() — one user action must cost one undo press.
44
+ r(this, "pendingNodeConfigWrite", null);
45
+ r(this, "pendingConfigFlushTimer", null);
40
46
  // Sub-control instances for lifecycle management
41
- n(this, "algorithmControl", null);
42
- n(this, "localeControl", null);
43
- n(this, "currencyControl", null);
44
- n(this, "productCountControl", null);
45
- n(this, "productLayoutControl", null);
46
- n(this, "filtersControl", null);
47
- n(this, "shuffleControl", null);
48
- n(this, "pricePlacementControl", null);
49
- n(this, "layoutOrientationControl", null);
50
- n(this, "strategyControl", null);
51
- n(this, "rrsEnabled", !1);
47
+ r(this, "algorithmControl", null);
48
+ r(this, "localeControl", null);
49
+ r(this, "currencyControl", null);
50
+ r(this, "productCountControl", null);
51
+ r(this, "productLayoutControl", null);
52
+ r(this, "filtersControl", null);
53
+ r(this, "shuffleControl", null);
54
+ r(this, "pricePlacementControl", null);
55
+ r(this, "layoutOrientationControl", null);
56
+ r(this, "strategyControl", null);
57
+ r(this, "rrsEnabled", !1);
52
58
  /**
53
59
  * Debounced product fetch to prevent rapid API calls during config changes
54
60
  */
55
- n(this, "_debouncedFetchProducts", h(() => {
56
- this.store.fetchRecommendationProducts();
61
+ r(this, "_debouncedFetchProducts", f(async () => {
62
+ try {
63
+ await this.store.fetchRecommendationProducts();
64
+ } finally {
65
+ this._scheduleConfigFlush();
66
+ }
57
67
  }, 500));
58
68
  /**
59
69
  * Debounced content update when products arrive from API.
@@ -66,16 +76,20 @@ class ot extends y {
66
76
  * count. The store pads products to the configured size, so in-place only
67
77
  * fails when the size actually changed.
68
78
  */
69
- n(this, "_debouncedRegenerateWithProducts", h(() => {
79
+ r(this, "_debouncedRegenerateWithProducts", f(() => {
70
80
  const t = this.store.recommendationProducts;
71
- if (!this.currentNode || !this.api || w(this.currentNode))
81
+ if (!this.currentNode || !this.api)
82
+ return;
83
+ const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
84
+ if (A(this.currentNode)) {
85
+ o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
72
86
  return;
73
- const e = this.api.getDocumentModifier();
74
- A({
87
+ }
88
+ v({
75
89
  currentNode: this.currentNode,
76
90
  documentModifier: e,
77
91
  products: t
78
- }) || v({
92
+ }) || x({
79
93
  currentNode: this.currentNode,
80
94
  documentModifier: e,
81
95
  products: t
@@ -83,7 +97,7 @@ class ot extends y {
83
97
  }, 100));
84
98
  }
85
99
  getId() {
86
- return F;
100
+ return U;
87
101
  }
88
102
  get _subControls() {
89
103
  return [
@@ -104,7 +118,7 @@ class ot extends y {
104
118
  return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
105
119
  var o;
106
120
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
107
- }), this.algorithmControl = new I(), this.localeControl = new S(), this.currencyControl = new R(), this.productCountControl = new P(), this.productLayoutControl = new L(), this.filtersControl = new b(), this.shuffleControl = new k(), this.pricePlacementControl = new O(), this.layoutOrientationControl = new T(), this.strategyControl = this.rrsEnabled ? new E() : null, this._subControls.forEach((e) => {
121
+ }), this.algorithmControl = new R(), this.localeControl = new S(), this.currencyControl = new b(), this.productCountControl = new L(), this.productLayoutControl = new E(), this.filtersControl = new T(), this.shuffleControl = new k(), this.pricePlacementControl = new O(), this.layoutOrientationControl = new P(), this.strategyControl = this.rrsEnabled ? new D() : null, this._subControls.forEach((e) => {
108
122
  e && (e.api = this.api);
109
123
  }), `
110
124
  <div class="recommendation-controls-container">
@@ -126,13 +140,13 @@ class ot extends y {
126
140
  const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
127
141
  if (!e)
128
142
  return;
129
- const o = this._getRecommendationIdFromNode(t) === null ? null : m.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
130
- e.classList.toggle("strategy-block", r);
143
+ const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
144
+ e.classList.toggle("strategy-block", n);
131
145
  }
132
146
  async onRender() {
133
147
  var o;
134
148
  const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
135
- if (e !== null && this.store.setCurrentBlock(e), t !== null && !this.syncedBlockIds.has(t) && (this.syncedBlockIds.add(t), this._syncNodeConfigToStore()), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
149
+ if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
136
150
  this._initializeSubControls();
137
151
  return;
138
152
  }
@@ -142,15 +156,15 @@ class ot extends y {
142
156
  var o;
143
157
  super.onTemplateNodeUpdated(t);
144
158
  const e = this._getRecommendationIdFromNode(t);
145
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.syncedBlockIds.has(e) && (this.syncedBlockIds.add(e), this._syncNodeConfigToStore()), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
159
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
146
160
  this._initializeSubControls();
147
- }), this._subControls.forEach((r) => {
161
+ }), this._subControls.forEach((n) => {
148
162
  var i;
149
- r != null && r.api && (r.currentNode = t, (i = r.onTemplateNodeUpdated) == null || i.call(r, t));
163
+ n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
150
164
  });
151
165
  }
152
166
  onDestroy() {
153
- this.storeUnsubscription(), this._subControls.forEach((t) => {
167
+ this.storeUnsubscription(), this._flushPendingNodeConfig(), this._subControls.forEach((t) => {
154
168
  var e;
155
169
  return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
156
170
  });
@@ -175,9 +189,73 @@ class ot extends y {
175
189
  * Uses triggerRefetch: false because the fetch hasn't happened yet —
176
190
  * values are being prepared for the upcoming initial fetch.
177
191
  */
192
+ /**
193
+ * Re-syncs the store when the node config moved since we last read it.
194
+ *
195
+ * Undo/redo, the code editor and version-history restore rewrite the node
196
+ * config behind the store's back — Stripo exposes no undo signal, so a
197
+ * fingerprint diff on this hook is the only way to notice (SD-149105).
198
+ * An unchanged fingerprint means the move came from us, so runtime store
199
+ * edits are never clobbered (SD-141049).
200
+ */
201
+ _syncNodeConfigIfChanged(t) {
202
+ this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
203
+ const e = JSON.stringify(c.getConfig(this.currentNode)), o = this.syncedConfigs.get(t);
204
+ this.syncedConfigs.set(t, e), o !== e && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
205
+ }
206
+ _capturePendingNodeConfigWrite() {
207
+ const t = this.store.currentRecommendationId;
208
+ if (!this.currentNode || !this.api || t === null)
209
+ return;
210
+ const { filters: e, strategyId: o, size: n } = this.store.recommendationConfigs;
211
+ this.pendingNodeConfigWrite = {
212
+ blockId: t,
213
+ node: this.currentNode,
214
+ updates: { filters: e, strategyId: o, size: n }
215
+ };
216
+ }
217
+ /**
218
+ * Accumulates the pending write into `documentModifier` without applying, so the
219
+ * caller's apply() commits config and re-render as ONE undo entry.
220
+ *
221
+ * Deliberately does not consume the pending record: the product helpers call
222
+ * apply() only when they actually changed something, so this batch may never be
223
+ * committed and the flush has to stay able to write it standalone.
224
+ * @param documentModifier - The batch to accumulate into
225
+ * @returns Whether anything was staged
226
+ */
227
+ _stagePendingNodeConfig(t) {
228
+ const e = this.pendingNodeConfigWrite;
229
+ return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
230
+ }
231
+ /**
232
+ * Arms the guaranteed fallback write, once the product fetch has settled. The
233
+ * delay only has to outlast the re-render debounce that fetch triggers — firing
234
+ * earlier writes the config on its own and the undo entry splits in two again.
235
+ */
236
+ _scheduleConfigFlush() {
237
+ this._clearConfigFlush(), this.pendingConfigFlushTimer = setTimeout(() => {
238
+ this.pendingConfigFlushTimer = null, this._flushPendingNodeConfig();
239
+ }, 800);
240
+ }
241
+ _clearConfigFlush() {
242
+ this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
243
+ }
244
+ /**
245
+ * Writes the deferred change standalone when the batch it was staged into never
246
+ * committed. Always targets the LIVE node — the captured one is an immutable
247
+ * snapshot the intervening re-render staled, and saveConfig swallows that failure.
248
+ */
249
+ _flushPendingNodeConfig() {
250
+ const t = this.pendingNodeConfigWrite;
251
+ if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
252
+ return;
253
+ const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
254
+ JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
255
+ }
178
256
  _syncNodeConfigToStore() {
179
- var r;
180
- const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
257
+ var n;
258
+ const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
181
259
  this.store.patchCurrentBlockConfig({
182
260
  strategy: t.strategy,
183
261
  strategyId: t.strategyId,
@@ -219,8 +297,8 @@ class ot extends y {
219
297
  t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
220
298
  this.store.fetchRecommendationCreateData(),
221
299
  this.store.fetchRecommendationFilters()
222
- ])).forEach((o, r) => {
223
- o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
300
+ ])).forEach((o, n) => {
301
+ o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
224
302
  }), this._applySmartDefaults();
225
303
  try {
226
304
  await this.store.fetchRecommendationProducts();
@@ -241,12 +319,12 @@ class ot extends y {
241
319
  _applySmartDefaults() {
242
320
  if (!this.currentNode || !this.api)
243
321
  return;
244
- const t = m.getConfig(this.currentNode), e = {};
245
- let o = null, r = null, i = null;
322
+ const t = c.getConfig(this.currentNode), e = {};
323
+ let o = null, n = null, i = null;
246
324
  if (t.currency.code === a.currency.code) {
247
325
  const { currencyList: s } = this.store;
248
326
  s.length > 0 && (s.some(
249
- (u) => u.value === `price.${a.currency.code}`
327
+ (d) => d.value === `price.${a.currency.code}`
250
328
  ) || (o = s[0].value.replace("price.", ""), e.currency = {
251
329
  ...a.currency,
252
330
  code: o,
@@ -256,21 +334,21 @@ class ot extends y {
256
334
  if (t.strategy === a.strategy) {
257
335
  const s = this.store.getActivePredictiveAlgorithms;
258
336
  s.length > 0 && (s.some(
259
- (u) => u.value === a.strategy
260
- ) || (r = s[0].value, e.strategy = r));
337
+ (d) => d.value === a.strategy
338
+ ) || (n = s[0].value, e.strategy = n));
261
339
  }
262
340
  if (t.language === a.language) {
263
341
  const s = this.store.getLanguages;
264
342
  s.length > 0 && (s.some(
265
- (u) => u.value === a.language
343
+ (d) => d.value === a.language
266
344
  ) || (i = s[0].value, e.language = i));
267
345
  }
268
- !o && !r && !i || (m.updateConfig(
346
+ !o && !n && !i || (c.updateConfig(
269
347
  this.api,
270
348
  this.currentNode,
271
349
  e,
272
350
  "Applied smart defaults"
273
- ), o && e.currency && D({
351
+ ), o && e.currency && F({
274
352
  currentNode: this.currentNode,
275
353
  documentModifier: this.api.getDocumentModifier(),
276
354
  currency: e.currency
@@ -286,7 +364,7 @@ class ot extends y {
286
364
  thousandSeparator: a.currency.thousandSeparator
287
365
  }
288
366
  } : {},
289
- ...r ? { strategy: r } : {},
367
+ ...n ? { strategy: n } : {},
290
368
  ...i ? { language: i } : {}
291
369
  }, { triggerRefetch: !1 }));
292
370
  }
@@ -294,14 +372,14 @@ class ot extends y {
294
372
  * Reads the recommendation-id attribute from the block element within the node
295
373
  */
296
374
  _getRecommendationIdFromNode(t) {
297
- const e = B(t);
375
+ const e = w(t);
298
376
  if (!e || !("getAttribute" in e))
299
377
  return null;
300
- const o = e.getAttribute(x);
378
+ const o = e.getAttribute(B);
301
379
  if (!o)
302
380
  return null;
303
- const r = parseInt(o);
304
- return Number.isNaN(r) ? null : r;
381
+ const n = parseInt(o);
382
+ return Number.isNaN(n) ? null : n;
305
383
  }
306
384
  /**
307
385
  * Listen to store changes that require product refresh or regeneration.
@@ -318,70 +396,53 @@ class ot extends y {
318
396
  */
319
397
  _listenStateUpdates() {
320
398
  const { store: t } = this;
321
- let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
399
+ let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
322
400
  this.storeUnsubscription = t.$subscribe(() => {
323
401
  const i = t.currentRecommendationId;
324
- if (i !== r) {
325
- r = i, e = t.recommendationProducts, o = t.$state.configVersion;
402
+ if (i !== n) {
403
+ n = i, e = t.recommendationProducts, o = t.$state.configVersion;
326
404
  return;
327
405
  }
328
406
  const s = t.$state.configVersion;
329
- s !== o && (o = s, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
330
- const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
331
- u && f && (e = l, this._debouncedRegenerateWithProducts());
407
+ s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
408
+ const u = t.recommendationProducts, d = u !== e, g = Array.isArray(u) && u.length > 0;
409
+ d && g && (e = u, this._debouncedRegenerateWithProducts());
332
410
  });
333
411
  }
334
- /**
335
- * Persists filter + strategy state to the Stripo node config so it survives
336
- * save/reload (strategyId must reach esd-ext-config before any save).
337
- * `size` rides along: assigning a strategy writes it to the store only, and a
338
- * stale node config would rebuild the block against the old slot count.
339
- */
340
- _persistFiltersToNodeConfig() {
341
- if (!this.currentNode || !this.api)
342
- return;
343
- const { filters: t, strategyId: e, size: o } = this.store.recommendationConfigs, r = m.getConfig(this.currentNode);
344
- JSON.stringify(r.filters) === JSON.stringify(t) && r.strategyId === e && r.size === o || m.updateConfig(
345
- this.api,
346
- this.currentNode,
347
- { filters: t, strategyId: e, size: o },
348
- "Update recommendation filters"
349
- );
350
- }
351
412
  }
352
413
  export {
353
- it as ALGORITHM_CONTROL_ID,
354
- I as AlgorithmControl,
355
- F as CONTROL_BLOCK_ID,
356
- at as CURRENCY_CONTROL_ID,
357
- R as CurrencyControl,
358
- lt as FILTERS_CONTROL_ID,
359
- b as FiltersControl,
360
- dt as LAYOUT_ORIENTATION_CONTROL_ID,
361
- ht as LOCALE_CONTROL_ID,
362
- T as LayoutOrientationControl,
414
+ at as ALGORITHM_CONTROL_ID,
415
+ R as AlgorithmControl,
416
+ U as CONTROL_BLOCK_ID,
417
+ ct as CURRENCY_CONTROL_ID,
418
+ b as CurrencyControl,
419
+ dt as FILTERS_CONTROL_ID,
420
+ T as FiltersControl,
421
+ ft as LAYOUT_ORIENTATION_CONTROL_ID,
422
+ mt as LOCALE_CONTROL_ID,
423
+ P as LayoutOrientationControl,
363
424
  S as LocaleControl,
364
- Ct as PRICE_PLACEMENT_CONTROL_ID,
365
- pt as PRODUCT_COUNT_CONTROL_ID,
366
- _t as PRODUCT_LAYOUT_CONTROL_ID,
425
+ pt as PRICE_PLACEMENT_CONTROL_ID,
426
+ Nt as PRODUCT_COUNT_CONTROL_ID,
427
+ It as PRODUCT_LAYOUT_CONTROL_ID,
367
428
  O as PricePlacementControl,
368
- P as ProductCountControl,
369
- L as ProductLayoutControl,
370
- ot as RecommendationBlockControl,
371
- It as SHUFFLE_CONTROL_ID,
372
- bt as STRATEGY_CONTROL_ID,
429
+ L as ProductCountControl,
430
+ E as ProductLayoutControl,
431
+ rt as RecommendationBlockControl,
432
+ bt as SHUFFLE_CONTROL_ID,
433
+ Pt as STRATEGY_CONTROL_ID,
373
434
  k as ShuffleControl,
374
- E as StrategyControl,
375
- St as adjustProductsToSize,
376
- Ot as formatProductPrice,
377
- B as getBlockElement,
378
- Pt as getCardComposition,
379
- Lt as getCurrentLayout,
380
- w as isPartnerManagedBlock,
381
- kt as regenerateMobileProductRows,
382
- v as regenerateProductRowsWithStyles,
383
- D as setCurrencyAttributes,
384
- Et as updatePricesInPlace,
385
- A as updateProductContentInPlace,
386
- Dt as updateSingleProductContent
435
+ D as StrategyControl,
436
+ Ot as adjustProductsToSize,
437
+ Lt as formatProductPrice,
438
+ w as getBlockElement,
439
+ Et as getCardComposition,
440
+ kt as getCurrentLayout,
441
+ A as isPartnerManagedBlock,
442
+ Dt as regenerateMobileProductRows,
443
+ x as regenerateProductRowsWithStyles,
444
+ F as setCurrencyAttributes,
445
+ Ft as updatePricesInPlace,
446
+ v as updateProductContentInPlace,
447
+ wt as updateSingleProductContent
387
448
  };
@@ -2,13 +2,13 @@ import { ModificationDescription as h } from "../../../../node_modules/@stripoin
2
2
  import { PRE_RRS_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as c } from "../constants/defaultConfig.js";
3
3
  import { setCurrencyAttributes as D } from "../controls/main/utils.js";
4
4
  import { hasMinimalConfig as S } from "../types/nodeConfig.js";
5
- function A(n) {
6
- return n === "." || n === "," || n === " ";
5
+ function A(r) {
6
+ return r === "." || r === "," || r === " ";
7
7
  }
8
- function N(n) {
9
- return n === "." || n === "," || n === " " || n === "";
8
+ function N(r) {
9
+ return r === "." || r === "," || r === " " || r === "";
10
10
  }
11
- class F {
11
+ class M {
12
12
  // ========================================================================
13
13
  // Read Operations
14
14
  // ========================================================================
@@ -83,9 +83,27 @@ class F {
83
83
  * @returns The new complete configuration
84
84
  */
85
85
  static updateConfig(i, t, o, e) {
86
- const r = this.getConfig(t), u = this.deepMerge(r, o);
86
+ const n = this.getConfig(t), u = this.deepMerge(n, o);
87
87
  return this.saveConfig(i, t, u, e), u;
88
88
  }
89
+ /**
90
+ * Accumulate a config update into an existing modifier batch, WITHOUT applying.
91
+ *
92
+ * The caller owns the apply(), so the write shares one undo entry with the rest
93
+ * of that batch — a change whose visible result only lands after an async product
94
+ * fetch would otherwise cost the user two undo presses (SD-149105).
95
+ * @param documentModifier - The batch to accumulate into (caller applies)
96
+ * @param node - The immutable HTML node to write to
97
+ * @param updates - Partial config with values to update
98
+ */
99
+ static stageConfig(i, t, o) {
100
+ const e = this.deepMerge(this.getConfig(t), o);
101
+ try {
102
+ i.modifyHtml(t).setNodeConfig(e);
103
+ } catch (n) {
104
+ console.warn("[RecommendationConfigService] Failed to stage config:", n);
105
+ }
106
+ }
89
107
  /**
90
108
  * Initialize configuration for a new block
91
109
  *
@@ -126,8 +144,8 @@ class F {
126
144
  static saveConfig(i, t, o, e) {
127
145
  try {
128
146
  i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(e));
129
- } catch (r) {
130
- console.warn("[RecommendationConfigService] Failed to save config:", r);
147
+ } catch (n) {
148
+ console.warn("[RecommendationConfigService] Failed to save config:", n);
131
149
  }
132
150
  }
133
151
  // ========================================================================
@@ -164,20 +182,20 @@ class F {
164
182
  s && typeof s == "object" && Object.assign(o, s);
165
183
  } catch {
166
184
  }
167
- const r = t.getAttribute("data-layout");
168
- r === "list" || r === "horizontal" ? o.layout = "list" : (r === "grid" || r === "vertical") && (o.layout = "grid");
185
+ const n = t.getAttribute("data-layout");
186
+ n === "list" || n === "horizontal" ? o.layout = "list" : (n === "grid" || n === "vertical") && (o.layout = "grid");
169
187
  const u = t.getAttribute("data-card-composition");
170
188
  u && (o.composition = u.split(",").filter(Boolean));
171
189
  const l = t.getAttribute("data-column-spacing");
172
190
  l && (o.columnSpacing = parseInt(l) || c.columnSpacing);
173
- const b = t.getAttribute("data-row-spacing");
174
- if (b && (o.rowSpacing = parseInt(b) || c.rowSpacing), !o.currency) {
175
- const s = t.getAttribute("currency"), p = t.getAttribute("currency-symbol"), y = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
176
- if (s || p || y || f || g || m) {
191
+ const p = t.getAttribute("data-row-spacing");
192
+ if (p && (o.rowSpacing = parseInt(p) || c.rowSpacing), !o.currency) {
193
+ const s = t.getAttribute("currency"), b = t.getAttribute("currency-symbol"), y = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
194
+ if (s || b || y || f || g || m) {
177
195
  const a = c.currency, d = m ? parseInt(m) : NaN;
178
196
  o.currency = {
179
197
  code: s ?? a.code,
180
- symbol: p ?? a.symbol,
198
+ symbol: b ?? a.symbol,
181
199
  alignment: y === "0" ? "before" : "after",
182
200
  decimalCount: Number.isFinite(d) ? d : a.decimalCount,
183
201
  decimalSeparator: A(g) ? g : a.decimalSeparator,
@@ -279,5 +297,5 @@ class F {
279
297
  }
280
298
  }
281
299
  export {
282
- F as RecommendationConfigService
300
+ M as RecommendationConfigService
283
301
  };
@@ -20,7 +20,9 @@ export * from './utils';
20
20
  export declare class RecommendationBlockControl extends CommonControl {
21
21
  private store;
22
22
  private storeUnsubscription;
23
- private syncedBlockIds;
23
+ private syncedConfigs;
24
+ private pendingNodeConfigWrite;
25
+ private pendingConfigFlushTimer;
24
26
  private algorithmControl;
25
27
  private localeControl;
26
28
  private currencyControl;
@@ -54,6 +56,41 @@ export declare class RecommendationBlockControl extends CommonControl {
54
56
  * Uses triggerRefetch: false because the fetch hasn't happened yet —
55
57
  * values are being prepared for the upcoming initial fetch.
56
58
  */
59
+ /**
60
+ * Re-syncs the store when the node config moved since we last read it.
61
+ *
62
+ * Undo/redo, the code editor and version-history restore rewrite the node
63
+ * config behind the store's back — Stripo exposes no undo signal, so a
64
+ * fingerprint diff on this hook is the only way to notice (SD-149105).
65
+ * An unchanged fingerprint means the move came from us, so runtime store
66
+ * edits are never clobbered (SD-141049).
67
+ */
68
+ private _syncNodeConfigIfChanged;
69
+ private _capturePendingNodeConfigWrite;
70
+ /**
71
+ * Accumulates the pending write into `documentModifier` without applying, so the
72
+ * caller's apply() commits config and re-render as ONE undo entry.
73
+ *
74
+ * Deliberately does not consume the pending record: the product helpers call
75
+ * apply() only when they actually changed something, so this batch may never be
76
+ * committed and the flush has to stay able to write it standalone.
77
+ * @param documentModifier - The batch to accumulate into
78
+ * @returns Whether anything was staged
79
+ */
80
+ private _stagePendingNodeConfig;
81
+ /**
82
+ * Arms the guaranteed fallback write, once the product fetch has settled. The
83
+ * delay only has to outlast the re-render debounce that fetch triggers — firing
84
+ * earlier writes the config on its own and the undo entry splits in two again.
85
+ */
86
+ private _scheduleConfigFlush;
87
+ private _clearConfigFlush;
88
+ /**
89
+ * Writes the deferred change standalone when the batch it was staged into never
90
+ * committed. Always targets the LIVE node — the captured one is an immutable
91
+ * snapshot the intervening re-render staled, and saveConfig swallows that failure.
92
+ */
93
+ private _flushPendingNodeConfig;
57
94
  private _syncNodeConfigToStore;
58
95
  /**
59
96
  * Fetches initial data for a block in three phases:
@@ -110,11 +147,4 @@ export declare class RecommendationBlockControl extends CommonControl {
110
147
  * We skip that tick and update tracking references instead.
111
148
  */
112
149
  private _listenStateUpdates;
113
- /**
114
- * Persists filter + strategy state to the Stripo node config so it survives
115
- * save/reload (strategyId must reach esd-ext-config before any save).
116
- * `size` rides along: assigning a strategy writes it to the store only, and a
117
- * stale node config would rebuild the block against the old slot count.
118
- */
119
- private _persistFiltersToNodeConfig;
120
150
  }
@@ -25,7 +25,7 @@ import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
25
25
  * Stripo Extension API interface for document modifications
26
26
  * Extracted to allow type-safe usage without importing full Stripo types
27
27
  */
28
- interface DocumentModifier {
28
+ export interface DocumentModifier {
29
29
  modifyHtml: (node: ImmutableHtmlNode) => {
30
30
  setNodeConfig: (config: Record<string, unknown>) => DocumentModifier;
31
31
  setAttribute: (name: string, value: string) => DocumentModifier;
@@ -90,6 +90,17 @@ export declare class RecommendationConfigService {
90
90
  * @returns The new complete configuration
91
91
  */
92
92
  static updateConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, updates: PartialNodeConfig, description: string): RecommendationNodeConfig;
93
+ /**
94
+ * Accumulate a config update into an existing modifier batch, WITHOUT applying.
95
+ *
96
+ * The caller owns the apply(), so the write shares one undo entry with the rest
97
+ * of that batch — a change whose visible result only lands after an async product
98
+ * fetch would otherwise cost the user two undo presses (SD-149105).
99
+ * @param documentModifier - The batch to accumulate into (caller applies)
100
+ * @param node - The immutable HTML node to write to
101
+ * @param updates - Partial config with values to update
102
+ */
103
+ static stageConfig(documentModifier: DocumentModifier, node: ImmutableHtmlNode, updates: PartialNodeConfig): void;
93
104
  /**
94
105
  * Initialize configuration for a new block
95
106
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.17.0-beta.0b3f301",
3
+ "version": "3.17.0-beta.238e3b9",
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",
@@ -25,7 +25,7 @@
25
25
  "start": "vite",
26
26
  "build": "vite build && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.app.json",
27
27
  "preview": "vite preview",
28
- "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
28
+ "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && npm run type-check",
29
29
  "lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
30
30
  "lint:e2e-quality": "node scripts/lint-e2e-quality.mjs",
31
31
  "lint:e2e-quality:ci": "node scripts/lint-e2e-quality.mjs --ci",