@useinsider/guido 3.24.0-beta.e71f772 → 3.24.0-beta.f838378

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.
Files changed (34) hide show
  1. package/README.md +6 -1
  2. package/dist/components/Guido.vue.js +3 -3
  3. package/dist/components/Guido.vue2.js +55 -56
  4. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +2 -2
  5. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +3 -3
  6. package/dist/composables/useActionsApi.js +2 -2
  7. package/dist/composables/useBlocksConfig.js +20 -22
  8. package/dist/composables/useDisplayConditions.js +7 -8
  9. package/dist/composables/useEditorTrackingIds.js +49 -0
  10. package/dist/composables/useHtmlCompiler.js +2 -0
  11. package/dist/composables/useStripo.js +70 -70
  12. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  13. package/dist/extensions/DisplayConditions/control.js +17 -19
  14. package/dist/extensions/DisplayConditions/display-conditions.css.js +2 -2
  15. package/dist/guido.css +1 -1
  16. package/dist/package.json.js +2 -2
  17. package/dist/services/templateLibraryApi.js +39 -36
  18. package/dist/src/@types/display-condition.d.ts +1 -0
  19. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  20. package/dist/src/composables/useStripo.d.ts +1 -1
  21. package/dist/src/extensions/DisplayConditions/control.d.ts +0 -1
  22. package/dist/src/stores/display-condition.d.ts +2 -0
  23. package/dist/src/utils/linkTrackingIds.d.ts +24 -22
  24. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  25. package/dist/static/styles/variables.css.js +1 -0
  26. package/dist/utils/displayCondition.js +19 -16
  27. package/dist/utils/linkTrackingIds.js +72 -72
  28. package/dist/utils/templatePreparation.js +59 -72
  29. package/dist/utils/trimHrefWhitespace.js +10 -0
  30. package/package.json +1 -1
  31. package/dist/extensions/LinkTracking/extension.js +0 -17
  32. package/dist/extensions/LinkTracking/writer.js +0 -41
  33. package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
  34. package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
@@ -10,13 +10,6 @@ export interface TrackingIdResult {
10
10
  changed: boolean;
11
11
  nextSeq: number;
12
12
  }
13
- export interface TrackingIdPlan {
14
- /** Anchor index in document order → id to write. Anchors keeping their id are absent. */
15
- assignments: Map<number, number>;
16
- nextSeq: number;
17
- seqChanged: boolean;
18
- changed: boolean;
19
- }
20
13
  /**
21
14
  * Reads the persisted id high-water mark: <body> attr, then <html> attr,
22
15
  * then the leading comment fallback. Returns 0 when absent.
@@ -27,21 +20,30 @@ export declare function readTrackSeq(html: string): number;
27
20
  * Scans the document because a rewrite can strip the seq host but keep the ids.
28
21
  */
29
22
  export declare function readTrackFloor(html: string, persistedCounter?: number): number;
23
+ export interface TrackingIdPlan {
24
+ /** Final id per anchor, in the order the raw values were given. */
25
+ ids: number[];
26
+ reassigned: boolean[];
27
+ nextSeq: number;
28
+ seqChanged: boolean;
29
+ changed: boolean;
30
+ }
30
31
  /**
31
- * Mints ids above max(persisted seq, max id seen, floor) so a deleted id is never reused;
32
- * invalid or duplicate values are reassigned, the first duplicate in document order keeps its id.
32
+ * The id rule shared by the string transform and the editor-model writer: `rawIds` are the
33
+ * anchors' current `data-ins-track-id` values in document order ('' when absent).
34
+ */
35
+ export declare function planTrackingIds(rawIds: readonly string[], persistedSeq: number, floor?: number): TrackingIdPlan;
36
+ /** Reads a `data-ins-track-seq` attribute value the way readTrackSeq reads it from HTML. */
37
+ export declare function parseTrackSeq(value: string | null): number;
38
+ /** The `data-ins-track-id` value of every `<a>` opening tag in `html`, in order ('' when absent). */
39
+ export declare function readAnchorTrackIds(html: string): string[];
40
+ /** Writes `ids[i]` onto the i-th `<a>` opening tag of `html`; `null` or a missing entry leaves it untouched. */
41
+ export declare function writeAnchorTrackIds(html: string, ids: readonly (number | null)[]): string;
42
+ /**
43
+ * Ensures every <a> opening tag carries a unique positive-integer id and the
44
+ * document records the id high-water mark. Ids are minted above
45
+ * max(persisted seq, max id in document, floor) so deleted ids are never
46
+ * reused — even after a version restore or paste-over (floor = session floor).
47
+ * Idempotent: a document already normalized returns changed=false.
33
48
  */
