rainbowindex 0.6.0 → 0.7.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +543 -0
  2. package/LICENSE +16 -17
  3. package/NOTICE.md +106 -0
  4. package/README.md +219 -65
  5. package/dist/browser.d.ts +4 -2
  6. package/dist/browser.mjs +12 -4
  7. package/dist/chunk-2T7V5XLK.mjs +912 -0
  8. package/dist/chunk-6OORICWF.mjs +16 -0
  9. package/dist/{chunk-KSNYSR3C.mjs → chunk-FJOZJIKB.mjs} +2499 -329
  10. package/dist/chunk-L56IRO7A.mjs +491 -0
  11. package/dist/chunk-PZDVDEZJ.mjs +196 -0
  12. package/dist/{chunk-3LWJTLOJ.mjs → chunk-RC6DDE4L.mjs} +23 -15
  13. package/dist/chunk-TQJYVQPE.mjs +217 -0
  14. package/dist/chunk-W756NVYI.mjs +33 -0
  15. package/dist/chunk-WBESS2ZD.mjs +598 -0
  16. package/dist/{chunk-3HRMFZGE.mjs → chunk-X66Z2YHT.mjs} +2 -1
  17. package/dist/{chunk-6U4IOFOS.mjs → chunk-XQGSG2HK.mjs} +199 -555
  18. package/dist/cli.mjs +1077 -123
  19. package/dist/{index-DSgpB6bS.d.ts → context-DcBtnnan.d.ts} +47 -103
  20. package/dist/editor.d.ts +71 -433
  21. package/dist/editor.mjs +51 -368
  22. package/dist/eslint.d.ts +16 -0
  23. package/dist/eslint.mjs +32 -0
  24. package/dist/{index-4Kyaq3IZ.d.ts → imports-C9esHd5Q.d.ts} +78 -84
  25. package/dist/index-CNqdL5U0.d.ts +56 -0
  26. package/dist/index-Czx-EUwh.d.ts +138 -0
  27. package/dist/index-DW8YSxTz.d.ts +104 -0
  28. package/dist/index.d.ts +46 -5
  29. package/dist/index.mjs +33 -9
  30. package/dist/oxlint.d.ts +21 -3
  31. package/dist/oxlint.mjs +19 -1
  32. package/dist/recipe.d.ts +111 -0
  33. package/dist/recipe.mjs +71 -0
  34. package/dist/safelist-CH3_PywB.d.ts +43 -0
  35. package/dist/session-CMaskdB7.d.ts +543 -0
  36. package/dist/tailwind.css +644 -0
  37. package/dist/theme-CIZiGlce.d.ts +115 -0
  38. package/dist/vite.d.ts +10 -1
  39. package/dist/vite.mjs +266 -118
  40. package/package.json +27 -5
  41. package/dist/chunk-WK6S4HTC.mjs +0 -1921
  42. package/dist/chunk-ZR7XJMUN.mjs +0 -251
  43. package/dist/safelist-CGCtF-Fr.d.ts +0 -96
@@ -37,7 +37,10 @@ interface CompilationContext {
37
37
  fontFamilies: Set<string>;
38
38
  colorNames: Set<string>;
39
39
  }
