@useinsider/guido 3.13.1 → 3.14.0-beta.8d5df20

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/dist/@types/config/schemas.js +108 -92
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +91 -85
  4. package/dist/components/organisms/header/ViewOptions.vue.js +1 -1
  5. package/dist/components/organisms/header/version-history/ViewOptions.vue.js +1 -1
  6. package/dist/composables/useActionsApi.js +30 -22
  7. package/dist/composables/useEmailTemplateApplier.js +8 -6
  8. package/dist/composables/useTimerClone.js +21 -19
  9. package/dist/config/migrator/index.js +11 -10
  10. package/dist/config/migrator/trackIdMigrator.js +11 -0
  11. package/dist/guido.css +1 -1
  12. package/dist/library.js +8 -5
  13. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +12 -12
  14. package/dist/node_modules/valibot/dist/index.js +230 -216
  15. package/dist/package.json.js +1 -1
  16. package/dist/src/@types/config/schemas.d.ts +20 -0
  17. package/dist/src/composables/useActionsApi.d.ts +1 -1
  18. package/dist/src/composables/useConfig.d.ts +4 -0
  19. package/dist/src/config/migrator/index.d.ts +6 -1
  20. package/dist/src/config/migrator/trackIdMigrator.d.ts +6 -0
  21. package/dist/src/library.d.ts +1 -0
  22. package/dist/src/stores/config.d.ts +36 -0
  23. package/dist/src/stores/editor.d.ts +25 -0
  24. package/dist/src/utils/linkTrackingIds.d.ts +25 -0
  25. package/dist/static/styles/components/wide-panel.css.js +7 -0
  26. package/dist/static/styles/customEditorStyle.css.js +8 -0
  27. package/dist/stores/editor.js +4 -1
  28. package/dist/utils/linkTrackingIds.js +46 -0
  29. package/dist/utils/templatePreparation.js +72 -61
  30. package/package.json +4 -4
@@ -10,7 +10,10 @@ const o = e("guidoEditor", {
10
10
  hasChanges: !1,
11
11
  isStripoInitialized: !1,
12
12
  templateId: "",
13
- syncModulesEnabled: !1
13
+ syncModulesEnabled: !1,
14
+ // In-session id high-water mark; floors tracking-id minting so ids
15
+ // deleted by a version restore / paste-over are never reused.
16
+ trackIdSessionFloor: 0
14
17
  }),
