@useinsider/guido 3.21.2-beta.e29e764 → 3.21.2-beta.e89b843
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 +41 -39
- package/dist/@types/display-condition.js +25 -0
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +81 -79
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -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/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
- package/dist/composables/useBlocksConfig.js +32 -24
- package/dist/composables/useDisplayConditions.js +102 -0
- package/dist/composables/useSave.js +75 -68
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
- package/dist/enums/academy.js +1 -0
- package/dist/enums/display-condition.js +12 -0
- package/dist/extensions/DisplayConditions/bridge.js +17 -0
- package/dist/extensions/DisplayConditions/constants.js +17 -0
- package/dist/extensions/DisplayConditions/control.js +178 -0
- package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
- package/dist/extensions/DisplayConditions/extension.js +28 -0
- package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
- package/dist/extensions/DisplayConditions/library.js +27 -0
- package/dist/extensions/DisplayConditions/settingsPanel.js +17 -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/services/displayConditionApi.js +39 -0
- package/dist/services/templateLibraryApi.js +36 -31
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/display-condition.d.ts +59 -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/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 +16 -0
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -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 +6 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +23 -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/mock/api/display-conditions.d.ts +2 -0
- package/dist/src/services/displayConditionApi.d.ts +8 -0
- package/dist/src/stores/config.d.ts +166 -0
- package/dist/src/stores/display-condition.d.ts +81 -0
- package/dist/src/stores/unsubscribe.d.ts +0 -10
- package/dist/src/utils/displayCondition.d.ts +10 -0
- package/dist/src/utils/protectTableText.d.ts +2 -0
- package/dist/src/utils/templatePreparation.d.ts +2 -1
- package/dist/stores/config.js +13 -6
- package/dist/stores/display-condition.js +28 -0
- package/dist/stores/unsubscribe.js +24 -28
- package/dist/utils/displayCondition.js +26 -0
- package/dist/utils/pairProductVariables.js +99 -90
- package/dist/utils/protectTableText.js +22 -0
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { TYPE_COLLECTIONS as
|
|
1
|
+
import { TYPE_COLLECTIONS as i, PAGE_TYPES as p } from "../enums/unsubscribe.js";
|
|
2
2
|
import { useUnsubscribeApi as d } from "../services/unsubscribeApi.js";
|
|
3
3
|
import { defineStore as u } from "pinia";
|
|
4
4
|
let o = null;
|
|
5
|
-
const
|
|
5
|
+
const r = () => ({
|
|
6
6
|
templates: [],
|
|
7
7
|
selectedTemplates: {},
|
|
8
8
|
selectedUnsubscribePages: [],
|
|
9
|
-
selectedCollectionType:
|
|
10
|
-
activeType:
|
|
9
|
+
selectedCollectionType: p.GLOBAL_UNSUBSCRIBE,
|
|
10
|
+
activeType: p.GLOBAL_UNSUBSCRIBE,
|
|
11
11
|
pageSelectionUpdateStatus: !1,
|
|
12
12
|
pageSelectionDrawerStatus: !1,
|
|
13
13
|
typeSelectionDrawerStatus: !1,
|
|
14
14
|
isGlobalUnsubscribeDisabled: !1,
|
|
15
15
|
isSubscriptionPreferencesCenterDisabled: !1,
|
|
16
16
|
pendingBlockId: null
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
return [...e].sort((t, l) => +!!l.isDefault - +!!t.isDefault);
|
|
20
|
-
}
|
|
21
|
-
const f = u("guidoUnsubscribe", {
|
|
22
|
-
state: () => p(),
|
|
17
|
+
}), b = u("guidoUnsubscribe", {
|
|
18
|
+
state: () => r(),
|
|
23
19
|
getters: {
|
|
24
|
-
getSelectedCollection: (e) =>
|
|
20
|
+
getSelectedCollection: (e) => i[e.selectedCollectionType],
|
|
25
21
|
getSelectedTemplateByActiveType: (e) => e.selectedTemplates[e.activeType],
|
|
26
22
|
getTemplatesByActiveType: (e) => e.templates.filter((t) => t.type === e.activeType),
|
|
27
23
|
getThumbnailByTemplateId: (e) => (t) => {
|
|
@@ -29,31 +25,31 @@ const f = u("guidoUnsubscribe", {
|
|
|
29
25
|
return ((l = e.templates.find((s) => s.id === t)) == null ? void 0 : l.thumbnail) ?? "";
|
|
30
26
|
},
|
|
31
27
|
getSelectedUnsubscribePagesByCollection: (e) => (t) => {
|
|
32
|
-
const l =
|
|
28
|
+
const l = i[t];
|
|
33
29
|
if (!l)
|
|
34
30
|
return [];
|
|
35
31
|
const s = /* @__PURE__ */ new Map();
|
|
36
32
|
e.templates.forEach((n) => {
|
|
37
33
|
s.set(n.id, n.type);
|
|
38
34
|
});
|
|
39
|
-
const
|
|
35
|
+
const c = new Set(l);
|
|
40
36
|
return e.selectedUnsubscribePages.filter((n) => {
|
|
41
37
|
const a = s.get(n);
|
|
42
|
-
return a !== void 0 &&
|
|
38
|
+
return a !== void 0 && c.has(a);
|
|
43
39
|
});
|
|
44
40
|
},
|
|
45
41
|
isActiveTypeFirstInCollection: (e) => {
|
|
46
|
-
const t =
|
|
42
|
+
const t = i[e.selectedCollectionType] ?? [];
|
|
47
43
|
return e.activeType === t[0];
|
|
48
44
|
},
|
|
49
45
|
isActiveTypeLastInCollection: (e) => {
|
|
50
|
-
const t =
|
|
46
|
+
const t = i[e.selectedCollectionType] ?? [];
|
|
51
47
|
return e.activeType === t[t.length - 1];
|
|
52
48
|
},
|
|
53
49
|
hasTemplatesByCollectionType: (e) => {
|
|
54
50
|
const t = {};
|
|
55
|
-
return (
|
|
56
|
-
t[s] = e.templates.some((
|
|
51
|
+
return (i[e.selectedCollectionType] ?? []).forEach((s) => {
|
|
52
|
+
t[s] = e.templates.some((c) => c.type === s);
|
|
57
53
|
}), t;
|
|
58
54
|
},
|
|
59
55
|
unsubscribePagesStatus: (e) => e.selectedUnsubscribePages.length > 0
|
|
@@ -62,7 +58,7 @@ const f = u("guidoUnsubscribe", {
|
|
|
62
58
|
$reset() {
|
|
63
59
|
const { templates: e, selectedUnsubscribePages: t } = this;
|
|
64
60
|
Object.assign(this, {
|
|
65
|
-
...
|
|
61
|
+
...r(),
|
|
66
62
|
templates: e,
|
|
67
63
|
selectedUnsubscribePages: t
|
|
68
64
|
});
|
|
@@ -70,28 +66,28 @@ const f = u("guidoUnsubscribe", {
|
|
|
70
66
|
async fetchTemplates(e = !1) {
|
|
71
67
|
!e && this.templates.length || ((e || !o) && (o = (async () => {
|
|
72
68
|
const { getUnsubscribePages: t } = d();
|
|
73
|
-
this.templates =
|
|
69
|
+
this.templates = await t();
|
|
74
70
|
})().finally(() => {
|
|
75
71
|
o = null;
|
|
76
72
|
})), await o);
|
|
77
73
|
},
|
|
78
74
|
setCollection(e) {
|
|
79
75
|
this.selectedCollectionType = e;
|
|
80
|
-
const t =
|
|
76
|
+
const t = i[e];
|
|
81
77
|
if (t && t.length > 0) {
|
|
82
78
|
[this.activeType] = t;
|
|
83
79
|
const l = { ...this.selectedTemplates };
|
|
84
80
|
t.forEach((s) => {
|
|
85
81
|
if (!l[s]) {
|
|
86
|
-
const
|
|
87
|
-
|
|
82
|
+
const c = this.templates.find((n) => n.type === s);
|
|
83
|
+
c && (l[s] = c.id);
|
|
88
84
|
}
|
|
89
85
|
}), this.selectedTemplates = l;
|
|
90
86
|
}
|
|
91
87
|
},
|
|
92
88
|
setCollectionWithoutAutoSelection(e) {
|
|
93
89
|
this.selectedCollectionType = e;
|
|
94
|
-
const t =
|
|
90
|
+
const t = i[e];
|
|
95
91
|
t && t.length > 0 && ([this.activeType] = t);
|
|
96
92
|
},
|
|
97
93
|
setSelectedTemplate(e) {
|
|
@@ -111,12 +107,12 @@ const f = u("guidoUnsubscribe", {
|
|
|
111
107
|
loadSelectedTemplates(e) {
|
|
112
108
|
const t = new Map(this.templates.map((s) => [s.id, s.type])), l = { ...this.selectedTemplates };
|
|
113
109
|
e.forEach((s) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
110
|
+
const c = t.get(s);
|
|
111
|
+
c !== void 0 && (l[c] = s);
|
|
116
112
|
}), this.selectedTemplates = l;
|
|
117
113
|
},
|
|
118
114
|
getSelectedTemplatesByCollection(e) {
|
|
119
|
-
const t =
|
|
115
|
+
const t = i[e], l = [];
|
|
120
116
|
return t.forEach((s) => {
|
|
121
117
|
this.selectedTemplates[s] && l.push(this.selectedTemplates[s]);
|
|
122
118
|
}), l;
|
|
@@ -133,5 +129,5 @@ const f = u("guidoUnsubscribe", {
|
|
|
133
129
|
}
|
|
134
130
|
});
|
|
135
131
|
export {
|
|
136
|
-
|
|
132
|
+
b as useUnsubscribeStore
|
|
137
133
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DisplayConditionSourceType as d } from "../enums/display-condition.js";
|
|
2
|
+
const m = (e) => {
|
|
3
|
+
if (!e)
|
|
4
|
+
return null;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(e.extraData ?? "{}").source === d.INLINE ? "inline" : "saved";
|
|
7
|
+
} catch {
|
|
8
|
+
return "saved";
|
|
9
|
+
}
|
|
10
|
+
}, E = (e) => !e || !(e.name || e.beforeScript || e.afterScript) ? null : { ...e, description: e.description ?? "" };
|
|
11
|
+
let o = 0;
|
|
12
|
+
const w = () => (o = Math.max(Date.now(), o + 1), o), f = /{%-?\s*(\w+)[\s\S]*?-?%}/g, p = /{%[\s\S]*?%}|{{[\s\S]*?}}/g, u = /{%-?\s*(comment|raw)\s*-?%}[\s\S]*?{%-?\s*end\1\s*-?%}/g, l = /* @__PURE__ */ new Set(["if", "unless", "for", "case", "capture", "tablerow", "comment"]), h = /* @__PURE__ */ new Set(["else", "elsif", "elif", "when"]), S = (e) => /{%|%}|{{|}}/.test(e.replace(p, "")), C = (e, c) => {
|
|
13
|
+
const t = /* @__PURE__ */ new Set(), r = [];
|
|
14
|
+
return [["codeBefore", e], ["codeAfter", c]].forEach(([n, i]) => {
|
|
15
|
+
const a = i.replace(u, "");
|
|
16
|
+
S(a) && t.add(n), Array.from(a.matchAll(f), (s) => s[1]).forEach((s) => {
|
|
17
|
+
l.has(s) ? r.push(s) : s.startsWith("end") && l.has(s.slice(3)) ? r.pop() !== s.slice(3) && t.add(n) : h.has(s) && !r.length && t.add(n);
|
|
18
|
+
});
|
|
19
|
+
}), r.length && t.add("codeAfter"), [...t];
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
C as findInvalidCodeFields,
|
|
23
|
+
w as nextConditionId,
|
|
24
|
+
m as parseSource,
|
|
25
|
+
E as toAppliedCondition
|
|
26
|
+
};
|
|
@@ -1,100 +1,109 @@
|
|
|
1
|
-
import { ITEMS_CURRENCY_ATTR as
|
|
2
|
-
import { productPairs as
|
|
3
|
-
import { escapeReplacement as
|
|
4
|
-
import { preserveTextStyles as
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
|
+
import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
|
+
import { preserveTextStyles as L } from "./preserveTextStyles.js";
|
|
5
|
+
import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
|
|
6
|
+
import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
|
|
7
|
+
const q = {
|
|
7
8
|
CART_ITEMS: "ins_apr",
|
|
8
9
|
BROWSED_ITEMS: "browsed_item",
|
|
9
10
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
-
},
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
for (;
|
|
14
|
-
|
|
15
|
-
return
|
|
11
|
+
}, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
12
|
+
function Q($, C, A) {
|
|
13
|
+
let d = C;
|
|
14
|
+
for (; d > 0 && /\s/.test($[d - 1]); )
|
|
15
|
+
d -= 1;
|
|
16
|
+
return A.some((E) => $.endsWith(E, d));
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
19
|
+
function J($, C) {
|
|
20
|
+
var d;
|
|
21
|
+
const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
|
|
22
|
+
for (let E = A.nextNode(); E; E = A.nextNode())
|
|
23
|
+
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
|
|
24
|
+
}
|
|
25
|
+
function ot($) {
|
|
26
|
+
const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
|
|
27
|
+
j(A);
|
|
28
|
+
const d = M.PAIRS_FOR_EXTENSION;
|
|
29
|
+
Object.entries(d).forEach(([o, p]) => {
|
|
30
|
+
A.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
31
|
+
const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
|
|
32
|
+
r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
33
|
+
var b, I, D, O;
|
|
34
|
+
const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
|
|
27
35
|
if (f)
|
|
28
|
-
switch (
|
|
36
|
+
switch (o) {
|
|
29
37
|
case "imageSrc": {
|
|
30
|
-
let e = null,
|
|
31
|
-
if (t.tagName === "IMG" ? (e = t,
|
|
38
|
+
let e = null, s = null;
|
|
39
|
+
if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
|
|
32
40
|
break;
|
|
33
41
|
const l = f.DEFAULT, c = f.ATTR;
|
|
34
42
|
if (l && e.src) {
|
|
35
|
-
const
|
|
36
|
-
l.some((
|
|
37
|
-
const u =
|
|
38
|
-
return
|
|
39
|
-
}) && (e.src = `{{${c}_${
|
|
43
|
+
const a = e.src;
|
|
44
|
+
l.some((g) => {
|
|
45
|
+
const u = g.split("/").pop() || "", H = a.split("/").pop() || "";
|
|
46
|
+
return a.includes(g) || a.includes(u) || H === u;
|
|
47
|
+
}) && (e.src = `{{${c}_${n}}}`);
|
|
40
48
|
}
|
|
41
|
-
const i = (
|
|
42
|
-
if (i && e.setAttribute("alt", `{{${i}_${
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(
|
|
49
|
+
const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
|
|
50
|
+
if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
|
|
51
|
+
const a = (D = d.itemLink) == null ? void 0 : D[m];
|
|
52
|
+
if (a) {
|
|
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}}}`);
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
break;
|
|
50
58
|
}
|
|
51
59
|
case "name": {
|
|
52
|
-
const e = f,
|
|
53
|
-
t.textContent && (t.innerHTML =
|
|
60
|
+
const e = f, s = e.ATTR, l = e.DEFAULT_HREF || "#!", c = e.HREF;
|
|
61
|
+
t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
54
62
|
const i = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
55
63
|
if (i && c) {
|
|
56
|
-
const
|
|
57
|
-
(
|
|
64
|
+
const a = i.href, S = `${window.location.href}${l}`;
|
|
65
|
+
(a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
|
|
58
66
|
}
|
|
59
67
|
break;
|
|
60
68
|
}
|
|
61
69
|
case "price":
|
|
62
70
|
case "originalPrice": {
|
|
63
|
-
const e = f,
|
|
64
|
-
let
|
|
65
|
-
i ?
|
|
66
|
-
const
|
|
67
|
-
let u = `{{${
|
|
68
|
-
const H = (t.getAttribute(
|
|
69
|
-
let
|
|
70
|
-
G ?
|
|
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";
|
|
72
|
+
let S;
|
|
73
|
+
i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
|
|
74
|
+
const g = e.CURRENCY;
|
|
75
|
+
let u = `{{${S}_${n}}}`;
|
|
76
|
+
const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
|
|
77
|
+
let F = "";
|
|
78
|
+
G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
|
|
71
79
|
break;
|
|
72
80
|
}
|
|
73
81
|
case "quantity": {
|
|
74
|
-
const e = f,
|
|
75
|
-
c && l.includes(c) && (t.innerHTML =
|
|
82
|
+
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
|
|
83
|
+
c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
76
84
|
break;
|
|
77
85
|
}
|
|
78
86
|
case "button": {
|
|
79
|
-
const e = f,
|
|
87
|
+
const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t.tagName === "A" ? t : t.querySelector("a");
|
|
80
88
|
if (c) {
|
|
81
|
-
const i = c.href || "",
|
|
82
|
-
(i === "" || i === "#" || i ===
|
|
89
|
+
const i = c.href || "", a = `${window.location.href}${l}`;
|
|
90
|
+
(i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
|
|
83
91
|
}
|
|
92
|
+
J(t, `{{${s}_${n}}}`);
|
|
84
93
|
break;
|
|
85
94
|
}
|
|
86
95
|
case "itemLink": {
|
|
87
|
-
const e = f,
|
|
96
|
+
const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t;
|
|
88
97
|
if (c.href) {
|
|
89
|
-
const i = c.href,
|
|
90
|
-
(i ===
|
|
98
|
+
const i = c.href, a = `${window.location.href}${l}`;
|
|
99
|
+
(i === a || i.endsWith(l)) && (c.href = `{{${s}_${n}}}`);
|
|
91
100
|
}
|
|
92
101
|
break;
|
|
93
102
|
}
|
|
94
103
|
default: {
|
|
95
104
|
if ("ATTR" in f) {
|
|
96
105
|
const e = f.ATTR;
|
|
97
|
-
t.textContent && (t.innerHTML =
|
|
106
|
+
t.textContent && (t.innerHTML = L(t, `{{${e}_${n}}}`));
|
|
98
107
|
}
|
|
99
108
|
break;
|
|
100
109
|
}
|
|
@@ -102,49 +111,49 @@ function Z(S) {
|
|
|
102
111
|
});
|
|
103
112
|
});
|
|
104
113
|
});
|
|
105
|
-
const
|
|
106
|
-
` : "",
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
element:
|
|
114
|
+
const E = C.match(/<!DOCTYPE[^>]*>/i), k = E ? `${E[0]}
|
|
115
|
+
` : "", P = A.querySelectorAll(".ins-product-td"), N = [];
|
|
116
|
+
P.forEach((o) => {
|
|
117
|
+
const p = o.getAttribute("data-type") || "CART_ITEMS", T = o.getAttribute("data-number") || "1", r = o.outerHTML;
|
|
118
|
+
N.push({
|
|
119
|
+
element: o,
|
|
111
120
|
outerHtml: r,
|
|
112
|
-
type:
|
|
113
|
-
number:
|
|
121
|
+
type: p,
|
|
122
|
+
number: T
|
|
114
123
|
});
|
|
115
124
|
});
|
|
116
|
-
let
|
|
117
|
-
|
|
118
|
-
const r =
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
|
|
125
|
+
let h = k + A.documentElement.outerHTML;
|
|
126
|
+
N.reverse().forEach(({ outerHtml: o, type: p, number: T }) => {
|
|
127
|
+
const r = q[p], _ = r ? `${r}_total_product_kind` : "";
|
|
128
|
+
if (_) {
|
|
129
|
+
const R = parseInt(T) - 1, n = `${`{% if ${_} > ${R} %}`}${o}{% endif %}`;
|
|
130
|
+
h = h.replace(o, B(n));
|
|
122
131
|
}
|
|
123
132
|
});
|
|
124
|
-
const V =
|
|
125
|
-
return V.forEach((
|
|
133
|
+
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
|
|
134
|
+
return V.forEach((o) => {
|
|
126
135
|
var t;
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
136
|
+
const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
|
|
137
|
+
if (!p || !q[T])
|
|
129
138
|
return;
|
|
130
|
-
const r =
|
|
131
|
-
if (!r ||
|
|
139
|
+
const r = o.closest(".product-original-price-class");
|
|
140
|
+
if (!r || x.has(r))
|
|
132
141
|
return;
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
}),
|
|
137
|
-
if (r.includes("{% if") || !
|
|
142
|
+
x.add(r);
|
|
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: [] };
|
|
144
|
+
R.wrap.push(y !== "false"), w.set(_, R);
|
|
145
|
+
}), w.forEach(({ number: o, type: p, wrap: T }, r) => {
|
|
146
|
+
if (r.includes("{% if") || !T.some(Boolean))
|
|
138
147
|
return;
|
|
139
|
-
const
|
|
140
|
-
let
|
|
141
|
-
for (;
|
|
142
|
-
const
|
|
143
|
-
|
|
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)];
|
|
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);
|
|
144
153
|
}
|
|
145
|
-
|
|
146
|
-
}),
|
|
154
|
+
h = m + h.slice(n);
|
|
155
|
+
}), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
147
156
|
}
|
|
148
157
|
export {
|
|
149
|
-
|
|
158
|
+
ot as pairProductVariables
|
|
150
159
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const c = "guido-table-text:", l = new RegExp(`<!--${c}([A-Za-z0-9+/=]*)-->`, "g"), i = /<!--[\s\S]*?-->|\{%[\s\S]*?%\}|<[a-zA-Z/!?](?:[^>"']|"[^"]*"|'[^']*')*>|[^<{]+|[<{]/g, o = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr"]), T = /* @__PURE__ */ new Set([...o, "td", "th", "caption"]), d = (s) => btoa(unescape(encodeURIComponent(s))), f = (s) => decodeURIComponent(escape(atob(s))), p = (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 u(s) {
|
|
6
|
+
const e = [];
|
|
7
|
+
let a = !1;
|
|
8
|
+
return s.replace(i, (t) => {
|
|
9
|
+
if (t.startsWith("<!--") || t.startsWith("{%"))
|
|
10
|
+
return t;
|
|
11
|
+
if (t.length > 1 && t.startsWith("<")) {
|
|
12
|
+
const { name: n, closing: r } = p(t);
|
|
13
|
+
return a = T.has(n), a && (r ? e.includes(n) && e.splice(e.lastIndexOf(n)) : e.push(n)), t;
|
|
14
|
+
}
|
|
15
|
+
return a && o.has(e[e.length - 1] ?? "") && t.trim() ? `<!--${c}${d(t)}-->` : t;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const E = (s) => s.replace(l, (e, a) => f(a));
|
|
19
|
+
export {
|
|
20
|
+
u as protectTableText,
|
|
21
|
+
E as restoreTableText
|
|
22
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useHtmlCompiler as
|
|
1
|
+
import { useActionsApi as E } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useConfig as F } from "../composables/useConfig.js";
|
|
3
|
+
import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
|
|
4
4
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
import { toBlockUrlConfig as
|
|
5
|
+
import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
|
|
6
6
|
import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
7
|
-
import { parsePageList as
|
|
8
|
-
import { useDynamicContentStore as
|
|
9
|
-
import { useEditorStore as
|
|
10
|
-
import { useUnsubscribeStore as
|
|
11
|
-
import { isPlainObject as
|
|
12
|
-
import { assignTrackingIds as
|
|
13
|
-
function
|
|
7
|
+
import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
8
|
+
import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
|
|
9
|
+
import { useEditorStore as N } from "../stores/editor.js";
|
|
10
|
+
import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
|
|
11
|
+
import { isPlainObject as z } from "./genericUtil.js";
|
|
12
|
+
import { assignTrackingIds as M } from "./linkTrackingIds.js";
|
|
13
|
+
function O(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);
|
|
17
|
-
t && e.push(...
|
|
17
|
+
t && e.push(...U(t));
|
|
18
18
|
}), [...new Set(e)];
|
|
19
19
|
}
|
|
20
20
|
async function S(n) {
|
|
@@ -35,7 +35,7 @@ async function S(n) {
|
|
|
35
35
|
} catch {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
z(a) && r.seedBlockUrlConfig(t, R(a));
|
|
39
39
|
});
|
|
40
40
|
try {
|
|
41
41
|
await r.fetchRecommendationCreateData();
|
|
@@ -46,40 +46,40 @@ async function S(n) {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
const n =
|
|
49
|
+
const Z = () => {
|
|
50
|
+
const n = L(), c = N(), o = v(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = E(), { compileHtml: t, compileAmpHtml: m } = I(), { isFeatureEnabled: a } = F();
|
|
51
51
|
return {
|
|
52
|
-
prepareTemplateDetails: async () => {
|
|
53
|
-
let { html: s, css: u, syncModulesIds:
|
|
52
|
+
prepareTemplateDetails: async (h) => {
|
|
53
|
+
let { html: s, css: u, syncModulesIds: y = [] } = h ?? await e();
|
|
54
54
|
if (a("linkTrackingIds"))
|
|
55
55
|
try {
|
|
56
|
-
const { html: d, changed:
|
|
57
|
-
c.trackIdSessionFloor =
|
|
56
|
+
const { html: d, changed: x, nextSeq: D } = M(s, c.trackIdSessionFloor);
|
|
57
|
+
c.trackIdSessionFloor = D, x && (s = d, await i(d, u));
|
|
58
58
|
} catch (d) {
|
|
59
59
|
console.error("Tracking-id step failed, saving anyway:", d);
|
|
60
60
|
}
|
|
61
|
-
const { html:
|
|
61
|
+
const { html: T, ampHtml: p = "", ampErrors: A = [] } = await r({
|
|
62
62
|
minimize: !0,
|
|
63
63
|
resetDataSavedFlag: !1
|
|
64
64
|
});
|
|
65
65
|
o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
|
|
66
|
-
const { compiledHtml:
|
|
66
|
+
const { compiledHtml: w, stats: l, appliedRules: C } = t(T), H = p && m(p).compiledHtml, k = n.getSelectedDynamicContentList, P = b(), f = O(s);
|
|
67
67
|
return console.debug("HTML Compilation Stats:", {
|
|
68
68
|
originalSize: l.originalSize,
|
|
69
69
|
compiledSize: l.compiledSize,
|
|
70
70
|
reduction: `${l.reductionPercentage.toFixed(2)}%`,
|
|
71
|
-
appliedRules:
|
|
71
|
+
appliedRules: C,
|
|
72
72
|
executionTime: `${l.executionTime.toFixed(2)}ms`
|
|
73
73
|
}), {
|
|
74
|
-
dynamicContentList:
|
|
75
|
-
compiledHtml:
|
|
74
|
+
dynamicContentList: k,
|
|
75
|
+
compiledHtml: w,
|
|
76
76
|
rawHtml: s,
|
|
77
77
|
css: u,
|
|
78
|
-
ampHtml:
|
|
79
|
-
ampErrors:
|
|
80
|
-
modules:
|
|
78
|
+
ampHtml: H,
|
|
79
|
+
ampErrors: A,
|
|
80
|
+
modules: y.map(Number),
|
|
81
81
|
recommendation: {
|
|
82
|
-
campaignUrls:
|
|
82
|
+
campaignUrls: P.recommendationCampaignUrls,
|
|
83
83
|
configs: {}
|
|
84
84
|
},
|
|
85
85
|
unsubscribe: {
|
|
@@ -94,6 +94,6 @@ const Y = () => {
|
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
96
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
O as getHtmlReferencedUnsubscribePages,
|
|
98
|
+
Z as useTemplatePreparation
|
|
99
99
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.21.2-beta.
|
|
3
|
+
"version": "3.21.2-beta.e89b843",
|
|
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",
|