@nersh/render 0.1.0 → 0.2.1

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/dist/index.d.mts CHANGED
@@ -2,6 +2,157 @@ import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
3
  import { z } from 'zod';
4
4
 
5
+ /**
6
+ * Component library configuration — provider-agnostic skin source of truth.
7
+ *
8
+ * Layer 2 in the skins stack (see specs/2026-06-08-shadcn-create-skins.md):
9
+ * Provider → LibraryConfig → CompiledSkin (cssVars + structuralStyleId)
10
+ *
11
+ * shadcn is v1. MUI and other providers extend the discriminated union without
12
+ * changing site/content/pattern contracts downstream.
13
+ */
14
+
15
+ declare const CompiledSkinSchema: z.ZodObject<{
16
+ provider: z.ZodEnum<{
17
+ shadcn: "shadcn";
18
+ mui: "mui";
19
+ }>;
20
+ structuralStyleId: z.ZodString;
21
+ cssVars: z.ZodObject<{
22
+ light: z.ZodRecord<z.ZodString, z.ZodString>;
23
+ dark: z.ZodRecord<z.ZodString, z.ZodString>;
24
+ }, z.core.$strip>;
25
+ libraryConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ provider: z.ZodLiteral<"shadcn">;
27
+ shadcn: z.ZodObject<{
28
+ base: z.ZodDefault<z.ZodEnum<{
29
+ radix: "radix";
30
+ "base-ui": "base-ui";
31
+ }>>;
32
+ style: z.ZodDefault<z.ZodEnum<{
33
+ vega: "vega";
34
+ nova: "nova";
35
+ maia: "maia";
36
+ lyra: "lyra";
37
+ mira: "mira";
38
+ luma: "luma";
39
+ sera: "sera";
40
+ rhea: "rhea";
41
+ }>>;
42
+ baseColor: z.ZodDefault<z.ZodEnum<{
43
+ neutral: "neutral";
44
+ stone: "stone";
45
+ zinc: "zinc";
46
+ slate: "slate";
47
+ gray: "gray";
48
+ mauve: "mauve";
49
+ olive: "olive";
50
+ mist: "mist";
51
+ taupe: "taupe";
52
+ }>>;
53
+ theme: z.ZodDefault<z.ZodEnum<{
54
+ neutral: "neutral";
55
+ stone: "stone";
56
+ zinc: "zinc";
57
+ slate: "slate";
58
+ gray: "gray";
59
+ mauve: "mauve";
60
+ olive: "olive";
61
+ mist: "mist";
62
+ taupe: "taupe";
63
+ red: "red";
64
+ rose: "rose";
65
+ orange: "orange";
66
+ amber: "amber";
67
+ yellow: "yellow";
68
+ lime: "lime";
69
+ green: "green";
70
+ emerald: "emerald";
71
+ teal: "teal";
72
+ cyan: "cyan";
73
+ sky: "sky";
74
+ blue: "blue";
75
+ indigo: "indigo";
76
+ violet: "violet";
77
+ purple: "purple";
78
+ fuchsia: "fuchsia";
79
+ pink: "pink";
80
+ }>>;
81
+ chartColor: z.ZodDefault<z.ZodEnum<{
82
+ neutral: "neutral";
83
+ stone: "stone";
84
+ zinc: "zinc";
85
+ gray: "gray";
86
+ mauve: "mauve";
87
+ olive: "olive";
88
+ mist: "mist";
89
+ taupe: "taupe";
90
+ red: "red";
91
+ rose: "rose";
92
+ orange: "orange";
93
+ amber: "amber";
94
+ yellow: "yellow";
95
+ lime: "lime";
96
+ green: "green";
97
+ emerald: "emerald";
98
+ teal: "teal";
99
+ cyan: "cyan";
100
+ sky: "sky";
101
+ blue: "blue";
102
+ indigo: "indigo";
103
+ violet: "violet";
104
+ purple: "purple";
105
+ fuchsia: "fuchsia";
106
+ pink: "pink";
107
+ }>>;
108
+ radius: z.ZodDefault<z.ZodEnum<{
109
+ default: "default";
110
+ none: "none";
111
+ sm: "sm";
112
+ md: "md";
113
+ lg: "lg";
114
+ xl: "xl";
115
+ }>>;
116
+ font: z.ZodDefault<z.ZodString>;
117
+ fontHeading: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"inherit">, z.ZodString]>>;
118
+ iconLibrary: z.ZodDefault<z.ZodEnum<{
119
+ lucide: "lucide";
120
+ tabler: "tabler";
121
+ hugeicons: "hugeicons";
122
+ phosphor: "phosphor";
123
+ remixicon: "remixicon";
124
+ }>>;
125
+ menuColor: z.ZodDefault<z.ZodEnum<{
126
+ default: "default";
127
+ inverted: "inverted";
128
+ "default-translucent": "default-translucent";
129
+ "inverted-translucent": "inverted-translucent";
130
+ }>>;
131
+ menuAccent: z.ZodDefault<z.ZodEnum<{
132
+ subtle: "subtle";
133
+ bold: "bold";
134
+ }>>;
135
+ }, z.core.$strip>;
136
+ }, z.core.$strip>, z.ZodObject<{
137
+ provider: z.ZodLiteral<"mui">;
138
+ mui: z.ZodObject<{
139
+ theme: z.ZodString;
140
+ palette: z.ZodEnum<{
141
+ light: "light";
142
+ dark: "dark";
143
+ }>;
144
+ density: z.ZodDefault<z.ZodEnum<{
145
+ comfortable: "comfortable";
146
+ standard: "standard";
147
+ compact: "compact";
148
+ }>>;
149
+ primaryColor: z.ZodOptional<z.ZodString>;
150
+ fontFamily: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strip>;
152
+ }, z.core.$strip>], "provider">;
153
+ }, z.core.$strip>;
154
+ type CompiledSkin = z.infer<typeof CompiledSkinSchema>;
155
+
5
156
  /**
6
157
  * Site shapes — both the legacy template-keyed shape and the new
7
158
  * composition-keyed shape. getSite returns a discriminated union;
@@ -202,15 +353,57 @@ interface SiteRendererProps {
202
353
  registry: SectionRegistry;
203
354
  /** CSS isolation scope; defaults to the site slug. */