40
-
40
+ /**
41
+ * Frozen snapshot of compilation state for SSR-safe ri() instances.
42
+ * Created by finalizeCompilationContext() and consumed by createRi().
43
+ */
41
44
  interface CompilationSnapshot {
42
45
  readonly customStaticProps: Readonly<Record<string, string[]>>;
43
46
  /** Longest root first, so `glow-outer-*` wins over `glow-*` for `glow-outer-4`. */
@@ -73,119 +76,60 @@ declare function registerCustomFontFamilies(ctx: CompilationContext, families: s
73
76
  * match the shade pattern and need no registration.
74
77
  */
75
78
  declare function registerColorNames(ctx: CompilationContext, names: string[]): void;
79
+ /**
80
+ * Publish a snapshot as the module-level state the default ri() reads.
81
+ *
82
+ * Split out of finalizeCompilationContext so a client bundle — which never runs
83
+ * a compile — can reach the same state through hydrateSnapshot(). Everything
84
+ * assigned here is already frozen-by-convention: the snapshot's arrays and Sets
85
+ * are the compile's own copies, never the mutable context's.
86
+ */
87
+ declare function publishSnapshot(snapshot: CompilationSnapshot): void;
76
88
  /**
77
89
  * Snapshot compilation context into module-level state that ri() reads from.
78
90
  * Called at the end of compile() to atomically publish the new state.
79
91
  */
80
92
  declare function finalizeCompilationContext(ctx: CompilationContext): CompilationSnapshot;
81
-
82
93
  /**
83
- * Generative color system — color domain model, OKLCH ramp generation,
84
- * and light-dark() pairing.
94
+ * A CompilationSnapshot with its Sets flattened to sorted arrays.
85
95
  *
86
- * 2 numbers (chroma + hue) → 19-stop palette with automatic dark mode.
87
- *
88
- * The ramp is sampled from a fixed reference profile (`L_PROFILE` / `C_SHAPE` /
89
- * `H_DRIFT`, captured from the reference palette): lightness is a curved,
90
- * compressed scale (low suffix → light, high → dark), chroma is an asymmetric
91
- * bell peaking at stop 500, and hue is near-flat. Dark mode is a simple ramp
92
- * reversal — the dark value is the stop the ramp reaches at the mirror position
93
- * (`1000 - suffix`), so stop 500 pivots to itself.
94
- */
95
- /** Per-color dark mode override strategy. */
96
- type ColorDarkOverride = {
97
- strategy: "mirror";
98
- } | {
99
- strategy: "fixed";
100
- } | {
101
- strategy: "shift";
102
- chromaDelta: number;
103
- hueDelta: number;
104
- };
105
- /**
106
- * Color definition — discriminated union supporting:
107
- * - Generative: `brand: 0.18 330;` → 19-stop palette with auto dark mode
108
- * - Explicit: `accent: oklch(0.72 0.21 330);` → single color value
109
- * - Pair: `surface: oklch(0.98 0.01 260) / oklch(0.15 0.01 260);` → light/dark pair
110
- * - Alias: `theme: brand;` → references another color's palette via var()
96
+ * A snapshot is built on the server and read on the client, so it has to cross
97
+ * a boundary that only carries JSON. `JSON.stringify` turns a Set into `{}`,
98
+ * silently — the class merge would then run against an empty theme and drop
99
+ * every project-defined size, weight, font slot, and color. Sorting is for
100
+ * build determinism: the same theme must produce byte-identical output, or the
101
+ * emitted module churns on every build.
111
102
  */
112
- type ColorDefinition = {
113
- type: "generative";
114
- chroma: number;
115
- hue: number;
116
- dark?: ColorDarkOverride;
117
- inline?: boolean;
118
- parabolic?: boolean;
119
- chromaBoost?: boolean;
120
- } | {
121
- type: "explicit";
122
- value: string;
123
- } | {
124
- type: "keyword";
125
- value: string;
126
- } | {
127
- type: "pair";
128
- light: string;
129
- dark: string;
130
- } | {
131
- type: "alias";
132
- source: string;
133
- };
134
- interface DarkModeConfig {
135
- mode: "auto" | "off";
136
- chromaBoost: number;
137
- hueShift: number;
103
+ interface SerializedSnapshot {
104
+ /** See {@link SNAPSHOT_FORMAT}. */
105
+ format: typeof SNAPSHOT_FORMAT;
106
+ customStaticProps: Readonly<Record<string, string[]>>;
107
+ customFunctionalProps: readonly CustomFunctionalEntry[];
108
+ textSizes: readonly string[];
109
+ fontFamilies: readonly string[];
110
+ colorNames: readonly string[];
138
111
  }
139
-
140
112
  /**
141
- * Default theme values — the static data that ships if the user writes no
142
- * directives. Only the colour palette and the spacing base ship a value; every
143
- * named scale starts empty and is filled by its directive.
113
+ * The wire shape's version. Bump it when a change would make a module written
114
+ * by an older version unreadable.
115
+ *
116
+ * This is the whole of the runtime validation. Producer and consumer are two
117
+ * functions in this file, joined by one `JSON.stringify`, so the only way the
118
+ * shapes can disagree is a *stale generated module* — one committed or cached
119
+ * from an older release. That is one failure with one fix, and checking a
120
+ * number catches it; checking every field of every array, as this used to,
121
+ * caught nothing else and left the declared type unenforced.
144
122
  */
145
-
146
- interface TextSize {
147
- fontSize: string;
148
- lineHeight: string;
149
- }
150
- /** Viewport units, and the container-query units that track a container
151
- * instead. Keep in step with `FLUID_UNITS` in directives/resolver.ts, which
152
- * validates the `unit` a `@fluid` block asks for. */
153
- type FluidUnit = "vw" | "vi" | "vmin" | "vmax" | "cqw" | "cqi" | "cqmin" | "cqmax";
154
- interface FluidConfig {
155
- min?: string;
156
- max?: string;
157
- unit?: FluidUnit;
158
- multiplier?: number;
159
- }
160
- interface AnimationDefinition {
161
- shorthand: string;
162
- keyframes: string;
163
- }
164
- interface Theme {
165
- spacing: {
166
- base: string;
167
- };
168
- colors: Record<string, ColorDefinition>;
169
- text: Record<string, TextSize>;
170
- breakpoints: Record<string, string>;
171
- shadows: Record<string, string>;
172
- weights: Record<string, number>;
173
- easing: Record<string, string>;
174
- fluid: FluidConfig;
175
- animations: Record<string, AnimationDefinition>;
176
- blur: Record<string, string>;
177
- }
123
+ declare const SNAPSHOT_FORMAT = 1;
124
+ declare function serializeSnapshot(snapshot: CompilationSnapshot): SerializedSnapshot;
178
125
  /**
179
- * Keyword corner-shape values. `superellipse(N)` is represented separately
180
- * as `{ superellipse: N }` since the numeric parameter isn't a keyword.
181
- * Single source for the type, the scale table below, and the @rounded
182
- * modifier parser (directives/parsers.ts).
126
+ * Rebuild a snapshot from its wire form.
127
+ *
128
+ * A wrong or missing {@link SNAPSHOT_FORMAT} means a generated module written
129
+ * by another release. That warns and yields the built-in defaults rather than
130
+ * throwing, because throwing here happens at import time inside someone's
131
+ * client bundle; the warning says which command puts it right.
183
132
  */
184
- declare const CORNER_SHAPE_KEYWORDS: readonly ["round", "scoop", "bevel", "notch", "square", "squircle"];
185
- type CornerShapeKeyword = (typeof CORNER_SHAPE_KEYWORDS)[number];
186
- type CornerShape = CornerShapeKeyword | {
187
- superellipse: number;
188
- };
189
- declare const defaultTheme: Theme;
133
+ declare function hydrateSnapshot(data: SerializedSnapshot): CompilationSnapshot;
190
134
 
191
- export { type AnimationDefinition as A, type ColorDefinition as C, type DarkModeConfig as D, type FluidConfig as F, type TextSize as T, type CompilationContext as a, type CompilationSnapshot as b, type Theme as c, createCompilationContext as d, defaultTheme as e, finalizeCompilationContext as f, registerCustomFontFamilies as g, registerCustomTextSizes as h, registerCustomUtility as i, type CornerShape as j, registerColorNames as r };
135
+ export { type CompilationContext as C, type SerializedSnapshot as S, type CompilationSnapshot as a, registerCustomFontFamilies as b, createCompilationContext as c, registerCustomTextSizes as d, registerCustomUtility as e, finalizeCompilationContext as f, hydrateSnapshot as h, publishSnapshot as p, registerColorNames as r, serializeSnapshot as s };