@useinsider/guido 3.1.1-beta.c728f08 → 3.1.1-beta.dee5e9c

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,41 @@
1
- import { usePartner as N } from "../../composables/usePartner.js";
2
- import { LINK_REGEXES as l, LINK_TYPES as S, INSIDER_ID as R, URLS as _ } from "../../enums/unsubscribe.js";
3
- import { parsePageList as U } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
4
- import { useConfigStore as B } from "../../stores/config.js";
5
- import { useDynamicContentStore as y } from "../../stores/dynamic-content.js";
6
- import { useUnsubscribeStore as L } from "../../stores/unsubscribe.js";
7
- const D = [
1
+ import { usePartner as y } from "../../composables/usePartner.js";
2
+ import { LINK_REGEXES as p, LINK_TYPES as S, INSIDER_ID as m, URLS as R } from "../../enums/unsubscribe.js";
3
+ import { parsePageList as I } 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
12
  processor: (t) => {
13
- const { getPartnerName: i } = N(), c = B(), n = y(), u = L(), a = c.variationId;
13
+ const { getPartnerName: i } = y(), o = N(), s = U(), d = C(), a = o.variationId;
14
14
  if (!a)
15
15
  return t;
16
16
  let e = t;
17
- const r = `/${i()}/email/${a}?user={{iid}}`;
18
- return new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]").forEach((p) => {
19
- var g;
20
- const m = p.getAttribute("data-unsubscribe-page-list");
21
- if (!m)
17
+ const r = `/${i()}/email/${a}?user={{iid}}`, E = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
18
+ let c = !1, l = !1;
19
+ return E.forEach((f) => {
20
+ var b;
21
+ const u = f.getAttribute("data-unsubscribe-page-list");
22
+ if (!u)
22
23
  return;
23
- const I = U(m), d = ((g = u.templates) == null ? void 0 : g.filter(
24
- (o) => I.includes(o.id)
25
- )) ?? [], E = d.some((o) => o.type === S.UNSUBSCRIBE_LINK_TYPE), b = d.some((o) => o.type === S.PREFERENCES_LINK_TYPE), f = p.outerHTML;
26
- let s = f;
27
- (E || b) && n.selectedDynamicContentList.push({
28
- text: R,
29
- value: R,
30
- fallback: ""
31
- }), E && (s = s.replace(
32
- l.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
33
- _.UNSUBSCRIBE_URL + r
34
- )), b && (s = s.replace(
35
- l.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
36
- _.PREFERENCES_URL + r
37
- )), s = s.replace(l.UNSUBSCRIBE_LINK_REGEX, ""), e = e.replace(f, s);
38
- }), e;
24
+ const _ = I(u), g = ((b = d.templates) == null ? void 0 : b.filter(
25
+ (n) => _.includes(n.id)
26
+ )) ?? [];
27
+ c = c || g.some((n) => n.type === S.UNSUBSCRIBE_LINK_TYPE), l = l || g.some((n) => n.type === S.PREFERENCES_LINK_TYPE);
28
+ }), (c || l) && (s.selectedDynamicContentList.some((u) => u.value === m) || s.selectedDynamicContentList.push({
29
+ text: m,
30
+ value: m,
31
+ fallback: ""
32
+ })), c && (e = e.replace(
33
+ p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
34
+ R.UNSUBSCRIBE_URL + r
35
+ )), l && (e = e.replace(
36
+ p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
37
+ R.PREFERENCES_URL + r
38
+ )), E.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
39
39
  },
40
40
  priority: 60
41
41
  },
