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