@useinsider/guido 3.23.0-beta.ff29317 → 3.24.0-beta.0abeefe
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 +1 -0
- package/dist/@types/config/schemas.js +39 -37
- package/dist/@types/display-condition.js +25 -0
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +98 -92
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +17 -0
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +41 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +81 -0
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +17 -0
- package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +45 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +36 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +63 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
- package/dist/composables/useBlocksConfig.js +31 -20
- package/dist/composables/useDisplayConditions.js +117 -0
- package/dist/composables/useTranslations.js +2 -1
- package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +67 -64
- package/dist/enums/academy.js +1 -0
- package/dist/enums/display-condition.js +12 -0
- package/dist/extensions/DisplayConditions/bridge.js +25 -0
- package/dist/extensions/DisplayConditions/constants.js +26 -0
- package/dist/extensions/DisplayConditions/control.js +215 -0
- package/dist/extensions/DisplayConditions/display-conditions.css.js +226 -0
- package/dist/extensions/DisplayConditions/extension.js +28 -0
- package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
- package/dist/extensions/DisplayConditions/library.js +30 -0
- package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
- package/dist/extensions/LinkTracking/extension.js +17 -0
- package/dist/extensions/LinkTracking/writer.js +41 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
- package/dist/node_modules/valibot/dist/index.js +297 -261
- package/dist/package.json.js +6 -6
- package/dist/services/displayConditionApi.js +39 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/display-condition.d.ts +60 -0
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +18 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useDisplayConditions.d.ts +18 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/display-condition.d.ts +15 -0
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +7 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +23 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +25 -0
- package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
- package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
- package/dist/src/extensions/LinkTracking/extension.d.ts +2 -0
- package/dist/src/extensions/LinkTracking/writer.d.ts +13 -0
- package/dist/src/mock/api/display-conditions.d.ts +2 -0
- package/dist/src/services/displayConditionApi.d.ts +8 -0
- package/dist/src/stores/config.d.ts +167 -0
- package/dist/src/stores/display-condition.d.ts +84 -0
- package/dist/src/utils/displayCondition.d.ts +11 -0
- package/dist/src/utils/linkTrackingIds.d.ts +22 -5
- package/dist/src/utils/protectTableText.d.ts +2 -0
- package/dist/stores/config.js +13 -6
- package/dist/stores/display-condition.js +29 -0
- package/dist/utils/displayCondition.js +26 -0
- package/dist/utils/linkTrackingIds.js +82 -48
- package/dist/utils/pairProductVariables.js +30 -29
- package/dist/utils/protectTableText.js +22 -0
- package/dist/utils/templatePreparation.js +67 -57
- package/package.json +1 -1
|
@@ -1,56 +1,90 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
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 };
|
|
5
|
+
}
|
|
6
|
+
function k(e) {
|
|
7
|
+
const t = Number(e);
|
|
8
|
+
return Number.isSafeInteger(t) && t > 0 ? t : 0;
|
|
9
|
+
}
|
|
10
|
+
function N(e) {
|
|
11
|
+
var s;
|
|
12
|
+
const t = (o) => {
|
|
9
13
|
var r;
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
[...e.matchAll(
|
|
18
|
-
const
|
|
19
|
-
|
|
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);
|
|
18
|
+
}
|
|
19
|
+
function K(e, t = 0) {
|
|
20
|
+
let n = 0;
|
|
21
|
+
[...e.matchAll(R)].forEach(([s]) => {
|
|
22
|
+
const { rawValue: o } = $(s);
|
|
23
|
+
I.test(o) && (n = Math.max(n, Number(o)));
|
|
20
24
|
});
|
|
21
|
-
const c = Number.isSafeInteger(
|
|
22
|
-
return Math.max(
|
|
25
|
+
const c = Number.isSafeInteger(t) && t > 0 ? t : 0;
|
|
26
|
+
return Math.max(N(e), n, c);
|
|
23
27
|
}
|
|
24
|
-
function
|
|
25
|
-
const
|
|
28
|
+
function M(e, t) {
|
|
29
|
+
const n = `${E}="${t}"`, c = _.exec(e) ?? l.exec(e);
|
|
26
30
|
if (c) {
|
|
27
|
-
const [
|
|
28
|
-
return e.slice(0, c.index) + r + e.slice(c.index +
|
|
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
33
|
}
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
function
|
|
34
|
-
const c = `${
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
const s = `<!--${p}:${t}-->`;
|
|
35
|
+
return d.test(e) ? e.replace(d, s) : `${s}${e}`;
|
|
36
|
+
}
|
|
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}`);
|
|
40
|
+
}
|
|
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 };
|
|
58
|
+
}
|
|
59
|
+
function b(e) {
|
|
60
|
+
return [...e.matchAll(R)].map((t) => {
|
|
61
|
+
const [n] = t;
|
|
62
|
+
return { index: t.index, tag: n, ...$(n) };
|
|
63
|
+
});
|
|
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) };
|
|
69
|
+
}
|
|
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;
|
|
76
|
+
}
|
|
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 };
|
|
49
80
|
}
|
|
50
81
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
P as
|
|
55
|
-
|
|
82
|
+
A as TRACK_ID_ATTRIBUTE,
|
|
83
|
+
E as TRACK_SEQ_ATTRIBUTE,
|
|
84
|
+
O as assignTrackingIds,
|
|
85
|
+
P as planDocumentTrackingIds,
|
|
86
|
+
w as planTrackingIds,
|
|
87
|
+
K as readTrackFloor,
|
|
88
|
+
N as readTrackSeq,
|
|
89
|
+
D as renderTrackingIdPlan
|
|
56
90
|
};
|
|
@@ -2,34 +2,35 @@ import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extens
|
|
|
2
2
|
import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
3
|
import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
4
|
import { preserveTextStyles as L } from "./preserveTextStyles.js";
|
|
5
|
-
import {
|
|
5
|
+
import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
|
|
6
|
+
import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
|
|
6
7
|
const q = {
|
|
7
8
|
CART_ITEMS: "ins_apr",
|
|
8
9
|
BROWSED_ITEMS: "browsed_item",
|
|
9
10
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
11
|
}, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
-
function
|
|
12
|
+
function Q($, C, A) {
|
|
12
13
|
let d = C;
|
|
13
14
|
for (; d > 0 && /\s/.test($[d - 1]); )
|
|
14
15
|
d -= 1;
|
|
15
16
|
return A.some((E) => $.endsWith(E, d));
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
18
|
+
const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
19
|
+
function J($, C) {
|
|
19
20
|
var d;
|
|
20
21
|
const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
|
|
21
22
|
for (let E = A.nextNode(); E; E = A.nextNode())
|
|
22
|
-
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(
|
|
23
|
+
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
const C = W($), A = new DOMParser().parseFromString(C, "text/html");
|
|
26
|
-
|
|
25
|
+
function ot($) {
|
|
26
|
+
const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
|
|
27
|
+
j(A);
|
|
27
28
|
const d = M.PAIRS_FOR_EXTENSION;
|
|
28
29
|
Object.entries(d).forEach(([o, p]) => {
|
|
29
30
|
A.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
30
31
|
const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
|
|
31
32
|
r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
32
|
-
var
|
|
33
|
+
var b, I, D, O;
|
|
33
34
|
const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
|
|
34
35
|
if (f)
|
|
35
36
|
switch (o) {
|
|
@@ -45,12 +46,12 @@ function et($) {
|
|
|
45
46
|
return a.includes(g) || a.includes(u) || H === u;
|
|
46
47
|
}) && (e.src = `{{${c}_${n}}}`);
|
|
47
48
|
}
|
|
48
|
-
const i = (I = (
|
|
49
|
+
const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
|
|
49
50
|
if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
|
|
50
|
-
const a = (
|
|
51
|
+
const a = (D = d.itemLink) == null ? void 0 : D[m];
|
|
51
52
|
if (a) {
|
|
52
|
-
const
|
|
53
|
-
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${
|
|
53
|
+
const S = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
|
|
54
|
+
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${S}_${n}}}`);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
break;
|
|
@@ -60,25 +61,25 @@ function et($) {
|
|
|
60
61
|
t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
61
62
|
const i = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
62
63
|
if (i && c) {
|
|
63
|
-
const a = i.href,
|
|
64
|
-
(a ===
|
|
64
|
+
const a = i.href, S = `${window.location.href}${l}`;
|
|
65
|
+
(a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
|
|
65
66
|
}
|
|
66
67
|
break;
|
|
67
68
|
}
|
|
68
69
|
case "price":
|
|
69
70
|
case "originalPrice": {
|
|
70
71
|
const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
|
|
71
|
-
let
|
|
72
|
-
i ?
|
|
72
|
+
let S;
|
|
73
|
+
i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
|
|
73
74
|
const g = e.CURRENCY;
|
|
74
|
-
let u = `{{${
|
|
75
|
+
let u = `{{${S}_${n}}}`;
|
|
75
76
|
const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
|
|
76
77
|
let F = "";
|
|
77
78
|
G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
80
81
|
case "quantity": {
|
|
81
|
-
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (
|
|
82
|
+
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
|
|
82
83
|
c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
@@ -88,7 +89,7 @@ function et($) {
|
|
|
88
89
|
const i = c.href || "", a = `${window.location.href}${l}`;
|
|
89
90
|
(i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
J(t, `{{${s}_${n}}}`);
|
|
92
93
|
break;
|
|
93
94
|
}
|
|
94
95
|
case "itemLink": {
|
|
@@ -129,30 +130,30 @@ function et($) {
|
|
|
129
130
|
h = h.replace(o, B(n));
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
|
-
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(),
|
|
133
|
+
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
|
|
133
134
|
return V.forEach((o) => {
|
|
134
135
|
var t;
|
|
135
136
|
const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
|
|
136
137
|
if (!p || !q[T])
|
|
137
138
|
return;
|
|
138
139
|
const r = o.closest(".product-original-price-class");
|
|
139
|
-
if (!r ||
|
|
140
|
+
if (!r || x.has(r))
|
|
140
141
|
return;
|
|
141
|
-
|
|
142
|
+
x.add(r);
|
|
142
143
|
const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
|
|
143
144
|
R.wrap.push(y !== "false"), w.set(_, R);
|
|
144
145
|
}), w.forEach(({ number: o, type: p, wrap: T }, r) => {
|
|
145
146
|
if (r.includes("{% if") || !T.some(Boolean))
|
|
146
147
|
return;
|
|
147
148
|
const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
|
|
148
|
-
let m = "", n = 0, f = 0,
|
|
149
|
-
for (;
|
|
150
|
-
const I = T[f] === !0 && !
|
|
151
|
-
m += h.slice(n,
|
|
149
|
+
let m = "", n = 0, f = 0, b = h.indexOf(r);
|
|
150
|
+
for (; b !== -1; ) {
|
|
151
|
+
const I = T[f] === !0 && !Q(h, b, t);
|
|
152
|
+
m += h.slice(n, b) + (I ? `${R}${r}{% endif %}` : r), n = b + r.length, f += 1, b = h.indexOf(r, n);
|
|
152
153
|
}
|
|
153
154
|
h = m + h.slice(n);
|
|
154
|
-
}), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
155
|
+
}), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
155
156
|
}
|
|
156
157
|
export {
|
|
157
|
-
|
|
158
|
+
ot as pairProductVariables
|
|
158
159
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const n = "guido-table-text:", i = new RegExp(`<!--${n}([A-Za-z0-9+/=]*)-->`, "g"), T = /<!--[\s\S]*?-->|\{%[\s\S]*?%\}|<[a-zA-Z/!?](?:[^>"']|"[^"]*"|'[^']*')*>|[^<{]+|[<{]/g, o = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr", "colgroup"]), r = /* @__PURE__ */ new Set(["col"]), f = /* @__PURE__ */ new Set([...o, ...r, "td", "th", "caption"]), p = (s) => btoa(unescape(encodeURIComponent(s))), u = (s) => decodeURIComponent(escape(atob(s))), d = (s) => {
|
|
2
|
+
const e = /^<(\/?)([a-zA-Z][\w-]*)/.exec(s);
|
|
3
|
+
return { name: e ? e[2].toLowerCase() : "", closing: e ? e[1] === "/" : !1 };
|
|
4
|
+
};
|
|
5
|
+
function E(s) {
|
|
6
|
+
const e = [];
|
|
7
|
+
let a = !1;
|
|
8
|
+
return s.replace(T, (t) => {
|
|
9
|
+
if (t.startsWith("<!--") || t.startsWith("{%"))
|
|
10
|
+
return t;
|
|
11
|
+
if (t.length > 1 && t.startsWith("<")) {
|
|
12
|
+
const { name: c, closing: l } = d(t);
|
|
13
|
+
return a = f.has(c), !a || r.has(c) || (l ? e.includes(c) && e.splice(e.lastIndexOf(c)) : e.push(c)), t;
|
|
14
|
+
}
|
|
15
|
+
return a && o.has(e[e.length - 1] ?? "") && t.trim() ? `<!--${n}${p(t)}-->` : t;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const g = (s) => s.replace(i, (e, a) => u(a));
|
|
19
|
+
export {
|
|
20
|
+
E as protectTableText,
|
|
21
|
+
g as restoreTableText
|
|
22
|
+
};
|
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
import { useActionsApi as E } from "../composables/useActionsApi.js";
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useHtmlCompiler as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
import { toBlockUrlConfig as
|
|
6
|
-
import { DATA_ATTRIBUTES as
|
|
7
|
-
import { parsePageList as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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));
|
|
18
19
|
}), [...new Set(e)];
|
|
19
20
|
}
|
|
20
|
-
async function
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
21
|
+
async function w(c) {
|
|
22
|
+
const a = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
23
|
+
if (a.length === 0)
|
|
23
24
|
return;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (!Number.isFinite(
|
|
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))
|
|
28
29
|
return;
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
30
|
+
const l = e.getAttribute("esd-ext-config");
|
|
31
|
+
if (!l)
|
|
31
32
|
return;
|
|
32
|
-
let
|
|
33
|
+
let m;
|
|
33
34
|
try {
|
|
34
|
-
|
|
35
|
+
m = JSON.parse(l);
|
|
35
36
|
} catch {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
O(m) && i.seedBlockUrlConfig(o, L(m));
|
|
39
40
|
});
|
|
40
41
|
try {
|
|
41
|
-
await
|
|
42
|
+
await i.fetchRecommendationCreateData();
|
|
42
43
|
} catch (e) {
|
|
43
44
|
console.warn(
|
|
44
45
|
"Recommendation reference data pre-load failed; validator will skip the availability check.",
|
|
@@ -46,54 +47,63 @@ async function S(n) {
|
|
|
46
47
|
);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
const
|
|
50
|
-
const
|
|
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();
|
|
51
52
|
return {
|
|
52
|
-
prepareTemplateDetails: async (
|
|
53
|
-
let { html:
|
|
54
|
-
if (
|
|
53
|
+
prepareTemplateDetails: async (y) => {
|
|
54
|
+
let { html: r, css: u, syncModulesIds: g = [] } = y ?? await e();
|
|
55
|
+
if (m("linkTrackingIds"))
|
|
55
56
|
try {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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);
|
|
60
70
|
}
|
|
61
|
-
const { html:
|
|
71
|
+
const { html: A, ampHtml: f = "", ampErrors: P = [] } = await i({
|
|
62
72
|
minimize: !0,
|
|
63
73
|
resetDataSavedFlag: !1
|
|
64
74
|
});
|
|
65
|
-
|
|
66
|
-
const { compiledHtml:
|
|
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);
|
|
67
77
|
return console.debug("HTML Compilation Stats:", {
|
|
68
|
-
originalSize:
|
|
69
|
-
compiledSize:
|
|
70
|
-
reduction: `${
|
|
71
|
-
appliedRules:
|
|
72
|
-
executionTime: `${
|
|
78
|
+
originalSize: d.originalSize,
|
|
79
|
+
compiledSize: d.compiledSize,
|
|
80
|
+
reduction: `${d.reductionPercentage.toFixed(2)}%`,
|
|
81
|
+
appliedRules: I,
|
|
82
|
+
executionTime: `${d.executionTime.toFixed(2)}ms`
|
|
73
83
|
}), {
|
|
74
|
-
dynamicContentList:
|
|
75
|
-
compiledHtml:
|
|
76
|
-
rawHtml:
|
|
84
|
+
dynamicContentList: D,
|
|
85
|
+
compiledHtml: C,
|
|
86
|
+
rawHtml: r,
|
|
77
87
|
css: u,
|
|
78
88
|
ampHtml: H,
|
|
79
|
-
ampErrors:
|
|
80
|
-
modules:
|
|
89
|
+
ampErrors: P,
|
|
90
|
+
modules: g.map(Number),
|
|
81
91
|
recommendation: {
|
|
82
|
-
campaignUrls:
|
|
92
|
+
campaignUrls: F.recommendationCampaignUrls,
|
|
83
93
|
configs: {}
|
|
84
94
|
},
|
|
85
95
|
unsubscribe: {
|
|
86
|
-
status:
|
|
87
|
-
config:
|
|
96
|
+
status: S.length > 0,
|
|
97
|
+
config: S
|
|
88
98
|
}
|
|
89
99
|
};
|
|
90
100
|
},
|
|
91
101
|
// Exposed so the back/test validate-only path can seed the reco store the
|
|
92
102
|
// same way a full save does (required-field findings depend on it).
|
|
93
|
-
hydrateRecommendationStore:
|
|
103
|
+
hydrateRecommendationStore: w
|
|
94
104
|
};
|
|
95
105
|
};
|
|
96
106
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
_ as getHtmlReferencedUnsubscribePages,
|
|
108
|
+
oe as useTemplatePreparation
|
|
99
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0-beta.0abeefe",
|
|
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",
|