@fecommunity/reactpress-template-hello-world 1.0.0-beta.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.next/build-manifest.json +35 -0
  2. package/.next/cache/webpack/client-development/0.pack +0 -0
  3. package/.next/cache/webpack/client-development/1.pack +0 -0
  4. package/.next/cache/webpack/client-development/index.pack +0 -0
  5. package/.next/cache/webpack/client-development/index.pack.old +0 -0
  6. package/.next/cache/webpack/client-development-fallback/0.pack +0 -0
  7. package/.next/cache/webpack/client-development-fallback/1.pack +0 -0
  8. package/.next/cache/webpack/client-development-fallback/index.pack +0 -0
  9. package/.next/cache/webpack/client-development-fallback/index.pack.old +0 -0
  10. package/.next/cache/webpack/server-development/0.pack +0 -0
  11. package/.next/cache/webpack/server-development/1.pack +0 -0
  12. package/.next/cache/webpack/server-development/2.pack +0 -0
  13. package/.next/cache/webpack/server-development/index.pack +0 -0
  14. package/.next/cache/webpack/server-development/index.pack.old +0 -0
  15. package/.next/fallback-build-manifest.json +27 -0
  16. package/.next/react-loadable-manifest.json +1 -0
  17. package/.next/server/_error.js +66 -0
  18. package/.next/server/pages/404.js +446 -126
  19. package/.next/server/pages/_app.js +43 -58
  20. package/.next/server/pages/_document.js +57 -731
  21. package/.next/server/pages/_error.js +29 -111
  22. package/.next/server/pages/index.js +1504 -260
  23. package/.next/server/pages-manifest.json +2 -4
  24. package/.next/server/webpack-runtime.js +13 -5
  25. package/.next/static/chunks/amp.js +961 -0
  26. package/.next/static/chunks/fallback/amp.js +961 -0
  27. package/.next/static/chunks/fallback/main.js +1266 -0
  28. package/.next/static/chunks/fallback/pages/_app.js +28 -0
  29. package/.next/static/chunks/fallback/pages/_error.js +28 -0
  30. package/.next/static/chunks/fallback/react-refresh.js +62 -0
  31. package/.next/static/chunks/fallback/webpack.js +1208 -0
  32. package/.next/static/chunks/main.js +1266 -0
  33. package/.next/static/chunks/pages/404.js +178 -0
  34. package/.next/static/chunks/pages/_app.js +28 -0
  35. package/.next/static/chunks/pages/_error.js +28 -0
  36. package/.next/static/chunks/polyfills.js +1 -0
  37. package/.next/static/chunks/react-refresh.js +62 -0
  38. package/.next/static/chunks/webpack.js +1220 -0
  39. package/.next/static/development/_buildManifest.js +1 -0
  40. package/.next/static/development/_ssgManifest.js +1 -0
  41. package/.next/static/webpack/82e97587a3709bd9.webpack.hot-update.json +1 -0
  42. package/.next/static/webpack/webpack.82e97587a3709bd9.hot-update.js +43 -0
  43. package/.next/trace +12 -0
  44. package/package.json +2 -2
  45. package/.next/routes-manifest.json +0 -1
  46. package/.next/server/chunks/402.js +0 -67
  47. package/.next/server/chunks/415.js +0 -32
  48. package/.next/server/chunks/843.js +0 -2759
  49. package/.next/server/chunks/990.js +0 -134
  50. package/.next/server/chunks/font-manifest.json +0 -1
  51. package/.next/server/font-manifest.json +0 -1
  52. package/.next/server/pages/404.js.nft.json +0 -1
  53. package/.next/server/pages/_app.js.nft.json +0 -1
  54. package/.next/server/pages/_document.js.nft.json +0 -1
  55. package/.next/server/pages/_error.js.nft.json +0 -1
  56. package/.next/server/pages/about.js +0 -450
  57. package/.next/server/pages/about.js.nft.json +0 -1
  58. package/.next/server/pages/index.js.nft.json +0 -1
  59. package/.next/server/pages/toolkit-demo.js +0 -574
  60. package/.next/server/pages/toolkit-demo.js.nft.json +0 -1
