lkd-web-kit 0.7.15 → 0.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/dist/components/EmptyState/index.cjs +5 -5
  2. package/dist/components/Icon.cjs +2 -2
  3. package/dist/components/InfinityLoadMoreButton/index.cjs +2 -2
  4. package/dist/components/InfinitySelect/index.cjs +9 -10
  5. package/dist/components/InfinitySelect/index.js +0 -1
  6. package/dist/components/MyCheckboxGroup/index.cjs +2 -2
  7. package/dist/components/MyDateInput/index.cjs +3 -3
  8. package/dist/components/MyDatePickerInput/CalendarIcon.cjs +7 -7
  9. package/dist/components/MyDatePickerInput/index.cjs +3 -3
  10. package/dist/components/MyDateTimePicker/index.cjs +3 -3
  11. package/dist/components/MyMonthPickerInput/index.cjs +3 -3
  12. package/dist/components/MyMultiSelect/index.cjs +2 -2
  13. package/dist/components/MyNotifications/index.cjs +2 -2
  14. package/dist/components/MyNumberInput/index.cjs +2 -2
  15. package/dist/components/MyRadioGroup/index.cjs +2 -2
  16. package/dist/components/MySelect/index.cjs +2 -2
  17. package/dist/components/MyTextInput/index.cjs +2 -2
  18. package/dist/components/MyTextarea/index.cjs +2 -2
  19. package/dist/components/MyTimeInput/index.cjs +2 -2
  20. package/dist/components/NavItems.cjs +4 -4
  21. package/dist/contexts/NavigationHistoryContext/hook.cjs +2 -2
  22. package/dist/contexts/NavigationHistoryContext/hook.js +2 -2
  23. package/dist/contexts/NavigationHistoryContext/index.cjs +3 -3
  24. package/dist/contexts/PageDataContext/index.cjs +2 -2
  25. package/dist/form/Form.cjs +2 -2
  26. package/dist/form/FormSubmitButton.cjs +2 -2
  27. package/dist/form/base/FormCheckbox.cjs +2 -2
  28. package/dist/form/base/FormCheckboxGroup.cjs +2 -2
  29. package/dist/form/base/FormDateInput.cjs +2 -2
  30. package/dist/form/base/FormDatePickerInput.cjs +2 -2
  31. package/dist/form/base/FormDateTimePicker.cjs +2 -2
  32. package/dist/form/base/FormMonthPickerInput.cjs +2 -2
  33. package/dist/form/base/FormMultiSelect.cjs +2 -2
  34. package/dist/form/base/FormNumberInput.cjs +2 -2
  35. package/dist/form/base/FormRadioGroup.cjs +2 -2
  36. package/dist/form/base/FormSelect.cjs +2 -2
  37. package/dist/form/base/FormSelectInfinity.cjs +2 -2
  38. package/dist/form/base/FormTextInput.cjs +2 -2
  39. package/dist/form/base/FormTextarea.cjs +2 -2
  40. package/dist/form/base/FormTimeInput.cjs +2 -2
  41. package/dist/hocs/withController.cjs +3 -3
  42. package/dist/hocs/withModalManager.cjs +2 -2
  43. package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.cjs +2 -2
  44. package/package.json +1 -1
  45. package/dist/_virtual/___vite-browser-external.cjs +0 -12
  46. package/dist/_virtual/___vite-browser-external.js +0 -6
  47. package/dist/_virtual/__vite-browser-external.cjs +0 -5
  48. package/dist/_virtual/__vite-browser-external.js +0 -3
  49. package/dist/_virtual/_commonjsHelpers.cjs +0 -34
  50. package/dist/_virtual/_commonjsHelpers.js +0 -30
  51. package/dist/_virtual/_interop_require_default.cjs +0 -7
  52. package/dist/_virtual/_interop_require_default.js +0 -3
  53. package/dist/_virtual/_interop_require_wildcard.cjs +0 -7
  54. package/dist/_virtual/_interop_require_wildcard.js +0 -3
  55. package/dist/_virtual/add-base-path.cjs +0 -7
  56. package/dist/_virtual/add-base-path.js +0 -3
  57. package/dist/_virtual/add-locale.cjs +0 -7
  58. package/dist/_virtual/add-locale.js +0 -3
  59. package/dist/_virtual/add-locale2.cjs +0 -7
  60. package/dist/_virtual/add-locale2.js +0 -3
  61. package/dist/_virtual/add-path-prefix.cjs +0 -7
  62. package/dist/_virtual/add-path-prefix.js +0 -3
  63. package/dist/_virtual/add-path-suffix.cjs +0 -7
  64. package/dist/_virtual/add-path-suffix.js +0 -3
  65. package/dist/_virtual/app-paths.cjs +0 -7
  66. package/dist/_virtual/app-paths.js +0 -3
  67. package/dist/_virtual/bloom-filter.cjs +0 -7
  68. package/dist/_virtual/bloom-filter.js +0 -3
  69. package/dist/_virtual/compare-states.cjs +0 -7
  70. package/dist/_virtual/compare-states.js +0 -3
  71. package/dist/_virtual/constants.cjs +0 -7
  72. package/dist/_virtual/constants.js +0 -3
  73. package/dist/_virtual/denormalize-page-path.cjs +0 -7
  74. package/dist/_virtual/denormalize-page-path.js +0 -3
  75. package/dist/_virtual/deployment-id.cjs +0 -7
  76. package/dist/_virtual/deployment-id.js +0 -3
  77. package/dist/_virtual/detect-domain-locale.cjs +0 -7
  78. package/dist/_virtual/detect-domain-locale.js +0 -3
  79. package/dist/_virtual/detect-domain-locale2.cjs +0 -7
  80. package/dist/_virtual/detect-domain-locale2.js +0 -3
  81. package/dist/_virtual/disable-smooth-scroll.cjs +0 -7
  82. package/dist/_virtual/disable-smooth-scroll.js +0 -3
  83. package/dist/_virtual/encode-uri-path.cjs +0 -7
  84. package/dist/_virtual/encode-uri-path.js +0 -3
  85. package/dist/_virtual/ensure-leading-slash.cjs +0 -7
  86. package/dist/_virtual/ensure-leading-slash.js +0 -3
  87. package/dist/_virtual/escape-regexp.cjs +0 -7
  88. package/dist/_virtual/escape-regexp.js +0 -3
  89. package/dist/_virtual/format-next-pathname-info.cjs +0 -7
  90. package/dist/_virtual/format-next-pathname-info.js +0 -3
  91. package/dist/_virtual/format-url.cjs +0 -7
  92. package/dist/_virtual/format-url.js +0 -3
  93. package/dist/_virtual/get-asset-path-from-route.cjs +0 -7
  94. package/dist/_virtual/get-asset-path-from-route.js +0 -3
  95. package/dist/_virtual/get-cookie-parser.cjs +0 -7
  96. package/dist/_virtual/get-cookie-parser.js +0 -3
  97. package/dist/_virtual/get-dynamic-param.cjs +0 -7
  98. package/dist/_virtual/get-dynamic-param.js +0 -3
  99. package/dist/_virtual/get-next-pathname-info.cjs +0 -7
  100. package/dist/_virtual/get-next-pathname-info.js +0 -3
  101. package/dist/_virtual/get-segment-param.cjs +0 -7
  102. package/dist/_virtual/get-segment-param.js +0 -3
  103. package/dist/_virtual/has-base-path.cjs +0 -7
  104. package/dist/_virtual/has-base-path.js +0 -3
  105. package/dist/_virtual/head-manager-context.shared-runtime.cjs +0 -7
  106. package/dist/_virtual/head-manager-context.shared-runtime.js +0 -3
  107. package/dist/_virtual/html-bots.cjs +0 -7
  108. package/dist/_virtual/html-bots.js +0 -3
  109. package/dist/_virtual/index.cjs +0 -7
  110. package/dist/_virtual/index.js +0 -3
  111. package/dist/_virtual/index2.cjs +0 -7
  112. package/dist/_virtual/index2.js +0 -3
  113. package/dist/_virtual/index3.cjs +0 -7
  114. package/dist/_virtual/index3.js +0 -3
  115. package/dist/_virtual/index4.cjs +0 -7
  116. package/dist/_virtual/index4.js +0 -3
  117. package/dist/_virtual/index5.cjs +0 -7
  118. package/dist/_virtual/index5.js +0 -3
  119. package/dist/_virtual/interception-routes.cjs +0 -7
  120. package/dist/_virtual/interception-routes.js +0 -3
  121. package/dist/_virtual/interpolate-as.cjs +0 -7
  122. package/dist/_virtual/interpolate-as.js +0 -3
  123. package/dist/_virtual/invariant-error.cjs +0 -7
  124. package/dist/_virtual/invariant-error.js +0 -3
  125. package/dist/_virtual/is-api-route.cjs +0 -7
  126. package/dist/_virtual/is-api-route.js +0 -3
  127. package/dist/_virtual/is-bot.cjs +0 -7
  128. package/dist/_virtual/is-bot.js +0 -3
  129. package/dist/_virtual/is-dynamic.cjs +0 -7
  130. package/dist/_virtual/is-dynamic.js +0 -3
  131. package/dist/_virtual/is-error.cjs +0 -7
  132. package/dist/_virtual/is-error.js +0 -3
  133. package/dist/_virtual/is-local-url.cjs +0 -7
  134. package/dist/_virtual/is-local-url.js +0 -3
  135. package/dist/_virtual/is-plain-object.cjs +0 -7
  136. package/dist/_virtual/is-plain-object.js +0 -3
  137. package/dist/_virtual/mitt.cjs +0 -7
  138. package/dist/_virtual/mitt.js +0 -3
  139. package/dist/_virtual/normalize-locale-path.cjs +0 -7
  140. package/dist/_virtual/normalize-locale-path.js +0 -3
  141. package/dist/_virtual/normalize-path-sep.cjs +0 -7
  142. package/dist/_virtual/normalize-path-sep.js +0 -3
  143. package/dist/_virtual/normalize-trailing-slash.cjs +0 -7
  144. package/dist/_virtual/normalize-trailing-slash.js +0 -3
  145. package/dist/_virtual/omit.cjs +0 -7
  146. package/dist/_virtual/omit.js +0 -3
  147. package/dist/_virtual/parse-loader-tree.cjs +0 -7
  148. package/dist/_virtual/parse-loader-tree.js +0 -3
  149. package/dist/_virtual/parse-path.cjs +0 -7
  150. package/dist/_virtual/parse-path.js +0 -3
  151. package/dist/_virtual/parse-relative-url.cjs +0 -7
  152. package/dist/_virtual/parse-relative-url.js +0 -3
  153. package/dist/_virtual/parse-url.cjs +0 -7
  154. package/dist/_virtual/parse-url.js +0 -3
  155. package/dist/_virtual/path-has-prefix.cjs +0 -7
  156. package/dist/_virtual/path-has-prefix.js +0 -3
  157. package/dist/_virtual/path-match.cjs +0 -7
  158. package/dist/_virtual/path-match.js +0 -3
  159. package/dist/_virtual/prepare-destination.cjs +0 -7
  160. package/dist/_virtual/prepare-destination.js +0 -3
  161. package/dist/_virtual/querystring.cjs +0 -7
  162. package/dist/_virtual/querystring.js +0 -3
  163. package/dist/_virtual/react-is.development.cjs +0 -7
  164. package/dist/_virtual/react-is.development.js +0 -3
  165. package/dist/_virtual/react-is.production.cjs +0 -7
  166. package/dist/_virtual/react-is.production.js +0 -3
  167. package/dist/_virtual/remove-base-path.cjs +0 -7
  168. package/dist/_virtual/remove-base-path.js +0 -3
  169. package/dist/_virtual/remove-locale.cjs +0 -7
  170. package/dist/_virtual/remove-locale.js +0 -3
  171. package/dist/_virtual/remove-path-prefix.cjs +0 -7
  172. package/dist/_virtual/remove-path-prefix.js +0 -3
  173. package/dist/_virtual/remove-trailing-slash.cjs +0 -7
  174. package/dist/_virtual/remove-trailing-slash.js +0 -3
  175. package/dist/_virtual/request-idle-callback.cjs +0 -7
  176. package/dist/_virtual/request-idle-callback.js +0 -3
  177. package/dist/_virtual/resolve-href.cjs +0 -7
  178. package/dist/_virtual/resolve-href.js +0 -3
  179. package/dist/_virtual/resolve-rewrites.cjs +0 -7
  180. package/dist/_virtual/resolve-rewrites.js +0 -3
  181. package/dist/_virtual/route-loader.cjs +0 -7
  182. package/dist/_virtual/route-loader.js +0 -3
  183. package/dist/_virtual/route-match-utils.cjs +0 -7
  184. package/dist/_virtual/route-match-utils.js +0 -3
  185. package/dist/_virtual/route-matcher.cjs +0 -7
  186. package/dist/_virtual/route-matcher.js +0 -3
  187. package/dist/_virtual/route-pattern-normalizer.cjs +0 -7
  188. package/dist/_virtual/route-pattern-normalizer.js +0 -3
  189. package/dist/_virtual/route-regex.cjs +0 -7
  190. package/dist/_virtual/route-regex.js +0 -3
  191. package/dist/_virtual/router-context.shared-runtime.cjs +0 -7
  192. package/dist/_virtual/router-context.shared-runtime.js +0 -3
  193. package/dist/_virtual/router.cjs +0 -9
  194. package/dist/_virtual/router.js +0 -5
  195. package/dist/_virtual/router2.cjs +0 -7
  196. package/dist/_virtual/router2.js +0 -3
  197. package/dist/_virtual/router3.cjs +0 -7
  198. package/dist/_virtual/router3.js +0 -3
  199. package/dist/_virtual/script.cjs +0 -7
  200. package/dist/_virtual/script.js +0 -3
  201. package/dist/_virtual/segment.cjs +0 -7
  202. package/dist/_virtual/segment.js +0 -3
  203. package/dist/_virtual/set-attributes-from-props.cjs +0 -7
  204. package/dist/_virtual/set-attributes-from-props.js +0 -3
  205. package/dist/_virtual/sorted-routes.cjs +0 -7
  206. package/dist/_virtual/sorted-routes.js +0 -3
  207. package/dist/_virtual/trusted-types.cjs +0 -7
  208. package/dist/_virtual/trusted-types.js +0 -3
  209. package/dist/_virtual/utils.cjs +0 -7
  210. package/dist/_virtual/utils.js +0 -3
  211. package/dist/_virtual/warn-once.cjs +0 -7
  212. package/dist/_virtual/warn-once.js +0 -3
  213. package/dist/_virtual/with-router.cjs +0 -7
  214. package/dist/_virtual/with-router.js +0 -3
  215. package/dist/node_modules/@swc/helpers/cjs/_interop_require_default.cjs +0 -20
  216. package/dist/node_modules/@swc/helpers/cjs/_interop_require_default.js +0 -16
  217. package/dist/node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs +0 -52
  218. package/dist/node_modules/@swc/helpers/cjs/_interop_require_wildcard.js +0 -48
  219. package/dist/node_modules/next/dist/build/deployment-id.cjs +0 -34
  220. package/dist/node_modules/next/dist/build/deployment-id.js +0 -30
  221. package/dist/node_modules/next/dist/client/add-base-path.cjs +0 -42
  222. package/dist/node_modules/next/dist/client/add-base-path.js +0 -38
  223. package/dist/node_modules/next/dist/client/add-locale.cjs +0 -43
  224. package/dist/node_modules/next/dist/client/add-locale.js +0 -39
  225. package/dist/node_modules/next/dist/client/detect-domain-locale.cjs +0 -40
  226. package/dist/node_modules/next/dist/client/detect-domain-locale.js +0 -36
  227. package/dist/node_modules/next/dist/client/has-base-path.cjs +0 -40
  228. package/dist/node_modules/next/dist/client/has-base-path.js +0 -36
  229. package/dist/node_modules/next/dist/client/normalize-trailing-slash.cjs +0 -54
  230. package/dist/node_modules/next/dist/client/normalize-trailing-slash.js +0 -50
  231. package/dist/node_modules/next/dist/client/remove-base-path.cjs +0 -49
  232. package/dist/node_modules/next/dist/client/remove-base-path.js +0 -45
  233. package/dist/node_modules/next/dist/client/remove-locale.cjs +0 -45
  234. package/dist/node_modules/next/dist/client/remove-locale.js +0 -41
  235. package/dist/node_modules/next/dist/client/request-idle-callback.cjs +0 -56
  236. package/dist/node_modules/next/dist/client/request-idle-callback.js +0 -52
  237. package/dist/node_modules/next/dist/client/resolve-href.cjs +0 -132
  238. package/dist/node_modules/next/dist/client/resolve-href.js +0 -128
  239. package/dist/node_modules/next/dist/client/route-loader.cjs +0 -363
  240. package/dist/node_modules/next/dist/client/route-loader.js +0 -359
  241. package/dist/node_modules/next/dist/client/router.cjs +0 -201
  242. package/dist/node_modules/next/dist/client/router.js +0 -197
  243. package/dist/node_modules/next/dist/client/script.cjs +0 -366
  244. package/dist/node_modules/next/dist/client/script.js +0 -362
  245. package/dist/node_modules/next/dist/client/set-attributes-from-props.cjs +0 -81
  246. package/dist/node_modules/next/dist/client/set-attributes-from-props.js +0 -77
  247. package/dist/node_modules/next/dist/client/trusted-types.cjs +0 -56
  248. package/dist/node_modules/next/dist/client/trusted-types.js +0 -52
  249. package/dist/node_modules/next/dist/client/with-router.cjs +0 -54
  250. package/dist/node_modules/next/dist/client/with-router.js +0 -50
  251. package/dist/node_modules/next/dist/compiled/cookie/index.cjs +0 -22
  252. package/dist/node_modules/next/dist/compiled/cookie/index.js +0 -18
  253. package/dist/node_modules/next/dist/compiled/gzip-size/index.cjs +0 -17
  254. package/dist/node_modules/next/dist/compiled/gzip-size/index.js +0 -13
  255. package/dist/node_modules/next/dist/compiled/path-to-regexp/index.cjs +0 -16
  256. package/dist/node_modules/next/dist/compiled/path-to-regexp/index.js +0 -12
  257. package/dist/node_modules/next/dist/compiled/react-is/cjs/react-is.development.cjs +0 -147
  258. package/dist/node_modules/next/dist/compiled/react-is/cjs/react-is.development.js +0 -143
  259. package/dist/node_modules/next/dist/compiled/react-is/cjs/react-is.production.cjs +0 -144
  260. package/dist/node_modules/next/dist/compiled/react-is/cjs/react-is.production.js +0 -140
  261. package/dist/node_modules/next/dist/compiled/react-is/index.cjs +0 -23
  262. package/dist/node_modules/next/dist/compiled/react-is/index.js +0 -19
  263. package/dist/node_modules/next/dist/lib/constants.cjs +0 -365
  264. package/dist/node_modules/next/dist/lib/constants.js +0 -361
  265. package/dist/node_modules/next/dist/lib/is-api-route.cjs +0 -31
  266. package/dist/node_modules/next/dist/lib/is-api-route.js +0 -27
  267. package/dist/node_modules/next/dist/lib/is-error.cjs +0 -91
  268. package/dist/node_modules/next/dist/lib/is-error.js +0 -87
  269. package/dist/node_modules/next/dist/lib/route-pattern-normalizer.cjs +0 -115
  270. package/dist/node_modules/next/dist/lib/route-pattern-normalizer.js +0 -111
  271. package/dist/node_modules/next/dist/server/api-utils/get-cookie-parser.cjs +0 -39
  272. package/dist/node_modules/next/dist/server/api-utils/get-cookie-parser.js +0 -35
  273. package/dist/node_modules/next/dist/shared/lib/bloom-filter.cjs +0 -101
  274. package/dist/node_modules/next/dist/shared/lib/bloom-filter.js +0 -97
  275. package/dist/node_modules/next/dist/shared/lib/encode-uri-path.cjs +0 -31
  276. package/dist/node_modules/next/dist/shared/lib/encode-uri-path.js +0 -27
  277. package/dist/node_modules/next/dist/shared/lib/escape-regexp.cjs +0 -37
  278. package/dist/node_modules/next/dist/shared/lib/escape-regexp.js +0 -33
  279. package/dist/node_modules/next/dist/shared/lib/head-manager-context.shared-runtime.cjs +0 -36
  280. package/dist/node_modules/next/dist/shared/lib/head-manager-context.shared-runtime.js +0 -32
  281. package/dist/node_modules/next/dist/shared/lib/i18n/detect-domain-locale.cjs +0 -41
  282. package/dist/node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js +0 -37
  283. package/dist/node_modules/next/dist/shared/lib/i18n/normalize-locale-path.cjs +0 -70
  284. package/dist/node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js +0 -66
  285. package/dist/node_modules/next/dist/shared/lib/invariant-error.cjs +0 -34
  286. package/dist/node_modules/next/dist/shared/lib/invariant-error.js +0 -30
  287. package/dist/node_modules/next/dist/shared/lib/is-plain-object.cjs +0 -54
  288. package/dist/node_modules/next/dist/shared/lib/is-plain-object.js +0 -50
  289. package/dist/node_modules/next/dist/shared/lib/mitt.cjs +0 -58
  290. package/dist/node_modules/next/dist/shared/lib/mitt.js +0 -54
  291. package/dist/node_modules/next/dist/shared/lib/page-path/denormalize-page-path.cjs +0 -36
  292. package/dist/node_modules/next/dist/shared/lib/page-path/denormalize-page-path.js +0 -32
  293. package/dist/node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.cjs +0 -36
  294. package/dist/node_modules/next/dist/shared/lib/page-path/ensure-leading-slash.js +0 -32
  295. package/dist/node_modules/next/dist/shared/lib/page-path/normalize-path-sep.cjs +0 -37
  296. package/dist/node_modules/next/dist/shared/lib/page-path/normalize-path-sep.js +0 -33
  297. package/dist/node_modules/next/dist/shared/lib/router/router.cjs +0 -1814
  298. package/dist/node_modules/next/dist/shared/lib/router/router.js +0 -1810
  299. package/dist/node_modules/next/dist/shared/lib/router/utils/add-locale.cjs +0 -46
  300. package/dist/node_modules/next/dist/shared/lib/router/utils/add-locale.js +0 -42
  301. package/dist/node_modules/next/dist/shared/lib/router/utils/add-path-prefix.cjs +0 -37
  302. package/dist/node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js +0 -33
  303. package/dist/node_modules/next/dist/shared/lib/router/utils/add-path-suffix.cjs +0 -37
  304. package/dist/node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js +0 -33
  305. package/dist/node_modules/next/dist/shared/lib/router/utils/app-paths.cjs +0 -65
  306. package/dist/node_modules/next/dist/shared/lib/router/utils/app-paths.js +0 -61
  307. package/dist/node_modules/next/dist/shared/lib/router/utils/compare-states.cjs +0 -50
  308. package/dist/node_modules/next/dist/shared/lib/router/utils/compare-states.js +0 -46
  309. package/dist/node_modules/next/dist/shared/lib/router/utils/disable-smooth-scroll.cjs +0 -60
  310. package/dist/node_modules/next/dist/shared/lib/router/utils/disable-smooth-scroll.js +0 -56
  311. package/dist/node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.cjs +0 -47
  312. package/dist/node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js +0 -43
  313. package/dist/node_modules/next/dist/shared/lib/router/utils/format-url.cjs +0 -103
  314. package/dist/node_modules/next/dist/shared/lib/router/utils/format-url.js +0 -99
  315. package/dist/node_modules/next/dist/shared/lib/router/utils/get-asset-path-from-route.cjs +0 -32
  316. package/dist/node_modules/next/dist/shared/lib/router/utils/get-asset-path-from-route.js +0 -28
  317. package/dist/node_modules/next/dist/shared/lib/router/utils/get-dynamic-param.cjs +0 -208
  318. package/dist/node_modules/next/dist/shared/lib/router/utils/get-dynamic-param.js +0 -204
  319. package/dist/node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.cjs +0 -71
  320. package/dist/node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js +0 -67
  321. package/dist/node_modules/next/dist/shared/lib/router/utils/get-segment-param.cjs +0 -94
  322. package/dist/node_modules/next/dist/shared/lib/router/utils/get-segment-param.js +0 -90
  323. package/dist/node_modules/next/dist/shared/lib/router/utils/html-bots.cjs +0 -29
  324. package/dist/node_modules/next/dist/shared/lib/router/utils/html-bots.js +0 -25
  325. package/dist/node_modules/next/dist/shared/lib/router/utils/index.cjs +0 -43
  326. package/dist/node_modules/next/dist/shared/lib/router/utils/index.js +0 -39
  327. package/dist/node_modules/next/dist/shared/lib/router/utils/interception-routes.cjs +0 -119
  328. package/dist/node_modules/next/dist/shared/lib/router/utils/interception-routes.js +0 -115
  329. package/dist/node_modules/next/dist/shared/lib/router/utils/interpolate-as.cjs +0 -71
  330. package/dist/node_modules/next/dist/shared/lib/router/utils/interpolate-as.js +0 -67
  331. package/dist/node_modules/next/dist/shared/lib/router/utils/is-bot.cjs +0 -68
  332. package/dist/node_modules/next/dist/shared/lib/router/utils/is-bot.js +0 -64
  333. package/dist/node_modules/next/dist/shared/lib/router/utils/is-dynamic.cjs +0 -43
  334. package/dist/node_modules/next/dist/shared/lib/router/utils/is-dynamic.js +0 -39
  335. package/dist/node_modules/next/dist/shared/lib/router/utils/is-local-url.cjs +0 -44
  336. package/dist/node_modules/next/dist/shared/lib/router/utils/is-local-url.js +0 -40
  337. package/dist/node_modules/next/dist/shared/lib/router/utils/omit.cjs +0 -37
  338. package/dist/node_modules/next/dist/shared/lib/router/utils/omit.js +0 -33
  339. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-loader-tree.cjs +0 -46
  340. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-loader-tree.js +0 -42
  341. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-path.cjs +0 -51
  342. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-path.js +0 -47
  343. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-relative-url.cjs +0 -54
  344. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js +0 -50
  345. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-url.cjs +0 -50
  346. package/dist/node_modules/next/dist/shared/lib/router/utils/parse-url.js +0 -46
  347. package/dist/node_modules/next/dist/shared/lib/router/utils/path-has-prefix.cjs +0 -37
  348. package/dist/node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js +0 -33
  349. package/dist/node_modules/next/dist/shared/lib/router/utils/path-match.cjs +0 -66
  350. package/dist/node_modules/next/dist/shared/lib/router/utils/path-match.js +0 -62
  351. package/dist/node_modules/next/dist/shared/lib/router/utils/prepare-destination.cjs +0 -303
  352. package/dist/node_modules/next/dist/shared/lib/router/utils/prepare-destination.js +0 -299
  353. package/dist/node_modules/next/dist/shared/lib/router/utils/querystring.cjs +0 -90
  354. package/dist/node_modules/next/dist/shared/lib/router/utils/querystring.js +0 -86
  355. package/dist/node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.cjs +0 -56
  356. package/dist/node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.js +0 -52
  357. package/dist/node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.cjs +0 -39
  358. package/dist/node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js +0 -35
  359. package/dist/node_modules/next/dist/shared/lib/router/utils/resolve-rewrites.cjs +0 -140
  360. package/dist/node_modules/next/dist/shared/lib/router/utils/resolve-rewrites.js +0 -136
  361. package/dist/node_modules/next/dist/shared/lib/router/utils/route-match-utils.cjs +0 -127
  362. package/dist/node_modules/next/dist/shared/lib/router/utils/route-match-utils.js +0 -123
  363. package/dist/node_modules/next/dist/shared/lib/router/utils/route-matcher.cjs +0 -63
  364. package/dist/node_modules/next/dist/shared/lib/router/utils/route-matcher.js +0 -59
  365. package/dist/node_modules/next/dist/shared/lib/router/utils/route-regex.cjs +0 -272
  366. package/dist/node_modules/next/dist/shared/lib/router/utils/route-regex.js +0 -268
  367. package/dist/node_modules/next/dist/shared/lib/router/utils/sorted-routes.cjs +0 -256
  368. package/dist/node_modules/next/dist/shared/lib/router/utils/sorted-routes.js +0 -252
  369. package/dist/node_modules/next/dist/shared/lib/router-context.shared-runtime.cjs +0 -36
  370. package/dist/node_modules/next/dist/shared/lib/router-context.shared-runtime.js +0 -32
  371. package/dist/node_modules/next/dist/shared/lib/segment.cjs +0 -103
  372. package/dist/node_modules/next/dist/shared/lib/segment.js +0 -99
  373. package/dist/node_modules/next/dist/shared/lib/utils/warn-once.cjs +0 -38
  374. package/dist/node_modules/next/dist/shared/lib/utils/warn-once.js +0 -34
  375. package/dist/node_modules/next/dist/shared/lib/utils.cjs +0 -204
  376. package/dist/node_modules/next/dist/shared/lib/utils.js +0 -200
  377. package/dist/node_modules/next/router.cjs +0 -17
  378. package/dist/node_modules/next/router.js +0 -13
