@useinsider/guido 3.21.2-beta.ccc7173 → 3.21.2-beta.d2a272e

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 (30) hide show
  1. package/README.md +35 -4
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +118 -108
  4. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
  5. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
  6. package/dist/composables/useEditorOpenMetrics.js +167 -0
  7. package/dist/composables/useSave.js +75 -68
  8. package/dist/composables/useStripo.js +93 -82
  9. package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
  10. package/dist/guido.css +1 -1
  11. package/dist/library.js +12 -10
  12. package/dist/package.json.js +6 -4
  13. package/dist/public/prefetchRuntime.js +4 -0
  14. package/dist/services/templateLibraryApi.js +36 -31
  15. package/dist/src/composables/useEditorOpenMetrics.d.ts +27 -0
  16. package/dist/src/composables/useStripo.d.ts +2 -1
  17. package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
  18. package/dist/src/library.d.ts +1 -0
  19. package/dist/src/public/prefetchRuntime.d.ts +1 -0
  20. package/dist/src/stores/unsubscribe.d.ts +0 -10
  21. package/dist/src/utils/runtimePrefetch.d.ts +4 -0
  22. package/dist/src/utils/stripoRuntime.d.ts +3 -0
  23. package/dist/src/utils/templatePreparation.d.ts +2 -1
  24. package/dist/static/stripo-runtime-manifest.json.js +9 -0
  25. package/dist/stores/unsubscribe.js +24 -28
  26. package/dist/utils/pairProductVariables.js +98 -90
  27. package/dist/utils/runtimePrefetch.js +26 -0
  28. package/dist/utils/stripoRuntime.js +13 -0
  29. package/dist/utils/templatePreparation.js +30 -30
  30. package/package.json +6 -1
@@ -1,24 +1,26 @@
1
- import { useConfig as w } from "../composables/useConfig.js";
2
- import { useHttp as b } from "../composables/useHttp.js";
3
- import { useToaster as C } from "../composables/useToaster.js";
4
- import { useTranslations as h } from "../composables/useTranslations.js";
5
- import { useLiquidValidator as S } from "../composables/validators/useLiquidValidator.js";
6
- import { EditorType as v } from "../enums/defaults.js";
7
- import { ToasterTypeOptions as x } from "../enums/toaster.js";
8
- import { useRecommendationExtensionStore as E } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
- import { useSaveAsTemplateStore as N } from "../stores/save-as-template.js";
1
+ import { useActionsApi as h } from "../composables/useActionsApi.js";
2
+ import { useConfig as S } from "../composables/useConfig.js";
3
+ import { useHttp as v } from "../composables/useHttp.js";
4
+ import { useToaster as x } from "../composables/useToaster.js";
5
+ import { useTranslations as A } from "../composables/useTranslations.js";
6
+ import { useHtmlDocumentCountValidator as E } from "../composables/validators/useHtmlDocumentCountValidator.js";
7
+ import { useLiquidValidator as N } from "../composables/validators/useLiquidValidator.js";
8
+ import { EditorType as H } from "../enums/defaults.js";
9
+ import { ToasterTypeOptions as P } from "../enums/toaster.js";
10
+ import { useRecommendationExtensionStore as D } from "../extensions/Blocks/Recommendation/store/recommendation.js";
11
+ import { useSaveAsTemplateStore as L } from "../stores/save-as-template.js";
10
12
  import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
