vike 0.4.239-commit-59f1017 → 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 (415) 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.js +1 -0
  5. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
  6. package/dist/esm/client/runtime-server-routing/entry.js +5 -0
  7. package/dist/esm/client/runtime-server-routing/globalContext.d.ts +2 -2
  8. package/dist/esm/client/runtime-server-routing/globalContext.js +7 -3
  9. package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +4 -3
  10. package/dist/esm/client/shared/createGetGlobalContextClient.js +38 -34
  11. package/dist/esm/node/vite/index.js +34 -15
  12. package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
  13. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +37 -35
  14. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.d.ts +1 -1
  15. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +82 -80
  16. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.d.ts +1 -1
  17. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +23 -21
  18. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.d.ts +1 -1
  19. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +38 -36
  20. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.d.ts +1 -1
  21. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +26 -24
  22. package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
  23. package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +1 -1
  24. package/dist/esm/node/vite/plugins/pluginEnvVars.js +87 -65
  25. package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
  26. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +29 -27
  27. package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
  28. package/dist/esm/node/vite/plugins/pluginFileEnv.js +75 -73
  29. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +1 -1
  30. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +30 -28
  31. package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
  32. package/dist/esm/node/vite/plugins/pluginPreview.js +35 -33
  33. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +9 -0
  34. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +45 -0
  35. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +3 -0
  36. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.js +89 -0
  37. package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
  38. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +50 -48
  39. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
  40. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +12 -10
  41. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
  42. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
  43. package/dist/esm/shared/createGlobalContextShared.js +1 -0
  44. package/dist/esm/shared/route/abort.d.ts +22 -11
  45. package/dist/esm/shared/route/abort.js +37 -5
  46. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  47. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  48. package/dist/esm/utils/findPackageJson.js +0 -1
  49. package/dist/esm/utils/getViteRPC.js +0 -2
  50. package/dist/esm/utils/requireResolve.js +0 -1
  51. package/package.json +2 -21
  52. package/dist/cjs/__internal/index.js +0 -35
  53. package/dist/cjs/client/runtime-client-routing/globalContext.js +0 -49
  54. package/dist/cjs/client/runtime-client-routing/prefetch/PrefetchSetting.js +0 -2
  55. package/dist/cjs/client/runtime-server-routing/globalContext.js +0 -41
  56. package/dist/cjs/client/runtime-server-routing/onLoad.js +0 -7
  57. package/dist/cjs/client/runtime-server-routing/utils.js +0 -34
  58. package/dist/cjs/client/shared/createGetGlobalContextClient.js +0 -65
  59. package/dist/cjs/client/shared/getJsonSerializedInHtml.js +0 -40
  60. package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +0 -41
  61. package/dist/cjs/client/shared/utils.js +0 -23
  62. package/dist/cjs/node/api/build.js +0 -24
  63. package/dist/cjs/node/api/context.js +0 -23
  64. package/dist/cjs/node/api/dev.js +0 -18
  65. package/dist/cjs/node/api/index.js +0 -44
  66. package/dist/cjs/node/api/onLoad.js +0 -9
  67. package/dist/cjs/node/api/prepareViteApiCall.js +0 -206
  68. package/dist/cjs/node/api/prerender.js +0 -18
  69. package/dist/cjs/node/api/preview.js +0 -38
  70. package/dist/cjs/node/api/types.js +0 -2
  71. package/dist/cjs/node/api/utils.js +0 -27
  72. package/dist/cjs/node/cli/context.js +0 -17
  73. package/dist/cjs/node/cli/entry.js +0 -121
  74. package/dist/cjs/node/cli/index.js +0 -12
  75. package/dist/cjs/node/cli/onLoad.js +0 -9
  76. package/dist/cjs/node/cli/parseCli.js +0 -95
  77. package/dist/cjs/node/cli/utils.js +0 -24
  78. package/dist/cjs/node/client/router.js +0 -19
  79. package/dist/cjs/node/createPageRenderer.js +0 -132
  80. package/dist/cjs/node/importBuild.js +0 -3
  81. package/dist/cjs/node/prerender/context.js +0 -26
  82. package/dist/cjs/node/prerender/index.js +0 -12
  83. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +0 -66
  84. package/dist/cjs/node/prerender/runPrerender.js +0 -778
  85. package/dist/cjs/node/prerender/runPrerenderEntry.js +0 -55
  86. package/dist/cjs/node/prerender/utils.js +0 -37
  87. package/dist/cjs/node/runtime/globalContext.js +0 -582
  88. package/dist/cjs/node/runtime/index-deprecated.js +0 -33
  89. package/dist/cjs/node/runtime/index.js +0 -74
  90. package/dist/cjs/node/runtime/loggerRuntime.js +0 -17
  91. package/dist/cjs/node/runtime/onLoad.js +0 -29
  92. package/dist/cjs/node/runtime/page-files/setup.js +0 -5
  93. package/dist/cjs/node/runtime/renderPage/analyzePage.js +0 -71
  94. package/dist/cjs/node/runtime/renderPage/assertArguments.js +0 -42
  95. package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +0 -51
  96. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -114
  97. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +0 -59
  98. package/dist/cjs/node/runtime/renderPage/csp.js +0 -47
  99. package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +0 -31
  100. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +0 -120
  101. package/dist/cjs/node/runtime/renderPage/execHookServer.js +0 -8
  102. package/dist/cjs/node/runtime/renderPage/getCacheControl.js +0 -24
  103. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +0 -20
  104. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +0 -137
  105. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +0 -125
  106. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.js +0 -86
  107. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.js +0 -77
  108. package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +0 -36
  109. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +0 -50
  110. package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +0 -41
  111. package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +0 -68
  112. package/dist/cjs/node/runtime/renderPage/headersResponse.js +0 -48
  113. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getHtmlTags.js +0 -269
  114. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getViteDevScript.js +0 -32
  115. package/dist/cjs/node/runtime/renderPage/html/injectAssets/inferHtmlTags.js +0 -55
  116. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectAssets__public.js +0 -31
  117. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectHtmlTags.js +0 -161
  118. package/dist/cjs/node/runtime/renderPage/html/injectAssets/mergeScriptTags.js +0 -73
  119. package/dist/cjs/node/runtime/renderPage/html/injectAssets/sanitizeJson.js +0 -8
  120. package/dist/cjs/node/runtime/renderPage/html/injectAssets.js +0 -93
  121. package/dist/cjs/node/runtime/renderPage/html/propKeys.js +0 -47
  122. package/dist/cjs/node/runtime/renderPage/html/renderHtml.js +0 -245
  123. package/dist/cjs/node/runtime/renderPage/html/serializeContext.js +0 -189
  124. package/dist/cjs/node/runtime/renderPage/html/stream/react-streaming.js +0 -36
  125. package/dist/cjs/node/runtime/renderPage/html/stream.js +0 -829
  126. package/dist/cjs/node/runtime/renderPage/inferMediaType.js +0 -81
  127. package/dist/cjs/node/runtime/renderPage/isFontFallback.js +0 -29
  128. package/dist/cjs/node/runtime/renderPage/isNewError.js +0 -25
  129. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +0 -124
  130. package/dist/cjs/node/runtime/renderPage/log404/index.js +0 -154
  131. package/dist/cjs/node/runtime/renderPage/logErrorHint/errors.js +0 -20
  132. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +0 -200
  133. package/dist/cjs/node/runtime/renderPage/loggerProd.js +0 -34
  134. package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +0 -10
  135. package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +0 -83
  136. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -71
  137. package/dist/cjs/node/runtime/renderPage.js +0 -502
  138. package/dist/cjs/node/runtime/universal-middleware.js +0 -20
  139. package/dist/cjs/node/runtime/utils.js +0 -83
  140. package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -27
  141. package/dist/cjs/node/runtime-dev/index.js +0 -42
  142. package/dist/cjs/node/shared/assertV1Design.js +0 -30
  143. package/dist/cjs/node/shared/extractAssetsQuery.js +0 -29
  144. package/dist/cjs/node/shared/getVikeConfigError.js +0 -22
  145. package/dist/cjs/node/shared/isErrorDebug.js +0 -7
  146. package/dist/cjs/node/shared/prependEntriesDir.js +0 -13
  147. package/dist/cjs/node/shared/resolveBase.js +0 -35
  148. package/dist/cjs/node/shared/utils.js +0 -35
  149. package/dist/cjs/node/shared/virtualFileId.js +0 -110
  150. package/dist/cjs/node/vite/index.js +0 -69
  151. package/dist/cjs/node/vite/onLoad.js +0 -21
  152. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +0 -52
  153. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -357
  154. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -183
  155. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -234
  156. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -256
  157. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -40
  158. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -49
  159. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -111
  160. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -65
  161. package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -22
  162. package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
  163. package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -183
  164. package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -28
  165. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +0 -163
  166. package/dist/cjs/node/vite/plugins/pluginDev.js +0 -111
  167. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -92
  168. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -241
  169. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -113
  170. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -172
  171. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -70
  172. package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -82
  173. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -95
  174. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -51
  175. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/debug.js +0 -5
  176. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +0 -56
  177. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +0 -190
  178. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +0 -54
  179. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +0 -97
  180. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +0 -233
  181. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -17
  182. package/dist/cjs/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +0 -35
  183. package/dist/cjs/node/vite/shared/addSsrMiddleware.js +0 -60
  184. package/dist/cjs/node/vite/shared/findPageFiles.js +0 -25
  185. package/dist/cjs/node/vite/shared/getAssetsDir.js +0 -10
  186. package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +0 -42
  187. package/dist/cjs/node/vite/shared/getEnvVarObject.js +0 -37
  188. package/dist/cjs/node/vite/shared/getFilePath.js +0 -172
  189. package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +0 -125
  190. package/dist/cjs/node/vite/shared/getMagicString.js +0 -18
  191. package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +0 -10
  192. package/dist/cjs/node/vite/shared/getOutDirs.js +0 -146
  193. package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +0 -21
  194. package/dist/cjs/node/vite/shared/isAsset.js +0 -40
  195. package/dist/cjs/node/vite/shared/isViteCliCall.js +0 -83
  196. package/dist/cjs/node/vite/shared/isViteServerSide.js +0 -68
  197. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +0 -15
  198. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.js +0 -15
  199. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +0 -38
  200. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.js +0 -26
  201. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.js +0 -85
  202. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.js +0 -30
  203. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.js +0 -19
  204. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.js +0 -19
  205. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +0 -29
  206. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.js +0 -13
  207. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.js +0 -15
  208. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +0 -162
  209. package/dist/cjs/node/vite/shared/loggerNotProd/log.js +0 -102
  210. package/dist/cjs/node/vite/shared/loggerNotProd.js +0 -208
  211. package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -26
  212. package/dist/cjs/node/vite/shared/loggerVite.js +0 -54
  213. package/dist/cjs/node/vite/shared/normalizeId.js +0 -9
  214. package/dist/cjs/node/vite/shared/parseEsModule.js +0 -33
  215. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +0 -136
  216. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -262
  217. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles/ignorePatternsBuiltIn.js +0 -18
  218. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +0 -252
  219. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +0 -190
  220. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getConfigFileExport.js +0 -17
  221. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getPlusFilesAll.js +0 -127
  222. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.js +0 -129
  223. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +0 -195
  224. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +0 -102
  225. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +0 -425
  226. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +0 -1151
  227. package/dist/cjs/node/vite/shared/rollupIsEsm.js +0 -15
  228. package/dist/cjs/node/vite/utils.js +0 -45
  229. package/dist/cjs/package.json +0 -1
  230. package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -4
  231. package/dist/cjs/shared/RenderErrorPage.js +0 -6
  232. package/dist/cjs/shared/abort.js +0 -16
  233. package/dist/cjs/shared/addIs404ToPageProps.js +0 -18
  234. package/dist/cjs/shared/assertHookReturnedObject.js +0 -21
  235. package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +0 -21
  236. package/dist/cjs/shared/assertPageContextProvidedByUser.js +0 -20
  237. package/dist/cjs/shared/createGlobalContextShared.js +0 -109
  238. package/dist/cjs/shared/createPageContextShared.js +0 -17
  239. package/dist/cjs/shared/determinePageIdOld.js +0 -11
  240. package/dist/cjs/shared/error-page.js +0 -40
  241. package/dist/cjs/shared/getPageContext.js +0 -6
  242. package/dist/cjs/shared/getPageContextRequestUrl.js +0 -16
  243. package/dist/cjs/shared/getPageContextUrlComputed.js +0 -132
  244. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +0 -19
  245. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/ClientDependency.js +0 -2
  246. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +0 -50
  247. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +0 -30
  248. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +0 -15
  249. package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +0 -59
  250. package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +0 -22
  251. package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +0 -24
  252. package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -52
  253. package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -102
  254. package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -56
  255. package/dist/cjs/shared/getPageFiles/parseVirtualFileExportsGlobalEntry.js +0 -100
  256. package/dist/cjs/shared/getPageFiles.js +0 -7
  257. package/dist/cjs/shared/getProxyForPublicUsage.js +0 -56
  258. package/dist/cjs/shared/hooks/execHook.js +0 -147
  259. package/dist/cjs/shared/hooks/getHook.js +0 -173
  260. package/dist/cjs/shared/htmlElementIds.js +0 -5
  261. package/dist/cjs/shared/misc/isServerSideError.js +0 -4
  262. package/dist/cjs/shared/misc/pageContextInitIsPassedToClient.js +0 -4
  263. package/dist/cjs/shared/modifyUrl.js +0 -28
  264. package/dist/cjs/shared/modifyUrlSameOrigin.js +0 -47
  265. package/dist/cjs/shared/page-configs/assertPlusFileExport.js +0 -42
  266. package/dist/cjs/shared/page-configs/findPageConfig.js +0 -10
  267. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +0 -65
  268. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -68
  269. package/dist/cjs/shared/page-configs/getConfigValueRuntime.js +0 -10
  270. package/dist/cjs/shared/page-configs/getConfigValueTyped.js +0 -32
  271. package/dist/cjs/shared/page-configs/getExportPath.js +0 -29
  272. package/dist/cjs/shared/page-configs/helpers.js +0 -27
  273. package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +0 -25
  274. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +0 -287
  275. package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +0 -2
  276. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -1
  277. package/dist/cjs/shared/page-configs/serialize/parsePageConfigsSerialized.js +0 -145
  278. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +0 -290
  279. package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +0 -10
  280. package/dist/cjs/shared/preparePageContextForPublicUsage.js +0 -80
  281. package/dist/cjs/shared/route/abort.js +0 -178
  282. package/dist/cjs/shared/route/debug.js +0 -23
  283. package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +0 -52
  284. package/dist/cjs/shared/route/execHookGuard.js +0 -37
  285. package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -84
  286. package/dist/cjs/shared/route/index.js +0 -107
  287. package/dist/cjs/shared/route/loadPageRoutes.js +0 -197
  288. package/dist/cjs/shared/route/noRouteMatch.js +0 -4
  289. package/dist/cjs/shared/route/resolvePrecedence.js +0 -93
  290. package/dist/cjs/shared/route/resolveRoute.js +0 -20
  291. package/dist/cjs/shared/route/resolveRouteFunction.js +0 -73
  292. package/dist/cjs/shared/route/resolveRouteString.js +0 -153
  293. package/dist/cjs/shared/route/resolveUrlPathname.js +0 -47
  294. package/dist/cjs/shared/route/routing.js +0 -9
  295. package/dist/cjs/shared/route/utils.js +0 -40
  296. package/dist/cjs/shared/utils.js +0 -49
  297. package/dist/cjs/types/Config/ConfigResolved.js +0 -2
  298. package/dist/cjs/types/Config.js +0 -2
  299. package/dist/cjs/types/FilePath.js +0 -2
  300. package/dist/cjs/types/PageConfig.js +0 -2
  301. package/dist/cjs/types/PageContext.js +0 -2
  302. package/dist/cjs/types/VikeGlobalInternal.js +0 -2
  303. package/dist/cjs/types/VikeNamespace.js +0 -2
  304. package/dist/cjs/types/ViteManifest.js +0 -2
  305. package/dist/cjs/types/defineConfig.js +0 -6
  306. package/dist/cjs/types/index-dreprecated.js +0 -3
  307. package/dist/cjs/types/index.js +0 -5
  308. package/dist/cjs/utils/PROJECT_VERSION.js +0 -5
  309. package/dist/cjs/utils/PromiseType.js +0 -2
  310. package/dist/cjs/utils/assert.js +0 -211
  311. package/dist/cjs/utils/assertIsBrowser.js +0 -8
  312. package/dist/cjs/utils/assertIsNotBrowser.js +0 -9
  313. package/dist/cjs/utils/assertKeys.js +0 -27
  314. package/dist/cjs/utils/assertNodeVersion.js +0 -14
  315. package/dist/cjs/utils/assertRoutingType.js +0 -29
  316. package/dist/cjs/utils/assertSetup.js +0 -171
  317. package/dist/cjs/utils/assertSingleInstance.js +0 -110
  318. package/dist/cjs/utils/assertVersion.js +0 -60
  319. package/dist/cjs/utils/capitalizeFirstLetter.js +0 -9
  320. package/dist/cjs/utils/cast.js +0 -6
  321. package/dist/cjs/utils/catchInfiniteLoop.js +0 -34
  322. package/dist/cjs/utils/changeEnumerable.js +0 -8
  323. package/dist/cjs/utils/checkType.js +0 -6
  324. package/dist/cjs/utils/compareString.js +0 -10
  325. package/dist/cjs/utils/createErrorWithCleanStackTrace.js +0 -39
  326. package/dist/cjs/utils/debug.js +0 -178
  327. package/dist/cjs/utils/debugGlob.js +0 -6
  328. package/dist/cjs/utils/deepEqual.js +0 -10
  329. package/dist/cjs/utils/escapeHtml.js +0 -13
  330. package/dist/cjs/utils/escapeRegex.js +0 -7
  331. package/dist/cjs/utils/findFile.js +0 -30
  332. package/dist/cjs/utils/findPackageJson.js +0 -18
  333. package/dist/cjs/utils/formatHintLog.js +0 -17
  334. package/dist/cjs/utils/freezePartial.js +0 -35
  335. package/dist/cjs/utils/genPromise.js +0 -51
  336. package/dist/cjs/utils/getFileExtension.js +0 -16
  337. package/dist/cjs/utils/getGlobalObject.js +0 -15
  338. package/dist/cjs/utils/getMostSimilar.js +0 -68
  339. package/dist/cjs/utils/getPropAccessNotation.js +0 -9
  340. package/dist/cjs/utils/getRandomId.js +0 -14
  341. package/dist/cjs/utils/getTerminalWidth.js +0 -7
  342. package/dist/cjs/utils/getValuePrintable.js +0 -10
  343. package/dist/cjs/utils/getViteRPC.js +0 -79
  344. package/dist/cjs/utils/hasProp.js +0 -50
  345. package/dist/cjs/utils/humanizeTime.js +0 -24
  346. package/dist/cjs/utils/includes.js +0 -13
  347. package/dist/cjs/utils/injectRollupInputs.js +0 -29
  348. package/dist/cjs/utils/isArray.js +0 -7
  349. package/dist/cjs/utils/isArrayOfStrings.js +0 -7
  350. package/dist/cjs/utils/isBrowser.js +0 -8
  351. package/dist/cjs/utils/isCallable.js +0 -6
  352. package/dist/cjs/utils/isDev.js +0 -20
  353. package/dist/cjs/utils/isDocker.js +0 -45
  354. package/dist/cjs/utils/isEqualStringList.js +0 -13
  355. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +0 -66
  356. package/dist/cjs/utils/isHtml.js +0 -9
  357. package/dist/cjs/utils/isImportPath.js +0 -21
  358. package/dist/cjs/utils/isNodeJS.js +0 -16
  359. package/dist/cjs/utils/isNonRunnableDev.js +0 -12
  360. package/dist/cjs/utils/isNullish.js +0 -16
  361. package/dist/cjs/utils/isObject.js +0 -6
  362. package/dist/cjs/utils/isObjectOfStrings.js +0 -7
  363. package/dist/cjs/utils/isObjectWithKeys.js +0 -15
  364. package/dist/cjs/utils/isPlainObject.js +0 -19
  365. package/dist/cjs/utils/isPromise.js +0 -7
  366. package/dist/cjs/utils/isPropertyGetter.js +0 -7
  367. package/dist/cjs/utils/isReact.js +0 -23
  368. package/dist/cjs/utils/isRunnableDevEnvironment.js +0 -9
  369. package/dist/cjs/utils/isSameErrorMessage.js +0 -9
  370. package/dist/cjs/utils/isScriptFile.js +0 -67
  371. package/dist/cjs/utils/isVikeReactApp.js +0 -8
  372. package/dist/cjs/utils/isVitest.js +0 -6
  373. package/dist/cjs/utils/joinEnglish.js +0 -14
  374. package/dist/cjs/utils/normalizeHeaders.js +0 -17
  375. package/dist/cjs/utils/objectAssign.js +0 -14
  376. package/dist/cjs/utils/objectAssignSafe.js +0 -7
  377. package/dist/cjs/utils/objectDefineProperty.js +0 -7
  378. package/dist/cjs/utils/objectEntries.js +0 -8
  379. package/dist/cjs/utils/objectEntriesForEach.js +0 -7
  380. package/dist/cjs/utils/objectFilter.js +0 -10
  381. package/dist/cjs/utils/objectFromEntries.js +0 -7
  382. package/dist/cjs/utils/objectKeys.js +0 -9
  383. package/dist/cjs/utils/objectReplace.js +0 -9
  384. package/dist/cjs/utils/onPageVisibilityChange.js +0 -18
  385. package/dist/cjs/utils/pLimit.js +0 -134
  386. package/dist/cjs/utils/parseNpmPackage.js +0 -106
  387. package/dist/cjs/utils/parseUrl-extras.js +0 -110
  388. package/dist/cjs/utils/parseUrl.js +0 -338
  389. package/dist/cjs/utils/path.js +0 -59
  390. package/dist/cjs/utils/pick.js +0 -12
  391. package/dist/cjs/utils/preservePropertyGetters.js +0 -30
  392. package/dist/cjs/utils/redirectHard.js +0 -6
  393. package/dist/cjs/utils/removeEmptyLines.js +0 -9
  394. package/dist/cjs/utils/removeFileExtension.js +0 -6
  395. package/dist/cjs/utils/requireResolve.js +0 -214
  396. package/dist/cjs/utils/rollupSourceMap.js +0 -19
  397. package/dist/cjs/utils/sleep.js +0 -6
  398. package/dist/cjs/utils/slice.js +0 -35
  399. package/dist/cjs/utils/sorter.js +0 -117
  400. package/dist/cjs/utils/stringifyStringArray.js +0 -6
  401. package/dist/cjs/utils/stripAnsi.js +0 -21
  402. package/dist/cjs/utils/styleFileRE.js +0 -6
  403. package/dist/cjs/utils/throttle.js +0 -15
  404. package/dist/cjs/utils/trackLogs.js +0 -31
  405. package/dist/cjs/utils/trimWithAnsi.js +0 -40
  406. package/dist/cjs/utils/truncateString.js +0 -23
  407. package/dist/cjs/utils/unique.js +0 -6
  408. package/dist/cjs/utils/updateType.js +0 -9
  409. package/dist/cjs/utils/urlToFile.js +0 -36
  410. package/dist/cjs/utils/virtualFileId.js +0 -43
  411. package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
  412. package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
  413. package/dist/esm/node/vite/plugins/pluginBuild.js +0 -20
  414. package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -14
  415. package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -92
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPageAssets = getPageAssets;
4
- const retrievePageAssetsProd_js_1 = require("./getPageAssets/retrievePageAssetsProd.js");
5
- const retrievePageAssetsDev_js_1 = require("./getPageAssets/retrievePageAssetsDev.js");
6
- const inferMediaType_js_1 = require("./inferMediaType.js");
7
- const sortPageAssetsForEarlyHintsHeader_js_1 = require("./getPageAssets/sortPageAssetsForEarlyHintsHeader.js");
8
- const utils_js_1 = require("../utils.js");
9
- async function getPageAssets(pageContext, clientDependencies, clientEntries) {
10
- const globalContext = pageContext._globalContext;
11
- const { _isProduction: isProduction } = globalContext;
12
- const isDev = !isProduction;
13
- const { assetUrls, clientEntriesSrc } = isDev
14
- ? !globalContext._viteDevServer
15
- ? await (0, utils_js_1.getViteRPC)().retrievePageAssetsDevRPC(clientDependencies, clientEntries)
16
- : await (0, retrievePageAssetsDev_js_1.retrievePageAssetsDev)(globalContext._viteDevServer, clientDependencies, clientEntries)
17
- : (0, retrievePageAssetsProd_js_1.retrievePageAssetsProd)(globalContext.assetsManifest, clientDependencies, clientEntries, globalContext.config);
18
- let pageAssets = [];
19
- (0, utils_js_1.unique)([...clientEntriesSrc, ...assetUrls]).forEach((src) => {
20
- const { mediaType = null, assetType = null } = (0, inferMediaType_js_1.inferMediaType)(src) || {};
21
- if (isDev && assetType === 'style') {
22
- // https://github.com/vikejs/vike/issues/449
23
- if (src.endsWith('?inline')) {
24
- return;
25
- }
26
- // https://github.com/vikejs/vike/issues/401
27
- // WARNING: if changing following line, then also update https://github.com/vikejs/vike/blob/fae90a15d88e5e87ca9fcbb54cf2dc8773d2f229/vike/client/shared/removeFoucBuster.ts#L28
28
- src = src + '?direct';
29
- }
30
- const isEntry = clientEntriesSrc.includes(src) ||
31
- // Vite automatically injects CSS, not only in development, but also in production (albeit with a FOUC). Therefore, strictly speaking, CSS aren't entries. We still, however, set `isEntry: true` for CSS, in order to denote page assets that should absolutely be injected in the HTML, regardless of preload strategy (not injecting CSS leads to FOUC).
32
- assetType === 'style';
33
- pageAssets.push({
34
- src,
35
- assetType,
36
- mediaType,
37
- isEntry,
38
- });
39
- });
40
- pageAssets.forEach(({ src }) => {
41
- (0, utils_js_1.assert)(1 === pageAssets.filter((p) => p.src === src).length);
42
- });
43
- pageAssets = pageAssets.map((pageAsset) => {
44
- const baseServerAssets = pageContext._baseAssets || pageContext._baseServer;
45
- pageAsset.src = (0, utils_js_1.prependBase)((0, utils_js_1.toPosixPath)(pageAsset.src), baseServerAssets);
46
- return pageAsset;
47
- });
48
- await (0, sortPageAssetsForEarlyHintsHeader_js_1.sortPageAssetsForEarlyHintsHeader)(pageAssets, isProduction);
49
- return pageAssets;
50
- }
@@ -1,41 +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.handleErrorWithoutErrorPage = handleErrorWithoutErrorPage;
7
- const stringify_1 = require("@brillout/json-serializer/stringify");
8
- const utils_js_1 = require("../utils.js");
9
- const createHttpResponse_js_1 = require("./createHttpResponse.js");
10
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
11
- // When the user hasn't defined _error.page.js
12
- async function handleErrorWithoutErrorPage(pageContext) {
13
- (0, utils_js_1.assert)(pageContext.pageId === null);
14
- (0, utils_js_1.assert)(pageContext.errorWhileRendering || pageContext.is404);
15
- {
16
- const isV1 = pageContext._globalContext._pageConfigs.length > 0;
17
- await warnMissingErrorPage(isV1, pageContext._globalContext._isProduction);
18
- }
19
- if (!pageContext.isClientSideNavigation) {
20
- const httpResponse = (0, createHttpResponse_js_1.createHttpResponseError)(pageContext);
21
- (0, utils_js_1.objectAssign)(pageContext, { httpResponse });
22
- return pageContext;
23
- }
24
- else {
25
- const __getPageAssets = async () => [];
26
- (0, utils_js_1.objectAssign)(pageContext, { __getPageAssets });
27
- const httpResponse = await (0, createHttpResponse_js_1.createHttpResponsePage)((0, stringify_1.stringify)({ serverSideError: true }), null, pageContext);
28
- (0, utils_js_1.objectAssign)(pageContext, { httpResponse });
29
- return pageContext;
30
- }
31
- }
32
- async function warnMissingErrorPage(isV1, isProduction) {
33
- if (!isProduction) {
34
- const msg = [
35
- `No ${isV1 ? 'error page' : picocolors_1.default.cyan('_error.page.js')} found,`,
36
- 'we recommend defining one',
37
- 'https://vike.dev/error-page',
38
- ].join(' ');
39
- (0, utils_js_1.assertWarning)(false, msg, { onlyOnce: true });
40
- }
41
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handlePageContextRequestUrl = handlePageContextRequestUrl;
4
- const getPageContextRequestUrl_js_1 = require("../../../shared/getPageContextRequestUrl.js");
5
- const modifyUrl_js_1 = require("../../../shared/modifyUrl.js");
6
- const utils_js_1 = require("../utils.js");
7
- // See also shared/getPageContextRequestUrl.ts
8
- function handlePageContextRequestUrl(url) {
9
- const urlParsed = (0, utils_js_1.parseUrl)(url, utils_js_1.baseServer);
10
- if (!isMatch(urlParsed)) {
11
- return {
12
- isPageContextJsonRequest: false,
13
- urlWithoutPageContextRequestSuffix: url,
14
- };
15
- }
16
- else {
17
- const { urlWithoutPageContextRequestSuffix, searchVikeArgs } = processUrl(urlParsed, url);
18
- const previousUrl = parseSearchVikeArgs(searchVikeArgs);
19
- return {
20
- /* TO-DO/soon/once: pass & use previousUrl
21
- isPageContextJsonRequest: { previousUrl },
22
- /*/
23
- isPageContextJsonRequest: true,
24
- //*/
25
- urlWithoutPageContextRequestSuffix,
26
- };
27
- }
28
- }
29
- function isMatch(urlParsed) {
30
- const { pathnameOriginal, pathname } = urlParsed;
31
- (0, utils_js_1.assert)(pathname.endsWith(getPageContextRequestUrl_js_1.pageContextJsonFileExtension) === pathnameOriginal.endsWith(getPageContextRequestUrl_js_1.pageContextJsonFileExtension));
32
- return pathname.endsWith(getPageContextRequestUrl_js_1.pageContextJsonFileExtension);
33
- }
34
- function processUrl(urlParsed, url) {
35
- // We cannot use `urlParsed.pathname` because it would break the `urlParsed.pathnameOriginal` value of subsequent `parseUrl()` calls.
36
- const { pathnameOriginal, search } = urlParsed;
37
- (0, utils_js_1.assert)(getPageContextRequestUrl_js_1.doNotCreateExtraDirectory === false);
38
- const urlSuffix = `/index${getPageContextRequestUrl_js_1.pageContextJsonFileExtension}`;
39
- (0, utils_js_1.assert)(pathnameOriginal.endsWith(urlSuffix), { url });
40
- let pathnameModified = (0, utils_js_1.slice)(pathnameOriginal, 0, -1 * urlSuffix.length);
41
- if (pathnameModified === '')
42
- pathnameModified = '/';
43
- const searchVikeArgs = search?._vike;
44
- const urlWithoutPageContextRequestSuffix = (0, modifyUrl_js_1.modifyUrl)(url, {
45
- pathname: pathnameModified,
46
- search: {
47
- _vike: searchVikeArgs ? null : undefined,
48
- },
49
- });
50
- return {
51
- searchVikeArgs,
52
- urlWithoutPageContextRequestSuffix,
53
- };
54
- }
55
- function parseSearchVikeArgs(searchVikeArgs) {
56
- const args = {
57
- previousUrl: null,
58
- };
59
- if (searchVikeArgs) {
60
- const parsed = JSON.parse(searchVikeArgs);
61
- (0, utils_js_1.assert)((0, utils_js_1.isObject)(parsed));
62
- if ('previousUrl' in parsed) {
63
- (0, utils_js_1.assert)((0, utils_js_1.hasProp)(parsed, 'previousUrl', 'string'));
64
- args.previousUrl = parsed.previousUrl;
65
- }
66
- }
67
- return args;
68
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveHeadersResponseEarly = resolveHeadersResponseEarly;
4
- exports.resolveHeadersResponseFinal = resolveHeadersResponseFinal;
5
- const csp_js_1 = require("./csp.js");
6
- const utils_js_1 = require("../utils.js");
7
- const getCacheControl_js_1 = require("./getCacheControl.js");
8
- function resolveHeadersResponseFinal(pageContext, statusCode) {
9
- const headersResponse = pageContext.headersResponse || new Headers();
10
- // 5xx error pages are temporary and shouldn't be cached.
11
- // This overrides any previously set Cache-Control value.
12
- if (statusCode >= 500)
13
- headersResponse.set('Cache-Control', getCacheControl_js_1.cacheControlDisable);
14
- const headers = [];
15
- headersResponse.forEach((value, key) => {
16
- headers.push([key, value]);
17
- });
18
- return headers;
19
- }
20
- async function resolveHeadersResponseEarly(pageContext) {
21
- const headersResponse = await resolveHeadersResponseConfig(pageContext);
22
- if (!headersResponse.get('Cache-Control')) {
23
- const cacheControl = (0, getCacheControl_js_1.getCacheControl)(pageContext.pageId, pageContext._globalContext._pageConfigs);
24
- if (cacheControl)
25
- headersResponse.set('Cache-Control', cacheControl);
26
- }
27
- (0, csp_js_1.addCspResponseHeader)(pageContext, headersResponse);
28
- const pageContextAddendum = {
29
- headersResponse,
30
- };
31
- return pageContextAddendum;
32
- }
33
- async function resolveHeadersResponseConfig(pageContext) {
34
- const headersMerged = new Headers();
35
- await Promise.all((pageContext.config.headersResponse ?? []).map(async (headers) => {
36
- let headersInit;
37
- if ((0, utils_js_1.isCallable)(headers)) {
38
- headersInit = await headers(pageContext);
39
- }
40
- else {
41
- headersInit = headers;
42
- }
43
- new Headers(headersInit).forEach((value, key) => {
44
- headersMerged.append(key, value);
45
- });
46
- }));
47
- return headersMerged;
48
- }
@@ -1,269 +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.getHtmlTags = getHtmlTags;
7
- const utils_js_1 = require("../../../utils.js");
8
- const serializeContext_js_1 = require("../serializeContext.js");
9
- const sanitizeJson_js_1 = require("./sanitizeJson.js");
10
- const inferHtmlTags_js_1 = require("./inferHtmlTags.js");
11
- const mergeScriptTags_js_1 = require("./mergeScriptTags.js");
12
- const helpers_js_1 = require("../../../../../shared/page-configs/helpers.js");
13
- const getConfigValueRuntime_js_1 = require("../../../../../shared/page-configs/getConfigValueRuntime.js");
14
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
15
- const getConfigDefinedAt_js_1 = require("../../../../../shared/page-configs/getConfigDefinedAt.js");
16
- const htmlElementIds_js_1 = require("../../../../../shared/htmlElementIds.js");
17
- const isFontFallback_js_1 = require("../../isFontFallback.js");
18
- const csp_js_1 = require("../../csp.js");
19
- const stamp = '__injectFilterEntry';
20
- async function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript, isStream) {
21
- (0, utils_js_1.assert)([true, false].includes(pageContext._isHtmlOnly));
22
- const isHtmlOnly = pageContext._isHtmlOnly;
23
- const { _isProduction: isProduction } = pageContext._globalContext;
24
- const injectScriptsAt = getInjectScriptsAt(pageContext.pageId, pageContext._globalContext._pageConfigs);
25
- const injectFilterEntries = [];
26
- pageAssets
27
- .filter((asset) => {
28
- if (asset.isEntry && asset.assetType === 'script') {
29
- // We could allow the user to change the position of <script> but we currently don't:
30
- // - Because of mergeScriptEntries()
31
- // - We would need to add HTML_STREAM to to PreloadFilterInject
32
- // To support this, we should add the JavaScript entry to injectFilterEntries (with an `src` value of `null`)
33
- return false;
34
- }
35
- return true;
36
- })
37
- .forEach((asset) => {
38
- const inject = (() => {
39
- if (!isProduction) {
40
- // In development, we should always load assets as soon as possible, in order to eagerly process assets (e.g. applying the transform() hooks of Vite plugins) which are lazily discovered.
41
- return 'HTML_BEGIN';
42
- }
43
- if (asset.assetType === 'style') {
44
- return 'HTML_BEGIN';
45
- }
46
- if (asset.assetType === 'font') {
47
- return !(0, isFontFallback_js_1.isFontFallback)(asset, injectFilterEntries) ? 'HTML_BEGIN' : false;
48
- }
49
- if (asset.assetType === 'script') {
50
- if (isHtmlOnly)
51
- return false;
52
- return 'HTML_END';
53
- }
54
- return false;
55
- })();
56
- const entry = {
57
- ...asset,
58
- inject,
59
- // @ts-ignore
60
- [stamp]: true,
61
- };
62
- injectFilterEntries.push(entry);
63
- });
64
- assertInjectFilterEntries(injectFilterEntries);
65
- // ==============
66
- // injectFilter()
67
- // ==============
68
- if (injectFilter && isProduction) {
69
- Object.seal(injectFilterEntries); // `Object.seal()` instead of `Object.freeze()` to allow the user to `assets.sort()`
70
- Object.values(injectFilterEntries).forEach((entry) => (0, utils_js_1.freezePartial)(entry, { inject: (val) => val === false || val === 'HTML_BEGIN' || val === 'HTML_END' }));
71
- // Call the user's injectFilter() hook https://vike.dev/injectFilter
72
- const res = injectFilter(injectFilterEntries);
73
- (0, utils_js_1.assertUsage)(res === undefined, `injectFilter() should return ${picocolors_1.default.cyan('undefined')}, see https://vike.dev/injectFilter`);
74
- assertInjectFilterUsage(injectFilterEntries);
75
- }
76
- const htmlTags = [];
77
- // ==============
78
- // Non-JavaScript
79
- // ==============
80
- injectFilterEntries
81
- .filter((asset) => asset.assetType !== 'script' && asset.inject)
82
- .forEach((asset) => {
83
- if (!asset.inject)
84
- return;
85
- const htmlTag = asset.isEntry ? (0, inferHtmlTags_js_1.inferAssetTag)(asset, pageContext) : (0, inferHtmlTags_js_1.inferPreloadTag)(asset);
86
- htmlTags.push({ htmlTag, position: asset.inject });
87
- });
88
- // ==========
89
- // JavaScript
90
- // ==========
91
- // - By default, we place the entry <script> towards the end of the HTML for better performance.
92
- // - Performance-wise, it's more interesting to start showing the page (parse HTML and load CSS) before starting loading scripts.
93
- // - But with HTML streaming, in order to support [Progressive Rendering](https://vike.dev/streaming#progressive-rendering), the entry <script> should be injected earlier instead.
94
- // - The entry <script> shouldn't be `<script defer>` upon HTML streaming, otherwise progressive hydration while SSR streaming won't work.
95
- // - `<script id="vike_pageContext" type="application/json">` (the `pageContext` JSON) should be fully sent before Vike's client runtime starts executing.
96
- // - Otherwise, race condition "SyntaxError: Unterminated string in JSON": https://github.com/vikejs/vike/issues/567
97
- // - `<script id="vike_pageContext" type="application/json">` must appear before the entry <script> (which loads Vike's client runtime).
98
- // - `<script id="vike_pageContext" type="application/json">` can't be async nor defer.
99
- const positionJavaScriptDefault = 'HTML_END';
100
- const positionJavaScriptEntry = (() => {
101
- if (injectScriptsAt !== null) {
102
- if (pageContext._pageContextPromise) {
103
- (0, utils_js_1.assertWarning)(injectScriptsAt === 'HTML_END' || !isStream, `You're setting injectScriptsAt to ${picocolors_1.default.code(JSON.stringify(injectScriptsAt))} while using HTML streaming with a pageContext promise (https://vike.dev/streaming#initial-data-after-stream-end) which is contradictory: the pageContext promise is skipped.`, { onlyOnce: true });
104
- }
105
- if (injectScriptsAt === 'HTML_STREAM' && !isStream) {
106
- return positionJavaScriptDefault;
107
- }
108
- return injectScriptsAt;
109
- }
110
- if (pageContext._pageContextPromise) {
111
- // - If there is a pageContext._pageContextPromise then <script id="vike_pageContext" type="application/json"> needs to await for it.
112
- // - pageContext._pageContextPromise is typically resolved only after the page's components are rendered and the stream ended.
113
- // - https://vike.dev/streaming#initial-data-after-stream-end
114
- return positionJavaScriptDefault;
115
- }
116
- if (streamFromReactStreamingPackage && !streamFromReactStreamingPackage.hasStreamEnded()) {
117
- // If there is a stream then, in order to support progressive hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary.
118
- return 'HTML_STREAM';
119
- }
120
- return positionJavaScriptDefault;
121
- })();
122
- if (pageContext._pageContextPromise && streamFromReactStreamingPackage) {
123
- // - Should we show this warning for Solid as well? Solid seems to also support progressive rendering.
124
- // - https://github.com/vikejs/vike-solid/issues/95
125
- // - Vue doesn't seem to support progressive rendering yet.
126
- // - https://github.com/vikejs/vike-vue/issues/85
127
- (0, utils_js_1.assertWarning)(false, "We recommend against using HTML streaming and a pageContext promise (https://vike.dev/streaming#initial-data-after-stream-end) at the same time, because progressive hydration (https://vike.dev/streaming#progressive-rendering) won't work.", { onlyOnce: true });
128
- }
129
- if (!isHtmlOnly) {
130
- // <script id="vike_pageContext" type="application/json">
131
- htmlTags.push({
132
- htmlTag: () =>
133
- // Needs to be called after resolvePageContextPromise()
134
- getPageContextJsonScriptTag(pageContext),
135
- position: positionJavaScriptEntry,
136
- });
137
- // <script id="vike_globalContext" type="application/json">
138
- htmlTags.push({
139
- htmlTag: () =>
140
- // Needs to be called after resolvePageContextPromise()
141
- getGlobalContextJsonScriptTag(pageContext),
142
- position: positionJavaScriptEntry,
143
- });
144
- }
145
- // The JavaScript entry <script> tag
146
- const scriptEntry = mergeScriptEntries(pageAssets, viteDevScript, pageContext);
147
- if (scriptEntry) {
148
- htmlTags.push({
149
- htmlTag: scriptEntry,
150
- position: positionJavaScriptEntry,
151
- });
152
- }
153
- // Preload tags
154
- injectFilterEntries
155
- .filter((asset) => asset.assetType === 'script')
156
- .forEach((asset) => {
157
- (0, utils_js_1.assert)(!asset.isEntry); // Users cannot re-order JavaScript entries, see creation of injectFilterEntries
158
- const htmlTag = (0, inferHtmlTags_js_1.inferPreloadTag)(asset);
159
- if (!asset.inject)
160
- return;
161
- // Ideally, instead of this conditional ternary operator, we should add HTML_STREAM to PreloadFilterInject
162
- const position = asset.inject === 'HTML_END' ? positionJavaScriptEntry : asset.inject;
163
- htmlTags.push({ htmlTag, position });
164
- });
165
- return htmlTags;
166
- }
167
- function mergeScriptEntries(pageAssets, viteDevScript, pageContext) {
168
- const scriptEntries = pageAssets.filter((pageAsset) => pageAsset.isEntry && pageAsset.assetType === 'script');
169
- let scriptEntry = `${viteDevScript}${scriptEntries.map((asset) => (0, inferHtmlTags_js_1.inferAssetTag)(asset, pageContext)).join('')}`;
170
- // We merge scripts to avoid the infamous HMR preamble error.
171
- // - Infamous HMR preamble error:
172
- // ```browser-console
173
- // usePageContext.tsx:10 Uncaught (in promise) Error: @vitejs/plugin-react can't detect preamble. Something is wrong.
174
- // at usePageContext.tsx:10:10
175
- // ```
176
- // - Note the following race condition. Maybe making the second script non-async ensures execution order?
177
- // ```html
178
- // <script type="module">console.log("I can be printed *after* the other log")</script>
179
- // <script src="entry.js" type="module" async></script>
180
- // ```
181
- // ```js
182
- // // entry.js
183
- // console.log("I can be printed *before* the other log")
184
- // ```
185
- // - Maybe an alternative would be to make Vike's client runtime entry <script> tag non-async. Would that work? Would it be a performance issue?
186
- // - The entry <script> shouldn't be `<script defer>` upon HTML streaming, otherwise progressive hydration while SSR streaming won't work.
187
- scriptEntry = (0, mergeScriptTags_js_1.mergeScriptTags)(scriptEntry, pageContext);
188
- return scriptEntry;
189
- }
190
- function getPageContextJsonScriptTag(pageContext) {
191
- const pageContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getPageContextClientSerialized)(pageContext, true));
192
- const nonceAttr = (0, csp_js_1.inferNonceAttr)(pageContext);
193
- const htmlTag = `<script id="${htmlElementIds_js_1.htmlElementId_pageContext}" type="application/json"${nonceAttr}>${pageContextClientSerialized}</script>`;
194
- // Used by contra.com https://github.com/gajus
195
- // @ts-expect-error
196
- pageContext._pageContextHtmlTag = htmlTag;
197
- return htmlTag;
198
- }
199
- function getGlobalContextJsonScriptTag(pageContext) {
200
- const globalContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getGlobalContextClientSerialized)(pageContext, true));
201
- const nonceAttr = (0, csp_js_1.inferNonceAttr)(pageContext);
202
- const htmlTag = `<script id="${htmlElementIds_js_1.htmlElementId_globalContext}" type="application/json"${nonceAttr}>${globalContextClientSerialized}</script>`;
203
- return htmlTag;
204
- }
205
- function assertInjectFilterEntries(injectFilterEntries) {
206
- try {
207
- checkForWrongUsage(injectFilterEntries);
208
- }
209
- catch (err) {
210
- if (err?.message.includes('[Wrong Usage]')) {
211
- (0, utils_js_1.assert)(false);
212
- }
213
- throw err;
214
- }
215
- }
216
- function assertInjectFilterUsage(injectFilterEntries) {
217
- checkForWrongUsage(injectFilterEntries);
218
- checkForWarnings(injectFilterEntries);
219
- }
220
- function checkForWrongUsage(injectFilterEntries) {
221
- injectFilterEntries.forEach((entry, i) => {
222
- (0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(entry), `[injectFilter()] Entry ${i} isn't an object`);
223
- (0, utils_js_1.assertUsage)(typeof entry.src === 'string', `[injectFilter()] Entry ${i} is missing property ${picocolors_1.default.cyan('src')}`);
224
- (0, utils_js_1.assertUsage)(entry[stamp] === true, `[injectFilter()] Entry ${i} (${entry.src}) isn't the original object, see https://vike.dev/injectFilter`);
225
- (0, utils_js_1.assert)([false, 'HTML_BEGIN', 'HTML_END'].includes(entry.inject));
226
- (0, utils_js_1.assert)(entry.assetType === null || typeof entry.assetType === 'string');
227
- (0, utils_js_1.assert)(entry.mediaType === null || typeof entry.mediaType === 'string');
228
- (0, utils_js_1.assert)(typeof entry.isEntry === 'boolean');
229
- (0, utils_js_1.assert)(Object.keys(entry).length === 6);
230
- });
231
- }
232
- function checkForWarnings(injectFilterEntries) {
233
- injectFilterEntries.forEach((a) => {
234
- /*
235
- if (a.assetType === 'script' && a.isEntry) {
236
- assertUsage(a.inject, `[injectFilter()] ${a.src} needs to be injected`)
237
- }
238
- */
239
- if (a.assetType === 'style' && a.isEntry) {
240
- // In development, Vite automatically inject styles, but we still inject `<link rel="stylesheet" type="text/css" href="${src}">` tags in order to avoid FOUC (flash of unstyled content).
241
- // - https://github.com/vitejs/vite/issues/2282
242
- // - https://github.com/vikejs/vike/issues/261
243
- (0, utils_js_1.assertWarning)(a.inject, `[injectFilter()] We recommend against not injecting ${a.src}`, {
244
- onlyOnce: true,
245
- });
246
- }
247
- if (a.assetType === 'script') {
248
- (0, utils_js_1.assertWarning)(a.inject, `[injectFilter()] We recommend against not preloading JavaScript (${a.src})`, {
249
- onlyOnce: true,
250
- });
251
- }
252
- });
253
- }
254
- function getInjectScriptsAt(pageId, pageConfigs) {
255
- if (pageConfigs.length === 0)
256
- return null; // only support V1 design
257
- const pageConfig = (0, helpers_js_1.getPageConfig)(pageId, pageConfigs);
258
- const configValue = (0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, 'injectScriptsAt');
259
- if (!configValue)
260
- return null;
261
- const injectScriptsAt = configValue.value;
262
- (0, utils_js_1.assert)(configValue.definedAtData);
263
- const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', 'injectScriptsAt', configValue.definedAtData);
264
- (0, utils_js_1.assertUsage)(injectScriptsAt === null ||
265
- injectScriptsAt === 'HTML_BEGIN' ||
266
- injectScriptsAt === 'HTML_END' ||
267
- injectScriptsAt === 'HTML_STREAM', `${configDefinedAt} has an invalid value`);
268
- return injectScriptsAt;
269
- }
@@ -1,32 +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.getViteDevScript = getViteDevScript;
7
- const utils_js_1 = require("../../../utils.js");
8
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
9
- const reachOutCTA = 'Create a new GitHub issue to discuss a solution.';
10
- async function getViteDevScript(pageContext) {
11
- const globalContext = pageContext._globalContext;
12
- if (globalContext._isProduction) {
13
- return '';
14
- }
15
- const { _viteDevServer: viteDevServer } = globalContext;
16
- const fakeHtmlBegin = '<html> <head>'; // White space to test whether user is using a minifier
17
- const fakeHtmlEnd = '</head><body></body></html>';
18
- let fakeHtml = fakeHtmlBegin + fakeHtmlEnd;
19
- fakeHtml = viteDevServer
20
- ? await viteDevServer.transformIndexHtml('/', fakeHtml)
21
- : await (0, utils_js_1.getViteRPC)().transformIndexHtmlRPC(fakeHtml);
22
- (0, utils_js_1.assertUsage)(!fakeHtml.includes('vite-plugin-pwa'), `The HTML transformer of ${picocolors_1.default.cyan('vite-plugin-pwa')} cannot be applied, see workaround at https://github.com/vikejs/vike/issues/388#issuecomment-1199280084`);
23
- (0, utils_js_1.assertUsage)(!fakeHtml.startsWith(fakeHtmlBegin.replace(' ', '')), `Vite plugins that minify the HTML cannot be applied, see https://github.com/vikejs/vike/issues/224`);
24
- (0, utils_js_1.assertUsage)(fakeHtml.startsWith(fakeHtmlBegin) && fakeHtml.endsWith(fakeHtmlEnd), `You are using a Vite Plugin that transforms the HTML in a way that conflicts with Vike. ${reachOutCTA}`);
25
- const viteInjection = fakeHtml.slice(fakeHtmlBegin.length, -1 * fakeHtmlEnd.length);
26
- (0, utils_js_1.assert)(viteInjection.includes('script'));
27
- (0, utils_js_1.assertWarning)(!viteInjection.includes('import('), `Unexpected Vite injected HMR code. ${reachOutCTA}`, {
28
- onlyOnce: true,
29
- });
30
- const viteDevScript = viteInjection;
31
- return viteDevScript;
32
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scriptCommonAttrs = void 0;
4
- exports.inferAssetTag = inferAssetTag;
5
- exports.inferPreloadTag = inferPreloadTag;
6
- exports.inferEarlyHintLink = inferEarlyHintLink;
7
- const utils_js_1 = require("../../../utils.js");
8
- const csp_js_1 = require("../../csp.js");
9
- // We can't use `defer` here. With `defer`, the entry script won't start before `</body>` has been parsed, preventing progressive hydration during SSR streaming, see https://github.com/vikejs/vike/pull/1271
10
- const scriptCommonAttrs = 'type="module" async';
11
- exports.scriptCommonAttrs = scriptCommonAttrs;
12
- function inferPreloadTag(pageAsset) {
13
- const { src, assetType, mediaType } = pageAsset;
14
- const rel = getRel(pageAsset);
15
- const attributes = [
16
- `rel="${rel}"`,
17
- `href="${src}"`,
18
- !assetType ? null : `as="${assetType}"`,
19
- !mediaType ? null : `type="${mediaType}"`,
20
- // `crossorigin` is needed for fonts, see https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload#cors-enabled_fetches
21
- !isCrossOrigin(pageAsset) ? null : 'crossorigin',
22
- ]
23
- .filter(Boolean)
24
- .join(' ');
25
- return `<link ${attributes}>`;
26
- }
27
- function inferAssetTag(pageAsset, pageContext) {
28
- const { src, assetType, mediaType } = pageAsset;
29
- if (assetType === 'script') {
30
- (0, utils_js_1.assert)(mediaType === 'text/javascript');
31
- const nonceAttr = (0, csp_js_1.inferNonceAttr)(pageContext);
32
- return `<script src="${src}" ${scriptCommonAttrs}${nonceAttr}></script>`;
33
- }
34
- if (assetType === 'style') {
35
- // WARNING: if changing following line, then also update https://github.com/vikejs/vike/blob/fae90a15d88e5e87ca9fcbb54cf2dc8773d2f229/vike/client/shared/removeFoucBuster.ts#L29
36
- return `<link rel="stylesheet" type="text/css" href="${src}">`;
37
- }
38
- (0, utils_js_1.assert)(false, { pageAsset });
39
- }
40
- // We ignore crossorigin, it seems like Early Hints doesn't have a "crossorigin" property: https://github.com/vikejs/vike/issues/618#issuecomment-1415752222
41
- function inferEarlyHintLink(pageAsset) {
42
- const { src, assetType } = pageAsset;
43
- const rel = getRel(pageAsset);
44
- return [`<${src}>`, `rel=${rel}`, !assetType ? null : `as=${assetType}`].filter(Boolean).join('; ');
45
- }
46
- function getRel({ assetType }) {
47
- if (assetType === 'script') {
48
- // Vite transpiles all browser-side JavaScript to ESM
49
- return 'modulepreload';
50
- }
51
- return 'preload';
52
- }
53
- function isCrossOrigin({ src, assetType }) {
54
- return assetType === 'font' || src.startsWith('http://') || src.startsWith('https://');
55
- }
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectAssets__public = injectAssets__public;
4
- const utils_js_1 = require("../../../utils.js");
5
- const injectAssets_js_1 = require("../injectAssets.js");
6
- // TO-DO/next-major-release: remove
7
- async function injectAssets__public(htmlString, pageContext) {
8
- (0, utils_js_1.assertWarning)(false, '`_injectAssets()` is deprecated and will be removed.', { onlyOnce: true, showStackTrace: true });
9
- (0, utils_js_1.assertUsage)(typeof htmlString === 'string', '[injectAssets(htmlString, pageContext)]: Argument `htmlString` should be a string.', { showStackTrace: true });
10
- (0, utils_js_1.assertUsage)(pageContext, '[injectAssets(htmlString, pageContext)]: Argument `pageContext` is missing.', {
11
- showStackTrace: true,
12
- });
13
- const errMsg = (body) => '[injectAssets(htmlString, pageContext)]: ' +
14
- body +
15
- '. Make sure that `pageContext` is the object that Vike provided to your `render(pageContext)` hook.';
16
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(pageContext, 'urlPathname', 'string'), errMsg('`pageContext.urlPathname` should be a string'), {
17
- showStackTrace: true,
18
- });
19
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(pageContext, 'pageId', 'string'), errMsg('`pageContext.pageId` should be a string'), {
20
- showStackTrace: true,
21
- });
22
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(pageContext, '__getPageAssets'), errMsg('`pageContext.__getPageAssets` is missing'), {
23
- showStackTrace: true,
24
- });
25
- (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(pageContext, '_passToClient', 'string[]'), errMsg('`pageContext._passToClient` is missing'), {
26
- showStackTrace: true,
27
- });
28
- (0, utils_js_1.castProp)(pageContext, '__getPageAssets');
29
- htmlString = await (0, injectAssets_js_1.injectHtmlTagsToString)([htmlString], pageContext, null);
30
- return htmlString;
31
- }