@useinsider/guido 3.20.0 → 3.20.1-beta.10fbbe9
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/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +25 -24
- 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 +70 -75
- package/dist/guido.css +1 -1
- 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 +1 -6
- 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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const R = ".ins-product-td", T = ".ins-product-wrapper", s = "width: 100%", c = /(^|;)\s*width\s*:\s*0(?:px|%)?\s*(?:!important)?\s*(?=;|$)/i, n = new RegExp(c.source, "gi"), o = /(^|;)\s*width\s*:/i, _ = /^0(?:px|%)?$/i, a = (t) => _.test((t ?? "").trim()), E = (t) => c.test(t), h = (t) => {
|
|
2
|
+
if (E(t))
|
|
3
|
+
return t.replace(
|
|
4
|
+
n,
|
|
5
|
+
(i, e) => `${e}${e ? " " : ""}${s}`
|
|
6
|
+
);
|
|
7
|
+
if (o.test(t))
|
|
8
|
+
return t;
|
|
9
|
+
const r = t.trim();
|
|
10
|
+
return r ? r.endsWith(";") ? `${r} ${s};` : `${r}; ${s};` : `${s};`;
|
|
11
|
+
}, p = (t) => t.replace(n, (r, i) => i).replace(/;{2,}/g, ";").replace(/^\s*;\s*/, "").replace(/;\s*$/, "").trim();
|
|
12
|
+
export {
|
|
13
|
+
R as PRODUCT_TD_SELECTOR,
|
|
14
|
+
T as PRODUCT_WRAPPER_SELECTOR,
|
|
15
|
+
s as WIDTH_PIN_DECLARATION,
|
|
16
|
+
E as hasZeroWidthDeclaration,
|
|
17
|
+
a as isZeroWidthValue,
|
|
18
|
+
h as withWidthPin,
|
|
19
|
+
p as withoutZeroWidth
|
|
20
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const t = `{-{-TEMPLATE_FIRST_LINE-}-}
|
|
2
|
-
<table class="es-left ins-product-wrapper" cellspacing="0" cellpadding="0" align="left" width="100%">
|
|
2
|
+
<table class="es-left ins-product-wrapper" cellspacing="0" cellpadding="0" align="left" width="100%" style="width: 100%;">
|
|
3
3
|
<tbody>
|
|
4
4
|
<tr>
|
|
5
5
|
<td class="es-p20b es-p10r es-p10l es-m-p20b es-p10t" width="100%" align="center">
|
|
@@ -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,20 +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 :
|
|
100
|
-
...o ? { partnerName:
|
|
103
|
+
configVersion: n ? N : w,
|
|
104
|
+
...o ? { partnerName: g().partnerName.value } : {},
|
|
101
105
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
102
106
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
103
107
|
// at save for a block the user never configured.
|
|
104
108
|
...o ? { strategy: "" } : {}
|
|
105
109
|
}
|
|
106
|
-
), f =
|
|
107
|
-
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted),
|
|
110
|
+
), f = h();
|
|
111
|
+
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), c) {
|
|
108
112
|
I(this.api);
|
|
109
113
|
const _ = this._getBlockElement(t);
|
|
110
114
|
_ && (R(this.api, _, !0), M({
|
|
@@ -134,11 +138,11 @@ class j extends E {
|
|
|
134
138
|
}
|
|
135
139
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
136
140
|
try {
|
|
137
|
-
|
|
141
|
+
y || (I(this.api), y = !0);
|
|
138
142
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
139
143
|
if (i) {
|
|
140
144
|
const n = !e.mobileLayoutEnabled;
|
|
141
|
-
|
|
145
|
+
O(i) !== n && R(this.api, i, n);
|
|
142
146
|
}
|
|
143
147
|
} catch {
|
|
144
148
|
}
|
|
@@ -152,7 +156,7 @@ class j extends E {
|
|
|
152
156
|
*/
|
|
153
157
|
onDelete(t) {
|
|
154
158
|
const e = this._getRecommendationId(t);
|
|
155
|
-
e &&
|
|
159
|
+
e && h().removeBlockState(e);
|
|
156
160
|
}
|
|
157
161
|
/**
|
|
158
162
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -168,7 +172,7 @@ class j extends E {
|
|
|
168
172
|
*/
|
|
169
173
|
_warnIfMultipleBlocks() {
|
|
170
174
|
try {
|
|
171
|
-
|
|
175
|
+
T().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
172
176
|
} catch {
|
|
173
177
|
}
|
|
174
178
|
}
|
|
@@ -178,17 +182,20 @@ class j extends E {
|
|
|
178
182
|
*/
|
|
179
183
|
_generateNextId() {
|
|
180
184
|
let t = 0;
|
|
185
|
+
const e = /* @__PURE__ */ new Set();
|
|
181
186
|
try {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
if ("getAttribute" in
|
|
185
|
-
const
|
|
186
|
-
|
|
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);
|
|
187
192
|
}
|
|
188
193
|
});
|
|
189
194
|
} catch {
|
|
190
195
|
}
|
|
191
|
-
return
|
|
196
|
+
return this._unsettledDuplicateIds.forEach((i) => {
|
|
197
|
+
e.has(i) && this._unsettledDuplicateIds.delete(i);
|
|
198
|
+
}), Math.max(t, ...this._unsettledDuplicateIds) + 1;
|
|
192
199
|
}
|
|
193
200
|
/**
|
|
194
201
|
* Drops the "already fetched" claims of a block that arrived holding a baked id
|
|
@@ -198,9 +205,9 @@ class j extends E {
|
|
|
198
205
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
199
206
|
*/
|
|
200
207
|
_scheduleArrivalReset(t) {
|
|
201
|
-
|
|
208
|
+
g().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
202
209
|
const e = this._getRecommendationId(t);
|
|
203
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
210
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && h().resetArrivedBlock(e);
|
|
204
211
|
}, 0);
|
|
205
212
|
}
|
|
206
213
|
/**
|
|
@@ -231,9 +238,9 @@ class j extends E {
|
|
|
231
238
|
if (!o)
|
|
232
239
|
return;
|
|
233
240
|
let r = -1;
|
|
234
|
-
for (let
|
|
235
|
-
if (n[
|
|
236
|
-
r =
|
|
241
|
+
for (let c = 0; c < n.length; c++)
|
|
242
|
+
if (n[c] === o) {
|
|
243
|
+
r = c;
|
|
237
244
|
break;
|
|
238
245
|
}
|
|
239
246
|
if (r <= 0)
|
|
@@ -256,8 +263,8 @@ class j extends E {
|
|
|
256
263
|
}
|
|
257
264
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
258
265
|
_handleDuplicate(t, e) {
|
|
259
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
260
|
-
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();
|
|
261
268
|
}
|
|
262
269
|
/**
|
|
263
270
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -272,7 +279,7 @@ class j extends E {
|
|
|
272
279
|
*/
|
|
273
280
|
_reassignDuplicateId(t, e) {
|
|
274
281
|
const i = this._generateNextId(), n = this._getBlockElement(t);
|
|
275
|
-
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(
|
|
276
283
|
this.api,
|
|
277
284
|
t,
|
|
278
285
|
{ recommendationId: i },
|
|
@@ -313,7 +320,7 @@ class j extends E {
|
|
|
313
320
|
*/
|
|
314
321
|
_stampHidePrice(t, e) {
|
|
315
322
|
const i = this._getBlockElement(t);
|
|
316
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
323
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(D, String(e)).apply(new p("Stamp hide-price"));
|
|
317
324
|
}
|
|
318
325
|
/**
|
|
319
326
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -321,7 +328,7 @@ class j extends E {
|
|
|
321
328
|
*/
|
|
322
329
|
_healHidePriceAttr(t) {
|
|
323
330
|
const e = this._getBlockElement(t);
|
|
324
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
331
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(D) !== null)
|
|
325
332
|
return;
|
|
326
333
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
327
334
|
this._stampHidePrice(t, i);
|
|
@@ -359,5 +366,5 @@ class j extends E {
|
|
|
359
366
|
}
|
|
360
367
|
export {
|
|
361
368
|
k as BLOCK_ID,
|
|
362
|
-
|
|
369
|
+
Y as RecommendationBlock
|
|
363
370
|
};
|