@useinsider/guido 3.7.2-beta.a114aa7 → 3.7.2-beta.af89512
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/composables/useHtmlCompiler.js +8 -6
- package/dist/composables/useHtmlValidator.js +133 -180
- package/dist/config/compiler/htmlCompilerRules.js +15 -7
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +27 -28
- package/dist/config/migrator/fontTagMigrator.js +7 -0
- package/dist/config/migrator/index.js +8 -7
- package/dist/config/migrator/recommendation/extractors.js +22 -44
- package/dist/config/migrator/recommendation/htmlBuilder.js +169 -175
- package/dist/config/migrator/recommendationMigrator.js +31 -30
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -21
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +41 -55
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +33 -44
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +2 -3
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +49 -59
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +82 -89
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +6 -7
- package/dist/extensions/Blocks/Recommendation/extension.js +5 -6
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +2 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +12 -13
- package/dist/extensions/Blocks/Recommendation/templates/index.js +4 -5
- package/dist/src/composables/useHtmlValidator.d.ts +0 -27
- package/dist/src/config/migrator/fontTagMigrator.d.ts +8 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -15
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -8
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -9
- package/dist/src/utils/stripFontTags.d.ts +13 -0
- package/dist/utils/stripFontTags.js +13 -0
- package/package.json +1 -1
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +0 -15
- package/dist/src/composables/useHtmlValidator.test.d.ts +0 -1
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +0 -17
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +0 -1
|
@@ -13,6 +13,8 @@ const y = /* @__PURE__ */ new Set([
|
|
|
13
13
|
"fix-url-encoding-end",
|
|
14
14
|
"fix-tags-start",
|
|
15
15
|
"fix-tags-end",
|
|
16
|
+
// Unwrap translate-injected <font dir="auto"> tags — pure removal, never emits AMP-forbidden output.
|
|
17
|
+
"strip-font-tags",
|
|
16
18
|
// Image domain corrections — plain string replacement.
|
|
17
19
|
"replace-old-image-domain",
|
|
18
20
|
"replace-old-v2-image-domain",
|
|
@@ -26,22 +28,22 @@ const y = /* @__PURE__ */ new Set([
|
|
|
26
28
|
// Coupon placeholder replacement (only present when liquidSyntax is enabled).
|
|
27
29
|
"liquid-coupon-code"
|
|
28
30
|
]), M = () => {
|
|
29
|
-
var
|
|
30
|
-
const { compiler: e, isFeatureEnabled: a, partner: n } = k(),
|
|
31
|
-
...!!((
|
|
31
|
+
var t, m, r;
|
|
32
|
+
const { compiler: e, isFeatureEnabled: a, partner: n } = k(), p = ((t = e.value) == null ? void 0 : t.customRules) || [], l = [
|
|
33
|
+
...!!((m = e.value) != null && m.ignoreDefaultRules) ? [] : R,
|
|
32
34
|
...v,
|
|
33
35
|
...x,
|
|
34
36
|
...g,
|
|
35
37
|
...b,
|
|
36
38
|
...H,
|
|
37
39
|
...a("liquidSyntax") ? C : [],
|
|
38
|
-
...
|
|
40
|
+
...p.map((o, f) => ({
|
|
39
41
|
...o,
|
|
40
42
|
priority: o.priority + 1e3 + f
|
|
41
43
|
// Ensure additional rules run after default rules
|
|
42
44
|
}))
|
|
43
|
-
],
|
|
44
|
-
return { compileHtml: (o) =>
|
|
45
|
+
], u = s(l), c = l.filter((o) => y.has(o.id)), d = s(c), i = (r = n.value) == null ? void 0 : r.fallbackFont;
|
|
46
|
+
return { compileHtml: (o) => u.compile(o, void 0, i), compileAmpHtml: (o) => d.compile(o, void 0, i) };
|
|
45
47
|
};
|
|
46
48
|
export {
|
|
47
49
|
M as useHtmlCompiler
|
|
@@ -1,219 +1,172 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as X, CampaignCouldNotBeSavedKey as $, CanNotMakeAnyChangesForRunningKey as Y, DATA_ATTRIBUTE_REGEX as U, DYNAMIC_CONTENT_TAG_REGEX as j, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
|
|
1
|
+
import { useConfig as V } from "./useConfig.js";
|
|
2
|
+
import { TemplateTypes as G } from "../enums/defaults.js";
|
|
3
|
+
import { DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M, CampaignCouldNotBeSavedKey as X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
|
|
5
4
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
6
|
-
import { itemsBlockDynamicVariables as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function ae(t) {
|
|
18
|
-
return [...t.matchAll(re)].map((m) => m[1]);
|
|
5
|
+
import { itemsBlockDynamicVariables as j } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { useRecommendationExtensionStore as U } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
7
|
+
import { RecommendationRequiredFieldsKey as z } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
8
|
+
import { useRecommendationStore as Z } from "../stores/recommendation.js";
|
|
9
|
+
import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
|
|
10
|
+
import { useHttp as Q } from "./useHttp.js";
|
|
11
|
+
import { useToaster as ee } from "./useToaster.js";
|
|
12
|
+
import { useTranslations as te } from "./useTranslations.js";
|
|
13
|
+
const se = /recommendation-id="(\d+)"/g;
|
|
14
|
+
function ne(i) {
|
|
15
|
+
return [...i.matchAll(se)].map((d) => d[1]);
|
|
19
16
|
}
|
|
20
|
-
function
|
|
21
|
-
return
|
|
17
|
+
function ie(i, d) {
|
|
18
|
+
return d.some((g) => i.startsWith(`${g}_`));
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
function ue(t) {
|
|
29
|
-
const m = new Set(Z);
|
|
30
|
-
return Object.values(t).forEach((f) => {
|
|
31
|
-
m.add(Q(f.attributeName, t).toLowerCase());
|
|
32
|
-
}), m;
|
|
33
|
-
}
|
|
34
|
-
function de(t, m, f, i, d) {
|
|
35
|
-
const u = t.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
|
|
36
|
-
if (!u)
|
|
37
|
-
return [];
|
|
38
|
-
const p = new Set(m.map((y) => y.toLowerCase())), h = [];
|
|
39
|
-
return u.forEach((y) => {
|
|
40
|
-
const g = y.slice(2, -2).trim().toLowerCase();
|
|
41
|
-
if (g !== "" && p.has(g))
|
|
42
|
-
return;
|
|
43
|
-
const E = me(g);
|
|
44
|
-
if (E && i.has(E.recoId)) {
|
|
45
|
-
if (!d || d.has(E.attribute))
|
|
46
|
-
return;
|
|
47
|
-
h.push(g);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
ce(g, f) || g.includes(".") || h.push(g);
|
|
51
|
-
}), h;
|
|
52
|
-
}
|
|
53
|
-
function fe(t) {
|
|
54
|
-
return (t.replace(U, "$1").match(j) ?? []).filter((i) => {
|
|
55
|
-
const d = i.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
|
|
56
|
-
return q.includes(p) ? !1 : K.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
|
|
20
|
+
function oe(i) {
|
|
21
|
+
return (i.replace(Y, "$1").match($) ?? []).filter((r) => {
|
|
22
|
+
const u = r.slice(2, -2), f = u.indexOf("|"), p = (f === -1 ? u : u.slice(0, f)).trim();
|
|
23
|
+
return q.includes(p) ? !1 : K.test(p) ? f !== -1 && u.slice(f + 1).trim() === "" : !0;
|
|
57
24
|
});
|
|
58
25
|
}
|
|
59
|
-
const
|
|
60
|
-
var
|
|
61
|
-
const { showToaster:
|
|
62
|
-
|
|
63
|
-
return /* @__PURE__ */ new Set();
|
|
64
|
-
try {
|
|
65
|
-
await u.fetchRecommendationFilters();
|
|
66
|
-
} catch {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return ue(u.filterList);
|
|
70
|
-
}, y = async (e) => {
|
|
71
|
-
const n = await m(
|
|
26
|
+
const Ce = () => {
|
|
27
|
+
var h, v;
|
|
28
|
+
const { showToaster: i } = ee(), { post: d } = Q(), { config: g } = V(), r = te(), u = Z(), f = U(), p = ((v = (h = g.value) == null ? void 0 : h.partner) == null ? void 0 : v.messageType) === G.transactional, A = async (e) => {
|
|
29
|
+
const t = await d(
|
|
72
30
|
"/newsletter/template-library/check-template-html-body",
|
|
73
|
-
{ html:
|
|
74
|
-
), { status:
|
|
75
|
-
return
|
|
31
|
+
{ html: J(e) }
|
|
32
|
+
), { status: n, message: l } = t.data;
|
|
33
|
+
return n || i({
|
|
76
34
|
type: c.Alert,
|
|
77
|
-
message:
|
|
78
|
-
}),
|
|
35
|
+
message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
|
|
36
|
+
}), r(X), l === r(P) && i({
|
|
79
37
|
type: c.Alert,
|
|
80
|
-
message:
|
|
81
|
-
}),
|
|
82
|
-
},
|
|
83
|
-
const
|
|
84
|
-
let
|
|
85
|
-
return
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
const [
|
|
89
|
-
|
|
38
|
+
message: r("newsletter.already-in-progress")
|
|
39
|
+
}), n;
|
|
40
|
+
}, S = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), b = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, s) => {
|
|
41
|
+
const t = e.match(/({%(.*?)%})/g);
|
|
42
|
+
let n = !0;
|
|
43
|
+
return t !== null && !p && t.forEach((l) => {
|
|
44
|
+
const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
45
|
+
if (o && o.length > 0) {
|
|
46
|
+
const [a] = o;
|
|
47
|
+
S(a) && !s.includes(a) && (i({
|
|
90
48
|
type: c.Warning,
|
|
91
|
-
message:
|
|
92
|
-
}),
|
|
49
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
50
|
+
}), n = !1);
|
|
93
51
|
}
|
|
94
|
-
}),
|
|
95
|
-
},
|
|
96
|
-
const
|
|
97
|
-
return
|
|
98
|
-
},
|
|
52
|
+
}), n;
|
|
53
|
+
}, T = async (e, s, t) => {
|
|
54
|
+
const n = t ? await A(e) : !0;
|
|
55
|
+
return I(e, s) && n;
|
|
56
|
+
}, w = (e) => e.length > 0 ? !0 : (i({
|
|
99
57
|
type: c.Warning,
|
|
100
|
-
message:
|
|
101
|
-
}), !1),
|
|
102
|
-
const s = (e.match(/{/gm) || []).length,
|
|
103
|
-
return s >
|
|
58
|
+
message: r("newsletter.html-content-is-empty")
|
|
59
|
+
}), !1), x = (e) => {
|
|
60
|
+
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
61
|
+
return s > t && i({
|
|
104
62
|
type: c.Warning,
|
|
105
|
-
message:
|
|
106
|
-
}), s <
|
|
63
|
+
message: r("custom-fields.missing-closing-braces")
|
|
64
|
+
}), s < t && i({
|
|
107
65
|
type: c.Warning,
|
|
108
|
-
message:
|
|
109
|
-
}), s ===
|
|
110
|
-
},
|
|
111
|
-
const s =
|
|
112
|
-
return s ||
|
|
66
|
+
message: r("custom-fields.missing-opening-braces")
|
|
67
|
+
}), s === t;
|
|
68
|
+
}, _ = (e) => {
|
|
69
|
+
const s = oe(e).length === 0;
|
|
70
|
+
return s || i({
|
|
113
71
|
type: c.Warning,
|
|
114
|
-
message:
|
|
72
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
115
73
|
}), s;
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
message: i("custom-fields.invalid-custom-fields") + r
|
|
135
|
-
}), !1;
|
|
74
|
+
}, k = (e, s) => {
|
|
75
|
+
const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
|
|
76
|
+
if (t && !p) {
|
|
77
|
+
const n = new Set(s.map((a) => a.toLowerCase())), l = ne(e), o = [];
|
|
78
|
+
if (t.forEach((a) => {
|
|
79
|
+
const m = a.slice(2, -2).trim().toLowerCase();
|
|
80
|
+
(!n.has(m) || m === "") && !ie(m, l) && o.push(m);
|
|
81
|
+
}), o.length > 0) {
|
|
82
|
+
const a = `
|
|
83
|
+
<ul>
|
|
84
|
+
${o.map((m) => `<li>${m}</li>`).join("")}
|
|
85
|
+
</ul>
|
|
86
|
+
`;
|
|
87
|
+
return i({
|
|
88
|
+
type: c.Alert,
|
|
89
|
+
message: r("custom-fields.invalid-custom-fields") + a
|
|
90
|
+
}), !1;
|
|
91
|
+
}
|
|
136
92
|
}
|
|
137
93
|
return !0;
|
|
138
|
-
},
|
|
139
|
-
const s = e.match(/{%(.*?)%}/g),
|
|
140
|
-
let
|
|
141
|
-
if (s && s.forEach((
|
|
142
|
-
const
|
|
143
|
-
(!
|
|
94
|
+
}, R = (e) => {
|
|
95
|
+
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
96
|
+
let n = !0;
|
|
97
|
+
if (s && s.forEach((l) => {
|
|
98
|
+
const o = l.match(H), a = l.match(M), m = (o == null ? void 0 : o.join("")) || "";
|
|
99
|
+
(!o || l !== m) && !a && (i({
|
|
144
100
|
type: c.Alert,
|
|
145
|
-
message:
|
|
146
|
-
}),
|
|
147
|
-
|
|
101
|
+
message: r("newsletter.display-conditions-invalid-syntax")
|
|
102
|
+
}), n = !1), o && o.forEach((y) => {
|
|
103
|
+
y.trim() === "=" && (i({
|
|
148
104
|
type: c.Alert,
|
|
149
|
-
message:
|
|
150
|
-
}),
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
E
|
|
105
|
+
message: r("custom-conditions.wrong-equality-operators")
|
|
106
|
+
}), n = !1);
|
|
107
|
+
const C = y.match(/^[a-zA-Z]*$/g);
|
|
108
|
+
C && C.forEach((E) => {
|
|
109
|
+
b(E) && t.push(E);
|
|
154
110
|
});
|
|
155
111
|
});
|
|
156
|
-
}),
|
|
157
|
-
const
|
|
158
|
-
|
|
112
|
+
}), t.length) {
|
|
113
|
+
const l = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
|
|
114
|
+
l.length !== o.length && (i({
|
|
159
115
|
type: c.Alert,
|
|
160
|
-
message:
|
|
161
|
-
}),
|
|
116
|
+
message: r("custom-conditions.missing-if-endif-tag")
|
|
117
|
+
}), n = !1);
|
|
162
118
|
}
|
|
163
|
-
return
|
|
164
|
-
},
|
|
165
|
-
const s = (e.match(/{% /gm) || []).length,
|
|
166
|
-
return
|
|
119
|
+
return n;
|
|
120
|
+
}, N = (e) => {
|
|
121
|
+
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
|
|
122
|
+
return n || i({
|
|
167
123
|
type: c.Warning,
|
|
168
|
-
message:
|
|
169
|
-
}),
|
|
170
|
-
},
|
|
124
|
+
message: r("custom-conditions.no-space-after-braces")
|
|
125
|
+
}), n;
|
|
126
|
+
}, D = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (i({
|
|
171
127
|
type: c.Warning,
|
|
172
|
-
message:
|
|
173
|
-
}), !1) : !0,
|
|
128
|
+
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
129
|
+
}), !1) : !0, F = () => f.hasInvalidBlock() ? (i({
|
|
174
130
|
type: c.Alert,
|
|
175
|
-
message:
|
|
176
|
-
}), !1) : !0,
|
|
131
|
+
message: r(z)
|
|
132
|
+
}), !1) : !0, O = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (i({
|
|
177
133
|
type: c.Alert,
|
|
178
|
-
message:
|
|
179
|
-
}), !1) : !0,
|
|
134
|
+
message: r("newsletter.fill-all-necessary-fields")
|
|
135
|
+
}), !1) : !0, B = (e) => {
|
|
180
136
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
181
|
-
return e.match(s) === null ? !0 : (
|
|
137
|
+
return e.match(s) === null ? !0 : (i({
|
|
182
138
|
type: c.Alert,
|
|
183
|
-
message:
|
|
139
|
+
message: r("newsletter.invalid-image-type")
|
|
184
140
|
}), !1);
|
|
185
|
-
},
|
|
186
|
-
const
|
|
187
|
-
return Array.from(
|
|
188
|
-
var
|
|
189
|
-
return !((
|
|
190
|
-
}) ? (
|
|
141
|
+
}, L = (e) => {
|
|
142
|
+
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
143
|
+
return Array.from(n).find((o) => {
|
|
144
|
+
var a;
|
|
145
|
+
return !((a = o.id) != null && a.trim());
|
|
146
|
+
}) ? (i({
|
|
191
147
|
type: c.Alert,
|
|
192
|
-
message:
|
|
148
|
+
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
193
149
|
}), !1) : !0;
|
|
194
|
-
},
|
|
195
|
-
const
|
|
196
|
-
return Array.from(
|
|
197
|
-
var
|
|
198
|
-
return !((
|
|
199
|
-
}) ? (
|
|
150
|
+
}, W = (e) => {
|
|
151
|
+
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
152
|
+
return Array.from(n).find((o) => {
|
|
153
|
+
var a;
|
|
154
|
+
return !((a = o.id) != null && a.trim());
|
|
155
|
+
}) ? (i({
|
|
200
156
|
type: c.Alert,
|
|
201
|
-
message:
|
|
157
|
+
message: r("unsubscribe-templates.select-radio-button-groups")
|
|
202
158
|
}), !1) : !0;
|
|
203
159
|
};
|
|
204
|
-
return { validateHtml: async (e, s,
|
|
205
|
-
var
|
|
206
|
-
const
|
|
207
|
-
...s.map((
|
|
208
|
-
...
|
|
209
|
-
...((
|
|
210
|
-
]
|
|
211
|
-
return await
|
|
160
|
+
return { validateHtml: async (e, s, t = !1) => {
|
|
161
|
+
var o, a;
|
|
162
|
+
const n = [
|
|
163
|
+
...s.map((m) => m.value),
|
|
164
|
+
...j,
|
|
165
|
+
...((a = (o = g.value) == null ? void 0 : o.template) == null ? void 0 : a.customFieldAttributes) ?? []
|
|
166
|
+
];
|
|
167
|
+
return await T(e, n, t) && w(e) && x(e) && _(e) && k(e, n) && R(e) && N(e) && D(e) && F() && O() && B(e) && L(e) && W(e);
|
|
212
168
|
} };
|
|
213
169
|
};
|
|
214
170
|
export {
|
|
215
|
-
|
|
216
|
-
de as findInvalidCustomFields,
|
|
217
|
-
me as parseRecommendationVariable,
|
|
218
|
-
xe as useHtmlValidator
|
|
171
|
+
Ce as useHtmlValidator
|
|
219
172
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { stripFontTags as n } from "../../utils/stripFontTags.js";
|
|
2
|
+
const l = [
|
|
2
3
|
{
|
|
3
4
|
id: "fix-url-encoding-start",
|
|
4
5
|
description: "Replace {%22 with %7B%22 to fix URL encoding",
|
|
@@ -53,6 +54,13 @@ const a = [
|
|
|
53
54
|
replaceAll: !0,
|
|
54
55
|
priority: 14
|
|
55
56
|
},
|
|
57
|
+
{
|
|
58
|
+
id: "strip-font-tags",
|
|
59
|
+
description: 'Unwrap <font dir="auto"> tags injected by browser translate extensions (e.g. Google Translate), keeping inner content — prevents Chrome DOM-depth overflow ("512 nodes"). Other <font> elements are left intact.',
|
|
60
|
+
type: "custom",
|
|
61
|
+
processor: (e) => n(e),
|
|
62
|
+
priority: 15
|
|
63
|
+
},
|
|
56
64
|
{
|
|
57
65
|
id: "remove-apty-iframe",
|
|
58
66
|
description: "Cleanup Apty Iframe Code",
|
|
@@ -91,7 +99,7 @@ const a = [
|
|
|
91
99
|
description: "Adding MSO Conditions",
|
|
92
100
|
type: "custom",
|
|
93
101
|
processor: (e) => {
|
|
94
|
-
const
|
|
102
|
+
const i = [
|
|
95
103
|
`<!--[if gte mso 9]>
|
|
96
104
|
<style>sup {
|
|
97
105
|
font-size: 100% !important;
|
|
@@ -114,10 +122,10 @@ const a = [
|
|
|
114
122
|
], s = /<head>([\S\s]*)<\/head>/, o = new RegExp(s);
|
|
115
123
|
if (!e.match(o))
|
|
116
124
|
return e;
|
|
117
|
-
let
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
}),
|
|
125
|
+
let t = e;
|
|
126
|
+
return i.forEach((r) => {
|
|
127
|
+
t = t.replace("</head>", `${r}</head>`);
|
|
128
|
+
}), t;
|
|
121
129
|
},
|
|
122
130
|
priority: 30
|
|
123
131
|
},
|
|
@@ -141,5 +149,5 @@ const a = [
|
|
|
141
149
|
}
|
|
142
150
|
];
|
|
143
151
|
export {
|
|
144
|
-
|
|
152
|
+
l as defaultHtmlCompilerRules
|
|
145
153
|
};
|
|
@@ -2,7 +2,6 @@ import { useConfig as g } from "../../../composables/useConfig.js";
|
|
|
2
2
|
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
|
|
6
5
|
function y(r, n, e, o, i = "") {
|
|
7
6
|
const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
|
|
8
7
|
return o === "before" ? `${t} ${c}` : `${c} ${t}`;
|
|
@@ -13,7 +12,7 @@ function A(r) {
|
|
|
13
12
|
[n] = n.children;
|
|
14
13
|
return n;
|
|
15
14
|
}
|
|
16
|
-
function
|
|
15
|
+
function f(r, n, e, o, i, c) {
|
|
17
16
|
switch (n) {
|
|
18
17
|
case "productImage": {
|
|
19
18
|
const t = r.querySelector("img");
|
|
@@ -88,45 +87,45 @@ function b(r, n, e, o, i, c) {
|
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
function
|
|
90
|
+
function w(r, n, e, o) {
|
|
92
91
|
r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
|
|
93
92
|
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
94
93
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
95
94
|
p.length > 0 ? p.forEach((l) => {
|
|
96
|
-
|
|
97
|
-
}) :
|
|
95
|
+
f(l, u, n, t, e, o);
|
|
96
|
+
}) : f(a, u, n, t, e, o);
|
|
98
97
|
});
|
|
99
98
|
});
|
|
100
99
|
}
|
|
101
|
-
function
|
|
100
|
+
function E(r, n, e, o) {
|
|
102
101
|
const i = r.querySelectorAll(".recommendation-product-row");
|
|
103
102
|
if (!i.length)
|
|
104
103
|
return;
|
|
105
104
|
const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
106
105
|
i.forEach((a, u) => {
|
|
107
106
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
108
|
-
const
|
|
107
|
+
const d = l.getAttribute("data-attribute-type") || "";
|
|
109
108
|
l.querySelectorAll(".attribute-cell").forEach((h, $) => {
|
|
110
109
|
const S = u * s + $;
|
|
111
|
-
|
|
110
|
+
f(h, d, n, S, e, o);
|
|
112
111
|
});
|
|
113
112
|
});
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
|
-
function
|
|
115
|
+
function R(r, n, e, o) {
|
|
117
116
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
118
|
-
|
|
117
|
+
E(c, n, e, o);
|
|
119
118
|
});
|
|
120
119
|
}
|
|
121
|
-
function
|
|
120
|
+
function P(r, n, e) {
|
|
122
121
|
const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
|
|
123
|
-
o === "list" ?
|
|
122
|
+
o === "list" ? w(r, n, i, e) : R(r, n, i, e);
|
|
124
123
|
}
|
|
125
|
-
function
|
|
124
|
+
function b(r, n, e) {
|
|
126
125
|
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
|
|
127
126
|
return i ? parseInt(i[1]) : e;
|
|
128
127
|
}
|
|
129
|
-
function
|
|
128
|
+
function T(r, n) {
|
|
130
129
|
let e = r.parentElement;
|
|
131
130
|
for (; e && e !== n; ) {
|
|
132
131
|
if (e.tagName === "TD") {
|
|
@@ -138,29 +137,29 @@ function v(r, n) {
|
|
|
138
137
|
}
|
|
139
138
|
return null;
|
|
140
139
|
}
|
|
141
|
-
function
|
|
142
|
-
const n = r.getAttribute("style") || "", e =
|
|
140
|
+
function v(r) {
|
|
141
|
+
const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, i = Math.max(0, e - o);
|
|
143
142
|
i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
144
143
|
if (c.hasAttribute("width"))
|
|
145
144
|
return;
|
|
146
|
-
const t =
|
|
145
|
+
const t = T(c, r);
|
|
147
146
|
if (!t)
|
|
148
147
|
return;
|
|
149
|
-
const s = t.getAttribute("width"), a = parseFloat(s), u =
|
|
148
|
+
const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
|
|
150
149
|
c.setAttribute("width", String(l));
|
|
151
|
-
const
|
|
152
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
153
|
-
const
|
|
154
|
-
c.setAttribute("style", `${
|
|
150
|
+
const d = c.getAttribute("style") || "";
|
|
151
|
+
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
152
|
+
const m = d && !d.trim().endsWith(";") ? "; " : "";
|
|
153
|
+
c.setAttribute("style", `${d}${m}width: ${l}px`);
|
|
155
154
|
}
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
|
-
function
|
|
157
|
+
function O(r, n) {
|
|
159
158
|
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
160
159
|
return (e ? `${e[0]}
|
|
161
160
|
` : "") + n.documentElement.outerHTML;
|
|
162
161
|
}
|
|
163
|
-
function
|
|
162
|
+
function N(r) {
|
|
164
163
|
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
165
164
|
if (!o.length)
|
|
166
165
|
return r;
|
|
@@ -168,12 +167,12 @@ function F(r) {
|
|
|
168
167
|
c.recommendationCampaignUrls = {};
|
|
169
168
|
const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
|
|
170
169
|
return o.forEach((u) => {
|
|
171
|
-
var l,
|
|
170
|
+
var l, d;
|
|
172
171
|
const p = u.getAttribute("recommendation-id");
|
|
173
|
-
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (
|
|
174
|
-
}),
|
|
172
|
+
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()), i(p), P(u, p, s), v(u));
|
|
173
|
+
}), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
175
174
|
}
|
|
176
175
|
export {
|
|
177
176
|
y as formatPriceVariable,
|
|
178
|
-
|
|
177
|
+
N as prepareRecommendationBlocks
|
|
179
178
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { migrateCheckbox as o } from "./checkboxMigrator.js";
|
|
2
2
|
import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
3
|
+
import { migrateFontTags as e } from "./fontTagMigrator.js";
|
|
4
|
+
import { migrateItemsBlock as a } from "./itemsBlockMigrator.js";
|
|
5
|
+
import { migrateRadioButton as g } from "./radioButtonMigrator.js";
|
|
6
|
+
import { migrateRecommendation as n } from "./recommendationMigrator.js";
|
|
7
|
+
import { migrateUnsubscribe as p } from "./unsubscribeMigrator.js";
|
|
8
|
+
const k = async (r, t = {}) => {
|
|
8
9
|
let m = r;
|
|
9
|
-
return m = o(m), m =
|
|
10
|
+
return m = e(m), m = o(m), m = g(m), m = await p(m), m = i(m), m = n(m, t), m = a(m), m;
|
|
10
11
|
};
|
|
11
12
|
export {
|
|
12
|
-
|
|
13
|
+
k as migrate
|
|
13
14
|
};
|