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