@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/server.js CHANGED
@@ -25,45 +25,19 @@ __export(server_exports, {
25
25
  NitroEntityJsonLd: () => NitroEntityJsonLd,
26
26
  NitroPage: () => NitroPage,
27
27
  NitroSlot: () => NitroSlot,
28
- getNitro: () => getNitro,
29
- getNitroConfig: () => getNitroConfig,
30
- getNitroEntities: () => getNitroEntities,
31
- getNitroPages: () => getNitroPages,
32
- getNitroSearch: () => getNitroSearch,
33
- getNitroSitemap: () => getNitroSitemap,
34
- globalNitroState: () => globalNitroState,
35
28
  initNitro: () => initNitro,
36
29
  nitroEntityGenerateMetadata: () => nitroEntityGenerateMetadata,
37
30
  nitroEntityRoute: () => nitroEntityRoute,
38
31
  nitroPageGenerateMetadata: () => nitroPageGenerateMetadata,
39
32
  nitroPageGenerateStaticParams: () => nitroPageGenerateStaticParams,
40
- nitroPageResolveRoute: () => nitroPageResolveRoute,
41
- nitroPageRoute: () => nitroPageRoute,
42
- nitroSitemap: () => nitroSitemap
33
+ nitroPageRoute: () => nitroPageRoute
43
34
  });
44
35
  module.exports = __toCommonJS(server_exports);
45
36
  var import_react = require("react");
46
37
  var import_navigation = require("next/navigation");
47
38
  var import_nitro_typescript = require("@flyo/nitro-typescript");
48
39
  var import_jsx_runtime = require("react/jsx-runtime");
