@useinsider/guido 3.13.0-beta.4a55a9f → 3.13.0-beta.a6f0620

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,43 +1,57 @@
1
- import { useActionsApi as T } from "./useActionsApi.js";
2
- import { useToaster as f } from "./useToaster.js";
3
- import { useTranslations as y } from "./useTranslations.js";
4
- import { ToasterTypeOptions as n } from "../enums/toaster.js";
5
- import { ref as v } from "vue";
6
- const E = 250, s = v({}), o = {}, j = () => {
7
- const { updateHtmlAndCss: l } = T(), { showToaster: p } = f(), i = y(), u = (e) => {
8
- s.value[e] === void 0 && (s.value = { ...s.value, [e]: "pending" });
9
- }, c = (e, t, r) => {
10
- s.value = { ...s.value, [e]: "applying" };
1
+ import { useActionsApi as d } from "./useActionsApi.js";
2
+ import { useConfig as D } from "./useConfig.js";
3
+ import { useToaster as h } from "./useToaster.js";
4
+ import { useTranslations as E } from "./useTranslations.js";
5
+ import { ToasterTypeOptions as f } from "../enums/toaster.js";
6
+ import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
7
+ import { flattenDynamicContentList as S } from "../utils/genericUtil.js";
8
+ import { extractUsedDynamicContent as O } from "../utils/registerUsedDynamicContent.js";
9
+ import { ref as U } from "vue";
10
+ const w = 250, o = U({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
11
+ const { updateHtmlAndCss: c } = d(), { showToaster: m } = h(), y = E(), { template: T } = D(), v = A(), g = (e, t) => {
12
+ const a = y(e);
13
+ return a === e ? t : a;
14
+ }, C = (e) => {
15
+ o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
16
+ }, l = (e, t, a) => {
17
+ var n;
18
+ o.value = { ...o.value, [e]: "applying" };
11
19
  try {
12
- l(t, r), s.value = { ...s.value, [e]: "applied" }, p({
13
- type: n.Success,
14
- message: i("newsletter.ai-template-applied")
15
- });
16
- } catch (a) {
17
- s.value = { ...s.value, [e]: "failed" }, p({
18
- type: n.Error,
19
- message: a instanceof Error ? a.message : "Failed to apply template"
20
+ c(t, a), o.value = { ...o.value, [e]: "applied" };
21
+ try {
22
+ const r = S((n = T.value) == null ? void 0 : n.dynamicContentList), p = O(t, r);
23
+ p.length > 0 && v.registerDynamicContent(p);
24
+ } catch {
25
+ }
26
+ u.get(e) !== t && (u.set(e, t), m({
27
+ type: f.Success,
28
+ message: g("newsletter.ai-template-applied", "Template applied to the editor")
29
+ }));
30
+ } catch (r) {
31
+ o.value = { ...o.value, [e]: "failed" }, m({
32
+ type: f.Error,
33
+ message: r instanceof Error ? r.message : "Failed to apply template"
20
34
  });
21
35
  }
22
- }, m = (e) => {
23
- const t = o[e];
24
- t && (clearTimeout(t), delete o[e]);
36
+ }, i = (e) => {
37
+ const t = s[e];
38
+ t && (clearTimeout(t), delete s[e]);
25
39
  };
26
- return { applyStatus: s, markPending: u, applyTemplate: (e, t) => {
27
- t.html && (m(e), c(e, t.html, t.css ?? ""));
40
+ return { applyStatus: o, markPending: C, applyTemplate: (e, t) => {
41
+ t.html && (i(e), l(e, t.html, t.css ?? ""));
28
42
  }, applyTemplateDebounced: (e, t) => {
29
43
  if (!t.html)
30
44
  return;
31
- m(e);
32
- const { html: r } = t, a = t.css ?? "";
33
- o[e] = setTimeout(() => {
34
- delete o[e], c(e, r, a);
35
- }, E);
45
+ i(e);
46
+ const { html: a } = t, n = t.css ?? "";
47
+ s[e] = setTimeout(() => {
48
+ delete s[e], l(e, a, n);
49
+ }, w);
36
50
  } };
37
- }, k = () => {
38
- Object.values(o).forEach(clearTimeout), Object.keys(o).forEach((l) => delete o[l]), s.value = {};
51
+ }, G = () => {
52
+ Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((c) => delete s[c]), o.value = {};
39
53
  };
40
54
  export {
41
- k as resetEmailTemplateApplier,
42
- j as useEmailTemplateApplier
55
+ G as resetEmailTemplateApplier,
56
+ z as useEmailTemplateApplier
43
57
  };
@@ -36,4 +36,21 @@ export declare const useDynamicContentStore: import("pinia").StoreDefinition<"gu
36
36
  }[];
37
37
  }, {
38
38
  setSelectedDynamicContent(dynamicContent: DynamicContent): void;
39
+ /**
40
+ * Bulk, append-only registration for dynamic content used by an
41
+ * AI-applied template (see useEmailTemplateApplier). Unlike
42
+ * `setSelectedDynamicContent`, this does NOT touch
43
+ * `selectedDynamicContent` (there is no single "active" picker
44
+ * selection here) — it only grows `selectedDynamicContentList`. The
45
+ * getter already removes duplicates, so a re-registration of the same
46
+ * entries (e.g. a re-apply) is harmless.
47
+ *
48
+ * `items` typically come straight from the host's own dynamic-content
49
+ * catalog (flattened `templateConfig.dynamicContentList`) — shallow-copy
50
+ * each one rather than storing the host's own object references, so
51
+ * Pinia/Vue's reactive conversion of this state can't turn a later
52
+ * in-place mutation of a "selected" item into an accidental write-back
53
+ * into the host's catalog.
54
+ */
55
+ registerDynamicContent(items: DynamicContent[]): void;
39
56
  }>;
@@ -0,0 +1,13 @@
1
+ import type { DynamicContent } from '@@/Types/generic';
2
+ export declare const extractUsedDynamicContent: (html: string, flattenedCatalog: DynamicContent[] | undefined | null) => DynamicContent[];
3
+ /**
4
+ * Dev-diagnostic sibling of `extractUsedDynamicContent`: the clean token names
5
+ * used in `html` that had NO catalog match (so were intentionally NOT
6
+ * registered). Wired into useEmailTemplateApplier's dev-gated `console.debug`
7
+ * so a developer can spot a neo↔guido personalization-vocabulary mismatch
8
+ * (see T-C2 report §8: neo may emit Atrium-schema keys the guido catalog
9
+ * doesn't recognize) in one look, without changing what actually gets
10
+ * registered. Same empty/undefined/null-catalog handling as
11
+ * `extractUsedDynamicContent` — never throws.
12
+ */
13
+ export declare const getUnmatchedDynamicContentTokens: (html: string, flattenedCatalog: DynamicContent[] | undefined | null) => string[];
@@ -1,6 +1,6 @@
1
1
  import { removeDuplicatesFromArray as n } from "../utils/arrayUtil.js";
2
2
  import { defineStore as a } from "pinia";
3
- const s = a("guidoDynamicContent", {
3
+ const c = a("guidoDynamicContent", {
4
4
  state: () => ({
5
5
  selectedDynamicContent: { text: "", value: "" },
6
6
  selectedDynamicContentList: []
@@ -8,6 +8,25 @@ const s = a("guidoDynamicContent", {
8
8
  actions: {
9
9
  setSelectedDynamicContent(t) {
10
10
  this.selectedDynamicContent = t, this.selectedDynamicContentList.push(t);
11
+ },
12
+ /**
13
+ * Bulk, append-only registration for dynamic content used by an
14
+ * AI-applied template (see useEmailTemplateApplier). Unlike
15
+ * `setSelectedDynamicContent`, this does NOT touch
16
+ * `selectedDynamicContent` (there is no single "active" picker
17
+ * selection here) — it only grows `selectedDynamicContentList`. The
18
+ * getter already removes duplicates, so a re-registration of the same
19
+ * entries (e.g. a re-apply) is harmless.
20
+ *
21
+ * `items` typically come straight from the host's own dynamic-content
22
+ * catalog (flattened `templateConfig.dynamicContentList`) — shallow-copy
23
+ * each one rather than storing the host's own object references, so
24
+ * Pinia/Vue's reactive conversion of this state can't turn a later
25
+ * in-place mutation of a "selected" item into an accidental write-back
26
+ * into the host's catalog.
27
+ */
28
+ registerDynamicContent(t) {
29
+ this.selectedDynamicContentList.push(...t.map((e) => ({ ...e })));
11
30
  }
12
31
  },
13
32
  getters: {
@@ -20,5 +39,5 @@ const s = a("guidoDynamicContent", {
20
39
  }
21
40
  });
22
41
  export {
23
- s as useDynamicContentStore
42
+ c as useDynamicContentStore
24
43
  };
@@ -0,0 +1,23 @@
1
+ import { DATA_ATTRIBUTE_REGEX as T } from "../enums/html-validator.js";
2
+ const d = /{{([a-zA-Z0-9_.\s]*)}}/gm, h = (n, e) => {
3
+ if (!e || e.length === 0)
4
+ return { matched: [], unmatchedTokens: [] };
5
+ const s = n.replace(T, "$1").match(d);
6
+ if (!s)
7
+ return { matched: [], unmatchedTokens: [] };
8
+ const u = new Map(
9
+ e.map((c) => [c.value.trim().toLowerCase(), c])
10
+ ), a = /* @__PURE__ */ new Set(), o = [], m = [];
11
+ return s.forEach((c) => {
12
+ const t = c.slice(2, -2).trim().toLowerCase();
13
+ if (t === "" || a.has(t))
14
+ return;
15
+ a.add(t);
16
+ const r = u.get(t);
17
+ r ? o.push(r) : m.push(t);
18
+ }), { matched: o, unmatchedTokens: m };
19
+ }, E = (n, e) => h(n, e).matched, k = (n, e) => h(n, e).unmatchedTokens;
20
+ export {
21
+ E as extractUsedDynamicContent,
22
+ k as getUnmatchedDynamicContentTokens
23
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.13.0-beta.4a55a9f",
3
+ "version": "3.13.0-beta.a6f0620",
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",