15
18
  getters: {
16
19
  // Middle Slot
@@ -0,0 +1,46 @@
1
+ const l = "data-ins-track-id", $ = "data-ins-track-seq", E = `(?:[^>"']|"[^"]*"|'[^']*')*`, N = new RegExp(`<a\\b${E}>`, "gi"), g = new RegExp(`<body\\b${E}>`, "i"), p = new RegExp(`<html\\b${E}>`, "i"), S = new RegExp(`\\b${l}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${$}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), b = "ins-track-seq", A = new RegExp(`<!--\\s*${b}:(\\d+)\\s*-->`, "i"), I = /^[1-9][0-9]{0,14}$/;
2
+ function w(e) {
3
+ const t = Number(e);
4
+ return Number.isSafeInteger(t) && t > 0 ? t : 0;
5
+ }
6
+ function q(e) {
7
+ var r;
8
+ const t = (a) => {
9
+ var i;
10
+ const c = (i = a.exec(e)) == null ? void 0 : i[0];
11
+ return c ? f.exec(c) : null;
12
+ }, n = t(g) ?? t(p), s = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((r = A.exec(e)) == null ? void 0 : r[1]) ?? "";
13
+ return w(s);
14
+ }
15
+ function k(e, t) {
16
+ const n = `${$}="${t}"`, s = g.exec(e) ?? p.exec(e);
17
+ if (s) {
18
+ const [a] = s, c = f.exec(a), i = c ? a.replace(c[0], n) : a.replace(/\/?>$/, (T) => ` ${n}${T}`);
19
+ return e.slice(0, s.index) + i + e.slice(s.index + a.length);
20
+ }
21
+ const r = `<!--${b}:${t}-->`;
22
+ return A.test(e) ? e.replace(A, r) : `${r}${e}`;
23
+ }
24
+ function C(e, t, n) {
25
+ const s = `${l}="${n}"`;
26
+ return t ? e.replace(t[0], s) : e.replace(/^<a\b/i, (r) => `${r} ${s}`);
27
+ }
28
+ function P(e, t = 0) {
29
+ const n = /* @__PURE__ */ new Set();
30
+ let s = 0;
31
+ const r = [...e.matchAll(N)].map((o) => {
32
+ const [_] = o, u = S.exec(_), R = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
33
+ let d = null;
34
+ return I.test(R) && !n.has(Number(R)) && (d = Number(R), n.add(d), s = Math.max(s, d)), { index: o.index, tag: _, attrMatch: u, id: d };
35
+ }), a = q(e);
36
+ let c = Math.max(a, s, t), i = "", T = 0, x = !1;
37
+ return r.forEach((o) => {
38
+ i += e.slice(T, o.index), o.id === null ? (c += 1, i += C(o.tag, o.attrMatch, c), x = !0) : i += o.tag, T = o.index + o.tag.length;
39
+ }), i += e.slice(T), c > 0 && a !== c && (i = k(i, c), x = !0), { html: i, changed: x, nextSeq: c };
40
+ }
41
+ export {
42
+ l as TRACK_ID_ATTRIBUTE,
43
+ $ as TRACK_SEQ_ATTRIBUTE,
44
+ P as assignTrackingIds,
45
+ q as readTrackSeq
46
+ };
@@ -1,62 +1,65 @@
1
- import { useActionsApi as P } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as w } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as i } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
- import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { mapLegacyStrategy as E } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
6
- import { DATA_ATTRIBUTES as h } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
- import { parsePageList as H } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
- import { useDynamicContentStore as U } from "../stores/dynamic-content.js";
9
- import { useUnsubscribeStore as F } from "../stores/unsubscribe.js";
10
- function L(s) {
11
- const o = new DOMParser().parseFromString(s, "text/html").querySelectorAll(`[${h.PAGE_LIST}]`), t = [];
12
- return o.forEach((a) => {
13
- const n = a.getAttribute(h.PAGE_LIST);
14
- n && t.push(...H(n));
1
+ import { useActionsApi as k } from "../composables/useActionsApi.js";
2
+ import { useConfig as U } from "../composables/useConfig.js";
3
+ import { useHtmlCompiler as x } from "../composables/useHtmlCompiler.js";
4
+ import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
5
+ import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
+ import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
7
+ import { DATA_ATTRIBUTES as A } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
+ import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
+ import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
10
+ import { useEditorStore as z } from "../stores/editor.js";
11
+ import { useUnsubscribeStore as _ } from "../stores/unsubscribe.js";
12
+ import { assignTrackingIds as v } from "./linkTrackingIds.js";
13
+ function O(m) {
14
+ const n = new DOMParser().parseFromString(m, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
15
+ return n.forEach((i) => {
16
+ const o = i.getAttribute(A.PAGE_LIST);
17
+ o && t.push(...R(o));
15
18
  }), [...new Set(t)];
16
19
  }
17
- async function R(s) {
18
- const m = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
19
- if (m.length === 0)
20
+ async function M(m) {
21
+ const a = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
22
+ if (a.length === 0)
20
23
  return;
21
- const o = b();
22
- m.forEach((t) => {
23
- var c, p, g, f, r;
24
- const a = t.getAttribute("recommendation-id"), n = a ? Number(a) : NaN;
25
- if (!Number.isFinite(n))
24
+ const n = C();
25
+ a.forEach((t) => {
26
+ var r, l, g, f, c;
27
+ const i = t.getAttribute("recommendation-id"), o = i ? Number(i) : NaN;
28
+ if (!Number.isFinite(o))
26
29
  return;
27
- const d = t.getAttribute("esd-ext-config");
28
- if (!d)
30
+ const p = t.getAttribute("esd-ext-config");
31
+ if (!p)
29
32
  return;
30
33
  let e;
31
34
  try {
32
- e = JSON.parse(d);
35
+ e = JSON.parse(p);
33
36
  } catch {
34
37
  return;
35
38
  }
36
39
  if (!e || typeof e != "object" || Array.isArray(e))
37
40
  return;
38
- const y = {
41
+ const h = {
39
42
  // Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
40
43
  // already-saved blocks that never re-run the migrator don't emit a
41
44
  // strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
42
- strategy: E(e.strategy) || i.strategy,
43
- language: e.language ?? i.language,
44
- size: e.size ?? i.size,
45
+ strategy: L(e.strategy) || s.strategy,
46
+ language: e.language ?? s.language,
47
+ size: e.size ?? s.size,
45
48
  // Spread the default arrays so each block gets a fresh reference
46
49
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
47
- productIds: e.productIds ?? [...i.productIds],
48
- filters: e.filters ?? [...i.filters],
49
- shuffleProducts: e.shuffleProducts ?? i.shuffleProducts,
50
- currencyCode: ((c = e.currency) == null ? void 0 : c.code) ?? l.code,
51
- currencyAlignment: ((p = e.currency) == null ? void 0 : p.alignment) ?? l.alignment,
52
- currencyDecimalCount: ((g = e.currency) == null ? void 0 : g.decimalCount) ?? l.decimalCount,
53
- currencyDecimalSeparator: ((f = e.currency) == null ? void 0 : f.decimalSeparator) ?? l.decimalSeparator,
54
- currencyThousandSeparator: ((r = e.currency) == null ? void 0 : r.thousandSeparator) ?? l.thousandSeparator
50
+ productIds: e.productIds ?? [...s.productIds],
51
+ filters: e.filters ?? [...s.filters],
52
+ shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
53
+ currencyCode: ((r = e.currency) == null ? void 0 : r.code) ?? d.code,
54
+ currencyAlignment: ((l = e.currency) == null ? void 0 : l.alignment) ?? d.alignment,
55
+ currencyDecimalCount: ((g = e.currency) == null ? void 0 : g.decimalCount) ?? d.decimalCount,
56
+ currencyDecimalSeparator: ((f = e.currency) == null ? void 0 : f.decimalSeparator) ?? d.decimalSeparator,
57
+ currencyThousandSeparator: ((c = e.currency) == null ? void 0 : c.thousandSeparator) ?? d.thousandSeparator
55
58
  };
56
- o.seedBlockUrlConfig(n, y);
59
+ n.seedBlockUrlConfig(o, h);
57
60
  });
58
61
  try {
59
- await o.fetchRecommendationCreateData();
62
+ await n.fetchRecommendationCreateData();
60
63
  } catch (t) {
61
64
  console.warn(
62
65
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -64,43 +67,51 @@ async function R(s) {
64
67
  );
65
68
  }
66
69
  }
67
- const G = () => {
68
- const s = U(), u = F(), { getCompiledEmail: m, getTemplateData: o } = P(), { compileHtml: t, compileAmpHtml: a } = w();
70
+ const Z = () => {
71
+ const m = N(), u = z(), a = _(), { getCompiledEmail: n, getTemplateData: t, updateHtmlAndCss: i } = k(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
69
72
  return {
70
73
  prepareTemplateDetails: async () => {
71
- const { html: d, ampHtml: e = "", ampErrors: y = [] } = await m({
74
+ let { html: r, css: l, syncModulesIds: g = [] } = await t();
75
+ if (e("linkTrackingIds"))
76
+ try {
77
+ const { html: y, changed: H, nextSeq: I } = v(r, u.trackIdSessionFloor);
78
+ u.trackIdSessionFloor = I, H && (r = y, await i(y, l));
79
+ } catch (y) {
80
+ console.error("Tracking-id step failed, saving anyway:", y);
81
+ }
82
+ const { html: f, ampHtml: c = "", ampErrors: T = [] } = await n({
72
83
  minimize: !0,
73
84
  resetDataSavedFlag: !1
74
- }), { html: c, css: p, syncModulesIds: g = [] } = await o();
75
- u.selectedUnsubscribePages.length && await u.fetchTemplates(), await R(c);
76
- const { compiledHtml: f, stats: r, appliedRules: A } = t(d), C = e && a(e).compiledHtml, T = s.getSelectedDynamicContentList, D = b(), S = L(c);
85
+ });
86
+ a.selectedUnsubscribePages.length && await a.fetchTemplates(), await M(r);
87
+ const { compiledHtml: w, stats: S, appliedRules: D } = o(f), E = c && p(c).compiledHtml, P = m.getSelectedDynamicContentList, F = C(), b = O(r);
77
88
  return console.debug("HTML Compilation Stats:", {
78
- originalSize: r.originalSize,
79
- compiledSize: r.compiledSize,
80
- reduction: `${r.reductionPercentage.toFixed(2)}%`,
81
- appliedRules: A,
82
- executionTime: `${r.executionTime.toFixed(2)}ms`
89
+ originalSize: S.originalSize,
90
+ compiledSize: S.compiledSize,
91
+ reduction: `${S.reductionPercentage.toFixed(2)}%`,
92
+ appliedRules: D,
93
+ executionTime: `${S.executionTime.toFixed(2)}ms`
83
94
  }), {
84
- dynamicContentList: T,
85
- compiledHtml: f,
86
- rawHtml: c,
87
- css: p,
88
- ampHtml: C,
89
- ampErrors: y,
95
+ dynamicContentList: P,
96
+ compiledHtml: w,
97
+ rawHtml: r,
98
+ css: l,
99
+ ampHtml: E,
100
+ ampErrors: T,
90
101
  modules: g.map(Number),
91
102
  recommendation: {
92
- campaignUrls: D.recommendationCampaignUrls,
103
+ campaignUrls: F.recommendationCampaignUrls,
93
104
  configs: {}
94
105
  },
95
106
  unsubscribe: {
96
- status: S.length > 0,
97
- config: S
107
+ status: b.length > 0,
108
+ config: b
98
109
  }
99
110
  };
100
111
  }
101
112
  };
102
113
  };
103
114
  export {
104
- L as getHtmlReferencedUnsubscribePages,
105
- G as useTemplatePreparation
115
+ O as getHtmlReferencedUnsubscribePages,
116
+ Z as useTemplatePreparation
106
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.13.1",
3
+ "version": "3.14.0-beta.8d5df20",
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",
@@ -43,8 +43,8 @@
43
43
  "author": "",
44
44
  "license": "ISC",
45
45
  "dependencies": {
46
- "@stripoinc/ui-editor-extensions": "3.8.0",
47
- "@useinsider/design-system-vue": "1.3.0",
46
+ "@stripoinc/ui-editor-extensions": "3.9.0",
47
+ "@useinsider/design-system-vue": "1.5.0",
48
48
  "@vueuse/core": "11.3.0",
49
49
  "lodash-es": "4.17.21",
50
50
  "pinia": "2.3.1",
@@ -113,7 +113,7 @@
113
113
  },
114
114
  "guido": {
115
115
  "stripo": {
116
- "version": "2.69.1"
116
+ "version": "2.72.1"
117
117
  }
118
118
  }
119
119
  }