@useinsider/guido 3.24.0 → 3.25.0-beta.0d90126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/@types/config/schemas.js +19 -15
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +79 -77
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useModuleRepair.js +14 -12
- package/dist/composables/useSave.js +57 -52
- package/dist/composables/useSaveValidation.js +118 -110
- package/dist/composables/useStripo.js +70 -70
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/config/migrator/index.js +16 -15
- package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
- package/dist/enums/save-validation.js +1 -1
- package/dist/extensions/Blocks/Items/block.js +115 -77
- package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
- package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/extension.js +15 -13
- package/dist/extensions/Blocks/Items/items.css.js +19 -0
- package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
- package/dist/extensions/Blocks/Items/template.js +250 -212
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
- package/dist/extensions/Blocks/controlFactories.js +104 -104
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useSaveValidation.d.ts +1 -1
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
- package/dist/src/config/migrator/index.d.ts +4 -1
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
- package/dist/src/enums/save-validation.d.ts +2 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
- package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
- package/dist/src/stores/config.d.ts +40 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
- package/dist/src/utils/linkTrackingIds.d.ts +19 -0
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/utils/itemsCurrencyRepair.js +29 -24
- package/dist/utils/linkTrackingIds.js +82 -48
- package/dist/utils/pairProductVariables.js +119 -99
- package/dist/utils/templatePreparation.js +30 -33
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { formatNumber as w } from "../../Recommendation/utils/priceFormatter.js";
|
|
2
|
+
import { escapeHtml as q } from "../../../../utils/htmlEscape.js";
|
|
3
|
+
import { extractWrapperTags as B } from "../../../../utils/preserveTextStyles.js";
|
|
4
|
+
import { ITEMS_PRICE_FORMAT_ATTR as c, priceFormatFromConfig as _, normalizeDecimalCount as V, LEGACY_PRICE_PARAGRAPH_ATTRS as O, ITEMS_CURRENCY_ATTR as b } from "../constants/currency.js";
|
|
5
|
+
import { productPairs as W } from "../enums/productEnums.js";
|
|
6
|
+
import { DefaultConfigValues as I } from "../enums/settingsEnums.js";
|
|
7
|
+
import { escapeReplacement as z } from "./nodeConfigUtils.js";
|
|
8
|
+
const J = 'p[product-attr="price"], p[product-attr="originalPrice"]', K = [
|
|
9
|
+
...Object.values(c),
|
|
10
|
+
"data-type"
|
|
11
|
+
], L = "CART_ITEMS";
|
|
12
|
+
function X() {
|
|
13
|
+
return { rootSet: {}, paragraphRemove: [], configPatch: null, texts: null, changed: !1 };
|
|
14
|
+
}
|
|
15
|
+
function h(t) {
|
|
16
|
+
return t != null;
|
|
17
|
+
}
|
|
18
|
+
function Pt(t) {
|
|
19
|
+
return t === "price" || t === "originalPrice" ? t : null;
|
|
20
|
+
}
|
|
21
|
+
function N(t) {
|
|
22
|
+
const n = W.PAIRS_FOR_EXTENSION, r = t != null && t.type && t.type in n.price ? t.type : L, o = (t == null ? void 0 : t.priceSinglePrice) === !0, e = n.price[r], i = n.originalPrice[r];
|
|
23
|
+
return {
|
|
24
|
+
price: o ? e.DEFAULT_SINGLE_PRICE : e.DEFAULT_PRICE,
|
|
25
|
+
originalPrice: o ? i.DEFAULT_SINGLE_PRICE : i.DEFAULT_PRICE
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function P({ amount: t, format: n, symbol: r, alignment: o }) {
|
|
29
|
+
const e = w(Number(t), n), i = q((r ?? "").trim());
|
|
30
|
+
return i ? o === "1" ? `${e} ${i}` : `${i} ${e}` : e;
|
|
31
|
+
}
|
|
32
|
+
function Tt(t) {
|
|
33
|
+
const n = N(t), r = {
|
|
34
|
+
format: _(t),
|
|
35
|
+
symbol: (t == null ? void 0 : t.priceCurrencySymbol) ?? I.productPriceCurrencySymbolControlValue,
|
|
36
|
+
alignment: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0"
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
price: P({ amount: n.price, ...r }),
|
|
40
|
+
originalPrice: P({ amount: n.originalPrice, ...r })
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const x = / |\u00a0|\s+/g, Q = "(?: | |\\s)+", Z = /&(amp|lt|gt|quot|#x27|#39);/g, tt = { amp: "&", lt: "<", gt: ">", quot: '"', "#x27": "'", "#39": "'" }, rt = {
|
|
44
|
+
"&": "(?:&|&)",
|
|
45
|
+
"<": "(?:<|<)",
|
|
46
|
+
">": "(?:>|>)",
|
|
47
|
+
'"': '(?:"|")',
|
|
48
|
+
"'": "(?:'|'|')"
|
|
49
|
+
}, et = (t) => t.replace(Z, (n, r) => tt[r]), nt = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
50
|
+
function ot(t) {
|
|
51
|
+
return Array.from(t, (n) => rt[n] ?? nt(n)).join("");
|
|
52
|
+
}
|
|
53
|
+
function D(t, n) {
|
|
54
|
+
const r = (o) => o.replace(x, " ").trim();
|
|
55
|
+
return r(t ?? "") === r(et(n ?? ""));
|
|
56
|
+
}
|
|
57
|
+
function it(t, n, r) {
|
|
58
|
+
const o = t.trim(), e = n.trim().split(x).filter(Boolean), i = e.length ? new RegExp(e.map(ot).join(Q)) : null;
|
|
59
|
+
if (i != null && i.test(o))
|
|
60
|
+
return o.replace(i, z(r));
|
|
61
|
+
const { openTags: s, closeTags: u } = B(o);
|
|
62
|
+
return `${s}${r}${u}`;
|
|
63
|
+
}
|
|
64
|
+
function ct(t, n) {
|
|
65
|
+
if (!t)
|
|
66
|
+
return null;
|
|
67
|
+
const r = Object.fromEntries(
|
|
68
|
+
Object.entries(n).filter(([o, e]) => t[o] !== e)
|
|
69
|
+
);
|
|
70
|
+
return Object.keys(r).length > 0 ? r : null;
|
|
71
|
+
}
|
|
72
|
+
function Ct(t, { convertLegacy: n }) {
|
|
73
|
+
const { rootAttrs: r, paragraphs: o, config: e } = t, i = h(r[c.DECIMAL_COUNT]);
|
|
74
|
+
if (!i && !n)
|
|
75
|
+
return X();
|
|
76
|
+
const s = o.find((a) => a.kind === "price") ?? o[0], u = (a) => (s == null ? void 0 : s.attrs[a]) ?? null, l = i ? r[c.SINGLE_PRICE] : u("data-single_price"), m = typeof (e == null ? void 0 : e.priceSinglePrice) == "boolean" ? e.priceSinglePrice : l === "true", A = e == null ? void 0 : e.priceCurrencyLocation, j = u(b.POSITION) === "after" ? "1" : "0", H = i ? r[c.ALIGNMENT] : j, E = (typeof A == "string" && A.trim() !== "" ? A : H) === "1" ? "1" : "0", U = i ? r[c.SYMBOL] : u(b.SYMBOL), S = typeof (e == null ? void 0 : e.priceCurrencySymbol) == "string" ? e.priceCurrencySymbol : U ?? I.productPriceCurrencySymbolControlValue, p = _({
|
|
77
|
+
priceThousandSeparator: (e == null ? void 0 : e.priceThousandSeparator) ?? (i ? r[c.THOUSAND_SEPARATOR] ?? void 0 : void 0),
|
|
78
|
+
priceDecimalSeparator: (e == null ? void 0 : e.priceDecimalSeparator) ?? (i ? r[c.DECIMAL_SEPARATOR] ?? void 0 : void 0),
|
|
79
|
+
priceDecimalCount: (e == null ? void 0 : e.priceDecimalCount) ?? (i ? V(r[c.DECIMAL_COUNT]) : void 0)
|
|
80
|
+
}), G = {
|
|
81
|
+
[c.SYMBOL]: S.trim(),
|
|
82
|
+
[c.ALIGNMENT]: E,
|
|
83
|
+
[c.THOUSAND_SEPARATOR]: p.thousandSeparator,
|
|
84
|
+
[c.DECIMAL_SEPARATOR]: p.decimalSeparator,
|
|
85
|
+
[c.DECIMAL_COUNT]: String(p.decimalCount),
|
|
86
|
+
[c.SINGLE_PRICE]: m ? "true" : "false"
|
|
87
|
+
}, T = Object.fromEntries(
|
|
88
|
+
Object.entries(G).filter(([a, d]) => r[a] !== d)
|
|
89
|
+
), C = O.filter(
|
|
90
|
+
(a) => o.some((d) => h(d.attrs[a]))
|
|
91
|
+
), $ = {
|
|
92
|
+
priceThousandSeparator: p.thousandSeparator,
|
|
93
|
+
priceDecimalSeparator: p.decimalSeparator,
|
|
94
|
+
priceDecimalCount: p.decimalCount,
|
|
95
|
+
priceSinglePrice: m,
|
|
96
|
+
priceCurrencyLocation: E,
|
|
97
|
+
priceCurrencySymbol: S
|
|
98
|
+
}, f = ct(e, $), k = (e == null ? void 0 : e.type) ?? r["data-type"] ?? L, R = N({ type: k, priceSinglePrice: m }), y = (a) => P({ amount: a, format: p, symbol: S, alignment: E }), g = { price: y(R.price), originalPrice: y(R.originalPrice) }, Y = o.some((a) => !D(a.text, g[a.kind]));
|
|
99
|
+
return {
|
|
100
|
+
rootSet: T,
|
|
101
|
+
paragraphRemove: C,
|
|
102
|
+
configPatch: f,
|
|
103
|
+
texts: g,
|
|
104
|
+
changed: Object.keys(T).length > 0 || C.length > 0 || f !== null || Y
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function at(t) {
|
|
108
|
+
const n = {};
|
|
109
|
+
return K.forEach((r) => {
|
|
110
|
+
n[r] = t.rootAttr(r) ?? null;
|
|
111
|
+
}), {
|
|
112
|
+
rootAttrs: n,
|
|
113
|
+
config: t.config,
|
|
114
|
+
paragraphs: t.paragraphs.map((r) => {
|
|
115
|
+
const o = {};
|
|
116
|
+
return O.forEach((e) => {
|
|
117
|
+
o[e] = r.attr(e) ?? null;
|
|
118
|
+
}), { kind: r.kind, attrs: o, text: r.text.trim() };
|
|
119
|
+
})
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function M(t) {
|
|
123
|
+
const n = t.getAttribute("esd-ext-config");
|
|
124
|
+
if (!n)
|
|
125
|
+
return null;
|
|
126
|
+
try {
|
|
127
|
+
const r = JSON.parse(n);
|
|
128
|
+
return r && typeof r == "object" ? r : null;
|
|
129
|
+
} catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function F(t) {
|
|
134
|
+
return Array.from(t.querySelectorAll(J)).map((n) => ({
|
|
135
|
+
kind: n.getAttribute("product-attr"),
|
|
136
|
+
element: n
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
function v(t) {
|
|
140
|
+
return t.textContent;
|
|
141
|
+
}
|
|
142
|
+
function ft(t) {
|
|
143
|
+
return at({
|
|
144
|
+
rootAttr: (n) => t.getAttribute(n),
|
|
145
|
+
config: M(t),
|
|
146
|
+
paragraphs: F(t).map(({ kind: n, element: r }) => ({
|
|
147
|
+
kind: n,
|
|
148
|
+
attr: (o) => r.getAttribute(o),
|
|
149
|
+
text: v(r)
|
|
150
|
+
}))
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function Rt(t, n) {
|
|
154
|
+
if (!n.changed)
|
|
155
|
+
return !1;
|
|
156
|
+
let r = !1;
|
|
157
|
+
if (Object.entries(n.rootSet).forEach(([o, e]) => {
|
|
158
|
+
t.getAttribute(o) !== e && (t.setAttribute(o, e), r = !0);
|
|
159
|
+
}), F(t).forEach(({ kind: o, element: e }) => {
|
|
160
|
+
var u;
|
|
161
|
+
n.paragraphRemove.forEach((l) => {
|
|
162
|
+
e.hasAttribute(l) && (e.removeAttribute(l), r = !0);
|
|
163
|
+
});
|
|
164
|
+
const i = (u = n.texts) == null ? void 0 : u[o], s = v(e).trim();
|
|
165
|
+
i !== void 0 && !D(s, i) && (e.innerHTML = it(e.innerHTML, s, i), r = !0);
|
|
166
|
+
}), n.configPatch) {
|
|
167
|
+
const o = M(t);
|
|
168
|
+
o && (t.setAttribute("esd-ext-config", JSON.stringify({ ...o, ...n.configPatch })), r = !0);
|
|
169
|
+
}
|
|
170
|
+
return r;
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
J as PRICE_PARAGRAPH_SELECTOR,
|
|
174
|
+
Rt as applyPriceFormatOpsToElement,
|
|
175
|
+
at as buildPriceFormatSnapshot,
|
|
176
|
+
P as formatItemsDummyPrice,
|
|
177
|
+
Pt as paragraphKindOf,
|
|
178
|
+
Ct as planPriceFormatOps,
|
|
179
|
+
Tt as priceTextsFromConfig,
|
|
180
|
+
M as readPersistedConfigAttribute,
|
|
181
|
+
it as replacePriceText,
|
|
182
|
+
N as resolvePriceDummyAmounts,
|
|
183
|
+
D as samePriceText,
|
|
184
|
+
ft as snapshotPriceFormatFromElement
|
|
185
|
+
};
|
|
@@ -17,9 +17,9 @@ import { CurrencyControl as U } from "./currency.js";
|
|
|
17
17
|
import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
|
|
18
18
|
import { FiltersControl as v } from "./filters.js";
|
|
19
19
|
import { FILTERS_CONTROL_ID as ke } from "./filters.js";
|
|
20
|
-
import { LayoutOrientationControl as
|
|
20
|
+
import { LayoutOrientationControl as w } from "./layoutOrientation.js";
|
|
21
21
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } from "./layoutOrientation.js";
|
|
22
|
-
import { LocaleControl as
|
|
22
|
+
import { LocaleControl as A } from "./locale.js";
|
|
23
23
|
import { LOCALE_CONTROL_ID as Be } from "./locale.js";
|
|
24
24
|
import { PricePlacementControl as V } from "./pricePlacement.js";
|
|
25
25
|
import { PRICE_PLACEMENT_CONTROL_ID as Le } from "./pricePlacement.js";
|
|
@@ -28,7 +28,7 @@ import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
|
|
|
28
28
|
import { ProductLayoutControl as x } from "./productLayout.js";
|
|
29
29
|
import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
|
|
30
30
|
import { ShuffleControl as M } from "./shuffle.js";
|
|
31
|
-
import { SHUFFLE_CONTROL_ID as
|
|
31
|
+
import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
|
|
32
32
|
import { StrategyControl as G } from "./strategy.js";
|
|
33
33
|
import { STRATEGY_CONTROL_ID as We } from "./strategy.js";
|
|
34
34
|
import { setCurrencyAttributes as $, getBlockElement as z, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
|
|
@@ -128,7 +128,7 @@ class _e extends I {
|
|
|
128
128
|
return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
129
129
|
var o;
|
|
130
130
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
131
|
-
}), this.algorithmControl = new E(), this.localeControl = new
|
|
131
|
+
}), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
|
|
132
132
|
t && (t.api = this.api);
|
|
133
133
|
}), `
|
|
134
134
|
<div class="recommendation-controls-container">
|
|
@@ -452,7 +452,9 @@ class _e extends I {
|
|
|
452
452
|
e,
|
|
453
453
|
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
454
454
|
h
|
|
455
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e })
|
|
455
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e });
|
|
456
|
+
const s = o && n.drawnProducts !== n.recommendationProducts;
|
|
457
|
+
(i || s) && this._refreshOutsidePanel(e, i);
|
|
456
458
|
} catch (n) {
|
|
457
459
|
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
458
460
|
}
|
|
@@ -552,8 +554,8 @@ export {
|
|
|
552
554
|
v as FiltersControl,
|
|
553
555
|
Oe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
554
556
|
Be as LOCALE_CONTROL_ID,
|
|
555
|
-
|
|
556
|
-
|
|
557
|
+
w as LayoutOrientationControl,
|
|
558
|
+
A as LocaleControl,
|
|
557
559
|
Le as PRICE_PLACEMENT_CONTROL_ID,
|
|
558
560
|
Ee as PRODUCT_COUNT_CONTROL_ID,
|
|
559
561
|
ve as PRODUCT_LAYOUT_CONTROL_ID,
|
|
@@ -561,7 +563,7 @@ export {
|
|
|
561
563
|
W as ProductCountControl,
|
|
562
564
|
x as ProductLayoutControl,
|
|
563
565
|
_e as RecommendationBlockControl,
|
|
564
|
-
|
|
566
|
+
Ae as SHUFFLE_CONTROL_ID,
|
|
565
567
|
We as STRATEGY_CONTROL_ID,
|
|
566
568
|
M as ShuffleControl,
|
|
567
569
|
G as StrategyControl,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useToaster as L } from "../../../../composables/useToaster.js";
|
|
2
2
|
import { useTranslations as U } from "../../../../composables/useTranslations.js";
|
|
3
|
-
import { getRecommendationFeedSourceMaps as
|
|
3
|
+
import { getRecommendationFeedSourceMaps as w, strategyEditPath as z, strategyCreatePath as B, getOperatorOptions as M, PriceAttributes as N } from "../../../../enums/extensions/recommendationBlock.js";
|
|
4
4
|
import { ToasterTypeOptions as E } from "../../../../enums/toaster.js";
|
|
5
5
|
import { useRecommendationApi as O } from "../../../../services/recommendationApi.js";
|
|
6
6
|
import { useConfigStore as R } from "../../../../stores/config.js";
|
|
@@ -8,21 +8,21 @@ import { defineStore as V } from "pinia";
|
|
|
8
8
|
import "../constants/selectors.js";
|
|
9
9
|
import { DEFAULT_MOBILE_CARDS_IN_ROW as A, DEFAULT_CARDS_IN_ROW as x } from "../constants/layout.js";
|
|
10
10
|
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as T, EXCLUDED_ALGORITHM_IDS as j } from "../constants/defaultConfig.js";
|
|
11
|
-
import { getDefaultProducts as
|
|
11
|
+
import { getDefaultProducts as F } from "../templates/utils.js";
|
|
12
12
|
import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
|
|
13
13
|
import { isLegacyStrategyConfig as $ } from "../utils/legacyStrategyMigration.js";
|
|
14
14
|
import { getPartnerRecommendationParams as q } from "../utils/partnerCustomizations.js";
|
|
15
15
|
import { sanitizeProductIds as K } from "../utils/productIds.js";
|
|
16
16
|
import { isFilterValid as H } from "../validation/filterSchema.js";
|
|
17
17
|
import { getInvalidFields as J, isConfigValid as Q } from "../validation/requiredFields.js";
|
|
18
|
-
const
|
|
18
|
+
const u = O();
|
|
19
19
|
let p = null, y = null;
|
|
20
20
|
const I = /* @__PURE__ */ new Map();
|
|
21
21
|
let k = null, b = 0;
|
|
22
|
-
const
|
|
22
|
+
const m = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
|
|
23
23
|
function W(t) {
|
|
24
24
|
const e = _.get(t);
|
|
25
|
-
return e && e.token ===
|
|
25
|
+
return e && e.token === m.get(t) ? e.outcome : !1;
|
|
26
26
|
}
|
|
27
27
|
let l = null;
|
|
28
28
|
const X = () => {
|
|
@@ -80,7 +80,8 @@ function G() {
|
|
|
80
80
|
syncedConfigFingerprint: null,
|
|
81
81
|
legacyConversionLoading: !1,
|
|
82
82
|
configVersion: 0,
|
|
83
|
-
adoptedSizeVersion: 0
|
|
83
|
+
adoptedSizeVersion: 0,
|
|
84
|
+
drawnProducts: null
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
const Y = () => ({
|
|
@@ -173,7 +174,7 @@ const Y = () => ({
|
|
|
173
174
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, n) => e - n);
|
|
174
175
|
},
|
|
175
176
|
getActivePredictiveAlgorithms: (t) => {
|
|
176
|
-
const e =
|
|
177
|
+
const e = w(), n = [];
|
|
177
178
|
return t.activePredictiveAlgorithms.filter((r) => !j.includes(r)).forEach((r) => {
|
|
178
179
|
n.push(...e.filter((o) => o.id === r));
|
|
179
180
|
}), n.map((r) => ({
|
|
@@ -245,7 +246,7 @@ const Y = () => ({
|
|
|
245
246
|
const n = this.blockStates[t];
|
|
246
247
|
if (n) {
|
|
247
248
|
const s = structuredClone(n);
|
|
248
|
-
s.recommendationConfigs.id = e, s.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (s.isInitialized = !1, s.syncedConfigFingerprint = null), this.blockStates = {
|
|
249
|
+
s.recommendationConfigs.id = e, s.drawnProducts = null, s.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (s.isInitialized = !1, s.syncedConfigFingerprint = null), this.blockStates = {
|
|
249
250
|
...this.blockStates,
|
|
250
251
|
[e]: s
|
|
251
252
|
};
|
|
@@ -256,6 +257,9 @@ const Y = () => ({
|
|
|
256
257
|
[o]: i
|
|
257
258
|
});
|
|
258
259
|
},
|
|
260
|
+
markProductsDrawn(t, e) {
|
|
261
|
+
this.blockStates[t] && (this.blockStates[t].drawnProducts = e);
|
|
262
|
+
},
|
|
259
263
|
/**
|
|
260
264
|
* Marks a block as initialized (initial API data has been fetched).
|
|
261
265
|
* Automatically cleaned up when removeBlockState deletes the block entry.
|
|
@@ -401,7 +405,7 @@ const Y = () => ({
|
|
|
401
405
|
const t = b, e = (async () => {
|
|
402
406
|
this.strategiesLoading = !0;
|
|
403
407
|
try {
|
|
404
|
-
const n = await
|
|
408
|
+
const n = await u.fetchRecommendationStrategies();
|
|
405
409
|
if (t !== b)
|
|
406
410
|
return;
|
|
407
411
|
this.strategies = n, this.strategiesFetched = !0;
|
|
@@ -495,7 +499,7 @@ const Y = () => ({
|
|
|
495
499
|
const n = typeof t.updated_at == "string" ? t.updated_at : "", r = n ? `${t.strategy_id}:${n}:${e}` : "", o = r ? this.strategyUrlTemplates[r] : void 0;
|
|
496
500
|
if (o)
|
|
497
501
|
return o;
|
|
498
|
-
const { full_path: i = "" } = await
|
|
502
|
+
const { full_path: i = "" } = await u.generateStrategyEndpoint(t, e) ?? {};
|
|
499
503
|
return r && i && (this.strategyUrlTemplates = {
|
|
500
504
|
...this.strategyUrlTemplates,
|
|
501
505
|
[r]: i
|
|
@@ -513,7 +517,7 @@ const Y = () => ({
|
|
|
513
517
|
throw new Error("[Guido] convertLegacyStrategy called without an active block");
|
|
514
518
|
this.blockStates[n].legacyConversionLoading = !0;
|
|
515
519
|
try {
|
|
516
|
-
const r = await
|
|
520
|
+
const r = await u.migrateLegacyStrategy(t, e);
|
|
517
521
|
this.invalidateStrategies();
|
|
518
522
|
try {
|
|
519
523
|
await this.fetchStrategies();
|
|
@@ -562,7 +566,7 @@ const Y = () => ({
|
|
|
562
566
|
activePredictiveAlgorithms: t,
|
|
563
567
|
languages: e,
|
|
564
568
|
currencies: n
|
|
565
|
-
} = await
|
|
569
|
+
} = await u.fetchRecommendationCreateData();
|
|
566
570
|
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
567
571
|
const r = this.blockStates[this.currentRecommendationId];
|
|
568
572
|
r.filterStatus = !!r.recommendationConfigs.filters.length;
|
|
@@ -583,7 +587,7 @@ const Y = () => ({
|
|
|
583
587
|
return;
|
|
584
588
|
}
|
|
585
589
|
y = (async () => {
|
|
586
|
-
const t = await
|
|
590
|
+
const t = await u.fetchRecommendationFilters();
|
|
587
591
|
this.filterList = t;
|
|
588
592
|
})();
|
|
589
593
|
try {
|
|
@@ -709,14 +713,14 @@ const Y = () => ({
|
|
|
709
713
|
await this._doFetchStrategyProducts(e);
|
|
710
714
|
return;
|
|
711
715
|
}
|
|
712
|
-
const i = (
|
|
713
|
-
|
|
716
|
+
const i = (m.get(e) ?? 0) + 1;
|
|
717
|
+
m.set(e, i);
|
|
714
718
|
const s = parseInt(r.size) || 6;
|
|
715
719
|
if (!r.strategy) {
|
|
716
720
|
this._setBlockProducts(e, [], s);
|
|
717
721
|
return;
|
|
718
722
|
}
|
|
719
|
-
const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S =
|
|
723
|
+
const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S = w().find((h) => h.key === r.strategy)) == null ? void 0 : S.path) || "", c = {
|
|
720
724
|
locale: r.language,
|
|
721
725
|
currency: r.currencySettings.value,
|
|
722
726
|
partnerName: o.partnerName,
|
|
@@ -730,11 +734,11 @@ const Y = () => ({
|
|
|
730
734
|
);
|
|
731
735
|
let g;
|
|
732
736
|
try {
|
|
733
|
-
g = await
|
|
737
|
+
g = await u.fetchRecommendationProducts(f, c);
|
|
734
738
|
} catch {
|
|
735
739
|
g = [];
|
|
736
740
|
}
|
|
737
|
-
|
|
741
|
+
m.get(e) === i && this._setBlockProducts(e, g, s);
|
|
738
742
|
},
|
|
739
743
|
/**
|
|
740
744
|
* Block-scoped counterpart of `fetchRecommendationProducts`, which only serves the selected block:
|
|
@@ -773,8 +777,8 @@ const Y = () => ({
|
|
|
773
777
|
return !0;
|
|
774
778
|
},
|
|
775
779
|
_doFetchStrategyProducts(t, e = {}) {
|
|
776
|
-
const n = (
|
|
777
|
-
|
|
780
|
+
const n = (m.get(t) ?? 0) + 1;
|
|
781
|
+
m.set(t, n);
|
|
778
782
|
const r = this._loadStrategyProducts(t, n, e);
|
|
779
783
|
return _.set(t, { token: n, outcome: r }), r;
|
|
780
784
|
},
|
|
@@ -789,20 +793,20 @@ const Y = () => ({
|
|
|
789
793
|
if (s) {
|
|
790
794
|
i = parseInt(String(s.size ?? "")) || i;
|
|
791
795
|
const a = r.currencySettings.value, f = (await this.resolveStrategyUrlTemplate(s, a)).replaceAll("{locale}", r.language).replaceAll("{currency}", a), c = f.indexOf("?"), g = c === -1 ? f : f.slice(0, c), S = (c === -1 ? "" : f.slice(c + 1)).split("&").filter((v) => v && !v.startsWith("user_id=")), h = S.length ? `${g}?${S.join("&")}` : g;
|
|
792
|
-
h && (o = await
|
|
796
|
+
h && (o = await u.fetchRecommendationProductsByUrl(h));
|
|
793
797
|
}
|
|
794
798
|
} catch {
|
|
795
799
|
o = [];
|
|
796
800
|
}
|
|
797
|
-
return
|
|
801
|
+
return m.get(t) !== e ? W(t) : !o.length && n ? !1 : (this._setBlockProducts(t, o, i), o.length > 0);
|
|
798
802
|
},
|
|
799
803
|
_setBlockProducts(t, e, n) {
|
|
800
804
|
if (!this.blockStates[t])
|
|
801
805
|
return;
|
|
802
|
-
const r = e.length > 0 ? e :
|
|
806
|
+
const r = e.length > 0 ? e : F(n);
|
|
803
807
|
this.blockStates[t].recommendationProducts = [
|
|
804
808
|
...r.slice(0, n),
|
|
805
|
-
...
|
|
809
|
+
...F(Math.max(0, n - r.length))
|
|
806
810
|
];
|
|
807
811
|
}
|
|
808
812
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ModificationDescription as a } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
2
|
import { RECOMMENDATION_ID_ATTR as m } from "../constants/selectors.js";
|
|
3
|
-
import { isPartnerManagedBlock as
|
|
3
|
+
import { isPartnerManagedBlock as N, updateProductContentInPlace as I, regenerateProductRowsWithStyles as O } from "../controls/main/utils.js";
|
|
4
4
|
import { RecommendationConfigService as c } from "../services/configService.js";
|
|
5
|
-
import { useRecommendationExtensionStore as
|
|
5
|
+
import { useRecommendationExtensionStore as C } from "../store/recommendation.js";
|
|
6
6
|
let r = null;
|
|
7
|
-
function
|
|
7
|
+
function T(t) {
|
|
8
8
|
r = t;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function p(t) {
|
|
11
11
|
const n = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
12
12
|
return !n || !("querySelector" in n) ? null : n.querySelector(`[${m}="${t}"]`) ?? null;
|
|
13
13
|
}
|
|
@@ -19,18 +19,18 @@ function R(t, n) {
|
|
|
19
19
|
const o = c.getConfig(t);
|
|
20
20
|
return ["filters", "strategy", "strategyId", "size", "productIds"].some((e) => e in n && JSON.stringify(o[e]) !== JSON.stringify(n[e]));
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
function
|
|
22
|
+
const S = "Updated product IDs";
|
|
23
|
+
function y(t, n) {
|
|
24
24
|
if (!("productIds" in n))
|
|
25
25
|
return !1;
|
|
26
26
|
const o = c.getConfig(t);
|
|
27
27
|
return JSON.stringify(o.productIds) !== JSON.stringify(n.productIds);
|
|
28
28
|
}
|
|
29
29
|
function h(t, n, o) {
|
|
30
|
-
return
|
|
30
|
+
return y(t, n) ? S : o;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
const e =
|
|
32
|
+
function $(t, n, o) {
|
|
33
|
+
const e = p(t);
|
|
34
34
|
if (!r || !e)
|
|
35
35
|
return !1;
|
|
36
36
|
if (R(e, n)) {
|
|
@@ -40,7 +40,7 @@ function k(t, n, o) {
|
|
|
40
40
|
return !0;
|
|
41
41
|
}
|
|
42
42
|
function P(t, n) {
|
|
43
|
-
const o =
|
|
43
|
+
const o = C(), e = o.currentRecommendationId;
|
|
44
44
|
if (e === t || !o.blockStates[t]) {
|
|
45
45
|
n();
|
|
46
46
|
return;
|
|
@@ -52,16 +52,17 @@ function P(t, n) {
|
|
|
52
52
|
o.$patch({ currentRecommendationId: e });
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function k(t) {
|
|
56
56
|
const n = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
57
57
|
return !n || !("querySelectorAll" in n) ? [] : n.querySelectorAll(`[${m}="${t}"]`).map((o) => c.getConfig(o));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
const i =
|
|
59
|
+
function q(t, n, o, e) {
|
|
60
|
+
const i = p(t);
|
|
61
61
|
if (!r || !i)
|
|
62
62
|
return !1;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
C().markProductsDrawn(t, o);
|
|
64
|
+
const f = r.getDocumentModifier(), d = D(i, n), g = y(i, n), s = g ? S : e, l = { currentNode: i, documentModifier: f, products: o, ...g ? { description: s } : {} };
|
|
65
|
+
if (c.stageConfig(f, i, n), N(i))
|
|
65
66
|
return d && f.apply(new a(s)), !0;
|
|
66
67
|
let u = !1;
|
|
67
68
|
return P(t, () => {
|
|
@@ -70,16 +71,16 @@ function w(t, n, o, e) {
|
|
|
70
71
|
onApplied: () => {
|
|
71
72
|
u = !0;
|
|
72
73
|
}
|
|
73
|
-
}) || (u =
|
|
74
|
+
}) || (u = O(l));
|
|
74
75
|
}), !u && d && f.apply(new a(s)), !0;
|
|
75
76
|
}
|
|
76
77
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
S as PRODUCT_IDS_DESCRIPTION,
|
|
79
|
+
q as commitBlockChangeOutsidePanel,
|
|
79
80
|
R as hasEditedConfigChange,
|
|
80
|
-
|
|
81
|
+
y as isProductIdsChange,
|
|
81
82
|
h as pickConfigDescription,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
k as readBlockNodeConfigs,
|
|
84
|
+
T as registerNodeConfigWriter,
|
|
85
|
+
$ as writeBlockConfigOutsidePanel
|
|
85
86
|
};
|