@eventcatalog/core 0.0.6 → 0.0.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 -0
- package/.next/build-manifest.json +110 -0
- package/.next/cache/.tsbuildinfo +1 -0
- package/.next/cache/config.json +7 -0
- package/.next/cache/eslint/.cache_1bay4w0 +1 -0
- package/.next/cache/next-server.js.nft.json +1 -0
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-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/export-marker.json +1 -0
- package/.next/images-manifest.json +1 -0
- package/.next/next-server.js.nft.json +1 -0
- package/.next/prerender-manifest.json +1 -0
- package/.next/react-loadable-manifest.json +1717 -0
- package/.next/required-server-files.json +1 -0
- package/.next/routes-manifest.json +1 -0
- package/.next/server/chunks/237.js +116 -0
- package/.next/server/chunks/428.js +84 -0
- package/.next/server/chunks/47.js +51 -0
- package/.next/server/chunks/526.js +131 -0
- package/.next/server/chunks/565.js +121 -0
- package/.next/server/chunks/596.js +98 -0
- package/.next/server/chunks/730.js +324 -0
- package/.next/server/chunks/8.js +122 -0
- package/.next/server/chunks/938.js +109 -0
- package/.next/server/chunks/944.js +649 -0
- package/.next/server/chunks/959.js +286 -0
- package/.next/server/chunks/97.js +1837 -0
- package/.next/server/chunks/font-manifest.json +1 -0
- package/.next/server/font-manifest.json +1 -0
- package/.next/server/middleware-manifest.json +6 -0
- package/.next/server/pages/404.html +1 -0
- package/.next/server/pages/500.html +1 -0
- package/.next/server/pages/_app.js +370 -0
- package/.next/server/pages/_app.js.nft.json +1 -0
- package/.next/server/pages/_document.js +1004 -0
- package/.next/server/pages/_document.js.nft.json +1 -0
- package/.next/server/pages/_error.js +123 -0
- package/.next/server/pages/_error.js.nft.json +1 -0
- package/.next/server/pages/api/event/[name]/download.js +64 -0
- package/.next/server/pages/api/event/[name]/download.js.nft.json +1 -0
- package/.next/server/pages/events/AddedItemToCart.html +73 -0
- package/.next/server/pages/events/AddedItemToCart.json +1 -0
- package/.next/server/pages/events/OrderComplete.html +48 -0
- package/.next/server/pages/events/OrderComplete.json +1 -0
- package/.next/server/pages/events/OrderConfirmed.html +48 -0
- package/.next/server/pages/events/OrderConfirmed.json +1 -0
- package/.next/server/pages/events/OrderRequested.html +48 -0
- package/.next/server/pages/events/OrderRequested.json +1 -0
- package/.next/server/pages/events/PaymentProcessed.html +52 -0
- package/.next/server/pages/events/PaymentProcessed.json +1 -0
- package/.next/server/pages/events/RemovedItemFromCart.html +55 -0
- package/.next/server/pages/events/RemovedItemFromCart.json +1 -0
- package/.next/server/pages/events/ShipmentDelivered.html +53 -0
- package/.next/server/pages/events/ShipmentDelivered.json +1 -0
- package/.next/server/pages/events/ShipmentDispatched.html +52 -0
- package/.next/server/pages/events/ShipmentDispatched.json +1 -0
- package/.next/server/pages/events/ShipmentPrepared.html +52 -0
- package/.next/server/pages/events/ShipmentPrepared.json +1 -0
- package/.next/server/pages/events/[name]/logs.js +414 -0
- package/.next/server/pages/events/[name]/logs.js.nft.json +1 -0
- package/.next/server/pages/events/[name]/v/[version].js +274 -0
- package/.next/server/pages/events/[name]/v/[version].js.nft.json +1 -0
- package/.next/server/pages/events/[name].js +235 -0
- package/.next/server/pages/events/[name].js.nft.json +1 -0
- package/.next/server/pages/events.js +519 -0
- package/.next/server/pages/events.js.nft.json +1 -0
- package/.next/server/pages/index.html +1 -0
- package/.next/server/pages/index.js.nft.json +1 -0
- package/.next/server/pages/overview.js +240 -0
- package/.next/server/pages/overview.js.nft.json +1 -0
- package/.next/server/pages/services/Basket Service.html +11 -0
- package/.next/server/pages/services/Basket Service.json +1 -0
- package/.next/server/pages/services/Data Lake.html +12 -0
- package/.next/server/pages/services/Data Lake.json +1 -0
- package/.next/server/pages/services/Payment Service.html +10 -0
- package/.next/server/pages/services/Payment Service.json +1 -0
- package/.next/server/pages/services/Shipping Service.html +14 -0
- package/.next/server/pages/services/Shipping Service.json +1 -0
- package/.next/server/pages/services/[name].js +675 -0
- package/.next/server/pages/services/[name].js.nft.json +1 -0
- package/.next/server/pages/services.js +396 -0
- package/.next/server/pages/services.js.nft.json +1 -0
- package/.next/server/pages/users/[id].js +327 -0
- package/.next/server/pages/users/[id].js.nft.json +1 -0
- package/.next/server/pages-manifest.json +16 -0
- package/.next/server/webpack-api-runtime.js +160 -0
- package/.next/server/webpack-runtime.js +264 -0
- package/.next/static/chunks/020d8314.aea2d24215754e7b.js +1 -0
- package/.next/static/chunks/176cb4e4-8a0f6f010ef8accb.js +1 -0
- package/.next/static/chunks/236-0acd5083c102a9cb.js +1 -0
- package/.next/static/chunks/274-11c4d093341d7201.js +1 -0
- package/.next/static/chunks/336-5d9007a96aa8f2c7.js +1 -0
- package/.next/static/chunks/364-3cb3c8cf1d3c95de.js +1 -0
- package/.next/static/chunks/519-7f22292093abd7c3.js +1 -0
- package/.next/static/chunks/638.d570519ae49c92c8.js +1 -0
- package/.next/static/chunks/873-9d69271e4b2dd496.js +1 -0
- package/.next/static/chunks/962-d5070461f6d4a478.js +1 -0
- package/.next/static/chunks/framework-576ec6a1c1386453.js +1 -0
- package/.next/static/chunks/main-0289ecbd51cd4cb4.js +1 -0
- package/.next/static/chunks/pages/_app-c9d3172cc09cf069.js +1 -0
- package/.next/static/chunks/pages/_error-5a714c45c50a8db4.js +1 -0
- package/.next/static/chunks/pages/events/[name]/logs-d159d7b82f44847f.js +1 -0
- package/.next/static/chunks/pages/events/[name]/v/[version]-dc146dc9bfa7362d.js +1 -0
- package/.next/static/chunks/pages/events/[name]-fb77119f66a5793e.js +1 -0
- package/.next/static/chunks/pages/events-bcad8442f21d6b67.js +1 -0
- package/.next/static/chunks/pages/index-3eeab7e4014a02ea.js +1 -0
- package/.next/static/chunks/pages/overview-5ac749891cbe1922.js +1 -0
- package/.next/static/chunks/pages/services/[name]-69692188d11304b7.js +1 -0
- package/.next/static/chunks/pages/services-bcc61898062e1bf4.js +1 -0
- package/.next/static/chunks/pages/users/[id]-2da54ccb6319b207.js +1 -0
- package/.next/static/chunks/polyfills-5cd94c89d3acac5f.js +1 -0
- package/.next/static/chunks/webpack-afe52d4a9fcc5a75.js +1 -0
- package/.next/static/css/5eeed9cb243ce668.css +1 -0
- package/.next/static/css/b44e1178a88a93b4.css +3 -0
- package/.next/static/yc3MsaLWgBvovlJpHpfqc/_buildManifest.js +1 -0
- package/.next/static/yc3MsaLWgBvovlJpHpfqc/_middlewareManifest.js +1 -0
- package/.next/static/yc3MsaLWgBvovlJpHpfqc/_ssgManifest.js +1 -0
- package/.next/trace +37 -0
- package/CHANGELOG.md +30 -0
- package/bin/eventcatalog.js +4 -15
- package/components/ContentView.tsx +22 -29
- package/components/Grids/EventGrid.tsx +3 -13
- package/components/Grids/ServiceGrid.tsx +3 -11
- package/components/Header.tsx +1 -3
- package/components/Mdx/Examples.tsx +2 -9
- package/components/NotFound/index.tsx +2 -6
- package/components/Sidebars/EventSidebar.tsx +19 -14
- package/components/Sidebars/ServiceSidebar.tsx +26 -25
- package/eventcatalog.config.js +40 -0
- package/hooks/EventCatalog.tsx +1 -1
- package/lib/__tests__/assets/services/Basket Service/index.md +19 -0
- package/lib/__tests__/events.spec.ts +16 -27
- package/lib/__tests__/file-reader.spec.ts +3 -9
- package/lib/__tests__/services.spec.ts +27 -6
- package/lib/events.ts +5 -10
- package/lib/file-reader.ts +1 -3
- package/lib/graphs.ts +2 -4
- package/lib/services.ts +5 -11
- package/package.json +2 -2
- package/pages/_app.tsx +3 -12
- package/pages/events/[name]/logs.tsx +7 -18
- package/pages/events/[name].tsx +4 -13
- package/pages/events.tsx +5 -16
- package/pages/index.tsx +2 -9
- package/pages/overview.tsx +1 -4
- package/pages/services/[name].tsx +2 -2
- package/pages/services.tsx +2 -6
- package/pages/users/[id].tsx +4 -13
- package/scripts/__tests__/assets/eventcatalog.config.js +1 -2
- package/scripts/__tests__/generate.spec.ts +1 -4
- package/scripts/generate.js +1 -1
- package/tailwind.config.js +1 -5
- package/tsconfig.json +1 -7
|
@@ -0,0 +1,1837 @@
|
|
|
1
|
+
exports.id = 97;
|
|
2
|
+
exports.ids = [97];
|
|
3
|
+
exports.modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 162:
|
|
6
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
var __webpack_unused_export__;
|
|
10
|
+
|
|
11
|
+
__webpack_unused_export__ = ({
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
exports["default"] = void 0;
|
|
15
|
+
var _react = _interopRequireDefault(__webpack_require__(6689));
|
|
16
|
+
var _router = __webpack_require__(9918);
|
|
17
|
+
var _router1 = __webpack_require__(3642);
|
|
18
|
+
var _useIntersection = __webpack_require__(2030);
|
|
19
|
+
function _interopRequireDefault(obj) {
|
|
20
|
+
return obj && obj.__esModule ? obj : {
|
|
21
|
+
default: obj
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const prefetched = {
|
|
25
|
+
};
|
|
26
|
+
function prefetch(router, href, as, options) {
|
|
27
|
+
if (true) return;
|
|
28
|
+
if (!(0, _router).isLocalURL(href)) return;
|
|
29
|
+
// Prefetch the JSON page if asked (only in the client)
|
|
30
|
+
// We need to handle a prefetch error here since we may be
|
|
31
|
+
// loading with priority which can reject but we don't
|
|
32
|
+
// want to force navigation since this is only a prefetch
|
|
33
|
+
router.prefetch(href, as, options).catch((err)=>{
|
|
34
|
+
if (false) {}
|
|
35
|
+
});
|
|
36
|
+
const curLocale = options && typeof options.locale !== 'undefined' ? options.locale : router && router.locale;
|
|
37
|
+
// Join on an invalid URI character
|
|
38
|
+
prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')] = true;
|
|
39
|
+
}
|
|
40
|
+
function isModifiedEvent(event) {
|
|
41
|
+
const { target } = event.currentTarget;
|
|
42
|
+
return target && target !== '_self' || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.nativeEvent && event.nativeEvent.which === 2;
|
|
43
|
+
}
|
|
44
|
+
function linkClicked(e, router, href, as, replace, shallow, scroll, locale) {
|
|
45
|
+
const { nodeName } = e.currentTarget;
|
|
46
|
+
if (nodeName === 'A' && (isModifiedEvent(e) || !(0, _router).isLocalURL(href))) {
|
|
47
|
+
// ignore click for browser’s default behavior
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
// avoid scroll for urls with anchor refs
|
|
52
|
+
if (scroll == null && as.indexOf('#') >= 0) {
|
|
53
|
+
scroll = false;
|
|
54
|
+
}
|
|
55
|
+
// replace state instead of push if prop is present
|
|
56
|
+
router[replace ? 'replace' : 'push'](href, as, {
|
|
57
|
+
shallow,
|
|
58
|
+
locale,
|
|
59
|
+
scroll
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function Link(props) {
|
|
63
|
+
if (false) {}
|
|
64
|
+
const p = props.prefetch !== false;
|
|
65
|
+
const router = (0, _router1).useRouter();
|
|
66
|
+
const { href , as } = _react.default.useMemo(()=>{
|
|
67
|
+
const [resolvedHref, resolvedAs] = (0, _router).resolveHref(router, props.href, true);
|
|
68
|
+
return {
|
|
69
|
+
href: resolvedHref,
|
|
70
|
+
as: props.as ? (0, _router).resolveHref(router, props.as) : resolvedAs || resolvedHref
|
|
71
|
+
};
|
|
72
|
+
}, [
|
|
73
|
+
router,
|
|
74
|
+
props.href,
|
|
75
|
+
props.as
|
|
76
|
+
]);
|
|
77
|
+
let { children , replace , shallow , scroll , locale } = props;
|
|
78
|
+
if (typeof children === 'string') {
|
|
79
|
+
children = /*#__PURE__*/ _react.default.createElement("a", null, children);
|
|
80
|
+
}
|
|
81
|
+
// This will return the first child, if multiple are provided it will throw an error
|
|
82
|
+
let child;
|
|
83
|
+
if (false) {} else {
|
|
84
|
+
child = _react.default.Children.only(children);
|
|
85
|
+
}
|
|
86
|
+
const childRef = child && typeof child === 'object' && child.ref;
|
|
87
|
+
const [setIntersectionRef, isVisible] = (0, _useIntersection).useIntersection({
|
|
88
|
+
rootMargin: '200px'
|
|
89
|
+
});
|
|
90
|
+
const setRef = _react.default.useCallback((el)=>{
|
|
91
|
+
setIntersectionRef(el);
|
|
92
|
+
if (childRef) {
|
|
93
|
+
if (typeof childRef === 'function') childRef(el);
|
|
94
|
+
else if (typeof childRef === 'object') {
|
|
95
|
+
childRef.current = el;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, [
|
|
99
|
+
childRef,
|
|
100
|
+
setIntersectionRef
|
|
101
|
+
]);
|
|
102
|
+
_react.default.useEffect(()=>{
|
|
103
|
+
const shouldPrefetch = isVisible && p && (0, _router).isLocalURL(href);
|
|
104
|
+
const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale;
|
|
105
|
+
const isPrefetched = prefetched[href + '%' + as + (curLocale ? '%' + curLocale : '')];
|
|
106
|
+
if (shouldPrefetch && !isPrefetched) {
|
|
107
|
+
prefetch(router, href, as, {
|
|
108
|
+
locale: curLocale
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}, [
|
|
112
|
+
as,
|
|
113
|
+
href,
|
|
114
|
+
isVisible,
|
|
115
|
+
locale,
|
|
116
|
+
p,
|
|
117
|
+
router
|
|
118
|
+
]);
|
|
119
|
+
const childProps = {
|
|
120
|
+
ref: setRef,
|
|
121
|
+
onClick: (e)=>{
|
|
122
|
+
if (child.props && typeof child.props.onClick === 'function') {
|
|
123
|
+
child.props.onClick(e);
|
|
124
|
+
}
|
|
125
|
+
if (!e.defaultPrevented) {
|
|
126
|
+
linkClicked(e, router, href, as, replace, shallow, scroll, locale);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
childProps.onMouseEnter = (e)=>{
|
|
131
|
+
if (child.props && typeof child.props.onMouseEnter === 'function') {
|
|
132
|
+
child.props.onMouseEnter(e);
|
|
133
|
+
}
|
|
134
|
+
if ((0, _router).isLocalURL(href)) {
|
|
135
|
+
prefetch(router, href, as, {
|
|
136
|
+
priority: true
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
// If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is
|
|
141
|
+
// defined, we specify the current 'href', so that repetition is not needed by the user
|
|
142
|
+
if (props.passHref || child.type === 'a' && !('href' in child.props)) {
|
|
143
|
+
const curLocale = typeof locale !== 'undefined' ? locale : router && router.locale;
|
|
144
|
+
// we only render domain locales if we are currently on a domain locale
|
|
145
|
+
// so that locale links are still visitable in development/preview envs
|
|
146
|
+
const localeDomain = router && router.isLocaleDomain && (0, _router).getDomainLocale(as, curLocale, router && router.locales, router && router.domainLocales);
|
|
147
|
+
childProps.href = localeDomain || (0, _router).addBasePath((0, _router).addLocale(as, curLocale, router && router.defaultLocale));
|
|
148
|
+
}
|
|
149
|
+
return(/*#__PURE__*/ _react.default.cloneElement(child, childProps));
|
|
150
|
+
}
|
|
151
|
+
var _default = Link;
|
|
152
|
+
exports["default"] = _default; //# sourceMappingURL=link.js.map
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
/***/ }),
|
|
156
|
+
|
|
157
|
+
/***/ 583:
|
|
158
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
159
|
+
|
|
160
|
+
"use strict";
|
|
161
|
+
|
|
162
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
163
|
+
value: true
|
|
164
|
+
}));
|
|
165
|
+
exports.removePathTrailingSlash = removePathTrailingSlash;
|
|
166
|
+
exports.normalizePathTrailingSlash = void 0;
|
|
167
|
+
function removePathTrailingSlash(path) {
|
|
168
|
+
return path.endsWith('/') && path !== '/' ? path.slice(0, -1) : path;
|
|
169
|
+
}
|
|
170
|
+
const normalizePathTrailingSlash = false ? 0 : removePathTrailingSlash;
|
|
171
|
+
exports.normalizePathTrailingSlash = normalizePathTrailingSlash; //# sourceMappingURL=normalize-trailing-slash.js.map
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
/***/ }),
|
|
175
|
+
|
|
176
|
+
/***/ 1437:
|
|
177
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
178
|
+
|
|
179
|
+
"use strict";
|
|
180
|
+
|
|
181
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
182
|
+
value: true
|
|
183
|
+
}));
|
|
184
|
+
exports.markAssetError = markAssetError;
|
|
185
|
+
exports.isAssetError = isAssetError;
|
|
186
|
+
exports.getClientBuildManifest = getClientBuildManifest;
|
|
187
|
+
exports.getMiddlewareManifest = getMiddlewareManifest;
|
|
188
|
+
exports.createRouteLoader = createRouteLoader;
|
|
189
|
+
var _getAssetPathFromRoute = _interopRequireDefault(__webpack_require__(9565));
|
|
190
|
+
var _requestIdleCallback = __webpack_require__(9071);
|
|
191
|
+
function _interopRequireDefault(obj) {
|
|
192
|
+
return obj && obj.__esModule ? obj : {
|
|
193
|
+
default: obj
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
// 3.8s was arbitrarily chosen as it's what https://web.dev/interactive
|
|
197
|
+
// considers as "Good" time-to-interactive. We must assume something went
|
|
198
|
+
// wrong beyond this point, and then fall-back to a full page transition to
|
|
199
|
+
// show the user something of value.
|
|
200
|
+
const MS_MAX_IDLE_DELAY = 3800;
|
|
201
|
+
function withFuture(key, map, generator) {
|
|
202
|
+
let entry = map.get(key);
|
|
203
|
+
if (entry) {
|
|
204
|
+
if ('future' in entry) {
|
|
205
|
+
return entry.future;
|
|
206
|
+
}
|
|
207
|
+
return Promise.resolve(entry);
|
|
208
|
+
}
|
|
209
|
+
let resolver;
|
|
210
|
+
const prom = new Promise((resolve)=>{
|
|
211
|
+
resolver = resolve;
|
|
212
|
+
});
|
|
213
|
+
map.set(key, entry = {
|
|
214
|
+
resolve: resolver,
|
|
215
|
+
future: prom
|
|
216
|
+
});
|
|
217
|
+
return generator ? generator() // eslint-disable-next-line no-sequences
|
|
218
|
+
.then((value)=>(resolver(value), value)
|
|
219
|
+
).catch((err)=>{
|
|
220
|
+
map.delete(key);
|
|
221
|
+
throw err;
|
|
222
|
+
}) : prom;
|
|
223
|
+
}
|
|
224
|
+
function hasPrefetch(link) {
|
|
225
|
+
try {
|
|
226
|
+
link = document.createElement('link');
|
|
227
|
+
return(// with relList.support
|
|
228
|
+
(!!window.MSInputMethodContext && !!document.documentMode) || link.relList.supports('prefetch'));
|
|
229
|
+
} catch (e) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const canPrefetch = hasPrefetch();
|
|
234
|
+
function prefetchViaDom(href, as, link) {
|
|
235
|
+
return new Promise((res, rej)=>{
|
|
236
|
+
const selector = `
|
|
237
|
+
link[rel="prefetch"][href^="${href}"],
|
|
238
|
+
link[rel="preload"][href^="${href}"],
|
|
239
|
+
script[src^="${href}"]`;
|
|
240
|
+
if (document.querySelector(selector)) {
|
|
241
|
+
return res();
|
|
242
|
+
}
|
|
243
|
+
link = document.createElement('link');
|
|
244
|
+
// The order of property assignment here is intentional:
|
|
245
|
+
if (as) link.as = as;
|
|
246
|
+
link.rel = `prefetch`;
|
|
247
|
+
link.crossOrigin = undefined;
|
|
248
|
+
link.onload = res;
|
|
249
|
+
link.onerror = rej;
|
|
250
|
+
// `href` should always be last:
|
|
251
|
+
link.href = href;
|
|
252
|
+
document.head.appendChild(link);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const ASSET_LOAD_ERROR = Symbol('ASSET_LOAD_ERROR');
|
|
256
|
+
function markAssetError(err) {
|
|
257
|
+
return Object.defineProperty(err, ASSET_LOAD_ERROR, {
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function isAssetError(err) {
|
|
261
|
+
return err && ASSET_LOAD_ERROR in err;
|
|
262
|
+
}
|
|
263
|
+
function appendScript(src, script) {
|
|
264
|
+
return new Promise((resolve, reject)=>{
|
|
265
|
+
script = document.createElement('script');
|
|
266
|
+
// The order of property assignment here is intentional.
|
|
267
|
+
// 1. Setup success/failure hooks in case the browser synchronously
|
|
268
|
+
// executes when `src` is set.
|
|
269
|
+
script.onload = resolve;
|
|
270
|
+
script.onerror = ()=>reject(markAssetError(new Error(`Failed to load script: ${src}`)))
|
|
271
|
+
;
|
|
272
|
+
// 2. Configure the cross-origin attribute before setting `src` in case the
|
|
273
|
+
// browser begins to fetch.
|
|
274
|
+
script.crossOrigin = undefined;
|
|
275
|
+
// 3. Finally, set the source and inject into the DOM in case the child
|
|
276
|
+
// must be appended for fetching to start.
|
|
277
|
+
script.src = src;
|
|
278
|
+
document.body.appendChild(script);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
// We wait for pages to be built in dev before we start the route transition
|
|
282
|
+
// timeout to prevent an un-necessary hard navigation in development.
|
|
283
|
+
let devBuildPromise;
|
|
284
|
+
// Resolve a promise that times out after given amount of milliseconds.
|
|
285
|
+
function resolvePromiseWithTimeout(p, ms, err) {
|
|
286
|
+
return new Promise((resolve, reject)=>{
|
|
287
|
+
let cancelled = false;
|
|
288
|
+
p.then((r)=>{
|
|
289
|
+
// Resolved, cancel the timeout
|
|
290
|
+
cancelled = true;
|
|
291
|
+
resolve(r);
|
|
292
|
+
}).catch(reject);
|
|
293
|
+
// We wrap these checks separately for better dead-code elimination in
|
|
294
|
+
// production bundles.
|
|
295
|
+
if (false) {}
|
|
296
|
+
if (true) {
|
|
297
|
+
(0, _requestIdleCallback).requestIdleCallback(()=>setTimeout(()=>{
|
|
298
|
+
if (!cancelled) {
|
|
299
|
+
reject(err);
|
|
300
|
+
}
|
|
301
|
+
}, ms)
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function getClientBuildManifest() {
|
|
307
|
+
if (self.__BUILD_MANIFEST) {
|
|
308
|
+
return Promise.resolve(self.__BUILD_MANIFEST);
|
|
309
|
+
}
|
|
310
|
+
const onBuildManifest = new Promise((resolve)=>{
|
|
311
|
+
// Mandatory because this is not concurrent safe:
|
|
312
|
+
const cb = self.__BUILD_MANIFEST_CB;
|
|
313
|
+
self.__BUILD_MANIFEST_CB = ()=>{
|
|
314
|
+
resolve(self.__BUILD_MANIFEST);
|
|
315
|
+
cb && cb();
|
|
316
|
+
};
|
|
317
|
+
});
|
|
318
|
+
return resolvePromiseWithTimeout(onBuildManifest, MS_MAX_IDLE_DELAY, markAssetError(new Error('Failed to load client build manifest')));
|
|
319
|
+
}
|
|
320
|
+
function getMiddlewareManifest() {
|
|
321
|
+
if (self.__MIDDLEWARE_MANIFEST) {
|
|
322
|
+
return Promise.resolve(self.__MIDDLEWARE_MANIFEST);
|
|
323
|
+
}
|
|
324
|
+
const onMiddlewareManifest = new Promise((resolve)=>{
|
|
325
|
+
const cb = self.__MIDDLEWARE_MANIFEST_CB;
|
|
326
|
+
self.__MIDDLEWARE_MANIFEST_CB = ()=>{
|
|
327
|
+
resolve(self.__MIDDLEWARE_MANIFEST);
|
|
328
|
+
cb && cb();
|
|
329
|
+
};
|
|
330
|
+
});
|
|
331
|
+
return resolvePromiseWithTimeout(onMiddlewareManifest, MS_MAX_IDLE_DELAY, markAssetError(new Error('Failed to load client middleware manifest')));
|
|
332
|
+
}
|
|
333
|
+
function getFilesForRoute(assetPrefix, route) {
|
|
334
|
+
if (false) {}
|
|
335
|
+
return getClientBuildManifest().then((manifest)=>{
|
|
336
|
+
if (!(route in manifest)) {
|
|
337
|
+
throw markAssetError(new Error(`Failed to lookup route: ${route}`));
|
|
338
|
+
}
|
|
339
|
+
const allFiles = manifest[route].map((entry)=>assetPrefix + '/_next/' + encodeURI(entry)
|
|
340
|
+
);
|
|
341
|
+
return {
|
|
342
|
+
scripts: allFiles.filter((v)=>v.endsWith('.js')
|
|
343
|
+
),
|
|
344
|
+
css: allFiles.filter((v)=>v.endsWith('.css')
|
|
345
|
+
)
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function createRouteLoader(assetPrefix) {
|
|
350
|
+
const entrypoints = new Map();
|
|
351
|
+
const loadedScripts = new Map();
|
|
352
|
+
const styleSheets = new Map();
|
|
353
|
+
const routes = new Map();
|
|
354
|
+
function maybeExecuteScript(src) {
|
|
355
|
+
// With HMR we might need to "reload" scripts when they are
|
|
356
|
+
// disposed and readded. Executing scripts twice has no functional
|
|
357
|
+
// differences
|
|
358
|
+
if (true) {
|
|
359
|
+
let prom = loadedScripts.get(src);
|
|
360
|
+
if (prom) {
|
|
361
|
+
return prom;
|
|
362
|
+
}
|
|
363
|
+
// Skip executing script if it's already in the DOM:
|
|
364
|
+
if (document.querySelector(`script[src^="${src}"]`)) {
|
|
365
|
+
return Promise.resolve();
|
|
366
|
+
}
|
|
367
|
+
loadedScripts.set(src, prom = appendScript(src));
|
|
368
|
+
return prom;
|
|
369
|
+
} else {}
|
|
370
|
+
}
|
|
371
|
+
function fetchStyleSheet(href) {
|
|
372
|
+
let prom = styleSheets.get(href);
|
|
373
|
+
if (prom) {
|
|
374
|
+
return prom;
|
|
375
|
+
}
|
|
376
|
+
styleSheets.set(href, prom = fetch(href).then((res)=>{
|
|
377
|
+
if (!res.ok) {
|
|
378
|
+
throw new Error(`Failed to load stylesheet: ${href}`);
|
|
379
|
+
}
|
|
380
|
+
return res.text().then((text)=>({
|
|
381
|
+
href: href,
|
|
382
|
+
content: text
|
|
383
|
+
})
|
|
384
|
+
);
|
|
385
|
+
}).catch((err)=>{
|
|
386
|
+
throw markAssetError(err);
|
|
387
|
+
}));
|
|
388
|
+
return prom;
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
whenEntrypoint (route) {
|
|
392
|
+
return withFuture(route, entrypoints);
|
|
393
|
+
},
|
|
394
|
+
onEntrypoint (route, execute) {
|
|
395
|
+
(execute ? Promise.resolve().then(()=>execute()
|
|
396
|
+
).then((exports)=>({
|
|
397
|
+
component: exports && exports.default || exports,
|
|
398
|
+
exports: exports
|
|
399
|
+
})
|
|
400
|
+
, (err)=>({
|
|
401
|
+
error: err
|
|
402
|
+
})
|
|
403
|
+
) : Promise.resolve(undefined)).then((input)=>{
|
|
404
|
+
const old = entrypoints.get(route);
|
|
405
|
+
if (old && 'resolve' in old) {
|
|
406
|
+
if (input) {
|
|
407
|
+
entrypoints.set(route, input);
|
|
408
|
+
old.resolve(input);
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
if (input) {
|
|
412
|
+
entrypoints.set(route, input);
|
|
413
|
+
} else {
|
|
414
|
+
entrypoints.delete(route);
|
|
415
|
+
}
|
|
416
|
+
// when this entrypoint has been resolved before
|
|
417
|
+
// the route is outdated and we want to invalidate
|
|
418
|
+
// this cache entry
|
|
419
|
+
routes.delete(route);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
},
|
|
423
|
+
loadRoute (route, prefetch) {
|
|
424
|
+
return withFuture(route, routes, ()=>{
|
|
425
|
+
let devBuildPromiseResolve;
|
|
426
|
+
if (false) {}
|
|
427
|
+
return resolvePromiseWithTimeout(getFilesForRoute(assetPrefix, route).then(({ scripts , css })=>{
|
|
428
|
+
return Promise.all([
|
|
429
|
+
entrypoints.has(route) ? [] : Promise.all(scripts.map(maybeExecuteScript)),
|
|
430
|
+
Promise.all(css.map(fetchStyleSheet)),
|
|
431
|
+
]);
|
|
432
|
+
}).then((res)=>{
|
|
433
|
+
return this.whenEntrypoint(route).then((entrypoint)=>({
|
|
434
|
+
entrypoint,
|
|
435
|
+
styles: res[1]
|
|
436
|
+
})
|
|
437
|
+
);
|
|
438
|
+
}), MS_MAX_IDLE_DELAY, markAssetError(new Error(`Route did not complete loading: ${route}`))).then(({ entrypoint , styles })=>{
|
|
439
|
+
const res = Object.assign({
|
|
440
|
+
styles: styles
|
|
441
|
+
}, entrypoint);
|
|
442
|
+
return 'error' in entrypoint ? entrypoint : res;
|
|
443
|
+
}).catch((err)=>{
|
|
444
|
+
if (prefetch) {
|
|
445
|
+
// we don't want to cache errors during prefetch
|
|
446
|
+
throw err;
|
|
447
|
+
}
|
|
448
|
+
return {
|
|
449
|
+
error: err
|
|
450
|
+
};
|
|
451
|
+
}).finally(()=>{
|
|
452
|
+
return devBuildPromiseResolve === null || devBuildPromiseResolve === void 0 ? void 0 : devBuildPromiseResolve();
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
prefetch (route) {
|
|
457
|
+
// https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
|
|
458
|
+
// License: Apache 2.0
|
|
459
|
+
let cn;
|
|
460
|
+
if (cn = navigator.connection) {
|
|
461
|
+
// Don't prefetch if using 2G or if Save-Data is enabled.
|
|
462
|
+
if (cn.saveData || /2g/.test(cn.effectiveType)) return Promise.resolve();
|
|
463
|
+
}
|
|
464
|
+
return getFilesForRoute(assetPrefix, route).then((output)=>Promise.all(canPrefetch ? output.scripts.map((script)=>prefetchViaDom(script, 'script')
|
|
465
|
+
) : [])
|
|
466
|
+
).then(()=>{
|
|
467
|
+
(0, _requestIdleCallback).requestIdleCallback(()=>this.loadRoute(route, true).catch(()=>{
|
|
468
|
+
})
|
|
469
|
+
);
|
|
470
|
+
}).catch(()=>{
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
} //# sourceMappingURL=route-loader.js.map
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
/***/ }),
|
|
478
|
+
|
|
479
|
+
/***/ 3642:
|
|
480
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
481
|
+
|
|
482
|
+
"use strict";
|
|
483
|
+
|
|
484
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
485
|
+
value: true
|
|
486
|
+
}));
|
|
487
|
+
Object.defineProperty(exports, "Router", ({
|
|
488
|
+
enumerable: true,
|
|
489
|
+
get: function() {
|
|
490
|
+
return _router.default;
|
|
491
|
+
}
|
|
492
|
+
}));
|
|
493
|
+
Object.defineProperty(exports, "withRouter", ({
|
|
494
|
+
enumerable: true,
|
|
495
|
+
get: function() {
|
|
496
|
+
return _withRouter.default;
|
|
497
|
+
}
|
|
498
|
+
}));
|
|
499
|
+
exports.useRouter = useRouter;
|
|
500
|
+
exports.createRouter = createRouter;
|
|
501
|
+
exports.makePublicRouterInstance = makePublicRouterInstance;
|
|
502
|
+
exports["default"] = void 0;
|
|
503
|
+
var _react = _interopRequireDefault(__webpack_require__(6689));
|
|
504
|
+
var _router = _interopRequireDefault(__webpack_require__(9918));
|
|
505
|
+
var _routerContext = __webpack_require__(4964);
|
|
506
|
+
var _isError = _interopRequireDefault(__webpack_require__(274));
|
|
507
|
+
var _withRouter = _interopRequireDefault(__webpack_require__(4959));
|
|
508
|
+
function _interopRequireDefault(obj) {
|
|
509
|
+
return obj && obj.__esModule ? obj : {
|
|
510
|
+
default: obj
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
const singletonRouter = {
|
|
514
|
+
router: null,
|
|
515
|
+
readyCallbacks: [],
|
|
516
|
+
ready (cb) {
|
|
517
|
+
if (this.router) return cb();
|
|
518
|
+
if (false) {}
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
// Create public properties and methods of the router in the singletonRouter
|
|
522
|
+
const urlPropertyFields = [
|
|
523
|
+
'pathname',
|
|
524
|
+
'route',
|
|
525
|
+
'query',
|
|
526
|
+
'asPath',
|
|
527
|
+
'components',
|
|
528
|
+
'isFallback',
|
|
529
|
+
'basePath',
|
|
530
|
+
'locale',
|
|
531
|
+
'locales',
|
|
532
|
+
'defaultLocale',
|
|
533
|
+
'isReady',
|
|
534
|
+
'isPreview',
|
|
535
|
+
'isLocaleDomain',
|
|
536
|
+
'domainLocales',
|
|
537
|
+
];
|
|
538
|
+
const routerEvents = [
|
|
539
|
+
'routeChangeStart',
|
|
540
|
+
'beforeHistoryChange',
|
|
541
|
+
'routeChangeComplete',
|
|
542
|
+
'routeChangeError',
|
|
543
|
+
'hashChangeStart',
|
|
544
|
+
'hashChangeComplete',
|
|
545
|
+
];
|
|
546
|
+
const coreMethodFields = [
|
|
547
|
+
'push',
|
|
548
|
+
'replace',
|
|
549
|
+
'reload',
|
|
550
|
+
'back',
|
|
551
|
+
'prefetch',
|
|
552
|
+
'beforePopState',
|
|
553
|
+
];
|
|
554
|
+
// Events is a static property on the router, the router doesn't have to be initialized to use it
|
|
555
|
+
Object.defineProperty(singletonRouter, 'events', {
|
|
556
|
+
get () {
|
|
557
|
+
return _router.default.events;
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
urlPropertyFields.forEach((field)=>{
|
|
561
|
+
// Here we need to use Object.defineProperty because we need to return
|
|
562
|
+
// the property assigned to the actual router
|
|
563
|
+
// The value might get changed as we change routes and this is the
|
|
564
|
+
// proper way to access it
|
|
565
|
+
Object.defineProperty(singletonRouter, field, {
|
|
566
|
+
get () {
|
|
567
|
+
const router = getRouter();
|
|
568
|
+
return router[field];
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
coreMethodFields.forEach((field)=>{
|
|
573
|
+
singletonRouter[field] = (...args)=>{
|
|
574
|
+
const router = getRouter();
|
|
575
|
+
return router[field](...args);
|
|
576
|
+
};
|
|
577
|
+
});
|
|
578
|
+
routerEvents.forEach((event)=>{
|
|
579
|
+
singletonRouter.ready(()=>{
|
|
580
|
+
_router.default.events.on(event, (...args)=>{
|
|
581
|
+
const eventField = `on${event.charAt(0).toUpperCase()}${event.substring(1)}`;
|
|
582
|
+
const _singletonRouter = singletonRouter;
|
|
583
|
+
if (_singletonRouter[eventField]) {
|
|
584
|
+
try {
|
|
585
|
+
_singletonRouter[eventField](...args);
|
|
586
|
+
} catch (err) {
|
|
587
|
+
console.error(`Error when running the Router event: ${eventField}`);
|
|
588
|
+
console.error((0, _isError).default(err) ? `${err.message}\n${err.stack}` : err + '');
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
function getRouter() {
|
|
595
|
+
if (!singletonRouter.router) {
|
|
596
|
+
const message = 'No router instance found.\n' + 'You should only use "next/router" on the client side of your app.\n';
|
|
597
|
+
throw new Error(message);
|
|
598
|
+
}
|
|
599
|
+
return singletonRouter.router;
|
|
600
|
+
}
|
|
601
|
+
var _default = singletonRouter;
|
|
602
|
+
exports["default"] = _default;
|
|
603
|
+
function useRouter() {
|
|
604
|
+
return _react.default.useContext(_routerContext.RouterContext);
|
|
605
|
+
}
|
|
606
|
+
function createRouter(...args) {
|
|
607
|
+
singletonRouter.router = new _router.default(...args);
|
|
608
|
+
singletonRouter.readyCallbacks.forEach((cb)=>cb()
|
|
609
|
+
);
|
|
610
|
+
singletonRouter.readyCallbacks = [];
|
|
611
|
+
return singletonRouter.router;
|
|
612
|
+
}
|
|
613
|
+
function makePublicRouterInstance(router) {
|
|
614
|
+
const scopedRouter = router;
|
|
615
|
+
const instance = {
|
|
616
|
+
};
|
|
617
|
+
for (const property of urlPropertyFields){
|
|
618
|
+
if (typeof scopedRouter[property] === 'object') {
|
|
619
|
+
instance[property] = Object.assign(Array.isArray(scopedRouter[property]) ? [] : {
|
|
620
|
+
}, scopedRouter[property]) // makes sure query is not stateful
|
|
621
|
+
;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
instance[property] = scopedRouter[property];
|
|
625
|
+
}
|
|
626
|
+
// Events is a static property on the router, the router doesn't have to be initialized to use it
|
|
627
|
+
instance.events = _router.default.events;
|
|
628
|
+
coreMethodFields.forEach((field)=>{
|
|
629
|
+
instance[field] = (...args)=>{
|
|
630
|
+
return scopedRouter[field](...args);
|
|
631
|
+
};
|
|
632
|
+
});
|
|
633
|
+
return instance;
|
|
634
|
+
} //# sourceMappingURL=router.js.map
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
/***/ }),
|
|
638
|
+
|
|
639
|
+
/***/ 2030:
|
|
640
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
641
|
+
|
|
642
|
+
"use strict";
|
|
643
|
+
|
|
644
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
645
|
+
value: true
|
|
646
|
+
}));
|
|
647
|
+
exports.useIntersection = useIntersection;
|
|
648
|
+
var _react = __webpack_require__(6689);
|
|
649
|
+
var _requestIdleCallback = __webpack_require__(9071);
|
|
650
|
+
const hasIntersectionObserver = typeof IntersectionObserver !== 'undefined';
|
|
651
|
+
function useIntersection({ rootMargin , disabled }) {
|
|
652
|
+
const isDisabled = disabled || !hasIntersectionObserver;
|
|
653
|
+
const unobserve = (0, _react).useRef();
|
|
654
|
+
const [visible, setVisible] = (0, _react).useState(false);
|
|
655
|
+
const setRef = (0, _react).useCallback((el)=>{
|
|
656
|
+
if (unobserve.current) {
|
|
657
|
+
unobserve.current();
|
|
658
|
+
unobserve.current = undefined;
|
|
659
|
+
}
|
|
660
|
+
if (isDisabled || visible) return;
|
|
661
|
+
if (el && el.tagName) {
|
|
662
|
+
unobserve.current = observe(el, (isVisible)=>isVisible && setVisible(isVisible)
|
|
663
|
+
, {
|
|
664
|
+
rootMargin
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}, [
|
|
668
|
+
isDisabled,
|
|
669
|
+
rootMargin,
|
|
670
|
+
visible
|
|
671
|
+
]);
|
|
672
|
+
(0, _react).useEffect(()=>{
|
|
673
|
+
if (!hasIntersectionObserver) {
|
|
674
|
+
if (!visible) {
|
|
675
|
+
const idleCallback = (0, _requestIdleCallback).requestIdleCallback(()=>setVisible(true)
|
|
676
|
+
);
|
|
677
|
+
return ()=>(0, _requestIdleCallback).cancelIdleCallback(idleCallback)
|
|
678
|
+
;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}, [
|
|
682
|
+
visible
|
|
683
|
+
]);
|
|
684
|
+
return [
|
|
685
|
+
setRef,
|
|
686
|
+
visible
|
|
687
|
+
];
|
|
688
|
+
}
|
|
689
|
+
function observe(element, callback, options) {
|
|
690
|
+
const { id , observer , elements } = createObserver(options);
|
|
691
|
+
elements.set(element, callback);
|
|
692
|
+
observer.observe(element);
|
|
693
|
+
return function unobserve() {
|
|
694
|
+
elements.delete(element);
|
|
695
|
+
observer.unobserve(element);
|
|
696
|
+
// Destroy observer when there's nothing left to watch:
|
|
697
|
+
if (elements.size === 0) {
|
|
698
|
+
observer.disconnect();
|
|
699
|
+
observers.delete(id);
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
const observers = new Map();
|
|
704
|
+
function createObserver(options) {
|
|
705
|
+
const id = options.rootMargin || '';
|
|
706
|
+
let instance = observers.get(id);
|
|
707
|
+
if (instance) {
|
|
708
|
+
return instance;
|
|
709
|
+
}
|
|
710
|
+
const elements = new Map();
|
|
711
|
+
const observer = new IntersectionObserver((entries)=>{
|
|
712
|
+
entries.forEach((entry)=>{
|
|
713
|
+
const callback = elements.get(entry.target);
|
|
714
|
+
const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
|
|
715
|
+
if (callback && isVisible) {
|
|
716
|
+
callback(isVisible);
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
}, options);
|
|
720
|
+
observers.set(id, instance = {
|
|
721
|
+
id,
|
|
722
|
+
observer,
|
|
723
|
+
elements
|
|
724
|
+
});
|
|
725
|
+
return instance;
|
|
726
|
+
} //# sourceMappingURL=use-intersection.js.map
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
/***/ }),
|
|
730
|
+
|
|
731
|
+
/***/ 4959:
|
|
732
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
733
|
+
|
|
734
|
+
"use strict";
|
|
735
|
+
|
|
736
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
737
|
+
value: true
|
|
738
|
+
}));
|
|
739
|
+
exports["default"] = withRouter;
|
|
740
|
+
var _react = _interopRequireDefault(__webpack_require__(6689));
|
|
741
|
+
var _router = __webpack_require__(3642);
|
|
742
|
+
function _interopRequireDefault(obj) {
|
|
743
|
+
return obj && obj.__esModule ? obj : {
|
|
744
|
+
default: obj
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function withRouter(ComposedComponent) {
|
|
748
|
+
function WithRouterWrapper(props) {
|
|
749
|
+
return(/*#__PURE__*/ _react.default.createElement(ComposedComponent, Object.assign({
|
|
750
|
+
router: (0, _router).useRouter()
|
|
751
|
+
}, props)));
|
|
752
|
+
}
|
|
753
|
+
WithRouterWrapper.getInitialProps = ComposedComponent.getInitialProps;
|
|
754
|
+
WithRouterWrapper.origGetInitialProps = ComposedComponent.origGetInitialProps;
|
|
755
|
+
if (false) {}
|
|
756
|
+
return WithRouterWrapper;
|
|
757
|
+
} //# sourceMappingURL=with-router.js.map
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
/***/ }),
|
|
761
|
+
|
|
762
|
+
/***/ 9918:
|
|
763
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
764
|
+
|
|
765
|
+
"use strict";
|
|
766
|
+
|
|
767
|
+
Object.defineProperty(exports, "__esModule", ({
|
|
768
|
+
value: true
|
|
769
|
+
}));
|
|
770
|
+
exports.getDomainLocale = getDomainLocale;
|
|
771
|
+
exports.addLocale = addLocale;
|
|
772
|
+
exports.delLocale = delLocale;
|
|
773
|
+
exports.hasBasePath = hasBasePath;
|
|
774
|
+
exports.addBasePath = addBasePath;
|
|
775
|
+
exports.delBasePath = delBasePath;
|
|
776
|
+
exports.isLocalURL = isLocalURL;
|
|
777
|
+
exports.interpolateAs = interpolateAs;
|
|
778
|
+
exports.resolveHref = resolveHref;
|
|
779
|
+
exports["default"] = void 0;
|
|
780
|
+
var _normalizeTrailingSlash = __webpack_require__(583);
|
|
781
|
+
var _routeLoader = __webpack_require__(1437);
|
|
782
|
+
var _isError = _interopRequireDefault(__webpack_require__(274));
|
|
783
|
+
var _denormalizePagePath = __webpack_require__(562);
|
|
784
|
+
var _normalizeLocalePath = __webpack_require__(4014);
|
|
785
|
+
var _mitt = _interopRequireDefault(__webpack_require__(8020));
|
|
786
|
+
var _utils = __webpack_require__(9232);
|
|
787
|
+
var _isDynamic = __webpack_require__(1428);
|
|
788
|
+
var _parseRelativeUrl = __webpack_require__(1292);
|
|
789
|
+
var _querystring = __webpack_require__(979);
|
|
790
|
+
var _resolveRewrites = _interopRequireDefault(__webpack_require__(6052));
|
|
791
|
+
var _routeMatcher = __webpack_require__(4226);
|
|
792
|
+
var _routeRegex = __webpack_require__(5052);
|
|
793
|
+
var _getMiddlewareRegex = __webpack_require__(4365);
|
|
794
|
+
function _interopRequireDefault(obj) {
|
|
795
|
+
return obj && obj.__esModule ? obj : {
|
|
796
|
+
default: obj
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
let detectDomainLocale;
|
|
800
|
+
if (false) {}
|
|
801
|
+
const basePath = false || '';
|
|
802
|
+
function buildCancellationError() {
|
|
803
|
+
return Object.assign(new Error('Route Cancelled'), {
|
|
804
|
+
cancelled: true
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
function addPathPrefix(path, prefix) {
|
|
808
|
+
if (!path.startsWith('/') || !prefix) {
|
|
809
|
+
return path;
|
|
810
|
+
}
|
|
811
|
+
const pathname = pathNoQueryHash(path);
|
|
812
|
+
return (0, _normalizeTrailingSlash).normalizePathTrailingSlash(`${prefix}${pathname}`) + path.substr(pathname.length);
|
|
813
|
+
}
|
|
814
|
+
function getDomainLocale(path, locale, locales, domainLocales) {
|
|
815
|
+
if (false) {} else {
|
|
816
|
+
return false;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function addLocale(path, locale, defaultLocale) {
|
|
820
|
+
if (false) {}
|
|
821
|
+
return path;
|
|
822
|
+
}
|
|
823
|
+
function delLocale(path, locale) {
|
|
824
|
+
if (false) {}
|
|
825
|
+
return path;
|
|
826
|
+
}
|
|
827
|
+
function pathNoQueryHash(path) {
|
|
828
|
+
const queryIndex = path.indexOf('?');
|
|
829
|
+
const hashIndex = path.indexOf('#');
|
|
830
|
+
if (queryIndex > -1 || hashIndex > -1) {
|
|
831
|
+
path = path.substring(0, queryIndex > -1 ? queryIndex : hashIndex);
|
|
832
|
+
}
|
|
833
|
+
return path;
|
|
834
|
+
}
|
|
835
|
+
function hasBasePath(path) {
|
|
836
|
+
path = pathNoQueryHash(path);
|
|
837
|
+
return path === basePath || path.startsWith(basePath + '/');
|
|
838
|
+
}
|
|
839
|
+
function addBasePath(path) {
|
|
840
|
+
// we only add the basepath on relative urls
|
|
841
|
+
return addPathPrefix(path, basePath);
|
|
842
|
+
}
|
|
843
|
+
function delBasePath(path) {
|
|
844
|
+
path = path.slice(basePath.length);
|
|
845
|
+
if (!path.startsWith('/')) path = `/${path}`;
|
|
846
|
+
return path;
|
|
847
|
+
}
|
|
848
|
+
function isLocalURL(url) {
|
|
849
|
+
// prevent a hydration mismatch on href for url with anchor refs
|
|
850
|
+
if (url.startsWith('/') || url.startsWith('#') || url.startsWith('?')) return true;
|
|
851
|
+
try {
|
|
852
|
+
// absolute urls can be local if they are on the same origin
|
|
853
|
+
const locationOrigin = (0, _utils).getLocationOrigin();
|
|
854
|
+
const resolved = new URL(url, locationOrigin);
|
|
855
|
+
return resolved.origin === locationOrigin && hasBasePath(resolved.pathname);
|
|
856
|
+
} catch (_) {
|
|
857
|
+
return false;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
function interpolateAs(route, asPathname, query) {
|
|
861
|
+
let interpolatedRoute = '';
|
|
862
|
+
const dynamicRegex = (0, _routeRegex).getRouteRegex(route);
|
|
863
|
+
const dynamicGroups = dynamicRegex.groups;
|
|
864
|
+
const dynamicMatches = (asPathname !== route ? (0, _routeMatcher).getRouteMatcher(dynamicRegex)(asPathname) : '') || // TODO: should this take priority; also need to change in the router.
|
|
865
|
+
query;
|
|
866
|
+
interpolatedRoute = route;
|
|
867
|
+
const params = Object.keys(dynamicGroups);
|
|
868
|
+
if (!params.every((param)=>{
|
|
869
|
+
let value = dynamicMatches[param] || '';
|
|
870
|
+
const { repeat , optional } = dynamicGroups[param];
|
|
871
|
+
// support single-level catch-all
|
|
872
|
+
// TODO: more robust handling for user-error (passing `/`)
|
|
873
|
+
let replaced = `[${repeat ? '...' : ''}${param}]`;
|
|
874
|
+
if (optional) {
|
|
875
|
+
replaced = `${!value ? '/' : ''}[${replaced}]`;
|
|
876
|
+
}
|
|
877
|
+
if (repeat && !Array.isArray(value)) value = [
|
|
878
|
+
value
|
|
879
|
+
];
|
|
880
|
+
return (optional || param in dynamicMatches) && (interpolatedRoute = interpolatedRoute.replace(replaced, repeat ? value.map(// path delimiter escaped since they are being inserted
|
|
881
|
+
// into the URL and we expect URL encoded segments
|
|
882
|
+
// when parsing dynamic route params
|
|
883
|
+
(segment)=>encodeURIComponent(segment)
|
|
884
|
+
).join('/') : encodeURIComponent(value)) || '/');
|
|
885
|
+
})) {
|
|
886
|
+
interpolatedRoute = '' // did not satisfy all requirements
|
|
887
|
+
;
|
|
888
|
+
// n.b. We ignore this error because we handle warning for this case in
|
|
889
|
+
// development in the `<Link>` component directly.
|
|
890
|
+
}
|
|
891
|
+
return {
|
|
892
|
+
params,
|
|
893
|
+
result: interpolatedRoute
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function omitParmsFromQuery(query, params) {
|
|
897
|
+
const filteredQuery = {
|
|
898
|
+
};
|
|
899
|
+
Object.keys(query).forEach((key)=>{
|
|
900
|
+
if (!params.includes(key)) {
|
|
901
|
+
filteredQuery[key] = query[key];
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
return filteredQuery;
|
|
905
|
+
}
|
|
906
|
+
function resolveHref(router, href, resolveAs) {
|
|
907
|
+
// we use a dummy base url for relative urls
|
|
908
|
+
let base;
|
|
909
|
+
let urlAsString = typeof href === 'string' ? href : (0, _utils).formatWithValidation(href);
|
|
910
|
+
// repeated slashes and backslashes in the URL are considered
|
|
911
|
+
// invalid and will never match a Next.js page/file
|
|
912
|
+
const urlProtoMatch = urlAsString.match(/^[a-zA-Z]{1,}:\/\//);
|
|
913
|
+
const urlAsStringNoProto = urlProtoMatch ? urlAsString.substr(urlProtoMatch[0].length) : urlAsString;
|
|
914
|
+
const urlParts = urlAsStringNoProto.split('?');
|
|
915
|
+
if ((urlParts[0] || '').match(/(\/\/|\\)/)) {
|
|
916
|
+
console.error(`Invalid href passed to next/router: ${urlAsString}, repeated forward-slashes (//) or backslashes \\ are not valid in the href`);
|
|
917
|
+
const normalizedUrl = (0, _utils).normalizeRepeatedSlashes(urlAsStringNoProto);
|
|
918
|
+
urlAsString = (urlProtoMatch ? urlProtoMatch[0] : '') + normalizedUrl;
|
|
919
|
+
}
|
|
920
|
+
// Return because it cannot be routed by the Next.js router
|
|
921
|
+
if (!isLocalURL(urlAsString)) {
|
|
922
|
+
return resolveAs ? [
|
|
923
|
+
urlAsString
|
|
924
|
+
] : urlAsString;
|
|
925
|
+
}
|
|
926
|
+
try {
|
|
927
|
+
base = new URL(urlAsString.startsWith('#') ? router.asPath : router.pathname, 'http://n');
|
|
928
|
+
} catch (_) {
|
|
929
|
+
// fallback to / for invalid asPath values e.g. //
|
|
930
|
+
base = new URL('/', 'http://n');
|
|
931
|
+
}
|
|
932
|
+
try {
|
|
933
|
+
const finalUrl = new URL(urlAsString, base);
|
|
934
|
+
finalUrl.pathname = (0, _normalizeTrailingSlash).normalizePathTrailingSlash(finalUrl.pathname);
|
|
935
|
+
let interpolatedAs = '';
|
|
936
|
+
if ((0, _isDynamic).isDynamicRoute(finalUrl.pathname) && finalUrl.searchParams && resolveAs) {
|
|
937
|
+
const query = (0, _querystring).searchParamsToUrlQuery(finalUrl.searchParams);
|
|
938
|
+
const { result , params } = interpolateAs(finalUrl.pathname, finalUrl.pathname, query);
|
|
939
|
+
if (result) {
|
|
940
|
+
interpolatedAs = (0, _utils).formatWithValidation({
|
|
941
|
+
pathname: result,
|
|
942
|
+
hash: finalUrl.hash,
|
|
943
|
+
query: omitParmsFromQuery(query, params)
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
// if the origin didn't change, it means we received a relative href
|
|
948
|
+
const resolvedHref = finalUrl.origin === base.origin ? finalUrl.href.slice(finalUrl.origin.length) : finalUrl.href;
|
|
949
|
+
return resolveAs ? [
|
|
950
|
+
resolvedHref,
|
|
951
|
+
interpolatedAs || resolvedHref
|
|
952
|
+
] : resolvedHref;
|
|
953
|
+
} catch (_1) {
|
|
954
|
+
return resolveAs ? [
|
|
955
|
+
urlAsString
|
|
956
|
+
] : urlAsString;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
function stripOrigin(url) {
|
|
960
|
+
const origin = (0, _utils).getLocationOrigin();
|
|
961
|
+
return url.startsWith(origin) ? url.substring(origin.length) : url;
|
|
962
|
+
}
|
|
963
|
+
function prepareUrlAs(router, url, as) {
|
|
964
|
+
// If url and as provided as an object representation,
|
|
965
|
+
// we'll format them into the string version here.
|
|
966
|
+
let [resolvedHref, resolvedAs] = resolveHref(router, url, true);
|
|
967
|
+
const origin = (0, _utils).getLocationOrigin();
|
|
968
|
+
const hrefHadOrigin = resolvedHref.startsWith(origin);
|
|
969
|
+
const asHadOrigin = resolvedAs && resolvedAs.startsWith(origin);
|
|
970
|
+
resolvedHref = stripOrigin(resolvedHref);
|
|
971
|
+
resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
|
|
972
|
+
const preparedUrl = hrefHadOrigin ? resolvedHref : addBasePath(resolvedHref);
|
|
973
|
+
const preparedAs = as ? stripOrigin(resolveHref(router, as)) : resolvedAs || resolvedHref;
|
|
974
|
+
return {
|
|
975
|
+
url: preparedUrl,
|
|
976
|
+
as: asHadOrigin ? preparedAs : addBasePath(preparedAs)
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
function resolveDynamicRoute(pathname, pages) {
|
|
980
|
+
const cleanPathname = (0, _normalizeTrailingSlash).removePathTrailingSlash((0, _denormalizePagePath).denormalizePagePath(pathname));
|
|
981
|
+
if (cleanPathname === '/404' || cleanPathname === '/_error') {
|
|
982
|
+
return pathname;
|
|
983
|
+
}
|
|
984
|
+
// handle resolving href for dynamic routes
|
|
985
|
+
if (!pages.includes(cleanPathname)) {
|
|
986
|
+
// eslint-disable-next-line array-callback-return
|
|
987
|
+
pages.some((page)=>{
|
|
988
|
+
if ((0, _isDynamic).isDynamicRoute(page) && (0, _routeRegex).getRouteRegex(page).re.test(cleanPathname)) {
|
|
989
|
+
pathname = page;
|
|
990
|
+
return true;
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
return (0, _normalizeTrailingSlash).removePathTrailingSlash(pathname);
|
|
995
|
+
}
|
|
996
|
+
const manualScrollRestoration = (/* unused pure expression or super */ null && ( false && 0));
|
|
997
|
+
const SSG_DATA_NOT_FOUND = Symbol('SSG_DATA_NOT_FOUND');
|
|
998
|
+
function fetchRetry(url, attempts, opts) {
|
|
999
|
+
return fetch(url, {
|
|
1000
|
+
// Cookies are required to be present for Next.js' SSG "Preview Mode".
|
|
1001
|
+
// Cookies may also be required for `getServerSideProps`.
|
|
1002
|
+
//
|
|
1003
|
+
// > `fetch` won’t send cookies, unless you set the credentials init
|
|
1004
|
+
// > option.
|
|
1005
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
|
|
1006
|
+
//
|
|
1007
|
+
// > For maximum browser compatibility when it comes to sending &
|
|
1008
|
+
// > receiving cookies, always supply the `credentials: 'same-origin'`
|
|
1009
|
+
// > option instead of relying on the default.
|
|
1010
|
+
// https://github.com/github/fetch#caveats
|
|
1011
|
+
credentials: 'same-origin'
|
|
1012
|
+
}).then((res)=>{
|
|
1013
|
+
if (!res.ok) {
|
|
1014
|
+
if (attempts > 1 && res.status >= 500) {
|
|
1015
|
+
return fetchRetry(url, attempts - 1, opts);
|
|
1016
|
+
}
|
|
1017
|
+
if (res.status === 404) {
|
|
1018
|
+
return res.json().then((data)=>{
|
|
1019
|
+
if (data.notFound) {
|
|
1020
|
+
return {
|
|
1021
|
+
notFound: SSG_DATA_NOT_FOUND
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
throw new Error(`Failed to load static props`);
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
throw new Error(`Failed to load static props`);
|
|
1028
|
+
}
|
|
1029
|
+
return opts.text ? res.text() : res.json();
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
function fetchNextData(dataHref, isServerRender, text, inflightCache, persistCache) {
|
|
1033
|
+
const { href: cacheKey } = new URL(dataHref, window.location.href);
|
|
1034
|
+
if (inflightCache[cacheKey] !== undefined) {
|
|
1035
|
+
return inflightCache[cacheKey];
|
|
1036
|
+
}
|
|
1037
|
+
return inflightCache[cacheKey] = fetchRetry(dataHref, isServerRender ? 3 : 1, {
|
|
1038
|
+
text
|
|
1039
|
+
}).catch((err)=>{
|
|
1040
|
+
// We should only trigger a server-side transition if this was caused
|
|
1041
|
+
// on a client-side transition. Otherwise, we'd get into an infinite
|
|
1042
|
+
// loop.
|
|
1043
|
+
if (!isServerRender) {
|
|
1044
|
+
(0, _routeLoader).markAssetError(err);
|
|
1045
|
+
}
|
|
1046
|
+
throw err;
|
|
1047
|
+
}).then((data)=>{
|
|
1048
|
+
if (!persistCache || "production" !== 'production') {
|
|
1049
|
+
delete inflightCache[cacheKey];
|
|
1050
|
+
}
|
|
1051
|
+
return data;
|
|
1052
|
+
}).catch((err)=>{
|
|
1053
|
+
delete inflightCache[cacheKey];
|
|
1054
|
+
throw err;
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
class Router {
|
|
1058
|
+
constructor(pathname1, query1, as1, { initialProps , pageLoader , App , wrapApp , Component , err: err2 , subscription , isFallback , locale , locales , defaultLocale , domainLocales , isPreview }){
|
|
1059
|
+
// Static Data Cache
|
|
1060
|
+
this.sdc = {
|
|
1061
|
+
};
|
|
1062
|
+
// In-flight Server Data Requests, for deduping
|
|
1063
|
+
this.sdr = {
|
|
1064
|
+
};
|
|
1065
|
+
// In-flight middleware preflight requests
|
|
1066
|
+
this.sde = {
|
|
1067
|
+
};
|
|
1068
|
+
this._idx = 0;
|
|
1069
|
+
this.onPopState = (e)=>{
|
|
1070
|
+
const state = e.state;
|
|
1071
|
+
if (!state) {
|
|
1072
|
+
// We get state as undefined for two reasons.
|
|
1073
|
+
// 1. With older safari (< 8) and older chrome (< 34)
|
|
1074
|
+
// 2. When the URL changed with #
|
|
1075
|
+
//
|
|
1076
|
+
// In the both cases, we don't need to proceed and change the route.
|
|
1077
|
+
// (as it's already changed)
|
|
1078
|
+
// But we can simply replace the state with the new changes.
|
|
1079
|
+
// Actually, for (1) we don't need to nothing. But it's hard to detect that event.
|
|
1080
|
+
// So, doing the following for (1) does no harm.
|
|
1081
|
+
const { pathname , query } = this;
|
|
1082
|
+
this.changeState('replaceState', (0, _utils).formatWithValidation({
|
|
1083
|
+
pathname: addBasePath(pathname),
|
|
1084
|
+
query
|
|
1085
|
+
}), (0, _utils).getURL());
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
if (!state.__N) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
let forcedScroll;
|
|
1092
|
+
const { url , as , options , idx } = state;
|
|
1093
|
+
if (false) {}
|
|
1094
|
+
this._idx = idx;
|
|
1095
|
+
const { pathname } = (0, _parseRelativeUrl).parseRelativeUrl(url);
|
|
1096
|
+
// Make sure we don't re-render on initial load,
|
|
1097
|
+
// can be caused by navigating back from an external site
|
|
1098
|
+
if (this.isSsr && as === this.asPath && pathname === this.pathname) {
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
// If the downstream application returns falsy, return.
|
|
1102
|
+
// They will then be responsible for handling the event.
|
|
1103
|
+
if (this._bps && !this._bps(state)) {
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
this.change('replaceState', url, as, Object.assign({
|
|
1107
|
+
}, options, {
|
|
1108
|
+
shallow: options.shallow && this._shallow,
|
|
1109
|
+
locale: options.locale || this.defaultLocale
|
|
1110
|
+
}), forcedScroll);
|
|
1111
|
+
};
|
|
1112
|
+
// represents the current component key
|
|
1113
|
+
this.route = (0, _normalizeTrailingSlash).removePathTrailingSlash(pathname1);
|
|
1114
|
+
// set up the component cache (by route keys)
|
|
1115
|
+
this.components = {
|
|
1116
|
+
};
|
|
1117
|
+
// We should not keep the cache, if there's an error
|
|
1118
|
+
// Otherwise, this cause issues when when going back and
|
|
1119
|
+
// come again to the errored page.
|
|
1120
|
+
if (pathname1 !== '/_error') {
|
|
1121
|
+
var ref;
|
|
1122
|
+
this.components[this.route] = {
|
|
1123
|
+
Component,
|
|
1124
|
+
initial: true,
|
|
1125
|
+
props: initialProps,
|
|
1126
|
+
err: err2,
|
|
1127
|
+
__N_SSG: initialProps && initialProps.__N_SSG,
|
|
1128
|
+
__N_SSP: initialProps && initialProps.__N_SSP,
|
|
1129
|
+
__N_RSC: !!((ref = Component) === null || ref === void 0 ? void 0 : ref.__next_rsc__)
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
this.components['/_app'] = {
|
|
1133
|
+
Component: App,
|
|
1134
|
+
styleSheets: []
|
|
1135
|
+
};
|
|
1136
|
+
// Backwards compat for Router.router.events
|
|
1137
|
+
// TODO: Should be remove the following major version as it was never documented
|
|
1138
|
+
this.events = Router.events;
|
|
1139
|
+
this.pageLoader = pageLoader;
|
|
1140
|
+
this.pathname = pathname1;
|
|
1141
|
+
this.query = query1;
|
|
1142
|
+
// if auto prerendered and dynamic route wait to update asPath
|
|
1143
|
+
// until after mount to prevent hydration mismatch
|
|
1144
|
+
const autoExportDynamic = (0, _isDynamic).isDynamicRoute(pathname1) && self.__NEXT_DATA__.autoExport;
|
|
1145
|
+
this.asPath = autoExportDynamic ? pathname1 : as1;
|
|
1146
|
+
this.basePath = basePath;
|
|
1147
|
+
this.sub = subscription;
|
|
1148
|
+
this.clc = null;
|
|
1149
|
+
this._wrapApp = wrapApp;
|
|
1150
|
+
// make sure to ignore extra popState in safari on navigating
|
|
1151
|
+
// back from external site
|
|
1152
|
+
this.isSsr = true;
|
|
1153
|
+
this.isFallback = isFallback;
|
|
1154
|
+
this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp || !autoExportDynamic && !self.location.search && !false);
|
|
1155
|
+
this.isPreview = !!isPreview;
|
|
1156
|
+
this.isLocaleDomain = false;
|
|
1157
|
+
if (false) {}
|
|
1158
|
+
if (false) {}
|
|
1159
|
+
}
|
|
1160
|
+
reload() {
|
|
1161
|
+
window.location.reload();
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Go back in history
|
|
1165
|
+
*/ back() {
|
|
1166
|
+
window.history.back();
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Performs a `pushState` with arguments
|
|
1170
|
+
* @param url of the route
|
|
1171
|
+
* @param as masks `url` for the browser
|
|
1172
|
+
* @param options object you can define `shallow` and other options
|
|
1173
|
+
*/ push(url, as, options = {
|
|
1174
|
+
}) {
|
|
1175
|
+
if (false) {}
|
|
1176
|
+
({ url , as } = prepareUrlAs(this, url, as));
|
|
1177
|
+
return this.change('pushState', url, as, options);
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Performs a `replaceState` with arguments
|
|
1181
|
+
* @param url of the route
|
|
1182
|
+
* @param as masks `url` for the browser
|
|
1183
|
+
* @param options object you can define `shallow` and other options
|
|
1184
|
+
*/ replace(url1, as2, options1 = {
|
|
1185
|
+
}) {
|
|
1186
|
+
({ url: url1 , as: as2 } = prepareUrlAs(this, url1, as2));
|
|
1187
|
+
return this.change('replaceState', url1, as2, options1);
|
|
1188
|
+
}
|
|
1189
|
+
async change(method, url2, as3, options2, forcedScroll) {
|
|
1190
|
+
if (!isLocalURL(url2)) {
|
|
1191
|
+
window.location.href = url2;
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
const shouldResolveHref = options2._h || options2._shouldResolveHref || pathNoQueryHash(url2) === pathNoQueryHash(as3);
|
|
1195
|
+
// for static pages with query params in the URL we delay
|
|
1196
|
+
// marking the router ready until after the query is updated
|
|
1197
|
+
if (options2._h) {
|
|
1198
|
+
this.isReady = true;
|
|
1199
|
+
}
|
|
1200
|
+
const prevLocale = this.locale;
|
|
1201
|
+
if (false) { var ref; }
|
|
1202
|
+
if (!options2._h) {
|
|
1203
|
+
this.isSsr = false;
|
|
1204
|
+
}
|
|
1205
|
+
// marking route changes as a navigation start entry
|
|
1206
|
+
if (_utils.ST) {
|
|
1207
|
+
performance.mark('routeChange');
|
|
1208
|
+
}
|
|
1209
|
+
const { shallow =false } = options2;
|
|
1210
|
+
const routeProps = {
|
|
1211
|
+
shallow
|
|
1212
|
+
};
|
|
1213
|
+
if (this._inFlightRoute) {
|
|
1214
|
+
this.abortComponentLoad(this._inFlightRoute, routeProps);
|
|
1215
|
+
}
|
|
1216
|
+
as3 = addBasePath(addLocale(hasBasePath(as3) ? delBasePath(as3) : as3, options2.locale, this.defaultLocale));
|
|
1217
|
+
const cleanedAs = delLocale(hasBasePath(as3) ? delBasePath(as3) : as3, this.locale);
|
|
1218
|
+
this._inFlightRoute = as3;
|
|
1219
|
+
let localeChange = prevLocale !== this.locale;
|
|
1220
|
+
// If the url change is only related to a hash change
|
|
1221
|
+
// We should not proceed. We should only change the state.
|
|
1222
|
+
// WARNING: `_h` is an internal option for handing Next.js client-side
|
|
1223
|
+
// hydration. Your app should _never_ use this property. It may change at
|
|
1224
|
+
// any time without notice.
|
|
1225
|
+
if (!options2._h && this.onlyAHashChange(cleanedAs) && !localeChange) {
|
|
1226
|
+
this.asPath = cleanedAs;
|
|
1227
|
+
Router.events.emit('hashChangeStart', as3, routeProps);
|
|
1228
|
+
// TODO: do we need the resolved href when only a hash change?
|
|
1229
|
+
this.changeState(method, url2, as3, options2);
|
|
1230
|
+
this.scrollToHash(cleanedAs);
|
|
1231
|
+
this.notify(this.components[this.route], null);
|
|
1232
|
+
Router.events.emit('hashChangeComplete', as3, routeProps);
|
|
1233
|
+
return true;
|
|
1234
|
+
}
|
|
1235
|
+
let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url2);
|
|
1236
|
+
let { pathname , query } = parsed;
|
|
1237
|
+
// The build manifest needs to be loaded before auto-static dynamic pages
|
|
1238
|
+
// get their query parameters to allow ensuring they can be parsed properly
|
|
1239
|
+
// when rewritten to
|
|
1240
|
+
let pages, rewrites;
|
|
1241
|
+
try {
|
|
1242
|
+
[pages, { __rewrites: rewrites }] = await Promise.all([
|
|
1243
|
+
this.pageLoader.getPageList(),
|
|
1244
|
+
(0, _routeLoader).getClientBuildManifest(),
|
|
1245
|
+
this.pageLoader.getMiddlewareList(),
|
|
1246
|
+
]);
|
|
1247
|
+
} catch (err) {
|
|
1248
|
+
// If we fail to resolve the page list or client-build manifest, we must
|
|
1249
|
+
// do a server-side transition:
|
|
1250
|
+
window.location.href = as3;
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
// If asked to change the current URL we should reload the current page
|
|
1254
|
+
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
|
|
1255
|
+
// We also need to set the method = replaceState always
|
|
1256
|
+
// as this should not go into the history (That's how browsers work)
|
|
1257
|
+
// We should compare the new asPath to the current asPath, not the url
|
|
1258
|
+
if (!this.urlIsNew(cleanedAs) && !localeChange) {
|
|
1259
|
+
method = 'replaceState';
|
|
1260
|
+
}
|
|
1261
|
+
// we need to resolve the as value using rewrites for dynamic SSG
|
|
1262
|
+
// pages to allow building the data URL correctly
|
|
1263
|
+
let resolvedAs = as3;
|
|
1264
|
+
// url and as should always be prefixed with basePath by this
|
|
1265
|
+
// point by either next/link or router.push/replace so strip the
|
|
1266
|
+
// basePath from the pathname to match the pages dir 1-to-1
|
|
1267
|
+
pathname = pathname ? (0, _normalizeTrailingSlash).removePathTrailingSlash(delBasePath(pathname)) : pathname;
|
|
1268
|
+
if (shouldResolveHref && pathname !== '/_error') {
|
|
1269
|
+
options2._shouldResolveHref = true;
|
|
1270
|
+
if (false) {} else {
|
|
1271
|
+
parsed.pathname = resolveDynamicRoute(pathname, pages);
|
|
1272
|
+
if (parsed.pathname !== pathname) {
|
|
1273
|
+
pathname = parsed.pathname;
|
|
1274
|
+
parsed.pathname = addBasePath(pathname);
|
|
1275
|
+
url2 = (0, _utils).formatWithValidation(parsed);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
if (!isLocalURL(as3)) {
|
|
1280
|
+
if (false) {}
|
|
1281
|
+
window.location.href = as3;
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
resolvedAs = delLocale(delBasePath(resolvedAs), this.locale);
|
|
1285
|
+
/**
|
|
1286
|
+
* If the route update was triggered for client-side hydration then
|
|
1287
|
+
* do not check the preflight request. Otherwise when rendering
|
|
1288
|
+
* a page with refresh it might get into an infinite loop.
|
|
1289
|
+
*/ if (options2._h !== 1) {
|
|
1290
|
+
const effect = await this._preflightRequest({
|
|
1291
|
+
as: as3,
|
|
1292
|
+
cache: "production" === 'production',
|
|
1293
|
+
pages,
|
|
1294
|
+
pathname,
|
|
1295
|
+
query
|
|
1296
|
+
});
|
|
1297
|
+
if (effect.type === 'rewrite') {
|
|
1298
|
+
query = {
|
|
1299
|
+
...query,
|
|
1300
|
+
...effect.parsedAs.query
|
|
1301
|
+
};
|
|
1302
|
+
resolvedAs = effect.asPath;
|
|
1303
|
+
pathname = effect.resolvedHref;
|
|
1304
|
+
parsed.pathname = effect.resolvedHref;
|
|
1305
|
+
url2 = (0, _utils).formatWithValidation(parsed);
|
|
1306
|
+
} else if (effect.type === 'redirect' && effect.newAs) {
|
|
1307
|
+
return this.change(method, effect.newUrl, effect.newAs, options2);
|
|
1308
|
+
} else if (effect.type === 'redirect' && effect.destination) {
|
|
1309
|
+
window.location.href = effect.destination;
|
|
1310
|
+
return new Promise(()=>{
|
|
1311
|
+
});
|
|
1312
|
+
} else if (effect.type === 'refresh') {
|
|
1313
|
+
window.location.href = as3;
|
|
1314
|
+
return new Promise(()=>{
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
const route = (0, _normalizeTrailingSlash).removePathTrailingSlash(pathname);
|
|
1319
|
+
if ((0, _isDynamic).isDynamicRoute(route)) {
|
|
1320
|
+
const parsedAs = (0, _parseRelativeUrl).parseRelativeUrl(resolvedAs);
|
|
1321
|
+
const asPathname = parsedAs.pathname;
|
|
1322
|
+
const routeRegex = (0, _routeRegex).getRouteRegex(route);
|
|
1323
|
+
const routeMatch = (0, _routeMatcher).getRouteMatcher(routeRegex)(asPathname);
|
|
1324
|
+
const shouldInterpolate = route === asPathname;
|
|
1325
|
+
const interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : {
|
|
1326
|
+
};
|
|
1327
|
+
if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
|
|
1328
|
+
const missingParams = Object.keys(routeRegex.groups).filter((param)=>!query[param]
|
|
1329
|
+
);
|
|
1330
|
+
if (missingParams.length > 0) {
|
|
1331
|
+
if (false) {}
|
|
1332
|
+
throw new Error((shouldInterpolate ? `The provided \`href\` (${url2}) 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'}`);
|
|
1333
|
+
}
|
|
1334
|
+
} else if (shouldInterpolate) {
|
|
1335
|
+
as3 = (0, _utils).formatWithValidation(Object.assign({
|
|
1336
|
+
}, parsedAs, {
|
|
1337
|
+
pathname: interpolatedAs.result,
|
|
1338
|
+
query: omitParmsFromQuery(query, interpolatedAs.params)
|
|
1339
|
+
}));
|
|
1340
|
+
} else {
|
|
1341
|
+
// Merge params into `query`, overwriting any specified in search
|
|
1342
|
+
Object.assign(query, routeMatch);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
Router.events.emit('routeChangeStart', as3, routeProps);
|
|
1346
|
+
try {
|
|
1347
|
+
var ref, ref1;
|
|
1348
|
+
let routeInfo = await this.getRouteInfo(route, pathname, query, as3, resolvedAs, routeProps);
|
|
1349
|
+
let { error , props , __N_SSG , __N_SSP } = routeInfo;
|
|
1350
|
+
// handle redirect on client-transition
|
|
1351
|
+
if ((__N_SSG || __N_SSP) && props) {
|
|
1352
|
+
if (props.pageProps && props.pageProps.__N_REDIRECT) {
|
|
1353
|
+
const destination = props.pageProps.__N_REDIRECT;
|
|
1354
|
+
// check if destination is internal (resolves to a page) and attempt
|
|
1355
|
+
// client-navigation if it is falling back to hard navigation if
|
|
1356
|
+
// it's not
|
|
1357
|
+
if (destination.startsWith('/') && props.pageProps.__N_REDIRECT_BASE_PATH !== false) {
|
|
1358
|
+
const parsedHref = (0, _parseRelativeUrl).parseRelativeUrl(destination);
|
|
1359
|
+
parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
|
|
1360
|
+
const { url: newUrl , as: newAs } = prepareUrlAs(this, destination, destination);
|
|
1361
|
+
return this.change(method, newUrl, newAs, options2);
|
|
1362
|
+
}
|
|
1363
|
+
window.location.href = destination;
|
|
1364
|
+
return new Promise(()=>{
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
this.isPreview = !!props.__N_PREVIEW;
|
|
1368
|
+
// handle SSG data 404
|
|
1369
|
+
if (props.notFound === SSG_DATA_NOT_FOUND) {
|
|
1370
|
+
let notFoundRoute;
|
|
1371
|
+
try {
|
|
1372
|
+
await this.fetchComponent('/404');
|
|
1373
|
+
notFoundRoute = '/404';
|
|
1374
|
+
} catch (_) {
|
|
1375
|
+
notFoundRoute = '/_error';
|
|
1376
|
+
}
|
|
1377
|
+
routeInfo = await this.getRouteInfo(notFoundRoute, notFoundRoute, query, as3, resolvedAs, {
|
|
1378
|
+
shallow: false
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
Router.events.emit('beforeHistoryChange', as3, routeProps);
|
|
1383
|
+
this.changeState(method, url2, as3, options2);
|
|
1384
|
+
if (options2._h && pathname === '/_error' && ((ref = self.__NEXT_DATA__.props) === null || ref === void 0 ? void 0 : (ref1 = ref.pageProps) === null || ref1 === void 0 ? void 0 : ref1.statusCode) === 500 && (props === null || props === void 0 ? void 0 : props.pageProps)) {
|
|
1385
|
+
// ensure statusCode is still correct for static 500 page
|
|
1386
|
+
// when updating query information
|
|
1387
|
+
props.pageProps.statusCode = 500;
|
|
1388
|
+
}
|
|
1389
|
+
// shallow routing is only allowed for same page URL changes.
|
|
1390
|
+
const isValidShallowRoute = options2.shallow && this.route === route;
|
|
1391
|
+
var _scroll;
|
|
1392
|
+
const shouldScroll = (_scroll = options2.scroll) !== null && _scroll !== void 0 ? _scroll : !isValidShallowRoute;
|
|
1393
|
+
const resetScroll = shouldScroll ? {
|
|
1394
|
+
x: 0,
|
|
1395
|
+
y: 0
|
|
1396
|
+
} : null;
|
|
1397
|
+
await this.set(route, pathname, query, cleanedAs, routeInfo, forcedScroll !== null && forcedScroll !== void 0 ? forcedScroll : resetScroll).catch((e)=>{
|
|
1398
|
+
if (e.cancelled) error = error || e;
|
|
1399
|
+
else throw e;
|
|
1400
|
+
});
|
|
1401
|
+
if (error) {
|
|
1402
|
+
Router.events.emit('routeChangeError', error, cleanedAs, routeProps);
|
|
1403
|
+
throw error;
|
|
1404
|
+
}
|
|
1405
|
+
if (false) {}
|
|
1406
|
+
Router.events.emit('routeChangeComplete', as3, routeProps);
|
|
1407
|
+
return true;
|
|
1408
|
+
} catch (err1) {
|
|
1409
|
+
if ((0, _isError).default(err1) && err1.cancelled) {
|
|
1410
|
+
return false;
|
|
1411
|
+
}
|
|
1412
|
+
throw err1;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
changeState(method1, url3, as4, options3 = {
|
|
1416
|
+
}) {
|
|
1417
|
+
if (false) {}
|
|
1418
|
+
if (method1 !== 'pushState' || (0, _utils).getURL() !== as4) {
|
|
1419
|
+
this._shallow = options3.shallow;
|
|
1420
|
+
window.history[method1]({
|
|
1421
|
+
url: url3,
|
|
1422
|
+
as: as4,
|
|
1423
|
+
options: options3,
|
|
1424
|
+
__N: true,
|
|
1425
|
+
idx: this._idx = method1 !== 'pushState' ? this._idx : this._idx + 1
|
|
1426
|
+
}, // Passing the empty string here should be safe against future changes to the method.
|
|
1427
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
|
|
1428
|
+
'', as4);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
async handleRouteInfoError(err1, pathname, query, as5, routeProps, loadErrorFail) {
|
|
1432
|
+
if (err1.cancelled) {
|
|
1433
|
+
// bubble up cancellation errors
|
|
1434
|
+
throw err1;
|
|
1435
|
+
}
|
|
1436
|
+
if ((0, _routeLoader).isAssetError(err1) || loadErrorFail) {
|
|
1437
|
+
Router.events.emit('routeChangeError', err1, as5, routeProps);
|
|
1438
|
+
// If we can't load the page it could be one of following reasons
|
|
1439
|
+
// 1. Page doesn't exists
|
|
1440
|
+
// 2. Page does exist in a different zone
|
|
1441
|
+
// 3. Internal error while loading the page
|
|
1442
|
+
// So, doing a hard reload is the proper way to deal with this.
|
|
1443
|
+
window.location.href = as5;
|
|
1444
|
+
// Changing the URL doesn't block executing the current code path.
|
|
1445
|
+
// So let's throw a cancellation error stop the routing logic.
|
|
1446
|
+
throw buildCancellationError();
|
|
1447
|
+
}
|
|
1448
|
+
try {
|
|
1449
|
+
let Component;
|
|
1450
|
+
let styleSheets;
|
|
1451
|
+
let props;
|
|
1452
|
+
if (typeof Component === 'undefined' || typeof styleSheets === 'undefined') {
|
|
1453
|
+
({ page: Component , styleSheets } = await this.fetchComponent('/_error'));
|
|
1454
|
+
}
|
|
1455
|
+
const routeInfo = {
|
|
1456
|
+
props,
|
|
1457
|
+
Component,
|
|
1458
|
+
styleSheets,
|
|
1459
|
+
err: err1,
|
|
1460
|
+
error: err1
|
|
1461
|
+
};
|
|
1462
|
+
if (!routeInfo.props) {
|
|
1463
|
+
try {
|
|
1464
|
+
routeInfo.props = await this.getInitialProps(Component, {
|
|
1465
|
+
err: err1,
|
|
1466
|
+
pathname,
|
|
1467
|
+
query
|
|
1468
|
+
});
|
|
1469
|
+
} catch (gipErr) {
|
|
1470
|
+
console.error('Error in error page `getInitialProps`: ', gipErr);
|
|
1471
|
+
routeInfo.props = {
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
return routeInfo;
|
|
1476
|
+
} catch (routeInfoErr) {
|
|
1477
|
+
return this.handleRouteInfoError((0, _isError).default(routeInfoErr) ? routeInfoErr : new Error(routeInfoErr + ''), pathname, query, as5, routeProps, true);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
async getRouteInfo(route, pathname2, query2, as6, resolvedAs, routeProps1) {
|
|
1481
|
+
try {
|
|
1482
|
+
const existingRouteInfo = this.components[route];
|
|
1483
|
+
if (routeProps1.shallow && existingRouteInfo && this.route === route) {
|
|
1484
|
+
return existingRouteInfo;
|
|
1485
|
+
}
|
|
1486
|
+
let cachedRouteInfo = undefined;
|
|
1487
|
+
// can only use non-initial route info
|
|
1488
|
+
// cannot reuse route info in development since it can change after HMR
|
|
1489
|
+
if ( true && existingRouteInfo && !('initial' in existingRouteInfo)) {
|
|
1490
|
+
cachedRouteInfo = existingRouteInfo;
|
|
1491
|
+
}
|
|
1492
|
+
const routeInfo = cachedRouteInfo || await this.fetchComponent(route).then((res)=>({
|
|
1493
|
+
Component: res.page,
|
|
1494
|
+
styleSheets: res.styleSheets,
|
|
1495
|
+
__N_SSG: res.mod.__N_SSG,
|
|
1496
|
+
__N_SSP: res.mod.__N_SSP,
|
|
1497
|
+
__N_RSC: !!res.page.__next_rsc__
|
|
1498
|
+
})
|
|
1499
|
+
);
|
|
1500
|
+
const { Component , __N_SSG , __N_SSP , __N_RSC } = routeInfo;
|
|
1501
|
+
if (false) {}
|
|
1502
|
+
let dataHref;
|
|
1503
|
+
if (__N_SSG || __N_SSP || __N_RSC) {
|
|
1504
|
+
dataHref = this.pageLoader.getDataHref({
|
|
1505
|
+
href: (0, _utils).formatWithValidation({
|
|
1506
|
+
pathname: pathname2,
|
|
1507
|
+
query: query2
|
|
1508
|
+
}),
|
|
1509
|
+
asPath: resolvedAs,
|
|
1510
|
+
ssg: __N_SSG,
|
|
1511
|
+
rsc: __N_RSC,
|
|
1512
|
+
locale: this.locale
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
const props = await this._getData(()=>__N_SSG || __N_SSP ? fetchNextData(dataHref, this.isSsr, false, __N_SSG ? this.sdc : this.sdr, !!__N_SSG && !this.isPreview) : this.getInitialProps(Component, {
|
|
1516
|
+
pathname: pathname2,
|
|
1517
|
+
query: query2,
|
|
1518
|
+
asPath: as6,
|
|
1519
|
+
locale: this.locale,
|
|
1520
|
+
locales: this.locales,
|
|
1521
|
+
defaultLocale: this.defaultLocale
|
|
1522
|
+
})
|
|
1523
|
+
);
|
|
1524
|
+
if (__N_RSC) {
|
|
1525
|
+
const { fresh , data } = await this._getData(()=>this._getFlightData(dataHref)
|
|
1526
|
+
);
|
|
1527
|
+
props.pageProps = Object.assign(props.pageProps, {
|
|
1528
|
+
__flight_serialized__: data,
|
|
1529
|
+
__flight_fresh__: fresh
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
routeInfo.props = props;
|
|
1533
|
+
this.components[route] = routeInfo;
|
|
1534
|
+
return routeInfo;
|
|
1535
|
+
} catch (err) {
|
|
1536
|
+
return this.handleRouteInfoError((0, _isError).default(err) ? err : new Error(err + ''), pathname2, query2, as6, routeProps1);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
set(route1, pathname3, query3, as7, data1, resetScroll) {
|
|
1540
|
+
this.isFallback = false;
|
|
1541
|
+
this.route = route1;
|
|
1542
|
+
this.pathname = pathname3;
|
|
1543
|
+
this.query = query3;
|
|
1544
|
+
this.asPath = as7;
|
|
1545
|
+
return this.notify(data1, resetScroll);
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Callback to execute before replacing router state
|
|
1549
|
+
* @param cb callback to be executed
|
|
1550
|
+
*/ beforePopState(cb) {
|
|
1551
|
+
this._bps = cb;
|
|
1552
|
+
}
|
|
1553
|
+
onlyAHashChange(as8) {
|
|
1554
|
+
if (!this.asPath) return false;
|
|
1555
|
+
const [oldUrlNoHash, oldHash] = this.asPath.split('#');
|
|
1556
|
+
const [newUrlNoHash, newHash] = as8.split('#');
|
|
1557
|
+
// Makes sure we scroll to the provided hash if the url/hash are the same
|
|
1558
|
+
if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
|
|
1559
|
+
return true;
|
|
1560
|
+
}
|
|
1561
|
+
// If the urls are change, there's more than a hash change
|
|
1562
|
+
if (oldUrlNoHash !== newUrlNoHash) {
|
|
1563
|
+
return false;
|
|
1564
|
+
}
|
|
1565
|
+
// If the hash has changed, then it's a hash only change.
|
|
1566
|
+
// This check is necessary to handle both the enter and
|
|
1567
|
+
// leave hash === '' cases. The identity case falls through
|
|
1568
|
+
// and is treated as a next reload.
|
|
1569
|
+
return oldHash !== newHash;
|
|
1570
|
+
}
|
|
1571
|
+
scrollToHash(as9) {
|
|
1572
|
+
const [, hash] = as9.split('#');
|
|
1573
|
+
// Scroll to top if the hash is just `#` with no value or `#top`
|
|
1574
|
+
// To mirror browsers
|
|
1575
|
+
if (hash === '' || hash === 'top') {
|
|
1576
|
+
window.scrollTo(0, 0);
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
// First we check if the element by id is found
|
|
1580
|
+
const idEl = document.getElementById(hash);
|
|
1581
|
+
if (idEl) {
|
|
1582
|
+
idEl.scrollIntoView();
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
// If there's no element with the id, we check the `name` property
|
|
1586
|
+
// To mirror browsers
|
|
1587
|
+
const nameEl = document.getElementsByName(hash)[0];
|
|
1588
|
+
if (nameEl) {
|
|
1589
|
+
nameEl.scrollIntoView();
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
urlIsNew(asPath) {
|
|
1593
|
+
return this.asPath !== asPath;
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Prefetch page code, you may wait for the data during page rendering.
|
|
1597
|
+
* This feature only works in production!
|
|
1598
|
+
* @param url the href of prefetched page
|
|
1599
|
+
* @param asPath the as path of the prefetched page
|
|
1600
|
+
*/ async prefetch(url4, asPath1 = url4, options4 = {
|
|
1601
|
+
}) {
|
|
1602
|
+
let parsed = (0, _parseRelativeUrl).parseRelativeUrl(url4);
|
|
1603
|
+
let { pathname , query } = parsed;
|
|
1604
|
+
if (false) {}
|
|
1605
|
+
const pages = await this.pageLoader.getPageList();
|
|
1606
|
+
let resolvedAs = asPath1;
|
|
1607
|
+
if (false) {} else {
|
|
1608
|
+
parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
|
|
1609
|
+
if (parsed.pathname !== pathname) {
|
|
1610
|
+
pathname = parsed.pathname;
|
|
1611
|
+
parsed.pathname = pathname;
|
|
1612
|
+
url4 = (0, _utils).formatWithValidation(parsed);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
// Prefetch is not supported in development mode because it would trigger on-demand-entries
|
|
1616
|
+
if (false) {}
|
|
1617
|
+
const effects = await this._preflightRequest({
|
|
1618
|
+
as: addBasePath(asPath1),
|
|
1619
|
+
cache: true,
|
|
1620
|
+
pages,
|
|
1621
|
+
pathname,
|
|
1622
|
+
query
|
|
1623
|
+
});
|
|
1624
|
+
if (effects.type === 'rewrite') {
|
|
1625
|
+
parsed.pathname = effects.resolvedHref;
|
|
1626
|
+
pathname = effects.resolvedHref;
|
|
1627
|
+
query = {
|
|
1628
|
+
...query,
|
|
1629
|
+
...effects.parsedAs.query
|
|
1630
|
+
};
|
|
1631
|
+
resolvedAs = effects.asPath;
|
|
1632
|
+
url4 = (0, _utils).formatWithValidation(parsed);
|
|
1633
|
+
}
|
|
1634
|
+
const route = (0, _normalizeTrailingSlash).removePathTrailingSlash(pathname);
|
|
1635
|
+
await Promise.all([
|
|
1636
|
+
this.pageLoader._isSsg(route).then((isSsg)=>{
|
|
1637
|
+
return isSsg ? fetchNextData(this.pageLoader.getDataHref({
|
|
1638
|
+
href: url4,
|
|
1639
|
+
asPath: resolvedAs,
|
|
1640
|
+
ssg: true,
|
|
1641
|
+
locale: typeof options4.locale !== 'undefined' ? options4.locale : this.locale
|
|
1642
|
+
}), false, false, this.sdc, true) : false;
|
|
1643
|
+
}),
|
|
1644
|
+
this.pageLoader[options4.priority ? 'loadPage' : 'prefetch'](route),
|
|
1645
|
+
]);
|
|
1646
|
+
}
|
|
1647
|
+
async fetchComponent(route2) {
|
|
1648
|
+
let cancelled = false;
|
|
1649
|
+
const cancel = this.clc = ()=>{
|
|
1650
|
+
cancelled = true;
|
|
1651
|
+
};
|
|
1652
|
+
const handleCancelled = ()=>{
|
|
1653
|
+
if (cancelled) {
|
|
1654
|
+
const error = new Error(`Abort fetching component for route: "${route2}"`);
|
|
1655
|
+
error.cancelled = true;
|
|
1656
|
+
throw error;
|
|
1657
|
+
}
|
|
1658
|
+
if (cancel === this.clc) {
|
|
1659
|
+
this.clc = null;
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
try {
|
|
1663
|
+
const componentResult = await this.pageLoader.loadPage(route2);
|
|
1664
|
+
handleCancelled();
|
|
1665
|
+
return componentResult;
|
|
1666
|
+
} catch (err) {
|
|
1667
|
+
handleCancelled();
|
|
1668
|
+
throw err;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
_getData(fn) {
|
|
1672
|
+
let cancelled = false;
|
|
1673
|
+
const cancel = ()=>{
|
|
1674
|
+
cancelled = true;
|
|
1675
|
+
};
|
|
1676
|
+
this.clc = cancel;
|
|
1677
|
+
return fn().then((data)=>{
|
|
1678
|
+
if (cancel === this.clc) {
|
|
1679
|
+
this.clc = null;
|
|
1680
|
+
}
|
|
1681
|
+
if (cancelled) {
|
|
1682
|
+
const err = new Error('Loading initial props cancelled');
|
|
1683
|
+
err.cancelled = true;
|
|
1684
|
+
throw err;
|
|
1685
|
+
}
|
|
1686
|
+
return data;
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
_getFlightData(dataHref) {
|
|
1690
|
+
const { href: cacheKey } = new URL(dataHref, window.location.href);
|
|
1691
|
+
if (!this.isPreview && this.sdc[cacheKey]) {
|
|
1692
|
+
return Promise.resolve({
|
|
1693
|
+
fresh: false,
|
|
1694
|
+
data: this.sdc[cacheKey]
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
return fetchNextData(dataHref, true, true, this.sdc, false).then((serialized)=>{
|
|
1698
|
+
this.sdc[cacheKey] = serialized;
|
|
1699
|
+
return {
|
|
1700
|
+
fresh: true,
|
|
1701
|
+
data: serialized
|
|
1702
|
+
};
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
async _preflightRequest(options5) {
|
|
1706
|
+
var ref;
|
|
1707
|
+
const cleanedAs = delLocale(hasBasePath(options5.as) ? delBasePath(options5.as) : options5.as, this.locale);
|
|
1708
|
+
const fns = await this.pageLoader.getMiddlewareList();
|
|
1709
|
+
const requiresPreflight = fns.some(([middleware, isSSR])=>{
|
|
1710
|
+
return (0, _routeMatcher).getRouteMatcher((0, _getMiddlewareRegex).getMiddlewareRegex(middleware, !isSSR))(cleanedAs);
|
|
1711
|
+
});
|
|
1712
|
+
if (!requiresPreflight) {
|
|
1713
|
+
return {
|
|
1714
|
+
type: 'next'
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
const preflight = await this._getPreflightData({
|
|
1718
|
+
preflightHref: options5.as,
|
|
1719
|
+
shouldCache: options5.cache
|
|
1720
|
+
});
|
|
1721
|
+
if ((ref = preflight.rewrite) === null || ref === void 0 ? void 0 : ref.startsWith('/')) {
|
|
1722
|
+
const parsed = (0, _parseRelativeUrl).parseRelativeUrl((0, _normalizeLocalePath).normalizeLocalePath(hasBasePath(preflight.rewrite) ? delBasePath(preflight.rewrite) : preflight.rewrite, this.locales).pathname);
|
|
1723
|
+
const fsPathname = (0, _normalizeTrailingSlash).removePathTrailingSlash(parsed.pathname);
|
|
1724
|
+
let matchedPage;
|
|
1725
|
+
let resolvedHref;
|
|
1726
|
+
if (options5.pages.includes(fsPathname)) {
|
|
1727
|
+
matchedPage = true;
|
|
1728
|
+
resolvedHref = fsPathname;
|
|
1729
|
+
} else {
|
|
1730
|
+
resolvedHref = resolveDynamicRoute(fsPathname, options5.pages);
|
|
1731
|
+
if (resolvedHref !== parsed.pathname && options5.pages.includes(resolvedHref)) {
|
|
1732
|
+
matchedPage = true;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
return {
|
|
1736
|
+
type: 'rewrite',
|
|
1737
|
+
asPath: parsed.pathname,
|
|
1738
|
+
parsedAs: parsed,
|
|
1739
|
+
matchedPage,
|
|
1740
|
+
resolvedHref
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
if (preflight.redirect) {
|
|
1744
|
+
if (preflight.redirect.startsWith('/')) {
|
|
1745
|
+
const cleanRedirect = (0, _normalizeTrailingSlash).removePathTrailingSlash((0, _normalizeLocalePath).normalizeLocalePath(hasBasePath(preflight.redirect) ? delBasePath(preflight.redirect) : preflight.redirect, this.locales).pathname);
|
|
1746
|
+
const { url: newUrl , as: newAs } = prepareUrlAs(this, cleanRedirect, cleanRedirect);
|
|
1747
|
+
return {
|
|
1748
|
+
type: 'redirect',
|
|
1749
|
+
newUrl,
|
|
1750
|
+
newAs
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
return {
|
|
1754
|
+
type: 'redirect',
|
|
1755
|
+
destination: preflight.redirect
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
// For SSR requests, they will be handled like normal pages.
|
|
1759
|
+
if (preflight.refresh && !preflight.ssr) {
|
|
1760
|
+
return {
|
|
1761
|
+
type: 'refresh'
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
return {
|
|
1765
|
+
type: 'next'
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
_getPreflightData(params) {
|
|
1769
|
+
const { preflightHref , shouldCache =false } = params;
|
|
1770
|
+
const { href: cacheKey } = new URL(preflightHref, window.location.href);
|
|
1771
|
+
if ( true && !this.isPreview && shouldCache && this.sde[cacheKey]) {
|
|
1772
|
+
return Promise.resolve(this.sde[cacheKey]);
|
|
1773
|
+
}
|
|
1774
|
+
return fetch(preflightHref, {
|
|
1775
|
+
method: 'HEAD',
|
|
1776
|
+
credentials: 'same-origin',
|
|
1777
|
+
headers: {
|
|
1778
|
+
'x-middleware-preflight': '1'
|
|
1779
|
+
}
|
|
1780
|
+
}).then((res)=>{
|
|
1781
|
+
if (!res.ok) {
|
|
1782
|
+
throw new Error(`Failed to preflight request`);
|
|
1783
|
+
}
|
|
1784
|
+
return {
|
|
1785
|
+
redirect: res.headers.get('Location'),
|
|
1786
|
+
refresh: res.headers.has('x-middleware-refresh'),
|
|
1787
|
+
rewrite: res.headers.get('x-middleware-rewrite'),
|
|
1788
|
+
ssr: !!res.headers.get('x-middleware-ssr')
|
|
1789
|
+
};
|
|
1790
|
+
}).then((data)=>{
|
|
1791
|
+
if (shouldCache) {
|
|
1792
|
+
this.sde[cacheKey] = data;
|
|
1793
|
+
}
|
|
1794
|
+
return data;
|
|
1795
|
+
}).catch((err)=>{
|
|
1796
|
+
delete this.sde[cacheKey];
|
|
1797
|
+
throw err;
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
getInitialProps(Component1, ctx) {
|
|
1801
|
+
const { Component: App } = this.components['/_app'];
|
|
1802
|
+
const AppTree = this._wrapApp(App);
|
|
1803
|
+
ctx.AppTree = AppTree;
|
|
1804
|
+
return (0, _utils).loadGetInitialProps(App, {
|
|
1805
|
+
AppTree,
|
|
1806
|
+
Component: Component1,
|
|
1807
|
+
router: this,
|
|
1808
|
+
ctx
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
abortComponentLoad(as10, routeProps2) {
|
|
1812
|
+
if (this.clc) {
|
|
1813
|
+
Router.events.emit('routeChangeError', buildCancellationError(), as10, routeProps2);
|
|
1814
|
+
this.clc();
|
|
1815
|
+
this.clc = null;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
notify(data, resetScroll1) {
|
|
1819
|
+
return this.sub(data, this.components['/_app'].Component, resetScroll1);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
Router.events = (0, _mitt).default();
|
|
1823
|
+
exports["default"] = Router; //# sourceMappingURL=router.js.map
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
/***/ }),
|
|
1827
|
+
|
|
1828
|
+
/***/ 9097:
|
|
1829
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1830
|
+
|
|
1831
|
+
module.exports = __webpack_require__(162)
|
|
1832
|
+
|
|
1833
|
+
|
|
1834
|
+
/***/ })
|
|
1835
|
+
|
|
1836
|
+
};
|
|
1837
|
+
;
|