@sitecore-jss/sitecore-jss-nextjs 21.1.0 → 21.2.0-canary.1

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,10 +1,10 @@
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
- [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/210/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
7
-
8
- [Documentation (XM Cloud)](https://doc.sitecore.com/xmc/en/developers/xm-cloud/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
9
-
10
- [API reference documentation](/ref-docs/sitecore-jss-nextjs/)
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 version 20.0.0 docs before release
7
+ -->
8
+ [Documentation](https://doc.sitecore.com/xp/en/developers/hd/190/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
9
+
10
+ [API reference documentation](/ref-docs/sitecore-jss-nextjs/).
@@ -44,6 +44,10 @@ const link_1 = __importDefault(require("next/link"));
44
44
  const sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
45
45
  exports.Link = (0, react_1.forwardRef)((props, ref) => {
46
46
  const { field, editable, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, htmlLinkProps = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
47
+ if (!field ||
48
+ (!field.editable && !field.value && !field.href)) {
49
+ return null;
50
+ }
47
51
  const value = (field.href
48
52
  ? field
49
53
  : field.value);
@@ -13,7 +13,7 @@ exports.EditingDataMiddleware = void 0;
13
13
  const editing_data_cache_1 = require("./editing-data-cache");
14
14
  const editing_data_1 = require("./editing-data");
15
15
  const editing_data_service_1 = require("./editing-data-service");
16
- const utils_1 = require("../utils");
16
+ const utils_1 = require("../utils/utils");
17
17
  /**
18
18
  * Middleware / handler for use in the editing data Next.js API dynamic route (e.g. '/api/editing/data/[key]')
19
19
  * which is required for Sitecore editing support.
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.editingDataService = exports.ServerlessEditingDataService = exports.BasicEditingDataService = exports.generateKey = exports.QUERY_PARAM_EDITING_SECRET = void 0;
13
13
  const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
14
14
  const editing_data_cache_1 = require("./editing-data-cache");
15
- const utils_1 = require("../utils");
15
+ const utils_1 = require("../utils/utils");
16
16
  exports.QUERY_PARAM_EDITING_SECRET = 'secret';
17
17
  /**
18
18
  * Unique key generator.
@@ -15,7 +15,7 @@ const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
15
15
  const layout_1 = require("@sitecore-jss/sitecore-jss/layout");
16
16
  const node_html_parser_1 = require("node-html-parser");
17
17
  const editing_data_service_1 = require("./editing-data-service");
18
- const utils_1 = require("../utils");
18
+ const utils_1 = require("../utils/utils");
19
19
  /**
20
20
  * Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
21
21
  * which is required for Sitecore editing support.
package/dist/cjs/index.js CHANGED
@@ -1,17 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Image = exports.NextImage = exports.EditingComponentPlaceholder = exports.Placeholder = exports.RichText = exports.Link = exports.getPublicUrl = exports.handleEditorFastRefresh = exports.useComponentProps = exports.ComponentPropsContext = exports.ComponentPropsReactContext = exports.normalizeSiteRewrite = exports.getSiteRewriteData = exports.getSiteRewrite = exports.GraphQLSiteInfoService = exports.SiteResolver = exports.GraphQLRobotsService = exports.GraphQLErrorPagesService = exports.GraphQLSitemapXmlService = exports.MultisiteGraphQLSitemapService = exports.GraphQLSitemapService = exports.DisconnectedSitemapService = exports.ComponentPropsService = exports.GraphQLRequestClient = exports.PosResolver = exports.CdpHelper = exports.normalizePersonalizedRewrite = exports.getPersonalizedRewriteData = exports.getPersonalizedRewrite = exports.personalizeLayout = exports.RestDictionaryService = exports.GraphQLDictionaryService = exports.trackingApi = exports.mediaApi = exports.EDITING_COMPONENT_ID = exports.EDITING_COMPONENT_PLACEHOLDER = exports.RenderingType = exports.getFieldValue = exports.getChildPlaceholder = exports.RestLayoutService = exports.GraphQLLayoutService = exports.LayoutServicePageState = exports.tryParseEnvValue = exports.resolveUrl = exports.resetEditorChromes = exports.isEditorActive = exports.enableDebug = exports.NativeDataFetcher = exports.AxiosDataFetcher = exports.constants = void 0;
4
- exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.VisitorIdentification = exports.File = exports.FEaaSComponent = exports.EditFrame = exports.DateField = exports.Text = void 0;
3
+ exports.Image = exports.NextImage = exports.EditingComponentPlaceholder = exports.Placeholder = exports.RichText = exports.Link = exports.useComponentProps = exports.ComponentPropsContext = exports.ComponentPropsReactContext = exports.normalizeSiteRewrite = exports.getSiteRewriteData = exports.getSiteRewrite = exports.GraphQLSiteInfoService = exports.SiteResolver = exports.GraphQLRobotsService = exports.GraphQLErrorPagesService = exports.GraphQLSitemapXmlService = exports.MultisiteGraphQLSitemapService = exports.GraphQLSitemapService = exports.DisconnectedSitemapService = exports.ComponentPropsService = exports.GraphQLRequestClient = exports.PosResolver = exports.CdpHelper = exports.normalizePersonalizedRewrite = exports.getPersonalizedRewriteData = exports.getPersonalizedRewrite = exports.personalizeLayout = exports.RestDictionaryService = exports.GraphQLDictionaryService = exports.trackingApi = exports.mediaApi = exports.EDITING_COMPONENT_ID = exports.EDITING_COMPONENT_PLACEHOLDER = exports.RenderingType = exports.getFieldValue = exports.getChildPlaceholder = exports.RestLayoutService = exports.GraphQLLayoutService = exports.LayoutServicePageState = exports.tryParseEnvValue = exports.resolveUrl = exports.resetEditorChromes = exports.isEditorActive = exports.getPublicUrl = exports.handleEditorFastRefresh = exports.enableDebug = exports.NativeDataFetcher = exports.AxiosDataFetcher = exports.constants = void 0;
4
+ exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.VisitorIdentification = exports.File = exports.getFEAASLibraryStylesheetLinks = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.EditFrame = exports.DateField = exports.Text = void 0;
5
5
  var sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
6
6
  Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return sitecore_jss_1.constants; } });
7
7
  Object.defineProperty(exports, "AxiosDataFetcher", { enumerable: true, get: function () { return sitecore_jss_1.AxiosDataFetcher; } });
8
8
  Object.defineProperty(exports, "NativeDataFetcher", { enumerable: true, get: function () { return sitecore_jss_1.NativeDataFetcher; } });
9
9
  Object.defineProperty(exports, "enableDebug", { enumerable: true, get: function () { return sitecore_jss_1.enableDebug; } });
10
- var utils_1 = require("@sitecore-jss/sitecore-jss/utils");
11
- Object.defineProperty(exports, "isEditorActive", { enumerable: true, get: function () { return utils_1.isEditorActive; } });
12
- Object.defineProperty(exports, "resetEditorChromes", { enumerable: true, get: function () { return utils_1.resetEditorChromes; } });
13
- Object.defineProperty(exports, "resolveUrl", { enumerable: true, get: function () { return utils_1.resolveUrl; } });
14
- Object.defineProperty(exports, "tryParseEnvValue", { enumerable: true, get: function () { return utils_1.tryParseEnvValue; } });
10
+ // we will remove the root exports for these later
11
+ // we cannot mark exports as deprected directly, so we're using this hack instead
12
+ const utils_1 = require("@sitecore-jss/sitecore-jss/utils");
13
+ const utils_2 = require("./utils");
14
+ /** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
15
+ const { isEditorActiveDep: isEditorActive, resetEditorChromesDep: resetEditorChromes, resolveUrlDep: resolveUrl, tryParseEnvValueDep: tryParseEnvValue, handleEditorFastRefreshDep: handleEditorFastRefresh, getPublicUrlDep: getPublicUrl, } = {
16
+ isEditorActiveDep: utils_1.isEditorActive,
17
+ resetEditorChromesDep: utils_1.resetEditorChromes,
18
+ resolveUrlDep: utils_1.resolveUrl,
19
+ tryParseEnvValueDep: utils_1.tryParseEnvValue,
20
+ handleEditorFastRefreshDep: utils_2.handleEditorFastRefresh,
21
+ getPublicUrlDep: utils_2.getPublicUrl,
22
+ };
23
+ exports.isEditorActive = isEditorActive;
24
+ exports.resetEditorChromes = resetEditorChromes;
25
+ exports.resolveUrl = resolveUrl;
26
+ exports.tryParseEnvValue = tryParseEnvValue;
27
+ exports.handleEditorFastRefresh = handleEditorFastRefresh;
28
+ exports.getPublicUrl = getPublicUrl;
15
29
  var layout_1 = require("@sitecore-jss/sitecore-jss/layout");
16
30
  Object.defineProperty(exports, "LayoutServicePageState", { enumerable: true, get: function () { return layout_1.LayoutServicePageState; } });
17
31
  Object.defineProperty(exports, "GraphQLLayoutService", { enumerable: true, get: function () { return layout_1.GraphQLLayoutService; } });
@@ -58,9 +72,6 @@ var ComponentPropsContext_1 = require("./components/ComponentPropsContext");
58
72
  Object.defineProperty(exports, "ComponentPropsReactContext", { enumerable: true, get: function () { return ComponentPropsContext_1.ComponentPropsReactContext; } });
59
73
  Object.defineProperty(exports, "ComponentPropsContext", { enumerable: true, get: function () { return ComponentPropsContext_1.ComponentPropsContext; } });
60
74
  Object.defineProperty(exports, "useComponentProps", { enumerable: true, get: function () { return ComponentPropsContext_1.useComponentProps; } });
61
- var utils_2 = require("./utils");
62
- Object.defineProperty(exports, "handleEditorFastRefresh", { enumerable: true, get: function () { return utils_2.handleEditorFastRefresh; } });
63
- Object.defineProperty(exports, "getPublicUrl", { enumerable: true, get: function () { return utils_2.getPublicUrl; } });
64
75
  var Link_1 = require("./components/Link");
65
76
  Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Link_1.Link; } });
66
77
  var RichText_1 = require("./components/RichText");
@@ -77,6 +88,8 @@ Object.defineProperty(exports, "Text", { enumerable: true, get: function () { re
77
88
  Object.defineProperty(exports, "DateField", { enumerable: true, get: function () { return sitecore_jss_react_1.DateField; } });
78
89
  Object.defineProperty(exports, "EditFrame", { enumerable: true, get: function () { return sitecore_jss_react_1.EditFrame; } });
79
90
  Object.defineProperty(exports, "FEaaSComponent", { enumerable: true, get: function () { return sitecore_jss_react_1.FEaaSComponent; } });
91
+ Object.defineProperty(exports, "fetchFEaaSComponentServerProps", { enumerable: true, get: function () { return sitecore_jss_react_1.fetchFEaaSComponentServerProps; } });
92
+ Object.defineProperty(exports, "getFEAASLibraryStylesheetLinks", { enumerable: true, get: function () { return sitecore_jss_react_1.getFEAASLibraryStylesheetLinks; } });
80
93
  Object.defineProperty(exports, "File", { enumerable: true, get: function () { return sitecore_jss_react_1.File; } });
81
94
  Object.defineProperty(exports, "VisitorIdentification", { enumerable: true, get: function () { return sitecore_jss_react_1.VisitorIdentification; } });
82
95
  Object.defineProperty(exports, "SitecoreContext", { enumerable: true, get: function () { return sitecore_jss_react_1.SitecoreContext; } });
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryParseEnvValue = exports.SiteResolver = exports.MultisiteMiddleware = exports.PersonalizeMiddleware = exports.RedirectsMiddleware = void 0;
3
+ exports.MultisiteMiddleware = exports.PersonalizeMiddleware = exports.RedirectsMiddleware = void 0;
4
4
  var redirects_middleware_1 = require("./redirects-middleware");
5
5
  Object.defineProperty(exports, "RedirectsMiddleware", { enumerable: true, get: function () { return redirects_middleware_1.RedirectsMiddleware; } });
6
6
  var personalize_middleware_1 = require("./personalize-middleware");
7
7
  Object.defineProperty(exports, "PersonalizeMiddleware", { enumerable: true, get: function () { return personalize_middleware_1.PersonalizeMiddleware; } });
8
8
  var multisite_middleware_1 = require("./multisite-middleware");
9
9
  Object.defineProperty(exports, "MultisiteMiddleware", { enumerable: true, get: function () { return multisite_middleware_1.MultisiteMiddleware; } });
10
- var site_1 = require("@sitecore-jss/sitecore-jss/site");
11
- Object.defineProperty(exports, "SiteResolver", { enumerable: true, get: function () { return site_1.SiteResolver; } });
12
- var utils_1 = require("@sitecore-jss/sitecore-jss/utils");
13
- Object.defineProperty(exports, "tryParseEnvValue", { enumerable: true, get: function () { return utils_1.tryParseEnvValue; } });
@@ -18,6 +18,7 @@ const server_1 = require("next/server");
18
18
  const site_1 = require("@sitecore-jss/sitecore-jss/site");
19
19
  const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
20
20
  const middleware_1 = require("./middleware");
21
+ const REGEXP_CONTEXT_SITE_LANG = new RegExp(/\$siteLang/, 'gi');
21
22
  /**
22
23
  * Middleware / handler fetches all redirects from Sitecore instance by grapqhl service
23
24
  * compares with current url and redirects to target url
@@ -55,6 +56,10 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
55
56
  sitecore_jss_1.debug.redirects('skipped (redirect does not exist)');
56
57
  return res || server_1.NextResponse.next();
57
58
  }
59
+ // Find context site language and replace token
60
+ if (REGEXP_CONTEXT_SITE_LANG.test(existsRedirect.target)) {
61
+ existsRedirect.target = existsRedirect.target.replace(REGEXP_CONTEXT_SITE_LANG, site.language);
62
+ }
58
63
  const url = req.nextUrl.clone();
59
64
  const absoluteUrlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
60
65
  if (absoluteUrlRegex.test(existsRedirect.target)) {
@@ -103,11 +108,20 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
103
108
  this.locales = config.locales;
104
109
  }
105
110
  /**
106
- * Gets the Next.js API route handler
111
+ * Gets the Next.js middleware handler with error handling
107
112
  * @returns route handler
108
113
  */
109
114
  getHandler() {
110
- return this.handler;
115
+ return (req, res) => __awaiter(this, void 0, void 0, function* () {
116
+ try {
117
+ return yield this.handler(req, res);
118
+ }
119
+ catch (error) {
120
+ console.log('Redirect middleware failed:');
121
+ console.log(error);
122
+ return res || server_1.NextResponse.next();
123
+ }
124
+ });
111
125
  }
112
126
  /**
113
127
  * Method returns RedirectInfo when matches
@@ -119,10 +133,16 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
119
133
  getExistsRedirect(req, siteName) {
120
134
  return __awaiter(this, void 0, void 0, function* () {
121
135
  const redirects = yield this.redirectsService.fetchRedirects(siteName);
136
+ const tragetURL = req.nextUrl.pathname;
137
+ const targetQS = `?${req.nextUrl.search || ''}`;
122
138
  return redirects.length
123
139
  ? redirects.find((redirect) => {
124
- return (((0, regex_parser_1.default)(redirect.pattern.toLowerCase()).test(req.nextUrl.pathname.toLowerCase()) ||
125
- (0, regex_parser_1.default)(redirect.pattern.toLowerCase()).test(`/${req.nextUrl.locale}${req.nextUrl.pathname}`.toLowerCase())) &&
140
+ const pattern = `/^/${redirect.pattern
141
+ .replace(/^\/|\/$/g, '')
142
+ .replace(/^\^|\$$/g, '')}$/gi`;
143
+ return (((0, regex_parser_1.default)(pattern).test(tragetURL) ||
144
+ (0, regex_parser_1.default)(pattern).test(`${tragetURL}${targetQS}`) ||
145
+ (0, regex_parser_1.default)(pattern).test(`/${req.nextUrl.locale}${tragetURL}`.toLowerCase())) &&
126
146
  (redirect.locale
127
147
  ? redirect.locale.toLowerCase() === req.nextUrl.locale.toLowerCase()
128
148
  : true));
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SiteResolver = void 0;
4
+ var site_1 = require("@sitecore-jss/sitecore-jss/site");
5
+ Object.defineProperty(exports, "SiteResolver", { enumerable: true, get: function () { return site_1.SiteResolver; } });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveUrl = exports.resetEditorChromes = exports.isEditorActive = exports.tryParseEnvValue = exports.handleEditorFastRefresh = exports.getPublicUrl = void 0;
4
+ var utils_1 = require("./utils");
5
+ Object.defineProperty(exports, "getPublicUrl", { enumerable: true, get: function () { return utils_1.getPublicUrl; } });
6
+ Object.defineProperty(exports, "handleEditorFastRefresh", { enumerable: true, get: function () { return utils_1.handleEditorFastRefresh; } });
7
+ var utils_2 = require("@sitecore-jss/sitecore-jss/utils");
8
+ Object.defineProperty(exports, "tryParseEnvValue", { enumerable: true, get: function () { return utils_2.tryParseEnvValue; } });
9
+ Object.defineProperty(exports, "isEditorActive", { enumerable: true, get: function () { return utils_2.isEditorActive; } });
10
+ Object.defineProperty(exports, "resetEditorChromes", { enumerable: true, get: function () { return utils_2.resetEditorChromes; } });
11
+ Object.defineProperty(exports, "resolveUrl", { enumerable: true, get: function () { return utils_2.resolveUrl; } });
@@ -15,6 +15,10 @@ import NextLink from 'next/link';
15
15
  import { Link as ReactLink, LinkPropTypes, } from '@sitecore-jss/sitecore-jss-react';
16
16
  export const Link = forwardRef((props, ref) => {
17
17
  const { field, editable, children, internalLinkMatcher = /^\//g, showLinkTextWithChildrenPresent } = props, htmlLinkProps = __rest(props, ["field", "editable", "children", "internalLinkMatcher", "showLinkTextWithChildrenPresent"]);
18
+ if (!field ||
19
+ (!field.editable && !field.value && !field.href)) {
20
+ return null;
21
+ }
18
22
  const value = (field.href
19
23
  ? field
20
24
  : field.value);
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { editingDataDiskCache } from './editing-data-cache';
11
11
  import { isEditingData } from './editing-data';
12
12
  import { QUERY_PARAM_EDITING_SECRET } from './editing-data-service';
13
- import { getJssEditingSecret } from '../utils';
13
+ import { getJssEditingSecret } from '../utils/utils';
14
14
  /**
15
15
  * Middleware / handler for use in the editing data Next.js API dynamic route (e.g. '/api/editing/data/[key]')
16
16
  * which is required for Sitecore editing support.
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { AxiosDataFetcher, debug } from '@sitecore-jss/sitecore-jss';
11
11
  import { editingDataDiskCache } from './editing-data-cache';
12
- import { getJssEditingSecret } from '../utils';
12
+ import { getJssEditingSecret } from '../utils/utils';
13
13
  export const QUERY_PARAM_EDITING_SECRET = 'secret';
14
14
  /**
15
15
  * Unique key generator.
@@ -12,7 +12,7 @@ import { AxiosDataFetcher, debug } from '@sitecore-jss/sitecore-jss';
12
12
  import { EDITING_COMPONENT_ID, RenderingType } from '@sitecore-jss/sitecore-jss/layout';
13
13
  import { parse } from 'node-html-parser';
14
14
  import { editingDataService, QUERY_PARAM_EDITING_SECRET, } from './editing-data-service';
15
- import { getJssEditingSecret } from '../utils';
15
+ import { getJssEditingSecret } from '../utils/utils';
16
16
  /**
17
17
  * Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
18
18
  * which is required for Sitecore editing support.
package/dist/esm/index.js CHANGED
@@ -1,5 +1,19 @@
1
1
  export { constants, AxiosDataFetcher, NativeDataFetcher, enableDebug, } from '@sitecore-jss/sitecore-jss';
2
- export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue, } from '@sitecore-jss/sitecore-jss/utils';
2
+ // we will remove the root exports for these later
3
+ // we cannot mark exports as deprected directly, so we're using this hack instead
4
+ import { isEditorActive as isEditorActiveDep, resetEditorChromes as resetEditorChromesDep, resolveUrl as resolveUrlDep, tryParseEnvValue as tryParseEnvValueDep, } from '@sitecore-jss/sitecore-jss/utils';
5
+ import { handleEditorFastRefresh as handleEditorFastRefreshDep, getPublicUrl as getPublicUrlDep, } from './utils';
6
+ /** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
7
+ const { isEditorActiveDep: isEditorActive, resetEditorChromesDep: resetEditorChromes, resolveUrlDep: resolveUrl, tryParseEnvValueDep: tryParseEnvValue, handleEditorFastRefreshDep: handleEditorFastRefresh, getPublicUrlDep: getPublicUrl, } = {
8
+ isEditorActiveDep,
9
+ resetEditorChromesDep,
10
+ resolveUrlDep,
11
+ tryParseEnvValueDep,
12
+ handleEditorFastRefreshDep,
13
+ getPublicUrlDep,
14
+ };
15
+ export { handleEditorFastRefresh, getPublicUrl };
16
+ export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue };
3
17
  export { LayoutServicePageState, GraphQLLayoutService, RestLayoutService, getChildPlaceholder, getFieldValue, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-jss/sitecore-jss/layout';
4
18
  export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
5
19
  export { trackingApi, } from '@sitecore-jss/sitecore-jss/tracking';
@@ -12,10 +26,9 @@ export { GraphQLSitemapService, } from './services/graphql-sitemap-service';
12
26
  export { MultisiteGraphQLSitemapService, } from './services/mutisite-graphql-sitemap-service';
13
27
  export { GraphQLSitemapXmlService, GraphQLErrorPagesService, GraphQLRobotsService, SiteResolver, GraphQLSiteInfoService, getSiteRewrite, getSiteRewriteData, normalizeSiteRewrite, } from '@sitecore-jss/sitecore-jss/site';
14
28
  export { ComponentPropsReactContext, ComponentPropsContext, useComponentProps, } from './components/ComponentPropsContext';
15
- export { handleEditorFastRefresh, getPublicUrl } from './utils';
16
29
  export { Link } from './components/Link';
17
30
  export { RichText } from './components/RichText';
18
31
  export { Placeholder } from './components/Placeholder';
19
32
  export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
20
33
  export { NextImage } from './components/NextImage';
21
- export { Image, Text, DateField, EditFrame, FEaaSComponent, File, VisitorIdentification, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, } from '@sitecore-jss/sitecore-jss-react';
34
+ export { Image, Text, DateField, EditFrame, FEaaSComponent, fetchFEaaSComponentServerProps, getFEAASLibraryStylesheetLinks, File, VisitorIdentification, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, } from '@sitecore-jss/sitecore-jss-react';
@@ -1,5 +1,3 @@
1
1
  export { RedirectsMiddleware } from './redirects-middleware';
2
2
  export { PersonalizeMiddleware } from './personalize-middleware';
3
3
  export { MultisiteMiddleware } from './multisite-middleware';
4
- export { SiteResolver } from '@sitecore-jss/sitecore-jss/site';
5
- export { tryParseEnvValue } from '@sitecore-jss/sitecore-jss/utils';
@@ -12,6 +12,7 @@ import { NextResponse } from 'next/server';
12
12
  import { GraphQLRedirectsService, REDIRECT_TYPE_301, REDIRECT_TYPE_302, REDIRECT_TYPE_SERVER_TRANSFER, } from '@sitecore-jss/sitecore-jss/site';
13
13
  import { debug } from '@sitecore-jss/sitecore-jss';
14
14
  import { MiddlewareBase } from './middleware';
15
+ const REGEXP_CONTEXT_SITE_LANG = new RegExp(/\$siteLang/, 'gi');
15
16
  /**
16
17
  * Middleware / handler fetches all redirects from Sitecore instance by grapqhl service
17
18
  * compares with current url and redirects to target url
@@ -49,6 +50,10 @@ export class RedirectsMiddleware extends MiddlewareBase {
49
50
  debug.redirects('skipped (redirect does not exist)');
50
51
  return res || NextResponse.next();
51
52
  }
53
+ // Find context site language and replace token
54
+ if (REGEXP_CONTEXT_SITE_LANG.test(existsRedirect.target)) {
55
+ existsRedirect.target = existsRedirect.target.replace(REGEXP_CONTEXT_SITE_LANG, site.language);
56
+ }
52
57
  const url = req.nextUrl.clone();
53
58
  const absoluteUrlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
54
59
  if (absoluteUrlRegex.test(existsRedirect.target)) {
@@ -97,11 +102,20 @@ export class RedirectsMiddleware extends MiddlewareBase {
97
102
  this.locales = config.locales;
98
103
  }
99
104
  /**
100
- * Gets the Next.js API route handler
105
+ * Gets the Next.js middleware handler with error handling
101
106
  * @returns route handler
102
107
  */
103
108
  getHandler() {
104
- return this.handler;
109
+ return (req, res) => __awaiter(this, void 0, void 0, function* () {
110
+ try {
111
+ return yield this.handler(req, res);
112
+ }
113
+ catch (error) {
114
+ console.log('Redirect middleware failed:');
115
+ console.log(error);
116
+ return res || NextResponse.next();
117
+ }
118
+ });
105
119
  }
106
120
  /**
107
121
  * Method returns RedirectInfo when matches
@@ -113,10 +127,16 @@ export class RedirectsMiddleware extends MiddlewareBase {
113
127
  getExistsRedirect(req, siteName) {
114
128
  return __awaiter(this, void 0, void 0, function* () {
115
129
  const redirects = yield this.redirectsService.fetchRedirects(siteName);
130
+ const tragetURL = req.nextUrl.pathname;
131
+ const targetQS = `?${req.nextUrl.search || ''}`;
116
132
  return redirects.length
117
133
  ? redirects.find((redirect) => {
118
- return ((regexParser(redirect.pattern.toLowerCase()).test(req.nextUrl.pathname.toLowerCase()) ||
119
- regexParser(redirect.pattern.toLowerCase()).test(`/${req.nextUrl.locale}${req.nextUrl.pathname}`.toLowerCase())) &&
134
+ const pattern = `/^/${redirect.pattern
135
+ .replace(/^\/|\/$/g, '')
136
+ .replace(/^\^|\$$/g, '')}$/gi`;
137
+ return ((regexParser(pattern).test(tragetURL) ||
138
+ regexParser(pattern).test(`${tragetURL}${targetQS}`) ||
139
+ regexParser(pattern).test(`/${req.nextUrl.locale}${tragetURL}`.toLowerCase())) &&
120
140
  (redirect.locale
121
141
  ? redirect.locale.toLowerCase() === req.nextUrl.locale.toLowerCase()
122
142
  : true));
@@ -0,0 +1 @@
1
+ export { SiteResolver } from '@sitecore-jss/sitecore-jss/site';
@@ -0,0 +1,2 @@
1
+ export { getPublicUrl, handleEditorFastRefresh } from './utils';
2
+ export { tryParseEnvValue, isEditorActive, resetEditorChromes, resolveUrl, } from '@sitecore-jss/sitecore-jss/utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "21.1.0",
3
+ "version": "21.2.0-canary.1",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -70,9 +70,9 @@
70
70
  "react-dom": "^18.2.0"
71
71
  },
72
72
  "dependencies": {
73
- "@sitecore-jss/sitecore-jss": "^21.1.0",
74
- "@sitecore-jss/sitecore-jss-dev-tools": "^21.1.0",
75
- "@sitecore-jss/sitecore-jss-react": "^21.1.0",
73
+ "@sitecore-jss/sitecore-jss": "^21.2.0-canary.1",
74
+ "@sitecore-jss/sitecore-jss-dev-tools": "^21.2.0-canary.1",
75
+ "@sitecore-jss/sitecore-jss-react": "^21.2.0-canary.1",
76
76
  "node-html-parser": "^6.1.4",
77
77
  "prop-types": "^15.8.1",
78
78
  "regex-parser": "^2.2.11",
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "description": "",
82
82
  "types": "types/index.d.ts",
83
- "gitHead": "b3e19b20d4ab6157e358c84dc78d16784b086858",
83
+ "gitHead": "dc42835a8d9241ab050938f45c795a795a1a190a",
84
84
  "files": [
85
85
  "dist",
86
86
  "types",
package/site.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './types/site/index';
package/site.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/cjs/site/index');
package/types/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
- export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, enableDebug, } from '@sitecore-jss/sitecore-jss';
2
- export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue, } from '@sitecore-jss/sitecore-jss/utils';
1
+ export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, } from '@sitecore-jss/sitecore-jss';
2
+ import { resolveUrl as resolveUrlDep } from '@sitecore-jss/sitecore-jss/utils';
3
+ /** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
4
+ declare const isEditorActive: () => boolean, resetEditorChromes: () => void, resolveUrl: typeof resolveUrlDep, tryParseEnvValue: <T>(envValue: string | undefined, defaultValue: T) => T, handleEditorFastRefresh: (forceReload?: boolean) => void, getPublicUrl: () => string;
5
+ export { handleEditorFastRefresh, getPublicUrl };
6
+ export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue };
3
7
  export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-jss/sitecore-jss/layout';
4
8
  export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
5
9
  export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
@@ -15,10 +19,9 @@ export { MultisiteGraphQLSitemapService, MultisiteGraphQLSitemapServiceConfig, }
15
19
  export { GraphQLSitemapXmlService, GraphQLSitemapXmlServiceConfig, GraphQLErrorPagesService, GraphQLErrorPagesServiceConfig, RobotsQueryResult, GraphQLRobotsService, GraphQLRobotsServiceConfig, ErrorPages, SiteInfo, SiteResolver, GraphQLSiteInfoService, GraphQLSiteInfoServiceConfig, getSiteRewrite, getSiteRewriteData, normalizeSiteRewrite, } from '@sitecore-jss/sitecore-jss/site';
16
20
  export { StaticPath } from './services/graphql-sitemap-service';
17
21
  export { ComponentPropsReactContext, ComponentPropsContextProps, ComponentPropsContext, useComponentProps, } from './components/ComponentPropsContext';
18
- export { handleEditorFastRefresh, getPublicUrl } from './utils';
19
22
  export { Link, LinkProps } from './components/Link';
20
23
  export { RichText, RichTextProps } from './components/RichText';
21
24
  export { Placeholder } from './components/Placeholder';
22
25
  export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
23
26
  export { NextImage } from './components/NextImage';
24
- export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
27
+ export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, getFEAASLibraryStylesheetLinks, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
@@ -1,5 +1,3 @@
1
1
  export { RedirectsMiddleware, RedirectsMiddlewareConfig } from './redirects-middleware';
2
2
  export { PersonalizeMiddleware, PersonalizeMiddlewareConfig } from './personalize-middleware';
3
3
  export { MultisiteMiddleware, MultisiteMiddlewareConfig } from './multisite-middleware';
4
- export { SiteResolver, SiteInfo } from '@sitecore-jss/sitecore-jss/site';
5
- export { tryParseEnvValue } from '@sitecore-jss/sitecore-jss/utils';
@@ -24,7 +24,7 @@ export declare class RedirectsMiddleware extends MiddlewareBase {
24
24
  */
25
25
  constructor(config: RedirectsMiddlewareConfig);
26
26
  /**
27
- * Gets the Next.js API route handler
27
+ * Gets the Next.js middleware handler with error handling
28
28
  * @returns route handler
29
29
  */
30
30
  getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
@@ -0,0 +1 @@
1
+ export { SiteResolver, SiteInfo } from '@sitecore-jss/sitecore-jss/site';
@@ -0,0 +1,2 @@
1
+ export { getPublicUrl, handleEditorFastRefresh } from './utils';
2
+ export { tryParseEnvValue, isEditorActive, resetEditorChromes, resolveUrl, } from '@sitecore-jss/sitecore-jss/utils';
package/utils.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './types/utils/index';
package/utils.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/cjs/utils/index');
File without changes
File without changes
File without changes