@sitecore-jss/sitecore-jss-nextjs 21.3.1 → 21.4.0-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 +202 -202
- package/README.md +11 -8
- package/dist/cjs/ComponentBuilder.js +3 -1
- package/dist/cjs/components/BYOCWrapper.js +47 -0
- package/dist/cjs/components/FEaaSWrapper.js +49 -0
- package/dist/cjs/editing/editing-render-middleware.js +5 -1
- package/dist/cjs/editing/index.js +3 -1
- package/dist/cjs/editing/vercel-editing-data-cache.js +48 -0
- package/dist/cjs/index.js +32 -2
- package/dist/cjs/middleware/index.js +3 -1
- package/dist/cjs/middleware/multisite-middleware.js +2 -1
- package/dist/cjs/middleware/personalize-middleware.js +6 -2
- package/dist/cjs/middleware/redirects-middleware.js +2 -1
- package/dist/cjs/services/component-props-service.js +2 -2
- package/dist/esm/ComponentBuilder.js +3 -1
- package/dist/esm/components/BYOCWrapper.js +42 -0
- package/dist/esm/components/FEaaSWrapper.js +44 -0
- package/dist/esm/editing/editing-render-middleware.js +5 -1
- package/dist/esm/editing/index.js +1 -0
- package/dist/esm/editing/vercel-editing-data-cache.js +44 -0
- package/dist/esm/index.js +6 -2
- package/dist/esm/middleware/index.js +1 -0
- package/dist/esm/middleware/multisite-middleware.js +2 -1
- package/dist/esm/middleware/personalize-middleware.js +6 -2
- package/dist/esm/middleware/redirects-middleware.js +2 -1
- package/dist/esm/services/component-props-service.js +2 -2
- package/package.json +6 -5
- package/types/ComponentBuilder.d.ts +1 -1
- package/types/components/BYOCWrapper.d.ts +19 -0
- package/types/components/FEaaSWrapper.d.ts +21 -0
- package/types/editing/index.d.ts +1 -0
- package/types/editing/vercel-editing-data-cache.d.ts +19 -0
- package/types/index.d.ts +7 -3
- package/types/middleware/index.d.ts +1 -0
- package/types/sharedTypes/component-props.d.ts +5 -1
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,9 +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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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/21/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
|
+
|
|
9
12
|
[API reference documentation](/ref-docs/sitecore-jss-nextjs/)
|
|
@@ -54,7 +54,9 @@ class ComponentBuilder {
|
|
|
54
54
|
if (exportName && exportName !== this.DEFAULT_EXPORT_NAME) {
|
|
55
55
|
return component[exportName];
|
|
56
56
|
}
|
|
57
|
-
return component.Default ||
|
|
57
|
+
return (component.Default ||
|
|
58
|
+
component.default ||
|
|
59
|
+
component);
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getServerSideProps = exports.getStaticProps = void 0;
|
|
13
|
+
const sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
|
|
14
|
+
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
15
|
+
/**
|
|
16
|
+
* This is a repackaged version of the React BYOCWrapper component with support for
|
|
17
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Will be called during SSG
|
|
21
|
+
* @param {ComponentRendering} rendering
|
|
22
|
+
* @returns {GetStaticPropsContext} context
|
|
23
|
+
*/
|
|
24
|
+
const getStaticProps = (rendering) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
if (process.env.JSS_MODE === sitecore_jss_1.constants.JSS_MODE.DISCONNECTED) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const params = rendering.params || {};
|
|
29
|
+
const result = yield (0, sitecore_jss_react_1.fetchBYOCComponentServerProps)(params);
|
|
30
|
+
return result;
|
|
31
|
+
});
|
|
32
|
+
exports.getStaticProps = getStaticProps;
|
|
33
|
+
/**
|
|
34
|
+
* Will be called during SSR
|
|
35
|
+
* @param {ComponentRendering} rendering
|
|
36
|
+
* @returns {GetStaticPropsContext} context
|
|
37
|
+
*/
|
|
38
|
+
const getServerSideProps = (rendering) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
if (process.env.JSS_MODE === sitecore_jss_1.constants.JSS_MODE.DISCONNECTED) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const params = rendering.params || {};
|
|
43
|
+
const result = yield (0, sitecore_jss_react_1.fetchBYOCComponentServerProps)(params);
|
|
44
|
+
return result;
|
|
45
|
+
});
|
|
46
|
+
exports.getServerSideProps = getServerSideProps;
|
|
47
|
+
exports.default = sitecore_jss_react_1.BYOCWrapper;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getServerSideProps = exports.getStaticProps = void 0;
|
|
13
|
+
const sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
|
|
14
|
+
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
15
|
+
/**
|
|
16
|
+
* This is a repackaged version of the React FEaaSWrapper component with support for
|
|
17
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Will be called during SSG
|
|
21
|
+
* @param {ComponentRendering} rendering
|
|
22
|
+
* @param {LayoutServiceData} layoutData
|
|
23
|
+
* @returns {GetStaticPropsContext} context
|
|
24
|
+
*/
|
|
25
|
+
const getStaticProps = (rendering, layoutData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
if (process.env.JSS_MODE === sitecore_jss_1.constants.JSS_MODE.DISCONNECTED) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const params = rendering.params || {};
|
|
30
|
+
const result = yield (0, sitecore_jss_react_1.fetchFEaaSComponentServerProps)(params, layoutData.sitecore.context.pageState);
|
|
31
|
+
return result;
|
|
32
|
+
});
|
|
33
|
+
exports.getStaticProps = getStaticProps;
|
|
34
|
+
/**
|
|
35
|
+
* Will be called during SSR
|
|
36
|
+
* @param {ComponentRendering} rendering
|
|
37
|
+
* @param {LayoutServiceData} layoutData
|
|
38
|
+
* @returns {GetStaticPropsContext} context
|
|
39
|
+
*/
|
|
40
|
+
const getServerSideProps = (rendering, layoutData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
if (process.env.JSS_MODE === sitecore_jss_1.constants.JSS_MODE.DISCONNECTED) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const params = rendering.params || {};
|
|
45
|
+
const result = yield (0, sitecore_jss_react_1.fetchFEaaSComponentServerProps)(params, layoutData.sitecore.context.pageState);
|
|
46
|
+
return result;
|
|
47
|
+
});
|
|
48
|
+
exports.getServerSideProps = getServerSideProps;
|
|
49
|
+
exports.default = sitecore_jss_react_1.FEaaSWrapper;
|
|
@@ -29,6 +29,7 @@ class EditingRenderMiddleware {
|
|
|
29
29
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
var _e, _f;
|
|
31
31
|
const { method, query, body, headers } = req;
|
|
32
|
+
const startTimestamp = Date.now();
|
|
32
33
|
sitecore_jss_1.debug.editing('editing render middleware start: %o', {
|
|
33
34
|
method,
|
|
34
35
|
query,
|
|
@@ -104,7 +105,10 @@ class EditingRenderMiddleware {
|
|
|
104
105
|
}
|
|
105
106
|
const body = { html };
|
|
106
107
|
// Return expected JSON result
|
|
107
|
-
sitecore_jss_1.debug.editing('editing render middleware end: %o',
|
|
108
|
+
sitecore_jss_1.debug.editing('editing render middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
109
|
+
status: 200,
|
|
110
|
+
body,
|
|
111
|
+
});
|
|
108
112
|
res.status(200).json(body);
|
|
109
113
|
}
|
|
110
114
|
catch (err) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.editingDataService = exports.ServerlessEditingDataService = exports.BasicEditingDataService = exports.EditingRenderMiddleware = exports.EditingDataMiddleware = exports.EditingDataDiskCache = void 0;
|
|
3
|
+
exports.VercelEditingDataCache = exports.editingDataService = exports.ServerlessEditingDataService = exports.BasicEditingDataService = exports.EditingRenderMiddleware = exports.EditingDataMiddleware = exports.EditingDataDiskCache = void 0;
|
|
4
4
|
var editing_data_cache_1 = require("./editing-data-cache");
|
|
5
5
|
Object.defineProperty(exports, "EditingDataDiskCache", { enumerable: true, get: function () { return editing_data_cache_1.EditingDataDiskCache; } });
|
|
6
6
|
var editing_data_middleware_1 = require("./editing-data-middleware");
|
|
@@ -11,3 +11,5 @@ var editing_data_service_1 = require("./editing-data-service");
|
|
|
11
11
|
Object.defineProperty(exports, "BasicEditingDataService", { enumerable: true, get: function () { return editing_data_service_1.BasicEditingDataService; } });
|
|
12
12
|
Object.defineProperty(exports, "ServerlessEditingDataService", { enumerable: true, get: function () { return editing_data_service_1.ServerlessEditingDataService; } });
|
|
13
13
|
Object.defineProperty(exports, "editingDataService", { enumerable: true, get: function () { return editing_data_service_1.editingDataService; } });
|
|
14
|
+
var vercel_editing_data_cache_1 = require("./vercel-editing-data-cache");
|
|
15
|
+
Object.defineProperty(exports, "VercelEditingDataCache", { enumerable: true, get: function () { return vercel_editing_data_cache_1.VercelEditingDataCache; } });
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VercelEditingDataCache = void 0;
|
|
4
|
+
const kv_1 = require("@vercel/kv");
|
|
5
|
+
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
6
|
+
/**
|
|
7
|
+
* Implementation of editing cache for Vercel deployments
|
|
8
|
+
* Uses Vercel KV database and client to store data
|
|
9
|
+
* Set TTL for cache data in constructor (default: 60 seconds)
|
|
10
|
+
*/
|
|
11
|
+
class VercelEditingDataCache {
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} redisUrl KV endpoint URL. Usually stored in process.env.KV_REST_API_URL
|
|
14
|
+
* @param {string} redisToken KV endpoint tokem. Usually stored in process.env.KV_REST_API_TOKEN
|
|
15
|
+
*/
|
|
16
|
+
constructor(redisUrl, redisToken) {
|
|
17
|
+
this.defaultTtl = 120;
|
|
18
|
+
if (!redisUrl || !redisToken) {
|
|
19
|
+
throw Error('API URL or token are missing, ensure you have set the KV or Upstash storage correctly.');
|
|
20
|
+
}
|
|
21
|
+
this.redisCache = (0, kv_1.createClient)({
|
|
22
|
+
url: redisUrl,
|
|
23
|
+
token: redisToken,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
set(key, editingData) {
|
|
27
|
+
sitecore_jss_1.debug.editing(`Putting editing data for ${key} into redis storage...`);
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
this.redisCache
|
|
30
|
+
.set(key, JSON.stringify(editingData), { ex: this.defaultTtl })
|
|
31
|
+
.then(() => resolve())
|
|
32
|
+
.catch((err) => reject(err));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
get(key) {
|
|
36
|
+
sitecore_jss_1.debug.editing(`Getting editing data for ${key} from redis storage...`);
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
this.redisCache
|
|
39
|
+
.get(key)
|
|
40
|
+
.then((entry) => {
|
|
41
|
+
const result = (entry || undefined);
|
|
42
|
+
this.redisCache.expire(key, 0).then(() => resolve(result));
|
|
43
|
+
})
|
|
44
|
+
.catch((err) => reject(err));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.VercelEditingDataCache = VercelEditingDataCache;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.VisitorIdentification = exports.File = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.EditFrame = exports.DateField = exports.Text = exports.Image = void 0;
|
|
26
|
+
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.debug = exports.enableDebug = exports.NativeDataFetcher = exports.AxiosDataFetcher = exports.constants = void 0;
|
|
27
|
+
exports.withDatasourceCheck = exports.withPlaceholder = exports.withEditorChromes = exports.useSitecoreContext = exports.withSitecoreContext = exports.SitecoreContextReactContext = exports.SitecoreContext = exports.VisitorIdentification = exports.File = exports.getFEAASLibraryStylesheetLinks = exports.BYOCComponent = exports.fetchFEaaSComponentServerProps = exports.FEaaSComponent = exports.EditFrame = exports.DateField = exports.Text = exports.Image = exports.ComponentBuilder = exports.BYOCWrapper = exports.FEaaSWrapper = void 0;
|
|
5
28
|
var sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
6
29
|
Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return sitecore_jss_1.constants; } });
|
|
7
30
|
Object.defineProperty(exports, "AxiosDataFetcher", { enumerable: true, get: function () { return sitecore_jss_1.AxiosDataFetcher; } });
|
|
8
31
|
Object.defineProperty(exports, "NativeDataFetcher", { enumerable: true, get: function () { return sitecore_jss_1.NativeDataFetcher; } });
|
|
9
32
|
Object.defineProperty(exports, "enableDebug", { enumerable: true, get: function () { return sitecore_jss_1.enableDebug; } });
|
|
33
|
+
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return sitecore_jss_1.debug; } });
|
|
10
34
|
// we will remove the root exports for these later
|
|
11
35
|
// we cannot mark exports as deprected directly, so we're using this hack instead
|
|
12
36
|
const utils_1 = require("@sitecore-jss/sitecore-jss/utils");
|
|
@@ -82,6 +106,10 @@ var EditingComponentPlaceholder_1 = require("./components/EditingComponentPlaceh
|
|
|
82
106
|
Object.defineProperty(exports, "EditingComponentPlaceholder", { enumerable: true, get: function () { return EditingComponentPlaceholder_1.EditingComponentPlaceholder; } });
|
|
83
107
|
var NextImage_1 = require("./components/NextImage");
|
|
84
108
|
Object.defineProperty(exports, "NextImage", { enumerable: true, get: function () { return NextImage_1.NextImage; } });
|
|
109
|
+
const FEaaSWrapper = __importStar(require("./components/FEaaSWrapper"));
|
|
110
|
+
exports.FEaaSWrapper = FEaaSWrapper;
|
|
111
|
+
const BYOCWrapper = __importStar(require("./components/BYOCWrapper"));
|
|
112
|
+
exports.BYOCWrapper = BYOCWrapper;
|
|
85
113
|
var ComponentBuilder_1 = require("./ComponentBuilder");
|
|
86
114
|
Object.defineProperty(exports, "ComponentBuilder", { enumerable: true, get: function () { return ComponentBuilder_1.ComponentBuilder; } });
|
|
87
115
|
var sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
|
|
@@ -91,6 +119,8 @@ Object.defineProperty(exports, "DateField", { enumerable: true, get: function ()
|
|
|
91
119
|
Object.defineProperty(exports, "EditFrame", { enumerable: true, get: function () { return sitecore_jss_react_1.EditFrame; } });
|
|
92
120
|
Object.defineProperty(exports, "FEaaSComponent", { enumerable: true, get: function () { return sitecore_jss_react_1.FEaaSComponent; } });
|
|
93
121
|
Object.defineProperty(exports, "fetchFEaaSComponentServerProps", { enumerable: true, get: function () { return sitecore_jss_react_1.fetchFEaaSComponentServerProps; } });
|
|
122
|
+
Object.defineProperty(exports, "BYOCComponent", { enumerable: true, get: function () { return sitecore_jss_react_1.BYOCComponent; } });
|
|
123
|
+
Object.defineProperty(exports, "getFEAASLibraryStylesheetLinks", { enumerable: true, get: function () { return sitecore_jss_react_1.getFEAASLibraryStylesheetLinks; } });
|
|
94
124
|
Object.defineProperty(exports, "File", { enumerable: true, get: function () { return sitecore_jss_react_1.File; } });
|
|
95
125
|
Object.defineProperty(exports, "VisitorIdentification", { enumerable: true, get: function () { return sitecore_jss_react_1.VisitorIdentification; } });
|
|
96
126
|
Object.defineProperty(exports, "SitecoreContext", { enumerable: true, get: function () { return sitecore_jss_react_1.SitecoreContext; } });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MultisiteMiddleware = exports.PersonalizeMiddleware = exports.RedirectsMiddleware = void 0;
|
|
3
|
+
exports.MultisiteMiddleware = exports.PersonalizeMiddleware = exports.RedirectsMiddleware = exports.debug = void 0;
|
|
4
|
+
var sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
5
|
+
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return sitecore_jss_1.debug; } });
|
|
4
6
|
var redirects_middleware_1 = require("./redirects-middleware");
|
|
5
7
|
Object.defineProperty(exports, "RedirectsMiddleware", { enumerable: true, get: function () { return redirects_middleware_1.RedirectsMiddleware; } });
|
|
6
8
|
var personalize_middleware_1 = require("./personalize-middleware");
|
|
@@ -29,6 +29,7 @@ class MultisiteMiddleware extends middleware_1.MiddlewareBase {
|
|
|
29
29
|
const pathname = req.nextUrl.pathname;
|
|
30
30
|
const language = this.getLanguage(req);
|
|
31
31
|
const hostname = this.getHostHeader(req) || this.defaultHostname;
|
|
32
|
+
const startTimestamp = Date.now();
|
|
32
33
|
sitecore_jss_1.debug.multisite('multisite middleware start: %o', {
|
|
33
34
|
pathname,
|
|
34
35
|
language,
|
|
@@ -58,7 +59,7 @@ class MultisiteMiddleware extends middleware_1.MiddlewareBase {
|
|
|
58
59
|
response.cookies.set(this.SITE_SYMBOL, siteName);
|
|
59
60
|
// Share rewrite path with following executed middlewares
|
|
60
61
|
response.headers.set('x-sc-rewrite', rewritePath);
|
|
61
|
-
sitecore_jss_1.debug.multisite('multisite middleware end: %o', {
|
|
62
|
+
sitecore_jss_1.debug.multisite('multisite middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
62
63
|
rewritePath,
|
|
63
64
|
siteName,
|
|
64
65
|
headers: this.extractDebugHeaders(response.headers),
|
|
@@ -28,6 +28,7 @@ class PersonalizeMiddleware extends middleware_1.MiddlewareBase {
|
|
|
28
28
|
const pathname = req.nextUrl.pathname;
|
|
29
29
|
const language = this.getLanguage(req);
|
|
30
30
|
const hostname = this.getHostHeader(req) || this.defaultHostname;
|
|
31
|
+
const startTimestamp = Date.now();
|
|
31
32
|
let browserId = this.getBrowserId(req);
|
|
32
33
|
sitecore_jss_1.debug.personalize('personalize middleware start: %o', {
|
|
33
34
|
pathname,
|
|
@@ -98,7 +99,7 @@ class PersonalizeMiddleware extends middleware_1.MiddlewareBase {
|
|
|
98
99
|
this.setBrowserId(response, browserId);
|
|
99
100
|
// Share site name with the following executed middlewares
|
|
100
101
|
response.cookies.set(this.SITE_SYMBOL, site.name);
|
|
101
|
-
sitecore_jss_1.debug.personalize('personalize middleware end: %o', {
|
|
102
|
+
sitecore_jss_1.debug.personalize('personalize middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
102
103
|
rewritePath,
|
|
103
104
|
browserId,
|
|
104
105
|
headers: this.extractDebugHeaders(response.headers),
|
|
@@ -149,7 +150,10 @@ class PersonalizeMiddleware extends middleware_1.MiddlewareBase {
|
|
|
149
150
|
}
|
|
150
151
|
getExperienceParams(req) {
|
|
151
152
|
return {
|
|
152
|
-
|
|
153
|
+
// It's expected that the header name "referer" is actually a misspelling of the word "referrer"
|
|
154
|
+
// req.referrer is used during fetching to determine the value of the Referer header of the request being made,
|
|
155
|
+
// used as a fallback
|
|
156
|
+
referrer: req.headers.get('referer') || req.referrer,
|
|
153
157
|
utm: {
|
|
154
158
|
campaign: req.nextUrl.searchParams.get('utm_campaign'),
|
|
155
159
|
content: req.nextUrl.searchParams.get('utm_content'),
|
|
@@ -35,6 +35,7 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
|
|
|
35
35
|
const language = this.getLanguage(req);
|
|
36
36
|
const hostname = this.getHostHeader(req) || this.defaultHostname;
|
|
37
37
|
let site;
|
|
38
|
+
const startTimestamp = Date.now();
|
|
38
39
|
sitecore_jss_1.debug.redirects('redirects middleware start: %o', {
|
|
39
40
|
pathname,
|
|
40
41
|
language,
|
|
@@ -94,7 +95,7 @@ class RedirectsMiddleware extends middleware_1.MiddlewareBase {
|
|
|
94
95
|
// Share site name with the following executed middlewares
|
|
95
96
|
// Don't need to set when middleware is disabled
|
|
96
97
|
site && response.cookies.set(this.SITE_SYMBOL, site.name);
|
|
97
|
-
sitecore_jss_1.debug.redirects('redirects middleware end: %o', {
|
|
98
|
+
sitecore_jss_1.debug.redirects('redirects middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
98
99
|
redirected: response.redirected,
|
|
99
100
|
status: response.status,
|
|
100
101
|
url: response.url,
|
|
@@ -128,11 +128,11 @@ class ComponentPropsService {
|
|
|
128
128
|
componentProps[uid] = result;
|
|
129
129
|
})
|
|
130
130
|
.catch((error) => {
|
|
131
|
-
const errLog = `Error during preload data for component ${uid}: ${error.message ||
|
|
132
|
-
error}`;
|
|
131
|
+
const errLog = `Error during preload data for component ${req.rendering.componentName} (${uid}): ${error.message || error}`;
|
|
133
132
|
console.error(chalk_1.default.red(errLog));
|
|
134
133
|
componentProps[uid] = {
|
|
135
134
|
error: error.message || errLog,
|
|
135
|
+
componentName: req.rendering.componentName,
|
|
136
136
|
};
|
|
137
137
|
});
|
|
138
138
|
});
|
|
@@ -51,7 +51,9 @@ export class ComponentBuilder {
|
|
|
51
51
|
if (exportName && exportName !== this.DEFAULT_EXPORT_NAME) {
|
|
52
52
|
return component[exportName];
|
|
53
53
|
}
|
|
54
|
-
return component.Default ||
|
|
54
|
+
return (component.Default ||
|
|
55
|
+
component.default ||
|
|
56
|
+
component);
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { BYOCWrapper, fetchBYOCComponentServerProps, } from '@sitecore-jss/sitecore-jss-react';
|
|
11
|
+
import { constants } from '@sitecore-jss/sitecore-jss';
|
|
12
|
+
/**
|
|
13
|
+
* This is a repackaged version of the React BYOCWrapper component with support for
|
|
14
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Will be called during SSG
|
|
18
|
+
* @param {ComponentRendering} rendering
|
|
19
|
+
* @returns {GetStaticPropsContext} context
|
|
20
|
+
*/
|
|
21
|
+
export const getStaticProps = (rendering) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
if (process.env.JSS_MODE === constants.JSS_MODE.DISCONNECTED) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const params = rendering.params || {};
|
|
26
|
+
const result = yield fetchBYOCComponentServerProps(params);
|
|
27
|
+
return result;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Will be called during SSR
|
|
31
|
+
* @param {ComponentRendering} rendering
|
|
32
|
+
* @returns {GetStaticPropsContext} context
|
|
33
|
+
*/
|
|
34
|
+
export const getServerSideProps = (rendering) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
if (process.env.JSS_MODE === constants.JSS_MODE.DISCONNECTED) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const params = rendering.params || {};
|
|
39
|
+
const result = yield fetchBYOCComponentServerProps(params);
|
|
40
|
+
return result;
|
|
41
|
+
});
|
|
42
|
+
export default BYOCWrapper;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { FEaaSWrapper, fetchFEaaSComponentServerProps, } from '@sitecore-jss/sitecore-jss-react';
|
|
11
|
+
import { constants } from '@sitecore-jss/sitecore-jss';
|
|
12
|
+
/**
|
|
13
|
+
* This is a repackaged version of the React FEaaSWrapper component with support for
|
|
14
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Will be called during SSG
|
|
18
|
+
* @param {ComponentRendering} rendering
|
|
19
|
+
* @param {LayoutServiceData} layoutData
|
|
20
|
+
* @returns {GetStaticPropsContext} context
|
|
21
|
+
*/
|
|
22
|
+
export const getStaticProps = (rendering, layoutData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
if (process.env.JSS_MODE === constants.JSS_MODE.DISCONNECTED) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const params = rendering.params || {};
|
|
27
|
+
const result = yield fetchFEaaSComponentServerProps(params, layoutData.sitecore.context.pageState);
|
|
28
|
+
return result;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Will be called during SSR
|
|
32
|
+
* @param {ComponentRendering} rendering
|
|
33
|
+
* @param {LayoutServiceData} layoutData
|
|
34
|
+
* @returns {GetStaticPropsContext} context
|
|
35
|
+
*/
|
|
36
|
+
export const getServerSideProps = (rendering, layoutData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
if (process.env.JSS_MODE === constants.JSS_MODE.DISCONNECTED) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const params = rendering.params || {};
|
|
41
|
+
const result = yield fetchFEaaSComponentServerProps(params, layoutData.sitecore.context.pageState);
|
|
42
|
+
return result;
|
|
43
|
+
});
|
|
44
|
+
export default FEaaSWrapper;
|
|
@@ -26,6 +26,7 @@ export class EditingRenderMiddleware {
|
|
|
26
26
|
this.handler = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
var _e, _f;
|
|
28
28
|
const { method, query, body, headers } = req;
|
|
29
|
+
const startTimestamp = Date.now();
|
|
29
30
|
debug.editing('editing render middleware start: %o', {
|
|
30
31
|
method,
|
|
31
32
|
query,
|
|
@@ -101,7 +102,10 @@ export class EditingRenderMiddleware {
|
|
|
101
102
|
}
|
|
102
103
|
const body = { html };
|
|
103
104
|
// Return expected JSON result
|
|
104
|
-
debug.editing('editing render middleware end: %o',
|
|
105
|
+
debug.editing('editing render middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
106
|
+
status: 200,
|
|
107
|
+
body,
|
|
108
|
+
});
|
|
105
109
|
res.status(200).json(body);
|
|
106
110
|
}
|
|
107
111
|
catch (err) {
|
|
@@ -2,3 +2,4 @@ export { EditingDataDiskCache } from './editing-data-cache';
|
|
|
2
2
|
export { EditingDataMiddleware } from './editing-data-middleware';
|
|
3
3
|
export { EditingRenderMiddleware, } from './editing-render-middleware';
|
|
4
4
|
export { BasicEditingDataService, ServerlessEditingDataService, editingDataService, } from './editing-data-service';
|
|
5
|
+
export { VercelEditingDataCache } from './vercel-editing-data-cache';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createClient } from '@vercel/kv';
|
|
2
|
+
import { debug } from '@sitecore-jss/sitecore-jss';
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of editing cache for Vercel deployments
|
|
5
|
+
* Uses Vercel KV database and client to store data
|
|
6
|
+
* Set TTL for cache data in constructor (default: 60 seconds)
|
|
7
|
+
*/
|
|
8
|
+
export class VercelEditingDataCache {
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} redisUrl KV endpoint URL. Usually stored in process.env.KV_REST_API_URL
|
|
11
|
+
* @param {string} redisToken KV endpoint tokem. Usually stored in process.env.KV_REST_API_TOKEN
|
|
12
|
+
*/
|
|
13
|
+
constructor(redisUrl, redisToken) {
|
|
14
|
+
this.defaultTtl = 120;
|
|
15
|
+
if (!redisUrl || !redisToken) {
|
|
16
|
+
throw Error('API URL or token are missing, ensure you have set the KV or Upstash storage correctly.');
|
|
17
|
+
}
|
|
18
|
+
this.redisCache = createClient({
|
|
19
|
+
url: redisUrl,
|
|
20
|
+
token: redisToken,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
set(key, editingData) {
|
|
24
|
+
debug.editing(`Putting editing data for ${key} into redis storage...`);
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
this.redisCache
|
|
27
|
+
.set(key, JSON.stringify(editingData), { ex: this.defaultTtl })
|
|
28
|
+
.then(() => resolve())
|
|
29
|
+
.catch((err) => reject(err));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
get(key) {
|
|
33
|
+
debug.editing(`Getting editing data for ${key} from redis storage...`);
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
this.redisCache
|
|
36
|
+
.get(key)
|
|
37
|
+
.then((entry) => {
|
|
38
|
+
const result = (entry || undefined);
|
|
39
|
+
this.redisCache.expire(key, 0).then(() => resolve(result));
|
|
40
|
+
})
|
|
41
|
+
.catch((err) => reject(err));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { constants, AxiosDataFetcher, NativeDataFetcher, enableDebug, } from '@sitecore-jss/sitecore-jss';
|
|
1
|
+
export { constants, AxiosDataFetcher, NativeDataFetcher, enableDebug, debug, } from '@sitecore-jss/sitecore-jss';
|
|
2
2
|
// we will remove the root exports for these later
|
|
3
3
|
// we cannot mark exports as deprected directly, so we're using this hack instead
|
|
4
4
|
import { isEditorActive as isEditorActiveDep, resetEditorChromes as resetEditorChromesDep, resolveUrl as resolveUrlDep, tryParseEnvValue as tryParseEnvValueDep, } from '@sitecore-jss/sitecore-jss/utils';
|
|
@@ -31,5 +31,9 @@ export { RichText } from './components/RichText';
|
|
|
31
31
|
export { Placeholder } from './components/Placeholder';
|
|
32
32
|
export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
|
|
33
33
|
export { NextImage } from './components/NextImage';
|
|
34
|
+
import * as FEaaSWrapper from './components/FEaaSWrapper';
|
|
35
|
+
import * as BYOCWrapper from './components/BYOCWrapper';
|
|
36
|
+
export { FEaaSWrapper };
|
|
37
|
+
export { BYOCWrapper };
|
|
34
38
|
export { ComponentBuilder } from './ComponentBuilder';
|
|
35
|
-
export { Image, Text, DateField, EditFrame, FEaaSComponent, fetchFEaaSComponentServerProps, File, VisitorIdentification, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, } from '@sitecore-jss/sitecore-jss-react';
|
|
39
|
+
export { Image, Text, DateField, EditFrame, FEaaSComponent, fetchFEaaSComponentServerProps, BYOCComponent, getFEAASLibraryStylesheetLinks, File, VisitorIdentification, SitecoreContext, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, } from '@sitecore-jss/sitecore-jss-react';
|
|
@@ -26,6 +26,7 @@ export class MultisiteMiddleware extends MiddlewareBase {
|
|
|
26
26
|
const pathname = req.nextUrl.pathname;
|
|
27
27
|
const language = this.getLanguage(req);
|
|
28
28
|
const hostname = this.getHostHeader(req) || this.defaultHostname;
|
|
29
|
+
const startTimestamp = Date.now();
|
|
29
30
|
debug.multisite('multisite middleware start: %o', {
|
|
30
31
|
pathname,
|
|
31
32
|
language,
|
|
@@ -55,7 +56,7 @@ export class MultisiteMiddleware extends MiddlewareBase {
|
|
|
55
56
|
response.cookies.set(this.SITE_SYMBOL, siteName);
|
|
56
57
|
// Share rewrite path with following executed middlewares
|
|
57
58
|
response.headers.set('x-sc-rewrite', rewritePath);
|
|
58
|
-
debug.multisite('multisite middleware end: %o', {
|
|
59
|
+
debug.multisite('multisite middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
59
60
|
rewritePath,
|
|
60
61
|
siteName,
|
|
61
62
|
headers: this.extractDebugHeaders(response.headers),
|
|
@@ -25,6 +25,7 @@ export class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
25
25
|
const pathname = req.nextUrl.pathname;
|
|
26
26
|
const language = this.getLanguage(req);
|
|
27
27
|
const hostname = this.getHostHeader(req) || this.defaultHostname;
|
|
28
|
+
const startTimestamp = Date.now();
|
|
28
29
|
let browserId = this.getBrowserId(req);
|
|
29
30
|
debug.personalize('personalize middleware start: %o', {
|
|
30
31
|
pathname,
|
|
@@ -95,7 +96,7 @@ export class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
95
96
|
this.setBrowserId(response, browserId);
|
|
96
97
|
// Share site name with the following executed middlewares
|
|
97
98
|
response.cookies.set(this.SITE_SYMBOL, site.name);
|
|
98
|
-
debug.personalize('personalize middleware end: %o', {
|
|
99
|
+
debug.personalize('personalize middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
99
100
|
rewritePath,
|
|
100
101
|
browserId,
|
|
101
102
|
headers: this.extractDebugHeaders(response.headers),
|
|
@@ -146,7 +147,10 @@ export class PersonalizeMiddleware extends MiddlewareBase {
|
|
|
146
147
|
}
|
|
147
148
|
getExperienceParams(req) {
|
|
148
149
|
return {
|
|
149
|
-
|
|
150
|
+
// It's expected that the header name "referer" is actually a misspelling of the word "referrer"
|
|
151
|
+
// req.referrer is used during fetching to determine the value of the Referer header of the request being made,
|
|
152
|
+
// used as a fallback
|
|
153
|
+
referrer: req.headers.get('referer') || req.referrer,
|
|
150
154
|
utm: {
|
|
151
155
|
campaign: req.nextUrl.searchParams.get('utm_campaign'),
|
|
152
156
|
content: req.nextUrl.searchParams.get('utm_content'),
|
|
@@ -29,6 +29,7 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
29
29
|
const language = this.getLanguage(req);
|
|
30
30
|
const hostname = this.getHostHeader(req) || this.defaultHostname;
|
|
31
31
|
let site;
|
|
32
|
+
const startTimestamp = Date.now();
|
|
32
33
|
debug.redirects('redirects middleware start: %o', {
|
|
33
34
|
pathname,
|
|
34
35
|
language,
|
|
@@ -88,7 +89,7 @@ export class RedirectsMiddleware extends MiddlewareBase {
|
|
|
88
89
|
// Share site name with the following executed middlewares
|
|
89
90
|
// Don't need to set when middleware is disabled
|
|
90
91
|
site && response.cookies.set(this.SITE_SYMBOL, site.name);
|
|
91
|
-
debug.redirects('redirects middleware end: %o', {
|
|
92
|
+
debug.redirects('redirects middleware end in %dms: %o', Date.now() - startTimestamp, {
|
|
92
93
|
redirected: response.redirected,
|
|
93
94
|
status: response.status,
|
|
94
95
|
url: response.url,
|
|
@@ -122,11 +122,11 @@ export class ComponentPropsService {
|
|
|
122
122
|
componentProps[uid] = result;
|
|
123
123
|
})
|
|
124
124
|
.catch((error) => {
|
|
125
|
-
const errLog = `Error during preload data for component ${uid}: ${error.message ||
|
|
126
|
-
error}`;
|
|
125
|
+
const errLog = `Error during preload data for component ${req.rendering.componentName} (${uid}): ${error.message || error}`;
|
|
127
126
|
console.error(chalk.red(errLog));
|
|
128
127
|
componentProps[uid] = {
|
|
129
128
|
error: error.message || errLog,
|
|
129
|
+
componentName: req.rendering.componentName,
|
|
130
130
|
};
|
|
131
131
|
});
|
|
132
132
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.4.0-canary.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -70,9 +70,10 @@
|
|
|
70
70
|
"react-dom": "^18.2.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@sitecore-jss/sitecore-jss": "21.
|
|
74
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "21.
|
|
75
|
-
"@sitecore-jss/sitecore-jss-react": "21.
|
|
73
|
+
"@sitecore-jss/sitecore-jss": "^21.4.0-canary.2",
|
|
74
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^21.4.0-canary.2",
|
|
75
|
+
"@sitecore-jss/sitecore-jss-react": "^21.4.0-canary.2",
|
|
76
|
+
"@vercel/kv": "^0.2.1",
|
|
76
77
|
"node-html-parser": "^6.1.4",
|
|
77
78
|
"prop-types": "^15.8.1",
|
|
78
79
|
"regex-parser": "^2.2.11",
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
},
|
|
81
82
|
"description": "",
|
|
82
83
|
"types": "types/index.d.ts",
|
|
83
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "30d79c092ae7bee91d3f6a1a480a89c76e5b262c",
|
|
84
85
|
"files": [
|
|
85
86
|
"dist",
|
|
86
87
|
"types",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BYOCWrapper } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
+
import { GetStaticComponentProps, GetServerSideComponentProps } from '../sharedTypes/component-props';
|
|
3
|
+
/**
|
|
4
|
+
* This is a repackaged version of the React BYOCWrapper component with support for
|
|
5
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Will be called during SSG
|
|
9
|
+
* @param {ComponentRendering} rendering
|
|
10
|
+
* @returns {GetStaticPropsContext} context
|
|
11
|
+
*/
|
|
12
|
+
export declare const getStaticProps: GetStaticComponentProps;
|
|
13
|
+
/**
|
|
14
|
+
* Will be called during SSR
|
|
15
|
+
* @param {ComponentRendering} rendering
|
|
16
|
+
* @returns {GetStaticPropsContext} context
|
|
17
|
+
*/
|
|
18
|
+
export declare const getServerSideProps: GetServerSideComponentProps;
|
|
19
|
+
export default BYOCWrapper;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FEaaSWrapper } from '@sitecore-jss/sitecore-jss-react';
|
|
2
|
+
import { GetStaticComponentProps, GetServerSideComponentProps } from '../sharedTypes/component-props';
|
|
3
|
+
/**
|
|
4
|
+
* This is a repackaged version of the React FEaaSWrapper component with support for
|
|
5
|
+
* server rendering in Next.js (using component-level data-fetching feature of JSS).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Will be called during SSG
|
|
9
|
+
* @param {ComponentRendering} rendering
|
|
10
|
+
* @param {LayoutServiceData} layoutData
|
|
11
|
+
* @returns {GetStaticPropsContext} context
|
|
12
|
+
*/
|
|
13
|
+
export declare const getStaticProps: GetStaticComponentProps;
|
|
14
|
+
/**
|
|
15
|
+
* Will be called during SSR
|
|
16
|
+
* @param {ComponentRendering} rendering
|
|
17
|
+
* @param {LayoutServiceData} layoutData
|
|
18
|
+
* @returns {GetStaticPropsContext} context
|
|
19
|
+
*/
|
|
20
|
+
export declare const getServerSideProps: GetServerSideComponentProps;
|
|
21
|
+
export default FEaaSWrapper;
|
package/types/editing/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { EditingDataCache, EditingDataDiskCache } from './editing-data-cache';
|
|
|
3
3
|
export { EditingDataMiddleware, EditingDataMiddlewareConfig } from './editing-data-middleware';
|
|
4
4
|
export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, } from './editing-render-middleware';
|
|
5
5
|
export { EditingPreviewData, EditingDataService, BasicEditingDataService, BasicEditingDataServiceConfig, ServerlessEditingDataService, ServerlessEditingDataServiceConfig, editingDataService, } from './editing-data-service';
|
|
6
|
+
export { VercelEditingDataCache } from './vercel-editing-data-cache';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VercelKV } from '@vercel/kv';
|
|
2
|
+
import { EditingDataCache } from './editing-data-cache';
|
|
3
|
+
import { EditingData } from './editing-data';
|
|
4
|
+
/**
|
|
5
|
+
* Implementation of editing cache for Vercel deployments
|
|
6
|
+
* Uses Vercel KV database and client to store data
|
|
7
|
+
* Set TTL for cache data in constructor (default: 60 seconds)
|
|
8
|
+
*/
|
|
9
|
+
export declare class VercelEditingDataCache implements EditingDataCache {
|
|
10
|
+
protected redisCache: VercelKV;
|
|
11
|
+
private defaultTtl;
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} redisUrl KV endpoint URL. Usually stored in process.env.KV_REST_API_URL
|
|
14
|
+
* @param {string} redisToken KV endpoint tokem. Usually stored in process.env.KV_REST_API_TOKEN
|
|
15
|
+
*/
|
|
16
|
+
constructor(redisUrl: string | undefined, redisToken: string | undefined);
|
|
17
|
+
set(key: string, editingData: EditingData): Promise<void>;
|
|
18
|
+
get(key: string): Promise<EditingData | undefined>;
|
|
19
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, } from '@sitecore-jss/sitecore-jss';
|
|
1
|
+
export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, debug, } from '@sitecore-jss/sitecore-jss';
|
|
2
2
|
import { resolveUrl as resolveUrlDep } from '@sitecore-jss/sitecore-jss/utils';
|
|
3
3
|
/** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
|
|
4
4
|
declare const isEditorActive: () => boolean, resetEditorChromes: () => void, resolveUrl: typeof resolveUrlDep, tryParseEnvValue: <T>(envValue: string | undefined, defaultValue: T) => T, handleEditorFastRefresh: (forceReload?: boolean) => void, getPublicUrl: () => string;
|
|
@@ -10,7 +10,7 @@ export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, Ou
|
|
|
10
10
|
export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, RestDictionaryService, RestDictionaryServiceConfig, } from '@sitecore-jss/sitecore-jss/i18n';
|
|
11
11
|
export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, PosResolver, } from '@sitecore-jss/sitecore-jss/personalize';
|
|
12
12
|
export { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss';
|
|
13
|
-
export { ComponentPropsCollection, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
|
|
13
|
+
export { ComponentPropsCollection, ComponentPropsError, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
|
|
14
14
|
export { ModuleFactory, Module } from './sharedTypes/module-factory';
|
|
15
15
|
export { ComponentPropsService } from './services/component-props-service';
|
|
16
16
|
export { DisconnectedSitemapService } from './services/disconnected-sitemap-service';
|
|
@@ -24,5 +24,9 @@ export { RichText, RichTextProps } from './components/RichText';
|
|
|
24
24
|
export { Placeholder } from './components/Placeholder';
|
|
25
25
|
export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
|
|
26
26
|
export { NextImage } from './components/NextImage';
|
|
27
|
+
import * as FEaaSWrapper from './components/FEaaSWrapper';
|
|
28
|
+
import * as BYOCWrapper from './components/BYOCWrapper';
|
|
29
|
+
export { FEaaSWrapper };
|
|
30
|
+
export { BYOCWrapper };
|
|
27
31
|
export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
|
|
28
|
-
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
|
|
32
|
+
export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, 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,3 +1,4 @@
|
|
|
1
|
+
export { debug } from '@sitecore-jss/sitecore-jss';
|
|
1
2
|
export { RedirectsMiddleware, RedirectsMiddlewareConfig } from './redirects-middleware';
|
|
2
3
|
export { PersonalizeMiddleware, PersonalizeMiddlewareConfig } from './personalize-middleware';
|
|
3
4
|
export { MultisiteMiddleware, MultisiteMiddlewareConfig } from './multisite-middleware';
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
|
|
2
2
|
import { ComponentRendering, LayoutServiceData } from '@sitecore-jss/sitecore-jss/layout';
|
|
3
|
+
export type ComponentPropsError = {
|
|
4
|
+
error: string;
|
|
5
|
+
componentName: string;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Shape of component props storage
|
|
5
9
|
*/
|
|
6
10
|
export type ComponentPropsCollection = {
|
|
7
|
-
[componentUid: string]: unknown;
|
|
11
|
+
[componentUid: string]: unknown | ComponentPropsError;
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
10
14
|
* Type of side effect function which could be invoked on component level (getStaticProps/getServerSideProps)
|