@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.
- package/README.md +6 -1
- package/dist/components/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +55 -56
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +2 -2
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +3 -3
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useBlocksConfig.js +20 -22
- package/dist/composables/useDisplayConditions.js +7 -8
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useStripo.js +70 -70
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/extensions/DisplayConditions/control.js +17 -19
- package/dist/extensions/DisplayConditions/display-conditions.css.js +2 -2
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/display-condition.d.ts +1 -0
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/extensions/DisplayConditions/control.d.ts +0 -1
- package/dist/src/stores/display-condition.d.ts +2 -0
- package/dist/src/utils/linkTrackingIds.d.ts +24 -22
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/static/styles/variables.css.js +1 -0
- package/dist/utils/displayCondition.js +19 -16
- package/dist/utils/linkTrackingIds.js +72 -72
- package/dist/utils/templatePreparation.js +59 -72
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
- package/dist/extensions/LinkTracking/extension.js +0 -17
- package/dist/extensions/LinkTracking/writer.js +0 -41
- package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
- 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
|
-
*
|
|
32
|
-
*
|
|
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;
|
|
@@ -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
|
|
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
|
-
|
|
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.
|
|
11
|
+
return n.INLINE;
|
|
9
12
|
}
|
|
10
|
-
},
|
|
11
|
-
let
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
return [["codeBefore", e], ["codeAfter",
|
|
15
|
-
const i = (
|
|
16
|
-
h(i) &&
|
|
17
|
-
|
|
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
|
-
}),
|
|
22
|
+
}), o.length && r.add("codeAfter"), [...r];
|
|
20
23
|
};
|
|
21
24
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
C as findInvalidCodeFields,
|
|
26
|
+
_ as nextConditionId,
|
|
27
|
+
I as parseSource,
|
|
28
|
+
m as toAppliedCondition
|
|
26
29
|
};
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
var
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
}, n =
|
|
17
|
-
return
|
|
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
|
|
21
|
+
function h(e, c = 0) {
|
|
20
22
|
let n = 0;
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
26
|
-
return Math.max(
|
|
26
|
+
const t = Number.isSafeInteger(c) && c > 0 ? c : 0;
|
|
27
|
+
return Math.max(b(e), n, t);
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
const n = `${E}="${
|
|
30
|
-
if (
|
|
31
|
-
const [
|
|
32
|
-
return e.slice(0,
|
|
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
|
|
35
|
-
return
|
|
35
|
+
const r = `<!--${p}:${c}-->`;
|
|
36
|
+
return x.test(e) ? e.replace(x, r) : `${r}${e}`;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
return
|
|
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
|
|
42
|
-
const
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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
|
|
71
|
-
|
|
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,
|
|
78
|
-
const n =
|
|
79
|
-
|
|
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
|
-
|
|
81
|
+
l as TRACK_ID_ATTRIBUTE,
|
|
83
82
|
E as TRACK_SEQ_ATTRIBUTE,
|
|
84
83
|
O as assignTrackingIds,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useDynamicContentStore as
|
|
10
|
-
import { useEditorStore as
|
|
11
|
-
import { useUnsubscribeStore as
|
|
12
|
-
import { isPlainObject as
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
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
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
if (!Number.isFinite(
|
|
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
|
|
31
|
-
if (!
|
|
29
|
+
const c = e.getAttribute("esd-ext-config");
|
|
30
|
+
if (!c)
|
|
32
31
|
return;
|
|
33
|
-
let
|
|
32
|
+
let a;
|
|
34
33
|
try {
|
|
35
|
-
|
|
34
|
+
a = JSON.parse(c);
|
|
36
35
|
} catch {
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
|
-
|
|
38
|
+
v(a) && r.seedBlockUrlConfig(t, R(a));
|
|
40
39
|
});
|
|
41
40
|
try {
|
|
42
|
-
await
|
|
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
|
|
51
|
-
const
|
|
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 (
|
|
54
|
-
let { html:
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
76
|
-
const { compiledHtml:
|
|
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:
|
|
79
|
-
compiledSize:
|
|
80
|
-
reduction: `${
|
|
81
|
-
appliedRules:
|
|
82
|
-
executionTime: `${
|
|
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:
|
|
85
|
-
compiledHtml:
|
|
86
|
-
rawHtml:
|
|
87
|
-
css:
|
|
88
|
-
ampHtml:
|
|
89
|
-
ampErrors:
|
|
90
|
-
modules:
|
|
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:
|
|
79
|
+
campaignUrls: H.recommendationCampaignUrls,
|
|
93
80
|
configs: {}
|
|
94
81
|
},
|
|
95
82
|
unsubscribe: {
|
|
96
|
-
status:
|
|
97
|
-
config:
|
|
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:
|
|
90
|
+
hydrateRecommendationStore: S
|
|
104
91
|
};
|
|
105
92
|
};
|
|
106
93
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
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| | | )+|(?:\s| | | )+$/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.
|
|
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,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;
|