@@ -43,7 +43,7 @@ const D = [
43
43
  id: "remove-data-ogsb-button-styles",
44
44
  description: "Removing styles like [data-ogsb] .es-button.es-button-123 { background: red; }",
45
45
  type: "regex",
46
- pattern: l.DATA_OGSB_BUTTON_CSS_REGEX,
46
+ pattern: p.DATA_OGSB_BUTTON_CSS_REGEX,
47
47
  replacement: "",
48
48
  flags: "g",
49
49
  priority: 61
@@ -61,16 +61,16 @@ const D = [
61
61
  type: "custom",
62
62
  processor: (t) => {
63
63
  let i = t;
64
- const c = i.match(/<a[^>]+>(.*?)<\/a>/gm);
65
- return c && c.forEach((n) => {
66
- if (n.includes("insEmail=1"))
64
+ const o = i.match(/<a[^>]+>(.*?)<\/a>/gm);
65
+ return o && o.forEach((s) => {
66
+ if (s.includes("insEmail=1"))
67
67
  return;
68
- if (n.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
69
- const a = n.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
68
+ if (s.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
69
+ const a = s.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
70
70
  const r = e.slice(6, e.length - 1).trim();
71
71
  return e.includes("?") || e.includes("#") ? r.slice(-1) === "&" ? e.replace(r, `${r}insEmail=1`) : e.replace(r, `${r}&insEmail=1`) : e.replace(r, `${r}?insEmail=1`);
72
72
  });
73
- i = i.replace(n, a);
73
+ i = i.replace(s, a);
74
74
  }
75
75
  }), i;
76
76
  },
@@ -78,5 +78,5 @@ const D = [
78
78
  }
79
79
  ];
80
80
  export {
81
- D as unsubscribeCompilerRules
81
+ G as unsubscribeCompilerRules
82
82
  };
@@ -3,22 +3,24 @@ import { useHtmlCompiler as C } from "../composables/useHtmlCompiler.js";
3
3
  import { useRecommendationExtensionStore as T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
4
  import { useDynamicContentStore as x } from "../stores/dynamic-content.js";
5
5
  import { useUnsubscribeStore as y } from "../stores/unsubscribe.js";
6
- const E = () => {
7
- const o = x(), t = y(), { getCompiledEmail: i, getTemplateData: n, editorSave: s } = f(), { compileHtml: m } = C();
6
+ const w = () => {
7
+ const o = x(), e = y(), { getCompiledEmail: i, getTemplateData: s, editorSave: n } = f(), { compileHtml: a } = C();
8
8
  return {
9
9
  prepareTemplateDetails: async () => {
10
- const { html: a, ampHtml: r = "", ampErrors: c = [] } = await i({
10
+ const { html: m, ampHtml: r = "", ampErrors: c = [] } = await i({
11
11
  minimize: !0,
12
12
  resetDataSavedFlag: !1
13
- }), { html: l, css: p, syncModulesIds: u = [] } = await n(), { compiledHtml: d, stats: e, appliedRules: S } = m(a), g = o.getSelectedDynamicContentList, b = T();
14
- return s(), console.debug("HTML Compilation Stats:", {
15
- originalSize: e.originalSize,
16
- compiledSize: e.compiledSize,
17
- reduction: `${e.reductionPercentage.toFixed(2)}%`,
18
- appliedRules: S,
19
- executionTime: `${e.executionTime.toFixed(2)}ms`
13
+ }), { html: l, css: p, syncModulesIds: u = [] } = await s();
14
+ e.selectedUnsubscribePages.length && await e.fetchTemplates();
15
+ const { compiledHtml: d, stats: t, appliedRules: g } = a(m), S = o.getSelectedDynamicContentList, b = T();
16
+ return n(), console.debug("HTML Compilation Stats:", {
17
+ originalSize: t.originalSize,
18
+ compiledSize: t.compiledSize,
19
+ reduction: `${t.reductionPercentage.toFixed(2)}%`,
20
+ appliedRules: g,
21
+ executionTime: `${t.executionTime.toFixed(2)}ms`
20
22
  }), {
21
- dynamicContentList: g,
23
+ dynamicContentList: S,
22
24
  compiledHtml: d,
23
25
  rawHtml: l,
24
26
  css: p,
@@ -30,13 +32,13 @@ const E = () => {
30
32
  configs: {}
31
33
  },
32
34
  unsubscribe: {
33
- status: t.unsubscribePagesStatus,
34
- config: t.selectedUnsubscribePages
35
+ status: e.unsubscribePagesStatus,
36
+ config: e.selectedUnsubscribePages
35
37
  }
36
38
  };
37
39
  }
38
40
  };
39
41
  };
40
42
  export {
41
- E as useTemplatePreparation
43
+ w as useTemplatePreparation
42
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.1.1-beta.c728f08",
3
+ "version": "3.1.1-beta.dee5e9c",
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",