204
355
  scope?: string;
356
+ /** Layer 2 structural styles. Omit for pure CSS-var tokens (Layer 1). */
357
+ compiledSkin?: CompiledSkin;
205
358
  }
206
359
  /**
207
360
  * Framework-agnostic, synchronous composition renderer.
208
361
  * Mirrors the hosted CompositionRenderer loop without RSC/async/Firebase:
209
362
  * sections are supplied via `registry` rather than the global getSection.
210
363
  */
211
- declare function SiteRenderer({ site, registry, scope }: SiteRendererProps): react.JSX.Element;
364
+ declare function SiteRenderer({ site, registry, scope, compiledSkin }: SiteRendererProps): react.JSX.Element;
212
365
 
213
366
  /** Render a composition to a static HTML string (no React runtime needed). */
214
- declare function renderSiteToHtml(site: CompositionSite, registry: SectionRegistry, scope?: string): string;
367
+ declare function renderSiteToHtml(site: CompositionSite, registry: SectionRegistry, scope?: string, compiledSkin?: CompiledSkin): string;
368
+
369
+ /**
370
+ * Adaptive site skins — every preset responds to prefers-color-scheme automatically.
371
+ * Stored site.ds holds light-mode snapshot + optional overrides; render uses SiteSurface.
372
+ */
373
+
374
+ /** Core palette per color scheme — sections read expanded aliases on the wrapper. */
375
+ interface SkinModeTokens {
376
+ background: string;
377
+ foreground: string;
378
+ muted: string;
379
+ mutedFg: string;
380
+ border: string;
381
+ accent: string;
382
+ accentFg: string;
383
+ }
384
+ interface AdaptiveSkinDefinition {
385
+ id: string;
386
+ name: string;
387
+ /** UI swatch / SkinSwitcher preview */
388
+ font: string;
389
+ radius: number;
390
+ radiusCss: string;
391
+ fontSans: string;
392
+ fontHeading: string;
393
+ base?: boolean;
394
+ light: SkinModeTokens;
395
+ dark: SkinModeTokens;
396
+ /** Per-scheme extensions: shadows, shape scale, MD color roles, etc. */
397
+ extraLight?: Record<string, string>;
398
+ extraDark?: Record<string, string>;
399
+ }
400
+ declare function getAdaptiveSkin(id: string): AdaptiveSkinDefinition;
401
+ declare function isRegisteredSkinId(skinId: string): boolean;
402
+ declare function resolveSkinId(site: {
403
+ skinId?: string;
404
+ ds?: Record<string, string>;
405
+ }): string;
406
+ /** Builder floater + intake — shadcn themes only (themes.ts). */
407
+ declare const PHASE1_SKIN_IDS: readonly string[];
215
408
 
216
- export { type SectionRegistry, SiteRenderer, type SiteRendererProps, renderSiteToHtml };
409
+ export { type AdaptiveSkinDefinition, type CompiledSkin, PHASE1_SKIN_IDS as PRESET_SKIN_IDS, type SectionRegistry, SiteRenderer, type SiteRendererProps, type SkinModeTokens, getAdaptiveSkin, isRegisteredSkinId, renderSiteToHtml, resolveSkinId };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,157 @@ import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
3
  import { z } from 'zod';
