@useinsider/guido 3.1.1-beta.a7d73f2 → 3.1.1-beta.be402b7
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.
|
@@ -1,40 +1,50 @@
|
|
|
1
|
-
import { usePartner as
|
|
2
|
-
import { LINK_REGEXES as
|
|
3
|
-
import { parsePageList as
|
|
4
|
-
import { useConfigStore as
|
|
5
|
-
import { useDynamicContentStore as
|
|
6
|
-
import { useUnsubscribeStore as
|
|
7
|
-
const
|
|
1
|
+
import { usePartner as I } from "../../composables/usePartner.js";
|
|
2
|
+
import { LINK_REGEXES as p, LINK_TYPES as R, INSIDER_ID as b, URLS as y } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { parsePageList as _ } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
4
|
+
import { useConfigStore as N } from "../../stores/config.js";
|
|
5
|
+
import { useDynamicContentStore as U } from "../../stores/dynamic-content.js";
|
|
6
|
+
import { useUnsubscribeStore as C } from "../../stores/unsubscribe.js";
|
|
7
|
+
const G = [
|
|
8
8
|
{
|
|
9
9
|
id: "add-unsubscribe-link-values",
|
|
10
10
|
description: "Adding unsubscribe link values",
|
|
11
11
|
type: "custom",
|
|
12
|
-
processor: (
|
|
13
|
-
const { getPartnerName:
|
|
14
|
-
if (!
|
|
15
|
-
return
|
|
16
|
-
let e =
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
processor: (i) => {
|
|
13
|
+
const { getPartnerName: n } = I(), a = N(), t = U(), g = C(), o = a.variationId;
|
|
14
|
+
if (console.debug("[SD-136953][compiler] variationId:", o), !o)
|
|
15
|
+
return i;
|
|
16
|
+
let e = i;
|
|
17
|
+
const s = `/${n()}/email/${o}?user={{iid}}`, d = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
|
|
18
|
+
console.debug("[SD-136953][compiler] blocks found:", d.length);
|
|
19
|
+
let c = !1, l = !1;
|
|
20
|
+
return d.forEach((f) => {
|
|
21
|
+
var S;
|
|
22
|
+
const u = f.getAttribute("data-unsubscribe-page-list");
|
|
23
|
+
if (!u)
|
|
22
24
|
return;
|
|
23
|
-
const
|
|
24
|
-
(
|
|
25
|
-
)) ?? []
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
const E = _(u), m = ((S = g.templates) == null ? void 0 : S.filter(
|
|
26
|
+
(r) => E.includes(r.id)
|
|
27
|
+
)) ?? [];
|
|
28
|
+
m.some((r) => r.type === R.UNSUBSCRIBE_LINK_TYPE) && (c = !0), m.some((r) => r.type === R.PREFERENCES_LINK_TYPE) && (l = !0), console.debug("[SD-136953][compiler] block:", {
|
|
29
|
+
pageIds: E,
|
|
30
|
+
pagesInBlock: m.map((r) => ({ id: r.id, type: r.type })),
|
|
31
|
+
hasUnsubscribePage: c,
|
|
32
|
+
hasPreferencesPage: l
|
|
33
|
+
});
|
|
34
|
+
}), (c || l) && (t.selectedDynamicContentList.some((u) => u.value === b) || t.selectedDynamicContentList.push({
|
|
35
|
+
text: b,
|
|
36
|
+
value: b,
|
|
37
|
+
fallback: ""
|
|
38
|
+
})), c && (e = e.replace(
|
|
39
|
+
p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
|
|
40
|
+
y.UNSUBSCRIBE_URL + s
|
|
41
|
+
)), l && (e = e.replace(
|
|
42
|
+
p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
|
|
43
|
+
y.PREFERENCES_URL + s
|
|
44
|
+
)), d.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), console.debug("[SD-136953][compiler] result:", {
|
|
45
|
+
hasUnsubscribePage: c,
|
|
46
|
+
hasPreferencesPage: l,
|
|
47
|
+
stillHasPlaceholder: e.includes("{{ins-global-unsubscribe-link}}")
|
|
38
48
|
}), e;
|
|
39
49
|
},
|
|
40
50
|
priority: 60
|
|
@@ -43,7 +53,7 @@ const D = [
|
|
|
43
53
|
id: "remove-data-ogsb-button-styles",
|
|
44
54
|
description: "Removing styles like [data-ogsb] .es-button.es-button-123 { background: red; }",
|
|
45
55
|
type: "regex",
|
|
46
|
-
pattern:
|
|
56
|
+
pattern: p.DATA_OGSB_BUTTON_CSS_REGEX,
|
|
47
57
|
replacement: "",
|
|
48
58
|
flags: "g",
|
|
49
59
|
priority: 61
|
|
@@ -52,31 +62,31 @@ const D = [
|
|
|
52
62
|
id: "format-comment-braces",
|
|
53
63
|
description: "Adding spaces around comment braces for proper formatting",
|
|
54
64
|
type: "custom",
|
|
55
|
-
processor: (
|
|
65
|
+
processor: (i) => i.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
|
|
56
66
|
priority: 62
|
|
57
67
|
},
|
|
58
68
|
{
|
|
59
69
|
id: "add-universal-link-flags",
|
|
60
70
|
description: "Adding universal link flags",
|
|
61
71
|
type: "custom",
|
|
62
|
-
processor: (
|
|
63
|
-
let
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
if (
|
|
72
|
+
processor: (i) => {
|
|
73
|
+
let n = i;
|
|
74
|
+
const a = n.match(/<a[^>]+>(.*?)<\/a>/gm);
|
|
75
|
+
return a && a.forEach((t) => {
|
|
76
|
+
if (t.includes("insEmail=1"))
|
|
67
77
|
return;
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
return e.includes("?") || e.includes("#") ?
|
|
78
|
+
if (t.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
|
|
79
|
+
const o = t.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
|
|
80
|
+
const s = e.slice(6, e.length - 1).trim();
|
|
81
|
+
return e.includes("?") || e.includes("#") ? s.slice(-1) === "&" ? e.replace(s, `${s}insEmail=1`) : e.replace(s, `${s}&insEmail=1`) : e.replace(s, `${s}?insEmail=1`);
|
|
72
82
|
});
|
|
73
|
-
|
|
83
|
+
n = n.replace(t, o);
|
|
74
84
|
}
|
|
75
|
-
}),
|
|
85
|
+
}), n;
|
|
76
86
|
},
|
|
77
87
|
priority: 63
|
|
78
88
|
}
|
|
79
89
|
];
|
|
80
90
|
export {
|
|
81
|
-
|
|
91
|
+
G as unsubscribeCompilerRules
|
|
82
92
|
};
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
import { useActionsApi as f } from "../composables/useActionsApi.js";
|
|
2
|
-
import { useHtmlCompiler as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
4
|
-
import { useDynamicContentStore as
|
|
2
|
+
import { useHtmlCompiler as h } from "../composables/useHtmlCompiler.js";
|
|
3
|
+
import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
import { useDynamicContentStore as D } from "../stores/dynamic-content.js";
|
|
5
5
|
import { useUnsubscribeStore as y } from "../stores/unsubscribe.js";
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const E = () => {
|
|
7
|
+
const n = D(), e = y(), { getCompiledEmail: a, getTemplateData: l, editorSave: m } = f(), { compileHtml: c } = h();
|
|
8
8
|
return {
|
|
9
9
|
prepareTemplateDetails: async () => {
|
|
10
|
-
const { html:
|
|
10
|
+
const { html: s, ampHtml: r = "", ampErrors: p = [] } = await a({
|
|
11
11
|
minimize: !0,
|
|
12
12
|
resetDataSavedFlag: !1
|
|
13
|
-
}), { html:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
}), { html: u, css: d, syncModulesIds: b = [] } = await l();
|
|
14
|
+
console.debug("[SD-136953] Pre-compile state:", {
|
|
15
|
+
selectedPages: e.selectedUnsubscribePages,
|
|
16
|
+
templatesCount: e.templates.length,
|
|
17
|
+
hasPlaceholder: s.includes("{{ins-global-unsubscribe-link}}")
|
|
18
|
+
}), e.selectedUnsubscribePages.length && await e.fetchTemplates(), console.debug("[SD-136953] Post-fetch state:", {
|
|
19
|
+
templatesCount: e.templates.length,
|
|
20
|
+
templates: e.templates.map((i) => ({ id: i.id, type: i.type }))
|
|
21
|
+
});
|
|
22
|
+
const { compiledHtml: o, stats: t, appliedRules: g } = c(s);
|
|
23
|
+
console.debug("[SD-136953] Post-compile:", {
|
|
24
|
+
stillHasPlaceholder: o.includes("{{ins-global-unsubscribe-link}}")
|
|
25
|
+
});
|
|
26
|
+
const S = n.getSelectedDynamicContentList, P = C();
|
|
27
|
+
return m(), console.debug("HTML Compilation Stats:", {
|
|
17
28
|
originalSize: t.originalSize,
|
|
18
29
|
compiledSize: t.compiledSize,
|
|
19
30
|
reduction: `${t.reductionPercentage.toFixed(2)}%`,
|
|
@@ -21,14 +32,14 @@ const w = () => {
|
|
|
21
32
|
executionTime: `${t.executionTime.toFixed(2)}ms`
|
|
22
33
|
}), {
|
|
23
34
|
dynamicContentList: S,
|
|
24
|
-
compiledHtml:
|
|
25
|
-
rawHtml:
|
|
26
|
-
css:
|
|
35
|
+
compiledHtml: o,
|
|
36
|
+
rawHtml: u,
|
|
37
|
+
css: d,
|
|
27
38
|
ampHtml: r,
|
|
28
|
-
ampErrors:
|
|
29
|
-
modules:
|
|
39
|
+
ampErrors: p,
|
|
40
|
+
modules: b.map(Number),
|
|
30
41
|
recommendation: {
|
|
31
|
-
campaignUrls:
|
|
42
|
+
campaignUrls: P.recommendationCampaignUrls,
|
|
32
43
|
configs: {}
|
|
33
44
|
},
|
|
34
45
|
unsubscribe: {
|
|
@@ -40,5 +51,5 @@ const w = () => {
|
|
|
40
51
|
};
|
|
41
52
|
};
|
|
42
53
|
export {
|
|
43
|
-
|
|
54
|
+
E as useTemplatePreparation
|
|
44
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.1.1-beta.
|
|
3
|
+
"version": "3.1.1-beta.be402b7",
|
|
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",
|