@useinsider/guido 3.18.0 → 3.18.1-beta.5cddb72
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/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +97 -87
- package/dist/components/organisms/header/EditorActions.vue.js +1 -1
- package/dist/components/organisms/header/EditorActions.vue2.js +54 -41
- package/dist/composables/useActionsApi.js +86 -67
- package/dist/composables/useAutoSave.js +31 -26
- package/dist/composables/useCortexBlueprintBridge.js +113 -54
- package/dist/composables/useEditorLock.js +20 -0
- package/dist/composables/useEmailTemplateApplier.js +93 -50
- package/dist/composables/useGuidoStateBridge.js +37 -31
- package/dist/composables/useSave.js +42 -39
- package/dist/composables/useTranslations.js +15 -8
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +4 -3
- package/dist/src/composables/useEditorLock.d.ts +10 -0
- package/dist/src/composables/useEmailTemplateApplier.d.ts +22 -2
- package/dist/src/composables/useTranslations.d.ts +5 -0
- package/dist/src/stores/guido-email-editor.d.ts +29 -7
- package/dist/stores/guido-email-editor.js +5 -1
- package/package.json +2 -2
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { useConfig as
|
|
1
|
+
import { useConfig as E } from "./useConfig.js";
|
|
2
|
+
import { useEditorLock as p } from "./useEditorLock.js";
|
|
2
3
|
import { useAutosaveStore as A, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
|
|
3
|
-
import { useEditorStore as
|
|
4
|
-
import { computed as
|
|
5
|
-
const
|
|
6
|
-
const { isFeatureEnabled: S } =
|
|
4
|
+
import { useEditorStore as f } from "../stores/editor.js";
|
|
5
|
+
import { computed as y, watch as I, onUnmounted as L } from "vue";
|
|
6
|
+
const w = 18e4, v = 6e4, R = (b) => {
|
|
7
|
+
const { isFeatureEnabled: S } = E(), o = f(), t = A(), { isEditorBusy: g } = p();
|
|
7
8
|
let i = null, c = 0;
|
|
8
|
-
const u =
|
|
9
|
+
const u = y(
|
|
9
10
|
() => S("autosave") && t.isOn
|
|
10
|
-
),
|
|
11
|
-
hasChanges:
|
|
12
|
-
isInSaveableState:
|
|
13
|
-
}),
|
|
11
|
+
), m = () => o.hasChanges && o.isInSaveableState, h = () => ({
|
|
12
|
+
hasChanges: o.hasChanges,
|
|
13
|
+
isInSaveableState: o.isInSaveableState
|
|
14
|
+
}), r = async (e) => {
|
|
14
15
|
if (!u.value) {
|
|
15
16
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
|
-
if (!
|
|
19
|
+
if (!m()) {
|
|
19
20
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates: h() });
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
@@ -23,15 +24,19 @@ const I = 18e4, r = 6e4, T = (b) => {
|
|
|
23
24
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "already-saving" });
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
27
|
+
if (g()) {
|
|
28
|
+
console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
26
31
|
console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
|
|
27
32
|
try {
|
|
28
33
|
if (await b() === void 0) {
|
|
29
34
|
console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
|
|
30
35
|
return;
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
} catch (
|
|
34
|
-
console.debug("guido:autosave:error", { trigger: e, error:
|
|
37
|
+
o.hasChanges = !1, t.status = s.SAVED, t.lastSavedAt = /* @__PURE__ */ new Date(), console.debug("guido:autosave:save-complete", { trigger: e, at: t.lastSavedAt });
|
|
38
|
+
} catch (a) {
|
|
39
|
+
console.debug("guido:autosave:error", { trigger: e, error: a }), t.status = s.ERROR;
|
|
35
40
|
}
|
|
36
41
|
}, n = () => {
|
|
37
42
|
const { visibilityState: e } = document;
|
|
@@ -40,32 +45,32 @@ const I = 18e4, r = 6e4, T = (b) => {
|
|
|
40
45
|
isActive: u.value
|
|
41
46
|
}), e !== "hidden")
|
|
42
47
|
return;
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
48
|
+
const a = Date.now() - c;
|
|
49
|
+
if (a < v) {
|
|
45
50
|
console.debug("guido:autosave:visibility-debounced", {
|
|
46
|
-
sinceLastMs:
|
|
47
|
-
debounceMs:
|
|
51
|
+
sinceLastMs: a,
|
|
52
|
+
debounceMs: v
|
|
48
53
|
});
|
|
49
54
|
return;
|
|
50
55
|
}
|
|
51
|
-
c = Date.now(),
|
|
56
|
+
c = Date.now(), r("visibility");
|
|
52
57
|
}, d = () => {
|
|
53
58
|
i && (clearInterval(i), i = null);
|
|
54
|
-
},
|
|
59
|
+
}, l = () => {
|
|
55
60
|
document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
|
|
56
61
|
};
|
|
57
|
-
|
|
62
|
+
I(
|
|
58
63
|
u,
|
|
59
64
|
(e) => {
|
|
60
65
|
console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
|
|
61
|
-
console.debug("guido:autosave:interval-tick"),
|
|
62
|
-
},
|
|
66
|
+
console.debug("guido:autosave:interval-tick"), r("interval");
|
|
67
|
+
}, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), l(), t.status = s.IDLE);
|
|
63
68
|
},
|
|
64
69
|
{ immediate: !0 }
|
|
65
|
-
),
|
|
66
|
-
d(),
|
|
70
|
+
), L(() => {
|
|
71
|
+
d(), l(), t.status = s.IDLE, t.lastSavedAt = null;
|
|
67
72
|
});
|
|
68
73
|
};
|
|
69
74
|
export {
|
|
70
|
-
|
|
75
|
+
R as useAutoSave
|
|
71
76
|
};
|
|
@@ -1,70 +1,129 @@
|
|
|
1
|
-
import { useEmailTemplateApplier as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import {
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { useEmailTemplateApplier as Y, resetEmailTemplateApplier as N } from "./useEmailTemplateApplier.js";
|
|
2
|
+
import { useToaster as X } from "./useToaster.js";
|
|
3
|
+
import { useTranslationWithFallback as j } from "./useTranslations.js";
|
|
4
|
+
import { ToasterTypeOptions as z } from "../enums/toaster.js";
|
|
5
|
+
import { useGuidoEmailEditorStore as J } from "../stores/guido-email-editor.js";
|
|
6
|
+
import { getActivePinia as Q } from "pinia";
|
|
7
|
+
import { onUnmounted as V, watch as W } from "vue";
|
|
8
|
+
const Z = "email_template", tt = "chat", et = "guido:debug:ai", rt = 2, nt = 500, ot = (A, p) => `${A}:${p ?? 1}`;
|
|
9
|
+
let S = null;
|
|
10
|
+
const it = () => {
|
|
8
11
|
if (typeof window > "u")
|
|
9
12
|
return !1;
|
|
10
13
|
try {
|
|
11
|
-
return window.localStorage.getItem(
|
|
14
|
+
return window.localStorage.getItem(et) === "1";
|
|
12
15
|
} catch {
|
|
13
16
|
return !1;
|
|
14
17
|
}
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
+
}, ft = () => {
|
|
19
|
+
const A = Q();
|
|
20
|
+
if (!A)
|
|
18
21
|
return;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
|
|
22
|
+
const p = J(), _ = Symbol("cortexBlueprintBridge");
|
|
23
|
+
S = _, p.$patch((t) => {
|
|
24
|
+
t.bridgeActive = !0;
|
|
25
|
+
});
|
|
26
|
+
const { markPending: R, applyTemplate: q, applyTemplateDebounced: x } = Y(), { showToaster: C } = X(), H = j(), h = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), M = it();
|
|
27
|
+
let T = null, b = null, f;
|
|
28
|
+
const O = (t, e) => {
|
|
29
|
+
M && console.debug(`[guido:cortex] msg=${t ?? "?"} type=${(e == null ? void 0 : e.type) ?? "?"}`, e);
|
|
30
|
+
}, G = () => new Set((f == null ? void 0 : f.appliedBlueprintKeys) ?? []), K = (t) => t instanceof Error ? t.message : String(t), g = (t, e, o, r) => {
|
|
31
|
+
const n = p.applyAcks[t], l = Math.max(Date.now(), ((n == null ? void 0 : n.ackAt) ?? 0) + 1), a = { status: e, requestedAt: o, ackAt: l };
|
|
32
|
+
r !== void 0 && (a.error = K(r)), p.$patch((c) => {
|
|
33
|
+
c.applyAcks = { ...c.applyAcks, [t]: a };
|
|
34
|
+
});
|
|
35
|
+
}, D = (t) => (d.get(t) ?? 0) > 0, m = async (t, e, o, r) => {
|
|
36
|
+
var c, i, L;
|
|
37
|
+
const n = ((c = o.blueprintData) == null ? void 0 : c.html) ?? "", l = ((i = o.blueprintData) == null ? void 0 : i.css) ?? "", a = o.applyRequestedAt ?? 0;
|
|
38
|
+
d.set(t, (d.get(t) ?? 0) + 1);
|
|
39
|
+
try {
|
|
40
|
+
const s = r === "debounced" ? await x(e, { html: n, css: l }) : await q(e, { html: n, css: l });
|
|
41
|
+
if (s.status === "superseded")
|
|
42
|
+
return;
|
|
43
|
+
if (s.status === "applied") {
|
|
44
|
+
h.set(e, n), u.delete(t), g(t, "applied", a);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const w = u.get(t);
|
|
48
|
+
u.set(t, { html: n, count: (w == null ? void 0 : w.html) === n ? w.count + 1 : 1 }), g(t, "failed", a, s.error);
|
|
49
|
+
} finally {
|
|
50
|
+
d.set(t, (d.get(t) ?? 1) - 1);
|
|
51
|
+
const s = E.get(t);
|
|
52
|
+
s && !D(t) && (E.delete(t), (((L = s.blueprintData) == null ? void 0 : L.html) ?? "") !== n && m(t, e, s, r));
|
|
53
|
+
}
|
|
54
|
+
}, U = (t) => {
|
|
55
|
+
var c;
|
|
56
|
+
if (t.blueprintType !== Z)
|
|
29
57
|
return;
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
58
|
+
const { blueprintId: e } = t, o = (c = t.blueprintData) == null ? void 0 : c.html;
|
|
59
|
+
if (!e || !o)
|
|
32
60
|
return;
|
|
33
|
-
if (!
|
|
34
|
-
|
|
61
|
+
if (!t.applyRequested) {
|
|
62
|
+
R(e);
|
|
35
63
|
return;
|
|
36
64
|
}
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
const r = ot(e, t.version), n = t.applyRequestedAt ?? 0, l = v.get(r);
|
|
66
|
+
if (l === void 0 || n > l) {
|
|
67
|
+
const i = l === void 0;
|
|
68
|
+
if (v.set(r, n), u.delete(r), i && G().has(r)) {
|
|
69
|
+
h.set(e, o);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
m(r, e, t, "immediate");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const a = h.get(e);
|
|
76
|
+
if (a !== o) {
|
|
77
|
+
if (a === void 0) {
|
|
78
|
+
if (D(r)) {
|
|
79
|
+
E.set(r, t);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const i = u.get(r);
|
|
83
|
+
if ((i == null ? void 0 : i.html) === o && i.count >= rt)
|
|
84
|
+
return;
|
|
85
|
+
m(r, e, t, "immediate");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
m(r, e, t, "debounced");
|
|
89
|
+
}
|
|
90
|
+
}, B = (t) => t === void 0 || y.has(t) ? !1 : (y.add(t), C({
|
|
91
|
+
type: z.Error,
|
|
92
|
+
message: H("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
|
|
93
|
+
}), !0), k = (t) => {
|
|
94
|
+
Array.isArray(t) && t.forEach((e) => {
|
|
95
|
+
const o = e == null ? void 0 : e.id;
|
|
96
|
+
(e == null ? void 0 : e.isError) === !0 && B(o) && M && console.debug(`[guido:cortex] message-level error id=${o}`, e);
|
|
97
|
+
const r = e == null ? void 0 : e.segments;
|
|
98
|
+
Array.isArray(r) && r.forEach((n) => {
|
|
99
|
+
if (n)
|
|
100
|
+
switch (O(o, n), n.type) {
|
|
101
|
+
case "blueprint":
|
|
102
|
+
U(n);
|
|
103
|
+
break;
|
|
104
|
+
case "error":
|
|
105
|
+
B(o);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
60
108
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
109
|
+
});
|
|
110
|
+
}, P = () => {
|
|
111
|
+
T !== null && (clearInterval(T), T = null);
|
|
112
|
+
}, $ = () => {
|
|
113
|
+
var t;
|
|
114
|
+
return (t = A._s) == null ? void 0 : t.get(tt);
|
|
115
|
+
}, F = (t) => {
|
|
116
|
+
f = t, b = W(() => t.messages, k, { deep: !0, immediate: !0 });
|
|
117
|
+
}, I = $();
|
|
118
|
+
I ? F(I) : T = setInterval(() => {
|
|
119
|
+
const t = $();
|
|
120
|
+
t && (P(), F(t));
|
|
121
|
+
}, nt), V(() => {
|
|
122
|
+
P(), b == null || b(), f = void 0, h.clear(), v.clear(), u.clear(), d.clear(), E.clear(), y.clear(), S === _ && (S = null, p.$patch((t) => {
|
|
123
|
+
t.bridgeActive = !1, t.applyAcks = {};
|
|
124
|
+
}), N());
|
|
66
125
|
});
|
|
67
126
|
};
|
|
68
127
|
export {
|
|
69
|
-
|
|
128
|
+
ft as useCortexBlueprintBridge
|
|
70
129
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let o = Promise.resolve(), n = 0, e = 0;
|
|
2
|
+
const s = () => n > 0, c = () => (e += 1, e), u = (t) => t > 0 && t === e, i = (t) => {
|
|
3
|
+
const r = o.then(async () => {
|
|
4
|
+
n += 1;
|
|
5
|
+
try {
|
|
6
|
+
return await t();
|
|
7
|
+
} finally {
|
|
8
|
+
n -= 1;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return o = r.catch(() => {
|
|
12
|
+
}), r;
|
|
13
|
+
}, a = () => ({ runExclusive: i, isEditorBusy: s, beginMount: c, isCurrentMount: u });
|
|
14
|
+
export {
|
|
15
|
+
c as beginMount,
|
|
16
|
+
u as isCurrentMount,
|
|
17
|
+
s as isEditorBusy,
|
|
18
|
+
i as runExclusive,
|
|
19
|
+
a as useEditorLock
|
|
20
|
+
};
|
|
@@ -1,59 +1,102 @@
|
|
|
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 Q } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as x } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as z } from "./useEditorLock.js";
|
|
4
|
+
import { useToaster as F } from "./useToaster.js";
|
|
5
|
+
import { useTranslationWithFallback as N } from "./useTranslations.js";
|
|
6
|
+
import { ToasterTypeOptions as h } from "../enums/toaster.js";
|
|
7
|
+
import { useDynamicContentStore as q } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useEditorStore as R } from "../stores/editor.js";
|
|
9
|
+
import { flattenDynamicContentList as G } from "../utils/genericUtil.js";
|
|
10
|
+
import { extractUsedDynamicContent as W } from "../utils/registerUsedDynamicContent.js";
|
|
11
|
+
import { ref as $, watch as j } from "vue";
|
|
12
|
+
const J = 250, D = 12e4, c = { status: "superseded" }, S = { status: "failed", error: new Error("Blueprint has no html to apply") }, i = $({}), v = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), ie = () => {
|
|
13
|
+
const { updateHtmlAndCss: a } = Q(), { runExclusive: M } = z(), { showToaster: d } = F(), y = N(), { template: U } = x(), A = q(), T = R(), E = (e, t) => {
|
|
14
|
+
u.get(e) !== t && (u.set(e, t), d({
|
|
15
|
+
type: h.Error,
|
|
16
|
+
message: y("newsletter.ai-template-failed-apply", "Failed to apply template")
|
|
17
|
+
}));
|
|
18
|
+
}, O = () => {
|
|
19
|
+
var e, t;
|
|
20
|
+
return T.isStripoInitialized && typeof ((t = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : t.updateHtmlAndCss) == "function";
|
|
21
|
+
}, P = (e) => {
|
|
22
|
+
i.value[e] === void 0 && (i.value = { ...i.value, [e]: "pending" });
|
|
23
|
+
}, m = (e, t) => {
|
|
24
|
+
i.value = { ...i.value, [e]: t };
|
|
25
|
+
}, _ = (e) => {
|
|
26
|
+
var t;
|
|
19
27
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const o = G((t = U.value) == null ? void 0 : t.dynamicContentList), s = W(e, o);
|
|
29
|
+
s.length > 0 && A.registerDynamicContent(s);
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}, k = (e, t) => {
|
|
33
|
+
u.delete(e), v.get(e) !== t && (v.set(e, t), d({
|
|
34
|
+
type: h.Success,
|
|
35
|
+
message: y("newsletter.ai-template-applied", "Template applied to the editor")
|
|
36
|
+
}));
|
|
37
|
+
}, g = async (e, t, o) => {
|
|
38
|
+
const s = (l.get(e) ?? 0) + 1;
|
|
39
|
+
l.set(e, s), m(e, "applying");
|
|
40
|
+
try {
|
|
41
|
+
await M(() => a(t, o));
|
|
32
42
|
} catch (n) {
|
|
33
|
-
|
|
34
|
-
type: f.Error,
|
|
35
|
-
message: n instanceof Error ? n.message : "Failed to apply template"
|
|
36
|
-
});
|
|
43
|
+
return l.get(e) !== s ? c : (console.error("[guido:apply] editor did not acknowledge the template apply", n), m(e, "failed"), E(e, t), { status: "failed", error: n });
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
t
|
|
45
|
+
return l.get(e) !== s ? c : (m(e, "applied"), _(t), k(e, t), { status: "applied" });
|
|
46
|
+
}, H = (e) => {
|
|
47
|
+
const t = r.get(e);
|
|
48
|
+
t && (clearTimeout(t.timer), r.delete(e), t.settle(c));
|
|
49
|
+
}, w = (e) => {
|
|
50
|
+
const t = p.get(e);
|
|
51
|
+
t && (clearTimeout(t.timer), p.delete(e), t.settle(c));
|
|
52
|
+
}, B = (e, t, o) => new Promise((s) => {
|
|
53
|
+
H(e);
|
|
54
|
+
const n = setTimeout(() => {
|
|
55
|
+
r.delete(e), m(e, "failed"), E(e, t), s({
|
|
56
|
+
status: "failed",
|
|
57
|
+
error: new Error(`Editor did not become ready within ${D}ms`)
|
|
58
|
+
});
|
|
59
|
+
}, D);
|
|
60
|
+
r.set(e, { html: t, css: o, timer: n, settle: s }), m(e, "applying");
|
|
61
|
+
}), C = (e, t, o) => O() ? g(e, t, o) : B(e, t, o), L = async () => {
|
|
62
|
+
if (r.size === 0)
|
|
63
|
+
return;
|
|
64
|
+
const e = [...r.entries()];
|
|
65
|
+
r.clear(), e.forEach(([, n]) => clearTimeout(n.timer));
|
|
66
|
+
const t = e.pop();
|
|
67
|
+
if (e.forEach(([n, f]) => {
|
|
68
|
+
m(n, "pending"), f.settle(c);
|
|
69
|
+
}), !t)
|
|
70
|
+
return;
|
|
71
|
+
const [o, s] = t;
|
|
72
|
+
s.settle(await g(o, s.html, s.css));
|
|
41
73
|
};
|
|
42
|
-
return
|
|
43
|
-
|
|
74
|
+
return j(() => T.isStripoInitialized, (e) => {
|
|
75
|
+
e && L();
|
|
76
|
+
}, { immediate: !0 }), { applyStatus: i, markPending: P, applyTemplate: (e, t) => {
|
|
77
|
+
const { html: o } = t;
|
|
78
|
+
return o ? (w(e), C(e, o, t.css ?? "")) : Promise.resolve(S);
|
|
44
79
|
}, applyTemplateDebounced: (e, t) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
const { html: o } = t;
|
|
81
|
+
if (!o)
|
|
82
|
+
return Promise.resolve(S);
|
|
83
|
+
const s = t.css ?? "";
|
|
84
|
+
return new Promise((n) => {
|
|
85
|
+
w(e);
|
|
86
|
+
const f = setTimeout(() => {
|
|
87
|
+
p.delete(e), C(e, o, s).then(n);
|
|
88
|
+
}, J);
|
|
89
|
+
p.set(e, { timer: f, settle: n });
|
|
90
|
+
});
|
|
52
91
|
} };
|
|
53
|
-
},
|
|
54
|
-
|
|
92
|
+
}, ce = () => {
|
|
93
|
+
p.forEach((a) => {
|
|
94
|
+
clearTimeout(a.timer), a.settle(c);
|
|
95
|
+
}), p.clear(), r.forEach((a) => {
|
|
96
|
+
clearTimeout(a.timer), a.settle(c);
|
|
97
|
+
}), r.clear(), l.clear(), u.clear(), i.value = {};
|
|
55
98
|
};
|
|
56
99
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
100
|
+
ce as resetEmailTemplateApplier,
|
|
101
|
+
ie as useEmailTemplateApplier
|
|
59
102
|
};
|
|
@@ -1,48 +1,54 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { useActionsApi as b } from "./useActionsApi.js";
|
|
2
|
+
import { useEditorLock as v } from "./useEditorLock.js";
|
|
3
|
+
import { useConfigStore as T } from "../stores/config.js";
|
|
4
|
+
import { useEditorStore as w } from "../stores/editor.js";
|
|
5
|
+
import { useGuidoEmailEditorStore as y } from "../stores/guido-email-editor.js";
|
|
6
|
+
import { watch as a, onUnmounted as B } from "vue";
|
|
7
|
+
const C = 500, L = () => {
|
|
8
|
+
const i = w(), u = y(), l = T(), { getTemplateData: d } = b(), { runExclusive: m, isEditorBusy: p } = v();
|
|
9
|
+
let o = null, s = !1;
|
|
10
|
+
const n = () => {
|
|
11
|
+
o && (clearTimeout(o), o = null);
|
|
12
|
+
}, c = (t) => {
|
|
13
|
+
n(), o = setTimeout(() => {
|
|
14
|
+
o = null, t();
|
|
15
|
+
}, C);
|
|
16
|
+
}, e = async () => {
|
|
17
|
+
var t, r;
|
|
18
|
+
if (!(s || !i.isStripoInitialized)) {
|
|
19
|
+
if (p()) {
|
|
20
|
+
c(() => void e());
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
14
23
|
try {
|
|
15
|
-
const { html:
|
|
16
|
-
if (
|
|
24
|
+
const { html: E, css: g } = await m(d), I = ((r = (t = l.config) == null ? void 0 : t.identity) == null ? void 0 : r.templateId) ?? "";
|
|
25
|
+
if (s)
|
|
17
26
|
return;
|
|
18
|
-
|
|
19
|
-
html:
|
|
20
|
-
css:
|
|
21
|
-
templateId:
|
|
27
|
+
u.$patch({
|
|
28
|
+
html: E ?? "",
|
|
29
|
+
css: g ?? "",
|
|
30
|
+
templateId: I,
|
|
22
31
|
lastUpdatedAt: Date.now()
|
|
23
32
|
});
|
|
24
33
|
} catch {
|
|
25
34
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
e = null, s();
|
|
29
|
-
}, w);
|
|
30
|
-
}, d = c(
|
|
35
|
+
}
|
|
36
|
+
}, f = () => c(() => void e()), h = a(
|
|
31
37
|
() => i.isStripoInitialized,
|
|
32
38
|
(t) => {
|
|
33
|
-
t &&
|
|
39
|
+
t && e();
|
|
34
40
|
},
|
|
35
41
|
{ immediate: !0 }
|
|
36
|
-
),
|
|
42
|
+
), S = a(
|
|
37
43
|
() => i.hasChanges,
|
|
38
|
-
(t,
|
|
39
|
-
i.isStripoInitialized && (t ?
|
|
44
|
+
(t, r) => {
|
|
45
|
+
i.isStripoInitialized && (t ? f() : r && (n(), e()));
|
|
40
46
|
}
|
|
41
47
|
);
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
B(() => {
|
|
49
|
+
s = !0, n(), h(), S();
|
|
44
50
|
});
|
|
45
51
|
};
|
|
46
52
|
export {
|
|
47
|
-
|
|
53
|
+
L as useGuidoStateBridge
|
|
48
54
|
};
|