@cmssy/next 9.1.1 → 9.3.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
  }
@@ -171,11 +174,37 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
171
174
  enabledLocales,
172
175
  forms,
173
176
  auth,
174
- workspace
177
+ workspace,
178
+ editMode
175
179
  }
176
180
  ) });
177
181
  };
178
182
  }
183
+ async function renderEditDiagnosticsPage(config, query) {
184
+ const { collectEditDiagnostics, renderEditDiagnostics } = await import('@cmssy/core/preflight');
185
+ const diagnostics = await collectEditDiagnostics({
186
+ config,
187
+ providedSecret: firstValue(query[core.CMSSY_SECRET_QUERY_PARAM]) ?? null,
188
+ devOrigin: await resolveDevOrigin()
189
+ });
190
+ return /* @__PURE__ */ jsxRuntime.jsx(
191
+ "div",
192
+ {
193
+ dangerouslySetInnerHTML: { __html: renderEditDiagnostics(diagnostics) }
194
+ }
195
+ );
196
+ }
197
+ async function resolveDevOrigin() {
198
+ try {
199
+ const requestHeaders = await headers.headers();
200
+ const host = requestHeaders.get("host");
201
+ if (!host) return void 0;
202
+ const proto = requestHeaders.get("x-forwarded-proto") ?? "http";
203
+ return `${proto}://${host}`;
204
+ } catch {
205
+ return void 0;
206
+ }
207
+ }
179
208
  function resolveBridgeOrigin(editorOrigin) {
180
209
  const resolved = core.resolveEditorOrigin(editorOrigin);
181
210
  const origins = (Array.isArray(resolved) ? resolved : [resolved]).map(
@@ -272,8 +301,8 @@ async function getCmssyLocale(config, options) {
272
301
  if (options?.path !== void 0) {
273
302
  return core.localeForPath(config, options.path);
274
303
  }
275
- const { headers: headers2 } = await import('next/headers');
276
- const headerList = await headers2();
304
+ const { headers: headers3 } = await import('next/headers');
305
+ const headerList = await headers3();
277
306
  const fromHeader = headerList.get(core.CMSSY_LOCALE_HEADER);
278
307
  if (fromHeader) return fromHeader;
279
308
  const { defaultLocale } = await core.resolveSiteLocales(config);
@@ -331,7 +360,8 @@ async function CmssyLayoutSlot({
331
360
  position,
332
361
  locale,
333
362
  defaultLocale: siteLocales.defaultLocale,
334
- enabledLocales: siteLocales.locales
363
+ enabledLocales: siteLocales.locales,
364
+ editMode
335
365
  }
336
366
  );
337
367
  }
@@ -344,8 +374,8 @@ async function resolveSeoBaseUrl(config, option) {
344
374
  if (typeof option === "function") return trimTrailingSlash(await option());
345
375
  if (typeof option === "string" && option) return trimTrailingSlash(option);
346
376
  if (config.siteUrl) return trimTrailingSlash(config.siteUrl);
347
- const { headers: headers2 } = await import('next/headers');
348
- const h = await headers2();
377
+ const { headers: headers3 } = await import('next/headers');
378
+ const h = await headers3();
349
379
  const host = h.get("host");
350
380
  if (!host) return "";
351
381
  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
  }
@@ -169,11 +172,37 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
169
172
  enabledLocales,
170
173
  forms,
171
174
  auth,
172
- workspace
175
+ workspace,
176
+ editMode
173
177
  }
174
178
  ) });
175
179
  };
176
180
  }
181
+ async function renderEditDiagnosticsPage(config, query) {
182
+ const { collectEditDiagnostics, renderEditDiagnostics } = await import('@cmssy/core/preflight');
183
+ const diagnostics = await collectEditDiagnostics({
184
+ config,
185
+ providedSecret: firstValue(query[CMSSY_SECRET_QUERY_PARAM]) ?? null,
186
+ devOrigin: await resolveDevOrigin()
187
+ });
188
+ return /* @__PURE__ */ jsx(
189
+ "div",
190
+ {
191
+ dangerouslySetInnerHTML: { __html: renderEditDiagnostics(diagnostics) }
192
+ }
193
+ );
194
+ }
195
+ async function resolveDevOrigin() {
196
+ try {
197
+ const requestHeaders = await headers();
198
+ const host = requestHeaders.get("host");
199
+ if (!host) return void 0;
200
+ const proto = requestHeaders.get("x-forwarded-proto") ?? "http";
201
+ return `${proto}://${host}`;
202
+ } catch {
203
+ return void 0;
204
+ }
205
+ }
177
206
  function resolveBridgeOrigin(editorOrigin) {
178
207
  const resolved = resolveEditorOrigin(editorOrigin);
179
208
  const origins = (Array.isArray(resolved) ? resolved : [resolved]).map(
@@ -270,8 +299,8 @@ async function getCmssyLocale(config, options) {
270
299
  if (options?.path !== void 0) {
271
300
  return localeForPath(config, options.path);
272
301
  }
273
- const { headers: headers2 } = await import('next/headers');
274
- const headerList = await headers2();
302
+ const { headers: headers3 } = await import('next/headers');
303
+ const headerList = await headers3();
275
304
  const fromHeader = headerList.get(CMSSY_LOCALE_HEADER);
276
305
  if (fromHeader) return fromHeader;
277
306
  const { defaultLocale } = await resolveSiteLocales$1(config);
@@ -329,7 +358,8 @@ async function CmssyLayoutSlot({
329
358
  position,
330
359
  locale,
331
360
  defaultLocale: siteLocales.defaultLocale,
332
- enabledLocales: siteLocales.locales
361
+ enabledLocales: siteLocales.locales,
362
+ editMode
333
363
  }
334
364
  );
335
365
  }
@@ -342,8 +372,8 @@ async function resolveSeoBaseUrl(config, option) {
342
372
  if (typeof option === "function") return trimTrailingSlash(await option());
343
373
  if (typeof option === "string" && option) return trimTrailingSlash(option);
344
374
  if (config.siteUrl) return trimTrailingSlash(config.siteUrl);
345
- const { headers: headers2 } = await import('next/headers');
346
- const h = await headers2();
375
+ const { headers: headers3 } = await import('next/headers');
376
+ const h = await headers3();
347
377
  const host = h.get("host");
348
378
  if (!host) return "";
349
379
  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.3.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.3.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.3.0"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsup",