@useinsider/guido 3.19.0-beta.76f392b → 3.19.0-beta.8776c42
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 +59 -53
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useEmailTemplateApplier.js +106 -50
- package/dist/config/migrator/itemsBlockMigrator.js +248 -236
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +105 -114
- package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
- package/dist/extensions/Blocks/Items/template.js +204 -219
- package/dist/guido.css +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
- package/dist/src/extensions/Blocks/Items/template.d.ts +0 -19
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/utils/pairProductVariables.js +71 -71
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as re, defineAsyncComponent as m, ref as
|
|
1
|
+
import { defineComponent as re, defineAsyncComponent as m, ref as x, computed as p, watch as W, onMounted as se, onUnmounted as ae } from "vue";
|
|
2
2
|
import { useCortexBlueprintBridge as ie } from "../composables/useCortexBlueprintBridge.js";
|
|
3
3
|
import { useEditorLock as ce } from "../composables/useEditorLock.js";
|
|
4
4
|
import { provideGuidoActions as de } from "../composables/useGuidoActions.js";
|
|
@@ -6,25 +6,25 @@ import { useGuidoStateBridge as me } from "../composables/useGuidoStateBridge.js
|
|
|
6
6
|
import { usePartner as le } from "../composables/usePartner.js";
|
|
7
7
|
import { useStripo as ue } from "../composables/useStripo.js";
|
|
8
8
|
import { useTimerClone as pe } from "../composables/useTimerClone.js";
|
|
9
|
-
import { migrate as
|
|
10
|
-
import { ModuleFolderDefaults as
|
|
9
|
+
import { migrate as G } from "../config/migrator/index.js";
|
|
10
|
+
import { ModuleFolderDefaults as z } from "../enums/defaults.js";
|
|
11
11
|
import { RIBBON_SELECTOR as fe } from "../enums/onboarding.js";
|
|
12
|
-
import { useRecommendationExtensionStore as
|
|
12
|
+
import { useRecommendationExtensionStore as E } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
13
13
|
import ye from "./organisms/AutoSaveController.vue.js";
|
|
14
14
|
import ge from "./organisms/base/Toaster.vue.js";
|
|
15
15
|
import ve from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
|
|
16
16
|
import Se from "./organisms/header/HeaderWrapper.vue.js";
|
|
17
|
-
import
|
|
18
|
-
import
|
|
17
|
+
import he from "./organisms/LoadingWrapper.vue.js";
|
|
18
|
+
import be from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
|
|
19
19
|
import Ee from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
|
|
20
20
|
import { useStripoApi as we } from "../services/stripoApi.js";
|
|
21
21
|
import { useConfigStore as Ce } from "../stores/config.js";
|
|
22
22
|
import { useDynamicContentStore as De } from "../stores/dynamic-content.js";
|
|
23
|
-
import { useEditorStore as
|
|
23
|
+
import { useEditorStore as w } from "../stores/editor.js";
|
|
24
24
|
import { usePreviewStore as ke } from "../stores/preview.js";
|
|
25
|
-
import { useTemplateStore as
|
|
26
|
-
import { useUnsubscribeStore as
|
|
27
|
-
import { readTrackFloor as
|
|
25
|
+
import { useTemplateStore as Fe } from "../stores/template.js";
|
|
26
|
+
import { useUnsubscribeStore as Te } from "../stores/unsubscribe.js";
|
|
27
|
+
import { readTrackFloor as H } from "../utils/linkTrackingIds.js";
|
|
28
28
|
const tt = /* @__PURE__ */ re({
|
|
29
29
|
__name: "Guido",
|
|
30
30
|
props: {
|
|
@@ -32,8 +32,8 @@ const tt = /* @__PURE__ */ re({
|
|
|
32
32
|
ready: { type: Boolean, default: !0 }
|
|
33
33
|
},
|
|
34
34
|
emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
|
|
35
|
-
setup(
|
|
36
|
-
const a =
|
|
35
|
+
setup($, { expose: q, emit: r }) {
|
|
36
|
+
const a = $, K = m(
|
|
37
37
|
() => import("./organisms/email-preview/PreviewContainer.vue.js")
|
|
38
38
|
), V = m(
|
|
39
39
|
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
@@ -43,32 +43,32 @@ const tt = /* @__PURE__ */ re({
|
|
|
43
43
|
() => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
|
|
44
44
|
), Q = m(
|
|
45
45
|
() => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
|
|
46
|
-
),
|
|
46
|
+
), C = x(), f = x(), y = De(), D = Te(), o = Ce();
|
|
47
47
|
a.ready && o.init(a.config);
|
|
48
|
-
const c =
|
|
48
|
+
const c = w(), X = ke(), l = p(() => c.hasChanges), { isTestPartner: Y } = le(), k = () => {
|
|
49
49
|
var t;
|
|
50
|
-
return (t =
|
|
51
|
-
},
|
|
50
|
+
return (t = C.value) == null ? void 0 : t.handleSave(!0);
|
|
51
|
+
}, F = (t) => {
|
|
52
52
|
c.loadingStatus = t;
|
|
53
53
|
};
|
|
54
54
|
ie(), me();
|
|
55
|
-
const
|
|
55
|
+
const g = () => {
|
|
56
56
|
var t, e;
|
|
57
57
|
return {
|
|
58
58
|
emailId: o.templateId,
|
|
59
59
|
userId: o.userId,
|
|
60
60
|
username: o.username,
|
|
61
61
|
partnerName: o.partnerName,
|
|
62
|
-
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) ||
|
|
63
|
-
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) ||
|
|
62
|
+
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || z.SAVED_MODULES,
|
|
63
|
+
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || z.DEFAULT_MODULES
|
|
64
64
|
};
|
|
65
|
-
}, { initPlugin:
|
|
66
|
-
let
|
|
67
|
-
const { getDefaultTemplate:
|
|
65
|
+
}, { initPlugin: T, preloadRuntime: I } = ue(), { runExclusive: M, beginMount: R, isCurrentMount: v } = ce();
|
|
66
|
+
let u = 0;
|
|
67
|
+
const { getDefaultTemplate: L } = we(), { cloneTimersOnSave: B, hasTimerBlocks: U } = pe(), Z = p(() => {
|
|
68
68
|
var t;
|
|
69
69
|
return !((t = o.ui) != null && t.showHeader);
|
|
70
|
-
}), ee =
|
|
71
|
-
() => !!
|
|
70
|
+
}), ee = p(() => o.isFeatureEnabled("reusableRecommendationStrategy")), te = p(
|
|
71
|
+
() => !!E().recommendationConfigs.strategyId
|
|
72
72
|
);
|
|
73
73
|
de({
|
|
74
74
|
onBack: () => {
|
|
@@ -78,70 +78,76 @@ const tt = /* @__PURE__ */ re({
|
|
|
78
78
|
console.debug("guido:save:start"), r("save:start");
|
|
79
79
|
},
|
|
80
80
|
onSaveComplete: (t) => {
|
|
81
|
-
const e = { ...t, metadata:
|
|
81
|
+
const e = { ...t, metadata: g() };
|
|
82
82
|
console.debug("guido:save:complete", e), r("save:complete", e);
|
|
83
83
|
},
|
|
84
84
|
onTestEmailClick: () => {
|
|
85
85
|
console.debug("guido:test-email:click"), r("test-email:click");
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
const
|
|
89
|
-
console.debug("dynamic-content:close", t),
|
|
90
|
-
},
|
|
88
|
+
const A = (t) => {
|
|
89
|
+
console.debug("dynamic-content:close", t), y.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
|
|
90
|
+
}, P = () => {
|
|
91
91
|
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
W(() => l.value, () => {
|
|
94
94
|
r("on-change", l.value);
|
|
95
95
|
});
|
|
96
|
-
const
|
|
96
|
+
const S = (t) => {
|
|
97
97
|
const e = t, { attribute: s, position: d } = e.detail;
|
|
98
98
|
console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", s, d);
|
|
99
99
|
};
|
|
100
100
|
let i = null;
|
|
101
|
-
const
|
|
101
|
+
const h = () => {
|
|
102
102
|
var e;
|
|
103
103
|
const t = document.querySelector(fe);
|
|
104
|
-
(e =
|
|
104
|
+
(e = f.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
|
|
105
105
|
}, b = async () => {
|
|
106
106
|
var t;
|
|
107
107
|
try {
|
|
108
108
|
o.initialized || o.init(a.config), c.templateId = o.templateId;
|
|
109
|
-
const e = o.template, s = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "",
|
|
110
|
-
|
|
111
|
-
const
|
|
109
|
+
const e = o.template, s = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", _ = (e == null ? void 0 : e.preselectedDynamicContent) || [];
|
|
110
|
+
D.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
|
|
111
|
+
const N = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, O = o.isFeatureEnabled("linkTrackingIds");
|
|
112
112
|
let n = {
|
|
113
|
-
html: s && await
|
|
113
|
+
html: s && await G(s, N),
|
|
114
114
|
css: d
|
|
115
115
|
};
|
|
116
|
-
n.html || (n = await
|
|
117
|
-
const oe =
|
|
118
|
-
|
|
116
|
+
n.html || (n = await L(), n.html = await G(n.html, N));
|
|
117
|
+
const oe = O ? H(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
|
|
118
|
+
U(n.html) && (n.html = await B(n.html)), O && (c.trackIdSessionFloor = Math.max(oe, H(n.html)));
|
|
119
119
|
const ne = {
|
|
120
|
-
preselectedDynamicContentList:
|
|
120
|
+
preselectedDynamicContentList: _,
|
|
121
121
|
onReady: () => {
|
|
122
122
|
console.debug("guido:ready"), r("ready");
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
|
|
125
|
+
u = R(), await T(n, g(), ne), y.selectedDynamicContentList = _;
|
|
126
126
|
} catch (e) {
|
|
127
127
|
console.error("Failed to initialize Stripo editor:", e);
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
return se(async () => {
|
|
131
131
|
var e;
|
|
132
|
-
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"),
|
|
133
|
-
const t = (e =
|
|
134
|
-
if (t && (i = new ResizeObserver(
|
|
132
|
+
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), E().$reset(), w().$reset(), Fe().$reset(), h();
|
|
133
|
+
const t = (e = f.value) == null ? void 0 : e.parentElement;
|
|
134
|
+
if (t && (i = new ResizeObserver(h), i.observe(t)), I(), a.ready)
|
|
135
135
|
await b();
|
|
136
136
|
else {
|
|
137
|
-
const s =
|
|
137
|
+
const s = W(() => a.ready, (d) => {
|
|
138
138
|
d && (s(), b());
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
-
document.addEventListener("dynamic-content:open",
|
|
141
|
+
document.addEventListener("dynamic-content:open", S);
|
|
142
142
|
}), ae(() => {
|
|
143
|
-
i == null || i.disconnect(), document.removeEventListener("dynamic-content:open",
|
|
144
|
-
|
|
143
|
+
if (i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", S), E().disposeStrategyPageReturn(), v(u))
|
|
144
|
+
try {
|
|
145
|
+
w().isStripoInitialized = !1;
|
|
146
|
+
} catch (t) {
|
|
147
|
+
console.debug("Failed to close the editor readiness gate on unmount", t);
|
|
148
|
+
}
|
|
149
|
+
M(async () => {
|
|
150
|
+
if (v(u))
|
|
145
151
|
try {
|
|
146
152
|
window.UIEditor.removeEditor();
|
|
147
153
|
} catch {
|
|
@@ -150,13 +156,13 @@ const tt = /* @__PURE__ */ re({
|
|
|
150
156
|
}), o.reset();
|
|
151
157
|
}), q({
|
|
152
158
|
dynamicContent: {
|
|
153
|
-
insert:
|
|
154
|
-
close:
|
|
159
|
+
insert: A,
|
|
160
|
+
close: P
|
|
155
161
|
},
|
|
156
162
|
hasChanges: l,
|
|
157
|
-
saveSilent:
|
|
158
|
-
setLoading:
|
|
159
|
-
}), { __sfc: !0, PreviewContainer: K, OnboardingWrapper: V, AssignStrategyDrawer: j, RemoveStrategyModal: J, LegacyStrategyUpdatedModal: Q, headerWrapperRef:
|
|
163
|
+
saveSilent: k,
|
|
164
|
+
setLoading: F
|
|
165
|
+
}), { __sfc: !0, PreviewContainer: K, OnboardingWrapper: V, AssignStrategyDrawer: j, RemoveStrategyModal: J, LegacyStrategyUpdatedModal: Q, headerWrapperRef: C, wrapperRef: f, dynamicContentStore: y, unsubscribeStore: D, props: a, configStore: o, editorStore: c, previewStore: X, hasChanges: l, isTestPartner: Y, saveSilent: k, setLoading: F, emit: r, buildMetadata: g, initPlugin: T, preloadRuntime: I, runExclusive: M, beginMount: R, isCurrentMount: v, mountGeneration: u, getDefaultTemplate: L, cloneTimersOnSave: B, hasTimerBlocks: U, noHeader: Z, isRrsEnabled: ee, hasAssignedStrategy: te, insertDynamicContent: A, closeDynamicContent: P, handleDynamicContentOpen: S, ribbonObserver: i, updateRibbonOffset: h, startEditor: b, AutoSaveController: ye, Toaster: ge, FilterSelectionDrawer: ve, HeaderWrapper: Se, LoadingWrapper: he, SaveAsTemplateDrawer: be, UnsubscribeWrapper: Ee };
|
|
160
166
|
}
|
|
161
167
|
});
|
|
162
168
|
export {
|
|
@@ -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,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
|
-
o.value = { ...o.value, [e]: "applying" };
|
|
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
|
+
let d = null;
|
|
14
|
+
const E = () => {
|
|
15
|
+
d && (clearInterval(d), d = null);
|
|
16
|
+
}, me = () => {
|
|
17
|
+
const { updateHtmlAndCss: i } = z(), { runExclusive: O } = K(), { showToaster: P } = R(), _ = F(), { template: b } = N(), L = G(), T = $(), w = (e, t) => {
|
|
19
18
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 = () => {
|
|
26
|
+
var e, t;
|
|
27
|
+
return T.isStripoInitialized && typeof ((t = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : t.updateHtmlAndCss) == "function";
|
|
28
|
+
}, Q = (e) => {
|
|
29
|
+
a.value[e] === void 0 && (a.value = { ...a.value, [e]: "pending" });
|
|
30
|
+
}, l = (e, t) => {
|
|
31
|
+
a.value = { ...a.value, [e]: t };
|
|
32
|
+
}, H = (e) => {
|
|
33
|
+
var t;
|
|
34
|
+
try {
|
|
35
|
+
const o = j((t = b.value) == null ? void 0 : t.dynamicContentList), r = J(e, o);
|
|
36
|
+
r.length > 0 && L.registerDynamicContent(r);
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
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
|
+
try {
|
|
45
|
+
await O(() => i(t, o));
|
|
32
46
|
} catch (n) {
|
|
33
|
-
|
|
34
|
-
type: f.Error,
|
|
35
|
-
message: n instanceof Error ? n.message : "Failed to apply template"
|
|
36
|
-
});
|
|
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 });
|
|
37
48
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
t
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
return u.get(e) !== r ? p : (l(e, "applied"), H(t), I(e, t), { status: "applied" });
|
|
50
|
+
}, B = (e) => {
|
|
51
|
+
const t = s.get(e);
|
|
52
|
+
t && (clearTimeout(t.timer), s.delete(e), t.settle(p));
|
|
53
|
+
}, C = (e) => {
|
|
54
|
+
const t = c.get(e);
|
|
55
|
+
t && (clearTimeout(t.timer), c.delete(e), t.settle(p));
|
|
56
|
+
}, q = () => {
|
|
57
|
+
[...c.keys()].forEach(C);
|
|
58
|
+
}, D = async () => {
|
|
59
|
+
if (s.size === 0) {
|
|
60
|
+
E();
|
|
46
61
|
return;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
}
|
|
63
|
+
if (!y())
|
|
64
|
+
return;
|
|
65
|
+
E();
|
|
66
|
+
const e = [...s.entries()];
|
|
67
|
+
s.clear(), e.forEach(([, n]) => clearTimeout(n.timer));
|
|
68
|
+
const t = e.pop();
|
|
69
|
+
if (e.forEach(([n, f]) => {
|
|
70
|
+
l(n, "failed"), f.settle({ status: "failed", error: new Error("Displaced by a newer apply") });
|
|
71
|
+
}), !t)
|
|
72
|
+
return;
|
|
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
|
+
status: "failed",
|
|
80
|
+
error: new Error(`Editor did not become ready within ${U}ms`)
|
|
81
|
+
});
|
|
51
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
|
+
}, applyTemplateDebounced: (e, t) => {
|
|
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
|
+
const f = setTimeout(() => {
|
|
100
|
+
c.delete(e), S(e, o, r).then(n);
|
|
101
|
+
}, X);
|
|
102
|
+
c.set(e, { timer: f, settle: n });
|
|
103
|
+
});
|
|
52
104
|
} };
|
|
53
|
-
},
|
|
54
|
-
|
|
105
|
+
}, de = () => {
|
|
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
|
+
de as resetEmailTemplateApplier,
|
|
114
|
+
me as useEmailTemplateApplier
|
|
59
115
|
};
|