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