@useinsider/guido 3.2.0-beta.bdc0c2a → 3.2.0-beta.c2a858e
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,41 +1,44 @@
|
|
|
1
|
-
import { usePartner as
|
|
2
|
-
import { LINK_REGEXES as p, LINK_TYPES as
|
|
3
|
-
import { parsePageList as
|
|
4
|
-
import { useConfigStore as
|
|
5
|
-
import { useDynamicContentStore as
|
|
6
|
-
import { useUnsubscribeStore as
|
|
7
|
-
|
|
1
|
+
import { usePartner as U } from "../../composables/usePartner.js";
|
|
2
|
+
import { LINK_REGEXES as p, PRODUCT_TYPE_URL_SEGMENTS as R, LINK_TYPES as _, INSIDER_ID as m, URLS as y } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { parsePageList as N } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
4
|
+
import { useConfigStore as C } from "../../stores/config.js";
|
|
5
|
+
import { useDynamicContentStore as L } from "../../stores/dynamic-content.js";
|
|
6
|
+
import { useUnsubscribeStore as P } from "../../stores/unsubscribe.js";
|
|
7
|
+
import { ProductType as B } from "../../@types/config/schemas.js";
|
|
8
|
+
import "../../@types/config/defaults.js";
|
|
9
|
+
const F = [
|
|
8
10
|
{
|
|
9
11
|
id: "add-unsubscribe-link-values",
|
|
10
12
|
description: "Adding unsubscribe link values",
|
|
11
13
|
type: "custom",
|
|
12
|
-
processor: (
|
|
13
|
-
const { getPartnerName: i } =
|
|
14
|
-
if (!
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
processor: (s) => {
|
|
15
|
+
const { getPartnerName: i } = U(), n = C(), t = L(), E = P(), c = n.variationId;
|
|
16
|
+
if (!c)
|
|
17
|
+
return s;
|
|
18
|
+
const r = R[n.productType] ?? R[B.EMAIL];
|
|
19
|
+
let e = s;
|
|
20
|
+
const d = `/${i()}/${r}/${c}?user={{iid}}`, f = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
|
|
21
|
+
let a = !1, l = !1;
|
|
22
|
+
return f.forEach((g) => {
|
|
23
|
+
var S;
|
|
24
|
+
const u = g.getAttribute("data-unsubscribe-page-list");
|
|
22
25
|
if (!u)
|
|
23
26
|
return;
|
|
24
|
-
const
|
|
25
|
-
(
|
|
27
|
+
const I = N(u), b = ((S = E.templates) == null ? void 0 : S.filter(
|
|
28
|
+
(o) => I.includes(o.id)
|
|
26
29
|
)) ?? [];
|
|
27
|
-
|
|
28
|
-
}), (
|
|
30
|
+
a = a || b.some((o) => o.type === _.UNSUBSCRIBE_LINK_TYPE), l = l || b.some((o) => o.type === _.PREFERENCES_LINK_TYPE);
|
|
31
|
+
}), (a || l) && (t.selectedDynamicContentList.some((u) => u.value === m) || t.selectedDynamicContentList.push({
|
|
29
32
|
text: m,
|
|
30
33
|
value: m,
|
|
31
34
|
fallback: ""
|
|
32
|
-
})),
|
|
35
|
+
})), a && (e = e.replace(
|
|
33
36
|
p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
|
|
34
|
-
|
|
37
|
+
y.UNSUBSCRIBE_URL + d
|
|
35
38
|
)), l && (e = e.replace(
|
|
36
39
|
p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
|
|
37
|
-
|
|
38
|
-
)),
|
|
40
|
+
y.PREFERENCES_URL + d
|
|
41
|
+
)), f.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
|
|
39
42
|
},
|
|
40
43
|
priority: 60
|
|
41
44
|
},
|
|
@@ -52,25 +55,25 @@ const G = [
|
|
|
52
55
|
id: "format-comment-braces",
|
|
53
56
|
description: "Adding spaces around comment braces for proper formatting",
|
|
54
57
|
type: "custom",
|
|
55
|
-
processor: (
|
|
58
|
+
processor: (s) => s.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
|
|
56
59
|
priority: 62
|
|
57
60
|
},
|
|
58
61
|
{
|
|
59
62
|
id: "add-universal-link-flags",
|
|
60
63
|
description: "Adding universal link flags",
|
|
61
64
|
type: "custom",
|
|
62
|
-
processor: (
|
|
63
|
-
let i =
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
if (
|
|
65
|
+
processor: (s) => {
|
|
66
|
+
let i = s;
|
|
67
|
+
const n = i.match(/<a[^>]+>(.*?)<\/a>/gm);
|
|
68
|
+
return n && n.forEach((t) => {
|
|
69
|
+
if (t.includes("insEmail=1"))
|
|
67
70
|
return;
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
return
|
|
71
|
+
if (t.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
|
|
72
|
+
const c = t.replace(/href=(["'`”])(.*?)\1/gm, (r) => {
|
|
73
|
+
const e = r.slice(6, r.length - 1).trim();
|
|
74
|
+
return r.includes("?") || r.includes("#") ? e.slice(-1) === "&" ? r.replace(e, `${e}insEmail=1`) : r.replace(e, `${e}&insEmail=1`) : r.replace(e, `${e}?insEmail=1`);
|
|
72
75
|
});
|
|
73
|
-
i = i.replace(
|
|
76
|
+
i = i.replace(t, c);
|
|
74
77
|
}
|
|
75
78
|
}), i;
|
|
76
79
|
},
|
|
@@ -78,5 +81,5 @@ const G = [
|
|
|
78
81
|
}
|
|
79
82
|
];
|
|
80
83
|
export {
|
|
81
|
-
|
|
84
|
+
F as unsubscribeCompilerRules
|
|
82
85
|
};
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import { useTranslations as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { useTranslations as R } from "../composables/useTranslations.js";
|
|
2
|
+
import { ProductType as s } from "../@types/config/schemas.js";
|
|
3
|
+
import "../@types/config/defaults.js";
|
|
4
|
+
import { getEnvironmentPrefix as S } from "../utils/environmentUtil.js";
|
|
5
|
+
const B = {
|
|
4
6
|
UNSUBSCRIBE_LINK_TYPE: 1,
|
|
5
7
|
PREFERENCES_LINK_TYPE: 3
|
|
6
|
-
},
|
|
8
|
+
}, i = {
|
|
7
9
|
UNSUBSCRIBE_LINK_REGEX: /{{ins-unsubscribe-link}}/g,
|
|
8
10
|
DATA_OGSB_BUTTON_CSS_REGEX: "\\[data-ogsb\\]\\s*\\.es-button\\.es-button-[0-9]+\\s*\\{(?:[^\\}]*)\\}",
|
|
9
11
|
GLOBAL_UNSUBSCRIBE_LINK_REGEX: /{{ins-global-unsubscribe-link}}/g,
|
|
10
12
|
PREFERENCES_UNSUBSCRIBE_LINK_REGEX: /{{ins-preferences-unsubscribe-link}}/g
|
|
11
|
-
}, n =
|
|
13
|
+
}, n = S(), C = {
|
|
12
14
|
UNSUBSCRIBE_URL: `https://mail.${n}.com/user/v1/unsub`,
|
|
13
15
|
PREFERENCES_URL: `https://mail.${n}.com/user/v1/prefs`
|
|
14
|
-
},
|
|
16
|
+
}, U = {
|
|
17
|
+
[s.EMAIL]: "email",
|
|
18
|
+
[s.ARCHITECT]: "journey",
|
|
19
|
+
[s.UNSUBSCRIBE_PAGES]: "email"
|
|
20
|
+
}, t = "iid", o = {
|
|
15
21
|
name: "Global Unsubscribe",
|
|
16
22
|
sendGridId: "G"
|
|
17
|
-
},
|
|
23
|
+
}, c = "/email/unsubscribe-pages", E = {
|
|
18
24
|
GLOBAL_UNSUBSCRIBE: 1,
|
|
19
25
|
GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE: 2,
|
|
20
26
|
SUBSCRIPTION_PREFERENCE_CENTER: 3,
|
|
21
27
|
SUBSCRIPTION_PREFERENCE_CONFIRMATION: 4,
|
|
22
28
|
RESUBSCRIBE: 5
|
|
23
|
-
},
|
|
29
|
+
}, u = {
|
|
24
30
|
[E.GLOBAL_UNSUBSCRIBE]: "custom-unsubscribe",
|
|
25
31
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "custom-preferences"
|
|
26
|
-
},
|
|
32
|
+
}, T = {
|
|
27
33
|
[E.GLOBAL_UNSUBSCRIBE]: [
|
|
28
34
|
E.GLOBAL_UNSUBSCRIBE,
|
|
29
35
|
E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE,
|
|
@@ -33,30 +39,31 @@ const _ = {
|
|
|
33
39
|
E.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
34
40
|
E.SUBSCRIPTION_PREFERENCE_CONFIRMATION
|
|
35
41
|
]
|
|
36
|
-
},
|
|
37
|
-
const
|
|
42
|
+
}, b = () => {
|
|
43
|
+
const e = R();
|
|
38
44
|
return {
|
|
39
|
-
[E.GLOBAL_UNSUBSCRIBE]:
|
|
40
|
-
[E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE]:
|
|
41
|
-
[E.RESUBSCRIBE]:
|
|
42
|
-
[E.SUBSCRIPTION_PREFERENCE_CENTER]:
|
|
43
|
-
[E.SUBSCRIPTION_PREFERENCE_CONFIRMATION]:
|
|
45
|
+
[E.GLOBAL_UNSUBSCRIBE]: e("unsubscription-preference.type-global-unsubscribe"),
|
|
46
|
+
[E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE]: e("unsubscription-preference.type-global-unsubscription-confirmation"),
|
|
47
|
+
[E.RESUBSCRIBE]: e("unsubscription-preference.type-resubscribe"),
|
|
48
|
+
[E.SUBSCRIPTION_PREFERENCE_CENTER]: e("unsubscription-preference.type-subscription-preferences-center"),
|
|
49
|
+
[E.SUBSCRIPTION_PREFERENCE_CONFIRMATION]: e("unsubscription-preference.type-subscription-preferences-confirmation")
|
|
44
50
|
};
|
|
45
|
-
},
|
|
51
|
+
}, P = {
|
|
46
52
|
default: "{{ins-unsubscribe-link}}",
|
|
47
53
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
48
54
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
49
55
|
};
|
|
50
56
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
o as DEFAULT_UNSUBSCRIBE_GROUP,
|
|
58
|
+
t as INSIDER_ID,
|
|
59
|
+
i as LINK_REGEXES,
|
|
60
|
+
B as LINK_TYPES,
|
|
61
|
+
P as MERGE_TAGS,
|
|
56
62
|
E as PAGE_TYPES,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
U as PRODUCT_TYPE_URL_SEGMENTS,
|
|
64
|
+
T as TYPE_COLLECTIONS,
|
|
65
|
+
c as UNSUBSCRIBE_PAGES_LINK,
|
|
66
|
+
u as UNSUBSCRIBE_SYNC_MODULE_TYPES,
|
|
67
|
+
C as URLS,
|
|
68
|
+
b as getTypeTranslations
|
|
62
69
|
};
|
|
@@ -12,6 +12,11 @@ export declare const URLS: {
|
|
|
12
12
|
UNSUBSCRIBE_URL: string;
|
|
13
13
|
PREFERENCES_URL: string;
|
|
14
14
|
};
|
|
15
|
+
export declare const PRODUCT_TYPE_URL_SEGMENTS: {
|
|
16
|
+
readonly 60: "email";
|
|
17
|
+
readonly 49: "journey";
|
|
18
|
+
readonly 97: "email";
|
|
19
|
+
};
|
|
15
20
|
export declare const INSIDER_ID = "iid";
|
|
16
21
|
export declare const DEFAULT_UNSUBSCRIBE_GROUP: {
|
|
17
22
|
readonly name: "Global Unsubscribe";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.2.0-beta.
|
|
3
|
+
"version": "3.2.0-beta.c2a858e",
|
|
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",
|