@charisol/plexo-sdk 2.0.4 → 2.0.6

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@charisol/plexo-sdk",
3
3
  "private": false,
4
- "version": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "description": "Plexo visual email and landing page builder SDK — drag-and-drop template editor with AI integration.",
6
6
  "keywords": [
7
7
  "email-builder",
@@ -1,225 +0,0 @@
1
- import { i as e } from "./colorUtils-ohNG3v1i.js";
2
- //#region src/v2/design/tokens.ts
3
- function t(e) {
4
- let t = String(e.value), n = e.unit && e.unit !== "null" ? e.unit : "";
5
- return !n || t.endsWith(n) || t.includes("var(") || t.includes("calc(") ? t : `${t}${n}`;
6
- }
7
- var n = (e) => `var(${e})`;
8
- function r(e) {
9
- let t = /^\s*var\(\s*(--[A-Za-z0-9_-]+)\s*(?:,.*)?\)\s*$/.exec(e);
10
- return t ? t[1] : null;
11
- }
12
- function i(e) {
13
- return new Map(e.tokens.map((e) => [e.key, e]));
14
- }
15
- function a(e, t) {
16
- return e.tokens.find((e) => e.key === t);
17
- }
18
- function o(e, t) {
19
- return a(e, t)?.value;
20
- }
21
- var s = (e) => /^#[0-9a-f]{3,8}$/i.test(e) || /^(rgb|hsl)a?\(/i.test(e) ? "color" : /^-?\d*\.?\d+(px|rem|em|%)$/.test(e) ? "dimension" : /^-?\d*\.?\d+$/.test(e) ? "number" : "string", c = (e) => e.replace(/^--/, "").split("-").filter(Boolean).map((e) => e[0].toUpperCase() + e.slice(1)).join(" ");
22
- function l(e, t, n, r = {}) {
23
- let i = a(e, t);
24
- if (i) return i.value === n && (r.unit === void 0 || r.unit === i.unit) ? e : {
25
- ...e,
26
- tokens: e.tokens.map((e) => e.key === t ? {
27
- ...e,
28
- value: n,
29
- ...r.unit === void 0 ? {} : { unit: r.unit }
30
- } : e)
31
- };
32
- let o = r.layer ?? "brand", l = {
33
- key: t,
34
- name: r.name ?? c(t),
35
- value: n,
36
- type: r.type ?? s(n),
37
- unit: r.unit ?? null,
38
- layer: o,
39
- comment: r.comment ?? null
40
- };
41
- return {
42
- ...e,
43
- tokens: [...e.tokens, l]
44
- };
45
- }
46
- function u(e, t) {
47
- let n = e;
48
- for (let [e, r] of Object.entries(t)) n = l(n, e, r);
49
- return n;
50
- }
51
- function d(e, t) {
52
- return e.tokens.some((e) => e.key === t) ? {
53
- ...e,
54
- tokens: e.tokens.filter((e) => e.key !== t)
55
- } : e;
56
- }
57
- function f(e, n, a = 0) {
58
- let o = e instanceof Map ? e : i(e), s = r(n);
59
- if (!s || a > 12) return n;
60
- let c = o.get(s);
61
- if (!c) {
62
- let e = /^\s*var\(\s*--[A-Za-z0-9_-]+\s*,\s*(.*)\)\s*$/.exec(n)?.[1];
63
- return e ? f(o, e.trim(), a + 1) : n;
64
- }
65
- return f(o, t(c), a + 1);
66
- }
67
- function p(e, n) {
68
- let r = a(e, n);
69
- return r ? f(e, t(r)) : void 0;
70
- }
71
- //#endregion
72
- //#region src/v2/design/lint.ts
73
- var m = { "--color-border-muted": "--color-border-subtle" }, h = /var\(\s*(--[A-Za-z0-9_-]+)/g, g = (e) => [...e.matchAll(h)].map((e) => e[1]);
74
- function* _(e) {
75
- for (let t of e ?? []) {
76
- for (let e of Object.values(t.properties ?? {})) yield String(e.value);
77
- for (let e of Object.values(t.variants ?? {})) for (let t of Object.values(e.properties ?? {})) yield String(t.value);
78
- yield* _(t.children);
79
- }
80
- }
81
- function v(t) {
82
- let n = [], i = /* @__PURE__ */ new Map();
83
- for (let e of t.tokens) i.set(e.key, (i.get(e.key) ?? 0) + 1);
84
- for (let r of t.tokens) {
85
- /^--[A-Za-z0-9_-]+$/.test(r.key) || n.push({
86
- kind: "bad-key",
87
- key: r.key,
88
- message: `"${r.key}" isn't a valid CSS variable name (it should look like --color-brand-primary).`,
89
- fixable: !1
90
- }), (i.get(r.key) ?? 0) > 1 && t.tokens.findIndex((e) => e.key === r.key) === t.tokens.indexOf(r) && n.push({
91
- kind: "duplicate-key",
92
- key: r.key,
93
- message: `${r.key} is defined more than once; only one value can win.`,
94
- fixable: !0
95
- });
96
- let a = String(r.value), o = g(a);
97
- o.length && r.unit && r.unit !== "null" && n.push({
98
- kind: "unit-on-reference",
99
- key: r.key,
100
- message: `${r.key} points at another token but also has the unit "${r.unit}", which produces invalid CSS ("${a}${r.unit}").`,
101
- fixable: !0
102
- }), r.layer === "brand" && o.length && n.push({
103
- kind: "brand-references-token",
104
- key: r.key,
105
- message: `${r.key} is a brand token, so it should hold a real value, not point at ${o[0]}.`,
106
- fixable: !0
107
- });
108
- for (let e of o) !i.has(e) && !e.startsWith("--plx-") && n.push({
109
- kind: "dangling-reference",
110
- key: r.key,
111
- message: `${r.key} points at ${e}, which doesn't exist, so it has no value.`,
112
- fixable: !0
113
- });
114
- r.type === "color" && !o.length && !e(a) && !/^(currentcolor|inherit|transparent|none)$/i.test(a) && n.push({
115
- kind: "invalid-color",
116
- key: r.key,
117
- message: `${r.key} is marked as a colour but "${a}" isn't one.`,
118
- fixable: !1
119
- });
120
- }
121
- let a = new Map(t.tokens.map((e) => [e.key, e])), o = /* @__PURE__ */ new Set();
122
- for (let e of t.tokens) {
123
- let t = /* @__PURE__ */ new Set(), i = e.key;
124
- for (; i && !t.has(i);) {
125
- t.add(i);
126
- let e = r(String(a.get(i)?.value ?? ""));
127
- i = e && a.has(e) ? e : void 0;
128
- }
129
- i && !o.has(i) && (o.add(i), n.push({
130
- kind: "circular-reference",
131
- key: i,
132
- message: `${i} ends up pointing back at itself, so it can never resolve.`,
133
- fixable: !1
134
- }));
135
- }
136
- let s = /* @__PURE__ */ new Set();
137
- for (let e of t.components) for (let t of _(e.nodes)) for (let r of g(t)) !i.has(r) && !s.has(`${e.name}:${r}`) && (s.add(`${e.name}:${r}`), n.push({
138
- kind: "dangling-reference",
139
- key: e.name,
140
- message: `The ${e.name} component uses ${r}, which doesn't exist.`,
141
- fixable: r in m
142
- }));
143
- return n;
144
- }
145
- function y(e, t, n = 0) {
146
- return n > 12 ? e : e.replace(/var\(\s*(--[A-Za-z0-9_-]+)\s*(?:,[^)]*)?\)/g, (e, r) => {
147
- let i = t.get(r);
148
- if (!i) return e;
149
- let a = i.unit && i.unit !== "null" ? i.unit : "", o = String(i.value);
150
- return y(!a || o.endsWith(a) || o.includes("var(") || o.includes("calc(") ? o : `${o}${a}`, t, n + 1);
151
- });
152
- }
153
- var b = (e) => e.replace(/var\(\s*(--[A-Za-z0-9_-]+)/g, (e, t) => m[t] ? e.replace(t, m[t]) : e);
154
- function x(e) {
155
- let t = !1, n = (e) => {
156
- if (!e) return e;
157
- let n = {};
158
- for (let [r, i] of Object.entries(e)) {
159
- let e = b(String(i.value));
160
- e !== i.value && (t = !0), n[r] = e === i.value ? i : {
161
- ...i,
162
- value: e
163
- };
164
- }
165
- return n;
166
- }, r = (e) => {
167
- if (!e) return e;
168
- let n = {};
169
- for (let [r, i] of Object.entries(e)) {
170
- let e = b(String(i));
171
- e !== i && (t = !0), n[r] = e;
172
- }
173
- return n;
174
- }, i = (e) => {
175
- let t = { ...e };
176
- return e.properties && (t.properties = n(e.properties)), e.styles && (t.styles = r(e.styles)), e.variants && (t.variants = Object.fromEntries(Object.entries(e.variants).map(([e, t]) => [e, t.properties ? {
177
- ...t,
178
- properties: n(t.properties)
179
- } : t]))), e.children && (t.children = e.children.map(i)), t;
180
- }, a = e?.map(i);
181
- return {
182
- nodes: t ? a : e,
183
- changed: t
184
- };
185
- }
186
- function S(e) {
187
- let t = !1, n = /* @__PURE__ */ new Set(), r = e.tokens.filter((e) => n.has(e.key) ? (t = !0, !1) : (n.add(e.key), !0)).map((e) => g(String(e.value)).length && e.unit && e.unit !== "null" ? (t = !0, {
188
- ...e,
189
- unit: null
190
- }) : e), i = new Map(r.map((e) => [e.key, e]));
191
- r = r.map((e) => {
192
- if (e.layer === "brand" && g(String(e.value)).length) {
193
- let n = y(String(e.value), i);
194
- if (n !== e.value && !g(n).length) return t = !0, {
195
- ...e,
196
- value: n
197
- };
198
- }
199
- return e;
200
- });
201
- let a = new Set(r.map((e) => e.key)), o = r.find((e) => e.key === "--font-family-sans");
202
- for (let e of [...r]) for (let n of g(String(e.value))) a.has(n) || (n === "--font-family-heading" || n === "--font-family-body") && o && (a.add(n), t = !0, r = [...r, {
203
- key: n,
204
- name: n === "--font-family-heading" ? "Font Family Heading" : "Font Family Body",
205
- value: o.value,
206
- type: "font family",
207
- unit: null,
208
- layer: "brand",
209
- comment: n === "--font-family-heading" ? "Heading font" : "Body font"
210
- }]);
211
- let s = e.components, c = e.components.map((e) => {
212
- let t = x(e.nodes);
213
- return t.changed ? {
214
- ...e,
215
- nodes: t.nodes ?? e.nodes
216
- } : e;
217
- });
218
- return c.some((t, n) => t !== e.components[n]) && (s = c, t = !0), t ? {
219
- ...e,
220
- tokens: r,
221
- components: s
222
- } : e;
223
- }
224
- //#endregion
225
- export { c as a, d as c, l as d, u as f, o as i, p as l, i as m, S as n, n as o, t as p, a as r, r as s, v as t, f as u };