@useinsider/guido 3.14.0-beta.1abaa5e → 3.14.0-beta.38ec3aa

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,68 +1,50 @@
1
1
  import { useAllowlistApi as A } from "../services/allowlistApi.js";
2
- import { base64EncodeWithSpecialChars as f } from "../utils/base64.js";
3
- import { useTranslations as D } from "./useTranslations.js";
4
- import { useUserRole as E } from "./useUserRole.js";
5
- const _ = /(?:https?:\/\/|www\.)[^\s"'<>()]+/gi, L = /&quot;\/\//gi, w = "s3-eu-west-1.amazonaws.com", d = [
6
- "insider-email",
7
- "web-image.useinsider.com",
8
- "image.useinsider.com",
9
- "panel-assets.useinsider.com",
10
- "stripo-editor-image"
11
- ], N = ({ hostname: r, pathname: l }) => {
12
- const n = r.toLowerCase();
13
- if (n === w) {
14
- const i = l.split("/")[1].toLowerCase();
15
- return d.includes(i);
16
- }
17
- return d.some((i) => n === `${i}.${w}`);
18
- }, m = {
2
+ import { base64EncodeWithSpecialChars as p } from "../utils/base64.js";
3
+ import { useTranslations as h } from "./useTranslations.js";
4
+ import { useUserRole as D } from "./useUserRole.js";
5
+ const f = /(?:https?:\/\/|www\.)[^\s"'<>()]+/gi, E = /&quot;\/\//gi, i = {
19
6
  MANAGE: "journey-builder.domain-allowlist-warning",
20
7
  NON_MANAGE: "settings.allow-list-warning-not-admin-architect",
21
8
  ADD_BUTTON: "settings.allow-list-warning-add-button"
22
- }, g = /* @__PURE__ */ new Set(), O = (r) => `/settings?openAddModal=true&type=domain&values=${f(r)}#security`, C = () => {
23
- const { checkDomain: r } = A(), { getIsManageUser: l } = E(), n = D(), i = (t, e) => {
24
- const a = `${t || ""} ${e || ""}`.replace(L, "https://").match(_) || [], s = /* @__PURE__ */ new Set();
25
- return a.forEach((c) => {
26
- const h = /^https?:\/\//i.test(c) ? c : `https://${c}`;
9
+ }, w = /* @__PURE__ */ new Set(), O = (n) => `/settings?openAddModal=true&type=domain&values=${p(n)}#security`, M = () => {
10
+ const { checkDomain: n } = A(), { getIsManageUser: l } = D(), a = h(), d = (t, s) => {
11
+ const c = `${t || ""} ${s || ""}`.replace(E, "https://").match(f) || [], e = /* @__PURE__ */ new Set();
12
+ return c.forEach((r) => {
13
+ const g = /^https?:\/\//i.test(r) ? r : `https://${r}`;
27
14
  try {
28
- const u = new URL(h);
29
- if (N(u))
30
- return;
31
- u.hostname && s.add(u.hostname.replace(/^www\./i, "").toLowerCase());
15
+ const { hostname: u } = new URL(g);
16
+ u && e.add(u.replace(/^www\./i, "").toLowerCase());
32
17
  } catch {
33
18
  }
34
- }), [...s];
35
- }, p = async (t) => {
36
- if (g.has(t))
19
+ }), [...e];
20
+ }, m = async (t) => {
21
+ if (w.has(t))
37
22
  return !0;
38
23
  try {
39
- const e = await r(t);
40
- return e && g.add(t), e;
41
- } catch (e) {
42
- return console.error("[GUIDO_ALLOWLIST] isDomainAllowlisted failed", t, e), !0;
24
+ const s = await n(t);
25
+ return s && w.add(t), s;
26
+ } catch (s) {
27
+ return console.error("[GUIDO_ALLOWLIST] isDomainAllowlisted failed", t, s), !0;
43
28
  }
44
29
  };
45
- return { getBlockedDomains: async (t, e) => {
30
+ return { getBlockedDomains: async (t, s) => {
46
31
  try {
47
- const o = i(t, e);
32
+ const o = d(t, s);
48
33
  return o.length ? (await Promise.all(
49
- o.map(async (s) => ({ domain: s, allowlisted: await p(s) }))
50
- )).filter((s) => !s.allowlisted).map((s) => s.domain) : [];
34
+ o.map(async (e) => ({ domain: e, allowlisted: await m(e) }))
35
+ )).filter((e) => !e.allowlisted).map((e) => e.domain) : [];
51
36
  } catch (o) {
52
37
  return console.error("[GUIDO_ALLOWLIST] getBlockedDomains failed", o), [];
53
38
  }
54
- }, resolveToast: async (t) => {
55
- const e = await l(), o = t.length ? ` (${t.join(", ")})` : "", a = (s) => `${s}${o}`;
56
- return e ? {
57
- message: a(n(m.MANAGE)),
58
- actionButton: {
59
- text: n(m.ADD_BUTTON),
60
- onClick: () => window.open(O(t.join(",")), "_blank")
61
- }
62
- } : { message: a(n(m.NON_MANAGE)) };
63
- } };
39
+ }, resolveToast: async (t) => await l() ? {
40
+ message: a(i.MANAGE),
41
+ actionButton: {
42
+ text: a(i.ADD_BUTTON),
43
+ onClick: () => window.open(O(t.join(",")), "_blank")
44
+ }
45
+ } : { message: a(i.NON_MANAGE) } };
64
46
  };
