@useinsider/guido 3.19.0-beta.c8d2be8 → 3.19.0-beta.cd25cc8
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 +6 -6
- package/dist/components/Guido.vue2.js +96 -85
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useActionsApi.js +52 -47
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/composables/useHttp.js +48 -49
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- 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 +21 -18
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +117 -93
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +130 -96
- package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -21
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +40 -17
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -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/composables/useHttp.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/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +16 -2
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -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/src/utils/stripoEditorApi.d.ts +4 -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/stores/unsubscribe.js +3 -3
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/stripoEditorApi.js +11 -0
- package/dist/utils/templatePreparation.js +61 -85
- package/package.json +2 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ToasterTypeOptions as l } from "../enums/toaster.js";
|
|
2
|
+
import { ref as p } from "vue";
|
|
3
|
+
import { useToaster as u } from "./useToaster.js";
|
|
4
|
+
import { useTranslations as f } from "./useTranslations.js";
|
|
5
|
+
const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRestricted"], n = p(null), a = (e) => {
|
|
6
|
+
try {
|
|
7
|
+
return new URL(e, window.location.href).origin === window.location.origin;
|
|
8
|
+
} catch {
|
|
9
|
+
return !0;
|
|
10
|
+
}
|
|
11
|
+
}, g = (e) => {
|
|
12
|
+
try {
|
|
13
|
+
const o = new URL(e, window.location.href);
|
|
14
|
+
return o.origin === window.location.origin ? o.href : "";
|
|
15
|
+
} catch {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
}, w = (e) => {
|
|
19
|
+
try {
|
|
20
|
+
const o = JSON.parse(e);
|
|
21
|
+
return o && typeof o == "object" && Object.keys(o).length ? o : null;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}, y = (e) => typeof (e == null ? void 0 : e.message) == "string" ? e.message : "", s = (e) => y(e) || f()("user-management.collaborate-forbidden-action"), c = (e) => {
|
|
26
|
+
u().showToaster({ type: l.Error, message: e });
|
|
27
|
+
}, R = (e, o, t) => {
|
|
28
|
+
if (t && !a(t))
|
|
29
|
+
return;
|
|
30
|
+
const r = w(o);
|
|
31
|
+
if (e === 403) {
|
|
32
|
+
c(s(r));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (e === 401 && (r == null ? void 0 : r.type) === "groupLevelAccess") {
|
|
36
|
+
c(s(r));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (e === 401 && typeof (r == null ? void 0 : r.type) == "string" && d.includes(r.type)) {
|
|
40
|
+
const i = typeof r.redirect == "string" ? g(r.redirect) : "";
|
|
41
|
+
if (i) {
|
|
42
|
+
window.location.replace(i);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
e !== 401 && e !== 419 || n.value || (window.isSessionExpired = !0, n.value = { status: e, data: r });
|
|
47
|
+
}, T = () => ({ authError: n });
|
|
48
|
+
export {
|
|
49
|
+
a as isPanelOrigin,
|
|
50
|
+
R as reportAuthError,
|
|
51
|
+
T as useAuthError
|
|
52
|
+
};
|
|
@@ -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,11 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ToasterTypeOptions as d } from "../enums/toaster.js";
|
|
2
|
+
import { findEditorApi as s, EDITOR_NOT_READY_MESSAGE as p } from "../utils/stripoEditorApi.js";
|
|
3
|
+
import { useToaster as E } from "./useToaster.js";
|
|
4
|
+
const T = () => {
|
|
5
|
+
const { showToaster: i } = E(), t = (o) => {
|
|
6
|
+
var r;
|
|
7
|
+
const e = (r = s()) == null ? void 0 : r.codeEditorApi;
|
|
8
|
+
if (!e) {
|
|
9
|
+
i({ type: d.Error, message: p });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
o(e);
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
openCodeEditor: () => {
|
|
16
|
+
t((o) => o.openCodeEditor());
|
|
17
|
+
},
|
|
18
|
+
closeCodeEditor: () => {
|
|
19
|
+
t((o) => o.closeCodeEditor());
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
9
23
|
export {
|
|
10
|
-
|
|
24
|
+
T as useCodeEditorApi
|
|
11
25
|
};
|
|
@@ -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,120 @@
|
|
|
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 x } 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 T = () => {
|
|
15
|
+
d && (clearInterval(d), d = null);
|
|
16
|
+
}, me = () => {
|
|
17
|
+
const { updateHtmlAndCss: i } = x(), { runExclusive: O } = K(), { showToaster: P } = R(), _ = F(), { template: b } = N(), L = G(), w = $(), g = (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
|
+
}, y = (e, t) => {
|
|
24
|
+
m.get(e) !== t && (m.set(e, t), g(v.Error, "newsletter.ai-template-failed-apply"));
|
|
25
|
+
}, h = () => {
|
|
26
|
+
var e, t;
|
|
27
|
+
return w.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), g(v.Success, "newsletter.ai-template-applied"));
|
|
41
|
+
}, C = 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"), y(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
|
+
}, z = (e) => {
|
|
51
|
+
const t = s.get(e);
|
|
52
|
+
t && (clearTimeout(t.timer), s.delete(e), t.settle(p));
|
|
53
|
+
}, D = (e) => {
|
|
54
|
+
const t = c.get(e);
|
|
55
|
+
t && (clearTimeout(t.timer), c.delete(e), t.settle(p));
|
|
56
|
+
}, B = () => {
|
|
57
|
+
[...c.keys()].forEach(D);
|
|
58
|
+
}, f = async () => {
|
|
59
|
+
if (s.size === 0) {
|
|
60
|
+
T();
|
|
46
61
|
return;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
}
|
|
63
|
+
if (!h())
|
|
64
|
+
return;
|
|
65
|
+
T();
|
|
66
|
+
const e = [...s.entries()];
|
|
67
|
+
s.clear(), e.forEach(([, n]) => clearTimeout(n.timer));
|
|
68
|
+
const t = e.pop();
|
|
69
|
+
if (e.forEach(([n, E]) => {
|
|
70
|
+
l(n, "failed"), E.settle({ status: "failed", error: new Error("Displaced by a newer apply") });
|
|
71
|
+
}), !t)
|
|
72
|
+
return;
|
|
73
|
+
const [o, r] = t;
|
|
74
|
+
r.settle(await C(o, r.html, r.css));
|
|
75
|
+
}, q = (e, t, o) => new Promise((r) => {
|
|
76
|
+
z(e);
|
|
77
|
+
const n = setTimeout(() => {
|
|
78
|
+
s.delete(e), l(e, "failed"), y(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
|
+
f();
|
|
85
|
+
}, Y));
|
|
86
|
+
}), S = (e, t, o) => {
|
|
87
|
+
if (h() && s.size === 0)
|
|
88
|
+
return C(e, t, o);
|
|
89
|
+
const r = q(e, t, o);
|
|
90
|
+
return f(), r;
|
|
91
|
+
};
|
|
92
|
+
return W(() => w.isStripoInitialized, (e) => {
|
|
93
|
+
e && f();
|
|
94
|
+
}, { immediate: !0 }), { applyStatus: a, markPending: Q, applyTemplate: (e, t) => {
|
|
95
|
+
const { html: o } = t;
|
|
96
|
+
return o ? (B(), S(e, o, t.css ?? "")) : Promise.resolve(M);
|
|
97
|
+
}, applyTemplateDebounced: (e, t) => {
|
|
98
|
+
const { html: o } = t;
|
|
99
|
+
if (!o)
|
|
100
|
+
return Promise.resolve(M);
|
|
101
|
+
const r = t.css ?? "";
|
|
102
|
+
return new Promise((n) => {
|
|
103
|
+
D(e);
|
|
104
|
+
const E = setTimeout(() => {
|
|
105
|
+
c.delete(e), S(e, o, r).then(n);
|
|
106
|
+
}, X);
|
|
107
|
+
c.set(e, { timer: E, settle: n });
|
|
108
|
+
});
|
|
52
109
|
} };
|
|
53
|
-
},
|
|
54
|
-
|
|
110
|
+
}, de = () => {
|
|
111
|
+
c.forEach((i) => {
|
|
112
|
+
clearTimeout(i.timer), i.settle(p);
|
|
113
|
+
}), c.clear(), s.forEach((i) => {
|
|
114
|
+
clearTimeout(i.timer), i.settle(p);
|
|
115
|
+
}), s.clear(), T(), m.clear(), a.value = {};
|
|
55
116
|
};
|
|
56
117
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
118
|
+
de as resetEmailTemplateApplier,
|
|
119
|
+
me as useEmailTemplateApplier
|
|
59
120
|
};
|