@makerinc/ssr-component 1.0.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.
package/README.md ADDED
@@ -0,0 +1,393 @@
1
+ # @maker/ssr-component
2
+
3
+ React component for embedding [Maker](https://ai.maker.co) projects with server-side rendering (SSR).
4
+
5
+ ## Features
6
+
7
+ - Server-side rendering for optimal performance
8
+ - SEO-friendly with meta tags and proper HTML structure
9
+ - Client-side hydration for interactive components
10
+ - TypeScript support
11
+ - Works with Next.js, React Server Components, and any React framework
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @maker/ssr-component
17
+ ```
18
+
19
+ or
20
+
21
+ ```bash
22
+ yarn add @maker/ssr-component
23
+ ```
24
+
25
+ or
26
+
27
+ ```bash
28
+ pnpm add @maker/ssr-component
29
+ ```
30
+
31
+ ## Prerequisites
32
+
33
+ Before using this package, you'll need:
34
+
35
+ 1. **API Key**: A Maker SSR API key (contact Maker team to obtain one)
36
+ 2. **Project ID**: The unique identifier for your Maker project
37
+
38
+ Set your API key as an environment variable:
39
+
40
+ ```env
41
+ MAKER_SSR_API_KEY=your_api_key_here
42
+ ```
43
+
44
+ ## API Key Handling
45
+
46
+ The `MakerComponent` requires an `apiKey` prop to authenticate with the Maker SSR API. Here are the recommended patterns:
47
+
48
+ ### Environment Variable (Recommended)
49
+
50
+ Store your API key in environment variables and pass it to the component:
51
+
52
+ ```tsx
53
+ const apiKey = process.env.MAKER_SSR_API_KEY!;
54
+
55
+ <MakerComponent apiKey={apiKey} projectId="your_project_id" />
56
+ ```
57
+
58
+ ### Validation Pattern
59
+
60
+ Always validate the API key before rendering:
61
+
62
+ ```tsx
63
+ export default async function Page() {
64
+ const apiKey = process.env.MAKER_SSR_API_KEY;
65
+
66
+ if (!apiKey) {
67
+ throw new Error("MAKER_SSR_API_KEY is required");
68
+ }
69
+
70
+ return <MakerComponent apiKey={apiKey} projectId="your_project_id" />;
71
+ }
72
+ ```
73
+
74
+ ### Graceful Error Handling
75
+
76
+ For better user experience, handle missing API keys gracefully:
77
+
78
+ ```tsx
79
+ export default async function Page() {
80
+ const apiKey = process.env.MAKER_SSR_API_KEY;
81
+
82
+ if (!apiKey) {
83
+ return <div>Configuration error: API key not found</div>;
84
+ }
85
+
86
+ return <MakerComponent apiKey={apiKey} projectId="your_project_id" />;
87
+ }
88
+ ```
89
+
90
+ **Security Note:** Never expose your API key in client-side code. Always access it from environment variables on the server side.
91
+
92
+ ## Usage
93
+
94
+ ### Next.js (App Router)
95
+
96
+ **Basic Usage:**
97
+
98
+ ```tsx
99
+ import { MakerComponent } from "@maker/ssr-component";
100
+
101
+ export default async function Page() {
102
+ const apiKey = process.env.MAKER_SSR_API_KEY!;
103
+
104
+ return (
105
+ <div>
106
+ <h1>My Page</h1>
107
+ <MakerComponent
108
+ apiKey={apiKey}
109
+ projectId="your_project_id"
110
+ options={{
111
+ debug: false,
112
+ device: "desktop",
113
+ }}
114
+ />
115
+ </div>
116
+ );
117
+ }
118
+ ```
119
+
120
+ **With API Key Validation:**
121
+
122
+ ```tsx
123
+ import { MakerComponent } from "@maker/ssr-component";
124
+
125
+ export default async function Page() {
126
+ const apiKey = process.env.MAKER_SSR_API_KEY;
127
+
128
+ if (!apiKey) {
129
+ return (
130
+ <div>
131
+ <h1>Configuration Error</h1>
132
+ <p>MAKER_SSR_API_KEY is not configured</p>
133
+ </div>
134
+ );
135
+ }
136
+
137
+ return (
138
+ <div>
139
+ <h1>My Page</h1>
140
+ <MakerComponent
141
+ apiKey={apiKey}
142
+ projectId="your_project_id"
143
+ options={{
144
+ debug: false,
145
+ device: "desktop",
146
+ }}
147
+ />
148
+ </div>
149
+ );
150
+ }
151
+ ```
152
+
153
+ **With Cache Busting:**
154
+
155
+ Use `cacheBust: true` to bypass the cache and fetch fresh content. This is useful during development or when you need to ensure users see the latest version:
156
+
157
+ ```tsx
158
+ import { MakerComponent } from "@maker/ssr-component";
159
+
160
+ export default async function Page() {
161
+ const apiKey = process.env.MAKER_SSR_API_KEY!;
162
+
163
+ return (
164
+ <div>
165
+ <h1>My Page</h1>
166
+ <MakerComponent
167
+ apiKey={apiKey}
168
+ projectId="your_project_id"
169
+ options={{
170
+ device: "desktop",
171
+ cacheBust: true, // Bypass cache and fetch fresh content
172
+ }}
173
+ />
174
+ </div>
175
+ );
176
+ }
177
+ ```
178
+
179
+ ### Next.js (Pages Router)
180
+
181
+ ```tsx
182
+ import { MakerComponent } from "@maker/ssr-component";
183
+
184
+ export default function Page({ pageData }) {
185
+ return (
186
+ <div>
187
+ <h1>My Page</h1>
188
+ {/* You'll need to implement the server-side fetch yourself */}
189
+ </div>
190
+ );
191
+ }
192
+
193
+ export async function getServerSideProps() {
194
+ // Fetch data server-side
195
+ const response = await fetch("https://ssr.maker.new/api/ssr/v1/content", {
196
+ method: "POST",
197
+ headers: {
198
+ Authorization: `Bearer ${process.env.MAKER_SSR_API_KEY}`,
199
+ "Content-Type": "application/json",
200
+ },
201
+ body: JSON.stringify({
202
+ idn: "your_project_id",
203
+ }),
204
+ });
205
+
206
+ const pageData = await response.json();
207
+ return { props: { pageData } };
208
+ }
209
+ ```
210
+
211
+ ### Custom React SSR Setup
212
+
213
+ If you're using a custom React SSR setup, you can import and use the components directly:
214
+
215
+ ```tsx
216
+ import { MakerComponent } from "@maker/ssr-component";
217
+
218
+ // In your server-side rendering function
219
+ async function renderPage() {
220
+ const apiKey = process.env.MAKER_SSR_API_KEY;
221
+
222
+ if (!apiKey) {
223
+ throw new Error("MAKER_SSR_API_KEY environment variable is not set");
224
+ }
225
+
226
+ return (
227
+ <html>
228
+ <body>
229
+ <MakerComponent apiKey={apiKey} projectId="your_project_id" />
230
+ </body>
231
+ </html>
232
+ );
233
+ }
234
+ ```
235
+
236
+ ## API Reference
237
+
238
+ ### MakerComponent
239
+
240
+ The main component for embedding Maker projects.
241
+
242
+ #### Props
243
+
244
+ | Prop | Type | Required | Description |
245
+ | ----------- | ------------------------- | -------- | ----------------------------------------------------- |
246
+ | `apiKey` | `string` | Yes | Your Maker SSR API key |
247
+ | `projectId` | `string` | Yes | Your Maker project ID |
248
+ | `options` | `MakerComponentOptions` | No | Configuration options (see below) |
249
+
250
+ #### MakerComponentOptions
251
+
252
+ | Option | Type | Default | Description |
253
+ | ------------ | ------------------------------------ | ------- | -------------------------------------------------- |
254
+ | `debug` | `boolean` | `false` | Enable debug logging |
255
+ | `device` | `"mobile" \| "desktop" \| "tablet"` | - | Specify device type for responsive rendering |
256
+ | `cacheBust` | `boolean` | `false` | Bypass cache and fetch fresh content |
257
+
258
+ ### MakerClientScripts
259
+
260
+ A client-side component that handles script hydration. This is used internally by `MakerComponent` but can be used separately if needed.
261
+
262
+ #### Props
263
+
264
+ | Prop | Type | Required | Description |
265
+ | --------- | ---------- | -------- | -------------------------- |
266
+ | `scripts` | `Script[]` | Yes | Array of scripts to inject |
267
+
268
+ ### Types
269
+
270
+ ```typescript
271
+ export type MakerComponentOptions = {
272
+ debug?: boolean;
273
+ device?: "mobile" | "desktop" | "tablet";
274
+ cacheBust?: boolean;
275
+ };
276
+
277
+ export type Script = {
278
+ src: string;
279
+ inline: string | null;
280
+ type?: string;
281
+ };
282
+
283
+ export type PageData = {
284
+ meta: Array<{
285
+ charset?: string;
286
+ name?: string;
287
+ property?: string;
288
+ content?: string;
289
+ }>;
290
+ fonts: string[];
291
+ title: string;
292
+ stylesheets: string[];
293
+ inlineStyles: string[];
294
+ scripts: Script[];
295
+ body: string;
296
+ };
297
+ ```
298
+
299
+ ## Environment Variables
300
+
301
+ | Variable | Required | Description |
302
+ | -------------------- | -------- | -------------------- |
303
+ | `MAKER_SSR_API_KEY` | Yes | Your Maker API key |
304
+
305
+ ## How It Works
306
+
307
+ 1. **Server-Side**: The component fetches pre-rendered content from the Maker SSR API
308
+ 2. **Render**: HTML content, styles, and metadata are injected into your page
309
+ 3. **Client Hydration**: JavaScript loads and executes, making the content interactive
310
+ 4. **Interactive**: The embedded project becomes fully functional after hydration
311
+
312
+ ## Caching and Performance
313
+
314
+ The Maker SSR API caches content by default for optimal performance. You have several options to control caching behavior:
315
+
316
+ ### Cache Busting
317
+
318
+ Use the `cacheBust` option to bypass the cache and fetch fresh content:
319
+
320
+ ```tsx
321
+ <MakerComponent
322
+ apiKey={apiKey}
323
+ projectId="your_project_id"
324
+ options={{ cacheBust: true }}
325
+ />
326
+ ```
327
+
328
+ **Note:** Set `cacheBust: true` during development or when you need to ensure users see the latest version. For production, rely on caching strategies below for better performance.
329
+
330
+ ### Next.js App Router
331
+
332
+ Use Next.js revalidation for caching:
333
+
334
+ ```tsx
335
+ import { MakerComponent } from "@maker/ssr-component";
336
+
337
+ // Revalidate every 60 seconds
338
+ export const revalidate = 60;
339
+
340
+ export default async function Page() {
341
+ const apiKey = process.env.MAKER_SSR_API_KEY!;
342
+
343
+ return <MakerComponent apiKey={apiKey} projectId="your_project_id" />;
344
+ }
345
+ ```
346
+
347
+ ### Custom Caching
348
+
349
+ Implement your own caching strategy to reduce API calls:
350
+
351
+ ```tsx
352
+ import { cache } from "react";
353
+
354
+ const getMakerContent = cache(async (projectId: string) => {
355
+ // Your caching logic here
356
+ // Could use Redis, memory cache, etc.
357
+ });
358
+ ```
359
+
360
+ ## Troubleshooting
361
+
362
+ ### Error: MAKER_SSR_API_KEY is not set
363
+
364
+ Make sure you've set the `MAKER_SSR_API_KEY` environment variable:
365
+
366
+ ```env
367
+ MAKER_SSR_API_KEY=your_api_key_here
368
+ ```
369
+
370
+ ### Styles Not Loading
371
+
372
+ - Verify your Content Security Policy allows external resources from Maker CDN
373
+ - Check browser console for CORS errors
374
+ - Ensure stylesheet URLs are accessible
375
+
376
+ ### Scripts Not Executing
377
+
378
+ - Check browser console for JavaScript errors
379
+ - Verify the `DOMContentLoaded` event is being fired
380
+ - Check for Content Security Policy restrictions
381
+
382
+ ## Requirements
383
+
384
+ - React >= 18.0.0
385
+ - react-dom >= 18.0.0
386
+
387
+ ## License
388
+
389
+ MIT
390
+
391
+ ## Support
392
+
393
+ For issues, questions, or feature requests, contact the Maker team at [ai.maker.co](https://ai.maker.co).
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+
3
+ type Script = {
4
+ src: string;
5
+ inline: string | null;
6
+ type?: string;
7
+ };
8
+ type PageData = {
9
+ meta: Array<{
10
+ charset?: string;
11
+ name?: string;
12
+ property?: string;
13
+ content?: string;
14
+ }>;
15
+ fonts: string[];
16
+ title: string;
17
+ stylesheets: string[];
18
+ inlineStyles: string[];
19
+ scripts: Script[];
20
+ body: string;
21
+ };
22
+ type MakerComponentOptions = {
23
+ debug?: boolean;
24
+ device?: "mobile" | "desktop" | "tablet";
25
+ cacheBust?: boolean;
26
+ };
27
+
28
+ declare function MakerComponent({ apiKey, projectId, options, }: {
29
+ apiKey: string;
30
+ projectId: string;
31
+ options?: MakerComponentOptions;
32
+ }): Promise<React.JSX.Element>;
33
+
34
+ export { MakerComponent, type MakerComponentOptions, type PageData, type Script };
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+
3
+ type Script = {
4
+ src: string;
5
+ inline: string | null;
6
+ type?: string;
7
+ };
8
+ type PageData = {
9
+ meta: Array<{
10
+ charset?: string;
11
+ name?: string;
12
+ property?: string;
13
+ content?: string;
14
+ }>;
15
+ fonts: string[];
16
+ title: string;
17
+ stylesheets: string[];
18
+ inlineStyles: string[];
19
+ scripts: Script[];
20
+ body: string;
21
+ };
22
+ type MakerComponentOptions = {
23
+ debug?: boolean;
24
+ device?: "mobile" | "desktop" | "tablet";
25
+ cacheBust?: boolean;
26
+ };
27
+
28
+ declare function MakerComponent({ apiKey, projectId, options, }: {
29
+ apiKey: string;
30
+ projectId: string;
31
+ options?: MakerComponentOptions;
32
+ }): Promise<React.JSX.Element>;
33
+
34
+ export { MakerComponent, type MakerComponentOptions, type PageData, type Script };
package/dist/index.js ADDED
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var React__default = /*#__PURE__*/_interopDefault(React);
8
+
9
+ // src/maker-component.tsx
10
+ var VERSION = "v1";
11
+ async function fetchSSRContent(apiKey, projectId, options) {
12
+ const response = await fetch(
13
+ `https://ssr.maker.new/api/ssr/${VERSION}/content`,
14
+ {
15
+ method: "POST",
16
+ headers: {
17
+ Authorization: `Bearer ${apiKey}`
18
+ },
19
+ body: JSON.stringify({
20
+ idn: projectId,
21
+ device: options?.device,
22
+ cacheBust: options?.cacheBust
23
+ })
24
+ }
25
+ );
26
+ if (options?.debug) {
27
+ console.log(
28
+ "[debug-maker-component] Debug info: ",
29
+ response.headers.get("x-debug-info")
30
+ );
31
+ }
32
+ if (!response.ok) {
33
+ throw new Error("Failed to fetch SSR content");
34
+ }
35
+ return response.json();
36
+ }
37
+ function renderMetaTags(meta) {
38
+ return meta?.map(
39
+ (m, i) => m.charset ? /* @__PURE__ */ React__default.default.createElement("meta", { key: `m-cs-${i}`, charSet: m.charset }) : m.name ? /* @__PURE__ */ React__default.default.createElement("meta", { key: `m-n-${i}`, name: m.name, content: m.content || "" }) : m.property ? /* @__PURE__ */ React__default.default.createElement("meta", { key: `m-p-${i}`, property: m.property, content: m.content || "" }) : null
40
+ );
41
+ }
42
+ function renderFonts(fonts) {
43
+ return fonts.map(
44
+ (href, i) => /\.(woff2?|otf|ttf)(\?|#|$)/i.test(href) ? /* @__PURE__ */ React__default.default.createElement(
45
+ "link",
46
+ {
47
+ key: `font-${i}`,
48
+ rel: "preload",
49
+ as: "font",
50
+ href,
51
+ crossOrigin: "anonymous"
52
+ }
53
+ ) : /* @__PURE__ */ React__default.default.createElement("link", { key: `mkr-font-css-${i}`, rel: "stylesheet", href })
54
+ );
55
+ }
56
+ function renderStylesheets(stylesheets) {
57
+ return stylesheets.map((href, i) => /* @__PURE__ */ React__default.default.createElement("link", { key: `mkr-css-${i}`, rel: "stylesheet", href }));
58
+ }
59
+ function renderInlineStyles(inlineStyles) {
60
+ return inlineStyles?.map((css, i) => /* @__PURE__ */ React__default.default.createElement(
61
+ "style",
62
+ {
63
+ key: `mkr-inline-css-${i}`,
64
+ dangerouslySetInnerHTML: { __html: css }
65
+ }
66
+ ));
67
+ }
68
+ function renderScripts(scripts) {
69
+ if (scripts && scripts.length > 0) {
70
+ return scripts.reduce((acc, script) => {
71
+ const found = acc.find(
72
+ (s) => s.src === script.src && s.inline === script.inline
73
+ );
74
+ if (!found) {
75
+ acc.push(script);
76
+ }
77
+ return acc;
78
+ }, []).map((script) => /* @__PURE__ */ React__default.default.createElement(
79
+ "script",
80
+ {
81
+ key: script.src || script.inline,
82
+ type: script.type || "text/javascript",
83
+ src: script.src,
84
+ dangerouslySetInnerHTML: script.inline ? { __html: script.inline } : void 0
85
+ }
86
+ ));
87
+ }
88
+ }
89
+ async function MakerComponent({
90
+ apiKey,
91
+ projectId,
92
+ options
93
+ }) {
94
+ if (!apiKey) {
95
+ throw new Error("MAKER_SSR_API_KEY is not set in environment variables");
96
+ }
97
+ if (!projectId) {
98
+ throw new Error("Project ID is required");
99
+ }
100
+ if (options?.debug) {
101
+ console.log("[debug-maker-component] Props: ", {
102
+ projectId,
103
+ options
104
+ });
105
+ }
106
+ const pageData = await fetchSSRContent(apiKey, projectId, options);
107
+ return /* @__PURE__ */ React__default.default.createElement(
108
+ "main",
109
+ {
110
+ className: `mkr-component-${projectId}`,
111
+ suppressHydrationWarning: true
112
+ },
113
+ /* @__PURE__ */ React__default.default.createElement("section", { "aria-hidden": true, className: "hidden" }, renderMetaTags(pageData.meta), renderFonts(pageData.fonts), renderStylesheets(pageData.stylesheets), renderInlineStyles(pageData.inlineStyles)),
114
+ /* @__PURE__ */ React__default.default.createElement(
115
+ "div",
116
+ {
117
+ dangerouslySetInnerHTML: { __html: pageData.body },
118
+ suppressHydrationWarning: true
119
+ }
120
+ ),
121
+ renderScripts(pageData.scripts)
122
+ );
123
+ }
124
+
125
+ exports.MakerComponent = MakerComponent;
126
+ //# sourceMappingURL=index.js.map
127
+ //# sourceMappingURL=index.js.map
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AC7C,SAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AACA,EAAA,MAAM,QAAA,GAAW,MAAM,eAAA,CAAgB,MAAA,EAAQ,WAAW,OAAO,CAAA;AACjE,EAAA,uBACEA,sBAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,iBAAiB,SAAS,CAAA,CAAA;AAAA,MACrC,wBAAA,EAA0B;AAAA,KAAA;AAAA,oBAE1BA,sBAAA,CAAA,aAAA,CAAC,aAAQ,aAAA,EAAW,IAAA,EAAC,WAAU,QAAA,EAAA,EAC5B,cAAA,CAAe,SAAS,IAAI,CAAA,EAC5B,YAAY,QAAA,CAAS,KAAK,GAC1B,iBAAA,CAAkB,QAAA,CAAS,WAAW,CAAA,EACtC,kBAAA,CAAmB,QAAA,CAAS,YAAY,CAC3C,CAAA;AAAA,oBACAA,sBAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,uBAAA,EAAyB,EAAE,MAAA,EAAQ,QAAA,CAAS,IAAA,EAAK;AAAA,QACjD,wBAAA,EAA0B;AAAA;AAAA,KAC5B;AAAA,IACC,aAAA,CAAc,SAAS,OAAO;AAAA,GACjC;AAEJ","file":"index.js","sourcesContent":["import React from \"react\";\nimport type { MakerComponentOptions, PageData, Script } from \"./types\";\n\nconst VERSION = \"v1\";\n\nasync function fetchSSRContent(\n apiKey: string,\n projectId: string,\n options?: MakerComponentOptions\n): Promise<PageData> {\n const response = await fetch(\n `https://ssr.maker.new/api/ssr/${VERSION}/content`,\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n idn: projectId,\n device: options?.device,\n cacheBust: options?.cacheBust,\n }),\n }\n );\n if (options?.debug) {\n console.log(\n \"[debug-maker-component] Debug info: \",\n response.headers.get(\"x-debug-info\")\n );\n }\n if (!response.ok) {\n throw new Error(\"Failed to fetch SSR content\");\n }\n return response.json();\n}\n\nfunction renderMetaTags(meta: PageData[\"meta\"]) {\n return meta?.map((m, i) =>\n m.charset ? (\n <meta key={`m-cs-${i}`} charSet={m.charset} />\n ) : m.name ? (\n <meta key={`m-n-${i}`} name={m.name} content={m.content || \"\"} />\n ) : m.property ? (\n <meta key={`m-p-${i}`} property={m.property} content={m.content || \"\"} />\n ) : null\n );\n}\n\nfunction renderFonts(fonts: string[]) {\n return fonts.map((href, i) =>\n /\\.(woff2?|otf|ttf)(\\?|#|$)/i.test(href) ? (\n <link\n key={`font-${i}`}\n rel=\"preload\"\n as=\"font\"\n href={href}\n crossOrigin=\"anonymous\"\n />\n ) : (\n <link key={`mkr-font-css-${i}`} rel=\"stylesheet\" href={href} />\n )\n );\n}\n\nfunction renderStylesheets(stylesheets: string[]) {\n return stylesheets.map((href, i) => (\n <link key={`mkr-css-${i}`} rel=\"stylesheet\" href={href} />\n ));\n}\n\nfunction renderInlineStyles(inlineStyles: string[]) {\n return inlineStyles?.map((css, i) => (\n <style\n key={`mkr-inline-css-${i}`}\n dangerouslySetInnerHTML={{ __html: css }}\n />\n ));\n}\n\nfunction renderScripts(scripts: Script[]) {\n if (scripts && scripts.length > 0) {\n return scripts\n .reduce<Script[]>((acc, script) => {\n const found = acc.find(\n (s) => s.src === script.src && s.inline === script.inline\n );\n if (!found) {\n acc.push(script);\n }\n return acc;\n }, [])\n .map((script) => (\n <script\n key={script.src || script.inline}\n type={script.type || \"text/javascript\"}\n src={script.src}\n dangerouslySetInnerHTML={\n script.inline ? { __html: script.inline } : undefined\n }\n />\n ));\n }\n}\n\nexport async function MakerComponent({\n apiKey,\n projectId,\n options,\n}: {\n apiKey: string;\n projectId: string;\n options?: MakerComponentOptions;\n}) {\n if (!apiKey) {\n throw new Error(\"MAKER_SSR_API_KEY is not set in environment variables\");\n }\n if (!projectId) {\n throw new Error(\"Project ID is required\");\n }\n if (options?.debug) {\n console.log(\"[debug-maker-component] Props: \", {\n projectId,\n options,\n });\n }\n const pageData = await fetchSSRContent(apiKey, projectId, options);\n return (\n <main\n className={`mkr-component-${projectId}`}\n suppressHydrationWarning={true}\n >\n <section aria-hidden className=\"hidden\">\n {renderMetaTags(pageData.meta)}\n {renderFonts(pageData.fonts)}\n {renderStylesheets(pageData.stylesheets)}\n {renderInlineStyles(pageData.inlineStyles)}\n </section>\n <div\n dangerouslySetInnerHTML={{ __html: pageData.body }}\n suppressHydrationWarning={true}\n />\n {renderScripts(pageData.scripts)}\n </main>\n );\n}\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+
3
+ // src/maker-component.tsx
4
+ var VERSION = "v1";
5
+ async function fetchSSRContent(apiKey, projectId, options) {
6
+ const response = await fetch(
7
+ `https://ssr.maker.new/api/ssr/${VERSION}/content`,
8
+ {
9
+ method: "POST",
10
+ headers: {
11
+ Authorization: `Bearer ${apiKey}`
12
+ },
13
+ body: JSON.stringify({
14
+ idn: projectId,
15
+ device: options?.device,
16
+ cacheBust: options?.cacheBust
17
+ })
18
+ }
19
+ );
20
+ if (options?.debug) {
21
+ console.log(
22
+ "[debug-maker-component] Debug info: ",
23
+ response.headers.get("x-debug-info")
24
+ );
25
+ }
26
+ if (!response.ok) {
27
+ throw new Error("Failed to fetch SSR content");
28
+ }
29
+ return response.json();
30
+ }
31
+ function renderMetaTags(meta) {
32
+ return meta?.map(
33
+ (m, i) => m.charset ? /* @__PURE__ */ React.createElement("meta", { key: `m-cs-${i}`, charSet: m.charset }) : m.name ? /* @__PURE__ */ React.createElement("meta", { key: `m-n-${i}`, name: m.name, content: m.content || "" }) : m.property ? /* @__PURE__ */ React.createElement("meta", { key: `m-p-${i}`, property: m.property, content: m.content || "" }) : null
34
+ );
35
+ }
36
+ function renderFonts(fonts) {
37
+ return fonts.map(
38
+ (href, i) => /\.(woff2?|otf|ttf)(\?|#|$)/i.test(href) ? /* @__PURE__ */ React.createElement(
39
+ "link",
40
+ {
41
+ key: `font-${i}`,
42
+ rel: "preload",
43
+ as: "font",
44
+ href,
45
+ crossOrigin: "anonymous"
46
+ }
47
+ ) : /* @__PURE__ */ React.createElement("link", { key: `mkr-font-css-${i}`, rel: "stylesheet", href })
48
+ );
49
+ }
50
+ function renderStylesheets(stylesheets) {
51
+ return stylesheets.map((href, i) => /* @__PURE__ */ React.createElement("link", { key: `mkr-css-${i}`, rel: "stylesheet", href }));
52
+ }
53
+ function renderInlineStyles(inlineStyles) {
54
+ return inlineStyles?.map((css, i) => /* @__PURE__ */ React.createElement(
55
+ "style",
56
+ {
57
+ key: `mkr-inline-css-${i}`,
58
+ dangerouslySetInnerHTML: { __html: css }
59
+ }
60
+ ));
61
+ }
62
+ function renderScripts(scripts) {
63
+ if (scripts && scripts.length > 0) {
64
+ return scripts.reduce((acc, script) => {
65
+ const found = acc.find(
66
+ (s) => s.src === script.src && s.inline === script.inline
67
+ );
68
+ if (!found) {
69
+ acc.push(script);
70
+ }
71
+ return acc;
72
+ }, []).map((script) => /* @__PURE__ */ React.createElement(
73
+ "script",
74
+ {
75
+ key: script.src || script.inline,
76
+ type: script.type || "text/javascript",
77
+ src: script.src,
78
+ dangerouslySetInnerHTML: script.inline ? { __html: script.inline } : void 0
79
+ }
80
+ ));
81
+ }
82
+ }
83
+ async function MakerComponent({
84
+ apiKey,
85
+ projectId,
86
+ options
87
+ }) {
88
+ if (!apiKey) {
89
+ throw new Error("MAKER_SSR_API_KEY is not set in environment variables");
90
+ }
91
+ if (!projectId) {
92
+ throw new Error("Project ID is required");
93
+ }
94
+ if (options?.debug) {
95
+ console.log("[debug-maker-component] Props: ", {
96
+ projectId,
97
+ options
98
+ });
99
+ }
100
+ const pageData = await fetchSSRContent(apiKey, projectId, options);
101
+ return /* @__PURE__ */ React.createElement(
102
+ "main",
103
+ {
104
+ className: `mkr-component-${projectId}`,
105
+ suppressHydrationWarning: true
106
+ },
107
+ /* @__PURE__ */ React.createElement("section", { "aria-hidden": true, className: "hidden" }, renderMetaTags(pageData.meta), renderFonts(pageData.fonts), renderStylesheets(pageData.stylesheets), renderInlineStyles(pageData.inlineStyles)),
108
+ /* @__PURE__ */ React.createElement(
109
+ "div",
110
+ {
111
+ dangerouslySetInnerHTML: { __html: pageData.body },
112
+ suppressHydrationWarning: true
113
+ }
114
+ ),
115
+ renderScripts(pageData.scripts)
116
+ );
117
+ }
118
+
119
+ export { MakerComponent };
120
+ //# sourceMappingURL=index.mjs.map
121
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/maker-component.tsx"],"names":[],"mappings":";;;AAGA,IAAM,OAAA,GAAU,IAAA;AAEhB,eAAe,eAAA,CACb,MAAA,EACA,SAAA,EACA,OAAA,EACmB;AACnB,EAAA,MAAM,WAAW,MAAM,KAAA;AAAA,IACrB,iCAAiC,OAAO,CAAA,QAAA,CAAA;AAAA,IACxC;AAAA,MACE,MAAA,EAAQ,MAAA;AAAA,MACR,OAAA,EAAS;AAAA,QACP,aAAA,EAAe,UAAU,MAAM,CAAA;AAAA,OACjC;AAAA,MACA,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,QACnB,GAAA,EAAK,SAAA;AAAA,QACL,QAAQ,OAAA,EAAS,MAAA;AAAA,QACjB,WAAW,OAAA,EAAS;AAAA,OACrB;AAAA;AACH,GACF;AACA,EAAA,IAAI,SAAS,KAAA,EAAO;AAClB,IAAA,OAAA,CAAQ,GAAA;AAAA,MACN,sCAAA;AAAA,MACA,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,cAAc;AAAA,KACrC;AAAA,EACF;AACA,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,IAAA,MAAM,IAAI,MAAM,6BAA6B,CAAA;AAAA,EAC/C;AACA,EAAA,OAAO,SAAS,IAAA,EAAK;AACvB;AAEA,SAAS,eAAe,IAAA,EAAwB;AAC9C,EAAA,OAAO,IAAA,EAAM,GAAA;AAAA,IAAI,CAAC,GAAG,CAAA,KACnB,CAAA,CAAE,0BACA,KAAA,CAAA,aAAA,CAAC,MAAA,E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;AACX,IAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,EACzE;AACA,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,MAAM,IAAI,MAAM,wBAAwB,CAAA;AAAA,EAC1C;AACA,EAAA,IAAI,SAAS,KAAA,EAAO;AAClB,IAAA,OAAA,CAAQ,IAAI,iCAAA,EAAmC;AAAA,MAC7C,SAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AACA,EAAA,MAAM,QAAA,GAAW,MAAM,eAAA,CAAgB,MAAA,EAAQ,WAAW,OAAO,CAAA;AACjE,EAAA,uBACE,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,iBAAiB,SAAS,CAAA,CAAA;AAAA,MACrC,wBAAA,EAA0B;AAAA,KAAA;AAAA,oBAE1B,KAAA,CAAA,aAAA,CAAC,aAAQ,aAAA,EAAW,IAAA,EAAC,WAAU,QAAA,EAAA,EAC5B,cAAA,CAAe,SAAS,IAAI,CAAA,EAC5B,YAAY,QAAA,CAAS,KAAK,GAC1B,iBAAA,CAAkB,QAAA,CAAS,WAAW,CAAA,EACtC,kBAAA,CAAmB,QAAA,CAAS,YAAY,CAC3C,CAAA;AAAA,oBACA,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,uBAAA,EAAyB,EAAE,MAAA,EAAQ,QAAA,CAAS,IAAA,EAAK;AAAA,QACjD,wBAAA,EAA0B;AAAA;AAAA,KAC5B;AAAA,IACC,aAAA,CAAc,SAAS,OAAO;AAAA,GACjC;AAEJ","file":"index.mjs","sourcesContent":["import React from \"react\";\nimport type { MakerComponentOptions, PageData, Script } from \"./types\";\n\nconst VERSION = \"v1\";\n\nasync function fetchSSRContent(\n apiKey: string,\n projectId: string,\n options?: MakerComponentOptions\n): Promise<PageData> {\n const response = await fetch(\n `https://ssr.maker.new/api/ssr/${VERSION}/content`,\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n idn: projectId,\n device: options?.device,\n cacheBust: options?.cacheBust,\n }),\n }\n );\n if (options?.debug) {\n console.log(\n \"[debug-maker-component] Debug info: \",\n response.headers.get(\"x-debug-info\")\n );\n }\n if (!response.ok) {\n throw new Error(\"Failed to fetch SSR content\");\n }\n return response.json();\n}\n\nfunction renderMetaTags(meta: PageData[\"meta\"]) {\n return meta?.map((m, i) =>\n m.charset ? (\n <meta key={`m-cs-${i}`} charSet={m.charset} />\n ) : m.name ? (\n <meta key={`m-n-${i}`} name={m.name} content={m.content || \"\"} />\n ) : m.property ? (\n <meta key={`m-p-${i}`} property={m.property} content={m.content || \"\"} />\n ) : null\n );\n}\n\nfunction renderFonts(fonts: string[]) {\n return fonts.map((href, i) =>\n /\\.(woff2?|otf|ttf)(\\?|#|$)/i.test(href) ? (\n <link\n key={`font-${i}`}\n rel=\"preload\"\n as=\"font\"\n href={href}\n crossOrigin=\"anonymous\"\n />\n ) : (\n <link key={`mkr-font-css-${i}`} rel=\"stylesheet\" href={href} />\n )\n );\n}\n\nfunction renderStylesheets(stylesheets: string[]) {\n return stylesheets.map((href, i) => (\n <link key={`mkr-css-${i}`} rel=\"stylesheet\" href={href} />\n ));\n}\n\nfunction renderInlineStyles(inlineStyles: string[]) {\n return inlineStyles?.map((css, i) => (\n <style\n key={`mkr-inline-css-${i}`}\n dangerouslySetInnerHTML={{ __html: css }}\n />\n ));\n}\n\nfunction renderScripts(scripts: Script[]) {\n if (scripts && scripts.length > 0) {\n return scripts\n .reduce<Script[]>((acc, script) => {\n const found = acc.find(\n (s) => s.src === script.src && s.inline === script.inline\n );\n if (!found) {\n acc.push(script);\n }\n return acc;\n }, [])\n .map((script) => (\n <script\n key={script.src || script.inline}\n type={script.type || \"text/javascript\"}\n src={script.src}\n dangerouslySetInnerHTML={\n script.inline ? { __html: script.inline } : undefined\n }\n />\n ));\n }\n}\n\nexport async function MakerComponent({\n apiKey,\n projectId,\n options,\n}: {\n apiKey: string;\n projectId: string;\n options?: MakerComponentOptions;\n}) {\n if (!apiKey) {\n throw new Error(\"MAKER_SSR_API_KEY is not set in environment variables\");\n }\n if (!projectId) {\n throw new Error(\"Project ID is required\");\n }\n if (options?.debug) {\n console.log(\"[debug-maker-component] Props: \", {\n projectId,\n options,\n });\n }\n const pageData = await fetchSSRContent(apiKey, projectId, options);\n return (\n <main\n className={`mkr-component-${projectId}`}\n suppressHydrationWarning={true}\n >\n <section aria-hidden className=\"hidden\">\n {renderMetaTags(pageData.meta)}\n {renderFonts(pageData.fonts)}\n {renderStylesheets(pageData.stylesheets)}\n {renderInlineStyles(pageData.inlineStyles)}\n </section>\n <div\n dangerouslySetInnerHTML={{ __html: pageData.body }}\n suppressHydrationWarning={true}\n />\n {renderScripts(pageData.scripts)}\n </main>\n );\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@makerinc/ssr-component",
3
+ "version": "1.0.0",
4
+ "description": "React component for embedding Maker projects with server-side rendering",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
12
+ },
13
+ "sideEffects": false,
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "maker",
24
+ "ssr",
25
+ "react",
26
+ "component",
27
+ "server-side-rendering",
28
+ "nextjs"
29
+ ],
30
+ "author": "",
31
+ "license": "MIT",
32
+ "peerDependencies": {
33
+ "react": ">=18.0.0",
34
+ "react-dom": ">=18.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^24.10.0",
38
+ "@types/react": "^19.0.0",
39
+ "@types/react-dom": "^19.0.0",
40
+ "tsup": "^8.0.0",
41
+ "typescript": "^5.0.0"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": ""
46
+ }
47
+ }