@useinsider/guido 3.2.0-beta.caa22bf → 3.2.0-beta.ccaf9f5

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 (79) hide show
  1. package/README.md +0 -92
  2. package/dist/@types/config/schemas.js +94 -150
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +75 -75
  5. package/dist/composables/useCortexBlueprintBridge.js +38 -0
  6. package/dist/composables/useEmailTemplateApplier.js +41 -0
  7. package/dist/composables/useRecommendation.js +26 -46
  8. package/dist/composables/useSave.js +18 -21
  9. package/dist/composables/useStripo.js +16 -14
  10. package/dist/config/compiler/recommendationCompilerRules.js +27 -27
  11. package/dist/config/migrator/index.js +9 -9
  12. package/dist/config/migrator/radioButtonMigrator.js +44 -64
  13. package/dist/config/migrator/recommendationMigrator.js +290 -74
  14. package/dist/enums/displayConditions.js +80 -0
  15. package/dist/enums/extensions/recommendationBlock.js +1 -2
  16. package/dist/extensions/Blocks/RadioButton/template.js +1 -1
  17. package/dist/extensions/Blocks/Recommendation/block.js +32 -35
  18. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  19. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +24 -25
  20. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +181 -228
  21. package/dist/extensions/Blocks/Recommendation/services/configService.js +29 -65
  22. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +90 -130
  23. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  24. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  25. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  26. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +22 -13
  27. package/dist/guido.css +1 -1
  28. package/dist/node_modules/valibot/dist/index.js +235 -450
  29. package/dist/src/@types/config/defaults.d.ts +1 -5
  30. package/dist/src/@types/config/index.d.ts +3 -3
  31. package/dist/src/@types/config/schemas.d.ts +0 -213
  32. package/dist/src/@types/config/types.d.ts +1 -9
  33. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  34. package/dist/src/composables/useConfig.d.ts +0 -56
  35. package/dist/src/composables/useCortexBlueprintBridge.d.ts +17 -0
  36. package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
  37. package/dist/src/composables/useRecommendation.d.ts +1 -10
  38. package/dist/src/config/migrator/index.d.ts +1 -2
  39. package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -13
  40. package/dist/src/enums/displayConditions.d.ts +2 -0
  41. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  42. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -10
  43. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -34
  44. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  45. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +3 -0
  46. package/dist/src/library.d.ts +1 -1
  47. package/dist/src/stores/config.d.ts +0 -504
  48. package/dist/utils/templatePreparation.js +32 -72
  49. package/package.json +1 -5
  50. package/dist/composables/validators/useCouponBlockValidator.js +0 -24
  51. package/dist/config/migrator/recommendation/compositionMapper.js +0 -98
  52. package/dist/config/migrator/recommendation/extractors.js +0 -27
  53. package/dist/config/migrator/recommendation/htmlBuilder.js +0 -496
  54. package/dist/config/migrator/recommendation/parseLegacyConfig.js +0 -33
  55. package/dist/config/migrator/recommendation/settingsMapper.js +0 -70
  56. package/dist/config/migrator/recommendation/themeMapper.js +0 -93
  57. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +0 -21
  58. package/dist/src/composables/useRecommendation.test.d.ts +0 -1
  59. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
  60. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +0 -2
  61. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +0 -1
  62. package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -7
  63. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +0 -1
  64. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -11
  65. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +0 -15
  66. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +0 -1
  67. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +0 -7
  68. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +0 -1
  69. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +0 -5
  70. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +0 -1
  71. package/dist/src/config/migrator/recommendation/types.d.ts +0 -205
  72. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +0 -1
  73. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +0 -1
  74. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +0 -1
  75. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +0 -21
  76. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +0 -1
  77. package/dist/src/utils/htmlEscape.d.ts +0 -5
  78. package/dist/src/utils/htmlEscape.test.d.ts +0 -1
  79. package/dist/utils/htmlEscape.js +0 -13
