@cmssy/next 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -201,8 +201,10 @@ function createCmssyPage(config, blocks, options) {
201
201
  const { isEnabled } = await headers.draftMode();
202
202
  const query = searchParams ? await searchParams : {};
203
203
  const editMode = isEnabled || hasEditFlag(query[EDIT_QUERY_PARAM]);
204
- const devMode = isDevelopment() && Boolean(config.devToken?.trim()) && hasEditFlag(query[DEV_QUERY_PARAM]);
205
- const editorActive = editMode || devMode;
204
+ const devAllowed = isDevelopment() && Boolean(config.devToken?.trim());
205
+ const devFlagged = hasEditFlag(query[DEV_QUERY_PARAM]);
206
+ const devPreview = devAllowed && (devFlagged || config.preview === "dev");
207
+ const editorActive = editMode || devAllowed && devFlagged;
206
208
  let locale;
207
209
  let pagePath = path;
208
210
  let defaultLocale;
@@ -219,11 +221,11 @@ function createCmssyPage(config, blocks, options) {
219
221
  locale = split.locale;
220
222
  pagePath = split.path;
221
223
  }
222
- const devWorkspaceId = devMode ? await client$1.resolveWorkspaceId() : void 0;
224
+ const devWorkspaceId = devPreview ? await client$1.resolveWorkspaceId() : void 0;
223
225
  const page = await react.fetchPage(clientConfig, pagePath, {
224
226
  previewSecret: editMode ? config.draftSecret : void 0,
225
- devPreview: devMode || void 0,
226
- devToken: devMode ? config.devToken : void 0,
227
+ devPreview: devPreview || void 0,
228
+ devToken: devPreview ? config.devToken : void 0,
227
229
  workspaceId: devWorkspaceId
228
230
  });
229
231
  if (!page) {
package/dist/index.d.cts CHANGED
@@ -12,6 +12,7 @@ interface CmssyAuthConfig {
12
12
  modelSlug: string;
13
13
  sessionSecret: string;
14
14
  }
15
+ type CmssyPreviewMode = "dev" | "live";
15
16
  interface CmssyNextConfig {
16
17
  /**
17
18
  * Full GraphQL delivery endpoint. Defaults to the cmssy cloud endpoint
@@ -21,6 +22,13 @@ interface CmssyNextConfig {
21
22
  workspaceSlug: string;
22
23
  draftSecret: string;
23
24
  devToken?: string;
25
+ /**
26
+ * Local content-source mode. `"dev"` (with NODE_ENV=development + a devToken)
27
+ * serves the caller's dev-draft overlay on every request without the
28
+ * `?cmssyDev` flag; `"live"` (or unset) serves published content. Ignored in
29
+ * production. Pass the raw env value through - the SDK owns the semantics.
30
+ */
31
+ preview?: CmssyPreviewMode | (string & {});
24
32
  /**
25
33
  * Origin allowed to frame your app in the editor. Defaults to
26
34
  * {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ interface CmssyAuthConfig {
12
12
  modelSlug: string;
13
13
  sessionSecret: string;
14
14
  }
15
+ type CmssyPreviewMode = "dev" | "live";
15
16
  interface CmssyNextConfig {
16
17
  /**
17
18
  * Full GraphQL delivery endpoint. Defaults to the cmssy cloud endpoint
@@ -21,6 +22,13 @@ interface CmssyNextConfig {
21
22
  workspaceSlug: string;
22
23
  draftSecret: string;
23
24
  devToken?: string;
25
+ /**
26
+ * Local content-source mode. `"dev"` (with NODE_ENV=development + a devToken)
27
+ * serves the caller's dev-draft overlay on every request without the
28
+ * `?cmssyDev` flag; `"live"` (or unset) serves published content. Ignored in
29
+ * production. Pass the raw env value through - the SDK owns the semantics.
30
+ */
31
+ preview?: CmssyPreviewMode | (string & {});
24
32
  /**
25
33
  * Origin allowed to frame your app in the editor. Defaults to
26
34
  * {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
package/dist/index.js CHANGED
@@ -200,8 +200,10 @@ function createCmssyPage(config, blocks, options) {
200
200
  const { isEnabled } = await draftMode();
201
201
  const query = searchParams ? await searchParams : {};
202
202
  const editMode = isEnabled || hasEditFlag(query[EDIT_QUERY_PARAM]);
203
- const devMode = isDevelopment() && Boolean(config.devToken?.trim()) && hasEditFlag(query[DEV_QUERY_PARAM]);
204
- const editorActive = editMode || devMode;
203
+ const devAllowed = isDevelopment() && Boolean(config.devToken?.trim());
204
+ const devFlagged = hasEditFlag(query[DEV_QUERY_PARAM]);
205
+ const devPreview = devAllowed && (devFlagged || config.preview === "dev");
206
+ const editorActive = editMode || devAllowed && devFlagged;
205
207
  let locale;
206
208
  let pagePath = path;
207
209
  let defaultLocale;
@@ -218,11 +220,11 @@ function createCmssyPage(config, blocks, options) {
218
220
  locale = split.locale;
219
221
  pagePath = split.path;
220
222
  }
221
- const devWorkspaceId = devMode ? await client.resolveWorkspaceId() : void 0;
223
+ const devWorkspaceId = devPreview ? await client.resolveWorkspaceId() : void 0;
222
224
  const page = await fetchPage(clientConfig, pagePath, {
223
225
  previewSecret: editMode ? config.draftSecret : void 0,
224
- devPreview: devMode || void 0,
225
- devToken: devMode ? config.devToken : void 0,
226
+ devPreview: devPreview || void 0,
227
+ devToken: devPreview ? config.devToken : void 0,
226
228
  workspaceId: devWorkspaceId
227
229
  });
228
230
  if (!page) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -41,7 +41,7 @@
41
41
  "dist"
42
42
  ],
43
43
  "peerDependencies": {
44
- "@cmssy/react": "^0.7.0",
44
+ "@cmssy/react": "^0.7.3",
45
45
  "next": ">=15",
46
46
  "react": "^18.2.0 || ^19.0.0",
47
47
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -54,7 +54,7 @@
54
54
  "tsup": "^8.3.0",
55
55
  "typescript": "^5.6.0",
56
56
  "vitest": "^2.1.0",
57
- "@cmssy/react": "0.7.1"
57
+ "@cmssy/react": "0.7.3"
58
58
  },
59
59
  "dependencies": {
60
60
  "jose": "^6.2.3"