@sitecore-content-sdk/nextjs 1.3.0-canary.21 → 1.3.0-canary.23
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/cjs/middleware/redirects-middleware.js +10 -3
- package/dist/cjs/route-handler/editing-config-route-handler.js +4 -1
- package/dist/esm/middleware/redirects-middleware.js +10 -3
- package/dist/esm/route-handler/editing-config-route-handler.js +4 -1
- package/package.json +4 -4
- package/types/middleware/redirects-middleware.d.ts.map +1 -1
- package/types/route-handler/editing-config-route-handler.d.ts +4 -0
- package/types/route-handler/editing-config-route-handler.d.ts.map +1 -1
|
@@ -54,6 +54,7 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
|
|
|
54
54
|
core_1.debug.redirects('skipped (redirects middleware is disabled)');
|
|
55
55
|
return res;
|
|
56
56
|
}
|
|
57
|
+
const isAppRouterRequest = this.isAppRouter(res);
|
|
57
58
|
const createResponse = () => __awaiter(this, void 0, void 0, function* () {
|
|
58
59
|
var _a;
|
|
59
60
|
if (this.isPreview(req)) {
|
|
@@ -81,7 +82,9 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
|
|
|
81
82
|
!(REGEXP_ABSOLUTE_URL.test(existsRedirect.target) &&
|
|
82
83
|
existsRedirect.target.includes(hostname))) {
|
|
83
84
|
existsRedirect.target = existsRedirect.target.replace(REGEXP_CONTEXT_SITE_LANG, site.language);
|
|
84
|
-
|
|
85
|
+
if (!isAppRouterRequest) {
|
|
86
|
+
req.nextUrl.locale = site.language;
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
const url = this.normalizeUrl(req.nextUrl.clone());
|
|
87
90
|
// Redirect logic for external (absolute) URLS. To avoid locale stripping: use plain string for external URLs to prevent Next.js rewriting.
|
|
@@ -105,7 +108,9 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
|
|
|
105
108
|
const targetParts = existsRedirect.target.split('/');
|
|
106
109
|
const urlFirstPart = targetParts[1];
|
|
107
110
|
if (this.locales.includes(urlFirstPart)) {
|
|
108
|
-
|
|
111
|
+
if (!isAppRouterRequest) {
|
|
112
|
+
req.nextUrl.locale = urlFirstPart;
|
|
113
|
+
}
|
|
109
114
|
existsRedirect.target = existsRedirect.target.replace(`/${urlFirstPart}`, '');
|
|
110
115
|
}
|
|
111
116
|
const targetSegments = isUrl
|
|
@@ -124,7 +129,9 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
|
|
|
124
129
|
url.href = prepareNewURL.href;
|
|
125
130
|
url.pathname = prepareNewURL.pathname;
|
|
126
131
|
url.search = prepareNewURL.search;
|
|
127
|
-
|
|
132
|
+
if (!isAppRouterRequest) {
|
|
133
|
+
url.locale = req.nextUrl.locale;
|
|
134
|
+
}
|
|
128
135
|
}
|
|
129
136
|
/** return Response redirect with http code of redirect type */
|
|
130
137
|
return this.dispatchRedirect(url, existsRedirect.redirectType, req, res, false);
|
|
@@ -23,7 +23,7 @@ const utils_2 = require("../utils/utils");
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
const createEditingConfigRouteHandler = (options) => {
|
|
26
|
-
const { components, metadata } = options;
|
|
26
|
+
const { components, metadata, clientComponents } = options;
|
|
27
27
|
const validateRequest = (req) => {
|
|
28
28
|
const secret = req.nextUrl.searchParams.get(editing_1.QUERY_PARAM_EDITING_SECRET);
|
|
29
29
|
const corsHeaders = (0, utils_1.getEnforcedCorsHeaders)({
|
|
@@ -56,8 +56,11 @@ const createEditingConfigRouteHandler = (options) => {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
const componentNames = Array.from(components.keys());
|
|
59
|
+
const clientComponentNames = clientComponents ? Array.from(clientComponents.keys()) : [];
|
|
59
60
|
const responseData = {
|
|
61
|
+
framework: 'nextjs-approuter',
|
|
60
62
|
components: componentNames,
|
|
63
|
+
clientComponents: clientComponentNames,
|
|
61
64
|
packages: metadata.packages,
|
|
62
65
|
editMode: layout_1.EditMode.Metadata,
|
|
63
66
|
};
|
|
@@ -48,6 +48,7 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
48
48
|
debug.redirects('skipped (redirects middleware is disabled)');
|
|
49
49
|
return res;
|
|
50
50
|
}
|
|
51
|
+
const isAppRouterRequest = this.isAppRouter(res);
|
|
51
52
|
const createResponse = () => __awaiter(this, void 0, void 0, function* () {
|
|
52
53
|
var _a;
|
|
53
54
|
if (this.isPreview(req)) {
|
|
@@ -75,7 +76,9 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
75
76
|
!(REGEXP_ABSOLUTE_URL.test(existsRedirect.target) &&
|
|
76
77
|
existsRedirect.target.includes(hostname))) {
|
|
77
78
|
existsRedirect.target = existsRedirect.target.replace(REGEXP_CONTEXT_SITE_LANG, site.language);
|
|
78
|
-
|
|
79
|
+
if (!isAppRouterRequest) {
|
|
80
|
+
req.nextUrl.locale = site.language;
|
|
81
|
+
}
|
|
79
82
|
}
|
|
80
83
|
const url = this.normalizeUrl(req.nextUrl.clone());
|
|
81
84
|
// Redirect logic for external (absolute) URLS. To avoid locale stripping: use plain string for external URLs to prevent Next.js rewriting.
|
|
@@ -99,7 +102,9 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
99
102
|
const targetParts = existsRedirect.target.split('/');
|
|
100
103
|
const urlFirstPart = targetParts[1];
|
|
101
104
|
if (this.locales.includes(urlFirstPart)) {
|
|
102
|
-
|
|
105
|
+
if (!isAppRouterRequest) {
|
|
106
|
+
req.nextUrl.locale = urlFirstPart;
|
|
107
|
+
}
|
|
103
108
|
existsRedirect.target = existsRedirect.target.replace(`/${urlFirstPart}`, '');
|
|
104
109
|
}
|
|
105
110
|
const targetSegments = isUrl
|
|
@@ -118,7 +123,9 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
118
123
|
url.href = prepareNewURL.href;
|
|
119
124
|
url.pathname = prepareNewURL.pathname;
|
|
120
125
|
url.search = prepareNewURL.search;
|
|
121
|
-
|
|
126
|
+
if (!isAppRouterRequest) {
|
|
127
|
+
url.locale = req.nextUrl.locale;
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
130
|
/** return Response redirect with http code of redirect type */
|
|
124
131
|
return this.dispatchRedirect(url, existsRedirect.redirectType, req, res, false);
|
|
@@ -20,7 +20,7 @@ import { getEditingSecret } from '../utils/utils';
|
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
22
|
export const createEditingConfigRouteHandler = (options) => {
|
|
23
|
-
const { components, metadata } = options;
|
|
23
|
+
const { components, metadata, clientComponents } = options;
|
|
24
24
|
const validateRequest = (req) => {
|
|
25
25
|
const secret = req.nextUrl.searchParams.get(QUERY_PARAM_EDITING_SECRET);
|
|
26
26
|
const corsHeaders = getEnforcedCorsHeaders({
|
|
@@ -53,8 +53,11 @@ export const createEditingConfigRouteHandler = (options) => {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
const componentNames = Array.from(components.keys());
|
|
56
|
+
const clientComponentNames = clientComponents ? Array.from(clientComponents.keys()) : [];
|
|
56
57
|
const responseData = {
|
|
58
|
+
framework: 'nextjs-approuter',
|
|
57
59
|
components: componentNames,
|
|
60
|
+
clientComponents: clientComponentNames,
|
|
58
61
|
packages: metadata.packages,
|
|
59
62
|
editMode: EditMode.Metadata,
|
|
60
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/nextjs",
|
|
3
|
-
"version": "1.3.0-canary.
|
|
3
|
+
"version": "1.3.0-canary.23",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -91,15 +91,15 @@
|
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@babel/parser": "^7.27.2",
|
|
94
|
-
"@sitecore-content-sdk/core": "1.3.0-canary.
|
|
95
|
-
"@sitecore-content-sdk/react": "1.3.0-canary.
|
|
94
|
+
"@sitecore-content-sdk/core": "1.3.0-canary.23",
|
|
95
|
+
"@sitecore-content-sdk/react": "1.3.0-canary.23",
|
|
96
96
|
"recast": "^0.23.11",
|
|
97
97
|
"regex-parser": "^2.3.1",
|
|
98
98
|
"sync-disk-cache": "^2.1.0"
|
|
99
99
|
},
|
|
100
100
|
"description": "",
|
|
101
101
|
"types": "types/index.d.ts",
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "cc2c3a40c84e6072add7f3ddbf75ccf862a037a5",
|
|
103
103
|
"files": [
|
|
104
104
|
"dist",
|
|
105
105
|
"types",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirects-middleware.d.ts","sourceRoot":"","sources":["../../src/middleware/redirects-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EAItB,YAAY,EAEb,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAuB,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAK3C,KAAK,cAAc,GAAG,YAAY,GAAG;IAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,eAAe,CAAC,GAC7F,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAC7B,oBAAoB,GACpB,cAAc,CAAC,WAAW,CAAC,GAAG;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AACJ;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IAOzC,SAAS,CAAC,MAAM,EAAE,yBAAyB;IANvD,SAA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;;;OAMG;cACa,iBAAiB,CAC/B,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IA2EtC;;;;;;OAMG;IACH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAuC7C;;;;;;;;;OASG;IACH,SAAS,CAAC,gBAAgB,CACxB,MAAM,EAAE,OAAO,GAAG,MAAM,EACxB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,YAAY,EACjB,UAAU,UAAQ,GACjB,YAAY;IAmBf;;;;;;;OAOG;IACH,SAAS,CAAC,sBAAsB,CAC9B,GAAG,EAAE,OAAO,GAAG,MAAM,EACrB,GAAG,EAAE,QAAQ,GAAG,SAAS,EACzB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,YAAY;CAahB"}
|
|
@@ -11,6 +11,10 @@ export type EditingConfigRouteHandlerOptions = {
|
|
|
11
11
|
* Application metadata
|
|
12
12
|
*/
|
|
13
13
|
metadata: Metadata;
|
|
14
|
+
/**
|
|
15
|
+
* Contains only client and universal components that can be used in client bundles
|
|
16
|
+
*/
|
|
17
|
+
clientComponents?: ComponentMap<NextjsContentSdkComponent>;
|
|
14
18
|
};
|
|
15
19
|
/**
|
|
16
20
|
* Creates a route handler for the editing config API route (e.g. '/api/editing/config')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editing-config-route-handler.d.ts","sourceRoot":"","sources":["../../src/route-handler/editing-config-route-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAI9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,UAAU,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"editing-config-route-handler.d.ts","sourceRoot":"","sources":["../../src/route-handler/editing-config-route-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAI9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,UAAU,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,gCAAgC;eAe/D,WAAW;mBAkEP,WAAW;CAkCxC,CAAC"}
|