@json-render/next 0.15.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/LICENSE +201 -0
- package/README.md +103 -0
- package/dist/chunk-37T7IDU5.js +104 -0
- package/dist/chunk-37T7IDU5.js.map +1 -0
- package/dist/chunk-KWYBSJZC.mjs +104 -0
- package/dist/chunk-KWYBSJZC.mjs.map +1 -0
- package/dist/index.d.mts +314 -0
- package/dist/index.d.ts +314 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +135 -0
- package/dist/index.mjs.map +1 -0
- package/dist/page-renderer-client.d.mts +25 -0
- package/dist/page-renderer-client.d.ts +25 -0
- package/dist/page-renderer-client.js +9 -0
- package/dist/page-renderer-client.js.map +1 -0
- package/dist/page-renderer-client.mjs +9 -0
- package/dist/page-renderer-client.mjs.map +1 -0
- package/dist/server.d.mts +358 -0
- package/dist/server.d.ts +358 -0
- package/dist/server.js +538 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +506 -0
- package/dist/server.mjs.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Vercel Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @json-render/next
|
|
2
|
+
|
|
3
|
+
Next.js renderer for [@json-render/core](https://json-render.dev). JSON becomes full Next.js applications with routes, layouts, metadata, and SSR.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @json-render/core @json-render/react @json-render/next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### 1. Define your application spec
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import type { NextAppSpec } from "@json-render/next";
|
|
17
|
+
|
|
18
|
+
const spec: NextAppSpec = {
|
|
19
|
+
metadata: {
|
|
20
|
+
title: { default: "My App", template: "%s | My App" },
|
|
21
|
+
},
|
|
22
|
+
layouts: {
|
|
23
|
+
main: {
|
|
24
|
+
root: "shell",
|
|
25
|
+
elements: {
|
|
26
|
+
shell: { type: "Container", props: {}, children: ["nav", "slot"] },
|
|
27
|
+
nav: { type: "NavBar", props: {}, children: [] },
|
|
28
|
+
slot: { type: "Slot", props: {}, children: [] },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
routes: {
|
|
33
|
+
"/": {
|
|
34
|
+
layout: "main",
|
|
35
|
+
metadata: { title: "Home" },
|
|
36
|
+
page: { root: "hero", elements: { hero: { type: "Card", props: { title: "Welcome" }, children: [] } } },
|
|
37
|
+
},
|
|
38
|
+
"/about": {
|
|
39
|
+
layout: "main",
|
|
40
|
+
metadata: { title: "About" },
|
|
41
|
+
page: { root: "content", elements: { content: { type: "Card", props: { title: "About" }, children: [] } } },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2. Create the app
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// lib/app.ts
|
|
51
|
+
import { createNextApp } from "@json-render/next/server";
|
|
52
|
+
|
|
53
|
+
export const { Page, generateMetadata, generateStaticParams } = createNextApp({ spec });
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 3. Wire up Next.js routes
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
// app/[[...slug]]/page.tsx
|
|
60
|
+
export { Page as default, generateMetadata, generateStaticParams } from "@/lib/app";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
// app/[[...slug]]/layout.tsx
|
|
65
|
+
import { NextAppProvider } from "@json-render/next";
|
|
66
|
+
import { registry, handlers } from "@/lib/registry";
|
|
67
|
+
|
|
68
|
+
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
69
|
+
return (
|
|
70
|
+
<html lang="en">
|
|
71
|
+
<body>
|
|
72
|
+
<NextAppProvider registry={registry} handlers={handlers}>
|
|
73
|
+
{children}
|
|
74
|
+
</NextAppProvider>
|
|
75
|
+
</body>
|
|
76
|
+
</html>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Features
|
|
82
|
+
|
|
83
|
+
- **Pages as spec** -- Define entire multi-page apps in JSON
|
|
84
|
+
- **Route matching** -- Dynamic segments (`[slug]`), catch-all (`[...path]`), optional catch-all (`[[...path]]`)
|
|
85
|
+
- **Nested layouts** -- Reusable layouts with `Slot` component for content injection
|
|
86
|
+
- **SEO metadata** -- Per-route metadata with title templates, OpenGraph, Twitter cards
|
|
87
|
+
- **SSR** -- Server-side rendering via Next.js App Router
|
|
88
|
+
- **Data loaders** -- Server-side async data loading before page render
|
|
89
|
+
- **Static generation** -- `generateStaticParams` for pre-rendering
|
|
90
|
+
- **Client navigation** -- Built-in `Link` component wrapping `next/link`
|
|
91
|
+
- **Error/Loading/NotFound** -- Per-route error boundaries, loading states, and 404 pages
|
|
92
|
+
- **AI streaming** -- Generate entire apps with JSONL patches via `SpecStream`
|
|
93
|
+
|
|
94
|
+
## Entry Points
|
|
95
|
+
|
|
96
|
+
| Import | Description |
|
|
97
|
+
| -------------------------- | ------------------------------------------------ |
|
|
98
|
+
| `@json-render/next` | Client components (NextAppProvider, PageRenderer) |
|
|
99
|
+
| `@json-render/next/server` | Server utilities (createNextApp, matchRoute) |
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
See the [json-render documentation](https://json-render.dev/docs/api/next) for full API reference.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/provider.tsx
|
|
4
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
5
|
+
var _navigation = require('next/navigation');
|
|
6
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
7
|
+
var NextAppContext = _react.createContext.call(void 0, null);
|
|
8
|
+
function NextAppProvider({
|
|
9
|
+
registry,
|
|
10
|
+
handlers,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
13
|
+
const router = _navigation.useRouter.call(void 0, );
|
|
14
|
+
const navigate = _react2.default.useCallback(
|
|
15
|
+
(href) => router.push(href),
|
|
16
|
+
[router]
|
|
17
|
+
);
|
|
18
|
+
const value = _react2.default.useMemo(
|
|
19
|
+
() => ({ registry, handlers, navigate }),
|
|
20
|
+
[registry, handlers, navigate]
|
|
21
|
+
);
|
|
22
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NextAppContext.Provider, { value, children });
|
|
23
|
+
}
|
|
24
|
+
function useNextApp() {
|
|
25
|
+
const ctx = _react.useContext.call(void 0, NextAppContext);
|
|
26
|
+
if (!ctx) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"[json-render/next] useNextApp must be used within a <NextAppProvider>. Wrap your root layout with <NextAppProvider registry={...} handlers={...}>."
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return ctx;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/components/page-renderer.tsx
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
var _react3 = require('@json-render/react');
|
|
43
|
+
|
|
44
|
+
function SlotComponent({ children }) {
|
|
45
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
|
46
|
+
}
|
|
47
|
+
function PageRenderer({
|
|
48
|
+
spec,
|
|
49
|
+
initialState,
|
|
50
|
+
layoutSpec,
|
|
51
|
+
loading
|
|
52
|
+
}) {
|
|
53
|
+
const { registry, handlers, navigate } = useNextApp();
|
|
54
|
+
const augmentedRegistry = _react.useMemo.call(void 0, () => {
|
|
55
|
+
return {
|
|
56
|
+
...registry,
|
|
57
|
+
Slot: SlotComponent
|
|
58
|
+
};
|
|
59
|
+
}, [registry]);
|
|
60
|
+
const actionHandlers = _react.useMemo.call(void 0, () => {
|
|
61
|
+
const base = { ...handlers };
|
|
62
|
+
base.navigate = (params) => {
|
|
63
|
+
const href = params.href;
|
|
64
|
+
if (href) navigate(href);
|
|
65
|
+
};
|
|
66
|
+
return base;
|
|
67
|
+
}, [handlers, navigate]);
|
|
68
|
+
const pageContent = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.Renderer, { spec, registry: augmentedRegistry, loading });
|
|
69
|
+
if (layoutSpec) {
|
|
70
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.StateProvider, { initialState, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.VisibilityProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.ValidationProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.ActionProvider, { handlers: actionHandlers, navigate, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
71
|
+
LayoutWithSlot,
|
|
72
|
+
{
|
|
73
|
+
layoutSpec,
|
|
74
|
+
registry: augmentedRegistry,
|
|
75
|
+
loading,
|
|
76
|
+
children: pageContent
|
|
77
|
+
}
|
|
78
|
+
) }) }) }) });
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.StateProvider, { initialState, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.VisibilityProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.ValidationProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.ActionProvider, { handlers: actionHandlers, navigate, children: pageContent }) }) }) });
|
|
81
|
+
}
|
|
82
|
+
function LayoutWithSlot({
|
|
83
|
+
layoutSpec,
|
|
84
|
+
registry,
|
|
85
|
+
loading,
|
|
86
|
+
children
|
|
87
|
+
}) {
|
|
88
|
+
const layoutRegistry = _react.useMemo.call(void 0, () => {
|
|
89
|
+
return {
|
|
90
|
+
...registry,
|
|
91
|
+
Slot: function LayoutSlot() {
|
|
92
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}, [registry, children]);
|
|
96
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.Renderer, { spec: layoutSpec, registry: layoutRegistry, loading });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
exports.NextAppProvider = NextAppProvider; exports.useNextApp = useNextApp; exports.PageRenderer = PageRenderer;
|
|
104
|
+
//# sourceMappingURL=chunk-37T7IDU5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/json-render/json-render/packages/next/dist/chunk-37T7IDU5.js","../src/components/provider.tsx","../src/components/page-renderer.tsx"],"names":["jsx"],"mappings":"AAAA,qLAAY;AACZ;AACA;ACAA,4EAAiE;AACjE,6CAA0B;AAuEtB,+CAAA;AAvDJ,IAAM,eAAA,EAAiB,kCAAA,IAA8C,CAAA;AAsC9D,SAAS,eAAA,CAAgB;AAAA,EAC9B,QAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAAyB;AACvB,EAAA,MAAM,OAAA,EAAS,mCAAA,CAAU;AACzB,EAAA,MAAM,SAAA,EAAW,eAAA,CAAM,WAA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AAEJ;AAKA,SAAS,cAAA,CAAe;AAAA,EACtB,UAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA,EAKG;AACD,EAAA,MAAM,eAAA,EAAoC,4BAAA,CAAQ,EAAA,GAAM;AACtD,IAAA,OAAO;AAAA,MACL,GAAG,QAAA;AAAA,MACH,IAAA,EAAM,SAAS,UAAA,CAAA,EAAa;AAC1B,QAAA,uBAAOA,6BAAAA,oBAAA,EAAA,EAAG,SAAA,CAAS,CAAA;AAAA,MACrB;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,QAAA,EAAU,QAAQ,CAAC,CAAA;AAEvB,EAAA,uBACEA,6BAAAA,gBAAC,EAAA,EAAS,IAAA,EAAM,UAAA,EAAY,QAAA,EAAU,cAAA,EAAgB,QAAA,CAAkB,CAAA;AAE5E;AFrCA;AACA;AACE;AACA;AACA;AACF,gHAAC","file":"/home/runner/work/json-render/json-render/packages/next/dist/chunk-37T7IDU5.js","sourcesContent":[null,"\"use client\";\n\nimport React, { createContext, useContext, type ReactNode } from \"react\";\nimport { useRouter } from \"next/navigation\";\nimport type { ComponentRegistry } from \"@json-render/react\";\n\n/**\n * Context value holding the component registry, action handlers,\n * and the Next.js router navigate function.\n */\nexport interface NextAppContextValue {\n registry: ComponentRegistry;\n handlers?: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n >;\n navigate: (href: string) => void;\n}\n\nconst NextAppContext = createContext<NextAppContextValue | null>(null);\n\n/**\n * Props for NextAppProvider.\n */\nexport interface NextAppProviderProps {\n /** Component registry for rendering */\n registry: ComponentRegistry;\n /** Action handlers */\n handlers?: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n >;\n children: ReactNode;\n}\n\n/**\n * Provider that holds the component registry and action handlers\n * for the entire json-render Next.js application.\n *\n * Wrap your root layout with this provider:\n *\n * ```tsx\n * // app/[[...slug]]/layout.tsx\n * import { NextAppProvider } from \"@json-render/next\";\n * import { registry, handlers } from \"@/lib/registry\";\n *\n * export default function Layout({ children }) {\n * return (\n * <html><body>\n * <NextAppProvider registry={registry} handlers={handlers}>\n * {children}\n * </NextAppProvider>\n * </body></html>\n * );\n * }\n * ```\n */\nexport function NextAppProvider({\n registry,\n handlers,\n children,\n}: NextAppProviderProps) {\n const router = useRouter();\n const navigate = React.useCallback(\n (href: string) => router.push(href),\n [router],\n );\n\n const value = React.useMemo(\n () => ({ registry, handlers, navigate }),\n [registry, handlers, navigate],\n );\n\n return (\n <NextAppContext.Provider value={value}>{children}</NextAppContext.Provider>\n );\n}\n\n/**\n * Hook to access the NextApp context.\n * Must be used within a NextAppProvider.\n */\nexport function useNextApp(): NextAppContextValue {\n const ctx = useContext(NextAppContext);\n if (!ctx) {\n throw new Error(\n \"[json-render/next] useNextApp must be used within a <NextAppProvider>. \" +\n \"Wrap your root layout with <NextAppProvider registry={...} handlers={...}>.\",\n );\n }\n return ctx;\n}\n","\"use client\";\n\nimport React, { useMemo, type ReactNode } from \"react\";\nimport type { Spec } from \"@json-render/core\";\nimport {\n Renderer,\n StateProvider,\n VisibilityProvider,\n ValidationProvider,\n ActionProvider,\n type ComponentRegistry,\n type ComponentRenderProps,\n} from \"@json-render/react\";\nimport { useNextApp } from \"./provider\";\n\n/**\n * Props for PageRenderer.\n */\nexport interface PageRendererProps {\n /** Page element tree spec */\n spec: Spec;\n /** Initial state (merged from spec.state, global state, and loader data) */\n initialState?: Record<string, unknown>;\n /** Optional layout element tree spec */\n layoutSpec?: Spec | null;\n /** Whether the spec is currently loading/streaming */\n loading?: boolean;\n}\n\n/**\n * Built-in Slot component that renders children passed into layouts.\n */\nfunction SlotComponent({ children }: ComponentRenderProps) {\n return <>{children}</>;\n}\n\n/**\n * Client component that renders a json-render page within the Next.js app.\n *\n * Reads the component registry and action handlers from NextAppProvider context.\n * Handles layout rendering by injecting page content into a Slot component.\n */\nexport function PageRenderer({\n spec,\n initialState,\n layoutSpec,\n loading,\n}: PageRendererProps) {\n const { registry, handlers, navigate } = useNextApp();\n\n const augmentedRegistry: ComponentRegistry = useMemo(() => {\n return {\n ...registry,\n Slot: SlotComponent,\n };\n }, [registry]);\n\n const actionHandlers = useMemo(() => {\n const base: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n > = { ...handlers };\n\n base.navigate = (params: Record<string, unknown>) => {\n const href = params.href as string | undefined;\n if (href) navigate(href);\n };\n\n return base;\n }, [handlers, navigate]);\n\n const pageContent = (\n <Renderer spec={spec} registry={augmentedRegistry} loading={loading} />\n );\n\n if (layoutSpec) {\n return (\n <StateProvider initialState={initialState}>\n <VisibilityProvider>\n <ValidationProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n <LayoutWithSlot\n layoutSpec={layoutSpec}\n registry={augmentedRegistry}\n loading={loading}\n >\n {pageContent}\n </LayoutWithSlot>\n </ActionProvider>\n </ValidationProvider>\n </VisibilityProvider>\n </StateProvider>\n );\n }\n\n return (\n <StateProvider initialState={initialState}>\n <VisibilityProvider>\n <ValidationProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n {pageContent}\n </ActionProvider>\n </ValidationProvider>\n </VisibilityProvider>\n </StateProvider>\n );\n}\n\n/**\n * Renders a layout spec and injects children into the Slot.\n */\nfunction LayoutWithSlot({\n layoutSpec,\n registry,\n loading,\n children,\n}: {\n layoutSpec: Spec;\n registry: ComponentRegistry;\n loading?: boolean;\n children: ReactNode;\n}) {\n const layoutRegistry: ComponentRegistry = useMemo(() => {\n return {\n ...registry,\n Slot: function LayoutSlot() {\n return <>{children}</>;\n },\n };\n }, [registry, children]);\n\n return (\n <Renderer spec={layoutSpec} registry={layoutRegistry} loading={loading} />\n );\n}\n"]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/provider.tsx
|
|
4
|
+
import React, { createContext, useContext } from "react";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var NextAppContext = createContext(null);
|
|
8
|
+
function NextAppProvider({
|
|
9
|
+
registry,
|
|
10
|
+
handlers,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
13
|
+
const router = useRouter();
|
|
14
|
+
const navigate = React.useCallback(
|
|
15
|
+
(href) => router.push(href),
|
|
16
|
+
[router]
|
|
17
|
+
);
|
|
18
|
+
const value = React.useMemo(
|
|
19
|
+
() => ({ registry, handlers, navigate }),
|
|
20
|
+
[registry, handlers, navigate]
|
|
21
|
+
);
|
|
22
|
+
return /* @__PURE__ */ jsx(NextAppContext.Provider, { value, children });
|
|
23
|
+
}
|
|
24
|
+
function useNextApp() {
|
|
25
|
+
const ctx = useContext(NextAppContext);
|
|
26
|
+
if (!ctx) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"[json-render/next] useNextApp must be used within a <NextAppProvider>. Wrap your root layout with <NextAppProvider registry={...} handlers={...}>."
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return ctx;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/components/page-renderer.tsx
|
|
35
|
+
import { useMemo } from "react";
|
|
36
|
+
import {
|
|
37
|
+
Renderer,
|
|
38
|
+
StateProvider,
|
|
39
|
+
VisibilityProvider,
|
|
40
|
+
ValidationProvider,
|
|
41
|
+
ActionProvider
|
|
42
|
+
} from "@json-render/react";
|
|
43
|
+
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
44
|
+
function SlotComponent({ children }) {
|
|
45
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
46
|
+
}
|
|
47
|
+
function PageRenderer({
|
|
48
|
+
spec,
|
|
49
|
+
initialState,
|
|
50
|
+
layoutSpec,
|
|
51
|
+
loading
|
|
52
|
+
}) {
|
|
53
|
+
const { registry, handlers, navigate } = useNextApp();
|
|
54
|
+
const augmentedRegistry = useMemo(() => {
|
|
55
|
+
return {
|
|
56
|
+
...registry,
|
|
57
|
+
Slot: SlotComponent
|
|
58
|
+
};
|
|
59
|
+
}, [registry]);
|
|
60
|
+
const actionHandlers = useMemo(() => {
|
|
61
|
+
const base = { ...handlers };
|
|
62
|
+
base.navigate = (params) => {
|
|
63
|
+
const href = params.href;
|
|
64
|
+
if (href) navigate(href);
|
|
65
|
+
};
|
|
66
|
+
return base;
|
|
67
|
+
}, [handlers, navigate]);
|
|
68
|
+
const pageContent = /* @__PURE__ */ jsx2(Renderer, { spec, registry: augmentedRegistry, loading });
|
|
69
|
+
if (layoutSpec) {
|
|
70
|
+
return /* @__PURE__ */ jsx2(StateProvider, { initialState, children: /* @__PURE__ */ jsx2(VisibilityProvider, { children: /* @__PURE__ */ jsx2(ValidationProvider, { children: /* @__PURE__ */ jsx2(ActionProvider, { handlers: actionHandlers, navigate, children: /* @__PURE__ */ jsx2(
|
|
71
|
+
LayoutWithSlot,
|
|
72
|
+
{
|
|
73
|
+
layoutSpec,
|
|
74
|
+
registry: augmentedRegistry,
|
|
75
|
+
loading,
|
|
76
|
+
children: pageContent
|
|
77
|
+
}
|
|
78
|
+
) }) }) }) });
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ jsx2(StateProvider, { initialState, children: /* @__PURE__ */ jsx2(VisibilityProvider, { children: /* @__PURE__ */ jsx2(ValidationProvider, { children: /* @__PURE__ */ jsx2(ActionProvider, { handlers: actionHandlers, navigate, children: pageContent }) }) }) });
|
|
81
|
+
}
|
|
82
|
+
function LayoutWithSlot({
|
|
83
|
+
layoutSpec,
|
|
84
|
+
registry,
|
|
85
|
+
loading,
|
|
86
|
+
children
|
|
87
|
+
}) {
|
|
88
|
+
const layoutRegistry = useMemo(() => {
|
|
89
|
+
return {
|
|
90
|
+
...registry,
|
|
91
|
+
Slot: function LayoutSlot() {
|
|
92
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}, [registry, children]);
|
|
96
|
+
return /* @__PURE__ */ jsx2(Renderer, { spec: layoutSpec, registry: layoutRegistry, loading });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
NextAppProvider,
|
|
101
|
+
useNextApp,
|
|
102
|
+
PageRenderer
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=chunk-KWYBSJZC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/provider.tsx","../src/components/page-renderer.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { createContext, useContext, type ReactNode } from \"react\";\nimport { useRouter } from \"next/navigation\";\nimport type { ComponentRegistry } from \"@json-render/react\";\n\n/**\n * Context value holding the component registry, action handlers,\n * and the Next.js router navigate function.\n */\nexport interface NextAppContextValue {\n registry: ComponentRegistry;\n handlers?: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n >;\n navigate: (href: string) => void;\n}\n\nconst NextAppContext = createContext<NextAppContextValue | null>(null);\n\n/**\n * Props for NextAppProvider.\n */\nexport interface NextAppProviderProps {\n /** Component registry for rendering */\n registry: ComponentRegistry;\n /** Action handlers */\n handlers?: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n >;\n children: ReactNode;\n}\n\n/**\n * Provider that holds the component registry and action handlers\n * for the entire json-render Next.js application.\n *\n * Wrap your root layout with this provider:\n *\n * ```tsx\n * // app/[[...slug]]/layout.tsx\n * import { NextAppProvider } from \"@json-render/next\";\n * import { registry, handlers } from \"@/lib/registry\";\n *\n * export default function Layout({ children }) {\n * return (\n * <html><body>\n * <NextAppProvider registry={registry} handlers={handlers}>\n * {children}\n * </NextAppProvider>\n * </body></html>\n * );\n * }\n * ```\n */\nexport function NextAppProvider({\n registry,\n handlers,\n children,\n}: NextAppProviderProps) {\n const router = useRouter();\n const navigate = React.useCallback(\n (href: string) => router.push(href),\n [router],\n );\n\n const value = React.useMemo(\n () => ({ registry, handlers, navigate }),\n [registry, handlers, navigate],\n );\n\n return (\n <NextAppContext.Provider value={value}>{children}</NextAppContext.Provider>\n );\n}\n\n/**\n * Hook to access the NextApp context.\n * Must be used within a NextAppProvider.\n */\nexport function useNextApp(): NextAppContextValue {\n const ctx = useContext(NextAppContext);\n if (!ctx) {\n throw new Error(\n \"[json-render/next] useNextApp must be used within a <NextAppProvider>. \" +\n \"Wrap your root layout with <NextAppProvider registry={...} handlers={...}>.\",\n );\n }\n return ctx;\n}\n","\"use client\";\n\nimport React, { useMemo, type ReactNode } from \"react\";\nimport type { Spec } from \"@json-render/core\";\nimport {\n Renderer,\n StateProvider,\n VisibilityProvider,\n ValidationProvider,\n ActionProvider,\n type ComponentRegistry,\n type ComponentRenderProps,\n} from \"@json-render/react\";\nimport { useNextApp } from \"./provider\";\n\n/**\n * Props for PageRenderer.\n */\nexport interface PageRendererProps {\n /** Page element tree spec */\n spec: Spec;\n /** Initial state (merged from spec.state, global state, and loader data) */\n initialState?: Record<string, unknown>;\n /** Optional layout element tree spec */\n layoutSpec?: Spec | null;\n /** Whether the spec is currently loading/streaming */\n loading?: boolean;\n}\n\n/**\n * Built-in Slot component that renders children passed into layouts.\n */\nfunction SlotComponent({ children }: ComponentRenderProps) {\n return <>{children}</>;\n}\n\n/**\n * Client component that renders a json-render page within the Next.js app.\n *\n * Reads the component registry and action handlers from NextAppProvider context.\n * Handles layout rendering by injecting page content into a Slot component.\n */\nexport function PageRenderer({\n spec,\n initialState,\n layoutSpec,\n loading,\n}: PageRendererProps) {\n const { registry, handlers, navigate } = useNextApp();\n\n const augmentedRegistry: ComponentRegistry = useMemo(() => {\n return {\n ...registry,\n Slot: SlotComponent,\n };\n }, [registry]);\n\n const actionHandlers = useMemo(() => {\n const base: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n > = { ...handlers };\n\n base.navigate = (params: Record<string, unknown>) => {\n const href = params.href as string | undefined;\n if (href) navigate(href);\n };\n\n return base;\n }, [handlers, navigate]);\n\n const pageContent = (\n <Renderer spec={spec} registry={augmentedRegistry} loading={loading} />\n );\n\n if (layoutSpec) {\n return (\n <StateProvider initialState={initialState}>\n <VisibilityProvider>\n <ValidationProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n <LayoutWithSlot\n layoutSpec={layoutSpec}\n registry={augmentedRegistry}\n loading={loading}\n >\n {pageContent}\n </LayoutWithSlot>\n </ActionProvider>\n </ValidationProvider>\n </VisibilityProvider>\n </StateProvider>\n );\n }\n\n return (\n <StateProvider initialState={initialState}>\n <VisibilityProvider>\n <ValidationProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n {pageContent}\n </ActionProvider>\n </ValidationProvider>\n </VisibilityProvider>\n </StateProvider>\n );\n}\n\n/**\n * Renders a layout spec and injects children into the Slot.\n */\nfunction LayoutWithSlot({\n layoutSpec,\n registry,\n loading,\n children,\n}: {\n layoutSpec: Spec;\n registry: ComponentRegistry;\n loading?: boolean;\n children: ReactNode;\n}) {\n const layoutRegistry: ComponentRegistry = useMemo(() => {\n return {\n ...registry,\n Slot: function LayoutSlot() {\n return <>{children}</>;\n },\n };\n }, [registry, children]);\n\n return (\n <Renderer spec={layoutSpec} registry={layoutRegistry} loading={loading} />\n );\n}\n"],"mappings":";;;AAEA,OAAO,SAAS,eAAe,kBAAkC;AACjE,SAAS,iBAAiB;AAuEtB;AAvDJ,IAAM,iBAAiB,cAA0C,IAAI;AAsC9D,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,SAAS,UAAU;AACzB,QAAM,WAAW,MAAM;AAAA,IACrB,CAAC,SAAiB,OAAO,KAAK,IAAI;AAAA,IAClC,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,QAAQ,MAAM;AAAA,IAClB,OAAO,EAAE,UAAU,UAAU,SAAS;AAAA,IACtC,CAAC,UAAU,UAAU,QAAQ;AAAA,EAC/B;AAEA,SACE,oBAAC,eAAe,UAAf,EAAwB,OAAe,UAAS;AAErD;AAMO,SAAS,aAAkC;AAChD,QAAM,M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