@@ -1,2759 +0,0 @@
1
- exports.id = 843;
2
- exports.ids = [843];
3
- exports.modules = {
4
-
5
- /***/ 5271:
6
- /***/ ((__unused_webpack_module, exports) => {
7
-
8
- "use strict";
9
- var __webpack_unused_export__;
10
-
11
- __webpack_unused_export__ = ({
12
- value: true
13
- });
14
- exports.Z = _extends;
15
- function _extends() {
16
- return extends_.apply(this, arguments);
17
- }
18
- function extends_() {
19
- extends_ = Object.assign || function(target) {
20
- for(var i = 1; i < arguments.length; i++){
21
- var source = arguments[i];
22
- for(var key in source){
23
- if (Object.prototype.hasOwnProperty.call(source, key)) {
24
- target[key] = source[key];
25
- }
26
- }
27
- }
28
- return target;
29
- };
30
- return extends_.apply(this, arguments);
31
- }
32
-
33
-
34
- /***/ }),
35
-
36
- /***/ 9371:
37
- /***/ ((__unused_webpack_module, exports) => {
38
-
39
- "use strict";
40
- var __webpack_unused_export__;
41
-
42
- __webpack_unused_export__ = ({
43
- value: true
44
- });
45
- exports.Z = _interopRequireWildcard;
46
- function _interopRequireWildcard(obj, nodeInterop) {
47
- if (!nodeInterop && obj && obj.__esModule) {
48
- return obj;
49
- }
50
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
51
- return {
52
- default: obj
53
- };
54
- }
55
- var cache = _getRequireWildcardCache(nodeInterop);
56
- if (cache && cache.has(obj)) {
57
- return cache.get(obj);
58
- }
59
- var newObj = {};
60
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
- for(var key in obj){
62
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
- if (desc && (desc.get || desc.set)) {
65
- Object.defineProperty(newObj, key, desc);
66
- } else {
67
- newObj[key] = obj[key];
68
- }
69
- }
70
- }
71
- newObj.default = obj;
72
- if (cache) {
73
- cache.set(obj, newObj);
74
- }
75
- return newObj;
76
- }
77
- function _getRequireWildcardCache(nodeInterop1) {
78
- if (typeof WeakMap !== "function") return null;
79
- var cacheBabelInterop = new WeakMap();
80
- var cacheNodeInterop = new WeakMap();
81
- return (_getRequireWildcardCache = function(nodeInterop) {
82
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
83
- })(nodeInterop1);
84
- }
85
-
86
-
87
- /***/ }),
88
-
89
- /***/ 5688:
90
- /***/ ((__unused_webpack_module, exports) => {
91
-
92
- "use strict";
93
- var __webpack_unused_export__;
94
-
95
- __webpack_unused_export__ = ({
96
- value: true
97
- });
98
- exports.Z = _objectWithoutPropertiesLoose;
99
- function _objectWithoutPropertiesLoose(source, excluded) {
100
- if (source == null) return {};
101
- var target = {};
102
- var sourceKeys = Object.keys(source);
103
- var key, i;
104
- for(i = 0; i < sourceKeys.length; i++){
105
- key = sourceKeys[i];
106
- if (excluded.indexOf(key) >= 0) continue;
107
- target[key] = source[key];
108
- }
109
- return target;
110
- }
111
-
112
-
113
- /***/ }),
114
-
115
- /***/ 7231:
116
- /***/ ((module, exports, __webpack_require__) => {
117
-
118
- "use strict";
119
-
120
- Object.defineProperty(exports, "__esModule", ({
121
- value: true
122
- }));
123
- exports.addBasePath = addBasePath;
124
- var _addPathPrefix = __webpack_require__(1751);
125
- var _normalizeTrailingSlash = __webpack_require__(7663);
126
- const basePath = false || "";
127
- function addBasePath(path, required) {
128
- if (false) {}
129
- return (0, _normalizeTrailingSlash).normalizePathTrailingSlash((0, _addPathPrefix).addPathPrefix(path, basePath));
130
- }
131
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
132
- Object.defineProperty(exports.default, "__esModule", {
133
- value: true
134
- });
135
- Object.assign(exports.default, exports);
136
- module.exports = exports.default;
137
- } //# sourceMappingURL=add-base-path.js.map
138
-
139
-
140
- /***/ }),
141
-
142
- /***/ 2916:
143
- /***/ ((module, exports, __webpack_require__) => {
144
-
145
- "use strict";
146
-
147
- Object.defineProperty(exports, "__esModule", ({
148
- value: true
149
- }));
150
- exports.addLocale = void 0;
151
- var _normalizeTrailingSlash = __webpack_require__(7663);
152
- const addLocale = (path, ...args)=>{
153
- if (false) {}
154
- return path;
155
- };
156
- exports.addLocale = addLocale;
157
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
158
- Object.defineProperty(exports.default, "__esModule", {
159
- value: true
160
- });
161
- Object.assign(exports.default, exports);
162
- module.exports = exports.default;
163
- } //# sourceMappingURL=add-locale.js.map
164
-
165
-
166
- /***/ }),
167
-
168
- /***/ 4165:
169
- /***/ ((module, exports) => {
170
-
171
- "use strict";
172
-
173
- Object.defineProperty(exports, "__esModule", ({
174
- value: true
175
- }));
176
- exports.detectDomainLocale = void 0;
177
- const detectDomainLocale = (...args)=>{
178
- if (false) {}
179
- };
180
- exports.detectDomainLocale = detectDomainLocale;
181
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
182
- Object.defineProperty(exports.default, "__esModule", {
183
- value: true
184
- });
185
- Object.assign(exports.default, exports);
186
- module.exports = exports.default;
187
- } //# sourceMappingURL=detect-domain-locale.js.map
188
-
189
-
190
- /***/ }),
191
-
192
- /***/ 4011:
193
- /***/ ((module, exports) => {
194
-
195
- "use strict";
196
-
197
- Object.defineProperty(exports, "__esModule", ({
198
- value: true
199
- }));
200
- exports.getDomainLocale = getDomainLocale;
201
- const basePath = (/* unused pure expression or super */ null && ( false || ""));
202
- function getDomainLocale(path, locale, locales, domainLocales) {
203
- if (false) {} else {
204
- return false;
205
- }
206
- }
207
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
208
- Object.defineProperty(exports.default, "__esModule", {
209
- value: true
210
- });
211
- Object.assign(exports.default, exports);
212
- module.exports = exports.default;
213
- } //# sourceMappingURL=get-domain-locale.js.map
214
-
215
-
216
- /***/ }),
217
-
218
- /***/ 3495:
219
- /***/ ((module, exports, __webpack_require__) => {
220
-
221
- "use strict";
222
-
223
- Object.defineProperty(exports, "__esModule", ({
224
- value: true
225
- }));
226
- exports.hasBasePath = hasBasePath;
227
- var _pathHasPrefix = __webpack_require__(4567);
228
- const basePath = false || "";
229
- function hasBasePath(path) {
230
- return (0, _pathHasPrefix).pathHasPrefix(path, basePath);
231
- }
232
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
233
- Object.defineProperty(exports.default, "__esModule", {
234
- value: true
235
- });
236
- Object.assign(exports.default, exports);
237
- module.exports = exports.default;
238
- } //# sourceMappingURL=has-base-path.js.map
239
-
240
-
241
- /***/ }),
242
-
243
- /***/ 4074:
244
- /***/ ((module, exports) => {
245
-
246
- "use strict";
247
-
248
- Object.defineProperty(exports, "__esModule", ({
249
- value: true
250
- }));
251
- exports["default"] = initHeadManager;
252
- exports.isEqualNode = isEqualNode;
253
- exports.DOMAttributeNames = void 0;
254
- function initHeadManager() {
255
- return {
256
- mountedInstances: new Set(),
257
- updateHead: (head)=>{
258
- const tags = {};
259
- head.forEach((h)=>{
260
- if (// it won't be inlined. In this case revert to the original behavior
261
- h.type === "link" && h.props["data-optimized-fonts"]) {
262
- if (document.querySelector(`style[data-href="${h.props["data-href"]}"]`)) {
263
- return;
264
- } else {
265
- h.props.href = h.props["data-href"];
266
- h.props["data-href"] = undefined;
267
- }
268
- }
269
- const components = tags[h.type] || [];
270
- components.push(h);
271
- tags[h.type] = components;
272
- });
273
- const titleComponent = tags.title ? tags.title[0] : null;
274
- let title = "";
275
- if (titleComponent) {
276
- const { children } = titleComponent.props;
277
- title = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
278
- }
279
- if (title !== document.title) document.title = title;
280
- [
281
- "meta",
282
- "base",
283
- "link",
284
- "style",
285
- "script"
286
- ].forEach((type)=>{
287
- updateElements(type, tags[type] || []);
288
- });
289
- }
290
- };
291
- }
292
- const DOMAttributeNames = {
293
- acceptCharset: "accept-charset",
294
- className: "class",
295
- htmlFor: "for",
296
- httpEquiv: "http-equiv",
297
- noModule: "noModule"
298
- };
299
- exports.DOMAttributeNames = DOMAttributeNames;
300
- function reactElementToDOM({ type , props }) {
301
- const el = document.createElement(type);
302
- for(const p in props){
303
- if (!props.hasOwnProperty(p)) continue;
304
- if (p === "children" || p === "dangerouslySetInnerHTML") continue;
305
- // we don't render undefined props to the DOM
306
- if (props[p] === undefined) continue;
307
- const attr = DOMAttributeNames[p] || p.toLowerCase();
308
- if (type === "script" && (attr === "async" || attr === "defer" || attr === "noModule")) {
309
- el[attr] = !!props[p];
310
- } else {
311
- el.setAttribute(attr, props[p]);
312
- }
313
- }
314
- const { children , dangerouslySetInnerHTML } = props;
315
- if (dangerouslySetInnerHTML) {
316
- el.innerHTML = dangerouslySetInnerHTML.__html || "";
317
- } else if (children) {
318
- el.textContent = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
319
- }
320
- return el;
321
- }
322
- function isEqualNode(oldTag, newTag) {
323
- if (oldTag instanceof HTMLElement && newTag instanceof HTMLElement) {
324
- const nonce = newTag.getAttribute("nonce");
325
- // Only strip the nonce if `oldTag` has had it stripped. An element's nonce attribute will not
326
- // be stripped if there is no content security policy response header that includes a nonce.
327
- if (nonce && !oldTag.getAttribute("nonce")) {
328
- const cloneTag = newTag.cloneNode(true);
329
- cloneTag.setAttribute("nonce", "");
330
- cloneTag.nonce = nonce;
331
- return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag);
332
- }
333
- }
334
- return oldTag.isEqualNode(newTag);
335
- }
336
- function updateElements(type, components) {
337
- const headEl = document.getElementsByTagName("head")[0];
338
- const headCountEl = headEl.querySelector("meta[name=next-head-count]");
339
- if (false) {}
340
- const headCount = Number(headCountEl.content);
341
- const oldTags = [];
342
- for(let i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = (j == null ? void 0 : j.previousElementSibling) || null){
343
- var ref;
344
- if ((j == null ? void 0 : (ref = j.tagName) == null ? void 0 : ref.toLowerCase()) === type) {
345
- oldTags.push(j);
346
- }
347
- }
348
- const newTags = components.map(reactElementToDOM).filter((newTag)=>{
349
- for(let k = 0, len = oldTags.length; k < len; k++){
350
- const oldTag = oldTags[k];
351
- if (isEqualNode(oldTag, newTag)) {
352
- oldTags.splice(k, 1);
353
- return false;
354
- }
355
- }
356
- return true;
357
- });
358
- oldTags.forEach((t)=>{
359
- var ref;
360
- return (ref = t.parentNode) == null ? void 0 : ref.removeChild(t);
361
- });
362
- newTags.forEach((t)=>headEl.insertBefore(t, headCountEl));
363
- headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
364
- }
365
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
366
- Object.defineProperty(exports.default, "__esModule", {
367
- value: true
368
- });
369
- Object.assign(exports.default, exports);
370
- module.exports = exports.default;
371
- } //# sourceMappingURL=head-manager.js.map
372
-
373
-
374
- /***/ }),
375
-
376
- /***/ 1484:
377
- /***/ ((module, exports, __webpack_require__) => {
378
-
379
- "use strict";
380
-
381
- "client";
382
- Object.defineProperty(exports, "__esModule", ({
383
- value: true
384
- }));
385
- exports["default"] = void 0;
386
- var _interop_require_default = (__webpack_require__(2009)/* ["default"] */ .Z);
387
- var _object_without_properties_loose = (__webpack_require__(5688)/* ["default"] */ .Z);
388
- var _react = _interop_require_default(__webpack_require__(6689));
389
- var _router = __webpack_require__(1158);
390
- var _addLocale = __webpack_require__(2916);
391
- var _routerContext = __webpack_require__(4964);
392
- var _appRouterContext = __webpack_require__(3280);
393
- var _useIntersection = __webpack_require__(6369);
394
- var _getDomainLocale = __webpack_require__(4011);
395
- var _addBasePath = __webpack_require__(7231);
396
- "client";
397
- const prefetched = {};
398
- function prefetch(router, href, as, options) {
399
- if (true) return;
400
- if (!(0, _router).isLocalURL(href)) return;
401
- // Prefetch the JSON page if asked (only in the client)
402
- // We need to handle a prefetch error here since we may be
403
- // loading with priority which can reject but we don't
404
- // want to force navigation since this is only a prefetch
405
- Promise.resolve(router.prefetch(href, as, options)).catch((err)=>{
406
- if (false) {}
407
- });
408
- const curLocale = options && typeof options.locale !== "undefined" ? options.locale : router && router.locale;
409
- // Join on an invalid URI character
410
- prefetched[href + "%" + as + (curLocale ? "%" + curLocale : "")] = true;
411
- }
412
- function isModifiedEvent(event) {
413
- const { target } = event.currentTarget;
414
- return target && target !== "_self" || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.nativeEvent && event.nativeEvent.which === 2;
415
- }
416
- function linkClicked(e, router, href, as, replace, shallow, scroll, locale, isAppRouter, prefetchEnabled) {
417
- const { nodeName } = e.currentTarget;
418
- // anchors inside an svg have a lowercase nodeName
419
- const isAnchorNodeName = nodeName.toUpperCase() === "A";
420
- if (isAnchorNodeName && (isModifiedEvent(e) || !(0, _router).isLocalURL(href))) {
421
- // ignore click for browser’s default behavior
422
- return;
423
- }
424
- e.preventDefault();
425
- const navigate = ()=>{
426
- // If the router is an NextRouter instance it will have `beforePopState`
427
- if ("beforePopState" in router) {
428
- router[replace ? "replace" : "push"](href, as, {
429
- shallow,
430
- locale,
431
- scroll
432
- });
433
- } else {
434
- // If `beforePopState` doesn't exist on the router it's the AppRouter.
435
- const method = replace ? "replace" : "push";
436
- router[method](href, {
437
- forceOptimisticNavigation: !prefetchEnabled
438
- });
439
- }
440
- };
441
- if (isAppRouter) {
442
- // @ts-expect-error startTransition exists.
443
- _react.default.startTransition(navigate);
444
- } else {
445
- navigate();
446
- }
447
- }
448
- const Link = /*#__PURE__*/ _react.default.forwardRef(function LinkComponent(props, forwardedRef) {
449
- if (false) {}
450
- let children;
451
- const { href: hrefProp , as: asProp , children: childrenProp , prefetch: prefetchProp , passHref , replace , shallow , scroll , locale , onClick , onMouseEnter , onTouchStart , legacyBehavior =Boolean(false) !== true } = props, restProps = _object_without_properties_loose(props, [
452
- "href",
453
- "as",
454
- "children",
455
- "prefetch",
456
- "passHref",
457
- "replace",
458
- "shallow",
459
- "scroll",
460
- "locale",
461
- "onClick",
462
- "onMouseEnter",
463
- "onTouchStart",
464
- "legacyBehavior"
465
- ]);
466
- children = childrenProp;
467
- if (legacyBehavior && (typeof children === "string" || typeof children === "number")) {
468
- children = /*#__PURE__*/ _react.default.createElement("a", null, children);
469
- }
470
- const p = prefetchProp !== false;
471
- let router = _react.default.useContext(_routerContext.RouterContext);
472
- // TODO-APP: type error. Remove `as any`
473
- const appRouter = _react.default.useContext(_appRouterContext.AppRouterContext);
474
- if (appRouter) {
475
- router = appRouter;
476
- }
477
- const { href , as } = _react.default.useMemo(()=>{
478
- const [resolvedHref, resolvedAs] = (0, _router).resolveHref(router, hrefProp, true);
479
- return {
480
- href: resolvedHref,
481
- as: asProp ? (0, _router).resolveHref(router, asProp) : resolvedAs || resolvedHref
482
- };
483
- }, [
484
- router,
485
- hrefProp,
486
- asProp
487
- ]);
488
- const previousHref = _react.default.useRef(href);
489
- const previousAs = _react.default.useRef(as);
490
- // This will return the first child, if multiple are provided it will throw an error
491
- let child;
492
- if (legacyBehavior) {
493
- if (false) {} else {
494
- child = _react.default.Children.only(children);
495
- }
496
- }
497
- const childRef = legacyBehavior ? child && typeof child === "object" && child.ref : forwardedRef;
498
- const [setIntersectionRef, isVisible, resetVisible] = (0, _useIntersection).useIntersection({
499
- rootMargin: "200px"
500
- });
501
- const setRef = _react.default.useCallback((el)=>{
502
- // Before the link getting observed, check if visible state need to be reset
503
- if (previousAs.current !== as || previousHref.current !== href) {
504
- resetVisible();
505
- previousAs.current = as;
506
- previousHref.current = href;
507
- }
508
- setIntersectionRef(el);
509
- if (childRef) {
510
- if (typeof childRef === "function") childRef(el);
511
- else if (typeof childRef === "object") {
512
- childRef.current = el;
513
- }
514
- }
515
- }, [
516
- as,
517
- childRef,
518
- href,
519
- resetVisible,
520
- setIntersectionRef
521
- ]);
522
- _react.default.useEffect(()=>{
523
- const shouldPrefetch = isVisible && p && (0, _router).isLocalURL(href);
524
- const curLocale = typeof locale !== "undefined" ? locale : router && router.locale;
525
- const isPrefetched = prefetched[href + "%" + as + (curLocale ? "%" + curLocale : "")];
526
- if (shouldPrefetch && !isPrefetched) {
527
- prefetch(router, href, as, {
528
- locale: curLocale
529
- });
530
- }
531
- }, [
532
- as,
533
- href,
534
- isVisible,
535
- locale,
536
- p,
537
- router
538
- ]);
539
- const childProps = {
540
- ref: setRef,
541
- onClick: (e)=>{
542
- if (false) {}
543
- if (!legacyBehavior && typeof onClick === "function") {
544
- onClick(e);
545
- }
546
- if (legacyBehavior && child.props && typeof child.props.onClick === "function") {
547
- child.props.onClick(e);
548
- }
549
- if (!e.defaultPrevented) {
550
- linkClicked(e, router, href, as, replace, shallow, scroll, locale, Boolean(appRouter), p);
551
- }
552
- },
553
- onMouseEnter: (e)=>{
554
- if (!legacyBehavior && typeof onMouseEnter === "function") {
555
- onMouseEnter(e);
556
- }
557
- if (legacyBehavior && child.props && typeof child.props.onMouseEnter === "function") {
558
- child.props.onMouseEnter(e);
559
- }
560
- // Check for not prefetch disabled in page using appRouter
561
- if (!(!p && appRouter)) {
562
- if ((0, _router).isLocalURL(href)) {
563
- prefetch(router, href, as, {
564
- priority: true
565
- });
566
- }
567
- }
568
- },
569
- onTouchStart: (e)=>{
570
- if (!legacyBehavior && typeof onTouchStart === "function") {
571
- onTouchStart(e);
572
- }
573
- if (legacyBehavior && child.props && typeof child.props.onTouchStart === "function") {
574
- child.props.onTouchStart(e);
575
- }
576
- // Check for not prefetch disabled in page using appRouter
577
- if (!(!p && appRouter)) {
578
- if ((0, _router).isLocalURL(href)) {
579
- prefetch(router, href, as, {
580
- priority: true
581
- });
582
- }
583
- }
584
- }
585
- };
586
- // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is
587
- // defined, we specify the current 'href', so that repetition is not needed by the user
588
- if (!legacyBehavior || passHref || child.type === "a" && !("href" in child.props)) {
589
- const curLocale = typeof locale !== "undefined" ? locale : router && router.locale;
590
- // we only render domain locales if we are currently on a domain locale
591
- // so that locale links are still visitable in development/preview envs
592
- const localeDomain = router && router.isLocaleDomain && (0, _getDomainLocale).getDomainLocale(as, curLocale, router.locales, router.domainLocales);
593
- childProps.href = localeDomain || (0, _addBasePath).addBasePath((0, _addLocale).addLocale(as, curLocale, router && router.defaultLocale));
594
- }
595
- return legacyBehavior ? /*#__PURE__*/ _react.default.cloneElement(child, childProps) : /*#__PURE__*/ _react.default.createElement("a", Object.assign({}, restProps, childProps), children);
596
- });
597
- var _default = Link;
598
- exports["default"] = _default;
599
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
600
- Object.defineProperty(exports.default, "__esModule", {
601
- value: true
602
- });
603
- Object.assign(exports.default, exports);
604
- module.exports = exports.default;
605
- } //# sourceMappingURL=link.js.map
606
-
607
-
608
- /***/ }),
609
-
610
- /***/ 7663:
611
- /***/ ((module, exports, __webpack_require__) => {
612
-
613
- "use strict";
614
-
615
- Object.defineProperty(exports, "__esModule", ({
616
- value: true
617
- }));
618
- exports.normalizePathTrailingSlash = void 0;
619
- var _removeTrailingSlash = __webpack_require__(3297);
620
- var _parsePath = __webpack_require__(8854);
621
- const normalizePathTrailingSlash = (path)=>{
622
- if (!path.startsWith("/") || undefined) {
623
- return path;
624
- }
625
- const { pathname , query , hash } = (0, _parsePath).parsePath(path);
626
- if (false) {}
627
- return `${(0, _removeTrailingSlash).removeTrailingSlash(pathname)}${query}${hash}`;
628
- };
629
- exports.normalizePathTrailingSlash = normalizePathTrailingSlash;
630
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
631
- Object.defineProperty(exports.default, "__esModule", {
632
- value: true
633
- });
634
- Object.assign(exports.default, exports);
635
- module.exports = exports.default;
636
- } //# sourceMappingURL=normalize-trailing-slash.js.map
637
-
638
-
639
- /***/ }),
640
-
641
- /***/ 3536:
642
- /***/ ((module, exports, __webpack_require__) => {
643
-
644
- "use strict";
645
-
646
- Object.defineProperty(exports, "__esModule", ({
647
- value: true
648
- }));
649
- exports.removeBasePath = removeBasePath;
650
- var _hasBasePath = __webpack_require__(3495);
651
- const basePath = false || "";
652
- function removeBasePath(path) {
653
- if (false) {}
654
- path = path.slice(basePath.length);
655
- if (!path.startsWith("/")) path = `/${path}`;
656
- return path;
657
- }
658
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
659
- Object.defineProperty(exports.default, "__esModule", {
660
- value: true
661
- });
662
- Object.assign(exports.default, exports);
663
- module.exports = exports.default;
664
- } //# sourceMappingURL=remove-base-path.js.map
665
-
666
-
667
- /***/ }),
668
-
669
- /***/ 1130:
670
- /***/ ((module, exports, __webpack_require__) => {
671
-
672
- "use strict";
673
-
674
- Object.defineProperty(exports, "__esModule", ({
675
- value: true
676
- }));
677
- exports.removeLocale = removeLocale;
678
- var _parsePath = __webpack_require__(8854);
679
- function removeLocale(path, locale) {
680
- if (false) {}
681
- return path;
682
- }
683
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
684
- Object.defineProperty(exports.default, "__esModule", {
685
- value: true
686
- });
687
- Object.assign(exports.default, exports);
688
- module.exports = exports.default;
689
- } //# sourceMappingURL=remove-locale.js.map
690
-
691
-
692
- /***/ }),
693
-
694
- /***/ 5495:
695
- /***/ ((module, exports) => {
696
-
697
- "use strict";
698
-
699
- Object.defineProperty(exports, "__esModule", ({
700
- value: true
701
- }));
702
- exports.cancelIdleCallback = exports.requestIdleCallback = void 0;
703
- const requestIdleCallback = typeof self !== "undefined" && self.requestIdleCallback && self.requestIdleCallback.bind(window) || function(cb) {
704
- let start = Date.now();
705
- return setTimeout(function() {
706
- cb({
707
- didTimeout: false,
708
- timeRemaining: function() {
709
- return Math.max(0, 50 - (Date.now() - start));
710
- }
711
- });
712
- }, 1);
713
- };
714
- exports.requestIdleCallback = requestIdleCallback;
715
- const cancelIdleCallback = typeof self !== "undefined" && self.cancelIdleCallback && self.cancelIdleCallback.bind(window) || function(id) {
716
- return clearTimeout(id);
717
- };
718
- exports.cancelIdleCallback = cancelIdleCallback;
719
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
720
- Object.defineProperty(exports.default, "__esModule", {
721
- value: true
722
- });
723
- Object.assign(exports.default, exports);
724
- module.exports = exports.default;
725
- } //# sourceMappingURL=request-idle-callback.js.map
726
-
727
-
728
- /***/ }),
729
-
730
- /***/ 6653:
731
- /***/ ((module, exports, __webpack_require__) => {
732
-
733
- "use strict";
734
-
735
- Object.defineProperty(exports, "__esModule", ({
736
- value: true
737
- }));
738
- exports.markAssetError = markAssetError;
739
- exports.isAssetError = isAssetError;
740
- exports.getClientBuildManifest = getClientBuildManifest;
741
- exports.createRouteLoader = createRouteLoader;
742
- var _interop_require_default = (__webpack_require__(2009)/* ["default"] */ .Z);
743
- var _getAssetPathFromRoute = _interop_require_default(__webpack_require__(9565));
744
- var _trustedTypes = __webpack_require__(9465);
745
- var _requestIdleCallback = __webpack_require__(5495);
746
- // 3.8s was arbitrarily chosen as it's what https://web.dev/interactive
747
- // considers as "Good" time-to-interactive. We must assume something went
748
- // wrong beyond this point, and then fall-back to a full page transition to
749
- // show the user something of value.
750
- const MS_MAX_IDLE_DELAY = 3800;
751
- function withFuture(key, map, generator) {
752
- let entry = map.get(key);
753
- if (entry) {
754
- if ("future" in entry) {
755
- return entry.future;
756
- }
757
- return Promise.resolve(entry);
758
- }
759
- let resolver;
760
- const prom = new Promise((resolve)=>{
761
- resolver = resolve;
762
- });
763
- map.set(key, entry = {
764
- resolve: resolver,
765
- future: prom
766
- });
767
- return generator ? generator() // eslint-disable-next-line no-sequences
768
- .then((value)=>(resolver(value), value)).catch((err)=>{
769
- map.delete(key);
770
- throw err;
771
- }) : prom;
772
- }
773
- function hasPrefetch(link) {
774
- try {
775
- link = document.createElement("link");
776
- return(// with relList.support
777
- !!window.MSInputMethodContext && !!document.documentMode || link.relList.supports("prefetch"));
778
- } catch (e) {
779
- return false;
780
- }
781
- }
782
- const canPrefetch = hasPrefetch();
783
- function prefetchViaDom(href, as, link) {
784
- return new Promise((res, rej)=>{
785
- const selector = `
786
- link[rel="prefetch"][href^="${href}"],
787
- link[rel="preload"][href^="${href}"],
788
- script[src^="${href}"]`;
789
- if (document.querySelector(selector)) {
790
- return res();
791
- }
792
- link = document.createElement("link");
793
- // The order of property assignment here is intentional:
794
- if (as) link.as = as;
795
- link.rel = `prefetch`;
796
- link.crossOrigin = undefined;
797
- link.onload = res;
798
- link.onerror = rej;
799
- // `href` should always be last:
800
- link.href = href;
801
- document.head.appendChild(link);
802
- });
803
- }
804
- const ASSET_LOAD_ERROR = Symbol("ASSET_LOAD_ERROR");
805
- function markAssetError(err) {
806
- return Object.defineProperty(err, ASSET_LOAD_ERROR, {});
807
- }
808
- function isAssetError(err) {
809
- return err && ASSET_LOAD_ERROR in err;
810
- }
811
- function appendScript(src, script) {
812
- return new Promise((resolve, reject)=>{
813
- script = document.createElement("script");
814
- // The order of property assignment here is intentional.
815
- // 1. Setup success/failure hooks in case the browser synchronously
816
- // executes when `src` is set.
817
- script.onload = resolve;
818
- script.onerror = ()=>reject(markAssetError(new Error(`Failed to load script: ${src}`)));
819
- // 2. Configure the cross-origin attribute before setting `src` in case the
820
- // browser begins to fetch.
821
- script.crossOrigin = undefined;
822
- // 3. Finally, set the source and inject into the DOM in case the child
823
- // must be appended for fetching to start.
824
- script.src = src;
825
- document.body.appendChild(script);
826
- });
827
- }
828
- // We wait for pages to be built in dev before we start the route transition
829
- // timeout to prevent an un-necessary hard navigation in development.
830
- let devBuildPromise;
831
- // Resolve a promise that times out after given amount of milliseconds.
832
- function resolvePromiseWithTimeout(p, ms, err) {
833
- return new Promise((resolve, reject)=>{
834
- let cancelled = false;
835
- p.then((r)=>{
836
- // Resolved, cancel the timeout
837
- cancelled = true;
838
- resolve(r);
839
- }).catch(reject);
840
- // We wrap these checks separately for better dead-code elimination in
841
- // production bundles.
842
- if (false) {}
843
- if (true) {
844
- (0, _requestIdleCallback).requestIdleCallback(()=>setTimeout(()=>{
845
- if (!cancelled) {
846
- reject(err);
847
- }
848
- }, ms));
849
- }
850
- });
851
- }
852
- function getClientBuildManifest() {
853
- if (self.__BUILD_MANIFEST) {
854
- return Promise.resolve(self.__BUILD_MANIFEST);
855
- }
856
- const onBuildManifest = new Promise((resolve)=>{
857
- // Mandatory because this is not concurrent safe:
858
- const cb = self.__BUILD_MANIFEST_CB;
859
- self.__BUILD_MANIFEST_CB = ()=>{
860
- resolve(self.__BUILD_MANIFEST);
861
- cb && cb();
862
- };
863
- });
864
- return resolvePromiseWithTimeout(onBuildManifest, MS_MAX_IDLE_DELAY, markAssetError(new Error("Failed to load client build manifest")));
865
- }
866
- function getFilesForRoute(assetPrefix, route) {
867
- if (false) {}
868
- return getClientBuildManifest().then((manifest)=>{
869
- if (!(route in manifest)) {
870
- throw markAssetError(new Error(`Failed to lookup route: ${route}`));
871
- }
872
- const allFiles = manifest[route].map((entry)=>assetPrefix + "/_next/" + encodeURI(entry));
873
- return {
874
- scripts: allFiles.filter((v)=>v.endsWith(".js")).map((v)=>(0, _trustedTypes).__unsafeCreateTrustedScriptURL(v)),
875
- css: allFiles.filter((v)=>v.endsWith(".css"))
876
- };
877
- });
878
- }
879
- function createRouteLoader(assetPrefix) {
880
- const entrypoints = new Map();
881
- const loadedScripts = new Map();
882
- const styleSheets = new Map();
883
- const routes = new Map();
884
- function maybeExecuteScript(src) {
885
- // With HMR we might need to "reload" scripts when they are
886
- // disposed and readded. Executing scripts twice has no functional
887
- // differences
888
- if (true) {
889
- let prom = loadedScripts.get(src.toString());
890
- if (prom) {
891
- return prom;
892
- }
893
- // Skip executing script if it's already in the DOM:
894
- if (document.querySelector(`script[src^="${src}"]`)) {
895
- return Promise.resolve();
896
- }
897
- loadedScripts.set(src.toString(), prom = appendScript(src));
898
- return prom;
899
- } else {}
900
- }
901
- function fetchStyleSheet(href) {
902
- let prom = styleSheets.get(href);
903
- if (prom) {
904
- return prom;
905
- }
906
- styleSheets.set(href, prom = fetch(href).then((res)=>{
907
- if (!res.ok) {
908
- throw new Error(`Failed to load stylesheet: ${href}`);
909
- }
910
- return res.text().then((text)=>({
911
- href: href,
912
- content: text
913
- }));
914
- }).catch((err)=>{
915
- throw markAssetError(err);
916
- }));
917
- return prom;
918
- }
919
- return {
920
- whenEntrypoint (route) {
921
- return withFuture(route, entrypoints);
922
- },
923
- onEntrypoint (route, execute) {
924
- (execute ? Promise.resolve().then(()=>execute()).then((exports1)=>({
925
- component: exports1 && exports1.default || exports1,
926
- exports: exports1
927
- }), (err)=>({
928
- error: err
929
- })) : Promise.resolve(undefined)).then((input)=>{
930
- const old = entrypoints.get(route);
931
- if (old && "resolve" in old) {
932
- if (input) {
933
- entrypoints.set(route, input);
934
- old.resolve(input);
935
- }
936
- } else {
937
- if (input) {
938
- entrypoints.set(route, input);
939
- } else {
940
- entrypoints.delete(route);
941
- }
942
- // when this entrypoint has been resolved before
943
- // the route is outdated and we want to invalidate
944
- // this cache entry
945
- routes.delete(route);
946
- }
947
- });
948
- },
949
- loadRoute (route, prefetch) {
950
- return withFuture(route, routes, ()=>{
951
- let devBuildPromiseResolve;
952
- if (false) {}
953
- return resolvePromiseWithTimeout(getFilesForRoute(assetPrefix, route).then(({ scripts , css })=>{
954
- return Promise.all([
955
- entrypoints.has(route) ? [] : Promise.all(scripts.map(maybeExecuteScript)),
956
- Promise.all(css.map(fetchStyleSheet)),
957
- ]);
958
- }).then((res)=>{
959
- return this.whenEntrypoint(route).then((entrypoint)=>({
960
- entrypoint,
961
- styles: res[1]
962
- }));
963
- }), MS_MAX_IDLE_DELAY, markAssetError(new Error(`Route did not complete loading: ${route}`))).then(({ entrypoint , styles })=>{
964
- const res = Object.assign({
965
- styles: styles
966
- }, entrypoint);
967
- return "error" in entrypoint ? entrypoint : res;
968
- }).catch((err)=>{
969
- if (prefetch) {
970
- // we don't want to cache errors during prefetch
971
- throw err;
972
- }
973
- return {
974
- error: err
975
- };
976
- }).finally(()=>{
977
- return devBuildPromiseResolve == null ? void 0 : devBuildPromiseResolve();
978
- });
979
- });
980
- },
981
- prefetch (route) {
982
- // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
983
- // License: Apache 2.0
984
- let cn;
985
- if (cn = navigator.connection) {
986
- // Don't prefetch if using 2G or if Save-Data is enabled.
987
- if (cn.saveData || /2g/.test(cn.effectiveType)) return Promise.resolve();
988
- }
989
- return getFilesForRoute(assetPrefix, route).then((output)=>Promise.all(canPrefetch ? output.scripts.map((script)=>prefetchViaDom(script.toString(), "script")) : [])).then(()=>{
990
- (0, _requestIdleCallback).requestIdleCallback(()=>this.loadRoute(route, true).catch(()=>{}));
991
- }).catch(()=>{});
992
- }
993
- };
994
- }
995
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
996
- Object.defineProperty(exports.default, "__esModule", {
997
- value: true
998
- });
999
- Object.assign(exports.default, exports);
1000
- module.exports = exports.default;
1001
- } //# sourceMappingURL=route-loader.js.map
1002
-
1003
-
1004
- /***/ }),
1005
-
1006
- /***/ 9944:
1007
- /***/ ((module, exports, __webpack_require__) => {
1008
-
1009
- "use strict";
1010
-
1011
- "client";
1012
- Object.defineProperty(exports, "__esModule", ({
1013
- value: true
1014
- }));
1015
- exports.handleClientScriptLoad = handleClientScriptLoad;
1016
- exports.initScriptLoader = initScriptLoader;
1017
- exports["default"] = void 0;
1018
- var _extends = (__webpack_require__(5271)/* ["default"] */ .Z);
1019
- var _interop_require_wildcard = (__webpack_require__(9371)/* ["default"] */ .Z);
1020
- var _object_without_properties_loose = (__webpack_require__(5688)/* ["default"] */ .Z);
1021
- var _react = _interop_require_wildcard(__webpack_require__(6689));
1022
- var _headManagerContext = __webpack_require__(2796);
1023
- var _headManager = __webpack_require__(4074);
1024
- var _requestIdleCallback = __webpack_require__(5495);
1025
- "client";
1026
- const ScriptCache = new Map();
1027
- const LoadCache = new Set();
1028
- const ignoreProps = [
1029
- "onLoad",
1030
- "onReady",
1031
- "dangerouslySetInnerHTML",
1032
- "children",
1033
- "onError",
1034
- "strategy",
1035
- ];
1036
- const loadScript = (props)=>{
1037
- const { src , id , onLoad =()=>{} , onReady =null , dangerouslySetInnerHTML , children ="" , strategy ="afterInteractive" , onError , } = props;
1038
- const cacheKey = id || src;
1039
- // Script has already loaded
1040
- if (cacheKey && LoadCache.has(cacheKey)) {
1041
- return;
1042
- }
1043
- // Contents of this script are already loading/loaded
1044
- if (ScriptCache.has(src)) {
1045
- LoadCache.add(cacheKey);
1046
- // It is possible that multiple `next/script` components all have same "src", but has different "onLoad"
1047
- // This is to make sure the same remote script will only load once, but "onLoad" are executed in order
1048
- ScriptCache.get(src).then(onLoad, onError);
1049
- return;
1050
- }
1051
- /** Execute after the script first loaded */ const afterLoad = ()=>{
1052
- // Run onReady for the first time after load event
1053
- if (onReady) {
1054
- onReady();
1055
- }
1056
- // add cacheKey to LoadCache when load successfully
1057
- LoadCache.add(cacheKey);
1058
- };
1059
- const el = document.createElement("script");
1060
- const loadPromise = new Promise((resolve, reject)=>{
1061
- el.addEventListener("load", function(e) {
1062
- resolve();
1063
- if (onLoad) {
1064
- onLoad.call(this, e);
1065
- }
1066
- afterLoad();
1067
- });
1068
- el.addEventListener("error", function(e) {
1069
- reject(e);
1070
- });
1071
- }).catch(function(e) {
1072
- if (onError) {
1073
- onError(e);
1074
- }
1075
- });
1076
- if (dangerouslySetInnerHTML) {
1077
- el.innerHTML = dangerouslySetInnerHTML.__html || "";
1078
- afterLoad();
1079
- } else if (children) {
1080
- el.textContent = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
1081
- afterLoad();
1082
- } else if (src) {
1083
- el.src = src;
1084
- // do not add cacheKey into LoadCache for remote script here
1085
- // cacheKey will be added to LoadCache when it is actually loaded (see loadPromise above)
1086
- ScriptCache.set(src, loadPromise);
1087
- }
1088
- for (const [k, value] of Object.entries(props)){
1089
- if (value === undefined || ignoreProps.includes(k)) {
1090
- continue;
1091
- }
1092
- const attr = _headManager.DOMAttributeNames[k] || k.toLowerCase();
1093
- el.setAttribute(attr, value);
1094
- }
1095
- if (strategy === "worker") {
1096
- el.setAttribute("type", "text/partytown");
1097
- }
1098
- el.setAttribute("data-nscript", strategy);
1099
- document.body.appendChild(el);
1100
- };
1101
- function handleClientScriptLoad(props) {
1102
- const { strategy ="afterInteractive" } = props;
1103
- if (strategy === "lazyOnload") {
1104
- window.addEventListener("load", ()=>{
1105
- (0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
1106
- });
1107
- } else {
1108
- loadScript(props);
1109
- }
1110
- }
1111
- function loadLazyScript(props) {
1112
- if (document.readyState === "complete") {
1113
- (0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
1114
- } else {
1115
- window.addEventListener("load", ()=>{
1116
- (0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
1117
- });
1118
- }
1119
- }
1120
- function addBeforeInteractiveToCache() {
1121
- const scripts = [
1122
- ...document.querySelectorAll('[data-nscript="beforeInteractive"]'),
1123
- ...document.querySelectorAll('[data-nscript="beforePageRender"]'),
1124
- ];
1125
- scripts.forEach((script)=>{
1126
- const cacheKey = script.id || script.getAttribute("src");
1127
- LoadCache.add(cacheKey);
1128
- });
1129
- }
1130
- function initScriptLoader(scriptLoaderItems) {
1131
- scriptLoaderItems.forEach(handleClientScriptLoad);
1132
- addBeforeInteractiveToCache();
1133
- }
1134
- function Script(props) {
1135
- const { id , src ="" , onLoad =()=>{} , onReady =null , strategy ="afterInteractive" , onError } = props, restProps = _object_without_properties_loose(props, [
1136
- "id",
1137
- "src",
1138
- "onLoad",
1139
- "onReady",
1140
- "strategy",
1141
- "onError"
1142
- ]);
1143
- // Context is available only during SSR
1144
- const { updateScripts , scripts , getIsSsr } = (0, _react).useContext(_headManagerContext.HeadManagerContext);
1145
- /**
1146
- * - First mount:
1147
- * 1. The useEffect for onReady executes
1148
- * 2. hasOnReadyEffectCalled.current is false, but the script hasn't loaded yet (not in LoadCache)
1149
- * onReady is skipped, set hasOnReadyEffectCalled.current to true
1150
- * 3. The useEffect for loadScript executes
1151
- * 4. hasLoadScriptEffectCalled.current is false, loadScript executes
1152
- * Once the script is loaded, the onLoad and onReady will be called by then
1153
- * [If strict mode is enabled / is wrapped in <OffScreen /> component]
1154
- * 5. The useEffect for onReady executes again
1155
- * 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
1156
- * 7. The useEffect for loadScript executes again
1157
- * 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
1158
- *
1159
- * - Second mount:
1160
- * 1. The useEffect for onReady executes
1161
- * 2. hasOnReadyEffectCalled.current is false, but the script has already loaded (found in LoadCache)
1162
- * onReady is called, set hasOnReadyEffectCalled.current to true
1163
- * 3. The useEffect for loadScript executes
1164
- * 4. The script is already loaded, loadScript bails out
1165
- * [If strict mode is enabled / is wrapped in <OffScreen /> component]
1166
- * 5. The useEffect for onReady executes again
1167
- * 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
1168
- * 7. The useEffect for loadScript executes again
1169
- * 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
1170
- */ const hasOnReadyEffectCalled = (0, _react).useRef(false);
1171
- (0, _react).useEffect(()=>{
1172
- const cacheKey = id || src;
1173
- if (!hasOnReadyEffectCalled.current) {
1174
- // Run onReady if script has loaded before but component is re-mounted
1175
- if (onReady && cacheKey && LoadCache.has(cacheKey)) {
1176
- onReady();
1177
- }
1178
- hasOnReadyEffectCalled.current = true;
1179
- }
1180
- }, [
1181
- onReady,
1182
- id,
1183
- src
1184
- ]);
1185
- const hasLoadScriptEffectCalled = (0, _react).useRef(false);
1186
- (0, _react).useEffect(()=>{
1187
- if (!hasLoadScriptEffectCalled.current) {
1188
- if (strategy === "afterInteractive") {
1189
- loadScript(props);
1190
- } else if (strategy === "lazyOnload") {
1191
- loadLazyScript(props);
1192
- }
1193
- hasLoadScriptEffectCalled.current = true;
1194
- }
1195
- }, [
1196
- props,
1197
- strategy
1198
- ]);
1199
- if (strategy === "beforeInteractive" || strategy === "worker") {
1200
- if (updateScripts) {
1201
- scripts[strategy] = (scripts[strategy] || []).concat([
1202
- _extends({
1203
- id,
1204
- src,
1205
- onLoad,
1206
- onReady,
1207
- onError
1208
- }, restProps),
1209
- ]);
1210
- updateScripts(scripts);
1211
- } else if (getIsSsr && getIsSsr()) {
1212
- // Script has already loaded during SSR
1213
- LoadCache.add(id || src);
1214
- } else if (getIsSsr && !getIsSsr()) {
1215
- loadScript(props);
1216
- }
1217
- }
1218
- return null;
1219
- }
1220
- Object.defineProperty(Script, "__nextScript", {
1221
- value: true
1222
- });
1223
- var _default = Script;
1224
- exports["default"] = _default;
1225
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
1226
- Object.defineProperty(exports.default, "__esModule", {
1227
- value: true
1228
- });
1229
- Object.assign(exports.default, exports);
1230
- module.exports = exports.default;
1231
- } //# sourceMappingURL=script.js.map
1232
-
1233
-
1234
- /***/ }),
1235
-
1236
- /***/ 9465:
1237
- /***/ ((module, exports) => {
1238
-
1239
- "use strict";
1240
-
1241
- Object.defineProperty(exports, "__esModule", ({
1242
- value: true
1243
- }));
1244
- exports.__unsafeCreateTrustedScriptURL = __unsafeCreateTrustedScriptURL;
1245
- /**
1246
- * Stores the Trusted Types Policy. Starts as undefined and can be set to null
1247
- * if Trusted Types is not supported in the browser.
1248
- */ let policy;
1249
- /**
1250
- * Getter for the Trusted Types Policy. If it is undefined, it is instantiated
1251
- * here or set to null if Trusted Types is not supported in the browser.
1252
- */ function getPolicy() {
1253
- if (typeof policy === "undefined" && "undefined" !== "undefined") { var ref; }
1254
- return policy;
1255
- }
1256
- function __unsafeCreateTrustedScriptURL(url) {
1257
- var ref;
1258
- return ((ref = getPolicy()) == null ? void 0 : ref.createScriptURL(url)) || url;
1259
- }
1260
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
1261
- Object.defineProperty(exports.default, "__esModule", {
1262
- value: true
1263
- });
1264
- Object.assign(exports.default, exports);
1265
- module.exports = exports.default;
1266
- } //# sourceMappingURL=trusted-types.js.map
1267
-
1268
-
1269
- /***/ }),
1270
-
1271
- /***/ 6369:
1272
- /***/ ((module, exports, __webpack_require__) => {
1273
-
1274
- "use strict";
1275
-
1276
- Object.defineProperty(exports, "__esModule", ({
1277
- value: true
1278
- }));
1279
- exports.useIntersection = useIntersection;
1280
- var _react = __webpack_require__(6689);
1281
- var _requestIdleCallback = __webpack_require__(5495);
1282
- const hasIntersectionObserver = typeof IntersectionObserver === "function";
1283
- const observers = new Map();
1284
- const idList = [];
1285
- function createObserver(options) {
1286
- const id = {
1287
- root: options.root || null,
1288
- margin: options.rootMargin || ""
1289
- };
1290
- const existing = idList.find((obj)=>obj.root === id.root && obj.margin === id.margin);
1291
- let instance;
1292
- if (existing) {
1293
- instance = observers.get(existing);
1294
- if (instance) {
1295
- return instance;
1296
- }
1297
- }
1298
- const elements = new Map();
1299
- const observer = new IntersectionObserver((entries)=>{
1300
- entries.forEach((entry)=>{
1301
- const callback = elements.get(entry.target);
1302
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
1303
- if (callback && isVisible) {
1304
- callback(isVisible);
1305
- }
1306
- });
1307
- }, options);
1308
- instance = {
1309
- id,
1310
- observer,
1311
- elements
1312
- };
1313
- idList.push(id);
1314
- observers.set(id, instance);
1315
- return instance;
1316
- }
1317
- function observe(element, callback, options) {
1318
- const { id , observer , elements } = createObserver(options);
1319
- elements.set(element, callback);
1320
- observer.observe(element);
1321
- return function unobserve() {
1322
- elements.delete(element);
1323
- observer.unobserve(element);
1324
- // Destroy observer when there's nothing left to watch:
1325
- if (elements.size === 0) {
1326
- observer.disconnect();
1327
- observers.delete(id);
1328
- const index = idList.findIndex((obj)=>obj.root === id.root && obj.margin === id.margin);
1329
- if (index > -1) {
1330
- idList.splice(index, 1);
1331
- }
1332
- }
1333
- };
1334
- }
1335
- function useIntersection({ rootRef , rootMargin , disabled }) {
1336
- const isDisabled = disabled || !hasIntersectionObserver;
1337
- const [visible, setVisible] = (0, _react).useState(false);
1338
- const [element, setElement] = (0, _react).useState(null);
1339
- (0, _react).useEffect(()=>{
1340
- if (hasIntersectionObserver) {
1341
- if (isDisabled || visible) return;
1342
- if (element && element.tagName) {
1343
- const unobserve = observe(element, (isVisible)=>isVisible && setVisible(isVisible), {
1344
- root: rootRef == null ? void 0 : rootRef.current,
1345
- rootMargin
1346
- });
1347
- return unobserve;
1348
- }
1349
- } else {
1350
- if (!visible) {
1351
- const idleCallback = (0, _requestIdleCallback).requestIdleCallback(()=>setVisible(true));
1352
- return ()=>(0, _requestIdleCallback).cancelIdleCallback(idleCallback);
1353
- }
1354
- }
1355
- }, [
1356
- element,
1357
- isDisabled,
1358
- rootMargin,
1359
- rootRef,
1360
- visible
1361
- ]);
1362
- const resetVisible = (0, _react).useCallback(()=>{
1363
- setVisible(false);
1364
- }, []);
1365
- return [
1366
- setElement,
1367
- visible,
1368
- resetVisible
1369
- ];
1370
- }
1371
- if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
1372
- Object.defineProperty(exports.default, "__esModule", {
1373
- value: true
1374
- });
1375
- Object.assign(exports.default, exports);
1376
- module.exports = exports.default;
1377
- } //# sourceMappingURL=use-intersection.js.map
1378
-
1379
-
1380
- /***/ }),
1381
-
1382
- /***/ 1158:
1383
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1384
-
1385
- "use strict";
1386
-
1387
- Object.defineProperty(exports, "__esModule", ({
1388
- value: true
1389
- }));
1390
- exports.matchesMiddleware = matchesMiddleware;
1391
- exports.isLocalURL = isLocalURL;
1392
- exports.interpolateAs = interpolateAs;
1393
- exports.resolveHref = resolveHref;
1394
- exports.createKey = createKey;
1395
- exports["default"] = void 0;
1396
- var _async_to_generator = (__webpack_require__(2510)/* ["default"] */ .Z);
1397
- var _extends = (__webpack_require__(5271)/* ["default"] */ .Z);
1398
- var _interop_require_default = (__webpack_require__(2009)/* ["default"] */ .Z);
1399
- var _interop_require_wildcard = (__webpack_require__(9371)/* ["default"] */ .Z);
1400
- var _normalizeTrailingSlash = __webpack_require__(7663);
1401
- var _removeTrailingSlash = __webpack_require__(3297);
1402
- var _routeLoader = __webpack_require__(6653);
1403
- var _script = __webpack_require__(9944);
1404
- var _isError = _interop_require_wildcard(__webpack_require__(3415));
1405
- var _denormalizePagePath = __webpack_require__(4406);
1406
- var _normalizeLocalePath = __webpack_require__(4014);
1407
- var _mitt = _interop_require_default(__webpack_require__(8020));
1408
- var _utils = __webpack_require__(9232);
1409
- var _isDynamic = __webpack_require__(1428);
1410
- var _parseRelativeUrl = __webpack_require__(1292);
1411
- var _querystring = __webpack_require__(979);
1412
- var _resolveRewrites = _interop_require_default(__webpack_require__(6052));
1413
- var _routeMatcher = __webpack_require__(4226);
1414
- var _routeRegex = __webpack_require__(5052);
1415
- var _formatUrl = __webpack_require__(3938);
1416
- var _detectDomainLocale = __webpack_require__(4165);
1417
- var _parsePath = __webpack_require__(8854);
1418
- var _addLocale = __webpack_require__(2916);
1419
- var _removeLocale = __webpack_require__(1130);
1420
- var _removeBasePath = __webpack_require__(3536);
1421
- var _addBasePath = __webpack_require__(7231);
1422
- var _hasBasePath = __webpack_require__(3495);
1423
- var _getNextPathnameInfo = __webpack_require__(5789);
1424
- var _formatNextPathnameInfo = __webpack_require__(299);
1425
- var _compareStates = __webpack_require__(6220);
1426
- var _isBot = __webpack_require__(1897);
1427
- function buildCancellationError() {
1428
- return Object.assign(new Error("Route Cancelled"), {
1429
- cancelled: true
1430
- });
1431
- }
1432
- function matchesMiddleware(options) {
1433
- return _matchesMiddleware.apply(this, arguments);
1434
- }
1435
- function _matchesMiddleware() {
1436
- _matchesMiddleware = _async_to_generator(function*(options) {
1437
- const matchers = yield Promise.resolve(options.router.pageLoader.getMiddleware());
1438
- if (!matchers) return false;
1439
- const { pathname: asPathname } = (0, _parsePath).parsePath(options.asPath);
1440
- // remove basePath first since path prefix has to be in the order of `/${basePath}/${locale}`
1441
- const cleanedAs = (0, _hasBasePath).hasBasePath(asPathname) ? (0, _removeBasePath).removeBasePath(asPathname) : asPathname;
1442
- const asWithBasePathAndLocale = (0, _addBasePath).addBasePath((0, _addLocale).addLocale(cleanedAs, options.locale));
1443
- // Check only path match on client. Matching "has" should be done on server
1444
- // where we can access more info such as headers, HttpOnly cookie, etc.
1445
- return matchers.some((m)=>new RegExp(m.regexp).test(asWithBasePathAndLocale));
1446
- });
1447
- return _matchesMiddleware.apply(this, arguments);
1448
- }
1449
- function stripOrigin(url) {
1450
- const origin = (0, _utils).getLocationOrigin();
1451
- return url.startsWith(origin) ? url.substring(origin.length) : url;
1452
- }
1453
- function omit(object, keys) {
1454
- const omitted = {};
1455
- Object.keys(object).forEach((key)=>{
1456
- if (!keys.includes(key)) {
1457
- omitted[key] = object[key];
1458
- }
1459
- });
1460
- return omitted;
1461
- }
1462
- function isLocalURL(url) {
1463
- // prevent a hydration mismatch on href for url with anchor refs
1464
- if (!(0, _utils).isAbsoluteUrl(url)) return true;
1465
- try {
1466
- // absolute urls can be local if they are on the same origin
1467
- const locationOrigin = (0, _utils).getLocationOrigin();
1468
- const resolved = new URL(url, locationOrigin);
1469
- return resolved.origin === locationOrigin && (0, _hasBasePath).hasBasePath(resolved.pathname);
1470
- } catch (_) {
1471
- return false;
1472
- }
1473
- }
1474
- function interpolateAs(route, asPathname, query) {
1475
- let interpolatedRoute = "";
1476
- const dynamicRegex = (0, _routeRegex).getRouteRegex(route);
1477
- const dynamicGroups = dynamicRegex.groups;
1478
- const dynamicMatches = (asPathname !== route ? (0, _routeMatcher).getRouteMatcher(dynamicRegex)(asPathname) : "") || // Fall back to reading the values from the href
1479
- // TODO: should this take priority; also need to change in the router.
1480
- query;
1481
- interpolatedRoute = route;
1482
- const params = Object.keys(dynamicGroups);
1483
- if (!params.every((param)=>{
1484
- let value = dynamicMatches[param] || "";
1485
- const { repeat , optional } = dynamicGroups[param];
1486
- // support single-level catch-all
1487
- // TODO: more robust handling for user-error (passing `/`)
1488
- let replaced = `[${repeat ? "..." : ""}${param}]`;
1489
- if (optional) {
1490
- replaced = `${!value ? "/" : ""}[${replaced}]`;
1491
- }
1492
- if (repeat && !Array.isArray(value)) value = [
1493
- value
1494
- ];
1495
- return (optional || param in dynamicMatches) && // Interpolate group into data URL if present
1496
- (interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map(// path delimiter escaped since they are being inserted
1497
- // into the URL and we expect URL encoded segments
1498
- // when parsing dynamic route params
1499
- (segment)=>encodeURIComponent(segment)).join("/") : encodeURIComponent(value)) || "/");
1500
- })) {
1501
- interpolatedRoute = "" // did not satisfy all requirements
1502
- ;
1503
- // n.b. We ignore this error because we handle warning for this case in
1504
- // development in the `<Link>` component directly.
1505
- }
1506
- return {
1507
- params,
1508
- result: interpolatedRoute
1509
- };
1510
- }
1511
- function resolveHref(router, href, resolveAs) {
1512
- // we use a dummy base url for relative urls
1513
- let base;
1514
- let urlAsString = typeof href === "string" ? href : (0, _formatUrl).formatWithValidation(href);
1515
- // repeated slashes and backslashes in the URL are considered
1516
- // invalid and will never match a Next.js page/file
1517
- const urlProtoMatch = urlAsString.match(/^[a-zA-Z]{1,}:\/\//);
1518
- const urlAsStringNoProto = urlProtoMatch ? urlAsString.slice(urlProtoMatch[0].length) : urlAsString;
1519
- const urlParts = urlAsStringNoProto.split("?");
1520
- if ((urlParts[0] || "").match(/(\/\/|\\)/)) {
1521
- console.error(`Invalid href passed to next/router: ${urlAsString}, repeated forward-slashes (//) or backslashes \\ are not valid in the href`);
1522
- const normalizedUrl = (0, _utils).normalizeRepeatedSlashes(urlAsStringNoProto);
1523
- urlAsString = (urlProtoMatch ? urlProtoMatch[0] : "") + normalizedUrl;
1524
- }
1525
- // Return because it cannot be routed by the Next.js router
1526
- if (!isLocalURL(urlAsString)) {
1527
- return resolveAs ? [
1528
- urlAsString
1529
- ] : urlAsString;
1530
- }
1531
- try {
1532
- base = new URL(urlAsString.startsWith("#") ? router.asPath : router.pathname, "http://n");
1533
- } catch (_) {
1534
- // fallback to / for invalid asPath values e.g. //
1535
- base = new URL("/", "http://n");
1536
- }
1537
- try {
1538
- const finalUrl = new URL(urlAsString, base);
1539
- finalUrl.pathname = (0, _normalizeTrailingSlash).normalizePathTrailingSlash(finalUrl.pathname);
1540
- let interpolatedAs = "";
1541
- if ((0, _isDynamic).isDynamicRoute(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
1542
- const query = (0, _querystring).searchParamsToUrlQuery(finalUrl.searchParams);
1543
- const { result , params } = interpolateAs(finalUrl.pathname, finalUrl.pathname, query);
1544
- if (result) {
1545
- interpolatedAs = (0, _formatUrl).formatWithValidation({
1546
- pathname: result,
1547
- hash: finalUrl.hash,
1548
- query: omit(query, params)
1549
- });
1550
- }
1551
- }
1552
- // if the origin didn't change, it means we received a relative href
1553
- const resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
1554
- return resolveAs ? [
1555
- resolvedHref,
1556
- interpolatedAs || resolvedHref
1557
- ] : resolvedHref;
1558
- } catch (_1) {
1559
- return resolveAs ? [
1560
- urlAsString
1561
- ] : urlAsString;
1562
- }
1563
- }
1564
- function prepareUrlAs(router, url, as) {
1565
- // If url and as provided as an object representation,
1566
- // we'll format them into the string version here.
1567
- let [resolvedHref, resolvedAs] = resolveHref(router, url, true);
1568
- const origin = (0, _utils).getLocationOrigin();
1569
- const hrefHadOrigin = resolvedHref.startsWith(origin);
1570
- const asHadOrigin = resolvedAs && resolvedAs.startsWith(origin);
1571
- resolvedHref = stripOrigin(resolvedHref);
1572
- resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
1573
- const preparedUrl = hrefHadOrigin ? resolvedHref : (0, _addBasePath).addBasePath(resolvedHref);
1574
- const preparedAs = as ? stripOrigin(resolveHref(router, as)) : resolvedAs || resolvedHref;
1575
- return {
1576
- url: preparedUrl,
1577
- as: asHadOrigin ? preparedAs : (0, _addBasePath).addBasePath(preparedAs)
1578
- };
1579
- }
1580
- function resolveDynamicRoute(pathname, pages) {
1581
- const cleanPathname = (0, _removeTrailingSlash).removeTrailingSlash((0, _denormalizePagePath).denormalizePagePath(pathname));
1582
- if (cleanPathname === "/404" || cleanPathname === "/_error") {
1583
- return pathname;
1584
- }
1585
- // handle resolving href for dynamic routes
1586
- if (!pages.includes(cleanPathname)) {
1587
- // eslint-disable-next-line array-callback-return
1588
- pages.some((page)=>{
1589
- if ((0, _isDynamic).isDynamicRoute(page) && (0, _routeRegex).getRouteRegex(page).re.test(cleanPathname)) {
1590
- pathname = page;
1591
- return true;
1592
- }
1593
- });
1594
- }
1595
- return (0, _removeTrailingSlash).removeTrailingSlash(pathname);
1596
- }
1597
- function getMiddlewareData(source, response, options) {
1598
- const nextConfig = {
1599
- basePath: options.router.basePath,
1600
- i18n: {
1601
- locales: options.router.locales
1602
- },
1603
- trailingSlash: Boolean(false)
1604
- };
1605
- const rewriteHeader = response.headers.get("x-nextjs-rewrite");
1606
- let rewriteTarget = rewriteHeader || response.headers.get("x-nextjs-matched-path");
1607
- const matchedPath = response.headers.get("x-matched-path");
1608
- if (matchedPath && !rewriteTarget && !matchedPath.includes("__next_data_catchall") && !matchedPath.includes("/_error") && !matchedPath.includes("/404")) {
1609
- // leverage x-matched-path to detect next.config.js rewrites
1610
- rewriteTarget = matchedPath;
1611
- }
1612
- if (rewriteTarget) {
1613
- if (rewriteTarget.startsWith("/")) {
1614
- const parsedRewriteTarget = (0, _parseRelativeUrl).parseRelativeUrl(rewriteTarget);
1615
- const pathnameInfo = (0, _getNextPathnameInfo).getNextPathnameInfo(parsedRewriteTarget.pathname, {
1616
- nextConfig,
1617
- parseData: true
1618
- });
1619
- let fsPathname = (0, _removeTrailingSlash).removeTrailingSlash(pathnameInfo.pathname);
1620
- return Promise.all([
1621
- options.router.pageLoader.getPageList(),
1622
- (0, _routeLoader).getClientBuildManifest(),
1623
- ]).then(([pages, { __rewrites: rewrites }])=>{
1624
- let as = (0, _addLocale).addLocale(pathnameInfo.pathname, pathnameInfo.locale);
1625
- if ((0, _isDynamic).isDynamicRoute(as) || !rewriteHeader && pages.includes((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(as), options.router.locales).pathname)) {
1626
- const parsedSource = (0, _getNextPathnameInfo).getNextPathnameInfo((0, _parseRelativeUrl).parseRelativeUrl(source).pathname, {
1627
- parseData: true
1628
- });
1629
- as = (0, _addBasePath).addBasePath(parsedSource.pathname);
1630
- parsedRewriteTarget.pathname = as;
1631
- }
1632
- if (false) {} else if (!pages.includes(fsPathname)) {
1633
- const resolvedPathname = resolveDynamicRoute(fsPathname, pages);
1634
- if (resolvedPathname !== fsPathname) {
1635
- fsPathname = resolvedPathname;
1636
- }
1637
- }
1638
- const resolvedHref = !pages.includes(fsPathname) ? resolveDynamicRoute((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(parsedRewriteTarget.pathname), options.router.locales).pathname, pages) : fsPathname;
1639
- if ((0, _isDynamic).isDynamicRoute(resolvedHref)) {
1640
- const matches = (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(resolvedHref))(as);
1641
- Object.assign(parsedRewriteTarget.query, matches || {});
1642
- }
1643
- return {
1644
- type: "rewrite",
1645
- parsedAs: parsedRewriteTarget,
1646
- resolvedHref
1647
- };
1648
- });
1649
- }
1650
- const src = (0, _parsePath).parsePath(source);
1651
- const pathname = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src.pathname, {
1652
- nextConfig,
1653
- parseData: true
1654
- }), {
1655
- defaultLocale: options.router.defaultLocale,
1656
- buildId: ""
1657
- }));
1658
- return Promise.resolve({
1659
- type: "redirect-external",
1660
- destination: `${pathname}${src.query}${src.hash}`
1661
- });
1662
- }
1663
- const redirectTarget = response.headers.get("x-nextjs-redirect");
1664
- if (redirectTarget) {
1665
- if (redirectTarget.startsWith("/")) {
1666
- const src1 = (0, _parsePath).parsePath(redirectTarget);
1667
- const pathname1 = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src1.pathname, {
1668
- nextConfig,
1669
- parseData: true
1670
- }), {
1671
- defaultLocale: options.router.defaultLocale,
1672
- buildId: ""
1673
- }));
1674
- return Promise.resolve({
1675
- type: "redirect-internal",
1676
- newAs: `${pathname1}${src1.query}${src1.hash}`,
1677
- newUrl: `${pathname1}${src1.query}${src1.hash}`
1678
- });
1679
- }
1680
- return Promise.resolve({
1681
- type: "redirect-external",
1682
- destination: redirectTarget
1683
- });
1684
- }
1685
- return Promise.resolve({
1686
- type: "next"
1687
- });
1688
- }
1689
- function withMiddlewareEffects(options) {
1690
- return matchesMiddleware(options).then((matches)=>{
1691
- if (matches && options.fetchData) {
1692
- return options.fetchData().then((data)=>getMiddlewareData(data.dataHref, data.response, options).then((effect)=>({
1693
- dataHref: data.dataHref,
1694
- cacheKey: data.cacheKey,
1695
- json: data.json,
1696
- response: data.response,
1697
- text: data.text,
1698
- effect
1699
- }))).catch((_err)=>{
1700
- /**
1701
- * TODO: Revisit this in the future.
1702
- * For now we will not consider middleware data errors to be fatal.
1703
- * maybe we should revisit in the future.
1704
- */ return null;
1705
- });
1706
- }
1707
- return null;
1708
- });
1709
- }
1710
- const manualScrollRestoration = (/* unused pure expression or super */ null && ( false && 0));
1711
- const SSG_DATA_NOT_FOUND = Symbol("SSG_DATA_NOT_FOUND");
1712
- function fetchRetry(url, attempts, options) {
1713
- return fetch(url, {
1714
- // Cookies are required to be present for Next.js' SSG "Preview Mode".
1715
- // Cookies may also be required for `getServerSideProps`.
1716
- //
1717
- // > `fetch` won’t send cookies, unless you set the credentials init
1718
- // > option.
1719
- // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
1720
- //
1721
- // > For maximum browser compatibility when it comes to sending &
1722
- // > receiving cookies, always supply the `credentials: 'same-origin'`
1723
- // > option instead of relying on the default.
1724
- // https://github.com/github/fetch#caveats
1725
- credentials: "same-origin",
1726
- method: options.method || "GET",
1727
- headers: Object.assign({}, options.headers, {
1728
- "x-nextjs-data": "1"
1729
- })
1730
- }).then((response)=>{
1731
- return !response.ok && attempts > 1 && response.status >= 500 ? fetchRetry(url, attempts - 1, options) : response;
1732
- });
1733
- }
1734
- const backgroundCache = {};
1735
- function handleSmoothScroll(fn) {
1736
- const htmlElement = document.documentElement;
1737
- const existing = htmlElement.style.scrollBehavior;
1738
- htmlElement.style.scrollBehavior = "auto";
1739
- fn();
1740
- htmlElement.style.scrollBehavior = existing;
1741
- }
1742
- function tryToParseAsJSON(text) {
1743
- try {
1744
- return JSON.parse(text);
1745
- } catch (error) {
1746
- return null;
1747
- }
1748
- }
1749
- function fetchNextData({ dataHref , inflightCache , isPrefetch , hasMiddleware , isServerRender , parseJSON , persistCache , isBackground , unstable_skipClientCache }) {
1750
- const { href: cacheKey } = new URL(dataHref, window.location.href);
1751
- var ref1;
1752
- const getData = (params)=>{
1753
- return fetchRetry(dataHref, isServerRender ? 3 : 1, {
1754
- headers: isPrefetch ? {
1755
- purpose: "prefetch"
1756
- } : {},
1757
- method: (ref1 = params == null ? void 0 : params.method) != null ? ref1 : "GET"
1758
- }).then((response)=>{
1759
- if (response.ok && (params == null ? void 0 : params.method) === "HEAD") {
1760
- return {
1761
- dataHref,
1762
- response,
1763
- text: "",
1764
- json: {},
1765
- cacheKey
1766
- };
1767
- }
1768
- return response.text().then((text)=>{
1769
- if (!response.ok) {
1770
- /**
1771
- * When the data response is a redirect because of a middleware
1772
- * we do not consider it an error. The headers must bring the
1773
- * mapped location.
1774
- * TODO: Change the status code in the handler.
1775
- */ if (hasMiddleware && [
1776
- 301,
1777
- 302,
1778
- 307,
1779
- 308
1780
- ].includes(response.status)) {
1781
- return {
1782
- dataHref,
1783
- response,
1784
- text,
1785
- json: {},
1786
- cacheKey
1787
- };
1788
- }
1789
- if (!hasMiddleware && response.status === 404) {
1790
- var ref;
1791
- if ((ref = tryToParseAsJSON(text)) == null ? void 0 : ref.notFound) {
1792
- return {
1793
- dataHref,
1794
- json: {
1795
- notFound: SSG_DATA_NOT_FOUND
1796
- },
1797
- response,
1798
- text,
1799
- cacheKey
1800
- };
1801
- }
1802
- }
1803
- const error = new Error(`Failed to load static props`);
1804
- /**
1805
- * We should only trigger a server-side transition if this was
1806
- * caused on a client-side transition. Otherwise, we'd get into
1807
- * an infinite loop.
1808
- */ if (!isServerRender) {
1809
- (0, _routeLoader).markAssetError(error);
1810
- }
1811
- throw error;
1812
- }
1813
- return {
1814
- dataHref,
1815
- json: parseJSON ? tryToParseAsJSON(text) : null,
1816
- response,
1817
- text,
1818
- cacheKey
1819
- };
1820
- });
1821
- }).then((data)=>{
1822
- if (!persistCache || "production" !== "production" || data.response.headers.get("x-middleware-cache") === "no-cache") {
1823
- delete inflightCache[cacheKey];
1824
- }
1825
- return data;
1826
- }).catch((err)=>{
1827
- delete inflightCache[cacheKey];
1828
- throw err;
1829
- });
1830
- };
1831
- // when skipping client cache we wait to update
1832
- // inflight cache until successful data response
1833
- // this allows racing click event with fetching newer data
1834
- // without blocking navigation when stale data is available
1835
- if (unstable_skipClientCache && persistCache) {
1836
- return getData({}).then((data)=>{
1837
- inflightCache[cacheKey] = Promise.resolve(data);
1838
- return data;
1839
- });
1840
- }
1841
- if (inflightCache[cacheKey] !== undefined) {
1842
- return inflightCache[cacheKey];
1843
- }
1844
- return inflightCache[cacheKey] = getData(isBackground ? {
1845
- method: "HEAD"
1846
- } : {});
1847
- }
1848
- function createKey() {
1849
- return Math.random().toString(36).slice(2, 10);
1850
- }
1851
- function handleHardNavigation({ url , router }) {
1852
- // ensure we don't trigger a hard navigation to the same
1853
- // URL as this can end up with an infinite refresh
1854
- if (url === (0, _addBasePath).addBasePath((0, _addLocale).addLocale(router.asPath, router.locale))) {
1855
- throw new Error(`Invariant: attempted to hard navigate to the same URL ${url} ${location.href}`);
1856
- }
1857
- window.location.href = url;
1858
- }
1859
- const getCancelledHandler = ({ route , router })=>{
1860
- let cancelled = false;
1861
- const cancel = router.clc = ()=>{
1862
- cancelled = true;
1863
- };
1864
- const handleCancelled = ()=>{
1865
- if (cancelled) {
1866
- const error = new Error(`Abort fetching component for route: "${route}"`);
1867
- error.cancelled = true;
1868
- throw error;
1869
- }
1870
- if (cancel === router.clc) {
1871
- router.clc = null;
1872
- }
1873
- };
1874
- return handleCancelled;
1875
- };
1876
- class Router {
1877
- reload() {
1878
- window.location.reload();
1879
- }
1880
- /**
1881
- * Go back in history
1882
- */ back() {
1883
- window.history.back();
1884
- }
1885
- /**
1886
- * Performs a `pushState` with arguments
1887
- * @param url of the route
1888
- * @param as masks `url` for the browser
1889
- * @param options object you can define `shallow` and other options
1890
- */ push(url, as, options = {}) {
1891
- if (false) {}
1892
- ({ url , as } = prepareUrlAs(this, url, as));
1893
- return this.change("pushState", url, as, options);
1894
- }
1895
- /**
1896
- * Performs a `replaceState` with arguments
1897
- * @param url of the route
1898
- * @param as masks `url` for the browser
1899
- * @param options object you can define `shallow` and other options
1900
- */ replace(url, as, options = {}) {
1901
- ({ url , as } = prepareUrlAs(this, url, as));
1902
- return this.change("replaceState", url, as, options);
1903
- }
1904
- change(method, url, as, options, forcedScroll) {
1905
- var _this = this;
1906
- return _async_to_generator(function*() {
1907
- if (!isLocalURL(url)) {
1908
- handleHardNavigation({
1909
- url,
1910
- router: _this
1911
- });
1912
- return false;
1913
- }
1914
- // WARNING: `_h` is an internal option for handing Next.js client-side
1915
- // hydration. Your app should _never_ use this property. It may change at
1916
- // any time without notice.
1917
- const isQueryUpdating = options._h;
1918
- const shouldResolveHref = isQueryUpdating || options._shouldResolveHref || (0, _parsePath).parsePath(url).pathname === (0, _parsePath).parsePath(as).pathname;
1919
- const nextState = _extends({}, _this.state);
1920
- // for static pages with query params in the URL we delay
1921
- // marking the router ready until after the query is updated
1922
- // or a navigation has occurred
1923
- const readyStateChange = _this.isReady !== true;
1924
- _this.isReady = true;
1925
- const isSsr = _this.isSsr;
1926
- if (!isQueryUpdating) {
1927
- _this.isSsr = false;
1928
- }
1929
- // if a route transition is already in progress before
1930
- // the query updating is triggered ignore query updating
1931
- if (isQueryUpdating && _this.clc) {
1932
- return false;
1933
- }
1934
- const prevLocale = nextState.locale;
1935
- if (false) { var ref; }
1936
- // marking route changes as a navigation start entry
1937
- if (_utils.ST) {
1938
- performance.mark("routeChange");
1939
- }
1940
- const { shallow =false , scroll =true } = options;
1941
- const routeProps = {
1942
- shallow
1943
- };
1944
- if (_this._inFlightRoute && _this.clc) {
1945
- if (!isSsr) {
1946
- Router.events.emit("routeChangeError", buildCancellationError(), _this._inFlightRoute, routeProps);
1947
- }
1948
- _this.clc();
1949
- _this.clc = null;
1950
- }
1951
- as = (0, _addBasePath).addBasePath((0, _addLocale).addLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, options.locale, _this.defaultLocale));
1952
- const cleanedAs = (0, _removeLocale).removeLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, nextState.locale);
1953
- _this._inFlightRoute = as;
1954
- const localeChange = prevLocale !== nextState.locale;
1955
- // If the url change is only related to a hash change
1956
- // We should not proceed. We should only change the state.
1957
- if (!isQueryUpdating && _this.onlyAHashChange(cleanedAs) && !localeChange) {
1958
- nextState.asPath = cleanedAs;
1959
- Router.events.emit("hashChangeStart", as, routeProps);
1960
- // TODO: do we need the resolved href when only a hash change?
1961
- _this.changeState(method, url, as, _extends({}, options, {
1962
- scroll: false
1963
- }));
1964
- if (scroll) {
1965
- _this.scrollToHash(cleanedAs);
1966
- }
1967
- try {
1968
- yield _this.set(nextState, _this.components[nextState.route], null);
1969
- } catch (err) {
1970
- if ((0, _isError).default(err) && err.cancelled) {
1971
- Router.events.emit("routeChangeError", err, cleanedAs, routeProps);
1972
- }
1973
- throw err;
1974
- }
1975
- Router.events.emit("hashChangeComplete", as, routeProps);
1976
- return true;
1977
- }
1978
- let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
1979
- let { pathname , query } = parsed;
1980
- // The build manifest needs to be loaded before auto-static dynamic pages
1981
- // get their query parameters to allow ensuring they can be parsed properly
1982
- // when rewritten to
1983
- let pages, rewrites;
1984
- try {
1985
- [pages, { __rewrites: rewrites }] = yield Promise.all([
1986
- _this.pageLoader.getPageList(),
1987
- (0, _routeLoader).getClientBuildManifest(),
1988
- _this.pageLoader.getMiddleware(),
1989
- ]);
1990
- } catch (err1) {
1991
- // If we fail to resolve the page list or client-build manifest, we must
1992
- // do a server-side transition:
1993
- handleHardNavigation({
1994
- url: as,
1995
- router: _this
1996
- });
1997
- return false;
1998
- }
1999
- // If asked to change the current URL we should reload the current page
2000
- // (not location.reload() but reload getInitialProps and other Next.js stuffs)
2001
- // We also need to set the method = replaceState always
2002
- // as this should not go into the history (That's how browsers work)
2003
- // We should compare the new asPath to the current asPath, not the url
2004
- if (!_this.urlIsNew(cleanedAs) && !localeChange) {
2005
- method = "replaceState";
2006
- }
2007
- // we need to resolve the as value using rewrites for dynamic SSG
2008
- // pages to allow building the data URL correctly
2009
- let resolvedAs = as;
2010
- // url and as should always be prefixed with basePath by this
2011
- // point by either next/link or router.push/replace so strip the
2012
- // basePath from the pathname to match the pages dir 1-to-1
2013
- pathname = pathname ? (0, _removeTrailingSlash).removeTrailingSlash((0, _removeBasePath).removeBasePath(pathname)) : pathname;
2014
- // we don't attempt resolve asPath when we need to execute
2015
- // middleware as the resolving will occur server-side
2016
- const isMiddlewareMatch = yield matchesMiddleware({
2017
- asPath: as,
2018
- locale: nextState.locale,
2019
- router: _this
2020
- });
2021
- if (options.shallow && isMiddlewareMatch) {
2022
- pathname = _this.pathname;
2023
- }
2024
- if (shouldResolveHref && pathname !== "/_error") {
2025
- options._shouldResolveHref = true;
2026
- if (false) {} else {
2027
- parsed.pathname = resolveDynamicRoute(pathname, pages);
2028
- if (parsed.pathname !== pathname) {
2029
- pathname = parsed.pathname;
2030
- parsed.pathname = (0, _addBasePath).addBasePath(pathname);
2031
- if (!isMiddlewareMatch) {
2032
- url = (0, _formatUrl).formatWithValidation(parsed);
2033
- }
2034
- }
2035
- }
2036
- }
2037
- if (!isLocalURL(as)) {
2038
- if (false) {}
2039
- handleHardNavigation({
2040
- url: as,
2041
- router: _this
2042
- });
2043
- return false;
2044
- }
2045
- resolvedAs = (0, _removeLocale).removeLocale((0, _removeBasePath).removeBasePath(resolvedAs), nextState.locale);
2046
- let route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
2047
- let routeMatch = false;
2048
- if ((0, _isDynamic).isDynamicRoute(route)) {
2049
- const parsedAs1 = (0, _parseRelativeUrl).parseRelativeUrl(resolvedAs);
2050
- const asPathname = parsedAs1.pathname;
2051
- const routeRegex = (0, _routeRegex).getRouteRegex(route);
2052
- routeMatch = (0, _routeMatcher).getRouteMatcher(routeRegex)(asPathname);
2053
- const shouldInterpolate = route === asPathname;
2054
- const interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {};
2055
- if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
2056
- const missingParams = Object.keys(routeRegex.groups).filter((param)=>!query[param]);
2057
- if (missingParams.length > 0 && !isMiddlewareMatch) {
2058
- if (false) {}
2059
- throw new Error((shouldInterpolate ? `The provided \`href\` (${url}) value is missing query values (${missingParams.join(", ")}) to be interpolated properly. ` : `The provided \`as\` value (${asPathname}) is incompatible with the \`href\` value (${route}). `) + `Read more: https://nextjs.org/docs/messages/${shouldInterpolate ? "href-interpolation-failed" : "incompatible-href-as"}`);
2060
- }
2061
- } else if (shouldInterpolate) {
2062
- as = (0, _formatUrl).formatWithValidation(Object.assign({}, parsedAs1, {
2063
- pathname: interpolatedAs.result,
2064
- query: omit(query, interpolatedAs.params)
2065
- }));
2066
- } else {
2067
- // Merge params into `query`, overwriting any specified in search
2068
- Object.assign(query, routeMatch);
2069
- }
2070
- }
2071
- if (!isQueryUpdating) {
2072
- Router.events.emit("routeChangeStart", as, routeProps);
2073
- }
2074
- try {
2075
- var ref2, ref3;
2076
- let routeInfo = yield _this.getRouteInfo({
2077
- route,
2078
- pathname,
2079
- query,
2080
- as,
2081
- resolvedAs,
2082
- routeProps,
2083
- locale: nextState.locale,
2084
- isPreview: nextState.isPreview,
2085
- hasMiddleware: isMiddlewareMatch
2086
- });
2087
- if ("route" in routeInfo && isMiddlewareMatch) {
2088
- pathname = routeInfo.route || route;
2089
- route = pathname;
2090
- if (!routeProps.shallow) {
2091
- query = Object.assign({}, routeInfo.query || {}, query);
2092
- }
2093
- const cleanedParsedPathname = (0, _hasBasePath).hasBasePath(parsed.pathname) ? (0, _removeBasePath).removeBasePath(parsed.pathname) : parsed.pathname;
2094
- if (routeMatch && pathname !== cleanedParsedPathname) {
2095
- Object.keys(routeMatch).forEach((key)=>{
2096
- if (routeMatch && query[key] === routeMatch[key]) {
2097
- delete query[key];
2098
- }
2099
- });
2100
- }
2101
- if ((0, _isDynamic).isDynamicRoute(pathname)) {
2102
- const prefixedAs = !routeProps.shallow && routeInfo.resolvedAs ? routeInfo.resolvedAs : (0, _addBasePath).addBasePath((0, _addLocale).addLocale(new URL(as, location.href).pathname, nextState.locale), true);
2103
- let rewriteAs = prefixedAs;
2104
- if ((0, _hasBasePath).hasBasePath(rewriteAs)) {
2105
- rewriteAs = (0, _removeBasePath).removeBasePath(rewriteAs);
2106
- }
2107
- if (false) {}
2108
- const routeRegex1 = (0, _routeRegex).getRouteRegex(pathname);
2109
- const curRouteMatch = (0, _routeMatcher).getRouteMatcher(routeRegex1)(rewriteAs);
2110
- if (curRouteMatch) {
2111
- Object.assign(query, curRouteMatch);
2112
- }
2113
- }
2114
- }
2115
- // If the routeInfo brings a redirect we simply apply it.
2116
- if ("type" in routeInfo) {
2117
- if (routeInfo.type === "redirect-internal") {
2118
- return _this.change(method, routeInfo.newUrl, routeInfo.newAs, options);
2119
- } else {
2120
- handleHardNavigation({
2121
- url: routeInfo.destination,
2122
- router: _this
2123
- });
2124
- return new Promise(()=>{});
2125
- }
2126
- }
2127
- let { error , props , __N_SSG , __N_SSP } = routeInfo;
2128
- const component = routeInfo.Component;
2129
- if (component && component.unstable_scriptLoader) {
2130
- const scripts = [].concat(component.unstable_scriptLoader());
2131
- scripts.forEach((script)=>{
2132
- (0, _script).handleClientScriptLoad(script.props);
2133
- });
2134
- }
2135
- // handle redirect on client-transition
2136
- if ((__N_SSG || __N_SSP) && props) {
2137
- if (props.pageProps && props.pageProps.__N_REDIRECT) {
2138
- // Use the destination from redirect without adding locale
2139
- options.locale = false;
2140
- const destination = props.pageProps.__N_REDIRECT;
2141
- // check if destination is internal (resolves to a page) and attempt
2142
- // client-navigation if it is falling back to hard navigation if
2143
- // it's not
2144
- if (destination.startsWith("/") && props.pageProps.__N_REDIRECT_BASE_PATH !== false) {
2145
- const parsedHref = (0, _parseRelativeUrl).parseRelativeUrl(destination);
2146
- parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
2147
- const { url: newUrl , as: newAs } = prepareUrlAs(_this, destination, destination);
2148
- return _this.change(method, newUrl, newAs, options);
2149
- }
2150
- handleHardNavigation({
2151
- url: destination,
2152
- router: _this
2153
- });
2154
- return new Promise(()=>{});
2155
- }
2156
- nextState.isPreview = !!props.__N_PREVIEW;
2157
- // handle SSG data 404
2158
- if (props.notFound === SSG_DATA_NOT_FOUND) {
2159
- let notFoundRoute;
2160
- try {
2161
- yield _this.fetchComponent("/404");
2162
- notFoundRoute = "/404";
2163
- } catch (_) {
2164
- notFoundRoute = "/_error";
2165
- }
2166
- routeInfo = yield _this.getRouteInfo({
2167
- route: notFoundRoute,
2168
- pathname: notFoundRoute,
2169
- query,
2170
- as,
2171
- resolvedAs,
2172
- routeProps: {
2173
- shallow: false
2174
- },
2175
- locale: nextState.locale,
2176
- isPreview: nextState.isPreview
2177
- });
2178
- if ("type" in routeInfo) {
2179
- throw new Error(`Unexpected middleware effect on /404`);
2180
- }
2181
- }
2182
- }
2183
- Router.events.emit("beforeHistoryChange", as, routeProps);
2184
- _this.changeState(method, url, as, options);
2185
- if (isQueryUpdating && pathname === "/_error" && ((ref2 = self.__NEXT_DATA__.props) == null ? void 0 : (ref3 = ref2.pageProps) == null ? void 0 : ref3.statusCode) === 500 && (props == null ? void 0 : props.pageProps)) {
2186
- // ensure statusCode is still correct for static 500 page
2187
- // when updating query information
2188
- props.pageProps.statusCode = 500;
2189
- }
2190
- var _route;
2191
- // shallow routing is only allowed for same page URL changes.
2192
- const isValidShallowRoute = options.shallow && nextState.route === ((_route = routeInfo.route) != null ? _route : route);
2193
- var _scroll;
2194
- const shouldScroll = (_scroll = options.scroll) != null ? _scroll : !options._h && !isValidShallowRoute;
2195
- const resetScroll = shouldScroll ? {
2196
- x: 0,
2197
- y: 0
2198
- } : null;
2199
- // the new state that the router gonna set
2200
- const upcomingRouterState = _extends({}, nextState, {
2201
- route,
2202
- pathname,
2203
- query,
2204
- asPath: cleanedAs,
2205
- isFallback: false
2206
- });
2207
- const upcomingScrollState = forcedScroll != null ? forcedScroll : resetScroll;
2208
- // for query updates we can skip it if the state is unchanged and we don't
2209
- // need to scroll
2210
- // https://github.com/vercel/next.js/issues/37139
2211
- const canSkipUpdating = options._h && !upcomingScrollState && !readyStateChange && !localeChange && (0, _compareStates).compareRouterStates(upcomingRouterState, _this.state);
2212
- if (!canSkipUpdating) {
2213
- yield _this.set(upcomingRouterState, routeInfo, upcomingScrollState).catch((e)=>{
2214
- if (e.cancelled) error = error || e;
2215
- else throw e;
2216
- });
2217
- if (error) {
2218
- if (!isQueryUpdating) {
2219
- Router.events.emit("routeChangeError", error, cleanedAs, routeProps);
2220
- }
2221
- throw error;
2222
- }
2223
- if (false) {}
2224
- if (!isQueryUpdating) {
2225
- Router.events.emit("routeChangeComplete", as, routeProps);
2226
- }
2227
- // A hash mark # is the optional last part of a URL
2228
- const hashRegex = /#.+$/;
2229
- if (shouldScroll && hashRegex.test(as)) {
2230
- _this.scrollToHash(as);
2231
- }
2232
- }
2233
- return true;
2234
- } catch (err11) {
2235
- if ((0, _isError).default(err11) && err11.cancelled) {
2236
- return false;
2237
- }
2238
- throw err11;
2239
- }
2240
- })();
2241
- }
2242
- changeState(method, url, as, options = {}) {
2243
- if (false) {}
2244
- if (method !== "pushState" || (0, _utils).getURL() !== as) {
2245
- this._shallow = options.shallow;
2246
- window.history[method]({
2247
- url,
2248
- as,
2249
- options,
2250
- __N: true,
2251
- key: this._key = method !== "pushState" ? this._key : createKey()
2252
- }, // Passing the empty string here should be safe against future changes to the method.
2253
- // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
2254
- "", as);
2255
- }
2256
- }
2257
- handleRouteInfoError(err, pathname, query, as, routeProps, loadErrorFail) {
2258
- var _this = this;
2259
- return _async_to_generator(function*() {
2260
- console.error(err);
2261
- if (err.cancelled) {
2262
- // bubble up cancellation errors
2263
- throw err;
2264
- }
2265
- if ((0, _routeLoader).isAssetError(err) || loadErrorFail) {
2266
- Router.events.emit("routeChangeError", err, as, routeProps);
2267
- // If we can't load the page it could be one of following reasons
2268
- // 1. Page doesn't exists
2269
- // 2. Page does exist in a different zone
2270
- // 3. Internal error while loading the page
2271
- // So, doing a hard reload is the proper way to deal with this.
2272
- handleHardNavigation({
2273
- url: as,
2274
- router: _this
2275
- });
2276
- // Changing the URL doesn't block executing the current code path.
2277
- // So let's throw a cancellation error stop the routing logic.
2278
- throw buildCancellationError();
2279
- }
2280
- try {
2281
- let props;
2282
- const { page: Component , styleSheets } = yield _this.fetchComponent("/_error");
2283
- const routeInfo = {
2284
- props,
2285
- Component,
2286
- styleSheets,
2287
- err,
2288
- error: err
2289
- };
2290
- if (!routeInfo.props) {
2291
- try {
2292
- routeInfo.props = yield _this.getInitialProps(Component, {
2293
- err,
2294
- pathname,
2295
- query
2296
- });
2297
- } catch (gipErr) {
2298
- console.error("Error in error page `getInitialProps`: ", gipErr);
2299
- routeInfo.props = {};
2300
- }
2301
- }
2302
- return routeInfo;
2303
- } catch (routeInfoErr) {
2304
- return _this.handleRouteInfoError((0, _isError).default(routeInfoErr) ? routeInfoErr : new Error(routeInfoErr + ""), pathname, query, as, routeProps, true);
2305
- }
2306
- })();
2307
- }
2308
- getRouteInfo({ route: requestedRoute , pathname , query , as , resolvedAs , routeProps , locale , hasMiddleware , isPreview , unstable_skipClientCache }) {
2309
- var _this = this;
2310
- return _async_to_generator(function*() {
2311
- /**
2312
- * This `route` binding can change if there's a rewrite
2313
- * so we keep a reference to the original requested route
2314
- * so we can store the cache for it and avoid re-requesting every time
2315
- * for shallow routing purposes.
2316
- */ let route = requestedRoute;
2317
- try {
2318
- var ref, ref4, ref5;
2319
- const handleCancelled = getCancelledHandler({
2320
- route,
2321
- router: _this
2322
- });
2323
- let existingInfo = _this.components[route];
2324
- if (routeProps.shallow && existingInfo && _this.route === route) {
2325
- return existingInfo;
2326
- }
2327
- if (hasMiddleware) {
2328
- existingInfo = undefined;
2329
- }
2330
- let cachedRouteInfo = existingInfo && !("initial" in existingInfo) && "production" !== "development" ? existingInfo : undefined;
2331
- const fetchNextDataParams = {
2332
- dataHref: _this.pageLoader.getDataHref({
2333
- href: (0, _formatUrl).formatWithValidation({
2334
- pathname,
2335
- query
2336
- }),
2337
- skipInterpolation: true,
2338
- asPath: resolvedAs,
2339
- locale
2340
- }),
2341
- hasMiddleware: true,
2342
- isServerRender: _this.isSsr,
2343
- parseJSON: true,
2344
- inflightCache: _this.sdc,
2345
- persistCache: !isPreview,
2346
- isPrefetch: false,
2347
- unstable_skipClientCache
2348
- };
2349
- const data = yield withMiddlewareEffects({
2350
- fetchData: ()=>fetchNextData(fetchNextDataParams),
2351
- asPath: resolvedAs,
2352
- locale: locale,
2353
- router: _this
2354
- });
2355
- handleCancelled();
2356
- if ((data == null ? void 0 : (ref = data.effect) == null ? void 0 : ref.type) === "redirect-internal" || (data == null ? void 0 : (ref4 = data.effect) == null ? void 0 : ref4.type) === "redirect-external") {
2357
- return data.effect;
2358
- }
2359
- if ((data == null ? void 0 : (ref5 = data.effect) == null ? void 0 : ref5.type) === "rewrite") {
2360
- route = (0, _removeTrailingSlash).removeTrailingSlash(data.effect.resolvedHref);
2361
- pathname = data.effect.resolvedHref;
2362
- query = _extends({}, query, data.effect.parsedAs.query);
2363
- resolvedAs = (0, _removeBasePath).removeBasePath((0, _normalizeLocalePath).normalizeLocalePath(data.effect.parsedAs.pathname, _this.locales).pathname);
2364
- // Check again the cache with the new destination.
2365
- existingInfo = _this.components[route];
2366
- if (routeProps.shallow && existingInfo && _this.route === route && !hasMiddleware) {
2367
- // If we have a match with the current route due to rewrite,
2368
- // we can copy the existing information to the rewritten one.
2369
- // Then, we return the information along with the matched route.
2370
- return _extends({}, existingInfo, {
2371
- route
2372
- });
2373
- }
2374
- }
2375
- if (route === "/api" || route.startsWith("/api/")) {
2376
- handleHardNavigation({
2377
- url: as,
2378
- router: _this
2379
- });
2380
- return new Promise(()=>{});
2381
- }
2382
- const routeInfo = cachedRouteInfo || (yield _this.fetchComponent(route).then((res)=>({
2383
- Component: res.page,
2384
- styleSheets: res.styleSheets,
2385
- __N_SSG: res.mod.__N_SSG,
2386
- __N_SSP: res.mod.__N_SSP
2387
- })));
2388
- if (false) {}
2389
- const shouldFetchData = routeInfo.__N_SSG || routeInfo.__N_SSP;
2390
- const { props , cacheKey } = yield _this._getData(_async_to_generator(function*() {
2391
- if (shouldFetchData) {
2392
- const { json , cacheKey: _cacheKey } = (data == null ? void 0 : data.json) ? data : yield fetchNextData({
2393
- dataHref: _this.pageLoader.getDataHref({
2394
- href: (0, _formatUrl).formatWithValidation({
2395
- pathname,
2396
- query
2397
- }),
2398
- asPath: resolvedAs,
2399
- locale
2400
- }),
2401
- isServerRender: _this.isSsr,
2402
- parseJSON: true,
2403
- inflightCache: _this.sdc,
2404
- persistCache: !isPreview,
2405
- isPrefetch: false,
2406
- unstable_skipClientCache
2407
- });
2408
- return {
2409
- cacheKey: _cacheKey,
2410
- props: json || {}
2411
- };
2412
- }
2413
- return {
2414
- headers: {},
2415
- cacheKey: "",
2416
- props: yield _this.getInitialProps(routeInfo.Component, {
2417
- pathname,
2418
- query,
2419
- asPath: as,
2420
- locale,
2421
- locales: _this.locales,
2422
- defaultLocale: _this.defaultLocale
2423
- })
2424
- };
2425
- }));
2426
- // Only bust the data cache for SSP routes although
2427
- // middleware can skip cache per request with
2428
- // x-middleware-cache: no-cache as well
2429
- if (routeInfo.__N_SSP && fetchNextDataParams.dataHref) {
2430
- delete _this.sdc[cacheKey];
2431
- }
2432
- // we kick off a HEAD request in the background
2433
- // when a non-prefetch request is made to signal revalidation
2434
- if (!_this.isPreview && routeInfo.__N_SSG && "production" !== "development") {
2435
- fetchNextData(Object.assign({}, fetchNextDataParams, {
2436
- isBackground: true,
2437
- persistCache: false,
2438
- inflightCache: backgroundCache
2439
- })).catch(()=>{});
2440
- }
2441
- props.pageProps = Object.assign({}, props.pageProps);
2442
- routeInfo.props = props;
2443
- routeInfo.route = route;
2444
- routeInfo.query = query;
2445
- routeInfo.resolvedAs = resolvedAs;
2446
- _this.components[route] = routeInfo;
2447
- return routeInfo;
2448
- } catch (err) {
2449
- return _this.handleRouteInfoError((0, _isError).getProperError(err), pathname, query, as, routeProps);
2450
- }
2451
- })();
2452
- }
2453
- set(state, data, resetScroll) {
2454
- this.state = state;
2455
- return this.sub(data, this.components["/_app"].Component, resetScroll);
2456
- }
2457
- /**
2458
- * Callback to execute before replacing router state
2459
- * @param cb callback to be executed
2460
- */ beforePopState(cb) {
2461
- this._bps = cb;
2462
- }
2463
- onlyAHashChange(as) {
2464
- if (!this.asPath) return false;
2465
- const [oldUrlNoHash, oldHash] = this.asPath.split("#");
2466
- const [newUrlNoHash, newHash] = as.split("#");
2467
- // Makes sure we scroll to the provided hash if the url/hash are the same
2468
- if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
2469
- return true;
2470
- }
2471
- // If the urls are change, there's more than a hash change
2472
- if (oldUrlNoHash !== newUrlNoHash) {
2473
- return false;
2474
- }
2475
- // If the hash has changed, then it's a hash only change.
2476
- // This check is necessary to handle both the enter and
2477
- // leave hash === '' cases. The identity case falls through
2478
- // and is treated as a next reload.
2479
- return oldHash !== newHash;
2480
- }
2481
- scrollToHash(as) {
2482
- const [, hash = ""] = as.split("#");
2483
- // Scroll to top if the hash is just `#` with no value or `#top`
2484
- // To mirror browsers
2485
- if (hash === "" || hash === "top") {
2486
- handleSmoothScroll(()=>window.scrollTo(0, 0));
2487
- return;
2488
- }
2489
- // Decode hash to make non-latin anchor works.
2490
- const rawHash = decodeURIComponent(hash);
2491
- // First we check if the element by id is found
2492
- const idEl = document.getElementById(rawHash);
2493
- if (idEl) {
2494
- handleSmoothScroll(()=>idEl.scrollIntoView());
2495
- return;
2496
- }
2497
- // If there's no element with the id, we check the `name` property
2498
- // To mirror browsers
2499
- const nameEl = document.getElementsByName(rawHash)[0];
2500
- if (nameEl) {
2501
- handleSmoothScroll(()=>nameEl.scrollIntoView());
2502
- }
2503
- }
2504
- urlIsNew(asPath) {
2505
- return this.asPath !== asPath;
2506
- }
2507
- /**
2508
- * Prefetch page code, you may wait for the data during page rendering.
2509
- * This feature only works in production!
2510
- * @param url the href of prefetched page
2511
- * @param asPath the as path of the prefetched page
2512
- */ prefetch(url, asPath = url, options = {}) {
2513
- var _this = this;
2514
- return _async_to_generator(function*() {
2515
- if (false) {}
2516
- let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
2517
- let { pathname , query } = parsed;
2518
- if (false) {}
2519
- const pages = yield _this.pageLoader.getPageList();
2520
- let resolvedAs = asPath;
2521
- const locale = typeof options.locale !== "undefined" ? options.locale || undefined : _this.locale;
2522
- if (false) {}
2523
- parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
2524
- if ((0, _isDynamic).isDynamicRoute(parsed.pathname)) {
2525
- pathname = parsed.pathname;
2526
- parsed.pathname = pathname;
2527
- Object.assign(query, (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(parsed.pathname))((0, _parsePath).parsePath(asPath).pathname) || {});
2528
- url = (0, _formatUrl).formatWithValidation(parsed);
2529
- }
2530
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
2531
- if (false) {}
2532
- const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
2533
- yield Promise.all([
2534
- _this.pageLoader._isSsg(route).then((isSsg)=>{
2535
- return isSsg ? fetchNextData({
2536
- dataHref: _this.pageLoader.getDataHref({
2537
- href: url,
2538
- asPath: resolvedAs,
2539
- locale: locale
2540
- }),
2541
- isServerRender: false,
2542
- parseJSON: true,
2543
- inflightCache: _this.sdc,
2544
- persistCache: !_this.isPreview,
2545
- isPrefetch: true,
2546
- unstable_skipClientCache: options.unstable_skipClientCache || options.priority && !!true
2547
- }).then(()=>false) : false;
2548
- }),
2549
- _this.pageLoader[options.priority ? "loadPage" : "prefetch"](route),
2550
- ]);
2551
- })();
2552
- }
2553
- fetchComponent(route) {
2554
- var _this = this;
2555
- return _async_to_generator(function*() {
2556
- const handleCancelled = getCancelledHandler({
2557
- route,
2558
- router: _this
2559
- });
2560
- try {
2561
- const componentResult = yield _this.pageLoader.loadPage(route);
2562
- handleCancelled();
2563
- return componentResult;
2564
- } catch (err) {
2565
- handleCancelled();
2566
- throw err;
2567
- }
2568
- })();
2569
- }
2570
- _getData(fn) {
2571
- let cancelled = false;
2572
- const cancel = ()=>{
2573
- cancelled = true;
2574
- };
2575
- this.clc = cancel;
2576
- return fn().then((data)=>{
2577
- if (cancel === this.clc) {
2578
- this.clc = null;
2579
- }
2580
- if (cancelled) {
2581
- const err = new Error("Loading initial props cancelled");
2582
- err.cancelled = true;
2583
- throw err;
2584
- }
2585
- return data;
2586
- });
2587
- }
2588
- _getFlightData(dataHref) {
2589
- // Do not cache RSC flight response since it's not a static resource
2590
- return fetchNextData({
2591
- dataHref,
2592
- isServerRender: true,
2593
- parseJSON: false,
2594
- inflightCache: this.sdc,
2595
- persistCache: false,
2596
- isPrefetch: false
2597
- }).then(({ text })=>({
2598
- data: text
2599
- }));
2600
- }
2601
- getInitialProps(Component, ctx) {
2602
- const { Component: App } = this.components["/_app"];
2603
- const AppTree = this._wrapApp(App);
2604
- ctx.AppTree = AppTree;
2605
- return (0, _utils).loadGetInitialProps(App, {
2606
- AppTree,
2607
- Component,
2608
- router: this,
2609
- ctx
2610
- });
2611
- }
2612
- get route() {
2613
- return this.state.route;
2614
- }
2615
- get pathname() {
2616
- return this.state.pathname;
2617
- }
2618
- get query() {
2619
- return this.state.query;
2620
- }
2621
- get asPath() {
2622
- return this.state.asPath;
2623
- }
2624
- get locale() {
2625
- return this.state.locale;
2626
- }
2627
- get isFallback() {
2628
- return this.state.isFallback;
2629
- }
2630
- get isPreview() {
2631
- return this.state.isPreview;
2632
- }
2633
- constructor(pathname1, query1, as1, { initialProps , pageLoader , App , wrapApp , Component , err , subscription , isFallback , locale , locales , defaultLocale , domainLocales , isPreview }){
2634
- // Server Data Cache
2635
- this.sdc = {};
2636
- this.isFirstPopStateEvent = true;
2637
- this._key = createKey();
2638
- this.onPopState = (e)=>{
2639
- const { isFirstPopStateEvent } = this;
2640
- this.isFirstPopStateEvent = false;
2641
- const state = e.state;
2642
- if (!state) {
2643
- // We get state as undefined for two reasons.
2644
- // 1. With older safari (< 8) and older chrome (< 34)
2645
- // 2. When the URL changed with #
2646
- //
2647
- // In the both cases, we don't need to proceed and change the route.
2648
- // (as it's already changed)
2649
- // But we can simply replace the state with the new changes.
2650
- // Actually, for (1) we don't need to nothing. But it's hard to detect that event.
2651
- // So, doing the following for (1) does no harm.
2652
- const { pathname , query } = this;
2653
- this.changeState("replaceState", (0, _formatUrl).formatWithValidation({
2654
- pathname: (0, _addBasePath).addBasePath(pathname),
2655
- query
2656
- }), (0, _utils).getURL());
2657
- return;
2658
- }
2659
- // __NA is used to identify if the history entry can be handled by the app-router.
2660
- if (state.__NA) {
2661
- window.location.reload();
2662
- return;
2663
- }
2664
- if (!state.__N) {
2665
- return;
2666
- }
2667
- // Safari fires popstateevent when reopening the browser.
2668
- if (isFirstPopStateEvent && this.locale === state.options.locale && state.as === this.asPath) {
2669
- return;
2670
- }
2671
- let forcedScroll;
2672
- const { url , as , options , key } = state;
2673
- if (false) {}
2674
- this._key = key;
2675
- const { pathname: pathname1 } = (0, _parseRelativeUrl).parseRelativeUrl(url);
2676
- // Make sure we don't re-render on initial load,
2677
- // can be caused by navigating back from an external site
2678
- if (this.isSsr && as === (0, _addBasePath).addBasePath(this.asPath) && pathname1 === (0, _addBasePath).addBasePath(this.pathname)) {
2679
- return;
2680
- }
2681
- // If the downstream application returns falsy, return.
2682
- // They will then be responsible for handling the event.
2683
- if (this._bps && !this._bps(state)) {
2684
- return;
2685
- }
2686
- this.change("replaceState", url, as, Object.assign({}, options, {
2687
- shallow: options.shallow && this._shallow,
2688
- locale: options.locale || this.defaultLocale,
2689
- // @ts-ignore internal value not exposed on types
2690
- _h: 0
2691
- }), forcedScroll);
2692
- };
2693
- // represents the current component key
2694
- const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname1);
2695
- // set up the component cache (by route keys)
2696
- this.components = {};
2697
- // We should not keep the cache, if there's an error
2698
- // Otherwise, this cause issues when when going back and
2699
- // come again to the errored page.
2700
- if (pathname1 !== "/_error") {
2701
- this.components[route] = {
2702
- Component,
2703
- initial: true,
2704
- props: initialProps,
2705
- err,
2706
- __N_SSG: initialProps && initialProps.__N_SSG,
2707
- __N_SSP: initialProps && initialProps.__N_SSP
2708
- };
2709
- }
2710
- this.components["/_app"] = {
2711
- Component: App,
2712
- styleSheets: []
2713
- };
2714
- // Backwards compat for Router.router.events
2715
- // TODO: Should be remove the following major version as it was never documented
2716
- this.events = Router.events;
2717
- this.pageLoader = pageLoader;
2718
- // if auto prerendered and dynamic route wait to update asPath
2719
- // until after mount to prevent hydration mismatch
2720
- const autoExportDynamic = (0, _isDynamic).isDynamicRoute(pathname1) && self.__NEXT_DATA__.autoExport;
2721
- this.basePath = false || "";
2722
- this.sub = subscription;
2723
- this.clc = null;
2724
- this._wrapApp = wrapApp;
2725
- // make sure to ignore extra popState in safari on navigating
2726
- // back from external site
2727
- this.isSsr = true;
2728
- this.isLocaleDomain = false;
2729
- this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp || !autoExportDynamic && !self.location.search && !false);
2730
- if (false) {}
2731
- this.state = {
2732
- route,
2733
- pathname: pathname1,
2734
- query: query1,
2735
- asPath: autoExportDynamic ? pathname1 : as1,
2736
- isPreview: !!isPreview,
2737
- locale: false ? 0 : undefined,
2738
- isFallback
2739
- };
2740
- this._initialMatchesMiddlewarePromise = Promise.resolve(false);
2741
- if (false) {}
2742
- }
2743
- }
2744
- Router.events = (0, _mitt).default();
2745
- exports["default"] = Router; //# sourceMappingURL=router.js.map
2746
-
2747
-
2748
- /***/ }),
2749
-
2750
- /***/ 6843:
2751
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2752
-
2753
- module.exports = __webpack_require__(1484)
2754
-
2755
-
2756
- /***/ })
2757
-
2758
- };
2759
- ;