@useinsider/guido 1.0.0-beta.f2fcf4d → 1.0.0-beta.f47d56f

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.
Files changed (111) hide show
  1. package/README.md +177 -89
  2. package/dist/@types/generic.d.ts +11 -4
  3. package/dist/@types/http.d.ts +19 -0
  4. package/dist/components/Guido.vue.d.ts +6 -0
  5. package/dist/components/Guido.vue.js +6 -6
  6. package/dist/components/Guido.vue2.js +34 -15
  7. package/dist/components/organisms/{top-bar/Header.vue.js → header/HeaderWrapper.vue.js} +7 -7
  8. package/dist/components/organisms/header/HeaderWrapper.vue2.js +14 -0
  9. package/dist/components/organisms/{top-bar/HeaderLeftSlot.vue.js → header/LeftSlot.vue.js} +7 -7
  10. package/dist/components/organisms/header/LeftSlot.vue2.js +11 -0
  11. package/dist/components/organisms/header/MiddleSlot.vue.d.ts +2 -0
  12. package/dist/components/organisms/header/MiddleSlot.vue.js +17 -0
  13. package/dist/components/organisms/header/MiddleSlot.vue2.js +20 -0
  14. package/dist/components/organisms/header/RightSlot.vue.d.ts +2 -0
  15. package/dist/components/organisms/header/RightSlot.vue.js +20 -0
  16. package/dist/components/organisms/header/RightSlot.vue2.js +24 -0
  17. package/dist/components/organisms/header/ViewOptions.vue.js +18 -0
  18. package/dist/components/organisms/header/ViewOptions.vue2.js +15 -0
  19. package/dist/components/organisms/header/version-history/VersionHistory.vue.d.ts +2 -0
  20. package/dist/components/organisms/header/version-history/VersionHistory.vue.js +22 -0
  21. package/dist/components/organisms/header/version-history/VersionHistory.vue2.js +15 -0
  22. package/dist/components/organisms/header/version-history/VersionHistoryItem.vue.d.ts +16 -0
  23. package/dist/components/organisms/header/version-history/VersionHistoryItem.vue.js +18 -0
  24. package/dist/components/organisms/header/version-history/VersionHistoryItem.vue2.js +16 -0
  25. package/dist/components/organisms/header/version-history/ViewOptions.vue.js +18 -0
  26. package/dist/components/organisms/header/version-history/ViewOptions.vue2.js +23 -0
  27. package/dist/composables/useActionsApi.d.ts +4 -0
  28. package/dist/composables/useActionsApi.js +36 -0
  29. package/dist/composables/useApiExample.d.ts +4 -6
  30. package/dist/composables/useExport.d.ts +3 -0
  31. package/dist/composables/useExport.js +30 -0
  32. package/dist/composables/useHttp.d.ts +1 -19
  33. package/dist/composables/useHttp.js +84 -0
  34. package/dist/composables/usePartner.d.ts +4 -0
  35. package/dist/composables/usePartner.js +16 -0
  36. package/dist/composables/useStripo.d.ts +2 -2
  37. package/dist/composables/useStripo.js +54 -48
  38. package/dist/composables/useTemplates.d.ts +1 -1
  39. package/dist/composables/useToaster.d.ts +1 -0
  40. package/dist/composables/useToaster.js +37 -0
  41. package/dist/composables/useTranslations.d.ts +1 -3
  42. package/dist/composables/useTranslations.js +18 -0
  43. package/dist/composables/useVersionHistoryApi.d.ts +8 -0
  44. package/dist/composables/useVersionHistoryApi.js +53 -0
  45. package/dist/enums/defaults.d.ts +4 -0
  46. package/dist/enums/defaults.js +8 -0
  47. package/dist/guido.css +1 -1
  48. package/dist/guido.png +0 -0
  49. package/dist/library.d.ts +1 -0
  50. package/dist/mock/api/custom-fonts.d.ts +2 -0
  51. package/dist/node_modules/lodash-es/_Hash.js +20 -0
  52. package/dist/node_modules/lodash-es/_ListCache.js +20 -0
  53. package/dist/node_modules/lodash-es/_Map.js +6 -0
  54. package/dist/node_modules/lodash-es/_MapCache.js +20 -0
  55. package/dist/node_modules/lodash-es/_Symbol.js +5 -0
  56. package/dist/node_modules/lodash-es/_assocIndexOf.js +10 -0
  57. package/dist/node_modules/lodash-es/_baseGetTag.js +10 -0
  58. package/dist/node_modules/lodash-es/_baseIsNative.js +16 -0
  59. package/dist/node_modules/lodash-es/_coreJsData.js +5 -0
  60. package/dist/node_modules/lodash-es/_freeGlobal.js +4 -0
  61. package/dist/node_modules/lodash-es/_getMapData.js +8 -0
  62. package/dist/node_modules/lodash-es/_getNative.js +9 -0
  63. package/dist/node_modules/lodash-es/_getRawTag.js +15 -0
  64. package/dist/node_modules/lodash-es/_getValue.js +6 -0
  65. package/dist/node_modules/lodash-es/_hashClear.js +7 -0
  66. package/dist/node_modules/lodash-es/_hashDelete.js +7 -0
  67. package/dist/node_modules/lodash-es/_hashGet.js +13 -0
  68. package/dist/node_modules/lodash-es/_hashHas.js +9 -0
  69. package/dist/node_modules/lodash-es/_hashSet.js +9 -0
  70. package/dist/node_modules/lodash-es/_isKeyable.js +7 -0
  71. package/dist/node_modules/lodash-es/_isMasked.js +11 -0
  72. package/dist/node_modules/lodash-es/_listCacheClear.js +6 -0
  73. package/dist/node_modules/lodash-es/_listCacheDelete.js +12 -0
  74. package/dist/node_modules/lodash-es/_listCacheGet.js +8 -0
  75. package/dist/node_modules/lodash-es/_listCacheHas.js +7 -0
  76. package/dist/node_modules/lodash-es/_listCacheSet.js +8 -0
  77. package/dist/node_modules/lodash-es/_mapCacheClear.js +13 -0
  78. package/dist/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  79. package/dist/node_modules/lodash-es/_mapCacheGet.js +7 -0
  80. package/dist/node_modules/lodash-es/_mapCacheHas.js +7 -0
  81. package/dist/node_modules/lodash-es/_mapCacheSet.js +8 -0
  82. package/dist/node_modules/lodash-es/_nativeCreate.js +5 -0
  83. package/dist/node_modules/lodash-es/_objectToString.js +7 -0
  84. package/dist/node_modules/lodash-es/_root.js +5 -0
  85. package/dist/node_modules/lodash-es/_toSource.js +17 -0
  86. package/dist/node_modules/lodash-es/eq.js +6 -0
  87. package/dist/node_modules/lodash-es/isFunction.js +12 -0
  88. package/dist/node_modules/lodash-es/isObject.js +7 -0
  89. package/dist/node_modules/lodash-es/memoize.js +18 -0
  90. package/dist/services/stripoApi.d.ts +7 -0
  91. package/dist/services/stripoApi.js +29 -0
  92. package/dist/static/editor.css.js +72 -22
  93. package/dist/stores/editor.d.ts +5 -0
  94. package/dist/stores/editor.js +11 -0
  95. package/dist/stores/version-history.d.ts +80 -0
  96. package/dist/stores/version-history.js +28 -0
  97. package/dist/utils/dateUtil.d.ts +1 -0
  98. package/dist/utils/dateUtil.js +16 -0
  99. package/package.json +1 -1
  100. package/dist/components/organisms/top-bar/Header.vue2.js +0 -14
  101. package/dist/components/organisms/top-bar/HeaderLeftSlot.vue2.js +0 -11
  102. package/dist/components/organisms/top-bar/HeaderMiddleSlot.vue.js +0 -17
  103. package/dist/components/organisms/top-bar/HeaderMiddleSlot.vue2.js +0 -11
  104. package/dist/components/organisms/top-bar/HeaderRightSlot.vue.js +0 -18
  105. package/dist/components/organisms/top-bar/HeaderRightSlot.vue2.js +0 -14
  106. package/dist/enums/defaults.enum.d.ts +0 -18
  107. package/dist/stores/counter.d.ts +0 -12
  108. /package/dist/components/organisms/{top-bar/Header.vue.d.ts → header/HeaderWrapper.vue.d.ts} +0 -0
  109. /package/dist/components/organisms/{top-bar/HeaderLeftSlot.vue.d.ts → header/LeftSlot.vue.d.ts} +0 -0
  110. /package/dist/components/organisms/{top-bar/HeaderMiddleSlot.vue.d.ts → header/ViewOptions.vue.d.ts} +0 -0
  111. /package/dist/components/organisms/{top-bar/HeaderRightSlot.vue.d.ts → header/version-history/ViewOptions.vue.d.ts} +0 -0
