@useinsider/guido 3.13.1-beta.a1e3c5f → 3.13.1-beta.de07673

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.
@@ -1,65 +1,62 @@
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 T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
- import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
7
- import { DATA_ATTRIBUTES as C } 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(c) {
14
- const n = new DOMParser().parseFromString(c, "text/html").querySelectorAll(`[${C.PAGE_LIST}]`), t = [];
15
- return n.forEach((a) => {
16
- const r = a.getAttribute(C.PAGE_LIST);
17
- r && t.push(...R(r));
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));
18
15
  }), [...new Set(t)];
19
16
  }
20
- async function M(c) {
21
- const m = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
17
+ async function R(s) {
18
+ const m = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
22
19
  if (m.length === 0)
23
20
  return;
24
- const n = T();
21
+ const o = b();
25
22
  m.forEach((t) => {
26
- var l, g, f, i, S;
27
- const a = t.getAttribute("recommendation-id"), r = a ? Number(a) : NaN;
28
- if (!Number.isFinite(r))
23
+ var c, p, g, f, r;
24
+ const a = t.getAttribute("recommendation-id"), n = a ? Number(a) : NaN;
25
+ if (!Number.isFinite(n))
29
26
  return;
30
- const p = t.getAttribute("esd-ext-config");
31
- if (!p)
27
+ const d = t.getAttribute("esd-ext-config");
28
+ if (!d)
32
29
  return;
33
30
  let e;
34
31
  try {
35
- e = JSON.parse(p);
32
+ e = JSON.parse(d);
36
33
  } catch {
37
34
  return;
38
35
  }
39
36
  if (!e || typeof e != "object" || Array.isArray(e))
40
37
  return;
41
- const o = {
38
+ const y = {
42
39
  // Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
43
40
  // already-saved blocks that never re-run the migrator don't emit a
44
41
  // strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
45
- strategy: L(e.strategy) || s.strategy,
46
- language: e.language ?? s.language,
47
- size: e.size ?? s.size,
42
+ strategy: E(e.strategy) || i.strategy,
43
+ language: e.language ?? i.language,
44
+ size: e.size ?? i.size,
48
45
  // Spread the default arrays so each block gets a fresh reference
49
46
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
50
- productIds: e.productIds ?? [...s.productIds],
51
- filters: e.filters ?? [...s.filters],
52
- shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
53
- currencyCode: ((l = e.currency) == null ? void 0 : l.code) ?? d.code,
54
- currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? d.alignment,
55
- currencyDecimalCount: ((f = e.currency) == null ? void 0 : f.decimalCount) ?? d.decimalCount,
56
- currencyDecimalSeparator: ((i = e.currency) == null ? void 0 : i.decimalSeparator) ?? d.decimalSeparator,
57
- currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? d.thousandSeparator
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
58
55
  };
59
- n.seedBlockUrlConfig(r, o);
56
+ o.seedBlockUrlConfig(n, y);
60
57
  });
61
58
  try {
62
- await n.fetchRecommendationCreateData();
59
+ await o.fetchRecommendationCreateData();
63
60
  } catch (t) {
64
61
  console.warn(
65
62
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -67,51 +64,43 @@ async function M(c) {
67
64
  );
68
65
  }
69
66
  }
70
- const Z = () => {
71
- const c = N(), u = _(), { getCompiledEmail: m, getTemplateData: n, updateHtmlAndCss: t } = k(), { compileHtml: a, compileAmpHtml: r } = x(), { isFeatureEnabled: p } = U();
67
+ const G = () => {
68
+ const s = U(), u = F(), { getCompiledEmail: m, getTemplateData: o } = P(), { compileHtml: t, compileAmpHtml: a } = w();
72
69
  return {
73
70
  prepareTemplateDetails: async () => {
74
- let { html: o, css: l, syncModulesIds: g = [] } = await n();
75
- if (p("linkTrackingIds"))
76
- try {
77
- const h = z(), { html: A, changed: H, nextSeq: I } = v(o, h.trackIdSessionFloor);
78
- H && (t(A, l), o = A), h.trackIdSessionFloor = I;
79
- } catch (h) {
80
- console.error("Tracking-id assignment failed, saving without new ids:", h);
81
- }
82
- const { html: f, ampHtml: i = "", ampErrors: S = [] } = await m({
71
+ const { html: d, ampHtml: e = "", ampErrors: y = [] } = await m({
83
72
  minimize: !0,
84
73
  resetDataSavedFlag: !1
85
- });
86
- u.selectedUnsubscribePages.length && await u.fetchTemplates(), await M(o);
87
- const { compiledHtml: w, stats: y, appliedRules: D } = a(f), E = i && r(i).compiledHtml, P = c.getSelectedDynamicContentList, F = T(), b = O(o);
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);
88
77
  return console.debug("HTML Compilation Stats:", {
89
- originalSize: y.originalSize,
90
- compiledSize: y.compiledSize,
91
- reduction: `${y.reductionPercentage.toFixed(2)}%`,
92
- appliedRules: D,
93
- executionTime: `${y.executionTime.toFixed(2)}ms`
78
+ originalSize: r.originalSize,
79
+ compiledSize: r.compiledSize,
80
+ reduction: `${r.reductionPercentage.toFixed(2)}%`,
81
+ appliedRules: A,
82
+ executionTime: `${r.executionTime.toFixed(2)}ms`
94
83
  }), {
95
- dynamicContentList: P,
96
- compiledHtml: w,
97
- rawHtml: o,
98
- css: l,
99
- ampHtml: E,
100
- ampErrors: S,
84
+ dynamicContentList: T,
85
+ compiledHtml: f,
86
+ rawHtml: c,
87
+ css: p,
88
+ ampHtml: C,
89
+ ampErrors: y,
101
90
  modules: g.map(Number),
102
91
  recommendation: {
103
- campaignUrls: F.recommendationCampaignUrls,
92
+ campaignUrls: D.recommendationCampaignUrls,
104
93
  configs: {}
105
94
  },
106
95
  unsubscribe: {
107
- status: b.length > 0,
108
- config: b
96
+ status: S.length > 0,
97
+ config: S
109
98
  }
110
99
  };
111
100
  }
112
101
  };
113
102
  };
114
103
  export {
115
- O as getHtmlReferencedUnsubscribePages,
116
- Z as useTemplatePreparation
104
+ L as getHtmlReferencedUnsubscribePages,
105
+ G as useTemplatePreparation
117
106
  };
@@ -0,0 +1,37 @@
1
+ const f = "text-decoration", A = /(?:[^;"'()]|"[^"]*"|'[^']*'|\([^)]*\))+/g, c = (e) => (e.match(A) || []).map((r) => r.trim()).filter(Boolean), l = (e) => e.slice(0, e.indexOf(":")).trim().toLowerCase(), m = (e) => e.slice(e.indexOf(":") + 1).trim().toLowerCase(), u = (e, r) => {
2
+ const s = e.getAttribute("style");
3
+ if (!s)
4
+ return;
5
+ const t = c(r.getAttribute("style") || ""), i = new Set(t.map(l)), o = c(s).filter((n) => {
6
+ const a = l(n);
7
+ return !a || i.has(a) ? !1 : !a.startsWith(f) && m(n) !== "inherit";
8
+ });
9
+ o.length && r.setAttribute("style", [...t, ...o].join("; "));
10
+ }, y = ["product-attr", "data-type", "data-number", "data-slot-2"], p = (e, r) => {
11
+ y.forEach((s) => {
12
+ const t = e.getAttribute(s);
13
+ t !== null && !r.hasAttribute(s) && r.setAttribute(s, t);
14
+ });
15
+ };
16
+ function E(e) {
17
+ e.querySelectorAll(".ins-product-td").forEach((r) => {
18
+ const s = /* @__PURE__ */ new Set();
19
+ r.querySelectorAll('[product-attr="name"]').forEach((t) => {
20
+ const i = t.closest("a");
21
+ i && r.contains(i) && s.add(i);
22
+ }), s.forEach((t) => {
23
+ if (t.querySelector("img") || Array.from(t.querySelectorAll("[product-attr]")).some((a) => a.getAttribute("product-attr") !== "name"))
24
+ return;
25
+ const o = t.closest("p");
26
+ if (o && r.contains(o)) {
27
+ p(t, o), u(t, o), t.replaceWith(...Array.from(t.childNodes));
28
+ return;
29
+ }
30
+ const n = e.createElement("span");
31
+ p(t, n), u(t, n), n.append(...Array.from(t.childNodes)), t.replaceWith(n);
32
+ });
33
+ });
34
+ }
35
+ export {
36
+ E as unwrapProductNameLinks
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.13.1-beta.a1e3c5f",
3
+ "version": "3.13.1-beta.de07673",
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",
@@ -1,11 +0,0 @@
1
- import { assignTrackingIds as t } from "../../utils/linkTrackingIds.js";
2
- function e(r) {
3
- try {
4
- return t(r).html;
5
- } catch (o) {
6
- return console.error("TrackIdMigrator failed:", o), r;
7
- }
8
- }
9
- export {
10
- e as migrateTrackIds
11
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * Backfills persistent link tracking ids (SD-141414) at load so legacy
3
- * templates, library imports and externally edited HTML enter the editor
4
- * already tagged — before Stripo sees the document (no dirty flag, no undo).
5
- */
6
- export declare function migrateTrackIds(html: string): string;
@@ -1,25 +0,0 @@
1
- /**
2
- * Persistent link tracking ids for the click heatmap (SD-141414).
3
- * Pure string transforms — no DOM parse/serialize round-trip, safe for both
4
- * Stripo raw HTML and hand-authored HTML-editor documents. Shared with email-fe.
5
- */
6
- export declare const TRACK_ID_ATTRIBUTE = "data-ins-track-id";
7
- export declare const TRACK_SEQ_ATTRIBUTE = "data-ins-track-seq";
8
- export interface TrackingIdResult {
9
- html: string;
10
- changed: boolean;
11
- nextSeq: number;
12
- }
13
- /**
14
- * Reads the persisted id high-water mark: <body> attr, then <html> attr,
15
- * then the leading comment fallback. Returns 0 when absent.
16
- */
17
- export declare function readTrackSeq(html: string): number;
18
- /**
19
- * Ensures every <a> opening tag carries a unique positive-integer id and the
20
- * document records the id high-water mark. Ids are minted above
21
- * max(persisted seq, max id in document, floor) so deleted ids are never
22
- * reused — even after a version restore or paste-over (floor = session floor).
23
- * Idempotent: a document already normalized returns changed=false.
24
- */
25
- export declare function assignTrackingIds(html: string, floor?: number): TrackingIdResult;
@@ -1,44 +0,0 @@
1
- const E = "data-ins-track-id", g = "data-ins-track-seq", N = /<a\b[^>]*>/gi, $ = /\bdata-ins-track-id\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i, R = /\bdata-ins-track-seq\s*=\s*(?:"(\d+)"|'(\d+)'|(\d+))/i, f = /<body\b[^>]*>/i, b = /<html\b[^>]*>/i, A = /<!--\s*ins-track-seq:(\d+)\s*-->/i, k = /^[1-9][0-9]{0,14}$/;
2
- function S(e) {
3
- const s = Number(e);
4
- return Number.isSafeInteger(s) && s > 0 ? s : 0;
5
- }
6
- function x(e) {
7
- var i, a, c;
8
- const n = [(i = f.exec(e)) == null ? void 0 : i[0], (a = b.exec(e)) == null ? void 0 : a[0]].reduce(
9
- (T, o) => T ?? (o ? R.exec(o) : null),
10
- null
11
- ), t = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((c = A.exec(e)) == null ? void 0 : c[1]) ?? "";
12
- return S(t);
13
- }
14
- function I(e, s) {
15
- const n = `${g}="${s}"`, t = f.exec(e) ?? b.exec(e);
16
- if (t) {
17
- const [i] = t, a = R.exec(i), c = a ? i.replace(a[0], n) : i.replace(/\/?>$/, (T) => ` ${n}${T}`);
18
- return e.slice(0, t.index) + c + e.slice(t.index + i.length);
19
- }
20
- return A.test(e) ? e.replace(A, `<!--ins-track-seq:${s}-->`) : `<!--ins-track-seq:${s}-->${e}`;
21
- }
22
- function p(e, s, n) {
23
- const t = `${E}="${n}"`;
24
- return s ? e.replace(s[0], t) : e.replace(/^<a\b/i, (i) => `${i} ${t}`);
25
- }
26
- function q(e, s = 0) {
27
- const n = /* @__PURE__ */ new Set();
28
- let t = 0;
29
- const i = [...e.matchAll(N)].map((r) => {
30
- const [_] = r, u = $.exec(_), l = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
31
- let d = null;
32
- return k.test(l) && !n.has(Number(l)) && (d = Number(l), n.add(d), t = Math.max(t, d)), { index: r.index, tag: _, attrMatch: u, id: d };
33
- });
34
- let a = Math.max(x(e), t, s), c = "", T = 0, o = !1;
35
- return i.forEach((r) => {
36
- c += e.slice(T, r.index), r.id === null ? (a += 1, c += p(r.tag, r.attrMatch, a), o = !0) : c += r.tag, T = r.index + r.tag.length;
37
- }), c += e.slice(T), a > 0 && x(c) !== a && (c = I(c, a), o = !0), { html: c, changed: o, nextSeq: a };
38
- }
39
- export {
40
- E as TRACK_ID_ATTRIBUTE,
41
- g as TRACK_SEQ_ATTRIBUTE,
42
- q as assignTrackingIds,
43
- x as readTrackSeq
44
- };