@useinsider/guido 3.19.0-beta.acb00a2 → 3.19.0-beta.c0e0606
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.
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { useToaster as
|
|
5
|
-
import { useTranslations as
|
|
6
|
-
import { ToasterTypeOptions as
|
|
7
|
-
import { useDynamicContentStore as
|
|
8
|
-
import { useEditorStore as
|
|
9
|
-
import { flattenDynamicContentList as
|
|
10
|
-
import { extractUsedDynamicContent as
|
|
11
|
-
import { ref as
|
|
12
|
-
const
|
|
1
|
+
import { useActionsApi as z } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as N } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as K } from "./useEditorLock.js";
|
|
4
|
+
import { useToaster as R } from "./useToaster.js";
|
|
5
|
+
import { useTranslations as F } from "./useTranslations.js";
|
|
6
|
+
import { ToasterTypeOptions as v } from "../enums/toaster.js";
|
|
7
|
+
import { useDynamicContentStore as G } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useEditorStore as $ } from "../stores/editor.js";
|
|
9
|
+
import { flattenDynamicContentList as j } from "../utils/genericUtil.js";
|
|
10
|
+
import { extractUsedDynamicContent as J } from "../utils/registerUsedDynamicContent.js";
|
|
11
|
+
import { ref as V, watch as W } from "vue";
|
|
12
|
+
const X = 250, U = 12e4, Y = 1e3, p = { status: "superseded" }, M = { status: "failed", error: new Error("Blueprint has no html to apply") }, a = V({}), A = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
13
13
|
let d = null;
|
|
14
14
|
const E = () => {
|
|
15
15
|
d && (clearInterval(d), d = null);
|
|
16
|
-
},
|
|
17
|
-
const { updateHtmlAndCss: i } =
|
|
18
|
-
|
|
19
|
-
type:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
}, me = () => {
|
|
17
|
+
const { updateHtmlAndCss: i } = z(), { runExclusive: O } = K(), { showToaster: P } = R(), _ = F(), { template: b } = N(), L = G(), T = $(), w = (e, t) => {
|
|
18
|
+
try {
|
|
19
|
+
P({ type: e, message: _(t) });
|
|
20
|
+
} catch (o) {
|
|
21
|
+
console.error("[guido:apply] could not show the apply toast", o);
|
|
22
|
+
}
|
|
23
|
+
}, g = (e, t) => {
|
|
24
|
+
m.get(e) !== t && (m.set(e, t), w(v.Error, "newsletter.ai-template-failed-apply"));
|
|
25
|
+
}, y = () => {
|
|
23
26
|
var e, t;
|
|
24
|
-
return
|
|
25
|
-
},
|
|
27
|
+
return T.isStripoInitialized && typeof ((t = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : t.updateHtmlAndCss) == "function";
|
|
28
|
+
}, Q = (e) => {
|
|
26
29
|
a.value[e] === void 0 && (a.value = { ...a.value, [e]: "pending" });
|
|
27
30
|
}, l = (e, t) => {
|
|
28
31
|
a.value = { ...a.value, [e]: t };
|
|
29
|
-
},
|
|
32
|
+
}, H = (e) => {
|
|
30
33
|
var t;
|
|
31
34
|
try {
|
|
32
|
-
const
|
|
33
|
-
|
|
35
|
+
const o = j((t = b.value) == null ? void 0 : t.dynamicContentList), r = J(e, o);
|
|
36
|
+
r.length > 0 && L.registerDynamicContent(r);
|
|
34
37
|
} catch {
|
|
35
38
|
}
|
|
36
|
-
},
|
|
37
|
-
m.delete(e),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, D = async (e, t, r) => {
|
|
42
|
-
const n = (u.get(e) ?? 0) + 1;
|
|
43
|
-
u.set(e, n), l(e, "applying");
|
|
39
|
+
}, I = (e, t) => {
|
|
40
|
+
m.delete(e), A.get(e) !== t && (A.set(e, t), w(v.Success, "newsletter.ai-template-applied"));
|
|
41
|
+
}, h = async (e, t, o) => {
|
|
42
|
+
const r = (u.get(e) ?? 0) + 1;
|
|
43
|
+
u.set(e, r), l(e, "applying");
|
|
44
44
|
try {
|
|
45
|
-
await
|
|
46
|
-
} catch (
|
|
47
|
-
return u.get(e) !==
|
|
45
|
+
await O(() => i(t, o));
|
|
46
|
+
} catch (n) {
|
|
47
|
+
return u.get(e) !== r ? p : (console.error("[guido:apply] editor did not acknowledge the template apply", n), l(e, "failed"), g(e, t), { status: "failed", error: n });
|
|
48
48
|
}
|
|
49
|
-
return u.get(e) !==
|
|
50
|
-
},
|
|
49
|
+
return u.get(e) !== r ? p : (l(e, "applied"), H(t), I(e, t), { status: "applied" });
|
|
50
|
+
}, B = (e) => {
|
|
51
51
|
const t = s.get(e);
|
|
52
52
|
t && (clearTimeout(t.timer), s.delete(e), t.settle(p));
|
|
53
|
-
},
|
|
53
|
+
}, C = (e) => {
|
|
54
54
|
const t = c.get(e);
|
|
55
55
|
t && (clearTimeout(t.timer), c.delete(e), t.settle(p));
|
|
56
|
-
},
|
|
57
|
-
[...c.keys()].forEach(
|
|
58
|
-
},
|
|
56
|
+
}, q = () => {
|
|
57
|
+
[...c.keys()].forEach(C);
|
|
58
|
+
}, D = async () => {
|
|
59
59
|
if (s.size === 0) {
|
|
60
60
|
E();
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
if (!
|
|
63
|
+
if (!y())
|
|
64
64
|
return;
|
|
65
65
|
E();
|
|
66
66
|
const e = [...s.entries()];
|
|
67
|
-
s.clear(), e.forEach(([,
|
|
67
|
+
s.clear(), e.forEach(([, n]) => clearTimeout(n.timer));
|
|
68
68
|
const t = e.pop();
|
|
69
|
-
if (e.forEach(([
|
|
70
|
-
l(
|
|
69
|
+
if (e.forEach(([n, f]) => {
|
|
70
|
+
l(n, "failed"), f.settle({ status: "failed", error: new Error("Displaced by a newer apply") });
|
|
71
71
|
}), !t)
|
|
72
72
|
return;
|
|
73
|
-
const [
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
s.delete(e), l(e, "failed"),
|
|
73
|
+
const [o, r] = t;
|
|
74
|
+
r.settle(await h(o, r.html, r.css));
|
|
75
|
+
}, x = (e, t, o) => new Promise((r) => {
|
|
76
|
+
B(e);
|
|
77
|
+
const n = setTimeout(() => {
|
|
78
|
+
s.delete(e), l(e, "failed"), g(e, t), r({
|
|
79
79
|
status: "failed",
|
|
80
|
-
error: new Error(`Editor did not become ready within ${
|
|
80
|
+
error: new Error(`Editor did not become ready within ${U}ms`)
|
|
81
81
|
});
|
|
82
|
-
},
|
|
83
|
-
s.set(e, { html: t, css:
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
}),
|
|
87
|
-
return
|
|
88
|
-
e &&
|
|
89
|
-
}, { immediate: !0 }), { applyStatus: a, markPending:
|
|
90
|
-
const { html:
|
|
91
|
-
return
|
|
82
|
+
}, U);
|
|
83
|
+
s.set(e, { html: t, css: o, timer: n, settle: r }), l(e, "applying"), d ?? (d = setInterval(() => {
|
|
84
|
+
D();
|
|
85
|
+
}, Y));
|
|
86
|
+
}), S = (e, t, o) => y() ? h(e, t, o) : x(e, t, o);
|
|
87
|
+
return W(() => T.isStripoInitialized, (e) => {
|
|
88
|
+
e && D();
|
|
89
|
+
}, { immediate: !0 }), { applyStatus: a, markPending: Q, applyTemplate: (e, t) => {
|
|
90
|
+
const { html: o } = t;
|
|
91
|
+
return o ? (q(), S(e, o, t.css ?? "")) : Promise.resolve(M);
|
|
92
92
|
}, applyTemplateDebounced: (e, t) => {
|
|
93
|
-
const { html:
|
|
94
|
-
if (!
|
|
95
|
-
return Promise.resolve(
|
|
96
|
-
const
|
|
97
|
-
return new Promise((
|
|
98
|
-
|
|
93
|
+
const { html: o } = t;
|
|
94
|
+
if (!o)
|
|
95
|
+
return Promise.resolve(M);
|
|
96
|
+
const r = t.css ?? "";
|
|
97
|
+
return new Promise((n) => {
|
|
98
|
+
C(e);
|
|
99
99
|
const f = setTimeout(() => {
|
|
100
|
-
c.delete(e),
|
|
101
|
-
},
|
|
102
|
-
c.set(e, { timer: f, settle:
|
|
100
|
+
c.delete(e), S(e, o, r).then(n);
|
|
101
|
+
}, X);
|
|
102
|
+
c.set(e, { timer: f, settle: n });
|
|
103
103
|
});
|
|
104
104
|
} };
|
|
105
|
-
},
|
|
105
|
+
}, de = () => {
|
|
106
106
|
c.forEach((i) => {
|
|
107
107
|
clearTimeout(i.timer), i.settle(p);
|
|
108
108
|
}), c.clear(), s.forEach((i) => {
|
|
@@ -110,6 +110,6 @@ const E = () => {
|
|
|
110
110
|
}), s.clear(), E(), m.clear(), a.value = {};
|
|
111
111
|
};
|
|
112
112
|
export {
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
de as resetEmailTemplateApplier,
|
|
114
|
+
me as useEmailTemplateApplier
|
|
115
115
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.19.0-beta.
|
|
3
|
+
"version": "3.19.0-beta.c0e0606",
|
|
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",
|