vike 0.4.239-commit-33e55d4 → 0.4.239-commit-4d0d950

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 (420) hide show
  1. package/dist/esm/client/runtime-client-routing/entry.js +5 -0
  2. package/dist/esm/client/runtime-client-routing/globalContext.d.ts +1 -1
  3. package/dist/esm/client/runtime-client-routing/globalContext.js +9 -3
  4. package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +2 -2
  5. package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +15 -1
  6. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
  7. package/dist/esm/client/runtime-server-routing/entry.js +5 -0
  8. package/dist/esm/client/runtime-server-routing/globalContext.d.ts +2 -2
  9. package/dist/esm/client/runtime-server-routing/globalContext.js +7 -3
  10. package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +4 -3
  11. package/dist/esm/client/shared/createGetGlobalContextClient.js +38 -34
  12. package/dist/esm/node/vite/index.js +34 -15
  13. package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
  14. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +37 -35
  15. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +4 -0
  16. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +21 -6
  17. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +16 -4
  18. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.d.ts +1 -1
  19. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +82 -80
  20. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.d.ts +1 -1
  21. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +23 -21
  22. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.d.ts +1 -1
  23. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +38 -36
  24. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.d.ts +1 -1
  25. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +26 -24
  26. package/dist/esm/node/vite/plugins/pluginCommon.js +1 -1
  27. package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
  28. package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +1 -1
  29. package/dist/esm/node/vite/plugins/pluginEnvVars.js +87 -65
  30. package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
  31. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +29 -27
  32. package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
  33. package/dist/esm/node/vite/plugins/pluginFileEnv.js +75 -73
  34. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +1 -1
  35. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +30 -28
  36. package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
  37. package/dist/esm/node/vite/plugins/pluginPreview.js +35 -33
  38. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +9 -0
  39. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +45 -0
  40. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +3 -0
  41. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.js +89 -0
  42. package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
  43. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +50 -48
  44. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
  45. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +12 -10
  46. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
  47. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
  48. package/dist/esm/shared/createGlobalContextShared.js +1 -0
  49. package/dist/esm/shared/route/abort.d.ts +22 -11
  50. package/dist/esm/shared/route/abort.js +37 -5
  51. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  52. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  53. package/dist/esm/utils/findPackageJson.js +0 -1
  54. package/dist/esm/utils/getViteRPC.js +0 -2
  55. package/dist/esm/utils/requireResolve.js +0 -1
  56. package/package.json +3 -22
  57. package/dist/cjs/__internal/index.js +0 -35
  58. package/dist/cjs/client/runtime-client-routing/globalContext.js +0 -49
  59. package/dist/cjs/client/runtime-client-routing/prefetch/PrefetchSetting.js +0 -2
  60. package/dist/cjs/client/runtime-server-routing/globalContext.js +0 -41
  61. package/dist/cjs/client/runtime-server-routing/onLoad.js +0 -7
  62. package/dist/cjs/client/runtime-server-routing/utils.js +0 -34
  63. package/dist/cjs/client/shared/createGetGlobalContextClient.js +0 -65
  64. package/dist/cjs/client/shared/getJsonSerializedInHtml.js +0 -40
  65. package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +0 -41
  66. package/dist/cjs/client/shared/utils.js +0 -23
  67. package/dist/cjs/node/api/build.js +0 -24
  68. package/dist/cjs/node/api/context.js +0 -23
  69. package/dist/cjs/node/api/dev.js +0 -18
  70. package/dist/cjs/node/api/index.js +0 -44
  71. package/dist/cjs/node/api/onLoad.js +0 -9
  72. package/dist/cjs/node/api/prepareViteApiCall.js +0 -206
  73. package/dist/cjs/node/api/prerender.js +0 -18
  74. package/dist/cjs/node/api/preview.js +0 -38
  75. package/dist/cjs/node/api/types.js +0 -2
  76. package/dist/cjs/node/api/utils.js +0 -27
  77. package/dist/cjs/node/cli/context.js +0 -17
  78. package/dist/cjs/node/cli/entry.js +0 -121
  79. package/dist/cjs/node/cli/index.js +0 -12
  80. package/dist/cjs/node/cli/onLoad.js +0 -9
  81. package/dist/cjs/node/cli/parseCli.js +0 -95
  82. package/dist/cjs/node/cli/utils.js +0 -24
  83. package/dist/cjs/node/client/router.js +0 -19
  84. package/dist/cjs/node/createPageRenderer.js +0 -132
  85. package/dist/cjs/node/importBuild.js +0 -3
  86. package/dist/cjs/node/prerender/context.js +0 -26
  87. package/dist/cjs/node/prerender/index.js +0 -12
  88. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +0 -66
  89. package/dist/cjs/node/prerender/runPrerender.js +0 -778
  90. package/dist/cjs/node/prerender/runPrerenderEntry.js +0 -55
  91. package/dist/cjs/node/prerender/utils.js +0 -37
  92. package/dist/cjs/node/runtime/globalContext.js +0 -582
  93. package/dist/cjs/node/runtime/index-deprecated.js +0 -33
  94. package/dist/cjs/node/runtime/index.js +0 -74
  95. package/dist/cjs/node/runtime/loggerRuntime.js +0 -17
  96. package/dist/cjs/node/runtime/onLoad.js +0 -29
  97. package/dist/cjs/node/runtime/page-files/setup.js +0 -5
  98. package/dist/cjs/node/runtime/renderPage/analyzePage.js +0 -71
  99. package/dist/cjs/node/runtime/renderPage/assertArguments.js +0 -42
  100. package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +0 -51
  101. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -114
  102. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +0 -59
  103. package/dist/cjs/node/runtime/renderPage/csp.js +0 -47
  104. package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +0 -31
  105. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +0 -120
  106. package/dist/cjs/node/runtime/renderPage/execHookServer.js +0 -8
  107. package/dist/cjs/node/runtime/renderPage/getCacheControl.js +0 -24
  108. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +0 -20
  109. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +0 -137
  110. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +0 -125
  111. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.js +0 -86
  112. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.js +0 -77
  113. package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +0 -36
  114. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +0 -50
  115. package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +0 -41
  116. package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +0 -68
  117. package/dist/cjs/node/runtime/renderPage/headersResponse.js +0 -48
  118. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getHtmlTags.js +0 -269
  119. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getViteDevScript.js +0 -32
  120. package/dist/cjs/node/runtime/renderPage/html/injectAssets/inferHtmlTags.js +0 -55
  121. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectAssets__public.js +0 -31
  122. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectHtmlTags.js +0 -161
  123. package/dist/cjs/node/runtime/renderPage/html/injectAssets/mergeScriptTags.js +0 -73
  124. package/dist/cjs/node/runtime/renderPage/html/injectAssets/sanitizeJson.js +0 -8
  125. package/dist/cjs/node/runtime/renderPage/html/injectAssets.js +0 -93
  126. package/dist/cjs/node/runtime/renderPage/html/propKeys.js +0 -47
  127. package/dist/cjs/node/runtime/renderPage/html/renderHtml.js +0 -245
  128. package/dist/cjs/node/runtime/renderPage/html/serializeContext.js +0 -189
  129. package/dist/cjs/node/runtime/renderPage/html/stream/react-streaming.js +0 -36
  130. package/dist/cjs/node/runtime/renderPage/html/stream.js +0 -829
  131. package/dist/cjs/node/runtime/renderPage/inferMediaType.js +0 -81
  132. package/dist/cjs/node/runtime/renderPage/isFontFallback.js +0 -29
  133. package/dist/cjs/node/runtime/renderPage/isNewError.js +0 -25
  134. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +0 -124
  135. package/dist/cjs/node/runtime/renderPage/log404/index.js +0 -154
  136. package/dist/cjs/node/runtime/renderPage/logErrorHint/errors.js +0 -20
  137. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +0 -200
  138. package/dist/cjs/node/runtime/renderPage/loggerProd.js +0 -34
  139. package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +0 -10
  140. package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +0 -83
  141. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -71
  142. package/dist/cjs/node/runtime/renderPage.js +0 -502
  143. package/dist/cjs/node/runtime/universal-middleware.js +0 -20
  144. package/dist/cjs/node/runtime/utils.js +0 -83
  145. package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -27
  146. package/dist/cjs/node/runtime-dev/index.js +0 -42
  147. package/dist/cjs/node/shared/assertV1Design.js +0 -30
  148. package/dist/cjs/node/shared/extractAssetsQuery.js +0 -29
  149. package/dist/cjs/node/shared/getVikeConfigError.js +0 -22
  150. package/dist/cjs/node/shared/isErrorDebug.js +0 -7
  151. package/dist/cjs/node/shared/prependEntriesDir.js +0 -13
  152. package/dist/cjs/node/shared/resolveBase.js +0 -35
  153. package/dist/cjs/node/shared/utils.js +0 -35
  154. package/dist/cjs/node/shared/virtualFileId.js +0 -110
  155. package/dist/cjs/node/vite/index.js +0 -69
  156. package/dist/cjs/node/vite/onLoad.js +0 -21
  157. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +0 -52
  158. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -342
  159. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -183
  160. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -222
  161. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -256
  162. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -40
  163. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -49
  164. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -111
  165. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -65
  166. package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -21
  167. package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
  168. package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -183
  169. package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -28
  170. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +0 -163
  171. package/dist/cjs/node/vite/plugins/pluginDev.js +0 -111
  172. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -92
  173. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -241
  174. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -113
  175. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -172
  176. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -70
  177. package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -82
  178. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -95
  179. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -51
  180. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/debug.js +0 -5
  181. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +0 -56
  182. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +0 -190
  183. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +0 -54
  184. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +0 -97
  185. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +0 -233
  186. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -17
  187. package/dist/cjs/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +0 -35
  188. package/dist/cjs/node/vite/shared/addSsrMiddleware.js +0 -60
  189. package/dist/cjs/node/vite/shared/findPageFiles.js +0 -25
  190. package/dist/cjs/node/vite/shared/getAssetsDir.js +0 -10
  191. package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +0 -42
  192. package/dist/cjs/node/vite/shared/getEnvVarObject.js +0 -37
  193. package/dist/cjs/node/vite/shared/getFilePath.js +0 -172
  194. package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +0 -125
  195. package/dist/cjs/node/vite/shared/getMagicString.js +0 -18
  196. package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +0 -10
  197. package/dist/cjs/node/vite/shared/getOutDirs.js +0 -146
  198. package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +0 -21
  199. package/dist/cjs/node/vite/shared/isAsset.js +0 -40
  200. package/dist/cjs/node/vite/shared/isViteCliCall.js +0 -83
  201. package/dist/cjs/node/vite/shared/isViteServerSide.js +0 -68
  202. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +0 -15
  203. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.js +0 -15
  204. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +0 -38
  205. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.js +0 -26
  206. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.js +0 -85
  207. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.js +0 -30
  208. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.js +0 -19
  209. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.js +0 -19
  210. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +0 -29
  211. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.js +0 -13
  212. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.js +0 -15
  213. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +0 -162
  214. package/dist/cjs/node/vite/shared/loggerNotProd/log.js +0 -102
  215. package/dist/cjs/node/vite/shared/loggerNotProd.js +0 -208
  216. package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -26
  217. package/dist/cjs/node/vite/shared/loggerVite.js +0 -54
  218. package/dist/cjs/node/vite/shared/normalizeId.js +0 -9
  219. package/dist/cjs/node/vite/shared/parseEsModule.js +0 -33
  220. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +0 -136
  221. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -262
  222. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles/ignorePatternsBuiltIn.js +0 -18
  223. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +0 -252
  224. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +0 -190
  225. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getConfigFileExport.js +0 -17
  226. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getPlusFilesAll.js +0 -127
  227. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.js +0 -129
  228. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +0 -195
  229. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +0 -102
  230. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +0 -425
  231. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +0 -1151
  232. package/dist/cjs/node/vite/shared/rollupIsEsm.js +0 -15
  233. package/dist/cjs/node/vite/utils.js +0 -45
  234. package/dist/cjs/package.json +0 -1
  235. package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -4
  236. package/dist/cjs/shared/RenderErrorPage.js +0 -6
  237. package/dist/cjs/shared/abort.js +0 -16
  238. package/dist/cjs/shared/addIs404ToPageProps.js +0 -18
  239. package/dist/cjs/shared/assertHookReturnedObject.js +0 -21
  240. package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +0 -21
  241. package/dist/cjs/shared/assertPageContextProvidedByUser.js +0 -20
  242. package/dist/cjs/shared/createGlobalContextShared.js +0 -109
  243. package/dist/cjs/shared/createPageContextShared.js +0 -17
  244. package/dist/cjs/shared/determinePageIdOld.js +0 -11
  245. package/dist/cjs/shared/error-page.js +0 -40
  246. package/dist/cjs/shared/getPageContext.js +0 -6
  247. package/dist/cjs/shared/getPageContextRequestUrl.js +0 -16
  248. package/dist/cjs/shared/getPageContextUrlComputed.js +0 -132
  249. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +0 -19
  250. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/ClientDependency.js +0 -2
  251. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +0 -50
  252. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +0 -30
  253. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +0 -15
  254. package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +0 -59
  255. package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +0 -22
  256. package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +0 -24
  257. package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -52
  258. package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -102
  259. package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -56
  260. package/dist/cjs/shared/getPageFiles/parseVirtualFileExportsGlobalEntry.js +0 -100
  261. package/dist/cjs/shared/getPageFiles.js +0 -7
  262. package/dist/cjs/shared/getProxyForPublicUsage.js +0 -56
  263. package/dist/cjs/shared/hooks/execHook.js +0 -147
  264. package/dist/cjs/shared/hooks/getHook.js +0 -173
  265. package/dist/cjs/shared/htmlElementIds.js +0 -5
  266. package/dist/cjs/shared/misc/isServerSideError.js +0 -4
  267. package/dist/cjs/shared/misc/pageContextInitIsPassedToClient.js +0 -4
  268. package/dist/cjs/shared/modifyUrl.js +0 -28
  269. package/dist/cjs/shared/modifyUrlSameOrigin.js +0 -47
  270. package/dist/cjs/shared/page-configs/assertPlusFileExport.js +0 -42
  271. package/dist/cjs/shared/page-configs/findPageConfig.js +0 -10
  272. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +0 -65
  273. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -68
  274. package/dist/cjs/shared/page-configs/getConfigValueRuntime.js +0 -10
  275. package/dist/cjs/shared/page-configs/getConfigValueTyped.js +0 -32
  276. package/dist/cjs/shared/page-configs/getExportPath.js +0 -29
  277. package/dist/cjs/shared/page-configs/helpers.js +0 -27
  278. package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +0 -25
  279. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +0 -287
  280. package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +0 -2
  281. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -1
  282. package/dist/cjs/shared/page-configs/serialize/parsePageConfigsSerialized.js +0 -145
  283. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +0 -290
  284. package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +0 -10
  285. package/dist/cjs/shared/preparePageContextForPublicUsage.js +0 -80
  286. package/dist/cjs/shared/route/abort.js +0 -178
  287. package/dist/cjs/shared/route/debug.js +0 -23
  288. package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +0 -52
  289. package/dist/cjs/shared/route/execHookGuard.js +0 -37
  290. package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -84
  291. package/dist/cjs/shared/route/index.js +0 -107
  292. package/dist/cjs/shared/route/loadPageRoutes.js +0 -197
  293. package/dist/cjs/shared/route/noRouteMatch.js +0 -4
  294. package/dist/cjs/shared/route/resolvePrecedence.js +0 -93
  295. package/dist/cjs/shared/route/resolveRoute.js +0 -20
  296. package/dist/cjs/shared/route/resolveRouteFunction.js +0 -73
  297. package/dist/cjs/shared/route/resolveRouteString.js +0 -153
  298. package/dist/cjs/shared/route/resolveUrlPathname.js +0 -47
  299. package/dist/cjs/shared/route/routing.js +0 -9
  300. package/dist/cjs/shared/route/utils.js +0 -40
  301. package/dist/cjs/shared/utils.js +0 -49
  302. package/dist/cjs/types/Config/ConfigResolved.js +0 -2
  303. package/dist/cjs/types/Config.js +0 -2
  304. package/dist/cjs/types/FilePath.js +0 -2
  305. package/dist/cjs/types/PageConfig.js +0 -2
  306. package/dist/cjs/types/PageContext.js +0 -2
  307. package/dist/cjs/types/VikeGlobalInternal.js +0 -2
  308. package/dist/cjs/types/VikeNamespace.js +0 -2
  309. package/dist/cjs/types/ViteManifest.js +0 -2
  310. package/dist/cjs/types/defineConfig.js +0 -6
  311. package/dist/cjs/types/index-dreprecated.js +0 -3
  312. package/dist/cjs/types/index.js +0 -5
  313. package/dist/cjs/utils/PROJECT_VERSION.js +0 -5
  314. package/dist/cjs/utils/PromiseType.js +0 -2
  315. package/dist/cjs/utils/assert.js +0 -211
  316. package/dist/cjs/utils/assertIsBrowser.js +0 -8
  317. package/dist/cjs/utils/assertIsNotBrowser.js +0 -9
  318. package/dist/cjs/utils/assertKeys.js +0 -27
  319. package/dist/cjs/utils/assertNodeVersion.js +0 -14
  320. package/dist/cjs/utils/assertRoutingType.js +0 -29
  321. package/dist/cjs/utils/assertSetup.js +0 -171
  322. package/dist/cjs/utils/assertSingleInstance.js +0 -110
  323. package/dist/cjs/utils/assertVersion.js +0 -60
  324. package/dist/cjs/utils/capitalizeFirstLetter.js +0 -9
  325. package/dist/cjs/utils/cast.js +0 -6
  326. package/dist/cjs/utils/catchInfiniteLoop.js +0 -34
  327. package/dist/cjs/utils/changeEnumerable.js +0 -8
  328. package/dist/cjs/utils/checkType.js +0 -6
  329. package/dist/cjs/utils/compareString.js +0 -10
  330. package/dist/cjs/utils/createErrorWithCleanStackTrace.js +0 -39
  331. package/dist/cjs/utils/debug.js +0 -178
  332. package/dist/cjs/utils/debugGlob.js +0 -6
  333. package/dist/cjs/utils/deepEqual.js +0 -10
  334. package/dist/cjs/utils/escapeHtml.js +0 -13
  335. package/dist/cjs/utils/escapeRegex.js +0 -7
  336. package/dist/cjs/utils/findFile.js +0 -30
  337. package/dist/cjs/utils/findPackageJson.js +0 -18
  338. package/dist/cjs/utils/formatHintLog.js +0 -17
  339. package/dist/cjs/utils/freezePartial.js +0 -35
  340. package/dist/cjs/utils/genPromise.js +0 -51
  341. package/dist/cjs/utils/getFileExtension.js +0 -16
  342. package/dist/cjs/utils/getGlobalObject.js +0 -15
  343. package/dist/cjs/utils/getMostSimilar.js +0 -68
  344. package/dist/cjs/utils/getPropAccessNotation.js +0 -9
  345. package/dist/cjs/utils/getRandomId.js +0 -14
  346. package/dist/cjs/utils/getTerminalWidth.js +0 -7
  347. package/dist/cjs/utils/getValuePrintable.js +0 -10
  348. package/dist/cjs/utils/getViteRPC.js +0 -79
  349. package/dist/cjs/utils/hasProp.js +0 -50
  350. package/dist/cjs/utils/humanizeTime.js +0 -24
  351. package/dist/cjs/utils/includes.js +0 -13
  352. package/dist/cjs/utils/injectRollupInputs.js +0 -29
  353. package/dist/cjs/utils/isArray.js +0 -7
  354. package/dist/cjs/utils/isArrayOfStrings.js +0 -7
  355. package/dist/cjs/utils/isBrowser.js +0 -8
  356. package/dist/cjs/utils/isCallable.js +0 -6
  357. package/dist/cjs/utils/isDev.js +0 -20
  358. package/dist/cjs/utils/isDocker.js +0 -45
  359. package/dist/cjs/utils/isEqualStringList.js +0 -13
  360. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +0 -66
  361. package/dist/cjs/utils/isHtml.js +0 -9
  362. package/dist/cjs/utils/isImportPath.js +0 -21
  363. package/dist/cjs/utils/isNodeJS.js +0 -16
  364. package/dist/cjs/utils/isNonRunnableDev.js +0 -12
  365. package/dist/cjs/utils/isNullish.js +0 -16
  366. package/dist/cjs/utils/isObject.js +0 -6
  367. package/dist/cjs/utils/isObjectOfStrings.js +0 -7
  368. package/dist/cjs/utils/isObjectWithKeys.js +0 -15
  369. package/dist/cjs/utils/isPlainObject.js +0 -19
  370. package/dist/cjs/utils/isPromise.js +0 -7
  371. package/dist/cjs/utils/isPropertyGetter.js +0 -7
  372. package/dist/cjs/utils/isReact.js +0 -23
  373. package/dist/cjs/utils/isRunnableDevEnvironment.js +0 -9
  374. package/dist/cjs/utils/isSameErrorMessage.js +0 -9
  375. package/dist/cjs/utils/isScriptFile.js +0 -67
  376. package/dist/cjs/utils/isVikeReactApp.js +0 -8
  377. package/dist/cjs/utils/isVitest.js +0 -6
  378. package/dist/cjs/utils/joinEnglish.js +0 -14
  379. package/dist/cjs/utils/normalizeHeaders.js +0 -17
  380. package/dist/cjs/utils/objectAssign.js +0 -14
  381. package/dist/cjs/utils/objectAssignSafe.js +0 -7
  382. package/dist/cjs/utils/objectDefineProperty.js +0 -7
  383. package/dist/cjs/utils/objectEntries.js +0 -8
  384. package/dist/cjs/utils/objectEntriesForEach.js +0 -7
  385. package/dist/cjs/utils/objectFilter.js +0 -10
  386. package/dist/cjs/utils/objectFromEntries.js +0 -7
  387. package/dist/cjs/utils/objectKeys.js +0 -9
  388. package/dist/cjs/utils/objectReplace.js +0 -9
  389. package/dist/cjs/utils/onPageVisibilityChange.js +0 -18
  390. package/dist/cjs/utils/pLimit.js +0 -134
  391. package/dist/cjs/utils/parseNpmPackage.js +0 -106
  392. package/dist/cjs/utils/parseUrl-extras.js +0 -110
  393. package/dist/cjs/utils/parseUrl.js +0 -338
  394. package/dist/cjs/utils/path.js +0 -59
  395. package/dist/cjs/utils/pick.js +0 -12
  396. package/dist/cjs/utils/preservePropertyGetters.js +0 -30
  397. package/dist/cjs/utils/redirectHard.js +0 -6
  398. package/dist/cjs/utils/removeEmptyLines.js +0 -9
  399. package/dist/cjs/utils/removeFileExtension.js +0 -6
  400. package/dist/cjs/utils/requireResolve.js +0 -214
  401. package/dist/cjs/utils/rollupSourceMap.js +0 -19
  402. package/dist/cjs/utils/sleep.js +0 -6
  403. package/dist/cjs/utils/slice.js +0 -35
  404. package/dist/cjs/utils/sorter.js +0 -117
  405. package/dist/cjs/utils/stringifyStringArray.js +0 -6
  406. package/dist/cjs/utils/stripAnsi.js +0 -21
  407. package/dist/cjs/utils/styleFileRE.js +0 -6
  408. package/dist/cjs/utils/throttle.js +0 -15
  409. package/dist/cjs/utils/trackLogs.js +0 -31
  410. package/dist/cjs/utils/trimWithAnsi.js +0 -40
  411. package/dist/cjs/utils/truncateString.js +0 -23
  412. package/dist/cjs/utils/unique.js +0 -6
  413. package/dist/cjs/utils/updateType.js +0 -9
  414. package/dist/cjs/utils/urlToFile.js +0 -36
  415. package/dist/cjs/utils/virtualFileId.js +0 -43
  416. package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
  417. package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
  418. package/dist/esm/node/vite/plugins/pluginBuild.js +0 -19
  419. package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -14
  420. 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
- }