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