@nextsparkjs/core 0.1.0-beta.133 → 0.1.0-beta.134
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/components/public/pageBuilder/PageRenderer.d.ts +5 -5
- package/dist/components/public/pageBuilder/PageRenderer.d.ts.map +1 -1
- package/dist/components/public/pageBuilder/PageRenderer.js +2 -1
- package/dist/styles/classes.json +1 -1
- package/package.json +2 -2
- package/scripts/build/registry/generators/block-registry.mjs +5 -14
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* PageRenderer Component
|
|
3
3
|
*
|
|
4
4
|
* Renders pages from the Page Builder by iterating over blocks
|
|
5
|
-
* and
|
|
5
|
+
* and loading block components from the SSR registry.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Block components are loaded via next/dynamic (ssr: true) for per-block
|
|
8
|
+
* code splitting. Each block gets its own JS chunk — only blocks used on
|
|
9
|
+
* the page have their JS loaded by the browser. SSR renders full HTML
|
|
10
|
+
* so content is visible without client JS (SEO-safe).
|
|
11
11
|
*
|
|
12
12
|
* @module core/components/public/pageBuilder
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/public/pageBuilder/PageRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"PageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/public/pageBuilder/PageRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAsC1D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,aAAa,EAAE,CAAA;QACvB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,iBAAiB,2CA+BvD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense } from "react";
|
|
2
3
|
import { getBlockComponentSSR, normalizeBlockProps } from "../../../lib/blocks/loader.js";
|
|
3
4
|
function BlockError({ blockSlug }) {
|
|
4
5
|
return /* @__PURE__ */ jsx("div", { className: "w-full py-12 px-4 bg-destructive/10 border border-destructive/20 rounded", children: /* @__PURE__ */ jsxs("div", { className: "max-w-7xl mx-auto text-center", children: [
|
|
@@ -16,7 +17,7 @@ function BlockRenderer({ block }) {
|
|
|
16
17
|
return /* @__PURE__ */ jsx(BlockError, { blockSlug: block.blockSlug });
|
|
17
18
|
}
|
|
18
19
|
const normalizedProps = normalizeBlockProps(block.props);
|
|
19
|
-
return /* @__PURE__ */ jsx(BlockComponent, { ...normalizedProps });
|
|
20
|
+
return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(BlockComponent, { ...normalizedProps }) });
|
|
20
21
|
}
|
|
21
22
|
function PageRenderer({ page }) {
|
|
22
23
|
const blocks = Array.isArray(page.blocks) ? page.blocks : [];
|
package/dist/styles/classes.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextsparkjs/core",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.134",
|
|
4
4
|
"description": "NextSpark - The complete SaaS framework for Next.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "NextSpark <hello@nextspark.dev>",
|
|
@@ -462,7 +462,7 @@
|
|
|
462
462
|
"tailwind-merge": "^3.3.1",
|
|
463
463
|
"uuid": "^13.0.0",
|
|
464
464
|
"zod": "^4.1.5",
|
|
465
|
-
"@nextsparkjs/testing": "0.1.0-beta.
|
|
465
|
+
"@nextsparkjs/testing": "0.1.0-beta.134"
|
|
466
466
|
},
|
|
467
467
|
"scripts": {
|
|
468
468
|
"postinstall": "node scripts/postinstall.mjs || true",
|
|
@@ -66,8 +66,6 @@ export const BLOCK_METADATA = {
|
|
|
66
66
|
|
|
67
67
|
// Import field definitions and examples (if they exist)
|
|
68
68
|
const imports = []
|
|
69
|
-
// Direct component imports for SSR (no React.lazy)
|
|
70
|
-
const ssrImports = []
|
|
71
69
|
|
|
72
70
|
blocks.forEach(block => {
|
|
73
71
|
const slugVar = block.slug.replace(/-/g, '_')
|
|
@@ -75,9 +73,6 @@ export const BLOCK_METADATA = {
|
|
|
75
73
|
// Always import field definitions
|
|
76
74
|
imports.push(`import { fieldDefinitions as ${slugVar}_fields } from '${block.paths.fields}'`)
|
|
77
75
|
|
|
78
|
-
// Direct component import for SSR rendering
|
|
79
|
-
ssrImports.push(`import { default as ${slugVar}_component } from '${block.paths.component}'`)
|
|
80
|
-
|
|
81
76
|
// Conditionally import examples if they exist
|
|
82
77
|
if (block.hasExamples) {
|
|
83
78
|
imports.push(`import { examples as ${slugVar}_examples } from '${block.paths.examples}'`)
|
|
@@ -85,7 +80,6 @@ export const BLOCK_METADATA = {
|
|
|
85
80
|
})
|
|
86
81
|
|
|
87
82
|
const fieldImports = imports.join('\n')
|
|
88
|
-
const ssrComponentImports = ssrImports.join('\n')
|
|
89
83
|
|
|
90
84
|
const registryEntries = blocks.map(block => {
|
|
91
85
|
const slugVar = block.slug.replace(/-/g, '_')
|
|
@@ -133,13 +127,11 @@ export const BLOCK_METADATA = {
|
|
|
133
127
|
*/
|
|
134
128
|
|
|
135
129
|
import React from 'react'
|
|
130
|
+
import dynamic from 'next/dynamic'
|
|
136
131
|
import type { BlockConfig, BlockCategory } from '${convertCorePath('@/core/types', outputFilePath, config)}'
|
|
137
132
|
|
|
138
133
|
${fieldImports}
|
|
139
134
|
|
|
140
|
-
// Direct component imports for SSR (no React.lazy, no Suspense needed)
|
|
141
|
-
${ssrComponentImports}
|
|
142
|
-
|
|
143
135
|
export const BLOCK_REGISTRY: Record<string, BlockConfig> = {
|
|
144
136
|
${registryEntries}
|
|
145
137
|
}
|
|
@@ -158,15 +150,14 @@ ${blocks.map(block => {
|
|
|
158
150
|
}
|
|
159
151
|
|
|
160
152
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
153
|
+
* Code-split block components for SSR rendering via next/dynamic.
|
|
154
|
+
* Each block is a separate JS chunk — only blocks used on the page are loaded.
|
|
155
|
+
* SSR is enabled (default) so HTML is fully visible without client JS.
|
|
164
156
|
*/
|
|
165
157
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
158
|
export const BLOCK_COMPONENTS_SSR: Record<string, React.ComponentType<any>> = {
|
|
167
159
|
${blocks.map(block => {
|
|
168
|
-
|
|
169
|
-
return ` '${block.slug}': ${slugVar}_component`
|
|
160
|
+
return ` '${block.slug}': dynamic(() => import('${block.paths.component}'), { ssr: true })`
|
|
170
161
|
}).join(',\n')}
|
|
171
162
|
}
|
|
172
163
|
|