@useinsider/guido 3.2.0-beta.da93bda → 3.2.0-beta.dc55d68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/config/schemas.js +150 -94
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +88 -87
- package/dist/composables/useRecommendation.js +16 -12
- package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
- package/dist/config/migrator/recommendation/extractors.js +27 -0
- package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +2 -1
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/Recommendation/block.js +35 -32
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
- package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +21 -19
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
- package/dist/node_modules/valibot/dist/index.js +450 -235
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/defaults.d.ts +5 -1
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +213 -0
- package/dist/src/@types/config/types.d.ts +9 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +56 -0
- package/dist/src/composables/useRecommendation.test.d.ts +1 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
- package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/stores/config.d.ts +504 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/utils/htmlEscape.js +13 -0
- package/package.json +7 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RecommendationFeedSourceMaps as g, URLS as p } from "../enums/extensions/recommendationBlock.js";
|
|
2
|
-
import { MinDeviceViewport as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
4
|
-
import { generateCompleteFilterQuery as
|
|
5
|
-
import { useConfigStore as
|
|
2
|
+
import { MinDeviceViewport as I, DefaultPadding as R } from "../enums/recommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
import { generateCompleteFilterQuery as b } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
|
+
import { useConfigStore as x } from "../stores/config.js";
|
|
6
6
|
const N = () => ({
|
|
7
7
|
calculateCardWidth: ({
|
|
8
8
|
mobileLeftPadding: i,
|
|
@@ -10,11 +10,11 @@ const N = () => ({
|
|
|
10
10
|
cardsInRow: o,
|
|
11
11
|
unresponsive: a
|
|
12
12
|
}) => {
|
|
13
|
-
const r = a ? o : 1, e = i + n + (r - 1) *
|
|
14
|
-
return (
|
|
13
|
+
const r = a ? o : 1, e = i + n + (r - 1) * R;
|
|
14
|
+
return (I - e) / r;
|
|
15
15
|
},
|
|
16
16
|
getRecommendationCampaignData: (i) => {
|
|
17
|
-
const n =
|
|
17
|
+
const n = l(), o = Number(i), a = n.blockStates[o];
|
|
18
18
|
if (!a)
|
|
19
19
|
return {
|
|
20
20
|
textTrimming: !1,
|
|
@@ -44,14 +44,18 @@ const N = () => ({
|
|
|
44
44
|
},
|
|
45
45
|
buildCampaignUrl: (i) => {
|
|
46
46
|
var m;
|
|
47
|
-
const n =
|
|
47
|
+
const n = l(), o = x(), a = Number(i), r = n.blockStates[a];
|
|
48
48
|
if (!r)
|
|
49
49
|
return "";
|
|
50
|
-
const { recommendationConfigs: e } = r,
|
|
51
|
-
t.set("locale", e.language), t.set("currency", e.currencySettings.value), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising"
|
|
52
|
-
|
|
50
|
+
const { recommendationConfigs: e } = r, u = ((m = g.find((s) => s.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
51
|
+
if (t.set("locale", e.language), t.set("currency", e.currencySettings.value), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising") {
|
|
52
|
+
const s = parseInt(e.size) || 6;
|
|
53
|
+
t.set("productId", e.productIds.slice(0, s).join(","));
|
|
54
|
+
} else e.strategy === "similarViewed" && t.set("productId", "{itemId}");
|
|
55
|
+
e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
56
|
+
const f = e.filters.filter((s) => s.isValid), c = b(f);
|
|
53
57
|
c && t.set("filter", c), e.shuffleProducts && t.set("shuffle", "true");
|
|
54
|
-
const d = `${p.RECOMMENDATION_API_URL}/v2/${
|
|
58
|
+
const d = `${p.RECOMMENDATION_API_URL}/v2/${u}?${t.toString()}`;
|
|
55
59
|
return n.recommendationCampaignUrls[i] = d, d;
|
|
56
60
|
}
|
|
57
61
|
});
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
import { usePartner as
|
|
2
|
-
import { LINK_REGEXES as p, LINK_TYPES as
|
|
3
|
-
import { parsePageList as
|
|
4
|
-
import { useConfigStore as
|
|
5
|
-
import { useDynamicContentStore as
|
|
6
|
-
import { useUnsubscribeStore as
|
|
7
|
-
|
|
1
|
+
import { usePartner as U } from "../../composables/usePartner.js";
|
|
2
|
+
import { LINK_REGEXES as p, PRODUCT_TYPE_URL_SEGMENTS as R, LINK_TYPES as _, INSIDER_ID as m, URLS as y } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { parsePageList as N } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
4
|
+
import { useConfigStore as C } from "../../stores/config.js";
|
|
5
|
+
import { useDynamicContentStore as L } from "../../stores/dynamic-content.js";
|
|
6
|
+
import { useUnsubscribeStore as P } from "../../stores/unsubscribe.js";
|
|
7
|
+
import { ProductType as B } from "../../@types/config/schemas.js";
|
|
8
|
+
import "../../@types/config/defaults.js";
|
|
9
|
+
const F = [
|
|
8
10
|
{
|
|
9
11
|
id: "add-unsubscribe-link-values",
|
|
10
12
|
description: "Adding unsubscribe link values",
|
|
11
13
|
type: "custom",
|
|
12
|
-
processor: (
|
|
13
|
-
const { getPartnerName: i } =
|
|
14
|
-
if (!
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
processor: (s) => {
|
|
15
|
+
const { getPartnerName: i } = U(), n = C(), t = L(), E = P(), c = n.variationId;
|
|
16
|
+
if (!c)
|
|
17
|
+
return s;
|
|
18
|
+
const r = R[n.productType] ?? R[B.EMAIL];
|
|
19
|
+
let e = s;
|
|
20
|
+
const d = `/${i()}/${r}/${c}?user={{iid}}`, f = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
|
|
21
|
+
let a = !1, l = !1;
|
|
22
|
+
return f.forEach((g) => {
|
|
23
|
+
var S;
|
|
24
|
+
const u = g.getAttribute("data-unsubscribe-page-list");
|
|
22
25
|
if (!u)
|
|
23
26
|
return;
|
|
24
|
-
const
|
|
25
|
-
(
|
|
27
|
+
const I = N(u), b = ((S = E.templates) == null ? void 0 : S.filter(
|
|
28
|
+
(o) => I.includes(o.id)
|
|
26
29
|
)) ?? [];
|
|
27
|
-
|
|
28
|
-
}), (
|
|
30
|
+
a = a || b.some((o) => o.type === _.UNSUBSCRIBE_LINK_TYPE), l = l || b.some((o) => o.type === _.PREFERENCES_LINK_TYPE);
|
|
31
|
+
}), (a || l) && (t.selectedDynamicContentList.some((u) => u.value === m) || t.selectedDynamicContentList.push({
|
|
29
32
|
text: m,
|
|
30
33
|
value: m,
|
|
31
34
|
fallback: ""
|
|
32
|
-
})),
|
|
35
|
+
})), a && (e = e.replace(
|
|
33
36
|
p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
|
|
34
|
-
|
|
37
|
+
y.UNSUBSCRIBE_URL + d
|
|
35
38
|
)), l && (e = e.replace(
|
|
36
39
|
p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
|
|
37
|
-
|
|
38
|
-
)),
|
|
40
|
+
y.PREFERENCES_URL + d
|
|
41
|
+
)), f.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
|
|
39
42
|
},
|
|
40
43
|
priority: 60
|
|
41
44
|
},
|
|
@@ -52,25 +55,25 @@ const G = [
|
|
|
52
55
|
id: "format-comment-braces",
|
|
53
56
|
description: "Adding spaces around comment braces for proper formatting",
|
|
54
57
|
type: "custom",
|
|
55
|
-
processor: (
|
|
58
|
+
processor: (s) => s.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
|
|
56
59
|
priority: 62
|
|
57
60
|
},
|
|
58
61
|
{
|
|
59
62
|
id: "add-universal-link-flags",
|
|
60
63
|
description: "Adding universal link flags",
|
|
61
64
|
type: "custom",
|
|
62
|
-
processor: (
|
|
63
|
-
let i =
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
if (
|
|
65
|
+
processor: (s) => {
|
|
66
|
+
let i = s;
|
|
67
|
+
const n = i.match(/<a[^>]+>(.*?)<\/a>/gm);
|
|
68
|
+
return n && n.forEach((t) => {
|
|
69
|
+
if (t.includes("insEmail=1"))
|
|
67
70
|
return;
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
return
|
|
71
|
+
if (t.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
|
|
72
|
+
const c = t.replace(/href=(["'`”])(.*?)\1/gm, (r) => {
|
|
73
|
+
const e = r.slice(6, r.length - 1).trim();
|
|
74
|
+
return r.includes("?") || r.includes("#") ? e.slice(-1) === "&" ? r.replace(e, `${e}insEmail=1`) : r.replace(e, `${e}&insEmail=1`) : r.replace(e, `${e}?insEmail=1`);
|
|
72
75
|
});
|
|
73
|
-
i = i.replace(
|
|
76
|
+
i = i.replace(t, c);
|
|
74
77
|
}
|
|
75
78
|
}), i;
|
|
76
79
|
},
|
|
@@ -78,5 +81,5 @@ const G = [
|
|
|
78
81
|
}
|
|
79
82
|
];
|
|
80
83
|
export {
|
|
81
|
-
|
|
84
|
+
F as unsubscribeCompilerRules
|
|
82
85
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateItemsBlock as
|
|
4
|
-
import { migrateRadioButton as
|
|
5
|
-
import { migrateRecommendation as
|
|
6
|
-
import { migrateUnsubscribe as
|
|
7
|
-
const
|
|
1
|
+
import { migrateCheckbox as o } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateRadioButton as a } from "./radioButtonMigrator.js";
|
|
5
|
+
import { migrateRecommendation as g } from "./recommendationMigrator.js";
|
|
6
|
+
import { migrateUnsubscribe as n } from "./unsubscribeMigrator.js";
|
|
7
|
+
const b = async (r, t = {}) => {
|
|
8
8
|
let m = r;
|
|
9
|
-
return m =
|
|
9
|
+
return m = o(m), m = a(m), m = await n(m), m = i(m), m = g(m, t), m = e(m), m;
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
b as migrate
|
|
13
13
|
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { DEFAULT_COMPOSITION as d, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
3
|
+
import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
|
|
4
|
+
const C = "__title__", a = "product_attribute.";
|
|
5
|
+
function N(r) {
|
|
6
|
+
const t = r.variable ?? "";
|
|
7
|
+
switch (t) {
|
|
8
|
+
case "p_recommendation_title":
|
|
9
|
+
return { key: C, kind: "title" };
|
|
10
|
+
case "p_image":
|
|
11
|
+
return { key: y, kind: "image" };
|
|
12
|
+
case "p_name":
|
|
13
|
+
return { key: h, kind: "text" };
|
|
14
|
+
case "p_price":
|
|
15
|
+
return { key: R, kind: "text" };
|
|
16
|
+
case "p_original_price":
|
|
17
|
+
return { key: f, kind: "text" };
|
|
18
|
+
case "p_omnibus_price":
|
|
19
|
+
return { key: x, kind: "text" };
|
|
20
|
+
case "p_omnibus_discount":
|
|
21
|
+
return { key: A, kind: "text" };
|
|
22
|
+
case "p_button":
|
|
23
|
+
return { key: k, kind: "button" };
|
|
24
|
+
default:
|
|
25
|
+
if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
|
|
26
|
+
const s = r.value ?? "", o = s.startsWith(a) ? s.slice(a.length) : s;
|
|
27
|
+
return o ? {
|
|
28
|
+
key: `${l}${o}`,
|
|
29
|
+
kind: "custom",
|
|
30
|
+
customAttrName: o,
|
|
31
|
+
customAttrValue: s || `${a}${o}`
|
|
32
|
+
} : null;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function p(r) {
|
|
38
|
+
const t = d.indexOf(r);
|
|
39
|
+
return t === -1 ? Number.POSITIVE_INFINITY : t;
|
|
40
|
+
}
|
|
41
|
+
function S(r) {
|
|
42
|
+
const t = {
|
|
43
|
+
composition: [],
|
|
44
|
+
visibility: { ...I },
|
|
45
|
+
customAttributes: [],
|
|
46
|
+
customAttrValues: {},
|
|
47
|
+
perElementStyles: {},
|
|
48
|
+
anyTextTrimming: !1
|
|
49
|
+
};
|
|
50
|
+
if (!r || r.length === 0)
|
|
51
|
+
return t.composition = [...d], t;
|
|
52
|
+
const s = [];
|
|
53
|
+
r.forEach((e, i) => {
|
|
54
|
+
const n = N(e);
|
|
55
|
+
if (n) {
|
|
56
|
+
if (n.kind === "title") {
|
|
57
|
+
t.titleVariable = e;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
s.push({
|
|
61
|
+
key: n.key,
|
|
62
|
+
kind: n.kind,
|
|
63
|
+
hidden: e.hidden === !0,
|
|
64
|
+
positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
|
|
65
|
+
legacy: e,
|
|
66
|
+
customAttrName: n.customAttrName,
|
|
67
|
+
customAttrValue: n.customAttrValue,
|
|
68
|
+
originalIndex: i
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}), s.sort((e, i) => {
|
|
72
|
+
if (e.positionIdx !== i.positionIdx)
|
|
73
|
+
return e.positionIdx - i.positionIdx;
|
|
74
|
+
const n = p(e.key), u = p(i.key);
|
|
75
|
+
return n !== u ? n - u : e.originalIndex - i.originalIndex;
|
|
76
|
+
});
|
|
77
|
+
const o = {};
|
|
78
|
+
return s.forEach((e) => {
|
|
79
|
+
const { key: i, kind: n, hidden: u, legacy: m, customAttrName: c, customAttrValue: T } = e;
|
|
80
|
+
switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && c && T && (t.customAttributes.includes(c) || t.customAttributes.push(c), t.customAttrValues[i] = T), n) {
|
|
81
|
+
case "image":
|
|
82
|
+
o[i] = b(m.theme);
|
|
83
|
+
break;
|
|
84
|
+
case "button":
|
|
85
|
+
o[i] = O(m.theme);
|
|
86
|
+
break;
|
|
87
|
+
case "text":
|
|
88
|
+
case "custom": {
|
|
89
|
+
const _ = E(m.theme);
|
|
90
|
+
o[i] = _, _.textTrimming && (t.anyTextTrimming = !0);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}), t.perElementStyles = o, t;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
S as mapComposition
|
|
98
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const i = "You May Also Like!";
|
|
2
|
+
function s(r) {
|
|
3
|
+
var e;
|
|
4
|
+
const o = r.querySelector(".ext-recommendation-title");
|
|
5
|
+
if (!o)
|
|
6
|
+
return i;
|
|
7
|
+
const t = (e = o.textContent) == null ? void 0 : e.trim();
|
|
8
|
+
return t && t.length > 0 ? t : i;
|
|
9
|
+
}
|
|
10
|
+
function u(r) {
|
|
11
|
+
const o = [
|
|
12
|
+
r,
|
|
13
|
+
...Array.from(r.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
14
|
+
];
|
|
15
|
+
let t = "";
|
|
16
|
+
return o.some((e) => {
|
|
17
|
+
const n = e.getAttribute("bgcolor");
|
|
18
|
+
if (n && n.trim())
|
|
19
|
+
return t = n.trim(), !0;
|
|
20
|
+
const c = (e.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
21
|
+
return c && c[1] ? (t = c[1].trim(), !0) : !1;
|
|
22
|
+
}), t;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
u as extractCardBgColor,
|
|
26
|
+
s as extractTitleText
|
|
27
|
+
};
|