@useinsider/guido 3.2.0-beta.a49c53c → 3.2.0-beta.a61fffe
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/useRibbonOffset.js +21 -0
- package/dist/composables/useSave.js +21 -18
- package/dist/composables/useStripo.js +42 -42
- package/dist/composables/validators/useCouponBlockValidator.js +24 -0
- package/dist/config/compiler/recommendationCompilerRules.js +27 -27
- package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
- package/dist/config/migrator/itemsBlockMigrator.js +28 -18
- package/dist/config/migrator/radioButtonMigrator.js +64 -44
- package/dist/enums/onboarding.js +7 -2
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/RadioButton/template.js +1 -1
- package/dist/guido.css +1 -1
- package/dist/package.json.js +7 -0
- package/dist/services/templateLibraryApi.js +5 -4
- package/dist/src/composables/useRibbonOffset.d.ts +4 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/enums/onboarding.d.ts +6 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/static/templates/empty/style.css.js +1 -0
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/pairProductVariables.js +89 -88
- package/package.json +2 -2
- package/dist/enums/displayConditions.js +0 -80
- package/dist/src/enums/displayConditions.d.ts +0 -2
|
@@ -6,38 +6,37 @@ import { useFullStoryBridge as R } from "./useFullStoryBridge.js";
|
|
|
6
6
|
import { useStripoEventHandler as q } from "./useStripoEventHandler.js";
|
|
7
7
|
import { useToaster as x } from "./useToaster.js";
|
|
8
8
|
import { localePatch as H } from "../config/i18n/index.js";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
const
|
|
15
|
-
const { features:
|
|
16
|
-
var
|
|
17
|
-
const e =
|
|
9
|
+
import { useStripoApi as O } from "../services/stripoApi.js";
|
|
10
|
+
import j from "../static/styles/customEditorStyle.css.js";
|
|
11
|
+
import { useEditorStore as E } from "../stores/editor.js";
|
|
12
|
+
import { dynamicContentToMergeTags as L } from "../utils/genericUtil.js";
|
|
13
|
+
import $ from "../package.json.js";
|
|
14
|
+
const se = (C, l) => {
|
|
15
|
+
const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken: w, getCustomFonts: b, getSyncModulesStatus: k } = O(), { handleEvent: B } = q(), { getStripoBlocksConfig: T } = I(), V = async (i, r = [], s = !1) => {
|
|
16
|
+
var g, S, y;
|
|
17
|
+
const e = E(), { 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;
|
|
18
18
|
window.UIEditor.initEditor(
|
|
19
19
|
document.querySelector("#guido-editor"),
|
|
20
20
|
{
|
|
21
|
-
metadata:
|
|
22
|
-
html:
|
|
23
|
-
css:
|
|
24
|
-
forceRecreate:
|
|
21
|
+
metadata: C,
|
|
22
|
+
html: p,
|
|
23
|
+
css: a,
|
|
24
|
+
forceRecreate: v,
|
|
25
25
|
locale: "en",
|
|
26
26
|
undoButtonSelector: "#guido__undo-button",
|
|
27
27
|
redoButtonSelector: "#guido__redo-button",
|
|
28
28
|
mobileViewButtonSelector: ".guido__view-option-selection-mobile",
|
|
29
29
|
desktopViewButtonSelector: ".guido__view-option-selection-desktop",
|
|
30
30
|
codeEditorButtonSelector: "#guido__code-button",
|
|
31
|
-
customAppearanceMergetags: !
|
|
31
|
+
customAppearanceMergetags: !u("liquidSyntax"),
|
|
32
32
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
33
33
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
34
|
-
customViewStyles:
|
|
35
|
-
conditionsEnabled:
|
|
36
|
-
customConditionsEnabled:
|
|
37
|
-
conditionCategories: O,
|
|
34
|
+
customViewStyles: j,
|
|
35
|
+
conditionsEnabled: f,
|
|
36
|
+
customConditionsEnabled: f,
|
|
38
37
|
enableXSSSecurity: !0,
|
|
39
|
-
modulesDisabled:
|
|
40
|
-
syncModulesEnabled:
|
|
38
|
+
modulesDisabled: F,
|
|
39
|
+
syncModulesEnabled: s,
|
|
41
40
|
messageSettingsEnabled: !0,
|
|
42
41
|
displayGmailAnnotations: !0,
|
|
43
42
|
displayHiddenPreheader: !1,
|
|
@@ -45,7 +44,7 @@ const ne = (y, a) => {
|
|
|
45
44
|
displayUTM: !1,
|
|
46
45
|
selectElementAfterDrop: !0,
|
|
47
46
|
allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
|
|
48
|
-
...
|
|
47
|
+
...o ? { baseBlocks: o } : {},
|
|
49
48
|
editorFonts: {
|
|
50
49
|
showDefaultStandardFonts: !0,
|
|
51
50
|
showDefaultNotStandardFonts: !0,
|
|
@@ -53,28 +52,28 @@ const ne = (y, a) => {
|
|
|
53
52
|
},
|
|
54
53
|
mergeTags: [
|
|
55
54
|
{
|
|
56
|
-
entries:
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
entries: L(
|
|
56
|
+
l.preselectedDynamicContentList,
|
|
57
|
+
u("liquidSyntax")
|
|
59
58
|
)
|
|
60
59
|
}
|
|
61
60
|
],
|
|
62
61
|
async onTokenRefreshRequest(t) {
|
|
63
62
|
try {
|
|
64
|
-
const
|
|
65
|
-
t(
|
|
66
|
-
} catch (
|
|
67
|
-
|
|
63
|
+
const n = await w();
|
|
64
|
+
t(n);
|
|
65
|
+
} catch (n) {
|
|
66
|
+
m(n, "Failed to refresh token");
|
|
68
67
|
}
|
|
69
68
|
},
|
|
70
69
|
onTemplateLoaded() {
|
|
71
70
|
try {
|
|
72
|
-
const { importCss: t } = U(), { activateCustomViewStyles:
|
|
73
|
-
t(),
|
|
71
|
+
const { importCss: t } = U(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: M } = D(), { injectFullStory: A } = R();
|
|
72
|
+
t(), n(), A(), M(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
|
|
74
73
|
e.hasChanges = !1;
|
|
75
74
|
}, 1e3);
|
|
76
75
|
} catch (t) {
|
|
77
|
-
|
|
76
|
+
m(t, "Failed to load custom interface appearance");
|
|
78
77
|
}
|
|
79
78
|
},
|
|
80
79
|
onCodeEditorVisibilityChanged(t) {
|
|
@@ -89,38 +88,39 @@ const ne = (y, a) => {
|
|
|
89
88
|
onDataChanged() {
|
|
90
89
|
e.hasChanges = !0;
|
|
91
90
|
},
|
|
92
|
-
onEvent:
|
|
91
|
+
onEvent: B,
|
|
93
92
|
ignoreClickOutsideSelectors: [
|
|
94
93
|
"#guido-dynamic-content-modal",
|
|
95
94
|
".in-on-board-wrapper",
|
|
96
95
|
".in-drawer__container"
|
|
97
96
|
],
|
|
98
|
-
extensions:
|
|
97
|
+
extensions: d,
|
|
99
98
|
localePatch: H
|
|
100
99
|
}
|
|
101
100
|
);
|
|
102
|
-
}, _ = (i) => new Promise((r,
|
|
101
|
+
}, _ = (i) => new Promise((r, s) => {
|
|
102
|
+
var d;
|
|
103
103
|
if (document.getElementById("UiEditorScript")) {
|
|
104
104
|
i(), r();
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
const e =
|
|
108
|
-
o.id = "UiEditorScript", o.type = "module", o.src =
|
|
107
|
+
const e = $.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");
|
|
108
|
+
o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
|
|
109
109
|
i(), r();
|
|
110
110
|
}, o.onerror = () => {
|
|
111
|
-
|
|
111
|
+
s(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
112
112
|
}, document.body.appendChild(o);
|
|
113
113
|
});
|
|
114
114
|
return { initPlugin: async (i) => {
|
|
115
115
|
await _(async () => {
|
|
116
|
-
const r =
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
const r = E(), [s, e] = await Promise.all([
|
|
117
|
+
b(),
|
|
118
|
+
k()
|
|
119
119
|
]);
|
|
120
|
-
r.syncModulesEnabled = e, await
|
|
120
|
+
r.syncModulesEnabled = e, await V(i, s, e);
|
|
121
121
|
});
|
|
122
122
|
} };
|
|
123
123
|
};
|
|
124
124
|
export {
|
|
125
|
-
|
|
125
|
+
se as useStripo
|
|
126
126
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
1
|
+
import { useRecommendation as N } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as y, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as A, CONDITIONS as g, HTML as h } from "../../enums/recommendation.js";
|
|
3
3
|
import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
|
|
4
4
|
const w = [
|
|
5
5
|
{
|
|
@@ -8,7 +8,7 @@ const w = [
|
|
|
8
8
|
type: "custom",
|
|
9
9
|
processor: (c) => {
|
|
10
10
|
let e = c;
|
|
11
|
-
return Object.entries(
|
|
11
|
+
return Object.entries(y).forEach(([, l]) => {
|
|
12
12
|
Object.entries(l).forEach(([n, s]) => {
|
|
13
13
|
e = e.replaceAll(s, `{{${n}}}`);
|
|
14
14
|
});
|
|
@@ -30,13 +30,13 @@ const w = [
|
|
|
30
30
|
description: "Adding recommendation unresponsive css",
|
|
31
31
|
type: "custom",
|
|
32
32
|
processor: (c) => {
|
|
33
|
-
const { calculateCardWidth: e, getRecommendationCampaignData: l } =
|
|
33
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: l } = N();
|
|
34
34
|
let n = c;
|
|
35
35
|
const s = n.match(T.ID);
|
|
36
36
|
if (s) {
|
|
37
37
|
const a = [];
|
|
38
38
|
if (s.forEach((i) => {
|
|
39
|
-
const
|
|
39
|
+
const u = /recommendation-id="(.*?)"/i.exec(i), _ = u ? u[1].trim() : "", R = l(_);
|
|
40
40
|
R.textTrimming && R.orientation === M && a.push(e(R));
|
|
41
41
|
}), a.length) {
|
|
42
42
|
const i = `width:${Math.min(...a)}px!important;`;
|
|
@@ -60,25 +60,25 @@ const w = [
|
|
|
60
60
|
type: "custom",
|
|
61
61
|
processor: (c) => {
|
|
62
62
|
let e = c;
|
|
63
|
-
const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } =
|
|
63
|
+
const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = N();
|
|
64
64
|
return l !== null && l.forEach((s) => {
|
|
65
65
|
const a = s.match(T.CUSTOM_FIELD);
|
|
66
66
|
if (!a)
|
|
67
67
|
return;
|
|
68
|
-
const [i] = a,
|
|
69
|
-
if (!
|
|
68
|
+
const [i] = a, u = i.match(T.CUSTOM_FIELD_INDEXES_PART), _ = i.match(T.CUSTOM_FIELD_NAME_PART), R = s.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
69
|
+
if (!u || !_ || !R)
|
|
70
70
|
return;
|
|
71
|
-
const [S] =
|
|
71
|
+
const [S] = u, [b] = _, [d] = R, o = b.substring(1, b.length - 2), r = d.match(T.COMPOSITION) !== null;
|
|
72
72
|
let t = i;
|
|
73
73
|
if (r) {
|
|
74
|
-
const I = S.substring(2, S.length - 3),
|
|
75
|
-
o === A.OMNIBUS_PRICE && (
|
|
74
|
+
const I = S.substring(2, S.length - 3), m = n(I);
|
|
75
|
+
o === A.OMNIBUS_PRICE && (m.priceBeforeTextValue && (t = `${m.priceBeforeTextValue}${t}`), m.priceAfterTextValue && (t = `${t}${m.priceAfterTextValue}`)), o === A.OMNIBUS_DISCOUNT && (m.discountBeforeTextValue && (t = `${m.discountBeforeTextValue}${t}`), m.discountAfterTextValue && (t = `${t}${m.discountAfterTextValue}`));
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const p = S.substring(2);
|
|
78
78
|
let f = "";
|
|
79
|
-
o in g.IF && (f = g.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${
|
|
80
|
-
const $ = `${
|
|
81
|
-
e = e.replace(s,
|
|
79
|
+
o in g.IF && (f = g.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${p}${A.DISCOUNT}`).replaceAll(`{${A.OMNIBUS_DISCOUNT}}`, `${p}${A.OMNIBUS_DISCOUNT}`).replaceAll(`{${A.OMNIBUS_PRICE}}`, `${p}${A.OMNIBUS_PRICE}`));
|
|
80
|
+
const $ = `${d}${t}${h.PARAGRAPH_END_TAG}`, C = `${f}${r ? $ : s}${g.ELSE}${d}${h.PARAGRAPH_END_TAG}${g.END_IF}`;
|
|
81
|
+
e = e.replace(s, C);
|
|
82
82
|
}), e;
|
|
83
83
|
},
|
|
84
84
|
priority: 53
|
|
@@ -136,7 +136,7 @@ const w = [
|
|
|
136
136
|
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
137
137
|
(l, n) => {
|
|
138
138
|
const s = n.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
139
|
-
return s.every((
|
|
139
|
+
return s.every((u) => a.test(u)) ? "" : l;
|
|
140
140
|
}
|
|
141
141
|
)), e;
|
|
142
142
|
},
|
|
@@ -151,7 +151,7 @@ const w = [
|
|
|
151
151
|
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
152
152
|
(o) => o.replace(
|
|
153
153
|
/([;"]color:)([^;"]+)/g,
|
|
154
|
-
(r, t,
|
|
154
|
+
(r, t, p) => p.includes("!important") ? r : `${t}${p} !important`
|
|
155
155
|
)
|
|
156
156
|
), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
|
|
157
157
|
let a = l.exec(e);
|
|
@@ -163,12 +163,12 @@ const w = [
|
|
|
163
163
|
}
|
|
164
164
|
n.lastIndex = 0, a = l.exec(e);
|
|
165
165
|
}
|
|
166
|
-
const i = /* @__PURE__ */ new Map(),
|
|
166
|
+
const i = /* @__PURE__ */ new Map(), u = [];
|
|
167
167
|
let _ = 0;
|
|
168
168
|
if (s.forEach((o, r) => {
|
|
169
169
|
if (o >= 6) {
|
|
170
|
-
const t = `rc${_++}
|
|
171
|
-
i.set(r, t),
|
|
170
|
+
const t = `rc${_++}`, p = r.endsWith(";") ? r : `${r};`;
|
|
171
|
+
i.set(r, t), u.push(`.${t}{${p}}`);
|
|
172
172
|
}
|
|
173
173
|
}), i.size === 0) {
|
|
174
174
|
let o = e;
|
|
@@ -182,23 +182,23 @@ const w = [
|
|
|
182
182
|
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
|
-
let
|
|
186
|
-
return
|
|
185
|
+
let d = e.replace("</style>", `${u.join("")}</style>`);
|
|
186
|
+
return d = d.replace(
|
|
187
187
|
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
188
188
|
(o, r) => {
|
|
189
189
|
let t = r;
|
|
190
|
-
return i.forEach((
|
|
190
|
+
return i.forEach((p, f) => {
|
|
191
191
|
const $ = b.get(f);
|
|
192
192
|
t = t.replace(
|
|
193
193
|
$.caseA,
|
|
194
|
-
(
|
|
194
|
+
(C, I, m) => S(I, p) + m
|
|
195
195
|
), t = t.replace(
|
|
196
196
|
$.caseB,
|
|
197
|
-
(
|
|
198
|
-
), t = t.replaceAll(` style="${f}"`, ` class="${
|
|
197
|
+
(C, I, m) => I + S(m, p)
|
|
198
|
+
), t = t.replaceAll(` style="${f}"`, ` class="${p}"`);
|
|
199
199
|
}), t;
|
|
200
200
|
}
|
|
201
|
-
),
|
|
201
|
+
), d = d.replaceAll("<!--REC_START-->", ""), d = d.replaceAll("<!--REC_END-->", ""), d;
|
|
202
202
|
},
|
|
203
203
|
priority: 58
|
|
204
204
|
}
|
|
@@ -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
|
};
|
|
@@ -155,6 +155,8 @@ class z {
|
|
|
155
155
|
}
|
|
156
156
|
migrate(t) {
|
|
157
157
|
try {
|
|
158
|
+
if (!this.containsItemsBlock(t))
|
|
159
|
+
return t;
|
|
158
160
|
let o = this.removeJinjaConditionals(t);
|
|
159
161
|
o = this.replaceTemplateVariables(o);
|
|
160
162
|
const l = this.parser.parseFromString(o, "text/html"), a = l.querySelectorAll(
|
|
@@ -178,15 +180,15 @@ class z {
|
|
|
178
180
|
originalPriceStyles: e.originalPriceStyles,
|
|
179
181
|
quantityStyles: e.quantityStyles,
|
|
180
182
|
nodeConfig: R(e.configBlockAttributes)
|
|
181
|
-
}),
|
|
183
|
+
}), u = this.parser.parseFromString(
|
|
182
184
|
`<table><tbody><tr>${c}</tr></tbody></table>`,
|
|
183
185
|
"text/html"
|
|
184
186
|
).querySelector("td");
|
|
185
|
-
if (
|
|
187
|
+
if (u && i.parentNode) {
|
|
186
188
|
const p = R(e.configBlockAttributes);
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
189
|
+
u.setAttribute("esd-ext-config", JSON.stringify(p));
|
|
190
|
+
const d = u.querySelector("esd-config-block");
|
|
191
|
+
d && d.remove(), i.parentNode.replaceChild(u, i);
|
|
190
192
|
}
|
|
191
193
|
}), l.documentElement.outerHTML);
|
|
192
194
|
} catch (o) {
|
|
@@ -201,22 +203,22 @@ class z {
|
|
|
201
203
|
*/
|
|
202
204
|
extractConfiguration(t) {
|
|
203
205
|
var C, D, P;
|
|
204
|
-
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD",
|
|
206
|
+
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
|
|
205
207
|
let b;
|
|
206
208
|
S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
207
|
-
const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0,
|
|
209
|
+
const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
208
210
|
return {
|
|
209
211
|
orientation: b,
|
|
210
212
|
itemsType: o,
|
|
211
213
|
itemId: i,
|
|
212
214
|
currencySymbol: c,
|
|
213
|
-
currencyLocation:
|
|
215
|
+
currencyLocation: u,
|
|
214
216
|
formattedPrice: p,
|
|
215
|
-
configBlockAttributes:
|
|
217
|
+
configBlockAttributes: d,
|
|
216
218
|
nameStyles: I,
|
|
217
219
|
buttonStyles: m,
|
|
218
|
-
priceStyles:
|
|
219
|
-
originalPriceStyles:
|
|
220
|
+
priceStyles: k,
|
|
221
|
+
originalPriceStyles: h,
|
|
220
222
|
quantityStyles: L
|
|
221
223
|
};
|
|
222
224
|
}
|
|
@@ -296,6 +298,14 @@ class z {
|
|
|
296
298
|
"data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
|
|
297
299
|
};
|
|
298
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
303
|
+
* in the raw HTML. Used to gate the migration pipeline so non-items templates
|
|
304
|
+
* are returned untouched.
|
|
305
|
+
*/
|
|
306
|
+
containsItemsBlock(t) {
|
|
307
|
+
return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
|
|
308
|
+
}
|
|
299
309
|
/**
|
|
300
310
|
* Removes Jinja2 conditional statements from HTML
|
|
301
311
|
* Handles all items block types:
|
|
@@ -337,18 +347,18 @@ class z {
|
|
|
337
347
|
const [, i, e, c] = n, _ = x[i];
|
|
338
348
|
if (!_)
|
|
339
349
|
return console.warn(`Unknown variable prefix: ${i}`), l;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
350
|
+
const u = q[e];
|
|
351
|
+
if (!u)
|
|
342
352
|
return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
|
|
343
|
-
const { pairsKey: p, defaultKey:
|
|
353
|
+
const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
|
|
344
354
|
if (!y)
|
|
345
355
|
return console.warn(`No data found for: ${p}.${_}`), l;
|
|
346
356
|
if (S) {
|
|
347
|
-
const f = parseInt(c) - 1, m = y[
|
|
348
|
-
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${
|
|
357
|
+
const f = parseInt(c) - 1, m = y[d];
|
|
358
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
|
|
349
359
|
}
|
|
350
|
-
const I = y[
|
|
351
|
-
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${
|
|
360
|
+
const I = y[d];
|
|
361
|
+
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
|
|
352
362
|
});
|
|
353
363
|
}
|
|
354
364
|
}
|