@@ -1,1814 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const router = require('../../../../../../_virtual/router3.cjs');
6
- const _interop_require_default = require('../../../../../@swc/helpers/cjs/_interop_require_default.cjs');
7
- const _interop_require_wildcard = require('../../../../../@swc/helpers/cjs/_interop_require_wildcard.cjs');
8
- const removeTrailingSlash = require('./utils/remove-trailing-slash.cjs');
9
- const routeLoader = require('../../../client/route-loader.cjs');
10
- const script = require('../../../client/script.cjs');
11
- const isError = require('../../../lib/is-error.cjs');
12
- const denormalizePagePath = require('../page-path/denormalize-page-path.cjs');
13
- const normalizeLocalePath = require('../i18n/normalize-locale-path.cjs');
14
- const mitt = require('../mitt.cjs');
15
- const utils = require('../utils.cjs');
16
- const isDynamic = require('./utils/is-dynamic.cjs');
17
- const parseRelativeUrl = require('./utils/parse-relative-url.cjs');
18
- const routeMatcher = require('./utils/route-matcher.cjs');
19
- const routeRegex = require('./utils/route-regex.cjs');
20
- const formatUrl = require('./utils/format-url.cjs');
21
- const detectDomainLocale = require('../../../client/detect-domain-locale.cjs');
22
- const parsePath = require('./utils/parse-path.cjs');
23
- const addLocale = require('../../../client/add-locale.cjs');
24
- const removeLocale = require('../../../client/remove-locale.cjs');
25
- const removeBasePath = require('../../../client/remove-base-path.cjs');
26
- const addBasePath = require('../../../client/add-base-path.cjs');
27
- const hasBasePath = require('../../../client/has-base-path.cjs');
28
- const resolveHref = require('../../../client/resolve-href.cjs');
29
- const isApiRoute = require('../../../lib/is-api-route.cjs');
30
- const getNextPathnameInfo = require('./utils/get-next-pathname-info.cjs');
31
- const formatNextPathnameInfo = require('./utils/format-next-pathname-info.cjs');
32
- const compareStates = require('./utils/compare-states.cjs');
33
- const isLocalUrl = require('./utils/is-local-url.cjs');
34
- const isBot = require('./utils/is-bot.cjs');
35
- const omit = require('./utils/omit.cjs');
36
- const interpolateAs = require('./utils/interpolate-as.cjs');
37
- const disableSmoothScroll = require('./utils/disable-smooth-scroll.cjs');
38
- const constants = require('../../../lib/constants.cjs');
39
- const resolveRewrites = require('./utils/resolve-rewrites.cjs');
40
- const bloomFilter = require('../bloom-filter.cjs');
41
- const index = require('../../../compiled/react-is/index.cjs');
42
-
43
- var hasRequiredRouter;
44
-
45
- function requireRouter () {
46
- if (hasRequiredRouter) return router.__exports;
47
- hasRequiredRouter = 1;
48
- (function (exports) {
49
- Object.defineProperty(exports, "__esModule", {
50
- value: true
51
- });
52
- function _export(target, all) {
53
- for(var name in all)Object.defineProperty(target, name, {
54
- enumerable: true,
55
- get: all[name]
56
- });
57
- }
58
- _export(exports, {
59
- createKey: function() {
60
- return createKey;
61
- },
62
- default: function() {
63
- return Router;
64
- },
65
- matchesMiddleware: function() {
66
- return matchesMiddleware;
67
- }
68
- });
69
- const _interop_require_default$1 = /*@__PURE__*/ _interop_require_default.__require();
70
- const _interop_require_wildcard$1 = /*@__PURE__*/ _interop_require_wildcard.__require();
71
- const _removetrailingslash = removeTrailingSlash.__require();
72
- const _routeloader = routeLoader.__require();
73
- const _script = script.__require();
74
- const _iserror = /*#__PURE__*/ _interop_require_wildcard$1._(isError.__require());
75
- const _denormalizepagepath = denormalizePagePath.__require();
76
- const _normalizelocalepath = normalizeLocalePath.__require();
77
- const _mitt = /*#__PURE__*/ _interop_require_default$1._(mitt.__require());
78
- const _utils = utils.__require();
79
- const _isdynamic = isDynamic.__require();
80
- const _parserelativeurl = parseRelativeUrl.__require();
81
- const _routematcher = routeMatcher.__require();
82
- const _routeregex = routeRegex.__require();
83
- const _formaturl = formatUrl.__require();
84
- const _detectdomainlocale = detectDomainLocale.__require();
85
- const _parsepath = parsePath.__require();
86
- const _addlocale = addLocale.__require();
87
- const _removelocale = removeLocale.__require();
88
- const _removebasepath = removeBasePath.__require();
89
- const _addbasepath = addBasePath.__require();
90
- const _hasbasepath = hasBasePath.__require();
91
- const _resolvehref = resolveHref.__require();
92
- const _isapiroute = isApiRoute.__require();
93
- const _getnextpathnameinfo = getNextPathnameInfo.__require();
94
- const _formatnextpathnameinfo = formatNextPathnameInfo.__require();
95
- const _comparestates = compareStates.__require();
96
- const _islocalurl = isLocalUrl.__require();
97
- const _isbot = isBot.__require();
98
- const _omit = omit.__require();
99
- const _interpolateas = interpolateAs.__require();
100
- const _disablesmoothscroll = disableSmoothScroll.__require();
101
- const _constants = constants.__require();
102
- let resolveRewrites$1;
103
- if (process.env.__NEXT_HAS_REWRITES) {
104
- resolveRewrites$1 = resolveRewrites.__require().default;
105
- }
106
- function buildCancellationError() {
107
- return Object.assign(Object.defineProperty(new Error('Route Cancelled'), "__NEXT_ERROR_CODE", {
108
- value: "E315",
109
- enumerable: false,
110
- configurable: true
111
- }), {
112
- cancelled: true
113
- });
114
- }
115
- async function matchesMiddleware(options) {
116
- const matchers = await Promise.resolve(options.router.pageLoader.getMiddleware());
117
- if (!matchers) return false;
118
- const { pathname: asPathname } = (0, _parsepath.parsePath)(options.asPath);
119
- // remove basePath first since path prefix has to be in the order of `/${basePath}/${locale}`
120
- const cleanedAs = (0, _hasbasepath.hasBasePath)(asPathname) ? (0, _removebasepath.removeBasePath)(asPathname) : asPathname;
121
- const asWithBasePathAndLocale = (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(cleanedAs, options.locale));
122
- // Check only path match on client. Matching "has" should be done on server
123
- // where we can access more info such as headers, HttpOnly cookie, etc.
124
- return matchers.some((m)=>new RegExp(m.regexp).test(asWithBasePathAndLocale));
125
- }
126
- function stripOrigin(url) {
127
- const origin = (0, _utils.getLocationOrigin)();
128
- return url.startsWith(origin) ? url.substring(origin.length) : url;
129
- }
130
- function prepareUrlAs(router, url, as) {
131
- // If url and as provided as an object representation,
132
- // we'll format them into the string version here.
133
- let [resolvedHref, resolvedAs] = (0, _resolvehref.resolveHref)(router, url, true);
134
- const origin = (0, _utils.getLocationOrigin)();
135
- const hrefWasAbsolute = resolvedHref.startsWith(origin);
136
- const asWasAbsolute = resolvedAs && resolvedAs.startsWith(origin);
137
- resolvedHref = stripOrigin(resolvedHref);
138
- resolvedAs = resolvedAs ? stripOrigin(resolvedAs) : resolvedAs;
139
- const preparedUrl = hrefWasAbsolute ? resolvedHref : (0, _addbasepath.addBasePath)(resolvedHref);
140
- const preparedAs = as ? stripOrigin((0, _resolvehref.resolveHref)(router, as)) : resolvedAs || resolvedHref;
141
- return {
142
- url: preparedUrl,
143
- as: asWasAbsolute ? preparedAs : (0, _addbasepath.addBasePath)(preparedAs)
144
- };
145
- }
146
- function resolveDynamicRoute(pathname, pages) {
147
- const cleanPathname = (0, _removetrailingslash.removeTrailingSlash)((0, _denormalizepagepath.denormalizePagePath)(pathname));
148
- if (cleanPathname === '/404' || cleanPathname === '/_error') {
149
- return pathname;
150
- }
151
- // handle resolving href for dynamic routes
152
- if (!pages.includes(cleanPathname)) {
153
- // eslint-disable-next-line array-callback-return
154
- pages.some((page)=>{
155
- if ((0, _isdynamic.isDynamicRoute)(page) && (0, _routeregex.getRouteRegex)(page).re.test(cleanPathname)) {
156
- pathname = page;
157
- return true;
158
- }
159
- });
160
- }
161
- return (0, _removetrailingslash.removeTrailingSlash)(pathname);
162
- }
163
- function getMiddlewareData(source, response, options) {
164
- const nextConfig = {
165
- basePath: options.router.basePath,
166
- i18n: {
167
- locales: options.router.locales
168
- },
169
- trailingSlash: Boolean(process.env.__NEXT_TRAILING_SLASH)
170
- };
171
- const rewriteHeader = response.headers.get('x-nextjs-rewrite');
172
- let rewriteTarget = rewriteHeader || response.headers.get('x-nextjs-matched-path');
173
- const matchedPath = response.headers.get(_constants.MATCHED_PATH_HEADER);
174
- if (matchedPath && !rewriteTarget && !matchedPath.includes('__next_data_catchall') && !matchedPath.includes('/_error') && !matchedPath.includes('/404')) {
175
- // leverage x-matched-path to detect next.config.js rewrites
176
- rewriteTarget = matchedPath;
177
- }
178
- if (rewriteTarget) {
179
- if (rewriteTarget.startsWith('/') || process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE) {
180
- const parsedRewriteTarget = (0, _parserelativeurl.parseRelativeUrl)(rewriteTarget);
181
- const pathnameInfo = (0, _getnextpathnameinfo.getNextPathnameInfo)(parsedRewriteTarget.pathname, {
182
- nextConfig,
183
- parseData: true
184
- });
185
- let fsPathname = (0, _removetrailingslash.removeTrailingSlash)(pathnameInfo.pathname);
186
- return Promise.all([
187
- options.router.pageLoader.getPageList(),
188
- (0, _routeloader.getClientBuildManifest)()
189
- ]).then(([pages, { __rewrites: rewrites }])=>{
190
- let as = (0, _addlocale.addLocale)(pathnameInfo.pathname, pathnameInfo.locale);
191
- if ((0, _isdynamic.isDynamicRoute)(as) || !rewriteHeader && pages.includes((0, _normalizelocalepath.normalizeLocalePath)((0, _removebasepath.removeBasePath)(as), options.router.locales).pathname)) {
192
- const parsedSource = (0, _getnextpathnameinfo.getNextPathnameInfo)((0, _parserelativeurl.parseRelativeUrl)(source).pathname, {
193
- nextConfig: process.env.__NEXT_HAS_REWRITES ? undefined : nextConfig,
194
- parseData: true
195
- });
196
- as = (0, _addbasepath.addBasePath)(parsedSource.pathname);
197
- parsedRewriteTarget.pathname = as;
198
- }
199
- if (process.env.__NEXT_HAS_REWRITES) {
200
- const result = resolveRewrites$1(as, pages, rewrites, parsedRewriteTarget.query, (path)=>resolveDynamicRoute(path, pages), options.router.locales);
201
- if (result.matchedPage) {
202
- parsedRewriteTarget.pathname = result.parsedAs.pathname;
203
- as = parsedRewriteTarget.pathname;
204
- Object.assign(parsedRewriteTarget.query, result.parsedAs.query);
205
- }
206
- } else if (!pages.includes(fsPathname)) {
207
- const resolvedPathname = resolveDynamicRoute(fsPathname, pages);
208
- if (resolvedPathname !== fsPathname) {
209
- fsPathname = resolvedPathname;
210
- }
211
- }
212
- const resolvedHref = !pages.includes(fsPathname) ? resolveDynamicRoute((0, _normalizelocalepath.normalizeLocalePath)((0, _removebasepath.removeBasePath)(parsedRewriteTarget.pathname), options.router.locales).pathname, pages) : fsPathname;
213
- if ((0, _isdynamic.isDynamicRoute)(resolvedHref)) {
214
- const matches = (0, _routematcher.getRouteMatcher)((0, _routeregex.getRouteRegex)(resolvedHref))(as);
215
- Object.assign(parsedRewriteTarget.query, matches || {});
216
- }
217
- return {
218
- type: 'rewrite',
219
- parsedAs: parsedRewriteTarget,
220
- resolvedHref
221
- };
222
- });
223
- }
224
- const src = (0, _parsepath.parsePath)(source);
225
- const pathname = (0, _formatnextpathnameinfo.formatNextPathnameInfo)({
226
- ...(0, _getnextpathnameinfo.getNextPathnameInfo)(src.pathname, {
227
- nextConfig,
228
- parseData: true
229
- }),
230
- defaultLocale: options.router.defaultLocale,
231
- buildId: ''
232
- });
233
- return Promise.resolve({
234
- type: 'redirect-external',
235
- destination: `${pathname}${src.query}${src.hash}`
236
- });
237
- }
238
- const redirectTarget = response.headers.get('x-nextjs-redirect');
239
- if (redirectTarget) {
240
- if (redirectTarget.startsWith('/')) {
241
- const src = (0, _parsepath.parsePath)(redirectTarget);
242
- const pathname = (0, _formatnextpathnameinfo.formatNextPathnameInfo)({
243
- ...(0, _getnextpathnameinfo.getNextPathnameInfo)(src.pathname, {
244
- nextConfig,
245
- parseData: true
246
- }),
247
- defaultLocale: options.router.defaultLocale,
248
- buildId: ''
249
- });
250
- return Promise.resolve({
251
- type: 'redirect-internal',
252
- newAs: `${pathname}${src.query}${src.hash}`,
253
- newUrl: `${pathname}${src.query}${src.hash}`
254
- });
255
- }
256
- return Promise.resolve({
257
- type: 'redirect-external',
258
- destination: redirectTarget
259
- });
260
- }
261
- return Promise.resolve({
262
- type: 'next'
263
- });
264
- }
265
- async function withMiddlewareEffects(options) {
266
- const matches = await matchesMiddleware(options);
267
- if (!matches || !options.fetchData) {
268
- return null;
269
- }
270
- const data = await options.fetchData();
271
- const effect = await getMiddlewareData(data.dataHref, data.response, options);
272
- return {
273
- dataHref: data.dataHref,
274
- json: data.json,
275
- response: data.response,
276
- text: data.text,
277
- cacheKey: data.cacheKey,
278
- effect
279
- };
280
- }
281
- const manualScrollRestoration = process.env.__NEXT_SCROLL_RESTORATION && typeof window !== 'undefined' && 'scrollRestoration' in window.history && !!function() {
282
- try {
283
- let v = '__next';
284
- return sessionStorage.setItem(v, v), sessionStorage.removeItem(v), true;
285
- } catch (n) {}
286
- }();
287
- const SSG_DATA_NOT_FOUND = Symbol('SSG_DATA_NOT_FOUND');
288
- function fetchRetry(url, attempts, options) {
289
- return fetch(url, {
290
- // Cookies are required to be present for Next.js' SSG "Preview Mode".
291
- // Cookies may also be required for `getServerSideProps`.
292
- //
293
- // > `fetch` won’t send cookies, unless you set the credentials init
294
- // > option.
295
- // https://developer.mozilla.org/docs/Web/API/Fetch_API/Using_Fetch
296
- //
297
- // > For maximum browser compatibility when it comes to sending &
298
- // > receiving cookies, always supply the `credentials: 'same-origin'`
299
- // > option instead of relying on the default.
300
- // https://github.com/github/fetch#caveats
301
- credentials: 'same-origin',
302
- method: options.method || 'GET',
303
- headers: Object.assign({}, options.headers, {
304
- 'x-nextjs-data': '1'
305
- })
306
- }).then((response)=>{
307
- return !response.ok && attempts > 1 && response.status >= 500 ? fetchRetry(url, attempts - 1, options) : response;
308
- });
309
- }
310
- function tryToParseAsJSON(text) {
311
- try {
312
- return JSON.parse(text);
313
- } catch (error) {
314
- return null;
315
- }
316
- }
317
- function fetchNextData({ dataHref, inflightCache, isPrefetch, hasMiddleware, isServerRender, parseJSON, persistCache, isBackground, unstable_skipClientCache }) {
318
- const { href: cacheKey } = new URL(dataHref, window.location.href);
319
- const getData = (params)=>fetchRetry(dataHref, isServerRender ? 3 : 1, {
320
- headers: Object.assign({}, isPrefetch ? {
321
- purpose: 'prefetch'
322
- } : {}, isPrefetch && hasMiddleware ? {
323
- 'x-middleware-prefetch': '1'
324
- } : {}, process.env.NEXT_DEPLOYMENT_ID ? {
325
- 'x-deployment-id': process.env.NEXT_DEPLOYMENT_ID
326
- } : {}),
327
- method: params?.method ?? 'GET'
328
- }).then((response)=>{
329
- if (response.ok && params?.method === 'HEAD') {
330
- return {
331
- dataHref,
332
- response,
333
- text: '',
334
- json: {},
335
- cacheKey
336
- };
337
- }
338
- return response.text().then((text)=>{
339
- if (!response.ok) {
340
- /**
341
- * When the data response is a redirect because of a middleware
342
- * we do not consider it an error. The headers must bring the
343
- * mapped location.
344
- * TODO: Change the status code in the handler.
345
- */ if (hasMiddleware && [
346
- 301,
347
- 302,
348
- 307,
349
- 308
350
- ].includes(response.status)) {
351
- return {
352
- dataHref,
353
- response,
354
- text,
355
- json: {},
356
- cacheKey
357
- };
358
- }
359
- if (response.status === 404) {
360
- if (tryToParseAsJSON(text)?.notFound) {
361
- return {
362
- dataHref,
363
- json: {
364
- notFound: SSG_DATA_NOT_FOUND
365
- },
366
- response,
367
- text,
368
- cacheKey
369
- };
370
- }
371
- }
372
- const error = Object.defineProperty(new Error(`Failed to load static props`), "__NEXT_ERROR_CODE", {
373
- value: "E124",
374
- enumerable: false,
375
- configurable: true
376
- });
377
- /**
378
- * We should only trigger a server-side transition if this was
379
- * caused on a client-side transition. Otherwise, we'd get into
380
- * an infinite loop.
381
- */ if (!isServerRender) {
382
- (0, _routeloader.markAssetError)(error);
383
- }
384
- throw error;
385
- }
386
- return {
387
- dataHref,
388
- json: parseJSON ? tryToParseAsJSON(text) : null,
389
- response,
390
- text,
391
- cacheKey
392
- };
393
- });
394
- }).then((data)=>{
395
- if (!persistCache || process.env.NODE_ENV !== 'production' || data.response.headers.get('x-middleware-cache') === 'no-cache') {
396
- delete inflightCache[cacheKey];
397
- }
398
- return data;
399
- }).catch((err)=>{
400
- if (!unstable_skipClientCache) {
401
- delete inflightCache[cacheKey];
402
- }
403
- if (// chrome
404
- err.message === 'Failed to fetch' || // firefox
405
- err.message === 'NetworkError when attempting to fetch resource.' || // safari
406
- err.message === 'Load failed') {
407
- (0, _routeloader.markAssetError)(err);
408
- }
409
- throw err;
410
- });
411
- // when skipping client cache we wait to update
412
- // inflight cache until successful data response
413
- // this allows racing click event with fetching newer data
414
- // without blocking navigation when stale data is available
415
- if (unstable_skipClientCache && persistCache) {
416
- return getData({}).then((data)=>{
417
- if (data.response.headers.get('x-middleware-cache') !== 'no-cache') {
418
- // only update cache if not marked as no-cache
419
- inflightCache[cacheKey] = Promise.resolve(data);
420
- }
421
- return data;
422
- });
423
- }
424
- if (inflightCache[cacheKey] !== undefined) {
425
- return inflightCache[cacheKey];
426
- }
427
- return inflightCache[cacheKey] = getData(isBackground ? {
428
- method: 'HEAD'
429
- } : {});
430
- }
431
- function createKey() {
432
- return Math.random().toString(36).slice(2, 10);
433
- }
434
- function handleHardNavigation({ url, router }) {
435
- // ensure we don't trigger a hard navigation to the same
436
- // URL as this can end up with an infinite refresh
437
- if (url === (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(router.asPath, router.locale))) {
438
- throw Object.defineProperty(new Error(`Invariant: attempted to hard navigate to the same URL ${url} ${location.href}`), "__NEXT_ERROR_CODE", {
439
- value: "E282",
440
- enumerable: false,
441
- configurable: true
442
- });
443
- }
444
- window.location.href = url;
445
- }
446
- const getCancelledHandler = ({ route, router })=>{
447
- let cancelled = false;
448
- const cancel = router.clc = ()=>{
449
- cancelled = true;
450
- };
451
- const handleCancelled = ()=>{
452
- if (cancelled) {
453
- const error = Object.defineProperty(new Error(`Abort fetching component for route: "${route}"`), "__NEXT_ERROR_CODE", {
454
- value: "E483",
455
- enumerable: false,
456
- configurable: true
457
- });
458
- error.cancelled = true;
459
- throw error;
460
- }
461
- if (cancel === router.clc) {
462
- router.clc = null;
463
- }
464
- };
465
- return handleCancelled;
466
- };
467
- class Router {
468
- static{
469
- this.events = (0, _mitt.default)();
470
- }
471
- constructor(pathname, query, as, { initialProps, pageLoader, App, wrapApp, Component, err, subscription, isFallback, locale, locales, defaultLocale, domainLocales, isPreview }){
472
- // Server Data Cache (full data requests)
473
- this.sdc = {};
474
- // Server Background Cache (HEAD requests)
475
- this.sbc = {};
476
- this.isFirstPopStateEvent = true;
477
- this._key = createKey();
478
- this.onPopState = (e)=>{
479
- const { isFirstPopStateEvent } = this;
480
- this.isFirstPopStateEvent = false;
481
- const state = e.state;
482
- if (!state) {
483
- // We get state as undefined for two reasons.
484
- // 1. With older safari (< 8) and older chrome (< 34)
485
- // 2. When the URL changed with #
486
- //
487
- // In the both cases, we don't need to proceed and change the route.
488
- // (as it's already changed)
489
- // But we can simply replace the state with the new changes.
490
- // Actually, for (1) we don't need to nothing. But it's hard to detect that event.
491
- // So, doing the following for (1) does no harm.
492
- const { pathname, query } = this;
493
- this.changeState('replaceState', (0, _formaturl.formatWithValidation)({
494
- pathname: (0, _addbasepath.addBasePath)(pathname),
495
- query
496
- }), (0, _utils.getURL)());
497
- return;
498
- }
499
- // __NA is used to identify if the history entry can be handled by the app-router.
500
- if (state.__NA) {
501
- window.location.reload();
502
- return;
503
- }
504
- if (!state.__N) {
505
- return;
506
- }
507
- // Safari fires popstateevent when reopening the browser.
508
- if (isFirstPopStateEvent && this.locale === state.options.locale && state.as === this.asPath) {
509
- return;
510
- }
511
- let forcedScroll;
512
- const { url, as, options, key } = state;
513
- if (process.env.__NEXT_SCROLL_RESTORATION) {
514
- if (manualScrollRestoration) {
515
- if (this._key !== key) {
516
- // Snapshot current scroll position:
517
- try {
518
- sessionStorage.setItem('__next_scroll_' + this._key, JSON.stringify({
519
- x: self.pageXOffset,
520
- y: self.pageYOffset
521
- }));
522
- } catch {}
523
- // Restore old scroll position:
524
- try {
525
- const v = sessionStorage.getItem('__next_scroll_' + key);
526
- forcedScroll = JSON.parse(v);
527
- } catch {
528
- forcedScroll = {
529
- x: 0,
530
- y: 0
531
- };
532
- }
533
- }
534
- }
535
- }
536
- this._key = key;
537
- const { pathname } = (0, _parserelativeurl.parseRelativeUrl)(url);
538
- // Make sure we don't re-render on initial load,
539
- // can be caused by navigating back from an external site
540
- if (this.isSsr && as === (0, _addbasepath.addBasePath)(this.asPath) && pathname === (0, _addbasepath.addBasePath)(this.pathname)) {
541
- return;
542
- }
543
- // If the downstream application returns falsy, return.
544
- // They will then be responsible for handling the event.
545
- if (this._bps && !this._bps(state)) {
546
- return;
547
- }
548
- this.change('replaceState', url, as, Object.assign({}, options, {
549
- shallow: options.shallow && this._shallow,
550
- locale: options.locale || this.defaultLocale,
551
- // @ts-ignore internal value not exposed on types
552
- _h: 0
553
- }), forcedScroll);
554
- };
555
- // represents the current component key
556
- const route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
557
- // set up the component cache (by route keys)
558
- this.components = {};
559
- // We should not keep the cache, if there's an error
560
- // Otherwise, this cause issues when when going back and
561
- // come again to the errored page.
562
- if (pathname !== '/_error') {
563
- this.components[route] = {
564
- Component,
565
- initial: true,
566
- props: initialProps,
567
- err,
568
- __N_SSG: initialProps && initialProps.__N_SSG,
569
- __N_SSP: initialProps && initialProps.__N_SSP
570
- };
571
- }
572
- this.components['/_app'] = {
573
- Component: App,
574
- styleSheets: []
575
- };
576
- // Backwards compat for Router.router.events
577
- // TODO: Should be remove the following major version as it was never documented
578
- this.events = Router.events;
579
- this.pageLoader = pageLoader;
580
- // if auto prerendered and dynamic route wait to update asPath
581
- // until after mount to prevent hydration mismatch
582
- const autoExportDynamic = (0, _isdynamic.isDynamicRoute)(pathname) && self.__NEXT_DATA__.autoExport;
583
- this.basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
584
- this.sub = subscription;
585
- this.clc = null;
586
- this._wrapApp = wrapApp;
587
- // make sure to ignore extra popState in safari on navigating
588
- // back from external site
589
- this.isSsr = true;
590
- this.isLocaleDomain = false;
591
- this.isReady = !!(self.__NEXT_DATA__.gssp || self.__NEXT_DATA__.gip || self.__NEXT_DATA__.isExperimentalCompile || self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp || !autoExportDynamic && !self.location.search && !process.env.__NEXT_HAS_REWRITES);
592
- if (process.env.__NEXT_I18N_SUPPORT) {
593
- this.locales = locales;
594
- this.defaultLocale = defaultLocale;
595
- this.domainLocales = domainLocales;
596
- this.isLocaleDomain = !!(0, _detectdomainlocale.detectDomainLocale)(domainLocales, self.location.hostname);
597
- }
598
- this.state = {
599
- route,
600
- pathname,
601
- query,
602
- asPath: autoExportDynamic ? pathname : as,
603
- isPreview: !!isPreview,
604
- locale: process.env.__NEXT_I18N_SUPPORT ? locale : undefined,
605
- isFallback
606
- };
607
- this._initialMatchesMiddlewarePromise = Promise.resolve(false);
608
- if (typeof window !== 'undefined') {
609
- // make sure "as" doesn't start with double slashes or else it can
610
- // throw an error as it's considered invalid
611
- if (!as.startsWith('//')) {
612
- // in order for `e.state` to work on the `onpopstate` event
613
- // we have to register the initial route upon initialization
614
- const options = {
615
- locale
616
- };
617
- const asPath = (0, _utils.getURL)();
618
- this._initialMatchesMiddlewarePromise = matchesMiddleware({
619
- router: this,
620
- locale,
621
- asPath
622
- }).then((matches)=>{
623
- options._shouldResolveHref = as !== pathname;
624
- this.changeState('replaceState', matches ? asPath : (0, _formaturl.formatWithValidation)({
625
- pathname: (0, _addbasepath.addBasePath)(pathname),
626
- query
627
- }), asPath, options);
628
- return matches;
629
- });
630
- }
631
- window.addEventListener('popstate', this.onPopState);
632
- // enable custom scroll restoration handling when available
633
- // otherwise fallback to browser's default handling
634
- if (process.env.__NEXT_SCROLL_RESTORATION) {
635
- if (manualScrollRestoration) {
636
- window.history.scrollRestoration = 'manual';
637
- }
638
- }
639
- }
640
- }
641
- reload() {
642
- window.location.reload();
643
- }
644
- /**
645
- * Go back in history
646
- */ back() {
647
- window.history.back();
648
- }
649
- /**
650
- * Go forward in history
651
- */ forward() {
652
- window.history.forward();
653
- }
654
- /**
655
- * Performs a `pushState` with arguments
656
- * @param url of the route
657
- * @param as masks `url` for the browser
658
- * @param options object you can define `shallow` and other options
659
- */ push(url, as, options = {}) {
660
- if (process.env.__NEXT_SCROLL_RESTORATION) {
661
- // TODO: remove in the future when we update history before route change
662
- // is complete, as the popstate event should handle this capture.
663
- if (manualScrollRestoration) {
664
- try {
665
- // Snapshot scroll position right before navigating to a new page:
666
- sessionStorage.setItem('__next_scroll_' + this._key, JSON.stringify({
667
- x: self.pageXOffset,
668
- y: self.pageYOffset
669
- }));
670
- } catch {}
671
- }
672
- }
673
- ({ url, as } = prepareUrlAs(this, url, as));
674
- return this.change('pushState', url, as, options);
675
- }
676
- /**
677
- * Performs a `replaceState` with arguments
678
- * @param url of the route
679
- * @param as masks `url` for the browser
680
- * @param options object you can define `shallow` and other options
681
- */ replace(url, as, options = {}) {
682
- ({ url, as } = prepareUrlAs(this, url, as));
683
- return this.change('replaceState', url, as, options);
684
- }
685
- async _bfl(as, resolvedAs, locale, skipNavigate) {
686
- if (process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED) {
687
- if (!this._bfl_s && !this._bfl_d) {
688
- const { BloomFilter } = bloomFilter.__require();
689
- let staticFilterData;
690
- let dynamicFilterData;
691
- try {
692
- ;
693
- ({ __routerFilterStatic: staticFilterData, __routerFilterDynamic: dynamicFilterData } = await (0, _routeloader.getClientBuildManifest)());
694
- } catch (err) {
695
- // failed to load build manifest hard navigate
696
- // to be safe
697
- console.error(err);
698
- if (skipNavigate) {
699
- return true;
700
- }
701
- handleHardNavigation({
702
- url: (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(as, locale || this.locale, this.defaultLocale)),
703
- router: this
704
- });
705
- return new Promise(()=>{});
706
- }
707
- const routerFilterSValue = process.env.__NEXT_CLIENT_ROUTER_S_FILTER;
708
- if (!staticFilterData && routerFilterSValue) {
709
- staticFilterData = routerFilterSValue ? routerFilterSValue : undefined;
710
- }
711
- const routerFilterDValue = process.env.__NEXT_CLIENT_ROUTER_D_FILTER;
712
- if (!dynamicFilterData && routerFilterDValue) {
713
- dynamicFilterData = routerFilterDValue ? routerFilterDValue : undefined;
714
- }
715
- if (staticFilterData?.numHashes) {
716
- this._bfl_s = new BloomFilter(staticFilterData.numItems, staticFilterData.errorRate);
717
- this._bfl_s.import(staticFilterData);
718
- }
719
- if (dynamicFilterData?.numHashes) {
720
- this._bfl_d = new BloomFilter(dynamicFilterData.numItems, dynamicFilterData.errorRate);
721
- this._bfl_d.import(dynamicFilterData);
722
- }
723
- }
724
- let matchesBflStatic = false;
725
- let matchesBflDynamic = false;
726
- const pathsToCheck = [
727
- {
728
- as
729
- },
730
- {
731
- as: resolvedAs
732
- }
733
- ];
734
- for (const { as: curAs, allowMatchCurrent } of pathsToCheck){
735
- if (curAs) {
736
- const asNoSlash = (0, _removetrailingslash.removeTrailingSlash)(new URL(curAs, 'http://n').pathname);
737
- const asNoSlashLocale = (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(asNoSlash, locale || this.locale));
738
- if (allowMatchCurrent || asNoSlash !== (0, _removetrailingslash.removeTrailingSlash)(new URL(this.asPath, 'http://n').pathname)) {
739
- matchesBflStatic = matchesBflStatic || !!this._bfl_s?.contains(asNoSlash) || !!this._bfl_s?.contains(asNoSlashLocale);
740
- for (const normalizedAS of [
741
- asNoSlash,
742
- asNoSlashLocale
743
- ]){
744
- // if any sub-path of as matches a dynamic filter path
745
- // it should be hard navigated
746
- const curAsParts = normalizedAS.split('/');
747
- for(let i = 0; !matchesBflDynamic && i < curAsParts.length + 1; i++){
748
- const currentPart = curAsParts.slice(0, i).join('/');
749
- if (currentPart && this._bfl_d?.contains(currentPart)) {
750
- matchesBflDynamic = true;
751
- break;
752
- }
753
- }
754
- }
755
- // if the client router filter is matched then we trigger
756
- // a hard navigation
757
- if (matchesBflStatic || matchesBflDynamic) {
758
- if (skipNavigate) {
759
- return true;
760
- }
761
- handleHardNavigation({
762
- url: (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(as, locale || this.locale, this.defaultLocale)),
763
- router: this
764
- });
765
- return new Promise(()=>{});
766
- }
767
- }
768
- }
769
- }
770
- }
771
- return false;
772
- }
773
- async change(method, url, as, options, forcedScroll) {
774
- if (!(0, _islocalurl.isLocalURL)(url)) {
775
- handleHardNavigation({
776
- url,
777
- router: this
778
- });
779
- return false;
780
- }
781
- // WARNING: `_h` is an internal option for handing Next.js client-side
782
- // hydration. Your app should _never_ use this property. It may change at
783
- // any time without notice.
784
- const isQueryUpdating = options._h === 1;
785
- if (!isQueryUpdating && !options.shallow) {
786
- await this._bfl(as, undefined, options.locale);
787
- }
788
- let shouldResolveHref = isQueryUpdating || options._shouldResolveHref || (0, _parsepath.parsePath)(url).pathname === (0, _parsepath.parsePath)(as).pathname;
789
- const nextState = {
790
- ...this.state
791
- };
792
- // for static pages with query params in the URL we delay
793
- // marking the router ready until after the query is updated
794
- // or a navigation has occurred
795
- const readyStateChange = this.isReady !== true;
796
- this.isReady = true;
797
- const isSsr = this.isSsr;
798
- if (!isQueryUpdating) {
799
- this.isSsr = false;
800
- }
801
- // if a route transition is already in progress before
802
- // the query updating is triggered ignore query updating
803
- if (isQueryUpdating && this.clc) {
804
- return false;
805
- }
806
- const prevLocale = nextState.locale;
807
- if (process.env.__NEXT_I18N_SUPPORT) {
808
- nextState.locale = options.locale === false ? this.defaultLocale : options.locale || nextState.locale;
809
- if (typeof options.locale === 'undefined') {
810
- options.locale = nextState.locale;
811
- }
812
- const parsedAs = (0, _parserelativeurl.parseRelativeUrl)((0, _hasbasepath.hasBasePath)(as) ? (0, _removebasepath.removeBasePath)(as) : as);
813
- const localePathResult = (0, _normalizelocalepath.normalizeLocalePath)(parsedAs.pathname, this.locales);
814
- if (localePathResult.detectedLocale) {
815
- nextState.locale = localePathResult.detectedLocale;
816
- parsedAs.pathname = (0, _addbasepath.addBasePath)(parsedAs.pathname);
817
- as = (0, _formaturl.formatWithValidation)(parsedAs);
818
- url = (0, _addbasepath.addBasePath)((0, _normalizelocalepath.normalizeLocalePath)((0, _hasbasepath.hasBasePath)(url) ? (0, _removebasepath.removeBasePath)(url) : url, this.locales).pathname);
819
- }
820
- let didNavigate = false;
821
- // we need to wrap this in the env check again since regenerator runtime
822
- // moves this on its own due to the return
823
- if (process.env.__NEXT_I18N_SUPPORT) {
824
- // if the locale isn't configured hard navigate to show 404 page
825
- if (!this.locales?.includes(nextState.locale)) {
826
- parsedAs.pathname = (0, _addlocale.addLocale)(parsedAs.pathname, nextState.locale);
827
- handleHardNavigation({
828
- url: (0, _formaturl.formatWithValidation)(parsedAs),
829
- router: this
830
- });
831
- // this was previously a return but was removed in favor
832
- // of better dead code elimination with regenerator runtime
833
- didNavigate = true;
834
- }
835
- }
836
- const detectedDomain = (0, _detectdomainlocale.detectDomainLocale)(this.domainLocales, undefined, nextState.locale);
837
- // we need to wrap this in the env check again since regenerator runtime
838
- // moves this on its own due to the return
839
- if (process.env.__NEXT_I18N_SUPPORT) {
840
- // if we are navigating to a domain locale ensure we redirect to the
841
- // correct domain
842
- if (!didNavigate && detectedDomain && this.isLocaleDomain && self.location.hostname !== detectedDomain.domain) {
843
- const asNoBasePath = (0, _removebasepath.removeBasePath)(as);
844
- handleHardNavigation({
845
- url: `http${detectedDomain.http ? '' : 's'}://${detectedDomain.domain}${(0, _addbasepath.addBasePath)(`${nextState.locale === detectedDomain.defaultLocale ? '' : `/${nextState.locale}`}${asNoBasePath === '/' ? '' : asNoBasePath}` || '/')}`,
846
- router: this
847
- });
848
- // this was previously a return but was removed in favor
849
- // of better dead code elimination with regenerator runtime
850
- didNavigate = true;
851
- }
852
- }
853
- if (didNavigate) {
854
- return new Promise(()=>{});
855
- }
856
- }
857
- // marking route changes as a navigation start entry
858
- if (_utils.ST) {
859
- performance.mark('routeChange');
860
- }
861
- const { shallow = false, scroll = true } = options;
862
- const routeProps = {
863
- shallow
864
- };
865
- if (this._inFlightRoute && this.clc) {
866
- if (!isSsr) {
867
- Router.events.emit('routeChangeError', buildCancellationError(), this._inFlightRoute, routeProps);
868
- }
869
- this.clc();
870
- this.clc = null;
871
- }
872
- as = (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)((0, _hasbasepath.hasBasePath)(as) ? (0, _removebasepath.removeBasePath)(as) : as, options.locale, this.defaultLocale));
873
- const cleanedAs = (0, _removelocale.removeLocale)((0, _hasbasepath.hasBasePath)(as) ? (0, _removebasepath.removeBasePath)(as) : as, nextState.locale);
874
- this._inFlightRoute = as;
875
- const localeChange = prevLocale !== nextState.locale;
876
- // If the url change is only related to a hash change
877
- // We should not proceed. We should only change the state.
878
- if (!isQueryUpdating && this.onlyAHashChange(cleanedAs) && !localeChange) {
879
- nextState.asPath = cleanedAs;
880
- Router.events.emit('hashChangeStart', as, routeProps);
881
- // TODO: do we need the resolved href when only a hash change?
882
- this.changeState(method, url, as, {
883
- ...options,
884
- scroll: false
885
- });
886
- if (scroll) {
887
- this.scrollToHash(cleanedAs);
888
- }
889
- try {
890
- await this.set(nextState, this.components[nextState.route], null);
891
- } catch (err) {
892
- if ((0, _iserror.default)(err) && err.cancelled) {
893
- Router.events.emit('routeChangeError', err, cleanedAs, routeProps);
894
- }
895
- throw err;
896
- }
897
- Router.events.emit('hashChangeComplete', as, routeProps);
898
- return true;
899
- }
900
- let parsed = (0, _parserelativeurl.parseRelativeUrl)(url);
901
- let { pathname, query } = parsed;
902
- // The build manifest needs to be loaded before auto-static dynamic pages
903
- // get their query parameters to allow ensuring they can be parsed properly
904
- // when rewritten to
905
- let pages, rewrites;
906
- try {
907
- ;
908
- [pages, { __rewrites: rewrites }] = await Promise.all([
909
- this.pageLoader.getPageList(),
910
- (0, _routeloader.getClientBuildManifest)(),
911
- this.pageLoader.getMiddleware()
912
- ]);
913
- } catch (err) {
914
- // If we fail to resolve the page list or client-build manifest, we must
915
- // do a server-side transition:
916
- handleHardNavigation({
917
- url: as,
918
- router: this
919
- });
920
- return false;
921
- }
922
- // If asked to change the current URL we should reload the current page
923
- // (not location.reload() but reload getInitialProps and other Next.js stuffs)
924
- // We also need to set the method = replaceState always
925
- // as this should not go into the history (That's how browsers work)
926
- // We should compare the new asPath to the current asPath, not the url
927
- if (!this.urlIsNew(cleanedAs) && !localeChange) {
928
- method = 'replaceState';
929
- }
930
- // we need to resolve the as value using rewrites for dynamic SSG
931
- // pages to allow building the data URL correctly
932
- let resolvedAs = as;
933
- // url and as should always be prefixed with basePath by this
934
- // point by either next/link or router.push/replace so strip the
935
- // basePath from the pathname to match the pages dir 1-to-1
936
- pathname = pathname ? (0, _removetrailingslash.removeTrailingSlash)((0, _removebasepath.removeBasePath)(pathname)) : pathname;
937
- let route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
938
- const parsedAsPathname = as.startsWith('/') && (0, _parserelativeurl.parseRelativeUrl)(as).pathname;
939
- // if we detected the path as app route during prefetching
940
- // trigger hard navigation
941
- if (this.components[pathname]?.__appRouter) {
942
- handleHardNavigation({
943
- url: as,
944
- router: this
945
- });
946
- return new Promise(()=>{});
947
- }
948
- const isMiddlewareRewrite = !!(parsedAsPathname && route !== parsedAsPathname && (!(0, _isdynamic.isDynamicRoute)(route) || !(0, _routematcher.getRouteMatcher)((0, _routeregex.getRouteRegex)(route))(parsedAsPathname)));
949
- // we don't attempt resolve asPath when we need to execute
950
- // middleware as the resolving will occur server-side
951
- const isMiddlewareMatch = !options.shallow && await matchesMiddleware({
952
- asPath: as,
953
- locale: nextState.locale,
954
- router: this
955
- });
956
- if (isQueryUpdating && isMiddlewareMatch) {
957
- shouldResolveHref = false;
958
- }
959
- if (shouldResolveHref && pathname !== '/_error') {
960
- options._shouldResolveHref = true;
961
- if (process.env.__NEXT_HAS_REWRITES && as.startsWith('/')) {
962
- const rewritesResult = resolveRewrites$1((0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(cleanedAs, nextState.locale), true), pages, rewrites, query, (p)=>resolveDynamicRoute(p, pages), this.locales);
963
- if (rewritesResult.externalDest) {
964
- handleHardNavigation({
965
- url: as,
966
- router: this
967
- });
968
- return true;
969
- }
970
- if (!isMiddlewareMatch) {
971
- resolvedAs = rewritesResult.asPath;
972
- }
973
- if (rewritesResult.matchedPage && rewritesResult.resolvedHref) {
974
- // if this directly matches a page we need to update the href to
975
- // allow the correct page chunk to be loaded
976
- pathname = rewritesResult.resolvedHref;
977
- parsed.pathname = (0, _addbasepath.addBasePath)(pathname);
978
- if (!isMiddlewareMatch) {
979
- url = (0, _formaturl.formatWithValidation)(parsed);
980
- }
981
- }
982
- } else {
983
- parsed.pathname = resolveDynamicRoute(pathname, pages);
984
- if (parsed.pathname !== pathname) {
985
- pathname = parsed.pathname;
986
- parsed.pathname = (0, _addbasepath.addBasePath)(pathname);
987
- if (!isMiddlewareMatch) {
988
- url = (0, _formaturl.formatWithValidation)(parsed);
989
- }
990
- }
991
- }
992
- }
993
- if (!(0, _islocalurl.isLocalURL)(as)) {
994
- if (process.env.NODE_ENV !== 'production') {
995
- throw Object.defineProperty(new Error(`Invalid href: "${url}" and as: "${as}", received relative href and external as` + `\nSee more info: https://nextjs.org/docs/messages/invalid-relative-url-external-as`), "__NEXT_ERROR_CODE", {
996
- value: "E380",
997
- enumerable: false,
998
- configurable: true
999
- });
1000
- }
1001
- handleHardNavigation({
1002
- url: as,
1003
- router: this
1004
- });
1005
- return false;
1006
- }
1007
- resolvedAs = (0, _removelocale.removeLocale)((0, _removebasepath.removeBasePath)(resolvedAs), nextState.locale);
1008
- route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
1009
- let routeMatch = false;
1010
- if ((0, _isdynamic.isDynamicRoute)(route)) {
1011
- const parsedAs = (0, _parserelativeurl.parseRelativeUrl)(resolvedAs);
1012
- const asPathname = parsedAs.pathname;
1013
- const routeRegex = (0, _routeregex.getRouteRegex)(route);
1014
- routeMatch = (0, _routematcher.getRouteMatcher)(routeRegex)(asPathname);
1015
- const shouldInterpolate = route === asPathname;
1016
- const interpolatedAs = shouldInterpolate ? (0, _interpolateas.interpolateAs)(route, asPathname, query) : {};
1017
- if (!routeMatch || shouldInterpolate && !interpolatedAs.result) {
1018
- const missingParams = Object.keys(routeRegex.groups).filter((param)=>!query[param] && !routeRegex.groups[param].optional);
1019
- if (missingParams.length > 0 && !isMiddlewareMatch) {
1020
- if (process.env.NODE_ENV !== 'production') {
1021
- console.warn(`${shouldInterpolate ? `Interpolating href` : `Mismatching \`as\` and \`href\``} failed to manually provide ` + `the params: ${missingParams.join(', ')} in the \`href\`'s \`query\``);
1022
- }
1023
- throw Object.defineProperty(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'}`), "__NEXT_ERROR_CODE", {
1024
- value: "E344",
1025
- enumerable: false,
1026
- configurable: true
1027
- });
1028
- }
1029
- } else if (shouldInterpolate) {
1030
- as = (0, _formaturl.formatWithValidation)(Object.assign({}, parsedAs, {
1031
- pathname: interpolatedAs.result,
1032
- query: (0, _omit.omit)(query, interpolatedAs.params)
1033
- }));
1034
- } else {
1035
- // Merge params into `query`, overwriting any specified in search
1036
- Object.assign(query, routeMatch);
1037
- }
1038
- }
1039
- if (!isQueryUpdating) {
1040
- Router.events.emit('routeChangeStart', as, routeProps);
1041
- }
1042
- const isErrorRoute = this.pathname === '/404' || this.pathname === '/_error';
1043
- try {
1044
- let routeInfo = await this.getRouteInfo({
1045
- route,
1046
- pathname,
1047
- query,
1048
- as,
1049
- resolvedAs,
1050
- routeProps,
1051
- locale: nextState.locale,
1052
- isPreview: nextState.isPreview,
1053
- hasMiddleware: isMiddlewareMatch,
1054
- unstable_skipClientCache: options.unstable_skipClientCache,
1055
- isQueryUpdating: isQueryUpdating && !this.isFallback,
1056
- isMiddlewareRewrite
1057
- });
1058
- if (!isQueryUpdating && !options.shallow) {
1059
- await this._bfl(as, 'resolvedAs' in routeInfo ? routeInfo.resolvedAs : undefined, nextState.locale);
1060
- }
1061
- if ('route' in routeInfo && isMiddlewareMatch) {
1062
- pathname = routeInfo.route || route;
1063
- route = pathname;
1064
- if (!routeProps.shallow) {
1065
- query = Object.assign({}, routeInfo.query || {}, query);
1066
- }
1067
- const cleanedParsedPathname = (0, _hasbasepath.hasBasePath)(parsed.pathname) ? (0, _removebasepath.removeBasePath)(parsed.pathname) : parsed.pathname;
1068
- if (routeMatch && pathname !== cleanedParsedPathname) {
1069
- Object.keys(routeMatch).forEach((key)=>{
1070
- if (routeMatch && query[key] === routeMatch[key]) {
1071
- delete query[key];
1072
- }
1073
- });
1074
- }
1075
- if ((0, _isdynamic.isDynamicRoute)(pathname)) {
1076
- const prefixedAs = !routeProps.shallow && routeInfo.resolvedAs ? routeInfo.resolvedAs : (0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(new URL(as, location.href).pathname, nextState.locale), true);
1077
- let rewriteAs = prefixedAs;
1078
- if ((0, _hasbasepath.hasBasePath)(rewriteAs)) {
1079
- rewriteAs = (0, _removebasepath.removeBasePath)(rewriteAs);
1080
- }
1081
- if (process.env.__NEXT_I18N_SUPPORT) {
1082
- const localeResult = (0, _normalizelocalepath.normalizeLocalePath)(rewriteAs, this.locales);
1083
- nextState.locale = localeResult.detectedLocale || nextState.locale;
1084
- rewriteAs = localeResult.pathname;
1085
- }
1086
- const routeRegex = (0, _routeregex.getRouteRegex)(pathname);
1087
- const curRouteMatch = (0, _routematcher.getRouteMatcher)(routeRegex)(new URL(rewriteAs, location.href).pathname);
1088
- if (curRouteMatch) {
1089
- Object.assign(query, curRouteMatch);
1090
- }
1091
- }
1092
- }
1093
- // If the routeInfo brings a redirect we simply apply it.
1094
- if ('type' in routeInfo) {
1095
- if (routeInfo.type === 'redirect-internal') {
1096
- return this.change(method, routeInfo.newUrl, routeInfo.newAs, options);
1097
- } else {
1098
- handleHardNavigation({
1099
- url: routeInfo.destination,
1100
- router: this
1101
- });
1102
- return new Promise(()=>{});
1103
- }
1104
- }
1105
- const component = routeInfo.Component;
1106
- if (component && component.unstable_scriptLoader) {
1107
- const scripts = [].concat(component.unstable_scriptLoader());
1108
- scripts.forEach((script)=>{
1109
- (0, _script.handleClientScriptLoad)(script.props);
1110
- });
1111
- }
1112
- // handle redirect on client-transition
1113
- if ((routeInfo.__N_SSG || routeInfo.__N_SSP) && routeInfo.props) {
1114
- if (routeInfo.props.pageProps && routeInfo.props.pageProps.__N_REDIRECT) {
1115
- // Use the destination from redirect without adding locale
1116
- options.locale = false;
1117
- const destination = routeInfo.props.pageProps.__N_REDIRECT;
1118
- // check if destination is internal (resolves to a page) and attempt
1119
- // client-navigation if it is falling back to hard navigation if
1120
- // it's not
1121
- if (destination.startsWith('/') && routeInfo.props.pageProps.__N_REDIRECT_BASE_PATH !== false) {
1122
- const parsedHref = (0, _parserelativeurl.parseRelativeUrl)(destination);
1123
- parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages);
1124
- const { url: newUrl, as: newAs } = prepareUrlAs(this, destination, destination);
1125
- return this.change(method, newUrl, newAs, options);
1126
- }
1127
- handleHardNavigation({
1128
- url: destination,
1129
- router: this
1130
- });
1131
- return new Promise(()=>{});
1132
- }
1133
- nextState.isPreview = !!routeInfo.props.__N_PREVIEW;
1134
- // handle SSG data 404
1135
- if (routeInfo.props.notFound === SSG_DATA_NOT_FOUND) {
1136
- let notFoundRoute;
1137
- try {
1138
- await this.fetchComponent('/404');
1139
- notFoundRoute = '/404';
1140
- } catch (_) {
1141
- notFoundRoute = '/_error';
1142
- }
1143
- routeInfo = await this.getRouteInfo({
1144
- route: notFoundRoute,
1145
- pathname: notFoundRoute,
1146
- query,
1147
- as,
1148
- resolvedAs,
1149
- routeProps: {
1150
- shallow: false
1151
- },
1152
- locale: nextState.locale,
1153
- isPreview: nextState.isPreview,
1154
- isNotFound: true
1155
- });
1156
- if ('type' in routeInfo) {
1157
- throw Object.defineProperty(new Error(`Unexpected middleware effect on /404`), "__NEXT_ERROR_CODE", {
1158
- value: "E158",
1159
- enumerable: false,
1160
- configurable: true
1161
- });
1162
- }
1163
- }
1164
- }
1165
- if (isQueryUpdating && this.pathname === '/_error' && self.__NEXT_DATA__.props?.pageProps?.statusCode === 500 && routeInfo.props?.pageProps) {
1166
- // ensure statusCode is still correct for static 500 page
1167
- // when updating query information
1168
- routeInfo.props.pageProps.statusCode = 500;
1169
- }
1170
- // shallow routing is only allowed for same page URL changes.
1171
- const isValidShallowRoute = options.shallow && nextState.route === (routeInfo.route ?? route);
1172
- const shouldScroll = options.scroll ?? (!isQueryUpdating && !isValidShallowRoute);
1173
- const resetScroll = shouldScroll ? {
1174
- x: 0,
1175
- y: 0
1176
- } : null;
1177
- const upcomingScrollState = forcedScroll ?? resetScroll;
1178
- // the new state that the router gonna set
1179
- const upcomingRouterState = {
1180
- ...nextState,
1181
- route,
1182
- pathname,
1183
- query,
1184
- asPath: cleanedAs,
1185
- isFallback: false
1186
- };
1187
- // When the page being rendered is the 404 page, we should only update the
1188
- // query parameters. Route changes here might add the basePath when it
1189
- // wasn't originally present. This is also why this block is before the
1190
- // below `changeState` call which updates the browser's history (changing
1191
- // the URL).
1192
- if (isQueryUpdating && isErrorRoute) {
1193
- routeInfo = await this.getRouteInfo({
1194
- route: this.pathname,
1195
- pathname: this.pathname,
1196
- query,
1197
- as,
1198
- resolvedAs,
1199
- routeProps: {
1200
- shallow: false
1201
- },
1202
- locale: nextState.locale,
1203
- isPreview: nextState.isPreview,
1204
- isQueryUpdating: isQueryUpdating && !this.isFallback
1205
- });
1206
- if ('type' in routeInfo) {
1207
- throw Object.defineProperty(new Error(`Unexpected middleware effect on ${this.pathname}`), "__NEXT_ERROR_CODE", {
1208
- value: "E225",
1209
- enumerable: false,
1210
- configurable: true
1211
- });
1212
- }
1213
- if (this.pathname === '/_error' && self.__NEXT_DATA__.props?.pageProps?.statusCode === 500 && routeInfo.props?.pageProps) {
1214
- // ensure statusCode is still correct for static 500 page
1215
- // when updating query information
1216
- routeInfo.props.pageProps.statusCode = 500;
1217
- }
1218
- try {
1219
- await this.set(upcomingRouterState, routeInfo, upcomingScrollState);
1220
- } catch (err) {
1221
- if ((0, _iserror.default)(err) && err.cancelled) {
1222
- Router.events.emit('routeChangeError', err, cleanedAs, routeProps);
1223
- }
1224
- throw err;
1225
- }
1226
- return true;
1227
- }
1228
- Router.events.emit('beforeHistoryChange', as, routeProps);
1229
- this.changeState(method, url, as, options);
1230
- // for query updates we can skip it if the state is unchanged and we don't
1231
- // need to scroll
1232
- // https://github.com/vercel/next.js/issues/37139
1233
- const canSkipUpdating = isQueryUpdating && !upcomingScrollState && !readyStateChange && !localeChange && (0, _comparestates.compareRouterStates)(upcomingRouterState, this.state);
1234
- if (!canSkipUpdating) {
1235
- try {
1236
- await this.set(upcomingRouterState, routeInfo, upcomingScrollState);
1237
- } catch (e) {
1238
- if (e.cancelled) routeInfo.error = routeInfo.error || e;
1239
- else throw e;
1240
- }
1241
- if (routeInfo.error) {
1242
- if (!isQueryUpdating) {
1243
- Router.events.emit('routeChangeError', routeInfo.error, cleanedAs, routeProps);
1244
- }
1245
- throw routeInfo.error;
1246
- }
1247
- if (process.env.__NEXT_I18N_SUPPORT) {
1248
- if (nextState.locale) {
1249
- document.documentElement.lang = nextState.locale;
1250
- }
1251
- }
1252
- if (!isQueryUpdating) {
1253
- Router.events.emit('routeChangeComplete', as, routeProps);
1254
- }
1255
- // A hash mark # is the optional last part of a URL
1256
- const hashRegex = /#.+$/;
1257
- if (shouldScroll && hashRegex.test(as)) {
1258
- this.scrollToHash(as);
1259
- }
1260
- }
1261
- return true;
1262
- } catch (err) {
1263
- if ((0, _iserror.default)(err) && err.cancelled) {
1264
- return false;
1265
- }
1266
- throw err;
1267
- }
1268
- }
1269
- changeState(method, url, as, options = {}) {
1270
- if (process.env.NODE_ENV !== 'production') {
1271
- if (typeof window.history === 'undefined') {
1272
- console.error(`Warning: window.history is not available.`);
1273
- return;
1274
- }
1275
- if (typeof window.history[method] === 'undefined') {
1276
- console.error(`Warning: window.history.${method} is not available`);
1277
- return;
1278
- }
1279
- }
1280
- if (method !== 'pushState' || (0, _utils.getURL)() !== as) {
1281
- this._shallow = options.shallow;
1282
- window.history[method]({
1283
- url,
1284
- as,
1285
- options,
1286
- __N: true,
1287
- key: this._key = method !== 'pushState' ? this._key : createKey()
1288
- }, // Most browsers currently ignores this parameter, although they may use it in the future.
1289
- // Passing the empty string here should be safe against future changes to the method.
1290
- // https://developer.mozilla.org/docs/Web/API/History/replaceState
1291
- '', as);
1292
- }
1293
- }
1294
- async handleRouteInfoError(err, pathname, query, as, routeProps, loadErrorFail) {
1295
- if (err.cancelled) {
1296
- // bubble up cancellation errors
1297
- throw err;
1298
- }
1299
- if ((0, _routeloader.isAssetError)(err) || loadErrorFail) {
1300
- Router.events.emit('routeChangeError', err, as, routeProps);
1301
- // If we can't load the page it could be one of following reasons
1302
- // 1. Page doesn't exists
1303
- // 2. Page does exist in a different zone
1304
- // 3. Internal error while loading the page
1305
- // So, doing a hard reload is the proper way to deal with this.
1306
- handleHardNavigation({
1307
- url: as,
1308
- router: this
1309
- });
1310
- // Changing the URL doesn't block executing the current code path.
1311
- // So let's throw a cancellation error stop the routing logic.
1312
- throw buildCancellationError();
1313
- }
1314
- console.error(err);
1315
- try {
1316
- let props;
1317
- const { page: Component, styleSheets } = await this.fetchComponent('/_error');
1318
- const routeInfo = {
1319
- props,
1320
- Component,
1321
- styleSheets,
1322
- err,
1323
- error: err
1324
- };
1325
- if (!routeInfo.props) {
1326
- try {
1327
- routeInfo.props = await this.getInitialProps(Component, {
1328
- err,
1329
- pathname,
1330
- query
1331
- });
1332
- } catch (gipErr) {
1333
- console.error('Error in error page `getInitialProps`: ', gipErr);
1334
- routeInfo.props = {};
1335
- }
1336
- }
1337
- return routeInfo;
1338
- } catch (routeInfoErr) {
1339
- return this.handleRouteInfoError((0, _iserror.default)(routeInfoErr) ? routeInfoErr : Object.defineProperty(new Error(routeInfoErr + ''), "__NEXT_ERROR_CODE", {
1340
- value: "E394",
1341
- enumerable: false,
1342
- configurable: true
1343
- }), pathname, query, as, routeProps, true);
1344
- }
1345
- }
1346
- async getRouteInfo({ route: requestedRoute, pathname, query, as, resolvedAs, routeProps, locale, hasMiddleware, isPreview, unstable_skipClientCache, isQueryUpdating, isMiddlewareRewrite, isNotFound }) {
1347
- /**
1348
- * This `route` binding can change if there's a rewrite
1349
- * so we keep a reference to the original requested route
1350
- * so we can store the cache for it and avoid re-requesting every time
1351
- * for shallow routing purposes.
1352
- */ let route = requestedRoute;
1353
- try {
1354
- let existingInfo = this.components[route];
1355
- if (routeProps.shallow && existingInfo && this.route === route) {
1356
- return existingInfo;
1357
- }
1358
- const handleCancelled = getCancelledHandler({
1359
- route,
1360
- router: this
1361
- });
1362
- if (hasMiddleware) {
1363
- existingInfo = undefined;
1364
- }
1365
- let cachedRouteInfo = existingInfo && !('initial' in existingInfo) && process.env.NODE_ENV !== 'development' ? existingInfo : undefined;
1366
- const isBackground = isQueryUpdating;
1367
- const fetchNextDataParams = {
1368
- dataHref: this.pageLoader.getDataHref({
1369
- href: (0, _formaturl.formatWithValidation)({
1370
- pathname,
1371
- query
1372
- }),
1373
- skipInterpolation: true,
1374
- asPath: isNotFound ? '/404' : resolvedAs,
1375
- locale
1376
- }),
1377
- hasMiddleware: true,
1378
- isServerRender: this.isSsr,
1379
- parseJSON: true,
1380
- inflightCache: isBackground ? this.sbc : this.sdc,
1381
- persistCache: !isPreview,
1382
- isPrefetch: false,
1383
- unstable_skipClientCache,
1384
- isBackground
1385
- };
1386
- let data = isQueryUpdating && !isMiddlewareRewrite ? null : await withMiddlewareEffects({
1387
- fetchData: ()=>fetchNextData(fetchNextDataParams),
1388
- asPath: isNotFound ? '/404' : resolvedAs,
1389
- locale: locale,
1390
- router: this
1391
- }).catch((err)=>{
1392
- // we don't hard error during query updating
1393
- // as it's un-necessary and doesn't need to be fatal
1394
- // unless it is a fallback route and the props can't
1395
- // be loaded
1396
- if (isQueryUpdating) {
1397
- return null;
1398
- }
1399
- throw err;
1400
- });
1401
- // when rendering error routes we don't apply middleware
1402
- // effects
1403
- if (data && (pathname === '/_error' || pathname === '/404')) {
1404
- data.effect = undefined;
1405
- }
1406
- if (isQueryUpdating) {
1407
- if (!data) {
1408
- data = {
1409
- json: self.__NEXT_DATA__.props
1410
- };
1411
- } else {
1412
- data.json = self.__NEXT_DATA__.props;
1413
- }
1414
- }
1415
- handleCancelled();
1416
- if (data?.effect?.type === 'redirect-internal' || data?.effect?.type === 'redirect-external') {
1417
- return data.effect;
1418
- }
1419
- if (data?.effect?.type === 'rewrite') {
1420
- const resolvedRoute = (0, _removetrailingslash.removeTrailingSlash)(data.effect.resolvedHref);
1421
- const pages = await this.pageLoader.getPageList();
1422
- // during query updating the page must match although during
1423
- // client-transition a redirect that doesn't match a page
1424
- // can be returned and this should trigger a hard navigation
1425
- // which is valid for incremental migration
1426
- if (!isQueryUpdating || pages.includes(resolvedRoute)) {
1427
- route = resolvedRoute;
1428
- pathname = data.effect.resolvedHref;
1429
- query = {
1430
- ...query,
1431
- ...data.effect.parsedAs.query
1432
- };
1433
- resolvedAs = (0, _removebasepath.removeBasePath)((0, _normalizelocalepath.normalizeLocalePath)(data.effect.parsedAs.pathname, this.locales).pathname);
1434
- // Check again the cache with the new destination.
1435
- existingInfo = this.components[route];
1436
- if (routeProps.shallow && existingInfo && this.route === route && !hasMiddleware) {
1437
- // If we have a match with the current route due to rewrite,
1438
- // we can copy the existing information to the rewritten one.
1439
- // Then, we return the information along with the matched route.
1440
- return {
1441
- ...existingInfo,
1442
- route
1443
- };
1444
- }
1445
- }
1446
- }
1447
- if ((0, _isapiroute.isAPIRoute)(route)) {
1448
- handleHardNavigation({
1449
- url: as,
1450
- router: this
1451
- });
1452
- return new Promise(()=>{});
1453
- }
1454
- const routeInfo = cachedRouteInfo || await this.fetchComponent(route).then((res)=>({
1455
- Component: res.page,
1456
- styleSheets: res.styleSheets,
1457
- __N_SSG: res.mod.__N_SSG,
1458
- __N_SSP: res.mod.__N_SSP
1459
- }));
1460
- if (process.env.NODE_ENV !== 'production') {
1461
- const { isValidElementType } = index.__require();
1462
- if (!isValidElementType(routeInfo.Component)) {
1463
- throw Object.defineProperty(new Error(`The default export is not a React Component in page: "${pathname}"`), "__NEXT_ERROR_CODE", {
1464
- value: "E286",
1465
- enumerable: false,
1466
- configurable: true
1467
- });
1468
- }
1469
- }
1470
- const wasBailedPrefetch = data?.response?.headers.get('x-middleware-skip');
1471
- const shouldFetchData = routeInfo.__N_SSG || routeInfo.__N_SSP;
1472
- // For non-SSG prefetches that bailed before sending data
1473
- // we clear the cache to fetch full response
1474
- if (wasBailedPrefetch && data?.dataHref) {
1475
- delete this.sdc[data.dataHref];
1476
- }
1477
- const { props, cacheKey } = await this._getData(async ()=>{
1478
- if (shouldFetchData) {
1479
- if (data?.json && !wasBailedPrefetch) {
1480
- return {
1481
- cacheKey: data.cacheKey,
1482
- props: data.json
1483
- };
1484
- }
1485
- const dataHref = data?.dataHref ? data.dataHref : this.pageLoader.getDataHref({
1486
- href: (0, _formaturl.formatWithValidation)({
1487
- pathname,
1488
- query
1489
- }),
1490
- asPath: resolvedAs,
1491
- locale
1492
- });
1493
- const fetched = await fetchNextData({
1494
- dataHref,
1495
- isServerRender: this.isSsr,
1496
- parseJSON: true,
1497
- inflightCache: wasBailedPrefetch ? {} : this.sdc,
1498
- persistCache: !isPreview,
1499
- isPrefetch: false,
1500
- unstable_skipClientCache
1501
- });
1502
- return {
1503
- cacheKey: fetched.cacheKey,
1504
- props: fetched.json || {}
1505
- };
1506
- }
1507
- return {
1508
- headers: {},
1509
- props: await this.getInitialProps(routeInfo.Component, // we provide AppTree later so this needs to be `any`
1510
- {
1511
- pathname,
1512
- query,
1513
- asPath: as,
1514
- locale,
1515
- locales: this.locales,
1516
- defaultLocale: this.defaultLocale
1517
- })
1518
- };
1519
- });
1520
- // Only bust the data cache for SSP routes although
1521
- // middleware can skip cache per request with
1522
- // x-middleware-cache: no-cache as well
1523
- if (routeInfo.__N_SSP && fetchNextDataParams.dataHref && cacheKey) {
1524
- delete this.sdc[cacheKey];
1525
- }
1526
- // we kick off a HEAD request in the background
1527
- // when a non-prefetch request is made to signal revalidation
1528
- if (!this.isPreview && routeInfo.__N_SSG && process.env.NODE_ENV !== 'development' && !isQueryUpdating) {
1529
- fetchNextData(Object.assign({}, fetchNextDataParams, {
1530
- isBackground: true,
1531
- persistCache: false,
1532
- inflightCache: this.sbc
1533
- })).catch(()=>{});
1534
- }
1535
- props.pageProps = Object.assign({}, props.pageProps);
1536
- routeInfo.props = props;
1537
- routeInfo.route = route;
1538
- routeInfo.query = query;
1539
- routeInfo.resolvedAs = resolvedAs;
1540
- this.components[route] = routeInfo;
1541
- return routeInfo;
1542
- } catch (err) {
1543
- return this.handleRouteInfoError((0, _iserror.getProperError)(err), pathname, query, as, routeProps);
1544
- }
1545
- }
1546
- set(state, data, resetScroll) {
1547
- this.state = state;
1548
- return this.sub(data, this.components['/_app'].Component, resetScroll);
1549
- }
1550
- /**
1551
- * Callback to execute before replacing router state
1552
- * @param cb callback to be executed
1553
- */ beforePopState(cb) {
1554
- this._bps = cb;
1555
- }
1556
- onlyAHashChange(as) {
1557
- if (!this.asPath) return false;
1558
- const [oldUrlNoHash, oldHash] = this.asPath.split('#', 2);
1559
- const [newUrlNoHash, newHash] = as.split('#', 2);
1560
- // Makes sure we scroll to the provided hash if the url/hash are the same
1561
- if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
1562
- return true;
1563
- }
1564
- // If the urls are change, there's more than a hash change
1565
- if (oldUrlNoHash !== newUrlNoHash) {
1566
- return false;
1567
- }
1568
- // If the hash has changed, then it's a hash only change.
1569
- // This check is necessary to handle both the enter and
1570
- // leave hash === '' cases. The identity case falls through
1571
- // and is treated as a next reload.
1572
- return oldHash !== newHash;
1573
- }
1574
- scrollToHash(as) {
1575
- const [, hash = ''] = as.split('#', 2);
1576
- (0, _disablesmoothscroll.disableSmoothScrollDuringRouteTransition)(()=>{
1577
- // Scroll to top if the hash is just `#` with no value or `#top`
1578
- // To mirror browsers
1579
- if (hash === '' || hash === 'top') {
1580
- window.scrollTo(0, 0);
1581
- return;
1582
- }
1583
- // Decode hash to make non-latin anchor works.
1584
- const rawHash = decodeURIComponent(hash);
1585
- // First we check if the element by id is found
1586
- const idEl = document.getElementById(rawHash);
1587
- if (idEl) {
1588
- idEl.scrollIntoView();
1589
- return;
1590
- }
1591
- // If there's no element with the id, we check the `name` property
1592
- // To mirror browsers
1593
- const nameEl = document.getElementsByName(rawHash)[0];
1594
- if (nameEl) {
1595
- nameEl.scrollIntoView();
1596
- }
1597
- }, {
1598
- onlyHashChange: this.onlyAHashChange(as)
1599
- });
1600
- }
1601
- urlIsNew(asPath) {
1602
- return this.asPath !== asPath;
1603
- }
1604
- /**
1605
- * Prefetch page code, you may wait for the data during page rendering.
1606
- * This feature only works in production!
1607
- * @param url the href of prefetched page
1608
- * @param asPath the as path of the prefetched page
1609
- */ async prefetch(url, asPath = url, options = {}) {
1610
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
1611
- if (process.env.NODE_ENV !== 'production') {
1612
- return;
1613
- }
1614
- if (typeof window !== 'undefined' && (0, _isbot.isBot)(window.navigator.userAgent)) {
1615
- // No prefetches for bots that render the link since they are typically navigating
1616
- // links via the equivalent of a hard navigation and hence never utilize these
1617
- // prefetches.
1618
- return;
1619
- }
1620
- let parsed = (0, _parserelativeurl.parseRelativeUrl)(url);
1621
- const urlPathname = parsed.pathname;
1622
- let { pathname, query } = parsed;
1623
- const originalPathname = pathname;
1624
- if (process.env.__NEXT_I18N_SUPPORT) {
1625
- if (options.locale === false) {
1626
- pathname = (0, _normalizelocalepath.normalizeLocalePath)(pathname, this.locales).pathname;
1627
- parsed.pathname = pathname;
1628
- url = (0, _formaturl.formatWithValidation)(parsed);
1629
- let parsedAs = (0, _parserelativeurl.parseRelativeUrl)(asPath);
1630
- const localePathResult = (0, _normalizelocalepath.normalizeLocalePath)(parsedAs.pathname, this.locales);
1631
- parsedAs.pathname = localePathResult.pathname;
1632
- options.locale = localePathResult.detectedLocale || this.defaultLocale;
1633
- asPath = (0, _formaturl.formatWithValidation)(parsedAs);
1634
- }
1635
- }
1636
- const pages = await this.pageLoader.getPageList();
1637
- let resolvedAs = asPath;
1638
- const locale = typeof options.locale !== 'undefined' ? options.locale || undefined : this.locale;
1639
- const isMiddlewareMatch = await matchesMiddleware({
1640
- asPath: asPath,
1641
- locale: locale,
1642
- router: this
1643
- });
1644
- if (process.env.__NEXT_HAS_REWRITES && asPath.startsWith('/')) {
1645
- let rewrites;
1646
- ({ __rewrites: rewrites } = await (0, _routeloader.getClientBuildManifest)());
1647
- const rewritesResult = resolveRewrites$1((0, _addbasepath.addBasePath)((0, _addlocale.addLocale)(asPath, this.locale), true), pages, rewrites, parsed.query, (p)=>resolveDynamicRoute(p, pages), this.locales);
1648
- if (rewritesResult.externalDest) {
1649
- return;
1650
- }
1651
- if (!isMiddlewareMatch) {
1652
- resolvedAs = (0, _removelocale.removeLocale)((0, _removebasepath.removeBasePath)(rewritesResult.asPath), this.locale);
1653
- }
1654
- if (rewritesResult.matchedPage && rewritesResult.resolvedHref) {
1655
- // if this directly matches a page we need to update the href to
1656
- // allow the correct page chunk to be loaded
1657
- pathname = rewritesResult.resolvedHref;
1658
- parsed.pathname = pathname;
1659
- if (!isMiddlewareMatch) {
1660
- url = (0, _formaturl.formatWithValidation)(parsed);
1661
- }
1662
- }
1663
- }
1664
- parsed.pathname = resolveDynamicRoute(parsed.pathname, pages);
1665
- if ((0, _isdynamic.isDynamicRoute)(parsed.pathname)) {
1666
- pathname = parsed.pathname;
1667
- parsed.pathname = pathname;
1668
- Object.assign(query, (0, _routematcher.getRouteMatcher)((0, _routeregex.getRouteRegex)(parsed.pathname))((0, _parsepath.parsePath)(asPath).pathname) || {});
1669
- if (!isMiddlewareMatch) {
1670
- url = (0, _formaturl.formatWithValidation)(parsed);
1671
- }
1672
- }
1673
- const data = process.env.__NEXT_MIDDLEWARE_PREFETCH === 'strict' ? null : await withMiddlewareEffects({
1674
- fetchData: ()=>fetchNextData({
1675
- dataHref: this.pageLoader.getDataHref({
1676
- href: (0, _formaturl.formatWithValidation)({
1677
- pathname: originalPathname,
1678
- query
1679
- }),
1680
- skipInterpolation: true,
1681
- asPath: resolvedAs,
1682
- locale
1683
- }),
1684
- hasMiddleware: true,
1685
- isServerRender: false,
1686
- parseJSON: true,
1687
- inflightCache: this.sdc,
1688
- persistCache: !this.isPreview,
1689
- isPrefetch: true
1690
- }),
1691
- asPath: asPath,
1692
- locale: locale,
1693
- router: this
1694
- });
1695
- /**
1696
- * If there was a rewrite we apply the effects of the rewrite on the
1697
- * current parameters for the prefetch.
1698
- */ if (data?.effect.type === 'rewrite') {
1699
- parsed.pathname = data.effect.resolvedHref;
1700
- pathname = data.effect.resolvedHref;
1701
- query = {
1702
- ...query,
1703
- ...data.effect.parsedAs.query
1704
- };
1705
- resolvedAs = data.effect.parsedAs.pathname;
1706
- url = (0, _formaturl.formatWithValidation)(parsed);
1707
- }
1708
- /**
1709
- * If there is a redirect to an external destination then we don't have
1710
- * to prefetch content as it will be unused.
1711
- */ if (data?.effect.type === 'redirect-external') {
1712
- return;
1713
- }
1714
- const route = (0, _removetrailingslash.removeTrailingSlash)(pathname);
1715
- if (await this._bfl(asPath, resolvedAs, options.locale, true)) {
1716
- this.components[urlPathname] = {
1717
- __appRouter: true
1718
- };
1719
- }
1720
- await Promise.all([
1721
- this.pageLoader._isSsg(route).then((isSsg)=>{
1722
- return isSsg ? fetchNextData({
1723
- dataHref: data?.json ? data?.dataHref : this.pageLoader.getDataHref({
1724
- href: url,
1725
- asPath: resolvedAs,
1726
- locale: locale
1727
- }),
1728
- isServerRender: false,
1729
- parseJSON: true,
1730
- inflightCache: this.sdc,
1731
- persistCache: !this.isPreview,
1732
- isPrefetch: true,
1733
- unstable_skipClientCache: options.unstable_skipClientCache || options.priority && !!process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE
1734
- }).then(()=>false).catch(()=>false) : false;
1735
- }),
1736
- this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)
1737
- ]);
1738
- }
1739
- async fetchComponent(route) {
1740
- const handleCancelled = getCancelledHandler({
1741
- route,
1742
- router: this
1743
- });
1744
- try {
1745
- const componentResult = await this.pageLoader.loadPage(route);
1746
- handleCancelled();
1747
- return componentResult;
1748
- } catch (err) {
1749
- handleCancelled();
1750
- throw err;
1751
- }
1752
- }
1753
- _getData(fn) {
1754
- let cancelled = false;
1755
- const cancel = ()=>{
1756
- cancelled = true;
1757
- };
1758
- this.clc = cancel;
1759
- return fn().then((data)=>{
1760
- if (cancel === this.clc) {
1761
- this.clc = null;
1762
- }
1763
- if (cancelled) {
1764
- const err = Object.defineProperty(new Error('Loading initial props cancelled'), "__NEXT_ERROR_CODE", {
1765
- value: "E405",
1766
- enumerable: false,
1767
- configurable: true
1768
- });
1769
- err.cancelled = true;
1770
- throw err;
1771
- }
1772
- return data;
1773
- });
1774
- }
1775
- getInitialProps(Component, ctx) {
1776
- const { Component: App } = this.components['/_app'];
1777
- const AppTree = this._wrapApp(App);
1778
- ctx.AppTree = AppTree;
1779
- return (0, _utils.loadGetInitialProps)(App, {
1780
- AppTree,
1781
- Component,
1782
- router: this,
1783
- ctx
1784
- });
1785
- }
1786
- get route() {
1787
- return this.state.route;
1788
- }
1789
- get pathname() {
1790
- return this.state.pathname;
1791
- }
1792
- get query() {
1793
- return this.state.query;
1794
- }
1795
- get asPath() {
1796
- return this.state.asPath;
1797
- }
1798
- get locale() {
1799
- return this.state.locale;
1800
- }
1801
- get isFallback() {
1802
- return this.state.isFallback;
1803
- }
1804
- get isPreview() {
1805
- return this.state.isPreview;
1806
- }
1807
- }
1808
-
1809
-
1810
- } (router.__exports));
1811
- return router.__exports;
1812
- }
1813
-
1814
- exports.__require = requireRouter;