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