34
- export declare function planTrackingIds(rawIds: (string | null)[], persistedSeq: number, floor?: number): TrackingIdPlan;
35
- export interface DocumentTrackingIdPlan {
36
- /** data-ins-track-id per anchor in document order; '' when absent. */
37
- anchorIds: string[];
38
- /** Per anchor: inside an HTML comment (e.g. Stripo's `<!--[if mso]>` button copy), absent from the node tree. */
39
- inComment: boolean[];
40
- plan: TrackingIdPlan;
41
- }
42
- /** Plans the ids for an HTML document without rewriting it. */
43
- export declare function planDocumentTrackingIds(html: string, floor?: number): DocumentTrackingIdPlan;
44
- /** Writes a plan into the HTML string: anchor ids by document order, then the seq host. */
45
- export declare function renderTrackingIdPlan(html: string, { plan }: DocumentTrackingIdPlan): string;
46
- /** Gives every <a> a unique positive-integer id and records the high-water mark; idempotent. */
47
49
  export declare function assignTrackingIds(html: string, floor?: number): TrackingIdResult;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Browsers ignore whitespace around an href, but the send-time link rewrite does not:
3
+ * a trailing space ends up inside the path and a leading one skips the tracking params.
4
+ */
5
+ export declare function trimHrefWhitespace(html: string): string;
@@ -12,6 +12,7 @@ const o = `:host {
12
12
  --guido-color-gray-100: #F5F5F5;
13
13
  --guido-color-gray-1: #F0F0F0;
14
14
  --guido-color-gray-0: #F9F9F9;
15
+ --guido-color-neutral-900: #0A0F19;
15
16
  --guido-color-neutral-800: #222938;
16
17
  --guido-color-neutral-700: #2C3546;
17
18
  --guido-color-neutral-500: #5D6980;
@@ -1,26 +1,29 @@
1
1
  import { DisplayConditionSourceType as n } from "../enums/display-condition.js";
2
- const m = (e) => {
2
+ const p = "PREDEFINED", I = (e) => {
3
3
  if (!e)
4
4
  return null;
5
+ if (e.type === p)
6
+ return n.SAVED;
5
7
  try {
6
- return JSON.parse(e.extraData ?? "{}").source === n.INLINE ? n.INLINE : n.SAVED;
8
+ const t = JSON.parse(e.extraData || "{}");
9
+ return (t == null ? void 0 : t.source) === n.SAVED ? n.SAVED : n.INLINE;
7
10
  } catch {
8
- return n.SAVED;
11
+ return n.INLINE;
9
12
  }
10
- }, I = (e) => !e || !(e.name || e.beforeScript || e.afterScript) ? null : { ...e, description: e.description ?? "" };
11
- let c = 0;
12
- const C = () => (c = Math.max(Date.now(), c + 1), c), p = /{%-?\s*(\w+)[\s\S]*?-?%}/g, S = /{%[\s\S]*?%}|{{[\s\S]*?}}/g, u = /{%-?\s*(comment|raw)\s*-?%}[\s\S]*?{%-?\s*end\1\s*-?%}/g, A = /{#[\s\S]*?#}/g, d = /* @__PURE__ */ new Set(["if", "unless", "for", "case", "capture", "tablerow", "comment"]), T = /* @__PURE__ */ new Set(["else", "elsif", "elif", "when"]), h = (e) => /{%|%}|{{|}}/.test(e.replace(S, "")), D = (e, a, f = "liquid") => {
13
- const t = /* @__PURE__ */ new Set(), r = [];
14
- return [["codeBefore", e], ["codeAfter", a]].forEach(([o, l]) => {
15
- const i = (f === "pongo" ? l.replace(A, "") : l).replace(u, "");
16
- h(i) && t.add(o), Array.from(i.matchAll(p), (s) => s[1]).forEach((s) => {
17
- d.has(s) ? r.push(s) : s.startsWith("end") && d.has(s.slice(3)) ? r.pop() !== s.slice(3) && t.add(o) : T.has(s) && !r.length && t.add(o);
13
+ }, m = (e) => !e || !(e.name || e.beforeScript || e.afterScript) ? null : { ...e, description: e.description ?? "" };
14
+ let l = 0;
15
+ const _ = () => (l = Math.max(Date.now(), l + 1), l), E = /{%-?\s*(\w+)[\s\S]*?-?%}/g, S = /{%[\s\S]*?%}|{{[\s\S]*?}}/g, u = /{%-?\s*(comment|raw)\s*-?%}[\s\S]*?{%-?\s*end\1\s*-?%}/g, A = /{#[\s\S]*?#}/g, f = /* @__PURE__ */ new Set(["if", "unless", "for", "case", "capture", "tablerow", "comment"]), T = /* @__PURE__ */ new Set(["else", "elsif", "elif", "when"]), h = (e) => /{%|{{/.test(e.replace(S, "")), C = (e, t, d = "liquid") => {
16
+ const r = /* @__PURE__ */ new Set(), o = [];
17
+ return [["codeBefore", e], ["codeAfter", t]].forEach(([c, a]) => {
18
+ const i = (d === "pongo" ? a.replace(A, "") : a).replace(u, "");
19
+ h(i) && r.add(c), Array.from(i.matchAll(E), (s) => s[1]).forEach((s) => {
20
+ f.has(s) ? o.push(s) : s.startsWith("end") && f.has(s.slice(3)) ? o.pop() !== s.slice(3) && r.add(c) : T.has(s) && !o.length && r.add(c);
18
21
  });
19
- }), r.length && t.add("codeAfter"), [...t];
22
+ }), o.length && r.add("codeAfter"), [...r];
20
23
  };
21
24
  export {
22
- D as findInvalidCodeFields,
23
- C as nextConditionId,
24
- m as parseSource,
25
- I as toAppliedCondition
25
+ C as findInvalidCodeFields,
26
+ _ as nextConditionId,
27
+ I as parseSource,
28
+ m as toAppliedCondition
26
29
  };
@@ -1,90 +1,90 @@
1
- const A = "data-ins-track-id", E = "data-ins-track-seq", g = `(?:[^>"']|"[^"]*"|'[^']*')*`, R = new RegExp(`<a\\b${g}>`, "gi"), _ = new RegExp(`<body\\b${g}>`, "i"), l = new RegExp(`<html\\b${g}>`, "i"), m = new RegExp(`\\b${A}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", d = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), I = /^[1-9][0-9]{0,14}$/, S = 999999999999999;
2
- function $(e) {
3
- const t = m.exec(e), n = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
4
- return { attrMatch: t, rawValue: n };
1
+ const l = "data-ins-track-id", E = "data-ins-track-seq", A = `(?:[^>"']|"[^"]*"|'[^']*')*`, k = new RegExp(`<a\\b${A}>`, "gi"), R = new RegExp(`<body\\b${A}>`, "i"), _ = new RegExp(`<html\\b${A}>`, "i"), m = new RegExp(`\\b${l}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", x = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), $ = /^[1-9][0-9]{0,14}$/, q = 999999999999999;
2
+ function I(e) {
3
+ const c = Number(e);
4
+ return Number.isSafeInteger(c) && c > 0 ? c : 0;
5
5
  }
6
- function k(e) {
7
- const t = Number(e);
8
- return Number.isSafeInteger(t) && t > 0 ? t : 0;
6
+ function T(e) {
7
+ return [...e.matchAll(k)].map((c) => {
8
+ const [n] = c, t = m.exec(n), r = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
9
+ return { index: c.index, tag: n, attrMatch: t, rawValue: r };
10
+ });
9
11
  }
10
- function N(e) {
11
- var s;
12
- const t = (o) => {
13
- var r;
14
- const a = (r = o.exec(e)) == null ? void 0 : r[0];
15
- return a ? f.exec(a) : null;
16
- }, n = t(_) ?? t(l), c = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((s = d.exec(e)) == null ? void 0 : s[1]) ?? "";
17
- return k(c);
12
+ function b(e) {
13
+ var r;
14
+ const c = (s) => {
15
+ var a;
16
+ const o = (a = s.exec(e)) == null ? void 0 : a[0];
17
+ return o ? f.exec(o) : null;
18
+ }, n = c(R) ?? c(_), t = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((r = x.exec(e)) == null ? void 0 : r[1]) ?? "";
19
+ return I(t);
18
20
  }
19
- function K(e, t = 0) {
21
+ function h(e, c = 0) {
20
22
  let n = 0;
21
- [...e.matchAll(R)].forEach(([s]) => {
22
- const { rawValue: o } = $(s);
23
- I.test(o) && (n = Math.max(n, Number(o)));
23
+ T(e).forEach(({ rawValue: r }) => {
24
+ $.test(r) && (n = Math.max(n, Number(r)));
24
25
  });
25
- const c = Number.isSafeInteger(t) && t > 0 ? t : 0;
26
- return Math.max(N(e), n, c);
26
+ const t = Number.isSafeInteger(c) && c > 0 ? c : 0;
27
+ return Math.max(b(e), n, t);
27
28
  }
28
- function M(e, t) {
29
- const n = `${E}="${t}"`, c = _.exec(e) ?? l.exec(e);
30
- if (c) {
31
- const [o] = c, a = f.exec(o), r = a ? o.replace(a[0], n) : o.replace(/\/?>$/, (i) => ` ${n}${i}`);
32
- return e.slice(0, c.index) + r + e.slice(c.index + o.length);
29
+ function w(e, c) {
30
+ const n = `${E}="${c}"`, t = R.exec(e) ?? _.exec(e);
31
+ if (t) {
32
+ const [s] = t, o = f.exec(s), a = o ? s.replace(o[0], n) : s.replace(/\/?>$/, (u) => ` ${n}${u}`);
33
+ return e.slice(0, t.index) + a + e.slice(t.index + s.length);
33
34
  }
34
- const s = `<!--${p}:${t}-->`;
35
- return d.test(e) ? e.replace(d, s) : `${s}${e}`;
35
+ const r = `<!--${p}:${c}-->`;
36
+ return x.test(e) ? e.replace(x, r) : `${r}${e}`;
36
37
  }
37
- function q(e, t, n) {
38
- const c = `${A}="${n}"`;
39
- return t ? e.replace(t[0], c) : e.replace(/^<a\b/i, (s) => `${s} ${c}`);
38
+ function M(e, c, n) {
39
+ const t = `${l}="${n}"`;
40
+ return c ? e.replace(c[0], t) : e.replace(/^<a\b/i, (r) => `${r} ${t}`);
40
41
  }
41
- function w(e, t, n = 0) {
42
- const c = /* @__PURE__ */ new Set();
43
- let s = 0;
44
- const o = e.map((u) => {
45
- if (u !== null && I.test(u) && !c.has(Number(u))) {
46
- const T = Number(u);
47
- return c.add(T), s = Math.max(s, T), T;
48
- }
49
- return null;
50
- }), a = Number.isSafeInteger(n) && n > 0 && n < S ? n : 0;
51
- let r = Math.max(t, s, a);
52
- const i = /* @__PURE__ */ new Map();
53
- o.forEach((u, T) => {
54
- u === null && (r += 1, i.set(T, r));
55
- });
56
- const x = r > 0 && t !== r;
57
- return { assignments: i, nextSeq: r, seqChanged: x, changed: i.size > 0 || x };
42
+ function C(e, c, n = 0) {
43
+ const t = /* @__PURE__ */ new Set();
44
+ let r = 0;
45
+ const s = e.map((i) => {
46
+ if (!$.test(i) || t.has(Number(i)))
47
+ return null;
48
+ const d = Number(i);
49
+ return t.add(d), r = Math.max(r, d), d;
50
+ }), o = Number.isSafeInteger(n) && n > 0 && n < q ? n : 0;
51
+ let a = Math.max(c, r, o);
52
+ const u = s.map((i) => i === null), S = s.map((i) => i !== null ? i : (a += 1, a)), g = a > 0 && c !== a;
53
+ return { ids: S, reassigned: u, nextSeq: a, seqChanged: g, changed: g || u.includes(!0) };
58
54
  }
59
- function b(e) {
60
- return [...e.matchAll(R)].map((t) => {
61
- const [n] = t;
62
- return { index: t.index, tag: n, ...$(n) };
63
- });
55
+ function D(e) {
56
+ return e !== null && /^\d+$/.test(e) ? I(e) : 0;
57
+ }
58
+ function N(e, c, n) {
59
+ let t = "", r = 0;
60
+ return c.forEach((s, o) => {
61
+ const a = n[o] ?? null;
62
+ t += e.slice(r, s.index), t += a === null ? s.tag : M(s.tag, s.attrMatch, a), r = s.index + s.tag.length;
63
+ }), t + e.slice(r);
64
64
  }
65
- const C = /<!--[\s\S]*?-->/g;
66
- function P(e, t = 0) {
67
- const n = b(e), c = n.map((a) => a.rawValue), s = [...e.matchAll(C)].map((a) => [a.index, a.index + a[0].length]), o = n.map(({ index: a }) => s.some(([r, i]) => a > r && a < i));
68
- return { anchorIds: c, inComment: o, plan: w(c, N(e), t) };
65
+ function P(e) {
66
+ return T(e).map((c) => c.rawValue);
69
67
  }
70
- function D(e, { plan: t }) {
71
- let n = "", c = 0;
72
- return b(e).forEach((s, o) => {
73
- const a = t.assignments.get(o);
74
- n += e.slice(c, s.index), n += a === void 0 ? s.tag : q(s.tag, s.attrMatch, a), c = s.index + s.tag.length;
75
- }), n += e.slice(c), t.seqChanged ? M(n, t.nextSeq) : n;
68
+ function K(e, c) {
69
+ return N(e, T(e), c);
76
70
  }
77
- function O(e, t = 0) {
78
- const n = P(e, t), { changed: c, nextSeq: s } = n.plan;
79
- return { html: c ? D(e, n) : e, changed: c, nextSeq: s };
71
+ function O(e, c = 0) {
72
+ const n = T(e), t = C(n.map((s) => s.rawValue), b(e), c);
73
+ let r = N(
74
+ e,
75
+ n,
76
+ t.ids.map((s, o) => t.reassigned[o] ? s : null)
77
+ );
78
+ return t.seqChanged && (r = w(r, t.nextSeq)), { html: r, changed: t.changed, nextSeq: t.nextSeq };
80
79
  }
81
80
  export {
82
- A as TRACK_ID_ATTRIBUTE,
81
+ l as TRACK_ID_ATTRIBUTE,
83
82
  E as TRACK_SEQ_ATTRIBUTE,
84
83
  O as assignTrackingIds,
85
- P as planDocumentTrackingIds,
86
- w as planTrackingIds,
87
- K as readTrackFloor,
88
- N as readTrackSeq,
89
- D as renderTrackingIdPlan
84
+ D as parseTrackSeq,
85
+ C as planTrackingIds,
86
+ P as readAnchorTrackIds,
87
+ h as readTrackFloor,
88
+ b as readTrackSeq,
89
+ K as writeAnchorTrackIds
90
90
  };
@@ -1,45 +1,44 @@
1
- import { useActionsApi as E } from "../composables/useActionsApi.js";
2
- import { useConfig as R } from "../composables/useConfig.js";
3
- import { useHtmlCompiler as U } from "../composables/useHtmlCompiler.js";
4
- import { useRecommendationExtensionStore as k } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { toBlockUrlConfig as L } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
- import { DATA_ATTRIBUTES as b } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
- import { parsePageList as v } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
- import { writeTrackingIdsInPlace as N } from "../extensions/LinkTracking/writer.js";
9
- import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
10
- import { useEditorStore as q } from "../stores/editor.js";
11
- import { useUnsubscribeStore as M } from "../stores/unsubscribe.js";
12
- import { isPlainObject as O } from "./genericUtil.js";
13
- import { planDocumentTrackingIds as T, renderTrackingIdPlan as B } from "./linkTrackingIds.js";
14
- function _(c) {
15
- const i = new DOMParser().parseFromString(c, "text/html").querySelectorAll(`[${b.PAGE_LIST}]`), e = [];
16
- return i.forEach((s) => {
17
- const o = s.getAttribute(b.PAGE_LIST);
18
- o && e.push(...v(o));
1
+ import { useActionsApi as x } from "../composables/useActionsApi.js";
2
+ import { useConfig as D } from "../composables/useConfig.js";
3
+ import { useEditorTrackingIds as F } from "../composables/useEditorTrackingIds.js";
4
+ import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
5
+ import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
+ import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
7
+ import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
+ import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
+ import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
10
+ import { useEditorStore as N } from "../stores/editor.js";
11
+ import { useUnsubscribeStore as z } from "../stores/unsubscribe.js";
12
+ import { isPlainObject as v } from "./genericUtil.js";
13
+ function M(n) {
14
+ const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
15
+ return r.forEach((i) => {
16
+ const t = i.getAttribute(g.PAGE_LIST);
17
+ t && e.push(...U(t));
19
18
  }), [...new Set(e)];
20
19
  }
21
- async function w(c) {
22
- const a = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
23
- if (a.length === 0)
20
+ async function S(n) {
21
+ const o = new DOMParser().parseFromString(n, "text/html").querySelectorAll(".recommendation-block-v2");
22
+ if (o.length === 0)
24
23
  return;
25
- const i = k();
26
- a.forEach((e) => {
27
- const s = e.getAttribute("recommendation-id"), o = s ? Number(s) : NaN;
28
- if (!Number.isFinite(o))
24
+ const r = b();
25
+ o.forEach((e) => {
26
+ const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
27
+ if (!Number.isFinite(t))
29
28
  return;
30
- const l = e.getAttribute("esd-ext-config");
31
- if (!l)
29
+ const c = e.getAttribute("esd-ext-config");
30
+ if (!c)
32
31
  return;
33
- let m;
32
+ let a;
34
33
  try {
35
- m = JSON.parse(l);
34
+ a = JSON.parse(c);
36
35
  } catch {
37
36
  return;
38
37
  }
39
- O(m) && i.seedBlockUrlConfig(o, L(m));
38
+ v(a) && r.seedBlockUrlConfig(t, R(a));
40
39
  });
41
40
  try {
42
- await i.fetchRecommendationCreateData();
41
+ await r.fetchRecommendationCreateData();
43
42
  } catch (e) {
44
43
  console.warn(
45
44
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -47,63 +46,51 @@ async function w(c) {
47
46
  );
48
47
  }
49
48
  }
50
- const oe = () => {
51
- const c = z(), n = q(), a = M(), { getCompiledEmail: i, getTemplateData: e, updateHtmlAndCss: s } = E(), { compileHtml: o, compileAmpHtml: l } = U(), { isFeatureEnabled: m } = R();
49
+ const Y = () => {
50
+ const n = L(), s = N(), o = z(), { getCompiledEmail: r, getTemplateData: e } = x(), { writeTrackingIds: i } = F(), { compileHtml: t, compileAmpHtml: c } = I(), { isFeatureEnabled: a } = D();
52
51
  return {
53
- prepareTemplateDetails: async (y) => {
54
- let { html: r, css: u, syncModulesIds: g = [] } = y ?? await e();
55
- if (m("linkTrackingIds"))
56
- try {
57
- let t = T(r, n.trackIdSessionFloor);
58
- n.trackIdSessionFloor = t.plan.nextSeq;
59
- let p = t.plan.changed;
60
- if (p && N(t)) {
61
- const h = await e().catch((x) => (console.warn(
62
- "Tracking-id re-read failed, saving the planned ids without a replacement:",
63
- x
64
- ), null));
65
- h ? ({ html: r, css: u, syncModulesIds: g = [] } = h, t = T(r, n.trackIdSessionFloor), n.trackIdSessionFloor = t.plan.nextSeq, p = t.plan.changed) : p = !1;
66
- }
67
- t.plan.changed && (r = B(r, t)), p && await s(r, u);
68
- } catch (t) {
69
- console.error("Tracking-id step failed, saving anyway:", t);
70
- }
71
- const { html: A, ampHtml: f = "", ampErrors: P = [] } = await i({
52
+ prepareTemplateDetails: async (h) => {
53
+ let { html: m, css: p, syncModulesIds: u = [] } = h ?? await e();
54
+ if (a("linkTrackingIds")) {
55
+ const { changed: P, nextSeq: E } = i(s.trackIdSessionFloor);
56
+ s.trackIdSessionFloor = E, P && ({ html: m, css: p, syncModulesIds: u = [] } = await e());
57
+ }
58
+ const { html: T, ampHtml: d = "", ampErrors: w = [] } = await r({
72
59
  minimize: !0,
73
60
  resetDataSavedFlag: !1
74
61
  });
75
- a.selectedUnsubscribePages.length && await a.fetchTemplates(), await w(r);
76
- const { compiledHtml: C, stats: d, appliedRules: I } = o(A), H = f && l(f).compiledHtml, D = c.getSelectedDynamicContentList, F = k(), S = _(r);
62
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(m);
63
+ const { compiledHtml: A, stats: l, appliedRules: y } = t(T), C = d && c(d).compiledHtml, k = n.getSelectedDynamicContentList, H = b(), f = M(m);
77
64
  return console.debug("HTML Compilation Stats:", {
78
- originalSize: d.originalSize,
79
- compiledSize: d.compiledSize,
80
- reduction: `${d.reductionPercentage.toFixed(2)}%`,
81
- appliedRules: I,
82
- executionTime: `${d.executionTime.toFixed(2)}ms`
65
+ originalSize: l.originalSize,
66
+ compiledSize: l.compiledSize,
67
+ reduction: `${l.reductionPercentage.toFixed(2)}%`,
68
+ appliedRules: y,
69
+ executionTime: `${l.executionTime.toFixed(2)}ms`
83
70
  }), {
84
- dynamicContentList: D,
85
- compiledHtml: C,
86
- rawHtml: r,
87
- css: u,
88
- ampHtml: H,
89
- ampErrors: P,
90
- modules: g.map(Number),
71
+ dynamicContentList: k,
72
+ compiledHtml: A,
73
+ rawHtml: m,
74
+ css: p,
75
+ ampHtml: C,
76
+ ampErrors: w,
77
+ modules: u.map(Number),
91
78
  recommendation: {
92
- campaignUrls: F.recommendationCampaignUrls,
79
+ campaignUrls: H.recommendationCampaignUrls,
93
80
  configs: {}
94
81
  },
95
82
  unsubscribe: {
96
- status: S.length > 0,
97
- config: S
83
+ status: f.length > 0,
84
+ config: f
98
85
  }
99
86
  };
100
87
  },
101
88
  // Exposed so the back/test validate-only path can seed the reco store the
102
89
  // same way a full save does (required-field findings depend on it).
103
- hydrateRecommendationStore: w
90
+ hydrateRecommendationStore: S
104
91
  };
105
92
  };
106
93
  export {
107
- _ as getHtmlReferencedUnsubscribePages,
108
- oe as useTemplatePreparation
94
+ M as getHtmlReferencedUnsubscribePages,
95
+ Y as useTemplatePreparation
109
96
  };
@@ -0,0 +1,10 @@
1
+ const E = /(<[a-z][\w:-]*(?:\s[^>]*?)?\shref\s*=\s*)(["'])([\s\S]*?)\2/gi, c = /^(?:\s|&nbsp;|&#160;|&#xa0;)+|(?:\s|&nbsp;|&#160;|&#xa0;)+$/gi;
2
+ function a(e) {
3
+ return !e || !/href/i.test(e) ? e : e.replace(E, (i, s, r, n) => {
4
+ const t = n.replace(c, "");
5
+ return `${s}${r}${t}${r}`;
6
+ });
7
+ }
8
+ export {
9
+ a as trimHrefWhitespace
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.24.0-beta.e71f772",
3
+ "version": "3.24.0-beta.f838378",
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",
@@ -1,17 +0,0 @@
1
- import { ExtensionBuilder as r, Control as t } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { registerTrackingIdWriter as i } from "./writer.js";
3
- class e extends t {
4
- constructor() {
5
- super(), i(() => this.api);
6
- }
7
- getId() {
8
- return "guidoLinkTrackingWriter";
9
- }
10
- getTemplate() {
11
- return "<div></div>";
12
- }
13
- }
14
- const a = new r().addControl(e).build();
15
- export {
16
- a as default
17
- };
@@ -1,41 +0,0 @@
1
- import { TRACK_ID_ATTRIBUTE as h, TRACK_SEQ_ATTRIBUTE as I } from "../../utils/linkTrackingIds.js";
2
- import { ModificationDescription as k } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
- let s = null;
4
- const q = (e) => {
5
- s = e;
6
- }, C = () => {
7
- s = null;
8
- };
9
- function w(e) {
10
- return "getTagName" in e && e.getTagName().toLowerCase() === "a";
11
- }
12
- const T = (e, r) => (w(e) && r.push(e), e.children().forEach((i) => T(i, r)), r), E = ({ anchorIds: e, inComment: r, plan: i }) => {
13
- const g = s == null ? void 0 : s();
14
- if (!g)
15
- return !1;
16
- try {
17
- const c = g.getDocumentRootHtmlNode(), f = T(c, []), l = f.map((t) => t.getAttribute(h) ?? ""), o = /* @__PURE__ */ new Map();
18
- e.forEach((t, n) => {
19
- r[n] || o.set(n, o.size);
20
- });
21
- const d = e.filter((t, n) => o.has(n)), p = l.length === d.length && l.every((t, n) => t === d[n]), u = [...i.assignments.keys()].some((t) => !o.has(t)), a = i.seqChanged ? c.querySelector("body") : void 0;
22
- if (!p || u || i.seqChanged && !a)
23
- return console.debug(
24
- "In-place tracking-id write skipped, replacing the document instead:",
25
- `live [${l.join(",")}] planned [${d.join(",")}]`,
26
- `commentWrite ${String(u)} seqHost ${String(!!a)}`
27
- ), !1;
28
- const m = g.getDocumentModifier();
29
- return i.assignments.forEach((t, n) => {
30
- const A = f[o.get(n)];
31
- m.modifyHtml(A).setAttribute(h, String(t));
32
- }), a && m.modifyHtml(a).setAttribute(I, String(i.nextSeq)), m.apply(new k("Assign link tracking ids").asHidden()), !0;
33
- } catch (c) {
34
- return console.warn("In-place tracking-id write failed, replacing the document instead:", c), !1;
35
- }
36
- };
37
- export {
38
- C as disposeTrackingIdWriter,
39
- q as registerTrackingIdWriter,
40
- E as writeTrackingIdsInPlace
41
- };
@@ -1,2 +0,0 @@
1
- declare const _default: import("@stripoinc/ui-editor-extensions").Extension;
2
- export default _default;
@@ -1,13 +0,0 @@
1
- import type { DocumentTrackingIdPlan } from '@@/Utils/linkTrackingIds';
2
- import type { CssNodeModifier, HtmlNodeModifier, ImmutableHtmlNode, TemplateModifier } from '@stripoinc/ui-editor-extensions';
3
- export interface TrackingIdWriterApi {
4
- getDocumentModifier: () => TemplateModifier<HtmlNodeModifier, CssNodeModifier>;
5
- getDocumentRootHtmlNode: () => ImmutableHtmlNode;
6
- }
7
- export declare const registerTrackingIdWriter: (readApi: () => TrackingIdWriterApi | undefined) => void;
8
- export declare const disposeTrackingIdWriter: () => void;
9
- /**
10
- * One hidden modification keeps the selection and the panel alive, unlike a document replacement.
11
- * Returns false when the live document does not match the plan; the caller then falls back.
12
- */
13
- export declare const writeTrackingIdsInPlace: ({ anchorIds, inComment, plan }: DocumentTrackingIdPlan) => boolean;