@scrabble-solver/scrabble-solver 2.10.8 → 2.10.10
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 -1
- package/.next/build-manifest.json +15 -15
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/.next/cache/next-server.js.nft.json +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/images-manifest.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/131.js +24 -17
- package/.next/server/chunks/176.js +443 -288
- package/.next/server/chunks/50.js +712 -1025
- package/.next/server/chunks/664.js +27 -2414
- package/.next/server/chunks/859.js +29 -1
- package/.next/server/font-loader-manifest.js +1 -0
- package/.next/server/font-loader-manifest.json +6 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +2 -2
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.html +1 -12
- package/.next/server/pages/_app.js +13 -133
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js +133 -17
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/solve.js +5 -6
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/index.js +34 -154
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/chunks/main-74c4d6b2b5c362f3.js +1 -0
- package/.next/static/chunks/pages/{404-8cab6d62fe4ead73.js → 404-d5ff00df1c687977.js} +1 -1
- package/.next/static/chunks/pages/_app-3272e798504c40d8.js +28 -0
- package/.next/static/chunks/pages/index-5c2544930e46c5ce.js +1 -0
- package/.next/static/chunks/webpack-6ef43a8d4a395f49.js +1 -0
- package/.next/static/css/336e75db2b74b157.css +2 -0
- package/.next/static/css/{d1cc6b79b211b7b8.css → ec4e47a6b1866fe5.css} +1 -1
- package/.next/static/warzWo25tDxo_Eiv9T6f2/_buildManifest.js +1 -0
- package/.next/trace +55 -55
- package/package.json +12 -11
- package/src/components/Board/Board.module.scss +14 -0
- package/src/components/Board/Board.tsx +117 -19
- package/src/components/Board/BoardPure.tsx +7 -15
- package/src/components/Board/components/Actions/Actions.module.scss +64 -0
- package/src/components/Board/components/Actions/Actions.tsx +74 -0
- package/src/components/Board/components/Actions/index.ts +1 -0
- package/src/components/Board/components/Cell/Cell.module.scss +10 -121
- package/src/components/Board/components/Cell/Cell.tsx +0 -37
- package/src/components/Board/components/Cell/CellPure.tsx +5 -68
- package/src/components/Board/components/index.ts +1 -0
- package/src/components/Board/hooks/useGrid.ts +16 -16
- package/src/components/Modal/Modal.module.scss +3 -1
- package/src/components/Rack/Rack.module.scss +2 -1
- package/src/components/Solver/Solver.module.scss +0 -5
- package/src/components/Solver/Solver.tsx +1 -1
- package/src/components/Tile/Tile.module.scss +0 -26
- package/src/components/Tile/Tile.tsx +5 -3
- package/src/components/Tile/TilePure.tsx +16 -18
- package/src/hooks/useLocalStorage/useLocalStorageBoard.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageConfigId.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageLocale.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageRack.ts +6 -3
- package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.module.scss +1 -1
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.module.scss +2 -2
- package/src/parameters/index.ts +5 -3
- package/src/styles/animations.scss +10 -0
- package/src/styles/global.scss +2 -2
- package/src/styles/mixins.scss +56 -1
- package/src/styles/variables.scss +5 -2
- package/.next/server/chunks/210.js +0 -122
- package/.next/server/chunks/676.js +0 -32
- package/.next/static/Cs23uxWG6AxS72F2yrjHu/_buildManifest.js +0 -1
- package/.next/static/chunks/main-f11614d8aa7ee555.js +0 -1
- package/.next/static/chunks/pages/_app-dcbbb823dc93a031.js +0 -28
- package/.next/static/chunks/pages/index-df1ff01aa82d2d4d.js +0 -1
- package/.next/static/chunks/webpack-59c5c889f52620d6.js +0 -1
- package/.next/static/css/bf2e969b88c4e3dd.css +0 -2
- /package/.next/static/{Cs23uxWG6AxS72F2yrjHu → warzWo25tDxo_Eiv9T6f2}/_ssgManifest.js +0 -0
|
@@ -2,7 +2,7 @@ exports.id = 664;
|
|
|
2
2
|
exports.ids = [664];
|
|
3
3
|
exports.modules = {
|
|
4
4
|
|
|
5
|
-
/***/
|
|
5
|
+
/***/ 92648:
|
|
6
6
|
/***/ ((__unused_webpack_module, exports) => {
|
|
7
7
|
|
|
8
8
|
"use strict";
|
|
@@ -14,36 +14,12 @@ __webpack_unused_export__ = ({
|
|
|
14
14
|
Object.defineProperty(exports, "Z", ({
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function() {
|
|
17
|
-
return
|
|
17
|
+
return _interopRequireDefault;
|
|
18
18
|
}
|
|
19
19
|
}));
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var value = info.value;
|
|
24
|
-
} catch (error) {
|
|
25
|
-
reject(error);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (info.done) {
|
|
29
|
-
resolve(value);
|
|
30
|
-
} else {
|
|
31
|
-
Promise.resolve(value).then(_next, _throw);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function _asyncToGenerator(fn) {
|
|
35
|
-
return function() {
|
|
36
|
-
var self = this, args = arguments;
|
|
37
|
-
return new Promise(function(resolve, reject) {
|
|
38
|
-
var gen = fn.apply(self, args);
|
|
39
|
-
function _next(value) {
|
|
40
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
41
|
-
}
|
|
42
|
-
function _throw(err) {
|
|
43
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
44
|
-
}
|
|
45
|
-
_next(undefined);
|
|
46
|
-
});
|
|
20
|
+
function _interopRequireDefault(obj) {
|
|
21
|
+
return obj && obj.__esModule ? obj : {
|
|
22
|
+
default: obj
|
|
47
23
|
};
|
|
48
24
|
}
|
|
49
25
|
|
|
@@ -132,30 +108,6 @@ if ((typeof exports.default === "function" || typeof exports.default === "object
|
|
|
132
108
|
} //# sourceMappingURL=add-locale.js.map
|
|
133
109
|
|
|
134
110
|
|
|
135
|
-
/***/ }),
|
|
136
|
-
|
|
137
|
-
/***/ 84643:
|
|
138
|
-
/***/ ((module, exports) => {
|
|
139
|
-
|
|
140
|
-
"use strict";
|
|
141
|
-
|
|
142
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
143
|
-
value: true
|
|
144
|
-
}));
|
|
145
|
-
exports.detectDomainLocale = void 0;
|
|
146
|
-
const detectDomainLocale = (...args)=>{
|
|
147
|
-
if (false) {}
|
|
148
|
-
};
|
|
149
|
-
exports.detectDomainLocale = detectDomainLocale;
|
|
150
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
151
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
152
|
-
value: true
|
|
153
|
-
});
|
|
154
|
-
Object.assign(exports.default, exports);
|
|
155
|
-
module.exports = exports.default;
|
|
156
|
-
} //# sourceMappingURL=detect-domain-locale.js.map
|
|
157
|
-
|
|
158
|
-
|
|
159
111
|
/***/ }),
|
|
160
112
|
|
|
161
113
|
/***/ 10227:
|
|
@@ -182,164 +134,6 @@ if ((typeof exports.default === "function" || typeof exports.default === "object
|
|
|
182
134
|
} //# sourceMappingURL=get-domain-locale.js.map
|
|
183
135
|
|
|
184
136
|
|
|
185
|
-
/***/ }),
|
|
186
|
-
|
|
187
|
-
/***/ 10928:
|
|
188
|
-
/***/ ((module, exports, __webpack_require__) => {
|
|
189
|
-
|
|
190
|
-
"use strict";
|
|
191
|
-
|
|
192
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
193
|
-
value: true
|
|
194
|
-
}));
|
|
195
|
-
exports.hasBasePath = hasBasePath;
|
|
196
|
-
var _pathHasPrefix = __webpack_require__(34567);
|
|
197
|
-
const basePath = false || "";
|
|
198
|
-
function hasBasePath(path) {
|
|
199
|
-
return (0, _pathHasPrefix).pathHasPrefix(path, basePath);
|
|
200
|
-
}
|
|
201
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
202
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
203
|
-
value: true
|
|
204
|
-
});
|
|
205
|
-
Object.assign(exports.default, exports);
|
|
206
|
-
module.exports = exports.default;
|
|
207
|
-
} //# sourceMappingURL=has-base-path.js.map
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
/***/ }),
|
|
211
|
-
|
|
212
|
-
/***/ 31831:
|
|
213
|
-
/***/ ((module, exports) => {
|
|
214
|
-
|
|
215
|
-
"use strict";
|
|
216
|
-
|
|
217
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
218
|
-
value: true
|
|
219
|
-
}));
|
|
220
|
-
exports["default"] = initHeadManager;
|
|
221
|
-
exports.isEqualNode = isEqualNode;
|
|
222
|
-
exports.DOMAttributeNames = void 0;
|
|
223
|
-
function initHeadManager() {
|
|
224
|
-
return {
|
|
225
|
-
mountedInstances: new Set(),
|
|
226
|
-
updateHead: (head)=>{
|
|
227
|
-
const tags = {};
|
|
228
|
-
head.forEach((h)=>{
|
|
229
|
-
if (// it won't be inlined. In this case revert to the original behavior
|
|
230
|
-
h.type === "link" && h.props["data-optimized-fonts"]) {
|
|
231
|
-
if (document.querySelector(`style[data-href="${h.props["data-href"]}"]`)) {
|
|
232
|
-
return;
|
|
233
|
-
} else {
|
|
234
|
-
h.props.href = h.props["data-href"];
|
|
235
|
-
h.props["data-href"] = undefined;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
const components = tags[h.type] || [];
|
|
239
|
-
components.push(h);
|
|
240
|
-
tags[h.type] = components;
|
|
241
|
-
});
|
|
242
|
-
const titleComponent = tags.title ? tags.title[0] : null;
|
|
243
|
-
let title = "";
|
|
244
|
-
if (titleComponent) {
|
|
245
|
-
const { children } = titleComponent.props;
|
|
246
|
-
title = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
|
|
247
|
-
}
|
|
248
|
-
if (title !== document.title) document.title = title;
|
|
249
|
-
[
|
|
250
|
-
"meta",
|
|
251
|
-
"base",
|
|
252
|
-
"link",
|
|
253
|
-
"style",
|
|
254
|
-
"script"
|
|
255
|
-
].forEach((type)=>{
|
|
256
|
-
updateElements(type, tags[type] || []);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
const DOMAttributeNames = {
|
|
262
|
-
acceptCharset: "accept-charset",
|
|
263
|
-
className: "class",
|
|
264
|
-
htmlFor: "for",
|
|
265
|
-
httpEquiv: "http-equiv",
|
|
266
|
-
noModule: "noModule"
|
|
267
|
-
};
|
|
268
|
-
exports.DOMAttributeNames = DOMAttributeNames;
|
|
269
|
-
function reactElementToDOM({ type , props }) {
|
|
270
|
-
const el = document.createElement(type);
|
|
271
|
-
for(const p in props){
|
|
272
|
-
if (!props.hasOwnProperty(p)) continue;
|
|
273
|
-
if (p === "children" || p === "dangerouslySetInnerHTML") continue;
|
|
274
|
-
// we don't render undefined props to the DOM
|
|
275
|
-
if (props[p] === undefined) continue;
|
|
276
|
-
const attr = DOMAttributeNames[p] || p.toLowerCase();
|
|
277
|
-
if (type === "script" && (attr === "async" || attr === "defer" || attr === "noModule")) {
|
|
278
|
-
el[attr] = !!props[p];
|
|
279
|
-
} else {
|
|
280
|
-
el.setAttribute(attr, props[p]);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
const { children , dangerouslySetInnerHTML } = props;
|
|
284
|
-
if (dangerouslySetInnerHTML) {
|
|
285
|
-
el.innerHTML = dangerouslySetInnerHTML.__html || "";
|
|
286
|
-
} else if (children) {
|
|
287
|
-
el.textContent = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
|
|
288
|
-
}
|
|
289
|
-
return el;
|
|
290
|
-
}
|
|
291
|
-
function isEqualNode(oldTag, newTag) {
|
|
292
|
-
if (oldTag instanceof HTMLElement && newTag instanceof HTMLElement) {
|
|
293
|
-
const nonce = newTag.getAttribute("nonce");
|
|
294
|
-
// Only strip the nonce if `oldTag` has had it stripped. An element's nonce attribute will not
|
|
295
|
-
// be stripped if there is no content security policy response header that includes a nonce.
|
|
296
|
-
if (nonce && !oldTag.getAttribute("nonce")) {
|
|
297
|
-
const cloneTag = newTag.cloneNode(true);
|
|
298
|
-
cloneTag.setAttribute("nonce", "");
|
|
299
|
-
cloneTag.nonce = nonce;
|
|
300
|
-
return nonce === oldTag.nonce && oldTag.isEqualNode(cloneTag);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return oldTag.isEqualNode(newTag);
|
|
304
|
-
}
|
|
305
|
-
function updateElements(type, components) {
|
|
306
|
-
const headEl = document.getElementsByTagName("head")[0];
|
|
307
|
-
const headCountEl = headEl.querySelector("meta[name=next-head-count]");
|
|
308
|
-
if (false) {}
|
|
309
|
-
const headCount = Number(headCountEl.content);
|
|
310
|
-
const oldTags = [];
|
|
311
|
-
for(let i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = (j == null ? void 0 : j.previousElementSibling) || null){
|
|
312
|
-
var ref;
|
|
313
|
-
if ((j == null ? void 0 : (ref = j.tagName) == null ? void 0 : ref.toLowerCase()) === type) {
|
|
314
|
-
oldTags.push(j);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
const newTags = components.map(reactElementToDOM).filter((newTag)=>{
|
|
318
|
-
for(let k = 0, len = oldTags.length; k < len; k++){
|
|
319
|
-
const oldTag = oldTags[k];
|
|
320
|
-
if (isEqualNode(oldTag, newTag)) {
|
|
321
|
-
oldTags.splice(k, 1);
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return true;
|
|
326
|
-
});
|
|
327
|
-
oldTags.forEach((t)=>{
|
|
328
|
-
var ref;
|
|
329
|
-
return (ref = t.parentNode) == null ? void 0 : ref.removeChild(t);
|
|
330
|
-
});
|
|
331
|
-
newTags.forEach((t)=>headEl.insertBefore(t, headCountEl));
|
|
332
|
-
headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
|
|
333
|
-
}
|
|
334
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
335
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
336
|
-
value: true
|
|
337
|
-
});
|
|
338
|
-
Object.assign(exports.default, exports);
|
|
339
|
-
module.exports = exports.default;
|
|
340
|
-
} //# sourceMappingURL=head-manager.js.map
|
|
341
|
-
|
|
342
|
-
|
|
343
137
|
/***/ }),
|
|
344
138
|
|
|
345
139
|
/***/ 31551:
|
|
@@ -355,8 +149,10 @@ exports["default"] = void 0;
|
|
|
355
149
|
var _interop_require_default = (__webpack_require__(92648)/* ["default"] */ .Z);
|
|
356
150
|
var _object_without_properties_loose = (__webpack_require__(17273)/* ["default"] */ .Z);
|
|
357
151
|
var _react = _interop_require_default(__webpack_require__(16689));
|
|
358
|
-
var
|
|
152
|
+
var _resolveHref = __webpack_require__(87782);
|
|
153
|
+
var _isLocalUrl = __webpack_require__(71109);
|
|
359
154
|
var _formatUrl = __webpack_require__(23938);
|
|
155
|
+
var _utils = __webpack_require__(59232);
|
|
360
156
|
var _addLocale = __webpack_require__(54465);
|
|
361
157
|
var _routerContext = __webpack_require__(24964);
|
|
362
158
|
var _appRouterContext = __webpack_require__(3280);
|
|
@@ -364,11 +160,12 @@ var _useIntersection = __webpack_require__(69246);
|
|
|
364
160
|
var _getDomainLocale = __webpack_require__(10227);
|
|
365
161
|
var _addBasePath = __webpack_require__(33468);
|
|
366
162
|
const prefetched = new Set();
|
|
367
|
-
function prefetch(router, href, as, options) {
|
|
163
|
+
function prefetch(router, href, as, options, isAppRouter) {
|
|
368
164
|
if (true) {
|
|
369
165
|
return;
|
|
370
166
|
}
|
|
371
|
-
|
|
167
|
+
// app-router supports external urls out of the box so it shouldn't short-circuit here as support for e.g. `replace` is added in the app-router.
|
|
168
|
+
if (!isAppRouter && !(0, _isLocalUrl).isLocalURL(href)) {
|
|
372
169
|
return;
|
|
373
170
|
}
|
|
374
171
|
// We should only dedupe requests when experimental.optimisticClientCache is
|
|
@@ -392,14 +189,16 @@ function prefetch(router, href, as, options) {
|
|
|
392
189
|
});
|
|
393
190
|
}
|
|
394
191
|
function isModifiedEvent(event) {
|
|
395
|
-
const
|
|
192
|
+
const eventTarget = event.currentTarget;
|
|
193
|
+
const target = eventTarget.getAttribute("target");
|
|
396
194
|
return target && target !== "_self" || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.nativeEvent && event.nativeEvent.which === 2;
|
|
397
195
|
}
|
|
398
196
|
function linkClicked(e, router, href, as, replace, shallow, scroll, locale, isAppRouter, prefetchEnabled) {
|
|
399
197
|
const { nodeName } = e.currentTarget;
|
|
400
198
|
// anchors inside an svg have a lowercase nodeName
|
|
401
199
|
const isAnchorNodeName = nodeName.toUpperCase() === "A";
|
|
402
|
-
if (isAnchorNodeName && (isModifiedEvent(e) ||
|
|
200
|
+
if (isAnchorNodeName && (isModifiedEvent(e) || // app-router supports external urls out of the box so it shouldn't short-circuit here as support for e.g. `replace` is added in the app-router.
|
|
201
|
+
!isAppRouter && !(0, _isLocalUrl).isLocalURL(href))) {
|
|
403
202
|
// ignore click for browser’s default behavior
|
|
404
203
|
return;
|
|
405
204
|
}
|
|
@@ -470,10 +269,10 @@ function formatStringOrUrl(urlObjOrString) {
|
|
|
470
269
|
as: asProp ? formatStringOrUrl(asProp) : resolvedHref
|
|
471
270
|
};
|
|
472
271
|
}
|
|
473
|
-
const [resolvedHref, resolvedAs] = (0,
|
|
272
|
+
const [resolvedHref, resolvedAs] = (0, _resolveHref).resolveHref(pagesRouter, hrefProp, true);
|
|
474
273
|
return {
|
|
475
274
|
href: resolvedHref,
|
|
476
|
-
as: asProp ? (0,
|
|
275
|
+
as: asProp ? (0, _resolveHref).resolveHref(pagesRouter, asProp) : resolvedAs || resolvedHref
|
|
477
276
|
};
|
|
478
277
|
}, [
|
|
479
278
|
pagesRouter,
|
|
@@ -530,7 +329,7 @@ function formatStringOrUrl(urlObjOrString) {
|
|
|
530
329
|
// Prefetch the URL.
|
|
531
330
|
prefetch(router, href, as, {
|
|
532
331
|
locale
|
|
533
|
-
});
|
|
332
|
+
}, isAppRouter);
|
|
534
333
|
}, [
|
|
535
334
|
as,
|
|
536
335
|
href,
|
|
@@ -538,7 +337,8 @@ function formatStringOrUrl(urlObjOrString) {
|
|
|
538
337
|
locale,
|
|
539
338
|
prefetchEnabled,
|
|
540
339
|
pagesRouter == null ? void 0 : pagesRouter.locale,
|
|
541
|
-
router
|
|
340
|
+
router,
|
|
341
|
+
isAppRouter
|
|
542
342
|
]);
|
|
543
343
|
const childProps = {
|
|
544
344
|
ref: setRef,
|
|
@@ -576,7 +376,7 @@ function formatStringOrUrl(urlObjOrString) {
|
|
|
576
376
|
priority: true,
|
|
577
377
|
// @see {https://github.com/vercel/next.js/discussions/40268?sort=top#discussioncomment-3572642}
|
|
578
378
|
bypassPrefetchedCheck: true
|
|
579
|
-
});
|
|
379
|
+
}, isAppRouter);
|
|
580
380
|
},
|
|
581
381
|
onTouchStart (e) {
|
|
582
382
|
if (!legacyBehavior && typeof onTouchStartProp === "function") {
|
|
@@ -596,12 +396,15 @@ function formatStringOrUrl(urlObjOrString) {
|
|
|
596
396
|
priority: true,
|
|
597
397
|
// @see {https://github.com/vercel/next.js/discussions/40268?sort=top#discussioncomment-3572642}
|
|
598
398
|
bypassPrefetchedCheck: true
|
|
599
|
-
});
|
|
399
|
+
}, isAppRouter);
|
|
600
400
|
}
|
|
601
401
|
};
|
|
602
402
|
// If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is
|
|
603
|
-
// defined, we specify the current 'href', so that repetition is not needed by the user
|
|
604
|
-
|
|
403
|
+
// defined, we specify the current 'href', so that repetition is not needed by the user.
|
|
404
|
+
// If the url is absolute, we can bypass the logic to prepend the domain and locale.
|
|
405
|
+
if ((0, _utils).isAbsoluteUrl(as)) {
|
|
406
|
+
childProps.href = as;
|
|
407
|
+
} else if (!legacyBehavior || passHref || child.type === "a" && !("href" in child.props)) {
|
|
605
408
|
const curLocale = typeof locale !== "undefined" ? locale : pagesRouter == null ? void 0 : pagesRouter.locale;
|
|
606
409
|
// we only render domain locales if we are currently on a domain locale
|
|
607
410
|
// so that locale links are still visitable in development/preview envs
|
|
@@ -652,59 +455,6 @@ if ((typeof exports.default === "function" || typeof exports.default === "object
|
|
|
652
455
|
} //# sourceMappingURL=normalize-trailing-slash.js.map
|
|
653
456
|
|
|
654
457
|
|
|
655
|
-
/***/ }),
|
|
656
|
-
|
|
657
|
-
/***/ 82813:
|
|
658
|
-
/***/ ((module, exports, __webpack_require__) => {
|
|
659
|
-
|
|
660
|
-
"use strict";
|
|
661
|
-
|
|
662
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
663
|
-
value: true
|
|
664
|
-
}));
|
|
665
|
-
exports.removeBasePath = removeBasePath;
|
|
666
|
-
var _hasBasePath = __webpack_require__(10928);
|
|
667
|
-
const basePath = false || "";
|
|
668
|
-
function removeBasePath(path) {
|
|
669
|
-
if (false) {}
|
|
670
|
-
path = path.slice(basePath.length);
|
|
671
|
-
if (!path.startsWith("/")) path = `/${path}`;
|
|
672
|
-
return path;
|
|
673
|
-
}
|
|
674
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
675
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
676
|
-
value: true
|
|
677
|
-
});
|
|
678
|
-
Object.assign(exports.default, exports);
|
|
679
|
-
module.exports = exports.default;
|
|
680
|
-
} //# sourceMappingURL=remove-base-path.js.map
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
/***/ }),
|
|
684
|
-
|
|
685
|
-
/***/ 66876:
|
|
686
|
-
/***/ ((module, exports, __webpack_require__) => {
|
|
687
|
-
|
|
688
|
-
"use strict";
|
|
689
|
-
|
|
690
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
691
|
-
value: true
|
|
692
|
-
}));
|
|
693
|
-
exports.removeLocale = removeLocale;
|
|
694
|
-
var _parsePath = __webpack_require__(28854);
|
|
695
|
-
function removeLocale(path, locale) {
|
|
696
|
-
if (false) {}
|
|
697
|
-
return path;
|
|
698
|
-
}
|
|
699
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
700
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
701
|
-
value: true
|
|
702
|
-
});
|
|
703
|
-
Object.assign(exports.default, exports);
|
|
704
|
-
module.exports = exports.default;
|
|
705
|
-
} //# sourceMappingURL=remove-locale.js.map
|
|
706
|
-
|
|
707
|
-
|
|
708
458
|
/***/ }),
|
|
709
459
|
|
|
710
460
|
/***/ 44686:
|
|
@@ -741,596 +491,6 @@ if ((typeof exports.default === "function" || typeof exports.default === "object
|
|
|
741
491
|
} //# sourceMappingURL=request-idle-callback.js.map
|
|
742
492
|
|
|
743
493
|
|
|
744
|
-
/***/ }),
|
|
745
|
-
|
|
746
|
-
/***/ 82497:
|
|
747
|
-
/***/ ((module, exports, __webpack_require__) => {
|
|
748
|
-
|
|
749
|
-
"use strict";
|
|
750
|
-
|
|
751
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
752
|
-
value: true
|
|
753
|
-
}));
|
|
754
|
-
exports.markAssetError = markAssetError;
|
|
755
|
-
exports.isAssetError = isAssetError;
|
|
756
|
-
exports.getClientBuildManifest = getClientBuildManifest;
|
|
757
|
-
exports.createRouteLoader = createRouteLoader;
|
|
758
|
-
var _interop_require_default = (__webpack_require__(92648)/* ["default"] */ .Z);
|
|
759
|
-
var _getAssetPathFromRoute = _interop_require_default(__webpack_require__(29565));
|
|
760
|
-
var _trustedTypes = __webpack_require__(65407);
|
|
761
|
-
var _requestIdleCallback = __webpack_require__(44686);
|
|
762
|
-
// 3.8s was arbitrarily chosen as it's what https://web.dev/interactive
|
|
763
|
-
// considers as "Good" time-to-interactive. We must assume something went
|
|
764
|
-
// wrong beyond this point, and then fall-back to a full page transition to
|
|
765
|
-
// show the user something of value.
|
|
766
|
-
const MS_MAX_IDLE_DELAY = 3800;
|
|
767
|
-
function withFuture(key, map, generator) {
|
|
768
|
-
let entry = map.get(key);
|
|
769
|
-
if (entry) {
|
|
770
|
-
if ("future" in entry) {
|
|
771
|
-
return entry.future;
|
|
772
|
-
}
|
|
773
|
-
return Promise.resolve(entry);
|
|
774
|
-
}
|
|
775
|
-
let resolver;
|
|
776
|
-
const prom = new Promise((resolve)=>{
|
|
777
|
-
resolver = resolve;
|
|
778
|
-
});
|
|
779
|
-
map.set(key, entry = {
|
|
780
|
-
resolve: resolver,
|
|
781
|
-
future: prom
|
|
782
|
-
});
|
|
783
|
-
return generator ? generator() // eslint-disable-next-line no-sequences
|
|
784
|
-
.then((value)=>(resolver(value), value)).catch((err)=>{
|
|
785
|
-
map.delete(key);
|
|
786
|
-
throw err;
|
|
787
|
-
}) : prom;
|
|
788
|
-
}
|
|
789
|
-
const ASSET_LOAD_ERROR = Symbol("ASSET_LOAD_ERROR");
|
|
790
|
-
function markAssetError(err) {
|
|
791
|
-
return Object.defineProperty(err, ASSET_LOAD_ERROR, {});
|
|
792
|
-
}
|
|
793
|
-
function isAssetError(err) {
|
|
794
|
-
return err && ASSET_LOAD_ERROR in err;
|
|
795
|
-
}
|
|
796
|
-
function hasPrefetch(link) {
|
|
797
|
-
try {
|
|
798
|
-
link = document.createElement("link");
|
|
799
|
-
return(// with relList.support
|
|
800
|
-
!!window.MSInputMethodContext && !!document.documentMode || link.relList.supports("prefetch"));
|
|
801
|
-
} catch (e) {
|
|
802
|
-
return false;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
const canPrefetch = hasPrefetch();
|
|
806
|
-
function prefetchViaDom(href, as, link) {
|
|
807
|
-
return new Promise((resolve, reject)=>{
|
|
808
|
-
const selector = `
|
|
809
|
-
link[rel="prefetch"][href^="${href}"],
|
|
810
|
-
link[rel="preload"][href^="${href}"],
|
|
811
|
-
script[src^="${href}"]`;
|
|
812
|
-
if (document.querySelector(selector)) {
|
|
813
|
-
return resolve();
|
|
814
|
-
}
|
|
815
|
-
link = document.createElement("link");
|
|
816
|
-
// The order of property assignment here is intentional:
|
|
817
|
-
if (as) link.as = as;
|
|
818
|
-
link.rel = `prefetch`;
|
|
819
|
-
link.crossOrigin = undefined;
|
|
820
|
-
link.onload = resolve;
|
|
821
|
-
link.onerror = ()=>reject(markAssetError(new Error(`Failed to prefetch: ${href}`)));
|
|
822
|
-
// `href` should always be last:
|
|
823
|
-
link.href = href;
|
|
824
|
-
document.head.appendChild(link);
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
|
-
function appendScript(src, script) {
|
|
828
|
-
return new Promise((resolve, reject)=>{
|
|
829
|
-
script = document.createElement("script");
|
|
830
|
-
// The order of property assignment here is intentional.
|
|
831
|
-
// 1. Setup success/failure hooks in case the browser synchronously
|
|
832
|
-
// executes when `src` is set.
|
|
833
|
-
script.onload = resolve;
|
|
834
|
-
script.onerror = ()=>reject(markAssetError(new Error(`Failed to load script: ${src}`)));
|
|
835
|
-
// 2. Configure the cross-origin attribute before setting `src` in case the
|
|
836
|
-
// browser begins to fetch.
|
|
837
|
-
script.crossOrigin = undefined;
|
|
838
|
-
// 3. Finally, set the source and inject into the DOM in case the child
|
|
839
|
-
// must be appended for fetching to start.
|
|
840
|
-
script.src = src;
|
|
841
|
-
document.body.appendChild(script);
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
// We wait for pages to be built in dev before we start the route transition
|
|
845
|
-
// timeout to prevent an un-necessary hard navigation in development.
|
|
846
|
-
let devBuildPromise;
|
|
847
|
-
// Resolve a promise that times out after given amount of milliseconds.
|
|
848
|
-
function resolvePromiseWithTimeout(p, ms, err) {
|
|
849
|
-
return new Promise((resolve, reject)=>{
|
|
850
|
-
let cancelled = false;
|
|
851
|
-
p.then((r)=>{
|
|
852
|
-
// Resolved, cancel the timeout
|
|
853
|
-
cancelled = true;
|
|
854
|
-
resolve(r);
|
|
855
|
-
}).catch(reject);
|
|
856
|
-
// We wrap these checks separately for better dead-code elimination in
|
|
857
|
-
// production bundles.
|
|
858
|
-
if (false) {}
|
|
859
|
-
if (true) {
|
|
860
|
-
(0, _requestIdleCallback).requestIdleCallback(()=>setTimeout(()=>{
|
|
861
|
-
if (!cancelled) {
|
|
862
|
-
reject(err);
|
|
863
|
-
}
|
|
864
|
-
}, ms));
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
function getClientBuildManifest() {
|
|
869
|
-
if (self.__BUILD_MANIFEST) {
|
|
870
|
-
return Promise.resolve(self.__BUILD_MANIFEST);
|
|
871
|
-
}
|
|
872
|
-
const onBuildManifest = new Promise((resolve)=>{
|
|
873
|
-
// Mandatory because this is not concurrent safe:
|
|
874
|
-
const cb = self.__BUILD_MANIFEST_CB;
|
|
875
|
-
self.__BUILD_MANIFEST_CB = ()=>{
|
|
876
|
-
resolve(self.__BUILD_MANIFEST);
|
|
877
|
-
cb && cb();
|
|
878
|
-
};
|
|
879
|
-
});
|
|
880
|
-
return resolvePromiseWithTimeout(onBuildManifest, MS_MAX_IDLE_DELAY, markAssetError(new Error("Failed to load client build manifest")));
|
|
881
|
-
}
|
|
882
|
-
function getFilesForRoute(assetPrefix, route) {
|
|
883
|
-
if (false) {}
|
|
884
|
-
return getClientBuildManifest().then((manifest)=>{
|
|
885
|
-
if (!(route in manifest)) {
|
|
886
|
-
throw markAssetError(new Error(`Failed to lookup route: ${route}`));
|
|
887
|
-
}
|
|
888
|
-
const allFiles = manifest[route].map((entry)=>assetPrefix + "/_next/" + encodeURI(entry));
|
|
889
|
-
return {
|
|
890
|
-
scripts: allFiles.filter((v)=>v.endsWith(".js")).map((v)=>(0, _trustedTypes).__unsafeCreateTrustedScriptURL(v)),
|
|
891
|
-
css: allFiles.filter((v)=>v.endsWith(".css"))
|
|
892
|
-
};
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
function createRouteLoader(assetPrefix) {
|
|
896
|
-
const entrypoints = new Map();
|
|
897
|
-
const loadedScripts = new Map();
|
|
898
|
-
const styleSheets = new Map();
|
|
899
|
-
const routes = new Map();
|
|
900
|
-
function maybeExecuteScript(src) {
|
|
901
|
-
// With HMR we might need to "reload" scripts when they are
|
|
902
|
-
// disposed and readded. Executing scripts twice has no functional
|
|
903
|
-
// differences
|
|
904
|
-
if (true) {
|
|
905
|
-
let prom = loadedScripts.get(src.toString());
|
|
906
|
-
if (prom) {
|
|
907
|
-
return prom;
|
|
908
|
-
}
|
|
909
|
-
// Skip executing script if it's already in the DOM:
|
|
910
|
-
if (document.querySelector(`script[src^="${src}"]`)) {
|
|
911
|
-
return Promise.resolve();
|
|
912
|
-
}
|
|
913
|
-
loadedScripts.set(src.toString(), prom = appendScript(src));
|
|
914
|
-
return prom;
|
|
915
|
-
} else {}
|
|
916
|
-
}
|
|
917
|
-
function fetchStyleSheet(href) {
|
|
918
|
-
let prom = styleSheets.get(href);
|
|
919
|
-
if (prom) {
|
|
920
|
-
return prom;
|
|
921
|
-
}
|
|
922
|
-
styleSheets.set(href, prom = fetch(href).then((res)=>{
|
|
923
|
-
if (!res.ok) {
|
|
924
|
-
throw new Error(`Failed to load stylesheet: ${href}`);
|
|
925
|
-
}
|
|
926
|
-
return res.text().then((text)=>({
|
|
927
|
-
href: href,
|
|
928
|
-
content: text
|
|
929
|
-
}));
|
|
930
|
-
}).catch((err)=>{
|
|
931
|
-
throw markAssetError(err);
|
|
932
|
-
}));
|
|
933
|
-
return prom;
|
|
934
|
-
}
|
|
935
|
-
return {
|
|
936
|
-
whenEntrypoint (route) {
|
|
937
|
-
return withFuture(route, entrypoints);
|
|
938
|
-
},
|
|
939
|
-
onEntrypoint (route, execute) {
|
|
940
|
-
(execute ? Promise.resolve().then(()=>execute()).then((exports1)=>({
|
|
941
|
-
component: exports1 && exports1.default || exports1,
|
|
942
|
-
exports: exports1
|
|
943
|
-
}), (err)=>({
|
|
944
|
-
error: err
|
|
945
|
-
})) : Promise.resolve(undefined)).then((input)=>{
|
|
946
|
-
const old = entrypoints.get(route);
|
|
947
|
-
if (old && "resolve" in old) {
|
|
948
|
-
if (input) {
|
|
949
|
-
entrypoints.set(route, input);
|
|
950
|
-
old.resolve(input);
|
|
951
|
-
}
|
|
952
|
-
} else {
|
|
953
|
-
if (input) {
|
|
954
|
-
entrypoints.set(route, input);
|
|
955
|
-
} else {
|
|
956
|
-
entrypoints.delete(route);
|
|
957
|
-
}
|
|
958
|
-
// when this entrypoint has been resolved before
|
|
959
|
-
// the route is outdated and we want to invalidate
|
|
960
|
-
// this cache entry
|
|
961
|
-
routes.delete(route);
|
|
962
|
-
}
|
|
963
|
-
});
|
|
964
|
-
},
|
|
965
|
-
loadRoute (route, prefetch) {
|
|
966
|
-
return withFuture(route, routes, ()=>{
|
|
967
|
-
let devBuildPromiseResolve;
|
|
968
|
-
if (false) {}
|
|
969
|
-
return resolvePromiseWithTimeout(getFilesForRoute(assetPrefix, route).then(({ scripts , css })=>{
|
|
970
|
-
return Promise.all([
|
|
971
|
-
entrypoints.has(route) ? [] : Promise.all(scripts.map(maybeExecuteScript)),
|
|
972
|
-
Promise.all(css.map(fetchStyleSheet))
|
|
973
|
-
]);
|
|
974
|
-
}).then((res)=>{
|
|
975
|
-
return this.whenEntrypoint(route).then((entrypoint)=>({
|
|
976
|
-
entrypoint,
|
|
977
|
-
styles: res[1]
|
|
978
|
-
}));
|
|
979
|
-
}), MS_MAX_IDLE_DELAY, markAssetError(new Error(`Route did not complete loading: ${route}`))).then(({ entrypoint , styles })=>{
|
|
980
|
-
const res = Object.assign({
|
|
981
|
-
styles: styles
|
|
982
|
-
}, entrypoint);
|
|
983
|
-
return "error" in entrypoint ? entrypoint : res;
|
|
984
|
-
}).catch((err)=>{
|
|
985
|
-
if (prefetch) {
|
|
986
|
-
// we don't want to cache errors during prefetch
|
|
987
|
-
throw err;
|
|
988
|
-
}
|
|
989
|
-
return {
|
|
990
|
-
error: err
|
|
991
|
-
};
|
|
992
|
-
}).finally(()=>{
|
|
993
|
-
return devBuildPromiseResolve == null ? void 0 : devBuildPromiseResolve();
|
|
994
|
-
});
|
|
995
|
-
});
|
|
996
|
-
},
|
|
997
|
-
prefetch (route) {
|
|
998
|
-
// https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
|
|
999
|
-
// License: Apache 2.0
|
|
1000
|
-
let cn;
|
|
1001
|
-
if (cn = navigator.connection) {
|
|
1002
|
-
// Don't prefetch if using 2G or if Save-Data is enabled.
|
|
1003
|
-
if (cn.saveData || /2g/.test(cn.effectiveType)) return Promise.resolve();
|
|
1004
|
-
}
|
|
1005
|
-
return getFilesForRoute(assetPrefix, route).then((output)=>Promise.all(canPrefetch ? output.scripts.map((script)=>prefetchViaDom(script.toString(), "script")) : [])).then(()=>{
|
|
1006
|
-
(0, _requestIdleCallback).requestIdleCallback(()=>this.loadRoute(route, true).catch(()=>{}));
|
|
1007
|
-
}).catch(()=>{});
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
1012
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
1013
|
-
value: true
|
|
1014
|
-
});
|
|
1015
|
-
Object.assign(exports.default, exports);
|
|
1016
|
-
module.exports = exports.default;
|
|
1017
|
-
} //# sourceMappingURL=route-loader.js.map
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
/***/ }),
|
|
1021
|
-
|
|
1022
|
-
/***/ 63573:
|
|
1023
|
-
/***/ ((module, exports, __webpack_require__) => {
|
|
1024
|
-
|
|
1025
|
-
"use strict";
|
|
1026
|
-
|
|
1027
|
-
"use client";
|
|
1028
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
1029
|
-
value: true
|
|
1030
|
-
}));
|
|
1031
|
-
exports.handleClientScriptLoad = handleClientScriptLoad;
|
|
1032
|
-
exports.initScriptLoader = initScriptLoader;
|
|
1033
|
-
exports["default"] = void 0;
|
|
1034
|
-
var _extends = (__webpack_require__(6495)/* ["default"] */ .Z);
|
|
1035
|
-
var _interop_require_default = (__webpack_require__(92648)/* ["default"] */ .Z);
|
|
1036
|
-
var _interop_require_wildcard = (__webpack_require__(91598)/* ["default"] */ .Z);
|
|
1037
|
-
var _object_without_properties_loose = (__webpack_require__(17273)/* ["default"] */ .Z);
|
|
1038
|
-
var _reactDom = _interop_require_default(__webpack_require__(66405));
|
|
1039
|
-
var _react = _interop_require_wildcard(__webpack_require__(16689));
|
|
1040
|
-
var _headManagerContext = __webpack_require__(92796);
|
|
1041
|
-
var _headManager = __webpack_require__(31831);
|
|
1042
|
-
var _requestIdleCallback = __webpack_require__(44686);
|
|
1043
|
-
const ScriptCache = new Map();
|
|
1044
|
-
const LoadCache = new Set();
|
|
1045
|
-
const ignoreProps = [
|
|
1046
|
-
"onLoad",
|
|
1047
|
-
"onReady",
|
|
1048
|
-
"dangerouslySetInnerHTML",
|
|
1049
|
-
"children",
|
|
1050
|
-
"onError",
|
|
1051
|
-
"strategy"
|
|
1052
|
-
];
|
|
1053
|
-
const loadScript = (props)=>{
|
|
1054
|
-
const { src , id , onLoad =()=>{} , onReady =null , dangerouslySetInnerHTML , children ="" , strategy ="afterInteractive" , onError } = props;
|
|
1055
|
-
const cacheKey = id || src;
|
|
1056
|
-
// Script has already loaded
|
|
1057
|
-
if (cacheKey && LoadCache.has(cacheKey)) {
|
|
1058
|
-
return;
|
|
1059
|
-
}
|
|
1060
|
-
// Contents of this script are already loading/loaded
|
|
1061
|
-
if (ScriptCache.has(src)) {
|
|
1062
|
-
LoadCache.add(cacheKey);
|
|
1063
|
-
// It is possible that multiple `next/script` components all have same "src", but has different "onLoad"
|
|
1064
|
-
// This is to make sure the same remote script will only load once, but "onLoad" are executed in order
|
|
1065
|
-
ScriptCache.get(src).then(onLoad, onError);
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
/** Execute after the script first loaded */ const afterLoad = ()=>{
|
|
1069
|
-
// Run onReady for the first time after load event
|
|
1070
|
-
if (onReady) {
|
|
1071
|
-
onReady();
|
|
1072
|
-
}
|
|
1073
|
-
// add cacheKey to LoadCache when load successfully
|
|
1074
|
-
LoadCache.add(cacheKey);
|
|
1075
|
-
};
|
|
1076
|
-
const el = document.createElement("script");
|
|
1077
|
-
const loadPromise = new Promise((resolve, reject)=>{
|
|
1078
|
-
el.addEventListener("load", function(e) {
|
|
1079
|
-
resolve();
|
|
1080
|
-
if (onLoad) {
|
|
1081
|
-
onLoad.call(this, e);
|
|
1082
|
-
}
|
|
1083
|
-
afterLoad();
|
|
1084
|
-
});
|
|
1085
|
-
el.addEventListener("error", function(e) {
|
|
1086
|
-
reject(e);
|
|
1087
|
-
});
|
|
1088
|
-
}).catch(function(e) {
|
|
1089
|
-
if (onError) {
|
|
1090
|
-
onError(e);
|
|
1091
|
-
}
|
|
1092
|
-
});
|
|
1093
|
-
if (dangerouslySetInnerHTML) {
|
|
1094
|
-
el.innerHTML = dangerouslySetInnerHTML.__html || "";
|
|
1095
|
-
afterLoad();
|
|
1096
|
-
} else if (children) {
|
|
1097
|
-
el.textContent = typeof children === "string" ? children : Array.isArray(children) ? children.join("") : "";
|
|
1098
|
-
afterLoad();
|
|
1099
|
-
} else if (src) {
|
|
1100
|
-
el.src = src;
|
|
1101
|
-
// do not add cacheKey into LoadCache for remote script here
|
|
1102
|
-
// cacheKey will be added to LoadCache when it is actually loaded (see loadPromise above)
|
|
1103
|
-
ScriptCache.set(src, loadPromise);
|
|
1104
|
-
}
|
|
1105
|
-
for (const [k, value] of Object.entries(props)){
|
|
1106
|
-
if (value === undefined || ignoreProps.includes(k)) {
|
|
1107
|
-
continue;
|
|
1108
|
-
}
|
|
1109
|
-
const attr = _headManager.DOMAttributeNames[k] || k.toLowerCase();
|
|
1110
|
-
el.setAttribute(attr, value);
|
|
1111
|
-
}
|
|
1112
|
-
if (strategy === "worker") {
|
|
1113
|
-
el.setAttribute("type", "text/partytown");
|
|
1114
|
-
}
|
|
1115
|
-
el.setAttribute("data-nscript", strategy);
|
|
1116
|
-
document.body.appendChild(el);
|
|
1117
|
-
};
|
|
1118
|
-
function handleClientScriptLoad(props) {
|
|
1119
|
-
const { strategy ="afterInteractive" } = props;
|
|
1120
|
-
if (strategy === "lazyOnload") {
|
|
1121
|
-
window.addEventListener("load", ()=>{
|
|
1122
|
-
(0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
|
|
1123
|
-
});
|
|
1124
|
-
} else {
|
|
1125
|
-
loadScript(props);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
function loadLazyScript(props) {
|
|
1129
|
-
if (document.readyState === "complete") {
|
|
1130
|
-
(0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
|
|
1131
|
-
} else {
|
|
1132
|
-
window.addEventListener("load", ()=>{
|
|
1133
|
-
(0, _requestIdleCallback).requestIdleCallback(()=>loadScript(props));
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
function addBeforeInteractiveToCache() {
|
|
1138
|
-
const scripts = [
|
|
1139
|
-
...document.querySelectorAll('[data-nscript="beforeInteractive"]'),
|
|
1140
|
-
...document.querySelectorAll('[data-nscript="beforePageRender"]')
|
|
1141
|
-
];
|
|
1142
|
-
scripts.forEach((script)=>{
|
|
1143
|
-
const cacheKey = script.id || script.getAttribute("src");
|
|
1144
|
-
LoadCache.add(cacheKey);
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
function initScriptLoader(scriptLoaderItems) {
|
|
1148
|
-
scriptLoaderItems.forEach(handleClientScriptLoad);
|
|
1149
|
-
addBeforeInteractiveToCache();
|
|
1150
|
-
}
|
|
1151
|
-
function Script(props) {
|
|
1152
|
-
const { id , src ="" , onLoad =()=>{} , onReady =null , strategy ="afterInteractive" , onError } = props, restProps = _object_without_properties_loose(props, [
|
|
1153
|
-
"id",
|
|
1154
|
-
"src",
|
|
1155
|
-
"onLoad",
|
|
1156
|
-
"onReady",
|
|
1157
|
-
"strategy",
|
|
1158
|
-
"onError"
|
|
1159
|
-
]);
|
|
1160
|
-
// Context is available only during SSR
|
|
1161
|
-
const { updateScripts , scripts , getIsSsr , appDir , nonce } = (0, _react).useContext(_headManagerContext.HeadManagerContext);
|
|
1162
|
-
/**
|
|
1163
|
-
* - First mount:
|
|
1164
|
-
* 1. The useEffect for onReady executes
|
|
1165
|
-
* 2. hasOnReadyEffectCalled.current is false, but the script hasn't loaded yet (not in LoadCache)
|
|
1166
|
-
* onReady is skipped, set hasOnReadyEffectCalled.current to true
|
|
1167
|
-
* 3. The useEffect for loadScript executes
|
|
1168
|
-
* 4. hasLoadScriptEffectCalled.current is false, loadScript executes
|
|
1169
|
-
* Once the script is loaded, the onLoad and onReady will be called by then
|
|
1170
|
-
* [If strict mode is enabled / is wrapped in <OffScreen /> component]
|
|
1171
|
-
* 5. The useEffect for onReady executes again
|
|
1172
|
-
* 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
|
|
1173
|
-
* 7. The useEffect for loadScript executes again
|
|
1174
|
-
* 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
|
|
1175
|
-
*
|
|
1176
|
-
* - Second mount:
|
|
1177
|
-
* 1. The useEffect for onReady executes
|
|
1178
|
-
* 2. hasOnReadyEffectCalled.current is false, but the script has already loaded (found in LoadCache)
|
|
1179
|
-
* onReady is called, set hasOnReadyEffectCalled.current to true
|
|
1180
|
-
* 3. The useEffect for loadScript executes
|
|
1181
|
-
* 4. The script is already loaded, loadScript bails out
|
|
1182
|
-
* [If strict mode is enabled / is wrapped in <OffScreen /> component]
|
|
1183
|
-
* 5. The useEffect for onReady executes again
|
|
1184
|
-
* 6. hasOnReadyEffectCalled.current is true, so entire effect is skipped
|
|
1185
|
-
* 7. The useEffect for loadScript executes again
|
|
1186
|
-
* 8. hasLoadScriptEffectCalled.current is true, so entire effect is skipped
|
|
1187
|
-
*/ const hasOnReadyEffectCalled = (0, _react).useRef(false);
|
|
1188
|
-
(0, _react).useEffect(()=>{
|
|
1189
|
-
const cacheKey = id || src;
|
|
1190
|
-
if (!hasOnReadyEffectCalled.current) {
|
|
1191
|
-
// Run onReady if script has loaded before but component is re-mounted
|
|
1192
|
-
if (onReady && cacheKey && LoadCache.has(cacheKey)) {
|
|
1193
|
-
onReady();
|
|
1194
|
-
}
|
|
1195
|
-
hasOnReadyEffectCalled.current = true;
|
|
1196
|
-
}
|
|
1197
|
-
}, [
|
|
1198
|
-
onReady,
|
|
1199
|
-
id,
|
|
1200
|
-
src
|
|
1201
|
-
]);
|
|
1202
|
-
const hasLoadScriptEffectCalled = (0, _react).useRef(false);
|
|
1203
|
-
(0, _react).useEffect(()=>{
|
|
1204
|
-
if (!hasLoadScriptEffectCalled.current) {
|
|
1205
|
-
if (strategy === "afterInteractive") {
|
|
1206
|
-
loadScript(props);
|
|
1207
|
-
} else if (strategy === "lazyOnload") {
|
|
1208
|
-
loadLazyScript(props);
|
|
1209
|
-
}
|
|
1210
|
-
hasLoadScriptEffectCalled.current = true;
|
|
1211
|
-
}
|
|
1212
|
-
}, [
|
|
1213
|
-
props,
|
|
1214
|
-
strategy
|
|
1215
|
-
]);
|
|
1216
|
-
if (strategy === "beforeInteractive" || strategy === "worker") {
|
|
1217
|
-
if (updateScripts) {
|
|
1218
|
-
scripts[strategy] = (scripts[strategy] || []).concat([
|
|
1219
|
-
_extends({
|
|
1220
|
-
id,
|
|
1221
|
-
src,
|
|
1222
|
-
onLoad,
|
|
1223
|
-
onReady,
|
|
1224
|
-
onError
|
|
1225
|
-
}, restProps)
|
|
1226
|
-
]);
|
|
1227
|
-
updateScripts(scripts);
|
|
1228
|
-
} else if (getIsSsr && getIsSsr()) {
|
|
1229
|
-
// Script has already loaded during SSR
|
|
1230
|
-
LoadCache.add(id || src);
|
|
1231
|
-
} else if (getIsSsr && !getIsSsr()) {
|
|
1232
|
-
loadScript(props);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
// For the app directory, we need React Float to preload these scripts.
|
|
1236
|
-
if (appDir) {
|
|
1237
|
-
// Before interactive scripts need to be loaded by Next.js' runtime instead
|
|
1238
|
-
// of native <script> tags, because they no longer have `defer`.
|
|
1239
|
-
if (strategy === "beforeInteractive") {
|
|
1240
|
-
if (!src) {
|
|
1241
|
-
// For inlined scripts, we put the content in `children`.
|
|
1242
|
-
if (restProps.dangerouslySetInnerHTML) {
|
|
1243
|
-
restProps.children = restProps.dangerouslySetInnerHTML.__html;
|
|
1244
|
-
delete restProps.dangerouslySetInnerHTML;
|
|
1245
|
-
}
|
|
1246
|
-
return /*#__PURE__*/ _react.default.createElement("script", {
|
|
1247
|
-
nonce: nonce,
|
|
1248
|
-
dangerouslySetInnerHTML: {
|
|
1249
|
-
__html: `(self.__next_s=self.__next_s||[]).push(${JSON.stringify([
|
|
1250
|
-
0,
|
|
1251
|
-
_extends({}, restProps)
|
|
1252
|
-
])})`
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
// @ts-ignore
|
|
1257
|
-
_reactDom.default.preload(src, restProps.integrity ? {
|
|
1258
|
-
as: "script",
|
|
1259
|
-
integrity: restProps.integrity
|
|
1260
|
-
} : {
|
|
1261
|
-
as: "script"
|
|
1262
|
-
});
|
|
1263
|
-
return /*#__PURE__*/ _react.default.createElement("script", {
|
|
1264
|
-
nonce: nonce,
|
|
1265
|
-
dangerouslySetInnerHTML: {
|
|
1266
|
-
__html: `(self.__next_s=self.__next_s||[]).push(${JSON.stringify([
|
|
1267
|
-
src
|
|
1268
|
-
])})`
|
|
1269
|
-
}
|
|
1270
|
-
});
|
|
1271
|
-
} else if (strategy === "afterInteractive") {
|
|
1272
|
-
if (src) {
|
|
1273
|
-
// @ts-ignore
|
|
1274
|
-
_reactDom.default.preload(src, restProps.integrity ? {
|
|
1275
|
-
as: "script",
|
|
1276
|
-
integrity: restProps.integrity
|
|
1277
|
-
} : {
|
|
1278
|
-
as: "script"
|
|
1279
|
-
});
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
return null;
|
|
1284
|
-
}
|
|
1285
|
-
Object.defineProperty(Script, "__nextScript", {
|
|
1286
|
-
value: true
|
|
1287
|
-
});
|
|
1288
|
-
var _default = Script;
|
|
1289
|
-
exports["default"] = _default;
|
|
1290
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
1291
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
1292
|
-
value: true
|
|
1293
|
-
});
|
|
1294
|
-
Object.assign(exports.default, exports);
|
|
1295
|
-
module.exports = exports.default;
|
|
1296
|
-
} //# sourceMappingURL=script.js.map
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
/***/ }),
|
|
1300
|
-
|
|
1301
|
-
/***/ 65407:
|
|
1302
|
-
/***/ ((module, exports) => {
|
|
1303
|
-
|
|
1304
|
-
"use strict";
|
|
1305
|
-
|
|
1306
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
1307
|
-
value: true
|
|
1308
|
-
}));
|
|
1309
|
-
exports.__unsafeCreateTrustedScriptURL = __unsafeCreateTrustedScriptURL;
|
|
1310
|
-
/**
|
|
1311
|
-
* Stores the Trusted Types Policy. Starts as undefined and can be set to null
|
|
1312
|
-
* if Trusted Types is not supported in the browser.
|
|
1313
|
-
*/ let policy;
|
|
1314
|
-
/**
|
|
1315
|
-
* Getter for the Trusted Types Policy. If it is undefined, it is instantiated
|
|
1316
|
-
* here or set to null if Trusted Types is not supported in the browser.
|
|
1317
|
-
*/ function getPolicy() {
|
|
1318
|
-
if (typeof policy === "undefined" && "undefined" !== "undefined") { var ref; }
|
|
1319
|
-
return policy;
|
|
1320
|
-
}
|
|
1321
|
-
function __unsafeCreateTrustedScriptURL(url) {
|
|
1322
|
-
var ref;
|
|
1323
|
-
return ((ref = getPolicy()) == null ? void 0 : ref.createScriptURL(url)) || url;
|
|
1324
|
-
}
|
|
1325
|
-
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
1326
|
-
Object.defineProperty(exports.default, "__esModule", {
|
|
1327
|
-
value: true
|
|
1328
|
-
});
|
|
1329
|
-
Object.assign(exports.default, exports);
|
|
1330
|
-
module.exports = exports.default;
|
|
1331
|
-
} //# sourceMappingURL=trusted-types.js.map
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
494
|
/***/ }),
|
|
1335
495
|
|
|
1336
496
|
/***/ 69246:
|
|
@@ -1447,1553 +607,6 @@ if ((typeof exports.default === "function" || typeof exports.default === "object
|
|
|
1447
607
|
} //# sourceMappingURL=use-intersection.js.map
|
|
1448
608
|
|
|
1449
609
|
|
|
1450
|
-
/***/ }),
|
|
1451
|
-
|
|
1452
|
-
/***/ 41003:
|
|
1453
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1454
|
-
|
|
1455
|
-
"use strict";
|
|
1456
|
-
|
|
1457
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
1458
|
-
value: true
|
|
1459
|
-
}));
|
|
1460
|
-
exports.matchesMiddleware = matchesMiddleware;
|
|
1461
|
-
exports.isLocalURL = isLocalURL;
|
|
1462
|
-
exports.interpolateAs = interpolateAs;
|
|
1463
|
-
exports.resolveHref = resolveHref;
|
|
1464
|
-
exports.handleSmoothScroll = handleSmoothScroll;
|
|
1465
|
-
exports.createKey = createKey;
|
|
1466
|
-
exports["default"] = void 0;
|
|
1467
|
-
var _async_to_generator = (__webpack_require__(60932)/* ["default"] */ .Z);
|
|
1468
|
-
var _extends = (__webpack_require__(6495)/* ["default"] */ .Z);
|
|
1469
|
-
var _interop_require_default = (__webpack_require__(92648)/* ["default"] */ .Z);
|
|
1470
|
-
var _interop_require_wildcard = (__webpack_require__(91598)/* ["default"] */ .Z);
|
|
1471
|
-
var _normalizeTrailingSlash = __webpack_require__(52700);
|
|
1472
|
-
var _removeTrailingSlash = __webpack_require__(93297);
|
|
1473
|
-
var _routeLoader = __webpack_require__(82497);
|
|
1474
|
-
var _script = __webpack_require__(63573);
|
|
1475
|
-
var _isError = _interop_require_wildcard(__webpack_require__(80676));
|
|
1476
|
-
var _denormalizePagePath = __webpack_require__(64406);
|
|
1477
|
-
var _normalizeLocalePath = __webpack_require__(34014);
|
|
1478
|
-
var _mitt = _interop_require_default(__webpack_require__(78020));
|
|
1479
|
-
var _utils = __webpack_require__(59232);
|
|
1480
|
-
var _isDynamic = __webpack_require__(1428);
|
|
1481
|
-
var _parseRelativeUrl = __webpack_require__(91292);
|
|
1482
|
-
var _querystring = __webpack_require__(80979);
|
|
1483
|
-
var _resolveRewrites = _interop_require_default(__webpack_require__(36052));
|
|
1484
|
-
var _routeMatcher = __webpack_require__(84226);
|
|
1485
|
-
var _routeRegex = __webpack_require__(95052);
|
|
1486
|
-
var _formatUrl = __webpack_require__(23938);
|
|
1487
|
-
var _detectDomainLocale = __webpack_require__(84643);
|
|
1488
|
-
var _parsePath = __webpack_require__(28854);
|
|
1489
|
-
var _addLocale = __webpack_require__(54465);
|
|
1490
|
-
var _removeLocale = __webpack_require__(66876);
|
|
1491
|
-
var _removeBasePath = __webpack_require__(82813);
|
|
1492
|
-
var _addBasePath = __webpack_require__(33468);
|
|
1493
|
-
var _hasBasePath = __webpack_require__(10928);
|
|
1494
|
-
var _isApiRoute = __webpack_require__(79423);
|
|
1495
|
-
var _getNextPathnameInfo = __webpack_require__(35789);
|
|
1496
|
-
var _formatNextPathnameInfo = __webpack_require__(10299);
|
|
1497
|
-
var _compareStates = __webpack_require__(46220);
|
|
1498
|
-
var _isBot = __webpack_require__(1897);
|
|
1499
|
-
function buildCancellationError() {
|
|
1500
|
-
return Object.assign(new Error("Route Cancelled"), {
|
|
1501
|
-
cancelled: true
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
function matchesMiddleware(options) {
|
|
1505
|
-
return _matchesMiddleware.apply(this, arguments);
|
|
1506
|
-
}
|
|
1507
|
-
function _matchesMiddleware() {
|
|
1508
|
-
_matchesMiddleware = _async_to_generator(function*(options) {
|
|
1509
|
-
const matchers = yield Promise.resolve(options.router.pageLoader.getMiddleware());
|
|
1510
|
-
if (!matchers) return false;
|
|
1511
|
-
const { pathname: asPathname } = (0, _parsePath).parsePath(options.asPath);
|
|
1512
|
-
// remove basePath first since path prefix has to be in the order of `/${basePath}/${locale}`
|
|
1513
|
-
const cleanedAs = (0, _hasBasePath).hasBasePath(asPathname) ? (0, _removeBasePath).removeBasePath(asPathname) : asPathname;
|
|
1514
|
-
const asWithBasePathAndLocale = (0, _addBasePath).addBasePath((0, _addLocale).addLocale(cleanedAs, options.locale));
|
|
1515
|
-
// Check only path match on client. Matching "has" should be done on server
|
|
1516
|
-
// where we can access more info such as headers, HttpOnly cookie, etc.
|
|
1517
|
-
return matchers.some((m)=>new RegExp(m.regexp).test(asWithBasePathAndLocale));
|
|
1518
|
-
});
|
|
1519
|
-
return _matchesMiddleware.apply(this, arguments);
|
|
1520
|
-
}
|
|
1521
|
-
function stripOrigin(url) {
|
|
1522
|
-
const origin = (0, _utils).getLocationOrigin();
|
|
1523
|
-
return url.startsWith(origin) ? url.substring(origin.length) : url;
|
|
1524
|
-
}
|
|
1525
|
-
function omit(object, keys) {
|
|
1526
|
-
const omitted = {};
|
|
1527
|
-
Object.keys(object).forEach((key)=>{
|
|
1528
|
-
if (!keys.includes(key)) {
|
|
1529
|
-
omitted[key] = object[key];
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
return omitted;
|
|
1533
|
-
}
|
|
1534
|
-
function isLocalURL(url) {
|
|
1535
|
-
// prevent a hydration mismatch on href for url with anchor refs
|
|
1536
|
-
if (!(0, _utils).isAbsoluteUrl(url)) return true;
|
|
1537
|
-
try {
|
|
1538
|
-
// absolute urls can be local if they are on the same origin
|
|
1539
|
-
const locationOrigin = (0, _utils).getLocationOrigin();
|
|
1540
|
-
const resolved = new URL(url, locationOrigin);
|
|
1541
|
-
return resolved.origin === locationOrigin && (0, _hasBasePath).hasBasePath(resolved.pathname);
|
|
1542
|
-
} catch (_) {
|
|
1543
|
-
return false;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
function interpolateAs(route, asPathname, query) {
|
|
1547
|
-
let interpolatedRoute = "";
|
|
1548
|
-
const dynamicRegex = (0, _routeRegex).getRouteRegex(route);
|
|
1549
|
-
const dynamicGroups = dynamicRegex.groups;
|
|
1550
|
-
const dynamicMatches = (asPathname !== route ? (0, _routeMatcher).getRouteMatcher(dynamicRegex)(asPathname) : "") || // Fall back to reading the values from the href
|
|
1551
|
-
// TODO: should this take priority; also need to change in the router.
|
|
1552
|
-
query;
|
|
1553
|
-
interpolatedRoute = route;
|
|
1554
|
-
const params = Object.keys(dynamicGroups);
|
|
1555
|
-
if (!params.every((param)=>{
|
|
1556
|
-
let value = dynamicMatches[param] || "";
|
|
1557
|
-
const { repeat , optional } = dynamicGroups[param];
|
|
1558
|
-
// support single-level catch-all
|
|
1559
|
-
// TODO: more robust handling for user-error (passing `/`)
|
|
1560
|
-
let replaced = `[${repeat ? "..." : ""}${param}]`;
|
|
1561
|
-
if (optional) {
|
|
1562
|
-
replaced = `${!value ? "/" : ""}[${replaced}]`;
|
|
1563
|
-
}
|
|
1564
|
-
if (repeat && !Array.isArray(value)) value = [
|
|
1565
|
-
value
|
|
1566
|
-
];
|
|
1567
|
-
return (optional || param in dynamicMatches) && // Interpolate group into data URL if present
|
|
1568
|
-
(interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map(// path delimiter escaped since they are being inserted
|
|
1569
|
-
// into the URL and we expect URL encoded segments
|
|
1570
|
-
// when parsing dynamic route params
|
|
1571
|
-
(segment)=>encodeURIComponent(segment)).join("/") : encodeURIComponent(value)) || "/");
|
|
1572
|
-
})) {
|
|
1573
|
-
interpolatedRoute = "" // did not satisfy all requirements
|
|
1574
|
-
;
|
|
1575
|
-
// n.b. We ignore this error because we handle warning for this case in
|
|
1576
|
-
// development in the `<Link>` component directly.
|
|
1577
|
-
}
|
|
1578
|
-
return {
|
|
1579
|
-
params,
|
|
1580
|
-
result: interpolatedRoute
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
function resolveHref(router, href, resolveAs) {
|
|
1584
|
-
// we use a dummy base url for relative urls
|
|
1585
|
-
let base;
|
|
1586
|
-
let urlAsString = typeof href === "string" ? href : (0, _formatUrl).formatWithValidation(href);
|
|
1587
|
-
// repeated slashes and backslashes in the URL are considered
|
|
1588
|
-
// invalid and will never match a Next.js page/file
|
|
1589
|
-
const urlProtoMatch = urlAsString.match(/^[a-zA-Z]{1,}:\/\//);
|
|
1590
|
-
const urlAsStringNoProto = urlProtoMatch ? urlAsString.slice(urlProtoMatch[0].length) : urlAsString;
|
|
1591
|
-
const urlParts = urlAsStringNoProto.split("?");
|
|
1592
|
-
if ((urlParts[0] || "").match(/(\/\/|\\)/)) {
|
|
1593
|
-
console.error(`Invalid href passed to next/router: ${urlAsString}, repeated forward-slashes (//) or backslashes \\ are not valid in the href`);
|
|
1594
|
-
const normalizedUrl = (0, _utils).normalizeRepeatedSlashes(urlAsStringNoProto);
|
|
1595
|
-
urlAsString = (urlProtoMatch ? urlProtoMatch[0] : "") + normalizedUrl;
|
|
1596
|
-
}
|
|
1597
|
-
// Return because it cannot be routed by the Next.js router
|
|
1598
|
-
if (!isLocalURL(urlAsString)) {
|
|
1599
|
-
return resolveAs ? [
|
|
1600
|
-
urlAsString
|
|
1601
|
-
] : urlAsString;
|
|
1602
|
-
}
|
|
1603
|
-
try {
|
|
1604
|
-
base = new URL(urlAsString.startsWith("#") ? router.asPath : router.pathname, "http://n");
|
|
1605
|
-
} catch (_) {
|
|
1606
|
-
// fallback to / for invalid asPath values e.g. //
|
|
1607
|
-
base = new URL("/", "http://n");
|
|
1608
|
-
}
|
|
1609
|
-
try {
|
|
1610
|
-
const finalUrl = new URL(urlAsString, base);
|
|
1611
|
-
finalUrl.pathname = (0, _normalizeTrailingSlash).normalizePathTrailingSlash(finalUrl.pathname);
|
|
1612
|
-
let interpolatedAs = "";
|
|
1613
|
-
if ((0, _isDynamic).isDynamicRoute(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
|
|
1614
|
-
const query = (0, _querystring).searchParamsToUrlQuery(finalUrl.searchParams);
|
|
1615
|
-
const { result , params } = interpolateAs(finalUrl.pathname, finalUrl.pathname, query);
|
|
1616
|
-
if (result) {
|
|
1617
|
-
interpolatedAs = (0, _formatUrl).formatWithValidation({
|
|
1618
|
-
pathname: result,
|
|
1619
|
-
hash: finalUrl.hash,
|
|
1620
|
-
query: omit(query, params)
|
|
1621
|
-
});
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
// if the origin didn't change, it means we received a relative href
|
|
1625
|
-
const resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
|
|
1626
|
-
return resolveAs ? [
|
|
1627
|
-
resolvedHref,
|
|
1628
|
-
interpolatedAs || resolvedHref
|
|
1629
|
-
] : resolvedHref;
|
|
1630
|
-
} catch (_1) {
|
|
1631
|
-
return resolveAs ? [
|
|
1632
|
-
urlAsString
|
|
1633
|
-
] : urlAsString;
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
function prepareUrlAs(router, url, as) {
|
|
1637
|
-
// If url and as provided as an object representation,
|
|
1638
|
-
// we'll format them into the string version here.
|
|
1639
|
-
let [resolvedHref, resolvedAs] = resolveHref(router, url, true);
|
|
1640
|
-
const origin = (0, _utils).getLocationOrigin();
|
|
1641
|
-
const hrefWasAbsolute = resolvedHref.startsWith(origin);
|
|
1642
|
-
const asWasAbsolute = resolvedAs && resolvedAs.startsWith(origin);
|
|
1643
|
-
resolvedHref = stripOrigin(resolvedHref);
|
|
1644
|
-
resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
|
|
1645
|
-
const preparedUrl = hrefWasAbsolute ? resolvedHref : (0, _addBasePath).addBasePath(resolvedHref);
|
|
1646
|
-
const preparedAs = as ? stripOrigin(resolveHref(router, as)) : resolvedAs || resolvedHref;
|
|
1647
|
-
return {
|
|
1648
|
-
url: preparedUrl,
|
|
1649
|
-
as: asWasAbsolute ? preparedAs : (0, _addBasePath).addBasePath(preparedAs)
|
|
1650
|
-
};
|
|
1651
|
-
}
|
|
1652
|
-
function resolveDynamicRoute(pathname, pages) {
|
|
1653
|
-
const cleanPathname = (0, _removeTrailingSlash).removeTrailingSlash((0, _denormalizePagePath).denormalizePagePath(pathname));
|
|
1654
|
-
if (cleanPathname === "/404" || cleanPathname === "/_error") {
|
|
1655
|
-
return pathname;
|
|
1656
|
-
}
|
|
1657
|
-
// handle resolving href for dynamic routes
|
|
1658
|
-
if (!pages.includes(cleanPathname)) {
|
|
1659
|
-
// eslint-disable-next-line array-callback-return
|
|
1660
|
-
pages.some((page)=>{
|
|
1661
|
-
if ((0, _isDynamic).isDynamicRoute(page) && (0, _routeRegex).getRouteRegex(page).re.test(cleanPathname)) {
|
|
1662
|
-
pathname = page;
|
|
1663
|
-
return true;
|
|
1664
|
-
}
|
|
1665
|
-
});
|
|
1666
|
-
}
|
|
1667
|
-
return (0, _removeTrailingSlash).removeTrailingSlash(pathname);
|
|
1668
|
-
}
|
|
1669
|
-
function getMiddlewareData(source, response, options) {
|
|
1670
|
-
const nextConfig = {
|
|
1671
|
-
basePath: options.router.basePath,
|
|
1672
|
-
i18n: {
|
|
1673
|
-
locales: options.router.locales
|
|
1674
|
-
},
|
|
1675
|
-
trailingSlash: Boolean(false)
|
|
1676
|
-
};
|
|
1677
|
-
const rewriteHeader = response.headers.get("x-nextjs-rewrite");
|
|
1678
|
-
let rewriteTarget = rewriteHeader || response.headers.get("x-nextjs-matched-path");
|
|
1679
|
-
const matchedPath = response.headers.get("x-matched-path");
|
|
1680
|
-
if (matchedPath && !rewriteTarget && !matchedPath.includes("__next_data_catchall") && !matchedPath.includes("/_error") && !matchedPath.includes("/404")) {
|
|
1681
|
-
// leverage x-matched-path to detect next.config.js rewrites
|
|
1682
|
-
rewriteTarget = matchedPath;
|
|
1683
|
-
}
|
|
1684
|
-
if (rewriteTarget) {
|
|
1685
|
-
if (rewriteTarget.startsWith("/")) {
|
|
1686
|
-
const parsedRewriteTarget = (0, _parseRelativeUrl).parseRelativeUrl(rewriteTarget);
|
|
1687
|
-
const pathnameInfo = (0, _getNextPathnameInfo).getNextPathnameInfo(parsedRewriteTarget.pathname, {
|
|
1688
|
-
nextConfig,
|
|
1689
|
-
parseData: true
|
|
1690
|
-
});
|
|
1691
|
-
let fsPathname = (0, _removeTrailingSlash).removeTrailingSlash(pathnameInfo.pathname);
|
|
1692
|
-
return Promise.all([
|
|
1693
|
-
options.router.pageLoader.getPageList(),
|
|
1694
|
-
(0, _routeLoader).getClientBuildManifest()
|
|
1695
|
-
]).then(([pages, { __rewrites: rewrites }])=>{
|
|
1696
|
-
let as = (0, _addLocale).addLocale(pathnameInfo.pathname, pathnameInfo.locale);
|
|
1697
|
-
if ((0, _isDynamic).isDynamicRoute(as) || !rewriteHeader && pages.includes((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(as), options.router.locales).pathname)) {
|
|
1698
|
-
const parsedSource = (0, _getNextPathnameInfo).getNextPathnameInfo((0, _parseRelativeUrl).parseRelativeUrl(source).pathname, {
|
|
1699
|
-
parseData: true
|
|
1700
|
-
});
|
|
1701
|
-
as = (0, _addBasePath).addBasePath(parsedSource.pathname);
|
|
1702
|
-
parsedRewriteTarget.pathname = as;
|
|
1703
|
-
}
|
|
1704
|
-
if (false) {} else if (!pages.includes(fsPathname)) {
|
|
1705
|
-
const resolvedPathname = resolveDynamicRoute(fsPathname, pages);
|
|
1706
|
-
if (resolvedPathname !== fsPathname) {
|
|
1707
|
-
fsPathname = resolvedPathname;
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
const resolvedHref = !pages.includes(fsPathname) ? resolveDynamicRoute((0, _normalizeLocalePath).normalizeLocalePath((0, _removeBasePath).removeBasePath(parsedRewriteTarget.pathname), options.router.locales).pathname, pages) : fsPathname;
|
|
1711
|
-
if ((0, _isDynamic).isDynamicRoute(resolvedHref)) {
|
|
1712
|
-
const matches = (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(resolvedHref))(as);
|
|
1713
|
-
Object.assign(parsedRewriteTarget.query, matches || {});
|
|
1714
|
-
}
|
|
1715
|
-
return {
|
|
1716
|
-
type: "rewrite",
|
|
1717
|
-
parsedAs: parsedRewriteTarget,
|
|
1718
|
-
resolvedHref
|
|
1719
|
-
};
|
|
1720
|
-
});
|
|
1721
|
-
}
|
|
1722
|
-
const src = (0, _parsePath).parsePath(source);
|
|
1723
|
-
const pathname = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src.pathname, {
|
|
1724
|
-
nextConfig,
|
|
1725
|
-
parseData: true
|
|
1726
|
-
}), {
|
|
1727
|
-
defaultLocale: options.router.defaultLocale,
|
|
1728
|
-
buildId: ""
|
|
1729
|
-
}));
|
|
1730
|
-
return Promise.resolve({
|
|
1731
|
-
type: "redirect-external",
|
|
1732
|
-
destination: `${pathname}${src.query}${src.hash}`
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
const redirectTarget = response.headers.get("x-nextjs-redirect");
|
|
1736
|
-
if (redirectTarget) {
|
|
1737
|
-
if (redirectTarget.startsWith("/")) {
|
|
1738
|
-
const src = (0, _parsePath).parsePath(redirectTarget);
|
|
1739
|
-
const pathname = (0, _formatNextPathnameInfo).formatNextPathnameInfo(_extends({}, (0, _getNextPathnameInfo).getNextPathnameInfo(src.pathname, {
|
|
1740
|
-
nextConfig,
|
|
1741
|
-
parseData: true
|
|
1742
|
-
}), {
|
|
1743
|
-
defaultLocale: options.router.defaultLocale,
|
|
1744
|
-
buildId: ""
|
|
1745
|
-
}));
|
|
1746
|
-
return Promise.resolve({
|
|
1747
|
-
type: "redirect-internal",
|
|
1748
|
-
newAs: `${pathname}${src.query}${src.hash}`,
|
|
1749
|
-
newUrl: `${pathname}${src.query}${src.hash}`
|
|
1750
|
-
});
|
|
1751
|
-
}
|
|
1752
|
-
return Promise.resolve({
|
|
1753
|
-
type: "redirect-external",
|
|
1754
|
-
destination: redirectTarget
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1757
|
-
return Promise.resolve({
|
|
1758
|
-
type: "next"
|
|
1759
|
-
});
|
|
1760
|
-
}
|
|
1761
|
-
function withMiddlewareEffects(options) {
|
|
1762
|
-
return _withMiddlewareEffects.apply(this, arguments);
|
|
1763
|
-
}
|
|
1764
|
-
function _withMiddlewareEffects() {
|
|
1765
|
-
_withMiddlewareEffects = _async_to_generator(function*(options) {
|
|
1766
|
-
const matches = yield matchesMiddleware(options);
|
|
1767
|
-
if (!matches || !options.fetchData) {
|
|
1768
|
-
return null;
|
|
1769
|
-
}
|
|
1770
|
-
try {
|
|
1771
|
-
const data = yield options.fetchData();
|
|
1772
|
-
const effect = yield getMiddlewareData(data.dataHref, data.response, options);
|
|
1773
|
-
return {
|
|
1774
|
-
dataHref: data.dataHref,
|
|
1775
|
-
json: data.json,
|
|
1776
|
-
response: data.response,
|
|
1777
|
-
text: data.text,
|
|
1778
|
-
cacheKey: data.cacheKey,
|
|
1779
|
-
effect
|
|
1780
|
-
};
|
|
1781
|
-
} catch (e) {
|
|
1782
|
-
/**
|
|
1783
|
-
* TODO: Revisit this in the future.
|
|
1784
|
-
* For now we will not consider middleware data errors to be fatal.
|
|
1785
|
-
* maybe we should revisit in the future.
|
|
1786
|
-
*/ return null;
|
|
1787
|
-
}
|
|
1788
|
-
});
|
|
1789
|
-
return _withMiddlewareEffects.apply(this, arguments);
|
|
1790
|
-
}
|
|
1791
|
-
const manualScrollRestoration = (/* unused pure expression or super */ null && ( false && 0));
|
|
1792
|
-
const SSG_DATA_NOT_FOUND = Symbol("SSG_DATA_NOT_FOUND");
|
|
1793
|
-
function fetchRetry(url, attempts, options) {
|
|
1794
|
-
return fetch(url, {
|
|
1795
|
-
// Cookies are required to be present for Next.js' SSG "Preview Mode".
|
|
1796
|
-
// Cookies may also be required for `getServerSideProps`.
|
|
1797
|
-
//
|
|
1798
|
-
// > `fetch` won’t send cookies, unless you set the credentials init
|
|
1799
|
-
// > option.
|
|
1800
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
|
|
1801
|
-
//
|
|
1802
|
-
// > For maximum browser compatibility when it comes to sending &
|
|
1803
|
-
// > receiving cookies, always supply the `credentials: 'same-origin'`
|
|
1804
|
-
// > option instead of relying on the default.
|
|
1805
|
-
// https://github.com/github/fetch#caveats
|
|
1806
|
-
credentials: "same-origin",
|
|
1807
|
-
method: options.method || "GET",
|
|
1808
|
-
headers: Object.assign({}, options.headers, {
|
|
1809
|
-
"x-nextjs-data": "1"
|
|
1810
|
-
})
|
|
1811
|
-
}).then((response)=>{
|
|
1812
|
-
return !response.ok && attempts > 1 && response.status >= 500 ? fetchRetry(url, attempts - 1, options) : response;
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
function handleSmoothScroll(fn, options = {}) {
|
|
1816
|
-
const htmlElement = document.documentElement;
|
|
1817
|
-
const existing = htmlElement.style.scrollBehavior;
|
|
1818
|
-
htmlElement.style.scrollBehavior = "auto";
|
|
1819
|
-
if (!options.dontForceLayout) {
|
|
1820
|
-
// In Chrome-based browsers we need to force reflow before calling `scrollTo`.
|
|
1821
|
-
// Otherwise it will not pickup the change in scrollBehavior
|
|
1822
|
-
// More info here: https://github.com/vercel/next.js/issues/40719#issuecomment-1336248042
|
|
1823
|
-
htmlElement.getClientRects();
|
|
1824
|
-
}
|
|
1825
|
-
fn();
|
|
1826
|
-
htmlElement.style.scrollBehavior = existing;
|
|
1827
|
-
}
|
|
1828
|
-
function tryToParseAsJSON(text) {
|
|
1829
|
-
try {
|
|
1830
|
-
return JSON.parse(text);
|
|
1831
|
-
} catch (error) {
|
|
1832
|
-
return null;
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
function fetchNextData({ dataHref , inflightCache , isPrefetch , hasMiddleware , isServerRender , parseJSON , persistCache , isBackground , unstable_skipClientCache }) {
|
|
1836
|
-
const { href: cacheKey } = new URL(dataHref, window.location.href);
|
|
1837
|
-
var ref1;
|
|
1838
|
-
const getData = (params)=>{
|
|
1839
|
-
return fetchRetry(dataHref, isServerRender ? 3 : 1, {
|
|
1840
|
-
headers: Object.assign({}, isPrefetch ? {
|
|
1841
|
-
purpose: "prefetch"
|
|
1842
|
-
} : {}, isPrefetch && hasMiddleware ? {
|
|
1843
|
-
"x-middleware-prefetch": "1"
|
|
1844
|
-
} : {}),
|
|
1845
|
-
method: (ref1 = params == null ? void 0 : params.method) != null ? ref1 : "GET"
|
|
1846
|
-
}).then((response)=>{
|
|
1847
|
-
if (response.ok && (params == null ? void 0 : params.method) === "HEAD") {
|
|
1848
|
-
return {
|
|
1849
|
-
dataHref,
|
|
1850
|
-
response,
|
|
1851
|
-
text: "",
|
|
1852
|
-
json: {},
|
|
1853
|
-
cacheKey
|
|
1854
|
-
};
|
|
1855
|
-
}
|
|
1856
|
-
return response.text().then((text)=>{
|
|
1857
|
-
if (!response.ok) {
|
|
1858
|
-
/**
|
|
1859
|
-
* When the data response is a redirect because of a middleware
|
|
1860
|
-
* we do not consider it an error. The headers must bring the
|
|
1861
|
-
* mapped location.
|
|
1862
|
-
* TODO: Change the status code in the handler.
|
|
1863
|
-
*/ if (hasMiddleware && [
|
|
1864
|
-
301,
|
|
1865
|
-
302,
|
|
1866
|
-
307,
|
|
1867
|
-
308
|
|
1868
|
-
].includes(response.status)) {
|
|
1869
|
-
return {
|
|
1870
|
-
dataHref,
|
|
1871
|
-
response,
|
|
1872
|
-
text,
|
|
1873
|
-
json: {},
|
|
1874
|
-
cacheKey
|
|
1875
|
-
};
|
|
1876
|
-
}
|
|
1877
|
-
if (!hasMiddleware && response.status === 404) {
|
|
1878
|
-
var ref;
|
|
1879
|
-
if ((ref = tryToParseAsJSON(text)) == null ? void 0 : ref.notFound) {
|
|
1880
|
-
return {
|
|
1881
|
-
dataHref,
|
|
1882
|
-
json: {
|
|
1883
|
-
notFound: SSG_DATA_NOT_FOUND
|
|
1884
|
-
},
|
|
1885
|
-
response,
|
|
1886
|
-
text,
|
|
1887
|
-
cacheKey
|
|
1888
|
-
};
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
const error = new Error(`Failed to load static props`);
|
|
1892
|
-
/**
|
|
1893
|
-
* We should only trigger a server-side transition if this was
|
|
1894
|
-
* caused on a client-side transition. Otherwise, we'd get into
|
|
1895
|
-
* an infinite loop.
|
|
1896
|
-
*/ if (!isServerRender) {
|
|
1897
|
-
(0, _routeLoader).markAssetError(error);
|
|
1898
|
-
}
|
|
1899
|
-
throw error;
|
|
1900
|
-
}
|
|
1901
|
-
return {
|
|
1902
|
-
dataHref,
|
|
1903
|
-
json: parseJSON ? tryToParseAsJSON(text) : null,
|
|
1904
|
-
response,
|
|
1905
|
-
text,
|
|
1906
|
-
cacheKey
|
|
1907
|
-
};
|
|
1908
|
-
});
|
|
1909
|
-
}).then((data)=>{
|
|
1910
|
-
if (!persistCache || "production" !== "production" || data.response.headers.get("x-middleware-cache") === "no-cache") {
|
|
1911
|
-
delete inflightCache[cacheKey];
|
|
1912
|
-
}
|
|
1913
|
-
return data;
|
|
1914
|
-
}).catch((err)=>{
|
|
1915
|
-
if (!unstable_skipClientCache) {
|
|
1916
|
-
delete inflightCache[cacheKey];
|
|
1917
|
-
}
|
|
1918
|
-
if (err.message === "Failed to fetch" || // firefox
|
|
1919
|
-
err.message === "NetworkError when attempting to fetch resource." || // safari
|
|
1920
|
-
err.message === "Load failed") {
|
|
1921
|
-
(0, _routeLoader).markAssetError(err);
|
|
1922
|
-
}
|
|
1923
|
-
throw err;
|
|
1924
|
-
});
|
|
1925
|
-
};
|
|
1926
|
-
// when skipping client cache we wait to update
|
|
1927
|
-
// inflight cache until successful data response
|
|
1928
|
-
// this allows racing click event with fetching newer data
|
|
1929
|
-
// without blocking navigation when stale data is available
|
|
1930
|
-
if (unstable_skipClientCache && persistCache) {
|
|
1931
|
-
return getData({}).then((data)=>{
|
|
1932
|
-
inflightCache[cacheKey] = Promise.resolve(data);
|
|
1933
|
-
return data;
|
|
1934
|
-
});
|
|
1935
|
-
}
|
|
1936
|
-
if (inflightCache[cacheKey] !== undefined) {
|
|
1937
|
-
return inflightCache[cacheKey];
|
|
1938
|
-
}
|
|
1939
|
-
return inflightCache[cacheKey] = getData(isBackground ? {
|
|
1940
|
-
method: "HEAD"
|
|
1941
|
-
} : {});
|
|
1942
|
-
}
|
|
1943
|
-
function createKey() {
|
|
1944
|
-
return Math.random().toString(36).slice(2, 10);
|
|
1945
|
-
}
|
|
1946
|
-
function handleHardNavigation({ url , router }) {
|
|
1947
|
-
// ensure we don't trigger a hard navigation to the same
|
|
1948
|
-
// URL as this can end up with an infinite refresh
|
|
1949
|
-
if (url === (0, _addBasePath).addBasePath((0, _addLocale).addLocale(router.asPath, router.locale))) {
|
|
1950
|
-
throw new Error(`Invariant: attempted to hard navigate to the same URL ${url} ${location.href}`);
|
|
1951
|
-
}
|
|
1952
|
-
window.location.href = url;
|
|
1953
|
-
}
|
|
1954
|
-
const getCancelledHandler = ({ route , router })=>{
|
|
1955
|
-
let cancelled = false;
|
|
1956
|
-
const cancel = router.clc = ()=>{
|
|
1957
|
-
cancelled = true;
|
|
1958
|
-
};
|
|
1959
|
-
const handleCancelled = ()=>{
|
|
1960
|
-
if (cancelled) {
|
|
1961
|
-
const error = new Error(`Abort fetching component for route: "${route}"`);
|
|
1962
|
-
error.cancelled = true;
|
|
1963
|
-
throw error;
|
|
1964
|
-
}
|
|
1965
|
-
if (cancel === router.clc) {
|
|
1966
|
-
router.clc = null;
|
|
1967
|
-
}
|
|
1968
|
-
};
|
|
1969
|
-
return handleCancelled;
|
|
1970
|
-
};
|
|
1971
|
-
class Router {
|
|
1972
|
-
reload() {
|
|
1973
|
-
window.location.reload();
|
|
1974
|
-
}
|
|
1975
|
-
/**
|
|
1976
|
-
* Go back in history
|
|
1977
|
-
*/ back() {
|
|
1978
|
-
window.history.back();
|
|
1979
|
-
}
|
|
1980
|
-
/**
|
|
1981
|
-
* Go forward in history
|
|
1982
|
-
*/ forward() {
|
|
1983
|
-
window.history.forward();
|
|
1984
|
-
}
|
|
1985
|
-
/**
|
|
1986
|
-
* Performs a `pushState` with arguments
|
|
1987
|
-
* @param url of the route
|
|
1988
|
-
* @param as masks `url` for the browser
|
|
1989
|
-
* @param options object you can define `shallow` and other options
|
|
1990
|
-
*/ push(url, as, options = {}) {
|
|
1991
|
-
if (false) {}
|
|
1992
|
-
({ url , as } = prepareUrlAs(this, url, as));
|
|
1993
|
-
return this.change("pushState", url, as, options);
|
|
1994
|
-
}
|
|
1995
|
-
/**
|
|
1996
|
-
* Performs a `replaceState` with arguments
|
|
1997
|
-
* @param url of the route
|
|
1998
|
-
* @param as masks `url` for the browser
|
|
1999
|
-
* @param options object you can define `shallow` and other options
|
|
2000
|
-
*/ replace(url, as, options = {}) {
|
|
2001
|
-
({ url , as } = prepareUrlAs(this, url, as));
|
|
2002
|
-
return this.change("replaceState", url, as, options);
|
|
2003
|
-
}
|
|
2004
|
-
change(method, url, as, options, forcedScroll) {
|
|
2005
|
-
var _this = this;
|
|
2006
|
-
return _async_to_generator(function*() {
|
|
2007
|
-
if (!isLocalURL(url)) {
|
|
2008
|
-
handleHardNavigation({
|
|
2009
|
-
url,
|
|
2010
|
-
router: _this
|
|
2011
|
-
});
|
|
2012
|
-
return false;
|
|
2013
|
-
}
|
|
2014
|
-
// WARNING: `_h` is an internal option for handing Next.js client-side
|
|
2015
|
-
// hydration. Your app should _never_ use this property. It may change at
|
|
2016
|
-
// any time without notice.
|
|
2017
|
-
const isQueryUpdating = options._h === 1;
|
|
2018
|
-
let shouldResolveHref = isQueryUpdating || options._shouldResolveHref || (0, _parsePath).parsePath(url).pathname === (0, _parsePath).parsePath(as).pathname;
|
|
2019
|
-
const nextState = _extends({}, _this.state);
|
|
2020
|
-
// for static pages with query params in the URL we delay
|
|
2021
|
-
// marking the router ready until after the query is updated
|
|
2022
|
-
// or a navigation has occurred
|
|
2023
|
-
const readyStateChange = _this.isReady !== true;
|
|
2024
|
-
_this.isReady = true;
|
|
2025
|
-
const isSsr = _this.isSsr;
|
|
2026
|
-
if (!isQueryUpdating) {
|
|
2027
|
-
_this.isSsr = false;
|
|
2028
|
-
}
|
|
2029
|
-
// if a route transition is already in progress before
|
|
2030
|
-
// the query updating is triggered ignore query updating
|
|
2031
|
-
if (isQueryUpdating && _this.clc) {
|
|
2032
|
-
return false;
|
|
2033
|
-
}
|
|
2034
|
-
const prevLocale = nextState.locale;
|
|
2035
|
-
if (false) { var ref; }
|
|
2036
|
-
// marking route changes as a navigation start entry
|
|
2037
|
-
if (_utils.ST) {
|
|
2038
|
-
performance.mark("routeChange");
|
|
2039
|
-
}
|
|
2040
|
-
const { shallow =false , scroll =true } = options;
|
|
2041
|
-
const routeProps = {
|
|
2042
|
-
shallow
|
|
2043
|
-
};
|
|
2044
|
-
if (_this._inFlightRoute && _this.clc) {
|
|
2045
|
-
if (!isSsr) {
|
|
2046
|
-
Router.events.emit("routeChangeError", buildCancellationError(), _this._inFlightRoute, routeProps);
|
|
2047
|
-
}
|
|
2048
|
-
_this.clc();
|
|
2049
|
-
_this.clc = null;
|
|
2050
|
-
}
|
|
2051
|
-
as = (0, _addBasePath).addBasePath((0, _addLocale).addLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, options.locale, _this.defaultLocale));
|
|
2052
|
-
const cleanedAs = (0, _removeLocale).removeLocale((0, _hasBasePath).hasBasePath(as) ? (0, _removeBasePath).removeBasePath(as) : as, nextState.locale);
|
|
2053
|
-
_this._inFlightRoute = as;
|
|
2054
|
-
const localeChange = prevLocale !== nextState.locale;
|
|
2055
|
-
// If the url change is only related to a hash change
|
|
2056
|
-
// We should not proceed. We should only change the state.
|
|
2057
|
-
if (!isQueryUpdating && _this.onlyAHashChange(cleanedAs) && !localeChange) {
|
|
2058
|
-
nextState.asPath = cleanedAs;
|
|
2059
|
-
Router.events.emit("hashChangeStart", as, routeProps);
|
|
2060
|
-
// TODO: do we need the resolved href when only a hash change?
|
|
2061
|
-
_this.changeState(method, url, as, _extends({}, options, {
|
|
2062
|
-
scroll: false
|
|
2063
|
-
}));
|
|
2064
|
-
if (scroll) {
|
|
2065
|
-
_this.scrollToHash(cleanedAs);
|
|
2066
|
-
}
|
|
2067
|
-
try {
|
|
2068
|
-
yield _this.set(nextState, _this.components[nextState.route], null);
|
|
2069
|
-
} catch (err) {
|
|
2070
|
-
if ((0, _isError).default(err) && err.cancelled) {
|
|
2071
|
-
Router.events.emit("routeChangeError", err, cleanedAs, routeProps);
|
|
2072
|
-
}
|
|
2073
|
-
throw err;
|
|
2074
|
-
}
|
|
2075
|
-
Router.events.emit("hashChangeComplete", as, routeProps);
|
|
2076
|
-
return true;
|
|
2077
|
-
}
|
|
2078
|
-
let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
|
|
2079
|
-
let { pathname , query } = parsed;
|
|
2080
|
-
// The build manifest needs to be loaded before auto-static dynamic pages
|
|
2081
|
-
// get their query parameters to allow ensuring they can be parsed properly
|
|
2082
|
-
// when rewritten to
|
|
2083
|
-
let pages, rewrites;
|
|
2084
|
-
try {
|
|
2085
|
-
[pages, { __rewrites: rewrites }] = yield Promise.all([
|
|
2086
|
-
_this.pageLoader.getPageList(),
|
|
2087
|
-
(0, _routeLoader).getClientBuildManifest(),
|
|
2088
|
-
_this.pageLoader.getMiddleware()
|
|
2089
|
-
]);
|
|
2090
|
-
} catch (err) {
|
|
2091
|
-
// If we fail to resolve the page list or client-build manifest, we must
|
|
2092
|
-
// do a server-side transition:
|
|
2093
|
-
handleHardNavigation({
|
|
2094
|
-
url: as,
|
|
2095
|
-
router: _this
|
|
2096
|
-
});
|
|
2097
|
-
return false;
|
|
2098
|
-
}
|
|
2099
|
-
// If asked to change the current URL we should reload the current page
|
|
2100
|
-
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
|
|
2101
|
-
// We also need to set the method = replaceState always
|
|
2102
|
-
// as this should not go into the history (That's how browsers work)
|
|
2103
|
-
// We should compare the new asPath to the current asPath, not the url
|
|
2104
|
-
if (!_this.urlIsNew(cleanedAs) && !localeChange) {
|
|
2105
|
-
method = "replaceState";
|
|
2106
|
-
}
|
|
2107
|
-
// we need to resolve the as value using rewrites for dynamic SSG
|
|
2108
|
-
// pages to allow building the data URL correctly
|
|
2109
|
-
let resolvedAs = as;
|
|
2110
|
-
// url and as should always be prefixed with basePath by this
|
|
2111
|
-
// point by either next/link or router.push/replace so strip the
|
|
2112
|
-
// basePath from the pathname to match the pages dir 1-to-1
|
|
2113
|
-
pathname = pathname ? (0, _removeTrailingSlash).removeTrailingSlash((0, _removeBasePath).removeBasePath(pathname)) : pathname;
|
|
2114
|
-
let route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
|
|
2115
|
-
const parsedAsPathname = as.startsWith("/") && (0, _parseRelativeUrl).parseRelativeUrl(as).pathname;
|
|
2116
|
-
const isMiddlewareRewrite = !!(parsedAsPathname && route !== parsedAsPathname && (!(0, _isDynamic).isDynamicRoute(route) || !(0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(route))(parsedAsPathname)));
|
|
2117
|
-
// we don't attempt resolve asPath when we need to execute
|
|
2118
|
-
// middleware as the resolving will occur server-side
|
|
2119
|
-
const isMiddlewareMatch = !options.shallow && (yield matchesMiddleware({
|
|
2120
|
-
asPath: as,
|
|
2121
|
-
locale: nextState.locale,
|
|
2122
|
-
router: _this
|
|
2123
|
-
}));
|
|
2124
|
-
if (isQueryUpdating && isMiddlewareMatch) {
|
|
2125
|
-
shouldResolveHref = false;
|
|
2126
|
-
}
|
|
2127
|
-
if (shouldResolveHref && pathname !== "/_error") {
|
|
2128
|
-
options._shouldResolveHref = true;
|
|
2129
|
-
if (false) {} else {
|
|
2130
|
-
parsed.pathname = resolveDynamicRoute(pathname, pages);
|
|
2131
|
-
if (parsed.pathname !== pathname) {
|
|
2132
|
-
pathname = parsed.pathname;
|
|
2133
|
-
parsed.pathname = (0, _addBasePath).addBasePath(pathname);
|
|
2134
|
-
if (!isMiddlewareMatch) {
|
|
2135
|
-
url = (0, _formatUrl).formatWithValidation(parsed);
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
if (!isLocalURL(as)) {
|
|
2141
|
-
if (false) {}
|
|
2142
|
-
handleHardNavigation({
|
|
2143
|
-
url: as,
|
|
2144
|
-
router: _this
|
|
2145
|
-
});
|
|
2146
|
-
return false;
|
|
2147
|
-
}
|
|
2148
|
-
resolvedAs = (0, _removeLocale).removeLocale((0, _removeBasePath).removeBasePath(resolvedAs), nextState.locale);
|
|
2149
|
-
route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
|
|
2150
|
-
let routeMatch = false;
|
|
2151
|
-
if ((0, _isDynamic).isDynamicRoute(route)) {
|
|
2152
|
-
const parsedAs = (0, _parseRelativeUrl).parseRelativeUrl(resolvedAs);
|
|
2153
|
-
const asPathname = parsedAs.pathname;
|
|
2154
|
-
const routeRegex = (0, _routeRegex).getRouteRegex(route);
|
|
2155
|
-
routeMatch = (0, _routeMatcher).getRouteMatcher(routeRegex)(asPathname);
|
|
2156
|
-
const shouldInterpolate = route === asPathname;
|
|
2157
|
-
const interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {};
|
|
2158
|
-
if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
|
|
2159
|
-
const missingParams = Object.keys(routeRegex.groups).filter((param)=>!query[param] && !routeRegex.groups[param].optional);
|
|
2160
|
-
if (missingParams.length > 0 && !isMiddlewareMatch) {
|
|
2161
|
-
if (false) {}
|
|
2162
|
-
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"}`);
|
|
2163
|
-
}
|
|
2164
|
-
} else if (shouldInterpolate) {
|
|
2165
|
-
as = (0, _formatUrl).formatWithValidation(Object.assign({}, parsedAs, {
|
|
2166
|
-
pathname: interpolatedAs.result,
|
|
2167
|
-
query: omit(query, interpolatedAs.params)
|
|
2168
|
-
}));
|
|
2169
|
-
} else {
|
|
2170
|
-
// Merge params into `query`, overwriting any specified in search
|
|
2171
|
-
Object.assign(query, routeMatch);
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
if (!isQueryUpdating) {
|
|
2175
|
-
Router.events.emit("routeChangeStart", as, routeProps);
|
|
2176
|
-
}
|
|
2177
|
-
try {
|
|
2178
|
-
var ref2, ref3, ref4;
|
|
2179
|
-
let routeInfo = yield _this.getRouteInfo({
|
|
2180
|
-
route,
|
|
2181
|
-
pathname,
|
|
2182
|
-
query,
|
|
2183
|
-
as,
|
|
2184
|
-
resolvedAs,
|
|
2185
|
-
routeProps,
|
|
2186
|
-
locale: nextState.locale,
|
|
2187
|
-
isPreview: nextState.isPreview,
|
|
2188
|
-
hasMiddleware: isMiddlewareMatch,
|
|
2189
|
-
unstable_skipClientCache: options.unstable_skipClientCache,
|
|
2190
|
-
isQueryUpdating: isQueryUpdating && !_this.isFallback,
|
|
2191
|
-
isMiddlewareRewrite
|
|
2192
|
-
});
|
|
2193
|
-
if ("route" in routeInfo && isMiddlewareMatch) {
|
|
2194
|
-
pathname = routeInfo.route || route;
|
|
2195
|
-
route = pathname;
|
|
2196
|
-
if (!routeProps.shallow) {
|
|
2197
|
-
query = Object.assign({}, routeInfo.query || {}, query);
|
|
2198
|
-
}
|
|
2199
|
-
const cleanedParsedPathname = (0, _hasBasePath).hasBasePath(parsed.pathname) ? (0, _removeBasePath).removeBasePath(parsed.pathname) : parsed.pathname;
|
|
2200
|
-
if (routeMatch && pathname !== cleanedParsedPathname) {
|
|
2201
|
-
Object.keys(routeMatch).forEach((key)=>{
|
|
2202
|
-
if (routeMatch && query[key] === routeMatch[key]) {
|
|
2203
|
-
delete query[key];
|
|
2204
|
-
}
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
if ((0, _isDynamic).isDynamicRoute(pathname)) {
|
|
2208
|
-
const prefixedAs = !routeProps.shallow && routeInfo.resolvedAs ? routeInfo.resolvedAs : (0, _addBasePath).addBasePath((0, _addLocale).addLocale(new URL(as, location.href).pathname, nextState.locale), true);
|
|
2209
|
-
let rewriteAs = prefixedAs;
|
|
2210
|
-
if ((0, _hasBasePath).hasBasePath(rewriteAs)) {
|
|
2211
|
-
rewriteAs = (0, _removeBasePath).removeBasePath(rewriteAs);
|
|
2212
|
-
}
|
|
2213
|
-
if (false) {}
|
|
2214
|
-
const routeRegex = (0, _routeRegex).getRouteRegex(pathname);
|
|
2215
|
-
const curRouteMatch = (0, _routeMatcher).getRouteMatcher(routeRegex)(new URL(rewriteAs, location.href).pathname);
|
|
2216
|
-
if (curRouteMatch) {
|
|
2217
|
-
Object.assign(query, curRouteMatch);
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
// If the routeInfo brings a redirect we simply apply it.
|
|
2222
|
-
if ("type" in routeInfo) {
|
|
2223
|
-
if (routeInfo.type === "redirect-internal") {
|
|
2224
|
-
return _this.change(method, routeInfo.newUrl, routeInfo.newAs, options);
|
|
2225
|
-
} else {
|
|
2226
|
-
handleHardNavigation({
|
|
2227
|
-
url: routeInfo.destination,
|
|
2228
|
-
router: _this
|
|
2229
|
-
});
|
|
2230
|
-
return new Promise(()=>{});
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
const component = routeInfo.Component;
|
|
2234
|
-
if (component && component.unstable_scriptLoader) {
|
|
2235
|
-
const scripts = [].concat(component.unstable_scriptLoader());
|
|
2236
|
-
scripts.forEach((script)=>{
|
|
2237
|
-
(0, _script).handleClientScriptLoad(script.props);
|
|
2238
|
-
});
|
|
2239
|
-
}
|
|
2240
|
-
// handle redirect on client-transition
|
|
2241
|
-
if ((routeInfo.__N_SSG || routeInfo.__N_SSP) && routeInfo.props) {
|
|
2242
|
-
if (routeInfo.props.pageProps && routeInfo.props.pageProps.__N_REDIRECT) {
|
|
2243
|
-
// Use the destination from redirect without adding locale
|
|
2244
|
-
options.locale = false;
|
|
2245
|
-
const destination = routeInfo.props.pageProps.__N_REDIRECT;
|
|
2246
|
-
// check if destination is internal (resolves to a page) and attempt
|
|
2247
|
-
// client-navigation if it is falling back to hard navigation if
|
|
2248
|
-
// it's not
|
|
2249
|
-
if (destination.startsWith("/") && routeInfo.props.pageProps.__N_REDIRECT_BASE_PATH !== false) {
|
|
2250
|
-
const parsedHref = (0, _parseRelativeUrl).parseRelativeUrl(destination);
|
|
2251
|
-
parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
|
|
2252
|
-
const { url: newUrl , as: newAs } = prepareUrlAs(_this, destination, destination);
|
|
2253
|
-
return _this.change(method, newUrl, newAs, options);
|
|
2254
|
-
}
|
|
2255
|
-
handleHardNavigation({
|
|
2256
|
-
url: destination,
|
|
2257
|
-
router: _this
|
|
2258
|
-
});
|
|
2259
|
-
return new Promise(()=>{});
|
|
2260
|
-
}
|
|
2261
|
-
nextState.isPreview = !!routeInfo.props.__N_PREVIEW;
|
|
2262
|
-
// handle SSG data 404
|
|
2263
|
-
if (routeInfo.props.notFound === SSG_DATA_NOT_FOUND) {
|
|
2264
|
-
let notFoundRoute;
|
|
2265
|
-
try {
|
|
2266
|
-
yield _this.fetchComponent("/404");
|
|
2267
|
-
notFoundRoute = "/404";
|
|
2268
|
-
} catch (_) {
|
|
2269
|
-
notFoundRoute = "/_error";
|
|
2270
|
-
}
|
|
2271
|
-
routeInfo = yield _this.getRouteInfo({
|
|
2272
|
-
route: notFoundRoute,
|
|
2273
|
-
pathname: notFoundRoute,
|
|
2274
|
-
query,
|
|
2275
|
-
as,
|
|
2276
|
-
resolvedAs,
|
|
2277
|
-
routeProps: {
|
|
2278
|
-
shallow: false
|
|
2279
|
-
},
|
|
2280
|
-
locale: nextState.locale,
|
|
2281
|
-
isPreview: nextState.isPreview
|
|
2282
|
-
});
|
|
2283
|
-
if ("type" in routeInfo) {
|
|
2284
|
-
throw new Error(`Unexpected middleware effect on /404`);
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
if (isQueryUpdating && _this.pathname === "/_error" && ((ref2 = self.__NEXT_DATA__.props) == null ? void 0 : (ref3 = ref2.pageProps) == null ? void 0 : ref3.statusCode) === 500 && ((ref4 = routeInfo.props) == null ? void 0 : ref4.pageProps)) {
|
|
2289
|
-
// ensure statusCode is still correct for static 500 page
|
|
2290
|
-
// when updating query information
|
|
2291
|
-
routeInfo.props.pageProps.statusCode = 500;
|
|
2292
|
-
}
|
|
2293
|
-
var _route;
|
|
2294
|
-
// shallow routing is only allowed for same page URL changes.
|
|
2295
|
-
const isValidShallowRoute = options.shallow && nextState.route === ((_route = routeInfo.route) != null ? _route : route);
|
|
2296
|
-
var _scroll;
|
|
2297
|
-
const shouldScroll = (_scroll = options.scroll) != null ? _scroll : !isQueryUpdating && !isValidShallowRoute;
|
|
2298
|
-
const resetScroll = shouldScroll ? {
|
|
2299
|
-
x: 0,
|
|
2300
|
-
y: 0
|
|
2301
|
-
} : null;
|
|
2302
|
-
const upcomingScrollState = forcedScroll != null ? forcedScroll : resetScroll;
|
|
2303
|
-
// the new state that the router gonna set
|
|
2304
|
-
const upcomingRouterState = _extends({}, nextState, {
|
|
2305
|
-
route,
|
|
2306
|
-
pathname,
|
|
2307
|
-
query,
|
|
2308
|
-
asPath: cleanedAs,
|
|
2309
|
-
isFallback: false
|
|
2310
|
-
});
|
|
2311
|
-
// When the page being rendered is the 404 page, we should only update the
|
|
2312
|
-
// query parameters. Route changes here might add the basePath when it
|
|
2313
|
-
// wasn't originally present. This is also why this block is before the
|
|
2314
|
-
// below `changeState` call which updates the browser's history (changing
|
|
2315
|
-
// the URL).
|
|
2316
|
-
if (isQueryUpdating && (_this.pathname === "/404" || _this.pathname === "/_error")) {
|
|
2317
|
-
var ref5, ref6, ref7;
|
|
2318
|
-
routeInfo = yield _this.getRouteInfo({
|
|
2319
|
-
route: _this.pathname,
|
|
2320
|
-
pathname: _this.pathname,
|
|
2321
|
-
query,
|
|
2322
|
-
as,
|
|
2323
|
-
resolvedAs,
|
|
2324
|
-
routeProps: {
|
|
2325
|
-
shallow: false
|
|
2326
|
-
},
|
|
2327
|
-
locale: nextState.locale,
|
|
2328
|
-
isPreview: nextState.isPreview
|
|
2329
|
-
});
|
|
2330
|
-
if ("type" in routeInfo) {
|
|
2331
|
-
throw new Error(`Unexpected middleware effect on ${_this.pathname}`);
|
|
2332
|
-
}
|
|
2333
|
-
if (_this.pathname === "/_error" && ((ref5 = self.__NEXT_DATA__.props) == null ? void 0 : (ref6 = ref5.pageProps) == null ? void 0 : ref6.statusCode) === 500 && ((ref7 = routeInfo.props) == null ? void 0 : ref7.pageProps)) {
|
|
2334
|
-
// ensure statusCode is still correct for static 500 page
|
|
2335
|
-
// when updating query information
|
|
2336
|
-
routeInfo.props.pageProps.statusCode = 500;
|
|
2337
|
-
}
|
|
2338
|
-
try {
|
|
2339
|
-
yield _this.set(upcomingRouterState, routeInfo, upcomingScrollState);
|
|
2340
|
-
} catch (err) {
|
|
2341
|
-
if ((0, _isError).default(err) && err.cancelled) {
|
|
2342
|
-
Router.events.emit("routeChangeError", err, cleanedAs, routeProps);
|
|
2343
|
-
}
|
|
2344
|
-
throw err;
|
|
2345
|
-
}
|
|
2346
|
-
return true;
|
|
2347
|
-
}
|
|
2348
|
-
Router.events.emit("beforeHistoryChange", as, routeProps);
|
|
2349
|
-
_this.changeState(method, url, as, options);
|
|
2350
|
-
// for query updates we can skip it if the state is unchanged and we don't
|
|
2351
|
-
// need to scroll
|
|
2352
|
-
// https://github.com/vercel/next.js/issues/37139
|
|
2353
|
-
const canSkipUpdating = isQueryUpdating && !upcomingScrollState && !readyStateChange && !localeChange && (0, _compareStates).compareRouterStates(upcomingRouterState, _this.state);
|
|
2354
|
-
if (!canSkipUpdating) {
|
|
2355
|
-
try {
|
|
2356
|
-
yield _this.set(upcomingRouterState, routeInfo, upcomingScrollState);
|
|
2357
|
-
} catch (e) {
|
|
2358
|
-
if (e.cancelled) routeInfo.error = routeInfo.error || e;
|
|
2359
|
-
else throw e;
|
|
2360
|
-
}
|
|
2361
|
-
if (routeInfo.error) {
|
|
2362
|
-
if (!isQueryUpdating) {
|
|
2363
|
-
Router.events.emit("routeChangeError", routeInfo.error, cleanedAs, routeProps);
|
|
2364
|
-
}
|
|
2365
|
-
throw routeInfo.error;
|
|
2366
|
-
}
|
|
2367
|
-
if (false) {}
|
|
2368
|
-
if (!isQueryUpdating) {
|
|
2369
|
-
Router.events.emit("routeChangeComplete", as, routeProps);
|
|
2370
|
-
}
|
|
2371
|
-
// A hash mark # is the optional last part of a URL
|
|
2372
|
-
const hashRegex = /#.+$/;
|
|
2373
|
-
if (shouldScroll && hashRegex.test(as)) {
|
|
2374
|
-
_this.scrollToHash(as);
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
return true;
|
|
2378
|
-
} catch (err1) {
|
|
2379
|
-
if ((0, _isError).default(err1) && err1.cancelled) {
|
|
2380
|
-
return false;
|
|
2381
|
-
}
|
|
2382
|
-
throw err1;
|
|
2383
|
-
}
|
|
2384
|
-
})();
|
|
2385
|
-
}
|
|
2386
|
-
changeState(method, url, as, options = {}) {
|
|
2387
|
-
if (false) {}
|
|
2388
|
-
if (method !== "pushState" || (0, _utils).getURL() !== as) {
|
|
2389
|
-
this._shallow = options.shallow;
|
|
2390
|
-
window.history[method]({
|
|
2391
|
-
url,
|
|
2392
|
-
as,
|
|
2393
|
-
options,
|
|
2394
|
-
__N: true,
|
|
2395
|
-
key: this._key = method !== "pushState" ? this._key : createKey()
|
|
2396
|
-
}, // Passing the empty string here should be safe against future changes to the method.
|
|
2397
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
|
|
2398
|
-
"", as);
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
handleRouteInfoError(err, pathname, query, as, routeProps, loadErrorFail) {
|
|
2402
|
-
var _this = this;
|
|
2403
|
-
return _async_to_generator(function*() {
|
|
2404
|
-
console.error(err);
|
|
2405
|
-
if (err.cancelled) {
|
|
2406
|
-
// bubble up cancellation errors
|
|
2407
|
-
throw err;
|
|
2408
|
-
}
|
|
2409
|
-
if ((0, _routeLoader).isAssetError(err) || loadErrorFail) {
|
|
2410
|
-
Router.events.emit("routeChangeError", err, as, routeProps);
|
|
2411
|
-
// If we can't load the page it could be one of following reasons
|
|
2412
|
-
// 1. Page doesn't exists
|
|
2413
|
-
// 2. Page does exist in a different zone
|
|
2414
|
-
// 3. Internal error while loading the page
|
|
2415
|
-
// So, doing a hard reload is the proper way to deal with this.
|
|
2416
|
-
handleHardNavigation({
|
|
2417
|
-
url: as,
|
|
2418
|
-
router: _this
|
|
2419
|
-
});
|
|
2420
|
-
// Changing the URL doesn't block executing the current code path.
|
|
2421
|
-
// So let's throw a cancellation error stop the routing logic.
|
|
2422
|
-
throw buildCancellationError();
|
|
2423
|
-
}
|
|
2424
|
-
try {
|
|
2425
|
-
let props;
|
|
2426
|
-
const { page: Component , styleSheets } = yield _this.fetchComponent("/_error");
|
|
2427
|
-
const routeInfo = {
|
|
2428
|
-
props,
|
|
2429
|
-
Component,
|
|
2430
|
-
styleSheets,
|
|
2431
|
-
err,
|
|
2432
|
-
error: err
|
|
2433
|
-
};
|
|
2434
|
-
if (!routeInfo.props) {
|
|
2435
|
-
try {
|
|
2436
|
-
routeInfo.props = yield _this.getInitialProps(Component, {
|
|
2437
|
-
err,
|
|
2438
|
-
pathname,
|
|
2439
|
-
query
|
|
2440
|
-
});
|
|
2441
|
-
} catch (gipErr) {
|
|
2442
|
-
console.error("Error in error page `getInitialProps`: ", gipErr);
|
|
2443
|
-
routeInfo.props = {};
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
return routeInfo;
|
|
2447
|
-
} catch (routeInfoErr) {
|
|
2448
|
-
return _this.handleRouteInfoError((0, _isError).default(routeInfoErr) ? routeInfoErr : new Error(routeInfoErr + ""), pathname, query, as, routeProps, true);
|
|
2449
|
-
}
|
|
2450
|
-
})();
|
|
2451
|
-
}
|
|
2452
|
-
getRouteInfo({ route: requestedRoute , pathname , query , as , resolvedAs , routeProps , locale , hasMiddleware , isPreview , unstable_skipClientCache , isQueryUpdating , isMiddlewareRewrite }) {
|
|
2453
|
-
var _this = this;
|
|
2454
|
-
return _async_to_generator(function*() {
|
|
2455
|
-
/**
|
|
2456
|
-
* This `route` binding can change if there's a rewrite
|
|
2457
|
-
* so we keep a reference to the original requested route
|
|
2458
|
-
* so we can store the cache for it and avoid re-requesting every time
|
|
2459
|
-
* for shallow routing purposes.
|
|
2460
|
-
*/ let route = requestedRoute;
|
|
2461
|
-
try {
|
|
2462
|
-
var ref, ref8, ref9, ref10;
|
|
2463
|
-
const handleCancelled = getCancelledHandler({
|
|
2464
|
-
route,
|
|
2465
|
-
router: _this
|
|
2466
|
-
});
|
|
2467
|
-
let existingInfo = _this.components[route];
|
|
2468
|
-
if (routeProps.shallow && existingInfo && _this.route === route) {
|
|
2469
|
-
return existingInfo;
|
|
2470
|
-
}
|
|
2471
|
-
if (hasMiddleware) {
|
|
2472
|
-
existingInfo = undefined;
|
|
2473
|
-
}
|
|
2474
|
-
let cachedRouteInfo = existingInfo && !("initial" in existingInfo) && "production" !== "development" ? existingInfo : undefined;
|
|
2475
|
-
const isBackground = isQueryUpdating;
|
|
2476
|
-
const fetchNextDataParams = {
|
|
2477
|
-
dataHref: _this.pageLoader.getDataHref({
|
|
2478
|
-
href: (0, _formatUrl).formatWithValidation({
|
|
2479
|
-
pathname,
|
|
2480
|
-
query
|
|
2481
|
-
}),
|
|
2482
|
-
skipInterpolation: true,
|
|
2483
|
-
asPath: resolvedAs,
|
|
2484
|
-
locale
|
|
2485
|
-
}),
|
|
2486
|
-
hasMiddleware: true,
|
|
2487
|
-
isServerRender: _this.isSsr,
|
|
2488
|
-
parseJSON: true,
|
|
2489
|
-
inflightCache: isBackground ? _this.sbc : _this.sdc,
|
|
2490
|
-
persistCache: !isPreview,
|
|
2491
|
-
isPrefetch: false,
|
|
2492
|
-
unstable_skipClientCache,
|
|
2493
|
-
isBackground
|
|
2494
|
-
};
|
|
2495
|
-
let data = isQueryUpdating && !isMiddlewareRewrite ? null : yield withMiddlewareEffects({
|
|
2496
|
-
fetchData: ()=>fetchNextData(fetchNextDataParams),
|
|
2497
|
-
asPath: resolvedAs,
|
|
2498
|
-
locale: locale,
|
|
2499
|
-
router: _this
|
|
2500
|
-
}).catch((err)=>{
|
|
2501
|
-
// we don't hard error during query updating
|
|
2502
|
-
// as it's un-necessary and doesn't need to be fatal
|
|
2503
|
-
// unless it is a fallback route and the props can't
|
|
2504
|
-
// be loaded
|
|
2505
|
-
if (isQueryUpdating) {
|
|
2506
|
-
return null;
|
|
2507
|
-
}
|
|
2508
|
-
throw err;
|
|
2509
|
-
});
|
|
2510
|
-
if (isQueryUpdating) {
|
|
2511
|
-
if (!data) {
|
|
2512
|
-
data = {
|
|
2513
|
-
json: self.__NEXT_DATA__.props
|
|
2514
|
-
};
|
|
2515
|
-
} else {
|
|
2516
|
-
data.json = self.__NEXT_DATA__.props;
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
handleCancelled();
|
|
2520
|
-
if ((data == null ? void 0 : (ref = data.effect) == null ? void 0 : ref.type) === "redirect-internal" || (data == null ? void 0 : (ref8 = data.effect) == null ? void 0 : ref8.type) === "redirect-external") {
|
|
2521
|
-
return data.effect;
|
|
2522
|
-
}
|
|
2523
|
-
if ((data == null ? void 0 : (ref9 = data.effect) == null ? void 0 : ref9.type) === "rewrite") {
|
|
2524
|
-
const resolvedRoute = (0, _removeTrailingSlash).removeTrailingSlash(data.effect.resolvedHref);
|
|
2525
|
-
const pages = yield _this.pageLoader.getPageList();
|
|
2526
|
-
// during query updating the page must match although during
|
|
2527
|
-
// client-transition a redirect that doesn't match a page
|
|
2528
|
-
// can be returned and this should trigger a hard navigation
|
|
2529
|
-
// which is valid for incremental migration
|
|
2530
|
-
if (!isQueryUpdating || pages.includes(resolvedRoute)) {
|
|
2531
|
-
route = resolvedRoute;
|
|
2532
|
-
pathname = data.effect.resolvedHref;
|
|
2533
|
-
query = _extends({}, query, data.effect.parsedAs.query);
|
|
2534
|
-
resolvedAs = (0, _removeBasePath).removeBasePath((0, _normalizeLocalePath).normalizeLocalePath(data.effect.parsedAs.pathname, _this.locales).pathname);
|
|
2535
|
-
// Check again the cache with the new destination.
|
|
2536
|
-
existingInfo = _this.components[route];
|
|
2537
|
-
if (routeProps.shallow && existingInfo && _this.route === route && !hasMiddleware) {
|
|
2538
|
-
// If we have a match with the current route due to rewrite,
|
|
2539
|
-
// we can copy the existing information to the rewritten one.
|
|
2540
|
-
// Then, we return the information along with the matched route.
|
|
2541
|
-
return _extends({}, existingInfo, {
|
|
2542
|
-
route
|
|
2543
|
-
});
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
}
|
|
2547
|
-
if ((0, _isApiRoute).isAPIRoute(route)) {
|
|
2548
|
-
handleHardNavigation({
|
|
2549
|
-
url: as,
|
|
2550
|
-
router: _this
|
|
2551
|
-
});
|
|
2552
|
-
return new Promise(()=>{});
|
|
2553
|
-
}
|
|
2554
|
-
const routeInfo = cachedRouteInfo || (yield _this.fetchComponent(route).then((res)=>({
|
|
2555
|
-
Component: res.page,
|
|
2556
|
-
styleSheets: res.styleSheets,
|
|
2557
|
-
__N_SSG: res.mod.__N_SSG,
|
|
2558
|
-
__N_SSP: res.mod.__N_SSP
|
|
2559
|
-
})));
|
|
2560
|
-
if (false) {}
|
|
2561
|
-
const wasBailedPrefetch = data == null ? void 0 : (ref10 = data.response) == null ? void 0 : ref10.headers.get("x-middleware-skip");
|
|
2562
|
-
const shouldFetchData = routeInfo.__N_SSG || routeInfo.__N_SSP;
|
|
2563
|
-
// For non-SSG prefetches that bailed before sending data
|
|
2564
|
-
// we clear the cache to fetch full response
|
|
2565
|
-
if (wasBailedPrefetch && (data == null ? void 0 : data.dataHref)) {
|
|
2566
|
-
delete _this.sdc[data.dataHref];
|
|
2567
|
-
}
|
|
2568
|
-
const { props , cacheKey } = yield _this._getData(_async_to_generator(function*() {
|
|
2569
|
-
if (shouldFetchData) {
|
|
2570
|
-
if ((data == null ? void 0 : data.json) && !wasBailedPrefetch) {
|
|
2571
|
-
return {
|
|
2572
|
-
cacheKey: data.cacheKey,
|
|
2573
|
-
props: data.json
|
|
2574
|
-
};
|
|
2575
|
-
}
|
|
2576
|
-
const dataHref = (data == null ? void 0 : data.dataHref) ? data.dataHref : _this.pageLoader.getDataHref({
|
|
2577
|
-
href: (0, _formatUrl).formatWithValidation({
|
|
2578
|
-
pathname,
|
|
2579
|
-
query
|
|
2580
|
-
}),
|
|
2581
|
-
asPath: resolvedAs,
|
|
2582
|
-
locale
|
|
2583
|
-
});
|
|
2584
|
-
const fetched = yield fetchNextData({
|
|
2585
|
-
dataHref,
|
|
2586
|
-
isServerRender: _this.isSsr,
|
|
2587
|
-
parseJSON: true,
|
|
2588
|
-
inflightCache: wasBailedPrefetch ? {} : _this.sdc,
|
|
2589
|
-
persistCache: !isPreview,
|
|
2590
|
-
isPrefetch: false,
|
|
2591
|
-
unstable_skipClientCache
|
|
2592
|
-
});
|
|
2593
|
-
return {
|
|
2594
|
-
cacheKey: fetched.cacheKey,
|
|
2595
|
-
props: fetched.json || {}
|
|
2596
|
-
};
|
|
2597
|
-
}
|
|
2598
|
-
return {
|
|
2599
|
-
headers: {},
|
|
2600
|
-
props: yield _this.getInitialProps(routeInfo.Component, {
|
|
2601
|
-
pathname,
|
|
2602
|
-
query,
|
|
2603
|
-
asPath: as,
|
|
2604
|
-
locale,
|
|
2605
|
-
locales: _this.locales,
|
|
2606
|
-
defaultLocale: _this.defaultLocale
|
|
2607
|
-
})
|
|
2608
|
-
};
|
|
2609
|
-
}));
|
|
2610
|
-
// Only bust the data cache for SSP routes although
|
|
2611
|
-
// middleware can skip cache per request with
|
|
2612
|
-
// x-middleware-cache: no-cache as well
|
|
2613
|
-
if (routeInfo.__N_SSP && fetchNextDataParams.dataHref && cacheKey) {
|
|
2614
|
-
delete _this.sdc[cacheKey];
|
|
2615
|
-
}
|
|
2616
|
-
// we kick off a HEAD request in the background
|
|
2617
|
-
// when a non-prefetch request is made to signal revalidation
|
|
2618
|
-
if (!_this.isPreview && routeInfo.__N_SSG && "production" !== "development" && !isQueryUpdating) {
|
|
2619
|
-
fetchNextData(Object.assign({}, fetchNextDataParams, {
|
|
2620
|
-
isBackground: true,
|
|
2621
|
-
persistCache: false,
|
|
2622
|
-
inflightCache: _this.sbc
|
|
2623
|
-
})).catch(()=>{});
|
|
2624
|
-
}
|
|
2625
|
-
props.pageProps = Object.assign({}, props.pageProps);
|
|
2626
|
-
routeInfo.props = props;
|
|
2627
|
-
routeInfo.route = route;
|
|
2628
|
-
routeInfo.query = query;
|
|
2629
|
-
routeInfo.resolvedAs = resolvedAs;
|
|
2630
|
-
_this.components[route] = routeInfo;
|
|
2631
|
-
return routeInfo;
|
|
2632
|
-
} catch (err) {
|
|
2633
|
-
return _this.handleRouteInfoError((0, _isError).getProperError(err), pathname, query, as, routeProps);
|
|
2634
|
-
}
|
|
2635
|
-
})();
|
|
2636
|
-
}
|
|
2637
|
-
set(state, data, resetScroll) {
|
|
2638
|
-
this.state = state;
|
|
2639
|
-
return this.sub(data, this.components["/_app"].Component, resetScroll);
|
|
2640
|
-
}
|
|
2641
|
-
/**
|
|
2642
|
-
* Callback to execute before replacing router state
|
|
2643
|
-
* @param cb callback to be executed
|
|
2644
|
-
*/ beforePopState(cb) {
|
|
2645
|
-
this._bps = cb;
|
|
2646
|
-
}
|
|
2647
|
-
onlyAHashChange(as) {
|
|
2648
|
-
if (!this.asPath) return false;
|
|
2649
|
-
const [oldUrlNoHash, oldHash] = this.asPath.split("#");
|
|
2650
|
-
const [newUrlNoHash, newHash] = as.split("#");
|
|
2651
|
-
// Makes sure we scroll to the provided hash if the url/hash are the same
|
|
2652
|
-
if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
|
|
2653
|
-
return true;
|
|
2654
|
-
}
|
|
2655
|
-
// If the urls are change, there's more than a hash change
|
|
2656
|
-
if (oldUrlNoHash !== newUrlNoHash) {
|
|
2657
|
-
return false;
|
|
2658
|
-
}
|
|
2659
|
-
// If the hash has changed, then it's a hash only change.
|
|
2660
|
-
// This check is necessary to handle both the enter and
|
|
2661
|
-
// leave hash === '' cases. The identity case falls through
|
|
2662
|
-
// and is treated as a next reload.
|
|
2663
|
-
return oldHash !== newHash;
|
|
2664
|
-
}
|
|
2665
|
-
scrollToHash(as) {
|
|
2666
|
-
const [, hash = ""] = as.split("#");
|
|
2667
|
-
// Scroll to top if the hash is just `#` with no value or `#top`
|
|
2668
|
-
// To mirror browsers
|
|
2669
|
-
if (hash === "" || hash === "top") {
|
|
2670
|
-
handleSmoothScroll(()=>window.scrollTo(0, 0));
|
|
2671
|
-
return;
|
|
2672
|
-
}
|
|
2673
|
-
// Decode hash to make non-latin anchor works.
|
|
2674
|
-
const rawHash = decodeURIComponent(hash);
|
|
2675
|
-
// First we check if the element by id is found
|
|
2676
|
-
const idEl = document.getElementById(rawHash);
|
|
2677
|
-
if (idEl) {
|
|
2678
|
-
handleSmoothScroll(()=>idEl.scrollIntoView());
|
|
2679
|
-
return;
|
|
2680
|
-
}
|
|
2681
|
-
// If there's no element with the id, we check the `name` property
|
|
2682
|
-
// To mirror browsers
|
|
2683
|
-
const nameEl = document.getElementsByName(rawHash)[0];
|
|
2684
|
-
if (nameEl) {
|
|
2685
|
-
handleSmoothScroll(()=>nameEl.scrollIntoView());
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
urlIsNew(asPath) {
|
|
2689
|
-
return this.asPath !== asPath;
|
|
2690
|
-
}
|
|
2691
|
-
/**
|
|
2692
|
-
* Prefetch page code, you may wait for the data during page rendering.
|
|
2693
|
-
* This feature only works in production!
|
|
2694
|
-
* @param url the href of prefetched page
|
|
2695
|
-
* @param asPath the as path of the prefetched page
|
|
2696
|
-
*/ prefetch(url, asPath = url, options = {}) {
|
|
2697
|
-
var _this = this;
|
|
2698
|
-
return _async_to_generator(function*() {
|
|
2699
|
-
// Prefetch is not supported in development mode because it would trigger on-demand-entries
|
|
2700
|
-
if (false) {}
|
|
2701
|
-
if (false) {}
|
|
2702
|
-
let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url);
|
|
2703
|
-
let { pathname , query } = parsed;
|
|
2704
|
-
const originalPathname = pathname;
|
|
2705
|
-
if (false) {}
|
|
2706
|
-
const pages = yield _this.pageLoader.getPageList();
|
|
2707
|
-
let resolvedAs = asPath;
|
|
2708
|
-
const locale = typeof options.locale !== "undefined" ? options.locale || undefined : _this.locale;
|
|
2709
|
-
const isMiddlewareMatch = yield matchesMiddleware({
|
|
2710
|
-
asPath: asPath,
|
|
2711
|
-
locale: locale,
|
|
2712
|
-
router: _this
|
|
2713
|
-
});
|
|
2714
|
-
if (false) {}
|
|
2715
|
-
parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
|
|
2716
|
-
if ((0, _isDynamic).isDynamicRoute(parsed.pathname)) {
|
|
2717
|
-
pathname = parsed.pathname;
|
|
2718
|
-
parsed.pathname = pathname;
|
|
2719
|
-
Object.assign(query, (0, _routeMatcher).getRouteMatcher((0, _routeRegex).getRouteRegex(parsed.pathname))((0, _parsePath).parsePath(asPath).pathname) || {});
|
|
2720
|
-
if (!isMiddlewareMatch) {
|
|
2721
|
-
url = (0, _formatUrl).formatWithValidation(parsed);
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
|
-
const data = false ? 0 : yield withMiddlewareEffects({
|
|
2725
|
-
fetchData: ()=>fetchNextData({
|
|
2726
|
-
dataHref: _this.pageLoader.getDataHref({
|
|
2727
|
-
href: (0, _formatUrl).formatWithValidation({
|
|
2728
|
-
pathname: originalPathname,
|
|
2729
|
-
query
|
|
2730
|
-
}),
|
|
2731
|
-
skipInterpolation: true,
|
|
2732
|
-
asPath: resolvedAs,
|
|
2733
|
-
locale
|
|
2734
|
-
}),
|
|
2735
|
-
hasMiddleware: true,
|
|
2736
|
-
isServerRender: _this.isSsr,
|
|
2737
|
-
parseJSON: true,
|
|
2738
|
-
inflightCache: _this.sdc,
|
|
2739
|
-
persistCache: !_this.isPreview,
|
|
2740
|
-
isPrefetch: true
|
|
2741
|
-
}),
|
|
2742
|
-
asPath: asPath,
|
|
2743
|
-
locale: locale,
|
|
2744
|
-
router: _this
|
|
2745
|
-
});
|
|
2746
|
-
/**
|
|
2747
|
-
* If there was a rewrite we apply the effects of the rewrite on the
|
|
2748
|
-
* current parameters for the prefetch.
|
|
2749
|
-
*/ if ((data == null ? void 0 : data.effect.type) === "rewrite") {
|
|
2750
|
-
parsed.pathname = data.effect.resolvedHref;
|
|
2751
|
-
pathname = data.effect.resolvedHref;
|
|
2752
|
-
query = _extends({}, query, data.effect.parsedAs.query);
|
|
2753
|
-
resolvedAs = data.effect.parsedAs.pathname;
|
|
2754
|
-
url = (0, _formatUrl).formatWithValidation(parsed);
|
|
2755
|
-
}
|
|
2756
|
-
/**
|
|
2757
|
-
* If there is a redirect to an external destination then we don't have
|
|
2758
|
-
* to prefetch content as it will be unused.
|
|
2759
|
-
*/ if ((data == null ? void 0 : data.effect.type) === "redirect-external") {
|
|
2760
|
-
return;
|
|
2761
|
-
}
|
|
2762
|
-
const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname);
|
|
2763
|
-
yield Promise.all([
|
|
2764
|
-
_this.pageLoader._isSsg(route).then((isSsg)=>{
|
|
2765
|
-
return isSsg ? fetchNextData({
|
|
2766
|
-
dataHref: (data == null ? void 0 : data.json) ? data == null ? void 0 : data.dataHref : _this.pageLoader.getDataHref({
|
|
2767
|
-
href: url,
|
|
2768
|
-
asPath: resolvedAs,
|
|
2769
|
-
locale: locale
|
|
2770
|
-
}),
|
|
2771
|
-
isServerRender: false,
|
|
2772
|
-
parseJSON: true,
|
|
2773
|
-
inflightCache: _this.sdc,
|
|
2774
|
-
persistCache: !_this.isPreview,
|
|
2775
|
-
isPrefetch: true,
|
|
2776
|
-
unstable_skipClientCache: options.unstable_skipClientCache || options.priority && !!true
|
|
2777
|
-
}).then(()=>false) : false;
|
|
2778
|
-
}),
|
|
2779
|
-
_this.pageLoader[options.priority ? "loadPage" : "prefetch"](route)
|
|
2780
|
-
]);
|
|
2781
|
-
})();
|
|
2782
|
-
}
|
|
2783
|
-
fetchComponent(route) {
|
|
2784
|
-
var _this = this;
|
|
2785
|
-
return _async_to_generator(function*() {
|
|
2786
|
-
const handleCancelled = getCancelledHandler({
|
|
2787
|
-
route,
|
|
2788
|
-
router: _this
|
|
2789
|
-
});
|
|
2790
|
-
try {
|
|
2791
|
-
const componentResult = yield _this.pageLoader.loadPage(route);
|
|
2792
|
-
handleCancelled();
|
|
2793
|
-
return componentResult;
|
|
2794
|
-
} catch (err) {
|
|
2795
|
-
handleCancelled();
|
|
2796
|
-
throw err;
|
|
2797
|
-
}
|
|
2798
|
-
})();
|
|
2799
|
-
}
|
|
2800
|
-
_getData(fn) {
|
|
2801
|
-
let cancelled = false;
|
|
2802
|
-
const cancel = ()=>{
|
|
2803
|
-
cancelled = true;
|
|
2804
|
-
};
|
|
2805
|
-
this.clc = cancel;
|
|
2806
|
-
return fn().then((data)=>{
|
|
2807
|
-
if (cancel === this.clc) {
|
|
2808
|
-
this.clc = null;
|
|
2809
|
-
}
|
|
2810
|
-
if (cancelled) {
|
|
2811
|
-
const err = new Error("Loading initial props cancelled");
|
|
2812
|
-
err.cancelled = true;
|
|
2813
|
-
throw err;
|
|
2814
|
-
}
|
|
2815
|
-
return data;
|
|
2816
|
-
});
|
|
2817
|
-
}
|
|
2818
|
-
_getFlightData(dataHref) {
|
|
2819
|
-
// Do not cache RSC flight response since it's not a static resource
|
|
2820
|
-
return fetchNextData({
|
|
2821
|
-
dataHref,
|
|
2822
|
-
isServerRender: true,
|
|
2823
|
-
parseJSON: false,
|
|
2824
|
-
inflightCache: this.sdc,
|
|
2825
|
-
persistCache: false,
|
|
2826
|
-
isPrefetch: false
|
|
2827
|
-
}).then(({ text })=>({
|
|
2828
|
-
data: text
|
|
2829
|
-
}));
|
|
2830
|
-
}
|
|
2831
|
-
getInitialProps(Component, ctx) {
|
|
2832
|
-
const { Component: App } = this.components["/_app"];
|
|
2833
|
-
const AppTree = this._wrapApp(App);
|
|
2834
|
-
ctx.AppTree = AppTree;
|
|
2835
|
-
return (0, _utils).loadGetInitialProps(App, {
|
|
2836
|
-
AppTree,
|
|
2837
|
-
Component,
|
|
2838
|
-
router: this,
|
|
2839
|
-
ctx
|
|
2840
|
-
});
|
|
2841
|
-
}
|
|
2842
|
-
get route() {
|
|
2843
|
-
return this.state.route;
|
|
2844
|
-
}
|
|
2845
|
-
get pathname() {
|
|
2846
|
-
return this.state.pathname;
|
|
2847
|
-
}
|
|
2848
|
-
get query() {
|
|
2849
|
-
return this.state.query;
|
|
2850
|
-
}
|
|
2851
|
-
get asPath() {
|
|
2852
|
-
return this.state.asPath;
|
|
2853
|
-
}
|
|
2854
|
-
get locale() {
|
|
2855
|
-
return this.state.locale;
|
|
2856
|
-
}
|
|
2857
|
-
get isFallback() {
|
|
2858
|
-
return this.state.isFallback;
|
|
2859
|
-
}
|
|
2860
|
-
get isPreview() {
|
|
2861
|
-
return this.state.isPreview;
|
|
2862
|
-
}
|
|
2863
|
-
constructor(pathname1, query1, as1, { initialProps , pageLoader , App , wrapApp , Component , err , subscription , isFallback , locale , locales , defaultLocale , domainLocales , isPreview }){
|
|
2864
|
-
// Server Data Cache (full data requests)
|
|
2865
|
-
this.sdc = {};
|
|
2866
|
-
// Server Background Cache (HEAD requests)
|
|
2867
|
-
this.sbc = {};
|
|
2868
|
-
this.isFirstPopStateEvent = true;
|
|
2869
|
-
this._key = createKey();
|
|
2870
|
-
this.onPopState = (e)=>{
|
|
2871
|
-
const { isFirstPopStateEvent } = this;
|
|
2872
|
-
this.isFirstPopStateEvent = false;
|
|
2873
|
-
const state = e.state;
|
|
2874
|
-
if (!state) {
|
|
2875
|
-
// We get state as undefined for two reasons.
|
|
2876
|
-
// 1. With older safari (< 8) and older chrome (< 34)
|
|
2877
|
-
// 2. When the URL changed with #
|
|
2878
|
-
//
|
|
2879
|
-
// In the both cases, we don't need to proceed and change the route.
|
|
2880
|
-
// (as it's already changed)
|
|
2881
|
-
// But we can simply replace the state with the new changes.
|
|
2882
|
-
// Actually, for (1) we don't need to nothing. But it's hard to detect that event.
|
|
2883
|
-
// So, doing the following for (1) does no harm.
|
|
2884
|
-
const { pathname , query } = this;
|
|
2885
|
-
this.changeState("replaceState", (0, _formatUrl).formatWithValidation({
|
|
2886
|
-
pathname: (0, _addBasePath).addBasePath(pathname),
|
|
2887
|
-
query
|
|
2888
|
-
}), (0, _utils).getURL());
|
|
2889
|
-
return;
|
|
2890
|
-
}
|
|
2891
|
-
// __NA is used to identify if the history entry can be handled by the app-router.
|
|
2892
|
-
if (state.__NA) {
|
|
2893
|
-
window.location.reload();
|
|
2894
|
-
return;
|
|
2895
|
-
}
|
|
2896
|
-
if (!state.__N) {
|
|
2897
|
-
return;
|
|
2898
|
-
}
|
|
2899
|
-
// Safari fires popstateevent when reopening the browser.
|
|
2900
|
-
if (isFirstPopStateEvent && this.locale === state.options.locale && state.as === this.asPath) {
|
|
2901
|
-
return;
|
|
2902
|
-
}
|
|
2903
|
-
let forcedScroll;
|
|
2904
|
-
const { url , as , options , key } = state;
|
|
2905
|
-
if (false) {}
|
|
2906
|
-
this._key = key;
|
|
2907
|
-
const { pathname } = (0, _parseRelativeUrl).parseRelativeUrl(url);
|
|
2908
|
-
// Make sure we don't re-render on initial load,
|
|
2909
|
-
// can be caused by navigating back from an external site
|
|
2910
|
-
if (this.isSsr && as === (0, _addBasePath).addBasePath(this.asPath) && pathname === (0, _addBasePath).addBasePath(this.pathname)) {
|
|
2911
|
-
return;
|
|
2912
|
-
}
|
|
2913
|
-
// If the downstream application returns falsy, return.
|
|
2914
|
-
// They will then be responsible for handling the event.
|
|
2915
|
-
if (this._bps && !this._bps(state)) {
|
|
2916
|
-
return;
|
|
2917
|
-
}
|
|
2918
|
-
this.change("replaceState", url, as, Object.assign({}, options, {
|
|
2919
|
-
shallow: options.shallow && this._shallow,
|
|
2920
|
-
locale: options.locale || this.defaultLocale,
|
|
2921
|
-
// @ts-ignore internal value not exposed on types
|
|
2922
|
-
_h: 0
|
|
2923
|
-
}), forcedScroll);
|
|
2924
|
-
};
|
|
2925
|
-
// represents the current component key
|
|
2926
|
-
const route = (0, _removeTrailingSlash).removeTrailingSlash(pathname1);
|
|
2927
|
-
// set up the component cache (by route keys)
|
|
2928
|
-
this.components = {};
|
|
2929
|
-
// We should not keep the cache, if there's an error
|
|
2930
|
-
// Otherwise, this cause issues when when going back and
|
|
2931
|
-
// come again to the errored page.
|
|
2932
|
-
if (pathname1 !== "/_error") {
|
|
2933
|
-
this.components[route] = {
|
|
2934
|
-
Component,
|
|
2935
|
-
initial: true,
|
|
2936
|
-
props: initialProps,
|
|
2937
|
-
err,
|
|
2938
|
-
__N_SSG: initialProps && initialProps.__N_SSG,
|
|
2939
|
-
__N_SSP: initialProps && initialProps.__N_SSP
|
|
2940
|
-
};
|
|
2941
|
-
}
|
|
2942
|
-
this.components["/_app"] = {
|
|
2943
|
-
Component: App,
|
|
2944
|
-
styleSheets: []
|
|
2945
|
-
};
|
|
2946
|
-
// Backwards compat for Router.router.events
|
|
2947
|
-
// TODO: Should be remove the following major version as it was never documented
|
|
2948
|
-
this.events = Router.events;
|
|
2949
|
-
this.pageLoader = pageLoader;
|
|
2950
|
-
// if auto prerendered and dynamic route wait to update asPath
|
|
2951
|
-
// until after mount to prevent hydration mismatch
|
|
2952
|
-
const autoExportDynamic = (0, _isDynamic).isDynamicRoute(pathname1) && self.__NEXT_DATA__.autoExport;
|
|
2953
|
-
this.basePath = false || "";
|
|
2954
|
-
this.sub = subscription;
|
|
2955
|
-
this.clc = null;
|
|
2956
|
-
this._wrapApp = wrapApp;
|
|
2957
|
-
// make sure to ignore extra popState in safari on navigating
|
|
2958
|
-
// back from external site
|
|
2959
|
-
this.isSsr = true;
|
|
2960
|
-
this.isLocaleDomain = false;
|
|
2961
|
-
this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp || !autoExportDynamic && !self.location.search && !false);
|
|
2962
|
-
if (false) {}
|
|
2963
|
-
this.state = {
|
|
2964
|
-
route,
|
|
2965
|
-
pathname: pathname1,
|
|
2966
|
-
query: query1,
|
|
2967
|
-
asPath: autoExportDynamic ? pathname1 : as1,
|
|
2968
|
-
isPreview: !!isPreview,
|
|
2969
|
-
locale: false ? 0 : undefined,
|
|
2970
|
-
isFallback
|
|
2971
|
-
};
|
|
2972
|
-
this._initialMatchesMiddlewarePromise = Promise.resolve(false);
|
|
2973
|
-
if (false) {}
|
|
2974
|
-
}
|
|
2975
|
-
}
|
|
2976
|
-
Router.events = (0, _mitt).default();
|
|
2977
|
-
exports["default"] = Router; //# sourceMappingURL=router.js.map
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
/***/ }),
|
|
2981
|
-
|
|
2982
|
-
/***/ 79423:
|
|
2983
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
2984
|
-
|
|
2985
|
-
"use strict";
|
|
2986
|
-
|
|
2987
|
-
Object.defineProperty(exports, "__esModule", ({
|
|
2988
|
-
value: true
|
|
2989
|
-
}));
|
|
2990
|
-
exports.isAPIRoute = isAPIRoute;
|
|
2991
|
-
function isAPIRoute(value) {
|
|
2992
|
-
return value === "/api" || Boolean(value == null ? void 0 : value.startsWith("/api/"));
|
|
2993
|
-
}
|
|
2994
|
-
|
|
2995
|
-
//# sourceMappingURL=is-api-route.js.map
|
|
2996
|
-
|
|
2997
610
|
/***/ }),
|
|
2998
611
|
|
|
2999
612
|
/***/ 41664:
|