@useinsider/guido 3.19.0-beta.9fe04f1 → 3.19.0-beta.a6fe4f3
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 +3 -3
- package/dist/components/Guido.vue2.js +47 -53
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCortexBlueprintBridge.js +54 -122
- package/dist/composables/useEmailTemplateApplier.js +50 -106
- package/dist/config/migrator/itemsBlockMigrator.js +236 -248
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +36 -30
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/guido.css +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +3 -2
- package/dist/src/composables/useEmailTemplateApplier.d.ts +5 -18
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/stores/guido-email-editor.d.ts +10 -20
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/guido-email-editor.js +1 -3
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as ae, defineAsyncComponent as m, ref as
|
|
1
|
+
import { defineComponent as ae, defineAsyncComponent as m, ref as x, computed as u, watch as W, onMounted as se, onUnmounted as ie } from "vue";
|
|
2
2
|
import { useCortexBlueprintBridge as ce } from "../composables/useCortexBlueprintBridge.js";
|
|
3
3
|
import { useEditorLock as de } from "../composables/useEditorLock.js";
|
|
4
4
|
import { provideGuidoActions as me } from "../composables/useGuidoActions.js";
|
|
@@ -6,10 +6,10 @@ import { useGuidoStateBridge as le } from "../composables/useGuidoStateBridge.js
|
|
|
6
6
|
import { usePartner as ue } from "../composables/usePartner.js";
|
|
7
7
|
import { useStripo as pe } from "../composables/useStripo.js";
|
|
8
8
|
import { useTimerClone as fe } from "../composables/useTimerClone.js";
|
|
9
|
-
import { migrate as
|
|
9
|
+
import { migrate as G } from "../config/migrator/index.js";
|
|
10
10
|
import { ModuleFolderDefaults as H } from "../enums/defaults.js";
|
|
11
11
|
import { RIBBON_SELECTOR as ye } from "../enums/onboarding.js";
|
|
12
|
-
import { useRecommendationExtensionStore as
|
|
12
|
+
import { useRecommendationExtensionStore as h } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
13
13
|
import ge from "./organisms/AutoSaveController.vue.js";
|
|
14
14
|
import Se from "./organisms/base/AuthErrorModal.vue.js";
|
|
15
15
|
import ve from "./organisms/base/Toaster.vue.js";
|
|
@@ -21,11 +21,11 @@ import Ce from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
|
|
|
21
21
|
import { useStripoApi as De } from "../services/stripoApi.js";
|
|
22
22
|
import { useConfigStore as ke } from "../stores/config.js";
|
|
23
23
|
import { useDynamicContentStore as Fe } from "../stores/dynamic-content.js";
|
|
24
|
-
import { useEditorStore as
|
|
24
|
+
import { useEditorStore as $ } from "../stores/editor.js";
|
|
25
25
|
import { usePreviewStore as Me } from "../stores/preview.js";
|
|
26
26
|
import { useTemplateStore as Re } from "../stores/template.js";
|
|
27
27
|
import { useUnsubscribeStore as Te } from "../stores/unsubscribe.js";
|
|
28
|
-
import { readTrackFloor as
|
|
28
|
+
import { readTrackFloor as z } from "../utils/linkTrackingIds.js";
|
|
29
29
|
const rt = /* @__PURE__ */ ae({
|
|
30
30
|
__name: "Guido",
|
|
31
31
|
props: {
|
|
@@ -44,16 +44,16 @@ const rt = /* @__PURE__ */ ae({
|
|
|
44
44
|
() => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
|
|
45
45
|
), X = m(
|
|
46
46
|
() => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
|
|
47
|
-
),
|
|
47
|
+
), E = x(), p = x(), f = Fe(), w = Te(), o = ke();
|
|
48
48
|
s.ready && o.init(s.config);
|
|
49
|
-
const c =
|
|
49
|
+
const c = $(), Y = Me(), l = u(() => c.hasChanges), { isTestPartner: Z } = ue(), C = () => {
|
|
50
50
|
var t;
|
|
51
|
-
return (t =
|
|
52
|
-
},
|
|
51
|
+
return (t = E.value) == null ? void 0 : t.handleSave(!0);
|
|
52
|
+
}, D = (t) => {
|
|
53
53
|
c.loadingStatus = t;
|
|
54
54
|
};
|
|
55
55
|
ce(), le();
|
|
56
|
-
const
|
|
56
|
+
const y = () => {
|
|
57
57
|
var t, e;
|
|
58
58
|
return {
|
|
59
59
|
emailId: o.templateId,
|
|
@@ -63,13 +63,13 @@ const rt = /* @__PURE__ */ ae({
|
|
|
63
63
|
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || H.SAVED_MODULES,
|
|
64
64
|
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || H.DEFAULT_MODULES
|
|
65
65
|
};
|
|
66
|
-
}, { initPlugin:
|
|
67
|
-
let
|
|
68
|
-
const { getDefaultTemplate:
|
|
66
|
+
}, { initPlugin: k, preloadRuntime: F } = pe(), { runExclusive: M, beginMount: R, isCurrentMount: T } = de();
|
|
67
|
+
let g = 0;
|
|
68
|
+
const { getDefaultTemplate: I } = De(), { cloneTimersOnSave: L, hasTimerBlocks: U } = fe(), ee = u(() => {
|
|
69
69
|
var t;
|
|
70
70
|
return !((t = o.ui) != null && t.showHeader);
|
|
71
|
-
}), te =
|
|
72
|
-
() => !!
|
|
71
|
+
}), te = u(() => o.isFeatureEnabled("reusableRecommendationStrategy")), oe = u(
|
|
72
|
+
() => !!h().recommendationConfigs.strategyId
|
|
73
73
|
);
|
|
74
74
|
me({
|
|
75
75
|
onBack: () => {
|
|
@@ -79,80 +79,74 @@ const rt = /* @__PURE__ */ ae({
|
|
|
79
79
|
console.debug("guido:save:start"), r("save:start");
|
|
80
80
|
},
|
|
81
81
|
onSaveComplete: (t) => {
|
|
82
|
-
const e = { ...t, metadata:
|
|
82
|
+
const e = { ...t, metadata: y() };
|
|
83
83
|
console.debug("guido:save:complete", e), r("save:complete", e);
|
|
84
84
|
},
|
|
85
85
|
onTestEmailClick: () => {
|
|
86
86
|
console.debug("guido:test-email:click"), r("test-email:click");
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
-
const
|
|
90
|
-
console.debug("dynamic-content:close", t),
|
|
91
|
-
},
|
|
89
|
+
const A = (t) => {
|
|
90
|
+
console.debug("dynamic-content:close", t), f.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
|
|
91
|
+
}, B = () => {
|
|
92
92
|
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
93
93
|
};
|
|
94
|
-
|
|
94
|
+
W(() => l.value, () => {
|
|
95
95
|
r("on-change", l.value);
|
|
96
96
|
});
|
|
97
|
-
const
|
|
97
|
+
const S = (t) => {
|
|
98
98
|
const e = t, { attribute: a, position: d } = e.detail;
|
|
99
99
|
console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", a, d);
|
|
100
100
|
};
|
|
101
101
|
let i = null;
|
|
102
|
-
const
|
|
102
|
+
const v = () => {
|
|
103
103
|
var e;
|
|
104
104
|
const t = document.querySelector(ye);
|
|
105
|
-
(e =
|
|
106
|
-
},
|
|
105
|
+
(e = p.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
|
|
106
|
+
}, b = async () => {
|
|
107
107
|
var t;
|
|
108
108
|
try {
|
|
109
109
|
o.initialized || o.init(s.config), c.templateId = o.templateId;
|
|
110
|
-
const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "",
|
|
111
|
-
|
|
112
|
-
const
|
|
110
|
+
const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", N = (e == null ? void 0 : e.preselectedDynamicContent) || [];
|
|
111
|
+
w.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
|
|
112
|
+
const P = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, _ = o.isFeatureEnabled("linkTrackingIds"), O = {
|
|
113
113
|
partnerName: o.partnerName,
|
|
114
114
|
campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
|
|
115
115
|
rrsEnabled: o.isFeatureEnabled("reusableRecommendationStrategy")
|
|
116
116
|
};
|
|
117
117
|
let n = {
|
|
118
|
-
html: a && await
|
|
118
|
+
html: a && await G(a, P, O),
|
|
119
119
|
css: d
|
|
120
120
|
};
|
|
121
|
-
n.html || (n = await
|
|
122
|
-
const ne =
|
|
123
|
-
|
|
121
|
+
n.html || (n = await I(), n.html = await G(n.html, P, O));
|
|
122
|
+
const ne = _ ? z(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
|
|
123
|
+
U(n.html) && (n.html = await L(n.html)), _ && (c.trackIdSessionFloor = Math.max(ne, z(n.html)));
|
|
124
124
|
const re = {
|
|
125
|
-
preselectedDynamicContentList:
|
|
125
|
+
preselectedDynamicContentList: N,
|
|
126
126
|
onReady: () => {
|
|
127
127
|
console.debug("guido:ready"), r("ready");
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
g = R(), await k(n, y(), re), f.selectedDynamicContentList = N;
|
|
131
131
|
} catch (e) {
|
|
132
132
|
console.error("Failed to initialize Stripo editor:", e);
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
return se(async () => {
|
|
136
136
|
var e;
|
|
137
|
-
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"),
|
|
138
|
-
const t = (e =
|
|
139
|
-
if (t && (i = new ResizeObserver(
|
|
140
|
-
await
|
|
137
|
+
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), h().$reset(), $().$reset(), Re().$reset(), v();
|
|
138
|
+
const t = (e = p.value) == null ? void 0 : e.parentElement;
|
|
139
|
+
if (t && (i = new ResizeObserver(v), i.observe(t)), F(), s.ready)
|
|
140
|
+
await b();
|
|
141
141
|
else {
|
|
142
|
-
const a =
|
|
143
|
-
d && (a(),
|
|
142
|
+
const a = W(() => s.ready, (d) => {
|
|
143
|
+
d && (a(), b());
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
document.addEventListener("dynamic-content:open",
|
|
146
|
+
document.addEventListener("dynamic-content:open", S);
|
|
147
147
|
}), ie(() => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
w().isStripoInitialized = !1;
|
|
151
|
-
} catch (t) {
|
|
152
|
-
console.debug("Failed to close the editor readiness gate on unmount", t);
|
|
153
|
-
}
|
|
154
|
-
T(async () => {
|
|
155
|
-
if (S(u))
|
|
148
|
+
i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", S), h().disposeStrategyPageReturn(), M(async () => {
|
|
149
|
+
if (T(g))
|
|
156
150
|
try {
|
|
157
151
|
window.UIEditor.removeEditor();
|
|
158
152
|
} catch {
|
|
@@ -161,13 +155,13 @@ const rt = /* @__PURE__ */ ae({
|
|
|
161
155
|
}), o.reset();
|
|
162
156
|
}), K({
|
|
163
157
|
dynamicContent: {
|
|
164
|
-
insert:
|
|
165
|
-
close:
|
|
158
|
+
insert: A,
|
|
159
|
+
close: B
|
|
166
160
|
},
|
|
167
161
|
hasChanges: l,
|
|
168
|
-
saveSilent:
|
|
169
|
-
setLoading:
|
|
170
|
-
}), { __sfc: !0, PreviewContainer: V, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef:
|
|
162
|
+
saveSilent: C,
|
|
163
|
+
setLoading: D
|
|
164
|
+
}), { __sfc: !0, PreviewContainer: V, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef: E, wrapperRef: p, dynamicContentStore: f, unsubscribeStore: w, props: s, configStore: o, editorStore: c, previewStore: Y, hasChanges: l, isTestPartner: Z, saveSilent: C, setLoading: D, emit: r, buildMetadata: y, initPlugin: k, preloadRuntime: F, runExclusive: M, beginMount: R, isCurrentMount: T, mountGeneration: g, getDefaultTemplate: I, cloneTimersOnSave: L, hasTimerBlocks: U, noHeader: ee, isRrsEnabled: te, hasAssignedStrategy: oe, insertDynamicContent: A, closeDynamicContent: B, handleDynamicContentOpen: S, ribbonObserver: i, updateRibbonOffset: v, startEditor: b, AutoSaveController: ge, AuthErrorModal: Se, Toaster: ve, FilterSelectionDrawer: be, HeaderWrapper: he, LoadingWrapper: Ee, SaveAsTemplateDrawer: we, UnsubscribeWrapper: Ce };
|
|
171
165
|
}
|
|
172
166
|
});
|
|
173
167
|
export {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useConfig as E } from "./useConfig.js";
|
|
2
|
-
import { useEditorLock as
|
|
3
|
-
import { useAutosaveStore as
|
|
4
|
-
import { useEditorStore as
|
|
2
|
+
import { useEditorLock as f } from "./useEditorLock.js";
|
|
3
|
+
import { useAutosaveStore as p, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
|
|
4
|
+
import { useEditorStore as A } from "../stores/editor.js";
|
|
5
5
|
import { computed as y, watch as I, onUnmounted as L } from "vue";
|
|
6
6
|
const w = 18e4, v = 6e4, R = (b) => {
|
|
7
|
-
const { isFeatureEnabled: S } = E(), o =
|
|
7
|
+
const { isFeatureEnabled: S } = E(), o = A(), t = p(), { isEditorBusy: g } = f();
|
|
8
8
|
let i = null, c = 0;
|
|
9
9
|
const u = y(
|
|
10
10
|
() => S("autosave") && t.isOn
|
|
11
11
|
), m = () => o.hasChanges && o.isInSaveableState, h = () => ({
|
|
12
12
|
hasChanges: o.hasChanges,
|
|
13
13
|
isInSaveableState: o.isInSaveableState
|
|
14
|
-
}),
|
|
14
|
+
}), l = async (e) => {
|
|
15
15
|
if (!u.value) {
|
|
16
16
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
|
|
17
17
|
return;
|
|
@@ -28,7 +28,7 @@ const w = 18e4, v = 6e4, R = (b) => {
|
|
|
28
28
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
|
|
31
|
+
e === "visibility" && (c = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
|
|
32
32
|
try {
|
|
33
33
|
if (await b() === void 0) {
|
|
34
34
|
console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
|
|
@@ -53,22 +53,22 @@ const w = 18e4, v = 6e4, R = (b) => {
|
|
|
53
53
|
});
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
l("visibility");
|
|
57
57
|
}, d = () => {
|
|
58
58
|
i && (clearInterval(i), i = null);
|
|
59
|
-
},
|
|
59
|
+
}, r = () => {
|
|
60
60
|
document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
|
|
61
61
|
};
|
|
62
62
|
I(
|
|
63
63
|
u,
|
|
64
64
|
(e) => {
|
|
65
65
|
console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
|
|
66
|
-
console.debug("guido:autosave:interval-tick"),
|
|
67
|
-
}, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(),
|
|
66
|
+
console.debug("guido:autosave:interval-tick"), l("interval");
|
|
67
|
+
}, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), r(), t.status = s.IDLE);
|
|
68
68
|
},
|
|
69
69
|
{ immediate: !0 }
|
|
70
70
|
), L(() => {
|
|
71
|
-
d(),
|
|
71
|
+
d(), r(), t.status = s.IDLE, t.lastSavedAt = null;
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
export {
|
|
@@ -1,138 +1,70 @@
|
|
|
1
|
-
import { useEmailTemplateApplier as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { useTranslations as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
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 = () => {
|
|
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
|
+
import { ToasterTypeOptions as S } from "../enums/toaster.js";
|
|
5
|
+
import { getActivePinia as v } from "pinia";
|
|
6
|
+
import { watch as B, onUnmounted as D } from "vue";
|
|
7
|
+
const x = "email_template", L = "chat", M = "guido:debug:ai", R = () => {
|
|
11
8
|
if (typeof window > "u")
|
|
12
9
|
return !1;
|
|
13
10
|
try {
|
|
14
|
-
return window.localStorage.getItem(
|
|
11
|
+
return window.localStorage.getItem(M) === "1";
|
|
15
12
|
} catch {
|
|
16
13
|
return !1;
|
|
17
14
|
}
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
15
|
+
}, H = () => {
|
|
16
|
+
const c = v();
|
|
17
|
+
if (!c)
|
|
21
18
|
return;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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)
|
|
63
|
-
return;
|
|
64
|
-
const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
|
|
65
|
-
if (!r || !n)
|
|
66
|
-
return;
|
|
67
|
-
const e = ct(r, t.version);
|
|
68
|
-
if (!t.applyRequested) {
|
|
69
|
-
F(e);
|
|
19
|
+
const l = c._s, p = l == null ? void 0 : l.get(L);
|
|
20
|
+
if (!p)
|
|
21
|
+
return;
|
|
22
|
+
const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: E } = I(), h = P(), y = (r, t) => {
|
|
23
|
+
const e = h(r);
|
|
24
|
+
return e === r ? t : e;
|
|
25
|
+
}, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), A = (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)
|
|
70
29
|
return;
|
|
71
|
-
|
|
72
|
-
|
|
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");
|
|
30
|
+
const t = r.blueprintId, e = r.blueprintData;
|
|
31
|
+
if (!t || !(e != null && e.html))
|
|
80
32
|
return;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (a === n || !P(e))
|
|
33
|
+
if (!r.applyRequested) {
|
|
34
|
+
d(t);
|
|
84
35
|
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
|
-
}));
|
|
98
36
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
Array.isArray(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
37
|
+
const o = i.get(t);
|
|
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), E({
|
|
40
|
+
type: S.Error,
|
|
41
|
+
message: y("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
|
|
42
|
+
}), !0), m = B(
|
|
43
|
+
() => p.messages,
|
|
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);
|
|
48
|
+
const o = t == null ? void 0 : t.segments;
|
|
49
|
+
Array.isArray(o) && o.forEach((n) => {
|
|
50
|
+
if (n)
|
|
51
|
+
switch (A(e, n), n.type) {
|
|
52
|
+
case "blueprint":
|
|
53
|
+
b(n);
|
|
54
|
+
break;
|
|
55
|
+
case "error":
|
|
56
|
+
s(e);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
117
60
|
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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());
|
|
61
|
+
},
|
|
62
|
+
{ deep: !0, immediate: !0 }
|
|
63
|
+
);
|
|
64
|
+
D(() => {
|
|
65
|
+
m(), i.clear(), a.clear(), _();
|
|
134
66
|
});
|
|
135
67
|
};
|
|
136
68
|
export {
|
|
137
|
-
|
|
69
|
+
H as useCortexBlueprintBridge
|
|
138
70
|
};
|
|
@@ -1,115 +1,59 @@
|
|
|
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
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
|
|
1
|
+
import { useActionsApi as C } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as h } from "./useConfig.js";
|
|
3
|
+
import { useToaster as D } from "./useToaster.js";
|
|
4
|
+
import { useTranslations as E } from "./useTranslations.js";
|
|
5
|
+
import { ToasterTypeOptions as f } from "../enums/toaster.js";
|
|
6
|
+
import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
|
|
7
|
+
import { flattenDynamicContentList as w } from "../utils/genericUtil.js";
|
|
8
|
+
import { extractUsedDynamicContent as S } from "../utils/registerUsedDynamicContent.js";
|
|
9
|
+
import { ref as O } from "vue";
|
|
10
|
+
const U = 250, o = O({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
|
|
11
|
+
const { updateHtmlAndCss: r } = C(), { showToaster: m } = D(), y = E(), { template: T } = h(), d = A(), g = (e, t) => {
|
|
12
|
+
const a = y(e);
|
|
13
|
+
return a === e ? t : a;
|
|
14
|
+
}, v = (e) => {
|
|
15
|
+
o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
|
|
16
|
+
}, l = (e, t, a) => {
|
|
17
|
+
var c;
|
|
18
|
+
o.value = { ...o.value, [e]: "applying" };
|
|
18
19
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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));
|
|
20
|
+
r(t, a).catch((n) => {
|
|
21
|
+
console.warn("Editor did not acknowledge the template apply.", n);
|
|
22
|
+
}), o.value = { ...o.value, [e]: "applied" };
|
|
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
|
+
}));
|
|
46
32
|
} catch (n) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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();
|
|
61
|
-
return;
|
|
33
|
+
o.value = { ...o.value, [e]: "failed" }, m({
|
|
34
|
+
type: f.Error,
|
|
35
|
+
message: n instanceof Error ? n.message : "Failed to apply template"
|
|
36
|
+
});
|
|
62
37
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}), !t)
|
|
38
|
+
}, p = (e) => {
|
|
39
|
+
const t = s[e];
|
|
40
|
+
t && (clearTimeout(t), delete s[e]);
|
|
41
|
+
};
|
|
42
|
+
return { applyStatus: o, markPending: v, applyTemplate: (e, t) => {
|
|
43
|
+
t.html && (p(e), l(e, t.html, t.css ?? ""));
|
|
44
|
+
}, applyTemplateDebounced: (e, t) => {
|
|
45
|
+
if (!t.html)
|
|
72
46
|
return;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
});
|
|
47
|
+
p(e);
|
|
48
|
+
const { html: a } = t, c = t.css ?? "";
|
|
49
|
+
s[e] = setTimeout(() => {
|
|
50
|
+
delete s[e], l(e, a, c);
|
|
82
51
|
}, 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
|
-
});
|
|
104
52
|
} };
|
|
105
|
-
},
|
|
106
|
-
|
|
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 = {};
|
|
53
|
+
}, G = () => {
|
|
54
|
+
Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((r) => delete s[r]), o.value = {};
|
|
111
55
|
};
|
|
112
56
|
export {
|
|
113
|
-
|
|
114
|
-
|
|
57
|
+
G as resetEmailTemplateApplier,
|
|
58
|
+
z as useEmailTemplateApplier
|
|
115
59
|
};
|