@useinsider/guido 3.1.1 → 3.2.0-beta.4345b1b

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 (79) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +66 -54
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +91 -81
  5. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  6. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
  7. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  8. package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
  9. package/dist/components/organisms/header/RightSlot.vue.js +10 -10
  10. package/dist/components/organisms/header/RightSlot.vue2.js +16 -13
  11. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
  12. package/dist/composables/useActionsApi.js +4 -4
  13. package/dist/composables/useHtmlCompiler.js +23 -21
  14. package/dist/composables/useHtmlValidator.js +40 -38
  15. package/dist/composables/usePreviewMode.js +20 -16
  16. package/dist/composables/useSave.js +23 -15
  17. package/dist/composables/useStripo.js +44 -41
  18. package/dist/composables/validators/useLiquidValidator.js +42 -0
  19. package/dist/config/compiler/liquidCompilerRules.js +15 -0
  20. package/dist/config/compiler/recommendationCompilerRules.js +162 -43
  21. package/dist/config/compiler/unsubscribeCompilerRules.js +37 -37
  22. package/dist/config/compiler/utils/recommendationCompilerUtils.js +49 -46
  23. package/dist/config/i18n/en/tooltips.json.js +2 -1
  24. package/dist/config/migrator/checkboxMigrator.js +5 -3
  25. package/dist/config/migrator/radioButtonMigrator.js +14 -12
  26. package/dist/enums/extensions/recommendationBlock.js +14 -11
  27. package/dist/enums/recommendation.js +2 -2
  28. package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
  29. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
  30. package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
  31. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  32. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  33. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  34. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +95 -93
  35. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +75 -73
  36. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
  37. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  38. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  39. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
  40. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +20 -20
  41. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  42. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  43. package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
  44. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
  45. package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
  46. package/dist/guido.css +1 -1
  47. package/dist/services/recommendationApi.js +15 -15
  48. package/dist/services/stripoApi.js +9 -9
  49. package/dist/services/templateLibraryApi.js +48 -46
  50. package/dist/src/@types/config/index.d.ts +1 -1
  51. package/dist/src/@types/config/schemas.d.ts +28 -0
  52. package/dist/src/@types/config/types.d.ts +3 -1
  53. package/dist/src/@types/generic.d.ts +0 -1
  54. package/dist/src/@types/save-as-template.d.ts +1 -0
  55. package/dist/src/composables/useActionsApi.d.ts +1 -1
  56. package/dist/src/composables/useConfig.d.ts +12 -0
  57. package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
  58. package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
  59. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  60. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  61. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
  62. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  63. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  64. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  65. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  66. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  67. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  68. package/dist/src/services/templateLibraryApi.d.ts +1 -1
  69. package/dist/src/stores/config.d.ts +108 -0
  70. package/dist/src/stores/preview.d.ts +3 -0
  71. package/dist/src/utils/genericUtil.d.ts +1 -1
  72. package/dist/src/utils/htmlCompiler.d.ts +2 -1
  73. package/dist/static/styles/base.css.js +7 -2
  74. package/dist/stores/preview.js +4 -3
  75. package/dist/utils/genericUtil.js +42 -20
  76. package/dist/utils/htmlCompiler.js +48 -41
  77. package/dist/utils/templatePreparation.js +36 -25
  78. package/dist/utils/tooltipUtils.js +4 -5
  79. package/package.json +2 -2