4
4
 
5
+ /**
6
+ * Component library configuration — provider-agnostic skin source of truth.
7
+ *
8
+ * Layer 2 in the skins stack (see specs/2026-06-08-shadcn-create-skins.md):
9
+ * Provider → LibraryConfig → CompiledSkin (cssVars + structuralStyleId)
10
+ *
11
+ * shadcn is v1. MUI and other providers extend the discriminated union without
12
+ * changing site/content/pattern contracts downstream.
13
+ */
14
+
15
+ declare const CompiledSkinSchema: z.ZodObject<{
16
+ provider: z.ZodEnum<{
17
+ shadcn: "shadcn";
18
+ mui: "mui";
19
+ }>;
20
+ structuralStyleId: z.ZodString;
21
+ cssVars: z.ZodObject<{
22
+ light: z.ZodRecord<z.ZodString, z.ZodString>;
23
+ dark: z.ZodRecord<z.ZodString, z.ZodString>;
24
+ }, z.core.$strip>;
25
+ libraryConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ provider: z.ZodLiteral<"shadcn">;
27
+ shadcn: z.ZodObject<{
28
+ base: z.ZodDefault<z.ZodEnum<{
29
+ radix: "radix";
30
+ "base-ui": "base-ui";
31
+ }>>;
32
+ style: z.ZodDefault<z.ZodEnum<{
33
+ vega: "vega";
34
+ nova: "nova";
35
+ maia: "maia";
36
+ lyra: "lyra";
37
+ mira: "mira";
38
+ luma: "luma";
39
+ sera: "sera";
40
+ rhea: "rhea";
41
+ }>>;
42
+ baseColor: z.ZodDefault<z.ZodEnum<{
43
+ neutral: "neutral";
44
+ stone: "stone";
45
+ zinc: "zinc";
46
+ slate: "slate";
47
+ gray: "gray";
48
+ mauve: "mauve";
49
+ olive: "olive";
50
+ mist: "mist";
51
+ taupe: "taupe";
52
+ }>>;
53
+ theme: z.ZodDefault<z.ZodEnum<{
54
+ neutral: "neutral";
55
+ stone: "stone";
56
+ zinc: "zinc";
57
+ slate: "slate";
58
+ gray: "gray";
59
+ mauve: "mauve";
60
+ olive: "olive";
61
+ mist: "mist";
62
+ taupe: "taupe";
63
+ red: "red";
64
+ rose: "rose";
65
+ orange: "orange";
66
+ amber: "amber";
67
+ yellow: "yellow";
68
+ lime: "lime";
69
+ green: "green";
70
+ emerald: "emerald";
71
+ teal: "teal";
72
+ cyan: "cyan";
73
+ sky: "sky";
74
+ blue: "blue";
75
+ indigo: "indigo";
76
+ violet: "violet";
77
+ purple: "purple";
78
+ fuchsia: "fuchsia";
79
+ pink: "pink";
80
+ }>>;
81
+ chartColor: z.ZodDefault<z.ZodEnum<{
82
+ neutral: "neutral";
83
+ stone: "stone";
84
+ zinc: "zinc";
85
+ gray: "gray";
86
+ mauve: "mauve";
87
+ olive: "olive";
88
+ mist: "mist";
89
+ taupe: "taupe";
90
+ red: "red";
91
+ rose: "rose";
92
+ orange: "orange";
93
+ amber: "amber";
94
+ yellow: "yellow";
95
+ lime: "lime";
96
+ green: "green";
97
+ emerald: "emerald";
98
+ teal: "teal";
99
+ cyan: "cyan";
100
+ sky: "sky";
101
+ blue: "blue";
102
+ indigo: "indigo";
103
+ violet: "violet";
104
+ purple: "purple";
105
+ fuchsia: "fuchsia";
106
+ pink: "pink";
107
+ }>>;
108
+ radius: z.ZodDefault<z.ZodEnum<{
109
+ default: "default";
110
+ none: "none";
111
+ sm: "sm";
112
+ md: "md";
113
+ lg: "lg";
114
+ xl: "xl";
115
+ }>>;
116
+ font: z.ZodDefault<z.ZodString>;
117
+ fontHeading: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"inherit">, z.ZodString]>>;
118
+ iconLibrary: z.ZodDefault<z.ZodEnum<{
119
+ lucide: "lucide";
120
+ tabler: "tabler";
121
+ hugeicons: "hugeicons";
122
+ phosphor: "phosphor";
123
+ remixicon: "remixicon";
124
+ }>>;
125
+ menuColor: z.ZodDefault<z.ZodEnum<{
126
+ default: "default";
127
+ inverted: "inverted";
128
+ "default-translucent": "default-translucent";
129
+ "inverted-translucent": "inverted-translucent";
130
+ }>>;
131
+ menuAccent: z.ZodDefault<z.ZodEnum<{
132
+ subtle: "subtle";
133
+ bold: "bold";
134
+ }>>;
135
+ }, z.core.$strip>;
136
+ }, z.core.$strip>, z.ZodObject<{
137
+ provider: z.ZodLiteral<"mui">;
138
+ mui: z.ZodObject<{
139
+ theme: z.ZodString;
140
+ palette: z.ZodEnum<{
141
+ light: "light";
142
+ dark: "dark";
143
+ }>;
144
+ density: z.ZodDefault<z.ZodEnum<{
145
+ comfortable: "comfortable";
146
+ standard: "standard";
147
+ compact: "compact";
148
+ }>>;
149
+ primaryColor: z.ZodOptional<z.ZodString>;
150
+ fontFamily: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strip>;
152
+ }, z.core.$strip>], "provider">;
153
+ }, z.core.$strip>;
154
+ type CompiledSkin = z.infer<typeof CompiledSkinSchema>;
155
+
5
156
  /**
6
157
  * Site shapes — both the legacy template-keyed shape and the new
7
158
  * composition-keyed shape. getSite returns a discriminated union;
@@ -202,15 +353,57 @@ interface SiteRendererProps {
202
353
  registry: SectionRegistry;
203
354
  /** CSS isolation scope; defaults to the site slug. */
