vike 0.4.239-commit-59f1017 → 0.4.239-commit-9dcde6d

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 (429) hide show
  1. package/dist/esm/client/index.d.ts +1 -1
  2. package/dist/esm/client/index.js +1 -1
  3. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
  4. package/dist/esm/client/runtime-client-routing/entry.js +5 -3
  5. package/dist/esm/client/runtime-client-routing/getBaseServer.js +0 -1
  6. package/dist/esm/client/runtime-client-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +1 -1
  7. package/dist/esm/client/runtime-client-routing/{globalContext.js → getGlobalContextClientInternal.js} +8 -4
  8. package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +4 -4
  9. package/dist/esm/client/runtime-client-routing/isClientSideRoutable.d.ts +1 -1
  10. package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +1 -1
  11. package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +2 -4
  12. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
  13. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
  14. package/dist/esm/client/runtime-server-routing/entry.js +5 -3
  15. package/dist/esm/client/runtime-server-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +2 -2
  16. package/dist/esm/client/runtime-server-routing/getGlobalContextClientInternal.js +6 -0
  17. package/dist/esm/client/shared/execHookOnRenderClient.d.ts +1 -1
  18. package/dist/esm/client/shared/{createGetGlobalContextClient.d.ts → getGlobalContextClientInternalShared.d.ts} +11 -8
  19. package/dist/esm/client/shared/getGlobalContextClientInternalShared.js +66 -0
  20. package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +1 -3
  21. package/dist/esm/node/prerender/runPrerender.js +3 -1
  22. package/dist/esm/node/vite/index.js +34 -15
  23. package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
  24. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +37 -35
  25. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.d.ts +1 -1
  26. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +82 -80
  27. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.d.ts +1 -1
  28. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +23 -21
  29. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.d.ts +1 -1
  30. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +38 -36
  31. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.d.ts +1 -1
  32. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +26 -24
  33. package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
  34. package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +1 -1
  35. package/dist/esm/node/vite/plugins/pluginEnvVars.js +87 -65
  36. package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
  37. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +29 -27
  38. package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
  39. package/dist/esm/node/vite/plugins/pluginFileEnv.js +75 -73
  40. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +1 -1
  41. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +30 -28
  42. package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
  43. package/dist/esm/node/vite/plugins/pluginPreview.js +35 -33
  44. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +9 -0
  45. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +45 -0
  46. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +3 -0
  47. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.js +89 -0
  48. package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
  49. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +50 -48
  50. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
  51. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +12 -10
  52. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
  53. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
  54. package/dist/esm/shared/createGlobalContextShared.d.ts +1 -1
  55. package/dist/esm/shared/route/abort.d.ts +22 -11
  56. package/dist/esm/shared/route/abort.js +37 -5
  57. package/dist/esm/types/PageContext.d.ts +8 -8
  58. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  59. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  60. package/dist/esm/utils/findPackageJson.js +0 -1
  61. package/dist/esm/utils/getViteRPC.js +0 -2
  62. package/dist/esm/utils/requireResolve.js +0 -1
  63. package/package.json +2 -21
  64. package/dist/cjs/__internal/index.js +0 -35
  65. package/dist/cjs/client/runtime-client-routing/globalContext.js +0 -49
  66. package/dist/cjs/client/runtime-client-routing/prefetch/PrefetchSetting.js +0 -2
  67. package/dist/cjs/client/runtime-server-routing/globalContext.js +0 -41
  68. package/dist/cjs/client/runtime-server-routing/onLoad.js +0 -7
  69. package/dist/cjs/client/runtime-server-routing/utils.js +0 -34
  70. package/dist/cjs/client/shared/createGetGlobalContextClient.js +0 -65
  71. package/dist/cjs/client/shared/getJsonSerializedInHtml.js +0 -40
  72. package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +0 -41
  73. package/dist/cjs/client/shared/utils.js +0 -23
  74. package/dist/cjs/node/api/build.js +0 -24
  75. package/dist/cjs/node/api/context.js +0 -23
  76. package/dist/cjs/node/api/dev.js +0 -18
  77. package/dist/cjs/node/api/index.js +0 -44
  78. package/dist/cjs/node/api/onLoad.js +0 -9
  79. package/dist/cjs/node/api/prepareViteApiCall.js +0 -206
  80. package/dist/cjs/node/api/prerender.js +0 -18
  81. package/dist/cjs/node/api/preview.js +0 -38
  82. package/dist/cjs/node/api/types.js +0 -2
  83. package/dist/cjs/node/api/utils.js +0 -27
  84. package/dist/cjs/node/cli/context.js +0 -17
  85. package/dist/cjs/node/cli/entry.js +0 -121
  86. package/dist/cjs/node/cli/index.js +0 -12
  87. package/dist/cjs/node/cli/onLoad.js +0 -9
  88. package/dist/cjs/node/cli/parseCli.js +0 -95
  89. package/dist/cjs/node/cli/utils.js +0 -24
  90. package/dist/cjs/node/client/router.js +0 -19
  91. package/dist/cjs/node/createPageRenderer.js +0 -132
  92. package/dist/cjs/node/importBuild.js +0 -3
  93. package/dist/cjs/node/prerender/context.js +0 -26
  94. package/dist/cjs/node/prerender/index.js +0 -12
  95. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +0 -66
  96. package/dist/cjs/node/prerender/runPrerender.js +0 -778
  97. package/dist/cjs/node/prerender/runPrerenderEntry.js +0 -55
  98. package/dist/cjs/node/prerender/utils.js +0 -37
  99. package/dist/cjs/node/runtime/globalContext.js +0 -582
  100. package/dist/cjs/node/runtime/index-deprecated.js +0 -33
  101. package/dist/cjs/node/runtime/index.js +0 -74
  102. package/dist/cjs/node/runtime/loggerRuntime.js +0 -17
  103. package/dist/cjs/node/runtime/onLoad.js +0 -29
  104. package/dist/cjs/node/runtime/page-files/setup.js +0 -5
  105. package/dist/cjs/node/runtime/renderPage/analyzePage.js +0 -71
  106. package/dist/cjs/node/runtime/renderPage/assertArguments.js +0 -42
  107. package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +0 -51
  108. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -114
  109. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +0 -59
  110. package/dist/cjs/node/runtime/renderPage/csp.js +0 -47
  111. package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +0 -31
  112. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +0 -120
  113. package/dist/cjs/node/runtime/renderPage/execHookServer.js +0 -8
  114. package/dist/cjs/node/runtime/renderPage/getCacheControl.js +0 -24
  115. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +0 -20
  116. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +0 -137
  117. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +0 -125
  118. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.js +0 -86
  119. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.js +0 -77
  120. package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +0 -36
  121. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +0 -50
  122. package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +0 -41
  123. package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +0 -68
  124. package/dist/cjs/node/runtime/renderPage/headersResponse.js +0 -48
  125. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getHtmlTags.js +0 -269
  126. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getViteDevScript.js +0 -32
  127. package/dist/cjs/node/runtime/renderPage/html/injectAssets/inferHtmlTags.js +0 -55
  128. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectAssets__public.js +0 -31
  129. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectHtmlTags.js +0 -161
  130. package/dist/cjs/node/runtime/renderPage/html/injectAssets/mergeScriptTags.js +0 -73
  131. package/dist/cjs/node/runtime/renderPage/html/injectAssets/sanitizeJson.js +0 -8
  132. package/dist/cjs/node/runtime/renderPage/html/injectAssets.js +0 -93
  133. package/dist/cjs/node/runtime/renderPage/html/propKeys.js +0 -47
  134. package/dist/cjs/node/runtime/renderPage/html/renderHtml.js +0 -245
  135. package/dist/cjs/node/runtime/renderPage/html/serializeContext.js +0 -189
  136. package/dist/cjs/node/runtime/renderPage/html/stream/react-streaming.js +0 -36
  137. package/dist/cjs/node/runtime/renderPage/html/stream.js +0 -829
  138. package/dist/cjs/node/runtime/renderPage/inferMediaType.js +0 -81
  139. package/dist/cjs/node/runtime/renderPage/isFontFallback.js +0 -29
  140. package/dist/cjs/node/runtime/renderPage/isNewError.js +0 -25
  141. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +0 -124
  142. package/dist/cjs/node/runtime/renderPage/log404/index.js +0 -154
  143. package/dist/cjs/node/runtime/renderPage/logErrorHint/errors.js +0 -20
  144. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +0 -200
  145. package/dist/cjs/node/runtime/renderPage/loggerProd.js +0 -34
  146. package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +0 -10
  147. package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +0 -83
  148. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -71
  149. package/dist/cjs/node/runtime/renderPage.js +0 -502
  150. package/dist/cjs/node/runtime/universal-middleware.js +0 -20
  151. package/dist/cjs/node/runtime/utils.js +0 -83
  152. package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -27
  153. package/dist/cjs/node/runtime-dev/index.js +0 -42
  154. package/dist/cjs/node/shared/assertV1Design.js +0 -30
  155. package/dist/cjs/node/shared/extractAssetsQuery.js +0 -29
  156. package/dist/cjs/node/shared/getVikeConfigError.js +0 -22
  157. package/dist/cjs/node/shared/isErrorDebug.js +0 -7
  158. package/dist/cjs/node/shared/prependEntriesDir.js +0 -13
  159. package/dist/cjs/node/shared/resolveBase.js +0 -35
  160. package/dist/cjs/node/shared/utils.js +0 -35
  161. package/dist/cjs/node/shared/virtualFileId.js +0 -110
  162. package/dist/cjs/node/vite/index.js +0 -69
  163. package/dist/cjs/node/vite/onLoad.js +0 -21
  164. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +0 -52
  165. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -357
  166. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -183
  167. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -234
  168. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -256
  169. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -40
  170. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -49
  171. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -111
  172. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -65
  173. package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -22
  174. package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
  175. package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -183
  176. package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -28
  177. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +0 -163
  178. package/dist/cjs/node/vite/plugins/pluginDev.js +0 -111
  179. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -92
  180. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -241
  181. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -113
  182. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -172
  183. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -70
  184. package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -82
  185. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -95
  186. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -51
  187. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/debug.js +0 -5
  188. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +0 -56
  189. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +0 -190
  190. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +0 -54
  191. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +0 -97
  192. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +0 -233
  193. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -17
  194. package/dist/cjs/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +0 -35
  195. package/dist/cjs/node/vite/shared/addSsrMiddleware.js +0 -60
  196. package/dist/cjs/node/vite/shared/findPageFiles.js +0 -25
  197. package/dist/cjs/node/vite/shared/getAssetsDir.js +0 -10
  198. package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +0 -42
  199. package/dist/cjs/node/vite/shared/getEnvVarObject.js +0 -37
  200. package/dist/cjs/node/vite/shared/getFilePath.js +0 -172
  201. package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +0 -125
  202. package/dist/cjs/node/vite/shared/getMagicString.js +0 -18
  203. package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +0 -10
  204. package/dist/cjs/node/vite/shared/getOutDirs.js +0 -146
  205. package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +0 -21
  206. package/dist/cjs/node/vite/shared/isAsset.js +0 -40
  207. package/dist/cjs/node/vite/shared/isViteCliCall.js +0 -83
  208. package/dist/cjs/node/vite/shared/isViteServerSide.js +0 -68
  209. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +0 -15
  210. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.js +0 -15
  211. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +0 -38
  212. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.js +0 -26
  213. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.js +0 -85
  214. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.js +0 -30
  215. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.js +0 -19
  216. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.js +0 -19
  217. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +0 -29
  218. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.js +0 -13
  219. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.js +0 -15
  220. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +0 -162
  221. package/dist/cjs/node/vite/shared/loggerNotProd/log.js +0 -102
  222. package/dist/cjs/node/vite/shared/loggerNotProd.js +0 -208
  223. package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -26
  224. package/dist/cjs/node/vite/shared/loggerVite.js +0 -54
  225. package/dist/cjs/node/vite/shared/normalizeId.js +0 -9
  226. package/dist/cjs/node/vite/shared/parseEsModule.js +0 -33
  227. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +0 -136
  228. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -262
  229. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles/ignorePatternsBuiltIn.js +0 -18
  230. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +0 -252
  231. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +0 -190
  232. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getConfigFileExport.js +0 -17
  233. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getPlusFilesAll.js +0 -127
  234. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.js +0 -129
  235. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +0 -195
  236. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +0 -102
  237. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +0 -425
  238. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +0 -1151
  239. package/dist/cjs/node/vite/shared/rollupIsEsm.js +0 -15
  240. package/dist/cjs/node/vite/utils.js +0 -45
  241. package/dist/cjs/package.json +0 -1
  242. package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -4
  243. package/dist/cjs/shared/RenderErrorPage.js +0 -6
  244. package/dist/cjs/shared/abort.js +0 -16
  245. package/dist/cjs/shared/addIs404ToPageProps.js +0 -18
  246. package/dist/cjs/shared/assertHookReturnedObject.js +0 -21
  247. package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +0 -21
  248. package/dist/cjs/shared/assertPageContextProvidedByUser.js +0 -20
  249. package/dist/cjs/shared/createGlobalContextShared.js +0 -109
  250. package/dist/cjs/shared/createPageContextShared.js +0 -17
  251. package/dist/cjs/shared/determinePageIdOld.js +0 -11
  252. package/dist/cjs/shared/error-page.js +0 -40
  253. package/dist/cjs/shared/getPageContext.js +0 -6
  254. package/dist/cjs/shared/getPageContextRequestUrl.js +0 -16
  255. package/dist/cjs/shared/getPageContextUrlComputed.js +0 -132
  256. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +0 -19
  257. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/ClientDependency.js +0 -2
  258. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +0 -50
  259. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +0 -30
  260. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +0 -15
  261. package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +0 -59
  262. package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +0 -22
  263. package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +0 -24
  264. package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -52
  265. package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -102
  266. package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -56
  267. package/dist/cjs/shared/getPageFiles/parseVirtualFileExportsGlobalEntry.js +0 -100
  268. package/dist/cjs/shared/getPageFiles.js +0 -7
  269. package/dist/cjs/shared/getProxyForPublicUsage.js +0 -56
  270. package/dist/cjs/shared/hooks/execHook.js +0 -147
  271. package/dist/cjs/shared/hooks/getHook.js +0 -173
  272. package/dist/cjs/shared/htmlElementIds.js +0 -5
  273. package/dist/cjs/shared/misc/isServerSideError.js +0 -4
  274. package/dist/cjs/shared/misc/pageContextInitIsPassedToClient.js +0 -4
  275. package/dist/cjs/shared/modifyUrl.js +0 -28
  276. package/dist/cjs/shared/modifyUrlSameOrigin.js +0 -47
  277. package/dist/cjs/shared/page-configs/assertPlusFileExport.js +0 -42
  278. package/dist/cjs/shared/page-configs/findPageConfig.js +0 -10
  279. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +0 -65
  280. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -68
  281. package/dist/cjs/shared/page-configs/getConfigValueRuntime.js +0 -10
  282. package/dist/cjs/shared/page-configs/getConfigValueTyped.js +0 -32
  283. package/dist/cjs/shared/page-configs/getExportPath.js +0 -29
  284. package/dist/cjs/shared/page-configs/helpers.js +0 -27
  285. package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +0 -25
  286. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +0 -287
  287. package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +0 -2
  288. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -1
  289. package/dist/cjs/shared/page-configs/serialize/parsePageConfigsSerialized.js +0 -145
  290. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +0 -290
  291. package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +0 -10
  292. package/dist/cjs/shared/preparePageContextForPublicUsage.js +0 -80
  293. package/dist/cjs/shared/route/abort.js +0 -178
  294. package/dist/cjs/shared/route/debug.js +0 -23
  295. package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +0 -52
  296. package/dist/cjs/shared/route/execHookGuard.js +0 -37
  297. package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -84
  298. package/dist/cjs/shared/route/index.js +0 -107
  299. package/dist/cjs/shared/route/loadPageRoutes.js +0 -197
  300. package/dist/cjs/shared/route/noRouteMatch.js +0 -4
  301. package/dist/cjs/shared/route/resolvePrecedence.js +0 -93
  302. package/dist/cjs/shared/route/resolveRoute.js +0 -20
  303. package/dist/cjs/shared/route/resolveRouteFunction.js +0 -73
  304. package/dist/cjs/shared/route/resolveRouteString.js +0 -153
  305. package/dist/cjs/shared/route/resolveUrlPathname.js +0 -47
  306. package/dist/cjs/shared/route/routing.js +0 -9
  307. package/dist/cjs/shared/route/utils.js +0 -40
  308. package/dist/cjs/shared/utils.js +0 -49
  309. package/dist/cjs/types/Config/ConfigResolved.js +0 -2
  310. package/dist/cjs/types/Config.js +0 -2
  311. package/dist/cjs/types/FilePath.js +0 -2
  312. package/dist/cjs/types/PageConfig.js +0 -2
  313. package/dist/cjs/types/PageContext.js +0 -2
  314. package/dist/cjs/types/VikeGlobalInternal.js +0 -2
  315. package/dist/cjs/types/VikeNamespace.js +0 -2
  316. package/dist/cjs/types/ViteManifest.js +0 -2
  317. package/dist/cjs/types/defineConfig.js +0 -6
  318. package/dist/cjs/types/index-dreprecated.js +0 -3
  319. package/dist/cjs/types/index.js +0 -5
  320. package/dist/cjs/utils/PROJECT_VERSION.js +0 -5
  321. package/dist/cjs/utils/PromiseType.js +0 -2
  322. package/dist/cjs/utils/assert.js +0 -211
  323. package/dist/cjs/utils/assertIsBrowser.js +0 -8
  324. package/dist/cjs/utils/assertIsNotBrowser.js +0 -9
  325. package/dist/cjs/utils/assertKeys.js +0 -27
  326. package/dist/cjs/utils/assertNodeVersion.js +0 -14
  327. package/dist/cjs/utils/assertRoutingType.js +0 -29
  328. package/dist/cjs/utils/assertSetup.js +0 -171
  329. package/dist/cjs/utils/assertSingleInstance.js +0 -110
  330. package/dist/cjs/utils/assertVersion.js +0 -60
  331. package/dist/cjs/utils/capitalizeFirstLetter.js +0 -9
  332. package/dist/cjs/utils/cast.js +0 -6
  333. package/dist/cjs/utils/catchInfiniteLoop.js +0 -34
  334. package/dist/cjs/utils/changeEnumerable.js +0 -8
  335. package/dist/cjs/utils/checkType.js +0 -6
  336. package/dist/cjs/utils/compareString.js +0 -10
  337. package/dist/cjs/utils/createErrorWithCleanStackTrace.js +0 -39
  338. package/dist/cjs/utils/debug.js +0 -178
  339. package/dist/cjs/utils/debugGlob.js +0 -6
  340. package/dist/cjs/utils/deepEqual.js +0 -10
  341. package/dist/cjs/utils/escapeHtml.js +0 -13
  342. package/dist/cjs/utils/escapeRegex.js +0 -7
  343. package/dist/cjs/utils/findFile.js +0 -30
  344. package/dist/cjs/utils/findPackageJson.js +0 -18
  345. package/dist/cjs/utils/formatHintLog.js +0 -17
  346. package/dist/cjs/utils/freezePartial.js +0 -35
  347. package/dist/cjs/utils/genPromise.js +0 -51
  348. package/dist/cjs/utils/getFileExtension.js +0 -16
  349. package/dist/cjs/utils/getGlobalObject.js +0 -15
  350. package/dist/cjs/utils/getMostSimilar.js +0 -68
  351. package/dist/cjs/utils/getPropAccessNotation.js +0 -9
  352. package/dist/cjs/utils/getRandomId.js +0 -14
  353. package/dist/cjs/utils/getTerminalWidth.js +0 -7
  354. package/dist/cjs/utils/getValuePrintable.js +0 -10
  355. package/dist/cjs/utils/getViteRPC.js +0 -79
  356. package/dist/cjs/utils/hasProp.js +0 -50
  357. package/dist/cjs/utils/humanizeTime.js +0 -24
  358. package/dist/cjs/utils/includes.js +0 -13
  359. package/dist/cjs/utils/injectRollupInputs.js +0 -29
  360. package/dist/cjs/utils/isArray.js +0 -7
  361. package/dist/cjs/utils/isArrayOfStrings.js +0 -7
  362. package/dist/cjs/utils/isBrowser.js +0 -8
  363. package/dist/cjs/utils/isCallable.js +0 -6
  364. package/dist/cjs/utils/isDev.js +0 -20
  365. package/dist/cjs/utils/isDocker.js +0 -45
  366. package/dist/cjs/utils/isEqualStringList.js +0 -13
  367. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +0 -66
  368. package/dist/cjs/utils/isHtml.js +0 -9
  369. package/dist/cjs/utils/isImportPath.js +0 -21
  370. package/dist/cjs/utils/isNodeJS.js +0 -16
  371. package/dist/cjs/utils/isNonRunnableDev.js +0 -12
  372. package/dist/cjs/utils/isNullish.js +0 -16
  373. package/dist/cjs/utils/isObject.js +0 -6
  374. package/dist/cjs/utils/isObjectOfStrings.js +0 -7
  375. package/dist/cjs/utils/isObjectWithKeys.js +0 -15
  376. package/dist/cjs/utils/isPlainObject.js +0 -19
  377. package/dist/cjs/utils/isPromise.js +0 -7
  378. package/dist/cjs/utils/isPropertyGetter.js +0 -7
  379. package/dist/cjs/utils/isReact.js +0 -23
  380. package/dist/cjs/utils/isRunnableDevEnvironment.js +0 -9
  381. package/dist/cjs/utils/isSameErrorMessage.js +0 -9
  382. package/dist/cjs/utils/isScriptFile.js +0 -67
  383. package/dist/cjs/utils/isVikeReactApp.js +0 -8
  384. package/dist/cjs/utils/isVitest.js +0 -6
  385. package/dist/cjs/utils/joinEnglish.js +0 -14
  386. package/dist/cjs/utils/normalizeHeaders.js +0 -17
  387. package/dist/cjs/utils/objectAssign.js +0 -14
  388. package/dist/cjs/utils/objectAssignSafe.js +0 -7
  389. package/dist/cjs/utils/objectDefineProperty.js +0 -7
  390. package/dist/cjs/utils/objectEntries.js +0 -8
  391. package/dist/cjs/utils/objectEntriesForEach.js +0 -7
  392. package/dist/cjs/utils/objectFilter.js +0 -10
  393. package/dist/cjs/utils/objectFromEntries.js +0 -7
  394. package/dist/cjs/utils/objectKeys.js +0 -9
  395. package/dist/cjs/utils/objectReplace.js +0 -9
  396. package/dist/cjs/utils/onPageVisibilityChange.js +0 -18
  397. package/dist/cjs/utils/pLimit.js +0 -134
  398. package/dist/cjs/utils/parseNpmPackage.js +0 -106
  399. package/dist/cjs/utils/parseUrl-extras.js +0 -110
  400. package/dist/cjs/utils/parseUrl.js +0 -338
  401. package/dist/cjs/utils/path.js +0 -59
  402. package/dist/cjs/utils/pick.js +0 -12
  403. package/dist/cjs/utils/preservePropertyGetters.js +0 -30
  404. package/dist/cjs/utils/redirectHard.js +0 -6
  405. package/dist/cjs/utils/removeEmptyLines.js +0 -9
  406. package/dist/cjs/utils/removeFileExtension.js +0 -6
  407. package/dist/cjs/utils/requireResolve.js +0 -214
  408. package/dist/cjs/utils/rollupSourceMap.js +0 -19
  409. package/dist/cjs/utils/sleep.js +0 -6
  410. package/dist/cjs/utils/slice.js +0 -35
  411. package/dist/cjs/utils/sorter.js +0 -117
  412. package/dist/cjs/utils/stringifyStringArray.js +0 -6
  413. package/dist/cjs/utils/stripAnsi.js +0 -21
  414. package/dist/cjs/utils/styleFileRE.js +0 -6
  415. package/dist/cjs/utils/throttle.js +0 -15
  416. package/dist/cjs/utils/trackLogs.js +0 -31
  417. package/dist/cjs/utils/trimWithAnsi.js +0 -40
  418. package/dist/cjs/utils/truncateString.js +0 -23
  419. package/dist/cjs/utils/unique.js +0 -6
  420. package/dist/cjs/utils/updateType.js +0 -9
  421. package/dist/cjs/utils/urlToFile.js +0 -36
  422. package/dist/cjs/utils/virtualFileId.js +0 -43
  423. package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
  424. package/dist/esm/client/runtime-server-routing/globalContext.js +0 -5
  425. package/dist/esm/client/shared/createGetGlobalContextClient.js +0 -65
  426. package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
  427. package/dist/esm/node/vite/plugins/pluginBuild.js +0 -20
  428. package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -14
  429. package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -92