@@ -1,70 +1,77 @@
1
- var y = Object.defineProperty;
2
- var g = (p, e, r) => e in p ? y(p, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : p[e] = r;
3
- var u = (p, e, r) => g(p, typeof e != "symbol" ? e + "" : e, r);
4
- import { useToaster as m } from "../composables/useToaster.js";
5
- class d {
1
+ var h = Object.defineProperty;
2
+ var f = (o, e, t) => e in o ? h(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var m = (o, e, t) => f(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { useToaster as x } from "../composables/useToaster.js";
5
+ const E = /font-family\s*:[^;}"']+/gi;
6
+ class T {
6
7
  constructor(e = []) {
7
- u(this, "rules");
8
+ m(this, "rules");
8
9
  this.rules = e;
9
10
  }
10
- compile(e, r) {
11
- const l = performance.now(), t = e, o = e.length;
11
+ compile(e, t, r) {
12
+ const n = performance.now(), l = e, c = e.length;
12
13
  let s = e;
13
- const a = [];
14
- (r || this.rules).sort((n, c) => n.priority - c.priority).forEach((n) => {
15
- const c = s.length;
16
- s = this.applyRule(s, n), s.length !== c && a.push(n.id);
14
+ const i = [];
15
+ (t || this.rules).sort((p, a) => p.priority - a.priority).forEach((p) => {
16
+ const a = s.length;
17
+ s = this.applyRule(s, p), s.length !== a && i.push(p.id);
17
18
  });
18
- const i = s.length, R = o > 0 ? (o - i) / o * 100 : 0;
19
+ const u = s.length, R = c > 0 ? (c - u) / c * 100 : 0, d = new TextEncoder().encode(s).byteLength;
20
+ let y = 0;
21
+ if (r && r.name && r.family) {
22
+ const p = (s.match(E) || []).length, a = `, ${r.name}, ${r.family}`;
23
+ y = p * new TextEncoder().encode(a).byteLength;
24
+ }
25
+ const g = Math.round((d + y) / 1024);
19
26
  return {
20
- originalHtml: t,
27
+ originalHtml: l,
21
28
  compiledHtml: s,
22
- appliedRules: a,
23
- // TODO: We can use stats for monitoring in the future
29
+ appliedRules: i,
30
+ estimatedSizeKB: g,
24
31
  stats: {
25
- originalSize: o,
26
- compiledSize: i,
32
+ originalSize: c,
33
+ compiledSize: u,
27
34
  reductionPercentage: R,
28
- executionTime: performance.now() - l
35
+ executionTime: performance.now() - n
29
36
  }
30
37
  };
31
38
  }
32
- applyRule(e, r) {
39
+ applyRule(e, t) {
33
40
  try {
34
- switch (r.type) {
41
+ switch (t.type) {
35
42
  case "replace":
36
- return this.applyReplaceRule(e, r);
43
+ return this.applyReplaceRule(e, t);
37
44
  case "regex":
38
- return this.applyRegexRule(e, r);
45
+ return this.applyRegexRule(e, t);
39
46
  case "remove":
40
- return this.applyRemoveRule(e, r);
47
+ return this.applyRemoveRule(e, t);
41
48
  case "custom":
42
- return this.applyCustomRule(e, r);
49
+ return this.applyCustomRule(e, t);
43
50
  default:
44
51
  return e;
45
52
  }
46
- } catch (l) {
47
- const { handleError: t } = m();
48
- return t(l, `Failed to apply rule ${r.id}:`), e;
53
+ } catch (r) {
54
+ const { handleError: n } = x();
55
+ return n(r, `Failed to apply rule ${t.id}:`), e;
49
56
  }
50
57
  }
51
- applyReplaceRule(e, r) {
52
- const { search: l, replacement: t, replaceAll: o = !0 } = r;
53
- return o ? e.replaceAll(l, t) : e.replace(l, t);
58
+ applyReplaceRule(e, t) {
59
+ const { search: r, replacement: n, replaceAll: l = !0 } = t;
60
+ return l ? e.replaceAll(r, n) : e.replace(r, n);
54
61
  }
55
- applyRegexRule(e, r) {
56
- const { pattern: l, replacement: t, flags: o = "g" } = r, s = new RegExp(l, o);
57
- return e.replace(s, t);
62
+ applyRegexRule(e, t) {
63
+ const { pattern: r, replacement: n, flags: l = "g" } = t, c = new RegExp(r, l);
64
+ return e.replace(c, n);
58
65
  }
59
- applyRemoveRule(e, r) {
60
- return r.targets.reduce((l, t) => t instanceof RegExp ? l.replace(t, "") : l.replaceAll(t, ""), e);
66
+ applyRemoveRule(e, t) {
67
+ return t.targets.reduce((r, n) => n instanceof RegExp ? r.replace(n, "") : r.replaceAll(n, ""), e);
61
68
  }
62
- applyCustomRule(e, r) {
63
- return r.processor(e);
69
+ applyCustomRule(e, t) {
70
+ return t.processor(e);
64
71
  }
65
72
  }
66
- const A = (p = []) => new d(p);
73
+ const H = (o = []) => new T(o);
67
74
  export {
68
- d as HtmlCompilerEngine,
69
- A as createHtmlCompiler
75
+ T as HtmlCompilerEngine,
76
+ H as createHtmlCompiler
70
77
  };
@@ -1,42 +1,53 @@
1
- import { useActionsApi as f } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as C } from "../composables/useHtmlCompiler.js";
3
- import { useRecommendationExtensionStore as T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { useDynamicContentStore as x } from "../stores/dynamic-content.js";
5
- import { useUnsubscribeStore as y } from "../stores/unsubscribe.js";
6
- const E = () => {
7
- const o = x(), t = y(), { getCompiledEmail: i, getTemplateData: n, editorSave: s } = f(), { compileHtml: m } = C();
1
+ import { useActionsApi as T } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as P } from "../composables/useHtmlCompiler.js";
3
+ import { useRecommendationExtensionStore as A } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { DATA_ATTRIBUTES as l } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
5
+ import { parsePageList as h } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
6
+ import { useDynamicContentStore as C } from "../stores/dynamic-content.js";
7
+ import { useUnsubscribeStore as D } from "../stores/unsubscribe.js";
8
+ function x(i, e) {
9
+ const r = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${l.PAGE_LIST}]`), n = [];
10
+ return r.forEach((t) => {
11
+ const o = t.getAttribute(l.PAGE_LIST);
12
+ o && n.push(...h(o));
13
+ }), e.filter((t) => n.includes(t));
14
+ }
15
+ const I = () => {
16
+ const i = C(), e = D(), { getCompiledEmail: a, getTemplateData: m } = T(), { compileHtml: r } = P();
8
17
  return {
9
18
  prepareTemplateDetails: async () => {
10
- const { html: a, ampHtml: r = "", ampErrors: c = [] } = await i({
19
+ const { html: t, ampHtml: o = "", ampErrors: p = [] } = await a({
11
20
  minimize: !0,
12
21
  resetDataSavedFlag: !1
13
- }), { html: l, css: p, syncModulesIds: u = [] } = await n(), { compiledHtml: d, stats: e, appliedRules: S } = m(a), g = o.getSelectedDynamicContentList, b = T();
14
- return s(), console.debug("HTML Compilation Stats:", {
15
- originalSize: e.originalSize,
16
- compiledSize: e.compiledSize,
17
- reduction: `${e.reductionPercentage.toFixed(2)}%`,
22
+ }), { html: u, css: d, syncModulesIds: g = [] } = await m();
23
+ e.selectedUnsubscribePages.length && await e.fetchTemplates();
24
+ const { compiledHtml: c, stats: s, appliedRules: S } = r(t), b = i.getSelectedDynamicContentList, f = A();
25
+ return console.debug("HTML Compilation Stats:", {
26
+ originalSize: s.originalSize,
27
+ compiledSize: s.compiledSize,
28
+ reduction: `${s.reductionPercentage.toFixed(2)}%`,
18
29
  appliedRules: S,
19
- executionTime: `${e.executionTime.toFixed(2)}ms`
30
+ executionTime: `${s.executionTime.toFixed(2)}ms`
20
31
  }), {
21
- dynamicContentList: g,
22
- compiledHtml: d,
23
- rawHtml: l,
24
- css: p,
25
- ampHtml: r,
26
- ampErrors: c,
27
- modules: u.map(Number),
32
+ dynamicContentList: b,
33
+ compiledHtml: c,
34
+ rawHtml: u,
35
+ css: d,
36
+ ampHtml: o,
37
+ ampErrors: p,
38
+ modules: g.map(Number),
28
39
  recommendation: {
29
- campaignUrls: b.recommendationCampaignUrls,
40
+ campaignUrls: f.recommendationCampaignUrls,
30
41
  configs: {}
31
42
  },
32
43
  unsubscribe: {
33
- status: t.unsubscribePagesStatus,
34
- config: t.selectedUnsubscribePages
44
+ status: e.unsubscribePagesStatus,
45
+ config: x(c, e.selectedUnsubscribePages)
35
46
  }
36
47
  };
37
48
  }
38
49
  };
39
50
  };
40
51
  export {
41
- E as useTemplatePreparation
52
+ I as useTemplatePreparation
42
53
  };
@@ -1,11 +1,10 @@
1
- const e = (s, t = {}) => ({
2
- id: s,
1
+ const o = (i, t = {}) => ({
2
+ id: i,
3
3
  dynamicPosition: t.dynamicPosition ?? !1,
4
4
  staticPosition: t.staticPosition ?? "bottom center",
5
5
  iconStatus: t.iconStatus ?? !1,
6
- offset: t.offset,
7
- preventXss: t.preventXss
6
+ offset: t.offset
8
7
  });
9
8
  export {
10
- e as getTooltipOptions
9
+ o as getTooltipOptions
11
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.1.1",
3
+ "version": "3.2.0-beta.4345b1b",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -33,7 +33,7 @@
33
33
  "license": "ISC",
34
34
  "dependencies": {
35
35
  "@stripoinc/ui-editor-extensions": "3.5.0",
36
- "@useinsider/design-system-vue": "0.14.28",
36
+ "@useinsider/design-system-vue": "1.1.0-beta.73ec2fa",
37
37
  "@vueuse/core": "11.3.0",
38
38
  "lodash-es": "4.17.21",
39
39
  "pinia": "2.3.1",