@sitecore-jss/sitecore-jss-nextjs 22.1.0-canary.9 → 22.1.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.
Files changed (55) hide show
  1. package/LICENSE.txt +202 -202
  2. package/README.md +11 -11
  3. package/dist/cjs/components/Link.js +7 -3
  4. package/dist/cjs/components/NextImage.js +16 -6
  5. package/dist/cjs/components/RichText.js +2 -2
  6. package/dist/cjs/editing/constants.js +12 -3
  7. package/dist/cjs/editing/editing-config-middleware.js +8 -0
  8. package/dist/cjs/editing/editing-data-middleware.js +6 -0
  9. package/dist/cjs/editing/editing-render-middleware.js +228 -103
  10. package/dist/cjs/editing/feaas-render-middleware.js +8 -0
  11. package/dist/cjs/editing/index.js +4 -1
  12. package/dist/cjs/editing/render-middleware.js +18 -4
  13. package/dist/cjs/index.js +9 -7
  14. package/dist/cjs/middleware/middleware.js +12 -0
  15. package/dist/cjs/middleware/personalize-middleware.js +85 -25
  16. package/dist/cjs/middleware/redirects-middleware.js +63 -25
  17. package/dist/cjs/services/base-graphql-sitemap-service.js +5 -4
  18. package/dist/cjs/utils/index.js +4 -3
  19. package/dist/cjs/utils/utils.js +3 -3
  20. package/dist/esm/components/Link.js +7 -3
  21. package/dist/esm/components/NextImage.js +17 -6
  22. package/dist/esm/components/RichText.js +2 -2
  23. package/dist/esm/editing/constants.js +11 -2
  24. package/dist/esm/editing/editing-config-middleware.js +9 -1
  25. package/dist/esm/editing/editing-data-middleware.js +7 -1
  26. package/dist/esm/editing/editing-render-middleware.js +226 -103
  27. package/dist/esm/editing/feaas-render-middleware.js +9 -1
  28. package/dist/esm/editing/index.js +2 -1
  29. package/dist/esm/editing/render-middleware.js +19 -5
  30. package/dist/esm/index.js +3 -4
  31. package/dist/esm/middleware/middleware.js +12 -0
  32. package/dist/esm/middleware/personalize-middleware.js +86 -26
  33. package/dist/esm/middleware/redirects-middleware.js +63 -25
  34. package/dist/esm/services/base-graphql-sitemap-service.js +5 -4
  35. package/dist/esm/utils/index.js +2 -1
  36. package/dist/esm/utils/utils.js +1 -1
  37. package/package.json +10 -11
  38. package/types/ComponentBuilder.d.ts +3 -5
  39. package/types/components/Placeholder.d.ts +7 -2
  40. package/types/components/RichText.d.ts +6 -0
  41. package/types/editing/constants.d.ts +11 -2
  42. package/types/editing/editing-config-middleware.d.ts +7 -0
  43. package/types/editing/editing-data-service.d.ts +1 -0
  44. package/types/editing/editing-render-middleware.d.ts +111 -23
  45. package/types/editing/index.d.ts +2 -1
  46. package/types/editing/render-middleware.d.ts +9 -0
  47. package/types/index.d.ts +3 -4
  48. package/types/middleware/middleware.d.ts +6 -0
  49. package/types/middleware/personalize-middleware.d.ts +22 -2
  50. package/types/middleware/redirects-middleware.d.ts +8 -0
  51. package/types/services/base-graphql-sitemap-service.d.ts +3 -2
  52. package/types/utils/index.d.ts +2 -1
  53. package/dist/cjs/components/EditingComponentPlaceholder.js +0 -12
  54. package/dist/esm/components/EditingComponentPlaceholder.js +0 -5
  55. package/types/components/EditingComponentPlaceholder.d.ts +0 -4
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { NextResponse } from 'next/server';
11
- import { GraphQLPersonalizeService, getPersonalizedRewrite, } from '@sitecore-jss/sitecore-jss/personalize';
11
+ import { GraphQLPersonalizeService, getPersonalizedRewrite, CdpHelper, DEFAULT_VARIANT, } from '@sitecore-jss/sitecore-jss/personalize';
12
12
  import { debug } from '@sitecore-jss/sitecore-jss';
13
13
  import { MiddlewareBase } from './middleware';
