@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.
Files changed (61) hide show
  1. package/dist/@types/config/schemas.js +150 -94
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +88 -87
  4. package/dist/composables/useRecommendation.js +16 -12
  5. package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
  6. package/dist/config/migrator/index.js +9 -9
  7. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  8. package/dist/config/migrator/recommendation/extractors.js +27 -0
  9. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  10. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  11. package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
  12. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  13. package/dist/config/migrator/recommendationMigrator.js +74 -290
  14. package/dist/enums/extensions/recommendationBlock.js +2 -1
  15. package/dist/enums/unsubscribe.js +34 -27
  16. package/dist/extensions/Blocks/Recommendation/block.js +35 -32
  17. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  18. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
  19. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  20. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +21 -19
  21. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  22. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  23. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  24. package/dist/guido.css +1 -1
  25. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
  26. package/dist/node_modules/valibot/dist/index.js +450 -235
  27. package/dist/package.json.js +1 -1
  28. package/dist/src/@types/config/defaults.d.ts +5 -1
  29. package/dist/src/@types/config/index.d.ts +3 -3
  30. package/dist/src/@types/config/schemas.d.ts +213 -0
  31. package/dist/src/@types/config/types.d.ts +9 -1
  32. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  33. package/dist/src/composables/useConfig.d.ts +56 -0
  34. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  35. package/dist/src/config/migrator/index.d.ts +2 -1
  36. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  37. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  38. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  39. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  40. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  41. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  42. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  43. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  44. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  45. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  46. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  47. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  48. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  49. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  50. package/dist/src/enums/unsubscribe.d.ts +5 -0
  51. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  52. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  53. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  54. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  56. package/dist/src/stores/config.d.ts +504 -0
  57. package/dist/src/utils/htmlEscape.d.ts +5 -0
  58. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  59. package/dist/utils/htmlEscape.js +13 -0
  60. package/package.json +7 -3
  61. 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 R, DefaultPadding as b } from "../enums/recommendation.js";
3
- import { useRecommendationExtensionStore as u } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { generateCompleteFilterQuery as x } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
- import { useConfigStore as I } from "../stores/config.js";
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) * b;
14
- return (R - e) / r;
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 = u(), o = Number(i), a = n.blockStates[o];
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 = u(), o = I(), a = Number(i), r = n.blockStates[a];
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, l = ((m = g.find((s) => s.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
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" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
52
- const f = e.filters.filter((s) => s.isValid), c = x(f);
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/${l}?${t.toString()}`;
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 y } from "../../composables/usePartner.js";
2
- import { LINK_REGEXES as p, LINK_TYPES as S, INSIDER_ID as m, URLS as R } from "../../enums/unsubscribe.js";
3
- import { parsePageList as I } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
4
- import { useConfigStore as N } from "../../stores/config.js";
5
- import { useDynamicContentStore as U } from "../../stores/dynamic-content.js";
6
- import { useUnsubscribeStore as C } from "../../stores/unsubscribe.js";
7
- const G = [
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: (t) => {
13
- const { getPartnerName: i } = y(), o = N(), s = U(), d = C(), a = o.variationId;
14
- if (!a)
15
- return t;
16
- let e = t;
17
- const r = `/${i()}/email/${a}?user={{iid}}`, E = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
18
- let c = !1, l = !1;
19
- return E.forEach((f) => {
20
- var b;
21
- const u = f.getAttribute("data-unsubscribe-page-list");
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 _ = I(u), g = ((b = d.templates) == null ? void 0 : b.filter(
25
- (n) => _.includes(n.id)
27
+ const I = N(u), b = ((S = E.templates) == null ? void 0 : S.filter(
28
+ (o) => I.includes(o.id)
26
29
  )) ?? [];
27
- c = c || g.some((n) => n.type === S.UNSUBSCRIBE_LINK_TYPE), l = l || g.some((n) => n.type === S.PREFERENCES_LINK_TYPE);
28
- }), (c || l) && (s.selectedDynamicContentList.some((u) => u.value === m) || s.selectedDynamicContentList.push({
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
- })), c && (e = e.replace(
35
+ })), a && (e = e.replace(
33
36
  p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
34
- R.UNSUBSCRIBE_URL + r
37
+ y.UNSUBSCRIBE_URL + d
35
38
  )), l && (e = e.replace(
36
39
  p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
37
- R.PREFERENCES_URL + r
38
- )), E.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
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: (t) => t.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
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: (t) => {
63
- let i = t;
64
- const o = i.match(/<a[^>]+>(.*?)<\/a>/gm);
65
- return o && o.forEach((s) => {
66
- if (s.includes("insEmail=1"))
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 (s.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
69
- const a = s.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
70
- const r = e.slice(6, e.length - 1).trim();
71
- return e.includes("?") || e.includes("#") ? r.slice(-1) === "&" ? e.replace(r, `${r}insEmail=1`) : e.replace(r, `${r}&insEmail=1`) : e.replace(r, `${r}?insEmail=1`);
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(s, a);
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
- G as unsubscribeCompilerRules
84
+ F as unsubscribeCompilerRules
82
85
  };
@@ -1,13 +1,13 @@
1
- import { migrateCheckbox as t } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as o } from "./couponBlockMigrator.js";
3
- import { migrateItemsBlock as i } from "./itemsBlockMigrator.js";
4
- import { migrateRadioButton as e } from "./radioButtonMigrator.js";
5
- import { migrateRecommendation as a } from "./recommendationMigrator.js";
6
- import { migrateUnsubscribe as g } from "./unsubscribeMigrator.js";
7
- const u = async (r) => {
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 = t(m), m = e(m), m = await g(m), m = o(m), m = a(m), m = i(m), 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
- u as migrate
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
+ };