@sitecore-jss/sitecore-jss-nextjs 22.5.0 → 22.5.1-canary.2

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/LICENSE.txt CHANGED
@@ -1,202 +1,202 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # Sitecore JavaScript Rendering SDK for Next.js
2
-
3
- This module is provided as a part of Sitecore JavaScript Rendering SDK. It contains Next.js components and integration for JSS.
4
-
5
- <!---
6
- @TODO: Update to next version docs before release
7
- -->
8
- [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/22/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
9
-
10
- [Documentation (XM Cloud)](https://doc.sitecore.com/xmc/en/developers/xm-cloud/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
11
-
1
+ # Sitecore JavaScript Rendering SDK for Next.js
2
+
3
+ This module is provided as a part of Sitecore JavaScript Rendering SDK. It contains Next.js components and integration for JSS.
4
+
5
+ <!---
6
+ @TODO: Update to next version docs before release
7
+ -->
8
+ [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/22/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
9
+
10
+ [Documentation (XM Cloud)](https://doc.sitecore.com/xmc/en/developers/xm-cloud/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
11
+
12
12
  [API reference documentation](/ref-docs/sitecore-jss-nextjs/)
@@ -67,14 +67,15 @@ exports.Link = (0, react_1.forwardRef)((props, ref) => {
67
67
  const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
68
68
  // determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
69
69
  if (isMatching && !isFileUrl) {
70
- return (react_1.default.createElement(link_1.default, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", locale: false, title: value.title, target: value.target, className: value.class }, htmlLinkProps, { ref: ref }),
70
+ return (react_1.default.createElement(link_1.default, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", locale: false, title: value.title, target: value.target, className: value.class, prefetch: props.prefetch }, htmlLinkProps, { ref: ref }),
71
71
  text,
72
72
  children));
73
73
  }
74
74
  }
75
- // prevent passing internalLinkMatcher as it is an invalid DOM element prop
75
+ // prevent passing internalLinkMatcher or prefetch as it is an invalid DOM element prop
76
76
  const reactLinkProps = Object.assign({}, props);
77
77
  delete reactLinkProps.internalLinkMatcher;
78
+ delete reactLinkProps.prefetch;
78
79
  return react_1.default.createElement(sitecore_jss_react_1.Link, Object.assign({}, reactLinkProps, { ref: ref }));
79
80
  });
80
81
  exports.Link.displayName = 'NextLink';
@@ -37,12 +37,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.RichText = void 0;
40
+ exports.RichText = exports.prefetched = void 0;
41
41
  const react_1 = __importStar(require("react"));
42
42
  const prop_types_1 = __importDefault(require("prop-types"));
43
43
  const router_1 = require("next/router");
44
44
  const sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
45
- const prefetched = {};
45
+ exports.prefetched = {};
46
46
  const RichText = (props) => {
47
47
  const { internalLinksSelector = 'a[href^="/"]', prefetchLinks = true, editable = true } = props, rest = __rest(props, ["internalLinksSelector", "prefetchLinks", "editable"]);
48
48
  const hasText = props.field && props.field.value;
@@ -50,7 +50,7 @@ const RichText = (props) => {
50
50
  const router = (0, router_1.useRouter)();
51
51
  const richTextRef = (0, react_1.useRef)(null);
52
52
  (0, react_1.useEffect)(() => {
53
- // NOT IN EXPERIENCE EDITOR
53
+ // NOT IN EDIT MODE
54
54
  if (hasText && !isEditing) {
55
55
  initializeLinks();
56
56
  }
@@ -71,9 +71,21 @@ const RichText = (props) => {
71
71
  internalLinks.forEach((link) => {
72
72
  if (link.target === '_blank')
73
73
  return;
74
- if (prefetchLinks && !prefetched[link.pathname]) {
74
+ const prefetch = () => {
75
75
  router.prefetch(link.pathname, undefined, { locale: false });
76
- prefetched[link.pathname] = true;
76
+ exports.prefetched[link.pathname] = true;
77
+ };
78
+ if (!exports.prefetched[link.pathname] && prefetchLinks !== false) {
79
+ if (prefetchLinks === true) {
80
+ prefetch();
81
+ }
82
+ if (prefetchLinks === 'hover') {
83
+ const mouseOverHandler = () => {
84
+ prefetch();
85
+ link.removeEventListener('mouseover', mouseOverHandler);
86
+ };
87
+ link.addEventListener('mouseover', mouseOverHandler, false);
88
+ }
77
89
  }
78
90
  link.addEventListener('click', routeHandler, false);
79
91
  });
@@ -32,7 +32,84 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
32
32
  constructor(config) {
33
33
  super(config);
34
34
  this.config = config;
35
- this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
35
+ // NOTE: we provide native fetch for compatibility on Next.js Edge Runtime
36
+ // (underlying default 'cross-fetch' is not currently compatible: https://github.com/lquixada/cross-fetch/issues/78)
37
+ this.redirectsService = new site_1.GraphQLRedirectsService(Object.assign(Object.assign({}, config), { fetch: fetch }));
38
+ this.locales = config.locales;
39
+ }
40
+ /**
41
+ * Gets the Next.js middleware handler with error handling
42
+ * @returns route handler
43
+ */
44
+ getHandler() {
45
+ return (req, res) => __awaiter(this, void 0, void 0, function* () {
46
+ try {
47
+ return this.processRedirectRequest(req, res);
48
+ }
49
+ catch (error) {
50
+ console.log('Redirect middleware failed:');
51
+ console.log(error);
52
+ return res || server_1.NextResponse.next();
53
+ }
54
+ });
55
+ }
56
+ /**
57
+ * Method returns RedirectInfo when matches
58
+ * @param {NextRequest} req request
59
+ * @param {string} siteName site name
60
+ * @returns Promise<RedirectInfo | undefined> The redirect info or undefined if no redirect is found
61
+ * @protected
62
+ */
63
+ getExistsRedirect(req, siteName) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const { pathname: targetURL, search: targetQS = '', locale } = this.normalizeUrl(req.nextUrl.clone());
66
+ const normalizedPath = targetURL.replace(/\/*$/gi, '');
67
+ const redirects = yield this.redirectsService.fetchRedirects(siteName);
68
+ const language = this.getLanguage(req);
69
+ const modifyRedirects = structuredClone(redirects);
70
+ let matchedQueryString;
71
+ return modifyRedirects.length
72
+ ? modifyRedirects.find((redirect) => {
73
+ var _a;
74
+ if ((0, utils_1.isRegexOrUrl)(redirect.pattern) === 'url') {
75
+ const parseUrlPattern = redirect.pattern.endsWith('/')
76
+ ? redirect.pattern.slice(0, -1).split('?')
77
+ : redirect.pattern.split('?');
78
+ return ((parseUrlPattern[0] === normalizedPath ||
79
+ parseUrlPattern[0] === `/${locale}${normalizedPath}`) &&
80
+ (0, utils_1.areURLSearchParamsEqual)(new URLSearchParams((_a = parseUrlPattern[1]) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQS)));
81
+ }
82
+ // Modify the redirect pattern to ignore the language prefix in the path
83
+ // And escapes non-special "?" characters in a string or regex.
84
+ redirect.pattern = (0, utils_1.escapeNonSpecialQuestionMarks)(redirect.pattern.replace(new RegExp(`^[^]?/${language}/`, 'gi'), ''));
85
+ // Prepare the redirect pattern as a regular expression, making it more flexible for matching URLs
86
+ redirect.pattern = `/^\/${redirect.pattern
87
+ .replace(/^\/|\/$/g, '') // Removes leading and trailing slashes
88
+ .replace(/^\^\/|\/\$$/g, '') // Removes unnecessary start (^) and end ($) anchors
89
+ .replace(/^\^|\$$/g, '') // Further cleans up anchors
90
+ .replace(/\$\/gi$/g, '')}[\/]?$/i`; // Ensures the pattern allows an optional trailing slash
91
+ matchedQueryString = [
92
+ (0, regex_parser_1.default)(redirect.pattern).test(`${normalizedPath}${targetQS}`),
93
+ (0, regex_parser_1.default)(redirect.pattern).test(`/${locale}${normalizedPath}${targetQS}`),
94
+ ].some(Boolean)
95
+ ? targetQS
96
+ : undefined;
97
+ // Save the matched query string (if found) into the redirect object
98
+ redirect.matchedQueryString = matchedQueryString || '';
99
+ return (!!((0, regex_parser_1.default)(redirect.pattern).test(targetURL) ||
100
+ (0, regex_parser_1.default)(redirect.pattern).test(`/${req.nextUrl.locale}${targetURL}`) ||
101
+ matchedQueryString) && (redirect.locale ? redirect.locale.toLowerCase() === locale.toLowerCase() : true));
102
+ })
103
+ : undefined;
104
+ });
105
+ }
106
+ /**
107
+ * @param {NextRequest} req request
108
+ * @param {Response} res response
109
+ * @returns {Promise<NextResponse>} The redirect response.
110
+ */
111
+ processRedirectRequest(req, res) {
112
+ return __awaiter(this, void 0, void 0, function* () {
36
113
  const pathname = req.nextUrl.pathname;
37
114
  const language = this.getLanguage(req);
38
115
  const hostname = this.getHostHeader(req) || this.defaultHostname;
@@ -129,76 +206,6 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
129
206
  });
130
207
  return response;
131
208
  });
132
- // NOTE: we provide native fetch for compatibility on Next.js Edge Runtime
133
- // (underlying default 'cross-fetch' is not currently compatible: https://github.com/lquixada/cross-fetch/issues/78)
134
- this.redirectsService = new site_1.GraphQLRedirectsService(Object.assign(Object.assign({}, config), { fetch: fetch }));
135
- this.locales = config.locales;
136
- }
137
- /**
138
- * Gets the Next.js middleware handler with error handling
139
- * @returns route handler
140
- */
141
- getHandler() {
142
- return (req, res) => __awaiter(this, void 0, void 0, function* () {
143
- try {
144
- return yield this.handler(req, res);
145
- }
146
- catch (error) {
147
- console.log('Redirect middleware failed:');
148
- console.log(error);
149
- return res || server_1.NextResponse.next();
150
- }
151
- });
152
- }
153
- /**
154
- * Method returns RedirectInfo when matches
155
- * @param {NextRequest} req request
156
- * @param {string} siteName site name
157
- * @returns Promise<RedirectInfo | undefined>
158
- * @private
159
- */
160
- getExistsRedirect(req, siteName) {
161
- return __awaiter(this, void 0, void 0, function* () {
162
- const { pathname: targetURL, search: targetQS = '', locale } = this.normalizeUrl(req.nextUrl.clone());
163
- const normalizedPath = targetURL.replace(/\/*$/gi, '');
164
- const redirects = yield this.redirectsService.fetchRedirects(siteName);
165
- const language = this.getLanguage(req);
166
- const modifyRedirects = structuredClone(redirects);
167
- let matchedQueryString;
168
- return modifyRedirects.length
169
- ? modifyRedirects.find((redirect) => {
170
- var _a;
171
- if ((0, utils_1.isRegexOrUrl)(redirect.pattern) === 'url') {
172
- const parseUrlPattern = redirect.pattern.endsWith('/')
173
- ? redirect.pattern.slice(0, -1).split('?')
174
- : redirect.pattern.split('?');
175
- return ((parseUrlPattern[0] === normalizedPath ||
176
- parseUrlPattern[0] === `/${locale}${normalizedPath}`) &&
177
- (0, utils_1.areURLSearchParamsEqual)(new URLSearchParams((_a = parseUrlPattern[1]) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQS)));
178
- }
179
- // Modify the redirect pattern to ignore the language prefix in the path
180
- // And escapes non-special "?" characters in a string or regex.
181
- redirect.pattern = (0, utils_1.escapeNonSpecialQuestionMarks)(redirect.pattern.replace(new RegExp(`^[^]?/${language}/`, 'gi'), ''));
182
- // Prepare the redirect pattern as a regular expression, making it more flexible for matching URLs
183
- redirect.pattern = `/^\/${redirect.pattern
184
- .replace(/^\/|\/$/g, '') // Removes leading and trailing slashes
185
- .replace(/^\^\/|\/\$$/g, '') // Removes unnecessary start (^) and end ($) anchors
186
- .replace(/^\^|\$$/g, '') // Further cleans up anchors
187
- .replace(/\$\/gi$/g, '')}[\/]?$/i`; // Ensures the pattern allows an optional trailing slash
188
- matchedQueryString = [
189
- (0, regex_parser_1.default)(redirect.pattern).test(`${normalizedPath}${targetQS}`),
190
- (0, regex_parser_1.default)(redirect.pattern).test(`/${locale}${normalizedPath}${targetQS}`),
191
- ].some(Boolean)
192
- ? targetQS
193
- : undefined;
194
- // Save the matched query string (if found) into the redirect object
195
- redirect.matchedQueryString = matchedQueryString || '';
196
- return (!!((0, regex_parser_1.default)(redirect.pattern).test(targetURL) ||
197
- (0, regex_parser_1.default)(redirect.pattern).test(`/${req.nextUrl.locale}${targetURL}`) ||
198
- matchedQueryString) && (redirect.locale ? redirect.locale.toLowerCase() === locale.toLowerCase() : true));
199
- })
200
- : undefined;
201
- });
202
209
  }
203
210
  /**
204
211
  * When a user clicks on a link generated by the Link component from next/link,
@@ -38,14 +38,15 @@ export const Link = forwardRef((props, ref) => {
38
38
  const isFileUrl = FILE_EXTENSION_MATCHER.test(href);
39
39
  // determine if a link is a route or not. File extensions are not routes and should not be pre-fetched.
40
40
  if (isMatching && !isFileUrl) {
41
- return (React.createElement(NextLink, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", locale: false, title: value.title, target: value.target, className: value.class }, htmlLinkProps, { ref: ref }),
41
+ return (React.createElement(NextLink, Object.assign({ href: { pathname: href, query: querystring, hash: anchor }, key: "link", locale: false, title: value.title, target: value.target, className: value.class, prefetch: props.prefetch }, htmlLinkProps, { ref: ref }),
42
42
  text,
43
43
  children));
44
44
  }
45
45
  }
46
- // prevent passing internalLinkMatcher as it is an invalid DOM element prop
46
+ // prevent passing internalLinkMatcher or prefetch as it is an invalid DOM element prop
47
47
  const reactLinkProps = Object.assign({}, props);
48
48
  delete reactLinkProps.internalLinkMatcher;
49
+ delete reactLinkProps.prefetch;
49
50
  return React.createElement(ReactLink, Object.assign({}, reactLinkProps, { ref: ref }));
50
51
  });
51
52
  Link.displayName = 'NextLink';
@@ -13,7 +13,7 @@ import React, { useEffect, useRef } from 'react';
13
13
  import PropTypes from 'prop-types';
14
14
  import { useRouter } from 'next/router';
15
15
  import { RichText as ReactRichText, RichTextPropTypes, } from '@sitecore-jss/sitecore-jss-react';
16
- const prefetched = {};
16
+ export const prefetched = {};
17
17
  export const RichText = (props) => {
18
18
  const { internalLinksSelector = 'a[href^="/"]', prefetchLinks = true, editable = true } = props, rest = __rest(props, ["internalLinksSelector", "prefetchLinks", "editable"]);
19
19
  const hasText = props.field && props.field.value;
@@ -21,7 +21,7 @@ export const RichText = (props) => {
21
21
  const router = useRouter();
22
22
  const richTextRef = useRef(null);
23
23
  useEffect(() => {
24
- // NOT IN EXPERIENCE EDITOR
24
+ // NOT IN EDIT MODE
25
25
  if (hasText && !isEditing) {
26
26
  initializeLinks();
27
27
  }
@@ -42,9 +42,21 @@ export const RichText = (props) => {
42
42
  internalLinks.forEach((link) => {
43
43
  if (link.target === '_blank')
44
44
  return;
45
- if (prefetchLinks && !prefetched[link.pathname]) {
45
+ const prefetch = () => {
46
46
  router.prefetch(link.pathname, undefined, { locale: false });
47
47
  prefetched[link.pathname] = true;
48
+ };
49
+ if (!prefetched[link.pathname] && prefetchLinks !== false) {
50
+ if (prefetchLinks === true) {
51
+ prefetch();
52
+ }
53
+ if (prefetchLinks === 'hover') {
54
+ const mouseOverHandler = () => {
55
+ prefetch();
56
+ link.removeEventListener('mouseover', mouseOverHandler);
57
+ };
58
+ link.addEventListener('mouseover', mouseOverHandler, false);
59
+ }
48
60
  }
49
61
  link.addEventListener('click', routeHandler, false);
50
62
  });
@@ -26,7 +26,84 @@ export class RedirectsMiddleware extends MiddlewareBase {
26
26
  constructor(config) {
27
27
  super(config);
28
28
  this.config = config;
29
- this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
29
+ // NOTE: we provide native fetch for compatibility on Next.js Edge Runtime
30
+ // (underlying default 'cross-fetch' is not currently compatible: https://github.com/lquixada/cross-fetch/issues/78)
31
+ this.redirectsService = new GraphQLRedirectsService(Object.assign(Object.assign({}, config), { fetch: fetch }));
32
+ this.locales = config.locales;
33
+ }
34
+ /**
35
+ * Gets the Next.js middleware handler with error handling
36
+ * @returns route handler
37
+ */
38
+ getHandler() {
39
+ return (req, res) => __awaiter(this, void 0, void 0, function* () {
40
+ try {
41
+ return this.processRedirectRequest(req, res);
42
+ }
43
+ catch (error) {
44
+ console.log('Redirect middleware failed:');
45
+ console.log(error);
46
+ return res || NextResponse.next();
47
+ }
48
+ });
49
+ }
50
+ /**
51
+ * Method returns RedirectInfo when matches
52
+ * @param {NextRequest} req request
53
+ * @param {string} siteName site name
54
+ * @returns Promise<RedirectInfo | undefined> The redirect info or undefined if no redirect is found
55
+ * @protected
56
+ */
57
+ getExistsRedirect(req, siteName) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const { pathname: targetURL, search: targetQS = '', locale } = this.normalizeUrl(req.nextUrl.clone());
60
+ const normalizedPath = targetURL.replace(/\/*$/gi, '');
61
+ const redirects = yield this.redirectsService.fetchRedirects(siteName);
62
+ const language = this.getLanguage(req);
63
+ const modifyRedirects = structuredClone(redirects);
64
+ let matchedQueryString;
65
+ return modifyRedirects.length
66
+ ? modifyRedirects.find((redirect) => {
67
+ var _a;
68
+ if (isRegexOrUrl(redirect.pattern) === 'url') {
69
+ const parseUrlPattern = redirect.pattern.endsWith('/')
70
+ ? redirect.pattern.slice(0, -1).split('?')
71
+ : redirect.pattern.split('?');
72
+ return ((parseUrlPattern[0] === normalizedPath ||
73
+ parseUrlPattern[0] === `/${locale}${normalizedPath}`) &&
74
+ areURLSearchParamsEqual(new URLSearchParams((_a = parseUrlPattern[1]) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQS)));
75
+ }
76
+ // Modify the redirect pattern to ignore the language prefix in the path
77
+ // And escapes non-special "?" characters in a string or regex.
78
+ redirect.pattern = escapeNonSpecialQuestionMarks(redirect.pattern.replace(new RegExp(`^[^]?/${language}/`, 'gi'), ''));
79
+ // Prepare the redirect pattern as a regular expression, making it more flexible for matching URLs
80
+ redirect.pattern = `/^\/${redirect.pattern
81
+ .replace(/^\/|\/$/g, '') // Removes leading and trailing slashes
82
+ .replace(/^\^\/|\/\$$/g, '') // Removes unnecessary start (^) and end ($) anchors
83
+ .replace(/^\^|\$$/g, '') // Further cleans up anchors
84
+ .replace(/\$\/gi$/g, '')}[\/]?$/i`; // Ensures the pattern allows an optional trailing slash
85
+ matchedQueryString = [
86
+ regexParser(redirect.pattern).test(`${normalizedPath}${targetQS}`),
87
+ regexParser(redirect.pattern).test(`/${locale}${normalizedPath}${targetQS}`),
88
+ ].some(Boolean)
89
+ ? targetQS
90
+ : undefined;
91
+ // Save the matched query string (if found) into the redirect object
92
+ redirect.matchedQueryString = matchedQueryString || '';
93
+ return (!!(regexParser(redirect.pattern).test(targetURL) ||
94
+ regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${targetURL}`) ||
95
+ matchedQueryString) && (redirect.locale ? redirect.locale.toLowerCase() === locale.toLowerCase() : true));
96
+ })
97
+ : undefined;
98
+ });
99
+ }
100
+ /**
101
+ * @param {NextRequest} req request
102
+ * @param {Response} res response
103
+ * @returns {Promise<NextResponse>} The redirect response.
104
+ */
105
+ processRedirectRequest(req, res) {
106
+ return __awaiter(this, void 0, void 0, function* () {
30
107
  const pathname = req.nextUrl.pathname;
31
108
  const language = this.getLanguage(req);
32
109
  const hostname = this.getHostHeader(req) || this.defaultHostname;
@@ -123,76 +200,6 @@ export class RedirectsMiddleware extends MiddlewareBase {
123
200
  });
124
201
  return response;
125
202
  });
126
- // NOTE: we provide native fetch for compatibility on Next.js Edge Runtime
127
- // (underlying default 'cross-fetch' is not currently compatible: https://github.com/lquixada/cross-fetch/issues/78)
128
- this.redirectsService = new GraphQLRedirectsService(Object.assign(Object.assign({}, config), { fetch: fetch }));
129
- this.locales = config.locales;
130
- }
131
- /**
132
- * Gets the Next.js middleware handler with error handling
133
- * @returns route handler
134
- */
135
- getHandler() {
136
- return (req, res) => __awaiter(this, void 0, void 0, function* () {
137
- try {
138
- return yield this.handler(req, res);
139
- }
140
- catch (error) {
141
- console.log('Redirect middleware failed:');
142
- console.log(error);
143
- return res || NextResponse.next();
144
- }
145
- });
146
- }
147
- /**
148
- * Method returns RedirectInfo when matches
149
- * @param {NextRequest} req request
150
- * @param {string} siteName site name
151
- * @returns Promise<RedirectInfo | undefined>
152
- * @private
153
- */
154
- getExistsRedirect(req, siteName) {
155
- return __awaiter(this, void 0, void 0, function* () {
156
- const { pathname: targetURL, search: targetQS = '', locale } = this.normalizeUrl(req.nextUrl.clone());
157
- const normalizedPath = targetURL.replace(/\/*$/gi, '');
158
- const redirects = yield this.redirectsService.fetchRedirects(siteName);
159
- const language = this.getLanguage(req);
160
- const modifyRedirects = structuredClone(redirects);
161
- let matchedQueryString;
162
- return modifyRedirects.length
163
- ? modifyRedirects.find((redirect) => {
164
- var _a;
165
- if (isRegexOrUrl(redirect.pattern) === 'url') {
166
- const parseUrlPattern = redirect.pattern.endsWith('/')
167
- ? redirect.pattern.slice(0, -1).split('?')
168
- : redirect.pattern.split('?');
169
- return ((parseUrlPattern[0] === normalizedPath ||
170
- parseUrlPattern[0] === `/${locale}${normalizedPath}`) &&
171
- areURLSearchParamsEqual(new URLSearchParams((_a = parseUrlPattern[1]) !== null && _a !== void 0 ? _a : ''), new URLSearchParams(targetQS)));
172
- }
173
- // Modify the redirect pattern to ignore the language prefix in the path
174
- // And escapes non-special "?" characters in a string or regex.
175
- redirect.pattern = escapeNonSpecialQuestionMarks(redirect.pattern.replace(new RegExp(`^[^]?/${language}/`, 'gi'), ''));
176
- // Prepare the redirect pattern as a regular expression, making it more flexible for matching URLs
177
- redirect.pattern = `/^\/${redirect.pattern
178
- .replace(/^\/|\/$/g, '') // Removes leading and trailing slashes
179
- .replace(/^\^\/|\/\$$/g, '') // Removes unnecessary start (^) and end ($) anchors
180
- .replace(/^\^|\$$/g, '') // Further cleans up anchors
181
- .replace(/\$\/gi$/g, '')}[\/]?$/i`; // Ensures the pattern allows an optional trailing slash
182
- matchedQueryString = [
183
- regexParser(redirect.pattern).test(`${normalizedPath}${targetQS}`),
184
- regexParser(redirect.pattern).test(`/${locale}${normalizedPath}${targetQS}`),
185
- ].some(Boolean)
186
- ? targetQS
187
- : undefined;
188
- // Save the matched query string (if found) into the redirect object
189
- redirect.matchedQueryString = matchedQueryString || '';
190
- return (!!(regexParser(redirect.pattern).test(targetURL) ||
191
- regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${targetURL}`) ||
192
- matchedQueryString) && (redirect.locale ? redirect.locale.toLowerCase() === locale.toLowerCase() : true));
193
- })
194
- : undefined;
195
- });
196
203
  }
197
204
  /**
198
205
  * When a user clicks on a link generated by the Link component from next/link,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "22.5.0",
3
+ "version": "22.5.1-canary.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -73,9 +73,9 @@
73
73
  "react-dom": "^18.2.0"
74
74
  },
75
75
  "dependencies": {
76
- "@sitecore-jss/sitecore-jss": "22.5.0",
77
- "@sitecore-jss/sitecore-jss-dev-tools": "22.5.0",
78
- "@sitecore-jss/sitecore-jss-react": "22.5.0",
76
+ "@sitecore-jss/sitecore-jss": "22.5.1-canary.2",
77
+ "@sitecore-jss/sitecore-jss-dev-tools": "22.5.1-canary.2",
78
+ "@sitecore-jss/sitecore-jss-react": "22.5.1-canary.2",
79
79
  "@vercel/kv": "^0.2.1",
80
80
  "prop-types": "^15.8.1",
81
81
  "regex-parser": "^2.2.11",
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "description": "",
85
85
  "types": "types/index.d.ts",
86
- "gitHead": "ed178d4ba29bd8654d44d154968cb3d0d0a44e4e",
86
+ "gitHead": "4dc3a8416e11756b8859b6e83ee62fc2e57fd391",
87
87
  "files": [
88
88
  "dist",
89
89
  "types",
@@ -1,5 +1,6 @@
1
1
  /// <reference types="@types/react" />
2
2
  import React from 'react';
3
+ import { LinkProps as NextLinkProps } from 'next/link';
3
4
  import { LinkProps as ReactLinkProps } from '@sitecore-jss/sitecore-jss-react';
4
5
  export type LinkProps = ReactLinkProps & {
5
6
  /**
@@ -7,5 +8,9 @@ export type LinkProps = ReactLinkProps & {
7
8
  * @default /^\//g
8
9
  */
9
10
  internalLinkMatcher?: RegExp;
11
+ /**
12
+ * Next.js Link prefetch.
13
+ */
14
+ prefetch?: NextLinkProps['prefetch'];
10
15
  };
11
16
  export declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
@@ -11,9 +11,15 @@ export type RichTextProps = ReactRichTextProps & {
11
11
  /**
12
12
  * Controls the prefetch of internal links. This can be beneficial if you have RichText fields
13
13
  * with large numbers of internal links in them.
14
+ * - `true` (default): The full route & its data will be prefetched.
15
+ * - `hover`: Prefetching will happen on hover.
16
+ * - `false`: Prefetching will not happen.
14
17
  * @default true
15
18
  */
16
- prefetchLinks?: boolean;
19
+ prefetchLinks?: boolean | 'hover';
20
+ };
21
+ export declare const prefetched: {
22
+ [cacheKey: string]: boolean;
17
23
  };
18
24
  export declare const RichText: {
19
25
  (props: RichTextProps): JSX.Element;
@@ -1,6 +1,9 @@
1
- import { GraphQLRedirectsServiceConfig } from '@sitecore-jss/sitecore-jss/site';
1
+ import { GraphQLRedirectsServiceConfig, RedirectInfo } from '@sitecore-jss/sitecore-jss/site';
2
2
  import { NextRequest, NextResponse } from 'next/server';
3
3
  import { MiddlewareBase, MiddlewareBaseConfig } from './middleware';
4
+ type RedirectResult = RedirectInfo & {
5
+ matchedQueryString?: string;
6
+ };
4
7
  /**
5
8
  * extended RedirectsMiddlewareConfig config type for RedirectsMiddleware
6
9
  */
@@ -28,15 +31,20 @@ export declare class RedirectsMiddleware extends MiddlewareBase {
28
31
  * @returns route handler
29
32
  */
30
33
  getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
31
- private handler;
32
34
  /**
33
35
  * Method returns RedirectInfo when matches
34
36
  * @param {NextRequest} req request
35
37
  * @param {string} siteName site name
36
- * @returns Promise<RedirectInfo | undefined>
37
- * @private
38
+ * @returns Promise<RedirectInfo | undefined> The redirect info or undefined if no redirect is found
39
+ * @protected
40
+ */
41
+ protected getExistsRedirect(req: NextRequest, siteName: string): Promise<RedirectResult | undefined>;
42
+ /**
43
+ * @param {NextRequest} req request
44
+ * @param {Response} res response
45
+ * @returns {Promise<NextResponse>} The redirect response.
38
46
  */
39
- private getExistsRedirect;
47
+ protected processRedirectRequest(req: NextRequest, res?: NextResponse): Promise<NextResponse>;
40
48
  /**
41
49
  * When a user clicks on a link generated by the Link component from next/link,
42
50
  * Next.js adds special parameters in the route called path.
@@ -55,3 +63,4 @@ export declare class RedirectsMiddleware extends MiddlewareBase {
55
63
  */
56
64
  private createRedirectResponse;
57
65
  }
66
+ export {};