@cmssy/next 9.1.1 → 9.2.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.cjs CHANGED
@@ -73,6 +73,9 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
73
73
  const query = searchParams ? await searchParams : {};
74
74
  editorActive = await resolveEditorRequest(query, config.draftSecret);
75
75
  if (!editorActive) {
76
+ if (core.isDevelopment()) {
77
+ return renderEditDiagnosticsPage(config, query);
78
+ }
76
79
  navigation.notFound();
77
80
  }
78
81
  }
@@ -176,6 +179,31 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
176
179
  ) });
177
180
  };
178
181
  }
182
+ async function renderEditDiagnosticsPage(config, query) {
183
+ const { collectEditDiagnostics, renderEditDiagnostics } = await import('@cmssy/core/preflight');
184
+ const diagnostics = await collectEditDiagnostics({
185
+ config,
186
+ providedSecret: firstValue(query[core.CMSSY_SECRET_QUERY_PARAM]) ?? null,
187
+ devOrigin: await resolveDevOrigin()
188
+ });
189
+ return /* @__PURE__ */ jsxRuntime.jsx(
190
+ "div",
191
+ {
192
+ dangerouslySetInnerHTML: { __html: renderEditDiagnostics(diagnostics) }
193
+ }
194
+ );
195
+ }
196
+ async function resolveDevOrigin() {
197
+ try {
198
+ const requestHeaders = await headers.headers();
199
+ const host = requestHeaders.get("host");
200
+ if (!host) return void 0;
201
+ const proto = requestHeaders.get("x-forwarded-proto") ?? "http";
202
+ return `${proto}://${host}`;
203
+ } catch {
204
+ return void 0;
205
+ }
206
+ }
179
207
  function resolveBridgeOrigin(editorOrigin) {
180
208
  const resolved = core.resolveEditorOrigin(editorOrigin);
181
209
  const origins = (Array.isArray(resolved) ? resolved : [resolved]).map(
@@ -272,8 +300,8 @@ async function getCmssyLocale(config, options) {
272
300
  if (options?.path !== void 0) {
273
301
  return core.localeForPath(config, options.path);
274
302
  }
275
- const { headers: headers2 } = await import('next/headers');
276
- const headerList = await headers2();
303
+ const { headers: headers3 } = await import('next/headers');
304
+ const headerList = await headers3();
277
305
  const fromHeader = headerList.get(core.CMSSY_LOCALE_HEADER);
278
306
  if (fromHeader) return fromHeader;
279
307
  const { defaultLocale } = await core.resolveSiteLocales(config);
@@ -344,8 +372,8 @@ async function resolveSeoBaseUrl(config, option) {
344
372
  if (typeof option === "function") return trimTrailingSlash(await option());
345
373
  if (typeof option === "string" && option) return trimTrailingSlash(option);
346
374
  if (config.siteUrl) return trimTrailingSlash(config.siteUrl);
347
- const { headers: headers2 } = await import('next/headers');
348
- const h = await headers2();
375
+ const { headers: headers3 } = await import('next/headers');
376
+ const h = await headers3();
349
377
  const host = h.get("host");
350
378
  if (!host) return "";
351
379
  const protocol = isLocalHost(host) ? "http" : "https";
package/dist/server.js CHANGED
@@ -3,7 +3,7 @@ import { draftMode, headers, cookies } from 'next/headers';
3
3
  import { notFound, redirect } from 'next/navigation';
4
4
  import { createCmssyClient, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, resolveBlockData, CmssyServerPage, fetchSiteConfig, fetchPageById, fetchLayouts, resolveLayoutBlockData, CmssyServerLayout, normalizeSlug, fetchPageMeta, fetchPages } from '@cmssy/react';
5
5
  import { CmssyLocaleProvider } from '@cmssy/react/client';
6
- import { isDevelopment, resolveEditorOrigin, toCspOrigin, CMSSY_EDIT_HEADER, localeForPath, CMSSY_LOCALE_HEADER, resolveSiteLocales as resolveSiteLocales$1, localesFromSiteConfig, localizedPath, normalizeSlug as normalizeSlug$1, assertAuthConfig, backendProduct, backendCheckout, backendMergeCart, backendSetShippingMethod, backendRemoveDiscount, backendApplyDiscount, backendClearCart, backendRemoveItem, backendUpdateItem, backendAddToCart, backendGetCart, backendMyOrder, backendMyOrders, cmssySecretsMatch, fetchProducts as fetchProducts$1, fetchProduct as fetchProduct$1, backendSignIn, toSessionPayload, backendRegister, backendSignOut, isAccessExpired, backendSignOutEverywhere, backendForgotPassword, backendResetPassword, backendVerifyEmail, CMSSY_SESSION_COOKIE, openSession, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, sealSession, sessionCookieOptions, backendRefresh } from '@cmssy/core';
6
+ import { isDevelopment, CMSSY_SECRET_QUERY_PARAM, resolveEditorOrigin, toCspOrigin, CMSSY_EDIT_HEADER, localeForPath, CMSSY_LOCALE_HEADER, resolveSiteLocales as resolveSiteLocales$1, localesFromSiteConfig, localizedPath, normalizeSlug as normalizeSlug$1, assertAuthConfig, backendProduct, backendCheckout, backendMergeCart, backendSetShippingMethod, backendRemoveDiscount, backendApplyDiscount, backendClearCart, backendRemoveItem, backendUpdateItem, backendAddToCart, backendGetCart, backendMyOrder, backendMyOrders, cmssySecretsMatch, fetchProducts as fetchProducts$1, fetchProduct as fetchProduct$1, backendSignIn, toSessionPayload, backendRegister, backendSignOut, isAccessExpired, backendSignOutEverywhere, backendForgotPassword, backendResetPassword, backendVerifyEmail, CMSSY_SESSION_COOKIE, openSession, CMSSY_EDIT_QUERY_PARAM, sealSession, sessionCookieOptions, backendRefresh } from '@cmssy/core';
7
7
  import { jsx, jsxs } from 'react/jsx-runtime';
8
8
 
9
9
  // src/server.ts
@@ -71,6 +71,9 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
71
71
  const query = searchParams ? await searchParams : {};
72
72
  editorActive = await resolveEditorRequest(query, config.draftSecret);
73
73
  if (!editorActive) {
74
+ if (isDevelopment()) {
75
+ return renderEditDiagnosticsPage(config, query);
76
+ }
74
77
  notFound();
75
78
  }
76
79
  }
@@ -174,6 +177,31 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
174
177
  ) });
