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