204
355
  scope?: string;
356
+ /** Layer 2 structural styles. Omit for pure CSS-var tokens (Layer 1). */
357
+ compiledSkin?: CompiledSkin;
205
358
  }
206
359
  /**
207
360
  * Framework-agnostic, synchronous composition renderer.
208
361
  * Mirrors the hosted CompositionRenderer loop without RSC/async/Firebase:
209
362
  * sections are supplied via `registry` rather than the global getSection.
210
363
  */
211
- declare function SiteRenderer({ site, registry, scope }: SiteRendererProps): react.JSX.Element;
364
+ declare function SiteRenderer({ site, registry, scope, compiledSkin }: SiteRendererProps): react.JSX.Element;
212
365
 
213
366
  /** Render a composition to a static HTML string (no React runtime needed). */
214
- declare function renderSiteToHtml(site: CompositionSite, registry: SectionRegistry, scope?: string): string;
367
+ declare function renderSiteToHtml(site: CompositionSite, registry: SectionRegistry, scope?: string, compiledSkin?: CompiledSkin): string;
368
+
369
+ /**
370
+ * Adaptive site skins — every preset responds to prefers-color-scheme automatically.
371
+ * Stored site.ds holds light-mode snapshot + optional overrides; render uses SiteSurface.
372
+ */
373
+
374
+ /** Core palette per color scheme — sections read expanded aliases on the wrapper. */
375
+ interface SkinModeTokens {
376
+ background: string;
377
+ foreground: string;
378
+ muted: string;
379
+ mutedFg: string;
380
+ border: string;
381
+ accent: string;
382
+ accentFg: string;
383
+ }
384
+ interface AdaptiveSkinDefinition {
385
+ id: string;
386
+ name: string;
387
+ /** UI swatch / SkinSwitcher preview */
388
+ font: string;
389
+ radius: number;
390
+ radiusCss: string;
391
+ fontSans: string;
392
+ fontHeading: string;
393
+ base?: boolean;
394
+ light: SkinModeTokens;
395
+ dark: SkinModeTokens;
396
+ /** Per-scheme extensions: shadows, shape scale, MD color roles, etc. */
397
+ extraLight?: Record<string, string>;
398
+ extraDark?: Record<string, string>;
399
+ }
400
+ declare function getAdaptiveSkin(id: string): AdaptiveSkinDefinition;
401
+ declare function isRegisteredSkinId(skinId: string): boolean;
402
+ declare function resolveSkinId(site: {
403
+ skinId?: string;
404
+ ds?: Record<string, string>;
405
+ }): string;
406
+ /** Builder floater + intake — shadcn themes only (themes.ts). */
407
+ declare const PHASE1_SKIN_IDS: readonly string[];
215
408
 
216
- export { type SectionRegistry, SiteRenderer, type SiteRendererProps, renderSiteToHtml };
409
+ export { type AdaptiveSkinDefinition, type CompiledSkin, PHASE1_SKIN_IDS as PRESET_SKIN_IDS, type SectionRegistry, SiteRenderer, type SiteRendererProps, type SkinModeTokens, getAdaptiveSkin, isRegisteredSkinId, renderSiteToHtml, resolveSkinId };