@useinsider/guido 3.1.1-beta.7b1351e → 3.1.1-beta.9d8e9d6

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