@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.
- package/README.md +0 -92
- package/dist/@types/config/schemas.js +94 -150
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +75 -75
- package/dist/composables/useCortexBlueprintBridge.js +38 -0
- package/dist/composables/useEmailTemplateApplier.js +41 -0
- package/dist/composables/useRecommendation.js +26 -46
- package/dist/composables/useSave.js +18 -21
- package/dist/composables/useStripo.js +16 -14
- package/dist/config/compiler/recommendationCompilerRules.js +27 -27
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/radioButtonMigrator.js +44 -64
- package/dist/config/migrator/recommendationMigrator.js +290 -74
- package/dist/enums/displayConditions.js +80 -0
- package/dist/enums/extensions/recommendationBlock.js +1 -2
- package/dist/extensions/Blocks/RadioButton/template.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +32 -35
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +24 -25
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +181 -228
- package/dist/extensions/Blocks/Recommendation/services/configService.js +29 -65
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +90 -130
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- 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 +22 -13
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +235 -450
- package/dist/src/@types/config/defaults.d.ts +1 -5
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +0 -213
- package/dist/src/@types/config/types.d.ts +1 -9
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +0 -56
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +17 -0
- package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
- package/dist/src/composables/useRecommendation.d.ts +1 -10
- package/dist/src/config/migrator/index.d.ts +1 -2
- package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -13
- package/dist/src/enums/displayConditions.d.ts +2 -0
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -34
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +3 -0
- package/dist/src/library.d.ts +1 -1
- package/dist/src/stores/config.d.ts +0 -504
- package/dist/utils/templatePreparation.js +32 -72
- package/package.json +1 -5
- package/dist/composables/validators/useCouponBlockValidator.js +0 -24
- package/dist/config/migrator/recommendation/compositionMapper.js +0 -98
- package/dist/config/migrator/recommendation/extractors.js +0 -27
- package/dist/config/migrator/recommendation/htmlBuilder.js +0 -496
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +0 -33
- package/dist/config/migrator/recommendation/settingsMapper.js +0 -70
- package/dist/config/migrator/recommendation/themeMapper.js +0 -93
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +0 -21
- package/dist/src/composables/useRecommendation.test.d.ts +0 -1
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +0 -2
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -7
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -11
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +0 -15
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +0 -7
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +0 -5
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +0 -1
- package/dist/src/config/migrator/recommendation/types.d.ts +0 -205
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +0 -1
- package/dist/src/utils/htmlEscape.d.ts +0 -5
- package/dist/src/utils/htmlEscape.test.d.ts +0 -1
- 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
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
const
|
|
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:
|
|
19
|
+
const { html: t, ampHtml: o = "", ampErrors: p = [] } = await a({
|
|
60
20
|
minimize: !0,
|
|
61
21
|
resetDataSavedFlag: !1
|
|
62
|
-
}), { html:
|
|
63
|
-
|
|
64
|
-
const { compiledHtml:
|
|
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:
|
|
67
|
-
compiledSize:
|
|
68
|
-
reduction: `${
|
|
26
|
+
originalSize: s.originalSize,
|
|
27
|
+
compiledSize: s.compiledSize,
|
|
28
|
+
reduction: `${s.reductionPercentage.toFixed(2)}%`,
|
|
69
29
|
appliedRules: S,
|
|
70
|
-
executionTime: `${
|
|
30
|
+
executionTime: `${s.executionTime.toFixed(2)}ms`
|
|
71
31
|
}), {
|
|
72
|
-
dynamicContentList:
|
|
73
|
-
compiledHtml:
|
|
74
|
-
rawHtml:
|
|
75
|
-
css:
|
|
32
|
+
dynamicContentList: b,
|
|
33
|
+
compiledHtml: c,
|
|
34
|
+
rawHtml: u,
|
|
35
|
+
css: d,
|
|
76
36
|
ampHtml: o,
|
|
77
|
-
ampErrors:
|
|
78
|
-
modules:
|
|
37
|
+
ampErrors: p,
|
|
38
|
+
modules: g.map(Number),
|
|
79
39
|
recommendation: {
|
|
80
|
-
campaignUrls:
|
|
40
|
+
campaignUrls: f.recommendationCampaignUrls,
|
|
81
41
|
configs: {}
|
|
82
42
|
},
|
|
83
43
|
unsubscribe: {
|
|
84
|
-
status:
|
|
85
|
-
config:
|
|
44
|
+
status: e.unsubscribePagesStatus,
|
|
45
|
+
config: x(c, e.selectedUnsubscribePages)
|
|
86
46
|
}
|
|
87
47
|
};
|
|
88
48
|
}
|
|
89
49
|
};
|
|
90
50
|
};
|
|
91
51
|
export {
|
|
92
|
-
|
|
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.
|
|
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
|
-
};
|