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