@useinsider/guido 3.15.0-beta.4e52059 → 3.15.0-beta.62e4f60

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,3 +1,17 @@
1
+ /**
2
+ * Result of one accepted apply request, keyed by `${blueprintId}:${version ?? 1}`
3
+ * (same key cortex-fe's `isBlueprintApplied` uses). One record per key,
4
+ * latest-wins; written by the blueprint bridge via `$patch`.
5
+ */
6
+ export interface ApplyAck {
7
+ status: 'applied' | 'failed';
8
+ /** Epoch ms of this ack; strictly increasing per key. */
9
+ ackAt: number;
10
+ /** Echo of the `segment.applyRequestedAt` this ack answers (0 when absent — legacy cortex). */
11
+ requestedAt: number;
12
+ /** Only on `failed`. Cortex never renders it — the error toaster is Guido's. */
13
+ error?: string;
14
+ }
1
15
  /**
2
16
  * Outbound contract Guido publishes to the host's shared Pinia singleton so
3
17
  * cortex-fe can pick up the current editor state and forward it as
@@ -21,6 +35,14 @@ export declare const useGuidoEmailEditorStore: import("pinia").StoreDefinition<"
21
35
  lastUpdatedAt: number;
22
36
  /** Template id from the editor config, for cortex-fe to scope per-template. */
23
37
  templateId: string;
38
+ /**
39
+ * True while useCortexBlueprintBridge is mounted. Cortex-fe gates the
40
+ * "Apply to editor" button on this — it must be set at bridge MOUNT
41
+ * (not lazily on first ack) so the button enables on the editor page.
42
+ */
43
+ bridgeActive: boolean;
44
+ /** Apply acks per `${blueprintId}:${version ?? 1}` key. Cleared on bridge teardown. */
45
+ applyAcks: Record<string, ApplyAck>;
24
46
  }, {
25
47
  /** True once the bridge has published at least one snapshot. */
26
48
  hasSnapshot: (state: {
@@ -28,6 +50,8 @@ export declare const useGuidoEmailEditorStore: import("pinia").StoreDefinition<"
28
50
  css: string;
29
51
  lastUpdatedAt: number;
30
52
  templateId: string;
53
+ bridgeActive: boolean;
54
+ applyAcks: Record<string, ApplyAck>;
31
55
  } & import("pinia").PiniaCustomStateProperties<{
32
56
  /** Current Stripo HTML — stripe tables only, no DOCTYPE/wrapper. */
33
57
  html: string;
@@ -37,5 +61,13 @@ export declare const useGuidoEmailEditorStore: import("pinia").StoreDefinition<"
37
61
  lastUpdatedAt: number;
38
62
  /** Template id from the editor config, for cortex-fe to scope per-template. */
39
63
  templateId: string;
64
+ /**
65
+ * True while useCortexBlueprintBridge is mounted. Cortex-fe gates the
66
+ * "Apply to editor" button on this — it must be set at bridge MOUNT
67
+ * (not lazily on first ack) so the button enables on the editor page.
68
+ */
69
+ bridgeActive: boolean;
70
+ /** Apply acks per `${blueprintId}:${version ?? 1}` key. Cleared on bridge teardown. */
71
+ applyAcks: Record<string, ApplyAck>;
40
72
  }>) => boolean;
41
73
  }, {}>;
@@ -10,10 +10,7 @@ const o = e("guidoEditor", {
10
10
  hasChanges: !1,
11
11
  isStripoInitialized: !1,
12
12
  templateId: "",
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
13
+ syncModulesEnabled: !1
17
14
  }),
