@useinsider/guido 3.21.2-beta.4b0fed7 → 3.21.2-beta.5a809f7
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/useSave.js +75 -68
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
- package/dist/config/migrator/recommendation/extractors.js +36 -27
- package/dist/config/migrator/recommendation/htmlBuilder.js +99 -105
- package/dist/config/migrator/recommendation/settingsMapper.js +13 -15
- package/dist/config/migrator/recommendationMigrator.js +62 -59
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +20 -19
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +101 -100
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
- package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +2 -0
- package/dist/services/templateLibraryApi.js +36 -31
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
- package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -20
- package/dist/src/utils/templatePreparation.d.ts +2 -1
- package/dist/utils/pairProductVariables.js +98 -90
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
|
@@ -1,84 +1,91 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { useSaveStart as
|
|
5
|
-
import { useSaveValidation as
|
|
6
|
-
import { useSaveValidationRollout as
|
|
7
|
-
import { useSyncModuleExtractor as
|
|
8
|
-
import { ToasterTypeOptions as
|
|
9
|
-
import { useStripoApi as
|
|
10
|
-
import { useConfigStore as
|
|
11
|
-
import { useDynamicContentStore as
|
|
12
|
-
import { useSaveValidationStore as
|
|
13
|
-
import { useTemplatePreparation as
|
|
14
|
-
import { useAllowlist as
|
|
15
|
-
import { useHtmlValidator as
|
|
16
|
-
import { useToaster as
|
|
17
|
-
import { useCouponBlockValidator as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { useActionsApi as q } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as O } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as D } from "./useEditorLock.js";
|
|
4
|
+
import { useSaveStart as F, useSaveComplete as j } from "./useGuidoActions.js";
|
|
5
|
+
import { useSaveValidation as z } from "./useSaveValidation.js";
|
|
6
|
+
import { useSaveValidationRollout as G } from "./useSaveValidationRollout.js";
|
|
7
|
+
import { useSyncModuleExtractor as I } from "./useSyncModuleExtractor.js";
|
|
8
|
+
import { ToasterTypeOptions as J } from "../enums/toaster.js";
|
|
9
|
+
import { useStripoApi as K } from "../services/stripoApi.js";
|
|
10
|
+
import { useConfigStore as N } from "../stores/config.js";
|
|
11
|
+
import { useDynamicContentStore as Q } from "../stores/dynamic-content.js";
|
|
12
|
+
import { useSaveValidationStore as X } from "../stores/save-validation.js";
|
|
13
|
+
import { useTemplatePreparation as Y, getHtmlReferencedUnsubscribePages as Z } from "../utils/templatePreparation.js";
|
|
14
|
+
import { useAllowlist as _ } from "./useAllowlist.js";
|
|
15
|
+
import { useHtmlValidator as $ } from "./useHtmlValidator.js";
|
|
16
|
+
import { useToaster as tt } from "./useToaster.js";
|
|
17
|
+
import { useCouponBlockValidator as et } from "./validators/useCouponBlockValidator.js";
|
|
18
|
+
import { useHtmlDocumentCountValidator as ot } from "./validators/useHtmlDocumentCountValidator.js";
|
|
19
|
+
import { useLiquidValidator as it } from "./validators/useLiquidValidator.js";
|
|
20
|
+
import { useSyncModuleBlockValidator as st } from "./validators/useSyncModuleBlockValidator.js";
|
|
21
|
+
import { useUnsubscribeBlockValidator as at } from "./validators/useUnsubscribeBlockValidator.js";
|
|
22
|
+
const Pt = () => {
|
|
23
|
+
const n = F(), w = j(), { validateHtml: y } = $(), { validateLiquidSyntax: E } = it(), { validateCouponBlockTags: b } = et(), { validateUnsubscribeBlockUniqueness: g, validateUnsubscribeBlockHasTemplate: H } = at(), { validateSyncModuleBlocks: l } = st(), { validateSingleHtmlDocument: c } = ot(), { callbacks: r, isFeatureEnabled: v } = O(), { extractSyncModuleData: V } = I(), { setSyncModuleUnsubscriptionPages: x } = K(), { editorSave: C, getTemplateData: u } = q(), { showToaster: k } = tt(), { getBlockedDomains: h, resolveToast: B } = _(), { prepareTemplateDetails: p } = Y(), { collectSaveValidationErrors: T } = z(), { isEnabled: P } = G(), L = X(), U = Q(), S = N(), { runExclusive: m } = D(), d = async (t, e, i) => {
|
|
24
|
+
if (!v("allowlistEnabled"))
|
|
24
25
|
return !1;
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
26
|
+
const o = await h(t, e);
|
|
27
|
+
if (!o.length)
|
|
27
28
|
return !1;
|
|
28
|
-
if (!
|
|
29
|
-
const s = await
|
|
30
|
-
s != null && s.message &&
|
|
31
|
-
type:
|
|
29
|
+
if (!i) {
|
|
30
|
+
const s = await B(o);
|
|
31
|
+
s != null && s.message && k({
|
|
32
|
+
type: J.Warning,
|
|
32
33
|
message: s.message,
|
|
33
34
|
actionButton: s.actionButton
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
return !0;
|
|
37
|
-
},
|
|
38
|
-
if (!await
|
|
38
|
+
}, A = async (t) => !b(t.compiledHtml) || !g(t.compiledHtml) || !H(t.compiledHtml) ? !1 : v("liquidSyntax") ? E(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), f = async (t, e) => {
|
|
39
|
+
if (!await C())
|
|
39
40
|
return;
|
|
40
|
-
const { unsubscribePayload:
|
|
41
|
-
if (await
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
const { unsubscribePayload: o, stripoModules: s } = V(t.rawHtml);
|
|
42
|
+
if (await x(o), t.modules = s, !e.suppress) {
|
|
43
|
+
const a = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
|
|
44
|
+
w({ ...t, ...a, silent: e.silent });
|
|
44
45
|
}
|
|
45
46
|
return t;
|
|
46
|
-
},
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
}, M = async (t, e) => {
|
|
48
|
+
var s;
|
|
49
|
+
n();
|
|
50
|
+
const i = await u();
|
|
51
|
+
if (!c(i.html, e))
|
|
52
|
+
return;
|
|
53
|
+
const o = await p(i);
|
|
54
|
+
if (l(o.rawHtml, e)) {
|
|
55
|
+
if (P.value && !e) {
|
|
56
|
+
const a = await T(
|
|
53
57
|
o.compiledHtml,
|
|
54
58
|
o.dynamicContentList
|
|
55
59
|
);
|
|
56
|
-
if (
|
|
57
|
-
|
|
60
|
+
if (a.length) {
|
|
61
|
+
L.open(a, "save");
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
|
-
} else if (!await
|
|
64
|
+
} else if (!await A(o))
|
|
61
65
|
return;
|
|
62
|
-
if (!((
|
|
63
|
-
return
|
|
66
|
+
if (!((s = r.value) != null && s.externalValidation && !await r.value.externalValidation(o)) && !await d(o.compiledHtml, o.css, e))
|
|
67
|
+
return f(o, { silent: e, suppress: t });
|
|
64
68
|
}
|
|
65
|
-
},
|
|
66
|
-
var
|
|
67
|
-
if (!
|
|
69
|
+
}, W = async () => {
|
|
70
|
+
var i;
|
|
71
|
+
if (!S.allowSaveWithErrors)
|
|
72
|
+
return;
|
|
73
|
+
n();
|
|
74
|
+
const t = await u();
|
|
75
|
+
if (!c(t.html, !1))
|
|
68
76
|
return;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!f.allowSaveWithErrors)
|
|
77
|
+
const e = await p(t);
|
|
78
|
+
if (l(e.rawHtml, !1) && !((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(e)) && !await d(e.compiledHtml, e.css, !1))
|
|
79
|
+
return f(e, { silent: !1, blankCompiled: !0 });
|
|
80
|
+
}, R = async () => {
|
|
81
|
+
if (!S.allowSaveWithErrors)
|
|
75
82
|
return;
|
|
76
|
-
|
|
77
|
-
const { html: t, css: e } = await
|
|
78
|
-
if (!
|
|
83
|
+
n();
|
|
84
|
+
const { html: t, css: e } = await u();
|
|
85
|
+
if (!c(t, !0) || !l(t, !0) || await d(t, e, !0))
|
|
79
86
|
return;
|
|
80
|
-
const
|
|
81
|
-
dynamicContentList:
|
|
87
|
+
const i = Z(t), o = {
|
|
88
|
+
dynamicContentList: U.getSelectedDynamicContentList,
|
|
82
89
|
compiledHtml: "",
|
|
83
90
|
rawHtml: t,
|
|
84
91
|
css: e,
|
|
@@ -88,16 +95,16 @@ const Bt = () => {
|
|
|
88
95
|
// No campaignUrls: hosts overwrite their stored map with any object, and raw HTML can't rebuild it.
|
|
89
96
|
recommendation: { configs: {} },
|
|
90
97
|
unsubscribe: {
|
|
91
|
-
status:
|
|
92
|
-
config:
|
|
98
|
+
status: i.length > 0,
|
|
99
|
+
config: i
|
|
93
100
|
}
|
|
94
101
|
};
|
|
95
|
-
return
|
|
102
|
+
return f(o, { silent: !0 });
|
|
96
103
|
};
|
|
97
|
-
return { save: (t = !1, e = !1) =>
|
|
98
|
-
() =>
|
|
99
|
-
), saveWithErrors: () =>
|
|
104
|
+
return { save: (t = !1, e = !1) => m(
|
|
105
|
+
() => M(t, e)
|
|
106
|
+
), saveWithErrors: () => m(W), saveRawOnly: () => m(R) };
|
|
100
107
|
};
|
|
101
108
|
export {
|
|
102
|
-
|
|
109
|
+
Pt as useSave
|
|
103
110
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useToaster as i } from "../useToaster.js";
|
|
2
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
3
|
+
import { ToasterTypeOptions as c } from "../../enums/toaster.js";
|
|
4
|
+
const u = "newsletter.multiple-html-designs-detected", r = `(?:[^>"']|"[^"]*"|'[^']*')*`, a = "style|script|noscript|xmp|iframe|noembed|noframes|textarea|title", T = /<html(?=[\s>/])/gi, A = new RegExp(
|
|
5
|
+
`<!--[\\s\\S]*?-->|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|<(${a})(?=[\\s/>])${r}>[\\s\\S]*?</\\1\\s*>|<([a-zA-Z][\\w:-]*)${r}>`,
|
|
6
|
+
"gi"
|
|
7
|
+
), p = (e) => Array.from(e.matchAll(A)).filter(([, , t]) => (t == null ? void 0 : t.toLowerCase()) === "html").length, g = () => {
|
|
8
|
+
const { showToaster: e } = i(), t = m();
|
|
9
|
+
return { validateSingleHtmlDocument: (o, l = !1) => {
|
|
10
|
+
var n;
|
|
11
|
+
if ((((n = o.match(T)) == null ? void 0 : n.length) ?? 0) < 2)
|
|
12
|
+
return !0;
|
|
13
|
+
const s = p(o);
|
|
14
|
+
return s <= 1 ? !0 : (console.debug("guido:save:blocked", { reason: "multiple-html-documents", htmlRootCount: s }), l || e({
|
|
15
|
+
type: c.Warning,
|
|
16
|
+
message: t(u)
|
|
17
|
+
}), !1);
|
|
18
|
+
} };
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
g as useHtmlDocumentCountValidator
|
|
22
|
+
};
|
|
@@ -1,54 +1,62 @@
|
|
|
1
|
-
import { CURRENCY_ATTR as c, CSS_CLASS_SKIP_COMPILE as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { CURRENCY_ATTR as c, CSS_CLASS_SKIP_COMPILE as p } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
const a = "You May Also Like!";
|
|
3
|
+
function C(t) {
|
|
4
4
|
var o;
|
|
5
5
|
const e = t.querySelector(".ext-recommendation-title");
|
|
6
6
|
if (!e)
|
|
7
|
-
return
|
|
7
|
+
return a;
|
|
8
8
|
const r = (o = e.textContent) == null ? void 0 : o.trim();
|
|
9
|
-
return r && r.length > 0 ? r :
|
|
9
|
+
return r && r.length > 0 ? r : a;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function S(t) {
|
|
12
12
|
const e = t.querySelector(".ext-recommendation-title");
|
|
13
13
|
return e ? !/display\s*:\s*none/i.test(e.getAttribute("style") ?? "") : !1;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function g(t) {
|
|
16
16
|
var r;
|
|
17
17
|
const e = t.querySelector(".ext-recommendation-title");
|
|
18
18
|
return !!e && !((r = e == null ? void 0 : e.textContent) != null && r.trim());
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function T(t) {
|
|
21
21
|
const e = t.querySelector(".ext-product-price"), r = t.querySelector(".ext-product-original-price");
|
|
22
22
|
return !e || !r ? !1 : e.compareDocumentPosition(r) === Node.DOCUMENT_POSITION_PRECEDING;
|
|
23
23
|
}
|
|
24
|
+
function m(t) {
|
|
25
|
+
return /(?:^|;)\s*display\s*:\s*table-cell/i.test(t.getAttribute("style") ?? "");
|
|
26
|
+
}
|
|
27
|
+
function y(t) {
|
|
28
|
+
var o, n;
|
|
29
|
+
const e = (o = t.querySelector(".ext-product-price")) == null ? void 0 : o.closest("tr"), r = (n = t.querySelector(".ext-product-original-price")) == null ? void 0 : n.closest("tr");
|
|
30
|
+
return !e || !r || e === r ? !1 : !m(e) && !m(r);
|
|
31
|
+
}
|
|
24
32
|
const d = /* @__PURE__ */ new Map([
|
|
25
33
|
["p_name", ".ext-product-name p"],
|
|
26
34
|
["p_price", ".ext-product-price p"],
|
|
27
35
|
["p_original_price", ".ext-product-original-price p"]
|
|
28
36
|
]);
|
|
29
|
-
function
|
|
37
|
+
function A(t) {
|
|
30
38
|
const e = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(/(?:^|;)\s*color\s*:\s*([^;]+)/i);
|
|
31
39
|
return (e == null ? void 0 : e[1].trim()) || void 0;
|
|
32
40
|
}
|
|
33
|
-
const
|
|
34
|
-
function
|
|
41
|
+
const f = "ins-trim-text";
|
|
42
|
+
function E(t, e) {
|
|
35
43
|
return t == null ? void 0 : t.map((r) => {
|
|
36
|
-
var
|
|
44
|
+
var u, l;
|
|
37
45
|
const o = d.get(r.variable ?? "");
|
|
38
46
|
if (!o)
|
|
39
47
|
return r;
|
|
40
|
-
const n = e.querySelector(o),
|
|
41
|
-
return !
|
|
48
|
+
const n = e.querySelector(o), s = (l = (u = r.theme) == null ? void 0 : u.textColor) != null && l.color ? void 0 : A(n), i = r.variable === "p_name" && (n == null ? void 0 : n.classList.contains(f));
|
|
49
|
+
return !s && !i ? r : {
|
|
42
50
|
...r,
|
|
43
51
|
theme: {
|
|
44
52
|
...r.theme,
|
|
45
|
-
...
|
|
53
|
+
...s ? { textColor: { color: s } } : {},
|
|
46
54
|
...i ? { textTrimming: !0 } : {}
|
|
47
55
|
}
|
|
48
56
|
};
|
|
49
57
|
});
|
|
50
58
|
}
|
|
51
|
-
function
|
|
59
|
+
function _(t) {
|
|
52
60
|
const e = [
|
|
53
61
|
t,
|
|
54
62
|
...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
@@ -62,7 +70,7 @@ function E(t) {
|
|
|
62
70
|
return i && i[1] ? (r = i[1].trim(), !0) : !1;
|
|
63
71
|
}), r;
|
|
64
72
|
}
|
|
65
|
-
function
|
|
73
|
+
function R(t) {
|
|
66
74
|
const e = t.getAttribute(c.CURRENCY);
|
|
67
75
|
if (!e)
|
|
68
76
|
return;
|
|
@@ -78,16 +86,17 @@ function _(t) {
|
|
|
78
86
|
thousandSeparator: t.getAttribute(c.THOUSAND_SEPARATOR) ?? ""
|
|
79
87
|
};
|
|
80
88
|
}
|
|
81
|
-
function
|
|
82
|
-
return t.classList.contains(
|
|
89
|
+
function L(t) {
|
|
90
|
+
return t.classList.contains(p);
|
|
83
91
|
}
|
|
84
92
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
_ as extractCardBgColor,
|
|
94
|
+
R as extractCurrencyFromBlock,
|
|
95
|
+
C as extractTitleText,
|
|
96
|
+
g as hasEmptyTitle,
|
|
97
|
+
S as hasVisibleTitle,
|
|
98
|
+
T as isOldPriceFirst,
|
|
99
|
+
L as isPartnerManagedBlock,
|
|
100
|
+
y as isPriceOnNextLine,
|
|
101
|
+
E as withRenderedTextTheme
|
|
93
102
|
};
|