rainbowindex 0.2.0 → 0.2.2

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.
@@ -0,0 +1,691 @@
1
+ import {
2
+ ANIMATION_STATIC_NAMES,
3
+ BACKGROUND_STATIC_NAMES,
4
+ BORDER_STATIC_NAMES,
5
+ EFFECTS_STATIC_NAMES,
6
+ LAYOUT_STATIC_NAMES,
7
+ PREFIX_DISPATCH,
8
+ ROUNDED_CORNER_NAMES,
9
+ ROUNDED_SIDE_NAMES,
10
+ STATIC_UTILITIES,
11
+ SVG_STATIC_NAMES,
12
+ TYPOGRAPHY_STATIC_NAMES,
13
+ codepointCompare,
14
+ parseUtility,
15
+ resolveUtilityDeclarations
16
+ } from "./chunk-W6XIBM4M.mjs";
17
+ import {
18
+ SPECIAL_COLORS
19
+ } from "./chunk-SOMDX7V6.mjs";
20
+
21
+ // src/project/css-entry.ts
22
+ var CSS_ENTRY_CANDIDATES = Object.freeze([
23
+ "src/index.css",
24
+ "src/style.css",
25
+ "src/styles.css",
26
+ "src/app.css",
27
+ "src/global.css",
28
+ "index.css",
29
+ "style.css",
30
+ "styles.css",
31
+ "app.css",
32
+ "global.css"
33
+ ]);
34
+
35
+ // src/utilities/enumerate.ts
36
+ var COLOR_STOPS = Object.freeze([
37
+ "50",
38
+ "100",
39
+ "150",
40
+ "200",
41
+ "250",
42
+ "300",
43
+ "350",
44
+ "400",
45
+ "450",
46
+ "500",
47
+ "550",
48
+ "600",
49
+ "650",
50
+ "700",
51
+ "750",
52
+ "800",
53
+ "850",
54
+ "900",
55
+ "950"
56
+ ]);
57
+ var SPACING_SAMPLES = Object.freeze([
58
+ "0",
59
+ "1",
60
+ "1_5",
61
+ "2",
62
+ "2_5",
63
+ "3",
64
+ "4",
65
+ "5",
66
+ "6",
67
+ "8",
68
+ "10",
69
+ "12",
70
+ "16",
71
+ "20",
72
+ "24",
73
+ "px"
74
+ ]);
75
+ var FRACTION_SAMPLES = Object.freeze([
76
+ "1/2",
77
+ "1/3",
78
+ "2/3",
79
+ "1/4",
80
+ "3/4",
81
+ "1/5",
82
+ "2/5",
83
+ "3/5",
84
+ "4/5",
85
+ "1/6",
86
+ "5/6"
87
+ ]);
88
+ var INT_SAMPLES = Object.freeze(["0", "1", "2", "3", "4", "6", "8", "10", "12"]);
89
+ var PERCENT_SAMPLES = Object.freeze([
90
+ "0",
91
+ "5",
92
+ "10",
93
+ "15",
94
+ "20",
95
+ "25",
96
+ "30",
97
+ "40",
98
+ "50",
99
+ "60",
100
+ "70",
101
+ "75",
102
+ "80",
103
+ "90",
104
+ "95",
105
+ "100"
106
+ ]);
107
+ var BUILTIN_FONT_SLOTS = Object.freeze(["sans", "serif", "mono"]);
108
+ var DURATION_SAMPLES = Object.freeze(["75", "100", "150", "200", "300", "500", "700", "1000"]);
109
+ var ROUNDED_SIDES = Object.freeze([
110
+ ...ROUNDED_SIDE_NAMES,
111
+ ...ROUNDED_CORNER_NAMES
112
+ ]);
113
+ var SPEC_GROUPS = [
114
+ // Spacing family — the scale is shared; sides/axes are distinct roots.
115
+ [
116
+ [
117
+ "p",
118
+ "px",
119
+ "py",
120
+ "pt",
121
+ "pb",
122
+ "pl",
123
+ "pr",
124
+ "ps",
125
+ "pe",
126
+ "pbs",
127
+ "pbe",
128
+ "m",
129
+ "mx",
130
+ "my",
131
+ "mt",
132
+ "mb",
133
+ "ml",
134
+ "mr",
135
+ "ms",
136
+ "me",
137
+ "mbs",
138
+ "mbe",
139
+ "gap",
140
+ "gap-x",
141
+ "gap-y",
142
+ "space",
143
+ "space-x",
144
+ "space-y",
145
+ "scroll",
146
+ "scroll-m",
147
+ "scroll-mx",
148
+ "scroll-my",
149
+ "scroll-mt",
150
+ "scroll-mb",
151
+ "scroll-ml",
152
+ "scroll-mr",
153
+ "scroll-ms",
154
+ "scroll-me",
155
+ "scroll-p",
156
+ "scroll-px",
157
+ "scroll-py",
158
+ "scroll-pt",
159
+ "scroll-pb",
160
+ "scroll-pl",
161
+ "scroll-pr",
162
+ "scroll-ps",
163
+ "scroll-pe",
164
+ "indent"
165
+ ],
166
+ { kinds: ["spacing"] }
167
+ ],
168
+ [
169
+ [
170
+ "inset",
171
+ "inset-x",
172
+ "inset-y",
173
+ "inset-s",
174
+ "inset-e",
175
+ "inset-bs",
176
+ "inset-be",
177
+ "top",
178
+ "bottom",
179
+ "left",
180
+ "right",
181
+ "start",
182
+ "end"
183
+ ],
184
+ { kinds: ["spacing", "fraction"], keywords: ["auto", "full"] }
185
+ ],
186
+ // Sizing
187
+ [
188
+ [
189
+ "w",
190
+ "h",
191
+ "size",
192
+ "min",
193
+ "max",
194
+ "min-w",
195
+ "max-w",
196
+ "min-h",
197
+ "max-h",
198
+ "inline",
199
+ "block",
200
+ "basis"
201
+ ],
202
+ { kinds: ["spacing", "fraction"] }
203
+ ],
204
+ [["max-w", "basis", "columns"], { kinds: ["breakpoint"] }],
205
+ // Typography
206
+ [["text"], { kinds: ["text-size", "fluid-text-size", "color", "special-color"] }],
207
+ [["font"], { kinds: ["font-slot", "weight"] }],
208
+ [["leading"], { kinds: ["leading", "int"] }],
209
+ [["tracking"], { kinds: ["tracking"] }],
210
+ [
211
+ ["decoration"],
212
+ {
213
+ kinds: ["color", "special-color", "int", "keywords"],
214
+ keywords: ["auto", "from-font", "solid", "double", "dotted", "dashed", "wavy"]
215
+ }
216
+ ],
217
+ [
218
+ ["underline"],
219
+ {
220
+ kinds: ["keywords"],
221
+ keywords: ["offset-auto", "offset-0", "offset-1", "offset-2", "offset-4", "offset-8"]
222
+ }
223
+ ],
224
+ [
225
+ ["line"],
226
+ {
227
+ kinds: ["keywords"],
228
+ keywords: ["clamp-none", "clamp-1", "clamp-2", "clamp-3", "clamp-4", "clamp-5", "clamp-6"]
229
+ }
230
+ ],
231
+ [["tab"], { kinds: ["int"] }],
232
+ [
233
+ ["break"],
234
+ {
235
+ kinds: ["keywords"],
236
+ keywords: ["normal", "words", "all", "keep", "after-avoid", "before-avoid", "inside-avoid"]
237
+ }
238
+ ],
239
+ [
240
+ [
241
+ "whitespace",
242
+ "italic",
243
+ "truncate",
244
+ "uppercase",
245
+ "lowercase",
246
+ "capitalize",
247
+ "normal",
248
+ "antialiased",
249
+ "subpixel",
250
+ "align",
251
+ "list",
252
+ "hyphens",
253
+ "wrap",
254
+ "ordinal",
255
+ "slashed",
256
+ "lining",
257
+ "oldstyle",
258
+ "proportional",
259
+ "tabular",
260
+ "diagonal",
261
+ "stacked"
262
+ ],
263
+ { kinds: [] }
264
+ ],
265
+ // Color-bearing families
266
+ [["bg", "accent", "caret", "fill"], { kinds: ["color", "special-color"] }],
267
+ [
268
+ ["bg-linear"],
269
+ {
270
+ kinds: ["keywords"],
271
+ keywords: ["to-t", "to-b", "to-l", "to-r", "to-tl", "to-tr", "to-bl", "to-br"]
272
+ }
273
+ ],
274
+ [["bg-conic", "bg-radial"], { kinds: ["int"] }],
275
+ [["border", "divide"], { kinds: ["color", "special-color", "int"] }],
276
+ [["stroke"], { kinds: ["color", "special-color", "int"] }],
277
+ [["from", "via", "to"], { kinds: ["color", "special-color"] }],
278
+ [
279
+ ["outline"],
280
+ {
281
+ kinds: ["color", "special-color", "int", "keywords"],
282
+ keywords: ["offset-0", "offset-1", "offset-2", "offset-4", "offset-8"]
283
+ }
284
+ ],
285
+ // SVG
286
+ [["stroke-cap"], { kinds: ["keywords"], keywords: ["butt", "round", "square"] }],
287
+ [["stroke-join"], { kinds: ["keywords"], keywords: ["miter", "round", "bevel"] }],
288
+ [["stroke-dash", "stroke-offset", "stroke-miter"], { kinds: ["int"] }],
289
+ [["stroke-opacity"], { kinds: ["opacity", "percent"] }],
290
+ [["paint", "vector"], { kinds: [] }],
291
+ // Layout — overwhelmingly statics; functional exceptions below.
292
+ [
293
+ [
294
+ "contents",
295
+ "hidden",
296
+ "table",
297
+ "flow",
298
+ "static",
299
+ "relative",
300
+ "absolute",
301
+ "fixed",
302
+ "sticky",
303
+ "items",
304
+ "justify",
305
+ "content",
306
+ "self",
307
+ "overflow",
308
+ "overscroll",
309
+ "visible",
310
+ "invisible",
311
+ "collapse",
312
+ "isolate",
313
+ "float",
314
+ "clear",
315
+ "object",
316
+ "cursor",
317
+ "pointer",
318
+ "select",
319
+ "touch",
320
+ "resize",
321
+ "scrollbar",
322
+ "snap",
323
+ "place",
324
+ "sr",
325
+ "box",
326
+ "caption",
327
+ "field",
328
+ "forced",
329
+ "scheme",
330
+ "backface",
331
+ "@container",
332
+ "@anchor",
333
+ "@anchor-to",
334
+ "position-area",
335
+ "anchor-scope"
336
+ ],
337
+ { kinds: [] }
338
+ ],
339
+ [["flex"], { kinds: ["int", "keywords"], keywords: ["auto", "initial", "none"] }],
340
+ [
341
+ ["grid"],
342
+ {
343
+ kinds: ["keywords"],
344
+ keywords: [
345
+ ...Array.from({ length: 12 }, (_, i) => `cols-${i + 1}`),
346
+ ...Array.from({ length: 6 }, (_, i) => `rows-${i + 1}`),
347
+ "cols-none",
348
+ "rows-none",
349
+ "cols-subgrid",
350
+ "rows-subgrid"
351
+ ]
352
+ }
353
+ ],
354
+ [["grow", "shrink"], { kinds: ["int"] }],
355
+ [["order"], { kinds: ["int"], keywords: ["first", "last", "none"] }],
356
+ [
357
+ ["col", "row"],
358
+ {
359
+ kinds: ["keywords"],
360
+ keywords: [
361
+ "auto",
362
+ "span-full",
363
+ ...Array.from({ length: 12 }, (_, i) => `span-${i + 1}`),
364
+ ...Array.from({ length: 13 }, (_, i) => `start-${i + 1}`),
365
+ ...Array.from({ length: 13 }, (_, i) => `end-${i + 1}`)
366
+ ]
367
+ }
368
+ ],
369
+ [["columns"], { kinds: ["int"] }],
370
+ [
371
+ ["auto"],
372
+ {
373
+ kinds: ["keywords"],
374
+ keywords: [
375
+ "cols-auto",
376
+ "cols-min",
377
+ "cols-max",
378
+ "cols-fr",
379
+ "rows-auto",
380
+ "rows-min",
381
+ "rows-max",
382
+ "rows-fr"
383
+ ]
384
+ }
385
+ ],
386
+ [["aspect"], { kinds: ["keywords"], keywords: ["auto", "square", "video"] }],
387
+ [["z"], { kinds: ["z", "int"] }],
388
+ [
389
+ ["contain"],
390
+ {
391
+ kinds: ["keywords"],
392
+ keywords: ["none", "strict", "content", "size", "inline-size", "layout", "style", "paint"]
393
+ }
394
+ ],
395
+ // Borders
396
+ [["rounded"], { kinds: ["rounded", "rounded-side"] }],
397
+ [
398
+ ["corner"],
399
+ { kinds: ["keywords"], keywords: ["round", "scoop", "bevel", "notch", "square", "squircle"] }
400
+ ],
401
+ // Effects
402
+ [["shadow", "text-shadow", "inset-shadow"], { kinds: ["shadow", "color", "special-color"] }],
403
+ [["ring", "inset-ring"], { kinds: ["int", "color", "special-color"] }],
404
+ [["opacity"], { kinds: ["opacity", "percent"] }],
405
+ [
406
+ ["transition"],
407
+ { kinds: ["keywords"], keywords: ["all", "colors", "opacity", "shadow", "transform", "none"] }
408
+ ],
409
+ [["duration", "delay"], { kinds: ["duration", "int"] }],
410
+ [["ease"], { kinds: ["ease", "keywords"], keywords: ["linear", "in", "out", "in-out"] }],
411
+ [["transform", "filter", "mask", "origin"], { kinds: [] }],
412
+ [
413
+ ["mix"],
414
+ {
415
+ kinds: ["keywords"],
416
+ keywords: [
417
+ "blend-normal",
418
+ "blend-multiply",
419
+ "blend-screen",
420
+ "blend-overlay",
421
+ "blend-darken",
422
+ "blend-lighten",
423
+ "blend-color-dodge",
424
+ "blend-color-burn",
425
+ "blend-hard-light",
426
+ "blend-soft-light",
427
+ "blend-difference",
428
+ "blend-exclusion",
429
+ "blend-hue",
430
+ "blend-saturation",
431
+ "blend-color",
432
+ "blend-luminosity"
433
+ ]
434
+ }
435
+ ],
436
+ [["grayscale", "invert", "sepia"], { kinds: ["percent"] }],
437
+ [["backdrop"], { kinds: ["keywords"], keywords: ["blur-none", "grayscale", "invert", "sepia"] }],
438
+ [
439
+ ["translate"],
440
+ {
441
+ kinds: ["keywords"],
442
+ keywords: [
443
+ ...SPACING_SAMPLES.flatMap((s) => [`x-${s}`, `y-${s}`, `z-${s}`]),
444
+ "x-full",
445
+ "y-full",
446
+ "x-1/2",
447
+ "y-1/2"
448
+ ]
449
+ }
450
+ ],
451
+ [
452
+ ["rotate", "skew"],
453
+ {
454
+ kinds: ["keywords"],
455
+ keywords: [
456
+ "0",
457
+ "1",
458
+ "2",
459
+ "3",
460
+ "6",
461
+ "12",
462
+ "45",
463
+ "90",
464
+ "180",
465
+ ...["0", "3", "6", "12", "45", "90"].flatMap((v) => [`x-${v}`, `y-${v}`])
466
+ ]
467
+ }
468
+ ],
469
+ [
470
+ ["scale"],
471
+ {
472
+ kinds: ["keywords"],
473
+ keywords: [
474
+ "0",
475
+ "50",
476
+ "75",
477
+ "90",
478
+ "95",
479
+ "100",
480
+ "105",
481
+ "110",
482
+ "125",
483
+ "150",
484
+ ...["0", "50", "75", "90", "95", "100", "105", "110", "125", "150"].flatMap((v) => [
485
+ `x-${v}`,
486
+ `y-${v}`
487
+ ])
488
+ ]
489
+ }
490
+ ],
491
+ [
492
+ ["will"],
493
+ {
494
+ kinds: ["keywords"],
495
+ keywords: ["change-auto", "change-scroll", "change-contents", "change-transform"]
496
+ }
497
+ ],
498
+ [["perspective"], { kinds: ["int"], keywords: ["none", "normal"] }],
499
+ // Animation
500
+ [["animate"], { kinds: ["animation", "keywords"], keywords: ["none", "in", "out"] }],
501
+ [
502
+ ["fade", "zoom"],
503
+ {
504
+ kinds: ["keywords"],
505
+ keywords: [
506
+ "in",
507
+ "out",
508
+ "in-0",
509
+ "in-50",
510
+ "in-75",
511
+ "in-95",
512
+ "out-0",
513
+ "out-50",
514
+ "out-75",
515
+ "out-95"
516
+ ]
517
+ }
518
+ ],
519
+ [
520
+ ["spin"],
521
+ {
522
+ kinds: ["keywords"],
523
+ keywords: ["in", "out", "in-45", "in-90", "in-180", "out-45", "out-90", "out-180"]
524
+ }
525
+ ],
526
+ [
527
+ ["slide"],
528
+ {
529
+ kinds: ["keywords"],
530
+ keywords: [
531
+ "in-from-top",
532
+ "in-from-bottom",
533
+ "in-from-left",
534
+ "in-from-right",
535
+ "out-to-top",
536
+ "out-to-bottom",
537
+ "out-to-left",
538
+ "out-to-right"
539
+ ]
540
+ }
541
+ ],
542
+ [["blur"], { kinds: ["blur"], keywords: ["none"] }]
543
+ ];
544
+ function buildValueSpaces() {
545
+ const table = /* @__PURE__ */ new Map();
546
+ for (const [roots, spec] of SPEC_GROUPS) {
547
+ for (const root of roots) {
548
+ let entry = table.get(root);
549
+ if (!entry) {
550
+ entry = { kinds: /* @__PURE__ */ new Set(), keywords: /* @__PURE__ */ new Set() };
551
+ table.set(root, entry);
552
+ }
553
+ for (const kind of spec.kinds) entry.kinds.add(kind);
554
+ for (const kw of spec.keywords ?? []) entry.keywords.add(kw);
555
+ }
556
+ }
557
+ const out = /* @__PURE__ */ new Map();
558
+ for (const [root, entry] of table) {
559
+ out.set(root, {
560
+ kinds: Object.freeze([...entry.kinds]),
561
+ keywords: entry.keywords.size > 0 ? Object.freeze([...entry.keywords]) : void 0
562
+ });
563
+ }
564
+ return out;
565
+ }
566
+ var UTILITY_VALUE_SPACES = buildValueSpaces();
567
+ function candidateValues(kind, theme) {
568
+ switch (kind) {
569
+ case "color": {
570
+ const out = [];
571
+ for (const name of Object.keys(theme.colors)) {
572
+ for (const stop of COLOR_STOPS) out.push(`${name}-${stop}`);
573
+ }
574
+ return out;
575
+ }
576
+ case "special-color":
577
+ return Object.keys(SPECIAL_COLORS);
578
+ case "spacing":
579
+ return [...SPACING_SAMPLES];
580
+ case "fraction":
581
+ return [...FRACTION_SAMPLES];
582
+ case "text-size":
583
+ return Object.keys(theme.text);
584
+ case "fluid-text-size":
585
+ return Object.keys(theme.text).map((size) => `fluid-${size}`);
586
+ case "font-slot":
587
+ return [.../* @__PURE__ */ new Set([...BUILTIN_FONT_SLOTS, ...theme.fonts.map((slot) => slot.slot)])];
588
+ case "weight":
589
+ return Object.keys(theme.weights);
590
+ case "rounded":
591
+ return Object.keys(theme.rounded);
592
+ case "rounded-side": {
593
+ const tokens = Object.keys(theme.rounded);
594
+ const out = [];
595
+ for (const side of ROUNDED_SIDES) {
596
+ out.push(side);
597
+ for (const token of tokens) out.push(`${side}-${token}`);
598
+ }
599
+ return out;
600
+ }
601
+ case "shadow":
602
+ return Object.keys(theme.shadows);
603
+ case "z":
604
+ return Object.keys(theme.z);
605
+ case "ease":
606
+ return Object.keys(theme.easing);
607
+ case "blur":
608
+ return Object.keys(theme.blur);
609
+ case "animation":
610
+ return Object.keys(theme.animations);
611
+ case "leading":
612
+ return Object.keys(theme.leading);
613
+ case "tracking":
614
+ return Object.keys(theme.tracking);
615
+ case "opacity":
616
+ return Object.keys(theme.opacity);
617
+ case "duration":
618
+ return [.../* @__PURE__ */ new Set([...Object.keys(theme.duration), ...DURATION_SAMPLES])];
619
+ case "breakpoint":
620
+ return Object.keys(theme.breakpoints);
621
+ case "int":
622
+ return [...INT_SAMPLES];
623
+ case "percent":
624
+ return [...PERCENT_SAMPLES];
625
+ case "keywords":
626
+ return [];
627
+ }
628
+ }
629
+ function enumerateClassNames(theme) {
630
+ const seen = /* @__PURE__ */ new Set();
631
+ const classes = [];
632
+ const templates = [];
633
+ const probeWarnings = [];
634
+ const resolves = (name) => resolveUtilityDeclarations(parseUtility(name), theme, probeWarnings) !== null;
635
+ const emit = (name, kind, root) => {
636
+ if (seen.has(name)) return;
637
+ if (!resolves(name)) return;
638
+ seen.add(name);
639
+ classes.push({ name, kind, root });
640
+ };
641
+ for (const name of STATIC_UTILITIES) emit(name, "static", null);
642
+ for (const names of [
643
+ ANIMATION_STATIC_NAMES,
644
+ BORDER_STATIC_NAMES,
645
+ BACKGROUND_STATIC_NAMES,
646
+ EFFECTS_STATIC_NAMES,
647
+ LAYOUT_STATIC_NAMES,
648
+ SVG_STATIC_NAMES,
649
+ TYPOGRAPHY_STATIC_NAMES
650
+ ]) {
651
+ for (const name of names) emit(name, "static", null);
652
+ }
653
+ for (const custom of theme.customUtilities) {
654
+ if (custom.functional) {
655
+ templates.push({ root: custom.name, kind: "custom", example: `${custom.name}-value` });
656
+ } else {
657
+ emit(custom.name, "custom", null);
658
+ }
659
+ }
660
+ for (const root of PREFIX_DISPATCH.keys()) {
661
+ const spec = UTILITY_VALUE_SPACES.get(root);
662
+ if (!spec) continue;
663
+ let spacingHit = false;
664
+ let intHit = false;
665
+ for (const kind of spec.kinds) {
666
+ for (const value of candidateValues(kind, theme)) {
667
+ const name = `${root}-${value}`;
668
+ if (seen.has(name)) continue;
669
+ if (!resolves(name)) continue;
670
+ seen.add(name);
671
+ classes.push({ name, kind, root });
672
+ if (kind === "spacing") spacingHit = true;
673
+ if (kind === "int") intHit = true;
674
+ }
675
+ }
676
+ for (const keyword of spec.keywords ?? []) {
677
+ emit(`${root}-${keyword}`, "keywords", root);
678
+ }
679
+ if (spacingHit) templates.push({ root, kind: "spacing", example: `${root}-4` });
680
+ else if (intHit) templates.push({ root, kind: "number", example: `${root}-2` });
681
+ }
682
+ classes.sort((a, b) => codepointCompare(a.name, b.name));
683
+ templates.sort((a, b) => codepointCompare(a.root, b.root));
684
+ return { classes, templates };
685
+ }
686
+
687
+ export {
688
+ CSS_ENTRY_CANDIDATES,
689
+ UTILITY_VALUE_SPACES,
690
+ enumerateClassNames
691
+ };