@useinsider/guido 3.19.0-beta.c8d2be8 → 3.19.0-beta.cac604e
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/@types/config/schemas.js +104 -91
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
- package/dist/composables/useActionsApi.js +52 -47
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useHttp.js +44 -55
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/extensions/Blocks/Recommendation/block.js +88 -53
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +42 -22
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +26 -0
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +27 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/stripoEditorApi.js +11 -0
- package/package.json +2 -1
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
7
|
-
import { Block as
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
9
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
10
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var S = (m, c, t) => c in m ? D(m, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[c] = t;
|
|
3
|
+
var _ = (m, c, t) => S(m, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as T } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as N } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as O, BlockCompositionType as M, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as w, PRE_RRS_CONFIG_VERSION as v } from "./constants/defaultConfig.js";
|
|
9
|
+
import { RECOMMENDATION_ID_ATTR as d, SELECTOR_ATTRIBUTE_ROW as F, ATTR_CUSTOM_PREFIX as H, ATTR_DATA_CARD_COMPOSITION as P, ATTR_DATA_CUSTOM_ATTRIBUTES as x } from "./constants/selectors.js";
|
|
10
|
+
import { regenerateMobileProductRows as $ } from "./controls/main/utils.js";
|
|
11
|
+
import { ensureMobileCssRulesExist as C, setMobileLayoutOptOut as b, hasMobileLayoutOptOut as L } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
14
|
-
import { getDefaultTemplate as
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
|
|
14
|
+
import { getDefaultTemplate as q } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as U } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
import { resolveRowCompositionKey as V } from "./utils/compositionKeys.js";
|
|
17
|
+
import { carriesForeignPartnerConfig as W, loadedRecommendationIds as K, withoutCustomAttributes as z } from "./utils/partnerScope.js";
|
|
18
|
+
const y = T.Recommendation, f = "recommendation-block-v2", B = "hide-price";
|
|
19
|
+
let E = !1;
|
|
20
|
+
class at extends O {
|
|
19
21
|
constructor() {
|
|
20
22
|
super();
|
|
21
23
|
/**
|
|
22
24
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
25
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
26
|
*/
|
|
25
|
-
|
|
27
|
+
_(this, "_pendingBlockId", null);
|
|
26
28
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
27
|
-
|
|
29
|
+
_(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
28
30
|
}
|
|
29
31
|
getId() {
|
|
30
|
-
return
|
|
32
|
+
return y;
|
|
31
33
|
}
|
|
32
34
|
getIcon() {
|
|
33
35
|
return "recommendation-icon";
|
|
34
36
|
}
|
|
35
37
|
getBlockCompositionType() {
|
|
36
|
-
return
|
|
38
|
+
return M.CONTAINER;
|
|
37
39
|
}
|
|
38
40
|
getName() {
|
|
39
41
|
return this.api.translate("Recommendation Block");
|
|
@@ -44,8 +46,8 @@ class j extends E {
|
|
|
44
46
|
);
|
|
45
47
|
}
|
|
46
48
|
getSettingsPanelTitleHtml() {
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
+
return N(
|
|
50
|
+
y,
|
|
49
51
|
this.api.translate("Recommendation Block"),
|
|
50
52
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
51
53
|
);
|
|
@@ -68,7 +70,7 @@ class j extends E {
|
|
|
68
70
|
*/
|
|
69
71
|
getTemplate() {
|
|
70
72
|
const t = this._generateNextId();
|
|
71
|
-
return this._pendingBlockId = t,
|
|
73
|
+
return this._pendingBlockId = t, q(t);
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
76
|
* Called when a new block is dropped into the template
|
|
@@ -91,27 +93,28 @@ class j extends E {
|
|
|
91
93
|
}
|
|
92
94
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
93
95
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
94
|
-
const n =
|
|
96
|
+
const n = g().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
|
|
95
97
|
this.api,
|
|
96
98
|
t,
|
|
97
99
|
{
|
|
98
100
|
recommendationId: i,
|
|
99
|
-
configVersion: n ?
|
|
101
|
+
configVersion: n ? w : v,
|
|
102
|
+
...o ? { partnerName: g().partnerName.value } : {},
|
|
100
103
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
101
104
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
102
105
|
// at save for a block the user never configured.
|
|
103
106
|
...o ? { strategy: "" } : {}
|
|
104
107
|
}
|
|
105
|
-
),
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
108
|
+
), u = p();
|
|
109
|
+
if (u.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
110
|
+
C(this.api);
|
|
111
|
+
const l = this._getBlockElement(t);
|
|
112
|
+
l && (b(this.api, l, !0), $({
|
|
110
113
|
currentNode: t,
|
|
111
114
|
documentModifier: this.api.getDocumentModifier()
|
|
112
115
|
}));
|
|
113
116
|
}
|
|
114
|
-
|
|
117
|
+
u.patchCurrentBlockConfig({ language: r.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
117
120
|
* Called when the document changes or template is loaded
|
|
@@ -131,13 +134,13 @@ class j extends E {
|
|
|
131
134
|
"Assign recommendation ID to legacy block"
|
|
132
135
|
);
|
|
133
136
|
}
|
|
134
|
-
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
137
|
+
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t), this._resetForeignPartnerConfig(t);
|
|
135
138
|
try {
|
|
136
|
-
|
|
139
|
+
E || (C(this.api), E = !0);
|
|
137
140
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
138
141
|
if (i) {
|
|
139
142
|
const n = !e.mobileLayoutEnabled;
|
|
140
|
-
|
|
143
|
+
L(i) !== n && b(this.api, i, n);
|
|
141
144
|
}
|
|
142
145
|
} catch {
|
|
143
146
|
}
|
|
@@ -151,7 +154,7 @@ class j extends E {
|
|
|
151
154
|
*/
|
|
152
155
|
onDelete(t) {
|
|
153
156
|
const e = this._getRecommendationId(t);
|
|
154
|
-
e &&
|
|
157
|
+
e && p().removeBlockState(e);
|
|
155
158
|
}
|
|
156
159
|
/**
|
|
157
160
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -167,7 +170,7 @@ class j extends E {
|
|
|
167
170
|
*/
|
|
168
171
|
_warnIfMultipleBlocks() {
|
|
169
172
|
try {
|
|
170
|
-
|
|
173
|
+
U().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
171
174
|
} catch {
|
|
172
175
|
}
|
|
173
176
|
}
|
|
@@ -179,9 +182,9 @@ class j extends E {
|
|
|
179
182
|
let t = 0;
|
|
180
183
|
try {
|
|
181
184
|
const e = this.api.getDocumentRoot();
|
|
182
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
185
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${f}`).forEach((n) => {
|
|
183
186
|
if ("getAttribute" in n) {
|
|
184
|
-
const o = n.getAttribute(
|
|
187
|
+
const o = n.getAttribute(d), r = o ? parseInt(o) : 0;
|
|
185
188
|
r > t && (t = r);
|
|
186
189
|
}
|
|
187
190
|
});
|
|
@@ -197,9 +200,9 @@ class j extends E {
|
|
|
197
200
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
198
201
|
*/
|
|
199
202
|
_scheduleArrivalReset(t) {
|
|
200
|
-
|
|
203
|
+
g().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
201
204
|
const e = this._getRecommendationId(t);
|
|
202
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
205
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && p().resetArrivedBlock(e);
|
|
203
206
|
}, 0);
|
|
204
207
|
}
|
|
205
208
|
/**
|
|
@@ -222,7 +225,7 @@ class j extends E {
|
|
|
222
225
|
if (!i || !("querySelectorAll" in i))
|
|
223
226
|
return;
|
|
224
227
|
const n = i.querySelectorAll(
|
|
225
|
-
`.${
|
|
228
|
+
`.${f}[${d}="${e}"]`
|
|
226
229
|
);
|
|
227
230
|
if (n.length <= 1)
|
|
228
231
|
return;
|
|
@@ -247,7 +250,7 @@ class j extends E {
|
|
|
247
250
|
const e = this.api.getDocumentRoot();
|
|
248
251
|
if (e && "querySelectorAll" in e)
|
|
249
252
|
return e.querySelectorAll(
|
|
250
|
-
`.${
|
|
253
|
+
`.${f}[${d}="${t}"]`
|
|
251
254
|
).length > 1;
|
|
252
255
|
} catch {
|
|
253
256
|
}
|
|
@@ -255,8 +258,8 @@ class j extends E {
|
|
|
255
258
|
}
|
|
256
259
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
257
260
|
_handleDuplicate(t, e) {
|
|
258
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
259
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i),
|
|
261
|
+
const i = this._reassignDuplicateId(t, e), n = p();
|
|
262
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), g().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), n.resetArrivedBlock(i)), this._warnIfMultipleBlocks();
|
|
260
263
|
}
|
|
261
264
|
/**
|
|
262
265
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -289,7 +292,7 @@ class j extends E {
|
|
|
289
292
|
if (!("getAttribute" in t))
|
|
290
293
|
return;
|
|
291
294
|
const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, r = this.api.getDocumentModifier();
|
|
292
|
-
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new
|
|
295
|
+
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new h(
|
|
293
296
|
`Reassign recommendation instance class ${n} -> ${o}`
|
|
294
297
|
));
|
|
295
298
|
}
|
|
@@ -304,7 +307,7 @@ class j extends E {
|
|
|
304
307
|
if (!i)
|
|
305
308
|
return;
|
|
306
309
|
const n = this.api.getDocumentModifier();
|
|
307
|
-
n.modifyHtml(i).setAttribute(
|
|
310
|
+
n.modifyHtml(i).setAttribute(d, e.toString()), n.apply(new h(`Assign recommendation ID ${e}`));
|
|
308
311
|
}
|
|
309
312
|
/**
|
|
310
313
|
* Stamps the `hide-price` attribute (read by email-service at send time) on
|
|
@@ -312,7 +315,7 @@ class j extends E {
|
|
|
312
315
|
*/
|
|
313
316
|
_stampHidePrice(t, e) {
|
|
314
317
|
const i = this._getBlockElement(t);
|
|
315
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new
|
|
318
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new h("Stamp hide-price"));
|
|
316
319
|
}
|
|
317
320
|
/**
|
|
318
321
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -325,6 +328,38 @@ class j extends E {
|
|
|
325
328
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
326
329
|
this._stampHidePrice(t, i);
|
|
327
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Empties a block copied in from another account: its strategy and attribute types
|
|
333
|
+
* are account-scoped and would not resolve here (SD-151945). Layout, locale and
|
|
334
|
+
* currency stay. The write stamps the current account, so the next pass is a no-op.
|
|
335
|
+
*/
|
|
336
|
+
_resetForeignPartnerConfig(t) {
|
|
337
|
+
var I, R;
|
|
338
|
+
const e = this._getRecommendationId(t), i = this._getBlockElement(t);
|
|
339
|
+
if (e === null || !i || !s.hasConfig(t))
|
|
340
|
+
return;
|
|
341
|
+
const { partnerName: n, template: o } = g(), r = s.getConfig(t);
|
|
342
|
+
if (!W({
|
|
343
|
+
config: r,
|
|
344
|
+
blockId: e,
|
|
345
|
+
partnerName: n.value,
|
|
346
|
+
campaignUrls: (I = o.value) == null ? void 0 : I.recommendationCampaignUrls,
|
|
347
|
+
loadedIds: K(((R = o.value) == null ? void 0 : R.html) ?? "")
|
|
348
|
+
}))
|
|
349
|
+
return;
|
|
350
|
+
const u = z(r.composition), l = this.api.getDocumentModifier();
|
|
351
|
+
i.querySelectorAll(F).forEach((k) => {
|
|
352
|
+
var A;
|
|
353
|
+
(A = V(k)) != null && A.startsWith(H) && l.modifyHtml(k).delete();
|
|
354
|
+
}), l.modifyHtml(i).setAttribute(P, u.join(",")).setAttribute(x, "[]"), s.stageConfig(l, t, {
|
|
355
|
+
strategyId: "",
|
|
356
|
+
strategy: "",
|
|
357
|
+
filters: [],
|
|
358
|
+
productIds: [],
|
|
359
|
+
composition: u,
|
|
360
|
+
partnerName: n.value
|
|
361
|
+
}), l.apply(new h("Reset recommendation block copied from another account")), p().resetPartnerScopedConfig(e);
|
|
362
|
+
}
|
|
328
363
|
/**
|
|
329
364
|
* Gets the recommendation-id from a block node
|
|
330
365
|
*/
|
|
@@ -332,7 +367,7 @@ class j extends E {
|
|
|
332
367
|
const e = this._getBlockElement(t);
|
|
333
368
|
if (!e || !("getAttribute" in e))
|
|
334
369
|
return null;
|
|
335
|
-
const i = e.getAttribute(
|
|
370
|
+
const i = e.getAttribute(d);
|
|
336
371
|
if (!i)
|
|
337
372
|
return null;
|
|
338
373
|
const n = parseInt(i);
|
|
@@ -344,10 +379,10 @@ class j extends E {
|
|
|
344
379
|
_getBlockElement(t) {
|
|
345
380
|
if ("getAttribute" in t) {
|
|
346
381
|
const e = t.getAttribute("class");
|
|
347
|
-
if (e && e.includes(
|
|
382
|
+
if (e && e.includes(f))
|
|
348
383
|
return t;
|
|
349
384
|
}
|
|
350
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
385
|
+
return "querySelector" in t ? t.querySelector(`.${f}`) ?? null : null;
|
|
351
386
|
}
|
|
352
387
|
/**
|
|
353
388
|
* Migrate configuration from legacy format
|
|
@@ -357,6 +392,6 @@ class j extends E {
|
|
|
357
392
|
}
|
|
358
393
|
}
|
|
359
394
|
export {
|
|
360
|
-
|
|
361
|
-
|
|
395
|
+
y as BLOCK_ID,
|
|
396
|
+
at as RecommendationBlock
|
|
362
397
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (g,
|
|
4
|
-
import { useConfig as
|
|
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
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as N } from "../../../common-control.js";
|
|
7
7
|
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
8
|
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
-
import { RecommendationConfigService as
|
|
9
|
+
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
11
|
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
15
|
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
@@ -29,9 +29,9 @@ 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
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as
|
|
34
|
-
import { useDebounceFn as
|
|
32
|
+
import { setCurrencyAttributes as v, getBlockElement as A, isPartnerManagedBlock as B, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as vt, regenerateMobileProductRows as At, updatePricesInPlace as Bt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
@@ -58,7 +58,7 @@ class at extends N {
|
|
|
58
58
|
/**
|
|
59
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
60
|
*/
|
|
61
|
-
i(this, "_debouncedFetchProducts",
|
|
61
|
+
i(this, "_debouncedFetchProducts", f(async () => {
|
|
62
62
|
try {
|
|
63
63
|
await this.store.fetchRecommendationProducts();
|
|
64
64
|
} finally {
|
|
@@ -76,12 +76,12 @@ class at extends N {
|
|
|
76
76
|
* count. The store pads products to the configured size, so in-place only
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
|
-
i(this, "_debouncedRegenerateWithProducts",
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
80
80
|
const t = this.store.recommendationProducts;
|
|
81
81
|
if (!this.currentNode || !this.api)
|
|
82
82
|
return;
|
|
83
83
|
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
84
|
-
if (
|
|
84
|
+
if (B(this.currentNode)) {
|
|
85
85
|
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
@@ -115,7 +115,7 @@ class at extends N {
|
|
|
115
115
|
}
|
|
116
116
|
getTemplate() {
|
|
117
117
|
var t;
|
|
118
|
-
return this.rrsEnabled =
|
|
118
|
+
return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
119
119
|
var o;
|
|
120
120
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
121
121
|
}), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new k(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
|
|
@@ -140,7 +140,7 @@ class at extends N {
|
|
|
140
140
|
const e = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
141
141
|
if (!e)
|
|
142
142
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
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) >= _), s = this.rrsEnabled && !!o && !n;
|
|
144
144
|
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
145
145
|
}
|
|
146
146
|
async onRender() {
|
|
@@ -209,23 +209,30 @@ class at extends N {
|
|
|
209
209
|
const e = this.store.blockStates[t];
|
|
210
210
|
if (!e)
|
|
211
211
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
212
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
|
|
213
213
|
e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
214
|
}
|
|
215
215
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
216
|
_isPendingStrategyIdChange() {
|
|
217
217
|
const t = this.pendingNodeConfigWrite;
|
|
218
|
-
return t ?
|
|
218
|
+
return t ? c.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
219
219
|
}
|
|
220
220
|
_capturePendingNodeConfigWrite() {
|
|
221
221
|
const t = this.store.currentRecommendationId;
|
|
222
222
|
if (!this.currentNode || !this.api || t === null)
|
|
223
223
|
return;
|
|
224
|
-
const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs;
|
|
224
|
+
const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs, { partnerName: l } = h();
|
|
225
225
|
this.pendingNodeConfigWrite = {
|
|
226
226
|
blockId: t,
|
|
227
227
|
node: this.currentNode,
|
|
228
|
-
updates: {
|
|
228
|
+
updates: {
|
|
229
|
+
filters: e,
|
|
230
|
+
strategy: o,
|
|
231
|
+
strategyId: n,
|
|
232
|
+
size: s,
|
|
233
|
+
configVersion: r,
|
|
234
|
+
...l.value ? { partnerName: l.value } : {}
|
|
235
|
+
}
|
|
229
236
|
};
|
|
230
237
|
}
|
|
231
238
|
/**
|
|
@@ -240,7 +247,7 @@ class at extends N {
|
|
|
240
247
|
*/
|
|
241
248
|
_stagePendingNodeConfig(t) {
|
|
242
249
|
const e = this.pendingNodeConfigWrite;
|
|
243
|
-
return !e || !this.currentNode ? !1 : (
|
|
250
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
244
251
|
}
|
|
245
252
|
/**
|
|
246
253
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -264,12 +271,12 @@ class at extends N {
|
|
|
264
271
|
const t = this.pendingNodeConfigWrite;
|
|
265
272
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
266
273
|
return;
|
|
267
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
268
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size ||
|
|
274
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
275
|
+
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");
|
|
269
276
|
}
|
|
270
277
|
_syncNodeConfigToStore() {
|
|
271
278
|
var n;
|
|
272
|
-
const t =
|
|
279
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
273
280
|
this.store.patchCurrentBlockConfig({
|
|
274
281
|
strategy: t.strategy,
|
|
275
282
|
strategyId: t.strategyId,
|
|
@@ -334,12 +341,12 @@ class at extends N {
|
|
|
334
341
|
_applySmartDefaults() {
|
|
335
342
|
if (!this.currentNode || !this.api)
|
|
336
343
|
return;
|
|
337
|
-
const t =
|
|
344
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
338
345
|
let o = null, n = null, s = null;
|
|
339
346
|
if (t.currency.code === a.currency.code) {
|
|
340
347
|
const { currencyList: r } = this.store;
|
|
341
348
|
r.length > 0 && (r.some(
|
|
342
|
-
(
|
|
349
|
+
(d) => d.value === `price.${a.currency.code}`
|
|
343
350
|
) || (o = r[0].value.replace("price.", ""), e.currency = {
|
|
344
351
|
...a.currency,
|
|
345
352
|
code: o,
|
|
@@ -349,21 +356,21 @@ class at extends N {
|
|
|
349
356
|
if (t.strategy === a.strategy) {
|
|
350
357
|
const r = this.store.getActivePredictiveAlgorithms;
|
|
351
358
|
r.length > 0 && (r.some(
|
|
352
|
-
(
|
|
359
|
+
(d) => d.value === a.strategy
|
|
353
360
|
) || (n = r[0].value, e.strategy = n));
|
|
354
361
|
}
|
|
355
362
|
if (t.language === a.language) {
|
|
356
363
|
const r = this.store.getLanguages;
|
|
357
364
|
r.length > 0 && (r.some(
|
|
358
|
-
(
|
|
365
|
+
(d) => d.value === a.language
|
|
359
366
|
) || (s = r[0].value, e.language = s));
|
|
360
367
|
}
|
|
361
|
-
!o && !n && !s || (
|
|
368
|
+
!o && !n && !s || (c.updateConfig(
|
|
362
369
|
this.api,
|
|
363
370
|
this.currentNode,
|
|
364
371
|
e,
|
|
365
372
|
"Applied smart defaults"
|
|
366
|
-
), o && e.currency &&
|
|
373
|
+
), o && e.currency && v({
|
|
367
374
|
currentNode: this.currentNode,
|
|
368
375
|
documentModifier: this.api.getDocumentModifier(),
|
|
369
376
|
currency: e.currency
|
|
@@ -387,7 +394,7 @@ class at extends N {
|
|
|
387
394
|
* Reads the recommendation-id attribute from the block element within the node
|
|
388
395
|
*/
|
|
389
396
|
_getRecommendationIdFromNode(t) {
|
|
390
|
-
const e =
|
|
397
|
+
const e = A(t);
|
|
391
398
|
if (!e || !("getAttribute" in e))
|
|
392
399
|
return null;
|
|
393
400
|
const o = e.getAttribute(I);
|
|
@@ -420,13 +427,13 @@ class at extends N {
|
|
|
420
427
|
}
|
|
421
428
|
const r = t.$state.configVersion;
|
|
422
429
|
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
423
|
-
const
|
|
424
|
-
|
|
430
|
+
const l = t.recommendationProducts, d = l !== e, m = Array.isArray(l) && l.length > 0;
|
|
431
|
+
d && m && (e = l, this._debouncedRegenerateWithProducts());
|
|
425
432
|
});
|
|
426
433
|
}
|
|
427
434
|
}
|
|
428
435
|
export {
|
|
429
|
-
|
|
436
|
+
ut as ALGORITHM_CONTROL_ID,
|
|
430
437
|
T as AlgorithmControl,
|
|
431
438
|
W as CONTROL_BLOCK_ID,
|
|
432
439
|
gt as CURRENCY_CONTROL_ID,
|
|
@@ -450,15 +457,15 @@ export {
|
|
|
450
457
|
w as StrategyControl,
|
|
451
458
|
Et as adjustProductsToSize,
|
|
452
459
|
Ft as formatProductPrice,
|
|
453
|
-
|
|
460
|
+
A as getBlockElement,
|
|
454
461
|
Dt as getCardComposition,
|
|
455
462
|
wt as getCurrentLayout,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
463
|
+
vt as getMainContainerTbody,
|
|
464
|
+
B as isPartnerManagedBlock,
|
|
465
|
+
At as regenerateMobileProductRows,
|
|
459
466
|
U as regenerateProductRowsWithStyles,
|
|
460
|
-
|
|
461
|
-
|
|
467
|
+
v as setCurrencyAttributes,
|
|
468
|
+
Bt as updatePricesInPlace,
|
|
462
469
|
x as updateProductContentInPlace,
|
|
463
470
|
xt as updateSingleProductContent
|
|
464
471
|
};
|