175
178
  };
176
179
  }
180
+ async function renderEditDiagnosticsPage(config, query) {
181
+ const { collectEditDiagnostics, renderEditDiagnostics } = await import('@cmssy/core/preflight');
182
+ const diagnostics = await collectEditDiagnostics({
183
+ config,
184
+ providedSecret: firstValue(query[CMSSY_SECRET_QUERY_PARAM]) ?? null,
185
+ devOrigin: await resolveDevOrigin()
186
+ });
187
+ return /* @__PURE__ */ jsx(
188
+ "div",
189
+ {
190
+ dangerouslySetInnerHTML: { __html: renderEditDiagnostics(diagnostics) }
191
+ }
192
+ );
193
+ }
194
+ async function resolveDevOrigin() {
195
+ try {
196
+ const requestHeaders = await headers();
197
+ const host = requestHeaders.get("host");
198
+ if (!host) return void 0;
199
+ const proto = requestHeaders.get("x-forwarded-proto") ?? "http";
200
+ return `${proto}://${host}`;
201
+ } catch {
202
+ return void 0;
203
+ }
204
+ }
177
205
  function resolveBridgeOrigin(editorOrigin) {
178
206
  const resolved = resolveEditorOrigin(editorOrigin);
179
207
  const origins = (Array.isArray(resolved) ? resolved : [resolved]).map(
@@ -270,8 +298,8 @@ async function getCmssyLocale(config, options) {
270
298
  if (options?.path !== void 0) {
271
299
  return localeForPath(config, options.path);
272
300
  }
273
- const { headers: headers2 } = await import('next/headers');
274
- const headerList = await headers2();
301
+ const { headers: headers3 } = await import('next/headers');
302
+ const headerList = await headers3();
275
303
  const fromHeader = headerList.get(CMSSY_LOCALE_HEADER);
276
304
  if (fromHeader) return fromHeader;
277
305
  const { defaultLocale } = await resolveSiteLocales$1(config);
@@ -342,8 +370,8 @@ async function resolveSeoBaseUrl(config, option) {
342
370
  if (typeof option === "function") return trimTrailingSlash(await option());
343
371
  if (typeof option === "string" && option) return trimTrailingSlash(option);
344
372
  if (config.siteUrl) return trimTrailingSlash(config.siteUrl);
345
- const { headers: headers2 } = await import('next/headers');
346
- const h = await headers2();
373
+ const { headers: headers3 } = await import('next/headers');
374
+ const h = await headers3();
347
375
  const host = h.get("host");
348
376
  if (!host) return "";
349
377
  const protocol = isLocalHost(host) ? "http" : "https";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "9.1.1",
3
+ "version": "9.2.0",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -70,12 +70,12 @@
70
70
  "tsup": "^8.3.0",
71
71
  "typescript": "^5.6.0",
72
72
  "vitest": "^2.1.0",
73
- "@cmssy/react": "9.1.1"
73
+ "@cmssy/react": "9.2.0"
74
74
  },
75
75
  "dependencies": {
76
76
  "@cmssy/types": "0.28.0",
77
77
  "server-only": "^0.0.1",
78
- "@cmssy/core": "9.1.1"
78
+ "@cmssy/core": "9.2.0"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsup",