@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.
@@ -1,49 +1,44 @@
1
- import { cssKeywords as Y, colorKeywords as F, namedColors as B, systemColors as G, colorFunctions as T, analyze as W } from "@projectwallace/css-analyzer";
2
- import { convert as k } from "css-time-sort";
3
- import { convert as K } from "color-sorter";
4
- import { parse as d } from "css-tree";
5
- import { ColorSpace as o, sRGB as M, XYZ_D65 as Z, XYZ_D50 as U, XYZ_ABS_D65 as V, Lab_D65 as J, Lab as Q, LCH as ee, sRGB_Linear as te, HSL as re, HWB as ne, HSV as le, P3_Linear as ie, P3 as se, A98RGB_Linear as oe, A98RGB as ue, ProPhoto_Linear as ae, ProPhoto as ce, REC_2020_Linear as fe, REC_2020 as pe, OKLab as me, OKLCH as he, OKLrab as ge, parse as _e } from "colorjs.io/fn";
6
- const N = 0, L = 1, E = 2, b = 3, q = 4, C = 5, j = 6, z = 7, A = 8, I = 9, R = 10, _ = 11, de = /* @__PURE__ */ new Map([
7
- [N, "white"],
8
- [L, "black"],
9
- [E, "grey"],
10
- [b, "red"],
11
- [q, "orange"],
12
- [C, "yellow"],
13
- [j, "green"],
14
- [z, "cyan"],
15
- [A, "blue"],
16
- [I, "magenta"],
17
- [R, "pink"],
18
- [_, "unknown"]
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 ve(n) {
20
+ function we(r) {
21
21
  let t = /* @__PURE__ */ new Map();
22
- for (let r in n) {
23
- let e = _;
24
- if (!r.includes("var(") && !r.includes("calc(")) {
25
- let s = K(r), { hue: l, saturation: i, lightness: m } = s;
26
- i < 10 && m === 100 ? e = N : i < 10 && m === 0 ? e = L : i < 5 ? e = E : l < 22 ? e = b : l < 50 ? e = q : l < 72 ? e = C : l < 144 ? e = j : l < 180 ? e = z : l < 250 ? e = A : l < 300 ? e = I : l < 350 ? e = R : e = b;
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(r) : t.set(e, [r]);
28
+ t.has(e) ? t.get(e).push(n) : t.set(e, [n]);
29
29
  }
30
30
  return Array.from(t).sort(
31
- (r, e) => r[0] === _ || e[0] === _ ? -1 : e[1].length - r[1].length
31
+ (n, e) => n[0] === v || e[0] === v ? -1 : e[1].length - n[1].length
32
32
  );
33
33
  }
34
- const u = "com.projectwallace.css-authored-as", a = "com.projectwallace.usage-count", be = "com.projectwallace.css-properties";
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
- function h(n) {
58
- let t = n.toLowerCase();
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 (Y.has(t) || F.has(t) || t.includes("var("))
65
+ if (T.has(t) || W.has(t) || t.includes("var("))
66
66
  return null;
67
67
  try {
68
- let r = _e(n), [e, s, l] = r.coords;
68
+ let n = xe(r), [e, s, l] = n.coords;
69
69
  return {
70
- colorSpace: r.spaceId,
70
+ colorSpace: n.spaceId,
71
71
  components: [
72
72
  e ?? "none",
73
73
  s ?? "none",
74
74
  l ?? "none"
75
75
  ],
76
- alpha: r.alpha ?? 0
76
+ alpha: n.alpha ?? 0
77
77
  };
78
78
  } catch {
79
79
  return null;
80
80
  }
81
81
  }
82
- function x() {
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 $e(n) {
93
- let t = d(n, {
92
+ function Se(r) {
93
+ let t = $(r, {
94
94
  context: "value",
95
95
  positions: !0
96
96
  });
97
- function r(l) {
98
- return l.loc ? n.slice(l.loc.start.offset, l.loc.end.offset) : "";
97
+ function n(l) {
98
+ return l.loc ? r.slice(l.loc.start.offset, l.loc.end.offset) : "";
99
99
  }
100
- let e = x(), s = [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 (B.has(l.name) || G.has(l.name)) {
106
- let i = h(l.name);
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 (T.has(l.name)) {
122
- let i = h(r(l));
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 = h(r(l));
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 = h(r(l));
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 === "," && (y(e), e = x(), s.push(e));
138
- }), y(e), s);
137
+ } else l.type === "Operator" && l.value === "," && (L(e), e = O(), s.push(e));
138
+ }), L(e), s);
139
139
  }
140
- const g = {
140
+ const _ = {
141
141
  value: 0,
142
142
  unit: "px"
143
143
  };
144
- function y(n) {
145
- return n.offsetX || (n.offsetX = g), n.offsetY || (n.offsetY = g), n.blur || (n.blur = g), n.spread || (n.spread = g), n.color || (n.color = h("#000")), n;
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 w = /* @__PURE__ */ new Map([
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 xe(n) {
155
- if (n = n.trim().toLowerCase(), w.has(n))
156
- return w.get(n);
157
- if (n.includes("var("))
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 (n.startsWith("cubic-bezier(")) {
160
- let t = n.replace("cubic-bezier(", "").replace(")", "").split(",").map((r) => Number(r.trim()));
161
- if (t.length === 4 && t.every((r) => Number.isFinite(r)))
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 S(n) {
167
- return n.replaceAll(/^['"]|['"]$/g, "");
166
+ function q(r) {
167
+ return r.replaceAll(/^['"]|['"]$/g, "");
168
168
  }
169
- function ye(n) {
170
- let t = d(n, {
169
+ function Oe(r) {
170
+ let t = $(r, {
171
171
  context: "value",
172
172
  positions: !0
173
173
  });
174
- function r(i) {
175
- return i.loc ? n.slice(i.loc.start.offset, i.loc.end.offset) : "";
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(S(s)), s = "", l = i.type;
183
+ e.push(q(s)), s = "", l = i.type;
184
184
  continue;
185
185
  }
186
- l === "Identifier" && i.type === "Identifier" && (s += " "), s += r(i), l = i.type;
186
+ l === "Identifier" && i.type === "Identifier" && (s += " "), s += n(i), l = i.type;
187
187
  }
188
- return e.push(S(s)), e;
188
+ return e.push(q(s)), e;
189
189
  }
190
- function c(n) {
191
- if (n === void 0 || typeof n == "number" && isNaN(n))
190
+ function a(r) {
191
+ if (r === void 0 || typeof r == "number" && isNaN(r))
192
192
  return "0";
193
- typeof n != "string" && (n = n.toString());
193
+ typeof r != "string" && (r = r.toString());
194
194
  let t = 0;
195
- for (let r of n)
196
- t = (t << 5) - t + r.charCodeAt(0), t |= 0;
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 we(n) {
200
- let t = d(n, { context: "value" });
199
+ function Le(r) {
200
+ let t = $(r, { context: "value" });
201
201
  if (t.children === null || t.children.size !== 1) return null;
202
- let r = t.children.first;
203
- switch (r.type) {
204
- case "Dimension":
205
- return {
206
- value: Number(r.value),
207
- unit: r.unit
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(r.value);
212
+ return Number(n.value);
211
213
  case "Percentage":
212
- return Number(r.value) / 100;
214
+ return Number(n.value) / 100;
213
215
  case "Identifier":
214
- if (r.name === "normal")
216
+ if (n.name === "normal")
215
217
  return 1.2;
216
218
  }
217
219
  return null;
218
220
  }
219
- let O = /* @__PURE__ */ new Map([
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 Se(n) {
230
- let t = d(n, { context: "value" });
231
+ function Ee(r) {
232
+ let t = $(r, { context: "value" });
231
233
  if (t.children === null || t.children.size !== 1) return null;
232
- let r = t.children.first;
233
- switch (r.type) {
234
+ let n = t.children.first;
235
+ switch (n.type) {
234
236
  case "Dimension": {
235
- if (r.unit === "px" || r.unit === "rem")
236
- return {
237
- value: Number(r.value),
238
- unit: r.unit
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 = r.name.toLowerCase();
244
- if (O.has(e))
251
+ let e = n.name.toLowerCase();
252
+ if (C.has(e))
245
253
  return {
246
- value: O.get(e),
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 je(n) {
254
- let t = W(n);
255
- return Oe(t);
270
+ function Re(r) {
271
+ let t = U(r);
272
+ return qe(t);
256
273
  }
257
- function f(n) {
258
- return "uniqueWithLocations" in n ? n.uniqueWithLocations : n.unique;
274
+ function p(r) {
275
+ return "uniqueWithLocations" in r ? r.uniqueWithLocations : r.unique;
259
276
  }
260
- function p(n) {
261
- return Array.isArray(n) ? n.length : n;
277
+ function m(r) {
278
+ return Array.isArray(r) ? r.length : r;
262
279
  }
263
- function Oe(n) {
280
+ function qe(r) {
264
281
  return {
265
282
  color: (() => {
266
- let t = /* @__PURE__ */ Object.create(null), r = f(n.values.colors), e = ve(r);
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 m = h(i);
270
- if (m !== null) {
271
- let X = `${de.get(s)}-${c(i)}`, D = n.values.colors.itemsPerContext, P = Object.entries(D).reduce(($, [H, v]) => ((i in v.unique || v.uniqueWithLocations && i in v.uniqueWithLocations) && $.push(H), $), []);
272
- t[X] = {
273
- $type: "color",
274
- $value: m,
275
- $extensions: {
276
- [u]: i,
277
- [a]: p(r[i]),
278
- [be]: P
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), r = f(n.values.fontSizes);
287
- for (let e in r) {
288
- let s = `fontSize-${c(e)}`, l = Se(e), i = {
289
- [u]: e,
290
- [a]: p(r[e])
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), r = f(n.values.fontFamilies);
305
- for (let e in r) {
306
- let s = ye(e), l = `fontFamily-${c(e)}`;
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
- [u]: e,
312
- [a]: p(r[e])
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), r = f(n.values.lineHeights);
320
- for (let e in r) {
321
- let s = `lineHeight-${c(e)}`, l = we(e), i = {
322
- [u]: e,
323
- [a]: p(r[e])
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
- l === null ? t[s] = {
326
- $value: e,
327
- $extensions: i
328
- } : typeof l == "number" ? t[s] = {
329
- $type: "number",
330
- $value: l,
331
- $extensions: i
332
- } : typeof l == "object" && (l.unit === "px" || l.unit === "rem" ? t[s] = {
333
- $type: "dimension",
334
- $value: l,
335
- $extensions: i
336
- } : t[s] = {
337
- $value: e,
338
- $extensions: i
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), r = f(n.values.gradients);
345
- for (let e in r)
346
- t[`gradient-${c(e)}`] = {
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
- [u]: e,
350
- [a]: p(r[e])
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), r = f(n.values.boxShadows);
357
- for (let e in r) {
358
- let s = `boxShadow-${c(e)}`, l = $e(e), i = {
359
- [u]: e,
360
- [a]: p(r[e])
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), r = f(n.values.borderRadiuses);
375
- for (let e in r) {
376
- let s = `radius-${c(e)}`;
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
- [u]: e,
381
- [a]: p(r[e])
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), r = f(n.values.animations.durations);
389
- for (let e in r) {
390
- let s = k(e), l = s < Number.MAX_SAFE_INTEGER - 1, i = c(s.toString()), m = {
391
- [u]: e,
392
- [a]: p(r[e])
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), r = f(n.values.animations.timingFunctions);
410
- for (let e in r) {
411
- let s = `easing-${c(e)}`, l = xe(e), i = {
412
- [u]: e,
413
- [a]: p(r[e])
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
- Oe as analysis_to_tokens,
430
- je as css_to_tokens
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.7.1",
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": ">=18"
29
+ "node": ">=22"
30
30
  },
31
31
  "scripts": {
32
32
  "test": "vitest run",