@@ -1,93 +1,53 @@
1
1
  import { useActionsApi as T } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as C } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
- import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as P } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as D } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as E } from "../stores/unsubscribe.js";
9
- function U(i, r) {
10
- const s = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), c = [];
11
- return s.forEach((t) => {
12
- const o = t.getAttribute(y.PAGE_LIST);
13
- o && c.push(...P(o));
14
- }), r.filter((t) => c.includes(t));
2
+ import { useHtmlCompiler as P } from "../composables/useHtmlCompiler.js";
3
+ import { useRecommendationExtensionStore as A } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { DATA_ATTRIBUTES as l } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
5
+ import { parsePageList as h } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
6
+ import { useDynamicContentStore as C } from "../stores/dynamic-content.js";
7
+ import { useUnsubscribeStore as D } from "../stores/unsubscribe.js";
8
+ function x(i, e) {
9
+ const r = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${l.PAGE_LIST}]`), n = [];
10
+ return r.forEach((t) => {
11
+ const o = t.getAttribute(l.PAGE_LIST);
12
+ o && n.push(...h(o));
13
+ }), e.filter((t) => n.includes(t));
15
14
  }
16
- function F(i) {
17
- const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
18
- if (m.length === 0)
19
- return;
20
- const d = b();
21
- m.forEach((s) => {
22
- var g, f, u, n, S;
23
- const c = s.getAttribute("recommendation-id"), t = c ? Number(c) : NaN;
24
- if (!Number.isFinite(t))
25
- return;
26
- const o = s.getAttribute("esd-ext-config");
27
- if (!o)
28
- return;
29
- let e;
30
- try {
31
- e = JSON.parse(o);
32
- } catch {
33
- return;
34
- }
35
- if (!e || typeof e != "object" || Array.isArray(e))
36
- return;
37
- const p = {
38
- strategy: e.strategy ?? a.strategy,
39
- language: e.language ?? a.language,
40
- size: e.size ?? a.size,
41
- // Spread the default arrays so each block gets a fresh reference
42
- // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...a.productIds],
44
- filters: e.filters ?? [...a.filters],
45
- shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
46
- currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? l.code,
47
- currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? l.alignment,
48
- currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? l.decimalCount,
49
- currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? l.decimalSeparator,
50
- currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? l.thousandSeparator
51
- };
52
- d.seedBlockUrlConfig(t, p);
53
- });
54
- }
55
- const _ = () => {
56
- const i = D(), r = E(), { getCompiledEmail: m, getTemplateData: d } = T(), { compileHtml: s } = C();
15
+ const I = () => {
16
+ const i = C(), e = D(), { getCompiledEmail: a, getTemplateData: m } = T(), { compileHtml: r } = P();
57
17
  return {
58
18
  prepareTemplateDetails: async () => {
59
- const { html: t, ampHtml: o = "", ampErrors: e = [] } = await m({
19
+ const { html: t, ampHtml: o = "", ampErrors: p = [] } = await a({
60
20
  minimize: !0,
61
21
  resetDataSavedFlag: !1
62
- }), { html: p, css: g, syncModulesIds: f = [] } = await d();
63
- r.selectedUnsubscribePages.length && await r.fetchTemplates(), F(p);
64
- const { compiledHtml: u, stats: n, appliedRules: S } = s(t), h = i.getSelectedDynamicContentList, A = b();
22
+ }), { html: u, css: d, syncModulesIds: g = [] } = await m();
23
+ e.selectedUnsubscribePages.length && await e.fetchTemplates();
24
+ const { compiledHtml: c, stats: s, appliedRules: S } = r(t), b = i.getSelectedDynamicContentList, f = A();
65
25
  return console.debug("HTML Compilation Stats:", {
66
- originalSize: n.originalSize,
67
- compiledSize: n.compiledSize,
68
- reduction: `${n.reductionPercentage.toFixed(2)}%`,
26
+ originalSize: s.originalSize,
27
+ compiledSize: s.compiledSize,
28
+ reduction: `${s.reductionPercentage.toFixed(2)}%`,
69
29
  appliedRules: S,
70
- executionTime: `${n.executionTime.toFixed(2)}ms`
30
+ executionTime: `${s.executionTime.toFixed(2)}ms`
71
31
  }), {
72
- dynamicContentList: h,
73
- compiledHtml: u,
74
- rawHtml: p,
75
- css: g,
32
+ dynamicContentList: b,
33
+ compiledHtml: c,
34
+ rawHtml: u,
35
+ css: d,
76
36
  ampHtml: o,
77
- ampErrors: e,
78
- modules: f.map(Number),
37
+ ampErrors: p,
38
+ modules: g.map(Number),
79
39
  recommendation: {
80
- campaignUrls: A.recommendationCampaignUrls,
40
+ campaignUrls: f.recommendationCampaignUrls,
81
41
  configs: {}
82
42
  },
83
43
  unsubscribe: {
84
- status: r.unsubscribePagesStatus,
85
- config: U(u, r.selectedUnsubscribePages)
44
+ status: e.unsubscribePagesStatus,
45
+ config: x(c, e.selectedUnsubscribePages)
86
46
  }
87
47
  };
88
48
  }
89
49
  };
90
50
  };
91
51
  export {
92
- _ as useTemplatePreparation
52
+ I as useTemplatePreparation
93
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.2.0-beta.caa22bf",
3
+ "version": "3.2.0-beta.ccaf9f5",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -24,8 +24,6 @@
24
24
  "lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
25
25
  "lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
26
26
  "type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json",
27
- "test": "vitest run",
28
- "test:watch": "vitest",
29
27
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
30
28
  "prepare": "husky",
31
29
  "preinstall": "rm -rf ./node_modules/.vite"
@@ -71,14 +69,12 @@
71
69
  "eslint-plugin-vue": "10.1.0",
72
70
  "eslint-plugin-vue-scoped-css": "2.6.1",
73
71
  "globals": "16.0.0",
74
- "happy-dom": "15.11.7",
75
72
  "husky": "9.1.7",
76
73
  "msw": "2.10.3",
77
74
  "sass": "1.69.7",
78
75
  "typescript": "5.5.4",
79
76
  "typescript-eslint": "8.26.0",
80
77
  "vite-plugin-dts": "4.5.4",
81
- "vitest": "2.1.9",
82
78
  "vue-tsc": "2.2.10"
83
79
  },
84
80
  "overrides": {
@@ -1,24 +0,0 @@
1
- import { ToasterTypeOptions as c } from "../../enums/toaster.js";
2
- import { COUPON_PLACEHOLDER_DEFAULT as i, COUPON_PLACEHOLDER_LIQUID as l } from "../../extensions/Blocks/CouponBlock/template.js";
3
- import { useToaster as m } from "../useToaster.js";
4
- import { useTranslations as p } from "../useTranslations.js";
5
- const u = /* @__PURE__ */ new Set([
6
- i,
7
- l
8
- ]), A = () => {
9
- const { showToaster: t } = m(), r = p();
10
- return { validateCouponBlockTags: (e) => {
11
- const n = new DOMParser().parseFromString(e, "text/html");
12
- return Array.from(n.querySelectorAll(".coupon-block")).find((s) => {
13
- var o;
14
- const a = ((o = s.textContent) == null ? void 0 : o.trim()) ?? "";
15
- return !u.has(a);
16
- }) ? (t({
17
- type: c.Warning,
18
- message: r("newsletter.coupon-tag-modified")
19
- }), !1) : !0;
20
- } };
21
- };
22
- export {
23
- A as useCouponBlockValidator
24
- };
@@ -1,98 +0,0 @@
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
- };
@@ -1,27 +0,0 @@
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
- };