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