tokenami 0.0.77--canary.400.e4d091f.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/LICENSE +21 -0
- package/README.md +3 -0
- package/bin.js +2 -0
- package/dist/cli.cjs +1256 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1227 -0
- package/dist/index.cjs +1172 -0
- package/dist/index.d.cts +526 -0
- package/dist/index.d.ts +526 -0
- package/dist/index.js +1149 -0
- package/package.json +69 -0
- package/stubs/tokenami.config.cjs +175 -0
- package/stubs/tokenami.config.js +175 -0
- package/stubs/tokenami.config.mjs +175 -0
- package/stubs/tokenami.config.ts +175 -0
- package/stubs/tokenami.env-custom.d.ts +9 -0
- package/stubs/tokenami.env.ci.d.ts +8 -0
- package/stubs/tokenami.env.d.ts +7 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,1227 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as Tokenami2 from '@tokenami/config';
|
|
4
|
+
import browserslist from 'browserslist';
|
|
5
|
+
import * as lightning from 'lightningcss';
|
|
6
|
+
import { browserslistToTargets } from 'lightningcss';
|
|
7
|
+
import cac from 'cac';
|
|
8
|
+
import glob from 'fast-glob';
|
|
9
|
+
import inquirer from 'inquirer';
|
|
10
|
+
import * as fs2 from 'fs';
|
|
11
|
+
import * as chokidar from 'chokidar';
|
|
12
|
+
import * as pathe from 'pathe';
|
|
13
|
+
import { stringify } from '@stitches/stringify';
|
|
14
|
+
import createJiti from 'jiti';
|
|
15
|
+
import { transform } from 'sucrase';
|
|
16
|
+
import chalk from 'chalk';
|
|
17
|
+
import * as acorn from 'acorn';
|
|
18
|
+
import * as acornWalk from 'acorn-walk';
|
|
19
|
+
|
|
20
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
21
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
22
|
+
}) : x)(function(x) {
|
|
23
|
+
if (typeof require !== "undefined")
|
|
24
|
+
return require.apply(this, arguments);
|
|
25
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
26
|
+
});
|
|
27
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
28
|
+
var getDirname = () => path.dirname(getFilename());
|
|
29
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
30
|
+
var __filename = /* @__PURE__ */ getFilename();
|
|
31
|
+
|
|
32
|
+
// src/supports.ts
|
|
33
|
+
var supportedLogical = {
|
|
34
|
+
"block-overflow": 1,
|
|
35
|
+
"block-size": 1,
|
|
36
|
+
"border-block": 1,
|
|
37
|
+
"border-block-end": 1,
|
|
38
|
+
"border-block-start": 1,
|
|
39
|
+
"border-block-color": 1,
|
|
40
|
+
"border-block-end-color": 1,
|
|
41
|
+
"border-block-end-style": 1,
|
|
42
|
+
"border-block-end-width": 1,
|
|
43
|
+
"border-block-start-color": 1,
|
|
44
|
+
"border-block-start-style": 1,
|
|
45
|
+
"border-block-start-width": 1,
|
|
46
|
+
"border-block-style": 1,
|
|
47
|
+
"border-block-width": 1,
|
|
48
|
+
"border-inline": 1,
|
|
49
|
+
"border-inline-end": 1,
|
|
50
|
+
"border-inline-start": 1,
|
|
51
|
+
"border-inline-color": 1,
|
|
52
|
+
"border-inline-end-color": 1,
|
|
53
|
+
"border-inline-end-style": 1,
|
|
54
|
+
"border-inline-end-width": 1,
|
|
55
|
+
"border-inline-start-color": 1,
|
|
56
|
+
"border-inline-start-style": 1,
|
|
57
|
+
"border-inline-start-width": 1,
|
|
58
|
+
"border-inline-style": 1,
|
|
59
|
+
"border-inline-width": 1,
|
|
60
|
+
"contain-intrinsic-block-size": 1,
|
|
61
|
+
"contain-intrinsic-inline-size": 1,
|
|
62
|
+
"inline-size": 1,
|
|
63
|
+
"inset-block": 1,
|
|
64
|
+
"inset-block-end": 1,
|
|
65
|
+
"inset-block-start": 1,
|
|
66
|
+
"inset-inline": 1,
|
|
67
|
+
"inset-inline-end": 1,
|
|
68
|
+
"inset-inline-start": 1,
|
|
69
|
+
"margin-block": 1,
|
|
70
|
+
"margin-block-end": 1,
|
|
71
|
+
"margin-block-start": 1,
|
|
72
|
+
"margin-inline": 1,
|
|
73
|
+
"margin-inline-end": 1,
|
|
74
|
+
"margin-inline-start": 1,
|
|
75
|
+
"max-block-size": 1,
|
|
76
|
+
"max-inline-size": 1,
|
|
77
|
+
"min-block-size": 1,
|
|
78
|
+
"min-inline-size": 1,
|
|
79
|
+
"overflow-block": 1,
|
|
80
|
+
"overflow-inline": 1,
|
|
81
|
+
"overscroll-behavior-block": 1,
|
|
82
|
+
"overscroll-behavior-inline": 1,
|
|
83
|
+
"padding-block": 1,
|
|
84
|
+
"padding-block-end": 1,
|
|
85
|
+
"padding-block-start": 1,
|
|
86
|
+
"padding-inline": 1,
|
|
87
|
+
"padding-inline-end": 1,
|
|
88
|
+
"padding-inline-start": 1,
|
|
89
|
+
"scroll-margin-block": 1,
|
|
90
|
+
"scroll-margin-block-end": 1,
|
|
91
|
+
"scroll-margin-block-start": 1,
|
|
92
|
+
"scroll-margin-inline": 1,
|
|
93
|
+
"scroll-margin-inline-end": 1,
|
|
94
|
+
"scroll-margin-inline-start": 1,
|
|
95
|
+
"scroll-padding-block": 1,
|
|
96
|
+
"scroll-padding-block-end": 1,
|
|
97
|
+
"scroll-padding-block-start": 1,
|
|
98
|
+
"scroll-padding-inline": 1,
|
|
99
|
+
"scroll-padding-inline-end": 1,
|
|
100
|
+
"scroll-padding-inline-start": 1
|
|
101
|
+
};
|
|
102
|
+
var supported = {
|
|
103
|
+
all: 1,
|
|
104
|
+
animation: 1,
|
|
105
|
+
"animation-range": 1,
|
|
106
|
+
background: 1,
|
|
107
|
+
"background-position": 1,
|
|
108
|
+
border: 1,
|
|
109
|
+
"border-bottom": 1,
|
|
110
|
+
"border-color": 1,
|
|
111
|
+
"border-image": 1,
|
|
112
|
+
"border-left": 1,
|
|
113
|
+
"border-radius": 1,
|
|
114
|
+
"border-right": 1,
|
|
115
|
+
"border-style": 1,
|
|
116
|
+
"border-top": 1,
|
|
117
|
+
"border-width": 1,
|
|
118
|
+
caret: 1,
|
|
119
|
+
"column-rule": 1,
|
|
120
|
+
columns: 1,
|
|
121
|
+
"contain-intrinsic-size": 1,
|
|
122
|
+
container: 1,
|
|
123
|
+
flex: 1,
|
|
124
|
+
"flex-flow": 1,
|
|
125
|
+
font: 1,
|
|
126
|
+
gap: 1,
|
|
127
|
+
grid: 1,
|
|
128
|
+
"grid-area": 1,
|
|
129
|
+
"grid-column": 1,
|
|
130
|
+
"grid-row": 1,
|
|
131
|
+
"grid-template": 1,
|
|
132
|
+
inset: 1,
|
|
133
|
+
"line-clamp": 1,
|
|
134
|
+
"list-style": 1,
|
|
135
|
+
margin: 1,
|
|
136
|
+
mask: 1,
|
|
137
|
+
"mask-border": 1,
|
|
138
|
+
motion: 1,
|
|
139
|
+
offset: 1,
|
|
140
|
+
outline: 1,
|
|
141
|
+
overflow: 1,
|
|
142
|
+
"overscroll-behavior": 1,
|
|
143
|
+
padding: 1,
|
|
144
|
+
"place-content": 1,
|
|
145
|
+
"place-items": 1,
|
|
146
|
+
"place-self": 1,
|
|
147
|
+
"scroll-margin": 1,
|
|
148
|
+
"scroll-padding": 1,
|
|
149
|
+
"scroll-snap-margin": 1,
|
|
150
|
+
"scroll-timeline": 1,
|
|
151
|
+
"text-decoration": 1,
|
|
152
|
+
"text-emphasis": 1,
|
|
153
|
+
transition: 1,
|
|
154
|
+
"view-timeline": 1,
|
|
155
|
+
"accent-color": 1,
|
|
156
|
+
"align-content": 1,
|
|
157
|
+
"align-items": 1,
|
|
158
|
+
"align-self": 1,
|
|
159
|
+
"align-tracks": 1,
|
|
160
|
+
"animation-composition": 1,
|
|
161
|
+
"animation-delay": 1,
|
|
162
|
+
"animation-direction": 1,
|
|
163
|
+
"animation-duration": 1,
|
|
164
|
+
"animation-fill-mode": 1,
|
|
165
|
+
"animation-iteration-count": 1,
|
|
166
|
+
"animation-name": 1,
|
|
167
|
+
"animation-play-state": 1,
|
|
168
|
+
"animation-range-end": 1,
|
|
169
|
+
"animation-range-start": 1,
|
|
170
|
+
"animation-timeline": 1,
|
|
171
|
+
"animation-timing-function": 1,
|
|
172
|
+
appearance: 1,
|
|
173
|
+
"aspect-ratio": 1,
|
|
174
|
+
"backdrop-filter": 1,
|
|
175
|
+
"backface-visibility": 1,
|
|
176
|
+
"background-attachment": 1,
|
|
177
|
+
"background-blend-mode": 1,
|
|
178
|
+
"background-clip": 1,
|
|
179
|
+
"background-color": 1,
|
|
180
|
+
"background-image": 1,
|
|
181
|
+
"background-origin": 1,
|
|
182
|
+
"background-position-x": 1,
|
|
183
|
+
"background-position-y": 1,
|
|
184
|
+
"background-repeat": 1,
|
|
185
|
+
"background-size": 1,
|
|
186
|
+
"border-bottom-color": 1,
|
|
187
|
+
"border-bottom-left-radius": 1,
|
|
188
|
+
"border-bottom-right-radius": 1,
|
|
189
|
+
"border-bottom-style": 1,
|
|
190
|
+
"border-bottom-width": 1,
|
|
191
|
+
"border-collapse": 1,
|
|
192
|
+
"border-end-end-radius": 1,
|
|
193
|
+
"border-end-start-radius": 1,
|
|
194
|
+
"border-image-outset": 1,
|
|
195
|
+
"border-image-repeat": 1,
|
|
196
|
+
"border-image-slice": 1,
|
|
197
|
+
"border-image-source": 1,
|
|
198
|
+
"border-image-width": 1,
|
|
199
|
+
"border-left-color": 1,
|
|
200
|
+
"border-left-style": 1,
|
|
201
|
+
"border-left-width": 1,
|
|
202
|
+
"border-right-color": 1,
|
|
203
|
+
"border-right-style": 1,
|
|
204
|
+
"border-right-width": 1,
|
|
205
|
+
"border-spacing": 1,
|
|
206
|
+
"border-start-end-radius": 1,
|
|
207
|
+
"border-start-start-radius": 1,
|
|
208
|
+
"border-top-color": 1,
|
|
209
|
+
"border-top-left-radius": 1,
|
|
210
|
+
"border-top-right-radius": 1,
|
|
211
|
+
"border-top-style": 1,
|
|
212
|
+
"border-top-width": 1,
|
|
213
|
+
bottom: 1,
|
|
214
|
+
"box-decoration-break": 1,
|
|
215
|
+
"box-shadow": 1,
|
|
216
|
+
"box-sizing": 1,
|
|
217
|
+
"break-after": 1,
|
|
218
|
+
"break-before": 1,
|
|
219
|
+
"break-inside": 1,
|
|
220
|
+
"caption-side": 1,
|
|
221
|
+
"caret-color": 1,
|
|
222
|
+
"caret-shape": 1,
|
|
223
|
+
clear: 1,
|
|
224
|
+
"clip-path": 1,
|
|
225
|
+
color: 1,
|
|
226
|
+
"color-adjust": 1,
|
|
227
|
+
"color-scheme": 1,
|
|
228
|
+
"column-count": 1,
|
|
229
|
+
"column-fill": 1,
|
|
230
|
+
"column-gap": 1,
|
|
231
|
+
"column-rule-color": 1,
|
|
232
|
+
"column-rule-style": 1,
|
|
233
|
+
"column-rule-width": 1,
|
|
234
|
+
"column-span": 1,
|
|
235
|
+
"column-width": 1,
|
|
236
|
+
contain: 1,
|
|
237
|
+
"contain-intrinsic-height": 1,
|
|
238
|
+
"contain-intrinsic-width": 1,
|
|
239
|
+
"container-name": 1,
|
|
240
|
+
"container-type": 1,
|
|
241
|
+
content: 1,
|
|
242
|
+
"content-visibility": 1,
|
|
243
|
+
"counter-increment": 1,
|
|
244
|
+
"counter-reset": 1,
|
|
245
|
+
"counter-set": 1,
|
|
246
|
+
cursor: 1,
|
|
247
|
+
direction: 1,
|
|
248
|
+
display: 1,
|
|
249
|
+
"empty-cells": 1,
|
|
250
|
+
filter: 1,
|
|
251
|
+
"flex-basis": 1,
|
|
252
|
+
"flex-direction": 1,
|
|
253
|
+
"flex-grow": 1,
|
|
254
|
+
"flex-shrink": 1,
|
|
255
|
+
"flex-wrap": 1,
|
|
256
|
+
float: 1,
|
|
257
|
+
"font-family": 1,
|
|
258
|
+
"font-feature-settings": 1,
|
|
259
|
+
"font-kerning": 1,
|
|
260
|
+
"font-language-override": 1,
|
|
261
|
+
"font-optical-sizing": 1,
|
|
262
|
+
"font-palette": 1,
|
|
263
|
+
"font-size": 1,
|
|
264
|
+
"font-size-adjust": 1,
|
|
265
|
+
"font-smooth": 1,
|
|
266
|
+
"font-stretch": 1,
|
|
267
|
+
"font-style": 1,
|
|
268
|
+
"font-synthesis": 1,
|
|
269
|
+
"font-synthesis-position": 1,
|
|
270
|
+
"font-synthesis-small-caps": 1,
|
|
271
|
+
"font-synthesis-style": 1,
|
|
272
|
+
"font-synthesis-weight": 1,
|
|
273
|
+
"font-variant": 1,
|
|
274
|
+
"font-variant-alternates": 1,
|
|
275
|
+
"font-variant-caps": 1,
|
|
276
|
+
"font-variant-east-asian": 1,
|
|
277
|
+
"font-variant-emoji": 1,
|
|
278
|
+
"font-variant-ligatures": 1,
|
|
279
|
+
"font-variant-numeric": 1,
|
|
280
|
+
"font-variant-position": 1,
|
|
281
|
+
"font-variation-settings": 1,
|
|
282
|
+
"font-weight": 1,
|
|
283
|
+
"forced-color-adjust": 1,
|
|
284
|
+
"grid-auto-columns": 1,
|
|
285
|
+
"grid-auto-flow": 1,
|
|
286
|
+
"grid-auto-rows": 1,
|
|
287
|
+
"grid-column-end": 1,
|
|
288
|
+
"grid-column-start": 1,
|
|
289
|
+
"grid-row-end": 1,
|
|
290
|
+
"grid-row-start": 1,
|
|
291
|
+
"grid-template-areas": 1,
|
|
292
|
+
"grid-template-columns": 1,
|
|
293
|
+
"grid-template-rows": 1,
|
|
294
|
+
"hanging-punctuation": 1,
|
|
295
|
+
height: 1,
|
|
296
|
+
"hyphenate-character": 1,
|
|
297
|
+
"hyphenate-limit-chars": 1,
|
|
298
|
+
hyphens: 1,
|
|
299
|
+
"image-orientation": 1,
|
|
300
|
+
"image-rendering": 1,
|
|
301
|
+
"image-resolution": 1,
|
|
302
|
+
"initial-letter": 1,
|
|
303
|
+
"input-security": 1,
|
|
304
|
+
isolation: 1,
|
|
305
|
+
"justify-content": 1,
|
|
306
|
+
"justify-items": 1,
|
|
307
|
+
"justify-self": 1,
|
|
308
|
+
"justify-tracks": 1,
|
|
309
|
+
left: 1,
|
|
310
|
+
"letter-spacing": 1,
|
|
311
|
+
"line-break": 1,
|
|
312
|
+
"line-height": 1,
|
|
313
|
+
"line-height-step": 1,
|
|
314
|
+
"list-style-image": 1,
|
|
315
|
+
"list-style-position": 1,
|
|
316
|
+
"list-style-type": 1,
|
|
317
|
+
"margin-bottom": 1,
|
|
318
|
+
"margin-left": 1,
|
|
319
|
+
"margin-right": 1,
|
|
320
|
+
"margin-top": 1,
|
|
321
|
+
"margin-trim": 1,
|
|
322
|
+
"mask-border-mode": 1,
|
|
323
|
+
"mask-border-outset": 1,
|
|
324
|
+
"mask-border-repeat": 1,
|
|
325
|
+
"mask-border-slice": 1,
|
|
326
|
+
"mask-border-source": 1,
|
|
327
|
+
"mask-border-width": 1,
|
|
328
|
+
"mask-clip": 1,
|
|
329
|
+
"mask-composite": 1,
|
|
330
|
+
"mask-image": 1,
|
|
331
|
+
"mask-mode": 1,
|
|
332
|
+
"mask-origin": 1,
|
|
333
|
+
"mask-position": 1,
|
|
334
|
+
"mask-repeat": 1,
|
|
335
|
+
"mask-size": 1,
|
|
336
|
+
"mask-type": 1,
|
|
337
|
+
"masonry-auto-flow": 1,
|
|
338
|
+
"math-depth": 1,
|
|
339
|
+
"math-shift": 1,
|
|
340
|
+
"math-style": 1,
|
|
341
|
+
"max-height": 1,
|
|
342
|
+
"max-lines": 1,
|
|
343
|
+
"max-width": 1,
|
|
344
|
+
"min-height": 1,
|
|
345
|
+
"min-width": 1,
|
|
346
|
+
"mix-blend-mode": 1,
|
|
347
|
+
"motion-distance": 1,
|
|
348
|
+
"motion-path": 1,
|
|
349
|
+
"motion-rotation": 1,
|
|
350
|
+
"object-fit": 1,
|
|
351
|
+
"object-position": 1,
|
|
352
|
+
"offset-anchor": 1,
|
|
353
|
+
"offset-distance": 1,
|
|
354
|
+
"offset-path": 1,
|
|
355
|
+
"offset-position": 1,
|
|
356
|
+
"offset-rotate": 1,
|
|
357
|
+
"offset-rotation": 1,
|
|
358
|
+
opacity: 1,
|
|
359
|
+
order: 1,
|
|
360
|
+
orphans: 1,
|
|
361
|
+
"outline-color": 1,
|
|
362
|
+
"outline-offset": 1,
|
|
363
|
+
"outline-style": 1,
|
|
364
|
+
"outline-width": 1,
|
|
365
|
+
"overflow-anchor": 1,
|
|
366
|
+
"overflow-clip-box": 1,
|
|
367
|
+
"overflow-clip-margin": 1,
|
|
368
|
+
"overflow-wrap": 1,
|
|
369
|
+
"overflow-x": 1,
|
|
370
|
+
"overflow-y": 1,
|
|
371
|
+
overlay: 1,
|
|
372
|
+
"overscroll-behavior-x": 1,
|
|
373
|
+
"overscroll-behavior-y": 1,
|
|
374
|
+
"padding-bottom": 1,
|
|
375
|
+
"padding-left": 1,
|
|
376
|
+
"padding-right": 1,
|
|
377
|
+
"padding-top": 1,
|
|
378
|
+
page: 1,
|
|
379
|
+
"page-break-after": 1,
|
|
380
|
+
"page-break-before": 1,
|
|
381
|
+
"page-break-inside": 1,
|
|
382
|
+
"paint-order": 1,
|
|
383
|
+
perspective: 1,
|
|
384
|
+
"perspective-origin": 1,
|
|
385
|
+
"pointer-events": 1,
|
|
386
|
+
position: 1,
|
|
387
|
+
"print-color-adjust": 1,
|
|
388
|
+
quotes: 1,
|
|
389
|
+
resize: 1,
|
|
390
|
+
right: 1,
|
|
391
|
+
rotate: 1,
|
|
392
|
+
"row-gap": 1,
|
|
393
|
+
"ruby-align": 1,
|
|
394
|
+
"ruby-merge": 1,
|
|
395
|
+
"ruby-position": 1,
|
|
396
|
+
scale: 1,
|
|
397
|
+
"scroll-behavior": 1,
|
|
398
|
+
"scroll-margin-bottom": 1,
|
|
399
|
+
"scroll-margin-left": 1,
|
|
400
|
+
"scroll-margin-right": 1,
|
|
401
|
+
"scroll-margin-top": 1,
|
|
402
|
+
"scroll-padding-bottom": 1,
|
|
403
|
+
"scroll-padding-left": 1,
|
|
404
|
+
"scroll-padding-right": 1,
|
|
405
|
+
"scroll-padding-top": 1,
|
|
406
|
+
"scroll-snap-align": 1,
|
|
407
|
+
"scroll-snap-margin-bottom": 1,
|
|
408
|
+
"scroll-snap-margin-left": 1,
|
|
409
|
+
"scroll-snap-margin-right": 1,
|
|
410
|
+
"scroll-snap-margin-top": 1,
|
|
411
|
+
"scroll-snap-stop": 1,
|
|
412
|
+
"scroll-snap-type": 1,
|
|
413
|
+
"scroll-timeline-axis": 1,
|
|
414
|
+
"scroll-timeline-name": 1,
|
|
415
|
+
"scrollbar-color": 1,
|
|
416
|
+
"scrollbar-gutter": 1,
|
|
417
|
+
"scrollbar-width": 1,
|
|
418
|
+
"shape-image-threshold": 1,
|
|
419
|
+
"shape-margin": 1,
|
|
420
|
+
"shape-outside": 1,
|
|
421
|
+
"tab-size": 1,
|
|
422
|
+
"table-layout": 1,
|
|
423
|
+
"text-align": 1,
|
|
424
|
+
"text-align-last": 1,
|
|
425
|
+
"text-combine-upright": 1,
|
|
426
|
+
"text-decoration-color": 1,
|
|
427
|
+
"text-decoration-line": 1,
|
|
428
|
+
"text-decoration-skip": 1,
|
|
429
|
+
"text-decoration-skip-ink": 1,
|
|
430
|
+
"text-decoration-style": 1,
|
|
431
|
+
"text-decoration-thickness": 1,
|
|
432
|
+
"text-emphasis-color": 1,
|
|
433
|
+
"text-emphasis-position": 1,
|
|
434
|
+
"text-emphasis-style": 1,
|
|
435
|
+
"text-indent": 1,
|
|
436
|
+
"text-justify": 1,
|
|
437
|
+
"text-orientation": 1,
|
|
438
|
+
"text-overflow": 1,
|
|
439
|
+
"text-rendering": 1,
|
|
440
|
+
"text-shadow": 1,
|
|
441
|
+
"text-size-adjust": 1,
|
|
442
|
+
"text-transform": 1,
|
|
443
|
+
"text-underline-offset": 1,
|
|
444
|
+
"text-underline-position": 1,
|
|
445
|
+
"text-wrap": 1,
|
|
446
|
+
"timeline-scope": 1,
|
|
447
|
+
top: 1,
|
|
448
|
+
"touch-action": 1,
|
|
449
|
+
transform: 1,
|
|
450
|
+
"transform-box": 1,
|
|
451
|
+
"transform-origin": 1,
|
|
452
|
+
"transform-style": 1,
|
|
453
|
+
"transition-behavior": 1,
|
|
454
|
+
"transition-delay": 1,
|
|
455
|
+
"transition-duration": 1,
|
|
456
|
+
"transition-property": 1,
|
|
457
|
+
"transition-timing-function": 1,
|
|
458
|
+
translate: 1,
|
|
459
|
+
"unicode-bidi": 1,
|
|
460
|
+
"user-select": 1,
|
|
461
|
+
"vertical-align": 1,
|
|
462
|
+
"view-timeline-axis": 1,
|
|
463
|
+
"view-timeline-inset": 1,
|
|
464
|
+
"view-timeline-name": 1,
|
|
465
|
+
"view-transition-name": 1,
|
|
466
|
+
visibility: 1,
|
|
467
|
+
"white-space": 1,
|
|
468
|
+
"white-space-collapse": 1,
|
|
469
|
+
"white-space-trim": 1,
|
|
470
|
+
widows: 1,
|
|
471
|
+
width: 1,
|
|
472
|
+
"will-change": 1,
|
|
473
|
+
"word-break": 1,
|
|
474
|
+
"word-spacing": 1,
|
|
475
|
+
"word-wrap": 1,
|
|
476
|
+
"writing-mode": 1,
|
|
477
|
+
"z-index": 1,
|
|
478
|
+
zoom: 1,
|
|
479
|
+
"alignment-baseline": 1,
|
|
480
|
+
"baseline-shift": 1,
|
|
481
|
+
clip: 1,
|
|
482
|
+
"clip-rule": 1,
|
|
483
|
+
"color-interpolation": 1,
|
|
484
|
+
"color-rendering": 1,
|
|
485
|
+
"dominant-baseline": 1,
|
|
486
|
+
fill: 1,
|
|
487
|
+
"fill-opacity": 1,
|
|
488
|
+
"fill-rule": 1,
|
|
489
|
+
"flood-color": 1,
|
|
490
|
+
"flood-opacity": 1,
|
|
491
|
+
"glyph-orientation-vertical": 1,
|
|
492
|
+
"lighting-color": 1,
|
|
493
|
+
marker: 1,
|
|
494
|
+
"marker-end": 1,
|
|
495
|
+
"marker-mid": 1,
|
|
496
|
+
"marker-start": 1,
|
|
497
|
+
"shape-rendering": 1,
|
|
498
|
+
"stop-color": 1,
|
|
499
|
+
"stop-opacity": 1,
|
|
500
|
+
stroke: 1,
|
|
501
|
+
"stroke-dasharray": 1,
|
|
502
|
+
"stroke-dashoffset": 1,
|
|
503
|
+
"stroke-linecap": 1,
|
|
504
|
+
"stroke-linejoin": 1,
|
|
505
|
+
"stroke-miterlimit": 1,
|
|
506
|
+
"stroke-opacity": 1,
|
|
507
|
+
"stroke-width": 1,
|
|
508
|
+
"text-anchor": 1,
|
|
509
|
+
"vector-effect": 1,
|
|
510
|
+
...supportedLogical
|
|
511
|
+
};
|
|
512
|
+
var inheritedProperties = /* @__PURE__ */ new Set([
|
|
513
|
+
"azimuth",
|
|
514
|
+
"border-collapse",
|
|
515
|
+
"border-spacing",
|
|
516
|
+
"caption-side",
|
|
517
|
+
"color",
|
|
518
|
+
"cursor",
|
|
519
|
+
"direction",
|
|
520
|
+
"empty-cells",
|
|
521
|
+
"font-family",
|
|
522
|
+
"font-size",
|
|
523
|
+
"font-style",
|
|
524
|
+
"font-variant",
|
|
525
|
+
"font-weight",
|
|
526
|
+
"font-stretch",
|
|
527
|
+
"font",
|
|
528
|
+
"letter-spacing",
|
|
529
|
+
"line-height",
|
|
530
|
+
"list-style-image",
|
|
531
|
+
"list-style-position",
|
|
532
|
+
"list-style-type",
|
|
533
|
+
"list-style",
|
|
534
|
+
"orphans",
|
|
535
|
+
"quotes",
|
|
536
|
+
"text-align",
|
|
537
|
+
"text-indent",
|
|
538
|
+
"text-transform",
|
|
539
|
+
"visibility",
|
|
540
|
+
"white-space",
|
|
541
|
+
"widows",
|
|
542
|
+
"word-spacing"
|
|
543
|
+
]);
|
|
544
|
+
var supportedProperties = new Set(Object.keys(supported));
|
|
545
|
+
var supportedLogicalProperties = new Set(Object.keys(supportedLogical));
|
|
546
|
+
|
|
547
|
+
// src/utils.ts
|
|
548
|
+
var DEFAULT_PATHS = {
|
|
549
|
+
js: "./.tokenami/tokenami.config.js",
|
|
550
|
+
ts: "./.tokenami/tokenami.config.ts",
|
|
551
|
+
cjs: "./.tokenami/tokenami.config.cjs",
|
|
552
|
+
mjs: "./.tokenami/tokenami.config.mjs"
|
|
553
|
+
};
|
|
554
|
+
function getConfigPath(cwd, path2, type) {
|
|
555
|
+
path2 = path2 || getConfigDefaultPath(cwd, type);
|
|
556
|
+
return pathe.join(cwd, path2);
|
|
557
|
+
}
|
|
558
|
+
function getConfigAtPath(path2) {
|
|
559
|
+
const config = function() {
|
|
560
|
+
try {
|
|
561
|
+
return __require(path2);
|
|
562
|
+
} catch {
|
|
563
|
+
return lazyJiti()(path2);
|
|
564
|
+
}
|
|
565
|
+
}();
|
|
566
|
+
return mergedConfigs(config.default ?? config);
|
|
567
|
+
}
|
|
568
|
+
function getReloadedConfigAtPath(path2) {
|
|
569
|
+
const config = function() {
|
|
570
|
+
try {
|
|
571
|
+
delete __require.cache[__require.resolve(path2)];
|
|
572
|
+
return __require(path2);
|
|
573
|
+
} catch {
|
|
574
|
+
return lazyJiti({ cache: false })(path2);
|
|
575
|
+
}
|
|
576
|
+
}();
|
|
577
|
+
return mergedConfigs(config.default ?? config);
|
|
578
|
+
}
|
|
579
|
+
function getConfigDefaultPath(cwd, type) {
|
|
580
|
+
const existingConfig = Object.values(DEFAULT_PATHS).find((path2) => {
|
|
581
|
+
return fs2.existsSync(pathe.join(cwd, path2));
|
|
582
|
+
});
|
|
583
|
+
return existingConfig || DEFAULT_PATHS[type || "js"];
|
|
584
|
+
}
|
|
585
|
+
function getTypeDefsPath(configPath) {
|
|
586
|
+
const dirname3 = pathe.dirname(configPath);
|
|
587
|
+
return `${dirname3}/tokenami.env.d.ts`;
|
|
588
|
+
}
|
|
589
|
+
function getCiTypeDefsPath(configPath) {
|
|
590
|
+
const dirname3 = pathe.dirname(configPath);
|
|
591
|
+
return `${dirname3}/tokenami.env.ci.d.ts`;
|
|
592
|
+
}
|
|
593
|
+
function getThemeValuesByTokenValues(tokenValues, theme) {
|
|
594
|
+
const entries = getThemeValueByTokenValueEntries(tokenValues, theme);
|
|
595
|
+
return Object.fromEntries(entries);
|
|
596
|
+
}
|
|
597
|
+
function getThemeValueByTokenValueEntries(tokenValues, theme) {
|
|
598
|
+
const sorted = [...tokenValues].sort();
|
|
599
|
+
return sorted.flatMap((tokenValue) => {
|
|
600
|
+
const parts = Tokenami2.getTokenValueParts(tokenValue);
|
|
601
|
+
const value = theme[parts.themeKey]?.[parts.token];
|
|
602
|
+
if (value == null)
|
|
603
|
+
return [];
|
|
604
|
+
const valueString = String(value);
|
|
605
|
+
const tokenValues2 = findTokenValuesInThemeValue(valueString);
|
|
606
|
+
const themeValuesEntries = getThemeValueByTokenValueEntries(tokenValues2, theme);
|
|
607
|
+
return [[parts.property, valueString], ...themeValuesEntries];
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
function findTokenValuesInThemeValue(themeValue) {
|
|
611
|
+
const cssVariables = themeValue.match(/var\([\w-_]+\)/g) || [];
|
|
612
|
+
const tokenValues = cssVariables.filter((v) => Tokenami2.TokenValue.safeParse(v).success);
|
|
613
|
+
return tokenValues;
|
|
614
|
+
}
|
|
615
|
+
function getThemeFromConfig(themeConfig) {
|
|
616
|
+
const { modes = {}, root, ...base } = themeConfig;
|
|
617
|
+
if ("modes" in themeConfig) {
|
|
618
|
+
const config = themeConfig;
|
|
619
|
+
return { modes: config.modes, root: config.root };
|
|
620
|
+
}
|
|
621
|
+
return { modes: {}, root: base };
|
|
622
|
+
}
|
|
623
|
+
function getThemeValuesByThemeMode(tokenValue, themeConfig) {
|
|
624
|
+
const theme = getThemeFromConfig(themeConfig);
|
|
625
|
+
const parts = Tokenami2.getTokenValueParts(tokenValue);
|
|
626
|
+
const modeThemeEntries = Object.entries(theme.modes);
|
|
627
|
+
const modeValues = modeThemeEntries.concat([["root", theme.root]]).flatMap(([mode, theme2]) => {
|
|
628
|
+
const value = theme2[parts.themeKey]?.[parts.token];
|
|
629
|
+
return value == null ? [] : [[mode, String(value)]];
|
|
630
|
+
});
|
|
631
|
+
return Object.fromEntries(modeValues);
|
|
632
|
+
}
|
|
633
|
+
function generateConfig(include, configPath) {
|
|
634
|
+
const filename = pathe.basename(configPath);
|
|
635
|
+
const configStubPath = pathe.resolve(__dirname, `../stubs/${filename}`);
|
|
636
|
+
const configStub = fs2.readFileSync(configStubPath, "utf8");
|
|
637
|
+
return configStub.replace("include: []", `include: [${include}]`);
|
|
638
|
+
}
|
|
639
|
+
function mergedConfigs(theirs) {
|
|
640
|
+
return theirs;
|
|
641
|
+
}
|
|
642
|
+
function generateTypeDefs(configPath, stubPath = "../stubs/tokenami.env.d.ts") {
|
|
643
|
+
const parsed = pathe.parse(configPath);
|
|
644
|
+
const typeDefStubPath = pathe.resolve(__dirname, stubPath);
|
|
645
|
+
const typeDefStub = fs2.readFileSync(typeDefStubPath, "utf8");
|
|
646
|
+
return typeDefStub.replace("tokenami.config", parsed.name);
|
|
647
|
+
}
|
|
648
|
+
function generateCiTypeDefs(configPath) {
|
|
649
|
+
return generateTypeDefs(configPath, "../stubs/tokenami.env.ci.d.ts");
|
|
650
|
+
}
|
|
651
|
+
function getResponsivePropertyVariants(tokenProperty2, responsive) {
|
|
652
|
+
return Object.keys(responsive || {}).map((query) => {
|
|
653
|
+
const name = Tokenami2.getTokenPropertyName(tokenProperty2);
|
|
654
|
+
return Tokenami2.variantProperty(query, name);
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function getValidProperties(config) {
|
|
658
|
+
return /* @__PURE__ */ new Set([
|
|
659
|
+
...supportedProperties,
|
|
660
|
+
...Object.keys(config.properties || {}),
|
|
661
|
+
...Object.keys(config.customProperties || {}),
|
|
662
|
+
...Object.keys(config.aliases || {})
|
|
663
|
+
]);
|
|
664
|
+
}
|
|
665
|
+
function unique(items) {
|
|
666
|
+
return Array.from(new Set(items));
|
|
667
|
+
}
|
|
668
|
+
var jitiCache = {};
|
|
669
|
+
function lazyJiti(options = {}) {
|
|
670
|
+
const cacheId = JSON.stringify(options);
|
|
671
|
+
return jitiCache[cacheId] ??= createJiti(__filename, {
|
|
672
|
+
transform: (opts) => transform(opts.source, { transforms: ["typescript", "imports"] }),
|
|
673
|
+
interopDefault: true,
|
|
674
|
+
requireCache: options.cache
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
function error(str) {
|
|
678
|
+
console.error(`${chalk.bgRed(" tokenami ")} ${chalk.red(str)}`);
|
|
679
|
+
process.exit(1);
|
|
680
|
+
}
|
|
681
|
+
function debug(str) {
|
|
682
|
+
console.debug(`${chalk.bgYellow(" tokenami ")} ${chalk.yellow(str)}`);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// src/sheet.ts
|
|
686
|
+
var UNUSED_LAYERS_REGEX = /[\n\s]*@layer[^;{]+;/g;
|
|
687
|
+
var DEFAULT_SELECTOR = "[style]";
|
|
688
|
+
var CUSTOM_PROP_PREFIX = "--_";
|
|
689
|
+
var LAYERS = {
|
|
690
|
+
BASE: "tk",
|
|
691
|
+
LOGICAL: "tkl",
|
|
692
|
+
SELECTORS: "tks",
|
|
693
|
+
SELECTORS_LOGICAL: "tksl"
|
|
694
|
+
};
|
|
695
|
+
function generate(params) {
|
|
696
|
+
try {
|
|
697
|
+
const sheet = createSheet(params);
|
|
698
|
+
const transformed = lightning.transform({
|
|
699
|
+
code: Buffer.from(sheet),
|
|
700
|
+
filename: params.output,
|
|
701
|
+
minify: params.minify,
|
|
702
|
+
targets: params.targets
|
|
703
|
+
});
|
|
704
|
+
return transformed.code.toString().replace(UNUSED_LAYERS_REGEX, "");
|
|
705
|
+
} catch (e) {
|
|
706
|
+
const message = e instanceof Error ? e.message : "Unknown error";
|
|
707
|
+
const escapedMessage = message.replace(/(['"])/g, "\\$1");
|
|
708
|
+
debug(`Error generating stylesheet: ${message}`);
|
|
709
|
+
return `body::after { content: 'Error generating stylesheet: ${escapedMessage}'; position: fixed; inset: 0; background: #ec6142; color: white; padding: 20px; font-family: sans-serif; z-index: 9999; }`;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function createSheet(params) {
|
|
713
|
+
if (!params.tokens.properties.length)
|
|
714
|
+
return "";
|
|
715
|
+
const tokenProperties = params.tokens.properties;
|
|
716
|
+
const tokenValues = params.tokens.values;
|
|
717
|
+
const propertyConfigsByCSSProperty = getPropertyConfigs(tokenProperties, params.config);
|
|
718
|
+
const allPropertyConfigs = Array.from(propertyConfigsByCSSProperty.values()).flat();
|
|
719
|
+
const elemSelectors = unique(
|
|
720
|
+
allPropertyConfigs.map((config) => {
|
|
721
|
+
const selectors = getSelectorsFromConfig(config.selector, params.config);
|
|
722
|
+
return selectors.find(isElementSelector) || DEFAULT_SELECTOR;
|
|
723
|
+
})
|
|
724
|
+
);
|
|
725
|
+
const styles = {
|
|
726
|
+
reset: /* @__PURE__ */ new Set(),
|
|
727
|
+
atomic: /* @__PURE__ */ new Set(),
|
|
728
|
+
selectors: /* @__PURE__ */ new Set(),
|
|
729
|
+
toggles: {}
|
|
730
|
+
};
|
|
731
|
+
propertyConfigsByCSSProperty.forEach((configs, cssProperty) => {
|
|
732
|
+
const isLogical = supportedLogicalProperties.has(cssProperty);
|
|
733
|
+
const isInheritable = inheritedProperties.has(cssProperty);
|
|
734
|
+
const sortedConfigs = [...configs].sort((a, b) => a.order - b.order);
|
|
735
|
+
const variants = sortedConfigs.flatMap((config) => config.variant ? [config.variant] : []);
|
|
736
|
+
const variantValue = unique(variants).reduce((fallback, variant) => {
|
|
737
|
+
const hashedProperty = hashVariantProperty(variant, cssProperty);
|
|
738
|
+
return `var(${hashedProperty}, ${fallback})`;
|
|
739
|
+
}, "revert-layer");
|
|
740
|
+
configs.forEach((config) => {
|
|
741
|
+
const layerIndex = getAtomicLayerIndex(cssProperty, params.config);
|
|
742
|
+
const toggleKey = config.responsive || config.selector;
|
|
743
|
+
const propertyPrefix = config.isCustom ? CUSTOM_PROP_PREFIX : "";
|
|
744
|
+
if (layerIndex === -1)
|
|
745
|
+
return;
|
|
746
|
+
if (config.variant && toggleKey) {
|
|
747
|
+
const responsive = getResponsiveSelectorFromConfig(config.responsive, params.config);
|
|
748
|
+
const selectors = getSelectorsFromConfig(config.selector, params.config);
|
|
749
|
+
const hasCombinator = selectors.some(isCombinatorSelector);
|
|
750
|
+
const responsiveSelectors = [responsive, ...selectors].filter(Boolean);
|
|
751
|
+
const hashedProperty = hashVariantProperty(config.variant, cssProperty);
|
|
752
|
+
const variantProperty2 = Tokenami2.parsedVariantProperty(config.variant, cssProperty);
|
|
753
|
+
const basePropertyValue = getBasePropertyValue(variantProperty2, config, false);
|
|
754
|
+
const toggleProperty = Tokenami2.parsedTokenProperty(config.variant);
|
|
755
|
+
const toggleDeclaration = `${hashedProperty}: var(${toggleProperty}) ${basePropertyValue};`;
|
|
756
|
+
const layer = `${isLogical ? LAYERS.SELECTORS_LOGICAL : LAYERS.SELECTORS}${layerIndex}`;
|
|
757
|
+
const customPropertyFallback = `var(${Tokenami2.tokenProperty(cssProperty)})`;
|
|
758
|
+
const customPropertyValue = variantValue.replace("revert-layer", customPropertyFallback);
|
|
759
|
+
const declaration = `${propertyPrefix}${cssProperty}: ${config.isCustom ? customPropertyValue : variantValue};`;
|
|
760
|
+
const toggle = responsiveSelectors.reduceRight(
|
|
761
|
+
(declaration2, selector) => `${selector} { ${declaration2} }`,
|
|
762
|
+
`${toggleProperty}: ;`
|
|
763
|
+
);
|
|
764
|
+
styles.reset.add(`${toggleProperty}: initial;`);
|
|
765
|
+
if (!isInheritable && !hasCombinator)
|
|
766
|
+
styles.reset.add(`${variantProperty2}: initial;`);
|
|
767
|
+
styles.selectors.add(`@layer ${layer} { ${elemSelectors} { ${declaration} } }`);
|
|
768
|
+
styles.selectors.add(`@layer ${layer} { ${elemSelectors} { ${toggleDeclaration} } }`);
|
|
769
|
+
styles.toggles[toggleKey] ??= /* @__PURE__ */ new Set();
|
|
770
|
+
styles.toggles[toggleKey].add(toggle);
|
|
771
|
+
if (config.isGrid) {
|
|
772
|
+
const gridToggle = getGridPropertyToggle(variantProperty2);
|
|
773
|
+
styles.selectors.add(`@layer ${layer} { ${elemSelectors} { ${gridToggle} } }`);
|
|
774
|
+
}
|
|
775
|
+
} else {
|
|
776
|
+
const propertyValue = getBasePropertyValue(config.tokenProperty, config);
|
|
777
|
+
const declaration = `${DEFAULT_SELECTOR} { ${propertyPrefix}${cssProperty}: ${propertyValue}; }`;
|
|
778
|
+
const layer = `${isLogical ? LAYERS.LOGICAL : LAYERS.BASE}${layerIndex}`;
|
|
779
|
+
if (!isInheritable)
|
|
780
|
+
styles.reset.add(`${config.tokenProperty}: initial;`);
|
|
781
|
+
styles.atomic.add(`@layer ${layer} { ${declaration} }`);
|
|
782
|
+
if (config.isGrid) {
|
|
783
|
+
const gridToggle = getGridPropertyToggle(config.tokenProperty);
|
|
784
|
+
styles.atomic.add(`@layer ${layer} { ${DEFAULT_SELECTOR} { ${gridToggle} } }`);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
return `
|
|
790
|
+
@layer global {
|
|
791
|
+
${params.config.globalStyles ? stringify(params.config.globalStyles) : ""}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
@layer tokenami {
|
|
795
|
+
${generateKeyframeRules(tokenValues, params.config)}
|
|
796
|
+
${generateThemeTokens(tokenValues, params.config)}
|
|
797
|
+
|
|
798
|
+
* { ${Array.from(styles.reset).join(" ")} }
|
|
799
|
+
|
|
800
|
+
${generatePlaceholderLayers(LAYERS.BASE)}
|
|
801
|
+
${generatePlaceholderLayers(LAYERS.LOGICAL)}
|
|
802
|
+
${generatePlaceholderLayers(LAYERS.SELECTORS)}
|
|
803
|
+
${generatePlaceholderLayers(LAYERS.SELECTORS_LOGICAL)}
|
|
804
|
+
|
|
805
|
+
${Array.from(styles.atomic).join(" ")}
|
|
806
|
+
${Array.from(styles.selectors).join(" ")}
|
|
807
|
+
|
|
808
|
+
${Object.values(styles.toggles).flatMap((set) => Array.from(set)).join(" ")}
|
|
809
|
+
}
|
|
810
|
+
`;
|
|
811
|
+
}
|
|
812
|
+
function getGridPropertyToggle(property) {
|
|
813
|
+
const hashGridProperty = hashVariantProperty("grid", property);
|
|
814
|
+
const gridProperty3 = Tokenami2.gridProperty();
|
|
815
|
+
return `${hashGridProperty}: var(${property}__calc) calc(var(${property}) * var(${gridProperty3}));`;
|
|
816
|
+
}
|
|
817
|
+
function getBasePropertyValue(property, config, revert = true) {
|
|
818
|
+
const hashGridProperty = hashVariantProperty("grid", property);
|
|
819
|
+
const baseProperty = `var(${property}${revert ? ", revert-layer" : ""})`;
|
|
820
|
+
return config.isGrid ? `var(${hashGridProperty}, ${baseProperty})` : baseProperty;
|
|
821
|
+
}
|
|
822
|
+
function generatePlaceholderLayers(prefix) {
|
|
823
|
+
return `@layer ${Array.from({ length: 20 }).map((_, layer) => `${prefix}${layer}`).join(", ")};`;
|
|
824
|
+
}
|
|
825
|
+
function getPropertyConfigs(tokenProperties, config) {
|
|
826
|
+
let propertyConfigs = /* @__PURE__ */ new Map();
|
|
827
|
+
const customProperties = Object.keys(config.customProperties || {});
|
|
828
|
+
tokenProperties.forEach((tokenProperty2) => {
|
|
829
|
+
const parts = Tokenami2.getTokenPropertyParts(tokenProperty2, config);
|
|
830
|
+
if (!parts)
|
|
831
|
+
return;
|
|
832
|
+
const properties = Tokenami2.getCSSPropertiesForAlias(parts.alias, config.aliases);
|
|
833
|
+
const responsiveOrder = parts.responsive ? 1 : 0;
|
|
834
|
+
const selectorOrder = parts.selector ? 2 : 0;
|
|
835
|
+
const order = responsiveOrder + selectorOrder;
|
|
836
|
+
properties.forEach((cssProperty) => {
|
|
837
|
+
const tokenProperty3 = Tokenami2.parsedTokenProperty(cssProperty);
|
|
838
|
+
const currentConfigs = propertyConfigs.get(cssProperty) || [];
|
|
839
|
+
const isCustom = customProperties.includes(cssProperty);
|
|
840
|
+
const isGrid = config.properties?.[cssProperty]?.includes("grid") ?? false;
|
|
841
|
+
const nextConfig = { ...parts, tokenProperty: tokenProperty3, order, isCustom, isGrid };
|
|
842
|
+
propertyConfigs.set(cssProperty, [...currentConfigs, nextConfig]);
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
return propertyConfigs;
|
|
846
|
+
}
|
|
847
|
+
var SHORTHAND_TO_LONGHAND_ENTRIES = [...Tokenami2.mapShorthandToLonghands.entries()];
|
|
848
|
+
function getAtomicLayerIndex(cssProperty, config) {
|
|
849
|
+
const validProperties = getValidProperties(config);
|
|
850
|
+
const isSupported = validProperties.has(cssProperty);
|
|
851
|
+
const initialDepth = isSupported ? 1 : -1;
|
|
852
|
+
if (cssProperty === "all")
|
|
853
|
+
return 0;
|
|
854
|
+
return SHORTHAND_TO_LONGHAND_ENTRIES.reduce((depth, [shorthand, longhands]) => {
|
|
855
|
+
const isLonghand = longhands.includes(cssProperty);
|
|
856
|
+
return isLonghand ? depth + getAtomicLayerIndex(shorthand, config) : depth;
|
|
857
|
+
}, initialDepth);
|
|
858
|
+
}
|
|
859
|
+
function generateKeyframeRules(tokenValues, config) {
|
|
860
|
+
const themeValues = tokenValues.flatMap((tokenValue) => {
|
|
861
|
+
return Object.values(getThemeValuesByThemeMode(tokenValue, config.theme));
|
|
862
|
+
});
|
|
863
|
+
const rules = Object.entries(config.keyframes || {}).flatMap(([name, styles]) => {
|
|
864
|
+
const nameRegex = new RegExp(`\\b${name}\\b`);
|
|
865
|
+
const isUsingKeyframeName = themeValues.some((value) => nameRegex.test(value));
|
|
866
|
+
if (!isUsingKeyframeName)
|
|
867
|
+
return [];
|
|
868
|
+
return [[`@keyframes ${name} { ${stringify(styles)} }`]];
|
|
869
|
+
});
|
|
870
|
+
return rules.join(" ");
|
|
871
|
+
}
|
|
872
|
+
function generateThemeTokens(tokenValues, config) {
|
|
873
|
+
const theme = getThemeFromConfig(config.theme);
|
|
874
|
+
const rootSelector = ":root";
|
|
875
|
+
const gridStyles = `${rootSelector} { ${Tokenami2.gridProperty()}: ${config.grid}; }`;
|
|
876
|
+
const rootStyles = getThemeStyles(rootSelector, tokenValues, theme.root, config);
|
|
877
|
+
const themeToModes = {};
|
|
878
|
+
const modeEntries = Object.entries(theme.modes || {});
|
|
879
|
+
for (const [mode, theme2] of modeEntries) {
|
|
880
|
+
const themeKey = JSON.stringify(theme2);
|
|
881
|
+
if (themeKey in themeToModes)
|
|
882
|
+
themeToModes[themeKey].push(mode);
|
|
883
|
+
else
|
|
884
|
+
themeToModes[themeKey] = [mode];
|
|
885
|
+
}
|
|
886
|
+
const modeStyles = Object.entries(themeToModes).map(([theme2, modes]) => {
|
|
887
|
+
const selector = modes.map(config.themeSelector).join(", ");
|
|
888
|
+
return getThemeStyles(selector, tokenValues, JSON.parse(theme2), config);
|
|
889
|
+
});
|
|
890
|
+
const themeTokens = [gridStyles, rootStyles, modeStyles.join(" ")];
|
|
891
|
+
return themeTokens.join(" ");
|
|
892
|
+
}
|
|
893
|
+
var getThemeStyles = (selector, tokenValues, theme, config) => {
|
|
894
|
+
const themeValues = getThemeValuesByTokenValues(tokenValues, theme);
|
|
895
|
+
const customPropertyThemeValues = getCustomPropertyThemeValues(themeValues, config);
|
|
896
|
+
const selectors = Array.isArray(selector) ? selector : [selector];
|
|
897
|
+
for (const customKey of Object.keys(customPropertyThemeValues)) {
|
|
898
|
+
delete themeValues[customKey];
|
|
899
|
+
}
|
|
900
|
+
const themeStyles = selectors.reduceRight(
|
|
901
|
+
(declaration, selector2) => `${selector2} { ${declaration} }`,
|
|
902
|
+
stringify(themeValues)
|
|
903
|
+
);
|
|
904
|
+
const elementSelector = selectors.at(-1);
|
|
905
|
+
const elementThemeStyles = getElementThemeStyles(elementSelector, customPropertyThemeValues);
|
|
906
|
+
const customPropertyThemeStyles = selectors.slice(0, -1).reduceRight((declaration, selector2) => {
|
|
907
|
+
return `${selector2} { ${declaration} }`;
|
|
908
|
+
}, elementThemeStyles);
|
|
909
|
+
return themeStyles + " " + customPropertyThemeStyles;
|
|
910
|
+
};
|
|
911
|
+
var getElementThemeStyles = (selector, themeValues) => {
|
|
912
|
+
const splitChained = selector.split(",");
|
|
913
|
+
return splitChained.map((selector2) => `${selector2}, ${selector2} ${DEFAULT_SELECTOR} { ${stringify(themeValues)} }`).join(" ");
|
|
914
|
+
};
|
|
915
|
+
function getCustomPropertyThemeValues(themeValues, config) {
|
|
916
|
+
const entries = Object.entries(themeValues).flatMap(([key, value]) => {
|
|
917
|
+
const valueWithCustomPrefixes = getPrefixedCustomPropertyValues(value, config.customProperties);
|
|
918
|
+
return valueWithCustomPrefixes ? [[key, valueWithCustomPrefixes]] : [];
|
|
919
|
+
});
|
|
920
|
+
return Object.fromEntries(entries);
|
|
921
|
+
}
|
|
922
|
+
var CUSTOM_PROP_REGEX = /\(--[^-][\w-]+/g;
|
|
923
|
+
var getPrefixedCustomPropertyValues = (themeValue, customProperties) => {
|
|
924
|
+
const variables = themeValue.match(CUSTOM_PROP_REGEX);
|
|
925
|
+
if (!variables)
|
|
926
|
+
return null;
|
|
927
|
+
return themeValue.replace(CUSTOM_PROP_REGEX, (m) => {
|
|
928
|
+
const match = m.replace("(", "");
|
|
929
|
+
const tokenProperty2 = Tokenami2.TokenProperty.safeParse(match);
|
|
930
|
+
if (!tokenProperty2.success)
|
|
931
|
+
return m;
|
|
932
|
+
const parts = Tokenami2.getTokenPropertySplit(tokenProperty2.output);
|
|
933
|
+
const isCustom = Boolean(customProperties?.[parts.alias]);
|
|
934
|
+
if (!isCustom)
|
|
935
|
+
return m;
|
|
936
|
+
const tokenPrefix = Tokenami2.tokenProperty("");
|
|
937
|
+
const customPrefixTokenValue = tokenProperty2.output.replace(tokenPrefix, CUSTOM_PROP_PREFIX);
|
|
938
|
+
return "(" + customPrefixTokenValue;
|
|
939
|
+
});
|
|
940
|
+
};
|
|
941
|
+
function hash(str) {
|
|
942
|
+
let hash2 = 0;
|
|
943
|
+
for (let i = 0, len = str.length; i < len; i++) {
|
|
944
|
+
let chr = str.charCodeAt(i);
|
|
945
|
+
hash2 = (hash2 << 5) - hash2 + chr;
|
|
946
|
+
hash2 |= 0;
|
|
947
|
+
}
|
|
948
|
+
return Math.abs(hash2).toString(32);
|
|
949
|
+
}
|
|
950
|
+
function hashVariantProperty(variant, property) {
|
|
951
|
+
return `--_${hash(variant + property)}`;
|
|
952
|
+
}
|
|
953
|
+
var PSEUDO_REGEX = /::/;
|
|
954
|
+
function isElementSelector(selector = "") {
|
|
955
|
+
return isCombinatorSelector(selector) || PSEUDO_REGEX.test(selector);
|
|
956
|
+
}
|
|
957
|
+
var COMBINATOR_REGEX = /(.+)\s\[style|style\]\s(.+)/;
|
|
958
|
+
function isCombinatorSelector(selector = "") {
|
|
959
|
+
return COMBINATOR_REGEX.test(selector);
|
|
960
|
+
}
|
|
961
|
+
function getResponsiveSelectorFromConfig(responsiveSelector, tokenamiConfig) {
|
|
962
|
+
return responsiveSelector && tokenamiConfig.responsive?.[responsiveSelector];
|
|
963
|
+
}
|
|
964
|
+
function getSelectorsFromConfig(propertySelector, tokenamiConfig) {
|
|
965
|
+
const arbitrarySelector = Tokenami2.getArbitrarySelector(propertySelector);
|
|
966
|
+
const configSelector = propertySelector && tokenamiConfig.selectors?.[propertySelector];
|
|
967
|
+
const selector = arbitrarySelector?.replace(/_/g, " ") || configSelector;
|
|
968
|
+
const selectors = selector ? Array.isArray(selector) ? selector : [selector] : ["&"];
|
|
969
|
+
const isSelectionVariant = selectors.includes("&::selection");
|
|
970
|
+
if (selectors.toString().indexOf("&") === -1) {
|
|
971
|
+
throw new Error(`Selector '${selector}' must include '&'`);
|
|
972
|
+
}
|
|
973
|
+
return selectors.map((selector2) => {
|
|
974
|
+
const tkSelector = isSelectionVariant ? `[style*="${propertySelector}_"]` : DEFAULT_SELECTOR;
|
|
975
|
+
return selector2.replace(/&/g, tkSelector);
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// package.json
|
|
980
|
+
var package_default = {
|
|
981
|
+
name: "tokenami",
|
|
982
|
+
version: "0.0.76",
|
|
983
|
+
license: "MIT",
|
|
984
|
+
type: "module",
|
|
985
|
+
main: "./dist/index.cjs",
|
|
986
|
+
module: "./dist/index.js",
|
|
987
|
+
types: "./dist/index.d.ts",
|
|
988
|
+
repository: "https://github.com/tokenami/tokenami",
|
|
989
|
+
publishConfig: {
|
|
990
|
+
access: "public"
|
|
991
|
+
},
|
|
992
|
+
exports: {
|
|
993
|
+
".": {
|
|
994
|
+
import: {
|
|
995
|
+
types: "./dist/index.d.ts",
|
|
996
|
+
default: "./dist/index.js"
|
|
997
|
+
},
|
|
998
|
+
require: {
|
|
999
|
+
types: "./dist/index.d.cts",
|
|
1000
|
+
default: "./dist/index.cjs"
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
bin: {
|
|
1005
|
+
tokenami: "bin.js"
|
|
1006
|
+
},
|
|
1007
|
+
files: [
|
|
1008
|
+
"dist",
|
|
1009
|
+
"stubs",
|
|
1010
|
+
"bin.js"
|
|
1011
|
+
],
|
|
1012
|
+
scripts: {
|
|
1013
|
+
build: "tsup",
|
|
1014
|
+
dev: "tsup --watch",
|
|
1015
|
+
typecheck: "tsc --noEmit"
|
|
1016
|
+
},
|
|
1017
|
+
devDependencies: {
|
|
1018
|
+
"@types/culori": "^2.1.0",
|
|
1019
|
+
"@types/inquirer": "^9.0.7",
|
|
1020
|
+
"@types/node": "^20.3.1",
|
|
1021
|
+
tsup: "^7.0.0",
|
|
1022
|
+
typescript: "^5.1.3"
|
|
1023
|
+
},
|
|
1024
|
+
dependencies: {
|
|
1025
|
+
"@stitches/stringify": "^1.2.8",
|
|
1026
|
+
"@tokenami/config": "workspace:*",
|
|
1027
|
+
"@tokenami/ds": "workspace:*",
|
|
1028
|
+
acorn: "^8.11.3",
|
|
1029
|
+
"acorn-walk": "^8.3.2",
|
|
1030
|
+
browserslist: "^4.22.2",
|
|
1031
|
+
cac: "^6.7.14",
|
|
1032
|
+
chalk: "^5.2.0",
|
|
1033
|
+
chokidar: "^3.5.3",
|
|
1034
|
+
csstype: "^3.1.2",
|
|
1035
|
+
culori: "^4.0.1",
|
|
1036
|
+
"fast-glob": "^3.2.12",
|
|
1037
|
+
inquirer: "^9.2.12",
|
|
1038
|
+
jiti: "^1.21.0",
|
|
1039
|
+
lightningcss: "1.23.0",
|
|
1040
|
+
pathe: "^1.1.1",
|
|
1041
|
+
sucrase: "^3.34.0",
|
|
1042
|
+
"trie-search": "^2.0.0"
|
|
1043
|
+
},
|
|
1044
|
+
peerDependencies: {
|
|
1045
|
+
typescript: ">= 5"
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
// src/cli.ts
|
|
1050
|
+
var questions = [
|
|
1051
|
+
{
|
|
1052
|
+
type: "list",
|
|
1053
|
+
name: "type",
|
|
1054
|
+
message: "TypeScript or JavaScript?",
|
|
1055
|
+
choices: [
|
|
1056
|
+
{ name: "TypeScript", value: "ts" },
|
|
1057
|
+
{ name: "JavaScript", value: "js" }
|
|
1058
|
+
]
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
type: "input",
|
|
1062
|
+
name: "folder",
|
|
1063
|
+
message: "What folder should Tokenami watch for token properties?",
|
|
1064
|
+
default: "./app"
|
|
1065
|
+
}
|
|
1066
|
+
];
|
|
1067
|
+
var run = () => {
|
|
1068
|
+
const cli = cac("tokenami");
|
|
1069
|
+
const cwd = process.cwd();
|
|
1070
|
+
cli.command("init").option("-c, --config [path]", "Path to a custom config file").action(async (_, flags) => {
|
|
1071
|
+
const tsconfigPath = pathe.join(cwd, "tsconfig.json");
|
|
1072
|
+
const jsconfigPath = pathe.join(cwd, "jsconfig.json");
|
|
1073
|
+
const hasTsConfig = fs2.existsSync(tsconfigPath);
|
|
1074
|
+
const hasJsConfig = fs2.existsSync(jsconfigPath);
|
|
1075
|
+
const hasProjectConfig = hasTsConfig || hasJsConfig;
|
|
1076
|
+
if (hasProjectConfig)
|
|
1077
|
+
questions.shift();
|
|
1078
|
+
const answers = await inquirer.prompt(questions);
|
|
1079
|
+
const type = hasTsConfig ? "ts" : hasJsConfig ? "js" : answers.type;
|
|
1080
|
+
const extensions = type === "ts" ? "ts,tsx" : "js,jsx";
|
|
1081
|
+
const include = `'${answers.folder}/**/*.{${extensions}}'`;
|
|
1082
|
+
const configPath = getConfigPath(cwd, flags?.config, type);
|
|
1083
|
+
const outDir = pathe.dirname(configPath);
|
|
1084
|
+
const initialConfig = generateConfig(include, configPath);
|
|
1085
|
+
const ciTypeDefs = generateCiTypeDefs(configPath);
|
|
1086
|
+
const typeDefs = generateTypeDefs(configPath);
|
|
1087
|
+
fs2.mkdirSync(outDir, { recursive: true });
|
|
1088
|
+
fs2.writeFileSync(configPath, initialConfig, { flag: "w" });
|
|
1089
|
+
fs2.writeFileSync(getTypeDefsPath(configPath), typeDefs, { flag: "w" });
|
|
1090
|
+
fs2.writeFileSync(getCiTypeDefsPath(configPath), ciTypeDefs, { flag: "w" });
|
|
1091
|
+
debug(`Project successfully configured in './tokenami'`);
|
|
1092
|
+
});
|
|
1093
|
+
cli.command("[files]", "Include file glob").option("-c, --config [path]", "Path to a custom config file").option("-o, --output [path]", "Output file", { default: "public/tokenami.css" }).option("-w, --watch", "Watch for changes and rebuild as needed").option("--minify", "Minify CSS output").action(async (_, flags) => {
|
|
1094
|
+
const startTime = startTimer();
|
|
1095
|
+
const minify = flags.minify;
|
|
1096
|
+
const configPath = getConfigPath(cwd, flags.config);
|
|
1097
|
+
const browsers = browserslist(null, { env: process.env.NODE_ENV || "development" });
|
|
1098
|
+
const targets = browserslistToTargets(browsers);
|
|
1099
|
+
let config = getConfigAtPath(configPath);
|
|
1100
|
+
config.include = flags.files || config.include;
|
|
1101
|
+
if (!config.include.length)
|
|
1102
|
+
error("Provide a glob pattern to include files");
|
|
1103
|
+
async function regenerateStylesheet(file, config2) {
|
|
1104
|
+
const generateTime = startTimer();
|
|
1105
|
+
const tokens2 = await findUsedTokens(cwd, config2);
|
|
1106
|
+
generateStyles({ tokens: tokens2, cwd, out: flags.output, config: config2, minify, targets });
|
|
1107
|
+
debug(`Generated styles from ${file} in ${generateTime()}ms.`);
|
|
1108
|
+
}
|
|
1109
|
+
if (flags.watch) {
|
|
1110
|
+
const configWatcher = watch2(cwd, [configPath]);
|
|
1111
|
+
const tokenWatcher = watch2(cwd, config.include, config.exclude);
|
|
1112
|
+
debug(`Watching for changes to ${config.include}.`);
|
|
1113
|
+
tokenWatcher.on("all", (_2, file) => regenerateStylesheet(file, config));
|
|
1114
|
+
configWatcher.on("all", async (_2, file) => {
|
|
1115
|
+
try {
|
|
1116
|
+
config = getReloadedConfigAtPath(configPath);
|
|
1117
|
+
config.include = flags.files || config.include;
|
|
1118
|
+
regenerateStylesheet(file, config);
|
|
1119
|
+
} catch (e) {
|
|
1120
|
+
debug(`Skipped change to ${file} with ${e}`);
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
process.once("SIGINT", async () => {
|
|
1124
|
+
await tokenWatcher.close();
|
|
1125
|
+
await configWatcher.close();
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
const tokens = await findUsedTokens(cwd, config);
|
|
1129
|
+
generateStyles({ tokens, cwd, out: flags.output, config, minify, targets });
|
|
1130
|
+
debug(`Ready in ${startTime()}ms.`);
|
|
1131
|
+
});
|
|
1132
|
+
cli.help();
|
|
1133
|
+
cli.version(package_default.version);
|
|
1134
|
+
cli.parse();
|
|
1135
|
+
};
|
|
1136
|
+
function generateStyles(params) {
|
|
1137
|
+
const { cwd, out, ...generateParams } = params;
|
|
1138
|
+
const outDir = pathe.join(cwd, pathe.dirname(out));
|
|
1139
|
+
const outPath = pathe.join(cwd, out);
|
|
1140
|
+
const output = generate({ ...generateParams, output: outPath });
|
|
1141
|
+
fs2.mkdirSync(outDir, { recursive: true });
|
|
1142
|
+
fs2.writeFileSync(outPath, output, { flag: "w" });
|
|
1143
|
+
}
|
|
1144
|
+
function watch2(cwd, include, exclude) {
|
|
1145
|
+
return chokidar.watch(include, {
|
|
1146
|
+
cwd,
|
|
1147
|
+
persistent: true,
|
|
1148
|
+
ignoreInitial: true,
|
|
1149
|
+
ignorePermissionErrors: true,
|
|
1150
|
+
ignored: exclude
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
async function findUsedTokens(cwd, config) {
|
|
1154
|
+
const include = config.include;
|
|
1155
|
+
const exclude = config.exclude;
|
|
1156
|
+
const entries = await glob(include, { cwd, onlyFiles: true, stats: false, ignore: exclude });
|
|
1157
|
+
let tokenProperties = [];
|
|
1158
|
+
let tokenValues = [];
|
|
1159
|
+
entries.forEach((entry) => {
|
|
1160
|
+
const fileContent = fs2.readFileSync(entry, "utf8");
|
|
1161
|
+
const tokens = matchTokens(fileContent, config.theme);
|
|
1162
|
+
const responsiveProperties = matchResponsiveComposeVariants(fileContent, config);
|
|
1163
|
+
tokenProperties = [...tokenProperties, ...tokens.properties, ...responsiveProperties];
|
|
1164
|
+
tokenValues = [...tokenValues, ...tokens.values];
|
|
1165
|
+
});
|
|
1166
|
+
return { properties: tokenProperties, values: tokenValues };
|
|
1167
|
+
}
|
|
1168
|
+
var CSS_VARIABLE_REGEX = /--(?:[\w-]+|\{[^\{\}]*\})+/g;
|
|
1169
|
+
function matchTokens(content, theme) {
|
|
1170
|
+
const matches = content.match(CSS_VARIABLE_REGEX) || [];
|
|
1171
|
+
const stringMatches = Array.from(matches).map(Tokenami2.stringifyProperty);
|
|
1172
|
+
const uniqueMatches = unique(stringMatches);
|
|
1173
|
+
const variableMatches = uniqueMatches.filter((match) => match !== Tokenami2.gridProperty());
|
|
1174
|
+
const values = variableMatches.flatMap((match) => {
|
|
1175
|
+
const valueProperty = Tokenami2.TokenValue.safeParse(`var(${match})`);
|
|
1176
|
+
if (!valueProperty.success)
|
|
1177
|
+
return [];
|
|
1178
|
+
const themeValues = getThemeValuesByThemeMode(valueProperty.output, theme);
|
|
1179
|
+
return Object.entries(themeValues).length ? [valueProperty.output] : [];
|
|
1180
|
+
});
|
|
1181
|
+
const properties = variableMatches.flatMap((match) => {
|
|
1182
|
+
const tokenProperty2 = Tokenami2.TokenProperty.safeParse(match);
|
|
1183
|
+
const isValue = values.includes(`var(${match})`);
|
|
1184
|
+
if (isValue || !tokenProperty2.success)
|
|
1185
|
+
return [];
|
|
1186
|
+
return tokenProperty2.output;
|
|
1187
|
+
});
|
|
1188
|
+
return { properties, values };
|
|
1189
|
+
}
|
|
1190
|
+
var COMPOSE_BLOCKS_REGEX = /^.*css\.compose\(\{[\s\S]*?\}\);/gm;
|
|
1191
|
+
function matchResponsiveComposeVariants(fileContent, config) {
|
|
1192
|
+
const composeBlocks = fileContent.match(COMPOSE_BLOCKS_REGEX);
|
|
1193
|
+
if (!composeBlocks)
|
|
1194
|
+
return [];
|
|
1195
|
+
const responsiveBlocks = composeBlocks.filter((block) => block.match("responsiveVariants"));
|
|
1196
|
+
return responsiveBlocks.flatMap((block) => {
|
|
1197
|
+
const ast = acorn.parse(block, { ecmaVersion: 2020 });
|
|
1198
|
+
const responsiveVariants = findResponsiveVariants(ast);
|
|
1199
|
+
const tokens = matchTokens(JSON.stringify(responsiveVariants), config.theme);
|
|
1200
|
+
return tokens.properties.flatMap((tokenProperty2) => {
|
|
1201
|
+
return getResponsivePropertyVariants(tokenProperty2, config.responsive);
|
|
1202
|
+
});
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
function findResponsiveVariants(node) {
|
|
1206
|
+
let responsiveVariantsNode = null;
|
|
1207
|
+
acornWalk.simple(node, {
|
|
1208
|
+
Property(node2) {
|
|
1209
|
+
if (node2.key.type === "Identifier" && node2.key.name === "responsiveVariants") {
|
|
1210
|
+
responsiveVariantsNode = node2;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
return responsiveVariantsNode;
|
|
1215
|
+
}
|
|
1216
|
+
function startTimer() {
|
|
1217
|
+
const start = performance.now();
|
|
1218
|
+
return () => {
|
|
1219
|
+
const stop = performance.now();
|
|
1220
|
+
return Math.round(stop - start);
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
try {
|
|
1224
|
+
run();
|
|
1225
|
+
} catch (e) {
|
|
1226
|
+
error(e instanceof Error ? e.message : "Unknown error occurred.");
|
|
1227
|
+
}
|