65
47
  export {
66
48
  O as buildAllowlistSettingsUrl,
67
- C as useAllowlist
49
+ M as useAllowlist
68
50
  };
@@ -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
  };
@@ -1,13 +1,13 @@
1
- import { defaultHtmlCompilerRules as g } from "../config/compiler/htmlCompilerRules.js";
2
- import { itemsCompilerRules as R } from "../config/compiler/itemsCompilerRules.js";
3
- import { liquidCompilerRules as b } from "../config/compiler/liquidCompilerRules.js";
4
- import { outlookCompilerRules as C } from "../config/compiler/outlookCompilerRules.js";
1
+ import { defaultHtmlCompilerRules as R } from "../config/compiler/htmlCompilerRules.js";
2
+ import { itemsCompilerRules as g } from "../config/compiler/itemsCompilerRules.js";
3
+ import { liquidCompilerRules as C } from "../config/compiler/liquidCompilerRules.js";
4
+ import { outlookCompilerRules as b } from "../config/compiler/outlookCompilerRules.js";
5
5
  import { recommendationCompilerRules as v } from "../config/compiler/recommendationCompilerRules.js";
6
- import { socialCompilerRules as y } from "../config/compiler/socialCompilerRules.js";
7
- import { unsubscribeCompilerRules as H } from "../config/compiler/unsubscribeCompilerRules.js";
6
+ import { socialCompilerRules as H } from "../config/compiler/socialCompilerRules.js";
7
+ import { unsubscribeCompilerRules as x } from "../config/compiler/unsubscribeCompilerRules.js";
8
8
  import { createHtmlCompiler as s } from "../utils/htmlCompiler.js";
