@cmssy/next 0.6.0 → 0.7.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/index.cjs +11 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -4
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -177,6 +177,7 @@ function applyCmssyCsp(response, options) {
|
|
|
177
177
|
return response;
|
|
178
178
|
}
|
|
179
179
|
var EDIT_QUERY_PARAM = "cmssyEdit";
|
|
180
|
+
var DEV_QUERY_PARAM = "cmssyDev";
|
|
180
181
|
function hasEditFlag(value) {
|
|
181
182
|
return Array.isArray(value) ? value.includes("1") : value === "1";
|
|
182
183
|
}
|
|
@@ -200,6 +201,8 @@ function createCmssyPage(config, blocks, options) {
|
|
|
200
201
|
const { isEnabled } = await headers.draftMode();
|
|
201
202
|
const query = searchParams ? await searchParams : {};
|
|
202
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;
|
|
203
206
|
let locale;
|
|
204
207
|
let pagePath = path;
|
|
205
208
|
let defaultLocale;
|
|
@@ -216,15 +219,19 @@ function createCmssyPage(config, blocks, options) {
|
|
|
216
219
|
locale = split.locale;
|
|
217
220
|
pagePath = split.path;
|
|
218
221
|
}
|
|
222
|
+
const devWorkspaceId = devMode ? await client$1.resolveWorkspaceId() : void 0;
|
|
219
223
|
const page = await react.fetchPage(clientConfig, pagePath, {
|
|
220
|
-
previewSecret: editMode ? config.draftSecret : void 0
|
|
224
|
+
previewSecret: editMode ? config.draftSecret : void 0,
|
|
225
|
+
devPreview: devMode || void 0,
|
|
226
|
+
devToken: devMode ? config.devToken : void 0,
|
|
227
|
+
workspaceId: devWorkspaceId
|
|
221
228
|
});
|
|
222
229
|
if (!page) {
|
|
223
230
|
navigation.notFound();
|
|
224
231
|
}
|
|
225
|
-
if (
|
|
232
|
+
if (editorActive && !Editor) {
|
|
226
233
|
throw new Error(
|
|
227
|
-
'cmssy: edit mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
|
|
234
|
+
'cmssy: edit/dev mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
|
|
228
235
|
);
|
|
229
236
|
}
|
|
230
237
|
const resolvedForms = await react.resolveForms(
|
|
@@ -239,7 +246,7 @@ function createCmssyPage(config, blocks, options) {
|
|
|
239
246
|
default: defaultLocale,
|
|
240
247
|
enabled: enabledLocales && enabledLocales.length > 0 ? enabledLocales : Array.from(/* @__PURE__ */ new Set([defaultLocale, locale]))
|
|
241
248
|
};
|
|
242
|
-
if (
|
|
249
|
+
if (editorActive && Editor) {
|
|
243
250
|
const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
|
|
244
251
|
return /* @__PURE__ */ jsxRuntime.jsx(client.CmssyLocaleProvider, { value: localeContext, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
245
252
|
Editor,
|
package/dist/index.d.cts
CHANGED
|
@@ -20,6 +20,7 @@ interface CmssyNextConfig {
|
|
|
20
20
|
apiUrl?: string;
|
|
21
21
|
workspaceSlug: string;
|
|
22
22
|
draftSecret: string;
|
|
23
|
+
devToken?: string;
|
|
23
24
|
/**
|
|
24
25
|
* Origin allowed to frame your app in the editor. Defaults to
|
|
25
26
|
* {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface CmssyNextConfig {
|
|
|
20
20
|
apiUrl?: string;
|
|
21
21
|
workspaceSlug: string;
|
|
22
22
|
draftSecret: string;
|
|
23
|
+
devToken?: string;
|
|
23
24
|
/**
|
|
24
25
|
* Origin allowed to frame your app in the editor. Defaults to
|
|
25
26
|
* {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
|
package/dist/index.js
CHANGED
|
@@ -176,6 +176,7 @@ function applyCmssyCsp(response, options) {
|
|
|
176
176
|
return response;
|
|
177
177
|
}
|
|
178
178
|
var EDIT_QUERY_PARAM = "cmssyEdit";
|
|
179
|
+
var DEV_QUERY_PARAM = "cmssyDev";
|
|
179
180
|
function hasEditFlag(value) {
|
|
180
181
|
return Array.isArray(value) ? value.includes("1") : value === "1";
|
|
181
182
|
}
|
|
@@ -199,6 +200,8 @@ function createCmssyPage(config, blocks, options) {
|
|
|
199
200
|
const { isEnabled } = await draftMode();
|
|
200
201
|
const query = searchParams ? await searchParams : {};
|
|
201
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;
|
|
202
205
|
let locale;
|
|
203
206
|
let pagePath = path;
|
|
204
207
|
let defaultLocale;
|
|
@@ -215,15 +218,19 @@ function createCmssyPage(config, blocks, options) {
|
|
|
215
218
|
locale = split.locale;
|
|
216
219
|
pagePath = split.path;
|
|
217
220
|
}
|
|
221
|
+
const devWorkspaceId = devMode ? await client.resolveWorkspaceId() : void 0;
|
|
218
222
|
const page = await fetchPage(clientConfig, pagePath, {
|
|
219
|
-
previewSecret: editMode ? config.draftSecret : void 0
|
|
223
|
+
previewSecret: editMode ? config.draftSecret : void 0,
|
|
224
|
+
devPreview: devMode || void 0,
|
|
225
|
+
devToken: devMode ? config.devToken : void 0,
|
|
226
|
+
workspaceId: devWorkspaceId
|
|
220
227
|
});
|
|
221
228
|
if (!page) {
|
|
222
229
|
notFound();
|
|
223
230
|
}
|
|
224
|
-
if (
|
|
231
|
+
if (editorActive && !Editor) {
|
|
225
232
|
throw new Error(
|
|
226
|
-
'cmssy: edit mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
|
|
233
|
+
'cmssy: edit/dev mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
|
|
227
234
|
);
|
|
228
235
|
}
|
|
229
236
|
const resolvedForms = await resolveForms(
|
|
@@ -238,7 +245,7 @@ function createCmssyPage(config, blocks, options) {
|
|
|
238
245
|
default: defaultLocale,
|
|
239
246
|
enabled: enabledLocales && enabledLocales.length > 0 ? enabledLocales : Array.from(/* @__PURE__ */ new Set([defaultLocale, locale]))
|
|
240
247
|
};
|
|
241
|
-
if (
|
|
248
|
+
if (editorActive && Editor) {
|
|
242
249
|
const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
|
|
243
250
|
return /* @__PURE__ */ jsx(CmssyLocaleProvider, { value: localeContext, children: /* @__PURE__ */ jsx(
|
|
244
251
|
Editor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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.
|
|
44
|
+
"@cmssy/react": "^0.7.0",
|
|
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.
|
|
57
|
+
"@cmssy/react": "0.7.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"jose": "^6.2.3"
|