@flyo/nitro-next 1.12.1 → 2.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/dist/client.d.mts +34 -2
- package/dist/client.d.ts +34 -2
- package/dist/client.js +10 -0
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +9 -0
- package/dist/client.mjs.map +1 -1
- package/dist/proxy.d.mts +6 -18
- package/dist/proxy.d.ts +6 -18
- package/dist/proxy.js +2 -1
- package/dist/proxy.js.map +1 -1
- package/dist/proxy.mjs +2 -1
- package/dist/proxy.mjs.map +1 -1
- package/dist/server.d.mts +136 -189
- package/dist/server.d.ts +136 -189
- package/dist/server.js +158 -187
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +157 -177
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -10,24 +10,7 @@ import {
|
|
|
10
10
|
SearchApi
|
|
11
11
|
} from "@flyo/nitro-typescript";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
|
|
14
|
-
configuration: null,
|
|
15
|
-
accessToken: null,
|
|
16
|
-
lang: null,
|
|
17
|
-
baseUrl: null,
|
|
18
|
-
components: {},
|
|
19
|
-
showMissingComponentAlert: false,
|
|
20
|
-
liveEdit: false,
|
|
21
|
-
serverCacheTtl: 1200,
|
|
22
|
-
clientCacheTtl: 900
|
|
23
|
-
};
|
|
24
|
-
function getNitro() {
|
|
25
|
-
if (!globalNitroState.configuration) {
|
|
26
|
-
throw new Error("Nitro has not been initialized. Make sure to call initNitro() first.");
|
|
27
|
-
}
|
|
28
|
-
return globalNitroState;
|
|
29
|
-
}
|
|
30
|
-
var initNitro = ({
|
|
13
|
+
function initNitro({
|
|
31
14
|
accessToken,
|
|
32
15
|
lang,
|
|
33
16
|
baseUrl,
|
|
@@ -36,57 +19,76 @@ var initNitro = ({
|
|
|
36
19
|
liveEdit,
|
|
37
20
|
serverCacheTtl,
|
|
38
21
|
clientCacheTtl
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
}) {
|
|
23
|
+
const configuration = new Configuration({ apiKey: accessToken });
|
|
24
|
+
const state = {
|
|
25
|
+
accessToken,
|
|
26
|
+
lang: lang ?? null,
|
|
27
|
+
baseUrl: baseUrl ?? null,
|
|
28
|
+
components: components ?? {},
|
|
29
|
+
showMissingComponentAlert: showMissingComponentAlert ?? liveEdit ?? false,
|
|
30
|
+
liveEdit: liveEdit ?? false,
|
|
31
|
+
serverCacheTtl: serverCacheTtl ?? 1200,
|
|
32
|
+
clientCacheTtl: clientCacheTtl ?? 900
|
|
33
|
+
};
|
|
34
|
+
const getNitroConfig = cache(async () => {
|
|
35
|
+
const configApi = new ConfigApi(configuration);
|
|
36
|
+
const useLang = state.lang ?? void 0;
|
|
37
|
+
return configApi.config({ lang: useLang });
|
|
38
|
+
});
|
|
39
|
+
const pageResolveRoute = cache(async ({ params }) => {
|
|
40
|
+
const { slug } = await params;
|
|
41
|
+
const path = slug?.join("/") ?? "";
|
|
42
|
+
const cfg = await getNitroConfig();
|
|
43
|
+
if (!cfg.pages?.includes(path)) {
|
|
44
|
+
notFound();
|
|
45
|
+
}
|
|
46
|
+
const page = await new PagesApi(configuration).page({ slug: path }).catch((error) => {
|
|
47
|
+
console.error("Error fetching page:", path, error);
|
|
48
|
+
notFound();
|
|
43
49
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
globalNitroState.components = components ?? {};
|
|
49
|
-
globalNitroState.showMissingComponentAlert = showMissingComponentAlert ?? liveEdit ?? false;
|
|
50
|
-
globalNitroState.liveEdit = liveEdit ?? false;
|
|
51
|
-
globalNitroState.serverCacheTtl = serverCacheTtl ?? 1200;
|
|
52
|
-
globalNitroState.clientCacheTtl = clientCacheTtl ?? 900;
|
|
53
|
-
return () => globalNitroState;
|
|
54
|
-
};
|
|
55
|
-
var getNitroConfig = cache(async () => {
|
|
56
|
-
const state = getNitro();
|
|
57
|
-
const configApi = new ConfigApi(state.configuration);
|
|
58
|
-
const useLang = state.lang ?? void 0;
|
|
59
|
-
const config = await configApi.config({ lang: useLang });
|
|
60
|
-
return config;
|
|
61
|
-
});
|
|
62
|
-
function getNitroPages() {
|
|
63
|
-
return new PagesApi(getNitro().configuration);
|
|
64
|
-
}
|
|
65
|
-
function getNitroEntities() {
|
|
66
|
-
return new EntitiesApi(getNitro().configuration);
|
|
67
|
-
}
|
|
68
|
-
function getNitroSitemap() {
|
|
69
|
-
return new SitemapApi(getNitro().configuration);
|
|
70
|
-
}
|
|
71
|
-
function getNitroSearch() {
|
|
72
|
-
return new SearchApi(getNitro().configuration);
|
|
73
|
-
}
|
|
74
|
-
var nitroPageResolveRoute = cache(async ({ params }) => {
|
|
75
|
-
const { slug } = await params;
|
|
76
|
-
const path = slug?.join("/") ?? "";
|
|
77
|
-
const cfg = await getNitroConfig();
|
|
78
|
-
if (!cfg.pages?.includes(path)) {
|
|
79
|
-
notFound();
|
|
80
|
-
}
|
|
81
|
-
const page = await getNitroPages().page({ slug: path }).catch((error) => {
|
|
82
|
-
console.error("Error fetching page:", path, error);
|
|
83
|
-
notFound();
|
|
50
|
+
if (!page) {
|
|
51
|
+
notFound();
|
|
52
|
+
}
|
|
53
|
+
return { page, path, cfg };
|
|
84
54
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
55
|
+
const sitemap = async () => {
|
|
56
|
+
const sitemapApi = new SitemapApi(configuration);
|
|
57
|
+
const sitemapLang = state.lang ?? void 0;
|
|
58
|
+
if (!state.baseUrl) {
|
|
59
|
+
throw new Error("baseUrl is not configured. Please set it in initNitro().");
|
|
60
|
+
}
|
|
61
|
+
const items = await sitemapApi.sitemap({ lang: sitemapLang });
|
|
62
|
+
const cleanBaseUrl = state.baseUrl.endsWith("/") ? state.baseUrl.slice(0, -1) : state.baseUrl;
|
|
63
|
+
return items.map((item) => {
|
|
64
|
+
let path = "";
|
|
65
|
+
if (item.routes && typeof item.routes === "object") {
|
|
66
|
+
const routeValues = Object.values(item.routes);
|
|
67
|
+
if (routeValues.length > 0) {
|
|
68
|
+
path = routeValues[0];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!path && item.entity_slug) {
|
|
72
|
+
path = item.entity_slug;
|
|
73
|
+
}
|
|
74
|
+
const cleanPath = path && !path.startsWith("/") ? `/${path}` : path;
|
|
75
|
+
return {
|
|
76
|
+
url: `${cleanBaseUrl}${cleanPath}`,
|
|
77
|
+
lastModified: /* @__PURE__ */ new Date()
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
state,
|
|
83
|
+
getNitroConfig,
|
|
84
|
+
getNitroPages: () => new PagesApi(configuration),
|
|
85
|
+
getNitroEntities: () => new EntitiesApi(configuration),
|
|
86
|
+
getNitroSitemap: () => new SitemapApi(configuration),
|
|
87
|
+
getNitroSearch: () => new SearchApi(configuration),
|
|
88
|
+
pageResolveRoute,
|
|
89
|
+
sitemap
|
|
90
|
+
};
|
|
91
|
+
}
|
|
90
92
|
var readEnv = (key, fallback = "") => {
|
|
91
93
|
const value = process.env[key];
|
|
92
94
|
if (value !== void 0 && value !== "") {
|
|
@@ -94,9 +96,19 @@ var readEnv = (key, fallback = "") => {
|
|
|
94
96
|
}
|
|
95
97
|
return fallback;
|
|
96
98
|
};
|
|
97
|
-
function
|
|
99
|
+
function createCachedEntityResolver(resolver) {
|
|
100
|
+
return cache(async ({ params }) => {
|
|
101
|
+
const entity = await resolver(params);
|
|
102
|
+
if (!entity) {
|
|
103
|
+
notFound();
|
|
104
|
+
}
|
|
105
|
+
return entity;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function NitroDebugInfo({ flyo }) {
|
|
98
109
|
try {
|
|
99
|
-
const
|
|
110
|
+
const config = await flyo.getNitroConfig();
|
|
111
|
+
const { state } = flyo;
|
|
100
112
|
const mode = readEnv("NODE_ENV", "-");
|
|
101
113
|
const vercelDeploymentId = readEnv("VERCEL_DEPLOYMENT_ID", "-");
|
|
102
114
|
const vercelGitCommitSha = readEnv("VERCEL_GIT_COMMIT_SHA", "-");
|
|
@@ -127,19 +139,10 @@ function NitroDebugInfo({ config }) {
|
|
|
127
139
|
}
|
|
128
140
|
const debugInfo = debugInfoParts.join(" | ");
|
|
129
141
|
return /* @__PURE__ */ jsx("template", { dangerouslySetInnerHTML: { __html: `<!-- ${debugInfo} -->` }, suppressHydrationWarning: true });
|
|
130
|
-
} catch
|
|
142
|
+
} catch {
|
|
131
143
|
return /* @__PURE__ */ jsx("template", { dangerouslySetInnerHTML: { __html: `<!-- nitro-debug: not initialized -->` }, suppressHydrationWarning: true });
|
|
132
144
|
}
|
|
133
145
|
}
|
|
134
|
-
function createCachedEntityResolver(resolver) {
|
|
135
|
-
return cache(async ({ params }) => {
|
|
136
|
-
const entity = await resolver(params);
|
|
137
|
-
if (!entity) {
|
|
138
|
-
notFound();
|
|
139
|
-
}
|
|
140
|
-
return entity;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
146
|
function NitroEntityJsonLd({ entity }) {
|
|
144
147
|
if (!entity?.jsonld) {
|
|
145
148
|
return null;
|
|
@@ -155,7 +158,8 @@ function NitroEntityJsonLd({ entity }) {
|
|
|
155
158
|
);
|
|
156
159
|
}
|
|
157
160
|
function NitroPage({
|
|
158
|
-
page
|
|
161
|
+
page,
|
|
162
|
+
flyo
|
|
159
163
|
}) {
|
|
160
164
|
if (!page?.json || !Array.isArray(page.json)) {
|
|
161
165
|
return null;
|
|
@@ -163,23 +167,24 @@ function NitroPage({
|
|
|
163
167
|
return /* @__PURE__ */ jsx(Fragment, { children: page.json.map((block, index) => /* @__PURE__ */ jsx(
|
|
164
168
|
NitroBlock,
|
|
165
169
|
{
|
|
166
|
-
block
|
|
170
|
+
block,
|
|
171
|
+
flyo
|
|
167
172
|
},
|
|
168
173
|
block.uid || index
|
|
169
174
|
)) });
|
|
170
175
|
}
|
|
171
176
|
function NitroBlock({
|
|
172
|
-
block
|
|
177
|
+
block,
|
|
178
|
+
flyo
|
|
173
179
|
}) {
|
|
174
180
|
if (!block) {
|
|
175
181
|
return null;
|
|
176
182
|
}
|
|
177
|
-
const
|
|
178
|
-
const Component = block.component ? state.components[block.component] : void 0;
|
|
183
|
+
const Component = block.component ? flyo.state.components[block.component] : void 0;
|
|
179
184
|
if (Component) {
|
|
180
185
|
return /* @__PURE__ */ jsx(Component, { block });
|
|
181
186
|
}
|
|
182
|
-
if (state.showMissingComponentAlert) {
|
|
187
|
+
if (flyo.state.showMissingComponentAlert) {
|
|
183
188
|
return /* @__PURE__ */ jsxs("div", { style: { border: "1px solid #fff", padding: "1rem", marginBottom: "1rem", backgroundColor: "red" }, children: [
|
|
184
189
|
"Component ",
|
|
185
190
|
/* @__PURE__ */ jsx("b", { children: block.component }),
|
|
@@ -189,7 +194,8 @@ function NitroBlock({
|
|
|
189
194
|
return null;
|
|
190
195
|
}
|
|
191
196
|
function NitroSlot({
|
|
192
|
-
slot
|
|
197
|
+
slot,
|
|
198
|
+
flyo
|
|
193
199
|
}) {
|
|
194
200
|
if (!slot?.content || !Array.isArray(slot.content)) {
|
|
195
201
|
return null;
|
|
@@ -197,109 +203,92 @@ function NitroSlot({
|
|
|
197
203
|
return /* @__PURE__ */ jsx(Fragment, { children: slot.content.map((block, index) => /* @__PURE__ */ jsx(
|
|
198
204
|
NitroBlock,
|
|
199
205
|
{
|
|
200
|
-
block
|
|
206
|
+
block,
|
|
207
|
+
flyo
|
|
201
208
|
},
|
|
202
209
|
block.uid || index
|
|
203
210
|
)) });
|
|
204
211
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
function nitroPageRoute(flyo) {
|
|
213
|
+
async function pageRoute(props) {
|
|
214
|
+
const { page } = await flyo.pageResolveRoute(props);
|
|
215
|
+
return /* @__PURE__ */ jsx(NitroPage, { page, flyo });
|
|
216
|
+
}
|
|
217
|
+
return pageRoute;
|
|
208
218
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
description,
|
|
220
|
-
openGraph: {
|
|
221
|
-
title,
|
|
222
|
-
description,
|
|
223
|
-
images: ogImage ? [ogImage] : [],
|
|
224
|
-
type: "website"
|
|
225
|
-
},
|
|
226
|
-
twitter: {
|
|
227
|
-
card: "summary_large_image",
|
|
219
|
+
function nitroPageGenerateMetadata(flyo) {
|
|
220
|
+
return async (props) => {
|
|
221
|
+
const { page } = await flyo.pageResolveRoute(props);
|
|
222
|
+
const meta = page.meta_json;
|
|
223
|
+
const title = meta?.title || page.title || "";
|
|
224
|
+
const description = meta?.description ?? "";
|
|
225
|
+
const image = meta?.image ?? "";
|
|
226
|
+
const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : void 0;
|
|
227
|
+
const twImage = image ? `${image}/thumb/1200x600?format=jpg` : void 0;
|
|
228
|
+
return {
|
|
228
229
|
title,
|
|
229
230
|
description,
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
openGraph: {
|
|
232
|
+
title,
|
|
233
|
+
description,
|
|
234
|
+
images: ogImage ? [ogImage] : [],
|
|
235
|
+
type: "website"
|
|
236
|
+
},
|
|
237
|
+
twitter: {
|
|
238
|
+
card: "summary_large_image",
|
|
239
|
+
title,
|
|
240
|
+
description,
|
|
241
|
+
images: twImage ? [twImage] : []
|
|
242
|
+
}
|
|
243
|
+
};
|
|
232
244
|
};
|
|
233
245
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
246
|
+
function nitroPageGenerateStaticParams(flyo) {
|
|
247
|
+
return async () => {
|
|
248
|
+
const cfg = await flyo.getNitroConfig();
|
|
249
|
+
const pages = cfg.pages ?? [];
|
|
250
|
+
return pages.map((path) => ({
|
|
251
|
+
slug: path === "" ? void 0 : path.split("/")
|
|
252
|
+
}));
|
|
253
|
+
};
|
|
240
254
|
}
|
|
241
|
-
function nitroEntityRoute(
|
|
255
|
+
function nitroEntityRoute(flyo, options) {
|
|
242
256
|
const cachedResolver = createCachedEntityResolver(options.resolver);
|
|
243
|
-
|
|
257
|
+
async function entityRoute(props) {
|
|
244
258
|
const entity = await cachedResolver(props);
|
|
245
259
|
if (options.render) {
|
|
246
260
|
return options.render(entity);
|
|
247
261
|
}
|
|
248
262
|
return /* @__PURE__ */ jsx("div", { children: entity.entity?.entity_title });
|
|
249
|
-
}
|
|
263
|
+
}
|
|
264
|
+
return entityRoute;
|
|
250
265
|
}
|
|
251
|
-
|
|
266
|
+
function nitroEntityGenerateMetadata(flyo, options) {
|
|
252
267
|
const cachedResolver = createCachedEntityResolver(options.resolver);
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
description,
|
|
262
|
-
openGraph: {
|
|
263
|
-
title,
|
|
264
|
-
description,
|
|
265
|
-
images: ogImage ? [ogImage] : [],
|
|
266
|
-
type: "website"
|
|
267
|
-
},
|
|
268
|
-
twitter: {
|
|
269
|
-
card: "summary_large_image",
|
|
268
|
+
return async (props) => {
|
|
269
|
+
const entity = await cachedResolver(props);
|
|
270
|
+
const title = entity.entity?.entity_title || "";
|
|
271
|
+
const description = entity.entity?.entity_teaser ?? "";
|
|
272
|
+
const image = entity.entity?.entity_image ?? "";
|
|
273
|
+
const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : void 0;
|
|
274
|
+
const twImage = image ? `${image}/thumb/1200x600?format=jpg` : void 0;
|
|
275
|
+
return {
|
|
270
276
|
title,
|
|
271
277
|
description,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const baseUrl = state.baseUrl;
|
|
284
|
-
const cleanBaseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
285
|
-
return items.map((item) => {
|
|
286
|
-
let path = "";
|
|
287
|
-
if (item.routes && typeof item.routes === "object") {
|
|
288
|
-
const routeValues = Object.values(item.routes);
|
|
289
|
-
if (routeValues.length > 0) {
|
|
290
|
-
path = routeValues[0];
|
|
278
|
+
openGraph: {
|
|
279
|
+
title,
|
|
280
|
+
description,
|
|
281
|
+
images: ogImage ? [ogImage] : [],
|
|
282
|
+
type: "website"
|
|
283
|
+
},
|
|
284
|
+
twitter: {
|
|
285
|
+
card: "summary_large_image",
|
|
286
|
+
title,
|
|
287
|
+
description,
|
|
288
|
+
images: twImage ? [twImage] : []
|
|
291
289
|
}
|
|
292
|
-
}
|
|
293
|
-
if (!path && item.entity_slug) {
|
|
294
|
-
path = item.entity_slug;
|
|
295
|
-
}
|
|
296
|
-
const cleanPath = path && !path.startsWith("/") ? `/${path}` : path;
|
|
297
|
-
const lastModified = /* @__PURE__ */ new Date();
|
|
298
|
-
return {
|
|
299
|
-
url: `${cleanBaseUrl}${cleanPath}`,
|
|
300
|
-
lastModified
|
|
301
290
|
};
|
|
302
|
-
}
|
|
291
|
+
};
|
|
303
292
|
}
|
|
304
293
|
export {
|
|
305
294
|
NitroBlock,
|
|
@@ -307,20 +296,11 @@ export {
|
|
|
307
296
|
NitroEntityJsonLd,
|
|
308
297
|
NitroPage,
|
|
309
298
|
NitroSlot,
|
|
310
|
-
getNitro,
|
|
311
|
-
getNitroConfig,
|
|
312
|
-
getNitroEntities,
|
|
313
|
-
getNitroPages,
|
|
314
|
-
getNitroSearch,
|
|
315
|
-
getNitroSitemap,
|
|
316
|
-
globalNitroState,
|
|
317
299
|
initNitro,
|
|
318
300
|
nitroEntityGenerateMetadata,
|
|
319
301
|
nitroEntityRoute,
|
|
320
302
|
nitroPageGenerateMetadata,
|
|
321
303
|
nitroPageGenerateStaticParams,
|
|
322
|
-
|
|
323
|
-
nitroPageRoute,
|
|
324
|
-
nitroSitemap
|
|
304
|
+
nitroPageRoute
|
|
325
305
|
};
|
|
326
306
|
//# sourceMappingURL=server.mjs.map
|
package/dist/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.tsx"],"sourcesContent":["import { cache } from 'react';\nimport type { Metadata, MetadataRoute } from 'next';\nimport { notFound } from 'next/navigation';\nimport {\n Page,\n Block,\n Entity,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi,\n SitemapApi,\n SearchApi\n} from '@flyo/nitro-typescript';\n\n/**\n * Interface for Nitro configuration state\n */\nexport interface NitroState {\n configuration: Configuration | null;\n accessToken: string | null;\n lang: string | null;\n baseUrl: string | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n components: Record<string, any>;\n showMissingComponentAlert: boolean;\n liveEdit: boolean;\n serverCacheTtl: number;\n clientCacheTtl: number;\n}\n\n/**\n * Global Nitro state - shared across server and middleware\n */\nexport const globalNitroState: NitroState = {\n configuration: null,\n accessToken: null,\n lang: null,\n baseUrl: null,\n components: {},\n showMissingComponentAlert: false,\n liveEdit: false,\n serverCacheTtl: 1200,\n clientCacheTtl: 900\n};\n\n/**\n * Access the Nitro configuration state\n * Can be used anywhere: server components, middlewares, API routes, etc.\n * Must be called after initNitro() has been initialized.\n * \n * @throws {Error} If Nitro has not been initialized with initNitro()\n * \n * @example\n * ```ts\n * const state = getNitro();\n * const { configuration, lang, components } = state;\n * ```\n */\nexport function getNitro(): NitroState {\n if (!globalNitroState.configuration) {\n throw new Error('Nitro has not been initialized. Make sure to call initNitro() first.');\n }\n return globalNitroState;\n}\n\nexport const initNitro = ({\n accessToken,\n lang,\n baseUrl,\n components,\n showMissingComponentAlert,\n liveEdit,\n serverCacheTtl,\n clientCacheTtl,\n}: {\n accessToken: string;\n lang?: string;\n baseUrl?: string;\n components?: object;\n showMissingComponentAlert?: boolean;\n liveEdit?: boolean;\n serverCacheTtl?: number;\n clientCacheTtl?: number;\n}): ( () => NitroState ) => {\n\n if (!globalNitroState.configuration) {\n globalNitroState.configuration = new Configuration({\n apiKey: accessToken,\n });\n }\n\n globalNitroState.accessToken = accessToken;\n globalNitroState.lang = lang ?? null;\n globalNitroState.baseUrl = baseUrl ?? null;\n globalNitroState.components = components ?? {};\n globalNitroState.showMissingComponentAlert = showMissingComponentAlert ?? liveEdit ?? false;\n globalNitroState.liveEdit = liveEdit ?? false;\n globalNitroState.serverCacheTtl = serverCacheTtl ?? 1200;\n globalNitroState.clientCacheTtl = clientCacheTtl ?? 900;\n\n return () => globalNitroState;\n}\n\nexport const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n const state = getNitro();\n\n const configApi = new ConfigApi(state.configuration!);\n const useLang = state.lang ?? undefined;\n\n const config = await configApi.config({ lang: useLang });\n \n return config;\n});\n\nexport function getNitroPages(): PagesApi {\n return new PagesApi(getNitro().configuration!);\n}\n\nexport function getNitroEntities(): EntitiesApi {\n return new EntitiesApi(getNitro().configuration!);\n}\n\nexport function getNitroSitemap(): SitemapApi {\n return new SitemapApi(getNitro().configuration!);\n}\n\nexport function getNitroSearch(): SearchApi {\n return new SearchApi(getNitro().configuration!);\n}\n\n/**\n * Route params type for Next.js catch-all routes\n */\ntype RouteParams = {\n params: Promise<{ slug?: string[] }>;\n};\n\n/**\n * Generic route params type for entity routes\n * Allows any param structure from Next.js app router\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype EntityRouteParams<T = any> = {\n params: Promise<T>;\n};\n\n/**\n * Resolve a Nitro page from route params\n * Uses React cache to avoid duplicate fetching.\n * Use this when you need access to the page data for custom rendering logic.\n * \n * @example\n * ```tsx\n * // app/[[...slug]]/page.tsx\n * import { nitroPageResolveRoute, NitroPage } from '@flyo/nitro-next/server';\n * \n * export default async function Page(props: { params: Promise<{ slug?: string[] }> }) {\n * const { page, cfg } = await nitroPageResolveRoute(props);\n * return <NitroPage page={page} />;\n * }\n * ```\n */\nexport const nitroPageResolveRoute = cache(async ({ params }: RouteParams) => {\n const { slug } = await params;\n const path = slug?.join('/') ?? '';\n\n const cfg = await getNitroConfig();\n\n if (!cfg.pages?.includes(path)) {\n notFound();\n }\n\n const page = await getNitroPages()\n .page({ slug: path })\n .catch((error: unknown) => {\n console.error('Error fetching page:', path, error);\n notFound();\n });\n\n if (!page) {\n notFound();\n }\n\n return { page, path, cfg };\n});\n\n/**\n * Entity resolver function type\n * Users provide this to resolve entities from their route params\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type EntityResolver<T = any> = (params: Promise<T>) => Promise<Entity>;\n\n/**\n * Helper function to read environment variables with fallback\n * Checks process.env for server-side environment variables\n */\nconst readEnv = (key: string, fallback = \"\"): string => {\n const value = process.env[key];\n if (value !== undefined && value !== \"\") {\n return String(value);\n }\n return fallback;\n};\n\n/**\n * NitroDebugInfo Component\n * \n * Outputs debug information about the current Nitro/Flyo setup as an HTML comment.\n * This includes environment info, API version, token type, deployment details, etc.\n * \n * Usage: Add <NitroDebugInfo config={config} /> to your layout to include debug info in the HTML output.\n */\nexport function NitroDebugInfo({ config }: { config: ConfigResponse }) {\n try {\n // Get Nitro state\n const state = getNitro();\n\n // Get environment variables\n const mode = readEnv(\"NODE_ENV\", \"-\");\n const vercelDeploymentId = readEnv(\"VERCEL_DEPLOYMENT_ID\", \"-\");\n const vercelGitCommitSha = readEnv(\"VERCEL_GIT_COMMIT_SHA\", \"-\");\n const version = readEnv(\"VERSION\", \"\");\n\n // Get token from configuration and determine type\n const tokenValue = state.accessToken || \"\";\n const token = typeof tokenValue === \"string\" ? tokenValue : \"\";\n const tokenType = token.startsWith(\"p-\")\n ? \"production\"\n : token.startsWith(\"d-\")\n ? \"develop\"\n : \"unknown\";\n\n // Get live edit / debug status\n const debug = state.liveEdit;\n\n // Get API version from config.nitro\n const apiVersion = config.nitro?.version?.toString() || \"-\";\n const apiLastUpdate = config.nitro?.updated_at\n ? new Date(config.nitro.updated_at * 1000).toLocaleString(\"de-CH\", {\n day: \"2-digit\",\n month: \"2-digit\",\n year: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n })\n : \"-\";\n\n // Build debug info parts\n const debugInfoParts = [\n `liveedit:${debug}`,\n `env:${mode}`,\n `version:${apiVersion}`,\n `versiondate:${apiLastUpdate}`,\n `tokentype:${tokenType}`,\n `did:${vercelDeploymentId}`,\n `csha:${vercelGitCommitSha}`,\n ];\n\n if (version) {\n debugInfoParts.push(`release:${version}`);\n }\n\n const debugInfo = debugInfoParts.join(\" | \");\n\n // Return just the HTML comment as a real HTML comment (not text)\n // React requires dangerouslySetInnerHTML for raw HTML, so we use an empty template element\n // which is semantic and doesn't render in the DOM tree\n return (\n <template dangerouslySetInnerHTML={{ __html: `<!-- ${debugInfo} -->` }} suppressHydrationWarning />\n );\n } catch (error) {\n // If Nitro is not initialized or there's an error, return empty comment\n return <template dangerouslySetInnerHTML={{ __html: `<!-- nitro-debug: not initialized -->` }} suppressHydrationWarning />;\n }\n}\n\n/**\n * Internal helper to wrap and cache entity resolvers\n * Ensures the resolver is only called once per unique params\n */\nfunction createCachedEntityResolver<T>(\n resolver: EntityResolver<T>\n): (props: EntityRouteParams<T>) => Promise<Entity> {\n return cache(async ({ params }: EntityRouteParams<T>) => {\n const entity = await resolver(params);\n \n if (!entity) {\n notFound();\n }\n \n return entity;\n });\n}\n\n\n/**\n * Renders a JSON-LD structured data script tag from an Entity's jsonld field.\n * Safely escapes HTML entities to prevent XSS attacks.\n * Returns null if the entity has no jsonld data.\n * \n * @example\n * ```tsx\n * import { NitroEntityJsonLd } from '@flyo/nitro-next/server';\n * \n * export default function BlogPost({ entity }: { entity: Entity }) {\n * return (\n * <>\n * <NitroEntityJsonLd entity={entity} />\n * <h1>{entity.entity?.entity_title}</h1>\n * </>\n * );\n * }\n * ```\n */\nexport function NitroEntityJsonLd({ entity }: { entity: Entity }) {\n if (!entity?.jsonld) {\n return null;\n }\n\n return (\n <script\n type=\"application/ld+json\"\n dangerouslySetInnerHTML={{\n __html: JSON.stringify(entity.jsonld).replace(/</g, '\\\\u003c'),\n }}\n />\n );\n}\n\n/**\n * NitroPage component renders all blocks from a Flyo page\n */\nexport function NitroPage({\n page,\n}: {\n page: Page\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\nexport function NitroBlock({\n block,\n}: {\n block: Block\n}) {\n if (!block) {\n return null;\n }\n\n const state = getNitro();\n const Component = block.component ? state.components[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n if (state.showMissingComponentAlert) {\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n }\n\n return null;\n}\n\n/**\n * NitroSlot component renders nested blocks from a slot\n * Used for recursive block rendering when blocks contain slots\n * \n * @example\n * ```tsx\n * import { NitroSlot } from '@flyo/nitro-next/server';\n * \n * export default function MyComponent({ block }) {\n * return (\n * <div>\n * <NitroSlot slot={block.slots.mysuperslotname} />\n * </div>\n * );\n * }\n * ```\n */\nexport function NitroSlot({\n slot,\n}: {\n slot?: {\n content?: Block[];\n };\n}) {\n if (!slot?.content || !Array.isArray(slot.content)) {\n return null;\n }\n\n return (\n <>\n {slot.content.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n />\n ))}\n </>\n );\n}\n\n/**\n * Default page route handler for Nitro pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageRoute as default } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageRoute(props: RouteParams) {\n const { page } = await nitroPageResolveRoute(props);\n return <NitroPage page={page} />;\n}\n\n/**\n * Generate metadata for Nitro pages\n * Provides basic meta tags based on Flyo page data\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageGenerateMetadata as generateMetadata } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageGenerateMetadata(\n props: RouteParams\n): Promise<Metadata> {\n const { page } = await nitroPageResolveRoute(props);\n\n // Extract meta information from page\n const meta = page.meta_json;\n \n const title = meta?.title || page.title || '';\n const description = meta?.description ?? '';\n const image = meta?.image ?? '';\n\n const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : undefined;\n const twImage = image ? `${image}/thumb/1200x600?format=jpg` : undefined;\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: ogImage ? [ogImage] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: twImage ? [twImage] : [],\n },\n };\n}\n\n/**\n * Generate static params for all Nitro pages\n * Enables static site generation (SSG) for all pages\n * Can be re-exported directly from Next.js app routes\n * \n * @example\n * ```ts\n * // app/[[...slug]]/page.tsx\n * export { nitroPageGenerateStaticParams as generateStaticParams } from '@flyo/nitro-next/server';\n * ```\n */\nexport async function nitroPageGenerateStaticParams() {\n const cfg = await getNitroConfig();\n const pages = cfg.pages ?? [];\n\n return pages.map((path: string) => ({\n slug: path === '' ? undefined : path.split('/'),\n }));\n}\n\n/**\n * Default entity route handler with custom resolver\n * Flexible solution that works with any route param structure\n * \n * @example\n * ```ts\n * // app/blog/[slug]/page.tsx\n * const resolver = async (params: Promise<{ slug: string }>) => {\n * const { slug } = await params;\n * return getNitroEntities().entityBySlug({ slug, typeId: 123 });\n * };\n * \n * export default (props) => nitroEntityRoute(props, {\n * resolver,\n * render: (entity) => <h1>{entity.entity?.entity_title}</h1>\n * });\n * ```\n * \n * @example\n * ```ts\n * // app/items/[uniqueid]/page.tsx\n * const resolver = async (params: Promise<{ uniqueid: string }>) => {\n * const { uniqueid } = await params;\n * return getNitroEntities().entityByUniqueid({ uniqueid });\n * };\n * \n * export default (props) => nitroEntityRoute(props, { resolver });\n * ```\n * \n * @example\n * ```ts\n * // app/custom/[whatever]/page.tsx\n * const resolver = async (params: Promise<{ whatever: string }>) => {\n * const { whatever } = await params;\n * return getNitroEntities().entityBySlug({ slug: whatever });\n * };\n * \n * export default (props) => nitroEntityRoute(props, { resolver });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function nitroEntityRoute<T = any>(\n props: EntityRouteParams<T>,\n options: {\n resolver: EntityResolver<T>;\n render?: (entity: Entity) => React.ReactNode;\n }\n) {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n \n return (async () => {\n const entity = await cachedResolver(props);\n \n if (options.render) {\n return options.render(entity);\n }\n\n // Default simple render - users should provide their own render function\n return <div>{entity.entity?.entity_title}</div>;\n })();\n}\n\n/**\n * Generate metadata for Nitro entities with custom resolver\n * Works with any route param structure\n * \n * @example\n * ```ts\n * // app/blog/[slug]/page.tsx\n * const resolver = async (params: Promise<{ slug: string }>) => {\n * const { slug } = await params;\n * return getNitroEntities().entityBySlug({ slug, typeId: 123 });\n * };\n * \n * export const generateMetadata = (props) => nitroEntityGenerateMetadata(props, { resolver });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function nitroEntityGenerateMetadata<T = any>(\n props: EntityRouteParams<T>,\n options: {\n resolver: EntityResolver<T>;\n }\n): Promise<Metadata> {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n const entity = await cachedResolver(props);\n\n const title = entity.entity?.entity_title || '';\n const description = entity.entity?.entity_teaser ?? '';\n const image = entity.entity?.entity_image ?? '';\n\n const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : undefined;\n const twImage = image ? `${image}/thumb/1200x600?format=jpg` : undefined;\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: ogImage ? [ogImage] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: twImage ? [twImage] : [],\n },\n };\n}\n\n/**\n * Generate sitemap for Next.js from Flyo Nitro\n * Fetches all pages and entities from the sitemap endpoint\n * Uses the baseUrl from the Nitro configuration state\n * \n * @param state The Nitro state containing configuration and baseUrl\n * @returns Promise resolving to Next.js MetadataRoute.Sitemap format\n * \n * @example\n * ```ts\n * // app/sitemap.ts\n * import { nitroSitemap } from '@flyo/nitro-next/server';\n * import { flyoConfig } from '../flyo.config';\n * \n * export default async function sitemap() {\n * return nitroSitemap(flyoConfig());\n * }\n * ```\n * \n * @example\n * ```ts\n * // flyo.config.tsx\n * export const flyoConfig = initNitro({\n * accessToken: process.env.FLYO_ACCESS_TOKEN!,\n * baseUrl: process.env.SITE_URL || 'http://localhost:3000',\n * lang: 'en',\n * });\n * ```\n */\nexport async function nitroSitemap(state: NitroState): Promise<MetadataRoute.Sitemap> {\n const sitemapApi = getNitroSitemap();\n const lang = state.lang ?? undefined;\n\n if (!state.baseUrl) {\n throw new Error('baseUrl is not configured in Nitro state. Please set it in initNitro().');\n }\n\n // Fetch all sitemap entries from Flyo Nitro\n const items = await sitemapApi.sitemap({ lang });\n\n const baseUrl = state.baseUrl;\n \n // Remove trailing slash from baseUrl for consistency\n const cleanBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;\n\n return items.map((item) => {\n // Prefer routes object if available, otherwise use entity_slug\n let path = '';\n \n if (item.routes && typeof item.routes === 'object') {\n // Use the first available route from the routes object\n const routeValues = Object.values(item.routes);\n if (routeValues.length > 0) {\n path = routeValues[0];\n }\n }\n \n // Fallback to entity_slug if no routes found\n if (!path && item.entity_slug) {\n path = item.entity_slug;\n }\n\n // Ensure path starts with /\n const cleanPath = path && !path.startsWith('/') ? `/${path}` : path;\n\n // Convert Unix timestamp to Date if available\n const lastModified = new Date();\n\n return {\n url: `${cleanBaseUrl}${cleanPath}`,\n lastModified,\n };\n });\n}"],"mappings":";AAAA,SAAS,aAAa;AAEtB,SAAS,gBAAgB;AACzB;AA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{ cache } from 'react';\nimport type { Metadata, MetadataRoute } from 'next';\nimport { notFound } from 'next/navigation';\nimport {\n Page,\n Block,\n Entity,\n ConfigApi,\n ConfigResponse,\n Configuration,\n PagesApi,\n EntitiesApi,\n SitemapApi,\n SearchApi\n} from '@flyo/nitro-typescript';\n\n/**\n * Read-only configuration state\n */\nexport interface NitroState {\n readonly accessToken: string;\n readonly lang: string | null;\n readonly baseUrl: string | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly components: Record<string, any>;\n readonly showMissingComponentAlert: boolean;\n readonly liveEdit: boolean;\n readonly serverCacheTtl: number;\n readonly clientCacheTtl: number;\n}\n\n/**\n * Route params type for Next.js catch-all routes\n */\ntype RouteParams = {\n params: Promise<{ slug?: string[] }>;\n};\n\n/**\n * Generic route params type for entity routes\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype EntityRouteParams<T = any> = {\n params: Promise<T>;\n};\n\n/**\n * Entity resolver function type\n * Users provide this to resolve entities from their route params\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type EntityResolver<T = any> = (params: Promise<T>) => Promise<Entity>;\n\n/**\n * The Flyo instance returned by initNitro().\n * Carries all API access methods and configuration state.\n */\nexport interface FlyoInstance {\n /** Read-only configuration state */\n readonly state: NitroState;\n /** Fetch and cache the Nitro CMS configuration (React-cached per request) */\n getNitroConfig(): Promise<ConfigResponse>;\n /** Create a PagesApi client */\n getNitroPages(): PagesApi;\n /** Create an EntitiesApi client */\n getNitroEntities(): EntitiesApi;\n /** Create a SitemapApi client */\n getNitroSitemap(): SitemapApi;\n /** Create a SearchApi client */\n getNitroSearch(): SearchApi;\n /** Resolve a page from catch-all route params (React-cached per request) */\n pageResolveRoute(props: RouteParams): Promise<{ page: Page; path: string; cfg: ConfigResponse }>;\n /** Generate a Next.js sitemap from Flyo Nitro content */\n sitemap(): Promise<MetadataRoute.Sitemap>;\n}\n\n/**\n * Initialize and return a FlyoInstance.\n *\n * Call once in your flyo.config.tsx and export the result.\n * The returned object carries all methods bound to the configuration,\n * eliminating the need for global state.\n *\n * @example\n * ```tsx\n * // flyo.config.tsx\n * import { initNitro } from '@flyo/nitro-next/server';\n *\n * export const flyo = initNitro({\n * accessToken: process.env.FLYO_ACCESS_TOKEN || '',\n * lang: 'en',\n * baseUrl: process.env.SITE_URL || 'http://localhost:3000',\n * liveEdit: process.env.FLYO_LIVE_EDIT === 'true',\n * components: { HeroBanner, Text },\n * });\n * ```\n */\nexport function initNitro({\n accessToken,\n lang,\n baseUrl,\n components,\n showMissingComponentAlert,\n liveEdit,\n serverCacheTtl,\n clientCacheTtl,\n}: {\n accessToken: string;\n lang?: string;\n baseUrl?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n components?: Record<string, any>;\n showMissingComponentAlert?: boolean;\n liveEdit?: boolean;\n serverCacheTtl?: number;\n clientCacheTtl?: number;\n}): FlyoInstance {\n const configuration = new Configuration({ apiKey: accessToken });\n\n const state: NitroState = {\n accessToken,\n lang: lang ?? null,\n baseUrl: baseUrl ?? null,\n components: components ?? {},\n showMissingComponentAlert: showMissingComponentAlert ?? liveEdit ?? false,\n liveEdit: liveEdit ?? false,\n serverCacheTtl: serverCacheTtl ?? 1200,\n clientCacheTtl: clientCacheTtl ?? 900,\n };\n\n const getNitroConfig = cache(async (): Promise<ConfigResponse> => {\n const configApi = new ConfigApi(configuration);\n const useLang = state.lang ?? undefined;\n return configApi.config({ lang: useLang });\n });\n\n const pageResolveRoute = cache(async ({ params }: RouteParams) => {\n const { slug } = await params;\n const path = slug?.join('/') ?? '';\n\n const cfg = await getNitroConfig();\n\n if (!cfg.pages?.includes(path)) {\n notFound();\n }\n\n const page = await new PagesApi(configuration)\n .page({ slug: path })\n .catch((error: unknown) => {\n console.error('Error fetching page:', path, error);\n notFound();\n });\n\n if (!page) {\n notFound();\n }\n\n return { page, path, cfg };\n });\n\n const sitemap = async (): Promise<MetadataRoute.Sitemap> => {\n const sitemapApi = new SitemapApi(configuration);\n const sitemapLang = state.lang ?? undefined;\n\n if (!state.baseUrl) {\n throw new Error('baseUrl is not configured. Please set it in initNitro().');\n }\n\n const items = await sitemapApi.sitemap({ lang: sitemapLang });\n const cleanBaseUrl = state.baseUrl.endsWith('/') ? state.baseUrl.slice(0, -1) : state.baseUrl;\n\n return items.map((item) => {\n let path = '';\n\n if (item.routes && typeof item.routes === 'object') {\n const routeValues = Object.values(item.routes);\n if (routeValues.length > 0) {\n path = routeValues[0];\n }\n }\n\n if (!path && item.entity_slug) {\n path = item.entity_slug;\n }\n\n const cleanPath = path && !path.startsWith('/') ? `/${path}` : path;\n\n return {\n url: `${cleanBaseUrl}${cleanPath}`,\n lastModified: new Date(),\n };\n });\n };\n\n return {\n state,\n getNitroConfig,\n getNitroPages: () => new PagesApi(configuration),\n getNitroEntities: () => new EntitiesApi(configuration),\n getNitroSitemap: () => new SitemapApi(configuration),\n getNitroSearch: () => new SearchApi(configuration),\n pageResolveRoute,\n sitemap,\n };\n}\n\n// ─── Helper ──────────────────────────────────────────────────────────────────\n\n/**\n * Helper function to read environment variables with fallback\n */\nconst readEnv = (key: string, fallback = \"\"): string => {\n const value = process.env[key];\n if (value !== undefined && value !== \"\") {\n return String(value);\n }\n return fallback;\n};\n\n/**\n * Internal helper to wrap and cache entity resolvers\n */\nfunction createCachedEntityResolver<T>(\n resolver: EntityResolver<T>\n): (props: EntityRouteParams<T>) => Promise<Entity> {\n return cache(async ({ params }: EntityRouteParams<T>) => {\n const entity = await resolver(params);\n\n if (!entity) {\n notFound();\n }\n\n return entity;\n });\n}\n\n// ─── Server Components ───────────────────────────────────────────────────────\n\n/**\n * NitroDebugInfo Component\n *\n * Async server component that outputs debug information as an HTML comment.\n * Resolves config internally from the flyo instance.\n *\n * @example\n * ```tsx\n * <NitroDebugInfo flyo={flyo} />\n * ```\n */\nexport async function NitroDebugInfo({ flyo }: { flyo: FlyoInstance }) {\n try {\n const config = await flyo.getNitroConfig();\n const { state } = flyo;\n\n const mode = readEnv(\"NODE_ENV\", \"-\");\n const vercelDeploymentId = readEnv(\"VERCEL_DEPLOYMENT_ID\", \"-\");\n const vercelGitCommitSha = readEnv(\"VERCEL_GIT_COMMIT_SHA\", \"-\");\n const version = readEnv(\"VERSION\", \"\");\n\n const tokenValue = state.accessToken || \"\";\n const token = typeof tokenValue === \"string\" ? tokenValue : \"\";\n const tokenType = token.startsWith(\"p-\")\n ? \"production\"\n : token.startsWith(\"d-\")\n ? \"develop\"\n : \"unknown\";\n\n const debug = state.liveEdit;\n\n const apiVersion = config.nitro?.version?.toString() || \"-\";\n const apiLastUpdate = config.nitro?.updated_at\n ? new Date(config.nitro.updated_at * 1000).toLocaleString(\"de-CH\", {\n day: \"2-digit\",\n month: \"2-digit\",\n year: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n })\n : \"-\";\n\n const debugInfoParts = [\n `liveedit:${debug}`,\n `env:${mode}`,\n `version:${apiVersion}`,\n `versiondate:${apiLastUpdate}`,\n `tokentype:${tokenType}`,\n `did:${vercelDeploymentId}`,\n `csha:${vercelGitCommitSha}`,\n ];\n\n if (version) {\n debugInfoParts.push(`release:${version}`);\n }\n\n const debugInfo = debugInfoParts.join(\" | \");\n\n return (\n <template dangerouslySetInnerHTML={{ __html: `<!-- ${debugInfo} -->` }} suppressHydrationWarning />\n );\n } catch {\n return <template dangerouslySetInnerHTML={{ __html: `<!-- nitro-debug: not initialized -->` }} suppressHydrationWarning />;\n }\n}\n\n/**\n * Renders a JSON-LD structured data script tag from an Entity's jsonld field.\n * Safely escapes HTML to prevent XSS.\n */\nexport function NitroEntityJsonLd({ entity }: { entity: Entity }) {\n if (!entity?.jsonld) {\n return null;\n }\n\n return (\n <script\n type=\"application/ld+json\"\n dangerouslySetInnerHTML={{\n __html: JSON.stringify(entity.jsonld).replace(/</g, '\\\\u003c'),\n }}\n />\n );\n}\n\n/**\n * NitroPage renders all blocks from a Flyo page.\n */\nexport function NitroPage({\n page,\n flyo,\n}: {\n page: Page;\n flyo: FlyoInstance;\n}) {\n if (!page?.json || !Array.isArray(page.json)) {\n return null;\n }\n\n return (\n <>\n {page.json.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n flyo={flyo}\n />\n ))}\n </>\n );\n}\n\n/**\n * NitroBlock renders a single block using the registered component.\n */\nexport function NitroBlock({\n block,\n flyo,\n}: {\n block: Block;\n flyo: FlyoInstance;\n}) {\n if (!block) {\n return null;\n }\n\n const Component = block.component ? flyo.state.components[block.component] : undefined;\n\n if (Component) {\n return <Component block={block} />;\n }\n\n if (flyo.state.showMissingComponentAlert) {\n return (\n <div style={{ border: '1px solid #fff', padding: '1rem', marginBottom: '1rem', backgroundColor: 'red' }}>\n Component <b>{block.component}</b> not found.\n </div>\n );\n }\n\n return null;\n}\n\n/**\n * NitroSlot renders nested blocks from a slot.\n * Used for recursive block rendering when blocks contain slots.\n *\n * @example\n * ```tsx\n * import { flyo } from '@/flyo.config';\n * import { NitroSlot } from '@flyo/nitro-next/server';\n *\n * export function MyComponent({ block }) {\n * return (\n * <div>\n * <NitroSlot slot={block.slots?.content} flyo={flyo} />\n * </div>\n * );\n * }\n * ```\n */\nexport function NitroSlot({\n slot,\n flyo,\n}: {\n slot?: {\n content?: Block[];\n };\n flyo: FlyoInstance;\n}) {\n if (!slot?.content || !Array.isArray(slot.content)) {\n return null;\n }\n\n return (\n <>\n {slot.content.map((block: Block, index: number) => (\n <NitroBlock\n key={block.uid || index}\n block={block}\n flyo={flyo}\n />\n ))}\n </>\n );\n}\n\n// ─── Factory Functions ───────────────────────────────────────────────────────\n\n/**\n * Create a page route handler for Nitro pages.\n * Returns a Next.js page component function.\n *\n * @example\n * ```tsx\n * import { flyo } from '@/flyo.config';\n * import { nitroPageRoute } from '@flyo/nitro-next/server';\n *\n * export default nitroPageRoute(flyo);\n * ```\n */\nexport function nitroPageRoute(flyo: FlyoInstance) {\n async function pageRoute(props: RouteParams) {\n const { page } = await flyo.pageResolveRoute(props);\n return <NitroPage page={page} flyo={flyo} />;\n }\n return pageRoute;\n}\n\n/**\n * Create a metadata generator for Nitro pages.\n * Returns a Next.js generateMetadata function.\n *\n * @example\n * ```tsx\n * import { flyo } from '@/flyo.config';\n * import { nitroPageGenerateMetadata } from '@flyo/nitro-next/server';\n *\n * export const generateMetadata = nitroPageGenerateMetadata(flyo);\n * ```\n */\nexport function nitroPageGenerateMetadata(flyo: FlyoInstance) {\n return async (props: RouteParams): Promise<Metadata> => {\n const { page } = await flyo.pageResolveRoute(props);\n\n const meta = page.meta_json;\n const title = meta?.title || page.title || '';\n const description = meta?.description ?? '';\n const image = meta?.image ?? '';\n\n const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : undefined;\n const twImage = image ? `${image}/thumb/1200x600?format=jpg` : undefined;\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: ogImage ? [ogImage] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: twImage ? [twImage] : [],\n },\n };\n };\n}\n\n/**\n * Create a static params generator for Nitro pages.\n * Returns a Next.js generateStaticParams function.\n *\n * @example\n * ```tsx\n * import { flyo } from '@/flyo.config';\n * import { nitroPageGenerateStaticParams } from '@flyo/nitro-next/server';\n *\n * export const generateStaticParams = nitroPageGenerateStaticParams(flyo);\n * ```\n */\nexport function nitroPageGenerateStaticParams(flyo: FlyoInstance) {\n return async () => {\n const cfg = await flyo.getNitroConfig();\n const pages = cfg.pages ?? [];\n\n return pages.map((path: string) => ({\n slug: path === '' ? undefined : path.split('/'),\n }));\n };\n}\n\n/**\n * Create an entity route handler with a custom resolver.\n * Returns a Next.js page component function.\n *\n * @example\n * ```tsx\n * import { flyo } from '@/flyo.config';\n * import { nitroEntityRoute } from '@flyo/nitro-next/server';\n *\n * const resolver = async (params) => {\n * const { slug } = await params;\n * return flyo.getNitroEntities().entityBySlug({ slug, typeId: 123 });\n * };\n *\n * export default nitroEntityRoute(flyo, {\n * resolver,\n * render: (entity) => <h1>{entity.entity?.entity_title}</h1>,\n * });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function nitroEntityRoute<T = any>(\n flyo: FlyoInstance,\n options: {\n resolver: EntityResolver<T>;\n render?: (entity: Entity) => React.ReactNode;\n }\n) {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n\n async function entityRoute(props: EntityRouteParams<T>) {\n const entity = await cachedResolver(props);\n\n if (options.render) {\n return options.render(entity);\n }\n\n return <div>{entity.entity?.entity_title}</div>;\n }\n return entityRoute;\n}\n\n/**\n * Create a metadata generator for entity detail pages.\n * Returns a Next.js generateMetadata function.\n *\n * @example\n * ```tsx\n * import { flyo } from '@/flyo.config';\n * import { nitroEntityGenerateMetadata } from '@flyo/nitro-next/server';\n *\n * export const generateMetadata = nitroEntityGenerateMetadata(flyo, { resolver });\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function nitroEntityGenerateMetadata<T = any>(\n flyo: FlyoInstance,\n options: {\n resolver: EntityResolver<T>;\n }\n) {\n const cachedResolver = createCachedEntityResolver(options.resolver);\n\n return async (props: EntityRouteParams<T>): Promise<Metadata> => {\n const entity = await cachedResolver(props);\n\n const title = entity.entity?.entity_title || '';\n const description = entity.entity?.entity_teaser ?? '';\n const image = entity.entity?.entity_image ?? '';\n\n const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : undefined;\n const twImage = image ? `${image}/thumb/1200x600?format=jpg` : undefined;\n\n return {\n title,\n description,\n openGraph: {\n title,\n description,\n images: ogImage ? [ogImage] : [],\n type: 'website',\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: twImage ? [twImage] : [],\n },\n };\n };\n}"],"mappings":";AAAA,SAAS,aAAa;AAEtB,SAAS,gBAAgB;AACzB;AAAA,EAIE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA2RD,SAyCF,UAzCE,KA2EA,YA3EA;AAxMC,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAA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