@cmssy/next 4.2.0 → 4.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/index.cjs CHANGED
@@ -399,7 +399,7 @@ function resolveBridgeOrigin(editorOrigin) {
399
399
  return origins.length === 1 ? origins[0] : origins;
400
400
  }
401
401
  var CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
402
- async function cmssyEditRewrite(request2, config) {
402
+ async function cmssyEditRewrite(request2, config, options = {}) {
403
403
  const { pathname, searchParams } = request2.nextUrl;
404
404
  if (pathname.startsWith(CMSSY_EDIT_PATH_PREFIX)) return null;
405
405
  if (!searchParams.getAll(CMSSY_EDIT_QUERY_PARAM).includes("1")) return null;
@@ -408,7 +408,10 @@ async function cmssyEditRewrite(request2, config) {
408
408
  if (!await cmssySecretsMatch(provided, config.draftSecret)) return null;
409
409
  const url = request2.nextUrl.clone();
410
410
  url.pathname = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}`;
411
- return server.NextResponse.rewrite(url);
411
+ return server.NextResponse.rewrite(
412
+ url,
413
+ options.requestHeaders ? { request: { headers: options.requestHeaders } } : void 0
414
+ );
412
415
  }
413
416
  function createCmssyEditMiddleware(config) {
414
417
  return async function cmssyEditMiddleware(request2) {
package/dist/index.d.cts CHANGED
@@ -128,6 +128,14 @@ declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
128
128
  */
129
129
  declare function cmssyEditRewrite(request: NextRequest, config: {
130
130
  draftSecret: string;
131
+ }, options?: {
132
+ /**
133
+ * Headers to forward to the edit route, for a site whose middleware tells
134
+ * the app something the path alone does not - a resolved locale, say.
135
+ * Without them the editor preview renders in the default language while the
136
+ * public page renders in the visitor's.
137
+ */
138
+ requestHeaders?: Headers;
131
139
  }): Promise<NextResponse | null>;
132
140
  /** Standalone middleware when the consumer has no other middleware to compose. */
133
141
  declare function createCmssyEditMiddleware(config: {
package/dist/index.d.ts CHANGED
@@ -128,6 +128,14 @@ declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
128
128
  */
129
129
  declare function cmssyEditRewrite(request: NextRequest, config: {
130
130
  draftSecret: string;
131
+ }, options?: {
132
+ /**
133
+ * Headers to forward to the edit route, for a site whose middleware tells
134
+ * the app something the path alone does not - a resolved locale, say.
135
+ * Without them the editor preview renders in the default language while the
136
+ * public page renders in the visitor's.
137
+ */
138
+ requestHeaders?: Headers;
131
139
  }): Promise<NextResponse | null>;
132
140
  /** Standalone middleware when the consumer has no other middleware to compose. */
133
141
  declare function createCmssyEditMiddleware(config: {
package/dist/index.js CHANGED
@@ -398,7 +398,7 @@ function resolveBridgeOrigin(editorOrigin) {
398
398
  return origins.length === 1 ? origins[0] : origins;
399
399
  }
400
400
  var CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
401
- async function cmssyEditRewrite(request2, config) {
401
+ async function cmssyEditRewrite(request2, config, options = {}) {
402
402
  const { pathname, searchParams } = request2.nextUrl;
403
403
  if (pathname.startsWith(CMSSY_EDIT_PATH_PREFIX)) return null;
404
404
  if (!searchParams.getAll(CMSSY_EDIT_QUERY_PARAM).includes("1")) return null;
@@ -407,7 +407,10 @@ async function cmssyEditRewrite(request2, config) {
407
407
  if (!await cmssySecretsMatch(provided, config.draftSecret)) return null;
408
408
  const url = request2.nextUrl.clone();
409
409
  url.pathname = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}`;
410
- return NextResponse.rewrite(url);
410
+ return NextResponse.rewrite(
411
+ url,
412
+ options.requestHeaders ? { request: { headers: options.requestHeaders } } : void 0
413
+ );
411
414
  }
412
415
  function createCmssyEditMiddleware(config) {
413
416
  return async function cmssyEditMiddleware(request2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "4.2.0",
3
+ "version": "4.3.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": "^4.2.0",
44
+ "@cmssy/react": "^4.3.0",
45
45
  "next": ">=15",
46
46
  "react": "^18.2.0 || ^19.0.0",
47
47
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -55,7 +55,7 @@
55
55
  "tsup": "^8.3.0",
56
56
  "typescript": "^5.6.0",
57
57
  "vitest": "^2.1.0",
58
- "@cmssy/react": "4.2.0"
58
+ "@cmssy/react": "4.3.0"
59
59
  },
60
60
  "dependencies": {
61
61
  "jose": "^6.2.3",