14
14
  import { init, personalize } from '@sitecore-cloudsdk/personalize/server';
@@ -58,6 +58,15 @@ export class PersonalizeMiddleware extends MiddlewareBase {
58
58
  debug.personalize('skipped (no personalization configured)');
59
59
  return response;
60
60
  }
61
+ if (this.isPrefetch(req)) {
62
+ debug.personalize('skipped (prefetch)');
63
+ // Personalized, but this is a prefetch request.
64
+ // In this case, don't execute a personalize request; otherwise, the metrics for component A/B experiments would be inaccurate.
65
+ // Disable preflight caching to force revalidation on client-side navigation (personalization WILL be influenced).
66
+ // Note the reason we don't move this any earlier in the middleware is that we would then be sacrificing performance for non-personalized pages.
67
+ response.headers.set('x-middleware-cache', 'no-cache');
68
+ return response;
69
+ }
61
70
  yield this.initPersonalizeServer({
62
71
  hostname,
63
72
  siteName: site.name,
@@ -65,32 +74,36 @@ export class PersonalizeMiddleware extends MiddlewareBase {
65
74
  response,
66
75
  });
67
76
  const params = this.getExperienceParams(req);
68
- debug.personalize('executing experience for %s %o', personalizeInfo.contentId, params);
69
- let variantId;
70
- // Execute targeted experience in Personalize SDK
71
- // eslint-disable-next-line no-useless-catch
72
- try {
73
- const personalization = yield this.personalize({ personalizeInfo, params, language, timeout }, req);
74
- variantId = personalization.variantId;
75
- }
76
- catch (error) {
77
- throw error;
78
- }
79
- if (!variantId) {
80
- debug.personalize('skipped (no variant identified)');
81
- return response;
82
- }
83
- if (!personalizeInfo.variantIds.includes(variantId)) {
84
- debug.personalize('skipped (invalid variant)');
77
+ const executions = this.getPersonalizeExecutions(personalizeInfo, language);
78
+ const identifiedVariantIds = [];
79
+ yield Promise.all(executions.map((execution) => this.personalize({
80
+ friendlyId: execution.friendlyId,
81
+ variantIds: execution.variantIds,
82
+ params,
83
+ language,
84
+ timeout,
85
+ }, req).then((personalization) => {
86
+ const variantId = personalization.variantId;
87
+ if (variantId) {
88
+ if (!execution.variantIds.includes(variantId)) {
89
+ debug.personalize('invalid variant %s', variantId);
90
+ }
91
+ else {
92
+ identifiedVariantIds.push(variantId);
93
+ }
94
+ }
95
+ })));
96
+ if (identifiedVariantIds.length === 0) {
97
+ debug.personalize('skipped (no variant(s) identified)');
85
98
  return response;
86
99
  }
87
100
  // Path can be rewritten by previously executed middleware
88
101
  const basePath = (res === null || res === void 0 ? void 0 : res.headers.get('x-sc-rewrite')) || pathname;
89
102
  // Rewrite to persononalized path
90
- const rewritePath = getPersonalizedRewrite(basePath, { variantId });
103
+ const rewritePath = getPersonalizedRewrite(basePath, identifiedVariantIds);
91
104
  response = this.rewrite(rewritePath, req, response);
92
- // Disable preflight caching to force revalidation on client-side navigation (personalization may be influenced)
93
- // See https://github.com/vercel/next.js/issues/32727
105
+ // Disable preflight caching to force revalidation on client-side navigation (personalization MAY be influenced).
106
+ // See https://github.com/vercel/next.js/pull/32767
94
107
  response.headers.set('x-middleware-cache', 'no-cache');
95
108
  debug.personalize('personalize middleware end in %dms: %o', Date.now() - startTimestamp, {
96
109
  rewritePath,
@@ -129,17 +142,18 @@ export class PersonalizeMiddleware extends MiddlewareBase {
129
142
  });
130
143
  });
131
144
  }
