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