@useinsider/guido 3.9.1-beta.c64c39e → 3.9.1-beta.de8e72f
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/config/compiler/recommendationCompilerRules.js +55 -38
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +149 -156
- package/dist/enums/defaults.js +4 -7
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +69 -75
- package/dist/services/stripoApi.js +18 -13
- package/dist/src/enums/defaults.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +0 -6
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/package.json +1 -1
- package/dist/services/blankTemplate.js +0 -34
- package/dist/src/services/blankTemplate.d.ts +0 -11
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useRecommendation as N } from "../../composables/useRecommendation.js";
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as h, REGEX as d, VerticalOrientation as $, CSS as n, ATTRIBUTES as p, CONDITIONS as A, HTML as g } from "../../enums/recommendation.js";
|
|
3
3
|
import { prepareRecommendationBlocks as O } from "./utils/recommendationCompilerUtils.js";
|
|
4
|
-
const
|
|
4
|
+
const H = [
|
|
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(r).forEach(([
|
|
13
|
-
e = e.replaceAll(i, `{{${
|
|
9
|
+
processor: (t) => {
|
|
10
|
+
let e = t;
|
|
11
|
+
return Object.entries(h).forEach(([, r]) => {
|
|
12
|
+
Object.entries(r).forEach(([o, i]) => {
|
|
13
|
+
e = e.replaceAll(i, `{{${o}}}`);
|
|
14
14
|
});
|
|
15
15
|
}), e;
|
|
16
16
|
},
|
|
@@ -41,10 +41,10 @@ const U = [
|
|
|
41
41
|
id: "add-recommendation-unresponsive-css",
|
|
42
42
|
description: "Adding recommendation unresponsive css",
|
|
43
43
|
type: "custom",
|
|
44
|
-
processor: (
|
|
44
|
+
processor: (t) => {
|
|
45
45
|
const { calculateCardWidth: e, getRecommendationCampaignData: r } = N();
|
|
46
|
-
let
|
|
47
|
-
const i =
|
|
46
|
+
let o = t;
|
|
47
|
+
const i = o.match(d.ID);
|
|
48
48
|
if (i) {
|
|
49
49
|
const s = [];
|
|
50
50
|
if (i.forEach((c) => {
|
|
@@ -52,10 +52,10 @@ const U = [
|
|
|
52
52
|
u.textTrimming && u.orientation === $ && s.push(e(u));
|
|
53
53
|
}), s.length) {
|
|
54
54
|
const c = `width:${Math.min(...s)}px!important;`;
|
|
55
|
-
|
|
55
|
+
o = o.replace(n.REGULAR_NAME_HEIGHT, `${n.TRIMMED_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.REGULAR_NAME_CONTAINER_HEIGHT, n.TRIMMED_NAME_CONTAINER_CSS).replace(n.RESPONSIVE_NAME_SIZE, `${n.RESPONSIVE_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.RESPONSIVE_NAME_CONTAINER_HEIGHT, n.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return o;
|
|
59
59
|
},
|
|
60
60
|
priority: 52
|
|
61
61
|
},
|
|
@@ -63,16 +63,16 @@ const U = [
|
|
|
63
63
|
id: "prepare-recommendations",
|
|
64
64
|
description: "Replacing product data with template variables in recommendation blocks",
|
|
65
65
|
type: "custom",
|
|
66
|
-
processor: (
|
|
66
|
+
processor: (t) => O(t),
|
|
67
67
|
priority: 48
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
id: "add-discount-conditions",
|
|
71
71
|
description: "Adding discount conditions to the recommendation block",
|
|
72
72
|
type: "custom",
|
|
73
|
-
processor: (
|
|
74
|
-
let e =
|
|
75
|
-
const r = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData:
|
|
73
|
+
processor: (t) => {
|
|
74
|
+
let e = t;
|
|
75
|
+
const r = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: o } = N();
|
|
76
76
|
return r !== null && r.forEach((i) => {
|
|
77
77
|
const s = i.match(d.CUSTOM_FIELD);
|
|
78
78
|
if (!s)
|
|
@@ -80,17 +80,17 @@ const U = [
|
|
|
80
80
|
const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u = i.match(d.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
81
81
|
if (!m || !E || !u)
|
|
82
82
|
return;
|
|
83
|
-
const [
|
|
83
|
+
const [T] = m, [I] = E, [_] = u, b = I.substring(1, I.length - 2), S = _.match(d.COMPOSITION) !== null;
|
|
84
84
|
let a = c;
|
|
85
85
|
if (S) {
|
|
86
|
-
const
|
|
86
|
+
const y = T.substring(2, T.length - 3), l = o(y);
|
|
87
87
|
b === p.OMNIBUS_PRICE && (l.priceBeforeTextValue && (a = `${l.priceBeforeTextValue}${a}`), l.priceAfterTextValue && (a = `${a}${l.priceAfterTextValue}`)), b === p.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (a = `${l.discountBeforeTextValue}${a}`), l.discountAfterTextValue && (a = `${a}${l.discountAfterTextValue}`));
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
let
|
|
91
|
-
b in
|
|
92
|
-
const
|
|
93
|
-
e = e.replace(i,
|
|
89
|
+
const R = T.substring(2);
|
|
90
|
+
let f = "";
|
|
91
|
+
b in A.IF && (f = A.IF[b].replaceAll(`{${p.DISCOUNT}}`, `${R}${p.DISCOUNT}`).replaceAll(`{${p.OMNIBUS_DISCOUNT}}`, `${R}${p.OMNIBUS_DISCOUNT}`).replaceAll(`{${p.OMNIBUS_PRICE}}`, `${R}${p.OMNIBUS_PRICE}`));
|
|
92
|
+
const M = `${_}${a}${g.PARAGRAPH_END_TAG}`, C = `${f}${S ? M : i}${A.ELSE}${_}${g.PARAGRAPH_END_TAG}${A.END_IF}`;
|
|
93
|
+
e = e.replace(i, C);
|
|
94
94
|
}), e;
|
|
95
95
|
},
|
|
96
96
|
priority: 53
|
|
@@ -110,11 +110,11 @@ const U = [
|
|
|
110
110
|
type: "custom",
|
|
111
111
|
// Scoped to REC_START/REC_END markers so it cannot strip `product-attr`
|
|
112
112
|
// from Items block elements, which the items compiler rule depends on.
|
|
113
|
-
processor: (
|
|
113
|
+
processor: (t) => {
|
|
114
114
|
const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|data-same-price|product-attr|composition)="[^"]*"/g;
|
|
115
|
-
return
|
|
115
|
+
return t.replace(
|
|
116
116
|
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
117
|
-
(r,
|
|
117
|
+
(r, o) => `<!--REC_START-->${o.replace(e, "")}<!--REC_END-->`
|
|
118
118
|
);
|
|
119
119
|
},
|
|
120
120
|
priority: 55
|
|
@@ -123,8 +123,8 @@ const U = [
|
|
|
123
123
|
id: "strip-unused-recommendation-classes",
|
|
124
124
|
description: "Remove CSS classes not referenced by any style rule from recommendation elements",
|
|
125
125
|
type: "custom",
|
|
126
|
-
processor: (
|
|
127
|
-
let e =
|
|
126
|
+
processor: (t) => {
|
|
127
|
+
let e = t.replace(
|
|
128
128
|
/ 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,
|
|
129
129
|
""
|
|
130
130
|
);
|
|
@@ -136,8 +136,8 @@ const U = [
|
|
|
136
136
|
id: "remove-empty-mobile-layout-artifacts",
|
|
137
137
|
description: "Remove empty mobile container rows and unused mobile layout CSS",
|
|
138
138
|
type: "custom",
|
|
139
|
-
processor: (
|
|
140
|
-
let e =
|
|
139
|
+
processor: (t) => {
|
|
140
|
+
let e = t;
|
|
141
141
|
return e = e.replace(
|
|
142
142
|
/<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
|
|
143
143
|
""
|
|
@@ -146,8 +146,8 @@ const U = [
|
|
|
146
146
|
""
|
|
147
147
|
), e = e.replace(
|
|
148
148
|
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
149
|
-
(r,
|
|
150
|
-
const i =
|
|
149
|
+
(r, o) => {
|
|
150
|
+
const i = o.match(/[^{}]+\{[^{}]*\}/g) || [], s = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
151
151
|
return i.every((m) => s.test(m)) ? "" : r;
|
|
152
152
|
}
|
|
153
153
|
)), e;
|
|
@@ -163,11 +163,11 @@ const U = [
|
|
|
163
163
|
// (SD-142395: split out of the removed deduplicate-inline-styles rule.)
|
|
164
164
|
description: "Force !important on es-button link color to defeat Gmail link-color override",
|
|
165
165
|
type: "custom",
|
|
166
|
-
processor: (
|
|
166
|
+
processor: (t) => t.replace(
|
|
167
167
|
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
168
168
|
(e) => e.replace(
|
|
169
169
|
/([;"]color:)([^;"]+)/g,
|
|
170
|
-
(r,
|
|
170
|
+
(r, o, i) => i.includes("!important") ? r : `${o}${i} !important`
|
|
171
171
|
)
|
|
172
172
|
),
|
|
173
173
|
priority: 58
|
|
@@ -183,13 +183,30 @@ const U = [
|
|
|
183
183
|
// rather than classed, so they survive Gmail clipping.
|
|
184
184
|
description: "Collapse whitespace inside recommendation blocks and strip boundary markers",
|
|
185
185
|
type: "custom",
|
|
186
|
-
processor: (
|
|
187
|
-
const e = (r) => r.replace(/>\s+</g, "><").replace(/<[^>]+>/g, (
|
|
188
|
-
return
|
|
186
|
+
processor: (t) => {
|
|
187
|
+
const e = (r) => r.replace(/>\s+</g, "><").replace(/<[^>]+>/g, (o) => o.replace(/\s+/g, " "));
|
|
188
|
+
return t.replace(/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, (r, o) => e(o)).replaceAll("<!--REC_START-->", "").replaceAll("<!--REC_END-->", "");
|
|
189
189
|
},
|
|
190
190
|
priority: 99
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: "wrap-mobile-row-mso-conditional",
|
|
194
|
+
// SD-145666: OLD Outlook (Word engine) ignores @media and honors display:none
|
|
195
|
+
// on <tr>/<table> unreliably, so it renders BOTH the desktop AND the populated
|
|
196
|
+
// mobile recommendation container — products duplicate (1,2,1,2). prepare-
|
|
197
|
+
// recommendations (P48) tags each POPULATED mobile <tr> with safe placeholder
|
|
198
|
+
// comments; swap them here — AFTER minify (P99) has collapsed whitespace and
|
|
199
|
+
// stripped the REC markers — into a downlevel-revealed conditional comment so
|
|
200
|
+
// Outlook skips the row while every other client still renders it. Injecting the
|
|
201
|
+
// delicate `<!-- -->` ghost token LAST keeps it out of every whitespace/comment-
|
|
202
|
+
// mangling pass. email-service preserves this exact pattern (proven around
|
|
203
|
+
// es-button spans in delivered emails).
|
|
204
|
+
description: "Wrap populated recommendation mobile row in [if !mso] conditional comment for Outlook",
|
|
205
|
+
type: "custom",
|
|
206
|
+
processor: (t) => t.replaceAll("<!--MSO_MOBILE_HIDE_START-->", "<!--[if !mso]><!-- -->").replaceAll("<!--MSO_MOBILE_HIDE_END-->", "<!--<![endif]-->"),
|
|
207
|
+
priority: 100
|
|
191
208
|
}
|
|
192
209
|
];
|
|
193
210
|
export {
|
|
194
|
-
|
|
211
|
+
H as recommendationCompilerRules
|
|
195
212
|
};
|
|
@@ -1,207 +1,200 @@
|
|
|
1
1
|
import { useConfig as C } from "../../../composables/useConfig.js";
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { CSS_CLASS_RECO_BUTTON as
|
|
2
|
+
import { useRecommendation as q } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { MOBILE_ROW_SELECTOR as O, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as T } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as w } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
import { isIgnoredRecommendationBlock as
|
|
6
|
-
function
|
|
7
|
-
const i = `{{${
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
for (;
|
|
13
|
-
[
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
function
|
|
17
|
-
switch (
|
|
5
|
+
import { isIgnoredRecommendationBlock as R } from "./recommendationIgnoreUtils.js";
|
|
6
|
+
function m(e, o, t, n, c = "") {
|
|
7
|
+
const i = `{{${c}${e}_${o}_${t}}}`, r = `{{${c}${e}_${o}_currency}}`;
|
|
8
|
+
return n === "before" ? `${r} ${i}` : `${i} ${r}`;
|
|
9
|
+
}
|
|
10
|
+
function f(e) {
|
|
11
|
+
let o = e;
|
|
12
|
+
for (; o.children.length === 1; )
|
|
13
|
+
[o] = o.children;
|
|
14
|
+
return o;
|
|
15
|
+
}
|
|
16
|
+
function y(e, o, t, n, c, i) {
|
|
17
|
+
switch (o) {
|
|
18
18
|
case "productImage": {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const r = e.querySelector("img");
|
|
20
|
+
r && (r.setAttribute("src", `{{${i}${t}_${n}_image_url}}`), r.setAttribute("alt", `{{${i}${t}_${n}_name}}`));
|
|
21
|
+
const s = e.querySelector("a");
|
|
22
|
+
s && (s.setAttribute("href", `{{${i}${t}_${n}_url}}`), s.classList.add(T));
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productName": {
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const r = e.querySelector("p");
|
|
27
|
+
r && (f(r).textContent = `{{${i}${t}_${n}_name}}`);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case "productPrice": {
|
|
31
|
+
const r = e.querySelector(".product-price p") ?? e.querySelector("p");
|
|
32
|
+
r && (f(r).textContent = m(
|
|
33
|
+
t,
|
|
34
|
+
n,
|
|
35
|
+
"price",
|
|
36
|
+
c,
|
|
37
|
+
i
|
|
38
|
+
));
|
|
39
|
+
const s = e.querySelector(".product-old-price p");
|
|
40
|
+
s && (f(s).textContent = m(
|
|
41
|
+
t,
|
|
42
|
+
n,
|
|
43
|
+
"original_price",
|
|
44
|
+
c,
|
|
45
|
+
i
|
|
46
|
+
));
|
|
28
47
|
break;
|
|
29
48
|
}
|
|
30
|
-
// Inline mode ("Move to next line" OFF) merges BOTH prices into one row
|
|
31
|
-
// anchored on whichever attribute comes first in the composition, so
|
|
32
|
-
// substitute by cell content, not by the row's anchor (SD-145161).
|
|
33
|
-
case "productPrice":
|
|
34
49
|
case "productOldPrice": {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, c = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !c && !a ? t.querySelector("p") : null;
|
|
44
|
-
n(c ?? (r === "productPrice" ? u : null), "price"), n(a ?? (r === "productOldPrice" ? u : null), "original_price");
|
|
50
|
+
const r = e.querySelector("p");
|
|
51
|
+
r && (f(r).textContent = m(
|
|
52
|
+
t,
|
|
53
|
+
n,
|
|
54
|
+
"original_price",
|
|
55
|
+
c,
|
|
56
|
+
i
|
|
57
|
+
));
|
|
45
58
|
break;
|
|
46
59
|
}
|
|
47
60
|
case "productButton": {
|
|
48
|
-
const
|
|
49
|
-
|
|
61
|
+
const r = e.querySelector("a");
|
|
62
|
+
r && r.setAttribute("href", `{{${i}${t}_${n}_url}}`);
|
|
50
63
|
break;
|
|
51
64
|
}
|
|
52
65
|
case "productOmnibusPrice": {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
66
|
+
const r = e.querySelector(".omnibus-price-value");
|
|
67
|
+
if (r) {
|
|
68
|
+
r.textContent = `{{${i}${t}_${n}_omnibus_price}}`;
|
|
69
|
+
const s = r.closest("p");
|
|
70
|
+
s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
|
|
58
71
|
}
|
|
59
72
|
break;
|
|
60
73
|
}
|
|
61
74
|
case "productOmnibusDiscount": {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
75
|
+
const r = e.querySelector(".omnibus-discount-value");
|
|
76
|
+
if (r) {
|
|
77
|
+
r.textContent = `{{${i}${t}_${n}_omnibus_discount}}`;
|
|
78
|
+
const s = r.closest("p");
|
|
79
|
+
s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
|
|
67
80
|
}
|
|
68
81
|
break;
|
|
69
82
|
}
|
|
70
83
|
default: {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
|
|
84
|
+
const r = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
|
|
85
|
+
if (r) {
|
|
86
|
+
const s = r.getAttribute("product-attr"), l = r.querySelector("p");
|
|
87
|
+
l && (f(l).textContent = `{{${i}${t}_${n}_${s}}}`);
|
|
75
88
|
}
|
|
76
89
|
break;
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
92
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
function L(t, r, e) {
|
|
89
|
-
return S(t, r, 0, e);
|
|
90
|
-
}
|
|
91
|
-
function N(t, r, e, o) {
|
|
92
|
-
if (!t.innerHTML.includes("{{"))
|
|
93
|
-
return;
|
|
94
|
-
const { open: s, close: i } = S(t.ownerDocument, r, e, o);
|
|
95
|
-
t.insertBefore(s, t.firstChild), t.appendChild(i);
|
|
96
|
-
}
|
|
97
|
-
function T(t, r, e, o) {
|
|
98
|
-
var n, c;
|
|
99
|
-
if (!t.innerHTML.includes("{{"))
|
|
100
|
-
return;
|
|
101
|
-
const { open: s, close: i } = S(t.ownerDocument, r, e, o);
|
|
102
|
-
(n = t.parentNode) == null || n.insertBefore(s, t), (c = t.parentNode) == null || c.insertBefore(i, t.nextSibling);
|
|
103
|
-
}
|
|
104
|
-
function v(t, r, e, o) {
|
|
105
|
-
t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
|
|
106
|
-
i.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
107
|
-
const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
|
|
108
|
-
l.length > 0 ? l.forEach((d) => {
|
|
109
|
-
A(d, u, r, n, e, o);
|
|
110
|
-
}) : A(a, u, r, n, e, o);
|
|
111
|
-
}), T(i, r, n, o);
|
|
93
|
+
function N(e, o, t, n) {
|
|
94
|
+
e.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
|
|
95
|
+
i.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
96
|
+
const u = l.getAttribute("data-attribute-type") || "", p = l.querySelectorAll(".attribute-cell");
|
|
97
|
+
p.length > 0 ? p.forEach((a) => {
|
|
98
|
+
y(a, u, o, r, t, n);
|
|
99
|
+
}) : y(l, u, o, r, t, n);
|
|
100
|
+
});
|
|
112
101
|
});
|
|
113
102
|
}
|
|
114
|
-
function
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
103
|
+
function P(e, o, t, n) {
|
|
104
|
+
const c = e.querySelectorAll(".recommendation-product-row");
|
|
105
|
+
if (!c.length)
|
|
117
106
|
return;
|
|
118
|
-
const [i] =
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
107
|
+
const [i] = c, r = i.querySelector("[data-attribute-type]"), s = r ? r.querySelectorAll(".attribute-cell").length : 1;
|
|
108
|
+
c.forEach((l, u) => {
|
|
109
|
+
l.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
110
|
+
const d = a.getAttribute("data-attribute-type") || "";
|
|
111
|
+
a.querySelectorAll(".attribute-cell").forEach(($, E) => {
|
|
112
|
+
const g = u * s + E;
|
|
113
|
+
y($, d, o, g, t, n);
|
|
125
114
|
});
|
|
126
115
|
});
|
|
127
116
|
});
|
|
128
117
|
}
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
|
|
118
|
+
function B(e, o, t, n) {
|
|
119
|
+
e.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
120
|
+
P(i, o, t, n);
|
|
132
121
|
});
|
|
133
122
|
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
function _(
|
|
143
|
-
const
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
return
|
|
150
|
-
const
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
function
|
|
154
|
-
let
|
|
155
|
-
for (;
|
|
156
|
-
if (
|
|
157
|
-
return
|
|
158
|
-
|
|
123
|
+
function L(e, o, t) {
|
|
124
|
+
const n = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
|
|
125
|
+
n === "list" ? N(e, o, c, t) : B(e, o, c, t);
|
|
126
|
+
}
|
|
127
|
+
function h(e, o, t) {
|
|
128
|
+
const n = new RegExp(`${o}\\s*:\\s*(\\d+)\\s*px`, "i"), c = e.match(n);
|
|
129
|
+
return c ? parseInt(c[1]) : t;
|
|
130
|
+
}
|
|
131
|
+
function _(e) {
|
|
132
|
+
const o = e.trim();
|
|
133
|
+
return o.endsWith("%") ? parseFloat(o) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(o) && parseInt(o) > 0;
|
|
134
|
+
}
|
|
135
|
+
function S(e) {
|
|
136
|
+
const o = e.getAttribute("width");
|
|
137
|
+
if (o && _(o))
|
|
138
|
+
return o.trim();
|
|
139
|
+
const t = (e.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
140
|
+
return t && _(t[1]) ? t[1] : null;
|
|
141
|
+
}
|
|
142
|
+
function D(e, o) {
|
|
143
|
+
let t = e.parentElement;
|
|
144
|
+
for (; t && t !== o; ) {
|
|
145
|
+
if (t.tagName === "TD" && S(t))
|
|
146
|
+
return t;
|
|
147
|
+
t = t.parentElement;
|
|
159
148
|
}
|
|
160
149
|
return null;
|
|
161
150
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
|
|
151
|
+
function W(e) {
|
|
152
|
+
const o = e.getAttribute("style") || "", t = h(o, "width", 600), n = h(o, "padding", 0) * 2, c = Math.max(0, t - n);
|
|
153
|
+
c !== 0 && e.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
165
154
|
if (i.hasAttribute("width"))
|
|
166
155
|
return;
|
|
167
|
-
const
|
|
168
|
-
if (!
|
|
156
|
+
const r = D(i, e);
|
|
157
|
+
if (!r)
|
|
169
158
|
return;
|
|
170
|
-
const
|
|
171
|
-
i.setAttribute("width", String(
|
|
172
|
-
const
|
|
173
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
174
|
-
const
|
|
175
|
-
i.setAttribute("style", `${
|
|
159
|
+
const s = S(r), l = h(r.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), p = Math.max(1, u - l);
|
|
160
|
+
i.setAttribute("width", String(p));
|
|
161
|
+
const a = i.getAttribute("style") || "";
|
|
162
|
+
if (!/\bwidth\s*:\s*\d/i.test(a)) {
|
|
163
|
+
const d = a && !a.trim().endsWith(";") ? "; " : "";
|
|
164
|
+
i.setAttribute("style", `${a}${d}width: ${p}px`);
|
|
176
165
|
}
|
|
177
166
|
});
|
|
178
167
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
168
|
+
const A = "MSO_MOBILE_HIDE_START", v = "MSO_MOBILE_HIDE_END";
|
|
169
|
+
function H(e, o) {
|
|
170
|
+
e.querySelectorAll(O).forEach((t) => {
|
|
171
|
+
var i, r;
|
|
172
|
+
const n = t.querySelector(M);
|
|
173
|
+
if (!n || n.children.length === 0)
|
|
174
|
+
return;
|
|
175
|
+
const c = t.previousSibling;
|
|
176
|
+
(c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data === A || ((i = t.parentNode) == null || i.insertBefore(o.createComment(A), t), (r = t.parentNode) == null || r.insertBefore(o.createComment(v), t.nextSibling));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function F(e, o) {
|
|
180
|
+
const t = e.match(/<!DOCTYPE[^>]*>/i);
|
|
181
|
+
return (t ? `${t[0]}
|
|
182
|
+
` : "") + o.documentElement.outerHTML;
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
const
|
|
186
|
-
if (!
|
|
187
|
-
return
|
|
188
|
-
const { buildCampaignUrl:
|
|
184
|
+
function j(e) {
|
|
185
|
+
const o = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), t = new DOMParser().parseFromString(o, "text/html"), n = t.querySelectorAll(".recommendation-block-v2");
|
|
186
|
+
if (!n.length)
|
|
187
|
+
return e;
|
|
188
|
+
const { buildCampaignUrl: c } = q(), i = w();
|
|
189
189
|
i.recommendationCampaignUrls = {};
|
|
190
|
-
const { isFeatureEnabled:
|
|
191
|
-
return
|
|
192
|
-
var
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
D(u, l, c);
|
|
197
|
-
const { open: f, close: h } = L(e, l, c);
|
|
198
|
-
(b = u.parentNode) == null || b.insertBefore(f, u), (m = u.parentNode) == null || m.insertBefore(h, u.nextSibling);
|
|
199
|
-
}
|
|
200
|
-
G(u);
|
|
201
|
-
}
|
|
202
|
-
}), H(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
190
|
+
const { isFeatureEnabled: r } = C(), s = r("liquidSyntax") ? "reco_" : "";
|
|
191
|
+
return n.forEach((u) => {
|
|
192
|
+
var a, d;
|
|
193
|
+
const p = u.getAttribute("recommendation-id");
|
|
194
|
+
p && ((a = u.parentNode) == null || a.insertBefore(t.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(t.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((b) => b.remove()), c(p), H(u, t), R(u) || L(u, p, s), W(u));
|
|
195
|
+
}), F(o, t).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
203
196
|
}
|
|
204
197
|
export {
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
m as formatPriceVariable,
|
|
199
|
+
j as prepareRecommendationBlocks
|
|
207
200
|
};
|
package/dist/enums/defaults.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
transactional: 2
|
|
3
|
-
},
|
|
3
|
+
}, o = 2, t = 13, s = {
|
|
4
4
|
SAVED_MODULES: "savedModules",
|
|
5
5
|
DEFAULT_MODULES: "defaultModules"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
s as EditorType,
|
|
12
|
-
a as MAX_DEFAULT_TEMPLATE_ID,
|
|
13
|
-
E as ModuleFolderDefaults,
|
|
8
|
+
o as EditorType,
|
|
9
|
+
t as MAX_DEFAULT_TEMPLATE_ID,
|
|
10
|
+
s as ModuleFolderDefaults,
|
|
14
11
|
e as TemplateTypes
|
|
15
12
|
};
|