@@ -0,0 +1,22 @@
1
+ import o from "./VersionHistory.vue2.js";
2
+ /* empty css */
3
+ import i from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var n = function() {
5
+ var r = this, e = r._self._c, t = r._self._setupProxy;
6
+ return e("div", { staticClass: "version-history-wrapper d-f a-i-c f-g-1 mx-2" }, [e(t.VersionHistoryItem, { attrs: { "text-align": "right", date: t.versionHistoryStore.previousPatch.date, description: t.versionHistoryStore.previousPatch.description } }), e("div", { staticClass: "d-f" }, [e(t.InButtonV2, { attrs: { id: "guido__undo-button", "left-icon": "line-undo", styling: "ghost", type: "secondary", "disabled-status": !t.versionHistoryStore.hasPreviousPatch, "label-text-status": !1 }, on: { click: function(s) {
7
+ return t.previewVersion(t.versionHistoryStore.previousPatch.id);
8
+ } } }), e(t.InButtonV2, { attrs: { id: "guido__redo-button", "left-icon": "line-redo", styling: "ghost", type: "secondary", "disabled-status": !t.versionHistoryStore.hasNextPatch, "label-text-status": !1 }, on: { click: function(s) {
9
+ return t.previewVersion(t.versionHistoryStore.nextPatch.id);
10
+ } } })], 1), e(t.VersionHistoryItem, { attrs: { "text-align": "left", date: t.versionHistoryStore.nextPatch.date, description: t.versionHistoryStore.nextPatch.description } })], 1);
11
+ }, a = [], c = /* @__PURE__ */ i(
12
+ o,
13
+ n,
14
+ a,
15
+ !1,
16
+ null,
17
+ "187d41fa"
18
+ );
19
+ const p = c.exports;
20
+ export {
21
+ p as default
22
+ };
@@ -0,0 +1,15 @@
1
+ import { defineComponent as t } from "vue";
2
+ import { useVersionHistoryApi as e } from "../../../../composables/useVersionHistoryApi.js";
3
+ import { useVersionHistoryStore as s } from "../../../../stores/version-history.js";
4
+ import { InButtonV2 as i } from "@useinsider/design-system-vue";
5
+ import n from "./VersionHistoryItem.vue.js";
6
+ const c = /* @__PURE__ */ t({
7
+ __name: "VersionHistory",
8
+ setup(m) {
9
+ const o = s(), { previewVersion: r } = e();
10
+ return { __sfc: !0, versionHistoryStore: o, previewVersion: r, InButtonV2: i, VersionHistoryItem: n };
11
+ }
12
+ });
13
+ export {
14
+ c as default
15
+ };
@@ -0,0 +1,16 @@
1
+ type __VLS_Props = {
2
+ description: string;
3
+ date: number;
4
+ textAlign: string;
5
+ };
6
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
7
+ export default _default;
8
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
9
+ type __VLS_TypePropsToOption<T> = {
10
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
11
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
12
+ } : {
13
+ type: import('vue').PropType<T[K]>;
14
+ required: true;
15
+ };
16
+ };
@@ -0,0 +1,18 @@
1
+ import e from "./VersionHistoryItem.vue2.js";
2
+ /* empty css */
3
+ import o from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var i = function() {
5
+ var s = this, r = s._self._c, t = s._self._setupProxy;
6
+ return r("div", { staticClass: "version-history-item f-g-1" }, [t.props.description ? r("div", { staticClass: "d-f f-d-c", class: { "t-a-r": t.props.textAlign === "right" } }, [r("div", { staticClass: "t-o-e o-h w-s-n-w", domProps: { innerHTML: s._s(t.props.description) } }), r("div", { staticClass: "f-s-1" }, [s._v(" " + s._s(t.formatPatchDate(t.props.date)) + " ")])]) : s._e()]);
7
+ }, a = [], n = /* @__PURE__ */ o(
8
+ e,
9
+ i,
10
+ a,
11
+ !1,
12
+ null,
13
+ "0e2ff42d"
14
+ );
15
+ const d = n.exports;
16
+ export {
17
+ d as default
18
+ };
@@ -0,0 +1,16 @@
1
+ import { defineComponent as o } from "vue";
2
+ import { formatPatchDate as e } from "../../../../utils/dateUtil.js";
3
+ const s = /* @__PURE__ */ o({
4
+ __name: "VersionHistoryItem",
5
+ props: {
6
+ description: null,
7
+ date: null,
8
+ textAlign: null
9
+ },
10
+ setup(t) {
11
+ return { __sfc: !0, props: t, formatPatchDate: e };
12
+ }
13
+ });
14
+ export {
15
+ s as default
16
+ };
@@ -0,0 +1,18 @@
1
+ import s from "./ViewOptions.vue2.js";
2
+ /* empty css */
3
+ import i from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var r = function() {
5
+ var t = this, o = t._self._c, e = t._self._setupProxy;
6
+ return o(e.InSegments, { attrs: { id: "guido__verion-history-view-option-selection", "with-icon": "", "segment-list": e.segmentList, selected: e.versionHistoryStore.editorVisualMode }, on: { click: e.changeVisualMode } });
7
+ }, n = [], _ = /* @__PURE__ */ i(
8
+ s,
9
+ r,
10
+ n,
11
+ !1,
12
+ null,
13
+ "6a2bde67"
14
+ );
15
+ const d = _.exports;
16
+ export {
17
+ d as default
18
+ };
@@ -0,0 +1,23 @@
1
+ import { defineComponent as s } from "vue";
2
+ import { useVersionHistoryApi as n } from "../../../../composables/useVersionHistoryApi.js";
3
+ import { useVersionHistoryStore as r } from "../../../../stores/version-history.js";
4
+ import { InSegments as m } from "@useinsider/design-system-vue";
5
+ const d = /* @__PURE__ */ s({
6
+ __name: "ViewOptions",
7
+ setup(p) {
8
+ const e = r(), { switchToDesktopPreview: o, switchToMobilePreview: t } = n();
9
+ return { __sfc: !0, versionHistoryStore: e, switchToDesktopPreview: o, switchToMobilePreview: t, segmentList: [
10
+ { text: "", icon: "line-desktop", value: "desktop" },
11
+ { text: "", icon: "line-menu-mobileapp", value: "mobile" }
12
+ ], changeVisualMode: (i) => {
13
+ if (e.editorVisualMode = i, i === "mobile") {
14
+ t();
15
+ return;
16
+ }
17
+ o();
18
+ }, InSegments: m };
19
+ }
20
+ });
21
+ export {
22
+ d as default
23
+ };
@@ -0,0 +1,4 @@
1
+ import { GetCompiledEmailOptions, CompiledEmailResult } from '@@/Types/actions-api';
2
+ export declare const useActionsApi: () => {
3
+ getCompiledEmail: (options?: GetCompiledEmailOptions) => Promise<CompiledEmailResult>;
4
+ };
@@ -0,0 +1,36 @@
1
+ const d = () => ({ getCompiledEmail: (t = {}) => new Promise((a, i) => {
2
+ const m = { ...{
3
+ minimize: !0,
4
+ utmEntity: {
5
+ utmSource: "",
6
+ utmMedium: "",
7
+ utmCampaign: "",
8
+ utmContent: "",
9
+ utmTerm: "",
10
+ customUtms: [
11
+ {
12
+ name1: "val1",
13
+ name2: "val2"
14
+ }
15
+ ]
16
+ },
17
+ mergeTags: ["Tag1", "Tag2"],
18
+ forseAmp: !1,
19
+ resetDataSavedFlag: !1,
20
+ disableLineHeightsReplace: !0
21
+ }, ...t }, s = {
22
+ callback: (e, l, n, o, c) => {
23
+ e ? i(e) : a({
24
+ html: l,
25
+ ampHtml: n,
26
+ ampErrors: o,
27
+ displayConditions: c
28
+ });
29
+ },
30
+ ...m
31
+ };
32
+ window.StripoEditorApi.actionsApi.compileEmail(s);
33
+ }) });
34
+ export {
35
+ d as useActionsApi
36
+ };
@@ -1,8 +1,7 @@
1
- interface User {
2
- id: number;
3
- name: string;
4
- email: string;
5
- }
1
+ /**
2
+ * @deprecated - It's added for example purposes.
3
+ */
4
+ import type { User } from '../@types/generic';
6
5
  export declare const useApiExample: () => {
7
6
  loading: import("vue").ComputedRef<boolean>;
8
7
  error: import("vue").ComputedRef<{
@@ -60,4 +59,3 @@ export declare const useApiExample: () => {
60
59
  uploadFile: (file: File) => Promise<string>;
61
60
  clearError: () => void;
62
61
  };
63
- export {};
@@ -0,0 +1,3 @@
1
+ export declare const useExport: () => {
2
+ exportHtml: () => Promise<void>;
3
+ };
@@ -0,0 +1,30 @@
1
+ import { useActionsApi as l } from "./useActionsApi.js";
2
+ import { useToaster as m } from "./useToaster.js";
3
+ const u = () => {
4
+ const a = (r, t, e) => {
5
+ const n = new Blob([r], { type: e }), s = URL.createObjectURL(n), o = document.createElement("a");
6
+ o.href = s, o.download = t, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(s);
7
+ }, c = (r) => {
8
+ const t = /* @__PURE__ */ new Date(), e = String(t.getDate()).padStart(2, "0"), n = String(t.getMonth() + 1).padStart(2, "0"), s = t.getFullYear(), o = String(t.getHours()).padStart(2, "0"), i = String(t.getMinutes()).padStart(2, "0");
9
+ return `${r}_${e}-${n}-${s}_${o}-${i}.html`;
10
+ };
11
+ return { exportHtml: async () => {
12
+ const { getCompiledEmail: r } = l(), { showToaster: t } = m();
13
+ try {
14
+ const { html: e } = await r();
15
+ e ? a(e, c("HTML"), "text/html") : t({
16
+ type: "error",
17
+ message: "No HTML content to download"
18
+ });
19
+ } catch (e) {
20
+ const n = e instanceof Error ? e.message : String(e);
21
+ t({
22
+ type: "error",
23
+ message: `Error compiling email: ${n}`
24
+ });
25
+ }
26
+ } };
27
+ };
28
+ export {
29
+ u as useExport
30
+ };
@@ -1,22 +1,4 @@
1
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
2
- export interface HttpOptions extends Omit<RequestInit, 'method' | 'body'> {
3
- baseURL?: string;
4
- timeout?: number;
5
- retry?: number;
6
- retryDelay?: number;
7
- }
8
- export interface HttpResponse<T = unknown> {
9
- data: T;
10
- status: number;
11
- statusText: string;
12
- headers: Headers;
13
- }
14
- export interface HttpError {
15
- message: string;
16
- status?: number;
17
- statusText?: string;
18
- response?: Response;
19
- }
1
+ import type { HttpMethod, HttpOptions, HttpResponse } from '@/@types/http';
20
2
  export declare const useHttp: (defaultOptions?: HttpOptions) => {
21
3
  loading: import("vue").ComputedRef<boolean>;
22
4
  error: import("vue").ComputedRef<{
@@ -0,0 +1,84 @@
1
+ import { ref as p, computed as v } from "vue";
2
+ const j = (y = {}) => {
3
+ const h = p(!1), a = p(null), u = p(null), E = v(() => h.value), g = v(() => a.value !== null), T = {
4
+ baseURL: "",
5
+ timeout: 1e4,
6
+ retry: 0,
7
+ retryDelay: 1e3,
8
+ headers: {
9
+ "Content-Type": "application/json"
10
+ },
11
+ ...y
12
+ }, w = (e, s) => {
13
+ if (e.startsWith("http://") || e.startsWith("https://"))
14
+ return e;
15
+ const t = s || T.baseURL || "";
16
+ return t.endsWith("/") && e.startsWith("/") ? `${t}${e.slice(1)}` : t.endsWith("/") || e.startsWith("/") ? `${t}${e}` : `${t}/${e}`;
17
+ }, P = (e) => new Promise((s, t) => {
18
+ setTimeout(() => {
19
+ t(new Error("Request timeout"));
20
+ }, e);
21
+ }), x = (e) => new Promise((s) => {
22
+ setTimeout(s, e);
23
+ }), i = async (e, s, t, D = {}) => {
24
+ a.value = null, h.value = !0, u.value = new AbortController();
25
+ const n = { ...T, ...D }, L = w(s, n.baseURL), c = {
26
+ method: e,
27
+ headers: { ...n.headers },
28
+ signal: u.value.signal,
29
+ ...n
30
+ };
31
+ t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
32
+ const b = async (m = 0) => {
33
+ try {
34
+ const o = [fetch(L, c)];
35
+ n.timeout && o.push(P(n.timeout));
36
+ const r = await Promise.race(o);
37
+ if (!r.ok) {
38
+ const H = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(H);
39
+ throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
40
+ }
41
+ let f;
42
+ const l = r.headers.get("content-type");
43
+ return l != null && l.includes("application/json") ? f = await r.json() : l != null && l.includes("text/") ? f = await r.text() : f = await r.blob(), {
44
+ data: f,
45
+ status: r.status,
46
+ statusText: r.statusText,
47
+ headers: r.headers
48
+ };
49
+ } catch (o) {
50
+ const r = o instanceof Error && o.name === "AbortError";
51
+ if (m < (n.retry || 0) && !r)
52
+ return await x(n.retryDelay || 1e3), b(m + 1);
53
+ throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
54
+ }
55
+ };
56
+ try {
57
+ return await b();
58
+ } finally {
59
+ h.value = !1, u.value = null;
60
+ }
61
+ }, $ = (e, s) => i("GET", e, void 0, s), C = (e, s, t) => i("POST", e, s, t), U = (e, s, t) => i("PUT", e, s, t), A = (e, s, t) => i("PATCH", e, s, t), R = (e, s) => i("DELETE", e, void 0, s), W = (e) => {
62
+ u.value && u.value.abort(e);
63
+ }, q = () => {
64
+ a.value = null;
65
+ };
66
+ return {
67
+ // State
68
+ loading: E,
69
+ error: v(() => a.value),
70
+ hasError: g,
71
+ // Methods
72
+ request: i,
73
+ get: $,
74
+ post: C,
75
+ put: U,
76
+ patch: A,
77
+ delete: R,
78
+ cancel: W,
79
+ clearError: q
80
+ };
81
+ };
82
+ export {
83
+ j as useHttp
84
+ };
@@ -0,0 +1,4 @@
1
+ export declare const usePartner: () => {
2
+ getPartnerName: () => string;
3
+ getProductType: () => string;
4
+ };
@@ -0,0 +1,16 @@
1
+ import { DefaultProductType as o } from "../enums/defaults.js";
2
+ const p = () => {
3
+ const e = {
4
+ email: "newsletter"
5
+ };
6
+ return {
7
+ getPartnerName: () => window.location.hostname.split(".")[0] || "",
8
+ getProductType: () => {
9
+ const t = window.location.pathname.split("/").filter(Boolean)[0] || o;
10
+ return e[t] || t;
11
+ }
12
+ };
13
+ };
14
+ export {
15
+ p as usePartner
16
+ };
@@ -1,4 +1,4 @@
1
- import type { Template } from '@@types/stripo';
2
- export declare const useStripo: (emailId: string) => {
1
+ import type { Metadata, Template } from '@@/Types/stripo';
2
+ export declare const useStripo: (metadata: Metadata) => {
3
3
  initPlugin: (template: Template) => Promise<void>;
4
4
  };
@@ -1,68 +1,74 @@
1
- import { useCustomInterfaceAppearance as d } from "./useCustomInterfaceAppearance.js";
2
- const u = (s) => {
3
- const c = () => {
4
- const t = new Headers();
5
- t.append("Content-Type", "application/json");
6
- const o = JSON.stringify({
7
- pluginId: void 0,
8
- secretKey: void 0,
9
- role: void 0,
10
- userId: s
11
- });
12
- return fetch("/v2/stripo/get-token", {
13
- method: "POST",
14
- headers: t,
15
- body: o,
16
- redirect: "follow"
17
- }).then((e) => e.json());
18
- }, i = (t) => {
19
- const o = t.html, n = t.css;
1
+ import { useCustomInterfaceAppearance as m } from "./useCustomInterfaceAppearance.js";
2
+ import { useToaster as g } from "./useToaster.js";
3
+ import { useStripoApi as E } from "../services/stripoApi.js";
4
+ import { useEditorStore as S } from "../stores/editor.js";
5
+ const _ = (c) => {
6
+ const { handleError: d } = g(), { getToken: u, getCustomFonts: a } = E(), l = (e, i = []) => {
7
+ const r = S(), { html: t, css: n } = e;
20
8
  window.UIEditor.initEditor(
21
9
  document.querySelector("#guido-editor"),
22
10
  {
23
- metadata: {
24
- emailId: s,
25
- userId: "1",
26
- username: "Plugin Demo User"
27
- },
28
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
29
- html: o,
30
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11
+ metadata: c,
12
+ html: t,
31
13
  css: n,
32
14
  locale: "en",
33
- async onTokenRefreshRequest(e) {
15
+ undoButtonSelector: "#guido__undo-button",
16
+ redoButtonSelector: "#guido__redo-button",
17
+ mobileViewButtonSelector: ".guido__view-option-selection-mobile",
18
+ desktopViewButtonSelector: ".guido__view-option-selection-desktop",
19
+ codeEditorButtonSelector: "#guido__code-button",
20
+ editorFonts: {
21
+ showDefaultStandardFonts: !0,
22
+ showDefaultNotStandardFonts: !0,
23
+ customFonts: i
24
+ },
25
+ async onTokenRefreshRequest(o) {
34
26
  try {
35
- const r = await c();
36
- e(r.token);
37
- } catch (r) {
38
- console.error("Failed to refresh token:", r);
27
+ const s = await u();
28
+ o(s);
29
+ } catch (s) {
30
+ d(s, "Failed to refresh token");
39
31
  }
40
32
  },
41
33
  onTemplateLoaded() {
42
34
  try {
43
- const { importCss: e } = d();
44
- e();
45
- } catch (e) {
46
- console.error("Failed to load custom interface appearance:", e);
35
+ const { importCss: o } = m();
36
+ o();
37
+ } catch (o) {
38
+ d(o, "Failed to load custom interface appearance");
47
39
  }
40
+ },
41
+ onCodeEditorVisibilityChanged(o) {
42
+ r.isCodeEditorOpen = o;
43
+ },
44
+ onEditorVisualModeChanged(o) {
45
+ r.editorVisualMode = o.toLowerCase();
46
+ },
47
+ onVersionHistoryVisibilityChanged(o) {
48
+ r.isVersionHistoryOpen = o;
48
49
  }
49
50
  }
50
51
  );
51
- };
52
- return { initPlugin: (t) => new Promise((o, n) => {
52
+ }, p = (e) => new Promise((i, r) => {
53
53
  if (document.getElementById("UiEditorScript")) {
54
- i(t), o();
54
+ e(), i();
55
55
  return;
56
56
  }
57
- const e = document.createElement("script");
58
- e.id = "UiEditorScript", e.type = "module", e.src = "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js", e.onload = () => {
59
- i(t), o();
60
- }, e.onerror = () => {
61
- const r = new Error("Failed to load Stripo UIEditor script");
62
- n(r);
63
- }, document.body.appendChild(e);
64
- }) };
57
+ const t = document.createElement("script");
58
+ t.id = "UiEditorScript", t.type = "module", t.src = "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js", t.onload = () => {
59
+ e(), i();
60
+ }, t.onerror = () => {
61
+ const n = new Error("Failed to load Stripo UIEditor script");
62
+ r(n);
63
+ }, document.body.appendChild(t);
64
+ });
65
+ return { initPlugin: async (e) => {
66
+ await p(async () => {
67
+ const i = await a();
68
+ l(e, i);
69
+ });
70
+ } };
65
71
  };
66
72
  export {
67
- u as useStripo
73
+ _ as useStripo
68
74
  };
@@ -1,4 +1,4 @@
1
- import type { Template } from '@@types/stripo';
1
+ import type { Template } from '@@/Types/stripo';
2
2
  export declare const useTemplates: () => {
3
3
  getDefaultTemplate: () => Promise<Template>;
4
4
  getTemplate: (templateName: string) => Promise<Template>;
@@ -17,4 +17,5 @@ export declare const useToaster: () => {
17
17
  } | undefined)[]>;
18
18
  showToaster: (options?: ToasterOptions) => void;
19
19
  hideToaster: () => void;
20
+ handleError: (error: unknown, context: string) => void;
20
21
  };
@@ -0,0 +1,37 @@
1
+ import { ref as o, watch as T } from "vue";
2
+ const v = () => {
3
+ const t = o(!1), s = o(""), c = o("success"), n = o([]);
4
+ let a = null;
5
+ function i() {
6
+ a && (clearTimeout(a), a = null);
7
+ }
8
+ function u() {
9
+ t.value = !1, n.value = [], s.value = "";
10
+ }
11
+ function l(e = { message: "" }) {
12
+ u(), s.value = e.message, c.value = e.type || "success", n.value = e.actionButton ? [e.actionButton] : [], t.value = !0;
13
+ }
14
+ function f(e, r) {
15
+ const m = e instanceof Error ? e.message : String(e);
16
+ l({
17
+ type: "error",
18
+ message: `${r}: ${m}`
19
+ });
20
+ }
21
+ return T([t, s], ([e, r]) => {
22
+ i(), e && r && (a = setTimeout(() => {
23
+ u();
24
+ }, 6e3));
25
+ }), {
26
+ isToasterVisible: t,
27
+ toasterMessage: s,
28
+ toasterType: c,
29
+ toasterActionButton: n,
30
+ showToaster: l,
31
+ hideToaster: u,
32
+ handleError: f
33
+ };
34
+ };
35
+ export {
36
+ v as useToaster
37
+ };
@@ -1,7 +1,5 @@
1
1
  interface TranslationValues {
2
2
  [key: string]: string | number | boolean;
3
3
  }
4
- export declare const useTranslations: () => {
5
- trans: ((key: string, params?: TranslationValues) => string) & import("lodash").MemoizedFunction;
6
- };
4
+ export declare const useTranslations: () => ((key: string, params?: TranslationValues) => string) & import("lodash").MemoizedFunction;
7
5
  export {};
@@ -0,0 +1,18 @@
1
+ import memoize from "../node_modules/lodash-es/memoize.js";
2
+ import { ref } from "vue";
3
+ const useTranslations = () => {
4
+ const translations = ref(eval(window.GuidoConfig.translationsPath)), trans = (n, t) => {
5
+ const r = translations.value[n];
6
+ return r ? t ? Object.entries(t).reduce(
7
+ (e, [o, i]) => e.replace(new RegExp(`{${o}}`, "g"), String(i)),
8
+ r
9
+ ) : r : (console.warn(`Translation key not found: ${n}`), n);
10
+ };
11
+ return memoize(
12
+ trans,
13
+ (n, t) => !t || Object.keys(t).length === 0 ? n : JSON.stringify({ key: n, params: t })
14
+ );
15
+ };
16
+ export {
17
+ useTranslations
18
+ };
@@ -0,0 +1,8 @@
1
+ export declare const useVersionHistoryApi: () => {
2
+ openVersionHistory: () => void;
3
+ closeVersionHistory: () => void;
4
+ switchToDesktopPreview: () => void;
5
+ switchToMobilePreview: () => void;
6
+ previewVersion: (id: string) => void;
7
+ restoreVersion: (id: string) => void;
8
+ };
@@ -0,0 +1,53 @@
1
+ import { useVersionHistoryStore as p } from "../stores/version-history.js";
2
+ import { useToaster as c } from "./useToaster.js";
3
+ const l = () => {
4
+ const i = p(), { showToaster: s } = c(), t = (e) => {
5
+ i.$reset(), i.updateState(e);
6
+ }, n = () => {
7
+ i.$reset();
8
+ };
9
+ return {
10
+ openVersionHistory: () => {
11
+ window.StripoEditorApi.versionHistoryApi.openVersionHistory(t, n);
12
+ },
13
+ closeVersionHistory: () => {
14
+ window.StripoEditorApi.versionHistoryApi.closeVersionHistory();
15
+ },
16
+ switchToDesktopPreview: () => {
17
+ window.StripoEditorApi.versionHistoryApi.switchToDesktopPreview();
18
+ },
19
+ switchToMobilePreview: () => {
20
+ window.StripoEditorApi.versionHistoryApi.switchToMobilePreview();
21
+ },
22
+ previewVersion: (e) => {
23
+ window.StripoEditorApi.versionHistoryApi.previewVersion(e, (o) => {
24
+ const r = o instanceof Error ? o.message : String(o);
25
+ s({
26
+ type: "error",
27
+ message: `Error compiling email: ${r}`
28
+ });
29
+ });
30
+ },
31
+ restoreVersion: (e) => {
32
+ window.StripoEditorApi.versionHistoryApi.restoreVersion(
33
+ e,
34
+ () => {
35
+ s({
36
+ type: "success",
37
+ message: `${e} patch restored successfully.`
38
+ });
39
+ },
40
+ (o) => {
41
+ const r = o instanceof Error ? o.message : String(o);
42
+ s({
43
+ type: "error",
44
+ message: `Error compiling email: ${r}`
45
+ });
46
+ }
47
+ );
48
+ }
49
+ };
50
+ };
51
+ export {
52
+ l as useVersionHistoryApi
53
+ };
@@ -0,0 +1,4 @@
1
+ import type { GuidoConfig } from '@@/Types/generic';
2
+ export declare const DefaultGuidoConfig: GuidoConfig;
3
+ export declare const DefaultProductType = "newsletter";
4
+ export declare const DefaultUsername = "Guido User";
@@ -0,0 +1,8 @@
1
+ const t = {
2
+ translationsPath: "window.trans.en"
3
+ }, e = "newsletter", n = "Guido User";
4
+ export {
5
+ t as DefaultGuidoConfig,
6
+ e as DefaultProductType,
7
+ n as DefaultUsername
8
+ };