132
- personalize({ params, personalizeInfo, language, timeout, }, request) {
145
+ personalize({ params, friendlyId, language, timeout, variantIds, }, request) {
133
146
  var _a;
134
147
  return __awaiter(this, void 0, void 0, function* () {
135
- const personalizationData = {
148
+ debug.personalize('executing experience for %s %o', friendlyId, params);
149
+ return (yield personalize(request, {
136
150
  channel: this.config.cdpConfig.channel || 'WEB',
137
151
  currency: (_a = this.config.cdpConfig.currency) !== null && _a !== void 0 ? _a : 'USD',
138
- friendlyId: personalizeInfo.contentId,
152
+ friendlyId,
139
153
  params,
140
154
  language,
141
- };
142
- return (yield personalize(request, personalizationData, { timeout }));
155
+ pageVariantIds: variantIds,
156
+ }, { timeout }));
143
157
  });
144
158
  }
145
159
  getExperienceParams(req) {
@@ -161,4 +175,50 @@ export class PersonalizeMiddleware extends MiddlewareBase {
161
175
  // ignore files
162
176
  return pathname.includes('.') || super.excludeRoute(pathname);
163
177
  }
178
+ /**
179
+ * Aggregates personalize executions based on the provided route personalize information and language
180
+ * @param {PersonalizeInfo} personalizeInfo the route personalize information
181
+ * @param {string} language the language
182
+ * @returns An array of personalize executions
183
+ */
184
+ getPersonalizeExecutions(personalizeInfo, language) {
185
+ if (personalizeInfo.variantIds.length === 0) {
186
+ return [];
187
+ }
188
+ const results = [];
189
+ return personalizeInfo.variantIds.reduce((results, variantId) => {
190
+ if (variantId.includes('_')) {
191
+ // Component-level personalization in format "<ComponentID>_<VariantID>"
192
+ const componentId = variantId.split('_')[0];
193
+ const friendlyId = CdpHelper.getComponentFriendlyId(personalizeInfo.pageId, componentId, language, this.config.scope || this.config.edgeConfig.scope);
194
+ const execution = results.find((x) => x.friendlyId === friendlyId);
195
+ if (execution) {
196
+ execution.variantIds.push(variantId);
197
+ }
198
+ else {
199
+ // The default/control variant (format "<ComponentID>_default") is also a valid value returned by the execution
200
+ const defaultVariant = `${componentId}${DEFAULT_VARIANT}`;
201
+ results.push({
202
+ friendlyId,
203
+ variantIds: [defaultVariant, variantId],
204
+ });
205
+ }
206
+ }
207
+ else {
208
+ // Embedded (page-level) personalization in format "<VariantID>"
209
+ const friendlyId = CdpHelper.getPageFriendlyId(personalizeInfo.pageId, language, this.config.scope || this.config.edgeConfig.scope);
210
+ const execution = results.find((x) => x.friendlyId === friendlyId);
211
+ if (execution) {
212
+ execution.variantIds.push(variantId);
213
+ }
214
+ else {
215
+ results.push({
216
+ friendlyId,
217
+ variantIds: [variantId],
218
+ });
219
+ }
220
+ }
221
+ return results;
222
+ }, results);
223
+ }
164
224
  }
@@ -37,6 +37,7 @@ export class RedirectsMiddleware extends MiddlewareBase {
37
37
  hostname,
38
38
  });