@@ -1,84 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.execHookOnBeforeRoute = execHookOnBeforeRoute;
7
- const assertPageContextProvidedByUser_js_1 = require("../assertPageContextProvidedByUser.js");
8
- const utils_js_1 = require("./utils.js");
9
- const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
10
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
11
- const execHook_js_1 = require("../hooks/execHook.js");
12
- const preparePageContextForPublicUsage_js_1 = require("../preparePageContextForPublicUsage.js");
13
- async function execHookOnBeforeRoute(pageContext) {
14
- const pageContextFromOnBeforeRouteHook = {};
15
- if (!pageContext._globalContext._onBeforeRouteHook)
16
- return null;
17
- const pageContextFromHook = await getPageContextFromHook(pageContext._globalContext._onBeforeRouteHook, pageContext);
18
- if (pageContextFromHook) {
19
- (0, utils_js_1.objectAssign)(pageContextFromOnBeforeRouteHook, pageContextFromHook);
20
- if ((0, utils_js_1.hasProp)(pageContextFromOnBeforeRouteHook, 'pageId', 'string') ||
21
- (0, utils_js_1.hasProp)(pageContextFromOnBeforeRouteHook, 'pageId', 'null')) {
22
- // We bypass Vike's routing
23
- if (!(0, utils_js_1.hasProp)(pageContextFromOnBeforeRouteHook, 'routeParams')) {
24
- (0, utils_js_1.objectAssign)(pageContextFromOnBeforeRouteHook, { routeParams: {} });
25
- }
26
- else {
27
- (0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContextFromOnBeforeRouteHook, 'routeParams', 'object'));
28
- }
29
- (0, utils_js_1.objectAssign)(pageContextFromOnBeforeRouteHook, {
30
- _routingProvidedByOnBeforeRouteHook: true,
31
- });
32
- return pageContextFromOnBeforeRouteHook;
33
- }
34
- }
35
- (0, utils_js_1.objectAssign)(pageContextFromOnBeforeRouteHook, {
36
- _routingProvidedByOnBeforeRouteHook: false,
37
- });
38
- return pageContextFromOnBeforeRouteHook;
39
- }
40
- async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
41
- let { hookReturn } = (0, execHook_js_1.execHookDirectSync)(onBeforeRouteHook, pageContext, preparePageContextForPublicUsage_js_1.preparePageContextForPublicUsage);
42
- (0, resolveRouteFunction_js_1.assertSyncRouting)(hookReturn, `The onBeforeRoute() hook ${onBeforeRouteHook.hookFilePath}`);
43
- // TO-DO/next-major-release: make execHookOnBeforeRoute() and route() sync
44
- hookReturn = await hookReturn;
45
- const errPrefix = `The onBeforeRoute() hook defined by ${onBeforeRouteHook.hookFilePath}`;
46
- (0, utils_js_1.assertUsage)(hookReturn === null ||
47
- hookReturn === undefined ||
48
- ((0, utils_js_1.isObjectWithKeys)(hookReturn, ['pageContext']) && (0, utils_js_1.hasProp)(hookReturn, 'pageContext')), `${errPrefix} should return ${picocolors_1.default.cyan('null')}, ${picocolors_1.default.cyan('undefined')}, or a plain JavaScript object ${picocolors_1.default.cyan('{ pageContext: { /* ... */ } }')}`);
49
- if (hookReturn === null || hookReturn === undefined) {
50
- return null;
51
- }
52
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(hookReturn, 'pageContext', 'object'), `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext }')} but pageContext should be a plain JavaScript object.`);
53
- if ((0, utils_js_1.hasProp)(hookReturn.pageContext, 'pageId') && !(0, utils_js_1.hasProp)(hookReturn.pageContext, 'pageId', 'null')) {
54
- const errPrefix2 = `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext: { pageId } }')} but ${picocolors_1.default.cyan('pageId')} should be`;
55
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(hookReturn.pageContext, 'pageId', 'string'), `${errPrefix2} a string or null`);
56
- (0, utils_js_1.assertUsage)(pageContext._globalContext._allPageIds.includes(hookReturn.pageContext.pageId), `${errPrefix2} ${(0, utils_js_1.joinEnglish)(pageContext._globalContext._allPageIds.map((s) => picocolors_1.default.cyan(s)), 'or')}`);
57
- }
58
- if ((0, utils_js_1.hasProp)(hookReturn.pageContext, 'routeParams')) {
59
- (0, resolveRouteFunction_js_1.assertRouteParams)(hookReturn.pageContext, `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext: { routeParams } }')} but routeParams should`);
60
- }
61
- const deprecatedReturn = (prop) => `${errPrefix} returned ${picocolors_1.default.cyan(`{ pageContext: { ${prop} } }`)} which is deprecated. Return ${picocolors_1.default.cyan('{ pageContext: { urlLogical } }')} instead.`;
62
- if ((0, utils_js_1.hasProp)(hookReturn.pageContext, 'url')) {
63
- (0, utils_js_1.assertWarning)(false, deprecatedReturn('url'), { onlyOnce: true });
64
- hookReturn.pageContext.urlLogical = hookReturn.pageContext.url;
65
- delete hookReturn.pageContext.url;
66
- }
67
- if ((0, utils_js_1.hasProp)(hookReturn.pageContext, 'urlOriginal')) {
68
- (0, utils_js_1.assertWarning)(false, deprecatedReturn('urlOriginal'), { onlyOnce: true });
69
- hookReturn.pageContext.urlLogical = hookReturn.pageContext.urlOriginal;
70
- delete hookReturn.pageContext.urlOriginal;
71
- }
72
- if ((0, utils_js_1.hasProp)(hookReturn.pageContext, 'urlLogical')) {
73
- (0, utils_js_1.assertUsageUrlPathnameAbsolute)(
74
- // We skip validation and type-cast instead of assertUsage() in order to save client-side KBs
75
- hookReturn.pageContext.urlLogical, `${errPrefix} returned ${picocolors_1.default.cyan('{ pageContext: { urlLogical } }')} and ${picocolors_1.default.cyan('urlLogical')}`);
76
- }
77
- (0, assertPageContextProvidedByUser_js_1.assertPageContextProvidedByUser)(hookReturn.pageContext, {
78
- hookFilePath: onBeforeRouteHook.hookFilePath,
79
- hookName: 'onBeforeRoute',
80
- });
81
- const pageContextAddendumHook = {};
82
- (0, utils_js_1.objectAssign)(pageContextAddendumHook, hookReturn.pageContext);
83
- return pageContextAddendumHook;
84
- }
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.route = route;
7
- // Ensure we don't bloat runtime of Server Routing
8
- const assertRoutingType_js_1 = require("../../utils/assertRoutingType.js");
9
- const isBrowser_js_1 = require("../../utils/isBrowser.js");
10
- if ((0, isBrowser_js_1.isBrowser)()) {
11
- (0, assertRoutingType_js_1.assertClientRouting)();
12
- }
13
- const utils_js_1 = require("./utils.js");
14
- const resolvePrecedence_js_1 = require("./resolvePrecedence.js");
15
- const resolveRouteString_js_1 = require("./resolveRouteString.js");
16
- const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
17
- const execHookOnBeforeRoute_js_1 = require("./execHookOnBeforeRoute.js");
18
- const debug_js_1 = require("./debug.js");
19
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
20
- // TO-DO/next-major-release: make it sync
21
- async function route(pageContext, skipOnBeforeRouteHook) {
22
- (0, debug_js_1.debug)('Pages routes:', pageContext._globalContext._pageRoutes);
23
- const pageContextFromRoute = {};
24
- // onBeforeRoute()
25
- if (!skipOnBeforeRouteHook) {
26
- const pageContextFromOnBeforeRouteHook = await (0, execHookOnBeforeRoute_js_1.execHookOnBeforeRoute)(pageContext);
27
- if (pageContextFromOnBeforeRouteHook) {
28
- if (pageContextFromOnBeforeRouteHook._routingProvidedByOnBeforeRouteHook) {
29
- (0, utils_js_1.assert)(pageContextFromOnBeforeRouteHook.pageId);
30
- return pageContextFromOnBeforeRouteHook;
31
- }
32
- else {
33
- (0, utils_js_1.objectAssign)(pageContextFromRoute, pageContextFromOnBeforeRouteHook);
34
- }
35
- }
36
- // We take into account pageContext.urlLogical set by onBeforeRoute()
37
- (0, utils_js_1.objectAssign)(pageContext, pageContextFromOnBeforeRouteHook);
38
- }
39
- // Vike's routing
40
- const allPageIds = pageContext._globalContext._allPageIds;
41
- (0, utils_js_1.assertUsage)(allPageIds.length > 0, 'No page found. You must create at least one page.');
42
- (0, utils_js_1.assert)(pageContext._globalContext._pageFilesAll.length > 0 || pageContext._globalContext._pageConfigs.length > 0);
43
- const { urlPathname } = pageContext;
44
- (0, utils_js_1.assert)(urlPathname.startsWith('/'));
45
- const routeMatches = [];
46
- await Promise.all(pageContext._globalContext._pageRoutes.map(async (pageRoute) => {
47
- const { pageId, routeType } = pageRoute;
48
- // Filesystem Routing
49
- if (pageRoute.routeType === 'FILESYSTEM') {
50
- const { routeString } = pageRoute;
51
- const match = (0, resolveRouteString_js_1.resolveRouteString)(routeString, urlPathname);
52
- if (match) {
53
- const { routeParams } = match;
54
- routeMatches.push({ pageId, routeParams, routeString, routeType });
55
- }
56
- return;
57
- }
58
- // Route String defined in `.page.route.js`
59
- if (pageRoute.routeType === 'STRING') {
60
- const { routeString } = pageRoute;
61
- const match = (0, resolveRouteString_js_1.resolveRouteString)(routeString, urlPathname);
62
- if (match) {
63
- const { routeParams } = match;
64
- (0, utils_js_1.assert)(routeType === 'STRING');
65
- routeMatches.push({
66
- pageId,
67
- routeString,
68
- routeParams,
69
- routeType,
70
- });
71
- }
72
- return;
73
- }
74
- // Route Function defined in `.page.route.js`
75
- if (pageRoute.routeType === 'FUNCTION') {
76
- const { routeFunction, routeFunctionFilePath } = pageRoute;
77
- const match = await (0, resolveRouteFunction_js_1.resolveRouteFunction)(routeFunction, pageContext, routeFunctionFilePath);
78
- if (match) {
79
- const { routeParams, precedence } = match;
80
- routeMatches.push({ pageId, precedence, routeParams, routeType });
81
- }
82
- return;
83
- }
84
- (0, utils_js_1.assert)(false);
85
- }));
86
- (0, resolvePrecedence_js_1.resolvePrecedence)(routeMatches);
87
- const winner = routeMatches[0] ?? null;
88
- (0, debug_js_1.debug)(`Route matches for URL ${picocolors_1.default.cyan(urlPathname)} (in precedence order):`, routeMatches);
89
- // For vite-plugin-vercel https://github.com/magne4000/vite-plugin-vercel/blob/main/packages/vike-integration/vike.ts#L173
90
- (0, utils_js_1.objectAssign)(pageContextFromRoute, { _routeMatch: winner });
91
- if (!winner) {
92
- (0, utils_js_1.objectAssign)(pageContextFromRoute, {
93
- pageId: null,
94
- routeParams: {},
95
- });
96
- return pageContextFromRoute;
97
- }
98
- {
99
- const { routeParams } = winner;
100
- (0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(routeParams));
101
- (0, utils_js_1.objectAssign)(pageContextFromRoute, {
102
- pageId: winner.pageId,
103
- routeParams: winner.routeParams,
104
- });
105
- }
106
- return pageContextFromRoute;
107
- }
@@ -1,197 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadPageRoutes = loadPageRoutes;
4
- exports.loadPageRoutesSync = loadPageRoutesSync;
5
- const error_page_js_1 = require("../error-page.js");
6
- const utils_js_1 = require("./utils.js");
7
- const deduceRouteStringFromFilesystemPath_js_1 = require("./deduceRouteStringFromFilesystemPath.js");
8
- const utils_js_2 = require("../utils.js");
9
- const getConfigValueRuntime_js_1 = require("../page-configs/getConfigValueRuntime.js");
10
- const getConfigDefinedAt_js_1 = require("../page-configs/getConfigDefinedAt.js");
11
- const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
12
- const getHook_js_1 = require("../hooks/getHook.js");
13
- async function loadPageRoutes(
14
- // Remove all arguments and use GlobalContextServerInternal instead?
15
- pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
16
- // TO-DO/next-major-release: remove this line, remove this function, rename loadPageRoutesSync() to loadPageRoutes()
17
- await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
18
- return loadPageRoutesSync(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
19
- }
20
- function loadPageRoutesSync(
21
- // Remove all arguments and use GlobalContextServerInternal instead?
22
- pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
23
- const { onBeforeRouteHook, filesystemRoots } = getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal);
24
- const pageRoutes = getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds);
25
- return { pageRoutes, onBeforeRouteHook };
26
- }
27
- function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
28
- const pageRoutes = [];
29
- // V1 Design
30
- if (pageConfigs.length > 0) {
31
- (0, utils_js_1.assert)(filesystemRoots === null);
32
- const comesFromV1PageConfig = true;
33
- pageConfigs
34
- .filter((p) => !p.isErrorPage)
35
- .forEach((pageConfig) => {
36
- const pageId = pageConfig.pageId;
37
- let pageRoute = null;
38
- {
39
- const configName = 'route';
40
- const configValue = (0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, configName);
41
- if (configValue) {
42
- const route = configValue.value;
43
- (0, utils_js_1.assert)(configValue.definedAtData);
44
- const definedAtString = (0, getConfigDefinedAt_js_1.getDefinedAtString)(configValue.definedAtData, configName);
45
- if (typeof route === 'string') {
46
- pageRoute = {
47
- pageId,
48
- comesFromV1PageConfig,
49
- routeString: route,
50
- routeDefinedAtString: definedAtString,
51
- routeType: 'STRING',
52
- };
53
- }
54
- else {
55
- const { definedAtData } = configValue;
56
- (0, utils_js_1.assert)(!(0, utils_js_2.isArray)(definedAtData) && !definedAtData.definedBy);
57
- const { filePathToShowToUser } = definedAtData;
58
- (0, utils_js_1.assert)(filePathToShowToUser);
59
- (0, utils_js_1.assert)((0, utils_js_2.isCallable)(route));
60
- // TO-DO/next-major-release: remove
61
- if ((0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
62
- (0, resolveRouteFunction_js_1.warnDeprecatedAllowKey)();
63
- pageRoute = {
64
- pageId,
65
- comesFromV1PageConfig,
66
- routeFunction: route,
67
- routeFunctionFilePath: filePathToShowToUser,
68
- routeDefinedAtString: definedAtString,
69
- routeType: 'FUNCTION',
70
- };
71
- }
72
- }
73
- }
74
- if (!pageRoute) {
75
- const { routeFilesystem } = pageConfig;
76
- (0, utils_js_1.assert)(routeFilesystem);
77
- const { routeString, definedAtLocation } = routeFilesystem;
78
- (0, utils_js_1.assert)(routeFilesystem.routeString.startsWith('/'));
79
- pageRoute = {
80
- pageId,
81
- routeFilesystemDefinedBy: definedAtLocation,
82
- comesFromV1PageConfig,
83
- routeString,
84
- routeDefinedAtString: null,
85
- routeType: 'FILESYSTEM',
86
- };
87
- }
88
- (0, utils_js_1.assert)(pageRoute);
89
- pageRoutes.push(pageRoute);
90
- });
91
- }
92
- // Old design
93
- // TO-DO/next-major-release: remove
94
- if (pageConfigs.length === 0) {
95
- (0, utils_js_1.assert)(filesystemRoots);
96
- const comesFromV1PageConfig = false;
97
- allPageIds
98
- .filter((pageId) => !(0, error_page_js_1.isErrorPageId)(pageId, false))
99
- .forEach((pageId) => {
100
- const pageRouteFile = pageFilesAll.find((p) => p.pageId === pageId && p.fileType === '.page.route');
101
- if (!pageRouteFile || !('default' in pageRouteFile.fileExports)) {
102
- const routeString = (0, deduceRouteStringFromFilesystemPath_js_1.deduceRouteStringFromFilesystemPath)(pageId, filesystemRoots);
103
- (0, utils_js_1.assert)(routeString.startsWith('/'));
104
- (0, utils_js_1.assert)(!routeString.endsWith('/') || routeString === '/');
105
- pageRoutes.push({
106
- pageId,
107
- comesFromV1PageConfig,
108
- routeString,
109
- routeDefinedAtString: null,
110
- routeFilesystemDefinedBy: `${pageId}.page.*`,
111
- routeType: 'FILESYSTEM',
112
- });
113
- }
114
- else {
115
- const { filePath, fileExports } = pageRouteFile;
116
- (0, utils_js_1.assert)(fileExports.default);
117
- if ((0, utils_js_1.hasProp)(fileExports, 'default', 'string')) {
118
- const routeString = fileExports.default;
119
- (0, utils_js_1.assertUsage)(routeString.startsWith('/'), `A Route String should start with a leading slash '/' but ${filePath} has \`export default '${routeString}'\`. Make sure to \`export default '/${routeString}'\` instead.`);
120
- pageRoutes.push({
121
- pageId,
122
- comesFromV1PageConfig,
123
- routeString,
124
- routeDefinedAtString: filePath,
125
- routeType: 'STRING',
126
- });
127
- return;
128
- }
129
- if ((0, utils_js_1.hasProp)(fileExports, 'default', 'function')) {
130
- const routeFunction = fileExports.default;
131
- {
132
- const allowKey = 'iKnowThePerformanceRisksOfAsyncRouteFunctions';
133
- if (allowKey in fileExports) {
134
- (0, resolveRouteFunction_js_1.warnDeprecatedAllowKey)();
135
- }
136
- }
137
- pageRoutes.push({
138
- pageId,
139
- comesFromV1PageConfig,
140
- routeFunction,
141
- routeFunctionFilePath: filePath,
142
- routeDefinedAtString: filePath,
143
- routeType: 'FUNCTION',
144
- });
145
- return;
146
- }
147
- (0, utils_js_1.assertUsage)(false, `The default export of ${filePath} should be a string or a function.`);
148
- }
149
- });
150
- }
151
- return pageRoutes;
152
- }
153
- function getGlobalHooks(pageFilesAll, pageConfigs, pageConfigGlobal) {
154
- // V1 Design
155
- if (pageConfigs.length > 0) {
156
- const hook = (0, getHook_js_1.getHookFromPageConfigGlobal)(pageConfigGlobal, 'onBeforeRoute');
157
- return { onBeforeRouteHook: hook, filesystemRoots: null };
158
- }
159
- // Old design
160
- // TO-DO/next-major-release: remove
161
- let onBeforeRouteHook = null;
162
- const filesystemRoots = [];
163
- pageFilesAll
164
- .filter((p) => p.fileType === '.page.route' && p.isDefaultPageFile)
165
- .forEach(({ filePath, fileExports }) => {
166
- (0, utils_js_1.assert)(fileExports);
167
- if ('onBeforeRoute' in fileExports) {
168
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(fileExports, 'onBeforeRoute', 'function'), `\`export { onBeforeRoute }\` of ${filePath} should be a function.`);
169
- const { onBeforeRoute } = fileExports;
170
- const hookName = 'onBeforeRoute';
171
- onBeforeRouteHook = {
172
- hookFilePath: filePath,
173
- hookFn: onBeforeRoute,
174
- hookName,
175
- hookTimeout: (0, getHook_js_1.getHookTimeoutDefault)(hookName),
176
- };
177
- }
178
- if ('filesystemRoutingRoot' in fileExports) {
179
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(fileExports, 'filesystemRoutingRoot', 'string'), `\`export { filesystemRoutingRoot }\` of ${filePath} should be a string.`);
180
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(fileExports, 'filesystemRoutingRoot', 'string'), `\`export { filesystemRoutingRoot }\` of ${filePath} is \`'${fileExports.filesystemRoutingRoot}'\` but it should start with a leading slash \`/\`.`);
181
- filesystemRoots.push({
182
- filesystemRoot: dirname(filePath),
183
- urlRoot: fileExports.filesystemRoutingRoot,
184
- });
185
- }
186
- });
187
- return { onBeforeRouteHook, filesystemRoots };
188
- }
189
- function dirname(filePath) {
190
- (0, utils_js_1.assert)(filePath.startsWith('/'));
191
- (0, utils_js_1.assert)(!filePath.endsWith('/'));
192
- const paths = filePath.split('/');
193
- const dirPath = (0, utils_js_1.slice)(paths, 0, -1).join('/') || '/';
194
- (0, utils_js_1.assert)(dirPath.startsWith('/'));
195
- (0, utils_js_1.assert)(!dirPath.endsWith('/') || dirPath === '/');
196
- return dirPath;
197
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noRouteMatch = void 0;
4
- exports.noRouteMatch = "doesn't match the route of any of your pages";
@@ -1,93 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePrecedence = resolvePrecedence;
4
- // export type { RouteMatch }
5
- const resolveRouteString_js_1 = require("./resolveRouteString.js");
6
- const utils_js_1 = require("./utils.js");
7
- const utils_js_2 = require("./utils.js");
8
- const resolveRouteString_js_2 = require("./resolveRouteString.js");
9
- // See https://vike.dev/route-function#precedence
10
- function resolvePrecedence(routeMatches) {
11
- // prettier-ignore
12
- // biome-ignore format:
13
- routeMatches
14
- .sort(sortMatches)
15
- .sort((0, utils_js_2.makeFirst)((routeMatch) => routeMatch.routeType === 'FUNCTION' && !!routeMatch.precedence && routeMatch.precedence < 0))
16
- .sort((0, utils_js_2.makeFirst)((routeMatch) => routeMatch.routeType === 'STRING' && (0, resolveRouteString_js_2.isStaticRouteString)(routeMatch.routeString) === false))
17
- .sort((0, utils_js_2.makeFirst)((routeMatch) => routeMatch.routeType === 'FUNCTION' && !routeMatch.precedence))
18
- .sort((0, utils_js_2.makeFirst)((routeMatch) => routeMatch.routeType === 'STRING' && (0, resolveRouteString_js_2.isStaticRouteString)(routeMatch.routeString) === true))
19
- .sort((0, utils_js_2.makeFirst)((routeMatch) => routeMatch.routeType === 'FILESYSTEM'))
20
- .sort((0, utils_js_2.makeFirst)((routeMatch) => routeMatch.routeType === 'FUNCTION' && !!routeMatch.precedence && routeMatch.precedence > 0));
21
- }
22
- // -1 => routeMatch1 higher precedence
23
- // +1 => routeMatch2 higher precedence
24
- function sortMatches(routeMatch1, routeMatch2) {
25
- {
26
- const precedence1 = routeMatch1.precedence ?? 0;
27
- const precedence2 = routeMatch2.precedence ?? 0;
28
- if (precedence1 !== precedence2) {
29
- return precedence1 > precedence2 ? -1 : 1;
30
- }
31
- }
32
- if (!routeMatch2.routeString) {
33
- return 0;
34
- }
35
- if (!routeMatch1.routeString) {
36
- return 0;
37
- }
38
- /* DEBUG
39
- console.log('routeMatch1.routeString', routeMatch1.routeString)
40
- console.log('routeMatch2.routeString', routeMatch2.routeString)
41
- console.log('parseRouteString(routeMatch1.routeString)', parseRouteString(routeMatch1.routeString))
42
- console.log('parseRouteString(routeMatch2.routeString)', parseRouteString(routeMatch2.routeString))
43
- //*/
44
- // Return route with highest number of static path segments at beginning first
45
- {
46
- const getValue = (routeString) => (0, resolveRouteString_js_1.analyzeRouteString)(routeString).numberOfStaticPartsBeginning;
47
- const result = (0, utils_js_1.higherFirst)(getValue)(routeMatch1.routeString, routeMatch2.routeString);
48
- if (result !== 0) {
49
- /* DEBUG
50
- console.log('analyzeRouteString(routeMatch1.routeString).numberOfStaticPartsBeginning', getValue(routeMatch1.routeString))
51
- console.log('analyzeRouteString(routeMatch2.routeString).numberOfStaticPartsBeginning', getValue(routeMatch2.routeString))
52
- //*/
53
- return result;
54
- }
55
- }
56
- // Return route with highest number of static path segments in total first
57
- {
58
- const getValue = (routeString) => (0, resolveRouteString_js_1.analyzeRouteString)(routeString).numberOfStaticParts;
59
- const result = (0, utils_js_1.higherFirst)(getValue)(routeMatch1.routeString, routeMatch2.routeString);
60
- if (result !== 0) {
61
- /* DEBUG
62
- console.log('analyzeRouteString(routeMatch1.routeString).numberOfStaticParts', getValue(routeMatch1.routeString))
63
- console.log('analyzeRouteString(routeMatch2.routeString).numberOfStaticParts', getValue(routeMatch2.routeString))
64
- //*/
65
- return result;
66
- }
67
- }
68
- // Return route with least amount of globs first
69
- {
70
- const getValue = (routeString) => (0, resolveRouteString_js_1.analyzeRouteString)(routeString).numberOfGlobs;
71
- const result = (0, utils_js_1.lowerFirst)(getValue)(routeMatch1.routeString, routeMatch2.routeString);
72
- if (result !== 0) {
73
- /* DEBUG
74
- console.log('analyzeRouteString(routeMatch1.routeString).numberOfGlobs', getValue(routeMatch1.routeString))
75
- console.log('analyzeRouteString(routeMatch2.routeString).numberOfGlobs', getValue(routeMatch2.routeString))
76
- //*/
77
- return result;
78
- }
79
- }
80
- // Return route with highest number of parameters first
81
- {
82
- const getValue = (routeString) => (0, resolveRouteString_js_1.analyzeRouteString)(routeString).numberOfParams;
83
- const result = (0, utils_js_1.higherFirst)(getValue)(routeMatch1.routeString, routeMatch2.routeString);
84
- if (result !== 0) {
85
- /* DEBUG
86
- console.log('analyzeRouteString(routeMatch1.routeString).numberOfParams', getValue(routeMatch1.routeString))
87
- console.log('analyzeRouteString(routeMatch2.routeString).numberOfParams', getValue(routeMatch2.routeString))
88
- //*/
89
- return result;
90
- }
91
- }
92
- return 0;
93
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveRoute = resolveRoute;
7
- const utils_js_1 = require("./utils.js");
8
- const resolveRouteString_js_1 = require("./resolveRouteString.js");
9
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
10
- function resolveRoute(routeString, urlPathname) {
11
- const errMsg = (propName, msg = 'a non-empty string') => `[resolveRoute(routeString, urlPathname)] ${picocolors_1.default.cyan(propName)} should be ` + msg;
12
- (0, utils_js_1.assertUsage)(routeString, errMsg('routeString'), { showStackTrace: true });
13
- (0, utils_js_1.assertUsage)(urlPathname, errMsg('urlPathname'), { showStackTrace: true });
14
- (0, utils_js_1.assertUsage)(urlPathname.startsWith('/'), errMsg('urlPathname', 'pageContext.urlPathname'), { showStackTrace: true });
15
- const result = (0, resolveRouteString_js_1.resolveRouteString)(routeString, urlPathname);
16
- return {
17
- match: !!result,
18
- routeParams: result?.routeParams ?? {},
19
- };
20
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveRouteFunction = resolveRouteFunction;
7
- exports.assertRouteParams = assertRouteParams;
8
- exports.assertSyncRouting = assertSyncRouting;
9
- exports.warnDeprecatedAllowKey = warnDeprecatedAllowKey;
10
- const execHook_js_1 = require("../hooks/execHook.js");
11
- const preparePageContextForPublicUsage_js_1 = require("../preparePageContextForPublicUsage.js");
12
- const utils_js_1 = require("./utils.js");
13
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
14
- async function resolveRouteFunction(routeFunction, pageContext, routeFunctionFilePath) {
15
- let { hookReturn: result } = (0, execHook_js_1.execHookDirectSync)({
16
- hookFn: routeFunction,
17
- hookFilePath: routeFunctionFilePath,
18
- hookName: 'route',
19
- }, pageContext, preparePageContextForPublicUsage_js_1.preparePageContextForPublicUsage);
20
- assertSyncRouting(result, `The Route Function ${routeFunctionFilePath}`);
21
- // TO-DO/next-major-release: make resolveRouteFunction() and route() sync
22
- //* We disallow asynchronous routing, because we need to check whether a link is a Vike link in a synchronous fashion before calling ev.preventDefault() in the 'click' event listener
23
- result = await result;
24
- //*/
25
- if (result === false) {
26
- return null;
27
- }
28
- if (result === true) {
29
- result = {};
30
- }
31
- (0, utils_js_1.assertUsage)((0, utils_js_1.isPlainObject)(result), `The Route Function ${routeFunctionFilePath} should return a boolean or a plain JavaScript object (but it's ${picocolors_1.default.cyan(`typeof result === ${JSON.stringify(typeof result)}`)} instead)`);
32
- // AFAICT this return interface is superfluous. Should we soft-deprecate it and remove it?
33
- if ('match' in result) {
34
- const { match } = result;
35
- (0, utils_js_1.assertUsage)(typeof match === 'boolean', `The ${picocolors_1.default.cyan('match')} value returned by the Route Function ${routeFunctionFilePath} should be a boolean.`);
36
- if (!match) {
37
- return null;
38
- }
39
- }
40
- let precedence = null;
41
- if ('precedence' in result) {
42
- precedence = result.precedence;
43
- (0, utils_js_1.assertUsage)(typeof precedence === 'number', `The ${picocolors_1.default.cyan('precedence')} value returned by the Route Function ${routeFunctionFilePath} should be a number.`);
44
- }
45
- assertRouteParams(result, `The ${picocolors_1.default.cyan('routeParams')} object returned by the Route Function ${routeFunctionFilePath} should`);
46
- const routeParams = result.routeParams || {};
47
- (0, utils_js_1.assertUsage)(!('pageContext' in result), `Providing ${picocolors_1.default.cyan('pageContext')} in Route Functions is prohibited, see https://vike.dev/route-function#cannot-provide-pagecontext`);
48
- (0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(routeParams));
49
- Object.keys(result).forEach((key) => {
50
- (0, utils_js_1.assertUsage)(key === 'match' || key === 'routeParams' || key === 'precedence', `The Route Function ${routeFunctionFilePath} returned an object with an unknown property ${picocolors_1.default.cyan(key)} (the known properties are ${picocolors_1.default.cyan('match')}, ${picocolors_1.default.cyan('routeParams')}, and ${picocolors_1.default.cyan('precedence')})`);
51
- });
52
- return {
53
- precedence,
54
- routeParams,
55
- };
56
- }
57
- // TO-DO/next-major-release: remove, and make routing synchronous (enabling Vike to synchronously check whether a link is a Vike link before even calling ev.preventDefault())
58
- function assertSyncRouting(res, errPrefix) {
59
- (0, utils_js_1.assertWarning)(!(0, utils_js_1.isPromise)(res), `${errPrefix} returned a promise, but asynchronous routing is deprecated and will be removed in the next major release, see https://vike.dev/route-function#async`, { onlyOnce: true });
60
- }
61
- // TO-DO/next-major-release: remove
62
- function warnDeprecatedAllowKey() {
63
- const allowKey = picocolors_1.default.cyan('iKnowThePerformanceRisksOfAsyncRouteFunctions');
64
- (0, utils_js_1.assertWarning)(false, `${allowKey} is deprecated and will be removed in the next major release`, { onlyOnce: true });
65
- }
66
- function assertRouteParams(result, errPrefix) {
67
- (0, utils_js_1.assert)(errPrefix.endsWith(' should'));
68
- if (!(0, utils_js_1.hasProp)(result, 'routeParams')) {
69
- return;
70
- }
71
- (0, utils_js_1.assert)(errPrefix.endsWith(' should'));
72
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(result, 'routeParams', 'string{}'), `${errPrefix} be an object holding string values.`);
73
- }