@greensight/gts 1.0.0-alpha.9 → 1.0.0-beta.2
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/README.md +55 -28
- package/classes/TokenManager/index.d.ts +19 -4
- package/classes/TokenManager/index.d.ts.map +1 -1
- package/classes/TokenManager/types/ds.d.ts +23 -12
- package/classes/TokenManager/types/ds.d.ts.map +1 -1
- package/classes/TokenManager/types/figma.d.ts +11 -3
- package/classes/TokenManager/types/figma.d.ts.map +1 -1
- package/commands/generate/index.d.ts.map +1 -1
- package/common/lodash.d.ts +8 -0
- package/common/lodash.d.ts.map +1 -0
- package/index.cjs +96 -5
- package/index.mjs +1039 -493
- package/modules/breakpoints/breakpointsFromTokenManager/index.d.ts +2 -0
- package/modules/breakpoints/breakpointsFromTokenManager/index.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsFromTokenManager/module.d.ts +13 -0
- package/modules/breakpoints/breakpointsFromTokenManager/module.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsFromTokenManager/utils.d.ts +8 -0
- package/modules/breakpoints/breakpointsFromTokenManager/utils.d.ts.map +1 -0
- package/modules/breakpoints/index.d.ts +3 -0
- package/modules/breakpoints/index.d.ts.map +1 -0
- package/modules/breakpoints/types.d.ts +6 -0
- package/modules/breakpoints/types.d.ts.map +1 -0
- package/modules/breakpoints/utils.d.ts +16 -0
- package/modules/breakpoints/utils.d.ts.map +1 -0
- package/modules/colors/colorsFromTokenManager/index.d.ts +2 -0
- package/modules/colors/colorsFromTokenManager/index.d.ts.map +1 -0
- package/modules/colors/{colorsFromTokenManager.d.ts → colorsFromTokenManager/module.d.ts} +4 -7
- package/modules/colors/colorsFromTokenManager/module.d.ts.map +1 -0
- package/modules/colors/colorsFromTokenManager/utils.d.ts +3 -0
- package/modules/colors/colorsFromTokenManager/utils.d.ts.map +1 -0
- package/modules/colors/index.d.ts +0 -2
- package/modules/colors/index.d.ts.map +1 -1
- package/modules/colors/utils.d.ts +8 -33
- package/modules/colors/utils.d.ts.map +1 -1
- package/modules/container/containerFromTokenManager/index.d.ts +2 -0
- package/modules/container/containerFromTokenManager/index.d.ts.map +1 -0
- package/modules/container/containerFromTokenManager/module.d.ts +13 -0
- package/modules/container/containerFromTokenManager/module.d.ts.map +1 -0
- package/modules/container/index.d.ts +3 -0
- package/modules/container/index.d.ts.map +1 -0
- package/modules/container/types.d.ts +5 -0
- package/modules/container/types.d.ts.map +1 -0
- package/modules/container/utils.d.ts +12 -0
- package/modules/container/utils.d.ts.map +1 -0
- package/modules/index.d.ts +5 -0
- package/modules/index.d.ts.map +1 -1
- package/modules/shadows/index.d.ts +3 -0
- package/modules/shadows/index.d.ts.map +1 -0
- package/modules/shadows/shadowsFromTokenManager.d.ts +13 -0
- package/modules/shadows/shadowsFromTokenManager.d.ts.map +1 -0
- package/modules/shadows/types.d.ts +6 -0
- package/modules/shadows/types.d.ts.map +1 -0
- package/modules/shadows/utils.d.ts +22 -0
- package/modules/shadows/utils.d.ts.map +1 -0
- package/modules/typography/index.d.ts +2 -0
- package/modules/typography/index.d.ts.map +1 -0
- package/modules/typography/types.d.ts +10 -0
- package/modules/typography/types.d.ts.map +1 -0
- package/modules/typography/typographyFromTokenManager/index.d.ts +2 -0
- package/modules/typography/typographyFromTokenManager/index.d.ts.map +1 -0
- package/modules/typography/typographyFromTokenManager/module.d.ts +19 -0
- package/modules/typography/typographyFromTokenManager/module.d.ts.map +1 -0
- package/modules/typography/utils.d.ts +56 -0
- package/modules/typography/utils.d.ts.map +1 -0
- package/modules/utilities/index.d.ts +4 -0
- package/modules/utilities/index.d.ts.map +1 -0
- package/modules/utilities/types.d.ts +48 -0
- package/modules/utilities/types.d.ts.map +1 -0
- package/modules/utilities/utilitiesFromTokenManager/index.d.ts +2 -0
- package/modules/utilities/utilitiesFromTokenManager/index.d.ts.map +1 -0
- package/modules/utilities/utilitiesFromTokenManager/module.d.ts +4 -0
- package/modules/utilities/utilitiesFromTokenManager/module.d.ts.map +1 -0
- package/modules/utilities/utils.d.ts +80 -0
- package/modules/utilities/utils.d.ts.map +1 -0
- package/package.json +1 -2
- package/temporarilyUnnecessary/colorsFromStyles.d.ts +1 -0
- package/temporarilyUnnecessary/colorsFromStyles.d.ts.map +1 -0
- package/temporarilyUnnecessary/colorsFromVariables.d.ts +1 -0
- package/temporarilyUnnecessary/colorsFromVariables.d.ts.map +1 -0
- package/temporarilyUnnecessary/utils.d.ts +1 -0
- package/temporarilyUnnecessary/utils.d.ts.map +1 -0
- package/modules/colors/colorsFromStyles.d.ts +0 -16
- package/modules/colors/colorsFromStyles.d.ts.map +0 -1
- package/modules/colors/colorsFromTokenManager.d.ts.map +0 -1
- package/modules/colors/colorsFromVariables.d.ts +0 -16
- package/modules/colors/colorsFromVariables.d.ts.map +0 -1
package/index.mjs
CHANGED
|
@@ -1,90 +1,89 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import { tsImport as
|
|
6
|
-
import { existsSync as
|
|
7
|
-
import { readFile as
|
|
8
|
-
import { resolve as
|
|
9
|
-
import { merge as se, get as q } from "lodash-es";
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var ue = (t, e, o) => e in t ? ce(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var m = (t, e, o) => ue(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
import k from "path";
|
|
5
|
+
import { tsImport as de } from "ts-import";
|
|
6
|
+
import { existsSync as C } from "node:fs";
|
|
7
|
+
import { readFile as V, mkdir as fe, writeFile as ye, rm as ge } from "node:fs/promises";
|
|
8
|
+
import { resolve as F } from "node:path";
|
|
10
9
|
const h = class h {
|
|
11
10
|
static resolveReadPath(e) {
|
|
12
11
|
if (!e || !e.trim())
|
|
13
12
|
throw new Error("File path must be a non-empty string");
|
|
14
|
-
return
|
|
13
|
+
return F(h.baseDir, e);
|
|
15
14
|
}
|
|
16
|
-
static resolveWritePath(e,
|
|
17
|
-
const
|
|
15
|
+
static resolveWritePath(e, o) {
|
|
16
|
+
const r = F(h.baseDir, o ?? "");
|
|
18
17
|
return {
|
|
19
|
-
targetDir:
|
|
20
|
-
targetPath:
|
|
18
|
+
targetDir: r,
|
|
19
|
+
targetPath: F(r, e)
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
|
-
static handleReadError(e,
|
|
24
|
-
throw e.code === "ENOENT" ? new Error(`File not found: ${
|
|
25
|
-
`Failed to read file "${
|
|
22
|
+
static handleReadError(e, o) {
|
|
23
|
+
throw e.code === "ENOENT" ? new Error(`File not found: ${o}`) : new Error(
|
|
24
|
+
`Failed to read file "${o}": ${e.message ?? String(e)}`
|
|
26
25
|
);
|
|
27
26
|
}
|
|
28
|
-
static async read(e,
|
|
29
|
-
const
|
|
27
|
+
static async read(e, o = "utf8") {
|
|
28
|
+
const r = h.resolveReadPath(e);
|
|
30
29
|
try {
|
|
31
|
-
return await
|
|
32
|
-
} catch (
|
|
33
|
-
h.handleReadError(
|
|
30
|
+
return await V(r, { encoding: o });
|
|
31
|
+
} catch (n) {
|
|
32
|
+
h.handleReadError(n, r);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
static async readBuffer(e) {
|
|
37
|
-
const
|
|
36
|
+
const o = h.resolveReadPath(e);
|
|
38
37
|
try {
|
|
39
|
-
return await
|
|
40
|
-
} catch (
|
|
41
|
-
h.handleReadError(
|
|
38
|
+
return await V(o);
|
|
39
|
+
} catch (r) {
|
|
40
|
+
h.handleReadError(r, o);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
static async readJson(e) {
|
|
45
|
-
const
|
|
44
|
+
const o = h.resolveReadPath(e);
|
|
46
45
|
try {
|
|
47
|
-
const
|
|
46
|
+
const r = await V(o, { encoding: "utf8" });
|
|
48
47
|
try {
|
|
49
|
-
return JSON.parse(
|
|
50
|
-
} catch (
|
|
51
|
-
throw new Error(`Failed to parse JSON from "${
|
|
48
|
+
return JSON.parse(r);
|
|
49
|
+
} catch (n) {
|
|
50
|
+
throw new Error(`Failed to parse JSON from "${o}": ${n.message}`);
|
|
52
51
|
}
|
|
53
|
-
} catch (
|
|
54
|
-
h.handleReadError(
|
|
52
|
+
} catch (r) {
|
|
53
|
+
h.handleReadError(r, o);
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
|
-
static async write(e,
|
|
58
|
-
const { directory:
|
|
59
|
-
if (!
|
|
60
|
-
throw new Error(`File ${
|
|
61
|
-
return await
|
|
56
|
+
static async write(e, o = "", r = {}) {
|
|
57
|
+
const { directory: n, overwrite: s = !0 } = r, { targetDir: a, targetPath: l } = h.resolveWritePath(e, n);
|
|
58
|
+
if (!s && C(l))
|
|
59
|
+
throw new Error(`File ${l} already exists`);
|
|
60
|
+
return await fe(a, { recursive: !0 }), await ye(l, o, { encoding: "utf8" }), l;
|
|
62
61
|
}
|
|
63
|
-
static async writeWithExtension(e,
|
|
64
|
-
const
|
|
65
|
-
return h.write(a,
|
|
62
|
+
static async writeWithExtension(e, o, r = "", n) {
|
|
63
|
+
const s = o.startsWith(".") ? o : `.${o}`, a = `${e}${s}`;
|
|
64
|
+
return h.write(a, r, n);
|
|
66
65
|
}
|
|
67
66
|
static exists(e) {
|
|
68
|
-
const
|
|
69
|
-
return
|
|
67
|
+
const o = h.resolveReadPath(e);
|
|
68
|
+
return C(o);
|
|
70
69
|
}
|
|
71
|
-
static async delete(e,
|
|
72
|
-
const { targetPath:
|
|
73
|
-
|
|
70
|
+
static async delete(e, o) {
|
|
71
|
+
const { targetPath: r } = h.resolveWritePath(e, o);
|
|
72
|
+
C(r) && await ge(r, { recursive: !0, force: !0 });
|
|
74
73
|
}
|
|
75
74
|
};
|
|
76
|
-
|
|
77
|
-
let
|
|
78
|
-
const
|
|
75
|
+
m(h, "baseDir", process.cwd());
|
|
76
|
+
let d = h;
|
|
77
|
+
const $ = class $ {
|
|
79
78
|
static async create() {
|
|
80
|
-
if (
|
|
79
|
+
if (d.exists($.configFileName))
|
|
81
80
|
throw new Error("The file already exists");
|
|
82
|
-
await
|
|
81
|
+
await d.write($.configFileName, "", { overwrite: !1 });
|
|
83
82
|
}
|
|
84
83
|
async load() {
|
|
85
84
|
try {
|
|
86
|
-
const e = await
|
|
87
|
-
`${
|
|
85
|
+
const e = await de.compile(
|
|
86
|
+
`${k.resolve(process.cwd(), $.configFileName)}`
|
|
88
87
|
);
|
|
89
88
|
if (!e) throw new Error();
|
|
90
89
|
return e.default;
|
|
@@ -93,61 +92,61 @@ const v = class v {
|
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
};
|
|
96
|
-
|
|
97
|
-
let
|
|
98
|
-
const
|
|
95
|
+
m($, "configFileName", "gts.config.ts");
|
|
96
|
+
let j = $;
|
|
97
|
+
const pe = (t) => {
|
|
99
98
|
const e = new URLSearchParams();
|
|
100
|
-
return Object.keys(
|
|
101
|
-
Array.isArray(
|
|
99
|
+
return Object.keys(t).forEach((o) => {
|
|
100
|
+
Array.isArray(t[o]) ? t[o].forEach((r) => e.append(`${o}[]`, r)) : e.append(o, t[o]);
|
|
102
101
|
}), e;
|
|
103
|
-
},
|
|
104
|
-
const
|
|
105
|
-
for (let
|
|
106
|
-
|
|
107
|
-
return
|
|
102
|
+
}, he = (t, e = 50) => {
|
|
103
|
+
const o = [];
|
|
104
|
+
for (let r = 0; r < t.length; r += e)
|
|
105
|
+
o.push(t.slice(r, r + e));
|
|
106
|
+
return o;
|
|
108
107
|
};
|
|
109
|
-
class
|
|
110
|
-
constructor(e,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.figmaToken = e, this.fileId =
|
|
108
|
+
class P {
|
|
109
|
+
constructor(e, o) {
|
|
110
|
+
m(this, "figmaToken");
|
|
111
|
+
m(this, "fileId");
|
|
112
|
+
m(this, "onTimeMeasureHandler");
|
|
113
|
+
this.figmaToken = e, this.fileId = o;
|
|
115
114
|
}
|
|
116
115
|
setOnTimeMeasureHandler(e) {
|
|
117
116
|
this.onTimeMeasureHandler = e;
|
|
118
117
|
}
|
|
119
118
|
static async returnJSON(e) {
|
|
120
|
-
const
|
|
119
|
+
const o = await e.json();
|
|
121
120
|
if (!e.ok) {
|
|
122
|
-
let
|
|
123
|
-
throw new Error(
|
|
121
|
+
let r = "Request failed";
|
|
122
|
+
throw new Error(r);
|
|
124
123
|
}
|
|
125
|
-
return
|
|
124
|
+
return o;
|
|
126
125
|
}
|
|
127
|
-
async performControlledRequest(e, { params:
|
|
128
|
-
var
|
|
126
|
+
async performControlledRequest(e, { params: o = {}, timeout: r = 3e4, abortController: n = new AbortController() } = {}) {
|
|
127
|
+
var g;
|
|
129
128
|
if (!this.figmaToken || !this.fileId)
|
|
130
129
|
throw new Error("Добавьте figmaToken и figmaId");
|
|
131
|
-
const
|
|
130
|
+
const s = Object.entries(o).reduce((p, [b, w]) => typeof w < "u" ? { ...p, [b]: w } : p, {}), a = `https://api.figma.com/v1${e}${s && Object.keys(s).length ? `?${pe(s)}` : ""}`;
|
|
132
131
|
console.log("endpoinWithParams=", a);
|
|
133
|
-
const
|
|
132
|
+
const l = setTimeout(() => n.abort(), r), i = {
|
|
134
133
|
"Content-Type": "application/json",
|
|
135
134
|
...this.figmaToken && { "X-Figma-Token": this.figmaToken }
|
|
136
135
|
}, c = {
|
|
137
136
|
method: "GET",
|
|
138
|
-
headers:
|
|
139
|
-
signal:
|
|
140
|
-
},
|
|
141
|
-
clearTimeout(
|
|
142
|
-
const y = performance.now() -
|
|
143
|
-
return (
|
|
144
|
-
}
|
|
145
|
-
async request(e,
|
|
146
|
-
var
|
|
147
|
-
const
|
|
148
|
-
...
|
|
137
|
+
headers: i,
|
|
138
|
+
signal: n.signal
|
|
139
|
+
}, u = performance.now(), f = await fetch(`${a}`, c);
|
|
140
|
+
clearTimeout(l);
|
|
141
|
+
const y = performance.now() - u;
|
|
142
|
+
return (g = this.onTimeMeasureHandler) == null || g.call(this, a, i, y), f;
|
|
143
|
+
}
|
|
144
|
+
async request(e, o) {
|
|
145
|
+
var n;
|
|
146
|
+
const r = await this.performControlledRequest(e, {
|
|
147
|
+
...o
|
|
149
148
|
});
|
|
150
|
-
return (
|
|
149
|
+
return (n = r.headers.get("content-type")) != null && n.includes("application/json") ? P.returnJSON(r) : r;
|
|
151
150
|
}
|
|
152
151
|
async getComponents() {
|
|
153
152
|
return this.request(`/files/${this.fileId}/components`);
|
|
@@ -156,36 +155,88 @@ class V {
|
|
|
156
155
|
return this.request(`/files/${this.fileId}/styles`);
|
|
157
156
|
}
|
|
158
157
|
async getNodes(e) {
|
|
159
|
-
const
|
|
160
|
-
(
|
|
161
|
-
),
|
|
158
|
+
const o = he(e).map(
|
|
159
|
+
(s) => this.request(`/files/${this.fileId}/nodes`, { params: { ids: s.join(",") } })
|
|
160
|
+
), r = await Promise.all(o);
|
|
162
161
|
return {
|
|
163
|
-
...
|
|
164
|
-
nodes:
|
|
162
|
+
...r[0],
|
|
163
|
+
nodes: r.reduce((s, a) => ({ ...s, ...a.nodes }), {})
|
|
165
164
|
};
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
|
-
|
|
167
|
+
const q = (t, e) => {
|
|
168
|
+
const o = Array.isArray(e) ? e : e.split(".");
|
|
169
|
+
let r = t;
|
|
170
|
+
for (const n of o) {
|
|
171
|
+
if (r == null || typeof r != "object") return;
|
|
172
|
+
r = r[n];
|
|
173
|
+
}
|
|
174
|
+
return r;
|
|
175
|
+
}, H = (t, e) => {
|
|
176
|
+
if (!e || typeof e != "object") return t;
|
|
177
|
+
if (!t || typeof t != "object") return e;
|
|
178
|
+
const o = { ...t };
|
|
179
|
+
for (const r in e)
|
|
180
|
+
e.hasOwnProperty(r) && (typeof e[r] == "object" && e[r] !== null && typeof o[r] == "object" && o[r] !== null ? o[r] = H(o[r], e[r]) : o[r] = e[r]);
|
|
181
|
+
return o;
|
|
182
|
+
};
|
|
183
|
+
function x(t, e) {
|
|
184
|
+
if (t === e)
|
|
185
|
+
return !0;
|
|
186
|
+
if (t == null || e == null)
|
|
187
|
+
return t === e;
|
|
188
|
+
if (typeof t != typeof e)
|
|
189
|
+
return !1;
|
|
190
|
+
if (t instanceof Date && e instanceof Date)
|
|
191
|
+
return t.getTime() === e.getTime();
|
|
192
|
+
if (t instanceof RegExp && e instanceof RegExp)
|
|
193
|
+
return t.toString() === e.toString();
|
|
194
|
+
if (Array.isArray(t) && Array.isArray(e)) {
|
|
195
|
+
if (t.length !== e.length)
|
|
196
|
+
return !1;
|
|
197
|
+
for (let o = 0; o < t.length; o++)
|
|
198
|
+
if (!x(t[o], e[o]))
|
|
199
|
+
return !1;
|
|
200
|
+
return !0;
|
|
201
|
+
}
|
|
202
|
+
if (typeof t == "object" && typeof e == "object") {
|
|
203
|
+
const o = Object.keys(t), r = Object.keys(e);
|
|
204
|
+
if (o.length !== r.length)
|
|
205
|
+
return !1;
|
|
206
|
+
for (const n of o)
|
|
207
|
+
if (!r.includes(n) || !x(t[n], e[n]))
|
|
208
|
+
return !1;
|
|
209
|
+
return !0;
|
|
210
|
+
}
|
|
211
|
+
return !1;
|
|
212
|
+
}
|
|
213
|
+
const R = {
|
|
214
|
+
color: {},
|
|
215
|
+
effect: {},
|
|
216
|
+
text: {},
|
|
217
|
+
grid: {}
|
|
218
|
+
};
|
|
219
|
+
class be {
|
|
169
220
|
constructor(e) {
|
|
170
221
|
// files
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
222
|
+
m(this, "tokensDir");
|
|
223
|
+
m(this, "manifestPath");
|
|
224
|
+
// result data
|
|
225
|
+
m(this, "variables");
|
|
226
|
+
m(this, "styles");
|
|
176
227
|
// flags
|
|
177
|
-
|
|
178
|
-
this.tokensDir = e || "", this.manifestPath =
|
|
228
|
+
m(this, "loaded", !1);
|
|
229
|
+
this.tokensDir = e || "", this.manifestPath = k.join(this.tokensDir, "manifest.json");
|
|
179
230
|
}
|
|
180
231
|
isLoaded() {
|
|
181
232
|
return this.loaded && !!this.variables && !!this.styles;
|
|
182
233
|
}
|
|
183
234
|
/** to camelCase */
|
|
184
235
|
normalizeKey(e) {
|
|
185
|
-
const
|
|
186
|
-
return
|
|
187
|
-
const
|
|
188
|
-
return
|
|
236
|
+
const o = e.trim();
|
|
237
|
+
return o && o.replace(/[-_\s]+/g, " ").split(" ").filter((r) => r.length).map((r, n) => {
|
|
238
|
+
const s = r.charAt(0), a = r.slice(1);
|
|
239
|
+
return n === 0 ? r.toLowerCase() : s.toUpperCase() + a;
|
|
189
240
|
}).join("");
|
|
190
241
|
}
|
|
191
242
|
/**
|
|
@@ -193,10 +244,10 @@ class ie {
|
|
|
193
244
|
*/
|
|
194
245
|
parseVariableString(e) {
|
|
195
246
|
if (typeof e != "string") return e;
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
return `{${this.normalizeKey(
|
|
247
|
+
const o = /^\{(.+)\}$/, r = e.match(o);
|
|
248
|
+
if (r) {
|
|
249
|
+
const n = r[1].trim();
|
|
250
|
+
return `{${this.normalizeKey(n)}}`;
|
|
200
251
|
}
|
|
201
252
|
return e;
|
|
202
253
|
}
|
|
@@ -205,59 +256,59 @@ class ie {
|
|
|
205
256
|
*/
|
|
206
257
|
createVariableFileList(e) {
|
|
207
258
|
return Object.entries(e).flatMap(
|
|
208
|
-
([
|
|
209
|
-
([
|
|
259
|
+
([o, r]) => Object.entries(r.modes).flatMap(
|
|
260
|
+
([n, s]) => s.map((a) => ({
|
|
210
261
|
fileName: a,
|
|
211
|
-
modeName: this.normalizeKey(
|
|
212
|
-
collectionName:
|
|
262
|
+
modeName: this.normalizeKey(n.trim()),
|
|
263
|
+
collectionName: o
|
|
213
264
|
}))
|
|
214
265
|
)
|
|
215
266
|
);
|
|
216
267
|
}
|
|
217
268
|
parseValue(e) {
|
|
218
|
-
return e && (typeof e == "string" ? this.parseVariableString(e) : typeof e != "object" ? e :
|
|
219
|
-
}
|
|
220
|
-
getTokensFromFile(e,
|
|
221
|
-
return Object.entries(e).reduce((
|
|
222
|
-
...
|
|
223
|
-
[this.normalizeKey(
|
|
224
|
-
type:
|
|
225
|
-
description:
|
|
226
|
-
value:
|
|
269
|
+
return e && (typeof e == "string" ? this.parseVariableString(e) : typeof e != "object" ? e : Array.isArray(e) ? e.map((o) => this.parseValue(o)) : Object.entries(e).reduce((o, [r, n]) => ({ ...o, [r]: this.parseValue(n) }), {}));
|
|
270
|
+
}
|
|
271
|
+
getTokensFromFile(e, o) {
|
|
272
|
+
return Object.entries(e).reduce((r, [n, s]) => "$type" in s && "$value" in s ? {
|
|
273
|
+
...r,
|
|
274
|
+
[this.normalizeKey(n)]: {
|
|
275
|
+
type: s.$type,
|
|
276
|
+
description: s.$description,
|
|
277
|
+
value: o ? { [this.normalizeKey(o)]: this.parseValue(s.$value) } : this.parseValue(s.$value)
|
|
227
278
|
}
|
|
228
|
-
} : { ...
|
|
279
|
+
} : { ...r, [this.normalizeKey(n)]: this.getTokensFromFile(s, o) }, {});
|
|
229
280
|
}
|
|
230
|
-
processTokensFile(e,
|
|
231
|
-
const
|
|
232
|
-
return { [
|
|
281
|
+
processTokensFile(e, o, r) {
|
|
282
|
+
const n = this.normalizeKey(r), s = this.getTokensFromFile(e, o);
|
|
283
|
+
return { [n]: s };
|
|
233
284
|
}
|
|
234
285
|
/**
|
|
235
286
|
* Loads all variable files in parallel and returns processed results
|
|
236
287
|
*/
|
|
237
288
|
async loadVariableFiles(e) {
|
|
238
289
|
return Promise.all(
|
|
239
|
-
e.map(async ({ fileName:
|
|
290
|
+
e.map(async ({ fileName: o, modeName: r, collectionName: n }) => {
|
|
240
291
|
try {
|
|
241
|
-
const
|
|
242
|
-
return this.processTokensFile(a,
|
|
243
|
-
} catch (
|
|
244
|
-
return console.warn(`Failed to load variable file: ${
|
|
292
|
+
const s = k.join(this.tokensDir, o), a = await d.readJson(s);
|
|
293
|
+
return this.processTokensFile(a, r, n);
|
|
294
|
+
} catch (s) {
|
|
295
|
+
return console.warn(`Failed to load variable file: ${k.join(this.tokensDir, o)}`, s), {};
|
|
245
296
|
}
|
|
246
297
|
})
|
|
247
298
|
);
|
|
248
299
|
}
|
|
249
300
|
mergeVariables(e) {
|
|
250
|
-
return e.reduce((
|
|
301
|
+
return e.reduce((o, r) => H(o, r), {});
|
|
251
302
|
}
|
|
252
303
|
/**
|
|
253
304
|
* Loads and processes all token variables from manifest collections
|
|
254
305
|
*/
|
|
255
306
|
async loadTokenVariables(e) {
|
|
256
307
|
try {
|
|
257
|
-
const
|
|
258
|
-
return this.mergeVariables(
|
|
259
|
-
} catch (
|
|
260
|
-
throw new Error(`Failed to load token variables from ${this.tokensDir}: ${
|
|
308
|
+
const o = this.createVariableFileList(e), r = await this.loadVariableFiles(o);
|
|
309
|
+
return this.mergeVariables(r);
|
|
310
|
+
} catch (o) {
|
|
311
|
+
throw new Error(`Failed to load token variables from ${this.tokensDir}: ${o}`);
|
|
261
312
|
}
|
|
262
313
|
}
|
|
263
314
|
/**
|
|
@@ -265,9 +316,9 @@ class ie {
|
|
|
265
316
|
*/
|
|
266
317
|
createStyleFileList(e) {
|
|
267
318
|
return Object.entries(e).flatMap(
|
|
268
|
-
([
|
|
269
|
-
styleType:
|
|
270
|
-
fileName:
|
|
319
|
+
([o, r]) => (r == null ? void 0 : r.map((n) => ({
|
|
320
|
+
styleType: o,
|
|
321
|
+
fileName: n
|
|
271
322
|
}))) || []
|
|
272
323
|
);
|
|
273
324
|
}
|
|
@@ -276,30 +327,32 @@ class ie {
|
|
|
276
327
|
*/
|
|
277
328
|
async loadStyleFiles(e) {
|
|
278
329
|
return (await Promise.all(
|
|
279
|
-
e.map(async ({ styleType:
|
|
330
|
+
e.map(async ({ styleType: r, fileName: n }) => {
|
|
280
331
|
try {
|
|
281
|
-
const
|
|
282
|
-
return { styleType:
|
|
283
|
-
} catch (
|
|
284
|
-
return console.warn(`Failed to load style file: ${
|
|
332
|
+
const s = k.join(this.tokensDir, n), a = await d.readJson(s);
|
|
333
|
+
return { styleType: r, styleTokens: a };
|
|
334
|
+
} catch (s) {
|
|
335
|
+
return console.warn(`Failed to load style file: ${k.join(this.tokensDir, n)}`, s), { styleType: r, styleTokens: {} };
|
|
285
336
|
}
|
|
286
337
|
})
|
|
287
338
|
)).reduce(
|
|
288
|
-
(
|
|
289
|
-
{
|
|
339
|
+
(r, n) => ({ ...r, [n.styleType]: this.getTokensFromFile(n.styleTokens, "") }),
|
|
340
|
+
{
|
|
341
|
+
...R
|
|
342
|
+
}
|
|
290
343
|
);
|
|
291
344
|
}
|
|
292
345
|
/**
|
|
293
346
|
* Loads and processes all style tokens from manifest
|
|
294
347
|
*/
|
|
295
348
|
async loadStyles(e) {
|
|
296
|
-
if (!e) return {};
|
|
297
|
-
const
|
|
298
|
-
return await this.loadStyleFiles(
|
|
349
|
+
if (!e) return { ...R };
|
|
350
|
+
const o = this.createStyleFileList(e);
|
|
351
|
+
return await this.loadStyleFiles(o);
|
|
299
352
|
}
|
|
300
353
|
async load() {
|
|
301
354
|
if (this.loaded) return;
|
|
302
|
-
const e = await
|
|
355
|
+
const e = await d.readJson(this.manifestPath);
|
|
303
356
|
if (!e)
|
|
304
357
|
throw new Error(`Failed to load manifest file from: ${this.manifestPath}`);
|
|
305
358
|
this.variables = await this.loadTokenVariables(e.collections), this.styles = await this.loadStyles(e.styles), this.loaded = !0;
|
|
@@ -336,397 +389,890 @@ class ie {
|
|
|
336
389
|
getVariablePath(e) {
|
|
337
390
|
return e.slice(1, -1);
|
|
338
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Resolves a variable reference by validating, parsing and getting the token
|
|
394
|
+
* @param value - Value to resolve (should be a variable reference like "{variable.path}")
|
|
395
|
+
* @param mode - Mode name to get value for (optional)
|
|
396
|
+
* @returns resolved token variable or undefined if not found or invalid
|
|
397
|
+
*/
|
|
398
|
+
resolveVariableValue(e) {
|
|
399
|
+
if (typeof e == "object")
|
|
400
|
+
return Object.keys(e).reduce((o, r) => {
|
|
401
|
+
const n = e[r], s = this.resolveVariableValueString(n, r);
|
|
402
|
+
return s && (o[r] = s), o;
|
|
403
|
+
}, {});
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Resolves a variable reference by validating, parsing and getting the token
|
|
407
|
+
* @param value - Value to resolve (should be a variable reference like "{variable.path}")
|
|
408
|
+
* @param mode - Mode name to get value for (optional)
|
|
409
|
+
* @returns resolved token variable or undefined if not found or invalid
|
|
410
|
+
*/
|
|
411
|
+
resolveVariableValueString(e, o) {
|
|
412
|
+
if (!this.isVariableReference(e)) return e;
|
|
413
|
+
const r = this.getVariablePath(e), n = this.getToken(r, o);
|
|
414
|
+
if (n)
|
|
415
|
+
return this.resolveVariableValueString(n, o);
|
|
416
|
+
}
|
|
339
417
|
/**
|
|
340
418
|
* Gets a nested token value by path, similar to lodash.get
|
|
341
419
|
* @param variablePath - Dot-separated string path or array of path segments
|
|
420
|
+
* @param mode - Mode name to get value for (optional)
|
|
342
421
|
*/
|
|
343
|
-
getToken(e) {
|
|
422
|
+
getToken(e, o) {
|
|
344
423
|
if (!this.loaded || !this.variables)
|
|
345
424
|
throw new Error("Tokens not loaded. Call load() first.");
|
|
346
|
-
const r
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
425
|
+
for (const r of Object.values(this.variables)) {
|
|
426
|
+
const n = q(r, e);
|
|
427
|
+
if (n != null && n.value && typeof n.value == "object") {
|
|
428
|
+
if (o) return n.value[o];
|
|
429
|
+
{
|
|
430
|
+
const s = Object.keys(n.value)[0];
|
|
431
|
+
return n.value[s];
|
|
432
|
+
}
|
|
433
|
+
}
|
|
351
434
|
}
|
|
352
435
|
}
|
|
353
436
|
}
|
|
354
|
-
const
|
|
355
|
-
const e = await new
|
|
437
|
+
const Kt = async () => {
|
|
438
|
+
const e = await new j().load();
|
|
356
439
|
if (!e)
|
|
357
440
|
throw new Error("Заполнить ошибку через нейронку");
|
|
358
|
-
const { figmaToken:
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
// // includeStyles: false,
|
|
365
|
-
// },
|
|
366
|
-
// output: {
|
|
367
|
-
// jsonDir: './fromVariables',
|
|
368
|
-
// stylesDir: './fromVariables',
|
|
369
|
-
// },
|
|
370
|
-
// }),
|
|
371
|
-
// ]
|
|
372
|
-
o.map((l) => l.executor({ figmaApiClient: a, tokenManagerClient: i }))
|
|
373
|
-
);
|
|
374
|
-
}, Oe = async () => {
|
|
375
|
-
await E.create(), console.log("\x1B[32m%s\x1B[0m", "✔️ Configuration file created gts.config.ts");
|
|
376
|
-
}, le = ({ r: s, g: e, b: r }) => {
|
|
377
|
-
const t = (o) => `0${o.toString(16)}`.slice(-2);
|
|
378
|
-
return `#${t(s)}${t(e)}${t(r)}`;
|
|
379
|
-
}, S = ({ opacity: s, r: e, g: r, b: t }) => {
|
|
380
|
-
const o = [e, r, t].map((n) => Math.round(n * 255));
|
|
381
|
-
return s < 1 ? `rgba(${o[0]}, ${o[1]}, ${o[2]}, ${s})` : le({ r: o[0], g: o[1], b: o[2] });
|
|
382
|
-
}, X = (s, e = 0) => {
|
|
383
|
-
const r = Math.atan2(
|
|
384
|
-
s[1].y - s[0].y,
|
|
385
|
-
s[1].x - s[0].x
|
|
386
|
-
);
|
|
387
|
-
return Math.round(r * 180 / Math.PI) + e;
|
|
388
|
-
}, R = (s) => s.reduce((e, r) => {
|
|
389
|
-
const t = Number((r.position * 100).toFixed(1));
|
|
390
|
-
return [
|
|
441
|
+
const { figmaToken: o, fileId: r, modules: n, manifest: s } = e, a = new P(o, r), l = new be(s);
|
|
442
|
+
s && d.exists(s) && await l.load(), await Promise.all(n.map((i) => i.executor({ figmaApiClient: a, tokenManagerClient: l })));
|
|
443
|
+
}, Lt = async () => {
|
|
444
|
+
await j.create(), console.log("\x1B[32m%s\x1B[0m", "✔️ Configuration file created gts.config.ts");
|
|
445
|
+
}, me = ["xxxl", "xxl", "xl", "lg", "md", "sm", "xs", "xxs", "xxxs"], we = (t) => parseInt(t.value, 10), ke = (t) => t.reduce(
|
|
446
|
+
(e, o) => ({
|
|
391
447
|
...e,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
},
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
448
|
+
[o.name]: we(o)
|
|
449
|
+
}),
|
|
450
|
+
{}
|
|
451
|
+
), $e = async (t, e) => {
|
|
452
|
+
await d.delete(t, e);
|
|
453
|
+
}, Se = async (t, e, o) => {
|
|
454
|
+
await d.write(t, e, { directory: o });
|
|
455
|
+
}, N = async (t, e, o) => {
|
|
456
|
+
await $e(t, o), await Se(t, e, o);
|
|
457
|
+
}, Te = (t) => {
|
|
458
|
+
const e = t.map(({ name: o, value: r }) => ` --${o}: ${r};`);
|
|
459
|
+
return e.length ? `.breakpoint-variables {
|
|
460
|
+
${e.join(`
|
|
461
|
+
`)}
|
|
462
|
+
}
|
|
463
|
+
` : "";
|
|
464
|
+
}, je = (t) => {
|
|
465
|
+
var r;
|
|
466
|
+
const e = t.map(({ name: n, value: s }) => ` ${n}: ${s}`), o = (r = t.at(-1)) == null ? void 0 : r.name;
|
|
467
|
+
return !e.length || !o ? "" : `$breakpointList: (
|
|
468
|
+
${e.join(`,
|
|
469
|
+
`)}
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
$defaultBreakpoint: '${o}';
|
|
473
|
+
`;
|
|
474
|
+
}, ve = (t) => [
|
|
475
|
+
`const breakpoints = ${JSON.stringify(t, null, 4)} as const;`,
|
|
476
|
+
"",
|
|
477
|
+
"const BREAKPOINTS_NAMES = Object.keys(breakpoints);",
|
|
478
|
+
"",
|
|
479
|
+
"type BreakpointsKeysType = keyof typeof breakpoints;",
|
|
480
|
+
"type AllowMedia = 'all' | BreakpointsKeysType;",
|
|
481
|
+
"",
|
|
482
|
+
"export { breakpoints, BREAKPOINTS_NAMES };",
|
|
483
|
+
"export type { BreakpointsKeysType, AllowMedia };",
|
|
484
|
+
""
|
|
485
|
+
].join(`
|
|
486
|
+
`), Me = async ({ breakpointTokens: t, dir: e }) => {
|
|
487
|
+
const o = ke(t), r = Te(t), n = je(t), s = ve(o);
|
|
488
|
+
await Promise.all([
|
|
489
|
+
N("styles.css", r, e),
|
|
490
|
+
N("styles.scss", n, e),
|
|
491
|
+
N("index.ts", s, e)
|
|
492
|
+
]);
|
|
493
|
+
}, Ce = (t, e) => {
|
|
494
|
+
const o = Object.keys(t).filter((s) => !isNaN(Number(s))).sort((s, a) => Number(s) - Number(a));
|
|
495
|
+
if (o.length > e.length)
|
|
496
|
+
throw new Error(
|
|
497
|
+
`Not enough breakpoint names provided. Found ${o.length} breakpoints in data, but only ${e.length} names specified: ${e.join(", ")}`
|
|
498
|
+
);
|
|
499
|
+
const n = Object.keys(t).filter((s) => isNaN(Number(s)));
|
|
500
|
+
if (n.length > 0)
|
|
501
|
+
throw new Error(
|
|
502
|
+
`Found non-numeric breakpoint keys in grid data: ${n.join(", ")}. All breakpoint keys must be numeric values.`
|
|
503
|
+
);
|
|
504
|
+
return o.map((s, a) => ({
|
|
505
|
+
name: e[e.length - 1 - a] || `bp-${s}`,
|
|
506
|
+
value: s
|
|
507
|
+
}));
|
|
508
|
+
}, Ut = ({
|
|
509
|
+
input: t = {},
|
|
510
|
+
output: { dir: e }
|
|
511
|
+
}) => ({
|
|
512
|
+
name: "breakpoints/tokenManager",
|
|
513
|
+
executor: async ({ tokenManagerClient: o }) => {
|
|
514
|
+
try {
|
|
515
|
+
console.log("[breakpoints/tokenManager] Generating breakpoints from TokenManager...");
|
|
516
|
+
const { names: r = me } = t;
|
|
517
|
+
if (!o.isLoaded())
|
|
518
|
+
throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
|
|
519
|
+
const n = o.getStyles();
|
|
520
|
+
if (!n.grid)
|
|
521
|
+
throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");
|
|
522
|
+
console.log("[breakpoints/tokenManager] Extracting breakpoints from grid styles...");
|
|
523
|
+
const s = Ce(n.grid, r);
|
|
524
|
+
if (!s.length) {
|
|
525
|
+
console.warn("[breakpoints/tokenManager] No breakpoints found in grid styles.");
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
console.log(
|
|
529
|
+
`[breakpoints/tokenManager] Found ${s.length} breakpoints: ${s.map((a) => a.name).join(", ")}`
|
|
530
|
+
), console.log(`[breakpoints/tokenManager] Writing files to ${e}...`), await Me({
|
|
531
|
+
breakpointTokens: s,
|
|
532
|
+
dir: e
|
|
533
|
+
}), console.log("[breakpoints/tokenManager] ✅ Successfully generated breakpoint files");
|
|
534
|
+
} catch (r) {
|
|
535
|
+
const n = r instanceof Error ? r.message : String(r);
|
|
536
|
+
throw console.error("[breakpoints/tokenManager] ❌ Failed to generate breakpoints:", n), r instanceof Error && r.stack && console.error("[breakpoints/tokenManager] Stack trace:", r.stack), r;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}), Ve = "styles.css", Fe = "index.ts", A = (t, e) => {
|
|
423
540
|
if (!e.length) return "";
|
|
424
|
-
const
|
|
541
|
+
const o = e.map((r) => ` ${r}`).join(`
|
|
425
542
|
`);
|
|
426
|
-
return `${
|
|
427
|
-
${
|
|
543
|
+
return `${t} {
|
|
544
|
+
${o}
|
|
428
545
|
}`;
|
|
429
|
-
},
|
|
430
|
-
(e,
|
|
431
|
-
const
|
|
432
|
-
return typeof
|
|
433
|
-
e[
|
|
434
|
-
}) : e.root.push(`${
|
|
546
|
+
}, Ne = (t) => `.${t.replace(/\s+/g, "-").toLowerCase()}`, Q = (t) => `--cl-${t}`, xe = (t) => t.reduce(
|
|
547
|
+
(e, o) => {
|
|
548
|
+
const r = Q(o.name);
|
|
549
|
+
return typeof o.value == "object" ? Object.entries(o.value).forEach(([n, s]) => {
|
|
550
|
+
e[n] || (e[n] = []), e[n].push(`${r}: ${s};`);
|
|
551
|
+
}) : e.root.push(`${r}: ${o.value};`), e;
|
|
435
552
|
},
|
|
436
553
|
{ root: [] }
|
|
437
|
-
),
|
|
438
|
-
const e =
|
|
439
|
-
if (
|
|
440
|
-
const a =
|
|
441
|
-
return a &&
|
|
554
|
+
), Oe = (t) => {
|
|
555
|
+
const e = A(".color-variables", t.root), o = Object.entries(t).reduce((r, [n, s]) => {
|
|
556
|
+
if (n === "root" || !s.length) return r;
|
|
557
|
+
const a = A(Ne(`${n}-color-variables`), s);
|
|
558
|
+
return a && r.push(a), r;
|
|
442
559
|
}, []).join(`
|
|
443
560
|
|
|
444
561
|
`);
|
|
445
|
-
return [e,
|
|
562
|
+
return [e, o].filter(Boolean).join(`
|
|
446
563
|
|
|
447
564
|
`);
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
cssFileName: o
|
|
565
|
+
}, Pe = (t) => `${`const colors = {
|
|
566
|
+
${t.map((r) => ` '${r.name}': 'var(${Q(r.name)})'`).join(`,
|
|
567
|
+
`)}
|
|
568
|
+
} as const;`}
|
|
569
|
+
|
|
570
|
+
type ColorsKeysType = keyof typeof colors;
|
|
571
|
+
|
|
572
|
+
export { colors, type ColorsKeysType };
|
|
573
|
+
`, Ee = async ({
|
|
574
|
+
tsContent: t,
|
|
575
|
+
cssContent: e,
|
|
576
|
+
dir: o
|
|
461
577
|
}) => {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
578
|
+
await d.delete(o);
|
|
579
|
+
const r = d.write(Fe, t, { directory: o }), n = d.write(Ve, e, { directory: o });
|
|
580
|
+
await Promise.all([r, n]);
|
|
581
|
+
}, Be = async ({ colorTokens: t, dir: e }) => {
|
|
582
|
+
const o = xe(t), r = Oe(o), n = Pe(t);
|
|
583
|
+
await Ee({ tsContent: n, cssContent: r, dir: e });
|
|
584
|
+
}, v = (t) => t.reduce((e, o) => {
|
|
585
|
+
const r = Number((o.position * 100).toFixed(1));
|
|
586
|
+
return [...e, `${o.color}${r > 0 && r < 100 ? ` ${r}%` : ""}`];
|
|
587
|
+
}, []).join(", "), Re = (t) => {
|
|
588
|
+
const e = v(t.stops);
|
|
589
|
+
return `linear-gradient(${t.angle}deg, ${e})`;
|
|
590
|
+
}, Ae = (t) => `radial-gradient(circle, ${v(t.stops)})`, De = (t) => {
|
|
591
|
+
const e = v(t.stops);
|
|
592
|
+
return `conic-gradient(from ${t.angle}deg, ${e})`;
|
|
593
|
+
}, Ke = (t) => {
|
|
594
|
+
const e = v(t.stops);
|
|
595
|
+
return `linear-gradient(${t.angle}deg, ${e})`;
|
|
596
|
+
}, D = (t) => typeof t == "string" ? t : t.type === "linear" ? Re(t) : t.type === "radial" ? Ae(t) : t.type === "conic" ? De(t) : t.type === "diamond" ? Ke(t) : "", Z = (t, e) => Object.keys(t).reduce(
|
|
597
|
+
(o, r) => {
|
|
598
|
+
const n = t[r], s = e ? `${e}-${r}` : r;
|
|
599
|
+
if (n && typeof n == "object" && "type" in n && "value" in n) {
|
|
600
|
+
const l = Object.keys(n.value), i = l.length > 1 ? n.value : n.value[l[0]], c = typeof i == "object" ? Object.keys(i).reduce(
|
|
601
|
+
(f, y) => ({
|
|
602
|
+
...f,
|
|
603
|
+
[y]: D(i[y])
|
|
604
|
+
}),
|
|
605
|
+
{}
|
|
606
|
+
) : D(i), u = { [s]: c };
|
|
607
|
+
return { ...o, ...u };
|
|
608
|
+
}
|
|
609
|
+
const a = Z(n, s);
|
|
610
|
+
return { ...o, ...a };
|
|
611
|
+
},
|
|
612
|
+
{}
|
|
613
|
+
), X = (t, e) => Object.keys(t).reduce((o, r) => {
|
|
614
|
+
const n = t[r];
|
|
615
|
+
if (n.type && n.type !== "color") return o;
|
|
616
|
+
if (n.type && n.value) {
|
|
617
|
+
const a = typeof n.value == "string" ? e.resolveVariableValueString(n.value, r) : e.resolveVariableValue(n.value);
|
|
618
|
+
return a ? { ...o, [r]: { ...n, value: a } } : o;
|
|
619
|
+
}
|
|
620
|
+
const s = X(n, e);
|
|
621
|
+
return s ? { ...o, [r]: s } : o;
|
|
622
|
+
}, {}), Wt = ({ input: t = {}, output: { dir: e } }) => ({
|
|
623
|
+
name: "colors/tokenManager",
|
|
624
|
+
executor: async ({ tokenManagerClient: o }) => {
|
|
470
625
|
try {
|
|
471
|
-
console.log("[
|
|
472
|
-
const
|
|
473
|
-
if (
|
|
474
|
-
|
|
475
|
-
|
|
626
|
+
console.log("[colors/tokenManager] Generating colors from TokenManager...");
|
|
627
|
+
const { includeVariables: r, includeStyles: n = !0 } = t;
|
|
628
|
+
if (!(r != null && r.length) && !n)
|
|
629
|
+
throw new Error("Either includeVariables or includeStyles must be enabled");
|
|
630
|
+
if (!o.isLoaded())
|
|
631
|
+
throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
|
|
632
|
+
const s = [], a = o.getVariables();
|
|
633
|
+
if (n) {
|
|
634
|
+
const i = o.getStyles();
|
|
635
|
+
console.log("[colors/tokenManager] Processing styles for colors..."), i.color && s.push(i.color);
|
|
476
636
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
console.log(`[styles/colors] Reading ${l.length} variable files...`);
|
|
482
|
-
try {
|
|
483
|
-
y = await Promise.all(
|
|
484
|
-
l.map(async (u) => {
|
|
485
|
-
try {
|
|
486
|
-
return await m.readJson(u);
|
|
487
|
-
} catch (p) {
|
|
488
|
-
throw console.error(`[styles/colors] Failed to read variable file: ${u}`, p), p;
|
|
489
|
-
}
|
|
490
|
-
})
|
|
491
|
-
);
|
|
492
|
-
} catch (u) {
|
|
493
|
-
throw console.error("[styles/colors] Error reading variable files:", u), new Error(`Failed to read variable files: ${u.message}`);
|
|
494
|
-
}
|
|
637
|
+
if (r != null && r.length) {
|
|
638
|
+
console.log(`[colors/tokenManager] Processing ${r.length} variable groups...`);
|
|
639
|
+
const i = r.map((c) => a[c]).filter(Boolean);
|
|
640
|
+
s.push(...i);
|
|
495
641
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (T.type === "SOLID" && y.length > 1) {
|
|
505
|
-
const L = (C = (N = T.boundVariables) == null ? void 0 : N.color) == null ? void 0 : C.id;
|
|
506
|
-
if (L) {
|
|
507
|
-
const D = y.reduce((G, J) => {
|
|
508
|
-
var z;
|
|
509
|
-
const W = (z = Object.entries(J).find(
|
|
510
|
-
([, F]) => F.$extensions["com.figma.variableId"] === L
|
|
511
|
-
)) == null ? void 0 : z[1];
|
|
512
|
-
if (W) {
|
|
513
|
-
const { components: F, alpha: H } = W.$value, Q = S({
|
|
514
|
-
opacity: H,
|
|
515
|
-
r: F[0],
|
|
516
|
-
g: F[1],
|
|
517
|
-
b: F[2]
|
|
518
|
-
});
|
|
519
|
-
return { ...G, [J.$extensions["com.figma.modeName"]]: Q };
|
|
520
|
-
}
|
|
521
|
-
return G;
|
|
522
|
-
}, {});
|
|
523
|
-
if (Object.keys(D).length > 1)
|
|
524
|
-
return [
|
|
525
|
-
...u,
|
|
526
|
-
{
|
|
527
|
-
name: A,
|
|
528
|
-
value: D
|
|
529
|
-
}
|
|
530
|
-
];
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
const I = fe(T);
|
|
534
|
-
return I ? [
|
|
535
|
-
...u,
|
|
536
|
-
{
|
|
537
|
-
name: A,
|
|
538
|
-
value: I
|
|
539
|
-
}
|
|
540
|
-
] : u;
|
|
541
|
-
} catch (k) {
|
|
542
|
-
return console.warn("[styles/colors] Error processing color node:", k), u;
|
|
543
|
-
}
|
|
544
|
-
}, []);
|
|
545
|
-
if (console.log(`[styles/colors] Generated ${f.length} color tokens`), f.length === 0) {
|
|
546
|
-
console.warn("[styles/colors] No color tokens generated. Check your Figma styles configuration.");
|
|
642
|
+
const l = s.map((i) => X(i, o)).flatMap(
|
|
643
|
+
(i) => Object.entries(Z(i, "")).reduce(
|
|
644
|
+
(c, [u, f]) => [...c, { name: u, value: f }],
|
|
645
|
+
[]
|
|
646
|
+
)
|
|
647
|
+
);
|
|
648
|
+
if (l.length === 0) {
|
|
649
|
+
console.warn("[colors/tokenManager] No color tokens generated");
|
|
547
650
|
return;
|
|
548
651
|
}
|
|
549
|
-
console.log(`[
|
|
550
|
-
colorTokens:
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
} catch (a) {
|
|
557
|
-
const i = a instanceof Error ? a.message : String(a);
|
|
558
|
-
throw console.error("[styles/colors] ❌ Failed to generate colors from styles:", i), a instanceof Error && a.stack && console.error("[styles/colors] Stack trace:", a.stack), a;
|
|
652
|
+
console.log(`[colors/tokenManager] Generated ${l.length} color tokens`), console.log(`[colors/tokenManager] Writing files to ${e}...`), await Be({
|
|
653
|
+
colorTokens: l,
|
|
654
|
+
dir: e
|
|
655
|
+
}), console.log("[colors/tokenManager] ✅ Successfully generated color files");
|
|
656
|
+
} catch (r) {
|
|
657
|
+
const n = r instanceof Error ? r.message : String(r);
|
|
658
|
+
throw console.error("[colors/tokenManager] ❌ Failed to generate colors:", n), r instanceof Error && r.stack && console.error("[colors/tokenManager] Stack trace:", r.stack), r;
|
|
559
659
|
}
|
|
560
660
|
}
|
|
561
|
-
}),
|
|
562
|
-
|
|
563
|
-
|
|
661
|
+
}), Le = (t) => ` @media (width <= ${t.breakpoint}px) {
|
|
662
|
+
.container {
|
|
663
|
+
padding-left: ${t.offset};
|
|
664
|
+
padding-right: ${t.offset};
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
.containerTablet {
|
|
668
|
+
padding-left: ${t.offset};
|
|
669
|
+
padding-right: ${t.offset};
|
|
670
|
+
}
|
|
671
|
+
}`, Ue = (t, e) => {
|
|
672
|
+
const o = e || "components", r = t.map((n) => Le(n)).join(`
|
|
673
|
+
|
|
674
|
+
`);
|
|
675
|
+
return `@layer ${o} {
|
|
676
|
+
${r}
|
|
677
|
+
}`;
|
|
678
|
+
}, We = () => `import styles from './styles.module.css';
|
|
679
|
+
|
|
680
|
+
export const conatinerClassName = styles.container;
|
|
681
|
+
export const conatinerTabletClassName = styles.containerTablet;
|
|
682
|
+
`, K = async (t, e, o) => {
|
|
683
|
+
await d.delete(t, o), await d.write(t, e, { directory: o });
|
|
684
|
+
}, ze = async ({ containerTokens: t, dir: e, layer: o }) => {
|
|
685
|
+
const r = Ue(t, o), n = We();
|
|
686
|
+
await K("styles.module.css", r, e), await K("index.ts", n, e);
|
|
687
|
+
}, Ie = (t) => {
|
|
688
|
+
const e = t.trim().toLowerCase();
|
|
689
|
+
return e === "0" || e === "0px";
|
|
690
|
+
}, Ge = (t, e) => Object.keys(t).filter((s) => !isNaN(Number(s))).sort((s, a) => Number(a) - Number(s)).reduce((s, a) => {
|
|
691
|
+
const l = t[a];
|
|
692
|
+
if (!l || !("value" in l) || !Array.isArray(l.value))
|
|
693
|
+
return s;
|
|
694
|
+
const i = l.value.find((u) => u.pattern === "columns");
|
|
695
|
+
if (!(i != null && i.offset))
|
|
696
|
+
return s;
|
|
697
|
+
const c = e.resolveVariableValueString(i.offset);
|
|
698
|
+
return !c || typeof c != "string" || Ie(c) ? s : [
|
|
699
|
+
...s,
|
|
700
|
+
{
|
|
701
|
+
breakpoint: Number(a),
|
|
702
|
+
offset: c
|
|
703
|
+
}
|
|
704
|
+
];
|
|
705
|
+
}, []).reduce((s, a) => {
|
|
706
|
+
const l = s[s.length - 1];
|
|
707
|
+
return l && x(l.offset, a.offset) || s.push(a), s;
|
|
708
|
+
}, []), zt = ({
|
|
709
|
+
input: t = {},
|
|
710
|
+
output: { dir: e }
|
|
564
711
|
}) => ({
|
|
565
|
-
name: "
|
|
566
|
-
executor: async () => {
|
|
712
|
+
name: "container/tokenManager",
|
|
713
|
+
executor: async ({ tokenManagerClient: o }) => {
|
|
567
714
|
try {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
);
|
|
580
|
-
console.log(`[variables/colors] Processing ${n.length} variable files...`);
|
|
581
|
-
const a = /* @__PURE__ */ new Map();
|
|
582
|
-
n.forEach((l, c) => {
|
|
583
|
-
try {
|
|
584
|
-
if (!l.$extensions || !l.$extensions["com.figma.modeName"]) {
|
|
585
|
-
console.warn(
|
|
586
|
-
`[variables/colors] File ${s[c]} is missing modeName in extensions`
|
|
587
|
-
);
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
const g = l.$extensions["com.figma.modeName"];
|
|
591
|
-
Object.entries(l).forEach(([d, y]) => {
|
|
592
|
-
if (d !== "$extensions")
|
|
593
|
-
try {
|
|
594
|
-
const f = y;
|
|
595
|
-
if (!f || f.$type !== "color") return;
|
|
596
|
-
if (!f.$value || !f.$value.components) {
|
|
597
|
-
console.warn(
|
|
598
|
-
`[variables/colors] Variable "${d}" in mode "${g}" has invalid structure`
|
|
599
|
-
);
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
const { components: u, alpha: p } = f.$value, w = S({
|
|
603
|
-
opacity: p ?? 1,
|
|
604
|
-
r: u[0],
|
|
605
|
-
g: u[1],
|
|
606
|
-
b: u[2]
|
|
607
|
-
});
|
|
608
|
-
a.has(d) || a.set(d, {}), a.get(d)[g] = w;
|
|
609
|
-
} catch (f) {
|
|
610
|
-
console.warn(
|
|
611
|
-
`[variables/colors] Error processing variable "${d}" in mode "${g}":`,
|
|
612
|
-
f
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
} catch (g) {
|
|
617
|
-
console.error(`[variables/colors] Error processing file ${s[c]}:`, g);
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
const i = Array.from(a.entries()).map(([l, c]) => ({
|
|
621
|
-
name: l,
|
|
622
|
-
value: Object.keys(c).length > 1 ? c : Object.values(c)[0]
|
|
623
|
-
}));
|
|
624
|
-
if (console.log(`[variables/colors] Generated ${i.length} color tokens`), i.length === 0) {
|
|
625
|
-
console.warn(
|
|
626
|
-
"[variables/colors] No color tokens generated. Check your variable files structure."
|
|
627
|
-
);
|
|
715
|
+
console.log("[container/tokenManager] Generating container styles...");
|
|
716
|
+
const { layer: r } = t;
|
|
717
|
+
if (!o.isLoaded())
|
|
718
|
+
throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
|
|
719
|
+
console.log("[container/tokenManager] Extracting container tokens...");
|
|
720
|
+
const n = o.getStyles();
|
|
721
|
+
if (!n.grid)
|
|
722
|
+
throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");
|
|
723
|
+
const s = Ge(n.grid, o);
|
|
724
|
+
if (!s.length) {
|
|
725
|
+
console.warn("[container/tokenManager] No container tokens found.");
|
|
628
726
|
return;
|
|
629
727
|
}
|
|
630
|
-
console.log(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}), console.log("[
|
|
637
|
-
} catch (
|
|
638
|
-
const
|
|
639
|
-
throw console.error("[
|
|
728
|
+
console.log(
|
|
729
|
+
`[container/tokenManager] Found ${s.length} container tokens: ${s.map((a) => a.breakpoint).join(", ")}`
|
|
730
|
+
), console.log(`[container/tokenManager] Writing files to ${e}...`), await ze({
|
|
731
|
+
containerTokens: s,
|
|
732
|
+
dir: e,
|
|
733
|
+
layer: r
|
|
734
|
+
}), console.log("[container/tokenManager] ✅ Successfully generated container files");
|
|
735
|
+
} catch (r) {
|
|
736
|
+
const n = r instanceof Error ? r.message : String(r);
|
|
737
|
+
throw console.error("[container/tokenManager] ❌ Failed to generate container:", n), r instanceof Error && r.stack && console.error("[container/tokenManager] Stack trace:", r.stack), r;
|
|
640
738
|
}
|
|
641
739
|
}
|
|
642
|
-
}),
|
|
643
|
-
(
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
740
|
+
}), Je = "styles.css", qe = "index.ts", L = (t, e) => {
|
|
741
|
+
if (!e.length) return "";
|
|
742
|
+
const o = e.map((r) => ` ${r}`).join(`
|
|
743
|
+
`);
|
|
744
|
+
return `${t} {
|
|
745
|
+
${o}
|
|
746
|
+
}`;
|
|
747
|
+
}, He = (t) => `.${t.replace(/\s+/g, "-").toLowerCase()}`, Y = (t) => `--${t}`, Qe = ({ offsetX: t, offsetY: e, blur: o, spread: r, color: n }) => `${t} ${e} ${o} ${r} ${n}`, Ze = (t) => t.reduce(
|
|
748
|
+
(e, o) => {
|
|
749
|
+
const r = Y(o.name);
|
|
750
|
+
return typeof o.value != "object" ? (e.root.push(`${r}: ${o.value};`), e) : Object.entries(o.value).reduce((n, [s, a]) => {
|
|
751
|
+
const l = n[s] ?? [];
|
|
752
|
+
return { ...n, [s]: [...l, `${r}: ${a};`] };
|
|
753
|
+
}, e);
|
|
754
|
+
},
|
|
755
|
+
{ root: [] }
|
|
756
|
+
), Xe = (t) => {
|
|
757
|
+
const e = L(".shadow-variables", t.root), o = Object.entries(t).reduce((r, [n, s]) => {
|
|
758
|
+
if (n === "root" || !s.length) return r;
|
|
759
|
+
const a = L(He(`${n}-shadow-variables`), s);
|
|
760
|
+
return a && r.push(a), r;
|
|
761
|
+
}, []).join(`
|
|
762
|
+
|
|
763
|
+
`);
|
|
764
|
+
return [e, o].filter(Boolean).join(`
|
|
765
|
+
|
|
766
|
+
`);
|
|
767
|
+
}, Ye = (t) => `${`const shadows = {
|
|
768
|
+
${t.map((r) => ` '${r.name}': 'var(${Y(r.name)})'`).join(`,
|
|
769
|
+
`)}
|
|
770
|
+
} as const;`}
|
|
771
|
+
|
|
772
|
+
type ShadowsKeysType = keyof typeof shadows;
|
|
773
|
+
|
|
774
|
+
export { shadows, type ShadowsKeysType };
|
|
775
|
+
`, _e = async ({
|
|
776
|
+
tsContent: t,
|
|
777
|
+
cssContent: e,
|
|
778
|
+
dir: o
|
|
779
|
+
}) => {
|
|
780
|
+
await d.delete(o);
|
|
781
|
+
const r = d.write(qe, t, { directory: o }), n = d.write(Je, e, { directory: o });
|
|
782
|
+
await Promise.all([r, n]);
|
|
783
|
+
}, et = async ({ shadowTokens: t, dir: e }) => {
|
|
784
|
+
const o = Ze(t), r = Xe(o), n = Ye(t);
|
|
785
|
+
await _e({ tsContent: n, cssContent: r, dir: e });
|
|
786
|
+
}, _ = (t, e) => Object.keys(t).reduce(
|
|
787
|
+
(o, r) => {
|
|
788
|
+
const n = t[r], s = e ? `${e}-${r}` : r;
|
|
789
|
+
if (n && typeof n == "object" && "type" in n && "value" in n) {
|
|
790
|
+
const l = {
|
|
791
|
+
[s]: n.value.map(Qe).join(", ")
|
|
792
|
+
};
|
|
793
|
+
return { ...o, ...l };
|
|
648
794
|
}
|
|
649
|
-
const a =
|
|
650
|
-
return { ...
|
|
795
|
+
const a = _(n, s);
|
|
796
|
+
return { ...o, ...a };
|
|
651
797
|
},
|
|
652
798
|
{}
|
|
653
|
-
),
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (typeof o == "string") {
|
|
657
|
-
if (!e.isVariableReference(o)) return { ...s, value: o };
|
|
658
|
-
const i = e.getToken(e.getVariablePath(o)), l = i ? O(i, e, r) : void 0;
|
|
659
|
-
return l != null && l.value ? { ...s, ...i } : void 0;
|
|
660
|
-
}
|
|
661
|
-
const a = Object.keys(o).reduce((i, l) => {
|
|
662
|
-
if (r && l !== r) return i;
|
|
663
|
-
const c = o[l];
|
|
664
|
-
if (typeof c != "string") return i;
|
|
665
|
-
if (!e.isVariableReference(c)) return { ...i, [l]: c };
|
|
666
|
-
const g = e.getToken(e.getVariablePath(c)), d = g ? O(g, e, l) : void 0;
|
|
667
|
-
return d != null && d.value ? { ...i, ...d.value } : i;
|
|
668
|
-
}, {});
|
|
669
|
-
if (Object.keys(a).length)
|
|
670
|
-
return { ...s, value: a };
|
|
671
|
-
}, U = (s, e) => Object.keys(s).reduce((r, t) => {
|
|
672
|
-
const o = s[t];
|
|
673
|
-
if (o.type && o.value) {
|
|
674
|
-
const a = O(o, e);
|
|
675
|
-
return a ? { ...r, [t]: a } : r;
|
|
676
|
-
}
|
|
677
|
-
const n = U(o, e);
|
|
678
|
-
return n ? { ...r, [t]: n } : r;
|
|
679
|
-
}, {}), Me = ({
|
|
680
|
-
input: s = {},
|
|
681
|
-
output: { jsonDir: e, stylesDir: r, jsonFileName: t = "colors.json", cssFileName: o = "colors.css" }
|
|
682
|
-
}) => ({
|
|
683
|
-
name: "colors/tokenManager",
|
|
684
|
-
executor: async ({ tokenManagerClient: n }) => {
|
|
799
|
+
), It = ({ input: t = {}, output: { dir: e } }) => ({
|
|
800
|
+
name: "shadows/tokenManager",
|
|
801
|
+
executor: async ({ tokenManagerClient: o }) => {
|
|
685
802
|
try {
|
|
686
|
-
console.log("[
|
|
687
|
-
const {
|
|
688
|
-
if (!
|
|
689
|
-
throw new Error("
|
|
690
|
-
if (!
|
|
803
|
+
console.log("[shadows/tokenManager] Generating shadows from TokenManager...");
|
|
804
|
+
const { includeStyles: r = !0 } = t;
|
|
805
|
+
if (!r)
|
|
806
|
+
throw new Error("includeStyles must be enabled for shadows generation");
|
|
807
|
+
if (!o.isLoaded())
|
|
691
808
|
throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
694
|
-
const
|
|
695
|
-
console.log("[
|
|
696
|
-
}
|
|
697
|
-
if (a != null && a.length) {
|
|
698
|
-
console.log(`[colors/tokenManager] Processing ${a.length} variable groups...`);
|
|
699
|
-
const d = a.map((y) => c[y]).filter(Boolean);
|
|
700
|
-
l.push(...d);
|
|
809
|
+
const n = [];
|
|
810
|
+
if (r) {
|
|
811
|
+
const a = o.getStyles();
|
|
812
|
+
console.log("[shadows/tokenManager] Processing styles for shadows..."), a.effect && n.push(a.effect);
|
|
701
813
|
}
|
|
702
|
-
const
|
|
703
|
-
(
|
|
704
|
-
(
|
|
814
|
+
const s = n.flatMap(
|
|
815
|
+
(a) => Object.entries(_(a, "")).reduce(
|
|
816
|
+
(l, [i, c]) => [...l, { name: i, value: c }],
|
|
705
817
|
[]
|
|
706
818
|
)
|
|
707
819
|
);
|
|
708
|
-
if (
|
|
709
|
-
console.warn("[
|
|
820
|
+
if (s.length === 0) {
|
|
821
|
+
console.warn("[shadows/tokenManager] No shadow tokens generated");
|
|
710
822
|
return;
|
|
711
823
|
}
|
|
712
|
-
console.log(`[
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
824
|
+
console.log(`[shadows/tokenManager] Generated ${s.length} shadow tokens`), console.log(`[shadows/tokenManager] Writing files to ${e}...`), await et({
|
|
825
|
+
shadowTokens: s,
|
|
826
|
+
dir: e
|
|
827
|
+
}), console.log("[shadows/tokenManager] ✅ Successfully generated shadow files");
|
|
828
|
+
} catch (r) {
|
|
829
|
+
const n = r instanceof Error ? r.message : String(r);
|
|
830
|
+
throw console.error("[shadows/tokenManager] ❌ Failed to generate shadows:", n), r instanceof Error && r.stack && console.error("[shadows/tokenManager] Stack trace:", r.stack), r;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}), tt = "styles.module.css", rt = "index.ts", ot = "typography.ts", U = "sans-serif", W = (t, e) => {
|
|
834
|
+
if (!e.length) return "";
|
|
835
|
+
const o = e.map((r) => ` ${r}`).join(`
|
|
836
|
+
`);
|
|
837
|
+
return `${t} {
|
|
838
|
+
${o}
|
|
839
|
+
}`;
|
|
840
|
+
}, ee = (t, e) => {
|
|
841
|
+
if (typeof t != "string") return t;
|
|
842
|
+
const o = e[t] ?? t;
|
|
843
|
+
return o.trim().toLowerCase().endsWith(U) ? o : `${o}, ${U}`;
|
|
844
|
+
}, z = (t, e) => typeof t.fontFamily != "string" ? t : {
|
|
845
|
+
...t,
|
|
846
|
+
fontFamily: ee(t.fontFamily, e)
|
|
847
|
+
}, S = (t, e) => {
|
|
848
|
+
const o = {};
|
|
849
|
+
return Object.entries(t).forEach(([r, n]) => {
|
|
850
|
+
const s = r === "fontFamily" ? ee(n, e) : n, a = r.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
851
|
+
o[a] = s;
|
|
852
|
+
}), o;
|
|
853
|
+
}, nt = (t, e, o) => {
|
|
854
|
+
const r = Object.keys(t.breakpoints), n = S(t.base, o);
|
|
855
|
+
return r.reduce(
|
|
856
|
+
(s, a, l) => {
|
|
857
|
+
const i = S(t.breakpoints[a], o);
|
|
858
|
+
return l ? [...s, { breakpoint: Number(e[a]), css: i }] : [
|
|
859
|
+
{
|
|
860
|
+
breakpoint: null,
|
|
861
|
+
css: {
|
|
862
|
+
...n,
|
|
863
|
+
...i
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
];
|
|
867
|
+
},
|
|
868
|
+
[
|
|
869
|
+
{
|
|
870
|
+
breakpoint: null,
|
|
871
|
+
css: n
|
|
872
|
+
}
|
|
873
|
+
]
|
|
874
|
+
);
|
|
875
|
+
}, te = () => ({
|
|
876
|
+
base: {},
|
|
877
|
+
breakpoints: {}
|
|
878
|
+
}), O = (t, e, o, r) => {
|
|
879
|
+
Object.keys(r).length && (t.breakpoints[e] || (t.breakpoints[e] = {}), t.breakpoints[e][o] = {
|
|
880
|
+
...t.breakpoints[e][o],
|
|
881
|
+
...r
|
|
882
|
+
});
|
|
883
|
+
}, T = (t, e, o, r) => {
|
|
884
|
+
nt(e.value, o, r).forEach(({ breakpoint: s, css: a }) => {
|
|
885
|
+
if (s === null) {
|
|
886
|
+
t.base[e.name] = a;
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
O(t, s, e.name, a);
|
|
890
|
+
});
|
|
891
|
+
}, re = (t) => {
|
|
892
|
+
const e = I(t.base), o = Object.keys(t.breakpoints).map(Number).sort((r, n) => n - r).reduce((r, n) => {
|
|
893
|
+
const s = t.breakpoints[n];
|
|
894
|
+
return r + `@media (max-width: ${n}px) { ${I(s)} }`;
|
|
895
|
+
}, "");
|
|
896
|
+
return e + o;
|
|
897
|
+
}, st = (t, e, o) => {
|
|
898
|
+
const r = t.reduce((n, s) => (T(n, s, e, o), n), te());
|
|
899
|
+
return re(r);
|
|
900
|
+
}, I = (t) => Object.keys(t).reduce((e, o) => {
|
|
901
|
+
const r = t[o], n = Object.keys(r).map((s) => `${s}: ${r[s]}`).join(";");
|
|
902
|
+
return e + `.typo-${o} { ${n} }`;
|
|
903
|
+
}, ""), G = (t) => {
|
|
904
|
+
if (typeof t == "number") return Number.isFinite(t) ? t : null;
|
|
905
|
+
const e = Number.parseFloat(t);
|
|
906
|
+
return Number.isFinite(e) ? e : null;
|
|
907
|
+
}, J = (t) => {
|
|
908
|
+
if (typeof t == "number") return t / 16;
|
|
909
|
+
const e = t.trim().toLowerCase();
|
|
910
|
+
if (e.endsWith("rem")) return G(e);
|
|
911
|
+
if (e.endsWith("px")) {
|
|
912
|
+
const o = G(e);
|
|
913
|
+
return o === null ? null : o / 16;
|
|
914
|
+
}
|
|
915
|
+
return null;
|
|
916
|
+
}, at = (t) => {
|
|
917
|
+
const { minValueRem: e, maxValueRem: o, minVwRem: r, maxVwRem: n } = t, s = o - e;
|
|
918
|
+
return `calc(${e}rem + ((100vw - ${r}rem) / (${n}rem - ${r}rem)) * ${s}rem)`;
|
|
919
|
+
}, it = (t, e, o, r) => {
|
|
920
|
+
const n = ["font-size", "line-height"], s = Object.entries(e.value.breakpoints).map(([p, b]) => {
|
|
921
|
+
const w = Number.parseInt(o[p], 10);
|
|
922
|
+
return { breakpointName: p, width: w, typography: b };
|
|
923
|
+
}).filter((p) => Number.isFinite(p.width)).sort((p, b) => b.width - p.width);
|
|
924
|
+
if (s.length < 2) {
|
|
925
|
+
T(t, e, o, r);
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
const a = s[0], l = s[s.length - 1];
|
|
929
|
+
if (a.width <= l.width) {
|
|
930
|
+
T(t, e, o, r);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const i = S(e.value.base, r), c = S(a.typography, r), u = S(l.typography, r), f = a.width / 16, y = l.width / 16;
|
|
934
|
+
if (f === y) {
|
|
935
|
+
T(t, e, o, r);
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
t.base[e.name] = {
|
|
939
|
+
...i,
|
|
940
|
+
...c
|
|
941
|
+
};
|
|
942
|
+
const g = n.reduce((p, b) => {
|
|
943
|
+
const w = c[b], M = u[b];
|
|
944
|
+
if (w === void 0 || M === void 0 || w === M)
|
|
945
|
+
return p;
|
|
946
|
+
const E = J(w), B = J(M);
|
|
947
|
+
return E === null || B === null ? p : {
|
|
948
|
+
...p,
|
|
949
|
+
[b]: at({ minValueRem: B, maxValueRem: E, minVwRem: y, maxVwRem: f })
|
|
950
|
+
};
|
|
951
|
+
}, {});
|
|
952
|
+
O(t, a.width, e.name, g), O(t, l.width, e.name, u);
|
|
953
|
+
}, lt = (t, e, o, r) => {
|
|
954
|
+
if (!r) return st(t, e, o);
|
|
955
|
+
const n = t.reduce((s, a) => (it(s, a, e, o), s), te());
|
|
956
|
+
return re(n);
|
|
957
|
+
}, ct = (t) => t.length ? `import styles from './styles.module.css';
|
|
958
|
+
import { typography } from './typography';
|
|
959
|
+
|
|
960
|
+
type TypographyKeysType = keyof typeof typography;
|
|
961
|
+
|
|
962
|
+
const getTypographyClass = (typographyKey: TypographyKeysType) => styles[\`typo-\${typographyKey}\`];
|
|
963
|
+
|
|
964
|
+
export { typography, getTypographyClass, type TypographyKeysType };
|
|
965
|
+
` : "", ut = (t, e) => t.length ? `const typography = {
|
|
966
|
+
${t.map((r) => {
|
|
967
|
+
const n = z(r.value.base, e), s = Object.entries(r.value.breakpoints).reduce(
|
|
968
|
+
(a, [l, i]) => ({
|
|
969
|
+
...a,
|
|
970
|
+
[l]: z(i, e)
|
|
971
|
+
}),
|
|
972
|
+
{}
|
|
973
|
+
);
|
|
974
|
+
return ` '${r.name}': {
|
|
975
|
+
base: ${JSON.stringify(n, null, 8).replace(/\n/g, `
|
|
976
|
+
`)},
|
|
977
|
+
breakpoints: ${JSON.stringify(s, null, 8).replace(/\n/g, `
|
|
978
|
+
`)}
|
|
979
|
+
}`;
|
|
980
|
+
}).join(`,
|
|
981
|
+
`)}
|
|
982
|
+
} as const;
|
|
983
|
+
|
|
984
|
+
export { typography };
|
|
985
|
+
` : "", dt = async ({
|
|
986
|
+
indexTSContent: t,
|
|
987
|
+
typographyTSContent: e,
|
|
988
|
+
cssContent: o,
|
|
989
|
+
dir: r
|
|
990
|
+
}) => {
|
|
991
|
+
await d.delete(r);
|
|
992
|
+
const n = d.write(rt, t, { directory: r }), s = d.write(ot, e, { directory: r }), a = d.write(tt, o, { directory: r });
|
|
993
|
+
await Promise.all([n, s, a]);
|
|
994
|
+
}, ft = async ({
|
|
995
|
+
typographyTokens: t,
|
|
996
|
+
dir: e,
|
|
997
|
+
breakpoints: o,
|
|
998
|
+
fontFamily: r,
|
|
999
|
+
fluid: n
|
|
1000
|
+
}) => {
|
|
1001
|
+
const s = lt(t, o, r, n), a = ut(t, r), l = ct(t);
|
|
1002
|
+
await dt({ indexTSContent: l, typographyTSContent: a, cssContent: s, dir: e });
|
|
1003
|
+
}, oe = (t, e, o) => Object.keys(t).reduce((r, n) => {
|
|
1004
|
+
const s = t[n];
|
|
1005
|
+
if (typeof s != "object" || Array.isArray(s)) return r;
|
|
1006
|
+
if (!("type" in s) || !("value" in s))
|
|
1007
|
+
return { ...r, [n]: oe(s, e, o) };
|
|
1008
|
+
if (s.type !== "typography") return r;
|
|
1009
|
+
const a = s.value, l = Object.entries(a).reduce(
|
|
1010
|
+
(i, [c, u]) => {
|
|
1011
|
+
const f = Object.keys(o.breakpoints);
|
|
1012
|
+
if (f.length)
|
|
1013
|
+
f.forEach((y) => {
|
|
1014
|
+
const g = e.resolveVariableValueString(u, y);
|
|
1015
|
+
g && (g === u ? i.base = { ...i.base, [c]: g } : i.breakpoints[y] = { ...i.breakpoints[y], [c]: g });
|
|
1016
|
+
});
|
|
1017
|
+
else {
|
|
1018
|
+
const y = e.resolveVariableValueString(u);
|
|
1019
|
+
y && (i.base = { ...i.base, [c]: y });
|
|
1020
|
+
}
|
|
1021
|
+
return i;
|
|
1022
|
+
},
|
|
1023
|
+
{ base: {}, breakpoints: {} }
|
|
1024
|
+
);
|
|
1025
|
+
return { ...r, [n]: { type: "typography", value: l } };
|
|
1026
|
+
}, {}), ne = (t, e) => Object.keys(t).reduce((o, r) => {
|
|
1027
|
+
const n = e ? `${e}-${r}` : r, s = t[r];
|
|
1028
|
+
if (!("type" in s) || !("value" in s))
|
|
1029
|
+
return { ...o, ...ne(s, n) };
|
|
1030
|
+
const a = s.value;
|
|
1031
|
+
return { ...o, [n]: a };
|
|
1032
|
+
}, {}), Gt = ({ input: t, output: { dir: e } }) => ({
|
|
1033
|
+
name: "typography/tokenManager",
|
|
1034
|
+
executor: async ({ tokenManagerClient: o }) => {
|
|
1035
|
+
try {
|
|
1036
|
+
console.log("[typography/tokenManager] Generating typography from TokenManager...");
|
|
1037
|
+
const { breakpoints: r, fontFamily: n } = t, s = t.fluid ?? !0;
|
|
1038
|
+
if (!o.isLoaded())
|
|
1039
|
+
throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
|
|
1040
|
+
const a = [], l = o.getStyles();
|
|
1041
|
+
console.log("[typography/tokenManager] Processing styles for typography..."), l.text && a.push(l.text);
|
|
1042
|
+
const i = a.reduce(
|
|
1043
|
+
(u, f) => ({
|
|
1044
|
+
...u,
|
|
1045
|
+
...oe(f, o, { breakpoints: t.breakpoints })
|
|
1046
|
+
}),
|
|
1047
|
+
{}
|
|
1048
|
+
), c = Object.entries(ne(i)).map(
|
|
1049
|
+
([u, f]) => ({ name: u, value: f })
|
|
1050
|
+
);
|
|
1051
|
+
if (c.length === 0) {
|
|
1052
|
+
console.warn("[typography/tokenManager] No typography tokens generated");
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
console.log(`[typography/tokenManager] Generated ${c.length} typography tokens`), console.log(`[typography/tokenManager] Writing files to ${e}...`), await ft({
|
|
1056
|
+
typographyTokens: c,
|
|
1057
|
+
dir: e,
|
|
1058
|
+
breakpoints: r,
|
|
1059
|
+
fontFamily: n || {},
|
|
1060
|
+
fluid: s
|
|
1061
|
+
}), console.log("[typography/tokenManager] ✅ Successfully generated typography files");
|
|
1062
|
+
} catch (r) {
|
|
1063
|
+
const n = r instanceof Error ? r.message : String(r);
|
|
1064
|
+
throw console.error("[typography/tokenManager] ❌ Failed to generate typography:", n), r instanceof Error && r.stack && console.error("[typography/tokenManager] Stack trace:", r.stack), r;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}), yt = (t) => typeof t == "object" && t !== null && "type" in t && "value" in t, gt = (t) => typeof t == "object" && t !== null && !Array.isArray(t), se = (t) => t.trim().split(".").map((e) => e.trim()).filter(Boolean), pt = (t, e) => {
|
|
1068
|
+
const o = se(e);
|
|
1069
|
+
if (!o.length)
|
|
1070
|
+
throw new Error("variablePath must contain at least one segment");
|
|
1071
|
+
const r = q(t, o);
|
|
1072
|
+
if (r === void 0)
|
|
1073
|
+
throw new Error(`Variables subtree not found at path: ${o.join(".")}`);
|
|
1074
|
+
return r;
|
|
1075
|
+
}, ae = (t, e, o) => {
|
|
1076
|
+
if (!t) return [];
|
|
1077
|
+
if (yt(t)) {
|
|
1078
|
+
if (t.type !== "dimension") return [];
|
|
1079
|
+
const r = t.value, n = Object.keys(r).reduce((s, a) => {
|
|
1080
|
+
const l = r[a], i = o.resolveVariableValueString(l, a);
|
|
1081
|
+
return { ...s, [a]: i ?? l };
|
|
1082
|
+
}, {});
|
|
1083
|
+
return [{ flatName: e, resolvedByMode: n }];
|
|
1084
|
+
}
|
|
1085
|
+
return gt(t) ? Object.keys(t).flatMap((r) => {
|
|
1086
|
+
const n = t[r], s = e ? `${e}-${r}` : r;
|
|
1087
|
+
return ae(n, s, o);
|
|
1088
|
+
}) : [];
|
|
1089
|
+
}, ht = (t, e) => ae(t, "", e), bt = (t, e) => typeof e == "string" ? t === e : e.test(t), mt = (t, e) => e != null && e.length ? t.filter(
|
|
1090
|
+
(o) => e.some((r) => bt(o.flatName, r))
|
|
1091
|
+
) : t, ie = (t) => Object.keys(t).map((e) => ({ mode: e, widthPx: Number.parseInt(t[e], 10) })).filter((e) => Number.isFinite(e.widthPx)).sort((e, o) => o.widthPx - e.widthPx), wt = (t) => {
|
|
1092
|
+
const e = se(t);
|
|
1093
|
+
if (!e.length)
|
|
1094
|
+
throw new Error("variablePath must contain at least one segment");
|
|
1095
|
+
const o = e[e.length - 1];
|
|
1096
|
+
return {
|
|
1097
|
+
variablesClassName: `${o}-variables`,
|
|
1098
|
+
variableNamePrefix: o
|
|
1099
|
+
};
|
|
1100
|
+
}, le = (t) => {
|
|
1101
|
+
const e = wt(t.variablePath), o = t.variableNamePrefix ?? e.variableNamePrefix, r = t.variablesClassName ?? `${o}-variables`;
|
|
1102
|
+
return {
|
|
1103
|
+
variableNamePrefix: o,
|
|
1104
|
+
variablesClassName: r
|
|
1105
|
+
};
|
|
1106
|
+
}, kt = (t, e) => t ? `--${t}-${e}` : `--${e}`, $t = (t, e) => Object.keys(e).reduce(
|
|
1107
|
+
(o, r) => {
|
|
1108
|
+
const n = Number(r);
|
|
1109
|
+
return { ...o, [n]: { ...o[n], ...e[n] } };
|
|
1110
|
+
},
|
|
1111
|
+
{ ...t }
|
|
1112
|
+
), St = (t, e, o) => {
|
|
1113
|
+
const r = kt(o, t.flatName), n = ie(e);
|
|
1114
|
+
if (Object.keys(e).length === 0 || n.length === 0) {
|
|
1115
|
+
const i = Object.values(t.resolvedByMode)[0] ?? "";
|
|
1116
|
+
return { base: { [r]: i }, byBreakpoint: {} };
|
|
1117
|
+
}
|
|
1118
|
+
const s = n.filter((i) => i.mode in t.resolvedByMode);
|
|
1119
|
+
if (s.length === 0) {
|
|
1120
|
+
const i = Object.values(t.resolvedByMode)[0] ?? "";
|
|
1121
|
+
return { base: { [r]: i }, byBreakpoint: {} };
|
|
1122
|
+
}
|
|
1123
|
+
if (s.length === 1) {
|
|
1124
|
+
const i = s[0], c = t.resolvedByMode[i.mode] ?? "";
|
|
1125
|
+
return { base: { [r]: c }, byBreakpoint: {} };
|
|
1126
|
+
}
|
|
1127
|
+
const a = t.resolvedByMode[s[0].mode] ?? "", l = s.slice(1).reduce((i, c, u) => {
|
|
1128
|
+
const f = s[u].mode, y = t.resolvedByMode[f], g = t.resolvedByMode[c.mode];
|
|
1129
|
+
if (g === void 0 || g === y) return i;
|
|
1130
|
+
const p = c.widthPx, b = i[p] ?? {};
|
|
1131
|
+
return { ...i, [p]: { ...b, [r]: g } };
|
|
1132
|
+
}, {});
|
|
1133
|
+
return { base: { [r]: a }, byBreakpoint: l };
|
|
1134
|
+
}, Tt = (t, e, o) => t.reduce(
|
|
1135
|
+
(r, n) => {
|
|
1136
|
+
const { base: s, byBreakpoint: a } = St(n, e, o);
|
|
1137
|
+
return {
|
|
1138
|
+
base: { ...r.base, ...s },
|
|
1139
|
+
breakpoints: $t(r.breakpoints, a)
|
|
1140
|
+
};
|
|
1141
|
+
},
|
|
1142
|
+
{ base: {}, breakpoints: {} }
|
|
1143
|
+
), jt = (t, e) => {
|
|
1144
|
+
if (!t.length) return "";
|
|
1145
|
+
const { breakpoints: o } = e, { variablesClassName: r, variableNamePrefix: n } = le(e), s = Tt(t, o, n), a = Object.keys(s.base).map((c) => ` ${c}: ${s.base[c]};`), l = W(`.${r}`, a), i = Object.keys(s.breakpoints).map(Number).sort((c, u) => u - c).map((c) => {
|
|
1146
|
+
const u = s.breakpoints[c], f = Object.keys(u).map((g) => ` ${g}: ${u[g]};`), y = W(`.${r}`, f);
|
|
1147
|
+
return `@media (max-width: ${c}px) {
|
|
1148
|
+
${y}
|
|
1149
|
+
}`;
|
|
1150
|
+
}).filter(Boolean).join(`
|
|
1151
|
+
|
|
1152
|
+
`);
|
|
1153
|
+
return i ? `${l}
|
|
1154
|
+
|
|
1155
|
+
${i}` : l;
|
|
1156
|
+
}, vt = (t, e) => {
|
|
1157
|
+
const o = t.resolvedByMode, r = ie(e), n = Object.keys(e).length > 0 && r.length > 0;
|
|
1158
|
+
return { breakpoints: (() => {
|
|
1159
|
+
if (!n)
|
|
1160
|
+
return Object.keys(o);
|
|
1161
|
+
const l = [], i = /* @__PURE__ */ new Set();
|
|
1162
|
+
return r.forEach(({ mode: c }) => {
|
|
1163
|
+
c in o && (l.push(c), i.add(c));
|
|
1164
|
+
}), Object.keys(o).forEach((c) => {
|
|
1165
|
+
i.has(c) || (l.push(c), i.add(c));
|
|
1166
|
+
}), l;
|
|
1167
|
+
})().reduce((l, i) => {
|
|
1168
|
+
const c = o[i];
|
|
1169
|
+
return c === void 0 ? l : { ...l, [i]: c };
|
|
1170
|
+
}, {}) };
|
|
1171
|
+
}, Mt = (t, e) => {
|
|
1172
|
+
const { breakpoints: o } = e;
|
|
1173
|
+
return t.length ? `const utilities = {
|
|
1174
|
+
${t.map((n) => {
|
|
1175
|
+
const s = vt(n, o), a = JSON.stringify(s, null, 8);
|
|
1176
|
+
return ` '${n.flatName}': ${a.replace(/\n/g, `
|
|
1177
|
+
`)}`;
|
|
1178
|
+
}).join(`,
|
|
1179
|
+
`)}
|
|
1180
|
+
} as const;
|
|
1181
|
+
|
|
1182
|
+
export { utilities };
|
|
1183
|
+
` : `const utilities = {} as const;
|
|
1184
|
+
|
|
1185
|
+
export { utilities };
|
|
1186
|
+
`;
|
|
1187
|
+
}, Ct = (t) => {
|
|
1188
|
+
const { variableNamePrefix: e } = le(t);
|
|
1189
|
+
return [
|
|
1190
|
+
"import { utilities } from './utilities';",
|
|
1191
|
+
"",
|
|
1192
|
+
"type UtilitiesKeysType = keyof typeof utilities;",
|
|
1193
|
+
"",
|
|
1194
|
+
`const utilityVariableNamePrefix = ${JSON.stringify(e)};`,
|
|
1195
|
+
"",
|
|
1196
|
+
"const getUtilityCssVariableName = (key: UtilitiesKeysType): string =>",
|
|
1197
|
+
" utilityVariableNamePrefix",
|
|
1198
|
+
" ? `--${utilityVariableNamePrefix}-${String(key)}`",
|
|
1199
|
+
" : `--${String(key)}`;",
|
|
1200
|
+
"",
|
|
1201
|
+
"const getUtilityCssVar = (key: UtilitiesKeysType): string =>",
|
|
1202
|
+
" `var(${getUtilityCssVariableName(key)})`;",
|
|
1203
|
+
"",
|
|
1204
|
+
"export {",
|
|
1205
|
+
" utilities,",
|
|
1206
|
+
" getUtilityCssVariableName,",
|
|
1207
|
+
" getUtilityCssVar,",
|
|
1208
|
+
" type UtilitiesKeysType,",
|
|
1209
|
+
"};",
|
|
1210
|
+
""
|
|
1211
|
+
].join(`
|
|
1212
|
+
`);
|
|
1213
|
+
}, Vt = "styles.css", Ft = "utilities.ts", Nt = "index.ts", xt = async ({
|
|
1214
|
+
dir: t,
|
|
1215
|
+
globalCss: e,
|
|
1216
|
+
utilitiesTs: o,
|
|
1217
|
+
indexTs: r
|
|
1218
|
+
}) => {
|
|
1219
|
+
await d.delete(t), await Promise.all([
|
|
1220
|
+
d.write(Vt, e, { directory: t }),
|
|
1221
|
+
d.write(Ft, o, { directory: t }),
|
|
1222
|
+
d.write(Nt, r, { directory: t })
|
|
1223
|
+
]);
|
|
1224
|
+
}, Ot = async ({
|
|
1225
|
+
tokens: t,
|
|
1226
|
+
input: e,
|
|
1227
|
+
output: o
|
|
1228
|
+
}) => {
|
|
1229
|
+
const { dir: r } = o, n = jt(t, e), s = Mt(t, e), a = Ct(e);
|
|
1230
|
+
await xt({ dir: r, globalCss: n, utilitiesTs: s, indexTs: a });
|
|
1231
|
+
}, Jt = ({ input: t, output: e }) => ({
|
|
1232
|
+
name: "utilities/tokenManager",
|
|
1233
|
+
executor: async ({ tokenManagerClient: o }) => {
|
|
1234
|
+
var r;
|
|
1235
|
+
try {
|
|
1236
|
+
if (console.log("[utilities/tokenManager] Generating utility classes from TokenManager..."), !o.isLoaded())
|
|
1237
|
+
throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
|
|
1238
|
+
const n = o.getVariables(), s = pt(n, t.variablePath), a = ht(s, o), l = mt(a, t.include);
|
|
1239
|
+
if (!l.length) {
|
|
1240
|
+
a.length && ((r = t.include) != null && r.length) ? console.warn(
|
|
1241
|
+
`[utilities/tokenManager] No tokens left after include filter (${a.length} at path "${t.variablePath}")`
|
|
1242
|
+
) : console.warn(`[utilities/tokenManager] No dimension tokens found at path "${t.variablePath}"`);
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
console.log(`[utilities/tokenManager] Resolved ${l.length} utility token(s)`), console.log(`[utilities/tokenManager] Writing files to ${e.dir}...`), await Ot({ tokens: l, input: t, output: e }), console.log("[utilities/tokenManager] ✅ Successfully generated utility files");
|
|
1246
|
+
} catch (n) {
|
|
1247
|
+
const s = n instanceof Error ? n.message : String(n);
|
|
1248
|
+
throw console.error("[utilities/tokenManager] ❌ Failed to generate utilities:", s), n instanceof Error && n.stack && console.error("[utilities/tokenManager] Stack trace:", n.stack), n;
|
|
722
1249
|
}
|
|
723
1250
|
}
|
|
724
1251
|
});
|
|
725
1252
|
export {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
1253
|
+
me as BREAKPOINTS_NAMES,
|
|
1254
|
+
be as TokenManager,
|
|
1255
|
+
Ut as breakpointsFromTokenManager,
|
|
1256
|
+
Mt as buildUtilitiesDataTSContent,
|
|
1257
|
+
jt as buildUtilitiesGlobalStylesCSS,
|
|
1258
|
+
Ct as buildUtilitiesIndexTSContent,
|
|
1259
|
+
Wt as colorsFromTokenManager,
|
|
1260
|
+
zt as containerFromTokenManager,
|
|
1261
|
+
wt as deriveUtilityNamingFromVariablePath,
|
|
1262
|
+
mt as filterResolvedUtilitiesByInclude,
|
|
1263
|
+
Kt as generate,
|
|
1264
|
+
Ot as generateUtilitiesFiles,
|
|
1265
|
+
ie as getSortedBreakpointModes,
|
|
1266
|
+
kt as getUtilityCssVariableName,
|
|
1267
|
+
pt as getVariablesSubtree,
|
|
1268
|
+
Lt as init,
|
|
1269
|
+
ht as resolveUtilitiesSubtree,
|
|
1270
|
+
le as resolveUtilityNaming,
|
|
1271
|
+
It as shadowsFromTokenManager,
|
|
1272
|
+
St as splitUtilityTokenForMedia,
|
|
1273
|
+
Gt as typographyFromTokenManager,
|
|
1274
|
+
Jt as utilitiesFromTokenManager,
|
|
1275
|
+
bt as utilityFlatNameMatchesIncludePattern,
|
|
1276
|
+
vt as utilityTokenToSerializableData,
|
|
1277
|
+
xt as writeUtilitiesFiles
|
|
732
1278
|
};
|