@useinsider/guido 3.24.0-beta.b9ec78b → 3.24.0-beta.bf47c23
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/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
- package/dist/config/migrator/recommendationMigrator.js +78 -64
- package/dist/config/migrator/unsubscribeMigrator.js +98 -94
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/extensions/Blocks/Unsubscribe/block.js +96 -104
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +3 -4
- package/dist/package.json.js +2 -2
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
- package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +0 -1
- package/dist/src/utils/linkTrackingIds.d.ts +19 -0
- package/dist/utils/linkTrackingIds.js +82 -48
- package/dist/utils/templatePreparation.js +30 -33
- package/package.json +1 -1
- package/dist/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js +0 -5
- package/dist/src/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.d.ts +0 -1
|
@@ -1,56 +1,90 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return Number.isSafeInteger(
|
|
5
|
-
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const o = (r = s.exec(e)) == null ? void 0 : r[0];
|
|
11
|
-
return o ? S.exec(o) : null;
|
|
12
|
-
}, t = n(b) ?? n(N), c = (t == null ? void 0 : t[1]) ?? (t == null ? void 0 : t[2]) ?? (t == null ? void 0 : t[3]) ?? ((a = _.exec(e)) == null ? void 0 : a[1]) ?? "";
|
|
13
|
-
return m(c);
|
|
14
|
-
}
|
|
15
|
-
function P(e, n = 0) {
|
|
16
|
-
let t = 0;
|
|
17
|
-
[...e.matchAll(f)].forEach(([a]) => {
|
|
18
|
-
const s = I.exec(a), o = s ? s[1] ?? s[2] ?? s[3] ?? "" : "";
|
|
19
|
-
w.test(o) && (t = Math.max(t, Number(o)));
|
|
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
|
+
}
|
|
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 };
|
|
20
10
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
}
|
|
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);
|
|
20
|
+
}
|
|
21
|
+
function h(e, c = 0) {
|
|
22
|
+
let n = 0;
|
|
23
|
+
T(e).forEach(({ rawValue: r }) => {
|
|
24
|
+
$.test(r) && (n = Math.max(n, Number(r)));
|
|
25
|
+
});
|
|
26
|
+
const t = Number.isSafeInteger(c) && c > 0 ? c : 0;
|
|
27
|
+
return Math.max(b(e), n, t);
|
|
28
|
+
}
|
|
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);
|
|
29
34
|
}
|
|
30
|
-
const
|
|
31
|
-
return
|
|
35
|
+
const r = `<!--${p}:${c}-->`;
|
|
36
|
+
return x.test(e) ? e.replace(x, r) : `${r}${e}`;
|
|
32
37
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
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}`);
|
|
36
41
|
}
|
|
37
|
-
function C(e, n = 0) {
|
|
42
|
+
function C(e, c, n = 0) {
|
|
38
43
|
const t = /* @__PURE__ */ new Set();
|
|
39
|
-
let
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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) };
|
|
54
|
+
}
|
|
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
|
+
}
|
|
65
|
+
function P(e) {
|
|
66
|
+
return T(e).map((c) => c.rawValue);
|
|
67
|
+
}
|
|
68
|
+
function K(e, c) {
|
|
69
|
+
return N(e, T(e), c);
|
|
70
|
+
}
|
|
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 };
|
|
49
79
|
}
|
|
50
80
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
81
|
+
l as TRACK_ID_ATTRIBUTE,
|
|
82
|
+
E as TRACK_SEQ_ATTRIBUTE,
|
|
83
|
+
O as assignTrackingIds,
|
|
84
|
+
D as parseTrackSeq,
|
|
85
|
+
C as planTrackingIds,
|
|
86
|
+
P as readAnchorTrackIds,
|
|
87
|
+
h as readTrackFloor,
|
|
88
|
+
b as readTrackSeq,
|
|
89
|
+
K as writeAnchorTrackIds
|
|
56
90
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
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";
|
|
3
4
|
import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
|
|
4
5
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
6
|
import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
|
|
@@ -7,10 +8,9 @@ import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/con
|
|
|
7
8
|
import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
8
9
|
import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
|
|
9
10
|
import { useEditorStore as N } from "../stores/editor.js";
|
|
10
|
-
import { useUnsubscribeStore as
|
|
11
|
-
import { isPlainObject as
|
|
12
|
-
|
|
13
|
-
function O(n) {
|
|
11
|
+
import { useUnsubscribeStore as z } from "../stores/unsubscribe.js";
|
|
12
|
+
import { isPlainObject as v } from "./genericUtil.js";
|
|
13
|
+
function M(n) {
|
|
14
14
|
const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
|
|
15
15
|
return r.forEach((i) => {
|
|
16
16
|
const t = i.getAttribute(g.PAGE_LIST);
|
|
@@ -26,16 +26,16 @@ async function S(n) {
|
|
|
26
26
|
const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
|
|
27
27
|
if (!Number.isFinite(t))
|
|
28
28
|
return;
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
29
|
+
const c = e.getAttribute("esd-ext-config");
|
|
30
|
+
if (!c)
|
|
31
31
|
return;
|
|
32
32
|
let a;
|
|
33
33
|
try {
|
|
34
|
-
a = JSON.parse(
|
|
34
|
+
a = JSON.parse(c);
|
|
35
35
|
} catch {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
v(a) && r.seedBlockUrlConfig(t, R(a));
|
|
39
39
|
});
|
|
40
40
|
try {
|
|
41
41
|
await r.fetchRecommendationCreateData();
|
|
@@ -46,40 +46,37 @@ async function S(n) {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
const n = L(),
|
|
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();
|
|
51
51
|
return {
|
|
52
52
|
prepareTemplateDetails: async (h) => {
|
|
53
|
-
let { html:
|
|
54
|
-
if (a("linkTrackingIds"))
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.error("Tracking-id step failed, saving anyway:", d);
|
|
60
|
-
}
|
|
61
|
-
const { html: T, ampHtml: p = "", ampErrors: A = [] } = await r({
|
|
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({
|
|
62
59
|
minimize: !0,
|
|
63
60
|
resetDataSavedFlag: !1
|
|
64
61
|
});
|
|
65
|
-
o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(
|
|
66
|
-
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);
|
|
67
64
|
return console.debug("HTML Compilation Stats:", {
|
|
68
65
|
originalSize: l.originalSize,
|
|
69
66
|
compiledSize: l.compiledSize,
|
|
70
67
|
reduction: `${l.reductionPercentage.toFixed(2)}%`,
|
|
71
|
-
appliedRules:
|
|
68
|
+
appliedRules: y,
|
|
72
69
|
executionTime: `${l.executionTime.toFixed(2)}ms`
|
|
73
70
|
}), {
|
|
74
71
|
dynamicContentList: k,
|
|
75
|
-
compiledHtml:
|
|
76
|
-
rawHtml:
|
|
77
|
-
css:
|
|
78
|
-
ampHtml:
|
|
79
|
-
ampErrors:
|
|
80
|
-
modules:
|
|
72
|
+
compiledHtml: A,
|
|
73
|
+
rawHtml: m,
|
|
74
|
+
css: p,
|
|
75
|
+
ampHtml: C,
|
|
76
|
+
ampErrors: w,
|
|
77
|
+
modules: u.map(Number),
|
|
81
78
|
recommendation: {
|
|
82
|
-
campaignUrls:
|
|
79
|
+
campaignUrls: H.recommendationCampaignUrls,
|
|
83
80
|
configs: {}
|
|
84
81
|
},
|
|
85
82
|
unsubscribe: {
|
|
@@ -94,6 +91,6 @@ const Z = () => {
|
|
|
94
91
|
};
|
|
95
92
|
};
|
|
96
93
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
M as getHtmlReferencedUnsubscribePages,
|
|
95
|
+
Y as useTemplatePreparation
|
|
99
96
|
};
|
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.bf47c23",
|
|
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 +0,0 @@
|
|
|
1
|
-
export declare const swapMergeTagInHref: (href: string, mergeTag: string) => string;
|