@nersh/render 0.1.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.
@@ -0,0 +1,216 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentType } from 'react';
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Site shapes — both the legacy template-keyed shape and the new
7
+ * composition-keyed shape. getSite returns a discriminated union;
8
+ * renderers branch on it.
9
+ *
10
+ * See /docs/superpowers/specs and plan file for architecture rationale.
11
+ */
12
+
13
+ /**
14
+ * One section rendered inside a composition.
15
+ * `id` references the sections registry; `instanceId` is unique per
16
+ * composition instance so multiple of the same section type can appear
17
+ * with independently-keyed copy.
18
+ * `children` holds nested layout shells and component blocks.
19
+ */
20
+ type SectionInstance = {
21
+ id: string;
22
+ instanceId: string;
23
+ layout?: string;
24
+ fullBleed?: boolean;
25
+ /** Marketing hero: fill layout below navbar (default on when omitted). */
26
+ fullHeight?: boolean;
27
+ hidden?: boolean;
28
+ children?: SectionInstance[];
29
+ };
30
+ declare const CompositionSiteSchema: z.ZodObject<{
31
+ slug: z.ZodString;
32
+ composition: z.ZodObject<{
33
+ id: z.ZodString;
34
+ sections: z.ZodDefault<z.ZodArray<z.ZodType<SectionInstance, unknown, z.core.$ZodTypeInternals<SectionInstance, unknown>>>>;
35
+ }, z.core.$strip>;
36
+ brandColor: z.ZodOptional<z.ZodString>;
37
+ theme: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
38
+ base: z.ZodEnum<{
39
+ mui: "mui";
40
+ "zero-point": "zero-point";
41
+ }>;
42
+ accent: z.ZodString;
43
+ typeCategory: z.ZodEnum<{
44
+ sans: "sans";
45
+ serif: "serif";
46
+ mono: "mono";
47
+ }>;
48
+ }, z.core.$strip>]>>;
49
+ designSystemId: z.ZodOptional<z.ZodString>;
50
+ skinId: z.ZodOptional<z.ZodString>;
51
+ seo: z.ZodOptional<z.ZodObject<{
52
+ title: z.ZodOptional<z.ZodString>;
53
+ description: z.ZodOptional<z.ZodString>;
54
+ ogType: z.ZodOptional<z.ZodEnum<{
55
+ article: "article";
56
+ website: "website";
57
+ profile: "profile";
58
+ }>>;
59
+ twitterCard: z.ZodOptional<z.ZodEnum<{
60
+ summary: "summary";
61
+ summary_large_image: "summary_large_image";
62
+ }>>;
63
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
+ schemaOrgType: z.ZodOptional<z.ZodEnum<{
65
+ WebSite: "WebSite";
66
+ Person: "Person";
67
+ Organization: "Organization";
68
+ CreativeWork: "CreativeWork";
69
+ Product: "Product";
70
+ LocalBusiness: "LocalBusiness";
71
+ }>>;
72
+ canonicalUrl: z.ZodOptional<z.ZodString>;
73
+ twitterHandle: z.ZodOptional<z.ZodString>;
74
+ ogImageUrl: z.ZodOptional<z.ZodString>;
75
+ ogImageSource: z.ZodOptional<z.ZodEnum<{
76
+ snap: "snap";
77
+ upload: "upload";
78
+ }>>;
79
+ ogSnappedAt: z.ZodOptional<z.ZodNumber>;
80
+ robotsIndex: z.ZodOptional<z.ZodBoolean>;
81
+ localBusiness: z.ZodOptional<z.ZodObject<{
82
+ type: z.ZodOptional<z.ZodString>;
83
+ telephone: z.ZodOptional<z.ZodString>;
84
+ email: z.ZodOptional<z.ZodString>;
85
+ address: z.ZodOptional<z.ZodObject<{
86
+ streetAddress: z.ZodOptional<z.ZodString>;
87
+ addressLocality: z.ZodOptional<z.ZodString>;
88
+ addressRegion: z.ZodOptional<z.ZodString>;
89
+ postalCode: z.ZodOptional<z.ZodString>;
90
+ addressCountry: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strip>>;
92
+ areaServed: z.ZodOptional<z.ZodString>;
93
+ priceRange: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strip>>;
95
+ geo: z.ZodOptional<z.ZodObject<{
96
+ region: z.ZodOptional<z.ZodString>;
97
+ placename: z.ZodOptional<z.ZodString>;
98
+ lat: z.ZodOptional<z.ZodNumber>;
99
+ lng: z.ZodOptional<z.ZodNumber>;
100
+ }, z.core.$strip>>;
101
+ }, z.core.$strip>>;
102
+ origin: z.ZodOptional<z.ZodEnum<{
103
+ template: "template";
104
+ "wizard-linkinbio": "wizard-linkinbio";
105
+ "wizard-marketing": "wizard-marketing";
106
+ "wizard-portfolio": "wizard-portfolio";
107
+ "wizard-blog": "wizard-blog";
108
+ builder: "builder";
109
+ }>>;
110
+ mode: z.ZodDefault<z.ZodEnum<{
111
+ builder: "builder";
112
+ easy: "easy";
113
+ }>>;
114
+ status: z.ZodDefault<z.ZodEnum<{
115
+ draft: "draft";
116
+ published: "published";
117
+ }>>;
118
+ copy: z.ZodRecord<z.ZodString, z.ZodString>;
119
+ owner: z.ZodOptional<z.ZodString>;
120
+ createdAt: z.ZodOptional<z.ZodNumber>;
121
+ updatedAt: z.ZodOptional<z.ZodNumber>;
122
+ listingEnabled: z.ZodDefault<z.ZodBoolean>;
123
+ derivedFrom: z.ZodOptional<z.ZodString>;
124
+ templateId: z.ZodOptional<z.ZodString>;
125
+ ds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
126
+ social: z.ZodOptional<z.ZodObject<{
127
+ profiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
128
+ platform: z.ZodEnum<{
129
+ link: "link";
130
+ twitter: "twitter";
131
+ instagram: "instagram";
132
+ linkedin: "linkedin";
133
+ youtube: "youtube";
134
+ tiktok: "tiktok";
135
+ bluesky: "bluesky";
136
+ github: "github";
137
+ facebook: "facebook";
138
+ threads: "threads";
139
+ substack: "substack";
140
+ mastodon: "mastodon";
141
+ site: "site";
142
+ }>;
143
+ handle: z.ZodString;
144
+ url: z.ZodString;
145
+ connectedAt: z.ZodOptional<z.ZodNumber>;
146
+ connectionId: z.ZodOptional<z.ZodString>;
147
+ }, z.core.$strip>>>;
148
+ syncFooter: z.ZodDefault<z.ZodBoolean>;
149
+ syncLinkStack: z.ZodDefault<z.ZodBoolean>;
150
+ }, z.core.$strip>>;
151
+ footerAttribution: z.ZodDefault<z.ZodEnum<{
152
+ default: "default";
153
+ custom: "custom";
154
+ hidden: "hidden";
155
+ logo: "logo";
156
+ }>>;
157
+ footerAttributionText: z.ZodOptional<z.ZodString>;
158
+ footerCopyrightText: z.ZodOptional<z.ZodString>;
159
+ footerDonateEnabled: z.ZodOptional<z.ZodBoolean>;
160
+ footerDonateWhenHidden: z.ZodOptional<z.ZodBoolean>;
161
+ customDomain: z.ZodOptional<z.ZodString>;
162
+ customDomainWww: z.ZodOptional<z.ZodString>;
163
+ hostingTier: z.ZodOptional<z.ZodEnum<{
164
+ free: "free";
165
+ paid: "paid";
166
+ }>>;
167
+ launchedAt: z.ZodOptional<z.ZodNumber>;
168
+ launchVersion: z.ZodOptional<z.ZodNumber>;
169
+ stagingPublishedAt: z.ZodOptional<z.ZodNumber>;
170
+ productionPublishedAt: z.ZodOptional<z.ZodNumber>;
171
+ googleAnalyticsId: z.ZodOptional<z.ZodString>;
172
+ }, z.core.$strip>;
173
+ type CompositionSite = z.infer<typeof CompositionSiteSchema>;
174
+
175
+ /**
176
+ * Props every section component receives. `copy` already has the instance
177
+ * prefix stripped — slots are keyed by their schema key.
178
+ * Sections style using nertia's design-system CSS vars (var(--foreground),
179
+ * var(--background), var(--accent), etc.) — the hosted site wrapper injects
180
+ * the user's brand color as --accent; dark/light mode cascades from globals.
181
+ */
182
+ interface SectionProps {
183
+ copy: Record<string, string>;
184
+ /** Set on hosted pages for live feed sections (Phase 2). */
185
+ siteSlug?: string;
186
+ /** Section instance id — used for contact form submissions. */
187
+ instanceId?: string;
188
+ layout?: string;
189
+ /** Marketing hero only — fills the main column below the navbar. */
190
+ fullHeight?: boolean;
191
+ /** Nested blocks rendered inside layout shells. */
192
+ slotContent?: ReactNode;
193
+ /** Builder-only — open insert drawer on a tab (layout shells). */
194
+ builderInsert?: {
195
+ openTab: (tab: 'structure' | 'components') => void;
196
+ };
197
+ }
198
+
199
+ type SectionRegistry = Record<string, ComponentType<SectionProps>>;
200
+ interface SiteRendererProps {
201
+ site: CompositionSite;
202
+ registry: SectionRegistry;
203
+ /** CSS isolation scope; defaults to the site slug. */
204
+ scope?: string;
205
+ }
206
+ /**
207
+ * Framework-agnostic, synchronous composition renderer.
208
+ * Mirrors the hosted CompositionRenderer loop without RSC/async/Firebase:
209
+ * sections are supplied via `registry` rather than the global getSection.
210
+ */
211
+ declare function SiteRenderer({ site, registry, scope }: SiteRendererProps): react.JSX.Element;
212
+
213
+ /** Render a composition to a static HTML string (no React runtime needed). */
214
+ declare function renderSiteToHtml(site: CompositionSite, registry: SectionRegistry, scope?: string): string;
215
+
216
+ export { type SectionRegistry, SiteRenderer, type SiteRendererProps, renderSiteToHtml };
@@ -0,0 +1,216 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentType } from 'react';
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Site shapes — both the legacy template-keyed shape and the new
7
+ * composition-keyed shape. getSite returns a discriminated union;
8
+ * renderers branch on it.
9
+ *
10
+ * See /docs/superpowers/specs and plan file for architecture rationale.
11
+ */
12
+
13
+ /**
14
+ * One section rendered inside a composition.
15
+ * `id` references the sections registry; `instanceId` is unique per
16
+ * composition instance so multiple of the same section type can appear
17
+ * with independently-keyed copy.
18
+ * `children` holds nested layout shells and component blocks.
19
+ */
20
+ type SectionInstance = {
21
+ id: string;
22
+ instanceId: string;
23
+ layout?: string;
24
+ fullBleed?: boolean;
25
+ /** Marketing hero: fill layout below navbar (default on when omitted). */
26
+ fullHeight?: boolean;
27
+ hidden?: boolean;
28
+ children?: SectionInstance[];
29
+ };
30
+ declare const CompositionSiteSchema: z.ZodObject<{
31
+ slug: z.ZodString;
32
+ composition: z.ZodObject<{
33
+ id: z.ZodString;
34
+ sections: z.ZodDefault<z.ZodArray<z.ZodType<SectionInstance, unknown, z.core.$ZodTypeInternals<SectionInstance, unknown>>>>;
35
+ }, z.core.$strip>;
36
+ brandColor: z.ZodOptional<z.ZodString>;
37
+ theme: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
38
+ base: z.ZodEnum<{
39
+ mui: "mui";
40
+ "zero-point": "zero-point";
41
+ }>;
42
+ accent: z.ZodString;
43
+ typeCategory: z.ZodEnum<{
44
+ sans: "sans";
45
+ serif: "serif";
46
+ mono: "mono";
47
+ }>;
48
+ }, z.core.$strip>]>>;
49
+ designSystemId: z.ZodOptional<z.ZodString>;
50
+ skinId: z.ZodOptional<z.ZodString>;
51
+ seo: z.ZodOptional<z.ZodObject<{
52
+ title: z.ZodOptional<z.ZodString>;
53
+ description: z.ZodOptional<z.ZodString>;
54
+ ogType: z.ZodOptional<z.ZodEnum<{
55
+ article: "article";
56
+ website: "website";
57
+ profile: "profile";
58
+ }>>;
59
+ twitterCard: z.ZodOptional<z.ZodEnum<{
60
+ summary: "summary";
61
+ summary_large_image: "summary_large_image";
62
+ }>>;
63
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
+ schemaOrgType: z.ZodOptional<z.ZodEnum<{
65
+ WebSite: "WebSite";
66
+ Person: "Person";
67
+ Organization: "Organization";
68
+ CreativeWork: "CreativeWork";
69
+ Product: "Product";
70
+ LocalBusiness: "LocalBusiness";
71
+ }>>;
72
+ canonicalUrl: z.ZodOptional<z.ZodString>;
73
+ twitterHandle: z.ZodOptional<z.ZodString>;
74
+ ogImageUrl: z.ZodOptional<z.ZodString>;
75
+ ogImageSource: z.ZodOptional<z.ZodEnum<{
76
+ snap: "snap";
77
+ upload: "upload";
78
+ }>>;
79
+ ogSnappedAt: z.ZodOptional<z.ZodNumber>;
80
+ robotsIndex: z.ZodOptional<z.ZodBoolean>;
81
+ localBusiness: z.ZodOptional<z.ZodObject<{
82
+ type: z.ZodOptional<z.ZodString>;
83
+ telephone: z.ZodOptional<z.ZodString>;
84
+ email: z.ZodOptional<z.ZodString>;
85
+ address: z.ZodOptional<z.ZodObject<{
86
+ streetAddress: z.ZodOptional<z.ZodString>;
87
+ addressLocality: z.ZodOptional<z.ZodString>;
88
+ addressRegion: z.ZodOptional<z.ZodString>;
89
+ postalCode: z.ZodOptional<z.ZodString>;
90
+ addressCountry: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strip>>;
92
+ areaServed: z.ZodOptional<z.ZodString>;
93
+ priceRange: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strip>>;
95
+ geo: z.ZodOptional<z.ZodObject<{
96
+ region: z.ZodOptional<z.ZodString>;
97
+ placename: z.ZodOptional<z.ZodString>;
98
+ lat: z.ZodOptional<z.ZodNumber>;
99
+ lng: z.ZodOptional<z.ZodNumber>;
100
+ }, z.core.$strip>>;
101
+ }, z.core.$strip>>;
102
+ origin: z.ZodOptional<z.ZodEnum<{
103
+ template: "template";
104
+ "wizard-linkinbio": "wizard-linkinbio";
105
+ "wizard-marketing": "wizard-marketing";
106
+ "wizard-portfolio": "wizard-portfolio";
107
+ "wizard-blog": "wizard-blog";
108
+ builder: "builder";
109
+ }>>;
110
+ mode: z.ZodDefault<z.ZodEnum<{
111
+ builder: "builder";
112
+ easy: "easy";
113
+ }>>;
114
+ status: z.ZodDefault<z.ZodEnum<{
115
+ draft: "draft";
116
+ published: "published";
117
+ }>>;
118
+ copy: z.ZodRecord<z.ZodString, z.ZodString>;
119
+ owner: z.ZodOptional<z.ZodString>;
120
+ createdAt: z.ZodOptional<z.ZodNumber>;
121
+ updatedAt: z.ZodOptional<z.ZodNumber>;
122
+ listingEnabled: z.ZodDefault<z.ZodBoolean>;
123
+ derivedFrom: z.ZodOptional<z.ZodString>;
124
+ templateId: z.ZodOptional<z.ZodString>;
125
+ ds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
126
+ social: z.ZodOptional<z.ZodObject<{
127
+ profiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
128
+ platform: z.ZodEnum<{
129
+ link: "link";
130
+ twitter: "twitter";
131
+ instagram: "instagram";
132
+ linkedin: "linkedin";
133
+ youtube: "youtube";
134
+ tiktok: "tiktok";
135
+ bluesky: "bluesky";
136
+ github: "github";
137
+ facebook: "facebook";
138
+ threads: "threads";
139
+ substack: "substack";
140
+ mastodon: "mastodon";
141
+ site: "site";
142
+ }>;
143
+ handle: z.ZodString;
144
+ url: z.ZodString;
145
+ connectedAt: z.ZodOptional<z.ZodNumber>;
146
+ connectionId: z.ZodOptional<z.ZodString>;
147
+ }, z.core.$strip>>>;
148
+ syncFooter: z.ZodDefault<z.ZodBoolean>;
149
+ syncLinkStack: z.ZodDefault<z.ZodBoolean>;
150
+ }, z.core.$strip>>;
151
+ footerAttribution: z.ZodDefault<z.ZodEnum<{
152
+ default: "default";
153
+ custom: "custom";
154
+ hidden: "hidden";
155
+ logo: "logo";
156
+ }>>;
157
+ footerAttributionText: z.ZodOptional<z.ZodString>;
158
+ footerCopyrightText: z.ZodOptional<z.ZodString>;
159
+ footerDonateEnabled: z.ZodOptional<z.ZodBoolean>;
160
+ footerDonateWhenHidden: z.ZodOptional<z.ZodBoolean>;
161
+ customDomain: z.ZodOptional<z.ZodString>;
162
+ customDomainWww: z.ZodOptional<z.ZodString>;
163
+ hostingTier: z.ZodOptional<z.ZodEnum<{
164
+ free: "free";
165
+ paid: "paid";
166
+ }>>;
167
+ launchedAt: z.ZodOptional<z.ZodNumber>;
168
+ launchVersion: z.ZodOptional<z.ZodNumber>;
169
+ stagingPublishedAt: z.ZodOptional<z.ZodNumber>;
170
+ productionPublishedAt: z.ZodOptional<z.ZodNumber>;
171
+ googleAnalyticsId: z.ZodOptional<z.ZodString>;
172
+ }, z.core.$strip>;
173
+ type CompositionSite = z.infer<typeof CompositionSiteSchema>;
174
+
175
+ /**
176
+ * Props every section component receives. `copy` already has the instance
177
+ * prefix stripped — slots are keyed by their schema key.
178
+ * Sections style using nertia's design-system CSS vars (var(--foreground),
179
+ * var(--background), var(--accent), etc.) — the hosted site wrapper injects
180
+ * the user's brand color as --accent; dark/light mode cascades from globals.
181
+ */
182
+ interface SectionProps {
183
+ copy: Record<string, string>;
184
+ /** Set on hosted pages for live feed sections (Phase 2). */
185
+ siteSlug?: string;
186
+ /** Section instance id — used for contact form submissions. */
187
+ instanceId?: string;
188
+ layout?: string;
189
+ /** Marketing hero only — fills the main column below the navbar. */
190
+ fullHeight?: boolean;
191
+ /** Nested blocks rendered inside layout shells. */
192
+ slotContent?: ReactNode;
193
+ /** Builder-only — open insert drawer on a tab (layout shells). */
194
+ builderInsert?: {
195
+ openTab: (tab: 'structure' | 'components') => void;
196
+ };
197
+ }
198
+
199
+ type SectionRegistry = Record<string, ComponentType<SectionProps>>;
200
+ interface SiteRendererProps {
201
+ site: CompositionSite;
202
+ registry: SectionRegistry;
203
+ /** CSS isolation scope; defaults to the site slug. */
204
+ scope?: string;
205
+ }
206
+ /**
207
+ * Framework-agnostic, synchronous composition renderer.
208
+ * Mirrors the hosted CompositionRenderer loop without RSC/async/Firebase:
209
+ * sections are supplied via `registry` rather than the global getSection.
210
+ */
211
+ declare function SiteRenderer({ site, registry, scope }: SiteRendererProps): react.JSX.Element;
212
+
213
+ /** Render a composition to a static HTML string (no React runtime needed). */
214
+ declare function renderSiteToHtml(site: CompositionSite, registry: SectionRegistry, scope?: string): string;
215
+
216
+ export { type SectionRegistry, SiteRenderer, type SiteRendererProps, renderSiteToHtml };