@sitecore-jss/sitecore-jss-nextjs 22.11.0-canary.6 → 22.11.0-canary.8

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.
@@ -10,7 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EditingRenderMiddleware = exports.MetadataHandler = exports.isDesignLibraryPreviewData = exports.isEditingMetadataPreviewData = exports.ChromesHandler = void 0;
13
- const constants_1 = require("next/constants");
13
+ // STATIC_PROPS_ID and SERVER_PROPS_ID were removed from next/constants in Next.js 16
14
+ // These are internal identifiers used in __NEXT_DATA__ script tag
15
+ // Defining them locally to maintain functionality
16
+ const STATIC_PROPS_ID = '__N_SSG';
17
+ const SERVER_PROPS_ID = '__N_SSR';
14
18
  const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
15
19
  const layout_1 = require("@sitecore-jss/sitecore-jss/layout");
16
20
  const editing_1 = require("@sitecore-jss/sitecore-jss/editing");
@@ -117,7 +121,7 @@ class ChromesHandler extends render_middleware_1.RenderMiddlewareBase {
117
121
  // to do with the Next route/page we've rendered. Beyond the extraneous request, this can result in a 404 with
118
122
  // certain route configurations (e.g. multiple catch-all routes).
119
123
  // The following line will trick it into thinking we're SSR, thus avoiding any router.replace.
120
- html = html.replace(constants_1.STATIC_PROPS_ID, constants_1.SERVER_PROPS_ID);
124
+ html = html.replace(STATIC_PROPS_ID, SERVER_PROPS_ID);
121
125
  const body = { html };
122
126
  // Return expected JSON result
123
127
  sitecore_jss_1.debug.editing('editing render middleware end in %dms: %o', Date.now() - startTimestamp, {
@@ -201,10 +201,12 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
201
201
  ? (0, utils_1.mergeURLSearchParams)(new URLSearchParams((_a = url.search) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQueryString || ''))
202
202
  : targetQueryString || '';
203
203
  const prepareNewURL = new URL(`${targetPath}${mergedQueryString ? `?${mergedQueryString}` : ''}`, url.origin);
204
+ const basePath = url.basePath; // setting NextUrl.href overrides basePath, so we need to store it
204
205
  url.href = prepareNewURL.href;
205
206
  url.pathname = prepareNewURL.pathname;
206
207
  url.search = prepareNewURL.search;
207
208
  url.locale = req.nextUrl.locale;
209
+ url.basePath = basePath;
208
210
  return this.dispatchRedirect(url, existsRedirect.redirectType, req, response, false);
209
211
  }
210
212
  });
@@ -258,9 +260,11 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
258
260
  .filter((param) => !splittedPathname.includes(param))
259
261
  .join('&');
260
262
  const newUrl = new URL(`${url.pathname.toLowerCase()}?${newQueryString}`, url.origin);
263
+ const basePath = url.basePath; // setting NextUrl.href overrides basePath, so we need to store it
261
264
  url.search = newUrl.search;
262
265
  url.pathname = newUrl.pathname.toLowerCase();
263
266
  url.href = newUrl.href;
267
+ url.basePath = basePath;
264
268
  return url;
265
269
  }
266
270
  /**
@@ -7,7 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { STATIC_PROPS_ID, SERVER_PROPS_ID } from 'next/constants';
10
+ // STATIC_PROPS_ID and SERVER_PROPS_ID were removed from next/constants in Next.js 16
11
+ // These are internal identifiers used in __NEXT_DATA__ script tag
12
+ // Defining them locally to maintain functionality
13
+ const STATIC_PROPS_ID = '__N_SSG';
14
+ const SERVER_PROPS_ID = '__N_SSR';
11
15
  import { NativeDataFetcher, debug } from '@sitecore-jss/sitecore-jss';
12
16
  import { EditMode, LayoutServicePageState } from '@sitecore-jss/sitecore-jss/layout';
13
17
  import { QUERY_PARAM_EDITING_SECRET, EDITING_ALLOWED_ORIGINS, isDesignLibraryMode, } from '@sitecore-jss/sitecore-jss/editing';
@@ -195,10 +195,12 @@ export class RedirectsMiddleware extends MiddlewareBase {
195
195
  ? mergeURLSearchParams(new URLSearchParams((_a = url.search) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQueryString || ''))
196
196
  : targetQueryString || '';
197
197
  const prepareNewURL = new URL(`${targetPath}${mergedQueryString ? `?${mergedQueryString}` : ''}`, url.origin);
198
+ const basePath = url.basePath; // setting NextUrl.href overrides basePath, so we need to store it
198
199
  url.href = prepareNewURL.href;
199
200
  url.pathname = prepareNewURL.pathname;
200
201
  url.search = prepareNewURL.search;
201
202
  url.locale = req.nextUrl.locale;
203
+ url.basePath = basePath;
202
204
  return this.dispatchRedirect(url, existsRedirect.redirectType, req, response, false);
203
205
  }
204
206
  });
@@ -252,9 +254,11 @@ export class RedirectsMiddleware extends MiddlewareBase {
252
254
  .filter((param) => !splittedPathname.includes(param))
253
255
  .join('&');
254
256
  const newUrl = new URL(`${url.pathname.toLowerCase()}?${newQueryString}`, url.origin);
257
+ const basePath = url.basePath; // setting NextUrl.href overrides basePath, so we need to store it
255
258
  url.search = newUrl.search;
256
259
  url.pathname = newUrl.pathname.toLowerCase();
257
260
  url.href = newUrl.href;
261
+ url.basePath = basePath;
258
262
  return url;
259
263
  }
260
264
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "22.11.0-canary.6",
3
+ "version": "22.11.0-canary.8",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -53,7 +53,7 @@
53
53
  "eslint-plugin-react": "^7.37.5",
54
54
  "jsdom": "^26.1.0",
55
55
  "mocha": "^11.7.0",
56
- "next": "^15.4.6",
56
+ "next": "^16.1.0",
57
57
  "nock": "^13.3.0",
58
58
  "nyc": "^17.1.0",
59
59
  "react": "^19.1.0",
@@ -67,21 +67,21 @@
67
67
  "@sitecore-cloudsdk/core": "^0.5.2",
68
68
  "@sitecore-cloudsdk/events": "^0.5.2",
69
69
  "@sitecore-cloudsdk/personalize": "^0.5.2",
70
- "next": "^15.4.6",
70
+ "next": "^16.1.0",
71
71
  "react": "^19.1.0",
72
72
  "react-dom": "^19.1.0"
73
73
  },
74
74
  "dependencies": {
75
- "@sitecore-jss/sitecore-jss": "22.11.0-canary.6",
76
- "@sitecore-jss/sitecore-jss-dev-tools": "22.11.0-canary.6",
77
- "@sitecore-jss/sitecore-jss-react": "22.11.0-canary.6",
75
+ "@sitecore-jss/sitecore-jss": "22.11.0-canary.8",
76
+ "@sitecore-jss/sitecore-jss-dev-tools": "22.11.0-canary.8",
77
+ "@sitecore-jss/sitecore-jss-react": "22.11.0-canary.8",
78
78
  "@vercel/kv": "^0.2.1",
79
79
  "regex-parser": "^2.2.11",
80
80
  "sync-disk-cache": "^2.1.0"
81
81
  },
82
82
  "description": "",
83
83
  "types": "types/index.d.ts",
84
- "gitHead": "d8887014b516b2eb4c1c913a172f7c4658dfed16",
84
+ "gitHead": "a364c52b72ef5f8736944eb97198b1290c182d72",
85
85
  "files": [
86
86
  "dist",
87
87
  "types",