@useinsider/guido 3.9.1 → 3.10.0-beta.f7505c1
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,55 +1,59 @@
|
|
|
1
|
-
import { useEmailTemplateApplier as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { useTranslations as
|
|
1
|
+
import { useEmailTemplateApplier as w, resetEmailTemplateApplier as _ } from "./useEmailTemplateApplier.js";
|
|
2
|
+
import { useToaster as I } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as P } from "./useTranslations.js";
|
|
4
4
|
import { ToasterTypeOptions as S } from "../enums/toaster.js";
|
|
5
5
|
import { getActivePinia as v } from "pinia";
|
|
6
6
|
import { watch as B, onUnmounted as D } from "vue";
|
|
7
|
-
const
|
|
7
|
+
const x = "email_template", L = "chat", M = "guido:debug:ai", R = () => {
|
|
8
8
|
if (typeof window > "u")
|
|
9
9
|
return !1;
|
|
10
10
|
try {
|
|
11
|
-
return window.localStorage.getItem(
|
|
11
|
+
return window.localStorage.getItem(M) === "1";
|
|
12
12
|
} catch {
|
|
13
13
|
return !1;
|
|
14
14
|
}
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
15
|
+
}, H = () => {
|
|
16
|
+
const c = v();
|
|
17
|
+
if (!c)
|
|
18
18
|
return;
|
|
19
|
-
const l =
|
|
19
|
+
const l = c._s, p = l == null ? void 0 : l.get(L);
|
|
20
20
|
if (!p)
|
|
21
21
|
return;
|
|
22
|
-
const {
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
}, i = /* @__PURE__ */ new Map(),
|
|
26
|
-
u && console.debug(`[guido:cortex] msg=${
|
|
27
|
-
},
|
|
28
|
-
if (
|
|
22
|
+
const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: h } = I(), y = P(), A = (r, t) => {
|
|
23
|
+
const e = y(r);
|
|
24
|
+
return e === r ? t : e;
|
|
25
|
+
}, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), E = (r, t) => {
|
|
26
|
+
u && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
|
|
27
|
+
}, b = (r) => {
|
|
28
|
+
if (r.blueprintType !== x)
|
|
29
29
|
return;
|
|
30
|
-
const t =
|
|
31
|
-
if (!t || !(
|
|
30
|
+
const t = r.blueprintId, e = r.blueprintData;
|
|
31
|
+
if (!t || !(e != null && e.html))
|
|
32
32
|
return;
|
|
33
|
+
if (!r.applyRequested) {
|
|
34
|
+
d(t);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
33
37
|
const o = i.get(t);
|
|
34
|
-
o === void 0 ? (i.set(t,
|
|
35
|
-
}, s = (
|
|
38
|
+
o === void 0 ? (i.set(t, e.html), f(t, e)) : o !== e.html && (i.set(t, e.html), T(t, e));
|
|
39
|
+
}, s = (r) => r === void 0 || a.has(r) ? !1 : (a.add(r), h({
|
|
36
40
|
type: S.Alert,
|
|
37
41
|
message: A("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
|
|
38
|
-
}), !0),
|
|
42
|
+
}), !0), m = B(
|
|
39
43
|
() => p.messages,
|
|
40
|
-
(
|
|
41
|
-
Array.isArray(
|
|
42
|
-
const
|
|
43
|
-
(t == null ? void 0 : t.isError) === !0 && s(
|
|
44
|
+
(r) => {
|
|
45
|
+
Array.isArray(r) && r.forEach((t) => {
|
|
46
|
+
const e = t == null ? void 0 : t.id;
|
|
47
|
+
(t == null ? void 0 : t.isError) === !0 && s(e) && u && console.debug(`[guido:cortex] message-level error id=${e}`, t);
|
|
44
48
|
const o = t == null ? void 0 : t.segments;
|
|
45
49
|
Array.isArray(o) && o.forEach((n) => {
|
|
46
50
|
if (n)
|
|
47
|
-
switch (E(
|
|
51
|
+
switch (E(e, n), n.type) {
|
|
48
52
|
case "blueprint":
|
|
49
|
-
|
|
53
|
+
b(n);
|
|
50
54
|
break;
|
|
51
55
|
case "error":
|
|
52
|
-
s(
|
|
56
|
+
s(e);
|
|
53
57
|
break;
|
|
54
58
|
}
|
|
55
59
|
});
|
|
@@ -58,9 +62,9 @@ const P = "email_template", x = "chat", L = "guido:debug:ai", M = () => {
|
|
|
58
62
|
{ deep: !0, immediate: !0 }
|
|
59
63
|
);
|
|
60
64
|
D(() => {
|
|
61
|
-
|
|
65
|
+
m(), i.clear(), a.clear(), _();
|
|
62
66
|
});
|
|
63
67
|
};
|
|
64
68
|
export {
|
|
65
|
-
|
|
69
|
+
H as useCortexBlueprintBridge
|
|
66
70
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { useTranslations as
|
|
1
|
+
import { useActionsApi as T } from "./useActionsApi.js";
|
|
2
|
+
import { useToaster as f } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as y } from "./useTranslations.js";
|
|
4
4
|
import { ToasterTypeOptions as n } from "../enums/toaster.js";
|
|
5
|
-
import { ref as
|
|
6
|
-
const h = 250, s =
|
|
7
|
-
const { updateHtmlAndCss: l } =
|
|
5
|
+
import { ref as v } from "vue";
|
|
6
|
+
const h = 250, s = v({}), o = {}, j = () => {
|
|
7
|
+
const { updateHtmlAndCss: l } = T(), { showToaster: r } = f(), i = y(), u = (e) => {
|
|
8
|
+
s.value[e] === void 0 && (s.value = { ...s.value, [e]: "pending" });
|
|
9
|
+
}, c = (e, t, p) => {
|
|
8
10
|
s.value = { ...s.value, [e]: "applying" };
|
|
9
11
|
try {
|
|
10
12
|
l(t, p), s.value = { ...s.value, [e]: "applied" }, r({
|
|
@@ -21,7 +23,7 @@ const h = 250, s = y({}), o = {}, j = () => {
|
|
|
21
23
|
const t = o[e];
|
|
22
24
|
t && (clearTimeout(t), delete o[e]);
|
|
23
25
|
};
|
|
24
|
-
return { applyStatus: s, applyTemplate: (e, t) => {
|
|
26
|
+
return { applyStatus: s, markPending: u, applyTemplate: (e, t) => {
|
|
25
27
|
t.html && (m(e), c(e, t.html, t.css ?? ""));
|
|
26
28
|
}, applyTemplateDebounced: (e, t) => {
|
|
27
29
|
if (!t.html)
|
|
@@ -32,10 +34,10 @@ const h = 250, s = y({}), o = {}, j = () => {
|
|
|
32
34
|
delete o[e], c(e, p, a);
|
|
33
35
|
}, h);
|
|
34
36
|
} };
|
|
35
|
-
},
|
|
37
|
+
}, k = () => {
|
|
36
38
|
Object.values(o).forEach(clearTimeout), Object.keys(o).forEach((l) => delete o[l]), s.value = {};
|
|
37
39
|
};
|
|
38
40
|
export {
|
|
39
|
-
|
|
41
|
+
k as resetEmailTemplateApplier,
|
|
40
42
|
j as useEmailTemplateApplier
|
|
41
43
|
};
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
* The bridge handles two segment shapes:
|
|
10
10
|
*
|
|
11
11
|
* - `blueprint` segments with `blueprintType === 'email_template'` are
|
|
12
|
-
* applied to the Stripo editor
|
|
13
|
-
*
|
|
12
|
+
* applied to the Stripo editor, but ONLY after the user clicks
|
|
13
|
+
* "Apply to editor" in cortex-fe (which sets `applyRequested` on the
|
|
14
|
+
* segment). Before that the template is marked `pending` and nothing is
|
|
15
|
+
* written to Stripo. Once applied, refines flow through debounced;
|
|
16
|
+
* identical-html no-ops.
|
|
14
17
|
* - `error` segments (and message-level `isError` / `isCancelled`) trigger
|
|
15
18
|
* a localized toaster.
|
|
16
19
|
*
|
|
@@ -2,12 +2,17 @@ type ApplyStatus = 'pending' | 'applying' | 'applied' | 'failed';
|
|
|
2
2
|
/**
|
|
3
3
|
* Applies email_template blueprints from the chat agent to the Stripo editor.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The first apply is gated behind the user's "Apply to editor" click — until
|
|
6
|
+
* then a blueprint is only marked `pending` (see `markPending`) and nothing is
|
|
7
|
+
* written to the editor.
|
|
8
|
+
*
|
|
9
|
+
* - manual Apply click (first apply): immediate.
|
|
10
|
+
* - blueprint_update after the user has applied once: debounced 250 ms trailing
|
|
11
|
+
* so rapid mid-stream updates don't thrash updateHtmlAndCss.
|
|
8
12
|
*/
|
|
9
13
|
export declare const useEmailTemplateApplier: () => {
|
|
10
14
|
applyStatus: import("vue").Ref<Record<string, ApplyStatus>>;
|
|
15
|
+
markPending: (blueprintId: string) => void;
|
|
11
16
|
applyTemplate: (blueprintId: string, data: {
|
|
12
17
|
html?: string;
|
|
13
18
|
css?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0-beta.f7505c1",
|
|
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",
|