@useinsider/guido 3.19.0-beta.87e26c0 → 3.19.0-beta.acb00a2
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 +21 -3
- package/dist/@types/config/schemas.js +59 -51
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +89 -81
- package/dist/components/organisms/base/Toaster.vue2.js +13 -12
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +78 -57
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -42
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
- package/dist/composables/useActionsApi.js +24 -20
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useCustomInterfaceAppearance.js +65 -51
- package/dist/composables/useEmailTemplateApplier.js +108 -52
- package/dist/composables/useHtmlValidator.js +87 -82
- package/dist/composables/useHttp.js +44 -55
- package/dist/composables/useLegacyStrategyConversion.js +61 -0
- package/dist/composables/useRecommendation.js +40 -35
- package/dist/composables/useStripo.js +30 -30
- package/dist/composables/useToaster.js +14 -20
- package/dist/enums/extensions/recommendationBlock.js +49 -33
- package/dist/extensions/Blocks/Recommendation/block.js +61 -42
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +100 -94
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +130 -55
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +273 -92
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +7 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +162 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +322 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/stores/onboarding.d.ts +808 -10
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +104 -9
- package/dist/static/styles/components/skeleton.css.js +23 -0
- package/dist/stores/config.js +74 -60
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +46 -36
- package/dist/utils/templatePreparation.js +55 -55
- package/package.json +1 -1
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { filterAmpErrors as v } from "../utils/ampErrorFilter.js";
|
|
2
2
|
import { useToaster as y } from "./useToaster.js";
|
|
3
|
-
const D = 1e4,
|
|
4
|
-
const
|
|
5
|
-
() =>
|
|
3
|
+
const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
|
|
4
|
+
const c = setTimeout(
|
|
5
|
+
() => s(new Error(`${n} did not report completion within ${l}ms`)),
|
|
6
6
|
l
|
|
7
|
-
),
|
|
8
|
-
clearTimeout(
|
|
7
|
+
), d = (r) => (t) => {
|
|
8
|
+
clearTimeout(c), r(t);
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
w(d(A), d(s));
|
|
12
|
+
} catch (r) {
|
|
13
|
+
clearTimeout(c), s(r instanceof Error ? r : new Error(String(r)));
|
|
14
|
+
}
|
|
11
15
|
}), I = () => {
|
|
12
|
-
const { handleError: n } = y(), l = (t = {}) =>
|
|
16
|
+
const { handleError: n } = y(), l = (t = {}) => p(
|
|
13
17
|
"compileEmail",
|
|
14
|
-
|
|
18
|
+
T,
|
|
15
19
|
(e, a) => {
|
|
16
20
|
const o = { ...{
|
|
17
21
|
minimize: !0,
|
|
@@ -32,9 +36,9 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
32
36
|
forceAmp: !1,
|
|
33
37
|
resetDataSavedFlag: !1,
|
|
34
38
|
disableLineHeightsReplace: !0
|
|
35
|
-
}, ...t },
|
|
36
|
-
callback: (
|
|
37
|
-
|
|
39
|
+
}, ...t }, u = {
|
|
40
|
+
callback: (m, C, f, S, g) => {
|
|
41
|
+
m ? a(m) : e({
|
|
38
42
|
html: C,
|
|
39
43
|
ampHtml: f,
|
|
40
44
|
ampErrors: v(S ?? []),
|
|
@@ -43,22 +47,22 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
43
47
|
},
|
|
44
48
|
...o
|
|
45
49
|
};
|
|
46
|
-
window.StripoEditorApi.actionsApi.compileEmail(
|
|
50
|
+
window.StripoEditorApi.actionsApi.compileEmail(u);
|
|
47
51
|
}
|
|
48
52
|
);
|
|
49
53
|
return {
|
|
50
54
|
getCompiledEmail: l,
|
|
51
|
-
getTemplateData: () =>
|
|
55
|
+
getTemplateData: () => p(
|
|
52
56
|
"getTemplateData",
|
|
53
|
-
|
|
57
|
+
T,
|
|
54
58
|
(t) => {
|
|
55
|
-
const e = ({ html: a, css: i, width: o, height: E, utmParams:
|
|
59
|
+
const e = ({ html: a, css: i, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
|
|
56
60
|
html: a,
|
|
57
61
|
css: i,
|
|
58
62
|
width: o,
|
|
59
63
|
height: E,
|
|
60
|
-
utmParams:
|
|
61
|
-
syncModulesIds:
|
|
64
|
+
utmParams: u,
|
|
65
|
+
syncModulesIds: m
|
|
62
66
|
});
|
|
63
67
|
window.StripoEditorApi.actionsApi.getTemplateData(e);
|
|
64
68
|
}
|
|
@@ -105,13 +109,13 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
105
109
|
}),
|
|
106
110
|
updateHtmlAndCss: (t, e) => {
|
|
107
111
|
const { actionsApi: a } = window.StripoEditorApi;
|
|
108
|
-
return
|
|
112
|
+
return p("updateHtmlAndCss", D, (i) => {
|
|
109
113
|
a.updateHtmlAndCss(t, e, () => i());
|
|
110
114
|
});
|
|
111
115
|
},
|
|
112
|
-
editorSave: () =>
|
|
116
|
+
editorSave: () => p(
|
|
113
117
|
"save",
|
|
114
|
-
|
|
118
|
+
T,
|
|
115
119
|
(t) => {
|
|
116
120
|
window.StripoEditorApi.actionsApi.save((e) => {
|
|
117
121
|
if (e) {
|
|
@@ -1,70 +1,138 @@
|
|
|
1
|
-
import { useEmailTemplateApplier as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { useTranslations as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { useEmailTemplateApplier as z, resetEmailTemplateApplier as J } from "./useEmailTemplateApplier.js";
|
|
2
|
+
import { useToaster as Q } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as V } from "./useTranslations.js";
|
|
4
|
+
import { ToasterTypeOptions as Z } from "../enums/toaster.js";
|
|
5
|
+
import { useGuidoEmailEditorStore as W } from "../stores/guido-email-editor.js";
|
|
6
|
+
import { getActivePinia as k } from "pinia";
|
|
7
|
+
import { onUnmounted as tt, watch as et } from "vue";
|
|
8
|
+
const rt = "email_template", nt = "chat", ot = "guido:debug:ai", it = 2, lt = 500, ct = (b, p) => `${b}:${p ?? 1}`;
|
|
9
|
+
let S = null;
|
|
10
|
+
const at = () => {
|
|
8
11
|
if (typeof window > "u")
|
|
9
12
|
return !1;
|
|
10
13
|
try {
|
|
11
|
-
return window.localStorage.getItem(
|
|
14
|
+
return window.localStorage.getItem(ot) === "1";
|
|
12
15
|
} catch {
|
|
13
16
|
return !1;
|
|
14
17
|
}
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
+
}, bt = () => {
|
|
19
|
+
const b = k();
|
|
20
|
+
if (!b)
|
|
18
21
|
return;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const p = W(), M = Symbol("cortexBlueprintBridge");
|
|
23
|
+
S = M, p.$patch((t) => {
|
|
24
|
+
t.bridgeActive = !0;
|
|
25
|
+
});
|
|
26
|
+
const { markPending: F, applyTemplate: H, applyTemplateDebounced: O } = z(), { showToaster: C } = Q(), G = V(), E = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
27
|
+
let s = null;
|
|
28
|
+
const d = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), B = at();
|
|
29
|
+
let w = null, m = null, A;
|
|
30
|
+
const K = (t, r) => {
|
|
31
|
+
B && console.debug(`[guido:cortex] msg=${t ?? "?"} type=${(r == null ? void 0 : r.type) ?? "?"}`, r);
|
|
32
|
+
}, U = () => new Set((A == null ? void 0 : A.appliedBlueprintKeys) ?? []), Y = (t) => t instanceof Error ? t.message : String(t), D = (t, r, n, e) => {
|
|
33
|
+
if (S !== M)
|
|
34
|
+
return;
|
|
35
|
+
const o = p.applyAcks[t], c = Math.max(Date.now(), ((o == null ? void 0 : o.ackAt) ?? 0) + 1), a = { status: r, requestedAt: n, ackAt: c };
|
|
36
|
+
e !== void 0 && (a.error = Y(e)), p.$patch((l) => {
|
|
37
|
+
l.applyAcks = { ...l.applyAcks, [t]: a };
|
|
38
|
+
});
|
|
39
|
+
}, I = (t) => (d.get(t) ?? 0) > 0, P = (t) => (s == null ? void 0 : s.key) === t, v = async (t, r, n) => {
|
|
40
|
+
var a, l, h;
|
|
41
|
+
const e = ((a = r.blueprintData) == null ? void 0 : a.html) ?? "", o = ((l = r.blueprintData) == null ? void 0 : l.css) ?? "", c = r.applyRequestedAt ?? 0;
|
|
42
|
+
d.set(t, (d.get(t) ?? 0) + 1);
|
|
43
|
+
try {
|
|
44
|
+
const i = n === "debounced" ? await O(t, { html: e, css: o }) : await H(t, { html: e, css: o });
|
|
45
|
+
if (i.status === "superseded")
|
|
46
|
+
return;
|
|
47
|
+
if (i.status === "applied") {
|
|
48
|
+
E.set(t, e), u.delete(t), D(t, "applied", c);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const y = u.get(t), j = (y == null ? void 0 : y.html) === e ? y.count + 1 : 1;
|
|
52
|
+
u.set(t, { html: e, count: j }), D(t, "failed", c, i.error);
|
|
53
|
+
} catch (i) {
|
|
54
|
+
console.error("[guido:apply] apply threw before it could settle", i), D(t, "failed", c, i);
|
|
55
|
+
} finally {
|
|
56
|
+
d.set(t, (d.get(t) ?? 1) - 1);
|
|
57
|
+
const i = T.get(t);
|
|
58
|
+
i && !I(t) && (T.delete(t), P(t) && (((h = i.blueprintData) == null ? void 0 : h.html) ?? "") !== e && v(t, i, n));
|
|
59
|
+
}
|
|
60
|
+
}, N = (t) => {
|
|
61
|
+
var h;
|
|
62
|
+
if (t.blueprintType !== rt)
|
|
29
63
|
return;
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
64
|
+
const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
|
|
65
|
+
if (!r || !n)
|
|
32
66
|
return;
|
|
33
|
-
|
|
34
|
-
|
|
67
|
+
const e = ct(r, t.version);
|
|
68
|
+
if (!t.applyRequested) {
|
|
69
|
+
F(e);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const o = t.applyRequestedAt ?? 0, c = _.get(e);
|
|
73
|
+
if (c === void 0 || o > c) {
|
|
74
|
+
const i = c === void 0;
|
|
75
|
+
if (_.set(e, o), u.delete(e), (!s || o >= s.requestedAt) && (s = { key: e, requestedAt: o }), i && U().has(e)) {
|
|
76
|
+
E.set(e, n);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
v(e, t, "immediate");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const a = E.get(e);
|
|
83
|
+
if (a === n || !P(e))
|
|
35
84
|
return;
|
|
85
|
+
const l = u.get(e);
|
|
86
|
+
if (!((l == null ? void 0 : l.html) === n && l.count >= it)) {
|
|
87
|
+
if (a === void 0) {
|
|
88
|
+
if (I(e)) {
|
|
89
|
+
T.set(e, t);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
v(e, t, "immediate");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
f.get(e) !== n && (f.set(e, n), v(e, t, "debounced").finally(() => {
|
|
96
|
+
f.get(e) === n && f.delete(e);
|
|
97
|
+
}));
|
|
36
98
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Array.isArray(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
case "error":
|
|
56
|
-
s(e);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
99
|
+
}, R = (t) => t === void 0 || g.has(t) ? !1 : (g.add(t), C({
|
|
100
|
+
type: Z.Error,
|
|
101
|
+
message: G("newsletter.ai-template-failed")
|
|
102
|
+
}), !0), X = (t) => {
|
|
103
|
+
Array.isArray(t) && t.forEach((r) => {
|
|
104
|
+
const n = r == null ? void 0 : r.id;
|
|
105
|
+
(r == null ? void 0 : r.isError) === !0 && R(n) && B && console.debug(`[guido:cortex] message-level error id=${n}`, r);
|
|
106
|
+
const e = r == null ? void 0 : r.segments;
|
|
107
|
+
Array.isArray(e) && e.forEach((o) => {
|
|
108
|
+
if (o)
|
|
109
|
+
switch (K(n, o), o.type) {
|
|
110
|
+
case "blueprint":
|
|
111
|
+
N(o);
|
|
112
|
+
break;
|
|
113
|
+
case "error":
|
|
114
|
+
R(n);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
60
117
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
118
|
+
});
|
|
119
|
+
}, $ = () => {
|
|
120
|
+
w !== null && (clearInterval(w), w = null);
|
|
121
|
+
}, q = () => {
|
|
122
|
+
var t;
|
|
123
|
+
return (t = b._s) == null ? void 0 : t.get(nt);
|
|
124
|
+
}, L = (t) => {
|
|
125
|
+
A = t, m = et(() => t.messages, X, { deep: !0, immediate: !0 });
|
|
126
|
+
}, x = q();
|
|
127
|
+
x ? L(x) : w = setInterval(() => {
|
|
128
|
+
const t = q();
|
|
129
|
+
t && ($(), L(t));
|
|
130
|
+
}, lt), tt(() => {
|
|
131
|
+
$(), m == null || m(), A = void 0, E.clear(), f.clear(), _.clear(), u.clear(), s = null, d.clear(), T.clear(), g.clear(), S === M && (S = null, p.$patch((t) => {
|
|
132
|
+
t.bridgeActive = !1, t.applyAcks = {};
|
|
133
|
+
}), J());
|
|
66
134
|
});
|
|
67
135
|
};
|
|
68
136
|
export {
|
|
69
|
-
|
|
137
|
+
bt as useCortexBlueprintBridge
|
|
70
138
|
};
|
|
@@ -1,67 +1,81 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import P from "../static/styles/components/
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import p from "../static/assets/icons/filled-arrow-rising.svg.js";
|
|
2
|
+
import s from "../static/assets/icons/line-change.svg.js";
|
|
3
|
+
import a from "../static/assets/icons/line-delete.svg.js";
|
|
4
|
+
import f from "../static/assets/icons/line-info.svg.js";
|
|
5
|
+
import c from "../static/assets/icons/line-plus.svg.js";
|
|
6
|
+
import l from "../static/styles/base.css.js";
|
|
7
|
+
import C from "../static/styles/components/alert-message.css.js";
|
|
8
|
+
import d from "../static/styles/components/amp-block.css.js";
|
|
9
|
+
import u from "../static/styles/components/base-input.css.js";
|
|
10
|
+
import h from "../static/styles/components/button-group.css.js";
|
|
11
|
+
import I from "../static/styles/components/button.css.js";
|
|
12
|
+
import g from "../static/styles/components/combobox.css.js";
|
|
13
|
+
import w from "../static/styles/components/counter.css.js";
|
|
14
|
+
import y from "../static/styles/components/dropdown-menu.css.js";
|
|
15
|
+
import A from "../static/styles/components/loader.css.js";
|
|
16
|
+
import $ from "../static/styles/components/narrow-panel.css.js";
|
|
17
|
+
import b from "../static/styles/components/popup.css.js";
|
|
18
|
+
import B from "../static/styles/components/recommendation-strategy.css.js";
|
|
19
|
+
import D from "../static/styles/components/skeleton.css.js";
|
|
20
|
+
import R from "../static/styles/components/switcher.css.js";
|
|
21
|
+
import P from "../static/styles/components/tabs.css.js";
|
|
22
|
+
import T from "../static/styles/components/tools.css.js";
|
|
23
|
+
import x from "../static/styles/components/version-history.css.js";
|
|
24
|
+
import M from "../static/styles/components/wide-panel.css.js";
|
|
25
|
+
import O from "../static/styles/variables.css.js";
|
|
26
|
+
function o(i, r) {
|
|
27
|
+
return `--guido-icon-${i}: url("data:image/svg+xml,${encodeURIComponent(r.trim())}");`;
|
|
25
28
|
}
|
|
26
|
-
const
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
${
|
|
30
|
-
}
|
|
31
|
-
|
|
29
|
+
const V = `:host {
|
|
30
|
+
${o("line-change", s)}
|
|
31
|
+
${o("line-delete", a)}
|
|
32
|
+
${o("filled-arrow-rising", p)}
|
|
33
|
+
${o("line-info", f)}
|
|
34
|
+
${o("line-plus", c)}
|
|
35
|
+
}`, W = [
|
|
36
|
+
O,
|
|
32
37
|
// Must be on top
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
V,
|
|
39
|
+
l,
|
|
35
40
|
// Must be on top
|
|
36
|
-
s,
|
|
37
41
|
C,
|
|
38
|
-
a,
|
|
39
|
-
f,
|
|
40
|
-
c,
|
|
41
|
-
u,
|
|
42
|
-
l,
|
|
43
42
|
d,
|
|
43
|
+
u,
|
|
44
44
|
h,
|
|
45
|
-
g,
|
|
46
45
|
I,
|
|
46
|
+
g,
|
|
47
|
+
w,
|
|
47
48
|
y,
|
|
48
|
-
|
|
49
|
-
B,
|
|
49
|
+
A,
|
|
50
50
|
$,
|
|
51
|
+
b,
|
|
52
|
+
D,
|
|
53
|
+
R,
|
|
51
54
|
P,
|
|
52
|
-
|
|
55
|
+
T,
|
|
56
|
+
x,
|
|
57
|
+
M,
|
|
58
|
+
B
|
|
53
59
|
// Last: overrides button.css / wide-panel.css defaults
|
|
54
60
|
].join(`
|
|
55
61
|
|
|
56
|
-
`),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
62
|
+
`), _ = 3e4;
|
|
63
|
+
let e = null;
|
|
64
|
+
function k() {
|
|
65
|
+
return e || (e = new CSSStyleSheet(), e.replaceSync(W)), e;
|
|
66
|
+
}
|
|
67
|
+
const po = () => ({ importCss: () => {
|
|
68
|
+
const r = k(), S = Date.now() + _, n = () => {
|
|
69
|
+
var m;
|
|
70
|
+
const t = (m = document.querySelector("ui-editor")) == null ? void 0 : m.shadowRoot;
|
|
71
|
+
if (t) {
|
|
72
|
+
t.adoptedStyleSheets.includes(r) || (t.adoptedStyleSheets = [...t.adoptedStyleSheets, r]);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
Date.now() < S && requestAnimationFrame(n);
|
|
76
|
+
};
|
|
77
|
+
n();
|
|
64
78
|
} });
|
|
65
79
|
export {
|
|
66
|
-
|
|
80
|
+
po as useCustomInterfaceAppearance
|
|
67
81
|
};
|
|
@@ -1,59 +1,115 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { useActionsApi as x } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as z } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as N } from "./useEditorLock.js";
|
|
4
|
+
import { useToaster as K } from "./useToaster.js";
|
|
5
|
+
import { useTranslations as R } from "./useTranslations.js";
|
|
6
|
+
import { ToasterTypeOptions as U } from "../enums/toaster.js";
|
|
7
|
+
import { useDynamicContentStore as F } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useEditorStore as G } from "../stores/editor.js";
|
|
9
|
+
import { flattenDynamicContentList as $ } from "../utils/genericUtil.js";
|
|
10
|
+
import { extractUsedDynamicContent as j } from "../utils/registerUsedDynamicContent.js";
|
|
11
|
+
import { ref as J, watch as V } from "vue";
|
|
12
|
+
const W = 250, M = 12e4, X = 1e3, p = { status: "superseded" }, A = { status: "failed", error: new Error("Blueprint has no html to apply") }, a = J({}), O = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
13
|
+
let d = null;
|
|
14
|
+
const E = () => {
|
|
15
|
+
d && (clearInterval(d), d = null);
|
|
16
|
+
}, ue = () => {
|
|
17
|
+
const { updateHtmlAndCss: i } = x(), { runExclusive: P } = N(), { showToaster: T } = K(), w = R(), { template: _ } = z(), b = F(), g = G(), y = (e, t) => {
|
|
18
|
+
m.get(e) !== t && (m.set(e, t), T({
|
|
19
|
+
type: U.Error,
|
|
20
|
+
message: w("newsletter.ai-template-failed-apply")
|
|
21
|
+
}));
|
|
22
|
+
}, C = () => {
|
|
23
|
+
var e, t;
|
|
24
|
+
return g.isStripoInitialized && typeof ((t = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : t.updateHtmlAndCss) == "function";
|
|
25
|
+
}, L = (e) => {
|
|
26
|
+
a.value[e] === void 0 && (a.value = { ...a.value, [e]: "pending" });
|
|
27
|
+
}, l = (e, t) => {
|
|
28
|
+
a.value = { ...a.value, [e]: t };
|
|
29
|
+
}, Q = (e) => {
|
|
30
|
+
var t;
|
|
19
31
|
try {
|
|
20
|
-
r(t
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const n = w((c = T.value) == null ? void 0 : c.dynamicContentList), i = S(t, n);
|
|
25
|
-
i.length > 0 && d.registerDynamicContent(i);
|
|
26
|
-
} catch {
|
|
27
|
-
}
|
|
28
|
-
u.get(e) !== t && (u.set(e, t), m({
|
|
29
|
-
type: f.Success,
|
|
30
|
-
message: g("newsletter.ai-template-applied", "Template applied to the editor")
|
|
31
|
-
}));
|
|
32
|
-
} catch (n) {
|
|
33
|
-
o.value = { ...o.value, [e]: "failed" }, m({
|
|
34
|
-
type: f.Error,
|
|
35
|
-
message: n instanceof Error ? n.message : "Failed to apply template"
|
|
36
|
-
});
|
|
32
|
+
const r = $((t = _.value) == null ? void 0 : t.dynamicContentList), n = j(e, r);
|
|
33
|
+
n.length > 0 && b.registerDynamicContent(n);
|
|
34
|
+
} catch {
|
|
37
35
|
}
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
}, H = (e, t) => {
|
|
37
|
+
m.delete(e), O.get(e) !== t && (O.set(e, t), T({
|
|
38
|
+
type: U.Success,
|
|
39
|
+
message: w("newsletter.ai-template-applied")
|
|
40
|
+
}));
|
|
41
|
+
}, D = async (e, t, r) => {
|
|
42
|
+
const n = (u.get(e) ?? 0) + 1;
|
|
43
|
+
u.set(e, n), l(e, "applying");
|
|
44
|
+
try {
|
|
45
|
+
await P(() => i(t, r));
|
|
46
|
+
} catch (o) {
|
|
47
|
+
return u.get(e) !== n ? p : (console.error("[guido:apply] editor did not acknowledge the template apply", o), l(e, "failed"), y(e, t), { status: "failed", error: o });
|
|
48
|
+
}
|
|
49
|
+
return u.get(e) !== n ? p : (l(e, "applied"), Q(t), H(e, t), { status: "applied" });
|
|
50
|
+
}, I = (e) => {
|
|
51
|
+
const t = s.get(e);
|
|
52
|
+
t && (clearTimeout(t.timer), s.delete(e), t.settle(p));
|
|
53
|
+
}, S = (e) => {
|
|
54
|
+
const t = c.get(e);
|
|
55
|
+
t && (clearTimeout(t.timer), c.delete(e), t.settle(p));
|
|
56
|
+
}, B = () => {
|
|
57
|
+
[...c.keys()].forEach(S);
|
|
58
|
+
}, h = async () => {
|
|
59
|
+
if (s.size === 0) {
|
|
60
|
+
E();
|
|
46
61
|
return;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
}
|
|
63
|
+
if (!C())
|
|
64
|
+
return;
|
|
65
|
+
E();
|
|
66
|
+
const e = [...s.entries()];
|
|
67
|
+
s.clear(), e.forEach(([, o]) => clearTimeout(o.timer));
|
|
68
|
+
const t = e.pop();
|
|
69
|
+
if (e.forEach(([o, f]) => {
|
|
70
|
+
l(o, "failed"), f.settle({ status: "failed", error: new Error("Displaced by a newer apply") });
|
|
71
|
+
}), !t)
|
|
72
|
+
return;
|
|
73
|
+
const [r, n] = t;
|
|
74
|
+
n.settle(await D(r, n.html, n.css));
|
|
75
|
+
}, q = (e, t, r) => new Promise((n) => {
|
|
76
|
+
I(e);
|
|
77
|
+
const o = setTimeout(() => {
|
|
78
|
+
s.delete(e), l(e, "failed"), y(e, t), n({
|
|
79
|
+
status: "failed",
|
|
80
|
+
error: new Error(`Editor did not become ready within ${M}ms`)
|
|
81
|
+
});
|
|
82
|
+
}, M);
|
|
83
|
+
s.set(e, { html: t, css: r, timer: o, settle: n }), l(e, "applying"), d ?? (d = setInterval(() => {
|
|
84
|
+
h();
|
|
85
|
+
}, X));
|
|
86
|
+
}), v = (e, t, r) => C() ? D(e, t, r) : q(e, t, r);
|
|
87
|
+
return V(() => g.isStripoInitialized, (e) => {
|
|
88
|
+
e && h();
|
|
89
|
+
}, { immediate: !0 }), { applyStatus: a, markPending: L, applyTemplate: (e, t) => {
|
|
90
|
+
const { html: r } = t;
|
|
91
|
+
return r ? (B(), v(e, r, t.css ?? "")) : Promise.resolve(A);
|
|
92
|
+
}, applyTemplateDebounced: (e, t) => {
|
|
93
|
+
const { html: r } = t;
|
|
94
|
+
if (!r)
|
|
95
|
+
return Promise.resolve(A);
|
|
96
|
+
const n = t.css ?? "";
|
|
97
|
+
return new Promise((o) => {
|
|
98
|
+
S(e);
|
|
99
|
+
const f = setTimeout(() => {
|
|
100
|
+
c.delete(e), v(e, r, n).then(o);
|
|
101
|
+
}, W);
|
|
102
|
+
c.set(e, { timer: f, settle: o });
|
|
103
|
+
});
|
|
52
104
|
} };
|
|
53
|
-
},
|
|
54
|
-
|
|
105
|
+
}, me = () => {
|
|
106
|
+
c.forEach((i) => {
|
|
107
|
+
clearTimeout(i.timer), i.settle(p);
|
|
108
|
+
}), c.clear(), s.forEach((i) => {
|
|
109
|
+
clearTimeout(i.timer), i.settle(p);
|
|
110
|
+
}), s.clear(), E(), m.clear(), a.value = {};
|
|
55
111
|
};
|
|
56
112
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
113
|
+
me as resetEmailTemplateApplier,
|
|
114
|
+
ue as useEmailTemplateApplier
|
|
59
115
|
};
|