@useinsider/guido 3.21.0-beta.9f9407d → 3.21.0-beta.a4cc621
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/extensions/Blocks/Recommendation/block.js +209 -139
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +132 -150
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +97 -98
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +43 -58
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +52 -31
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +23 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -4
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +11 -0
- package/package.json +1 -1
|
@@ -90,21 +90,21 @@ function F(t, e = {}) {
|
|
|
90
90
|
documentModifier: o,
|
|
91
91
|
products: r,
|
|
92
92
|
layout: s,
|
|
93
|
-
composition:
|
|
93
|
+
composition: l
|
|
94
94
|
} = t;
|
|
95
95
|
if (!n || !("querySelector" in n))
|
|
96
96
|
return !1;
|
|
97
|
-
const u = s ?? T(n),
|
|
98
|
-
if (u === "list" || !
|
|
97
|
+
const u = s ?? T(n), i = g.getConfig(n);
|
|
98
|
+
if (u === "list" || !i.mobileLayoutEnabled)
|
|
99
99
|
return ne({ currentNode: n, documentModifier: o });
|
|
100
|
-
const c = E(),
|
|
101
|
-
productsPerRow:
|
|
102
|
-
composition:
|
|
100
|
+
const c = E(), a = v(r, c.recommendationProducts), f = l ?? B(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${x(a, u, {
|
|
101
|
+
productsPerRow: i.mobileCardsInRow,
|
|
102
|
+
composition: f,
|
|
103
103
|
filterList: c.filterList,
|
|
104
|
-
priceInline: !
|
|
104
|
+
priceInline: !i.priceMovedToNextLine,
|
|
105
105
|
// Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
|
|
106
|
-
cellPadding: j(
|
|
107
|
-
rowSpacingPx:
|
|
106
|
+
cellPadding: j(i.mobileColumnSpacing),
|
|
107
|
+
rowSpacingPx: i.mobileRowSpacing,
|
|
108
108
|
...e
|
|
109
109
|
})}</table></td>`, y = n.querySelector(k);
|
|
110
110
|
return y ? (o.modifyHtml(y).setInnerHtml(p), !0) : (ie(n, o, p), !1);
|
|
@@ -118,17 +118,17 @@ function le(t, e = {}) {
|
|
|
118
118
|
documentModifier: o,
|
|
119
119
|
products: r,
|
|
120
120
|
layout: s,
|
|
121
|
-
composition:
|
|
121
|
+
composition: l
|
|
122
122
|
} = t;
|
|
123
123
|
if (!n || !("querySelector" in n))
|
|
124
124
|
return !1;
|
|
125
125
|
const u = n.querySelector(w) ?? n.querySelector(Y);
|
|
126
126
|
if (!u)
|
|
127
127
|
return !1;
|
|
128
|
-
const
|
|
129
|
-
productsPerRow:
|
|
130
|
-
composition:
|
|
131
|
-
filterList:
|
|
128
|
+
const i = E(), c = v(r, i.recommendationProducts), { cardsInRow: a } = g.getConfig(n), f = l ?? B(n, i.filterList), d = s ?? T(n), p = g.getConfig(n), y = x(c, d, {
|
|
129
|
+
productsPerRow: a,
|
|
130
|
+
composition: f,
|
|
131
|
+
filterList: i.filterList,
|
|
132
132
|
priceInline: !p.priceMovedToNextLine,
|
|
133
133
|
// Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
|
|
134
134
|
cellPadding: j(p.columnSpacing),
|
|
@@ -154,14 +154,14 @@ function ue(t, e, n) {
|
|
|
154
154
|
const r = o.getAttribute(q);
|
|
155
155
|
if (!r)
|
|
156
156
|
return !1;
|
|
157
|
-
const s = E(),
|
|
158
|
-
c &&
|
|
159
|
-
const
|
|
157
|
+
const s = E(), l = r.split(",").filter(Boolean), u = H(l, o, s.filterList), i = [], c = u.join(",") !== l.join(",");
|
|
158
|
+
c && i.push([q, u.join(",")]);
|
|
159
|
+
const a = ce(
|
|
160
160
|
o.getAttribute(h)
|
|
161
|
-
),
|
|
162
|
-
if (
|
|
161
|
+
), f = a && J(a, o, s.filterList);
|
|
162
|
+
if (a && f && f.join(",") !== a.join(",") && i.push([h, JSON.stringify(f)]), i.length === 0)
|
|
163
163
|
return !1;
|
|
164
|
-
if (
|
|
164
|
+
if (i.forEach(([d, p]) => {
|
|
165
165
|
e.modifyHtml(o).setAttribute(d, p);
|
|
166
166
|
}), c && g.hasConfig(t)) {
|
|
167
167
|
const d = {
|
|
@@ -179,21 +179,20 @@ function Re(t) {
|
|
|
179
179
|
afterRegenerate: o,
|
|
180
180
|
products: r,
|
|
181
181
|
layout: s,
|
|
182
|
-
composition:
|
|
183
|
-
skipStylePreservation: u
|
|
184
|
-
description: l
|
|
182
|
+
composition: l,
|
|
183
|
+
skipStylePreservation: u
|
|
185
184
|
} = t;
|
|
186
185
|
if (!e)
|
|
187
186
|
return !1;
|
|
188
|
-
const
|
|
187
|
+
const i = u ? {} : D(e), c = {
|
|
189
188
|
currentNode: e,
|
|
190
189
|
documentModifier: n,
|
|
191
190
|
products: r,
|
|
192
191
|
layout: s,
|
|
193
|
-
composition:
|
|
192
|
+
composition: l
|
|
194
193
|
};
|
|
195
|
-
let a = le(
|
|
196
|
-
return a = F(
|
|
194
|
+
let a = le(c, i);
|
|
195
|
+
return a = F(c, i) || a, a && (ue(e, n, l), n.apply(new C("Regenerate products with styles"))), o == null || o(), a;
|
|
197
196
|
}
|
|
198
197
|
function qe(t, e) {
|
|
199
198
|
return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...U(e - t.length)];
|
|
@@ -217,28 +216,28 @@ function R(t, e = "price") {
|
|
|
217
216
|
});
|
|
218
217
|
}
|
|
219
218
|
function se(t) {
|
|
220
|
-
var s,
|
|
221
|
-
const e = K(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, o = ((
|
|
219
|
+
var s, l;
|
|
220
|
+
const e = K(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, o = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - o) / n * 100) : 0;
|
|
222
221
|
return r > 0 ? `-${r}%` : "0%";
|
|
223
222
|
}
|
|
224
223
|
function V(t) {
|
|
225
|
-
const { documentModifier: e, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl:
|
|
224
|
+
const { documentModifier: e, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: l } = t;
|
|
226
225
|
let u = !1;
|
|
227
226
|
if (o && "querySelector" in o) {
|
|
228
|
-
const
|
|
229
|
-
S(e,
|
|
227
|
+
const i = o.querySelector("strong") ?? o.querySelector("p"), c = R(n, "price");
|
|
228
|
+
S(e, i ?? null, c) && (u = !0);
|
|
230
229
|
}
|
|
231
230
|
if (r && "querySelector" in r) {
|
|
232
|
-
const
|
|
233
|
-
S(e,
|
|
231
|
+
const i = r.querySelector("strong") ?? r.querySelector("p"), c = R(n, "original_price");
|
|
232
|
+
S(e, i ?? null, c) && (u = !0), A(e, r, "data-same-price", String(Z(n))) && (u = !0);
|
|
234
233
|
}
|
|
235
234
|
if (s && "querySelector" in s) {
|
|
236
|
-
const
|
|
237
|
-
S(e,
|
|
235
|
+
const i = s.querySelector(".omnibus-price-value") ?? null, c = R(n, "original_price");
|
|
236
|
+
S(e, i, c) && (u = !0);
|
|
238
237
|
}
|
|
239
|
-
if (
|
|
240
|
-
const
|
|
241
|
-
S(e,
|
|
238
|
+
if (l && "querySelector" in l) {
|
|
239
|
+
const i = l.querySelector(".omnibus-discount-value") ?? null, c = se(n);
|
|
240
|
+
S(e, i, c) && (u = !0);
|
|
242
241
|
}
|
|
243
242
|
return u;
|
|
244
243
|
}
|
|
@@ -249,37 +248,37 @@ function ae(t) {
|
|
|
249
248
|
imageEl: o,
|
|
250
249
|
nameEl: r,
|
|
251
250
|
priceEl: s,
|
|
252
|
-
oldPriceEl:
|
|
251
|
+
oldPriceEl: l,
|
|
253
252
|
omnibusPriceEl: u,
|
|
254
|
-
omnibusDiscountEl:
|
|
253
|
+
omnibusDiscountEl: i,
|
|
255
254
|
buttonEl: c
|
|
256
255
|
} = t;
|
|
257
|
-
let
|
|
256
|
+
let a = !1;
|
|
258
257
|
if (o && "querySelector" in o) {
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
const p = A(e,
|
|
262
|
-
|
|
258
|
+
const f = o.querySelector("img");
|
|
259
|
+
if (f) {
|
|
260
|
+
const p = A(e, f, "src", Q(n.image_url)), y = A(e, f, "alt", n.name);
|
|
261
|
+
a = a || p || y;
|
|
263
262
|
}
|
|
264
263
|
const d = o.querySelector("a");
|
|
265
|
-
d && A(e, d, "href", n.url) && (
|
|
264
|
+
d && A(e, d, "href", n.url) && (a = !0);
|
|
266
265
|
}
|
|
267
266
|
if (r && "querySelector" in r) {
|
|
268
|
-
const
|
|
269
|
-
S(e,
|
|
267
|
+
const f = r.querySelector("strong") ?? r.querySelector("p");
|
|
268
|
+
S(e, f ?? null, n.name) && (a = !0);
|
|
270
269
|
}
|
|
271
270
|
if (V({
|
|
272
271
|
documentModifier: e,
|
|
273
272
|
product: n,
|
|
274
273
|
priceEl: s,
|
|
275
|
-
oldPriceEl:
|
|
274
|
+
oldPriceEl: l,
|
|
276
275
|
omnibusPriceEl: u,
|
|
277
|
-
omnibusDiscountEl:
|
|
278
|
-
}) && (
|
|
279
|
-
const
|
|
280
|
-
|
|
276
|
+
omnibusDiscountEl: i
|
|
277
|
+
}) && (a = !0), c && "querySelector" in c) {
|
|
278
|
+
const f = c.querySelector("a.es-button") || c.querySelector("a");
|
|
279
|
+
f && A(e, f, "href", n.url) && (a = !0);
|
|
281
280
|
}
|
|
282
|
-
return
|
|
281
|
+
return a;
|
|
283
282
|
}
|
|
284
283
|
function G(t) {
|
|
285
284
|
return "querySelector" in t ? t.querySelector(w) ?? t : t;
|
|
@@ -303,26 +302,26 @@ function de(t, e, n) {
|
|
|
303
302
|
if (o.length === 0)
|
|
304
303
|
return !1;
|
|
305
304
|
const r = /* @__PURE__ */ new Map();
|
|
306
|
-
o.forEach((
|
|
307
|
-
if (!("getAttribute" in
|
|
305
|
+
o.forEach((l) => {
|
|
306
|
+
if (!("getAttribute" in l))
|
|
308
307
|
return;
|
|
309
|
-
const u =
|
|
308
|
+
const u = l.getAttribute(z);
|
|
310
309
|
if (!u)
|
|
311
310
|
return;
|
|
312
|
-
const
|
|
313
|
-
|
|
311
|
+
const i = r.get(u) ?? [];
|
|
312
|
+
i.push(l), r.set(u, i);
|
|
314
313
|
});
|
|
315
314
|
let s = !1;
|
|
316
|
-
return r.forEach((
|
|
317
|
-
const
|
|
318
|
-
|
|
315
|
+
return r.forEach((l, u) => {
|
|
316
|
+
const i = Math.min(l.length, n.length);
|
|
317
|
+
l.slice(0, i).forEach((c, a) => {
|
|
319
318
|
if (!("querySelector" in c))
|
|
320
319
|
return;
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
320
|
+
const f = fe(u, n[a]);
|
|
321
|
+
if (f === null)
|
|
323
322
|
return;
|
|
324
323
|
const d = c.querySelector("p") ?? null;
|
|
325
|
-
S(e, d,
|
|
324
|
+
S(e, d, f) && (s = !0);
|
|
326
325
|
});
|
|
327
326
|
}), s;
|
|
328
327
|
}
|
|
@@ -335,55 +334,55 @@ function _(t, e, n) {
|
|
|
335
334
|
`[esd-extension-block-id="${m.NAME}"]`
|
|
336
335
|
), s = t.querySelectorAll(
|
|
337
336
|
`[esd-extension-block-id="${m.PRICE}"]`
|
|
338
|
-
),
|
|
337
|
+
), l = t.querySelectorAll(
|
|
339
338
|
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
340
339
|
), u = t.querySelectorAll(
|
|
341
340
|
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
342
|
-
),
|
|
341
|
+
), i = t.querySelectorAll(
|
|
343
342
|
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
344
343
|
), c = t.querySelectorAll(
|
|
345
344
|
`[esd-extension-block-id="${m.BUTTON}"]`
|
|
346
|
-
),
|
|
347
|
-
let
|
|
348
|
-
for (let d = 0; d <
|
|
345
|
+
), a = Math.min(o.length, n.length);
|
|
346
|
+
let f = !1;
|
|
347
|
+
for (let d = 0; d < a; d++) {
|
|
349
348
|
const p = ae({
|
|
350
349
|
documentModifier: e,
|
|
351
350
|
product: n[d],
|
|
352
351
|
imageEl: o[d] ?? null,
|
|
353
352
|
nameEl: r[d] ?? null,
|
|
354
353
|
priceEl: s[d] ?? null,
|
|
355
|
-
oldPriceEl:
|
|
354
|
+
oldPriceEl: l[d] ?? null,
|
|
356
355
|
omnibusPriceEl: u[d] ?? null,
|
|
357
|
-
omnibusDiscountEl:
|
|
356
|
+
omnibusDiscountEl: i[d] ?? null,
|
|
358
357
|
buttonEl: c[d] ?? null
|
|
359
358
|
});
|
|
360
|
-
|
|
359
|
+
f = f || p;
|
|
361
360
|
}
|
|
362
|
-
return de(t, e, n) && (
|
|
361
|
+
return de(t, e, n) && (f = !0), f;
|
|
363
362
|
}
|
|
364
363
|
function he(t) {
|
|
365
|
-
const { currentNode: e, documentModifier: n, products: o, onApplied: r
|
|
364
|
+
const { currentNode: e, documentModifier: n, products: o, onApplied: r } = t;
|
|
366
365
|
if (!e || !("querySelectorAll" in e))
|
|
367
366
|
return !1;
|
|
368
|
-
const
|
|
369
|
-
if (!("querySelectorAll" in
|
|
367
|
+
const s = G(e);
|
|
368
|
+
if (!("querySelectorAll" in s) || s.querySelectorAll(
|
|
370
369
|
`[esd-extension-block-id="${m.IMAGE}"]`
|
|
371
370
|
).length !== o.length)
|
|
372
371
|
return !1;
|
|
373
|
-
let
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
372
|
+
let u = _(s, n, o);
|
|
373
|
+
const i = T(e), c = g.getConfig(e);
|
|
374
|
+
if (i !== "list" && c.mobileLayoutEnabled && "querySelector" in e) {
|
|
376
375
|
const a = e.querySelector(L);
|
|
377
376
|
if (a) {
|
|
378
|
-
const
|
|
377
|
+
const f = _(
|
|
379
378
|
a,
|
|
380
379
|
n,
|
|
381
380
|
o
|
|
382
381
|
);
|
|
383
|
-
|
|
382
|
+
u = u || f;
|
|
384
383
|
}
|
|
385
384
|
}
|
|
386
|
-
return
|
|
385
|
+
return u && (n.apply(new C("Updated product content in-place")), r == null || r()), !0;
|
|
387
386
|
}
|
|
388
387
|
function N(t, e, n) {
|
|
389
388
|
if (!("querySelectorAll" in t))
|
|
@@ -394,10 +393,10 @@ function N(t, e, n) {
|
|
|
394
393
|
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
395
394
|
), s = t.querySelectorAll(
|
|
396
395
|
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
397
|
-
),
|
|
396
|
+
), l = t.querySelectorAll(
|
|
398
397
|
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
399
398
|
), u = Math.min(o.length, n.length);
|
|
400
|
-
let
|
|
399
|
+
let i = !1;
|
|
401
400
|
for (let c = 0; c < u; c++)
|
|
402
401
|
V({
|
|
403
402
|
documentModifier: e,
|
|
@@ -405,9 +404,9 @@ function N(t, e, n) {
|
|
|
405
404
|
priceEl: o[c] ?? null,
|
|
406
405
|
oldPriceEl: r[c] ?? null,
|
|
407
406
|
omnibusPriceEl: s[c] ?? null,
|
|
408
|
-
omnibusDiscountEl:
|
|
409
|
-
}) && (
|
|
410
|
-
return
|
|
407
|
+
omnibusDiscountEl: l[c] ?? null
|
|
408
|
+
}) && (i = !0);
|
|
409
|
+
return i;
|
|
411
410
|
}
|
|
412
411
|
function Me(t) {
|
|
413
412
|
const { currentNode: e, documentModifier: n } = t;
|
|
@@ -419,25 +418,25 @@ function Me(t) {
|
|
|
419
418
|
if (r.length === 0)
|
|
420
419
|
return !1;
|
|
421
420
|
const s = G(e);
|
|
422
|
-
let
|
|
423
|
-
const u = T(e),
|
|
424
|
-
if (u !== "list" &&
|
|
421
|
+
let l = N(s, n, r);
|
|
422
|
+
const u = T(e), i = g.getConfig(e);
|
|
423
|
+
if (u !== "list" && i.mobileLayoutEnabled && "querySelector" in e) {
|
|
425
424
|
const c = e.querySelector(L);
|
|
426
425
|
if (c) {
|
|
427
|
-
const
|
|
428
|
-
|
|
426
|
+
const a = N(c, n, r);
|
|
427
|
+
l = l || a;
|
|
429
428
|
}
|
|
430
429
|
}
|
|
431
|
-
return
|
|
430
|
+
return l && n.apply(new C("Updated price formatting in-place")), l;
|
|
432
431
|
}
|
|
433
432
|
function Ie(t) {
|
|
434
433
|
const { currentNode: e, documentModifier: n, currency: o } = t, r = P(e);
|
|
435
434
|
if (!r)
|
|
436
435
|
return;
|
|
437
|
-
const s = o.alignment === "before" ? "0" : "1",
|
|
438
|
-
n.modifyHtml(r).setAttribute(u,
|
|
436
|
+
const s = o.alignment === "before" ? "0" : "1", l = (u, i) => {
|
|
437
|
+
n.modifyHtml(r).setAttribute(u, i);
|
|
439
438
|
};
|
|
440
|
-
|
|
439
|
+
l(b.CURRENCY, o.code), l(b.SYMBOL, o.symbol), l(b.ALIGNMENT, s), l(b.THOUSAND_SEPARATOR, o.thousandSeparator), l(b.DECIMAL_SEPARATOR, o.decimalSeparator), l(b.DECIMAL_COUNT, o.decimalCount.toString()), n.apply(new C("Update currency attributes"));
|
|
441
440
|
}
|
|
442
441
|
export {
|
|
443
442
|
qe as adjustProductsToSize,
|
|
@@ -1,83 +1,68 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
3
|
-
import { isPartnerManagedBlock as
|
|
1
|
+
import { ModificationDescription as g } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { RECOMMENDATION_ID_ATTR as l } from "../constants/selectors.js";
|
|
3
|
+
import { isPartnerManagedBlock as m, updateProductContentInPlace as d, regenerateProductRowsWithStyles as C } from "../controls/main/utils.js";
|
|
4
4
|
import { RecommendationConfigService as c } from "../services/configService.js";
|
|
5
|
-
import { useRecommendationExtensionStore as
|
|
5
|
+
import { useRecommendationExtensionStore as y } from "../store/recommendation.js";
|
|
6
6
|
let r = null;
|
|
7
|
-
function
|
|
8
|
-
r =
|
|
7
|
+
function M(n) {
|
|
8
|
+
r = n;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
return !
|
|
10
|
+
function a(n) {
|
|
11
|
+
const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
12
|
+
return !e || !("querySelector" in e) ? null : e.querySelector(`[${l}="${n}"]`) ?? null;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
return Object.keys(
|
|
14
|
+
function N(n, e) {
|
|
15
|
+
const o = c.getConfig(n);
|
|
16
|
+
return Object.keys(e).some((t) => JSON.stringify(o[t]) !== JSON.stringify(e[t]));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
return ["filters", "strategy", "strategyId", "size"
|
|
18
|
+
function S(n, e) {
|
|
19
|
+
const o = c.getConfig(n);
|
|
20
|
+
return ["filters", "strategy", "strategyId", "size"].some((t) => t in e && JSON.stringify(o[t]) !== JSON.stringify(e[t]));
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return !1;
|
|
26
|
-
const e = c.getConfig(t);
|
|
27
|
-
return JSON.stringify(e.productIds) !== JSON.stringify(n.productIds);
|
|
28
|
-
}
|
|
29
|
-
function M(t, n, e) {
|
|
30
|
-
const o = l(t);
|
|
31
|
-
if (!r || !o)
|
|
32
|
-
return !1;
|
|
33
|
-
if (y(o, n)) {
|
|
34
|
-
const i = I(o, n) ? p : e;
|
|
35
|
-
c.updateConfig(r, o, n, i);
|
|
36
|
-
}
|
|
37
|
-
return !0;
|
|
22
|
+
function P(n, e, o) {
|
|
23
|
+
const t = a(n);
|
|
24
|
+
return !r || !t ? !1 : (S(t, e) && c.updateConfig(r, t, e, o), !0);
|
|
38
25
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
|
|
26
|
+
function p(n, e) {
|
|
27
|
+
const o = y(), t = o.currentRecommendationId;
|
|
28
|
+
if (t === n || !o.blockStates[n]) {
|
|
29
|
+
e();
|
|
43
30
|
return;
|
|
44
31
|
}
|
|
45
|
-
|
|
32
|
+
o.setCurrentBlock(n);
|
|
46
33
|
try {
|
|
47
|
-
|
|
34
|
+
e();
|
|
48
35
|
} finally {
|
|
49
|
-
|
|
36
|
+
o.$patch({ currentRecommendationId: t });
|
|
50
37
|
}
|
|
51
38
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
return !
|
|
39
|
+
function I(n) {
|
|
40
|
+
const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
|
|
41
|
+
return !e || !("querySelectorAll" in e) ? [] : e.querySelectorAll(`[${l}="${n}"]`).map((o) => c.getConfig(o));
|
|
55
42
|
}
|
|
56
|
-
function
|
|
57
|
-
const i =
|
|
43
|
+
function $(n, e, o, t) {
|
|
44
|
+
const i = a(n);
|
|
58
45
|
if (!r || !i)
|
|
59
46
|
return !1;
|
|
60
|
-
const f = r.getDocumentModifier(), s =
|
|
61
|
-
if (c.stageConfig(f, i,
|
|
62
|
-
return s && f.apply(new
|
|
47
|
+
const f = r.getDocumentModifier(), s = N(i, e);
|
|
48
|
+
if (c.stageConfig(f, i, e), m(i))
|
|
49
|
+
return s && f.apply(new g(t)), !0;
|
|
63
50
|
let u = !1;
|
|
64
|
-
return
|
|
65
|
-
|
|
51
|
+
return p(n, () => {
|
|
52
|
+
d({
|
|
66
53
|
currentNode: i,
|
|
67
54
|
documentModifier: f,
|
|
68
|
-
products:
|
|
55
|
+
products: o,
|
|
69
56
|
onApplied: () => {
|
|
70
57
|
u = !0;
|
|
71
58
|
}
|
|
72
|
-
}) || (u = C({ currentNode: i, documentModifier: f, products:
|
|
73
|
-
}), !u && s && f.apply(new
|
|
59
|
+
}) || (u = C({ currentNode: i, documentModifier: f, products: o }));
|
|
60
|
+
}), !u && s && f.apply(new g(t)), !0;
|
|
74
61
|
}
|
|
75
62
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
J as registerNodeConfigWriter,
|
|
82
|
-
M as writeBlockConfigOutsidePanel
|
|
63
|
+
$ as commitBlockChangeOutsidePanel,
|
|
64
|
+
S as hasEditedConfigChange,
|
|
65
|
+
I as readBlockNodeConfigs,
|
|
66
|
+
M as registerNodeConfigWriter,
|
|
67
|
+
P as writeBlockConfigOutsidePanel
|
|
83
68
|
};
|
|
@@ -1,43 +1,64 @@
|
|
|
1
|
-
import { useRecommendationExtensionStore as
|
|
2
|
-
import { refreshBlockOutsidePanel as
|
|
3
|
-
import { toBlockUrlConfig as
|
|
4
|
-
import {
|
|
5
|
-
function
|
|
6
|
-
const r = JSON.stringify(
|
|
7
|
-
return
|
|
1
|
+
import { useRecommendationExtensionStore as f } from "../store/recommendation.js";
|
|
2
|
+
import { refreshBlockOutsidePanel as l } from "./blockRefresh.js";
|
|
3
|
+
import { toBlockUrlConfig as c } from "./blockUrlConfig.js";
|
|
4
|
+
import { readBlockNodeConfigs as m, commitBlockChangeOutsidePanel as d } from "./nodeConfigWriter.js";
|
|
5
|
+
function u(n, t) {
|
|
6
|
+
const r = JSON.stringify(c(t));
|
|
7
|
+
return m(n).find((s) => JSON.stringify(c(s)) !== r) ?? t;
|
|
8
8
|
}
|
|
9
|
-
async function
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(!!n.strategyId || i === t) && ((m = o.blockStates[i]) == null ? void 0 : m.recommendationConfigs.strategyId) !== n.strategyId && o.seedBlockUrlConfig(i, a(n));
|
|
14
|
-
}), o.resetArrivedBlock(t), await Promise.all(s.map(async (n) => {
|
|
15
|
-
if (!await o.refreshStrategyBlock(n))
|
|
9
|
+
async function y(n, t, r = () => !0) {
|
|
10
|
+
const s = f();
|
|
11
|
+
await Promise.all(n.map(async (e) => {
|
|
12
|
+
if (!await s.refreshStrategyBlock(e))
|
|
16
13
|
return;
|
|
17
|
-
const { recommendationConfigs:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{ size:
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const { recommendationConfigs: a, recommendationProducts: o } = s.blockStates[e];
|
|
15
|
+
r(e, a.size) && d(
|
|
16
|
+
e,
|
|
17
|
+
{ size: a.size },
|
|
18
|
+
o,
|
|
19
|
+
t
|
|
23
20
|
);
|
|
24
21
|
}));
|
|
25
22
|
}
|
|
26
|
-
async function
|
|
27
|
-
|
|
23
|
+
async function w(n, t, r) {
|
|
24
|
+
const s = f(), e = [n, t];
|
|
25
|
+
(/* @__PURE__ */ new Map([[n, u(n, r)], [t, r]])).forEach((o, i) => {
|
|
26
|
+
var g;
|
|
27
|
+
(!!o.strategyId || i === t) && ((g = s.blockStates[i]) == null ? void 0 : g.recommendationConfigs.strategyId) !== o.strategyId && s.seedBlockUrlConfig(i, c(o));
|
|
28
|
+
}), s.resetArrivedBlock(t), await y(e, "Refresh duplicated recommendation strategy");
|
|
29
|
+
}
|
|
30
|
+
async function k(n) {
|
|
31
|
+
const t = f(), r = n.filter(({ config: e }) => !!e.strategyId);
|
|
32
|
+
if (!r.length)
|
|
33
|
+
return;
|
|
34
|
+
r.forEach(({ id: e, config: a }) => t.seedBlockUrlConfig(e, c(a))), t.invalidateStrategies();
|
|
35
|
+
const s = new Map(r.map(({ id: e, config: a }) => [e, a]));
|
|
36
|
+
await y(
|
|
37
|
+
r.map(({ id: e }) => e),
|
|
38
|
+
"Refresh recommendation strategy",
|
|
39
|
+
(e, a) => {
|
|
40
|
+
const o = s.get(e);
|
|
41
|
+
return a !== (o == null ? void 0 : o.size) && m(e).some((i) => i.strategyId === (o == null ? void 0 : o.strategyId));
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
async function O(n, t) {
|
|
46
|
+
if (!f().blockStates[n])
|
|
28
47
|
return !1;
|
|
29
|
-
const r = await
|
|
30
|
-
pickUpdates: ({ strategyId:
|
|
31
|
-
strategyId:
|
|
32
|
-
strategy:
|
|
33
|
-
size:
|
|
34
|
-
configVersion:
|
|
48
|
+
const r = await l(n, {
|
|
49
|
+
pickUpdates: ({ strategyId: s, strategy: e, size: a, nodeConfigVersion: o }) => ({
|
|
50
|
+
strategyId: s,
|
|
51
|
+
strategy: e,
|
|
52
|
+
size: a,
|
|
53
|
+
configVersion: o
|
|
35
54
|
}),
|
|
36
55
|
description: t
|
|
37
56
|
});
|
|
38
|
-
return r || console.error("[recommendation] strategy change did not reach a node", { blockId:
|
|
57
|
+
return r || console.error("[recommendation] strategy change did not reach a node", { blockId: n }), r;
|
|
39
58
|
}
|
|
40
59
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
60
|
+
O as commitStrategyChange,
|
|
61
|
+
k as refreshArrivedStrategyBlocks,
|
|
62
|
+
w as refreshDuplicatedStrategyBlocks,
|
|
63
|
+
u as resolveSourceConfig
|
|
43
64
|
};
|
|
@@ -19,6 +19,9 @@ export declare class RecommendationBlock extends Block {
|
|
|
19
19
|
private _resetSourceIds;
|
|
20
20
|
/** Ids handed to duplicates the document root does not show yet: a copied module renames all its blocks at once. */
|
|
21
21
|
private _unsettledDuplicateIds;
|
|
22
|
+
private _arrivedBlocks;
|
|
23
|
+
/** Strategy each in-flight arrival or duplicate refresh is fetching, by block id, so a second one does not race it. */
|
|
24
|
+
private _refreshClaims;
|
|
22
25
|
constructor();
|
|
23
26
|
getId(): string;
|
|
24
27
|
getIcon(): string;
|
|
@@ -44,6 +47,8 @@ export declare class RecommendationBlock extends Block {
|
|
|
44
47
|
* @param node - The newly created block node
|
|
45
48
|
*/
|
|
46
49
|
onCreated(node: ImmutableHtmlNode): void;
|
|
50
|
+
/** Refreshes every block of an opened template: Stripo restores a stored document without `onCreated`. */
|
|
51
|
+
onDocumentInit(): void;
|
|
47
52
|
/**
|
|
48
53
|
* Called when the document changes or template is loaded
|
|
49
54
|
*
|
|
@@ -85,15 +90,26 @@ export declare class RecommendationBlock extends Block {
|
|
|
85
90
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
86
91
|
*/
|
|
87
92
|
private _scheduleArrivalReset;
|
|
93
|
+
/**
|
|
94
|
+
* Re-reads the strategy of a block that arrived with saved cards, without waiting for a click.
|
|
95
|
+
* Blocks of one opened template or dropped module arrive in one tick and refresh together.
|
|
96
|
+
*/
|
|
97
|
+
private _queueArrivalRefresh;
|
|
98
|
+
private _refreshArrivedBlocks;
|
|
99
|
+
/**
|
|
100
|
+
* A new document reports each block to onCreated and onDocumentInit, not always in one batch, so a
|
|
101
|
+
* claimed block refreshes again only once the document shows it under another strategy (a restored version).
|
|
102
|
+
*/
|
|
103
|
+
private _canClaimRefresh;
|
|
104
|
+
private _releaseRefreshClaim;
|
|
88
105
|
/**
|
|
89
106
|
* Heals a duplicate that slipped past the create-time `_detectDuplicate`
|
|
90
107
|
* scan (or that was persisted by an older template before SD-142352).
|
|
91
108
|
* When two blocks share a `recommendation-id`, the first occurrence in DOM
|
|
92
109
|
* order is treated as the source and any later sibling is reassigned a
|
|
93
|
-
* fresh id
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* will seed the new id from that. Skipping `setCurrentBlock` avoids
|
|
110
|
+
* fresh id and queued for the arrival refresh, which seeds the new id's
|
|
111
|
+
* store entry from its persisted `esd-ext-config`. The source's store
|
|
112
|
+
* entry is not cloned and focus is not moved. Skipping `setCurrentBlock` avoids
|
|
97
113
|
* yanking the user's current selection mid-edit when the heal fires from
|
|
98
114
|
* `onDocumentChanged`.
|
|
99
115
|
*/
|
|
@@ -109,9 +125,9 @@ export declare class RecommendationBlock extends Block {
|
|
|
109
125
|
*
|
|
110
126
|
* Used by `_handleDuplicate` at create-time (which additionally clones the
|
|
111
127
|
* store entry and focuses the new block) and by `_healLingeringDuplicate`
|
|
112
|
-
* at document-change time (which
|
|
113
|
-
*
|
|
114
|
-
*
|
|
128
|
+
* at document-change time (which skips the clone and focus change so older
|
|
129
|
+
* bug-affected templates can self-repair without disturbing the user's
|
|
130
|
+
* current selection, and queues the arrival refresh for the new id).
|
|
115
131
|
*/
|
|
116
132
|
private _reassignDuplicateId;
|
|
117
133
|
/**
|