@projectwallace/css-design-tokens 0.7.1 → 0.8.0
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/dist/css-design-tokens.js +245 -199
- package/package.json +2 -2
|
@@ -1,49 +1,44 @@
|
|
|
1
|
-
import { cssKeywords as
|
|
2
|
-
import { convert as
|
|
3
|
-
import { convert as
|
|
4
|
-
import { parse as
|
|
5
|
-
import { ColorSpace as o, sRGB as
|
|
6
|
-
const
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
1
|
+
import { cssKeywords as T, colorKeywords as W, namedColors as K, systemColors as M, colorFunctions as Z, analyze as U } from "@projectwallace/css-analyzer";
|
|
2
|
+
import { convert as V } from "css-time-sort";
|
|
3
|
+
import { convert as J } from "color-sorter";
|
|
4
|
+
import { parse as $ } from "css-tree";
|
|
5
|
+
import { ColorSpace as o, sRGB as Q, XYZ_D65 as ee, XYZ_D50 as te, XYZ_ABS_D65 as re, Lab_D65 as ne, Lab as ie, LCH as le, sRGB_Linear as se, HSL as oe, HWB as ue, HSV as ae, P3_Linear as ce, P3 as fe, A98RGB_Linear as pe, A98RGB as me, ProPhoto_Linear as ge, ProPhoto as he, REC_2020_Linear as de, REC_2020 as _e, OKLab as ve, OKLCH as $e, OKLrab as be, parse as xe } from "colorjs.io/fn";
|
|
6
|
+
const A = 0, j = 1, z = 2, y = 3, I = 4, R = 5, H = 6, X = 7, D = 8, P = 9, Y = 10, v = 11, ye = /* @__PURE__ */ new Map([
|
|
7
|
+
[A, "white"],
|
|
8
|
+
[j, "black"],
|
|
9
|
+
[z, "grey"],
|
|
10
|
+
[y, "red"],
|
|
11
|
+
[I, "orange"],
|
|
12
|
+
[R, "yellow"],
|
|
13
|
+
[H, "green"],
|
|
14
|
+
[X, "cyan"],
|
|
15
|
+
[D, "blue"],
|
|
16
|
+
[P, "magenta"],
|
|
17
|
+
[Y, "pink"],
|
|
18
|
+
[v, "unknown"]
|
|
19
19
|
]);
|
|
20
|
-
function
|
|
20
|
+
function we(r) {
|
|
21
21
|
let t = /* @__PURE__ */ new Map();
|
|
22
|
-
for (let
|
|
23
|
-
let e =
|
|
24
|
-
if (!
|
|
25
|
-
let s =
|
|
26
|
-
i < 10 &&
|
|
22
|
+
for (let n in r) {
|
|
23
|
+
let e = v;
|
|
24
|
+
if (!n.includes("var(") && !n.includes("calc(")) {
|
|
25
|
+
let s = J(n), { hue: l, saturation: i, lightness: c } = s;
|
|
26
|
+
i < 10 && c === 100 ? e = A : i < 10 && c === 0 ? e = j : i < 5 ? e = z : l < 22 ? e = y : l < 50 ? e = I : l < 72 ? e = R : l < 144 ? e = H : l < 180 ? e = X : l < 250 ? e = D : l < 300 ? e = P : l < 350 ? e = Y : e = y;
|
|
27
27
|
}
|
|
28
|
-
t.has(e) ? t.get(e).push(
|
|
28
|
+
t.has(e) ? t.get(e).push(n) : t.set(e, [n]);
|
|
29
29
|
}
|
|
30
30
|
return Array.from(t).sort(
|
|
31
|
-
(
|
|
31
|
+
(n, e) => n[0] === v || e[0] === v ? -1 : e[1].length - n[1].length
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
o.register(M);
|
|
36
|
-
o.register(Z);
|
|
37
|
-
o.register(U);
|
|
38
|
-
o.register(V);
|
|
39
|
-
o.register(J);
|
|
34
|
+
const f = "com.projectwallace.css-authored-as", u = "com.projectwallace.usage-count", x = "com.projectwallace.css-properties";
|
|
40
35
|
o.register(Q);
|
|
41
36
|
o.register(ee);
|
|
42
37
|
o.register(te);
|
|
43
38
|
o.register(re);
|
|
44
39
|
o.register(ne);
|
|
45
|
-
o.register(le);
|
|
46
40
|
o.register(ie);
|
|
41
|
+
o.register(le);
|
|
47
42
|
o.register(se);
|
|
48
43
|
o.register(oe);
|
|
49
44
|
o.register(ue);
|
|
@@ -52,34 +47,39 @@ o.register(ce);
|
|
|
52
47
|
o.register(fe);
|
|
53
48
|
o.register(pe);
|
|
54
49
|
o.register(me);
|
|
55
|
-
o.register(he);
|
|
56
50
|
o.register(ge);
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
o.register(he);
|
|
52
|
+
o.register(de);
|
|
53
|
+
o.register(_e);
|
|
54
|
+
o.register(ve);
|
|
55
|
+
o.register($e);
|
|
56
|
+
o.register(be);
|
|
57
|
+
function g(r) {
|
|
58
|
+
let t = r.toLowerCase();
|
|
59
59
|
if (t === "transparent")
|
|
60
60
|
return {
|
|
61
61
|
colorSpace: "srgb",
|
|
62
62
|
components: [0, 0, 0],
|
|
63
63
|
alpha: 0
|
|
64
64
|
};
|
|
65
|
-
if (
|
|
65
|
+
if (T.has(t) || W.has(t) || t.includes("var("))
|
|
66
66
|
return null;
|
|
67
67
|
try {
|
|
68
|
-
let
|
|
68
|
+
let n = xe(r), [e, s, l] = n.coords;
|
|
69
69
|
return {
|
|
70
|
-
colorSpace:
|
|
70
|
+
colorSpace: n.spaceId,
|
|
71
71
|
components: [
|
|
72
72
|
e ?? "none",
|
|
73
73
|
s ?? "none",
|
|
74
74
|
l ?? "none"
|
|
75
75
|
],
|
|
76
|
-
alpha:
|
|
76
|
+
alpha: n.alpha ?? 0
|
|
77
77
|
};
|
|
78
78
|
} catch {
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function O() {
|
|
83
83
|
return {
|
|
84
84
|
color: void 0,
|
|
85
85
|
offsetX: void 0,
|
|
@@ -89,21 +89,21 @@ function x() {
|
|
|
89
89
|
inset: !1
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
let t =
|
|
92
|
+
function Se(r) {
|
|
93
|
+
let t = $(r, {
|
|
94
94
|
context: "value",
|
|
95
95
|
positions: !0
|
|
96
96
|
});
|
|
97
|
-
function
|
|
98
|
-
return l.loc ?
|
|
97
|
+
function n(l) {
|
|
98
|
+
return l.loc ? r.slice(l.loc.start.offset, l.loc.end.offset) : "";
|
|
99
99
|
}
|
|
100
|
-
let e =
|
|
100
|
+
let e = O(), s = [e];
|
|
101
101
|
return t.children.size < 2 ? null : (t.children.forEach((l) => {
|
|
102
102
|
if (l.type === "Identifier") {
|
|
103
103
|
if (l.name.toLowerCase() === "inset")
|
|
104
104
|
e.inset = !0;
|
|
105
|
-
else if (
|
|
106
|
-
let i =
|
|
105
|
+
else if (K.has(l.name) || M.has(l.name)) {
|
|
106
|
+
let i = g(l.name);
|
|
107
107
|
if (i === null)
|
|
108
108
|
return;
|
|
109
109
|
e.color = i;
|
|
@@ -118,61 +118,61 @@ function $e(n) {
|
|
|
118
118
|
};
|
|
119
119
|
e.offsetX ? e.offsetY ? e.blur ? e.spread || (e.spread = i) : e.blur = i : e.offsetY = i : e.offsetX = i;
|
|
120
120
|
} else if (l.type === "Function") {
|
|
121
|
-
if (
|
|
122
|
-
let i =
|
|
121
|
+
if (Z.has(l.name)) {
|
|
122
|
+
let i = g(n(l));
|
|
123
123
|
if (i === null)
|
|
124
124
|
return;
|
|
125
125
|
e.color = i;
|
|
126
126
|
} else if (l.name.toLowerCase() === "var" && !e.color) {
|
|
127
|
-
let i =
|
|
127
|
+
let i = g(n(l));
|
|
128
128
|
if (i === null)
|
|
129
129
|
return;
|
|
130
130
|
e.color = i;
|
|
131
131
|
}
|
|
132
132
|
} else if (l.type === "Hash") {
|
|
133
|
-
let i =
|
|
133
|
+
let i = g(n(l));
|
|
134
134
|
if (i === null)
|
|
135
135
|
return;
|
|
136
136
|
e.color = i;
|
|
137
|
-
} else l.type === "Operator" && l.value === "," && (
|
|
138
|
-
}),
|
|
137
|
+
} else l.type === "Operator" && l.value === "," && (L(e), e = O(), s.push(e));
|
|
138
|
+
}), L(e), s);
|
|
139
139
|
}
|
|
140
|
-
const
|
|
140
|
+
const _ = {
|
|
141
141
|
value: 0,
|
|
142
142
|
unit: "px"
|
|
143
143
|
};
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function L(r) {
|
|
145
|
+
return r.offsetX || (r.offsetX = _), r.offsetY || (r.offsetY = _), r.blur || (r.blur = _), r.spread || (r.spread = _), r.color || (r.color = g("#000")), r;
|
|
146
146
|
}
|
|
147
|
-
const
|
|
147
|
+
const E = /* @__PURE__ */ new Map([
|
|
148
148
|
["linear", [0, 0, 1, 1]],
|
|
149
149
|
["ease", [0.25, 0.1, 0.25, 1]],
|
|
150
150
|
["ease-in", [0.42, 0, 1, 1]],
|
|
151
151
|
["ease-out", [0, 0, 0.58, 1]],
|
|
152
152
|
["ease-in-out", [0.42, 0, 0.58, 1]]
|
|
153
153
|
]);
|
|
154
|
-
function
|
|
155
|
-
if (
|
|
156
|
-
return
|
|
157
|
-
if (
|
|
154
|
+
function Ne(r) {
|
|
155
|
+
if (r = r.trim().toLowerCase(), E.has(r))
|
|
156
|
+
return E.get(r);
|
|
157
|
+
if (r.includes("var("))
|
|
158
158
|
return null;
|
|
159
|
-
if (
|
|
160
|
-
let t =
|
|
161
|
-
if (t.length === 4 && t.every((
|
|
159
|
+
if (r.startsWith("cubic-bezier(")) {
|
|
160
|
+
let t = r.replace("cubic-bezier(", "").replace(")", "").split(",").map((n) => Number(n.trim()));
|
|
161
|
+
if (t.length === 4 && t.every((n) => Number.isFinite(n)))
|
|
162
162
|
return t;
|
|
163
163
|
}
|
|
164
164
|
return null;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
167
|
-
return
|
|
166
|
+
function q(r) {
|
|
167
|
+
return r.replaceAll(/^['"]|['"]$/g, "");
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
let t =
|
|
169
|
+
function Oe(r) {
|
|
170
|
+
let t = $(r, {
|
|
171
171
|
context: "value",
|
|
172
172
|
positions: !0
|
|
173
173
|
});
|
|
174
|
-
function
|
|
175
|
-
return i.loc ?
|
|
174
|
+
function n(i) {
|
|
175
|
+
return i.loc ? r.slice(i.loc.start.offset, i.loc.end.offset) : "";
|
|
176
176
|
}
|
|
177
177
|
let e = [];
|
|
178
178
|
if (!t.children || t.children.size === 0)
|
|
@@ -180,43 +180,45 @@ function ye(n) {
|
|
|
180
180
|
let s = "", l;
|
|
181
181
|
for (let i of t.children) {
|
|
182
182
|
if (i.type === "Operator" && i.value === ",") {
|
|
183
|
-
e.push(
|
|
183
|
+
e.push(q(s)), s = "", l = i.type;
|
|
184
184
|
continue;
|
|
185
185
|
}
|
|
186
|
-
l === "Identifier" && i.type === "Identifier" && (s += " "), s +=
|
|
186
|
+
l === "Identifier" && i.type === "Identifier" && (s += " "), s += n(i), l = i.type;
|
|
187
187
|
}
|
|
188
|
-
return e.push(
|
|
188
|
+
return e.push(q(s)), e;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
if (
|
|
190
|
+
function a(r) {
|
|
191
|
+
if (r === void 0 || typeof r == "number" && isNaN(r))
|
|
192
192
|
return "0";
|
|
193
|
-
typeof
|
|
193
|
+
typeof r != "string" && (r = r.toString());
|
|
194
194
|
let t = 0;
|
|
195
|
-
for (let
|
|
196
|
-
t = (t << 5) - t +
|
|
195
|
+
for (let n of r)
|
|
196
|
+
t = (t << 5) - t + n.charCodeAt(0), t |= 0;
|
|
197
197
|
return (t >>> 0).toString(16);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
let t =
|
|
199
|
+
function Le(r) {
|
|
200
|
+
let t = $(r, { context: "value" });
|
|
201
201
|
if (t.children === null || t.children.size !== 1) return null;
|
|
202
|
-
let
|
|
203
|
-
switch (
|
|
204
|
-
case "Dimension":
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
let n = t.children.first;
|
|
203
|
+
switch (n.type) {
|
|
204
|
+
case "Dimension": {
|
|
205
|
+
let e = Number(n.value);
|
|
206
|
+
return e === 0 ? 0 : {
|
|
207
|
+
value: e,
|
|
208
|
+
unit: n.unit
|
|
208
209
|
};
|
|
210
|
+
}
|
|
209
211
|
case "Number":
|
|
210
|
-
return Number(
|
|
212
|
+
return Number(n.value);
|
|
211
213
|
case "Percentage":
|
|
212
|
-
return Number(
|
|
214
|
+
return Number(n.value) / 100;
|
|
213
215
|
case "Identifier":
|
|
214
|
-
if (
|
|
216
|
+
if (n.name === "normal")
|
|
215
217
|
return 1.2;
|
|
216
218
|
}
|
|
217
219
|
return null;
|
|
218
220
|
}
|
|
219
|
-
let
|
|
221
|
+
let C = /* @__PURE__ */ new Map([
|
|
220
222
|
["xx-small", 0.6],
|
|
221
223
|
["x-small", 0.75],
|
|
222
224
|
["small", 0.89],
|
|
@@ -226,138 +228,176 @@ let O = /* @__PURE__ */ new Map([
|
|
|
226
228
|
["xx-large", 2],
|
|
227
229
|
["xxx-large", 3]
|
|
228
230
|
]);
|
|
229
|
-
function
|
|
230
|
-
let t =
|
|
231
|
+
function Ee(r) {
|
|
232
|
+
let t = $(r, { context: "value" });
|
|
231
233
|
if (t.children === null || t.children.size !== 1) return null;
|
|
232
|
-
let
|
|
233
|
-
switch (
|
|
234
|
+
let n = t.children.first;
|
|
235
|
+
switch (n.type) {
|
|
234
236
|
case "Dimension": {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
let e = n.unit.toLowerCase();
|
|
238
|
+
if (e === "px" || e === "rem") {
|
|
239
|
+
let s = Number(n.value);
|
|
240
|
+
return s === 0 ? {
|
|
241
|
+
value: 0,
|
|
242
|
+
unit: "px"
|
|
243
|
+
} : {
|
|
244
|
+
value: s,
|
|
245
|
+
unit: e
|
|
239
246
|
};
|
|
247
|
+
}
|
|
240
248
|
break;
|
|
241
249
|
}
|
|
242
250
|
case "Identifier": {
|
|
243
|
-
let e =
|
|
244
|
-
if (
|
|
251
|
+
let e = n.name.toLowerCase();
|
|
252
|
+
if (C.has(e))
|
|
245
253
|
return {
|
|
246
|
-
value:
|
|
254
|
+
value: C.get(e),
|
|
247
255
|
unit: "rem"
|
|
248
256
|
};
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
case "Number": {
|
|
260
|
+
if (Number(n.value) === 0)
|
|
261
|
+
return {
|
|
262
|
+
value: 0,
|
|
263
|
+
unit: "px"
|
|
264
|
+
};
|
|
265
|
+
break;
|
|
249
266
|
}
|
|
250
267
|
}
|
|
251
268
|
return null;
|
|
252
269
|
}
|
|
253
|
-
function
|
|
254
|
-
let t =
|
|
255
|
-
return
|
|
270
|
+
function Re(r) {
|
|
271
|
+
let t = U(r);
|
|
272
|
+
return qe(t);
|
|
256
273
|
}
|
|
257
|
-
function
|
|
258
|
-
return "uniqueWithLocations" in
|
|
274
|
+
function p(r) {
|
|
275
|
+
return "uniqueWithLocations" in r ? r.uniqueWithLocations : r.unique;
|
|
259
276
|
}
|
|
260
|
-
function
|
|
261
|
-
return Array.isArray(
|
|
277
|
+
function m(r) {
|
|
278
|
+
return Array.isArray(r) ? r.length : r;
|
|
262
279
|
}
|
|
263
|
-
function
|
|
280
|
+
function qe(r) {
|
|
264
281
|
return {
|
|
265
282
|
color: (() => {
|
|
266
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
283
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.colors), e = we(n);
|
|
267
284
|
for (let [s, l] of e)
|
|
268
285
|
for (let i of l) {
|
|
269
|
-
let
|
|
270
|
-
if (
|
|
271
|
-
let
|
|
272
|
-
t[
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
let c = g(i), w = m(n[i]);
|
|
287
|
+
if (c !== null) {
|
|
288
|
+
let { colorSpace: k, components: F, alpha: B } = c, h = `${ye.get(s)}-${a([k, ...F, B].join(""))}`, G = r.values.colors.itemsPerContext, S = Object.entries(G).reduce((d, [N, b]) => i in b.unique || b.uniqueWithLocations && i in b.uniqueWithLocations ? d.add(N) : d, /* @__PURE__ */ new Set());
|
|
289
|
+
if (t[h]) {
|
|
290
|
+
let d = t[h].$extensions[x];
|
|
291
|
+
t[h].$extensions[x] = Array.from(new Set(d).union(S)), t[h].$extensions[u] += w;
|
|
292
|
+
} else
|
|
293
|
+
t[h] = {
|
|
294
|
+
$type: "color",
|
|
295
|
+
$value: c,
|
|
296
|
+
$extensions: {
|
|
297
|
+
[f]: i,
|
|
298
|
+
[u]: w,
|
|
299
|
+
[x]: Array.from(S)
|
|
300
|
+
}
|
|
301
|
+
};
|
|
281
302
|
}
|
|
282
303
|
}
|
|
283
304
|
return t;
|
|
284
305
|
})(),
|
|
285
306
|
font_size: (() => {
|
|
286
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
287
|
-
for (let e in
|
|
288
|
-
let s =
|
|
289
|
-
[
|
|
290
|
-
[
|
|
291
|
-
};
|
|
292
|
-
l === null ? t[s] = {
|
|
293
|
-
$value: e,
|
|
294
|
-
$extensions: i
|
|
295
|
-
} : t[s] = {
|
|
296
|
-
$type: "dimension",
|
|
297
|
-
$value: l,
|
|
298
|
-
$extensions: i
|
|
307
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.fontSizes);
|
|
308
|
+
for (let e in n) {
|
|
309
|
+
let s = Ee(e), l = {
|
|
310
|
+
[f]: e,
|
|
311
|
+
[u]: m(n[e])
|
|
299
312
|
};
|
|
313
|
+
if (s === null) {
|
|
314
|
+
let i = `fontSize-${a(e)}`;
|
|
315
|
+
t[i] = {
|
|
316
|
+
$value: e,
|
|
317
|
+
$extensions: l
|
|
318
|
+
};
|
|
319
|
+
} else {
|
|
320
|
+
let i = `fontSize-${a(s.value.toString() + s.unit)}`;
|
|
321
|
+
t[i] ? t[i].$extensions[u] += l[u] : t[i] = {
|
|
322
|
+
$type: "dimension",
|
|
323
|
+
$value: s,
|
|
324
|
+
$extensions: l
|
|
325
|
+
};
|
|
326
|
+
}
|
|
300
327
|
}
|
|
301
328
|
return t;
|
|
302
329
|
})(),
|
|
303
330
|
font_family: (() => {
|
|
304
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
305
|
-
for (let e in
|
|
306
|
-
let s =
|
|
331
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.fontFamilies);
|
|
332
|
+
for (let e in n) {
|
|
333
|
+
let s = Oe(e), l = `fontFamily-${a(e)}`;
|
|
307
334
|
t[l] = {
|
|
308
335
|
$type: "fontFamily",
|
|
309
336
|
$value: s,
|
|
310
337
|
$extensions: {
|
|
311
|
-
[
|
|
312
|
-
[
|
|
338
|
+
[f]: e,
|
|
339
|
+
[u]: m(n[e])
|
|
313
340
|
}
|
|
314
341
|
};
|
|
315
342
|
}
|
|
316
343
|
return t;
|
|
317
344
|
})(),
|
|
318
345
|
line_height: (() => {
|
|
319
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
320
|
-
for (let e in
|
|
321
|
-
let s =
|
|
322
|
-
[
|
|
323
|
-
[
|
|
346
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.lineHeights);
|
|
347
|
+
for (let e in n) {
|
|
348
|
+
let s = Le(e), l = {
|
|
349
|
+
[f]: e,
|
|
350
|
+
[u]: m(n[e])
|
|
324
351
|
};
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
352
|
+
if (s === null) {
|
|
353
|
+
let i = `lineHeight-${a(e)}`;
|
|
354
|
+
t[i] = {
|
|
355
|
+
$value: e,
|
|
356
|
+
$extensions: l
|
|
357
|
+
};
|
|
358
|
+
} else if (typeof s == "number") {
|
|
359
|
+
let i = `lineHeight-${a(s)}`;
|
|
360
|
+
t[i] ? t[i].$extensions[u] += l[u] : t[i] = {
|
|
361
|
+
$type: "number",
|
|
362
|
+
$value: s,
|
|
363
|
+
$extensions: l
|
|
364
|
+
};
|
|
365
|
+
} else if (typeof s == "object")
|
|
366
|
+
if (s.unit === "px" || s.unit === "rem") {
|
|
367
|
+
let i = `lineHeight-${a(s.value.toString() + s.unit)}`;
|
|
368
|
+
t[i] ? t[i].$extensions[u] += l[u] : t[i] = {
|
|
369
|
+
$type: "dimension",
|
|
370
|
+
$value: s,
|
|
371
|
+
$extensions: l
|
|
372
|
+
};
|
|
373
|
+
} else {
|
|
374
|
+
let i = `lineHeight-${a(e)}`;
|
|
375
|
+
t[i] = {
|
|
376
|
+
$value: e,
|
|
377
|
+
$extensions: l
|
|
378
|
+
};
|
|
379
|
+
}
|
|
340
380
|
}
|
|
341
381
|
return t;
|
|
342
382
|
})(),
|
|
343
383
|
gradient: (() => {
|
|
344
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
345
|
-
for (let e in
|
|
346
|
-
t[`gradient-${
|
|
384
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.gradients);
|
|
385
|
+
for (let e in n)
|
|
386
|
+
t[`gradient-${a(e)}`] = {
|
|
347
387
|
$value: e,
|
|
348
388
|
$extensions: {
|
|
349
|
-
[
|
|
350
|
-
[
|
|
389
|
+
[f]: e,
|
|
390
|
+
[u]: m(n[e])
|
|
351
391
|
}
|
|
352
392
|
};
|
|
353
393
|
return t;
|
|
354
394
|
})(),
|
|
355
395
|
box_shadow: (() => {
|
|
356
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
357
|
-
for (let e in
|
|
358
|
-
let s = `boxShadow-${
|
|
359
|
-
[
|
|
360
|
-
[
|
|
396
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.boxShadows);
|
|
397
|
+
for (let e in n) {
|
|
398
|
+
let s = `boxShadow-${a(e)}`, l = Se(e), i = {
|
|
399
|
+
[f]: e,
|
|
400
|
+
[u]: m(n[e])
|
|
361
401
|
};
|
|
362
402
|
l === null ? t[s] = {
|
|
363
403
|
$value: e,
|
|
@@ -371,46 +411,52 @@ function Oe(n) {
|
|
|
371
411
|
return t;
|
|
372
412
|
})(),
|
|
373
413
|
radius: (() => {
|
|
374
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
375
|
-
for (let e in
|
|
376
|
-
let s = `radius-${
|
|
414
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.borderRadiuses);
|
|
415
|
+
for (let e in n) {
|
|
416
|
+
let s = `radius-${a(e)}`;
|
|
377
417
|
t[s] = {
|
|
378
418
|
$value: e,
|
|
379
419
|
$extensions: {
|
|
380
|
-
[
|
|
381
|
-
[
|
|
420
|
+
[f]: e,
|
|
421
|
+
[u]: m(n[e])
|
|
382
422
|
}
|
|
383
423
|
};
|
|
384
424
|
}
|
|
385
425
|
return t;
|
|
386
426
|
})(),
|
|
387
427
|
duration: (() => {
|
|
388
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
389
|
-
for (let e in
|
|
390
|
-
let s =
|
|
391
|
-
[
|
|
392
|
-
[
|
|
393
|
-
};
|
|
394
|
-
l ? t[`duration-${i}`] = {
|
|
395
|
-
$type: "duration",
|
|
396
|
-
$value: {
|
|
397
|
-
value: s,
|
|
398
|
-
unit: "ms"
|
|
399
|
-
},
|
|
400
|
-
$extensions: m
|
|
401
|
-
} : t[`duration-${i}`] = {
|
|
402
|
-
$value: e,
|
|
403
|
-
$extensions: m
|
|
428
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.animations.durations);
|
|
429
|
+
for (let e in n) {
|
|
430
|
+
let s = V(e), l = s < Number.MAX_SAFE_INTEGER - 1, i = {
|
|
431
|
+
[f]: e,
|
|
432
|
+
[u]: m(n[e])
|
|
404
433
|
};
|
|
434
|
+
if (l) {
|
|
435
|
+
let c = `duration-${a(s.toString())}`;
|
|
436
|
+
t[c] ? t[c].$extensions[u] += i[u] : t[c] = {
|
|
437
|
+
$type: "duration",
|
|
438
|
+
$value: {
|
|
439
|
+
value: s,
|
|
440
|
+
unit: "ms"
|
|
441
|
+
},
|
|
442
|
+
$extensions: i
|
|
443
|
+
};
|
|
444
|
+
} else {
|
|
445
|
+
let c = `duration-${a("invalid" + s.toString())}`;
|
|
446
|
+
t[c] = {
|
|
447
|
+
$value: e,
|
|
448
|
+
$extensions: i
|
|
449
|
+
};
|
|
450
|
+
}
|
|
405
451
|
}
|
|
406
452
|
return t;
|
|
407
453
|
})(),
|
|
408
454
|
easing: (() => {
|
|
409
|
-
let t = /* @__PURE__ */ Object.create(null),
|
|
410
|
-
for (let e in
|
|
411
|
-
let s = `easing-${
|
|
412
|
-
[
|
|
413
|
-
[
|
|
455
|
+
let t = /* @__PURE__ */ Object.create(null), n = p(r.values.animations.timingFunctions);
|
|
456
|
+
for (let e in n) {
|
|
457
|
+
let s = `easing-${a(e)}`, l = Ne(e), i = {
|
|
458
|
+
[f]: e,
|
|
459
|
+
[u]: m(n[e])
|
|
414
460
|
};
|
|
415
461
|
l !== null ? t[s] = {
|
|
416
462
|
$value: l,
|
|
@@ -426,6 +472,6 @@ function Oe(n) {
|
|
|
426
472
|
};
|
|
427
473
|
}
|
|
428
474
|
export {
|
|
429
|
-
|
|
430
|
-
|
|
475
|
+
qe as analysis_to_tokens,
|
|
476
|
+
Re as css_to_tokens
|
|
431
477
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectwallace/css-design-tokens",
|
|
3
3
|
"description": "Generate spec-compliant Design Tokens from CSS.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"license": "EUPL-1.2",
|
|
6
6
|
"author": "Bart Veneman <bart@projectwallace.com>",
|
|
7
7
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"default": "./dist/css-design-tokens.js"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
29
|
+
"node": ">=22"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"test": "vitest run",
|