18
15
  getters: {
19
16
  // Middle Slot
@@ -8,7 +8,15 @@ const d = e("guidoEmailEditor", {
8
8
  /** Wall-clock ms when html/css were last written by the bridge. */
9
9
  lastUpdatedAt: 0,
10
10
  /** Template id from the editor config, for cortex-fe to scope per-template. */
11
- templateId: ""
11
+ templateId: "",
12
+ /**
13
+ * True while useCortexBlueprintBridge is mounted. Cortex-fe gates the
14
+ * "Apply to editor" button on this — it must be set at bridge MOUNT
15
+ * (not lazily on first ack) so the button enables on the editor page.
16
+ */
17
+ bridgeActive: !1,
18
+ /** Apply acks per `${blueprintId}:${version ?? 1}` key. Cleared on bridge teardown. */
19
+ applyAcks: {}
12
20
  }),
13
21
  getters: {
14
22
  /** True once the bridge has published at least one snapshot. */
@@ -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 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));
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(m) {
21
- const a = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
22
- if (a.length === 0)
17
+ async function R(s) {
18
+ const m = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
19
+ if (m.length === 0)
23
20
  return;
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))
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))
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 h = {
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: ((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
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(o, h);
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(m) {
67
64
  );
68
65
  }
69
66
  }
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();
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: 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({
71
+ const { html: d, ampHtml: e = "", ampErrors: y = [] } = await m({
83
72
  minimize: !0,
84
73
  resetDataSavedFlag: !1
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);
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: S.originalSize,
90
- compiledSize: S.compiledSize,
91
- reduction: `${S.reductionPercentage.toFixed(2)}%`,
92
- appliedRules: D,
93
- executionTime: `${S.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: r,
98
- css: l,
99
- ampHtml: E,
100
- ampErrors: T,
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.15.0-beta.4e52059",
3
+ "version": "3.15.0-beta.62e4f60",
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",
@@ -14,10 +14,6 @@
14
14
  "types": "./dist/components/Guido.vue.d.ts",
15
15
  "require": "./dist/components/Guido.vue.js"
16
16
  },
17
- "./tracking-ids": {
18
- "types": "./dist/src/public/trackingIds.d.ts",
19
- "import": "./dist/public/trackingIds.js"
20
- },
21
17
  "./style": "./dist/guido.css"
22
18
  },
23
19
  "scripts": {
@@ -1,8 +0,0 @@
1
- import { TRACK_ID_ATTRIBUTE as a, TRACK_SEQ_ATTRIBUTE as e, assignTrackingIds as o, readTrackFloor as A, readTrackSeq as I } from "../utils/linkTrackingIds.js";
2
- export {
3
- a as TRACK_ID_ATTRIBUTE,
4
- e as TRACK_SEQ_ATTRIBUTE,
5
- o as assignTrackingIds,
6
- A as readTrackFloor,
7
- I as readTrackSeq
8
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * Published as `@useinsider/guido/tracking-ids` — persistent link ids for the click heatmap.
3
- *
4
- * Importing from here pulls in nothing else, so the editor never enters a
5
- * consumer's module graph. Re-export surface only: this is the contract,
6
- * `utils/linkTrackingIds` is the implementation and stays free to move.
7
- */
8
- export { assignTrackingIds, readTrackFloor, readTrackSeq, TRACK_ID_ATTRIBUTE, TRACK_SEQ_ATTRIBUTE, } from '@@/Utils/linkTrackingIds';
9
- export type { TrackingIdResult } from '@@/Utils/linkTrackingIds';
@@ -1,30 +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
- * Highest id already handed out: persisted seq, live ids, consumer counter.
20
- * Scans the document because a rewrite can strip the seq host but keep the ids.
21
- */
22
- export declare function readTrackFloor(html: string, persistedCounter?: number): number;
23
- /**
24
- * Ensures every <a> opening tag carries a unique positive-integer id and the
25
- * document records the id high-water mark. Ids are minted above
26
- * max(persisted seq, max id in document, floor) so deleted ids are never
27
- * reused — even after a version restore or paste-over (floor = session floor).
28
- * Idempotent: a document already normalized returns changed=false.
29
- */
30
- export declare function assignTrackingIds(html: string, floor?: number): TrackingIdResult;
@@ -1,56 +0,0 @@
1
- const g = "data-ins-track-id", $ = "data-ins-track-seq", E = `(?:[^>"']|"[^"]*"|'[^']*')*`, f = new RegExp(`<a\\b${E}>`, "gi"), b = new RegExp(`<body\\b${E}>`, "i"), N = new RegExp(`<html\\b${E}>`, "i"), I = new RegExp(`\\b${g}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), S = new RegExp(`\\b${$}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", _ = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), w = /^[1-9][0-9]{0,14}$/, k = 999999999999999;
2
- function m(e) {
3
- const n = Number(e);
4
- return Number.isSafeInteger(n) && n > 0 ? n : 0;
5
- }
6
- function M(e) {
7
- var a;
8
- const n = (s) => {
9
- var r;
10
- const o = (r = s.exec(e)) == null ? void 0 : r[0];
11
- return o ? S.exec(o) : null;
12
- }, t = n(b) ?? n(N), c = (t == null ? void 0 : t[1]) ?? (t == null ? void 0 : t[2]) ?? (t == null ? void 0 : t[3]) ?? ((a = _.exec(e)) == null ? void 0 : a[1]) ?? "";
13
- return m(c);
14
- }
15
- function P(e, n = 0) {
16
- let t = 0;
17
- [...e.matchAll(f)].forEach(([a]) => {
18
- const s = I.exec(a), o = s ? s[1] ?? s[2] ?? s[3] ?? "" : "";
19
- w.test(o) && (t = Math.max(t, Number(o)));
20
- });
21
- const c = Number.isSafeInteger(n) && n > 0 ? n : 0;
22
- return Math.max(M(e), t, c);
23
- }
24
- function q(e, n) {
25
- const t = `${$}="${n}"`, c = b.exec(e) ?? N.exec(e);
26
- if (c) {
27
- const [s] = c, o = S.exec(s), r = o ? s.replace(o[0], t) : s.replace(/\/?>$/, (T) => ` ${t}${T}`);
28
- return e.slice(0, c.index) + r + e.slice(c.index + s.length);
29
- }
30
- const a = `<!--${p}:${n}-->`;
31
- return _.test(e) ? e.replace(_, a) : `${a}${e}`;
32
- }
33
- function D(e, n, t) {
34
- const c = `${g}="${t}"`;
35
- return n ? e.replace(n[0], c) : e.replace(/^<a\b/i, (a) => `${a} ${c}`);
36
- }
37
- function C(e, n = 0) {
38
- const t = /* @__PURE__ */ new Set();
39
- let c = 0;
40
- const a = [...e.matchAll(f)].map((i) => {
41
- const [l] = i, u = I.exec(l), R = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
42
- let x = null;
43
- return w.test(R) && !t.has(Number(R)) && (x = Number(R), t.add(x), c = Math.max(c, x)), { index: i.index, tag: l, attrMatch: u, id: x };
44
- }), s = M(e), o = Number.isSafeInteger(n) && n > 0 && n < k ? n : 0;
45
- let r = Math.max(s, c, o), T = "", d = 0, A = !1;
46
- return a.forEach((i) => {
47
- T += e.slice(d, i.index), i.id === null ? (r += 1, T += D(i.tag, i.attrMatch, r), A = !0) : T += i.tag, d = i.index + i.tag.length;
48
- }), T += e.slice(d), r > 0 && s !== r && (T = q(T, r), A = !0), { html: T, changed: A, nextSeq: r };
49
- }
50
- export {
51
- g as TRACK_ID_ATTRIBUTE,
52
- $ as TRACK_SEQ_ATTRIBUTE,
53
- C as assignTrackingIds,
54
- P as readTrackFloor,
55
- M as readTrackSeq
56
- };