@useinsider/guido 3.19.0-beta.169cb33 → 3.19.0-beta.173cb77
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/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +96 -85
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/itemsBlockMigrator.js +236 -248
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/block.js +51 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +117 -93
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +132 -99
- package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +46 -25
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +40 -17
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +18 -5
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/templatePreparation.js +61 -85
- package/package.json +2 -2
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var b = (a, l, t) => l in a ? B(a, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[l] = t;
|
|
3
|
+
var d = (a, l, t) => b(a, typeof l != "symbol" ? l + "" : l, t);
|
|
4
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as C } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as A } from "../../../utils/migrationBannerHtml.js";
|
|
7
7
|
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as w } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
10
|
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
|
-
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as
|
|
11
|
+
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as O } 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 h } from "./store/recommendation.js";
|
|
14
|
+
import { getDefaultTemplate as x } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as T } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
import { registerNodeConfigWriter as H } from "./utils/nodeConfigWriter.js";
|
|
17
|
+
import { refreshDuplicatedStrategyBlocks as $ } from "./utils/strategyCommit.js";
|
|
18
|
+
const k = C.Recommendation, u = "recommendation-block-v2", D = "hide-price";
|
|
19
|
+
let y = !1;
|
|
20
|
+
class Y extends E {
|
|
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
|
+
d(this, "_pendingBlockId", null);
|
|
26
28
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
27
|
-
|
|
29
|
+
d(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
30
|
+
/** Ids handed to duplicates the document root does not show yet: a copied module renames all its blocks at once. */
|
|
31
|
+
d(this, "_unsettledDuplicateIds", /* @__PURE__ */ new Set());
|
|
28
32
|
}
|
|
29
33
|
getId() {
|
|
30
34
|
return k;
|
|
@@ -44,7 +48,7 @@ class j extends E {
|
|
|
44
48
|
);
|
|
45
49
|
}
|
|
46
50
|
getSettingsPanelTitleHtml() {
|
|
47
|
-
return
|
|
51
|
+
return A(
|
|
48
52
|
k,
|
|
49
53
|
this.api.translate("Recommendation Block"),
|
|
50
54
|
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.")
|
|
@@ -68,7 +72,7 @@ class j extends E {
|
|
|
68
72
|
*/
|
|
69
73
|
getTemplate() {
|
|
70
74
|
const t = this._generateNextId();
|
|
71
|
-
return this._pendingBlockId = t,
|
|
75
|
+
return this._pendingBlockId = t, x(t);
|
|
72
76
|
}
|
|
73
77
|
/**
|
|
74
78
|
* Called when a new block is dropped into the template
|
|
@@ -91,19 +95,20 @@ class j extends E {
|
|
|
91
95
|
}
|
|
92
96
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
93
97
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
94
|
-
const n =
|
|
98
|
+
const n = g().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: c } = s.initializeConfig(
|
|
95
99
|
this.api,
|
|
96
100
|
t,
|
|
97
101
|
{
|
|
98
102
|
recommendationId: i,
|
|
99
|
-
configVersion: n ? N :
|
|
103
|
+
configVersion: n ? N : w,
|
|
104
|
+
...o ? { partnerName: g().partnerName.value } : {},
|
|
100
105
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
101
106
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
102
107
|
// at save for a block the user never configured.
|
|
103
108
|
...o ? { strategy: "" } : {}
|
|
104
109
|
}
|
|
105
|
-
), f =
|
|
106
|
-
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted),
|
|
110
|
+
), f = h();
|
|
111
|
+
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), c) {
|
|
107
112
|
I(this.api);
|
|
108
113
|
const _ = this._getBlockElement(t);
|
|
109
114
|
_ && (R(this.api, _, !0), M({
|
|
@@ -133,11 +138,11 @@ class j extends E {
|
|
|
133
138
|
}
|
|
134
139
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
135
140
|
try {
|
|
136
|
-
|
|
141
|
+
y || (I(this.api), y = !0);
|
|
137
142
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
138
143
|
if (i) {
|
|
139
144
|
const n = !e.mobileLayoutEnabled;
|
|
140
|
-
|
|
145
|
+
O(i) !== n && R(this.api, i, n);
|
|
141
146
|
}
|
|
142
147
|
} catch {
|
|
143
148
|
}
|
|
@@ -151,7 +156,7 @@ class j extends E {
|
|
|
151
156
|
*/
|
|
152
157
|
onDelete(t) {
|
|
153
158
|
const e = this._getRecommendationId(t);
|
|
154
|
-
e &&
|
|
159
|
+
e && h().removeBlockState(e);
|
|
155
160
|
}
|
|
156
161
|
/**
|
|
157
162
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -167,7 +172,7 @@ class j extends E {
|
|
|
167
172
|
*/
|
|
168
173
|
_warnIfMultipleBlocks() {
|
|
169
174
|
try {
|
|
170
|
-
|
|
175
|
+
T().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
171
176
|
} catch {
|
|
172
177
|
}
|
|
173
178
|
}
|
|
@@ -177,17 +182,20 @@ class j extends E {
|
|
|
177
182
|
*/
|
|
178
183
|
_generateNextId() {
|
|
179
184
|
let t = 0;
|
|
185
|
+
const e = /* @__PURE__ */ new Set();
|
|
180
186
|
try {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
if ("getAttribute" in
|
|
184
|
-
const
|
|
185
|
-
|
|
187
|
+
const i = this.api.getDocumentRoot();
|
|
188
|
+
i && "querySelectorAll" in i && i.querySelectorAll(`.${u}`).forEach((o) => {
|
|
189
|
+
if ("getAttribute" in o) {
|
|
190
|
+
const r = o.getAttribute(m), c = r ? parseInt(r) : 0;
|
|
191
|
+
e.add(c), c > t && (t = c);
|
|
186
192
|
}
|
|
187
193
|
});
|
|
188
194
|
} catch {
|
|
189
195
|
}
|
|
190
|
-
return
|
|
196
|
+
return this._unsettledDuplicateIds.forEach((i) => {
|
|
197
|
+
e.has(i) && this._unsettledDuplicateIds.delete(i);
|
|
198
|
+
}), Math.max(t, ...this._unsettledDuplicateIds) + 1;
|
|
191
199
|
}
|
|
192
200
|
/**
|
|
193
201
|
* Drops the "already fetched" claims of a block that arrived holding a baked id
|
|
@@ -197,9 +205,9 @@ class j extends E {
|
|
|
197
205
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
198
206
|
*/
|
|
199
207
|
_scheduleArrivalReset(t) {
|
|
200
|
-
|
|
208
|
+
g().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
201
209
|
const e = this._getRecommendationId(t);
|
|
202
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
210
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && h().resetArrivedBlock(e);
|
|
203
211
|
}, 0);
|
|
204
212
|
}
|
|
205
213
|
/**
|
|
@@ -230,9 +238,9 @@ class j extends E {
|
|
|
230
238
|
if (!o)
|
|
231
239
|
return;
|
|
232
240
|
let r = -1;
|
|
233
|
-
for (let
|
|
234
|
-
if (n[
|
|
235
|
-
r =
|
|
241
|
+
for (let c = 0; c < n.length; c++)
|
|
242
|
+
if (n[c] === o) {
|
|
243
|
+
r = c;
|
|
236
244
|
break;
|
|
237
245
|
}
|
|
238
246
|
if (r <= 0)
|
|
@@ -255,8 +263,8 @@ class j extends E {
|
|
|
255
263
|
}
|
|
256
264
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
257
265
|
_handleDuplicate(t, e) {
|
|
258
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
259
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i),
|
|
266
|
+
const i = this._reassignDuplicateId(t, e), n = h();
|
|
267
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), g().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), H(this.api), $(e, i, s.getConfig(t)).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o))), this._warnIfMultipleBlocks();
|
|
260
268
|
}
|
|
261
269
|
/**
|
|
262
270
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -271,7 +279,7 @@ class j extends E {
|
|
|
271
279
|
*/
|
|
272
280
|
_reassignDuplicateId(t, e) {
|
|
273
281
|
const i = this._generateNextId(), n = this._getBlockElement(t);
|
|
274
|
-
return this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), s.hasConfig(t) && s.updateConfig(
|
|
282
|
+
return this._unsettledDuplicateIds.add(i), this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), s.hasConfig(t) && s.updateConfig(
|
|
275
283
|
this.api,
|
|
276
284
|
t,
|
|
277
285
|
{ recommendationId: i },
|
|
@@ -312,7 +320,7 @@ class j extends E {
|
|
|
312
320
|
*/
|
|
313
321
|
_stampHidePrice(t, e) {
|
|
314
322
|
const i = this._getBlockElement(t);
|
|
315
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
323
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(D, String(e)).apply(new p("Stamp hide-price"));
|
|
316
324
|
}
|
|
317
325
|
/**
|
|
318
326
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -320,7 +328,7 @@ class j extends E {
|
|
|
320
328
|
*/
|
|
321
329
|
_healHidePriceAttr(t) {
|
|
322
330
|
const e = this._getBlockElement(t);
|
|
323
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
331
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(D) !== null)
|
|
324
332
|
return;
|
|
325
333
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
326
334
|
this._stampHidePrice(t, i);
|
|
@@ -358,5 +366,5 @@ class j extends E {
|
|
|
358
366
|
}
|
|
359
367
|
export {
|
|
360
368
|
k as BLOCK_ID,
|
|
361
|
-
|
|
369
|
+
Y as RecommendationBlock
|
|
362
370
|
};
|
|
@@ -1,37 +1,37 @@
|
|
|
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
|
-
import { AlgorithmControl as
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
14
|
-
import { CurrencyControl as
|
|
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
15
|
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
17
|
import { FILTERS_CONTROL_ID as ft } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
|
-
import { LocaleControl as
|
|
20
|
+
import { LocaleControl as k } from "./locale.js";
|
|
21
21
|
import { LOCALE_CONTROL_ID as yt } from "./locale.js";
|
|
22
|
-
import { PricePlacementControl as
|
|
22
|
+
import { PricePlacementControl as L } from "./pricePlacement.js";
|
|
23
23
|
import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
|
|
24
24
|
import { ProductCountControl as E } from "./productCount.js";
|
|
25
25
|
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
26
|
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
27
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Pt } from "./productLayout.js";
|
|
28
28
|
import { ShuffleControl as D } from "./shuffle.js";
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
|
-
import { StrategyControl as
|
|
31
|
-
import { STRATEGY_CONTROL_ID as
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as
|
|
34
|
-
import { useDebounceFn as
|
|
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
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,24 +76,22 @@ 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",
|
|
80
|
-
const t = this.store.recommendationProducts;
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
81
80
|
if (!this.currentNode || !this.api)
|
|
82
81
|
return;
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
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();
|
|
86
85
|
return;
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
87
|
+
if (this.store.blockStates[t].recommendationProducts.length) {
|
|
88
|
+
this.store.setCurrentBlock(t);
|
|
89
|
+
try {
|
|
90
|
+
this._regenerateWithProducts();
|
|
91
|
+
} finally {
|
|
92
|
+
this.store.setCurrentBlock(e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
97
95
|
}, 100));
|
|
98
96
|
}
|
|
99
97
|
getId() {
|
|
@@ -115,10 +113,10 @@ class at extends N {
|
|
|
115
113
|
}
|
|
116
114
|
getTemplate() {
|
|
117
115
|
var t;
|
|
118
|
-
return this.rrsEnabled =
|
|
116
|
+
return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
119
117
|
var o;
|
|
120
118
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
121
|
-
}), this.algorithmControl = new
|
|
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) => {
|
|
122
120
|
e && (e.api = this.api);
|
|
123
121
|
}), `
|
|
124
122
|
<div class="recommendation-controls-container">
|
|
@@ -136,12 +134,12 @@ class at extends N {
|
|
|
136
134
|
`;
|
|
137
135
|
}
|
|
138
136
|
_showControlsForBlock(t) {
|
|
139
|
-
var
|
|
140
|
-
const e = (
|
|
137
|
+
var n;
|
|
138
|
+
const e = (n = this.getContainer()) == null ? void 0 : n.querySelector(".recommendation-controls-container");
|
|
141
139
|
if (!e)
|
|
142
140
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
144
|
-
e.classList.toggle("strategy-block",
|
|
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);
|
|
145
143
|
}
|
|
146
144
|
async onRender() {
|
|
147
145
|
var o;
|
|
@@ -159,9 +157,9 @@ class at extends N {
|
|
|
159
157
|
const e = this._getRecommendationIdFromNode(t);
|
|
160
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(() => {
|
|
161
159
|
this._initializeSubControls();
|
|
162
|
-
}), this._subControls.forEach((
|
|
160
|
+
}), this._subControls.forEach((r) => {
|
|
163
161
|
var s;
|
|
164
|
-
|
|
162
|
+
r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
|
|
165
163
|
});
|
|
166
164
|
}
|
|
167
165
|
onDestroy() {
|
|
@@ -209,23 +207,30 @@ class at extends N {
|
|
|
209
207
|
const e = this.store.blockStates[t];
|
|
210
208
|
if (!e)
|
|
211
209
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
213
|
-
e.syncedConfigFingerprint = o,
|
|
210
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
|
|
211
|
+
e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
212
|
}
|
|
215
213
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
214
|
_isPendingStrategyIdChange() {
|
|
217
215
|
const t = this.pendingNodeConfigWrite;
|
|
218
|
-
return t ?
|
|
216
|
+
return t ? c.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
219
217
|
}
|
|
220
218
|
_capturePendingNodeConfigWrite() {
|
|
221
219
|
const t = this.store.currentRecommendationId;
|
|
222
220
|
if (!this.currentNode || !this.api || t === null)
|
|
223
221
|
return;
|
|
224
|
-
const { filters: e, strategy: o, strategyId:
|
|
222
|
+
const { filters: e, strategy: o, strategyId: r, size: s, nodeConfigVersion: n } = this.store.recommendationConfigs, { partnerName: l } = h();
|
|
225
223
|
this.pendingNodeConfigWrite = {
|
|
226
224
|
blockId: t,
|
|
227
225
|
node: this.currentNode,
|
|
228
|
-
updates: {
|
|
226
|
+
updates: {
|
|
227
|
+
filters: e,
|
|
228
|
+
strategy: o,
|
|
229
|
+
strategyId: r,
|
|
230
|
+
size: s,
|
|
231
|
+
configVersion: n,
|
|
232
|
+
...l.value ? { partnerName: l.value } : {}
|
|
233
|
+
}
|
|
229
234
|
};
|
|
230
235
|
}
|
|
231
236
|
/**
|
|
@@ -240,7 +245,7 @@ class at extends N {
|
|
|
240
245
|
*/
|
|
241
246
|
_stagePendingNodeConfig(t) {
|
|
242
247
|
const e = this.pendingNodeConfigWrite;
|
|
243
|
-
return !e || !this.currentNode ? !1 : (
|
|
248
|
+
return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
|
|
244
249
|
}
|
|
245
250
|
/**
|
|
246
251
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -264,12 +269,12 @@ class at extends N {
|
|
|
264
269
|
const t = this.pendingNodeConfigWrite;
|
|
265
270
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
266
271
|
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 ||
|
|
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");
|
|
269
274
|
}
|
|
270
275
|
_syncNodeConfigToStore() {
|
|
271
|
-
var
|
|
272
|
-
const t =
|
|
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);
|
|
273
278
|
this.store.patchCurrentBlockConfig({
|
|
274
279
|
strategy: t.strategy,
|
|
275
280
|
strategyId: t.strategyId,
|
|
@@ -312,8 +317,8 @@ class at extends N {
|
|
|
312
317
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
313
318
|
this.store.fetchRecommendationCreateData(),
|
|
314
319
|
this.store.fetchRecommendationFilters()
|
|
315
|
-
])).forEach((o,
|
|
316
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
320
|
+
])).forEach((o, r) => {
|
|
321
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
|
|
317
322
|
}), this._applySmartDefaults();
|
|
318
323
|
try {
|
|
319
324
|
await this.store.fetchRecommendationProducts();
|
|
@@ -334,36 +339,36 @@ class at extends N {
|
|
|
334
339
|
_applySmartDefaults() {
|
|
335
340
|
if (!this.currentNode || !this.api)
|
|
336
341
|
return;
|
|
337
|
-
const t =
|
|
338
|
-
let o = null,
|
|
342
|
+
const t = c.getConfig(this.currentNode), e = {};
|
|
343
|
+
let o = null, r = null, s = null;
|
|
339
344
|
if (t.currency.code === a.currency.code) {
|
|
340
|
-
const { currencyList:
|
|
341
|
-
|
|
342
|
-
(
|
|
343
|
-
) || (o =
|
|
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 = {
|
|
344
349
|
...a.currency,
|
|
345
350
|
code: o,
|
|
346
351
|
symbol: o
|
|
347
352
|
}));
|
|
348
353
|
}
|
|
349
354
|
if (t.strategy === a.strategy) {
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
(
|
|
353
|
-
) || (
|
|
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));
|
|
354
359
|
}
|
|
355
360
|
if (t.language === a.language) {
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
(
|
|
359
|
-
) || (s =
|
|
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));
|
|
360
365
|
}
|
|
361
|
-
!o && !
|
|
366
|
+
!o && !r && !s || (c.updateConfig(
|
|
362
367
|
this.api,
|
|
363
368
|
this.currentNode,
|
|
364
369
|
e,
|
|
365
370
|
"Applied smart defaults"
|
|
366
|
-
), o && e.currency &&
|
|
371
|
+
), o && e.currency && w({
|
|
367
372
|
currentNode: this.currentNode,
|
|
368
373
|
documentModifier: this.api.getDocumentModifier(),
|
|
369
374
|
currency: e.currency
|
|
@@ -379,7 +384,7 @@ class at extends N {
|
|
|
379
384
|
thousandSeparator: a.currency.thousandSeparator
|
|
380
385
|
}
|
|
381
386
|
} : {},
|
|
382
|
-
...
|
|
387
|
+
...r ? { strategy: r } : {},
|
|
383
388
|
...s ? { language: s } : {}
|
|
384
389
|
}, { triggerRefetch: !1 }));
|
|
385
390
|
}
|
|
@@ -387,14 +392,33 @@ class at extends N {
|
|
|
387
392
|
* Reads the recommendation-id attribute from the block element within the node
|
|
388
393
|
*/
|
|
389
394
|
_getRecommendationIdFromNode(t) {
|
|
390
|
-
const e =
|
|
395
|
+
const e = v(t);
|
|
391
396
|
if (!e || !("getAttribute" in e))
|
|
392
397
|
return null;
|
|
393
398
|
const o = e.getAttribute(I);
|
|
394
399
|
if (!o)
|
|
395
400
|
return null;
|
|
396
|
-
const
|
|
397
|
-
return Number.isNaN(
|
|
401
|
+
const r = parseInt(o);
|
|
402
|
+
return Number.isNaN(r) ? null : r;
|
|
403
|
+
}
|
|
404
|
+
/** Draws the current block's products into this panel's node. */
|
|
405
|
+
_regenerateWithProducts() {
|
|
406
|
+
if (!this.currentNode || !this.api)
|
|
407
|
+
return;
|
|
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());
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
x({
|
|
414
|
+
currentNode: this.currentNode,
|
|
415
|
+
documentModifier: e,
|
|
416
|
+
products: t
|
|
417
|
+
}) || U({
|
|
418
|
+
currentNode: this.currentNode,
|
|
419
|
+
documentModifier: e,
|
|
420
|
+
products: t
|
|
421
|
+
});
|
|
398
422
|
}
|
|
399
423
|
/**
|
|
400
424
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -411,54 +435,54 @@ class at extends N {
|
|
|
411
435
|
*/
|
|
412
436
|
_listenStateUpdates() {
|
|
413
437
|
const { store: t } = this;
|
|
414
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
438
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
|
|
415
439
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
416
440
|
const s = t.currentRecommendationId;
|
|
417
|
-
if (s !==
|
|
418
|
-
|
|
441
|
+
if (s !== r) {
|
|
442
|
+
r = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
419
443
|
return;
|
|
420
444
|
}
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
|
|
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());
|
|
425
449
|
});
|
|
426
450
|
}
|
|
427
451
|
}
|
|
428
452
|
export {
|
|
429
|
-
|
|
430
|
-
|
|
453
|
+
ut as ALGORITHM_CONTROL_ID,
|
|
454
|
+
P as AlgorithmControl,
|
|
431
455
|
W as CONTROL_BLOCK_ID,
|
|
432
456
|
gt as CURRENCY_CONTROL_ID,
|
|
433
|
-
|
|
457
|
+
T as CurrencyControl,
|
|
434
458
|
ft as FILTERS_CONTROL_ID,
|
|
435
459
|
S as FiltersControl,
|
|
436
460
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
437
461
|
yt as LOCALE_CONTROL_ID,
|
|
438
462
|
O as LayoutOrientationControl,
|
|
439
|
-
|
|
463
|
+
k as LocaleControl,
|
|
440
464
|
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
441
465
|
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
442
|
-
|
|
443
|
-
|
|
466
|
+
Pt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
467
|
+
L as PricePlacementControl,
|
|
444
468
|
E as ProductCountControl,
|
|
445
469
|
F as ProductLayoutControl,
|
|
446
470
|
at as RecommendationBlockControl,
|
|
447
471
|
St as SHUFFLE_CONTROL_ID,
|
|
448
|
-
|
|
472
|
+
kt as STRATEGY_CONTROL_ID,
|
|
449
473
|
D as ShuffleControl,
|
|
450
|
-
|
|
474
|
+
B as StrategyControl,
|
|
451
475
|
Et as adjustProductsToSize,
|
|
452
476
|
Ft as formatProductPrice,
|
|
453
|
-
|
|
477
|
+
v as getBlockElement,
|
|
454
478
|
Dt as getCardComposition,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
479
|
+
Bt as getCurrentLayout,
|
|
480
|
+
wt as getMainContainerTbody,
|
|
481
|
+
A as isPartnerManagedBlock,
|
|
482
|
+
vt as regenerateMobileProductRows,
|
|
459
483
|
U as regenerateProductRowsWithStyles,
|
|
460
|
-
|
|
461
|
-
|
|
484
|
+
w as setCurrencyAttributes,
|
|
485
|
+
At as updatePricesInPlace,
|
|
462
486
|
x as updateProductContentInPlace,
|
|
463
487
|
xt as updateSingleProductContent
|
|
464
488
|
};
|