@useinsider/guido 3.2.0-beta.6d12eec → 3.2.0-beta.72a3482
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/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
- package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
- package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
- package/dist/composables/useActionsApi.js +4 -4
- package/dist/composables/useFullStoryBridge.js +9 -29
- package/dist/composables/useHtmlValidator.js +41 -36
- package/dist/composables/useRibbonOffset.js +21 -0
- package/dist/composables/useSave.js +1 -1
- package/dist/composables/useStripo.js +23 -22
- package/dist/config/compiler/recommendationCompilerRules.js +72 -67
- package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +33 -30
- package/dist/config/migrator/recommendationMigrator.js +1 -1
- package/dist/enums/onboarding.js +7 -2
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
- package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +39 -31
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +11 -11
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +33 -0
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
- package/dist/package.json.js +1 -1
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useFullStoryBridge.d.ts +6 -6
- package/dist/src/composables/useRibbonOffset.d.ts +4 -0
- package/dist/src/enums/onboarding.d.ts +6 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +21 -0
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/static/styles/components/button.css.js +16 -9
- package/dist/static/styles/components/loader.css.js +4 -0
- package/dist/static/styles/components/narrow-panel.css.js +52 -0
- package/dist/stores/onboarding.js +4 -0
- package/package.json +3 -3
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { TemplateTypes as
|
|
3
|
-
import { DISPLAY_CONDITIONS_REGEX as
|
|
1
|
+
import { useConfig as _ } from "./useConfig.js";
|
|
2
|
+
import { TemplateTypes as H } from "../enums/defaults.js";
|
|
3
|
+
import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
|
|
4
4
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
5
|
-
import { itemsBlockDynamicVariables as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
7
|
+
import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
8
|
+
import { useRecommendationStore as K } from "../stores/recommendation.js";
|
|
9
|
+
import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
|
|
10
|
+
import { useHttp as U } from "./useHttp.js";
|
|
11
|
+
import { useToaster as Y } from "./useToaster.js";
|
|
12
|
+
import { useTranslations as Z } from "./useTranslations.js";
|
|
13
|
+
const J = /recommendation-id="(\d+)"/g;
|
|
14
|
+
function Q(a) {
|
|
15
|
+
return [...a.matchAll(J)].map((u) => u[1]);
|
|
14
16
|
}
|
|
15
|
-
function
|
|
17
|
+
function ee(a, u) {
|
|
16
18
|
return u.some((d) => a.startsWith(`${d}_`));
|
|
17
19
|
}
|
|
18
|
-
const
|
|
20
|
+
const ge = () => {
|
|
19
21
|
var y, h;
|
|
20
|
-
const { showToaster: a } =
|
|
22
|
+
const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
|
|
21
23
|
const t = await u(
|
|
22
24
|
"/newsletter/template-library/check-template-html-body",
|
|
23
|
-
{ html:
|
|
25
|
+
{ html: z(e) }
|
|
24
26
|
), { status: n, message: l } = t.data;
|
|
25
27
|
return n || a({
|
|
26
28
|
type: c.Alert,
|
|
27
29
|
message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
|
|
28
|
-
}), r(
|
|
30
|
+
}), r(M), l === r($) && a({
|
|
29
31
|
type: c.Alert,
|
|
30
32
|
message: r("newsletter.already-in-progress")
|
|
31
33
|
}), n;
|
|
32
|
-
}, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()),
|
|
34
|
+
}, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
|
|
33
35
|
const t = e.match(/({%(.*?)%})/g);
|
|
34
36
|
let n = !0;
|
|
35
37
|
return t !== null && !p && t.forEach((l) => {
|
|
@@ -42,13 +44,13 @@ const ce = () => {
|
|
|
42
44
|
}), n = !1);
|
|
43
45
|
}
|
|
44
46
|
}), n;
|
|
45
|
-
},
|
|
47
|
+
}, k = async (e, s, t) => {
|
|
46
48
|
const n = t ? await b(e) : !0;
|
|
47
|
-
return
|
|
48
|
-
},
|
|
49
|
+
return A(e, s) && n;
|
|
50
|
+
}, x = (e) => e.length > 0 ? !0 : (a({
|
|
49
51
|
type: c.Warning,
|
|
50
52
|
message: r("newsletter.html-content-is-empty")
|
|
51
|
-
}), !1),
|
|
53
|
+
}), !1), I = (e) => {
|
|
52
54
|
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
53
55
|
return s > t && a({
|
|
54
56
|
type: c.Warning,
|
|
@@ -57,7 +59,7 @@ const ce = () => {
|
|
|
57
59
|
type: c.Warning,
|
|
58
60
|
message: r("custom-fields.missing-opening-braces")
|
|
59
61
|
}), s === t;
|
|
60
|
-
},
|
|
62
|
+
}, F = (e) => {
|
|
61
63
|
const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
|
|
62
64
|
return s || a({
|
|
63
65
|
type: c.Warning,
|
|
@@ -66,10 +68,10 @@ const ce = () => {
|
|
|
66
68
|
}, T = (e, s) => {
|
|
67
69
|
const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
|
|
68
70
|
if (t && !p) {
|
|
69
|
-
const n = new Set(s.map((i) => i.toLowerCase())), l =
|
|
71
|
+
const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
|
|
70
72
|
if (t.forEach((i) => {
|
|
71
73
|
const m = i.slice(2, -2).trim().toLowerCase();
|
|
72
|
-
(!n.has(m) || m === "") && !
|
|
74
|
+
(!n.has(m) || m === "") && !ee(m, l) && o.push(m);
|
|
73
75
|
}), o.length > 0) {
|
|
74
76
|
const i = `
|
|
75
77
|
<ul>
|
|
@@ -83,11 +85,11 @@ const ce = () => {
|
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
return !0;
|
|
86
|
-
},
|
|
88
|
+
}, R = (e) => {
|
|
87
89
|
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
88
90
|
let n = !0;
|
|
89
91
|
if (s && s.forEach((l) => {
|
|
90
|
-
const o = l.match(
|
|
92
|
+
const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
|
|
91
93
|
(!o || l !== m) && !i && (a({
|
|
92
94
|
type: c.Alert,
|
|
93
95
|
message: r("newsletter.display-conditions-invalid-syntax")
|
|
@@ -98,7 +100,7 @@ const ce = () => {
|
|
|
98
100
|
}), n = !1);
|
|
99
101
|
const v = f.match(/^[a-zA-Z]*$/g);
|
|
100
102
|
v && v.forEach((C) => {
|
|
101
|
-
|
|
103
|
+
E(C) && t.push(C);
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
}), t.length) {
|
|
@@ -109,25 +111,28 @@ const ce = () => {
|
|
|
109
111
|
}), n = !1);
|
|
110
112
|
}
|
|
111
113
|
return n;
|
|
112
|
-
},
|
|
114
|
+
}, B = (e) => {
|
|
113
115
|
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
|
|
114
116
|
return n || a({
|
|
115
117
|
type: c.Warning,
|
|
116
118
|
message: r("custom-conditions.no-space-after-braces")
|
|
117
119
|
}), n;
|
|
118
|
-
},
|
|
120
|
+
}, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
|
|
119
121
|
type: c.Warning,
|
|
120
122
|
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
123
|
+
}), !1) : !0, N = () => S.hasInvalidBlock ? (a({
|
|
124
|
+
type: c.Alert,
|
|
125
|
+
message: r(j)
|
|
121
126
|
}), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
|
|
122
127
|
type: c.Alert,
|
|
123
128
|
message: r("newsletter.fill-all-necessary-fields")
|
|
124
|
-
}), !1) : !0,
|
|
129
|
+
}), !1) : !0, D = (e) => {
|
|
125
130
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
126
131
|
return e.match(s) === null ? !0 : (a({
|
|
127
132
|
type: c.Alert,
|
|
128
133
|
message: r("newsletter.invalid-image-type")
|
|
129
134
|
}), !1);
|
|
130
|
-
},
|
|
135
|
+
}, L = (e) => {
|
|
131
136
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
132
137
|
return Array.from(n).find((o) => {
|
|
133
138
|
var i;
|
|
@@ -136,7 +141,7 @@ const ce = () => {
|
|
|
136
141
|
type: c.Alert,
|
|
137
142
|
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
138
143
|
}), !1) : !0;
|
|
139
|
-
},
|
|
144
|
+
}, V = (e) => {
|
|
140
145
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
141
146
|
return Array.from(n).find((o) => {
|
|
142
147
|
var i;
|
|
@@ -150,12 +155,12 @@ const ce = () => {
|
|
|
150
155
|
var o, i;
|
|
151
156
|
const n = [
|
|
152
157
|
...s.map((m) => m.value),
|
|
153
|
-
...
|
|
158
|
+
...q,
|
|
154
159
|
...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
|
|
155
160
|
];
|
|
156
|
-
return await
|
|
161
|
+
return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
|
|
157
162
|
} };
|
|
158
163
|
};
|
|
159
164
|
export {
|
|
160
|
-
|
|
165
|
+
ge as useHtmlValidator
|
|
161
166
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RIBBON_SELECTOR as r } from "../enums/onboarding.js";
|
|
2
|
+
import { ref as f, onMounted as c, onBeforeUnmount as i } from "vue";
|
|
3
|
+
const m = () => {
|
|
4
|
+
const o = f(0);
|
|
5
|
+
let e = null;
|
|
6
|
+
const n = () => {
|
|
7
|
+
const t = document.querySelector(r), s = (t == null ? void 0 : t.offsetHeight) ?? 0;
|
|
8
|
+
o.value !== s && (o.value = s);
|
|
9
|
+
}, u = (t) => `${t + o.value}px`;
|
|
10
|
+
return c(() => {
|
|
11
|
+
n(), e = new MutationObserver(n), e.observe(document.body, {
|
|
12
|
+
childList: !0,
|
|
13
|
+
subtree: !0
|
|
14
|
+
});
|
|
15
|
+
}), i(() => {
|
|
16
|
+
e == null || e.disconnect();
|
|
17
|
+
}), { ribbonOffset: o, getTopPosition: u };
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
m as useRibbonOffset
|
|
21
|
+
};
|
|
@@ -19,7 +19,7 @@ const F = () => {
|
|
|
19
19
|
return;
|
|
20
20
|
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
|
|
21
21
|
return;
|
|
22
|
-
c();
|
|
22
|
+
await c();
|
|
23
23
|
const { unsubscribePayload: f, stripoModules: v } = d(t.rawHtml);
|
|
24
24
|
return await u(f), t.modules = v, m || s(t), t;
|
|
25
25
|
} };
|
|
@@ -12,17 +12,17 @@ import L from "../static/styles/customEditorStyle.css.js";
|
|
|
12
12
|
import { useEditorStore as C } from "../stores/editor.js";
|
|
13
13
|
import { dynamicContentToMergeTags as $ } from "../utils/genericUtil.js";
|
|
14
14
|
import z from "../package.json.js";
|
|
15
|
-
const
|
|
16
|
-
const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken:
|
|
17
|
-
var g,
|
|
18
|
-
const e = C(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await T(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0,
|
|
15
|
+
const ae = (E, l) => {
|
|
16
|
+
const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken: w, getCustomFonts: b, getSyncModulesStatus: k } = j(), { handleEvent: B } = q(), { getStripoBlocksConfig: T } = I(), V = async (i, r = [], s = !1) => {
|
|
17
|
+
var g, S, y;
|
|
18
|
+
const e = C(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await T(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, F = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, v = ((y = h.value) == null ? void 0 : y.forceRecreate) ?? !1;
|
|
19
19
|
window.UIEditor.initEditor(
|
|
20
20
|
document.querySelector("#guido-editor"),
|
|
21
21
|
{
|
|
22
22
|
metadata: E,
|
|
23
23
|
html: p,
|
|
24
24
|
css: a,
|
|
25
|
-
forceRecreate:
|
|
25
|
+
forceRecreate: v,
|
|
26
26
|
locale: "en",
|
|
27
27
|
undoButtonSelector: "#guido__undo-button",
|
|
28
28
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -37,19 +37,20 @@ const se = (E, l) => {
|
|
|
37
37
|
customConditionsEnabled: f,
|
|
38
38
|
conditionCategories: O,
|
|
39
39
|
enableXSSSecurity: !0,
|
|
40
|
-
modulesDisabled:
|
|
41
|
-
syncModulesEnabled:
|
|
40
|
+
modulesDisabled: F,
|
|
41
|
+
syncModulesEnabled: s,
|
|
42
42
|
messageSettingsEnabled: !0,
|
|
43
43
|
displayGmailAnnotations: !0,
|
|
44
44
|
displayHiddenPreheader: !1,
|
|
45
45
|
displayTitle: !1,
|
|
46
46
|
displayUTM: !1,
|
|
47
47
|
selectElementAfterDrop: !0,
|
|
48
|
+
allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
|
|
48
49
|
...o ? { baseBlocks: o } : {},
|
|
49
50
|
editorFonts: {
|
|
50
51
|
showDefaultStandardFonts: !0,
|
|
51
52
|
showDefaultNotStandardFonts: !0,
|
|
52
|
-
customFonts:
|
|
53
|
+
customFonts: r
|
|
53
54
|
},
|
|
54
55
|
mergeTags: [
|
|
55
56
|
{
|
|
@@ -61,16 +62,16 @@ const se = (E, l) => {
|
|
|
61
62
|
],
|
|
62
63
|
async onTokenRefreshRequest(t) {
|
|
63
64
|
try {
|
|
64
|
-
const
|
|
65
|
-
t(
|
|
66
|
-
} catch (
|
|
67
|
-
m(
|
|
65
|
+
const n = await w();
|
|
66
|
+
t(n);
|
|
67
|
+
} catch (n) {
|
|
68
|
+
m(n, "Failed to refresh token");
|
|
68
69
|
}
|
|
69
70
|
},
|
|
70
71
|
onTemplateLoaded() {
|
|
71
72
|
try {
|
|
72
|
-
const { importCss: t } = U(), { activateCustomViewStyles:
|
|
73
|
-
t(),
|
|
73
|
+
const { importCss: t } = U(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: M } = D(), { injectFullStory: A } = R();
|
|
74
|
+
t(), n(), A(), M(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
|
|
74
75
|
e.hasChanges = !1;
|
|
75
76
|
}, 1e3);
|
|
76
77
|
} catch (t) {
|
|
@@ -99,29 +100,29 @@ const se = (E, l) => {
|
|
|
99
100
|
localePatch: H
|
|
100
101
|
}
|
|
101
102
|
);
|
|
102
|
-
}, _ = (i) => new Promise((
|
|
103
|
+
}, _ = (i) => new Promise((r, s) => {
|
|
103
104
|
var d;
|
|
104
105
|
if (document.getElementById("UiEditorScript")) {
|
|
105
|
-
i(),
|
|
106
|
+
i(), r();
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
108
109
|
const e = z.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
|
|
109
110
|
o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
|
|
110
|
-
i(),
|
|
111
|
+
i(), r();
|
|
111
112
|
}, o.onerror = () => {
|
|
112
|
-
|
|
113
|
+
s(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
113
114
|
}, document.body.appendChild(o);
|
|
114
115
|
});
|
|
115
116
|
return { initPlugin: async (i) => {
|
|
116
117
|
await _(async () => {
|
|
117
|
-
const
|
|
118
|
-
|
|
118
|
+
const r = C(), [s, e] = await Promise.all([
|
|
119
|
+
b(),
|
|
119
120
|
k()
|
|
120
121
|
]);
|
|
121
|
-
|
|
122
|
+
r.syncModulesEnabled = e, await V(i, s, e);
|
|
122
123
|
});
|
|
123
124
|
} };
|
|
124
125
|
};
|
|
125
126
|
export {
|
|
126
|
-
|
|
127
|
+
ae as useStripo
|
|
127
128
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
1
|
+
import { useRecommendation as C } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as h, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as A, CONDITIONS as g, HTML as N } from "../../enums/recommendation.js";
|
|
3
3
|
import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
|
|
4
4
|
const w = [
|
|
5
5
|
{
|
|
6
6
|
id: "replace-images-with-variable-names",
|
|
7
7
|
description: "Replacing dummy images with variable names in recommendation module",
|
|
8
8
|
type: "custom",
|
|
9
|
-
processor: (
|
|
10
|
-
let e =
|
|
11
|
-
return Object.entries(
|
|
12
|
-
Object.entries(
|
|
13
|
-
e = e.replaceAll(
|
|
9
|
+
processor: (c) => {
|
|
10
|
+
let e = c;
|
|
11
|
+
return Object.entries(h).forEach(([, l]) => {
|
|
12
|
+
Object.entries(l).forEach(([n, s]) => {
|
|
13
|
+
e = e.replaceAll(s, `{{${n}}}`);
|
|
14
14
|
});
|
|
15
15
|
}), e;
|
|
16
16
|
},
|
|
@@ -29,21 +29,21 @@ const w = [
|
|
|
29
29
|
id: "add-recommendation-unresponsive-css",
|
|
30
30
|
description: "Adding recommendation unresponsive css",
|
|
31
31
|
type: "custom",
|
|
32
|
-
processor: (
|
|
33
|
-
const { calculateCardWidth: e, getRecommendationCampaignData:
|
|
34
|
-
let
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
32
|
+
processor: (c) => {
|
|
33
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: l } = C();
|
|
34
|
+
let n = c;
|
|
35
|
+
const s = n.match(T.ID);
|
|
36
|
+
if (s) {
|
|
37
37
|
const a = [];
|
|
38
|
-
if (
|
|
39
|
-
const d = /recommendation-id="(.*?)"/i.exec(
|
|
40
|
-
|
|
38
|
+
if (s.forEach((i) => {
|
|
39
|
+
const d = /recommendation-id="(.*?)"/i.exec(i), _ = d ? d[1].trim() : "", R = l(_);
|
|
40
|
+
R.textTrimming && R.orientation === M && a.push(e(R));
|
|
41
41
|
}), a.length) {
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const i = `width:${Math.min(...a)}px!important;`;
|
|
43
|
+
n = n.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${i} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${i} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return n;
|
|
47
47
|
},
|
|
48
48
|
priority: 52
|
|
49
49
|
},
|
|
@@ -51,34 +51,34 @@ const w = [
|
|
|
51
51
|
id: "prepare-recommendations",
|
|
52
52
|
description: "Replacing product data with template variables in recommendation blocks",
|
|
53
53
|
type: "custom",
|
|
54
|
-
processor: (
|
|
54
|
+
processor: (c) => x(c),
|
|
55
55
|
priority: 48
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
id: "add-discount-conditions",
|
|
59
59
|
description: "Adding discount conditions to the recommendation block",
|
|
60
60
|
type: "custom",
|
|
61
|
-
processor: (
|
|
62
|
-
let e =
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
const a =
|
|
61
|
+
processor: (c) => {
|
|
62
|
+
let e = c;
|
|
63
|
+
const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = C();
|
|
64
|
+
return l !== null && l.forEach((s) => {
|
|
65
|
+
const a = s.match(T.CUSTOM_FIELD);
|
|
66
66
|
if (!a)
|
|
67
67
|
return;
|
|
68
|
-
const [
|
|
69
|
-
if (!d || !_ || !
|
|
68
|
+
const [i] = a, d = i.match(T.CUSTOM_FIELD_INDEXES_PART), _ = i.match(T.CUSTOM_FIELD_NAME_PART), R = s.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
69
|
+
if (!d || !_ || !R)
|
|
70
70
|
return;
|
|
71
|
-
const [
|
|
72
|
-
let t =
|
|
71
|
+
const [S] = d, [b] = _, [m] = R, o = b.substring(1, b.length - 2), r = m.match(T.COMPOSITION) !== null;
|
|
72
|
+
let t = i;
|
|
73
73
|
if (r) {
|
|
74
|
-
const
|
|
75
|
-
o ===
|
|
74
|
+
const I = S.substring(2, S.length - 3), p = n(I);
|
|
75
|
+
o === A.OMNIBUS_PRICE && (p.priceBeforeTextValue && (t = `${p.priceBeforeTextValue}${t}`), p.priceAfterTextValue && (t = `${t}${p.priceAfterTextValue}`)), o === A.OMNIBUS_DISCOUNT && (p.discountBeforeTextValue && (t = `${p.discountBeforeTextValue}${t}`), p.discountAfterTextValue && (t = `${t}${p.discountAfterTextValue}`));
|
|
76
76
|
}
|
|
77
|
-
const u =
|
|
77
|
+
const u = S.substring(2);
|
|
78
78
|
let f = "";
|
|
79
|
-
o in
|
|
80
|
-
const
|
|
81
|
-
e = e.replace(
|
|
79
|
+
o in g.IF && (f = g.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${u}${A.DISCOUNT}`).replaceAll(`{${A.OMNIBUS_DISCOUNT}}`, `${u}${A.OMNIBUS_DISCOUNT}`).replaceAll(`{${A.OMNIBUS_PRICE}}`, `${u}${A.OMNIBUS_PRICE}`));
|
|
80
|
+
const $ = `${m}${t}${N.PARAGRAPH_END_TAG}`, y = `${f}${r ? $ : s}${g.ELSE}${m}${N.PARAGRAPH_END_TAG}${g.END_IF}`;
|
|
81
|
+
e = e.replace(s, y);
|
|
82
82
|
}), e;
|
|
83
83
|
},
|
|
84
84
|
priority: 53
|
|
@@ -95,19 +95,24 @@ const w = [
|
|
|
95
95
|
{
|
|
96
96
|
id: "strip-recommendation-editor-attributes",
|
|
97
97
|
description: "Strip editor-only attributes from compiled recommendation output",
|
|
98
|
-
type: "
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
type: "custom",
|
|
99
|
+
// Scoped to REC_START/REC_END markers so it cannot strip `product-attr`
|
|
100
|
+
// from Items block elements, which the items compiler rule depends on.
|
|
101
|
+
processor: (c) => {
|
|
102
|
+
const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"/g;
|
|
103
|
+
return c.replace(
|
|
104
|
+
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
105
|
+
(l, n) => `<!--REC_START-->${n.replace(e, "")}<!--REC_END-->`
|
|
106
|
+
);
|
|
107
|
+
},
|
|
103
108
|
priority: 55
|
|
104
109
|
},
|
|
105
110
|
{
|
|
106
111
|
id: "strip-unused-recommendation-classes",
|
|
107
112
|
description: "Remove CSS classes not referenced by any style rule from recommendation elements",
|
|
108
113
|
type: "custom",
|
|
109
|
-
processor: (
|
|
110
|
-
let e =
|
|
114
|
+
processor: (c) => {
|
|
115
|
+
let e = c.replace(
|
|
111
116
|
/ class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
|
|
112
117
|
""
|
|
113
118
|
);
|
|
@@ -119,8 +124,8 @@ const w = [
|
|
|
119
124
|
id: "remove-empty-mobile-layout-artifacts",
|
|
120
125
|
description: "Remove empty mobile container rows and unused mobile layout CSS",
|
|
121
126
|
type: "custom",
|
|
122
|
-
processor: (
|
|
123
|
-
let e =
|
|
127
|
+
processor: (c) => {
|
|
128
|
+
let e = c;
|
|
124
129
|
return e = e.replace(
|
|
125
130
|
/<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
|
|
126
131
|
""
|
|
@@ -129,9 +134,9 @@ const w = [
|
|
|
129
134
|
""
|
|
130
135
|
), e = e.replace(
|
|
131
136
|
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
132
|
-
(
|
|
133
|
-
const
|
|
134
|
-
return
|
|
137
|
+
(l, n) => {
|
|
138
|
+
const s = n.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
139
|
+
return s.every((d) => a.test(d)) ? "" : l;
|
|
135
140
|
}
|
|
136
141
|
)), e;
|
|
137
142
|
},
|
|
@@ -141,38 +146,38 @@ const w = [
|
|
|
141
146
|
id: "deduplicate-inline-styles",
|
|
142
147
|
description: "Replace repeated inline styles with CSS class references within recommendation blocks",
|
|
143
148
|
type: "custom",
|
|
144
|
-
processor: (
|
|
145
|
-
const e =
|
|
149
|
+
processor: (c) => {
|
|
150
|
+
const e = c.replace(
|
|
146
151
|
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
147
152
|
(o) => o.replace(
|
|
148
153
|
/([;"]color:)([^;"]+)/g,
|
|
149
154
|
(r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
|
|
150
155
|
)
|
|
151
|
-
),
|
|
152
|
-
let a =
|
|
156
|
+
), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
|
|
157
|
+
let a = l.exec(e);
|
|
153
158
|
for (; a !== null; ) {
|
|
154
|
-
let o =
|
|
159
|
+
let o = n.exec(a[1]);
|
|
155
160
|
for (; o !== null; ) {
|
|
156
161
|
const [, r] = o;
|
|
157
|
-
|
|
162
|
+
s.set(r, (s.get(r) || 0) + 1), o = n.exec(a[1]);
|
|
158
163
|
}
|
|
159
|
-
|
|
164
|
+
n.lastIndex = 0, a = l.exec(e);
|
|
160
165
|
}
|
|
161
|
-
const
|
|
166
|
+
const i = /* @__PURE__ */ new Map(), d = [];
|
|
162
167
|
let _ = 0;
|
|
163
|
-
if (
|
|
168
|
+
if (s.forEach((o, r) => {
|
|
164
169
|
if (o >= 6) {
|
|
165
170
|
const t = `rc${_++}`;
|
|
166
|
-
|
|
171
|
+
i.set(r, t), d.push(`.${t}{${r}}`);
|
|
167
172
|
}
|
|
168
|
-
}),
|
|
173
|
+
}), i.size === 0) {
|
|
169
174
|
let o = e;
|
|
170
175
|
return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
|
|
171
176
|
}
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
const t =
|
|
175
|
-
|
|
177
|
+
const R = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), S = (o, r) => `${o.slice(0, -1)} ${r}"`, b = /* @__PURE__ */ new Map();
|
|
178
|
+
i.forEach((o, r) => {
|
|
179
|
+
const t = R(r);
|
|
180
|
+
b.set(r, {
|
|
176
181
|
caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
|
|
177
182
|
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
178
183
|
});
|
|
@@ -182,14 +187,14 @@ const w = [
|
|
|
182
187
|
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
183
188
|
(o, r) => {
|
|
184
189
|
let t = r;
|
|
185
|
-
return
|
|
186
|
-
const
|
|
190
|
+
return i.forEach((u, f) => {
|
|
191
|
+
const $ = b.get(f);
|
|
187
192
|
t = t.replace(
|
|
188
|
-
|
|
189
|
-
(y,
|
|
193
|
+
$.caseA,
|
|
194
|
+
(y, I, p) => S(I, u) + p
|
|
190
195
|
), t = t.replace(
|
|
191
|
-
|
|
192
|
-
(y,
|
|
196
|
+
$.caseB,
|
|
197
|
+
(y, I, p) => I + S(p, u)
|
|
193
198
|
), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
|
|
194
199
|
}), t;
|
|
195
200
|
}
|