rainbowindex 0.2.2 → 0.4.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,43 +0,0 @@
1
- /**
2
- * `safelist()` — declare utility classes that must be emitted regardless of
3
- * whether the consumer's source files reference them directly.
4
- *
5
- * At runtime this is a plain identity-join: pass any number of strings (and
6
- * falsy values, which are filtered) and receive a single space-joined string
7
- * suitable for `className`. The function performs no global registration, has
8
- * no side effects, and is tree-shake-safe.
9
- *
10
- * The build-time meaning comes from the scanner: when the source-file
11
- * extractor encounters a `safelist(...)` call, it extracts every literal
12
- * string argument as a class declaration — so the classes get emitted in the
13
- * final CSS even though the consumer's source never names them literally.
14
- *
15
- * Primary use case is component libraries that ship classNames inside their
16
- * bundled code (e.g. a curated icon set whose strokes are described by
17
- * utility classes). The library wraps its declarations in `safelist(...)`,
18
- * the consumer's setup points the scanner at the library's `dist/`, and the
19
- * classes flow through unchanged. The Vite plugin auto-discovers libraries
20
- * that opt in via a `rainbowindex.safelistSources` field in their
21
- * `package.json`, so consumers typically don't have to add `@source` lines
22
- * by hand.
23
- *
24
- * const ICON_BASE = safelist("stroke-cap-round", "stroke-join-round");
25
- * const SidebarLeft = defineIcon({
26
- * primitives: SIDEBAR,
27
- * className: safelist(ICON_BASE, "-scale-x-100"),
28
- * });
29
- *
30
- * Scanner contract:
31
- * - Only STATIC string literals at the call site are extracted. Values
32
- * passed through variables (`safelist(ICON_BASE, ...)`) won't be re-read
33
- * at the outer call site, but the original `safelist("stroke-cap-round",
34
- * ...)` that produced `ICON_BASE` is itself extracted, so the classes are
35
- * still covered.
36
- * - Template literals with no `${…}` interpolation are extracted; templates
37
- * with interpolation are skipped.
38
- * - Falsy arguments are dropped at runtime so conditional fragments compose
39
- * naturally: `safelist("flex", side === "left" && "flex-row-reverse")`.
40
- */
41
- declare function safelist(...parts: ReadonlyArray<string | false | null | undefined>): string;
42
-
43
- export { safelist as s };