11
- import { isPlainObject as P } from "../utils/genericUtil.js";
12
- import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
13
- const B = () => {
14
- const { get: n, post: m } = b(), { handleError: o, showToaster: l } = C(), { config: c, isFeatureEnabled: p } = w(), { validateLiquidSyntax: f } = S(), u = h();
13
+ import { isPlainObject as q } from "../utils/genericUtil.js";
14
+ import { useTemplatePreparation as F } from "../utils/templatePreparation.js";
15
+ const Z = () => {
16
+ const { get: n, post: m } = v(), { handleError: s, showToaster: l } = x(), { config: c, isFeatureEnabled: p } = S(), { validateLiquidSyntax: T } = N(), { validateSingleHtmlDocument: w } = E(), { getTemplateData: b } = h(), u = A();
15
17
  return {
16
18
  getCategories: async () => {
17
19
  try {
18
20
  const { data: e = [] } = await n("/newsletter/template-library/get-template-categories");
19
21
  return e;
20
22
  } catch (e) {
21
- return o(e, "Failed to fetch template categories"), [];
23
+ return s(e, "Failed to fetch template categories"), [];
22
24
  }
23
25
  },
24
26
  checkTemplateNameAvailability: async (e) => {
@@ -35,27 +37,30 @@ const B = () => {
35
37
  );
36
38
  return t.toString();
37
39
  } catch (t) {
38
- return o(t, "Failed to create category"), "";
40
+ return s(t, "Failed to create category"), "";
39
41
  }
40
42
  },
41
43
  createTemplate: async () => {
42
44
  var e, t, d, y;
43
45
  try {
44
- const { prepareTemplateDetails: i } = A(), s = N(), a = await i();
45
- if (p("liquidSyntax") && !await f(a.compiledHtml))
46
+ const { prepareTemplateDetails: i } = F(), o = L(), g = await b();
47
+ if (!w(g.html))
46
48
  return !1;
47
- const T = {
48
- name: s.getTemplateName,
49
- categories: s.getSelectedCategoryIds,
49
+ const a = await i(g);
50
+ if (p("liquidSyntax") && !await T(a.compiledHtml))
51
+ return !1;
52
+ const C = {
53
+ name: o.getTemplateName,
54
+ categories: o.getSelectedCategoryIds,
50
55
  productId: ((t = (e = c.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
51
- editorType: v,
56
+ editorType: H,
52
57
  messageType: ((y = (d = c.value) == null ? void 0 : d.partner) == null ? void 0 : y.messageType) || 0,
53
58
  content: r(a.compiledHtml),
54
59
  css: r(a.css),
55
60
  unsubscriptionPreferencePageStatus: !1,
56
61
  unsubscriptionPreferencePages: [],
57
62
  recommendationCampaignUrls: r(
58
- E().recommendationCampaignUrls
63
+ D().recommendationCampaignUrls
59
64
  ),
60
65
  recommendationConfigs: r({}),
61
66
  isGuido: !0,
@@ -67,31 +72,31 @@ const B = () => {
67
72
  css: a.css,
68
73
  dynamicContentList: a.dynamicContentList
69
74
  })
70
- }, { data: g } = await m(
75
+ }, { data: f } = await m(
71
76
  "/newsletter/template-library/create-template",
72
- T
77
+ C
73
78
  );
74
- if (!P(g))
79
+ if (!q(f))
75
80
  throw new Error("Unexpected create-template response");
76
- return g.type === "alert" ? (l({
81
+ return f.type === "alert" ? (l({
77
82
  message: u(
78
83
  "newsletter.template-library-save-alert",
79
- { templateName: s.getTemplateName }
84
+ { templateName: o.getTemplateName }
80
85
  ),
81
- type: x.Error
86
+ type: P.Error
82
87
  }), !1) : (l({
83
88
  message: u(
84
89
  "newsletter.template-library-save-success",
85
- { templateName: s.getTemplateName }
90
+ { templateName: o.getTemplateName }
86
91
  ),
87
92
  type: "success"
88
93
  }), !0);
89
94
  } catch (i) {
90
- return o(i, "Failed to create template"), !1;
95
+ return s(i, "Failed to create template"), !1;
91
96
  }
92
97
  }
93
98
  };
94
99
  };
95
100
  export {
96
- B as useTemplateLibraryApi
101
+ Z as useTemplateLibraryApi
97
102
  };
@@ -0,0 +1,27 @@
1
+ export type TimedOpenPhase = 'migration' | 'default_template' | 'timer_clone';
2
+ declare const PHASES: readonly ["setup", "host_ready", "migration_start", "migration_end", "default_template_start", "default_template_end", "timer_clone_start", "timer_clone_end", "plugin_start", "script_ready", "fonts_sync_ready", "blocks_config_ready", "init_editor", "token_start", "token_end", "ready"];
3
+ export type OpenPhase = typeof PHASES[number];
4
+ export type OpenOutcome = 'ready' | 'error' | 'abandoned';
5
+ export interface OpenContext {
6
+ partnerName: string;
7
+ productType: number;
8
+ templateId: string;
9
+ variationId: string;
10
+ }
11
+ export interface OpenTemplate {
12
+ html: string;
13
+ css: string;
14
+ forceRecreate: boolean;
15
+ }
16
+ export interface EditorOpenMetrics {
17
+ mark: (phase: OpenPhase) => void;
18
+ timed: <T>(phase: TimedOpenPhase, task: () => Promise<T>) => Promise<T>;
19
+ setContext: (context: OpenContext) => void;
20
+ setTemplate: (template: OpenTemplate) => void;
21
+ setScriptPreloaded: (preloaded: boolean) => void;
22
+ markReady: () => void;
23
+ markFailed: () => void;
24
+ dispose: () => void;
25
+ }
26
+ export declare const startEditorOpenMetrics: () => EditorOpenMetrics;
27
+ export {};
@@ -1,5 +1,6 @@
1
+ import type { EditorOpenMetrics } from '@@/Composables/useEditorOpenMetrics';
1
2
  import type { Metadata, Options, Template } from '@@/Types/stripo';
2
- export declare const useStripo: () => {
3
+ export declare const useStripo: (openMetrics: EditorOpenMetrics) => {
3
4
  initPlugin: (template: Template, metadata: Metadata, options: Options) => Promise<void>;
4
5
  preloadRuntime: () => void;
5
6
  };
@@ -0,0 +1,3 @@
1
+ export declare const useHtmlDocumentCountValidator: () => {
2
+ validateSingleHtmlDocument: (rawHtml: string, silent?: boolean) => boolean;
3
+ };
@@ -4,5 +4,6 @@ export { validateConfig, parseConfig, parseConfigSafe, isValidConfig, getValidat
4
4
  export { assignTrackingIds, readTrackFloor, readTrackSeq } from './public/trackingIds';
5
5
  export { useGuidoEmailEditorStore } from './public/editorState';
6
6
  export type { GuidoEmailEditorState } from './public/editorState';
7
+ export { prefetchGuidoRuntime } from './public/prefetchRuntime';
7
8
  export type { StripoEventType } from './@types/events';
8
9
  export type { PositionData, DynamicContentEvent, MergeTagClickEvent, MergeTag, BaseDynamicContent, DynamicContentNode, DynamicContentList, TooltipOptions, TextValueObject, L10n, } from './@types/generic';
@@ -0,0 +1 @@
1
+ export { prefetchGuidoRuntime } from '../utils/runtimePrefetch';
@@ -26,7 +26,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
26
26
  createdAt: string;
27
27
  updatedAt: string;
28
28
  status: number;
29
- isDefault?: boolean | undefined;
30
29
  }[];
31
30
  selectedTemplates: Record<number, number>;
32
31
  selectedUnsubscribePages: number[];
@@ -52,7 +51,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
52
51
  createdAt: string;
53
52
  updatedAt: string;
54
53
  status: number;
55
- isDefault?: boolean | undefined;
56
54
  }[];
57
55
  selectedTemplates: Record<number, number>;
58
56
  selectedUnsubscribePages: number[];
@@ -78,7 +76,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
78
76
  createdAt: string;
79
77
  updatedAt: string;
80
78
  status: number;
81
- isDefault?: boolean | undefined;
82
79
  }[];
83
80
  selectedTemplates: Record<number, number>;
84
81
  selectedUnsubscribePages: number[];
@@ -102,7 +99,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
102
99
  createdAt: string;
103
100
  updatedAt: string;
104
101
  status: number;
105
- isDefault?: boolean | undefined;
106
102
  }[];
107
103
  getThumbnailByTemplateId: (state: {
108
104
  templates: {
@@ -117,7 +113,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
117
113
  createdAt: string;
118
114
  updatedAt: string;
119
115
  status: number;
120
- isDefault?: boolean | undefined;
121
116
  }[];
122
117
  selectedTemplates: Record<number, number>;
123
118
  selectedUnsubscribePages: number[];
@@ -143,7 +138,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
143
138
  createdAt: string;
144
139
  updatedAt: string;
145
140
  status: number;
146
- isDefault?: boolean | undefined;
147
141
  }[];
148
142
  selectedTemplates: Record<number, number>;
149
143
  selectedUnsubscribePages: number[];
@@ -169,7 +163,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
169
163
  createdAt: string;
170
164
  updatedAt: string;
171
165
  status: number;
172
- isDefault?: boolean | undefined;
173
166
  }[];
174
167
  selectedTemplates: Record<number, number>;
175
168
  selectedUnsubscribePages: number[];
@@ -195,7 +188,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
195
188
  createdAt: string;
196
189
  updatedAt: string;
197
190
  status: number;
198
- isDefault?: boolean | undefined;
199
191
  }[];
200
192
  selectedTemplates: Record<number, number>;
201
193
  selectedUnsubscribePages: number[];
@@ -221,7 +213,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
221
213
  createdAt: string;
222
214
  updatedAt: string;
223
215
  status: number;
224
- isDefault?: boolean | undefined;
225
216
  }[];
226
217
  selectedTemplates: Record<number, number>;
227
218
  selectedUnsubscribePages: number[];
@@ -247,7 +238,6 @@ export declare const useUnsubscribeStore: import("pinia").StoreDefinition<"guido
247
238
  createdAt: string;
248
239
  updatedAt: string;
249
240
  status: number;
250
- isDefault?: boolean | undefined;
251
241
  }[];
252
242
  selectedTemplates: Record<number, number>;
253
243
  selectedUnsubscribePages: number[];
@@ -0,0 +1,4 @@
1
+ export type RuntimePrefetchState = 'none' | 'pending' | 'done';
2
+ export declare const RUNTIME_PREFETCH_ATTRIBUTE = "data-guido-prefetch";
3
+ export declare const prefetchGuidoRuntime: () => void;
4
+ export declare const readRuntimePrefetchState: () => RuntimePrefetchState;
@@ -0,0 +1,3 @@
1
+ /** Null when package.json does not pin `guido.stripo.version`. */
2
+ export declare const getStripoVersion: () => string | null;
3
+ export declare const getStripoRuntimeBaseUrl: () => string | null;
@@ -1,3 +1,4 @@
1
+ import type { TemplateData } from '@@/Types/actions-api';
1
2
  import type { SavedTemplateDetails } from '@@/Types/stripo';
2
3
  /**
3
4
  * Collects every unsubscribe page id referenced by the unsubscribe blocks
@@ -44,7 +45,7 @@ export declare function getHtmlReferencedUnsubscribePages(html: string): number[
44
45
  */
45
46
  declare function hydrateRecommendationStoreFromRawHtml(rawHtml: string): Promise<void>;
46
47
  export declare const useTemplatePreparation: () => {
47
- prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
48
+ prepareTemplateDetails: (prefetched?: TemplateData) => Promise<Omit<SavedTemplateDetails, "metadata">>;
48
49
  hydrateRecommendationStore: typeof hydrateRecommendationStoreFromRawHtml;
49
50
  };
50
51
  export {};
@@ -0,0 +1,9 @@
1
+ const s = "2.81.1", n = ["UIEditor.js", "zone.js", "styles-BWH3PMR4.css", "polyfills-FF3RLU5F.js", "main-5LCHF56A.js", "chunk-2HYLRI4G.js", "chunk-4SN7BSQN.js", "chunk-5IY7ZG3R.js", "chunk-62K3AMOD.js", "chunk-GK543IRH.js", "chunk-L2EPGQ76.js", "chunk-LXS5IGCQ.js", "chunk-PNWIGF4L.js", "chunk-S2TYCIH3.js", "chunk-S5UZ4LUK.js", "chunk-V2AGQPVL.js", "chunk-XZ6MUAN5.js", "chunk-ZPL4VL4O.js", "assets/css/uiEditor.css", "assets/i18n/en.json", "assets/icons/ui-editor-icons.sprite.svg", "assets/icons/ui-editor-icons.map.json", "assets/imageeditor/scripts.min.js", "assets/imageeditor/assets/icons/merged.svg"], i = {
2
+ version: s,
3
+ files: n
4
+ };
5
+ export {
6
+ i as default,
7
+ n as files,
8
+ s as version
9
+ };
@@ -1,27 +1,23 @@
1
- import { TYPE_COLLECTIONS as c, PAGE_TYPES as r } from "../enums/unsubscribe.js";
1
+ import { TYPE_COLLECTIONS as i, PAGE_TYPES as p } from "../enums/unsubscribe.js";
2
2
  import { useUnsubscribeApi as d } from "../services/unsubscribeApi.js";
3
3
  import { defineStore as u } from "pinia";
4
4
  let o = null;
5
- const p = () => ({
5
+ const r = () => ({
6
6
  templates: [],
7
7
  selectedTemplates: {},
8
8
  selectedUnsubscribePages: [],
9
- selectedCollectionType: r.GLOBAL_UNSUBSCRIBE,
10
- activeType: r.GLOBAL_UNSUBSCRIBE,
9
+ selectedCollectionType: p.GLOBAL_UNSUBSCRIBE,
10
+ activeType: p.GLOBAL_UNSUBSCRIBE,
11
11
  pageSelectionUpdateStatus: !1,
12
12
  pageSelectionDrawerStatus: !1,
13
13
  typeSelectionDrawerStatus: !1,
14
14
  isGlobalUnsubscribeDisabled: !1,
15
15
  isSubscriptionPreferencesCenterDisabled: !1,
16
16
  pendingBlockId: null
17
- });
18
- function h(e) {
19
- return [...e].sort((t, l) => +!!l.isDefault - +!!t.isDefault);
20
- }
21
- const f = u("guidoUnsubscribe", {
22
- state: () => p(),
17
+ }), b = u("guidoUnsubscribe", {
18
+ state: () => r(),
23
19
  getters: {
24
- getSelectedCollection: (e) => c[e.selectedCollectionType],
20
+ getSelectedCollection: (e) => i[e.selectedCollectionType],
25
21
  getSelectedTemplateByActiveType: (e) => e.selectedTemplates[e.activeType],
26
22
  getTemplatesByActiveType: (e) => e.templates.filter((t) => t.type === e.activeType),
27
23
  getThumbnailByTemplateId: (e) => (t) => {
@@ -29,31 +25,31 @@ const f = u("guidoUnsubscribe", {
29
25
  return ((l = e.templates.find((s) => s.id === t)) == null ? void 0 : l.thumbnail) ?? "";
30
26
  },
31
27
  getSelectedUnsubscribePagesByCollection: (e) => (t) => {
32
- const l = c[t];
28
+ const l = i[t];
33
29
  if (!l)
34
30
  return [];
35
31
  const s = /* @__PURE__ */ new Map();
36
32
  e.templates.forEach((n) => {
37
33
  s.set(n.id, n.type);
38
34
  });
39
- const i = new Set(l);
35
+ const c = new Set(l);
40
36
  return e.selectedUnsubscribePages.filter((n) => {
41
37
  const a = s.get(n);
42
- return a !== void 0 && i.has(a);
38
+ return a !== void 0 && c.has(a);
43
39
  });
44
40
  },
45
41
  isActiveTypeFirstInCollection: (e) => {
46
- const t = c[e.selectedCollectionType] ?? [];
42
+ const t = i[e.selectedCollectionType] ?? [];
47
43
  return e.activeType === t[0];
48
44
  },
49
45
  isActiveTypeLastInCollection: (e) => {
50
- const t = c[e.selectedCollectionType] ?? [];
46
+ const t = i[e.selectedCollectionType] ?? [];
51
47
  return e.activeType === t[t.length - 1];
52
48
  },
53
49
  hasTemplatesByCollectionType: (e) => {
54
50
  const t = {};
55
- return (c[e.selectedCollectionType] ?? []).forEach((s) => {
56
- t[s] = e.templates.some((i) => i.type === s);
51
+ return (i[e.selectedCollectionType] ?? []).forEach((s) => {
52
+ t[s] = e.templates.some((c) => c.type === s);
57
53
  }), t;
58
54
  },
59
55
  unsubscribePagesStatus: (e) => e.selectedUnsubscribePages.length > 0
@@ -62,7 +58,7 @@ const f = u("guidoUnsubscribe", {
62
58
  $reset() {
63
59
  const { templates: e, selectedUnsubscribePages: t } = this;
64
60
  Object.assign(this, {
65
- ...p(),
61
+ ...r(),
66
62
  templates: e,
67
63
  selectedUnsubscribePages: t
68
64
  });
@@ -70,28 +66,28 @@ const f = u("guidoUnsubscribe", {
70
66
  async fetchTemplates(e = !1) {
71
67
  !e && this.templates.length || ((e || !o) && (o = (async () => {
72
68
  const { getUnsubscribePages: t } = d();
73
- this.templates = h(await t());
69
+ this.templates = await t();
74
70
  })().finally(() => {
75
71
  o = null;
76
72
  })), await o);
77
73
  },
78
74
  setCollection(e) {
79
75
  this.selectedCollectionType = e;
80
- const t = c[e];
76
+ const t = i[e];
81
77
  if (t && t.length > 0) {
82
78
  [this.activeType] = t;
83
79
  const l = { ...this.selectedTemplates };
84
80
  t.forEach((s) => {
85
81
  if (!l[s]) {
86
- const i = this.templates.find((n) => n.type === s);
87
- i && (l[s] = i.id);
82
+ const c = this.templates.find((n) => n.type === s);
83
+ c && (l[s] = c.id);
88
84
  }
89
85
  }), this.selectedTemplates = l;
90
86
  }
91
87
  },
92
88
  setCollectionWithoutAutoSelection(e) {
93
89
  this.selectedCollectionType = e;
94
- const t = c[e];
90
+ const t = i[e];
95
91
  t && t.length > 0 && ([this.activeType] = t);
96
92
  },
97
93
  setSelectedTemplate(e) {
@@ -111,12 +107,12 @@ const f = u("guidoUnsubscribe", {
111
107
  loadSelectedTemplates(e) {
112
108
  const t = new Map(this.templates.map((s) => [s.id, s.type])), l = { ...this.selectedTemplates };
113
109
  e.forEach((s) => {
114
- const i = t.get(s);
115
- i !== void 0 && (l[i] = s);
110
+ const c = t.get(s);
111
+ c !== void 0 && (l[c] = s);
116
112
  }), this.selectedTemplates = l;
117
113
  },
118
114
  getSelectedTemplatesByCollection(e) {
119
- const t = c[e], l = [];
115
+ const t = i[e], l = [];
120
116
  return t.forEach((s) => {
121
117
  this.selectedTemplates[s] && l.push(this.selectedTemplates[s]);
122
118
  }), l;
@@ -133,5 +129,5 @@ const f = u("guidoUnsubscribe", {
133
129
  }
134
130
  });
135
131
  export {
136
- f as useUnsubscribeStore
132
+ b as useUnsubscribeStore
137
133
  };