@useinsider/guido 3.11.0-beta.f2b79f2 → 3.11.0-beta.f398c54

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,13 +1,6 @@
1
1
  import type { DynamicContent, MergeTag } from '@@/Types/generic';
2
2
  export declare const mergeTagToDynamicContent: (mergeTag: MergeTag) => DynamicContent;
3
3
  export declare const dynamicContentToMergeTags: (dynamicContentList: DynamicContent[], liquidSyntax?: boolean) => MergeTag[];
4
- /**
5
- * Builds the editor merge-tag entries from the template's preselected list plus
6
- * the account's full available list, deduped by token value (preselected wins so
7
- * its fallback/format is kept). Registering the full list lets every recognized
8
- * token — including ones repaired on module drop — render as a chip.
9
- */
10
- export declare const buildMergeTagEntries: (preselected: DynamicContent[], available: DynamicContent[], liquidSyntax?: boolean) => MergeTag[];
11
4
  export declare const getCsrfToken: () => string;
12
5
  /**
13
6
  * URL Parameter utilities
@@ -1,54 +1,47 @@
1
- const u = (t) => {
2
- const a = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((l) => l.trim()), [n] = a, e = {
3
- text: t.label,
1
+ const s = (e) => {
2
+ const a = e.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((l) => l.trim()), [n] = a, c = {
3
+ text: e.label,
4
4
  value: n || ""
5
5
  };
6
6
  if (a.length >= 2) {
7
- const [, l, f] = a;
7
+ const [, l, r] = a;
8
8
  if (l.startsWith("default:")) {
9
- let r = l.slice(8).trim();
10
- r.startsWith('"') && r.endsWith('"') && (r = r.slice(1, -1)), e.fallback = r;
9
+ let t = l.slice(8).trim();
10
+ t.startsWith('"') && t.endsWith('"') && (t = t.slice(1, -1)), c.fallback = t;
11
11
  } else {
12
- const r = l.includes("=") ? { key: l.split("=")[0].trim(), value: l.split("=")[1].trim() } : null;
13
- r ? e.format = r : f || (e.fallback = l), f && (e.fallback = f);
12
+ const t = l.includes("=") ? { key: l.split("=")[0].trim(), value: l.split("=")[1].trim() } : null;
13
+ t ? c.format = t : r || (c.fallback = l), r && (c.fallback = r);
14
14
  }
15
15
  }
16
- return e;
17
- }, s = (t, c = !1) => t.map((a) => {
16
+ return c;
17
+ }, u = (e, f = !1) => e.map((a) => {
18
18
  if (a.format)
19
19
  return {
20
20
  label: `${a.text} | ${a.format.key}=${a.format.value}`,
21
21
  value: `{{${a.value}|${a.format.key}=${a.format.value}}}`
22
22
  };
23
- if (c) {
23
+ if (f) {
24
24
  if (!a.fallback)
25
25
  return {
26
26
  label: a.text,
27
27
  value: `{{ ${a.value} }}`
28
28
  };
29
- const e = !Number.isNaN(Number(a.fallback)) && a.fallback.trim() !== "" ? a.fallback : `"${a.fallback}"`;
29
+ const c = !Number.isNaN(Number(a.fallback)) && a.fallback.trim() !== "" ? a.fallback : `"${a.fallback}"`;
30
30
  return {
31
31
  label: `${a.text} | ${a.fallback}`,
32
- value: `{{ ${a.value} | default: ${e} }}`
32
+ value: `{{ ${a.value} | default: ${c} }}`
33
33
  };
34
34
  }
35
35
  return {
36
36
  label: a.fallback ? `${a.text} | ${a.fallback}` : a.text,
37
37
  value: a.fallback ? `{{${a.value}|${a.fallback}}}` : `{{${a.value}}}`
38
38
  };
39
- }), o = (t, c, a = !1) => {
40
- const n = new Set(t.map((l) => l.value)), e = c.filter((l) => n.has(l.value) ? !1 : (n.add(l.value), !0));
41
- return [
42
- ...s(t, a),
43
- ...s(e, a)
44
- ];
45
- }, b = () => {
46
- var t;
47
- return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
39
+ }), o = () => {
40
+ var e;
41
+ return ((e = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : e.getAttribute("content")) ?? "";
48
42
  };
49
43
  export {
50
- o as buildMergeTagEntries,
51
- s as dynamicContentToMergeTags,
52
- b as getCsrfToken,
53
- u as mergeTagToDynamicContent
44
+ u as dynamicContentToMergeTags,
45
+ o as getCsrfToken,
46
+ s as mergeTagToDynamicContent
54
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.11.0-beta.f2b79f2",
3
+ "version": "3.11.0-beta.f398c54",
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",
@@ -34,8 +34,6 @@
34
34
  "test:visual-update": "npx playwright test --update-snapshots --reporter html",
35
35
  "test:e2e:coverage": "E2E_COVERAGE=true playwright test",
36
36
  "coverage:e2e:report": "nyc report --reporter=lcov --reporter=text-summary --report-dir=coverage/e2e",
37
- "test:mutation": "stryker run",
38
- "test:mutation:since": "CHANGED=$(git diff --name-only --diff-filter=AMR origin/develop...HEAD -- 'src/**/*.ts' ':(glob)src/components/organisms/onboarding/**/*.vue' ':(glob)src/components/organisms/header/**/*.vue' ':(glob)src/components/organisms/unsubscribe/**/*.vue' ':(glob)src/components/organisms/save-as-template/**/*.vue' ':(glob)src/components/organisms/email-preview/**/*.vue' ':(glob)src/components/wrappers/**/*.vue' 'src/components/Guido.vue' ':(exclude)src/**/*.test.ts' ':(exclude)src/**/index.ts' ':(exclude)src/@types/**' ':(exclude)src/enums/**' ':(exclude)src/mock/**' ':(exclude)src/**/_Boilerplate/**' | paste -sd, -); if [ -n \"$CHANGED\" ]; then stryker run --incremental --mutate \"$CHANGED\"; else echo \"No changed mutatable src files vs origin/develop\"; fi",
39
37
  "prepare": "husky",
40
38
  "preinstall": "rm -rf ./node_modules/.vite"
41
39
  },
@@ -59,8 +57,6 @@
59
57
  "@eslint/eslintrc": "3.3.0",
60
58
  "@eslint/js": "8.57.1",
61
59
  "@playwright/test": "1.57.0",
62
- "@stryker-mutator/core": "9.6.1",
63
- "@stryker-mutator/vitest-runner": "9.6.1",
64
60
  "@stylistic/eslint-plugin": "3.1.0",
65
61
  "@stylistic/eslint-plugin-migrate": "3.1.0",
66
62
  "@types/eslint": "8.56.12",
@@ -87,7 +83,7 @@
87
83
  "msw": "2.10.3",
88
84
  "nyc": "17.1.0",
89
85
  "sass": "1.69.7",
90
- "typescript": "5.5.4",
86
+ "typescript": "5.5.3",
91
87
  "typescript-eslint": "8.26.0",
92
88
  "vite-plugin-dts": "4.5.4",
93
89
  "vite-plugin-istanbul": "7.0.0",
@@ -1,36 +0,0 @@
1
- import { useConfig as D } from "./useConfig.js";
2
- import { useToaster as T } from "./useToaster.js";
3
- import { useTranslations as g } from "./useTranslations.js";
4
- import { ToasterTypeOptions as C } from "../enums/toaster.js";
5
- import { buildDynamicContentLookup as h, convertModuleDynamicContent as O } from "../utils/dynamicContentConverter.js";
6
- const M = "dynamic-content.unresolved-attributes-on-drop", A = () => {
7
- const { template: i, isFeatureEnabled: p } = D(), { showToaster: a } = T(), m = g();
8
- return { handleModuleAdd: (n, e) => {
9
- var s, c, l;
10
- try {
11
- if ((n == null ? void 0 : n.action) !== "ADD" && (n == null ? void 0 : n.action) !== "COPY")
12
- return;
13
- const o = h(((s = i.value) == null ? void 0 : s.availableDynamicContent) ?? []);
14
- if (o.size === 0)
15
- return;
16
- const t = (c = e == null ? void 0 : e.getTargetNode) == null ? void 0 : c.call(e), r = (l = t == null ? void 0 : t.getOuterHTML) == null ? void 0 : l.call(t);
17
- if (!t || typeof r != "string")
18
- return;
19
- const { html: u, unresolved: y } = O(
20
- r,
21
- o,
22
- p("liquidSyntax")
23
- );
24
- u !== r && e.modifyHtml(t).replaceWith(u), y.length > 0 && a({
25
- type: C.Warning,
26
- message: m(M)
27
- });
28
- } catch (o) {
29
- console.error("Failed to repair dynamic content on module add:", o);
30
- }
31
- } };
32
- };
33
- export {
34
- M as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
35
- A as useModuleDynamicContentRepair
36
- };
@@ -1,18 +0,0 @@
1
- import type { ModuleAddData, ModuleModifier } from '@@/Types/stripo';
2
- /**
3
- * Host-registered translation key for the "some attributes could not be
4
- * converted" toaster. Guido resolves it against the host's `window.trans.en`;
5
- * the copy is registered host-side.
6
- */
7
- export declare const UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY = "dynamic-content.unresolved-attributes-on-drop";
8
- /**
9
- * Repairs label-form dynamic-content tokens in saved modules as they are dropped
10
- * or copied into the editor. Saved modules serialize merge-tag chips by their
11
- * display label (`{{ Phone Number }}`); this maps them back to their canonical
12
- * token (`{{phone_number}}`) using the account's dynamic-content list.
13
- *
14
- * Wired into Stripo via the `onModuleAdd` init callback (see `useStripo`).
15
- */
16
- export declare const useModuleDynamicContentRepair: () => {
17
- handleModuleAdd: (data: ModuleAddData, modifier: ModuleModifier) => void;
18
- };
@@ -1,27 +0,0 @@
1
- import type { DynamicContent } from '@@/Types/generic';
2
- export interface DynamicContentConversionResult {
3
- html: string;
4
- /** Distinct tokens that matched neither a known value nor a known label (reported to the user). */
5
- unresolved: string[];
6
- }
7
- /**
8
- * Builds a label→item lookup from one or more dynamic-content lists, keyed by
9
- * normalized label (trimmed, lowercased). When lists overlap, a later list wins
10
- * for a shared key.
11
- */
12
- export declare const buildDynamicContentLookup: (...lists: DynamicContent[][]) => Map<string, DynamicContent>;
13
- /**
14
- * Repairs dynamic-content tokens in a dropped module's HTML, using `lookup`
15
- * (label→item) built from the account's full dynamic-content list. Returns the
16
- * rewritten HTML plus the tokens it could not resolve.
17
- *
18
- * A token is rewritten to its canonical `{{value}}` form when its name matches a
19
- * display label (`{{ Phone Number }}` → `{{phone_number}}`). Left untouched: an
20
- * exact canonical value (already correct — this also stops a valid token being
21
- * rewritten just because it coincides with an unrelated label), Liquid nested
22
- * tokens (dotted, e.g. `coupon.code`), recommendation-block variables
23
- * (`123_0_attr`), allowed system tokens, and `data-*` product tags. The account
24
- * list is exhaustive, so any remaining token matching neither a value nor a label
25
- * is reported in `unresolved`; the text itself is always left in place.
26
- */
27
- export declare const convertModuleDynamicContent: (html: string, lookup: Map<string, DynamicContent>, liquidSyntax: boolean) => DynamicContentConversionResult;
@@ -1,31 +0,0 @@
1
- import { DATA_ATTRIBUTE_REGEX as A, DYNAMIC_CONTENT_TAG_REGEX as m, ALLOWED_DYNAMIC_SYSTEM_TOKENS as D } from "../enums/html-validator.js";
2
- import { dynamicContentToMergeTags as T } from "./genericUtil.js";
3
- const p = "guidoDataMask", M = "EndDataMask", f = /guidoDataMask(\d+)EndDataMask/g, h = /^\d+_\d+_.+$/, E = (o) => o.trim().toLowerCase(), I = (...o) => {
4
- const r = /* @__PURE__ */ new Map();
5
- return o.forEach((i) => {
6
- i.forEach((s) => {
7
- const a = E(s.text);
8
- a && r.set(a, s);
9
- });
10
- }), r;
11
- }, w = (o, r, i) => {
12
- const s = /* @__PURE__ */ new Set(), a = new Set([...r.values()].map((e) => e.value)), u = [];
13
- return { html: o.replace(A, (e) => (u.push(e), `${p}${u.length - 1}${M}`)).replace(m, (e) => {
14
- const n = e.slice(2, -2), c = n.indexOf("|"), l = c === -1 ? n : n.slice(0, c), t = l.trim();
15
- if (t === "" || D.includes(t) || t.includes(".") || h.test(t) || a.has(t))
16
- return e;
17
- const d = r.get(E(t));
18
- if (d) {
19
- if (c !== -1) {
20
- const _ = n.slice(c);
21
- return `{{${l.replace(t, () => d.value)}${_}}}`;
22
- }
23
- return T([d], i)[0].value;
24
- }
25
- return s.add(t), e;
26
- }).replace(f, (e, n) => u[Number(n)]), unresolved: [...s] };
27
- };
28
- export {
29
- I as buildDynamicContentLookup,
30
- w as convertModuleDynamicContent
31
- };