@useinsider/guido 3.4.1-beta.c04b4e7 → 3.4.1-beta.ce8d9b0

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.
@@ -21,9 +21,9 @@ const v = () => {
21
21
  resetDataSavedFlag: !1,
22
22
  disableLineHeightsReplace: !0
23
23
  }, ...t }, s = {
24
- callback: (l, p, d, c, u) => {
24
+ callback: (l, r, d, c, u) => {
25
25
  l ? a(l) : e({
26
- html: p,
26
+ html: r,
27
27
  ampHtml: d,
28
28
  ampErrors: c,
29
29
  displayConditions: u
@@ -36,11 +36,11 @@ const v = () => {
36
36
  return {
37
37
  getCompiledEmail: m,
38
38
  getTemplateData: () => new Promise((t) => {
39
- const e = ({ html: a, css: i, width: o, height: r, utmParams: s, syncModulesIds: l }) => t({
39
+ const e = ({ html: a, css: i, width: o, height: p, utmParams: s, syncModulesIds: l }) => t({
40
40
  html: a,
41
41
  css: i,
42
42
  width: o,
43
- height: r,
43
+ height: p,
44
44
  utmParams: s,
45
45
  syncModulesIds: l
46
46
  });
@@ -91,11 +91,7 @@ const v = () => {
91
91
  },
92
92
  editorSave: () => new Promise((t) => {
93
93
  window.StripoEditorApi.actionsApi.save((e) => {
94
- if (e) {
95
- n(e, "Failed to save template"), t(!1);
96
- return;
97
- }
98
- t(!0);
94
+ e && n(e, "Failed to save template"), t();
99
95
  });
100
96
  })
101
97
  };
@@ -1,30 +1,48 @@
1
- import { defaultHtmlCompilerRules as c } from "../config/compiler/htmlCompilerRules.js";
2
- import { itemsCompilerRules as f } from "../config/compiler/itemsCompilerRules.js";
3
- import { liquidCompilerRules as R } from "../config/compiler/liquidCompilerRules.js";
4
- import { outlookCompilerRules as C } from "../config/compiler/outlookCompilerRules.js";
5
- import { recommendationCompilerRules as d } from "../config/compiler/recommendationCompilerRules.js";
6
- import { socialCompilerRules as b } from "../config/compiler/socialCompilerRules.js";
7
- import { unsubscribeCompilerRules as g } from "../config/compiler/unsubscribeCompilerRules.js";
8
- import { createHtmlCompiler as H } from "../utils/htmlCompiler.js";
9
- import { useConfig as v } from "./useConfig.js";
10
- const w = () => {
11
- var l, m, r;
12
- const { compiler: e, isFeatureEnabled: t, partner: i } = v(), s = ((l = e.value) == null ? void 0 : l.customRules) || [], u = [
13
- ...!!((m = e.value) != null && m.ignoreDefaultRules) ? [] : c,
14
- ...d,
1
+ import { defaultHtmlCompilerRules as R } from "../config/compiler/htmlCompilerRules.js";
2
+ import { itemsCompilerRules as g } from "../config/compiler/itemsCompilerRules.js";
3
+ import { liquidCompilerRules as C } from "../config/compiler/liquidCompilerRules.js";
4
+ import { outlookCompilerRules as b } from "../config/compiler/outlookCompilerRules.js";
5
+ import { recommendationCompilerRules as v } from "../config/compiler/recommendationCompilerRules.js";
6
+ import { socialCompilerRules as H } from "../config/compiler/socialCompilerRules.js";
7
+ import { unsubscribeCompilerRules as x } from "../config/compiler/unsubscribeCompilerRules.js";
8
+ import { createHtmlCompiler as s } from "../utils/htmlCompiler.js";
9
+ import { useConfig as k } from "./useConfig.js";
10
+ const y = /* @__PURE__ */ new Set([
11
+ // URL/tag encoding fixes — keep merge-tag and placeholder integrity intact.
12
+ "fix-url-encoding-start",
13
+ "fix-url-encoding-end",
14
+ "fix-tags-start",
15
+ "fix-tags-end",
16
+ // Image domain corrections — plain string replacement.
17
+ "replace-old-image-domain",
18
+ "replace-old-v2-image-domain",
19
+ // Unsubscribe domain — the actual fix: injects the real unsubscribe href in
20
+ // place of the `{{ins-*-unsubscribe-link}}` placeholders, plus related
21
+ // unsubscribe-only cleanups. All pure regex/text, no AMP-forbidden output.
22
+ "add-unsubscribe-link-values",
23
+ "remove-data-ogsb-button-styles",
24
+ "format-comment-braces",
25
+ "add-universal-link-flags",
26
+ // Coupon placeholder replacement (only present when liquidSyntax is enabled).
27
+ "liquid-coupon-code"
28
+ ]), M = () => {
29
+ var m, t, r;
30
+ const { compiler: e, isFeatureEnabled: a, partner: n } = k(), u = ((m = e.value) == null ? void 0 : m.customRules) || [], l = [
31
+ ...!!((t = e.value) != null && t.ignoreDefaultRules) ? [] : R,
32
+ ...v,
33
+ ...x,
15
34
  ...g,
16
- ...f,
17
- ...C,
18
35
  ...b,
19
- ...t("liquidSyntax") ? R : [],
20
- ...s.map((o, a) => ({
36
+ ...H,
37
+ ...a("liquidSyntax") ? C : [],
38
+ ...u.map((o, f) => ({
21
39
  ...o,
22
- priority: o.priority + 1e3 + a
40
+ priority: o.priority + 1e3 + f
23
41
  // Ensure additional rules run after default rules
24
42
  }))
25
- ], p = H(u), n = (r = i.value) == null ? void 0 : r.fallbackFont;
26
- return { compileHtml: (o) => p.compile(o, void 0, n) };
43
+ ], p = s(l), c = l.filter((o) => y.has(o.id)), d = s(c), i = (r = n.value) == null ? void 0 : r.fallbackFont;
44
+ return { compileHtml: (o) => p.compile(o, void 0, i), compileAmpHtml: (o) => d.compile(o, void 0, i) };
27
45
  };
28
46
  export {
29
- w as useHtmlCompiler
47
+ M as useHtmlCompiler
30
48
  };
@@ -1,31 +1,32 @@
1
1
  import { useActionsApi as x } from "./useActionsApi.js";
2
2
  import { useConfig as y } from "./useConfig.js";
3
3
  import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
4
- import { useSyncModuleExtractor as E } from "./useSyncModuleExtractor.js";
5
- import { useStripoApi as H } from "../services/stripoApi.js";
6
- import { useTemplatePreparation as b } from "../utils/templatePreparation.js";
7
- import { useHtmlValidator as q } from "./useHtmlValidator.js";
8
- import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
9
- import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
10
- const z = () => {
11
- const o = w(), s = C(), { validateHtml: r } = q(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = E(), { setSyncModuleUnsubscriptionPages: c } = H(), { editorSave: m } = x();
4
+ import { useSyncModuleExtractor as H } from "./useSyncModuleExtractor.js";
5
+ import { useStripoApi as b } from "../services/stripoApi.js";
6
+ import { useTemplatePreparation as q } from "../utils/templatePreparation.js";
7
+ import { useHtmlValidator as L } from "./useHtmlValidator.js";
8
+ import { useCouponBlockValidator as P } from "./validators/useCouponBlockValidator.js";
9
+ import { useLiquidValidator as E } from "./validators/useLiquidValidator.js";
10
+ const j = () => {
11
+ const o = w(), s = C(), { validateHtml: r } = L(), { validateLiquidSyntax: l } = E(), { validateCouponBlockTags: n } = P(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = H(), { setSyncModuleUnsubscriptionPages: c } = b(), { editorSave: m } = x();
12
12
  return { save: async (p = !1, f = !1) => {
13
13
  var i;
14
14
  o();
15
- const { prepareTemplateDetails: v } = b(), t = await v();
16
- if (!l(t.compiledHtml))
15
+ const { prepareTemplateDetails: v } = q(), t = await v();
16
+ if (!n(t.compiledHtml))
17
17
  return;
18
18
  if (d("liquidSyntax")) {
19
- if (!await n(t.compiledHtml))
19
+ if (!await l(t.compiledHtml))
20
20
  return;
21
21
  } else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
22
22
  return;
23
- if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t) || !await m())
23
+ if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
24
24
  return;
25
+ await m();
25
26
  const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
26
27
  return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
27
28
  } };
28
29
  };
29
30
  export {
30
- z as useSave
31
+ j as useSave
31
32
  };
@@ -1,34 +1,31 @@
1
1
  var d = Object.defineProperty;
2
- var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var c = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
4
- import { useToaster as L } from "../../../composables/useToaster.js";
5
- import { ToasterTypeOptions as S } from "../../../enums/toaster.js";
6
- import { PAGE_TYPES as b } from "../../../enums/unsubscribe.js";
7
- import { useUnsubscribeStore as a } from "../../../stores/unsubscribe.js";
8
- import { Block as g, BlockCompositionType as v, BlockType as k, ModificationDescription as E } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
9
- import { getDefaultTemplate as f } from "./template.js";
10
- import { UNSUBSCRIBE_EVENTS as u, DATA_ATTRIBUTES as o } from "./utils/constants.js";
11
- import { parsePageList as h } from "./utils/utils.js";
12
- const T = "unsubscribe-block", p = 'a[data-unsubscribe-link="true"]', B = ".unsubscribe-block-v2", U = "{{ins-unsubscribe-link}}", C = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", A = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", N = {
13
- [b.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
14
- [b.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
2
+ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
4
+ import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
5
+ import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
6
+ import { Block as _, BlockCompositionType as S, BlockType as L, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
+ import { getDefaultTemplate as v } from "./template.js";
8
+ import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
9
+ import { parsePageList as p } from "./utils/utils.js";
10
+ const g = "unsubscribe-block", T = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", C = {
11
+ [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
12
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
15
13
  };
16
- class x extends g {
14
+ class I extends _ {
17
15
  constructor() {
18
16
  super();
19
- c(this, "selectEventListener", null);
20
- c(this, "cancelEventListener", null);
21
- c(this, "currentNode");
22
- c(this, "hadUnsubscribeLink", !1);
17
+ u(this, "selectEventListener", null);
18
+ u(this, "cancelEventListener", null);
19
+ u(this, "currentNode");
23
20
  }
24
21
  getId() {
25
- return T;
22
+ return g;
26
23
  }
27
24
  getIcon() {
28
25
  return "unsubscribe-icon";
29
26
  }
30
27
  getBlockCompositionType() {
31
- return v.BLOCK;
28
+ return S.BLOCK;
32
29
  }
33
30
  getName() {
34
31
  return this.api.translate("Unsubscribe Block");
@@ -37,63 +34,39 @@ class x extends g {
37
34
  return this.api.translate("Unsubscribe Block Description");
38
35
  }
39
36
  getTemplate() {
40
- return f();
37
+ return v();
41
38
  }
42
39
  onSelect(e) {
43
- this.currentNode = e, this.hadUnsubscribeLink = this._hasUnsubscribeLink(e), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
44
- }
45
- onDocumentChanged(e) {
46
- const t = this._hasUnsubscribeLink(e);
47
- this.hadUnsubscribeLink && !t && this._warnLinkRemoved(), this.hadUnsubscribeLink = t;
40
+ this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
48
41
  }
49
42
  onDelete(e) {
50
- this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState(), this.hadUnsubscribeLink = !1;
43
+ this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
51
44
  }
52
45
  onDestroy() {
53
- this._removeEventListeners(), this.currentNode = void 0, this.hadUnsubscribeLink = !1;
54
- }
55
- _hasUnsubscribeLink(e) {
56
- return "querySelector" in e ? !!e.querySelector(p) : !1;
57
- }
58
- _warnLinkRemoved() {
59
- try {
60
- const { showToaster: e } = L();
61
- e({
62
- type: S.Warning,
63
- message: this.api.translate(A),
64
- actionButton: {
65
- text: this.api.translate("Visit Academy"),
66
- onClick: () => {
67
- window.open(C, "_blank", "noopener,noreferrer");
68
- }
69
- }
70
- });
71
- } catch (e) {
72
- console.error("[UnsubscribeBlock] Failed to show warning toaster:", e);
73
- }
46
+ this._removeEventListeners(), this.currentNode = void 0;
74
47
  }
75
48
  _setupSelectEventListener() {
76
49
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
77
- const t = e, { collectionType: r, selectedPages: s } = t.detail;
78
- this._updateBlock(r, s.join(","));
79
- }, document.addEventListener(u.SELECT, this.selectEventListener);
50
+ const r = e, { collectionType: s, selectedPages: t } = r.detail;
51
+ this._updateBlock(s, t.join(","));
52
+ }, document.addEventListener(a.SELECT, this.selectEventListener);
80
53
  }
81
54
  _removeSelectEventListener() {
82
- this.selectEventListener && (document.removeEventListener(u.SELECT, this.selectEventListener), this.selectEventListener = null);
55
+ this.selectEventListener && (document.removeEventListener(a.SELECT, this.selectEventListener), this.selectEventListener = null);
83
56
  }
84
57
  _setupCancelEventListener() {
85
58
  this._removeCancelEventListener(), this.cancelEventListener = () => {
86
59
  this._handleCancel();
87
- }, document.addEventListener(u.CANCEL, this.cancelEventListener);
60
+ }, document.addEventListener(a.CANCEL, this.cancelEventListener);
88
61
  }
89
62
  _removeCancelEventListener() {
90
- this.cancelEventListener && (document.removeEventListener(u.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
63
+ this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
91
64
  }
92
65
  _handleCancel() {
93
66
  try {
94
67
  if (!this.currentNode)
95
68
  return;
96
- this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${k.EMPTY_CONTAINER}/>`).apply(new E("Removed unsubscribe block due to cancel"));
69
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${L.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
97
70
  } catch (e) {
98
71
  console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
99
72
  }
@@ -101,35 +74,35 @@ class x extends g {
101
74
  _removeEventListeners() {
102
75
  this._removeSelectEventListener(), this._removeCancelEventListener();
103
76
  }
104
- _updateBlock(e, t) {
77
+ _updateBlock(e, r) {
105
78
  if (!this.currentNode || !("querySelector" in this.currentNode))
106
79
  return;
107
- const r = this.currentNode.querySelector(p);
108
- if (!r)
80
+ const s = this.currentNode.querySelector(T);
81
+ if (!s)
109
82
  return;
110
- const s = this._getMergeTag(e);
111
- this.api.getDocumentModifier().modifyHtml(r).setAttribute("href", s).apply(new E(`Updated unsubscribe link to ${s}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, t).apply(new E("Updated unsubscribe block metadata"));
83
+ const t = this._getMergeTag(e);
84
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
112
85
  }
113
86
  _getMergeTag(e) {
114
- return N[e] ?? U;
87
+ return C[e] ?? B;
115
88
  }
116
89
  _openDrawer() {
117
90
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
118
91
  try {
119
- const e = a();
92
+ const e = c();
120
93
  e.typeSelectionDrawerStatus = !0;
121
94
  } catch (e) {
122
95
  console.error("[UnsubscribeBlock] Failed to open drawer:", e);
123
96
  }
124
97
  }
125
98
  _checkExistingBlocks() {
126
- const e = a();
127
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(B).forEach((r) => {
128
- if ("getAttribute" in r) {
129
- const s = r.getAttribute(o.PAGE_TYPE);
130
- if (s) {
131
- const l = Number(s);
132
- l === b.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === b.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
99
+ const e = c();
100
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
101
+ if ("getAttribute" in s) {
102
+ const t = s.getAttribute(o.PAGE_TYPE);
103
+ if (t) {
104
+ const l = Number(t);
105
+ l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
133
106
  }
134
107
  }
135
108
  });
@@ -137,26 +110,26 @@ class x extends g {
137
110
  async _loadBlockState(e) {
138
111
  if (!("getAttribute" in e))
139
112
  return;
140
- const t = e.getAttribute(o.PAGE_TYPE), r = e.getAttribute(o.PAGE_LIST);
141
- if (!t || !r)
113
+ const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
114
+ if (!r || !s)
142
115
  return;
143
- const s = a(), l = Number(t), m = h(r);
144
- await s.fetchTemplates(), s.setCollectionWithoutAutoSelection(l), s.loadSelectedTemplates(m);
116
+ const t = c(), l = Number(r), m = p(s);
117
+ await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
145
118
  }
146
119
  _resetStoreState() {
147
- a().$reset();
120
+ c().$reset();
148
121
  }
149
122
  _removeBlockTemplatesFromStore(e) {
150
123
  if (!("getAttribute" in e))
151
124
  return;
152
- const t = e.getAttribute(o.PAGE_LIST);
153
- if (!t)
125
+ const r = e.getAttribute(o.PAGE_LIST);
126
+ if (!r)
154
127
  return;
155
- const r = a(), s = h(t);
156
- r.removeUnsubscribePages(s);
128
+ const s = c(), t = p(r);
129
+ s.removeUnsubscribePages(t);
157
130
  }
158
131
  }
159
132
  export {
160
- T as UNSUBSCRIBE_BLOCK_ID,
161
- x as UnsubscribeBlock
133
+ g as UNSUBSCRIBE_BLOCK_ID,
134
+ I as UnsubscribeBlock
162
135
  };
@@ -1,22 +1,22 @@
1
- import { BlockType as s } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- const e = "unsubscribe", n = "{{ins-unsubscribe-link}}", t = `
3
- <${s.BLOCK_TEXT}
1
+ import { BlockType as e } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ const s = "unsubscribe", n = "{{ins-unsubscribe-link}}", t = `
3
+ <${e.BLOCK_TEXT}
4
4
  class="unsubscribe-block-v2 esd-block-unsubscribe es-p0"
5
5
  align="center"
6
6
  data-unsubscribe-page-type=""
7
7
  data-unsubscribe-page-list=""
8
8
  >
9
- <p>&nbsp;<strong><a
9
+ <p>You can <strong><a
10
10
  href="${n}"
11
11
  class="unsubscribe-link"
12
12
  target="_blank"
13
13
  data-unsubscribe-link="true"
14
- >${e}</a></strong></p>
15
- </${s.BLOCK_TEXT}>
14
+ >${s}</a></strong> from our emails, if you need to.</p>
15
+ </${e.BLOCK_TEXT}>
16
16
  `;
17
- function u() {
17
+ function r() {
18
18
  return t;
19
19
  }
20
20
  export {
21
- u as getDefaultTemplate
21
+ r as getDefaultTemplate
22
22
  };
@@ -7,5 +7,5 @@ export declare const useActionsApi: () => {
7
7
  getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
8
8
  updateTimerInClonedTemplate: () => Promise<string | null>;
9
9
  updateHtmlAndCss: (html: string, css: string) => void;
10
- editorSave: () => Promise<boolean>;
10
+ editorSave: () => Promise<void>;
11
11
  };
@@ -1,4 +1,5 @@
1
1
  import type { CompilationResult } from '@@/Types/html-compiler';
2
2
  export declare const useHtmlCompiler: () => {
3
3
  compileHtml: (html: string) => CompilationResult;
4
+ compileAmpHtml: (amp: string) => CompilationResult;
4
5
  };
@@ -1,11 +1,10 @@
1
- import type { ImmutableHtmlElementNode, ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
1
+ import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
2
2
  import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
3
3
  export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
4
4
  export declare class UnsubscribeBlock extends Block {
5
5
  private selectEventListener;
6
6
  private cancelEventListener;
7
7
  private currentNode?;
8
- private hadUnsubscribeLink;
9
8
  constructor();
10
9
  getId(): string;
11
10
  getIcon(): string;
@@ -14,11 +13,8 @@ export declare class UnsubscribeBlock extends Block {
14
13
  getDescription(): string;
15
14
  getTemplate(): string;
16
15
  onSelect(node: ImmutableHtmlElementNode): void;
17
- onDocumentChanged(node: ImmutableHtmlNode): void;
18
16
  onDelete(node: ImmutableHtmlElementNode): void;
19
17
  onDestroy(): void;
20
- private _hasUnsubscribeLink;
21
- private _warnLinkRemoved;
22
18
  private _setupSelectEventListener;
23
19
  private _removeSelectEventListener;
24
20
  private _setupCancelEventListener;
@@ -1,101 +1,93 @@
1
- import { useActionsApi as C } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { useActionsApi as P } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as D } from "../composables/useHtmlCompiler.js";
3
+ import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as i } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
9
- function E(i, o) {
10
- const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
11
- return t.forEach((r) => {
12
- const a = r.getAttribute(S.PAGE_LIST);
13
- a && c.push(...D(a));
14
- }), o.filter((r) => c.includes(r));
5
+ import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as E } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as H } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as U } from "../stores/unsubscribe.js";
9
+ function F(a, t) {
10
+ const c = new DOMParser().parseFromString(a, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), r = [];
11
+ return c.forEach((o) => {
12
+ const n = o.getAttribute(y.PAGE_LIST);
13
+ n && r.push(...E(n));
14
+ }), t.filter((o) => r.includes(o));
15
15
  }
16
- async function U(i) {
17
- const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
16
+ function x(a) {
17
+ const m = new DOMParser().parseFromString(a, "text/html").querySelectorAll(".recommendation-block-v2");
18
18
  if (m.length === 0)
19
19
  return;
20
- const l = b();
21
- m.forEach((t) => {
22
- var g, f, u, n, y;
23
- const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
24
- if (!Number.isFinite(r))
20
+ const p = b();
21
+ m.forEach((c) => {
22
+ var l, g, f, u, s;
23
+ const r = c.getAttribute("recommendation-id"), o = r ? Number(r) : NaN;
24
+ if (!Number.isFinite(o))
25
25
  return;
26
- const a = t.getAttribute("esd-ext-config");
27
- if (!a)
26
+ const n = c.getAttribute("esd-ext-config");
27
+ if (!n)
28
28
  return;
29
29
  let e;
30
30
  try {
31
- e = JSON.parse(a);
31
+ e = JSON.parse(n);
32
32
  } catch {
33
33
  return;
34
34
  }
35
35
  if (!e || typeof e != "object" || Array.isArray(e))
36
36
  return;
37
- const p = {
38
- strategy: e.strategy ?? s.strategy,
39
- language: e.language ?? s.language,
40
- size: e.size ?? s.size,
37
+ const S = {
38
+ strategy: e.strategy ?? i.strategy,
39
+ language: e.language ?? i.language,
40
+ size: e.size ?? i.size,
41
41
  // Spread the default arrays so each block gets a fresh reference
42
42
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...s.productIds],
44
- filters: e.filters ?? [...s.filters],
45
- shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
46
- currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
47
- currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
48
- currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
49
- currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
50
- currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
43
+ productIds: e.productIds ?? [...i.productIds],
44
+ filters: e.filters ?? [...i.filters],
45
+ shuffleProducts: e.shuffleProducts ?? i.shuffleProducts,
46
+ currencyCode: ((l = e.currency) == null ? void 0 : l.code) ?? d.code,
47
+ currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? d.alignment,
48
+ currencyDecimalCount: ((f = e.currency) == null ? void 0 : f.decimalCount) ?? d.decimalCount,
49
+ currencyDecimalSeparator: ((u = e.currency) == null ? void 0 : u.decimalSeparator) ?? d.decimalSeparator,
50
+ currencyThousandSeparator: ((s = e.currency) == null ? void 0 : s.thousandSeparator) ?? d.thousandSeparator
51
51
  };
52
- l.seedBlockUrlConfig(r, p);
52
+ p.seedBlockUrlConfig(o, S);
53
53
  });
54
- try {
55
- await l.fetchRecommendationCreateData();
56
- } catch (t) {
57
- console.warn(
58
- "Recommendation reference data pre-load failed; validator will skip the availability check.",
59
- t
60
- );
61
- }
62
54
  }
63
- const _ = () => {
64
- const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
55
+ const M = () => {
56
+ const a = H(), t = U(), { getCompiledEmail: m, getTemplateData: p } = P(), { compileHtml: c, compileAmpHtml: r } = D();
65
57
  return {
66
58
  prepareTemplateDetails: async () => {
67
- const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
59
+ const { html: n, ampHtml: e = "", ampErrors: S = [] } = await m({
68
60
  minimize: !0,
69
61
  resetDataSavedFlag: !1
70
- }), { html: p, css: g, syncModulesIds: f = [] } = await l();
71
- o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
72
- const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
62
+ }), { html: l, css: g, syncModulesIds: f = [] } = await p();
63
+ t.selectedUnsubscribePages.length && await t.fetchTemplates(), x(l);
64
+ const { compiledHtml: u, stats: s, appliedRules: A } = c(n), h = e && r(e).compiledHtml, C = a.getSelectedDynamicContentList, T = b();
73
65
  return console.debug("HTML Compilation Stats:", {
74
- originalSize: n.originalSize,
75
- compiledSize: n.compiledSize,
76
- reduction: `${n.reductionPercentage.toFixed(2)}%`,
77
- appliedRules: y,
78
- executionTime: `${n.executionTime.toFixed(2)}ms`
66
+ originalSize: s.originalSize,
67
+ compiledSize: s.compiledSize,
68
+ reduction: `${s.reductionPercentage.toFixed(2)}%`,
69
+ appliedRules: A,
70
+ executionTime: `${s.executionTime.toFixed(2)}ms`
79
71
  }), {
80
- dynamicContentList: h,
72
+ dynamicContentList: C,
81
73
  compiledHtml: u,
82
- rawHtml: p,
74
+ rawHtml: l,
83
75
  css: g,
84
- ampHtml: a,
85
- ampErrors: e,
76
+ ampHtml: h,
77
+ ampErrors: S,
86
78
  modules: f.map(Number),
87
79
  recommendation: {
88
- campaignUrls: A.recommendationCampaignUrls,
80
+ campaignUrls: T.recommendationCampaignUrls,
89
81
  configs: {}
90
82
  },
91
83
  unsubscribe: {
92
- status: o.unsubscribePagesStatus,
93
- config: E(u, o.selectedUnsubscribePages)
84
+ status: t.unsubscribePagesStatus,
85
+ config: F(u, t.selectedUnsubscribePages)
94
86
  }
95
87
  };
96
88
  }
97
89
  };
98
90
  };
99
91
  export {
100
- _ as useTemplatePreparation
92
+ M as useTemplatePreparation
101
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.4.1-beta.c04b4e7",
3
+ "version": "3.4.1-beta.ce8d9b0",
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",