9
- import { useConfig as x } from "./useConfig.js";
10
- const h = /* @__PURE__ */ new Set([
9
+ import { useConfig as k } from "./useConfig.js";
10
+ const y = /* @__PURE__ */ new Set([
11
11
  // URL/tag encoding fixes — keep merge-tag and placeholder integrity intact.
12
12
  "fix-url-encoding-start",
13
13
  "fix-url-encoding-end",
@@ -18,9 +18,6 @@ const h = /* @__PURE__ */ new Set([
18
18
  // Image domain corrections — plain string replacement.
19
19
  "replace-old-image-domain",
20
20
  "replace-old-v2-image-domain",
21
- "replace-s3-path-style-web-image-domain",
22
- "replace-s3-path-style-image-domain",
23
- "replace-s3-path-style-panel-assets-domain",
24
21
  // Unsubscribe domain — the actual fix: injects the real unsubscribe href in
25
22
  // place of the `{{ins-*-unsubscribe-link}}` placeholders, plus related
26
23
  // unsubscribe-only cleanups. All pure regex/text, no AMP-forbidden output.
@@ -35,21 +32,21 @@ const h = /* @__PURE__ */ new Set([
35
32
  "remove-contenteditable"
36
33
  ]), M = () => {
37
34
  var i, m, r;
38
- const { compiler: o, isFeatureEnabled: a, partner: n } = x(), p = ((i = o.value) == null ? void 0 : i.customRules) || [], l = [
39
- ...!!((m = o.value) != null && m.ignoreDefaultRules) ? [] : g,
35
+ const { compiler: o, isFeatureEnabled: n, partner: a } = k(), p = ((i = o.value) == null ? void 0 : i.customRules) || [], l = [
36
+ ...!!((m = o.value) != null && m.ignoreDefaultRules) ? [] : R,
40
37
  ...v,
38
+ ...x,
39
+ ...g,
40
+ ...b,
41
41
  ...H,
42
- ...R,
43
- ...C,
44
- ...y,
45
- ...a("liquidSyntax") ? b : [],
42
+ ...n("liquidSyntax") ? C : [],
46
43
  ...p.map((e, f) => ({
47
44
  ...e,
48
45
  priority: e.priority + 1e3 + f
49
46
  // Ensure additional rules run after default rules
50
47
  }))
51
- ], c = s(l), u = l.filter((e) => h.has(e.id)), d = s(u), t = (r = n.value) == null ? void 0 : r.fallbackFont;
52
- return { compileHtml: (e) => c.compile(e, void 0, t), compileAmpHtml: (e) => d.compile(e, void 0, t) };
48
+ ], u = s(l), c = l.filter((e) => y.has(e.id)), d = s(c), t = (r = a.value) == null ? void 0 : r.fallbackFont;
49
+ return { compileHtml: (e) => u.compile(e, void 0, t), compileAmpHtml: (e) => d.compile(e, void 0, t) };
53
50
  };
54
51
  export {
55
52
  M as useHtmlCompiler
@@ -122,10 +122,10 @@ const d = [
122
122
  ], i = /<head>([\S\s]*)<\/head>/, o = new RegExp(i);
123
123
  if (!e.match(o))
124
124
  return e;
125
- let s = e;
126
- return t.forEach((r) => {
127
- s = s.replace("</head>", `${r}</head>`);
128
- }), s;
125
+ let r = e;
126
+ return t.forEach((s) => {
127
+ r = r.replace("</head>", `${s}</head>`);
128
+ }), r;
129
129
  },
130
130
  priority: 30
131
131
  },
@@ -147,33 +147,6 @@ const d = [
147
147
  replaceAll: !0,
148
148
  priority: 41
149
149
  },
150
- {
151
- id: "replace-s3-path-style-web-image-domain",
152
- description: "Rewriting path-style S3 asset URLs to the web-image.useinsider.com domain",
153
- type: "replace",
154
- search: "s3-eu-west-1.amazonaws.com/web-image.useinsider.com",
155
- replacement: "web-image.useinsider.com",
156
- replaceAll: !0,
157
- priority: 42
158
- },
159
- {
160
- id: "replace-s3-path-style-image-domain",
161
- description: "Rewriting path-style S3 asset URLs to the image.useinsider.com domain",
162
- type: "replace",
163
- search: "s3-eu-west-1.amazonaws.com/image.useinsider.com",
164
- replacement: "image.useinsider.com",
165
- replaceAll: !0,
166
- priority: 43
167
- },
168
- {
169
- id: "replace-s3-path-style-panel-assets-domain",
170
- description: "Rewriting path-style S3 asset URLs to the panel-assets.useinsider.com domain",
171
- type: "replace",
172
- search: "s3-eu-west-1.amazonaws.com/panel-assets.useinsider.com",
173
- replacement: "panel-assets.useinsider.com",
174
- replaceAll: !0,
175
- priority: 46
176
- },
177
150
  {
178
151
  id: "convert-rgb-to-hex",
179
152
  // SD-142395: rgb()/6-digit hex are verbose; hex/3-digit shorthand is byte-identical
@@ -183,9 +156,9 @@ const d = [
183
156
  type: "custom",
184
157
  processor: (e) => {
185
158
  const t = (i) => i.toString(16).padStart(2, "0");
186
- return e.replace(/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/gi, (i, o, a, s) => {
187
- const [r, n, c] = [Number(o), Number(a), Number(s)];
188
- return r > 255 || n > 255 || c > 255 ? i : `#${t(r)}${t(n)}${t(c)}`;
159
+ return e.replace(/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/gi, (i, o, n, r) => {
160
+ const [s, a, c] = [Number(o), Number(n), Number(r)];
161
+ return s > 255 || a > 255 || c > 255 ? i : `#${t(s)}${t(a)}${t(c)}`;
189
162
  }).replace(/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3\b/gi, "#$1$2$3");
190
163
  },
191
164
  priority: 44
@@ -36,4 +36,12 @@ export declare const useDynamicContentStore: import("pinia").StoreDefinition<"gu
36
36
  }[];
37
37
  }, {
38
38
  setSelectedDynamicContent(dynamicContent: DynamicContent): void;
39
+ /**
40
+ * Append-only bulk registration for dynamic content used by an
41
+ * AI-applied template. Unlike `setSelectedDynamicContent` it doesn't
42
+ * touch `selectedDynamicContent`; the getter removes duplicates, so
43
+ * re-registering the same entries is harmless. Items are shallow-copied so Pinia
44
+ * reactivity can't write a later mutation back into the host's catalog.
45
+ */
46
+ registerDynamicContent(items: DynamicContent[]): void;
39
47
  }>;
@@ -0,0 +1,8 @@
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 used token names
5
+ * with NO catalog match (so intentionally not registered). Surfaced via a
6
+ * dev-gated `console.debug` to spot a neo↔guido vocabulary mismatch. Never throws.
7
+ */
8
+ 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,16 @@ const s = a("guidoDynamicContent", {
8
8
  actions: {
9
9
  setSelectedDynamicContent(t) {
10
10
  this.selectedDynamicContent = t, this.selectedDynamicContentList.push(t);
11
+ },
12
+ /**
13
+ * Append-only bulk registration for dynamic content used by an
14
+ * AI-applied template. Unlike `setSelectedDynamicContent` it doesn't
15
+ * touch `selectedDynamicContent`; the getter removes duplicates, so
16
+ * re-registering the same entries is harmless. Items are shallow-copied so Pinia
17
+ * reactivity can't write a later mutation back into the host's catalog.
18
+ */
19
+ registerDynamicContent(t) {
20
+ this.selectedDynamicContentList.push(...t.map((e) => ({ ...e })));
11
21
  }
12
22
  },
13
23
  getters: {
@@ -20,5 +30,5 @@ const s = a("guidoDynamicContent", {
20
30
  }
21
31
  });
22
32
  export {
23
- s as useDynamicContentStore
33
+ c as useDynamicContentStore
24
34
  };
@@ -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.14.0-beta.1abaa5e",
3
+ "version": "3.14.0-beta.38ec3aa",
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",