@useinsider/guido 3.2.0-beta.066130b → 3.2.0-beta.080341b
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 +117 -1
- package/dist/@types/config/schemas.js +153 -95
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +90 -88
- package/dist/components/organisms/AutoSaveController.vue.js +17 -0
- package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
- package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
- package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
- package/dist/components/organisms/header/RightSlot.vue.js +8 -8
- package/dist/components/organisms/header/RightSlot.vue2.js +9 -8
- package/dist/composables/useAutoSave.js +71 -0
- package/dist/composables/useRecommendation.js +46 -26
- package/dist/composables/useSave.js +19 -16
- package/dist/composables/useStripo.js +14 -16
- package/dist/composables/validators/useCouponBlockValidator.js +24 -0
- package/dist/config/compiler/recommendationCompilerRules.js +25 -25
- package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +107 -71
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/radioButtonMigrator.js +64 -44
- package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
- package/dist/config/migrator/recommendation/extractors.js +27 -0
- package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +2 -1
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/RadioButton/template.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +60 -50
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- 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 +27 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
- 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/services/configService.js +76 -33
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -79
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +19 -10
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +25 -15
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +11 -11
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
- package/dist/node_modules/valibot/dist/index.js +450 -235
- package/dist/package.json.js +1 -1
- package/dist/services/templateLibraryApi.js +5 -4
- package/dist/src/@types/config/defaults.d.ts +5 -1
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +217 -0
- package/dist/src/@types/config/types.d.ts +9 -1
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useAutoSave.d.ts +3 -0
- package/dist/src/composables/useConfig.d.ts +58 -0
- package/dist/src/composables/useRecommendation.d.ts +10 -1
- package/dist/src/composables/useRecommendation.test.d.ts +1 -0
- package/dist/src/composables/useSave.d.ts +1 -1
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
- package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- 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/main/utils.test.d.ts +1 -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/services/configService.d.ts +21 -3
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/library.d.ts +1 -1
- package/dist/src/stores/autosave.d.ts +12 -0
- package/dist/src/stores/config.d.ts +522 -0
- package/dist/src/stores/editor.d.ts +23 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/src/utils/timeUtil.d.ts +8 -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/autosave.js +17 -0
- package/dist/stores/editor.js +3 -1
- package/dist/utils/htmlEscape.js +13 -0
- package/dist/utils/pairProductVariables.js +89 -88
- package/dist/utils/templatePreparation.js +72 -32
- package/dist/utils/timeUtil.js +19 -0
- package/package.json +7 -3
- package/dist/enums/displayConditions.js +0 -80
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
- package/dist/src/enums/displayConditions.d.ts +0 -2
|
@@ -6,20 +6,19 @@ 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
|
-
|
|
15
|
-
const
|
|
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) => {
|
|
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) => {
|
|
17
16
|
var g, S, y;
|
|
18
|
-
const e =
|
|
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;
|
|
19
18
|
window.UIEditor.initEditor(
|
|
20
19
|
document.querySelector("#guido-editor"),
|
|
21
20
|
{
|
|
22
|
-
metadata:
|
|
21
|
+
metadata: C,
|
|
23
22
|
html: p,
|
|
24
23
|
css: a,
|
|
25
24
|
forceRecreate: v,
|
|
@@ -32,10 +31,9 @@ const ae = (E, l) => {
|
|
|
32
31
|
customAppearanceMergetags: !u("liquidSyntax"),
|
|
33
32
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
34
33
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
35
|
-
customViewStyles:
|
|
34
|
+
customViewStyles: j,
|
|
36
35
|
conditionsEnabled: f,
|
|
37
36
|
customConditionsEnabled: f,
|
|
38
|
-
conditionCategories: O,
|
|
39
37
|
enableXSSSecurity: !0,
|
|
40
38
|
modulesDisabled: F,
|
|
41
39
|
syncModulesEnabled: s,
|
|
@@ -54,7 +52,7 @@ const ae = (E, l) => {
|
|
|
54
52
|
},
|
|
55
53
|
mergeTags: [
|
|
56
54
|
{
|
|
57
|
-
entries:
|
|
55
|
+
entries: L(
|
|
58
56
|
l.preselectedDynamicContentList,
|
|
59
57
|
u("liquidSyntax")
|
|
60
58
|
)
|
|
@@ -106,7 +104,7 @@ const ae = (E, l) => {
|
|
|
106
104
|
i(), r();
|
|
107
105
|
return;
|
|
108
106
|
}
|
|
109
|
-
const e =
|
|
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");
|
|
110
108
|
o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
|
|
111
109
|
i(), r();
|
|
112
110
|
}, o.onerror = () => {
|
|
@@ -115,7 +113,7 @@ const ae = (E, l) => {
|
|
|
115
113
|
});
|
|
116
114
|
return { initPlugin: async (i) => {
|
|
117
115
|
await _(async () => {
|
|
118
|
-
const r =
|
|
116
|
+
const r = E(), [s, e] = await Promise.all([
|
|
119
117
|
b(),
|
|
120
118
|
k()
|
|
121
119
|
]);
|
|
@@ -124,5 +122,5 @@ const ae = (E, l) => {
|
|
|
124
122
|
} };
|
|
125
123
|
};
|
|
126
124
|
export {
|
|
127
|
-
|
|
125
|
+
se as useStripo
|
|
128
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
1
|
import { useRecommendation as C } from "../../composables/useRecommendation.js";
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as y, 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
|
{
|
|
@@ -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
|
});
|
|
@@ -36,7 +36,7 @@ const w = [
|
|
|
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;`;
|
|
@@ -65,20 +65,20 @@ const w = [
|
|
|
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}${N.PARAGRAPH_END_TAG}`, h = `${f}${r ? $ : s}${g.ELSE}${d}${N.PARAGRAPH_END_TAG}${g.END_IF}`;
|
|
81
|
+
e = e.replace(s, h);
|
|
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
|
-
if (o >= 6) {
|
|
170
|
-
const t = `rc${_++}
|
|
171
|
-
i.set(r, t),
|
|
169
|
+
if (!r.includes("v-text-anchor") && o >= 6) {
|
|
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
|
+
(h, I, m) => S(I, p) + m
|
|
195
195
|
), t = t.replace(
|
|
196
196
|
$.caseB,
|
|
197
|
-
(
|
|
198
|
-
), t = t.replaceAll(` style="${f}"`, ` class="${
|
|
197
|
+
(h, 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
|
};
|
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as S } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as _ } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
function y(r, c, e, o, s = "") {
|
|
5
|
+
const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
|
|
5
6
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
switch (
|
|
8
|
+
function f(r, c, e, o, s, n) {
|
|
9
|
+
switch (c) {
|
|
9
10
|
case "productImage": {
|
|
10
|
-
const t =
|
|
11
|
-
t && (t.setAttribute("src", `{{${n}${
|
|
12
|
-
const
|
|
13
|
-
|
|
11
|
+
const t = r.querySelector("img");
|
|
12
|
+
t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
|
|
13
|
+
const i = r.querySelector("a");
|
|
14
|
+
i && i.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
14
15
|
break;
|
|
15
16
|
}
|
|
16
17
|
case "productName": {
|
|
17
|
-
const t =
|
|
18
|
+
const t = r.querySelector("p");
|
|
18
19
|
if (t) {
|
|
19
|
-
const
|
|
20
|
-
|
|
20
|
+
const i = t.querySelector("strong") || t;
|
|
21
|
+
i.textContent = `{{${n}${e}_${o}_name}}`;
|
|
21
22
|
}
|
|
22
23
|
break;
|
|
23
24
|
}
|
|
24
25
|
case "productPrice": {
|
|
25
|
-
const t =
|
|
26
|
+
const t = r.querySelector("p");
|
|
26
27
|
if (t) {
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const i = t.querySelector("strong") || t;
|
|
29
|
+
i.textContent = y(e, o, "price", s, n);
|
|
29
30
|
}
|
|
30
31
|
break;
|
|
31
32
|
}
|
|
32
33
|
case "productOldPrice": {
|
|
33
|
-
const t =
|
|
34
|
+
const t = r.querySelector("p");
|
|
34
35
|
if (t) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const i = t.querySelector("strong") || t;
|
|
37
|
+
i.textContent = y(
|
|
38
|
+
e,
|
|
38
39
|
o,
|
|
39
40
|
"original_price",
|
|
40
41
|
s,
|
|
@@ -44,92 +45,127 @@ function p(e, u, r, o, s, n) {
|
|
|
44
45
|
break;
|
|
45
46
|
}
|
|
46
47
|
case "productButton": {
|
|
47
|
-
const t =
|
|
48
|
-
t && t.setAttribute("href", `{{${n}${
|
|
48
|
+
const t = r.querySelector("a");
|
|
49
|
+
t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
49
50
|
break;
|
|
50
51
|
}
|
|
51
52
|
case "productOmnibusPrice": {
|
|
52
|
-
const t =
|
|
53
|
+
const t = r.querySelector(".omnibus-price-value");
|
|
53
54
|
if (t) {
|
|
54
|
-
t.textContent = `{{${n}${
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_price}}`;
|
|
56
|
+
const i = t.closest("p");
|
|
57
|
+
i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
|
|
57
58
|
}
|
|
58
59
|
break;
|
|
59
60
|
}
|
|
60
61
|
case "productOmnibusDiscount": {
|
|
61
|
-
const t =
|
|
62
|
+
const t = r.querySelector(".omnibus-discount-value");
|
|
62
63
|
if (t) {
|
|
63
|
-
t.textContent = `{{${n}${
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_discount}}`;
|
|
65
|
+
const i = t.closest("p");
|
|
66
|
+
i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
|
|
66
67
|
}
|
|
67
68
|
break;
|
|
68
69
|
}
|
|
69
70
|
default: {
|
|
70
|
-
const t =
|
|
71
|
+
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
71
72
|
if (t) {
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
73
|
+
const i = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
74
|
+
if (a) {
|
|
75
|
+
const u = a.querySelector("strong") || a;
|
|
76
|
+
u.textContent = `{{${n}${e}_${o}_${i}}}`;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
n.querySelectorAll("[data-attribute-type]").forEach((
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}) :
|
|
83
|
+
function q(r, c, e, o) {
|
|
84
|
+
r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
85
|
+
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
86
|
+
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
87
|
+
p.length > 0 ? p.forEach((l) => {
|
|
88
|
+
f(l, u, c, t, e, o);
|
|
89
|
+
}) : f(a, u, c, t, e, o);
|
|
89
90
|
});
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
-
const s =
|
|
93
|
+
function w(r, c, e, o) {
|
|
94
|
+
const s = r.querySelectorAll(".recommendation-product-row");
|
|
94
95
|
if (!s.length)
|
|
95
96
|
return;
|
|
96
|
-
const [n] = s, t = n.querySelector("[data-attribute-type]"),
|
|
97
|
-
s.forEach((
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
l.querySelectorAll(".attribute-cell").forEach((
|
|
101
|
-
const
|
|
102
|
-
|
|
97
|
+
const [n] = s, t = n.querySelector("[data-attribute-type]"), i = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
98
|
+
s.forEach((a, u) => {
|
|
99
|
+
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
100
|
+
const d = l.getAttribute("data-attribute-type") || "";
|
|
101
|
+
l.querySelectorAll(".attribute-cell").forEach((A, h) => {
|
|
102
|
+
const $ = u * i + h;
|
|
103
|
+
f(A, d, c, $, e, o);
|
|
103
104
|
});
|
|
104
105
|
});
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
function E(r, c, e, o) {
|
|
109
|
+
r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
110
|
+
w(n, c, e, o);
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
-
const o =
|
|
114
|
-
o === "list" ?
|
|
113
|
+
function C(r, c, e) {
|
|
114
|
+
const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
|
|
115
|
+
o === "list" ? q(r, c, s, e) : E(r, c, s, e);
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
-
const
|
|
118
|
-
return
|
|
119
|
-
` : "") + u.documentElement.outerHTML;
|
|
117
|
+
function b(r, c, e) {
|
|
118
|
+
const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
|
|
119
|
+
return s ? parseInt(s[1]) : e;
|
|
120
120
|
}
|
|
121
|
-
function P(
|
|
122
|
-
|
|
121
|
+
function P(r, c) {
|
|
122
|
+
let e = r.parentElement;
|
|
123
|
+
for (; e && e !== c; ) {
|
|
124
|
+
if (e.tagName === "TD") {
|
|
125
|
+
const o = e.getAttribute("width");
|
|
126
|
+
if (o && o.endsWith("%") && parseFloat(o) < 100)
|
|
127
|
+
return e;
|
|
128
|
+
}
|
|
129
|
+
e = e.parentElement;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
function R(r) {
|
|
134
|
+
const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
135
|
+
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
|
|
136
|
+
if (n.hasAttribute("width"))
|
|
137
|
+
return;
|
|
138
|
+
const t = P(n, r);
|
|
139
|
+
if (!t)
|
|
140
|
+
return;
|
|
141
|
+
const i = t.getAttribute("width"), a = parseFloat(i), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
|
|
142
|
+
n.setAttribute("width", String(l));
|
|
143
|
+
const d = n.getAttribute("style") || "";
|
|
144
|
+
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
145
|
+
const m = d && !d.trim().endsWith(";") ? "; " : "";
|
|
146
|
+
n.setAttribute("style", `${d}${m}width: ${l}px`);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function v(r, c) {
|
|
151
|
+
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
152
|
+
return (e ? `${e[0]}
|
|
153
|
+
` : "") + c.documentElement.outerHTML;
|
|
154
|
+
}
|
|
155
|
+
function O(r) {
|
|
156
|
+
const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
123
157
|
if (!o.length)
|
|
124
|
-
return
|
|
125
|
-
const { buildCampaignUrl: s } =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
158
|
+
return r;
|
|
159
|
+
const { buildCampaignUrl: s } = S(), n = _();
|
|
160
|
+
n.recommendationCampaignUrls = {};
|
|
161
|
+
const { isFeatureEnabled: t } = g(), i = t("liquidSyntax") ? "reco_" : "";
|
|
162
|
+
return o.forEach((u) => {
|
|
163
|
+
var l, d;
|
|
164
|
+
const p = u.getAttribute("recommendation-id");
|
|
165
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), C(u, p, i), R(u));
|
|
166
|
+
}), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
131
167
|
}
|
|
132
168
|
export {
|
|
133
169
|
y as formatPriceVariable,
|
|
134
|
-
|
|
170
|
+
O as prepareRecommendationBlocks
|
|
135
171
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateItemsBlock as
|
|
4
|
-
import { migrateRadioButton as
|
|
5
|
-
import { migrateRecommendation as
|
|
6
|
-
import { migrateUnsubscribe as
|
|
7
|
-
const
|
|
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 =
|
|
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
|
-
|
|
12
|
+
b as migrate
|
|
13
13
|
};
|