@useinsider/guido 3.6.0-beta.590990f → 3.6.0-beta.6807430
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/useActionsApi.js +16 -15
- package/dist/composables/useHtmlCompiler.js +40 -22
- package/dist/composables/useRecommendation.js +34 -33
- package/dist/composables/useSave.js +16 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -9
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +21 -0
- package/dist/src/composables/useHtmlCompiler.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerCustomizations.d.ts +7 -0
- package/dist/src/utils/ampErrorFilter.d.ts +2 -0
- package/dist/utils/ampErrorFilter.js +8 -0
- package/dist/utils/templatePreparation.js +53 -53
- package/package.json +1 -1
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +0 -24
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -3
- /package/dist/src/{composables/validators/useUnsubscribeBlockValidator.test.d.ts → utils/ampErrorFilter.test.d.ts} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { filterAmpErrors as w } from "../utils/ampErrorFilter.js";
|
|
2
|
+
import { useToaster as A } from "./useToaster.js";
|
|
3
|
+
const D = () => {
|
|
4
|
+
const { handleError: n } = A(), s = (t = {}) => new Promise((e, a) => {
|
|
4
5
|
const o = { ...{
|
|
5
6
|
minimize: !0,
|
|
6
7
|
utmEntity: {
|
|
@@ -20,29 +21,29 @@ const v = () => {
|
|
|
20
21
|
forceAmp: !1,
|
|
21
22
|
resetDataSavedFlag: !1,
|
|
22
23
|
disableLineHeightsReplace: !0
|
|
23
|
-
}, ...t },
|
|
24
|
-
callback: (
|
|
25
|
-
|
|
24
|
+
}, ...t }, l = {
|
|
25
|
+
callback: (r, p, d, c, u) => {
|
|
26
|
+
r ? a(r) : e({
|
|
26
27
|
html: p,
|
|
27
28
|
ampHtml: d,
|
|
28
|
-
ampErrors: c,
|
|
29
|
+
ampErrors: w(c ?? []),
|
|
29
30
|
displayConditions: u
|
|
30
31
|
});
|
|
31
32
|
},
|
|
32
33
|
...o
|
|
33
34
|
};
|
|
34
|
-
window.StripoEditorApi.actionsApi.compileEmail(
|
|
35
|
+
window.StripoEditorApi.actionsApi.compileEmail(l);
|
|
35
36
|
});
|
|
36
37
|
return {
|
|
37
|
-
getCompiledEmail:
|
|
38
|
+
getCompiledEmail: s,
|
|
38
39
|
getTemplateData: () => new Promise((t) => {
|
|
39
|
-
const e = ({ html: a, css: i, width: o, height:
|
|
40
|
+
const e = ({ html: a, css: i, width: o, height: m, utmParams: l, syncModulesIds: r }) => t({
|
|
40
41
|
html: a,
|
|
41
42
|
css: i,
|
|
42
43
|
width: o,
|
|
43
|
-
height:
|
|
44
|
-
utmParams:
|
|
45
|
-
syncModulesIds:
|
|
44
|
+
height: m,
|
|
45
|
+
utmParams: l,
|
|
46
|
+
syncModulesIds: r
|
|
46
47
|
});
|
|
47
48
|
window.StripoEditorApi.actionsApi.getTemplateData(e);
|
|
48
49
|
}),
|
|
@@ -56,7 +57,7 @@ const v = () => {
|
|
|
56
57
|
displayConditions: a,
|
|
57
58
|
ampHtml: i = "",
|
|
58
59
|
ampErrors: o = []
|
|
59
|
-
} = await
|
|
60
|
+
} = await s({ minimize: !1, resetDataSavedFlag: !1, ...t });
|
|
60
61
|
return {
|
|
61
62
|
html: e,
|
|
62
63
|
ampHtml: i,
|
|
@@ -101,5 +102,5 @@ const v = () => {
|
|
|
101
102
|
};
|
|
102
103
|
};
|
|
103
104
|
export {
|
|
104
|
-
|
|
105
|
+
D as useActionsApi
|
|
105
106
|
};
|
|
@@ -1,30 +1,48 @@
|
|
|
1
|
-
import { defaultHtmlCompilerRules as
|
|
2
|
-
import { itemsCompilerRules as
|
|
3
|
-
import { liquidCompilerRules as
|
|
4
|
-
import { outlookCompilerRules as
|
|
5
|
-
import { recommendationCompilerRules as
|
|
6
|
-
import { socialCompilerRules as
|
|
7
|
-
import { unsubscribeCompilerRules as
|
|
8
|
-
import { createHtmlCompiler as
|
|
9
|
-
import { useConfig as
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { defaultHtmlCompilerRules as R } from "../config/compiler/htmlCompilerRules.js";
|
|
2
|
+
import { itemsCompilerRules as g } from "../config/compiler/itemsCompilerRules.js";
|
|
3
|
+
import { liquidCompilerRules as C } from "../config/compiler/liquidCompilerRules.js";
|
|
4
|
+
import { outlookCompilerRules as b } from "../config/compiler/outlookCompilerRules.js";
|
|
5
|
+
import { recommendationCompilerRules as v } from "../config/compiler/recommendationCompilerRules.js";
|
|
6
|
+
import { socialCompilerRules as H } from "../config/compiler/socialCompilerRules.js";
|
|
7
|
+
import { unsubscribeCompilerRules as x } from "../config/compiler/unsubscribeCompilerRules.js";
|
|
8
|
+
import { createHtmlCompiler as s } from "../utils/htmlCompiler.js";
|
|
9
|
+
import { useConfig as k } from "./useConfig.js";
|
|
10
|
+
const y = /* @__PURE__ */ new Set([
|
|
11
|
+
// URL/tag encoding fixes — keep merge-tag and placeholder integrity intact.
|
|
12
|
+
"fix-url-encoding-start",
|
|
13
|
+
"fix-url-encoding-end",
|
|
14
|
+
"fix-tags-start",
|
|
15
|
+
"fix-tags-end",
|
|
16
|
+
// Image domain corrections — plain string replacement.
|
|
17
|
+
"replace-old-image-domain",
|
|
18
|
+
"replace-old-v2-image-domain",
|
|
19
|
+
// Unsubscribe domain — the actual fix: injects the real unsubscribe href in
|
|
20
|
+
// place of the `{{ins-*-unsubscribe-link}}` placeholders, plus related
|
|
21
|
+
// unsubscribe-only cleanups. All pure regex/text, no AMP-forbidden output.
|
|
22
|
+
"add-unsubscribe-link-values",
|
|
23
|
+
"remove-data-ogsb-button-styles",
|
|
24
|
+
"format-comment-braces",
|
|
25
|
+
"add-universal-link-flags",
|
|
26
|
+
// Coupon placeholder replacement (only present when liquidSyntax is enabled).
|
|
27
|
+
"liquid-coupon-code"
|
|
28
|
+
]), M = () => {
|
|
29
|
+
var m, t, r;
|
|
30
|
+
const { compiler: e, isFeatureEnabled: a, partner: n } = k(), u = ((m = e.value) == null ? void 0 : m.customRules) || [], l = [
|
|
31
|
+
...!!((t = e.value) != null && t.ignoreDefaultRules) ? [] : R,
|
|
32
|
+
...v,
|
|
33
|
+
...x,
|
|
15
34
|
...g,
|
|
16
|
-
...f,
|
|
17
|
-
...C,
|
|
18
35
|
...b,
|
|
19
|
-
...
|
|
20
|
-
...
|
|
36
|
+
...H,
|
|
37
|
+
...a("liquidSyntax") ? C : [],
|
|
38
|
+
...u.map((o, f) => ({
|
|
21
39
|
...o,
|
|
22
|
-
priority: o.priority + 1e3 +
|
|
40
|
+
priority: o.priority + 1e3 + f
|
|
23
41
|
// Ensure additional rules run after default rules
|
|
24
42
|
}))
|
|
25
|
-
], p =
|
|
26
|
-
return { compileHtml: (o) => p.compile(o, void 0,
|
|
43
|
+
], p = s(l), c = l.filter((o) => y.has(o.id)), d = s(c), i = (r = n.value) == null ? void 0 : r.fallbackFont;
|
|
44
|
+
return { compileHtml: (o) => p.compile(o, void 0, i), compileAmpHtml: (o) => d.compile(o, void 0, i) };
|
|
27
45
|
};
|
|
28
46
|
export {
|
|
29
|
-
|
|
47
|
+
M as useHtmlCompiler
|
|
30
48
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as I, URLS as
|
|
2
|
-
import { MinDeviceViewport as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
1
|
+
import { getRecommendationFeedSourceMaps as I, URLS as R } from "../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
4
|
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
|
+
import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
5
6
|
import { useConfigStore as x } from "../stores/config.js";
|
|
6
|
-
const
|
|
7
|
+
const k = () => ({
|
|
7
8
|
calculateCardWidth: ({
|
|
8
|
-
mobileLeftPadding:
|
|
9
|
+
mobileLeftPadding: a,
|
|
9
10
|
mobileRightPadding: s,
|
|
10
|
-
cardsInRow:
|
|
11
|
-
unresponsive:
|
|
11
|
+
cardsInRow: c,
|
|
12
|
+
unresponsive: o
|
|
12
13
|
}) => {
|
|
13
|
-
const r =
|
|
14
|
-
return (
|
|
14
|
+
const r = o ? c : 1, e = a + s + (r - 1) * b;
|
|
15
|
+
return (C - e) / r;
|
|
15
16
|
},
|
|
16
|
-
getRecommendationCampaignData: (
|
|
17
|
-
const s =
|
|
18
|
-
if (!
|
|
17
|
+
getRecommendationCampaignData: (a) => {
|
|
18
|
+
const s = l(), c = Number(a), o = s.blockStates[c];
|
|
19
|
+
if (!o)
|
|
19
20
|
return {
|
|
20
21
|
textTrimming: !1,
|
|
21
22
|
orientation: "vertical",
|
|
@@ -28,7 +29,7 @@ const w = () => ({
|
|
|
28
29
|
discountBeforeTextValue: "",
|
|
29
30
|
discountAfterTextValue: ""
|
|
30
31
|
};
|
|
31
|
-
const { recommendationConfigs: r } =
|
|
32
|
+
const { recommendationConfigs: r } = o, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
32
33
|
return {
|
|
33
34
|
textTrimming: r.textTrimming,
|
|
34
35
|
orientation: e,
|
|
@@ -42,35 +43,35 @@ const w = () => ({
|
|
|
42
43
|
discountAfterTextValue: ""
|
|
43
44
|
};
|
|
44
45
|
},
|
|
45
|
-
buildCampaignUrl: (
|
|
46
|
-
var
|
|
47
|
-
const
|
|
46
|
+
buildCampaignUrl: (a, s) => {
|
|
47
|
+
var m;
|
|
48
|
+
const c = l(), o = x(), r = Number(a);
|
|
48
49
|
let e;
|
|
49
50
|
if (s)
|
|
50
51
|
e = s;
|
|
51
52
|
else {
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
53
|
+
const i = c.blockStates[r];
|
|
54
|
+
if (!i)
|
|
54
55
|
return "";
|
|
55
|
-
const { recommendationConfigs:
|
|
56
|
+
const { recommendationConfigs: n } = i;
|
|
56
57
|
e = {
|
|
57
|
-
strategy:
|
|
58
|
-
language:
|
|
59
|
-
currencyCode:
|
|
60
|
-
size:
|
|
61
|
-
productIds:
|
|
62
|
-
filters:
|
|
63
|
-
shuffleProducts:
|
|
58
|
+
strategy: n.strategy,
|
|
59
|
+
language: n.language,
|
|
60
|
+
currencyCode: n.currencySettings.value,
|
|
61
|
+
size: n.size,
|
|
62
|
+
productIds: n.productIds,
|
|
63
|
+
filters: n.filters,
|
|
64
|
+
shuffleProducts: n.shuffleProducts
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
const f = ((
|
|
67
|
-
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName",
|
|
68
|
-
const g = e.filters.filter((
|
|
69
|
-
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
|
|
70
|
-
const p = decodeURIComponent(t.toString()), u = `${
|
|
71
|
-
return
|
|
67
|
+
const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
68
|
+
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
69
|
+
const g = e.filters.filter((i) => i.isValid), d = h(g);
|
|
70
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(o.partnerName, e.strategy)).forEach(([i, n]) => t.set(i, n));
|
|
71
|
+
const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
72
|
+
return c.recommendationCampaignUrls[a] = u, u;
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
export {
|
|
75
|
-
|
|
76
|
+
k as useRecommendation
|
|
76
77
|
};
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
import { useActionsApi as x } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as y } from "./useConfig.js";
|
|
3
|
-
import { useSaveStart as w, useSaveComplete as
|
|
4
|
-
import { useSyncModuleExtractor as
|
|
5
|
-
import { useStripoApi as
|
|
6
|
-
import { useTemplatePreparation as
|
|
7
|
-
import { useHtmlValidator as
|
|
3
|
+
import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
|
|
4
|
+
import { useSyncModuleExtractor as E } from "./useSyncModuleExtractor.js";
|
|
5
|
+
import { useStripoApi as H } from "../services/stripoApi.js";
|
|
6
|
+
import { useTemplatePreparation as b } from "../utils/templatePreparation.js";
|
|
7
|
+
import { useHtmlValidator as q } from "./useHtmlValidator.js";
|
|
8
8
|
import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
|
|
9
9
|
import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var a;
|
|
10
|
+
const z = () => {
|
|
11
|
+
const o = w(), s = C(), { validateHtml: r } = q(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = E(), { setSyncModuleUnsubscriptionPages: c } = H(), { editorSave: m } = x();
|
|
12
|
+
return { save: async (p = !1, f = !1) => {
|
|
13
|
+
var i;
|
|
15
14
|
o();
|
|
16
|
-
const { prepareTemplateDetails:
|
|
17
|
-
if (!l(t.compiledHtml)
|
|
15
|
+
const { prepareTemplateDetails: v } = b(), t = await v();
|
|
16
|
+
if (!l(t.compiledHtml))
|
|
18
17
|
return;
|
|
19
|
-
if (
|
|
18
|
+
if (d("liquidSyntax")) {
|
|
20
19
|
if (!await n(t.compiledHtml))
|
|
21
20
|
return;
|
|
22
21
|
} else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
|
|
23
22
|
return;
|
|
24
|
-
if ((
|
|
23
|
+
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t) || !await m())
|
|
25
24
|
return;
|
|
26
|
-
const { unsubscribePayload:
|
|
27
|
-
return await
|
|
25
|
+
const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
|
|
26
|
+
return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
|
|
28
27
|
} };
|
|
29
28
|
};
|
|
30
29
|
export {
|
|
31
|
-
|
|
30
|
+
z as useSave
|
|
32
31
|
};
|
|
@@ -6,8 +6,9 @@ import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
|
|
|
6
6
|
import { EXCLUDED_ALGORITHM_IDS as D } from "../constants/defaultConfig.js";
|
|
7
7
|
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
8
8
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
|
|
10
|
+
import { isFilterValid as w } from "../validation/filterSchema.js";
|
|
11
|
+
import { isConfigValid as N } from "../validation/requiredFields.js";
|
|
11
12
|
const h = y();
|
|
12
13
|
let m = null, u = null, d = null;
|
|
13
14
|
function I() {
|
|
@@ -49,7 +50,7 @@ function k() {
|
|
|
49
50
|
filterSnapshot: null
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
+
const x = () => ({
|
|
53
54
|
recommendationCampaignUrls: {},
|
|
54
55
|
activePredictiveAlgorithms: [],
|
|
55
56
|
languages: {},
|
|
@@ -58,8 +59,8 @@ const N = () => ({
|
|
|
58
59
|
blockStates: {},
|
|
59
60
|
currentRecommendationId: null,
|
|
60
61
|
configVersion: 0
|
|
61
|
-
}),
|
|
62
|
-
state: () =>
|
|
62
|
+
}), T = P("guidoRecommendationExtension", {
|
|
63
|
+
state: () => x(),
|
|
63
64
|
getters: {
|
|
64
65
|
// ====================================================================
|
|
65
66
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -378,7 +379,7 @@ const N = () => ({
|
|
|
378
379
|
const n = [...e.recommendationConfigs.filters];
|
|
379
380
|
n[r] = {
|
|
380
381
|
...t,
|
|
381
|
-
isValid:
|
|
382
|
+
isValid: w(t)
|
|
382
383
|
}, e.recommendationConfigs.filters = n;
|
|
383
384
|
}
|
|
384
385
|
},
|
|
@@ -424,7 +425,7 @@ const N = () => ({
|
|
|
424
425
|
* every block's recommendationConfigs across user edits.
|
|
425
426
|
*/
|
|
426
427
|
hasInvalidBlock() {
|
|
427
|
-
return Object.values(this.blockStates).some((t) => !
|
|
428
|
+
return Object.values(this.blockStates).some((t) => !N(t.recommendationConfigs, this));
|
|
428
429
|
},
|
|
429
430
|
// ====================================================================
|
|
430
431
|
// Per-Block Product Fetching
|
|
@@ -453,7 +454,10 @@ const N = () => ({
|
|
|
453
454
|
details: !0,
|
|
454
455
|
campaignId: o.variationId
|
|
455
456
|
};
|
|
456
|
-
r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0)
|
|
457
|
+
r.strategy === "manualMerchandising" ? a.productId = r.productIds.join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
|
|
458
|
+
a,
|
|
459
|
+
v(o.partnerName, r.strategy)
|
|
460
|
+
);
|
|
457
461
|
let f;
|
|
458
462
|
try {
|
|
459
463
|
f = await h.fetchRecommendationProducts(i, a);
|
|
@@ -471,5 +475,5 @@ const N = () => ({
|
|
|
471
475
|
}
|
|
472
476
|
});
|
|
473
477
|
export {
|
|
474
|
-
|
|
478
|
+
T as useRecommendationExtensionStore
|
|
475
479
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const i = [
|
|
2
|
+
"ozonebg",
|
|
3
|
+
"ozonehr",
|
|
4
|
+
"ozonero",
|
|
5
|
+
"ozoneinfo",
|
|
6
|
+
"babybg",
|
|
7
|
+
"ozongr",
|
|
8
|
+
"iboodat",
|
|
9
|
+
"iboodbe",
|
|
10
|
+
"iboodde",
|
|
11
|
+
"iboodfr",
|
|
12
|
+
"iboodnl",
|
|
13
|
+
"iboodpl"
|
|
14
|
+
], r = ["interencheres", "interencherespreprod"], d = ["lodenfrey", "lodenfreyuat"], c = "manualMerchandising";
|
|
15
|
+
function s(e, n) {
|
|
16
|
+
const o = {};
|
|
17
|
+
return i.includes(e) && (o.excludePurchaseDay = "30", o.userId = "{user_id}"), r.includes(e) && (o.hp = "1"), d.includes(e) && n === c && (o.includeOutOfStockItems = "true"), o;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
s as getPartnerRecommendationParams
|
|
21
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the extra recommendation feed query params for an account, if any.
|
|
3
|
+
* Accounts without customizations get an empty object.
|
|
4
|
+
* @param partnerName Account subdomain (`config.partner.name`)
|
|
5
|
+
* @param strategy Recommendation strategy key of the block
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPartnerRecommendationParams(partnerName: string, strategy: string): Record<string, string>;
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useHtmlCompiler as
|
|
3
|
-
import { DEFAULT_CURRENCY as
|
|
1
|
+
import { useActionsApi as D } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useHtmlCompiler as P } from "../composables/useHtmlCompiler.js";
|
|
3
|
+
import { DEFAULT_CURRENCY as p, DEFAULT_NODE_CONFIG as i } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
4
4
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
5
|
import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
-
import { parsePageList as
|
|
7
|
-
import { useDynamicContentStore as
|
|
8
|
-
import { useUnsubscribeStore as
|
|
9
|
-
function
|
|
10
|
-
const t = new DOMParser().parseFromString(
|
|
11
|
-
return t.forEach((
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
}),
|
|
6
|
+
import { parsePageList as w } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
7
|
+
import { useDynamicContentStore as E } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useUnsubscribeStore as H } from "../stores/unsubscribe.js";
|
|
9
|
+
function U(s, r) {
|
|
10
|
+
const t = new DOMParser().parseFromString(s, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), o = [];
|
|
11
|
+
return t.forEach((a) => {
|
|
12
|
+
const n = a.getAttribute(S.PAGE_LIST);
|
|
13
|
+
n && o.push(...w(n));
|
|
14
|
+
}), r.filter((a) => o.includes(a));
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
17
|
-
const m = new DOMParser().parseFromString(
|
|
16
|
+
async function F(s) {
|
|
17
|
+
const m = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
18
18
|
if (m.length === 0)
|
|
19
19
|
return;
|
|
20
20
|
const l = b();
|
|
21
21
|
m.forEach((t) => {
|
|
22
|
-
var g, f,
|
|
23
|
-
const
|
|
24
|
-
if (!Number.isFinite(
|
|
22
|
+
var u, g, f, d, c;
|
|
23
|
+
const o = t.getAttribute("recommendation-id"), a = o ? Number(o) : NaN;
|
|
24
|
+
if (!Number.isFinite(a))
|
|
25
25
|
return;
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
26
|
+
const n = t.getAttribute("esd-ext-config");
|
|
27
|
+
if (!n)
|
|
28
28
|
return;
|
|
29
29
|
let e;
|
|
30
30
|
try {
|
|
31
|
-
e = JSON.parse(
|
|
31
|
+
e = JSON.parse(n);
|
|
32
32
|
} catch {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
36
36
|
return;
|
|
37
|
-
const
|
|
38
|
-
strategy: e.strategy ??
|
|
39
|
-
language: e.language ??
|
|
40
|
-
size: e.size ??
|
|
37
|
+
const y = {
|
|
38
|
+
strategy: e.strategy ?? i.strategy,
|
|
39
|
+
language: e.language ?? i.language,
|
|
40
|
+
size: e.size ?? i.size,
|
|
41
41
|
// Spread the default arrays so each block gets a fresh reference
|
|
42
42
|
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
43
|
-
productIds: e.productIds ?? [...
|
|
44
|
-
filters: e.filters ?? [...
|
|
45
|
-
shuffleProducts: e.shuffleProducts ??
|
|
46
|
-
currencyCode: ((
|
|
47
|
-
currencyAlignment: ((
|
|
48
|
-
currencyDecimalCount: ((
|
|
49
|
-
currencyDecimalSeparator: ((
|
|
50
|
-
currencyThousandSeparator: ((
|
|
43
|
+
productIds: e.productIds ?? [...i.productIds],
|
|
44
|
+
filters: e.filters ?? [...i.filters],
|
|
45
|
+
shuffleProducts: e.shuffleProducts ?? i.shuffleProducts,
|
|
46
|
+
currencyCode: ((u = e.currency) == null ? void 0 : u.code) ?? p.code,
|
|
47
|
+
currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? p.alignment,
|
|
48
|
+
currencyDecimalCount: ((f = e.currency) == null ? void 0 : f.decimalCount) ?? p.decimalCount,
|
|
49
|
+
currencyDecimalSeparator: ((d = e.currency) == null ? void 0 : d.decimalSeparator) ?? p.decimalSeparator,
|
|
50
|
+
currencyThousandSeparator: ((c = e.currency) == null ? void 0 : c.thousandSeparator) ?? p.thousandSeparator
|
|
51
51
|
};
|
|
52
|
-
l.seedBlockUrlConfig(
|
|
52
|
+
l.seedBlockUrlConfig(a, y);
|
|
53
53
|
});
|
|
54
54
|
try {
|
|
55
55
|
await l.fetchRecommendationCreateData();
|
|
@@ -60,42 +60,42 @@ async function U(i) {
|
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
const
|
|
64
|
-
const
|
|
63
|
+
const O = () => {
|
|
64
|
+
const s = E(), r = H(), { getCompiledEmail: m, getTemplateData: l } = D(), { compileHtml: t, compileAmpHtml: o } = P();
|
|
65
65
|
return {
|
|
66
66
|
prepareTemplateDetails: async () => {
|
|
67
|
-
const { html:
|
|
67
|
+
const { html: n, ampHtml: e = "", ampErrors: y = [] } = await m({
|
|
68
68
|
minimize: !0,
|
|
69
69
|
resetDataSavedFlag: !1
|
|
70
|
-
}), { html:
|
|
71
|
-
|
|
72
|
-
const { compiledHtml:
|
|
70
|
+
}), { html: u, css: g, syncModulesIds: f = [] } = await l();
|
|
71
|
+
r.selectedUnsubscribePages.length && await r.fetchTemplates(), await F(u);
|
|
72
|
+
const { compiledHtml: d, stats: c, appliedRules: h } = t(n), A = e && o(e).compiledHtml, C = s.getSelectedDynamicContentList, T = b();
|
|
73
73
|
return console.debug("HTML Compilation Stats:", {
|
|
74
|
-
originalSize:
|
|
75
|
-
compiledSize:
|
|
76
|
-
reduction: `${
|
|
77
|
-
appliedRules:
|
|
78
|
-
executionTime: `${
|
|
74
|
+
originalSize: c.originalSize,
|
|
75
|
+
compiledSize: c.compiledSize,
|
|
76
|
+
reduction: `${c.reductionPercentage.toFixed(2)}%`,
|
|
77
|
+
appliedRules: h,
|
|
78
|
+
executionTime: `${c.executionTime.toFixed(2)}ms`
|
|
79
79
|
}), {
|
|
80
|
-
dynamicContentList:
|
|
81
|
-
compiledHtml:
|
|
82
|
-
rawHtml:
|
|
80
|
+
dynamicContentList: C,
|
|
81
|
+
compiledHtml: d,
|
|
82
|
+
rawHtml: u,
|
|
83
83
|
css: g,
|
|
84
|
-
ampHtml:
|
|
85
|
-
ampErrors:
|
|
84
|
+
ampHtml: A,
|
|
85
|
+
ampErrors: y,
|
|
86
86
|
modules: f.map(Number),
|
|
87
87
|
recommendation: {
|
|
88
|
-
campaignUrls:
|
|
88
|
+
campaignUrls: T.recommendationCampaignUrls,
|
|
89
89
|
configs: {}
|
|
90
90
|
},
|
|
91
91
|
unsubscribe: {
|
|
92
|
-
status:
|
|
93
|
-
config:
|
|
92
|
+
status: r.unsubscribePagesStatus,
|
|
93
|
+
config: U(d, r.selectedUnsubscribePages)
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
export {
|
|
100
|
-
|
|
100
|
+
O as useTemplatePreparation
|
|
101
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.6.0-beta.
|
|
3
|
+
"version": "3.6.0-beta.6807430",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ToasterTypeOptions as p } from "../../enums/toaster.js";
|
|
2
|
-
import { PAGE_TYPES as n } from "../../enums/unsubscribe.js";
|
|
3
|
-
import { DATA_ATTRIBUTES as b } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
-
import { useToaster as f } from "../useToaster.js";
|
|
5
|
-
import { useTranslations as m } from "../useTranslations.js";
|
|
6
|
-
const E = ".unsubscribe-block-v2", C = () => {
|
|
7
|
-
const { showToaster: i } = f(), r = m();
|
|
8
|
-
return { validateUnsubscribeBlockUniqueness: (c) => {
|
|
9
|
-
const u = new DOMParser().parseFromString(c, "text/html"), a = Array.from(u.querySelectorAll(E));
|
|
10
|
-
let s = 0, t = 0;
|
|
11
|
-
a.forEach((l) => {
|
|
12
|
-
const o = Number(l.getAttribute(b.PAGE_TYPE));
|
|
13
|
-
o === n.GLOBAL_UNSUBSCRIBE ? s += 1 : o === n.SUBSCRIPTION_PREFERENCE_CENTER && (t += 1);
|
|
14
|
-
});
|
|
15
|
-
const e = [];
|
|
16
|
-
return s > 1 && e.push(r("unsubscription-preference.global-unsub-added")), t > 1 && e.push(r("unsubscription-preference.pref-center-added")), e.length ? (i({
|
|
17
|
-
type: p.Alert,
|
|
18
|
-
message: e.join(" ")
|
|
19
|
-
}), !1) : !0;
|
|
20
|
-
} };
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
C as useUnsubscribeBlockValidator
|
|
24
|
-
};
|
|
File without changes
|