@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/dist/index.js ADDED
@@ -0,0 +1,135 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }"use client";
2
+ "use client";
3
+
4
+
5
+
6
+
7
+ var _chunk37T7IDU5js = require('./chunk-37T7IDU5.js');
8
+
9
+ // src/components/error-boundary.tsx
10
+ var _react = require('@json-render/react');
11
+ var _jsxruntime = require('react/jsx-runtime');
12
+ function NextErrorBoundary({
13
+ error,
14
+ reset,
15
+ errorSpec
16
+ }) {
17
+ let registry;
18
+ try {
19
+ const ctx = _chunk37T7IDU5js.useNextApp.call(void 0, );
20
+ registry = ctx.registry;
21
+ } catch (e) {
22
+ }
23
+ if (errorSpec && registry) {
24
+ const augmentedRegistry = {
25
+ ...registry,
26
+ Slot: () => null
27
+ };
28
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Renderer, { spec: errorSpec, registry: augmentedRegistry });
29
+ }
30
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { padding: "2rem", textAlign: "center" }, children: [
31
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { style: { marginBottom: "1rem" }, children: "Something went wrong" }),
32
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { style: { color: "#666", marginBottom: "1.5rem" }, children: error.message || "An unexpected error occurred." }),
33
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
34
+ "button",
35
+ {
36
+ onClick: reset,
37
+ style: {
38
+ padding: "0.5rem 1rem",
39
+ borderRadius: "0.375rem",
40
+ border: "1px solid #ccc",
41
+ background: "#fff",
42
+ cursor: "pointer"
43
+ },
44
+ children: "Try again"
45
+ }
46
+ )
47
+ ] });
48
+ }
49
+
50
+ // src/components/loading-renderer.tsx
51
+
52
+ function NextLoading({ loadingSpec: _loadingSpec }) {
53
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
54
+ "div",
55
+ {
56
+ style: {
57
+ display: "flex",
58
+ justifyContent: "center",
59
+ alignItems: "center",
60
+ minHeight: "200px"
61
+ },
62
+ children: [
63
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
64
+ "div",
65
+ {
66
+ style: {
67
+ width: "2rem",
68
+ height: "2rem",
69
+ border: "2px solid #e5e7eb",
70
+ borderTopColor: "#3b82f6",
71
+ borderRadius: "50%",
72
+ animation: "jr-spin 0.6s linear infinite"
73
+ }
74
+ }
75
+ ),
76
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { children: `@keyframes jr-spin { to { transform: rotate(360deg) } }` })
77
+ ]
78
+ }
79
+ );
80
+ }
81
+
82
+ // src/components/not-found-renderer.tsx
83
+
84
+ function NextNotFound() {
85
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
86
+ "div",
87
+ {
88
+ style: {
89
+ display: "flex",
90
+ flexDirection: "column",
91
+ alignItems: "center",
92
+ justifyContent: "center",
93
+ minHeight: "400px",
94
+ padding: "2rem",
95
+ textAlign: "center"
96
+ },
97
+ children: [
98
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { style: { fontSize: "4rem", fontWeight: 700, margin: 0 }, children: "404" }),
99
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { style: { color: "#666", marginTop: "0.5rem", fontSize: "1.125rem" }, children: "This page could not be found." })
100
+ ]
101
+ }
102
+ );
103
+ }
104
+
105
+ // src/components/link.tsx
106
+ var _link = require('next/link'); var _link2 = _interopRequireDefault(_link);
107
+
108
+ function Link({ element, children }) {
109
+ const { href, replace, prefetch, className, style } = element.props;
110
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
111
+ _link2.default,
112
+ {
113
+ href,
114
+ replace,
115
+ prefetch,
116
+ className,
117
+ style,
118
+ children
119
+ }
120
+ );
121
+ }
122
+
123
+ // src/index.ts
124
+ var _core = require('@json-render/core');
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+ exports.Link = Link; exports.NextAppProvider = _chunk37T7IDU5js.NextAppProvider; exports.NextErrorBoundary = NextErrorBoundary; exports.NextLoading = NextLoading; exports.NextNotFound = NextNotFound; exports.PageRenderer = _chunk37T7IDU5js.PageRenderer; exports.createStateStore = _core.createStateStore; exports.useNextApp = _chunk37T7IDU5js.useNextApp;
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/json-render/json-render/packages/next/dist/index.js","../src/components/error-boundary.tsx","../src/components/loading-renderer.tsx","../src/components/not-found-renderer.tsx","../src/components/link.tsx","../src/index.ts"],"names":["jsxs","jsx"],"mappings":"AAAA,qLAAY;AACZ,YAAY;AACZ;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACA;ACJA,2CAAiD;AAyCtC,+CAAA;AAlBJ,SAAS,iBAAA,CAAkB;AAAA,EAChC,KAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAA2B;AACzB,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,EAAM,yCAAA,CAAW;AACvB,IAAA,SAAA,EAAW,GAAA,CAAI,QAAA;AAAA,EACjB,EAAA,UAAQ;AAAA,EAER;AAEA,EAAA,GAAA,CAAI,UAAA,GAAa,QAAA,EAAU;AACzB,IAAA,MAAM,kBAAA,EAAuC;AAAA,MAC3C,GAAG,QAAA;AAAA,MACH,IAAA,EAAM,CAAA,EAAA,GAAM;AAAA,IACd,CAAA;AACA,IAAA,uBAAO,6BAAA,eAAC,EAAA,EAAS,IAAA,EAAM,SAAA,EAAW,QAAA,EAAU,kBAAA,CAAmB,CAAA;AAAA,EACjE;AAEA,EAAA,uBACE,8BAAA,KAAC,EAAA,EAAI,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,EAAQ,SAAA,EAAW,SAAS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A,SAAA;AAAA,MACA,KAAA;AAAA,MAEC;AAAA,IAAA;AAAA,EACH,CAAA;AAEJ;AJsEA;AACA;AKtDA,yCAAiC;ALwDjC;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,kWAAC","file":"/home/runner/work/json-render/json-render/packages/next/dist/index.js","sourcesContent":[null,"\"use client\";\n\nimport React from \"react\";\nimport type { Spec } from \"@json-render/core\";\nimport { Renderer, type ComponentRegistry } from \"@json-render/react\";\nimport { useNextApp } from \"./provider\";\n\n/**\n * Props for NextErrorBoundary.\n */\nexport interface NextErrorBoundaryProps {\n /** The error that occurred */\n error: Error & { digest?: string };\n /** Function to attempt re-rendering the page */\n reset: () => void;\n /** Optional error UI spec from the matched route */\n errorSpec?: Spec | null;\n}\n\n/**\n * Error boundary component for json-render Next.js apps.\n *\n * If the matched route defines an `error` spec, it renders that.\n * Otherwise renders a minimal default error UI.\n *\n * Must be used in a file with `\"use client\"` directive (Next.js requirement).\n */\nexport function NextErrorBoundary({\n error,\n reset,\n errorSpec,\n}: NextErrorBoundaryProps) {\n let registry: ComponentRegistry | undefined;\n try {\n const ctx = useNextApp();\n registry = ctx.registry;\n } catch {\n // Provider may not be available in error boundaries\n }\n\n if (errorSpec && registry) {\n const augmentedRegistry: ComponentRegistry = {\n ...registry,\n Slot: () => null,\n };\n return <Renderer spec={errorSpec} registry={augmentedRegistry} />;\n }\n\n return (\n <div style={{ padding: \"2rem\", textAlign: \"center\" }}>\n <h2 style={{ marginBottom: \"1rem\" }}>Something went wrong</h2>\n <p style={{ color: \"#666\", marginBottom: \"1.5rem\" }}>\n {error.message || \"An unexpected error occurred.\"}\n </p>\n <button\n onClick={reset}\n style={{\n padding: \"0.5rem 1rem\",\n borderRadius: \"0.375rem\",\n border: \"1px solid #ccc\",\n background: \"#fff\",\n cursor: \"pointer\",\n }}\n >\n Try again\n </button>\n </div>\n );\n}\n","import React from \"react\";\nimport type { Spec } from \"@json-render/core\";\n\n/**\n * Props for NextLoading.\n */\nexport interface NextLoadingProps {\n /** Optional loading UI spec */\n loadingSpec?: Spec | null;\n}\n\n/**\n * Loading component for json-render Next.js apps.\n *\n * If a loading spec is provided, it will be rendered by the PageRenderer.\n * Otherwise renders a minimal default loading indicator.\n *\n * Note: Since Next.js loading.tsx is static (no params), this renders\n * a generic loading state. Route-specific loading can be achieved with\n * Suspense boundaries in page content.\n */\nexport function NextLoading({ loadingSpec: _loadingSpec }: NextLoadingProps) {\n return (\n <div\n style={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n minHeight: \"200px\",\n }}\n >\n <div\n style={{\n width: \"2rem\",\n height: \"2rem\",\n border: \"2px solid #e5e7eb\",\n borderTopColor: \"#3b82f6\",\n borderRadius: \"50%\",\n animation: \"jr-spin 0.6s linear infinite\",\n }}\n />\n <style>{`@keyframes jr-spin { to { transform: rotate(360deg) } }`}</style>\n </div>\n );\n}\n","import React from \"react\";\n\n/**\n * Not-found component for json-render Next.js apps.\n *\n * Renders when the pathname does not match any route in the spec.\n */\nexport function NextNotFound() {\n return (\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minHeight: \"400px\",\n padding: \"2rem\",\n textAlign: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", fontWeight: 700, margin: 0 }}>404</h1>\n <p style={{ color: \"#666\", marginTop: \"0.5rem\", fontSize: \"1.125rem\" }}>\n This page could not be found.\n </p>\n </div>\n );\n}\n","\"use client\";\n\nimport React, { type ReactNode } from \"react\";\nimport NextLink from \"next/link\";\nimport type { ComponentRenderProps } from \"@json-render/react\";\n\n/**\n * Props expected by the Link component in json-render specs.\n */\nexport interface LinkProps {\n /** The target URL or route path */\n href: string;\n /** Whether to replace the current history entry */\n replace?: boolean;\n /** Whether to prefetch the linked route */\n prefetch?: boolean;\n /** CSS class name */\n className?: string;\n /** Inline styles */\n style?: React.CSSProperties;\n}\n\n/**\n * Built-in Link component for json-render Next.js specs.\n *\n * Wraps `next/link` for client-side navigation between routes.\n *\n * Usage in a spec:\n * ```json\n * {\n * \"type\": \"Link\",\n * \"props\": { \"href\": \"/about\" },\n * \"children\": [\"link-text\"]\n * }\n * ```\n */\nexport function Link({ element, children }: ComponentRenderProps<LinkProps>) {\n const { href, replace, prefetch, className, style } =\n element.props as LinkProps;\n\n return (\n <NextLink\n href={href}\n replace={replace}\n prefetch={prefetch}\n className={className}\n style={style}\n >\n {children}\n </NextLink>\n );\n}\n","\"use client\";\n\n// =============================================================================\n// @json-render/next — Client exports\n//\n// This entry point includes client components and is safe to import\n// in \"use client\" modules and Next.js pages/layouts.\n// =============================================================================\n\n// Provider\nexport {\n NextAppProvider,\n useNextApp,\n type NextAppProviderProps,\n type NextAppContextValue,\n} from \"./components/provider\";\n\n// Page renderer\nexport {\n PageRenderer,\n type PageRendererProps,\n} from \"./components/page-renderer\";\n\n// Error boundary\nexport {\n NextErrorBoundary,\n type NextErrorBoundaryProps,\n} from \"./components/error-boundary\";\n\n// Loading\nexport {\n NextLoading,\n type NextLoadingProps,\n} from \"./components/loading-renderer\";\n\n// Not found\nexport { NextNotFound } from \"./components/not-found-renderer\";\n\n// Link component\nexport { Link, type LinkProps } from \"./components/link\";\n\n// Types (re-exported for convenience)\nexport type {\n NextAppSpec,\n NextRouteSpec,\n NextMetadata,\n MatchedRoute,\n LoaderFn,\n CreateNextAppOptions,\n NextAppExports,\n PageData,\n} from \"./types\";\n\n// Catalog types (re-exported from @json-render/react)\nexport type {\n EventHandle,\n BaseComponentProps,\n SetState,\n StateModel,\n ComponentContext,\n ComponentFn,\n Components,\n ActionFn,\n Actions,\n} from \"./catalog-types\";\n\n// Core types (re-exported for convenience)\nexport type { Spec, StateStore } from \"@json-render/core\";\nexport { createStateStore } from \"@json-render/core\";\nexport type {\n ComponentRegistry,\n ComponentRenderProps,\n} from \"@json-render/react\";\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,135 @@
1
+ "use client";
2
+ "use client";
3
+ import {
4
+ NextAppProvider,
5
+ PageRenderer,
6
+ useNextApp
7
+ } from "./chunk-KWYBSJZC.mjs";
8
+
9
+ // src/components/error-boundary.tsx
10
+ import { Renderer } from "@json-render/react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ function NextErrorBoundary({
13
+ error,
14
+ reset,
15
+ errorSpec
16
+ }) {
17
+ let registry;
18
+ try {
19
+ const ctx = useNextApp();
20
+ registry = ctx.registry;
21
+ } catch {
22
+ }
23
+ if (errorSpec && registry) {
24
+ const augmentedRegistry = {
25
+ ...registry,
26
+ Slot: () => null
27
+ };
28
+ return /* @__PURE__ */ jsx(Renderer, { spec: errorSpec, registry: augmentedRegistry });
29
+ }
30
+ return /* @__PURE__ */ jsxs("div", { style: { padding: "2rem", textAlign: "center" }, children: [
31
+ /* @__PURE__ */ jsx("h2", { style: { marginBottom: "1rem" }, children: "Something went wrong" }),
32
+ /* @__PURE__ */ jsx("p", { style: { color: "#666", marginBottom: "1.5rem" }, children: error.message || "An unexpected error occurred." }),
33
+ /* @__PURE__ */ jsx(
34
+ "button",
35
+ {
36
+ onClick: reset,
37
+ style: {
38
+ padding: "0.5rem 1rem",
39
+ borderRadius: "0.375rem",
40
+ border: "1px solid #ccc",
41
+ background: "#fff",
42
+ cursor: "pointer"
43
+ },
44
+ children: "Try again"
45
+ }
46
+ )
47
+ ] });
48
+ }
49
+
50
+ // src/components/loading-renderer.tsx
51
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
52
+ function NextLoading({ loadingSpec: _loadingSpec }) {
53
+ return /* @__PURE__ */ jsxs2(
54
+ "div",
55
+ {
56
+ style: {
57
+ display: "flex",
58
+ justifyContent: "center",
59
+ alignItems: "center",
60
+ minHeight: "200px"
61
+ },
62
+ children: [
63
+ /* @__PURE__ */ jsx2(
64
+ "div",
65
+ {
66
+ style: {
67
+ width: "2rem",
68
+ height: "2rem",
69
+ border: "2px solid #e5e7eb",
70
+ borderTopColor: "#3b82f6",
71
+ borderRadius: "50%",
72
+ animation: "jr-spin 0.6s linear infinite"
73
+ }
74
+ }
75
+ ),
76
+ /* @__PURE__ */ jsx2("style", { children: `@keyframes jr-spin { to { transform: rotate(360deg) } }` })
77
+ ]
78
+ }
79
+ );
80
+ }
81
+
82
+ // src/components/not-found-renderer.tsx
83
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
84
+ function NextNotFound() {
85
+ return /* @__PURE__ */ jsxs3(
86
+ "div",
87
+ {
88
+ style: {
89
+ display: "flex",
90
+ flexDirection: "column",
91
+ alignItems: "center",
92
+ justifyContent: "center",
93
+ minHeight: "400px",
94
+ padding: "2rem",
95
+ textAlign: "center"
96
+ },
97
+ children: [
98
+ /* @__PURE__ */ jsx3("h1", { style: { fontSize: "4rem", fontWeight: 700, margin: 0 }, children: "404" }),
99
+ /* @__PURE__ */ jsx3("p", { style: { color: "#666", marginTop: "0.5rem", fontSize: "1.125rem" }, children: "This page could not be found." })
100
+ ]
101
+ }
102
+ );
103
+ }
104
+
105
+ // src/components/link.tsx
106
+ import NextLink from "next/link";
107
+ import { jsx as jsx4 } from "react/jsx-runtime";
108
+ function Link({ element, children }) {
109
+ const { href, replace, prefetch, className, style } = element.props;
110
+ return /* @__PURE__ */ jsx4(
111
+ NextLink,
112
+ {
113
+ href,
114
+ replace,
115
+ prefetch,
116
+ className,
117
+ style,
118
+ children
119
+ }
120
+ );
121
+ }
122
+
123
+ // src/index.ts
124
+ import { createStateStore } from "@json-render/core";
125
+ export {
126
+ Link,
127
+ NextAppProvider,
128
+ NextErrorBoundary,
129
+ NextLoading,
130
+ NextNotFound,
131
+ PageRenderer,
132
+ createStateStore,
133
+ useNextApp
134
+ };
135
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/error-boundary.tsx","../src/components/loading-renderer.tsx","../src/components/not-found-renderer.tsx","../src/components/link.tsx","../src/index.ts"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport type { Spec } from \"@json-render/core\";\nimport { Renderer, type ComponentRegistry } from \"@json-render/react\";\nimport { useNextApp } from \"./provider\";\n\n/**\n * Props for NextErrorBoundary.\n */\nexport interface NextErrorBoundaryProps {\n /** The error that occurred */\n error: Error & { digest?: string };\n /** Function to attempt re-rendering the page */\n reset: () => void;\n /** Optional error UI spec from the matched route */\n errorSpec?: Spec | null;\n}\n\n/**\n * Error boundary component for json-render Next.js apps.\n *\n * If the matched route defines an `error` spec, it renders that.\n * Otherwise renders a minimal default error UI.\n *\n * Must be used in a file with `\"use client\"` directive (Next.js requirement).\n */\nexport function NextErrorBoundary({\n error,\n reset,\n errorSpec,\n}: NextErrorBoundaryProps) {\n let registry: ComponentRegistry | undefined;\n try {\n const ctx = useNextApp();\n registry = ctx.registry;\n } catch {\n // Provider may not be available in error boundaries\n }\n\n if (errorSpec && registry) {\n const augmentedRegistry: ComponentRegistry = {\n ...registry,\n Slot: () => null,\n };\n return <Renderer spec={errorSpec} registry={augmentedRegistry} />;\n }\n\n return (\n <div style={{ padding: \"2rem\", textAlign: \"center\" }}>\n <h2 style={{ marginBottom: \"1rem\" }}>Something went wrong</h2>\n <p style={{ color: \"#666\", marginBottom: \"1.5rem\" }}>\n {error.message || \"An unexpected error occurred.\"}\n </p>\n <button\n onClick={reset}\n style={{\n padding: \"0.5rem 1rem\",\n borderRadius: \"0.375rem\",\n border: \"1px solid #ccc\",\n background: \"#fff\",\n cursor: \"pointer\",\n }}\n >\n Try again\n </button>\n </div>\n );\n}\n","import React from \"react\";\nimport type { Spec } from \"@json-render/core\";\n\n/**\n * Props for NextLoading.\n */\nexport interface NextLoadingProps {\n /** Optional loading UI spec */\n loadingSpec?: Spec | null;\n}\n\n/**\n * Loading component for json-render Next.js apps.\n *\n * If a loading spec is provided, it will be rendered by the PageRenderer.\n * Otherwise renders a minimal default loading indicator.\n *\n * Note: Since Next.js loading.tsx is static (no params), this renders\n * a generic loading state. Route-specific loading can be achieved with\n * Suspense boundaries in page content.\n */\nexport function NextLoading({ loadingSpec: _loadingSpec }: NextLoadingProps) {\n return (\n <div\n style={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n minHeight: \"200px\",\n }}\n >\n <div\n style={{\n width: \"2rem\",\n height: \"2rem\",\n border: \"2px solid #e5e7eb\",\n borderTopColor: \"#3b82f6\",\n borderRadius: \"50%\",\n animation: \"jr-spin 0.6s linear infinite\",\n }}\n />\n <style>{`@keyframes jr-spin { to { transform: rotate(360deg) } }`}</style>\n </div>\n );\n}\n","import React from \"react\";\n\n/**\n * Not-found component for json-render Next.js apps.\n *\n * Renders when the pathname does not match any route in the spec.\n */\nexport function NextNotFound() {\n return (\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minHeight: \"400px\",\n padding: \"2rem\",\n textAlign: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", fontWeight: 700, margin: 0 }}>404</h1>\n <p style={{ color: \"#666\", marginTop: \"0.5rem\", fontSize: \"1.125rem\" }}>\n This page could not be found.\n </p>\n </div>\n );\n}\n","\"use client\";\n\nimport React, { type ReactNode } from \"react\";\nimport NextLink from \"next/link\";\nimport type { ComponentRenderProps } from \"@json-render/react\";\n\n/**\n * Props expected by the Link component in json-render specs.\n */\nexport interface LinkProps {\n /** The target URL or route path */\n href: string;\n /** Whether to replace the current history entry */\n replace?: boolean;\n /** Whether to prefetch the linked route */\n prefetch?: boolean;\n /** CSS class name */\n className?: string;\n /** Inline styles */\n style?: React.CSSProperties;\n}\n\n/**\n * Built-in Link component for json-render Next.js specs.\n *\n * Wraps `next/link` for client-side navigation between routes.\n *\n * Usage in a spec:\n * ```json\n * {\n * \"type\": \"Link\",\n * \"props\": { \"href\": \"/about\" },\n * \"children\": [\"link-text\"]\n * }\n * ```\n */\nexport function Link({ element, children }: ComponentRenderProps<LinkProps>) {\n const { href, replace, prefetch, className, style } =\n element.props as LinkProps;\n\n return (\n <NextLink\n href={href}\n replace={replace}\n prefetch={prefetch}\n className={className}\n style={style}\n >\n {children}\n </NextLink>\n );\n}\n","\"use client\";\n\n// =============================================================================\n// @json-render/next — Client exports\n//\n// This entry point includes client components and is safe to import\n// in \"use client\" modules and Next.js pages/layouts.\n// =============================================================================\n\n// Provider\nexport {\n NextAppProvider,\n useNextApp,\n type NextAppProviderProps,\n type NextAppContextValue,\n} from \"./components/provider\";\n\n// Page renderer\nexport {\n PageRenderer,\n type PageRendererProps,\n} from \"./components/page-renderer\";\n\n// Error boundary\nexport {\n NextErrorBoundary,\n type NextErrorBoundaryProps,\n} from \"./components/error-boundary\";\n\n// Loading\nexport {\n NextLoading,\n type NextLoadingProps,\n} from \"./components/loading-renderer\";\n\n// Not found\nexport { NextNotFound } from \"./components/not-found-renderer\";\n\n// Link component\nexport { Link, type LinkProps } from \"./components/link\";\n\n// Types (re-exported for convenience)\nexport type {\n NextAppSpec,\n NextRouteSpec,\n NextMetadata,\n MatchedRoute,\n LoaderFn,\n CreateNextAppOptions,\n NextAppExports,\n PageData,\n} from \"./types\";\n\n// Catalog types (re-exported from @json-render/react)\nexport type {\n EventHandle,\n BaseComponentProps,\n SetState,\n StateModel,\n ComponentContext,\n ComponentFn,\n Components,\n ActionFn,\n Actions,\n} from \"./catalog-types\";\n\n// Core types (re-exported for convenience)\nexport type { Spec, StateStore } from \"@json-render/core\";\nexport { createStateStore } from \"@json-render/core\";\nexport type {\n ComponentRegistry,\n ComponentRenderProps,\n} from \"@json-render/react\";\n"],"mappings":";;;;;;;;;AAIA,SAAS,gBAAwC;AAyCtC,cAIP,YAJO;AAlBJ,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAA2B;AACzB,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,WAAW;AACvB,eAAW,IAAI;AAAA,EACjB,QAAQ;AAAA,EAER;AAEA,MAAI,aAAa,UAAU;AACzB,UAAM,oBAAuC;AAAA,MAC3C,GAAG;AAAA,MACH,MAAM,MAAM;AAAA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AA,MAEA;AAAA,wBAAAD,KAAC,QAAG,OAAO,EAAE,UAAU,QAAQ,YAAY,KAAK,QAAQ,EAAE,GAAG,iBAAG;AAAA,QAChE,gBAAAA,KAAC,OAAE,OAAO,EAAE,OAAO,QAAQ,WAAW,UAAU,UAAU,WAAW,GAAG,2CAExE;AAAA;AAAA;AAAA,EACF;AAEJ;;;ACvBA,OAAO,cAAc;AAsCjB,gBAAAE,YAAA;AALG,SAAS,KAAK,EAAE,SAAS,SAAS,GAAoC;AAC3E,QAAM,EAAE,MAAM,SAAS,UAAU,WAAW,MAAM,IAChD,QAAQ;AAEV,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;;;ACiBA,SAAS,wBAAwB;","names":["jsx","jsxs","jsx","jsxs","jsx"]}
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Spec } from '@json-render/core';
3
+
4
+ /**
5
+ * Props for PageRenderer.
6
+ */
7
+ interface PageRendererProps {
8
+ /** Page element tree spec */
9
+ spec: Spec;
10
+ /** Initial state (merged from spec.state, global state, and loader data) */
11
+ initialState?: Record<string, unknown>;
12
+ /** Optional layout element tree spec */
13
+ layoutSpec?: Spec | null;
14
+ /** Whether the spec is currently loading/streaming */
15
+ loading?: boolean;
16
+ }
17
+ /**
18
+ * Client component that renders a json-render page within the Next.js app.
19
+ *
20
+ * Reads the component registry and action handlers from NextAppProvider context.
21
+ * Handles layout rendering by injecting page content into a Slot component.
22
+ */
23
+ declare function PageRenderer({ spec, initialState, layoutSpec, loading, }: PageRendererProps): react_jsx_runtime.JSX.Element;
24
+
25
+ export { PageRenderer, type PageRendererProps };
@@ -0,0 +1,25 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Spec } from '@json-render/core';
3
+
4
+ /**
5
+ * Props for PageRenderer.
6
+ */
7
+ interface PageRendererProps {
8
+ /** Page element tree spec */
9
+ spec: Spec;
10
+ /** Initial state (merged from spec.state, global state, and loader data) */
11
+ initialState?: Record<string, unknown>;
12
+ /** Optional layout element tree spec */
13
+ layoutSpec?: Spec | null;
14
+ /** Whether the spec is currently loading/streaming */
15
+ loading?: boolean;
16
+ }
17
+ /**
18
+ * Client component that renders a json-render page within the Next.js app.
19
+ *
20
+ * Reads the component registry and action handlers from NextAppProvider context.
21
+ * Handles layout rendering by injecting page content into a Slot component.
22
+ */
23
+ declare function PageRenderer({ spec, initialState, layoutSpec, loading, }: PageRendererProps): react_jsx_runtime.JSX.Element;
24
+
25
+ export { PageRenderer, type PageRendererProps };
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+ "use client";
3
+
4
+
5
+ var _chunk37T7IDU5js = require('./chunk-37T7IDU5.js');
6
+
7
+
8
+ exports.PageRenderer = _chunk37T7IDU5js.PageRenderer;
9
+ //# sourceMappingURL=page-renderer-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/json-render/json-render/packages/next/dist/page-renderer-client.js"],"names":[],"mappings":"AAAA,qFAAY;AACZ,YAAY;AACZ;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,qDAAC","file":"/home/runner/work/json-render/json-render/packages/next/dist/page-renderer-client.js"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ "use client";
3
+ import {
4
+ PageRenderer
5
+ } from "./chunk-KWYBSJZC.mjs";
6
+ export {
7
+ PageRenderer
8
+ };
9
+ //# sourceMappingURL=page-renderer-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}