@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 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 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: (t) => {
13
- const { getPartnerName: i } = N(), c = B(), n = y(), u = L(), a = c.variationId;
14
- if (!a)
15
- return t;
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)
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 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);
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: l.DATA_OGSB_BUTTON_CSS_REGEX,
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: (t) => t.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
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: (t) => {
63
- let i = t;
64
- const c = i.match(/<a[^>]+>(.*?)<\/a>/gm);
65
- return c && c.forEach((n) => {
66
- if (n.includes("insEmail=1"))
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 (n.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
69
- const a = n.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
70
- const r = e.slice(6, e.length - 1).trim();
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`);
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
- i = i.replace(n, a);
83
+ n = n.replace(t, o);
74
84
  }
75
- }), i;
85
+ }), n;
76
86
  },
77
87
  priority: 63
78
88
  }
79
89
  ];
80
90
  export {
81
- D as unsubscribeCompilerRules
91
+ G as unsubscribeCompilerRules
82
92
  };
@@ -1,19 +1,30 @@
1
1
  import { useActionsApi as f } from "../composables/useActionsApi.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";
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 w = () => {
7
- const o = x(), e = y(), { getCompiledEmail: i, getTemplateData: s, editorSave: n } = f(), { compileHtml: a } = C();
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: m, ampHtml: r = "", ampErrors: c = [] } = await i({
10
+ const { html: s, ampHtml: r = "", ampErrors: p = [] } = await a({
11
11
  minimize: !0,
12
12
  resetDataSavedFlag: !1
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:", {
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: d,
25
- rawHtml: l,
26
- css: p,
35
+ compiledHtml: o,
36
+ rawHtml: u,
37
+ css: d,
27
38
  ampHtml: r,
28
- ampErrors: c,
29
- modules: u.map(Number),
39
+ ampErrors: p,
40
+ modules: b.map(Number),
30
41
  recommendation: {
31
- campaignUrls: b.recommendationCampaignUrls,
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
- w as useTemplatePreparation
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.a7d73f2",
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",