49
- var globalNitroState = {
50
- configuration: null,
51
- accessToken: null,
52
- lang: null,
53
- baseUrl: null,
54
- components: {},
55
- showMissingComponentAlert: false,
56
- liveEdit: false,
57
- serverCacheTtl: 1200,
58
- clientCacheTtl: 900
59
- };
60
- function getNitro() {
61
- if (!globalNitroState.configuration) {
62
- throw new Error("Nitro has not been initialized. Make sure to call initNitro() first.");
63
- }
64
- return globalNitroState;
65
- }
66
- var initNitro = ({
40
+ function initNitro({
67
41
  accessToken,
68
42
  lang,
69
43
  baseUrl,
@@ -72,57 +46,76 @@ var initNitro = ({
72
46
  liveEdit,
73
47
  serverCacheTtl,
74
48
  clientCacheTtl
75
- }) => {
76
- if (!globalNitroState.configuration) {
77
- globalNitroState.configuration = new import_nitro_typescript.Configuration({
78
- apiKey: accessToken
49
+ }) {
50
+ const configuration = new import_nitro_typescript.Configuration({ apiKey: accessToken });
51
+ const state = {
52
+ accessToken,
53
+ lang: lang ?? null,
54
+ baseUrl: baseUrl ?? null,
55
+ components: components ?? {},
56
+ showMissingComponentAlert: showMissingComponentAlert ?? liveEdit ?? false,
57
+ liveEdit: liveEdit ?? false,
58
+ serverCacheTtl: serverCacheTtl ?? 1200,
59
+ clientCacheTtl: clientCacheTtl ?? 900
60
+ };
61
+ const getNitroConfig = (0, import_react.cache)(async () => {
62
+ const configApi = new import_nitro_typescript.ConfigApi(configuration);
63
+ const useLang = state.lang ?? void 0;
64
+ return configApi.config({ lang: useLang });
65
+ });
66
+ const pageResolveRoute = (0, import_react.cache)(async ({ params }) => {
67
+ const { slug } = await params;
68
+ const path = slug?.join("/") ?? "";
69
+ const cfg = await getNitroConfig();
70
+ if (!cfg.pages?.includes(path)) {
71
+ (0, import_navigation.notFound)();
72
+ }
73
+ const page = await new import_nitro_typescript.PagesApi(configuration).page({ slug: path }).catch((error) => {
74
+ console.error("Error fetching page:", path, error);
75
+ (0, import_navigation.notFound)();
79
76
  });
80
- }
81
- globalNitroState.accessToken = accessToken;
82
- globalNitroState.lang = lang ?? null;
83
- globalNitroState.baseUrl = baseUrl ?? null;
84
- globalNitroState.components = components ?? {};
85
- globalNitroState.showMissingComponentAlert = showMissingComponentAlert ?? liveEdit ?? false;
86
- globalNitroState.liveEdit = liveEdit ?? false;
87
- globalNitroState.serverCacheTtl = serverCacheTtl ?? 1200;
88
- globalNitroState.clientCacheTtl = clientCacheTtl ?? 900;
89
- return () => globalNitroState;
90
- };
91
- var getNitroConfig = (0, import_react.cache)(async () => {
92
- const state = getNitro();
93
- const configApi = new import_nitro_typescript.ConfigApi(state.configuration);
94
- const useLang = state.lang ?? void 0;
95
- const config = await configApi.config({ lang: useLang });
96
- return config;
97
- });
98
- function getNitroPages() {
99
- return new import_nitro_typescript.PagesApi(getNitro().configuration);
100
- }
101
- function getNitroEntities() {
102
- return new import_nitro_typescript.EntitiesApi(getNitro().configuration);
103
- }
104
- function getNitroSitemap() {
105
- return new import_nitro_typescript.SitemapApi(getNitro().configuration);
106
- }
107
- function getNitroSearch() {
108
- return new import_nitro_typescript.SearchApi(getNitro().configuration);
109
- }
110
- var nitroPageResolveRoute = (0, import_react.cache)(async ({ params }) => {
111
- const { slug } = await params;
112
- const path = slug?.join("/") ?? "";
113
- const cfg = await getNitroConfig();
114
- if (!cfg.pages?.includes(path)) {
115
- (0, import_navigation.notFound)();
116
- }
117
- const page = await getNitroPages().page({ slug: path }).catch((error) => {
118
- console.error("Error fetching page:", path, error);
119
- (0, import_navigation.notFound)();
77
+ if (!page) {
78
+ (0, import_navigation.notFound)();
79
+ }
80
+ return { page, path, cfg };
120
81
  });
121
- if (!page) {
122
- (0, import_navigation.notFound)();
123
- }
124
- return { page, path, cfg };
125
- });
82
+ const sitemap = async () => {
83
+ const sitemapApi = new import_nitro_typescript.SitemapApi(configuration);
84
+ const sitemapLang = state.lang ?? void 0;
85
+ if (!state.baseUrl) {
86
+ throw new Error("baseUrl is not configured. Please set it in initNitro().");
87
+ }
88
+ const items = await sitemapApi.sitemap({ lang: sitemapLang });
89
+ const cleanBaseUrl = state.baseUrl.endsWith("/") ? state.baseUrl.slice(0, -1) : state.baseUrl;
90
+ return items.map((item) => {
91
+ let path = "";
92
+ if (item.routes && typeof item.routes === "object") {
93
+ const routeValues = Object.values(item.routes);
94
+ if (routeValues.length > 0) {
95
+ path = routeValues[0];
96
+ }
97
+ }
98
+ if (!path && item.entity_slug) {
99
+ path = item.entity_slug;
100
+ }
101
+ const cleanPath = path && !path.startsWith("/") ? `/${path}` : path;
102
+ return {
103
+ url: `${cleanBaseUrl}${cleanPath}`,
104
+ lastModified: /* @__PURE__ */ new Date()
105
+ };
106
+ });
107
+ };
108
+ return {
109
+ state,
110
+ getNitroConfig,
111
+ getNitroPages: () => new import_nitro_typescript.PagesApi(configuration),
112
+ getNitroEntities: () => new import_nitro_typescript.EntitiesApi(configuration),
113
+ getNitroSitemap: () => new import_nitro_typescript.SitemapApi(configuration),
114
+ getNitroSearch: () => new import_nitro_typescript.SearchApi(configuration),
115
+ pageResolveRoute,
116
+ sitemap
117
+ };
118
+ }
126
119
  var readEnv = (key, fallback = "") => {
127
120
  const value = process.env[key];
128
121
  if (value !== void 0 && value !== "") {
@@ -130,9 +123,19 @@ var readEnv = (key, fallback = "") => {
130
123
  }
131
124
  return fallback;
132
125
  };
133
- function NitroDebugInfo({ config }) {
126
+ function createCachedEntityResolver(resolver) {
127
+ return (0, import_react.cache)(async ({ params }) => {
128
+ const entity = await resolver(params);
129
+ if (!entity) {
130
+ (0, import_navigation.notFound)();
131
+ }
132
+ return entity;
133
+ });
134
+ }
135
+ async function NitroDebugInfo({ flyo }) {
134
136
  try {
135
- const state = getNitro();
137
+ const config = await flyo.getNitroConfig();
138
+ const { state } = flyo;
136
139
  const mode = readEnv("NODE_ENV", "-");
137
140
  const vercelDeploymentId = readEnv("VERCEL_DEPLOYMENT_ID", "-");
138
141
  const vercelGitCommitSha = readEnv("VERCEL_GIT_COMMIT_SHA", "-");
@@ -163,19 +166,10 @@ function NitroDebugInfo({ config }) {
163
166
  }
164
167
  const debugInfo = debugInfoParts.join(" | ");
165
168
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("template", { dangerouslySetInnerHTML: { __html: `<!-- ${debugInfo} -->` }, suppressHydrationWarning: true });
166
- } catch (error) {
169
+ } catch {
167
170
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("template", { dangerouslySetInnerHTML: { __html: `<!-- nitro-debug: not initialized -->` }, suppressHydrationWarning: true });
168
171
  }
169
172
  }
170
- function createCachedEntityResolver(resolver) {
171
- return (0, import_react.cache)(async ({ params }) => {
172
- const entity = await resolver(params);
173
- if (!entity) {
174
- (0, import_navigation.notFound)();
175
- }
176
- return entity;
177
- });
178
- }
179
173
  function NitroEntityJsonLd({ entity }) {
180
174
  if (!entity?.jsonld) {
181
175
  return null;
@@ -191,7 +185,8 @@ function NitroEntityJsonLd({ entity }) {
191
185
  );
192
186
  }
193
187
  function NitroPage({
194
- page
188
+ page,
189
+ flyo
195
190
  }) {
196
191
  if (!page?.json || !Array.isArray(page.json)) {
197
192
  return null;
@@ -199,23 +194,24 @@ function NitroPage({
199
194
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: page.json.map((block, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
200
195
  NitroBlock,
201
196
  {
202
- block
197
+ block,
198
+ flyo
203
199
  },
204
200
  block.uid || index
205
201
  )) });
206
202
  }
207
203
  function NitroBlock({
208
- block
204
+ block,
205
+ flyo
209
206
  }) {
210
207
  if (!block) {
211
208
  return null;
212
209
  }
213
- const state = getNitro();
214
- const Component = block.component ? state.components[block.component] : void 0;
210
+ const Component = block.component ? flyo.state.components[block.component] : void 0;
215
211
  if (Component) {
216
212
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { block });
217
213
  }
218
- if (state.showMissingComponentAlert) {
214
+ if (flyo.state.showMissingComponentAlert) {
219
215
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { border: "1px solid #fff", padding: "1rem", marginBottom: "1rem", backgroundColor: "red" }, children: [
220
216
  "Component ",
221
217
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: block.component }),
@@ -225,7 +221,8 @@ function NitroBlock({
225
221
  return null;
226
222
  }
227
223
  function NitroSlot({
228
- slot
224
+ slot,
225
+ flyo
229
226
  }) {
230
227
  if (!slot?.content || !Array.isArray(slot.content)) {
231
228
  return null;
@@ -233,109 +230,92 @@ function NitroSlot({
233
230
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: slot.content.map((block, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
234
231
  NitroBlock,
235
232
  {
236
- block
233
+ block,
234
+ flyo
237
235
  },
238
236
  block.uid || index
239
237
  )) });
240
238
  }
241
- async function nitroPageRoute(props) {
242
- const { page } = await nitroPageResolveRoute(props);
243
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NitroPage, { page });
239
+ function nitroPageRoute(flyo) {
240
+ async function pageRoute(props) {
241
+ const { page } = await flyo.pageResolveRoute(props);
242
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NitroPage, { page, flyo });
243
+ }
244
+ return pageRoute;
244
245
  }
245
- async function nitroPageGenerateMetadata(props) {
246
- const { page } = await nitroPageResolveRoute(props);
247
- const meta = page.meta_json;
248
- const title = meta?.title || page.title || "";
249
- const description = meta?.description ?? "";
250
- const image = meta?.image ?? "";
251
- const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : void 0;
252
- const twImage = image ? `${image}/thumb/1200x600?format=jpg` : void 0;
253
- return {
254
- title,
255
- description,
256
- openGraph: {
257
- title,
258
- description,
259
- images: ogImage ? [ogImage] : [],
260
- type: "website"
261
- },
262
- twitter: {
263
- card: "summary_large_image",
246
+ function nitroPageGenerateMetadata(flyo) {
247
+ return async (props) => {
248
+ const { page } = await flyo.pageResolveRoute(props);
249
+ const meta = page.meta_json;
250
+ const title = meta?.title || page.title || "";
251
+ const description = meta?.description ?? "";
252
+ const image = meta?.image ?? "";
253
+ const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : void 0;
254
+ const twImage = image ? `${image}/thumb/1200x600?format=jpg` : void 0;
255
+ return {
264
256
  title,
265
257
  description,
266
- images: twImage ? [twImage] : []
267
- }
258
+ openGraph: {
259
+ title,
260
+ description,
261
+ images: ogImage ? [ogImage] : [],
262
+ type: "website"
263
+ },
264
+ twitter: {
265
+ card: "summary_large_image",
266
+ title,
267
+ description,
268
+ images: twImage ? [twImage] : []
269
+ }
270
+ };
268
271
  };
269
272
  }
270
- async function nitroPageGenerateStaticParams() {
271
- const cfg = await getNitroConfig();
272
- const pages = cfg.pages ?? [];
273
- return pages.map((path) => ({
274
- slug: path === "" ? void 0 : path.split("/")
275
- }));
273
+ function nitroPageGenerateStaticParams(flyo) {
274
+ return async () => {
275
+ const cfg = await flyo.getNitroConfig();
276
+ const pages = cfg.pages ?? [];
277
+ return pages.map((path) => ({
278
+ slug: path === "" ? void 0 : path.split("/")
279
+ }));
280
+ };
276
281
  }
277
- function nitroEntityRoute(props, options) {
282
+ function nitroEntityRoute(flyo, options) {
278
283
  const cachedResolver = createCachedEntityResolver(options.resolver);
279
- return (async () => {
284
+ async function entityRoute(props) {
280
285
  const entity = await cachedResolver(props);
281
286
  if (options.render) {
282
287
  return options.render(entity);
283
288
  }
284
289
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: entity.entity?.entity_title });
285
- })();
290
+ }
291
+ return entityRoute;
286
292
  }
287
- async function nitroEntityGenerateMetadata(props, options) {
293
+ function nitroEntityGenerateMetadata(flyo, options) {
288
294
  const cachedResolver = createCachedEntityResolver(options.resolver);
289
- const entity = await cachedResolver(props);
290
- const title = entity.entity?.entity_title || "";
291
- const description = entity.entity?.entity_teaser ?? "";
292
- const image = entity.entity?.entity_image ?? "";
293
- const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : void 0;
294
- const twImage = image ? `${image}/thumb/1200x600?format=jpg` : void 0;
295
- return {
296
- title,
297
- description,
298
- openGraph: {
299
- title,
300
- description,
301
- images: ogImage ? [ogImage] : [],
302
- type: "website"
303
- },
304
- twitter: {
305
- card: "summary_large_image",
295
+ return async (props) => {
296
+ const entity = await cachedResolver(props);
297
+ const title = entity.entity?.entity_title || "";
298
+ const description = entity.entity?.entity_teaser ?? "";
299
+ const image = entity.entity?.entity_image ?? "";
300
+ const ogImage = image ? `${image}/thumb/1200x630?format=jpg` : void 0;
301
+ const twImage = image ? `${image}/thumb/1200x600?format=jpg` : void 0;
302
+ return {
306
303
  title,
307
304
  description,
308
- images: twImage ? [twImage] : []
309
- }
310
- };
311
- }
312
- async function nitroSitemap(state) {
313
- const sitemapApi = getNitroSitemap();
314
- const lang = state.lang ?? void 0;
315
- if (!state.baseUrl) {
316
- throw new Error("baseUrl is not configured in Nitro state. Please set it in initNitro().");
317
- }
318
- const items = await sitemapApi.sitemap({ lang });
319
- const baseUrl = state.baseUrl;
320
- const cleanBaseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
321
- return items.map((item) => {
322
- let path = "";
323
- if (item.routes && typeof item.routes === "object") {
324
- const routeValues = Object.values(item.routes);
325
- if (routeValues.length > 0) {
326
- path = routeValues[0];
305
+ openGraph: {
306
+ title,
307
+ description,
308
+ images: ogImage ? [ogImage] : [],
309
+ type: "website"
310
+ },
311
+ twitter: {
312
+ card: "summary_large_image",
313
+ title,
314
+ description,
315
+ images: twImage ? [twImage] : []
327
316
  }
328
- }
329
- if (!path && item.entity_slug) {
330
- path = item.entity_slug;
331
- }
332
- const cleanPath = path && !path.startsWith("/") ? `/${path}` : path;
333
- const lastModified = /* @__PURE__ */ new Date();
334
- return {
335
- url: `${cleanBaseUrl}${cleanPath}`,
336
- lastModified
337
317
  };
338
- });
318
+ };
339
319
  }
340
320
  // Annotate the CommonJS export names for ESM import in node:
341
321
  0 && (module.exports = {
@@ -344,20 +324,11 @@ async function nitroSitemap(state) {
344
324
  NitroEntityJsonLd,
345
325
  NitroPage,
346
326
  NitroSlot,
347
- getNitro,
348
- getNitroConfig,
349
- getNitroEntities,
350
- getNitroPages,
351
- getNitroSearch,
352
- getNitroSitemap,
353
- globalNitroState,
354
327
  initNitro,
355
328
  nitroEntityGenerateMetadata,
356
329
  nitroEntityRoute,
357
330
  nitroPageGenerateMetadata,
358
331
  nitroPageGenerateStaticParams,
359
- nitroPageResolveRoute,
360
- nitroPageRoute,
361
- nitroSitemap
332
+ nitroPageRoute
362
333
  });
363
334
  //# sourceMappingURL=server.js.map
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,wBAAyB;AACzB,8BAWO;AAiQD;AA5OC,IAAM,mBAA+B;AAAA,EAC1C,eAAe;AAAA,EACf,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AAA,MACA,QAAQ,UAAU,CAAC,OAAO,IAAI,CAAC;AAAA,MAC/B,MAAM;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,QAAQ,UAAU,CAAC,OAAO,IAAI,CAAC;AAAA,IACjC;AAAA,EACF;AACF;AA+BA,eAAsB,aAAa,OAAmD;AACpF,QAAM,aAAa,gBAAgB;AACnC,QAAM,OAAO,MAAM,QAAQ;AAE3B,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,IAAI,MAAM,yEAAyE;AAAA,EAC3F;AAGA,QAAM,QAAQ,MAAM,WAAW,QAAQ,EAAE,KAAK,CAAC;AAE/C,QAAM,UAAU,MAAM;AAGtB,QAAM,eAAe,QAAQ,SAAS,GAAG,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI;AAEpE,SAAO,MAAM,IAAI,CAAC,SAAS;AAEzB,QAAI,OAAO;AAEX,QAAI,KAAK,UAAU,OAAO,KAAK,WAAW,UAAU;AAElD,YAAM,cAAc,OAAO,OAAO,KAAK,MAAM;AAC7C,UAAI,YAAY,SAAS,GAAG;AAC1B,eAAO,YAAY,CAAC;AAAA,MACtB;AAAA,IACF;AAGA,QAAI,CAAC,QAAQ,KAAK,aAAa;AAC7B,aAAO,KAAK;AAAA,IACd;AAGA,UAAM,YAAY,QAAQ,CAAC,KAAK,WAAW,GAAG,IAAI,IAAI,IAAI,KAAK;AAG/D,UAAM,eAAe,oBAAI,KAAK;AAE9B,WAAO;AAAA,MACL,KAAK,GAAG,YAAY,GAAG,SAAS;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
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 * 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,wBAAyB;AACzB,8BAWO;AA2RD;AAxMC,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAUiB;AACf,QAAM,gBAAgB,IAAI,sCAAc,EAAE,QAAQ,YAAY,CAAC;AAE/D,QAAM,QAAoB;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