@useinsider/guido 3.20.0 → 3.20.1-beta.5e7765e
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/config/compiler/itemsCompilerRules.js +21 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +64 -17
- package/dist/config/migrator/itemsBlockMigrator.js +112 -108
- package/dist/extensions/Blocks/Items/block.js +78 -67
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +51 -44
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +103 -91
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +90 -73
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +122 -90
- package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +46 -25
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +40 -17
- package/dist/extensions/Blocks/Unsubscribe/block.js +82 -83
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +10 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -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/utils/blockUrlConfig.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +0 -2
- package/dist/src/utils/liquidProtection.d.ts +3 -0
- package/dist/utils/liquidProtection.js +5 -0
- package/dist/utils/templatePreparation.js +61 -85
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { extractWrapperTags as
|
|
1
|
+
import { extractWrapperTags as A } from "../../../../utils/preserveTextStyles.js";
|
|
2
2
|
import { RecommendationBlockId as c } from "../constants/blockIds.js";
|
|
3
|
-
import { DESKTOP_CONTAINER_SELECTOR as
|
|
4
|
-
import { CSS_CLASS_TEXT_TRIM as
|
|
5
|
-
import { toCustomCompositionKey as
|
|
6
|
-
import {
|
|
7
|
-
import { hasQuerySelectorAll as
|
|
3
|
+
import { DESKTOP_CONTAINER_SELECTOR as b, ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as y, ATTR_PRODUCT_OLD_PRICE as p, ATTR_PRODUCT_OMNIBUS_PRICE as R, ATTR_PRODUCT_OMNIBUS_DISCOUNT as _, ATTR_PRODUCT_BUTTON as x, ATTR_PRODUCT_IMAGE as q, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
|
|
4
|
+
import { CSS_CLASS_TEXT_TRIM as B } from "../controls/shared/textTrimCssRules.js";
|
|
5
|
+
import { toCustomCompositionKey as U } from "../templates/utils.js";
|
|
6
|
+
import { resolveRowVisibilityKeys as N, isMergedInlinePriceRow as C } from "./compositionKeys.js";
|
|
7
|
+
import { hasQuerySelectorAll as I, hasGetAttribute as l, hasGetStyle as O, hasGetComputedStyle as M } from "./tagName.js";
|
|
8
8
|
const s = [
|
|
9
9
|
"font-size",
|
|
10
10
|
"font-family",
|
|
@@ -14,14 +14,14 @@ const s = [
|
|
|
14
14
|
"text-align",
|
|
15
15
|
"line-height",
|
|
16
16
|
"text-decoration"
|
|
17
|
-
],
|
|
17
|
+
], D = [
|
|
18
18
|
"background",
|
|
19
19
|
"background-color",
|
|
20
20
|
"border-width",
|
|
21
21
|
"border-color",
|
|
22
22
|
"border-style",
|
|
23
23
|
"border-radius"
|
|
24
|
-
],
|
|
24
|
+
], w = [
|
|
25
25
|
...s,
|
|
26
26
|
"background",
|
|
27
27
|
"background-color",
|
|
@@ -40,47 +40,47 @@ const s = [
|
|
|
40
40
|
"border-radius",
|
|
41
41
|
"margin"
|
|
42
42
|
], g = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), L = [
|
|
43
|
-
{ attrKey:
|
|
44
|
-
{ attrKey:
|
|
45
|
-
{ attrKey:
|
|
46
|
-
{ attrKey:
|
|
47
|
-
{ attrKey:
|
|
48
|
-
{ attrKey:
|
|
43
|
+
{ attrKey: k, blockId: c.NAME, kind: "text" },
|
|
44
|
+
{ attrKey: y, blockId: c.PRICE, kind: "text" },
|
|
45
|
+
{ attrKey: p, blockId: c.OLD_PRICE, kind: "text" },
|
|
46
|
+
{ attrKey: R, blockId: c.OMNIBUS_PRICE, kind: "text" },
|
|
47
|
+
{ attrKey: _, blockId: c.OMNIBUS_DISCOUNT, kind: "text" },
|
|
48
|
+
{ attrKey: x, blockId: c.BUTTON, kind: "button" },
|
|
49
49
|
{ attrKey: q, blockId: c.IMAGE, kind: "image" }
|
|
50
50
|
];
|
|
51
|
-
function
|
|
51
|
+
function h(t) {
|
|
52
52
|
return t && "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "";
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function K(t) {
|
|
55
55
|
return t && "getInnerText" in t && typeof t.getInnerText == "function" ? t.getInnerText().trim() : "";
|
|
56
56
|
}
|
|
57
57
|
function a(t, e, r) {
|
|
58
|
-
!e || !
|
|
58
|
+
!e || !O(e) || r.forEach((n) => {
|
|
59
59
|
const o = e.getStyle(n);
|
|
60
60
|
o && o !== "inherit" && o !== "initial" && (t[n] = o);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function E(t) {
|
|
64
64
|
return Object.entries(t).map(([e, r]) => `${e}: ${r};`).join(" ");
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
if (!t || !
|
|
66
|
+
function P(t) {
|
|
67
|
+
if (!t || !O(t))
|
|
68
68
|
return;
|
|
69
69
|
const e = t.getStyle("background-color") || t.getStyle("background");
|
|
70
70
|
return e && !g.has(e) ? e : void 0;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function S(t, e) {
|
|
73
73
|
const r = {};
|
|
74
|
-
return a(r, t, e),
|
|
74
|
+
return a(r, t, e), E(r);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function $(t) {
|
|
77
77
|
const e = t.querySelector("p"), r = {};
|
|
78
78
|
a(r, t, s), a(r, e, s), a(r, t.querySelector("strong"), s), a(r, t.querySelector("em"), s), a(r, t.querySelector("s"), s);
|
|
79
|
-
const n =
|
|
79
|
+
const n = E(r), { openTags: o, closeTags: i } = A(h(e));
|
|
80
80
|
return !n && !o ? null : { pStyle: n || void 0, openTags: o, closeTags: i };
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n =
|
|
82
|
+
function H(t) {
|
|
83
|
+
const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n = S(e, D), o = S(r, w), i = e && "getAttribute" in e ? e.getAttribute("class") ?? "" : "", u = /\bes-fw\b/.test(i), { openTags: T, closeTags: d } = A(h(r)), m = K(r);
|
|
84
84
|
return !n && !o && !u && !T && !m ? null : {
|
|
85
85
|
buttonBorderStyle: n || void 0,
|
|
86
86
|
buttonAnchorStyle: o || void 0,
|
|
@@ -90,44 +90,44 @@ function $(t) {
|
|
|
90
90
|
closeTags: d
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const e =
|
|
93
|
+
function F(t) {
|
|
94
|
+
const e = S(t.querySelector("img"), G);
|
|
95
95
|
return e ? { imgStyle: e } : null;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
return e === "button" ?
|
|
97
|
+
function j(t, e) {
|
|
98
|
+
return e === "button" ? H(t) : e === "image" ? F(t) : $(t);
|
|
99
99
|
}
|
|
100
100
|
function f(t, e) {
|
|
101
101
|
if (!t || !("querySelector" in t))
|
|
102
102
|
return;
|
|
103
|
-
const r = t.querySelector(
|
|
103
|
+
const r = t.querySelector(b) ?? t;
|
|
104
104
|
if (L.forEach(({ attrKey: i, blockId: u, kind: T }) => {
|
|
105
105
|
const d = r.querySelector(`[esd-extension-block-id="${u}"]`);
|
|
106
106
|
d && e(d, i, T);
|
|
107
|
-
}), !
|
|
107
|
+
}), !I(r))
|
|
108
108
|
return;
|
|
109
109
|
const n = /* @__PURE__ */ new Set();
|
|
110
110
|
r.querySelectorAll(
|
|
111
111
|
`[esd-extension-block-id="${c.CUSTOM_ATTRIBUTE}"]`
|
|
112
112
|
).forEach((i) => {
|
|
113
|
-
const u = l(i) ? i.getAttribute(
|
|
114
|
-
!u || n.has(u) || (n.add(u), e(i,
|
|
113
|
+
const u = l(i) ? i.getAttribute(v) : null;
|
|
114
|
+
!u || n.has(u) || (n.add(u), e(i, U(u), "text"));
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function V(t) {
|
|
118
118
|
const e = {};
|
|
119
119
|
return f(t, (r, n, o) => {
|
|
120
120
|
if (!("querySelector" in r))
|
|
121
121
|
return;
|
|
122
|
-
const i =
|
|
122
|
+
const i = j(r, o);
|
|
123
123
|
i && (e[n] = i);
|
|
124
124
|
}), e;
|
|
125
125
|
}
|
|
126
126
|
function X(t) {
|
|
127
127
|
if (!t || !("querySelector" in t))
|
|
128
128
|
return;
|
|
129
|
-
const e = t.querySelector(
|
|
130
|
-
return
|
|
129
|
+
const e = t.querySelector(b) ?? t, r = e.querySelector(".product-card-segment") ?? e.querySelector(".product-card-wrapper");
|
|
130
|
+
return P(r);
|
|
131
131
|
}
|
|
132
132
|
function z(t) {
|
|
133
133
|
if (!t)
|
|
@@ -135,10 +135,10 @@ function z(t) {
|
|
|
135
135
|
const e = l(t) ? t.getAttribute("bgcolor") : null;
|
|
136
136
|
if (e && !g.has(e))
|
|
137
137
|
return e;
|
|
138
|
-
const r =
|
|
138
|
+
const r = P(t);
|
|
139
139
|
if (r)
|
|
140
140
|
return r;
|
|
141
|
-
const n =
|
|
141
|
+
const n = M(t) ? t.getComputedStyle("background-color") : void 0;
|
|
142
142
|
return n && !g.has(n) ? n : void 0;
|
|
143
143
|
}
|
|
144
144
|
function Q(t) {
|
|
@@ -150,7 +150,7 @@ function Q(t) {
|
|
|
150
150
|
i && (e[n] = i);
|
|
151
151
|
}), e;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function W(t) {
|
|
154
154
|
const e = {};
|
|
155
155
|
return f(t, (r, n, o) => {
|
|
156
156
|
if (o === "image")
|
|
@@ -159,68 +159,70 @@ function V(t) {
|
|
|
159
159
|
i && (e[n] = i);
|
|
160
160
|
}), e;
|
|
161
161
|
}
|
|
162
|
-
const
|
|
163
|
-
function
|
|
162
|
+
const Y = /^es-[pm]\d+[trbl]?$/;
|
|
163
|
+
function J(t) {
|
|
164
164
|
const e = l(t) ? t.getAttribute("class") : null;
|
|
165
165
|
if (!e)
|
|
166
166
|
return;
|
|
167
|
-
const r = e.split(/\s+/).filter((n) =>
|
|
167
|
+
const r = e.split(/\s+/).filter((n) => Y.test(n) || n === B);
|
|
168
168
|
return r.length ? r.join(" ") : void 0;
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function Z(t) {
|
|
171
171
|
if (!t || !("querySelector" in t))
|
|
172
172
|
return !1;
|
|
173
|
-
const e = t.querySelector(
|
|
174
|
-
return
|
|
173
|
+
const e = t.querySelector(b) ?? t;
|
|
174
|
+
return C(e.querySelector(`[data-attribute-type="${y}"]`)) || C(e.querySelector(`[data-attribute-type="${p}"]`));
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
const e = {}, r =
|
|
176
|
+
function tt(t) {
|
|
177
|
+
const e = {}, r = Z(t);
|
|
178
178
|
return f(t, (n, o, i) => {
|
|
179
|
-
if (i === "image" || r && (o ===
|
|
179
|
+
if (i === "image" || r && (o === y || o === p))
|
|
180
180
|
return;
|
|
181
|
-
const u =
|
|
181
|
+
const u = J(n);
|
|
182
182
|
u && (e[o] = u);
|
|
183
183
|
}), e;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function et(t) {
|
|
186
186
|
const e = {};
|
|
187
187
|
return f(t, (r, n) => {
|
|
188
|
-
if (n !==
|
|
188
|
+
if (n !== R && n !== _ || !l(r))
|
|
189
189
|
return;
|
|
190
190
|
const o = r.getAttribute("data-text-before"), i = r.getAttribute("data-text-after");
|
|
191
191
|
(o != null || i != null) && (e[n] = { before: o ?? void 0, after: i ?? void 0 });
|
|
192
192
|
}), e;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function rt(t) {
|
|
195
195
|
const e = {};
|
|
196
196
|
if (!t || !("querySelector" in t))
|
|
197
197
|
return e;
|
|
198
|
-
const r = t.querySelector(
|
|
199
|
-
return
|
|
198
|
+
const r = t.querySelector(b) ?? t;
|
|
199
|
+
return I(r) && r.querySelectorAll(".recommendation-attribute-row").forEach((n) => {
|
|
200
200
|
if (!l(n))
|
|
201
201
|
return;
|
|
202
|
-
const o =
|
|
203
|
-
o
|
|
202
|
+
const o = n.getAttribute("data-visibility");
|
|
203
|
+
o != null && N(n).forEach((i) => {
|
|
204
|
+
e[i] = o !== "0";
|
|
205
|
+
});
|
|
204
206
|
}), e;
|
|
205
207
|
}
|
|
206
|
-
function
|
|
208
|
+
function lt(t) {
|
|
207
209
|
return {
|
|
208
|
-
styleTemplates:
|
|
210
|
+
styleTemplates: V(t),
|
|
209
211
|
cardBackgroundColor: X(t),
|
|
210
212
|
cellBackgroundColors: Q(t),
|
|
211
|
-
cellAlignments:
|
|
212
|
-
cellClasses:
|
|
213
|
-
omnibusTexts:
|
|
214
|
-
visibility:
|
|
213
|
+
cellAlignments: W(t),
|
|
214
|
+
cellClasses: tt(t),
|
|
215
|
+
omnibusTexts: et(t),
|
|
216
|
+
visibility: rt(t)
|
|
215
217
|
};
|
|
216
218
|
}
|
|
217
219
|
export {
|
|
218
|
-
|
|
220
|
+
V as captureAttributeStyleTemplates,
|
|
219
221
|
X as captureCardBackgroundColor,
|
|
220
|
-
|
|
222
|
+
W as captureCellAlignments,
|
|
221
223
|
Q as captureCellBackgroundColors,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
tt as captureCellClasses,
|
|
225
|
+
et as captureOmnibusTexts,
|
|
226
|
+
lt as captureStyles,
|
|
227
|
+
rt as captureVisibility
|
|
226
228
|
};
|
|
@@ -1,89 +1,98 @@
|
|
|
1
|
-
import { ATTR_CUSTOM_PREFIX as
|
|
2
|
-
function
|
|
3
|
-
return !t.startsWith(
|
|
1
|
+
import { ATTR_CUSTOM_PREFIX as o, ATTR_PRODUCT_PRICE as g, ATTR_PRODUCT_OLD_PRICE as d, PRODUCT_ATTRIBUTE_PREFIX as a, ATTR_DATA_ATTRIBUTE_TYPE as f, ATTR_PRODUCT_ATTR as c, SELECTOR_ATTRIBUTE_ROW as y } from "../constants/selectors.js";
|
|
2
|
+
function q(t) {
|
|
3
|
+
return !t.startsWith(a);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return t.startsWith(
|
|
7
|
-
}
|
|
8
|
-
function T(t) {
|
|
9
|
-
return t.startsWith(s) ? t.substring(s.length) : t;
|
|
5
|
+
function $(t) {
|
|
6
|
+
return t.startsWith(a) ? t.substring(a.length) : t;
|
|
10
7
|
}
|
|
11
8
|
function A(t) {
|
|
12
|
-
return
|
|
9
|
+
return t.startsWith(o) ? t.substring(o.length) : t;
|
|
10
|
+
}
|
|
11
|
+
function T(t) {
|
|
12
|
+
return `${o}${t}`;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return t.type === "defaultAttribute" ? t.attributeName : `${
|
|
14
|
+
function C(t) {
|
|
15
|
+
return t.type === "defaultAttribute" ? t.attributeName : `${a}${t.attributeName}`;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function h(t, r) {
|
|
18
18
|
const n = Object.values(r).filter((e) => e.attributeName === t);
|
|
19
19
|
return n.find((e) => e.type === "defaultAttribute") ?? n[0];
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function l(t, r) {
|
|
22
22
|
return t && "getAttribute" in t ? t.getAttribute(r) : null;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const e = `${
|
|
26
|
-
`${
|
|
27
|
-
),
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
const
|
|
31
|
-
return
|
|
24
|
+
function S(t, r, n = {}) {
|
|
25
|
+
const e = `${o}${t}`, u = r == null ? void 0 : r.querySelector(
|
|
26
|
+
`${y}[${f}="${e}"]`
|
|
27
|
+
), i = l(u, c) ?? l(u == null ? void 0 : u.querySelector(`[${c}]`), c);
|
|
28
|
+
if (i)
|
|
29
|
+
return i;
|
|
30
|
+
const s = h(t, n);
|
|
31
|
+
return s ? C(s) : t;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return t.startsWith(
|
|
33
|
+
function P(t, r, n = {}) {
|
|
34
|
+
return t.startsWith(a) ? t : S(t, r, n);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function O(t, r, n = {}) {
|
|
37
37
|
return t.map((e) => {
|
|
38
|
-
if (!e.startsWith(
|
|
38
|
+
if (!e.startsWith(o))
|
|
39
39
|
return e;
|
|
40
|
-
const u =
|
|
41
|
-
return
|
|
40
|
+
const u = A(e);
|
|
41
|
+
return T(P(u, r, n));
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
return t.map((e) =>
|
|
44
|
+
function p(t, r, n = {}) {
|
|
45
|
+
return t.map((e) => P(e, r, n));
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
const r =
|
|
49
|
-
if (!(r != null && r.startsWith(
|
|
47
|
+
function b(t) {
|
|
48
|
+
const r = l(t, f);
|
|
49
|
+
if (!(r != null && r.startsWith(o)))
|
|
50
50
|
return r;
|
|
51
|
-
const n = "querySelector" in t ? t.querySelector(`[${
|
|
52
|
-
return e ?
|
|
51
|
+
const n = "querySelector" in t ? t.querySelector(`[${c}]`) : void 0, e = l(n, c);
|
|
52
|
+
return e ? T(e) : r;
|
|
53
|
+
}
|
|
54
|
+
function m(t) {
|
|
55
|
+
return !!(t && "querySelector" in t && t.querySelector(".product-price") && t.querySelector(".product-old-price"));
|
|
56
|
+
}
|
|
57
|
+
function D(t) {
|
|
58
|
+
const r = b(t);
|
|
59
|
+
return r ? m(t) ? [g, d] : [r] : [];
|
|
53
60
|
}
|
|
54
|
-
function
|
|
55
|
-
const e =
|
|
56
|
-
return
|
|
61
|
+
function R(t, r, n) {
|
|
62
|
+
const e = l(t, c), u = l(t.querySelector(`[${c}]`), c), i = e ?? u;
|
|
63
|
+
return i === null ? n : i === r;
|
|
57
64
|
}
|
|
58
|
-
function
|
|
59
|
-
const n = (
|
|
60
|
-
`${
|
|
65
|
+
function I(t, r) {
|
|
66
|
+
const n = (_) => t.querySelector(
|
|
67
|
+
`${y}[${f}="${_}"]`
|
|
61
68
|
);
|
|
62
|
-
if (!r.startsWith(
|
|
69
|
+
if (!r.startsWith(o))
|
|
63
70
|
return n(r) ?? null;
|
|
64
|
-
const e =
|
|
65
|
-
if (u &&
|
|
71
|
+
const e = A(r), u = n(r);
|
|
72
|
+
if (u && R(u, e, !0))
|
|
66
73
|
return u;
|
|
67
|
-
const
|
|
68
|
-
return
|
|
74
|
+
const i = T($(e)), s = i === r ? void 0 : n(i);
|
|
75
|
+
return s && R(s, e, !1) ? s : null;
|
|
69
76
|
}
|
|
70
|
-
function
|
|
71
|
-
const n =
|
|
77
|
+
function U(t, r) {
|
|
78
|
+
const n = A(r), e = T($(n));
|
|
72
79
|
return e === r ? t : t.replace(
|
|
73
|
-
`${
|
|
74
|
-
`${
|
|
80
|
+
`${f}="${e}"`,
|
|
81
|
+
`${f}="${r}"`
|
|
75
82
|
);
|
|
76
83
|
}
|
|
77
84
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
$ as bareAttributeName,
|
|
86
|
+
A as compositionKeyToProductAttr,
|
|
87
|
+
C as filterToProductAttrValue,
|
|
88
|
+
I as findAttributeRow,
|
|
89
|
+
h as findFilterByBareName,
|
|
90
|
+
q as isDefaultProductAttr,
|
|
91
|
+
m as isMergedInlinePriceRow,
|
|
92
|
+
O as normalizeCompositionKeys,
|
|
93
|
+
p as normalizeCustomAttrValues,
|
|
94
|
+
T as productAttrToCompositionKey,
|
|
95
|
+
b as resolveRowCompositionKey,
|
|
96
|
+
D as resolveRowVisibilityKeys,
|
|
97
|
+
U as rewriteLegacyRowKeyHtml
|
|
89
98
|
};
|
|
@@ -1,32 +1,53 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
3
|
-
import { isPartnerManagedBlock as
|
|
1
|
+
import { ModificationDescription as s } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { RECOMMENDATION_ID_ATTR as a } from "../constants/selectors.js";
|
|
3
|
+
import { isPartnerManagedBlock as C, updateProductContentInPlace as p, regenerateProductRowsWithStyles as y } from "../controls/main/utils.js";
|
|
4
4
|
import { RecommendationConfigService as m } from "../services/configService.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { useRecommendationExtensionStore as N } from "../store/recommendation.js";
|
|
6
|
+
let n = null;
|
|
7
|
+
function B(e) {
|
|
8
|
+
n = e;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
10
|
+
function S(e, t) {
|
|
11
|
+
const o = N(), i = o.currentRecommendationId;
|
|
12
|
+
if (i === e || !o.blockStates[e]) {
|
|
13
|
+
t();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
o.setCurrentBlock(e);
|
|
17
|
+
try {
|
|
18
|
+
t();
|
|
19
|
+
} finally {
|
|
20
|
+
o.$patch({ currentRecommendationId: i });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function P(e) {
|
|
24
|
+
const t = n == null ? void 0 : n.getDocumentRootHtmlNode();
|
|
25
|
+
return !t || !("querySelectorAll" in t) ? [] : t.querySelectorAll(`[${a}="${e}"]`).map((o) => m.getConfig(o));
|
|
26
|
+
}
|
|
27
|
+
function $(e, t, o, i) {
|
|
28
|
+
const f = n == null ? void 0 : n.getDocumentRootHtmlNode();
|
|
29
|
+
if (!n || !f || !("querySelector" in f))
|
|
12
30
|
return !1;
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
31
|
+
const r = f.querySelector(`[${a}="${e}"]`);
|
|
32
|
+
if (!r)
|
|
15
33
|
return !1;
|
|
16
|
-
const
|
|
17
|
-
if (m.stageConfig(
|
|
18
|
-
return
|
|
19
|
-
let
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
const c = n.getDocumentModifier(), d = m.getConfig(r), g = Object.keys(t).some((l) => JSON.stringify(d[l]) !== JSON.stringify(t[l]));
|
|
35
|
+
if (m.stageConfig(c, r, t), C(r))
|
|
36
|
+
return c.apply(new s(i)), !0;
|
|
37
|
+
let u = !1;
|
|
38
|
+
return S(e, () => {
|
|
39
|
+
p({
|
|
40
|
+
currentNode: r,
|
|
41
|
+
documentModifier: c,
|
|
42
|
+
products: o,
|
|
43
|
+
onApplied: () => {
|
|
44
|
+
u = !0;
|
|
45
|
+
}
|
|
46
|
+
}) || (u = y({ currentNode: r, documentModifier: c, products: o }));
|
|
47
|
+
}), !u && g && c.apply(new s(i)), !0;
|
|
28
48
|
}
|
|
29
49
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
$ as commitBlockChangeOutsidePanel,
|
|
51
|
+
P as readBlockNodeConfigs,
|
|
52
|
+
B as registerNodeConfigWriter
|
|
32
53
|
};
|
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
import { useRecommendationExtensionStore as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useRecommendationExtensionStore as g } from "../store/recommendation.js";
|
|
2
|
+
import { toBlockUrlConfig as m } from "./blockUrlConfig.js";
|
|
3
|
+
import { commitBlockChangeOutsidePanel as d, readBlockNodeConfigs as y } from "./nodeConfigWriter.js";
|
|
4
|
+
function l(t, o) {
|
|
5
|
+
const r = JSON.stringify(m(o));
|
|
6
|
+
return y(t).find((e) => JSON.stringify(m(e)) !== r) ?? o;
|
|
7
|
+
}
|
|
8
|
+
async function C(t, o, r) {
|
|
9
|
+
const e = g(), c = [t, o];
|
|
10
|
+
(/* @__PURE__ */ new Map([[t, l(t, r)], [o, r]])).forEach((n, s) => {
|
|
11
|
+
var a;
|
|
12
|
+
(!!n.strategyId || s === o) && ((a = e.blockStates[s]) == null ? void 0 : a.recommendationConfigs.strategyId) !== n.strategyId && e.seedBlockUrlConfig(s, m(n));
|
|
13
|
+
}), e.resetArrivedBlock(o), await Promise.all(c.map(async (n) => {
|
|
14
|
+
if (!await e.refreshStrategyBlock(n))
|
|
15
|
+
return;
|
|
16
|
+
const { recommendationConfigs: s, recommendationProducts: i } = e.blockStates[n];
|
|
17
|
+
d(
|
|
18
|
+
n,
|
|
19
|
+
{ size: s.size },
|
|
20
|
+
i,
|
|
21
|
+
"Refresh duplicated recommendation strategy"
|
|
22
|
+
);
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
async function B(t, o) {
|
|
26
|
+
const r = g(), e = r.blockStates[t];
|
|
27
|
+
if (!e)
|
|
6
28
|
return !1;
|
|
7
|
-
const { strategyId:
|
|
8
|
-
if (
|
|
29
|
+
const { strategyId: c, strategy: f, size: n, nodeConfigVersion: s } = e.recommendationConfigs;
|
|
30
|
+
if (r.currentRecommendationId === t)
|
|
9
31
|
try {
|
|
10
|
-
await
|
|
11
|
-
} catch (
|
|
12
|
-
console.error("[recommendation] product refetch after a strategy change failed",
|
|
32
|
+
await r.fetchRecommendationProducts();
|
|
33
|
+
} catch (a) {
|
|
34
|
+
console.error("[recommendation] product refetch after a strategy change failed", a);
|
|
13
35
|
}
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
{ strategyId:
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
const i = d(
|
|
37
|
+
t,
|
|
38
|
+
{ strategyId: c, strategy: f, size: n, configVersion: s },
|
|
39
|
+
e.recommendationProducts,
|
|
40
|
+
o
|
|
19
41
|
);
|
|
20
|
-
return
|
|
42
|
+
return i || console.error("[recommendation] strategy change did not reach a node", { blockId: t }), i;
|
|
21
43
|
}
|
|
22
44
|
export {
|
|
23
|
-
|
|
45
|
+
B as commitStrategyChange,
|
|
46
|
+
C as refreshDuplicatedStrategyBlocks
|
|
24
47
|
};
|