@useinsider/guido 3.20.1-beta.f34075e → 3.20.1-beta.f69c15d
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/dist/components/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +58 -57
- package/dist/components/organisms/AutoSaveController.vue2.js +9 -10
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +51 -53
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +22 -23
- package/dist/composables/useAutoSave.js +44 -46
- package/dist/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/composables/useSave.js +23 -26
- package/dist/composables/useSaveValidation.js +114 -113
- package/dist/composables/useSaveValidationRollout.js +6 -17
- package/dist/composables/useStripo.js +3 -4
- package/dist/extensions/Blocks/Items/block.js +42 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +223 -296
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +205 -219
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +36 -51
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +35 -31
- package/dist/extensions/Blocks/Unsubscribe/block.js +70 -75
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +192 -271
- package/dist/package.json.js +1 -1
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/composables/useAutoSave.d.ts +1 -4
- package/dist/src/composables/useSaveValidationRollout.d.ts +0 -1
- package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +0 -8
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +0 -40
- package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -11
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -18
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -8
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +0 -7
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +1 -6
- package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +0 -1
- package/dist/src/extensions/Blocks/controlFactories.d.ts +0 -22
- package/dist/static/styles/components/button.css.js +0 -5
- package/package.json +3 -3
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +0 -19
- package/dist/services/settingsApi.js +0 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +0 -17
- package/dist/src/services/settingsApi.d.ts +0 -6
- package/dist/src/stores/setup-settings.d.ts +0 -4
- package/dist/stores/setup-settings.js +0 -10
|
@@ -1,56 +1,48 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { ModificationDescription as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RRS_CONFIG_VERSION as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
9
|
-
import { RecommendationConfigService as
|
|
10
|
-
import { useRecommendationExtensionStore as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class he extends P {
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var p = (g, u, t) => u in g ? C(g, u, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[u] = t;
|
|
3
|
+
var i = (g, u, t) => p(g, typeof u != "symbol" ? u + "" : u, t);
|
|
4
|
+
import { useConfig as h } from "../../../../../composables/useConfig.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";
|
|
7
|
+
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
|
+
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
|
+
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
|
+
import { AlgorithmControl as P } from "./algorithm.js";
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
|
+
import { CurrencyControl as T } from "./currency.js";
|
|
15
|
+
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
|
+
import { FiltersControl as S } from "./filters.js";
|
|
17
|
+
import { FILTERS_CONTROL_ID as ft } from "./filters.js";
|
|
18
|
+
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
|
+
import { LocaleControl as k } from "./locale.js";
|
|
21
|
+
import { LOCALE_CONTROL_ID as yt } from "./locale.js";
|
|
22
|
+
import { PricePlacementControl as L } from "./pricePlacement.js";
|
|
23
|
+
import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
|
|
24
|
+
import { ProductCountControl as E } from "./productCount.js";
|
|
25
|
+
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
|
+
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Pt } from "./productLayout.js";
|
|
28
|
+
import { ShuffleControl as D } from "./shuffle.js";
|
|
29
|
+
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
|
+
import { StrategyControl as B } from "./strategy.js";
|
|
31
|
+
import { STRATEGY_CONTROL_ID as kt } from "./strategy.js";
|
|
32
|
+
import { setCurrencyAttributes as w, getBlockElement as v, isPartnerManagedBlock as A, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as Bt, getMainContainerTbody as wt, regenerateMobileProductRows as vt, updatePricesInPlace as At, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
|
+
const W = "ui-elements-recommendation-block";
|
|
36
|
+
class at extends N {
|
|
38
37
|
constructor() {
|
|
39
38
|
super(...arguments);
|
|
40
|
-
i(this, "store",
|
|
39
|
+
i(this, "store", R());
|
|
41
40
|
i(this, "storeUnsubscription", () => {
|
|
42
41
|
});
|
|
43
42
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
44
43
|
// re-render's single apply() — one user action must cost one undo press.
|
|
45
44
|
i(this, "pendingNodeConfigWrite", null);
|
|
46
45
|
i(this, "pendingConfigFlushTimer", null);
|
|
47
|
-
// What the panel still owes the block it watches — finished outside the panel on teardown
|
|
48
|
-
// and block switch. A new generation tells debounced work queued for the old one to stand down.
|
|
49
|
-
i(this, "trackedBlockId", null);
|
|
50
|
-
i(this, "fetchedConfigVersion", 0);
|
|
51
|
-
i(this, "hasUnrenderedProducts", !1);
|
|
52
|
-
i(this, "panelGeneration", 0);
|
|
53
|
-
i(this, "isPanelAlive", !0);
|
|
54
46
|
// Sub-control instances for lifecycle management
|
|
55
47
|
i(this, "algorithmControl", null);
|
|
56
48
|
i(this, "localeControl", null);
|
|
@@ -66,14 +58,11 @@ class he extends P {
|
|
|
66
58
|
/**
|
|
67
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
68
60
|
*/
|
|
69
|
-
i(this, "_debouncedFetchProducts",
|
|
70
|
-
if (t !== this.panelGeneration)
|
|
71
|
-
return;
|
|
72
|
-
const o = this._getBlockConfigVersion(e);
|
|
61
|
+
i(this, "_debouncedFetchProducts", f(async () => {
|
|
73
62
|
try {
|
|
74
|
-
await
|
|
63
|
+
await this.store.fetchRecommendationProducts();
|
|
75
64
|
} finally {
|
|
76
|
-
|
|
65
|
+
this._scheduleConfigFlush();
|
|
77
66
|
}
|
|
78
67
|
}, 500));
|
|
79
68
|
/**
|
|
@@ -87,12 +76,12 @@ class he extends P {
|
|
|
87
76
|
* count. The store pads products to the configured size, so in-place only
|
|
88
77
|
* fails when the size actually changed.
|
|
89
78
|
*/
|
|
90
|
-
i(this, "_debouncedRegenerateWithProducts",
|
|
91
|
-
if (
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
80
|
+
if (!this.currentNode || !this.api)
|
|
92
81
|
return;
|
|
93
|
-
const t = this._getRecommendationIdFromNode(this.currentNode),
|
|
94
|
-
if (t === null ||
|
|
95
|
-
this.
|
|
82
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), e = this.store.currentRecommendationId;
|
|
83
|
+
if (t === null || e === null || t === e || !this.store.blockStates[t]) {
|
|
84
|
+
this._regenerateWithProducts();
|
|
96
85
|
return;
|
|
97
86
|
}
|
|
98
87
|
if (this.store.blockStates[t].recommendationProducts.length) {
|
|
@@ -100,13 +89,13 @@ class he extends P {
|
|
|
100
89
|
try {
|
|
101
90
|
this._regenerateWithProducts();
|
|
102
91
|
} finally {
|
|
103
|
-
this.store.setCurrentBlock(
|
|
92
|
+
this.store.setCurrentBlock(e);
|
|
104
93
|
}
|
|
105
94
|
}
|
|
106
95
|
}, 100));
|
|
107
96
|
}
|
|
108
97
|
getId() {
|
|
109
|
-
return
|
|
98
|
+
return W;
|
|
110
99
|
}
|
|
111
100
|
get _subControls() {
|
|
112
101
|
return [
|
|
@@ -123,15 +112,15 @@ class he extends P {
|
|
|
123
112
|
];
|
|
124
113
|
}
|
|
125
114
|
getTemplate() {
|
|
126
|
-
var
|
|
127
|
-
return this.rrsEnabled =
|
|
115
|
+
var t;
|
|
116
|
+
return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
128
117
|
var o;
|
|
129
|
-
return (o =
|
|
130
|
-
}), this.algorithmControl = new
|
|
131
|
-
|
|
118
|
+
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
119
|
+
}), this.algorithmControl = new P(), this.localeControl = new k(), this.currencyControl = new T(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new L(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new B() : null, this._subControls.forEach((e) => {
|
|
120
|
+
e && (e.api = this.api);
|
|
132
121
|
}), `
|
|
133
122
|
<div class="recommendation-controls-container">
|
|
134
|
-
${((
|
|
123
|
+
${((t = this.strategyControl) == null ? void 0 : t.getTemplate()) ?? ""}
|
|
135
124
|
${this.layoutOrientationControl.getTemplate()}
|
|
136
125
|
${this.productCountControl.getTemplate()}
|
|
137
126
|
${this.productLayoutControl.getTemplate()}
|
|
@@ -144,39 +133,39 @@ class he extends P {
|
|
|
144
133
|
</div>
|
|
145
134
|
`;
|
|
146
135
|
}
|
|
147
|
-
_showControlsForBlock(
|
|
148
|
-
var
|
|
149
|
-
const
|
|
150
|
-
if (!
|
|
136
|
+
_showControlsForBlock(t) {
|
|
137
|
+
var n;
|
|
138
|
+
const e = (n = this.getContainer()) == null ? void 0 : n.querySelector(".recommendation-controls-container");
|
|
139
|
+
if (!e)
|
|
151
140
|
return;
|
|
152
|
-
const o = this._getRecommendationIdFromNode(
|
|
153
|
-
|
|
141
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !r;
|
|
142
|
+
e.classList.toggle("strategy-block", r), e.classList.toggle("legacy-strategy-block", s);
|
|
154
143
|
}
|
|
155
144
|
async onRender() {
|
|
156
145
|
var o;
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
146
|
+
b(this.api);
|
|
147
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
148
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), t !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
160
149
|
this._initializeSubControls();
|
|
161
150
|
return;
|
|
162
151
|
}
|
|
163
|
-
await this._fetchBlockData(
|
|
152
|
+
await this._fetchBlockData(e), this._initializeSubControls();
|
|
164
153
|
}
|
|
165
|
-
onTemplateNodeUpdated(
|
|
154
|
+
onTemplateNodeUpdated(t) {
|
|
166
155
|
var o;
|
|
167
|
-
super.onTemplateNodeUpdated(
|
|
168
|
-
const
|
|
169
|
-
|
|
156
|
+
super.onTemplateNodeUpdated(t);
|
|
157
|
+
const e = this._getRecommendationIdFromNode(t);
|
|
158
|
+
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(() => {
|
|
170
159
|
this._initializeSubControls();
|
|
171
|
-
}), this._subControls.forEach((
|
|
172
|
-
var
|
|
173
|
-
|
|
160
|
+
}), this._subControls.forEach((r) => {
|
|
161
|
+
var s;
|
|
162
|
+
r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
|
|
174
163
|
});
|
|
175
164
|
}
|
|
176
165
|
onDestroy() {
|
|
177
|
-
this.
|
|
178
|
-
var
|
|
179
|
-
return (
|
|
166
|
+
this.storeUnsubscription(), this._flushPendingNodeConfig(), this._subControls.forEach((t) => {
|
|
167
|
+
var e;
|
|
168
|
+
return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
|
|
180
169
|
});
|
|
181
170
|
}
|
|
182
171
|
/**
|
|
@@ -184,9 +173,9 @@ class he extends P {
|
|
|
184
173
|
* Each sub-control manages its own form values and event listeners
|
|
185
174
|
*/
|
|
186
175
|
_initializeSubControls() {
|
|
187
|
-
this._subControls.forEach((
|
|
188
|
-
var
|
|
189
|
-
|
|
176
|
+
this._subControls.forEach((t) => {
|
|
177
|
+
var e;
|
|
178
|
+
t && (t.api = this.api, t.currentNode = this.currentNode, (e = t.onRender) == null || e.call(t));
|
|
190
179
|
});
|
|
191
180
|
}
|
|
192
181
|
/**
|
|
@@ -213,36 +202,35 @@ class he extends P {
|
|
|
213
202
|
* that state and made a re-dropped saved module keep the defaults its wiped
|
|
214
203
|
* state was rebuilt with (SD-150347).
|
|
215
204
|
*/
|
|
216
|
-
_syncNodeConfigIfChanged(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (!t)
|
|
205
|
+
_syncNodeConfigIfChanged(t) {
|
|
206
|
+
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
|
|
207
|
+
const e = this.store.blockStates[t];
|
|
208
|
+
if (!e)
|
|
221
209
|
return;
|
|
222
|
-
const o = JSON.stringify(
|
|
223
|
-
|
|
210
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
|
|
211
|
+
e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
224
212
|
}
|
|
225
213
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
226
214
|
_isPendingStrategyIdChange() {
|
|
227
|
-
const
|
|
228
|
-
return
|
|
215
|
+
const t = this.pendingNodeConfigWrite;
|
|
216
|
+
return t ? c.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
229
217
|
}
|
|
230
218
|
_capturePendingNodeConfigWrite() {
|
|
231
|
-
const
|
|
232
|
-
!this.currentNode || !this.api ||
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
219
|
+
const t = this.store.currentRecommendationId;
|
|
220
|
+
if (!this.currentNode || !this.api || t === null)
|
|
221
|
+
return;
|
|
222
|
+
const { filters: e, strategy: o, strategyId: r, size: s, nodeConfigVersion: n } = this.store.recommendationConfigs, { partnerName: l } = h();
|
|
223
|
+
this.pendingNodeConfigWrite = {
|
|
224
|
+
blockId: t,
|
|
225
|
+
node: this.currentNode,
|
|
226
|
+
updates: {
|
|
227
|
+
filters: e,
|
|
228
|
+
strategy: o,
|
|
229
|
+
strategyId: r,
|
|
230
|
+
size: s,
|
|
231
|
+
configVersion: n,
|
|
232
|
+
...l.value ? { partnerName: l.value } : {}
|
|
233
|
+
}
|
|
246
234
|
};
|
|
247
235
|
}
|
|
248
236
|
/**
|
|
@@ -255,9 +243,9 @@ class he extends P {
|
|
|
255
243
|
* @param documentModifier - The batch to accumulate into
|
|
256
244
|
* @returns Whether anything was staged
|
|
257
245
|
*/
|
|
258
|
-
_stagePendingNodeConfig(
|
|
259
|
-
const
|
|
260
|
-
return !
|
|
246
|
+
_stagePendingNodeConfig(t) {
|
|
247
|
+
const e = this.pendingNodeConfigWrite;
|
|
248
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
261
249
|
}
|
|
262
250
|
/**
|
|
263
251
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -274,54 +262,45 @@ class he extends P {
|
|
|
274
262
|
}
|
|
275
263
|
/**
|
|
276
264
|
* Writes the deferred change standalone when the batch it was staged into never
|
|
277
|
-
* committed. Always targets
|
|
278
|
-
* the intervening re-render staled, and saveConfig swallows that failure.
|
|
265
|
+
* committed. Always targets the LIVE node — the captured one is an immutable
|
|
266
|
+
* snapshot the intervening re-render staled, and saveConfig swallows that failure.
|
|
279
267
|
*/
|
|
280
268
|
_flushPendingNodeConfig() {
|
|
281
|
-
const
|
|
282
|
-
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
b(this.currentNode, e.updates) && l.updateConfig(
|
|
289
|
-
this.api,
|
|
290
|
-
this.currentNode,
|
|
291
|
-
e.updates,
|
|
292
|
-
f
|
|
293
|
-
);
|
|
294
|
-
}
|
|
269
|
+
const t = this.pendingNodeConfigWrite;
|
|
270
|
+
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
271
|
+
return;
|
|
272
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
273
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
295
274
|
}
|
|
296
275
|
_syncNodeConfigToStore() {
|
|
297
|
-
var
|
|
298
|
-
const
|
|
276
|
+
var r;
|
|
277
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
|
|
299
278
|
this.store.patchCurrentBlockConfig({
|
|
300
|
-
strategy:
|
|
301
|
-
strategyId:
|
|
302
|
-
nodeConfigVersion:
|
|
303
|
-
language:
|
|
304
|
-
size:
|
|
305
|
-
productIds:
|
|
306
|
-
cardsInRow:
|
|
307
|
-
mobileCardsInRow:
|
|
308
|
-
mobileLayoutEnabled:
|
|
309
|
-
orientation:
|
|
279
|
+
strategy: t.strategy,
|
|
280
|
+
strategyId: t.strategyId,
|
|
281
|
+
nodeConfigVersion: t.configVersion,
|
|
282
|
+
language: t.language,
|
|
283
|
+
size: t.size,
|
|
284
|
+
productIds: t.productIds,
|
|
285
|
+
cardsInRow: t.cardsInRow,
|
|
286
|
+
mobileCardsInRow: t.mobileCardsInRow,
|
|
287
|
+
mobileLayoutEnabled: t.mobileLayoutEnabled,
|
|
288
|
+
orientation: t.layout,
|
|
310
289
|
// Only sync filters from node config during initial load.
|
|
311
290
|
// After initialization, the Pinia store is the source of truth
|
|
312
291
|
// for filters (edited via the filter drawer).
|
|
313
|
-
...o ? {} : { filters:
|
|
314
|
-
shuffleProducts:
|
|
315
|
-
priceMovedToNextLine:
|
|
316
|
-
priceHideIfSameAsDiscounted:
|
|
292
|
+
...o ? {} : { filters: t.filters },
|
|
293
|
+
shuffleProducts: t.shuffleProducts,
|
|
294
|
+
priceMovedToNextLine: t.priceMovedToNextLine,
|
|
295
|
+
priceHideIfSameAsDiscounted: t.priceHideIfSameAsDiscounted,
|
|
317
296
|
currencySettings: {
|
|
318
|
-
name:
|
|
319
|
-
value:
|
|
320
|
-
symbol:
|
|
321
|
-
alignment:
|
|
322
|
-
decimalCount:
|
|
323
|
-
decimalSeparator:
|
|
324
|
-
thousandSeparator:
|
|
297
|
+
name: t.currency.code,
|
|
298
|
+
value: t.currency.code,
|
|
299
|
+
symbol: t.currency.symbol,
|
|
300
|
+
alignment: t.currency.alignment === "before" ? "0" : "1",
|
|
301
|
+
decimalCount: t.currency.decimalCount.toString(),
|
|
302
|
+
decimalSeparator: t.currency.decimalSeparator,
|
|
303
|
+
thousandSeparator: t.currency.thousandSeparator
|
|
325
304
|
}
|
|
326
305
|
}, { triggerRefetch: !1 });
|
|
327
306
|
}
|
|
@@ -334,27 +313,18 @@ class he extends P {
|
|
|
334
313
|
* Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
|
|
335
314
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
336
315
|
*/
|
|
337
|
-
async _fetchBlockData(
|
|
338
|
-
|
|
316
|
+
async _fetchBlockData(t) {
|
|
317
|
+
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
339
318
|
this.store.fetchRecommendationCreateData(),
|
|
340
319
|
this.store.fetchRecommendationFilters()
|
|
341
|
-
])).forEach((
|
|
342
|
-
|
|
343
|
-
}),
|
|
344
|
-
this._refreshOutsidePanel(e, !0);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
this._applySmartDefaults();
|
|
348
|
-
const o = this._getBlockConfigVersion(e);
|
|
320
|
+
])).forEach((o, r) => {
|
|
321
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
|
|
322
|
+
}), this._applySmartDefaults();
|
|
349
323
|
try {
|
|
350
324
|
await this.store.fetchRecommendationProducts();
|
|
351
|
-
} catch (
|
|
352
|
-
console.warn("Recommendation block: fetchRecommendationProducts failed",
|
|
325
|
+
} catch (o) {
|
|
326
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", o);
|
|
353
327
|
}
|
|
354
|
-
e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !== o);
|
|
355
|
-
}
|
|
356
|
-
_isPanelOn(e) {
|
|
357
|
-
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
358
328
|
}
|
|
359
329
|
/**
|
|
360
330
|
* Applies smart defaults for newly dropped blocks.
|
|
@@ -369,39 +339,39 @@ class he extends P {
|
|
|
369
339
|
_applySmartDefaults() {
|
|
370
340
|
if (!this.currentNode || !this.api)
|
|
371
341
|
return;
|
|
372
|
-
const
|
|
373
|
-
let o = null,
|
|
374
|
-
if (
|
|
375
|
-
const { currencyList:
|
|
376
|
-
|
|
377
|
-
(
|
|
378
|
-
) || (o =
|
|
342
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
343
|
+
let o = null, r = null, s = null;
|
|
344
|
+
if (t.currency.code === a.currency.code) {
|
|
345
|
+
const { currencyList: n } = this.store;
|
|
346
|
+
n.length > 0 && (n.some(
|
|
347
|
+
(d) => d.value === `price.${a.currency.code}`
|
|
348
|
+
) || (o = n[0].value.replace("price.", ""), e.currency = {
|
|
379
349
|
...a.currency,
|
|
380
350
|
code: o,
|
|
381
351
|
symbol: o
|
|
382
352
|
}));
|
|
383
353
|
}
|
|
384
|
-
if (
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
(
|
|
388
|
-
) || (
|
|
354
|
+
if (t.strategy === a.strategy) {
|
|
355
|
+
const n = this.store.getActivePredictiveAlgorithms;
|
|
356
|
+
n.length > 0 && (n.some(
|
|
357
|
+
(d) => d.value === a.strategy
|
|
358
|
+
) || (r = n[0].value, e.strategy = r));
|
|
389
359
|
}
|
|
390
|
-
if (
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
(
|
|
394
|
-
) || (
|
|
360
|
+
if (t.language === a.language) {
|
|
361
|
+
const n = this.store.getLanguages;
|
|
362
|
+
n.length > 0 && (n.some(
|
|
363
|
+
(d) => d.value === a.language
|
|
364
|
+
) || (s = n[0].value, e.language = s));
|
|
395
365
|
}
|
|
396
|
-
!o && !
|
|
366
|
+
!o && !r && !s || (c.updateConfig(
|
|
397
367
|
this.api,
|
|
398
368
|
this.currentNode,
|
|
399
|
-
|
|
369
|
+
e,
|
|
400
370
|
"Applied smart defaults"
|
|
401
|
-
), o &&
|
|
371
|
+
), o && e.currency && w({
|
|
402
372
|
currentNode: this.currentNode,
|
|
403
373
|
documentModifier: this.api.getDocumentModifier(),
|
|
404
|
-
currency:
|
|
374
|
+
currency: e.currency
|
|
405
375
|
}), this.store.patchCurrentBlockConfig({
|
|
406
376
|
...o ? {
|
|
407
377
|
currencySettings: {
|
|
@@ -414,88 +384,46 @@ class he extends P {
|
|
|
414
384
|
thousandSeparator: a.currency.thousandSeparator
|
|
415
385
|
}
|
|
416
386
|
} : {},
|
|
417
|
-
...
|
|
418
|
-
...
|
|
387
|
+
...r ? { strategy: r } : {},
|
|
388
|
+
...s ? { language: s } : {}
|
|
419
389
|
}, { triggerRefetch: !1 }));
|
|
420
390
|
}
|
|
421
391
|
/**
|
|
422
392
|
* Reads the recommendation-id attribute from the block element within the node
|
|
423
393
|
*/
|
|
424
|
-
_getRecommendationIdFromNode(
|
|
425
|
-
const
|
|
426
|
-
if (!
|
|
394
|
+
_getRecommendationIdFromNode(t) {
|
|
395
|
+
const e = v(t);
|
|
396
|
+
if (!e || !("getAttribute" in e))
|
|
427
397
|
return null;
|
|
428
|
-
const o =
|
|
398
|
+
const o = e.getAttribute(I);
|
|
429
399
|
if (!o)
|
|
430
400
|
return null;
|
|
431
|
-
const
|
|
432
|
-
return Number.isNaN(
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Lands what the panel still owes its block before it stops watching it: the config now, the
|
|
436
|
-
* products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
|
|
437
|
-
*/
|
|
438
|
-
_finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: o } = this._trackedBlockSnapshot()) {
|
|
439
|
-
try {
|
|
440
|
-
this._flushPendingNodeConfig();
|
|
441
|
-
const n = e === null ? void 0 : this.store.blockStates[e];
|
|
442
|
-
if (e === null || !n)
|
|
443
|
-
return;
|
|
444
|
-
const r = t !== n.configVersion;
|
|
445
|
-
r && !m(
|
|
446
|
-
e,
|
|
447
|
-
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
448
|
-
f
|
|
449
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (r || o) && this._refreshOutsidePanel(e, r);
|
|
450
|
-
} catch (n) {
|
|
451
|
-
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
_trackedBlockSnapshot() {
|
|
455
|
-
return {
|
|
456
|
-
blockId: this.trackedBlockId,
|
|
457
|
-
fetchedConfigVersion: this.fetchedConfigVersion,
|
|
458
|
-
hasUnrenderedProducts: this.hasUnrenderedProducts
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
_refreshOutsidePanel(e, t) {
|
|
462
|
-
S(e, {
|
|
463
|
-
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
464
|
-
description: "Update recommendation configuration",
|
|
465
|
-
fetch: t
|
|
466
|
-
}).then((o) => {
|
|
467
|
-
!o && this.store.blockStates[e] && console.error("[recommendation] refresh outside the panel did not reach a node", { blockId: e });
|
|
468
|
-
}).catch((o) => {
|
|
469
|
-
console.error("[recommendation] refresh outside the panel failed", o);
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
_getBlockConfigVersion(e) {
|
|
473
|
-
var t;
|
|
474
|
-
return e === null ? 0 : ((t = this.store.blockStates[e]) == null ? void 0 : t.configVersion) ?? 0;
|
|
401
|
+
const r = parseInt(o);
|
|
402
|
+
return Number.isNaN(r) ? null : r;
|
|
475
403
|
}
|
|
476
404
|
/** Draws the current block's products into this panel's node. */
|
|
477
405
|
_regenerateWithProducts() {
|
|
478
406
|
if (!this.currentNode || !this.api)
|
|
479
407
|
return;
|
|
480
|
-
const
|
|
481
|
-
if (
|
|
482
|
-
o && (
|
|
408
|
+
const t = this.store.recommendationProducts, e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
409
|
+
if (A(this.currentNode)) {
|
|
410
|
+
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
483
411
|
return;
|
|
484
412
|
}
|
|
485
|
-
|
|
413
|
+
x({
|
|
486
414
|
currentNode: this.currentNode,
|
|
487
|
-
documentModifier:
|
|
488
|
-
products:
|
|
489
|
-
}) ||
|
|
415
|
+
documentModifier: e,
|
|
416
|
+
products: t
|
|
417
|
+
}) || U({
|
|
490
418
|
currentNode: this.currentNode,
|
|
491
|
-
documentModifier:
|
|
492
|
-
products:
|
|
419
|
+
documentModifier: e,
|
|
420
|
+
products: t
|
|
493
421
|
});
|
|
494
422
|
}
|
|
495
423
|
/**
|
|
496
424
|
* Listen to store changes that require product refresh or regeneration.
|
|
497
425
|
*
|
|
498
|
-
* Uses
|
|
426
|
+
* Uses configVersion counter (incremented only by patchCurrentBlockConfig)
|
|
499
427
|
* to distinguish user-initiated config changes from internal mutations
|
|
500
428
|
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
501
429
|
*
|
|
@@ -506,56 +434,55 @@ class he extends P {
|
|
|
506
434
|
* We skip that tick and update tracking references instead.
|
|
507
435
|
*/
|
|
508
436
|
_listenStateUpdates() {
|
|
509
|
-
const { store:
|
|
510
|
-
let
|
|
511
|
-
this.
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
|
|
437
|
+
const { store: t } = this;
|
|
438
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
|
|
439
|
+
this.storeUnsubscription = t.$subscribe(() => {
|
|
440
|
+
const s = t.currentRecommendationId;
|
|
441
|
+
if (s !== r) {
|
|
442
|
+
r = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
516
443
|
return;
|
|
517
444
|
}
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
d &&
|
|
445
|
+
const n = t.$state.configVersion;
|
|
446
|
+
n !== o && (o = n, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
447
|
+
const l = t.recommendationProducts, d = l !== e, m = Array.isArray(l) && l.length > 0;
|
|
448
|
+
d && m && (e = l, this._debouncedRegenerateWithProducts());
|
|
522
449
|
});
|
|
523
450
|
}
|
|
524
451
|
}
|
|
525
452
|
export {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
453
|
+
ut as ALGORITHM_CONTROL_ID,
|
|
454
|
+
P as AlgorithmControl,
|
|
455
|
+
W as CONTROL_BLOCK_ID,
|
|
456
|
+
gt as CURRENCY_CONTROL_ID,
|
|
457
|
+
T as CurrencyControl,
|
|
458
|
+
ft as FILTERS_CONTROL_ID,
|
|
459
|
+
S as FiltersControl,
|
|
460
|
+
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
461
|
+
yt as LOCALE_CONTROL_ID,
|
|
462
|
+
O as LayoutOrientationControl,
|
|
463
|
+
k as LocaleControl,
|
|
464
|
+
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
465
|
+
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
466
|
+
Pt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
467
|
+
L as PricePlacementControl,
|
|
468
|
+
E as ProductCountControl,
|
|
469
|
+
F as ProductLayoutControl,
|
|
470
|
+
at as RecommendationBlockControl,
|
|
471
|
+
St as SHUFFLE_CONTROL_ID,
|
|
472
|
+
kt as STRATEGY_CONTROL_ID,
|
|
473
|
+
D as ShuffleControl,
|
|
474
|
+
B as StrategyControl,
|
|
475
|
+
Et as adjustProductsToSize,
|
|
476
|
+
Ft as formatProductPrice,
|
|
477
|
+
v as getBlockElement,
|
|
478
|
+
Dt as getCardComposition,
|
|
479
|
+
Bt as getCurrentLayout,
|
|
480
|
+
wt as getMainContainerTbody,
|
|
481
|
+
A as isPartnerManagedBlock,
|
|
482
|
+
vt as regenerateMobileProductRows,
|
|
483
|
+
U as regenerateProductRowsWithStyles,
|
|
484
|
+
w as setCurrencyAttributes,
|
|
485
|
+
At as updatePricesInPlace,
|
|
486
|
+
x as updateProductContentInPlace,
|
|
487
|
+
xt as updateSingleProductContent
|
|
561
488
|
};
|