39
39
  const createResponse = () => __awaiter(this, void 0, void 0, function* () {
40
+ var _a;
40
41
  if (this.config.disabled && this.config.disabled(req, res || NextResponse.next())) {
41
42
  debug.redirects('skipped (redirects middleware is disabled)');
42
43
  return res || NextResponse.next();
@@ -58,47 +59,44 @@ export class RedirectsMiddleware extends MiddlewareBase {
58
59
  existsRedirect.target.includes(hostname))) {
59
60
  existsRedirect.target = existsRedirect.target.replace(REGEXP_CONTEXT_SITE_LANG, site.language);
60
61
  }
61
- const url = req.nextUrl.clone();
62
+ const url = this.normalizeUrl(req.nextUrl.clone());
62
63
  if (REGEXP_ABSOLUTE_URL.test(existsRedirect.target)) {
63
64
  url.href = existsRedirect.target;
64
65
  }
65
66
  else {
66
- const source = `${url.pathname}${url.search}`;
67
- url.search = existsRedirect.isQueryStringPreserved ? url.search : '';
67
+ const source = `${url.pathname.replace(/\/*$/gi, '')}${url.search}`;
68
68
  const urlFirstPart = existsRedirect.target.split('/')[1];
69
69
  if (this.locales.includes(urlFirstPart)) {
70
- url.locale = urlFirstPart;
70
+ req.nextUrl.locale = urlFirstPart;
71
71
  existsRedirect.target = existsRedirect.target.replace(`/${urlFirstPart}`, '');
72
72
  }
73
73
  const target = source
74
74
  .replace(regexParser(existsRedirect.pattern), existsRedirect.target)
75
75
  .replace(/^\/\//, '/')
76
76
  .split('?');
77
- url.pathname = target[0];
78
- if (target[1]) {
79
- const newParams = new URLSearchParams(target[1]);
80
- for (const [key, val] of newParams.entries()) {
81
- url.searchParams.append(key, val);
82
- }
77
+ if (url.search && existsRedirect.isQueryStringPreserved) {
78
+ const targetQueryString = (_a = target[1]) !== null && _a !== void 0 ? _a : '';
79
+ url.search = '?' + new URLSearchParams(`${url.search}&${targetQueryString}`).toString();
83
80
  }
81
+ else if (target[1]) {
82
+ url.search = '?' + target[1];
83
+ }
84
+ else {
85
+ url.search = '';
86
+ }
87
+ const prepareNewURL = new URL(`${target[0]}${url.search}`, url.origin);
88
+ url.href = prepareNewURL.href;
84
89
  }
85
90
  const redirectUrl = decodeURIComponent(url.href);
86
91
  /** return Response redirect with http code of redirect type **/
87
92
  switch (existsRedirect.redirectType) {
88
93
  case REDIRECT_TYPE_301:
89
- return NextResponse.redirect(redirectUrl, {
90
- status: 301,
91
- statusText: 'Moved Permanently',
92
- headers: res === null || res === void 0 ? void 0 : res.headers,
93
- });
94
+ return NextResponse.redirect(redirectUrl, Object.assign(Object.assign({}, res), { status: 301, statusText: 'Moved Permanently', headers: res === null || res === void 0 ? void 0 : res.headers }));
94
95
  case REDIRECT_TYPE_302:
95
- return NextResponse.redirect(redirectUrl, {
96
- status: 302,
97
- statusText: 'Found',
98
- headers: res === null || res === void 0 ? void 0 : res.headers,
99
- });
100
- case REDIRECT_TYPE_SERVER_TRANSFER:
101
- return NextResponse.rewrite(redirectUrl, res);
96
+ return NextResponse.redirect(redirectUrl, Object.assign(Object.assign({}, res), { status: 302, statusText: 'Found', headers: res === null || res === void 0 ? void 0 : res.headers }));
97
+ case REDIRECT_TYPE_SERVER_TRANSFER: {
98
+ return this.rewrite(redirectUrl, req, res || NextResponse.next());
99
+ }
102
100
  default:
103
101
  return res || NextResponse.next();
104
102
  }
@@ -143,8 +141,9 @@ export class RedirectsMiddleware extends MiddlewareBase {
143
141
  getExistsRedirect(req, siteName) {
144
142
  return __awaiter(this, void 0, void 0, function* () {
145
143
  const redirects = yield this.redirectsService.fetchRedirects(siteName);
146
- const tragetURL = req.nextUrl.pathname;
147
- const targetQS = req.nextUrl.search || '';
144
+ const normalizedUrl = this.normalizeUrl(req.nextUrl.clone());
145
+ const tragetURL = normalizedUrl.pathname;
146
+ const targetQS = normalizedUrl.search || '';
148
147
  const language = this.getLanguage(req);
149
148
  const modifyRedirects = structuredClone(redirects);
150
149
  return modifyRedirects.length
@@ -157,7 +156,7 @@ export class RedirectsMiddleware extends MiddlewareBase {
157
156
  .replace(/(?<!\\)\?/g, '\\?')
158
157
  .replace(/\$\/gi$/g, '')}[\/]?$/gi`;
159
158
  return ((regexParser(redirect.pattern).test(tragetURL) ||
160
- regexParser(redirect.pattern).test(`${tragetURL}${targetQS}`) ||
159
+ regexParser(redirect.pattern).test(`${tragetURL.replace(/\/*$/gi, '')}${targetQS}`) ||
161
160
  regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${tragetURL}`) ||
162
161
  regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${tragetURL}${targetQS}`)) &&
163
162
  (redirect.locale
@@ -167,4 +166,43 @@ export class RedirectsMiddleware extends MiddlewareBase {
167
166
  : undefined;
168
167
  });
169
168
  }
169
+ /**
170
+ * When a user clicks on a link generated by the Link component from next/link,
171
+ * Next.js adds special parameters in the route called path.
172
+ * This method removes these special parameters.
173
+ * @param {URL} url
174
+ * @returns {string} normalize url
175
+ */
176
+ normalizeUrl(url) {
177
+ if (!url.search) {
178
+ return url;
179
+ }
180
+ /**
181
+ * Prepare special parameters for exclusion.
182
+ */
183
+ const splittedPathname = url.pathname
184
+ .split('/')
185
+ .filter((route) => route)
186
+ .map((route) => `path=${route}`);
187
+ /**
188
+ * Remove special parameters(Next.JS)
189
+ * Example: /about/contact/us
190
+ * When a user clicks on this link, Next.js should generate a link for the middleware, formatted like this:
191
+ * http://host/about/contact/us?path=about&path=contact&path=us
192
+ */
193
+ const newQueryString = url.search
194
+ .replace(/^\?/, '')
195
+ .split('&')
196
+ .filter((param) => {
197
+ if (!splittedPathname.includes(param)) {
198
+ return param;
199
+ }
200
+ return false;
201
+ })
202
+ .join('&');
203
+ if (newQueryString) {
204
+ return new URL(`${url.pathname}?${newQueryString}`, url.origin);
205
+ }
206
+ return new URL(`${url.pathname}`, url.origin);
207
+ }
170
208
  }
@@ -144,13 +144,14 @@ export class BaseGraphQLSitemapService {
144
144
  const formatPath = (path) => formatStaticPath(path.replace(/^\/|\/$/g, '').split('/'), language);
145
145
  const aggregatedPaths = [];
146
146
  sitePaths.forEach((item) => {
147
- var _a, _b, _c, _d;
147
+ var _a, _b, _c;
148
148
  if (!item)
149
149
  return;
150
150
  aggregatedPaths.push(formatPath(item.path));
151
- // check for type safety's sake - personalize may be empty depending on query type
152
- if ((_b = (_a = item.route) === null || _a === void 0 ? void 0 : _a.personalization) === null || _b === void 0 ? void 0 : _b.variantIds.length) {
153
- aggregatedPaths.push(...(((_d = (_c = item.route) === null || _c === void 0 ? void 0 : _c.personalization) === null || _d === void 0 ? void 0 : _d.variantIds.map((varId) => formatPath(getPersonalizedRewrite(item.path, { variantId: varId })))) || {}));
151
+ const variantIds = (_c = (_b = (_a = item.route) === null || _a === void 0 ? void 0 : _a.personalization) === null || _b === void 0 ? void 0 : _b.variantIds) === null || _c === void 0 ? void 0 : _c.filter((variantId) => !variantId.includes('_') // exclude component A/B test variants
152
+ );
153
+ if (variantIds === null || variantIds === void 0 ? void 0 : variantIds.length) {
154
+ aggregatedPaths.push(...variantIds.map((varId) => formatPath(getPersonalizedRewrite(item.path, [varId]))));
154
155
  }
155
156
  });
156
157
  return aggregatedPaths;
@@ -1,2 +1,3 @@
1
1
  export { getPublicUrl, handleEditorFastRefresh } from './utils';
2
- export { tryParseEnvValue, isEditorActive, resetEditorChromes, resolveUrl, } from '@sitecore-jss/sitecore-jss/utils';
2
+ export { tryParseEnvValue, resolveUrl } from '@sitecore-jss/sitecore-jss/utils';
3
+ export { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/editing';
@@ -1,4 +1,4 @@
1
- import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/utils';
1
+ import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/editing';
2
2
  /**
3
3
  * Get the publicUrl.
4
4
  * This is used primarily to enable compatibility with Sitecore editors.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "22.1.0-canary.9",
3
+ "version": "22.1.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -14,7 +14,7 @@
14
14
  "generate-docs": "npx typedoc --plugin typedoc-plugin-markdown --readme none --out ../../ref-docs/sitecore-jss-nextjs --entryPoints src/index.ts --entryPoints src/monitoring/index.ts --entryPoints src/editing/index.ts --entryPoints src/middleware/index.ts --entryPoints src/context/index.ts --entryPoints src/utils/index.ts --entryPoints src/site/index.ts --entryPoints src/graphql/index.ts --githubPages false"
15
15
  },
16
16
  "engines": {
17
- "node": ">=18"
17
+ "node": ">=20"
18
18
  },
19
19
  "author": {
20
20
  "name": "Sitecore Corporation",
@@ -29,13 +29,13 @@
29
29
  "url": "https://github.com/sitecore/jss/issues"
30
30
  },
31
31
  "devDependencies": {
32
- "@sitecore-cloudsdk/personalize": "^0.3.0",
32
+ "@sitecore-cloudsdk/personalize": "^0.3.1",
33
33
  "@types/chai": "^4.3.4",
34
34
  "@types/chai-as-promised": "^7.1.5",
35
35
  "@types/chai-string": "^1.4.2",
36
36
  "@types/enzyme": "^3.10.12",
37
37
  "@types/mocha": "^10.0.1",
38
- "@types/node": "~18.11.18",
38
+ "@types/node": "~20.14.2",
39
39
  "@types/prop-types": "^15.7.5",
40
40
  "@types/react": "^18.2.22",
41
41
  "@types/react-dom": "^18.0.10",
@@ -65,25 +65,24 @@
65
65
  "typescript": "~4.9.4"
66
66
  },
67
67
  "peerDependencies": {
68
- "@sitecore-cloudsdk/events": "^0.3.0",
69
- "@sitecore-cloudsdk/personalize": "^0.3.0",
68
+ "@sitecore-cloudsdk/events": "^0.3.1",
69
+ "@sitecore-cloudsdk/personalize": "^0.3.1",
70
70
  "next": "^14.1.0",
71
71
  "react": "^18.2.0",
72
72
  "react-dom": "^18.2.0"
73
73
  },
74
74
  "dependencies": {
75
- "@sitecore-jss/sitecore-jss": "^22.1.0-canary.9",
76
- "@sitecore-jss/sitecore-jss-dev-tools": "^22.1.0-canary.9",
77
- "@sitecore-jss/sitecore-jss-react": "^22.1.0-canary.9",
75
+ "@sitecore-jss/sitecore-jss": "22.1.0",
76
+ "@sitecore-jss/sitecore-jss-dev-tools": "22.1.0",
77
+ "@sitecore-jss/sitecore-jss-react": "22.1.0",
78
78
  "@vercel/kv": "^0.2.1",
79
- "node-html-parser": "^6.1.4",
80
79
  "prop-types": "^15.8.1",
81
80
  "regex-parser": "^2.2.11",
82
81
  "sync-disk-cache": "^2.1.0"
83
82
  },
84
83
  "description": "",
85
84
  "types": "types/index.d.ts",
86
- "gitHead": "9b249f8d03fb9d74e74f74f3040fc2668137bdcc",
85
+ "gitHead": "8f6fa5709f6b306bf40fb2b0775ae6c5ac4182e7",
87
86
  "files": [
88
87
  "dist",
89
88
  "types",
@@ -1,18 +1,16 @@
1
- /// <reference types="@types/react" />
2
- import { ComponentFactory } from '@sitecore-jss/sitecore-jss-react';
1
+ import { ComponentFactory, JssComponentType } from '@sitecore-jss/sitecore-jss-react';
3
2
  import { Module, ModuleFactory } from './sharedTypes/module-factory';
4
- import { ComponentType } from 'react';
5
3
  /**
6
4
  * Represents a component that can be imported dynamically
7
5
  */
8
6
  export type LazyModule = {
9
7
  module: () => Promise<Module>;
10
- element: (isEditing?: boolean) => ComponentType;
8
+ element: (isEditing?: boolean) => JssComponentType;
11
9
  };
12
10
  /**
13
11
  * Component is a module or a lazy module
14
12
  */
15
- type Component = Module | LazyModule | ComponentType;
13
+ type Component = Module | LazyModule | JssComponentType;
16
14
  /**
17
15
  * Configuration for ComponentBuilder
18
16
  */
@@ -1,4 +1,9 @@
1
1
  /// <reference types="@types/react" />
2
2
  import React from 'react';
3
- import { PlaceholderComponentProps } from '@sitecore-jss/sitecore-jss-react';
4
- export declare const Placeholder: (props: PlaceholderComponentProps) => React.JSX.Element;
3
+ import { PlaceholderComponentProps, WithSitecoreContextProps, EnhancedOmit } from '@sitecore-jss/sitecore-jss-react';
4
+ /**
5
+ * React Placeholder component wrapped by withSitecoreContext, so these properties shouldn't be passed to the Next.js Placeholder.
6
+ */
7
+ type PlaceholderProps = EnhancedOmit<PlaceholderComponentProps, keyof WithSitecoreContextProps>;
8
+ export declare const Placeholder: (props: PlaceholderProps) => React.JSX.Element;
9
+ export {};
@@ -1,3 +1,5 @@
1
+ /// <reference types="@types/react" />
2
+ import React from 'react';
1
3
  import PropTypes from 'prop-types';
2
4
  import { RichTextProps as ReactRichTextProps } from '@sitecore-jss/sitecore-jss-react';
3
5
  export type RichTextProps = ReactRichTextProps & {
@@ -19,9 +21,13 @@ export declare const RichText: {
19
21
  field: PropTypes.Requireable<PropTypes.InferProps<{
20
22
  value: PropTypes.Requireable<string>;
21
23
  editable: PropTypes.Requireable<string>;
24
+ metadata: PropTypes.Requireable<{
25
+ [x: string]: any;
26
+ }>;
22
27
  }>>;
23
28
  tag: PropTypes.Requireable<string>;
24
29
  editable: PropTypes.Requireable<boolean>;
30
+ emptyFieldEditingComponent: PropTypes.Requireable<NonNullable<React.ComponentClass<unknown, any> | React.FC<unknown>>>;
25
31
  internalLinksSelector: PropTypes.Requireable<string>;
26
32
  };
27
33
  displayName: string;
@@ -1,3 +1,12 @@
1
1
  export declare const QUERY_PARAM_EDITING_SECRET = "secret";
2
- export declare const QUERY_PARAM_PROTECTION_BYPASS_SITECORE = "x-sitecore-protection-bypass";
3
- export declare const QUERY_PARAM_PROTECTION_BYPASS_VERCEL = "x-vercel-protection-bypass";
2
+ export declare const QUERY_PARAM_VERCEL_PROTECTION_BYPASS = "x-vercel-protection-bypass";
3
+ export declare const QUERY_PARAM_VERCEL_SET_BYPASS_COOKIE = "x-vercel-set-bypass-cookie";
4
+ /**
5
+ * Headers that should be passed along to (Editing Chromes handler) SSR request.
6
+ * Note these are in lowercase format to match expected `IncomingHttpHeaders`.
7
+ */
8
+ export declare const EDITING_PASS_THROUGH_HEADERS: string[];
9
+ /**
10
+ * Default allowed origins for editing requests. This is used to enforce CORS, CSP headers.
11
+ */
12
+ export declare const EDITING_ALLOWED_ORIGINS: string[];
@@ -1,4 +1,5 @@
1
1
  import { NextApiRequest, NextApiResponse } from 'next';
2
+ import { EditMode } from '@sitecore-jss/sitecore-jss/layout';
2
3
  import { Metadata } from '@sitecore-jss/sitecore-jss-dev-tools';
3
4
  export type EditingConfigMiddlewareConfig = {
4
5
  /**
@@ -9,6 +10,12 @@ export type EditingConfigMiddlewareConfig = {
9
10
  * Application metadata
10
11
  */
11
12
  metadata: Metadata;
13
+ /**
14
+ * Determines which editing mode should be used by Pages.
15
+ * Can be either 'chromes' or 'metadata'.
16
+ * By default its 'metadata'
17
+ */
18
+ pagesEditMode?: EditMode;
12
19
  };
13
20
  /**
14
21
  * Middleware / handler used in the editing config API route in xmcloud add on (e.g. '/api/editing/config')
@@ -4,6 +4,7 @@ import { EditingDataCache } from './editing-data-cache';
4
4
  import { PreviewData } from 'next';
5
5
  /**
6
6
  * Data for Next.js Preview (Editing) mode
7
+ * Used in Chromes Edit Mode only
7
8
  */
8
9
  export interface EditingPreviewData {
9
10
  key: string;