vike 0.4.239 → 0.4.240

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 (465) hide show
  1. package/dist/esm/client/index.d.ts +1 -1
  2. package/dist/esm/client/index.js +1 -1
  3. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +1 -1
  4. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
  5. package/dist/esm/client/runtime-client-routing/entry.js +5 -3
  6. package/dist/esm/client/runtime-client-routing/getBaseServer.js +0 -1
  7. package/dist/esm/client/runtime-client-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +2 -2
  8. package/dist/esm/client/runtime-client-routing/{globalContext.js → getGlobalContextClientInternal.js} +8 -4
  9. package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +6 -6
  10. package/dist/esm/client/runtime-client-routing/isClientSideRoutable.d.ts +1 -1
  11. package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +4 -4
  12. package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +15 -4
  13. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
  14. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
  15. package/dist/esm/client/runtime-server-routing/entry.js +5 -3
  16. package/dist/esm/client/runtime-server-routing/{globalContext.d.ts → getGlobalContextClientInternal.d.ts} +2 -2
  17. package/dist/esm/client/runtime-server-routing/getGlobalContextClientInternal.js +6 -0
  18. package/dist/esm/client/shared/execHookOnRenderClient.d.ts +1 -1
  19. package/dist/esm/client/shared/{createGetGlobalContextClient.d.ts → getGlobalContextClientInternalShared.d.ts} +11 -8
  20. package/dist/esm/client/shared/getGlobalContextClientInternalShared.js +66 -0
  21. package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +1 -3
  22. package/dist/esm/node/prerender/runPrerender.d.ts +4 -2
  23. package/dist/esm/node/prerender/runPrerender.js +5 -2
  24. package/dist/esm/node/runtime/globalContext.d.ts +15 -2
  25. package/dist/esm/node/runtime/globalContext.js +46 -32
  26. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +4 -2
  27. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +4 -2
  28. package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +8 -4
  29. package/dist/esm/node/runtime/renderPage.d.ts +4 -2
  30. package/dist/esm/node/vite/index.js +41 -17
  31. package/dist/esm/node/vite/onLoad.js +1 -1
  32. package/dist/esm/node/vite/plugins/{pluginBuild → build}/handleAssetsManifest.d.ts +4 -0
  33. package/dist/esm/node/vite/plugins/{pluginBuild → build}/handleAssetsManifest.js +21 -6
  34. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildApp.js +24 -20
  35. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildConfig.js +20 -6
  36. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginDistFileNames.d.ts +1 -1
  37. package/dist/esm/node/vite/plugins/build/pluginDistFileNames.js +253 -0
  38. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginDistPackageJsonFile.d.ts +1 -1
  39. package/dist/esm/node/vite/plugins/build/pluginDistPackageJsonFile.js +40 -0
  40. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginModuleBanner.d.ts +1 -1
  41. package/dist/esm/node/vite/plugins/build/pluginModuleBanner.js +49 -0
  42. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginProdBuildEntry.js +4 -2
  43. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginSuppressRollupWarning.d.ts +1 -1
  44. package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginSuppressRollupWarning.js +27 -23
  45. package/dist/esm/node/vite/plugins/non-runnable-dev/pluginReplaceConstantsNonRunnableDev.d.ts +7 -0
  46. package/dist/esm/node/vite/plugins/non-runnable-dev/pluginReplaceConstantsNonRunnableDev.js +47 -0
  47. package/dist/esm/node/vite/plugins/{pluginNonRunnableDev.d.ts → non-runnable-dev/pluginViteRPC.d.ts} +3 -7
  48. package/dist/esm/node/vite/plugins/non-runnable-dev/pluginViteRPC.js +30 -0
  49. package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
  50. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +39 -33
  51. package/dist/esm/node/vite/plugins/pluginCommon.js +8 -28
  52. package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
  53. package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +1 -1
  54. package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
  55. package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +1 -1
  56. package/dist/esm/node/vite/plugins/pluginEnvVars.js +88 -63
  57. package/dist/esm/node/vite/plugins/pluginExtractAssets.js +108 -92
  58. package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
  59. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +39 -23
  60. package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
  61. package/dist/esm/node/vite/plugins/pluginFileEnv.js +117 -92
  62. package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
  63. package/dist/esm/node/vite/plugins/pluginPreview.js +38 -30
  64. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +9 -0
  65. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +45 -0
  66. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +3 -0
  67. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.js +87 -0
  68. package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
  69. package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +1 -1
  70. package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
  71. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +67 -47
  72. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
  73. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +13 -9
  74. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
  75. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
  76. package/dist/esm/node/vite/shared/getMagicString.d.ts +1 -1
  77. package/dist/esm/node/vite/shared/getMagicString.js +2 -0
  78. package/dist/esm/shared/createGlobalContextShared.d.ts +4 -4
  79. package/dist/esm/shared/route/abort.d.ts +22 -11
  80. package/dist/esm/shared/route/abort.js +37 -5
  81. package/dist/esm/types/PageContext.d.ts +8 -8
  82. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  83. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  84. package/dist/esm/utils/debug.js +10 -0
  85. package/dist/esm/utils/findPackageJson.js +0 -1
  86. package/dist/esm/utils/getViteRPC.js +0 -2
  87. package/dist/esm/utils/isDev.js +3 -1
  88. package/dist/esm/utils/isNonRunnableDev.js +2 -2
  89. package/dist/esm/utils/requireResolve.js +0 -1
  90. package/dist/esm/utils/virtualFileId.d.ts +4 -0
  91. package/dist/esm/utils/virtualFileId.js +14 -11
  92. package/package.json +6 -25
  93. package/dist/cjs/__internal/index.js +0 -35
  94. package/dist/cjs/client/runtime-client-routing/globalContext.js +0 -49
  95. package/dist/cjs/client/runtime-client-routing/prefetch/PrefetchSetting.js +0 -2
  96. package/dist/cjs/client/runtime-server-routing/globalContext.js +0 -41
  97. package/dist/cjs/client/runtime-server-routing/onLoad.js +0 -7
  98. package/dist/cjs/client/runtime-server-routing/utils.js +0 -34
  99. package/dist/cjs/client/shared/createGetGlobalContextClient.js +0 -65
  100. package/dist/cjs/client/shared/getJsonSerializedInHtml.js +0 -40
  101. package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +0 -41
  102. package/dist/cjs/client/shared/utils.js +0 -23
  103. package/dist/cjs/node/api/build.js +0 -24
  104. package/dist/cjs/node/api/context.js +0 -23
  105. package/dist/cjs/node/api/dev.js +0 -18
  106. package/dist/cjs/node/api/index.js +0 -44
  107. package/dist/cjs/node/api/onLoad.js +0 -9
  108. package/dist/cjs/node/api/prepareViteApiCall.js +0 -206
  109. package/dist/cjs/node/api/prerender.js +0 -18
  110. package/dist/cjs/node/api/preview.js +0 -38
  111. package/dist/cjs/node/api/types.js +0 -2
  112. package/dist/cjs/node/api/utils.js +0 -27
  113. package/dist/cjs/node/cli/context.js +0 -17
  114. package/dist/cjs/node/cli/entry.js +0 -121
  115. package/dist/cjs/node/cli/index.js +0 -12
  116. package/dist/cjs/node/cli/onLoad.js +0 -9
  117. package/dist/cjs/node/cli/parseCli.js +0 -95
  118. package/dist/cjs/node/cli/utils.js +0 -24
  119. package/dist/cjs/node/client/router.js +0 -19
  120. package/dist/cjs/node/createPageRenderer.js +0 -132
  121. package/dist/cjs/node/importBuild.js +0 -3
  122. package/dist/cjs/node/prerender/context.js +0 -26
  123. package/dist/cjs/node/prerender/index.js +0 -12
  124. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +0 -66
  125. package/dist/cjs/node/prerender/runPrerender.js +0 -777
  126. package/dist/cjs/node/prerender/runPrerenderEntry.js +0 -55
  127. package/dist/cjs/node/prerender/utils.js +0 -37
  128. package/dist/cjs/node/runtime/globalContext.js +0 -572
  129. package/dist/cjs/node/runtime/index-deprecated.js +0 -33
  130. package/dist/cjs/node/runtime/index.js +0 -74
  131. package/dist/cjs/node/runtime/loggerRuntime.js +0 -17
  132. package/dist/cjs/node/runtime/onLoad.js +0 -29
  133. package/dist/cjs/node/runtime/page-files/setup.js +0 -5
  134. package/dist/cjs/node/runtime/renderPage/analyzePage.js +0 -71
  135. package/dist/cjs/node/runtime/renderPage/assertArguments.js +0 -42
  136. package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +0 -51
  137. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -114
  138. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +0 -59
  139. package/dist/cjs/node/runtime/renderPage/csp.js +0 -47
  140. package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +0 -31
  141. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +0 -120
  142. package/dist/cjs/node/runtime/renderPage/execHookServer.js +0 -8
  143. package/dist/cjs/node/runtime/renderPage/getCacheControl.js +0 -24
  144. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +0 -20
  145. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +0 -137
  146. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +0 -125
  147. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.js +0 -86
  148. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.js +0 -77
  149. package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +0 -36
  150. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +0 -50
  151. package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +0 -41
  152. package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +0 -68
  153. package/dist/cjs/node/runtime/renderPage/headersResponse.js +0 -48
  154. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getHtmlTags.js +0 -269
  155. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getViteDevScript.js +0 -32
  156. package/dist/cjs/node/runtime/renderPage/html/injectAssets/inferHtmlTags.js +0 -55
  157. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectAssets__public.js +0 -31
  158. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectHtmlTags.js +0 -161
  159. package/dist/cjs/node/runtime/renderPage/html/injectAssets/mergeScriptTags.js +0 -73
  160. package/dist/cjs/node/runtime/renderPage/html/injectAssets/sanitizeJson.js +0 -8
  161. package/dist/cjs/node/runtime/renderPage/html/injectAssets.js +0 -93
  162. package/dist/cjs/node/runtime/renderPage/html/propKeys.js +0 -47
  163. package/dist/cjs/node/runtime/renderPage/html/renderHtml.js +0 -245
  164. package/dist/cjs/node/runtime/renderPage/html/serializeContext.js +0 -189
  165. package/dist/cjs/node/runtime/renderPage/html/stream/react-streaming.js +0 -36
  166. package/dist/cjs/node/runtime/renderPage/html/stream.js +0 -829
  167. package/dist/cjs/node/runtime/renderPage/inferMediaType.js +0 -81
  168. package/dist/cjs/node/runtime/renderPage/isFontFallback.js +0 -29
  169. package/dist/cjs/node/runtime/renderPage/isNewError.js +0 -25
  170. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +0 -124
  171. package/dist/cjs/node/runtime/renderPage/log404/index.js +0 -154
  172. package/dist/cjs/node/runtime/renderPage/logErrorHint/errors.js +0 -20
  173. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +0 -200
  174. package/dist/cjs/node/runtime/renderPage/loggerProd.js +0 -34
  175. package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +0 -10
  176. package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +0 -83
  177. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -71
  178. package/dist/cjs/node/runtime/renderPage.js +0 -502
  179. package/dist/cjs/node/runtime/universal-middleware.js +0 -20
  180. package/dist/cjs/node/runtime/utils.js +0 -83
  181. package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -27
  182. package/dist/cjs/node/runtime-dev/index.js +0 -42
  183. package/dist/cjs/node/shared/assertV1Design.js +0 -30
  184. package/dist/cjs/node/shared/extractAssetsQuery.js +0 -29
  185. package/dist/cjs/node/shared/getVikeConfigError.js +0 -22
  186. package/dist/cjs/node/shared/isErrorDebug.js +0 -7
  187. package/dist/cjs/node/shared/prependEntriesDir.js +0 -13
  188. package/dist/cjs/node/shared/resolveBase.js +0 -35
  189. package/dist/cjs/node/shared/utils.js +0 -35
  190. package/dist/cjs/node/shared/virtualFileId.js +0 -110
  191. package/dist/cjs/node/vite/index.js +0 -69
  192. package/dist/cjs/node/vite/onLoad.js +0 -21
  193. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +0 -48
  194. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -342
  195. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -179
  196. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -220
  197. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -254
  198. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -36
  199. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -41
  200. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -109
  201. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -63
  202. package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -21
  203. package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
  204. package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -197
  205. package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -28
  206. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +0 -163
  207. package/dist/cjs/node/vite/plugins/pluginDev.js +0 -107
  208. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -87
  209. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -227
  210. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -99
  211. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -149
  212. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -52
  213. package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -76
  214. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -69
  215. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -49
  216. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/debug.js +0 -5
  217. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +0 -56
  218. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +0 -190
  219. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +0 -54
  220. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +0 -97
  221. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +0 -215
  222. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -15
  223. package/dist/cjs/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +0 -35
  224. package/dist/cjs/node/vite/shared/addSsrMiddleware.js +0 -60
  225. package/dist/cjs/node/vite/shared/findPageFiles.js +0 -25
  226. package/dist/cjs/node/vite/shared/getAssetsDir.js +0 -10
  227. package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +0 -42
  228. package/dist/cjs/node/vite/shared/getEnvVarObject.js +0 -37
  229. package/dist/cjs/node/vite/shared/getFilePath.js +0 -172
  230. package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +0 -125
  231. package/dist/cjs/node/vite/shared/getMagicString.js +0 -18
  232. package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +0 -10
  233. package/dist/cjs/node/vite/shared/getOutDirs.js +0 -146
  234. package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +0 -21
  235. package/dist/cjs/node/vite/shared/isAsset.js +0 -40
  236. package/dist/cjs/node/vite/shared/isViteCliCall.js +0 -83
  237. package/dist/cjs/node/vite/shared/isViteServerSide.js +0 -68
  238. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +0 -15
  239. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.js +0 -15
  240. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +0 -38
  241. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.js +0 -26
  242. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.js +0 -85
  243. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.js +0 -30
  244. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.js +0 -19
  245. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.js +0 -19
  246. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +0 -29
  247. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.js +0 -13
  248. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.js +0 -15
  249. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +0 -162
  250. package/dist/cjs/node/vite/shared/loggerNotProd/log.js +0 -102
  251. package/dist/cjs/node/vite/shared/loggerNotProd.js +0 -208
  252. package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -26
  253. package/dist/cjs/node/vite/shared/loggerVite.js +0 -54
  254. package/dist/cjs/node/vite/shared/normalizeId.js +0 -9
  255. package/dist/cjs/node/vite/shared/parseEsModule.js +0 -33
  256. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +0 -136
  257. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -262
  258. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles/ignorePatternsBuiltIn.js +0 -18
  259. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +0 -252
  260. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +0 -190
  261. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getConfigFileExport.js +0 -17
  262. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getPlusFilesAll.js +0 -127
  263. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.js +0 -129
  264. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +0 -195
  265. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +0 -102
  266. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +0 -425
  267. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +0 -1151
  268. package/dist/cjs/node/vite/shared/rollupIsEsm.js +0 -15
  269. package/dist/cjs/node/vite/utils.js +0 -45
  270. package/dist/cjs/package.json +0 -1
  271. package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -4
  272. package/dist/cjs/shared/RenderErrorPage.js +0 -6
  273. package/dist/cjs/shared/abort.js +0 -16
  274. package/dist/cjs/shared/addIs404ToPageProps.js +0 -18
  275. package/dist/cjs/shared/assertHookReturnedObject.js +0 -21
  276. package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +0 -21
  277. package/dist/cjs/shared/assertPageContextProvidedByUser.js +0 -20
  278. package/dist/cjs/shared/createGlobalContextShared.js +0 -109
  279. package/dist/cjs/shared/createPageContextShared.js +0 -17
  280. package/dist/cjs/shared/determinePageIdOld.js +0 -11
  281. package/dist/cjs/shared/error-page.js +0 -40
  282. package/dist/cjs/shared/getPageContext.js +0 -6
  283. package/dist/cjs/shared/getPageContextRequestUrl.js +0 -16
  284. package/dist/cjs/shared/getPageContextUrlComputed.js +0 -132
  285. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +0 -19
  286. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/ClientDependency.js +0 -2
  287. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +0 -50
  288. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +0 -30
  289. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +0 -15
  290. package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +0 -59
  291. package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +0 -22
  292. package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +0 -24
  293. package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -52
  294. package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -102
  295. package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -56
  296. package/dist/cjs/shared/getPageFiles/parseVirtualFileExportsGlobalEntry.js +0 -100
  297. package/dist/cjs/shared/getPageFiles.js +0 -7
  298. package/dist/cjs/shared/getProxyForPublicUsage.js +0 -56
  299. package/dist/cjs/shared/hooks/execHook.js +0 -147
  300. package/dist/cjs/shared/hooks/getHook.js +0 -173
  301. package/dist/cjs/shared/htmlElementIds.js +0 -5
  302. package/dist/cjs/shared/misc/isServerSideError.js +0 -4
  303. package/dist/cjs/shared/misc/pageContextInitIsPassedToClient.js +0 -4
  304. package/dist/cjs/shared/modifyUrl.js +0 -28
  305. package/dist/cjs/shared/modifyUrlSameOrigin.js +0 -47
  306. package/dist/cjs/shared/page-configs/assertPlusFileExport.js +0 -42
  307. package/dist/cjs/shared/page-configs/findPageConfig.js +0 -10
  308. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +0 -65
  309. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -68
  310. package/dist/cjs/shared/page-configs/getConfigValueRuntime.js +0 -10
  311. package/dist/cjs/shared/page-configs/getConfigValueTyped.js +0 -32
  312. package/dist/cjs/shared/page-configs/getExportPath.js +0 -29
  313. package/dist/cjs/shared/page-configs/helpers.js +0 -27
  314. package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +0 -25
  315. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +0 -287
  316. package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +0 -2
  317. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -1
  318. package/dist/cjs/shared/page-configs/serialize/parsePageConfigsSerialized.js +0 -145
  319. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +0 -290
  320. package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +0 -10
  321. package/dist/cjs/shared/preparePageContextForPublicUsage.js +0 -80
  322. package/dist/cjs/shared/route/abort.js +0 -178
  323. package/dist/cjs/shared/route/debug.js +0 -23
  324. package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +0 -52
  325. package/dist/cjs/shared/route/execHookGuard.js +0 -37
  326. package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -84
  327. package/dist/cjs/shared/route/index.js +0 -107
  328. package/dist/cjs/shared/route/loadPageRoutes.js +0 -197
  329. package/dist/cjs/shared/route/noRouteMatch.js +0 -4
  330. package/dist/cjs/shared/route/resolvePrecedence.js +0 -93
  331. package/dist/cjs/shared/route/resolveRoute.js +0 -20
  332. package/dist/cjs/shared/route/resolveRouteFunction.js +0 -73
  333. package/dist/cjs/shared/route/resolveRouteString.js +0 -153
  334. package/dist/cjs/shared/route/resolveUrlPathname.js +0 -47
  335. package/dist/cjs/shared/route/routing.js +0 -9
  336. package/dist/cjs/shared/route/utils.js +0 -40
  337. package/dist/cjs/shared/utils.js +0 -49
  338. package/dist/cjs/types/Config/ConfigResolved.js +0 -2
  339. package/dist/cjs/types/Config.js +0 -2
  340. package/dist/cjs/types/FilePath.js +0 -2
  341. package/dist/cjs/types/PageConfig.js +0 -2
  342. package/dist/cjs/types/PageContext.js +0 -2
  343. package/dist/cjs/types/VikeGlobalInternal.js +0 -2
  344. package/dist/cjs/types/VikeNamespace.js +0 -2
  345. package/dist/cjs/types/ViteManifest.js +0 -2
  346. package/dist/cjs/types/defineConfig.js +0 -6
  347. package/dist/cjs/types/index-dreprecated.js +0 -3
  348. package/dist/cjs/types/index.js +0 -5
  349. package/dist/cjs/utils/PROJECT_VERSION.js +0 -5
  350. package/dist/cjs/utils/PromiseType.js +0 -2
  351. package/dist/cjs/utils/assert.js +0 -211
  352. package/dist/cjs/utils/assertIsBrowser.js +0 -8
  353. package/dist/cjs/utils/assertIsNotBrowser.js +0 -9
  354. package/dist/cjs/utils/assertKeys.js +0 -27
  355. package/dist/cjs/utils/assertNodeVersion.js +0 -14
  356. package/dist/cjs/utils/assertRoutingType.js +0 -29
  357. package/dist/cjs/utils/assertSetup.js +0 -171
  358. package/dist/cjs/utils/assertSingleInstance.js +0 -110
  359. package/dist/cjs/utils/assertVersion.js +0 -60
  360. package/dist/cjs/utils/capitalizeFirstLetter.js +0 -9
  361. package/dist/cjs/utils/cast.js +0 -6
  362. package/dist/cjs/utils/catchInfiniteLoop.js +0 -34
  363. package/dist/cjs/utils/changeEnumerable.js +0 -8
  364. package/dist/cjs/utils/checkType.js +0 -6
  365. package/dist/cjs/utils/compareString.js +0 -10
  366. package/dist/cjs/utils/createErrorWithCleanStackTrace.js +0 -39
  367. package/dist/cjs/utils/debug.js +0 -178
  368. package/dist/cjs/utils/debugGlob.js +0 -6
  369. package/dist/cjs/utils/deepEqual.js +0 -10
  370. package/dist/cjs/utils/escapeHtml.js +0 -13
  371. package/dist/cjs/utils/escapeRegex.js +0 -7
  372. package/dist/cjs/utils/findFile.js +0 -30
  373. package/dist/cjs/utils/findPackageJson.js +0 -18
  374. package/dist/cjs/utils/formatHintLog.js +0 -17
  375. package/dist/cjs/utils/freezePartial.js +0 -35
  376. package/dist/cjs/utils/genPromise.js +0 -51
  377. package/dist/cjs/utils/getFileExtension.js +0 -16
  378. package/dist/cjs/utils/getGlobalObject.js +0 -15
  379. package/dist/cjs/utils/getMostSimilar.js +0 -68
  380. package/dist/cjs/utils/getPropAccessNotation.js +0 -9
  381. package/dist/cjs/utils/getRandomId.js +0 -14
  382. package/dist/cjs/utils/getTerminalWidth.js +0 -7
  383. package/dist/cjs/utils/getValuePrintable.js +0 -10
  384. package/dist/cjs/utils/getViteRPC.js +0 -79
  385. package/dist/cjs/utils/hasProp.js +0 -50
  386. package/dist/cjs/utils/humanizeTime.js +0 -24
  387. package/dist/cjs/utils/includes.js +0 -13
  388. package/dist/cjs/utils/injectRollupInputs.js +0 -29
  389. package/dist/cjs/utils/isArray.js +0 -7
  390. package/dist/cjs/utils/isArrayOfStrings.js +0 -7
  391. package/dist/cjs/utils/isBrowser.js +0 -8
  392. package/dist/cjs/utils/isCallable.js +0 -6
  393. package/dist/cjs/utils/isDev.js +0 -20
  394. package/dist/cjs/utils/isDocker.js +0 -45
  395. package/dist/cjs/utils/isEqualStringList.js +0 -13
  396. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +0 -66
  397. package/dist/cjs/utils/isHtml.js +0 -9
  398. package/dist/cjs/utils/isImportPath.js +0 -21
  399. package/dist/cjs/utils/isNodeJS.js +0 -16
  400. package/dist/cjs/utils/isNonRunnableDev.js +0 -12
  401. package/dist/cjs/utils/isNullish.js +0 -16
  402. package/dist/cjs/utils/isObject.js +0 -6
  403. package/dist/cjs/utils/isObjectOfStrings.js +0 -7
  404. package/dist/cjs/utils/isObjectWithKeys.js +0 -15
  405. package/dist/cjs/utils/isPlainObject.js +0 -19
  406. package/dist/cjs/utils/isPromise.js +0 -7
  407. package/dist/cjs/utils/isPropertyGetter.js +0 -7
  408. package/dist/cjs/utils/isReact.js +0 -23
  409. package/dist/cjs/utils/isRunnableDevEnvironment.js +0 -9
  410. package/dist/cjs/utils/isSameErrorMessage.js +0 -9
  411. package/dist/cjs/utils/isScriptFile.js +0 -67
  412. package/dist/cjs/utils/isVikeReactApp.js +0 -8
  413. package/dist/cjs/utils/isVitest.js +0 -6
  414. package/dist/cjs/utils/joinEnglish.js +0 -14
  415. package/dist/cjs/utils/normalizeHeaders.js +0 -17
  416. package/dist/cjs/utils/objectAssign.js +0 -14
  417. package/dist/cjs/utils/objectAssignSafe.js +0 -7
  418. package/dist/cjs/utils/objectDefineProperty.js +0 -7
  419. package/dist/cjs/utils/objectEntries.js +0 -8
  420. package/dist/cjs/utils/objectEntriesForEach.js +0 -7
  421. package/dist/cjs/utils/objectFilter.js +0 -10
  422. package/dist/cjs/utils/objectFromEntries.js +0 -7
  423. package/dist/cjs/utils/objectKeys.js +0 -9
  424. package/dist/cjs/utils/objectReplace.js +0 -9
  425. package/dist/cjs/utils/onPageVisibilityChange.js +0 -18
  426. package/dist/cjs/utils/pLimit.js +0 -134
  427. package/dist/cjs/utils/parseNpmPackage.js +0 -106
  428. package/dist/cjs/utils/parseUrl-extras.js +0 -110
  429. package/dist/cjs/utils/parseUrl.js +0 -338
  430. package/dist/cjs/utils/path.js +0 -59
  431. package/dist/cjs/utils/pick.js +0 -12
  432. package/dist/cjs/utils/preservePropertyGetters.js +0 -30
  433. package/dist/cjs/utils/redirectHard.js +0 -6
  434. package/dist/cjs/utils/removeEmptyLines.js +0 -9
  435. package/dist/cjs/utils/removeFileExtension.js +0 -6
  436. package/dist/cjs/utils/requireResolve.js +0 -214
  437. package/dist/cjs/utils/rollupSourceMap.js +0 -19
  438. package/dist/cjs/utils/sleep.js +0 -6
  439. package/dist/cjs/utils/slice.js +0 -35
  440. package/dist/cjs/utils/sorter.js +0 -117
  441. package/dist/cjs/utils/stringifyStringArray.js +0 -6
  442. package/dist/cjs/utils/stripAnsi.js +0 -21
  443. package/dist/cjs/utils/styleFileRE.js +0 -6
  444. package/dist/cjs/utils/throttle.js +0 -15
  445. package/dist/cjs/utils/trackLogs.js +0 -31
  446. package/dist/cjs/utils/trimWithAnsi.js +0 -40
  447. package/dist/cjs/utils/truncateString.js +0 -23
  448. package/dist/cjs/utils/unique.js +0 -6
  449. package/dist/cjs/utils/updateType.js +0 -9
  450. package/dist/cjs/utils/urlToFile.js +0 -36
  451. package/dist/cjs/utils/virtualFileId.js +0 -39
  452. package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
  453. package/dist/esm/client/runtime-server-routing/globalContext.js +0 -5
  454. package/dist/esm/client/shared/createGetGlobalContextClient.js +0 -65
  455. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -249
  456. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -34
  457. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -39
  458. package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
  459. package/dist/esm/node/vite/plugins/pluginBuild.js +0 -19
  460. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +0 -50
  461. package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -3
  462. package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -67
  463. /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildApp.d.ts +0 -0
  464. /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginBuildConfig.d.ts +0 -0
  465. /package/dist/esm/node/vite/plugins/{pluginBuild → build}/pluginProdBuildEntry.d.ts +0 -0
@@ -1,161 +0,0 @@
1
- "use strict";
2
- // Unit tests at ./injectHtmlTags.spec.ts
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.injectHtmlTags = injectHtmlTags;
5
- exports.injectHtmlTagsUsingStream = injectHtmlTagsUsingStream;
6
- exports.createHtmlHeadIfMissing = createHtmlHeadIfMissing;
7
- exports.joinHtmlTags = joinHtmlTags;
8
- exports.injectAtOpeningTag = injectAtOpeningTag;
9
- exports.injectAtClosingTag = injectAtClosingTag;
10
- const utils_js_1 = require("../../../utils.js");
11
- function injectHtmlTags(htmlString, htmlTags, position) {
12
- const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === position));
13
- if (htmlFragment) {
14
- htmlString = injectHtmlFragment(position, htmlFragment, htmlString);
15
- }
16
- return htmlString;
17
- }
18
- // Is it worth it? Should we remove this? https://github.com/vikejs/vike/pull/1740#issuecomment-2230540892
19
- function injectHtmlTagsUsingStream(htmlTags, streamFromReactStreamingPackage) {
20
- const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === 'HTML_STREAM'));
21
- if (htmlFragment) {
22
- (0, utils_js_1.assert)(!streamFromReactStreamingPackage.hasStreamEnded());
23
- streamFromReactStreamingPackage.injectToStream(htmlFragment, { flush: true });
24
- }
25
- }
26
- function joinHtmlTags(htmlTags) {
27
- const htmlFragment = htmlTags.map((h) => resolveHtmlTag(h.htmlTag)).join('');
28
- return htmlFragment;
29
- }
30
- function injectHtmlFragment(position, htmlFragment, htmlString) {
31
- if (position === 'HTML_BEGIN') {
32
- {
33
- const res = injectAtPlaceholder(htmlFragment, htmlString, true);
34
- if (res)
35
- return res;
36
- }
37
- (0, utils_js_1.assert)(tagOpeningExists('head', htmlString));
38
- htmlString = injectAtOpeningTag('head', htmlString, htmlFragment);
39
- return htmlString;
40
- }
41
- if (position === 'HTML_END') {
42
- {
43
- const res = injectAtPlaceholder(htmlFragment, htmlString, false);
44
- if (res)
45
- return res;
46
- }
47
- if (tagClosingExists('body', htmlString)) {
48
- return injectAtClosingTag('body', htmlString, htmlFragment);
49
- }
50
- if (tagClosingExists('html', htmlString)) {
51
- return injectAtClosingTag('html', htmlString, htmlFragment);
52
- }
53
- return htmlString + '\n' + htmlFragment;
54
- }
55
- (0, utils_js_1.assert)(false);
56
- }
57
- function resolveHtmlTag(htmlTag) {
58
- return typeof htmlTag !== 'string' ? htmlTag() : htmlTag;
59
- }
60
- function injectAtOpeningTag(tag, htmlString, htmlFragment) {
61
- const openingTag = getTagOpening(tag);
62
- const matches = htmlString.match(openingTag);
63
- (0, utils_js_1.assert)(matches && matches.length >= 1);
64
- const tagInstance = matches[0];
65
- (0, utils_js_1.assert)(tagInstance);
66
- const htmlParts = htmlString.split(tagInstance);
67
- (0, utils_js_1.assert)(htmlParts.length >= 2);
68
- // Insert `htmlFragment` after first `tagInstance`
69
- const before = (0, utils_js_1.slice)(htmlParts, 0, 1)[0] + tagInstance;
70
- const after = (0, utils_js_1.slice)(htmlParts, 1, 0).join(tagInstance);
71
- htmlFragment = injectBreakLines(htmlFragment, before, after);
72
- return before + htmlFragment + after;
73
- }
74
- function injectAtClosingTag(tag, htmlString, htmlFragment) {
75
- const tagClosing = getTagClosing(tag);
76
- const matches = htmlString.match(tagClosing);
77
- (0, utils_js_1.assert)(matches && matches.length >= 1);
78
- const tagInstance = matches[0];
79
- (0, utils_js_1.assert)(tagInstance);
80
- const htmlParts = htmlString.split(tagInstance);
81
- (0, utils_js_1.assert)(htmlParts.length >= 2);
82
- // Insert `htmlFragment` before last `tagClosing`
83
- const before = (0, utils_js_1.slice)(htmlParts, 0, -1).join(tagInstance);
84
- const after = tagInstance + (0, utils_js_1.slice)(htmlParts, -1, 0);
85
- htmlFragment = injectBreakLines(htmlFragment, before, after);
86
- return before + htmlFragment + after;
87
- }
88
- function injectBreakLines(htmlFragment, before, after) {
89
- (0, utils_js_1.assert)(htmlFragment.trim() === htmlFragment);
90
- const currentLineBefore = before.split('\n').slice(-1)[0];
91
- let paddingParent = currentLineBefore.match(/\s*$/)[0];
92
- let isBlankLine = !!paddingParent;
93
- if (!paddingParent) {
94
- paddingParent = currentLineBefore.match(/^\s*/)[0];
95
- }
96
- if (!paddingParent)
97
- return htmlFragment;
98
- const whitespaceExtra = paddingParent ? ' ' : '';
99
- const whitespace = `${paddingParent}${whitespaceExtra}`;
100
- const padding = `\n${whitespace}`;
101
- htmlFragment = htmlFragment.replace(/<[^\/]/g, (match) => `${padding}${match}`);
102
- if (isBlankLine) {
103
- (0, utils_js_1.assert)(htmlFragment.startsWith(padding), { htmlFragment });
104
- htmlFragment = whitespaceExtra + htmlFragment.slice(padding.length);
105
- }
106
- const currentLineAfter = after.split('\n')[0];
107
- if (currentLineAfter.trim().length > 0) {
108
- htmlFragment += '\n' + paddingParent;
109
- }
110
- return htmlFragment;
111
- }
112
- function createHtmlHeadIfMissing(htmlString) {
113
- const assertion = () => (0, utils_js_1.assert)(tagOpeningExists('head', htmlString) && tagClosingExists('head', htmlString));
114
- if (tagOpeningExists('head', htmlString) && tagClosingExists('head', htmlString)) {
115
- assertion();
116
- return htmlString;
117
- }
118
- const htmlFragment = '<head></head>';
119
- if (tagOpeningExists('html', htmlString)) {
120
- htmlString = injectAtOpeningTag('html', htmlString, htmlFragment);
121
- assertion();
122
- return htmlString;
123
- }
124
- if (tagOpeningExists('!doctype', htmlString)) {
125
- htmlString = injectAtOpeningTag('!doctype', htmlString, htmlFragment);
126
- assertion();
127
- return htmlString;
128
- }
129
- htmlString = htmlFragment + '\n' + htmlString;
130
- assertion();
131
- return htmlString;
132
- }
133
- // Pay attention to performance when searching for tags
134
- // Use the most effective way to test or match tag existence
135
- // Use tag existence checking with caution as it is costly operation
136
- function tagOpeningExists(tag, htmlString) {
137
- const tagOpeningRE = getTagOpening(tag);
138
- return tagOpeningRE.test(htmlString);
139
- }
140
- function tagClosingExists(tag, htmlString) {
141
- const tagClosingRE = getTagClosing(tag);
142
- return tagClosingRE.test(htmlString);
143
- }
144
- function getTagOpening(tag) {
145
- const tagOpening = new RegExp(`<${tag}(>| [^>]*>)`, 'i');
146
- return tagOpening;
147
- }
148
- function getTagClosing(tag) {
149
- const tagClosing = new RegExp(`</${tag}>`, 'i');
150
- return tagClosing;
151
- }
152
- function injectAtPlaceholder(htmlFragment, htmlString, isFirst) {
153
- // TO-DO/eventually: soft deprecate in favor of https://github.com/vikejs/vike/issues/695
154
- // Used by BurdaForward https://github.com/vikejs/vike/discussions/2528#discussioncomment-13637156
155
- const placeholder = isFirst ? '__VITE_PLUGIN_SSR__ASSETS_FIRST__' : '__VITE_PLUGIN__SSR_ASSETS_LAST__';
156
- const parts = htmlString.split(placeholder);
157
- if (parts.length === 1)
158
- return null;
159
- (0, utils_js_1.assertUsage)(parts.length === 2, "You're inserting assets twice into your HTML", { showStackTrace: true });
160
- return [parts[0], htmlFragment, parts[1]].join('');
161
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeScriptTags = mergeScriptTags;
4
- const csp_js_1 = require("../../csp.js");
5
- const utils_js_1 = require("../../../utils.js");
6
- const inferHtmlTags_js_1 = require("./inferHtmlTags.js");
7
- const scriptRE = /(<script\b(?:\s[^>]*>|>))(.*?)<\/script>/gims;
8
- const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
9
- const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
10
- function mergeScriptTags(scriptTagsHtml, pageContext) {
11
- let scriptTag = '';
12
- const scripts = parseScripts(scriptTagsHtml);
13
- // We need to merge module scripts to ensure execution order
14
- {
15
- const scriptsModule = scripts.filter(({ isModule }) => isModule);
16
- if (scriptsModule.length === 1) {
17
- scriptTag += scriptsModule[0].outerHtml;
18
- }
19
- else {
20
- const contents = [];
21
- scriptsModule.forEach(({ src, innerHtml }) => {
22
- const hasInnerHtml = !!innerHtml.trim();
23
- if (src) {
24
- (0, utils_js_1.assert)(!hasInnerHtml);
25
- // - We don't use a static import because static imports are hoisted => React's HMR preamble can be executed after user land code => triggering this error:
26
- // ```
27
- // [22:28:57.885][/test-dev.test.ts][pnpm run dev][Browser Error] Error: @vitejs/plugin-react-swc can't detect preamble. Something is wrong.
28
- // at http://localhost:3000/@fs/home/rom/code/docpress/src/renderer/usePageContext.tsx:9:11
29
- // ```
30
- // - We don't use `await` the dynamic import() to avoid waterfall
31
- contents.push(`import(${JSON.stringify(src)});`);
32
- }
33
- else if (hasInnerHtml) {
34
- innerHtml = innerHtml.split('\n').filter(Boolean).join('\n');
35
- contents.push(innerHtml);
36
- }
37
- });
38
- if (contents.length > 0) {
39
- const nonceAttr = (0, csp_js_1.inferNonceAttr)(pageContext);
40
- scriptTag += `<script ${inferHtmlTags_js_1.scriptCommonAttrs}${nonceAttr}>\n${contents.join('\n')}\n</script>`;
41
- }
42
- }
43
- }
44
- // We don't need to merge ES5 scripts
45
- {
46
- const scriptsES5 = scripts.filter(({ isModule }) => !isModule);
47
- scriptsES5.forEach(({ outerHtml }) => {
48
- scriptTag += outerHtml;
49
- });
50
- }
51
- return scriptTag;
52
- }
53
- function parseScripts(htmlString) {
54
- const scripts = [];
55
- let match;
56
- while ((match = scriptRE.exec(htmlString))) {
57
- const [outerHtml, openTag, innerHtml] = match;
58
- (0, utils_js_1.assert)(outerHtml && openTag && innerHtml !== undefined);
59
- let isModule = false;
60
- {
61
- const typeMatch = openTag.match(typeRE);
62
- const type = typeMatch && (typeMatch[1] || typeMatch[2] || typeMatch[3]);
63
- isModule = type === 'module';
64
- }
65
- let src = null;
66
- {
67
- const srcMatch = openTag.match(srcRE);
68
- src = (srcMatch && (srcMatch[1] || srcMatch[2] || srcMatch[3])) || '';
69
- }
70
- scripts.push({ isModule, src, innerHtml, outerHtml });
71
- }
72
- return scripts;
73
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- // Prevent XSS attacks, see https://github.com/vikejs/vike/pull/181#issuecomment-952846026
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.sanitizeJson = sanitizeJson;
5
- function sanitizeJson(unsafe) {
6
- const safe = unsafe.replace(/</g, '\\u003c');
7
- return safe;
8
- }
@@ -1,93 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectHtmlTagsToString = injectHtmlTagsToString;
4
- exports.injectHtmlTagsToStream = injectHtmlTagsToStream;
5
- const utils_js_1 = require("../../utils.js");
6
- const assertPageContextProvidedByUser_js_1 = require("../../../../shared/assertPageContextProvidedByUser.js");
7
- const injectHtmlTags_js_1 = require("./injectAssets/injectHtmlTags.js");
8
- const getHtmlTags_js_1 = require("./injectAssets/getHtmlTags.js");
9
- const getViteDevScript_js_1 = require("./injectAssets/getViteDevScript.js");
10
- async function injectHtmlTagsToString(htmlParts, pageContext, injectFilter) {
11
- const pageAssets = await pageContext.__getPageAssets();
12
- const viteDevScript = await (0, getViteDevScript_js_1.getViteDevScript)(pageContext);
13
- const htmlTags = await (0, getHtmlTags_js_1.getHtmlTags)(pageContext, null, injectFilter, pageAssets, viteDevScript, false);
14
- let htmlString = htmlPartsToString(htmlParts, pageAssets);
15
- htmlString = injectToHtmlBegin(htmlString, htmlTags);
16
- htmlString = injectToHtmlEnd(htmlString, htmlTags);
17
- (0, utils_js_1.assert)(htmlTags.filter((snippet) => snippet.position === 'HTML_STREAM').length === 0);
18
- return htmlString;
19
- }
20
- function injectHtmlTagsToStream(pageContext, streamFromReactStreamingPackage, injectFilter) {
21
- let htmlTags;
22
- return {
23
- injectAtStreamBegin,
24
- injectAtStreamAfterFirstChunk,
25
- injectAtStreamEnd,
26
- };
27
- async function injectAtStreamBegin(htmlPartsBegin) {
28
- const pageAssets = await pageContext.__getPageAssets();
29
- const viteDevScript = await (0, getViteDevScript_js_1.getViteDevScript)(pageContext);
30
- htmlTags = await (0, getHtmlTags_js_1.getHtmlTags)(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript, true);
31
- let htmlBegin = htmlPartsToString(htmlPartsBegin, pageAssets);
32
- htmlBegin = injectToHtmlBegin(htmlBegin, htmlTags);
33
- if (streamFromReactStreamingPackage) {
34
- (0, injectHtmlTags_js_1.injectHtmlTagsUsingStream)(htmlTags, streamFromReactStreamingPackage);
35
- }
36
- return htmlBegin;
37
- }
38
- // Is it worth it? Should we remove this? https://github.com/vikejs/vike/pull/1740#issuecomment-2230540892
39
- function injectAtStreamAfterFirstChunk() {
40
- // React has its own stream injection mechanism, see injectHtmlTagsUsingStream()
41
- if (streamFromReactStreamingPackage)
42
- return null;
43
- (0, utils_js_1.assert)(htmlTags);
44
- const tags = htmlTags.filter((h) => h.position === 'HTML_STREAM');
45
- if (tags.length === 0)
46
- return null;
47
- const htmlFragment = (0, injectHtmlTags_js_1.joinHtmlTags)(tags);
48
- return htmlFragment;
49
- }
50
- async function injectAtStreamEnd(htmlPartsEnd) {
51
- (0, utils_js_1.assert)(htmlTags);
52
- await resolvePageContextPromise(pageContext);
53
- const pageAssets = await pageContext.__getPageAssets();
54
- let htmlEnd = htmlPartsToString(htmlPartsEnd, pageAssets);
55
- htmlEnd = injectToHtmlEnd(htmlEnd, htmlTags);
56
- return htmlEnd;
57
- }
58
- }
59
- function injectToHtmlBegin(htmlBegin, htmlTags) {
60
- // Ensure existence of `<head>`
61
- htmlBegin = (0, injectHtmlTags_js_1.createHtmlHeadIfMissing)(htmlBegin);
62
- htmlBegin = (0, injectHtmlTags_js_1.injectHtmlTags)(htmlBegin, htmlTags, 'HTML_BEGIN');
63
- return htmlBegin;
64
- }
65
- function injectToHtmlEnd(htmlEnd, htmlTags) {
66
- htmlEnd = (0, injectHtmlTags_js_1.injectHtmlTags)(htmlEnd, htmlTags, 'HTML_END');
67
- return htmlEnd;
68
- }
69
- async function resolvePageContextPromise(pageContext) {
70
- const pageContextPromise = pageContext._pageContextPromise;
71
- if (!pageContextPromise) {
72
- return;
73
- }
74
- let pageContextProvidedByUser;
75
- if ((0, utils_js_1.isCallable)(pageContextPromise)) {
76
- pageContextProvidedByUser = await pageContextPromise();
77
- }
78
- else if ((0, utils_js_1.isPromise)(pageContextPromise)) {
79
- pageContextProvidedByUser = await pageContextPromise;
80
- }
81
- else {
82
- (0, utils_js_1.assert)(false);
83
- }
84
- (0, assertPageContextProvidedByUser_js_1.assertPageContextProvidedByUser)(pageContextProvidedByUser, pageContext._renderHook);
85
- Object.assign(pageContext, pageContextProvidedByUser);
86
- }
87
- function htmlPartsToString(htmlParts, pageAssets) {
88
- let htmlString = '';
89
- htmlParts.forEach((p) => {
90
- htmlString += typeof p === 'string' ? p : p(pageAssets);
91
- });
92
- return htmlString;
93
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPropVal = getPropVal;
4
- exports.setPropVal = setPropVal;
5
- exports.getPropKeys = getPropKeys;
6
- const utils_js_1 = require("../../utils.js");
7
- // Get a nested property from an object using a dot-separated path such as 'user.id'
8
- function getPropVal(obj, prop) {
9
- const keys = getPropKeys(prop);
10
- let value = obj;
11
- for (const key of keys) {
12
- if ((0, utils_js_1.isObject)(value) && key in value) {
13
- value = value[key];
14
- }
15
- else {
16
- return null; // Property or intermediate property doesn't exist
17
- }
18
- }
19
- return { value };
20
- }
21
- // Set a nested property in an object using a dot-separated path such as 'user.id'
22
- function setPropVal(obj, prop, val) {
23
- const keys = getPropKeys(prop);
24
- let currentObj = obj;
25
- // Creating intermediate objects if necessary
26
- for (let i = 0; i <= keys.length - 2; i++) {
27
- const key = keys[i];
28
- if (!(key in currentObj)) {
29
- // Create intermediate object
30
- currentObj[key] = {};
31
- }
32
- if (!(0, utils_js_1.isObject)(currentObj[key])) {
33
- // Skip value upon data structure conflict
34
- return;
35
- }
36
- currentObj = currentObj[key];
37
- }
38
- // Set the final key to the value
39
- const finalKey = keys[keys.length - 1];
40
- currentObj[finalKey] = val;
41
- }
42
- function getPropKeys(prop) {
43
- // Like `prop.split('.')` but with added support for `\` escaping, see getPageContextClientSerialized.spec.ts
44
- return prop
45
- .split(/(?<!\\)\./) // Split on unescaped dots
46
- .map((key) => key.replace(/\\\./g, '.')); // Replace escaped dots with literal dots
47
- }
@@ -1,245 +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.escapeInject = escapeInject;
7
- exports.dangerouslySkipEscape = dangerouslySkipEscape;
8
- exports.renderDocumentHtml = renderDocumentHtml;
9
- exports.isDocumentHtml = isDocumentHtml;
10
- exports.getHtmlString = getHtmlString;
11
- const utils_js_1 = require("../../utils.js");
12
- const injectAssets_js_1 = require("./injectAssets.js");
13
- const stream_js_1 = require("./stream.js");
14
- const react_streaming_js_1 = require("./stream/react-streaming.js");
15
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
16
- function isDocumentHtml(something) {
17
- if (isTemplateWrapped(something) || isEscapedString(something) || (0, stream_js_1.isStream)(something)) {
18
- (0, utils_js_1.checkType)(something);
19
- return true;
20
- }
21
- return false;
22
- }
23
- async function renderDocumentHtml(documentHtml, pageContext, onErrorWhileStreaming, injectFilter) {
24
- if (isEscapedString(documentHtml)) {
25
- (0, utils_js_1.objectAssign)(pageContext, { _isStream: false });
26
- let htmlString = getEscapedString(documentHtml);
27
- htmlString = await (0, injectAssets_js_1.injectHtmlTagsToString)([htmlString], pageContext, injectFilter);
28
- return htmlString;
29
- }
30
- if ((0, stream_js_1.isStream)(documentHtml)) {
31
- (0, utils_js_1.objectAssign)(pageContext, { _isStream: true });
32
- const stream = documentHtml;
33
- const streamWrapper = await renderHtmlStream(stream, null, pageContext, onErrorWhileStreaming, injectFilter);
34
- return streamWrapper;
35
- }
36
- if (isTemplateWrapped(documentHtml)) {
37
- const templateContent = documentHtml._template;
38
- const render = renderTemplate(templateContent, pageContext);
39
- if (!('htmlStream' in render)) {
40
- (0, utils_js_1.objectAssign)(pageContext, { _isStream: false });
41
- const { htmlPartsAll } = render;
42
- const htmlString = await (0, injectAssets_js_1.injectHtmlTagsToString)(htmlPartsAll, pageContext, injectFilter);
43
- return htmlString;
44
- }
45
- else {
46
- (0, utils_js_1.objectAssign)(pageContext, { _isStream: true });
47
- const { htmlStream } = render;
48
- const streamWrapper = await renderHtmlStream(htmlStream, {
49
- htmlPartsBegin: render.htmlPartsBegin,
50
- htmlPartsEnd: render.htmlPartsEnd,
51
- }, pageContext, onErrorWhileStreaming, injectFilter);
52
- return streamWrapper;
53
- }
54
- }
55
- (0, utils_js_1.checkType)(documentHtml);
56
- (0, utils_js_1.assert)(false);
57
- }
58
- async function renderHtmlStream(streamOriginal, injectString, pageContext, onErrorWhileStreaming, injectFilter) {
59
- const processStreamOptions = {
60
- onErrorWhileStreaming,
61
- enableEagerStreaming: pageContext.enableEagerStreaming,
62
- };
63
- if (injectString) {
64
- let streamFromReactStreamingPackage = null;
65
- if ((0, react_streaming_js_1.isStreamFromReactStreamingPackage)(streamOriginal) && !streamOriginal.disabled) {
66
- streamFromReactStreamingPackage = streamOriginal;
67
- }
68
- const { injectAtStreamBegin, injectAtStreamAfterFirstChunk, injectAtStreamEnd } = (0, injectAssets_js_1.injectHtmlTagsToStream)(pageContext, streamFromReactStreamingPackage, injectFilter);
69
- processStreamOptions.injectStringAtBegin = async () => {
70
- return await injectAtStreamBegin(injectString.htmlPartsBegin);
71
- };
72
- processStreamOptions.injectStringAtEnd = async () => {
73
- return await injectAtStreamEnd(injectString.htmlPartsEnd);
74
- };
75
- processStreamOptions.injectStringAfterFirstChunk = () => {
76
- return injectAtStreamAfterFirstChunk();
77
- };
78
- }
79
- let makeClosableAgain = () => { };
80
- if ((0, react_streaming_js_1.isStreamFromReactStreamingPackage)(streamOriginal)) {
81
- // Make sure Vike injects its HTML fragments, such as `<script id="vike_pageContext" type="application/json">`, before the stream is closed (if React/Vue finishes its stream before the promise below resolves).
82
- makeClosableAgain = streamOriginal.doNotClose();
83
- }
84
- try {
85
- const streamWrapper = await (0, stream_js_1.processStream)(streamOriginal, processStreamOptions);
86
- return streamWrapper;
87
- }
88
- finally {
89
- makeClosableAgain();
90
- }
91
- }
92
- function isTemplateWrapped(something) {
93
- return (0, utils_js_1.hasProp)(something, '_template');
94
- }
95
- function isEscapedString(something) {
96
- const result = (0, utils_js_1.hasProp)(something, '_escaped');
97
- if (result) {
98
- (0, utils_js_1.assert)((0, utils_js_1.hasProp)(something, '_escaped', 'string'));
99
- (0, utils_js_1.checkType)(something);
100
- }
101
- return result;
102
- }
103
- function getEscapedString(escapedString) {
104
- let htmlString;
105
- (0, utils_js_1.assert)((0, utils_js_1.hasProp)(escapedString, '_escaped'));
106
- htmlString = escapedString._escaped;
107
- (0, utils_js_1.assert)(typeof htmlString === 'string');
108
- return htmlString;
109
- }
110
- function escapeInject(templateStrings, ...templateVariables) {
111
- (0, utils_js_1.assertUsage)(templateStrings.length === templateVariables.length + 1 && templateStrings.every((str) => typeof str === 'string'), `You're using ${picocolors_1.default.cyan('escapeInject')} as a function, but ${picocolors_1.default.cyan('escapeInject')} is a string template tag, see https://vike.dev/escapeInject`, { showStackTrace: true });
112
- return {
113
- _template: {
114
- templateStrings,
115
- templateVariables: templateVariables,
116
- },
117
- };
118
- }
119
- function dangerouslySkipEscape(alreadyEscapedString) {
120
- return _dangerouslySkipEscape(alreadyEscapedString);
121
- }
122
- function _dangerouslySkipEscape(arg) {
123
- if ((0, utils_js_1.hasProp)(arg, '_escaped')) {
124
- (0, utils_js_1.assert)(isEscapedString(arg));
125
- return arg;
126
- }
127
- (0, utils_js_1.assertUsage)(!(0, utils_js_1.isPromise)(arg), `[dangerouslySkipEscape(${picocolors_1.default.cyan('str')})] Argument ${picocolors_1.default.cyan('str')} is a promise. It should be a string instead (or a stream). Make sure to ${picocolors_1.default.cyan('await str')}.`, { showStackTrace: true });
128
- if (typeof arg === 'string') {
129
- return { _escaped: arg };
130
- }
131
- (0, utils_js_1.assertWarning)(false, `[dangerouslySkipEscape(${picocolors_1.default.cyan('str')})] Argument ${picocolors_1.default.cyan('str')} should be a string but we got ${picocolors_1.default.cyan(`typeof str === "${typeof arg}"`)}.`, {
132
- onlyOnce: false,
133
- showStackTrace: true,
134
- });
135
- return { _escaped: String(arg) };
136
- }
137
- function renderTemplate(templateContent, pageContext) {
138
- const htmlPartsBegin = [];
139
- const htmlPartsEnd = [];
140
- let htmlStream = null;
141
- const addHtmlPart = (htmlPart) => {
142
- if (htmlStream === null) {
143
- htmlPartsBegin.push(htmlPart);
144
- }
145
- else {
146
- htmlPartsEnd.push(htmlPart);
147
- }
148
- };
149
- const setStream = (stream) => {
150
- const { hookName, hookFilePath } = pageContext._renderHook;
151
- (0, utils_js_1.assertUsage)(!htmlStream, `Injecting two streams in ${picocolors_1.default.cyan('escapeInject')} template tag of ${hookName}() hook defined by ${hookFilePath}. Inject only one stream instead.`);
152
- htmlStream = stream;
153
- };
154
- const { templateStrings, templateVariables } = templateContent;
155
- for (let i = 0; i < templateVariables.length; i++) {
156
- addHtmlPart(templateStrings[i]);
157
- let templateVar = templateVariables[i];
158
- // Process `dangerouslySkipEscape()`
159
- if (isEscapedString(templateVar)) {
160
- const htmlString = getEscapedString(templateVar);
161
- // User used `dangerouslySkipEscape()` so we assume the string to be safe
162
- addHtmlPart(htmlString);
163
- continue;
164
- }
165
- // Process `escapeInject` fragments
166
- if (isTemplateWrapped(templateVar)) {
167
- const templateContentInner = templateVar._template;
168
- const result = renderTemplate(templateContentInner, pageContext);
169
- if (!('htmlStream' in result)) {
170
- result.htmlPartsAll.forEach(addHtmlPart);
171
- }
172
- else {
173
- result.htmlPartsBegin.forEach(addHtmlPart);
174
- setStream(result.htmlStream);
175
- result.htmlPartsEnd.forEach(addHtmlPart);
176
- }
177
- continue;
178
- }
179
- if ((0, stream_js_1.isStream)(templateVar)) {
180
- setStream(templateVar);
181
- continue;
182
- }
183
- const getErrMsg = (msg) => {
184
- const { hookName, hookFilePath } = pageContext._renderHook;
185
- const nth = (i === 0 && '1st') || (i === 1 && '2nd') || (i === 2 && '3rd') || `${i}-th`;
186
- return [
187
- `The ${nth} HTML variable is ${msg}`,
188
- `The HTML was provided by the ${hookName}() hook at ${hookFilePath}.`,
189
- ]
190
- .filter(Boolean)
191
- .join(' ');
192
- };
193
- (0, utils_js_1.assertUsage)(!(0, utils_js_1.isPromise)(templateVar), getErrMsg(`a promise, did you forget to ${picocolors_1.default.cyan('await')} the promise?`));
194
- if (templateVar === undefined || templateVar === null) {
195
- const msgVal = picocolors_1.default.cyan(String(templateVar));
196
- const msgEmptyString = picocolors_1.default.cyan("''");
197
- const msg = `${msgVal} which will be converted to an empty string. Pass the empty string ${msgEmptyString} instead of ${msgVal} to remove this warning.`;
198
- (0, utils_js_1.assertWarning)(false, getErrMsg(msg), { onlyOnce: false });
199
- templateVar = '';
200
- }
201
- {
202
- const varType = typeof templateVar;
203
- if (varType !== 'string') {
204
- const msgType = picocolors_1.default.cyan(`typeof htmlVariable === "${varType}"`);
205
- const msg = `${msgType} but a string or stream (https://vike.dev/streaming) is expected instead.`;
206
- (0, utils_js_1.assertUsage)(false, getErrMsg(msg));
207
- }
208
- }
209
- {
210
- const { _isProduction: isProduction } = pageContext._globalContext;
211
- if ((0, utils_js_1.isHtml)(templateVar) &&
212
- // We don't show this warning in production because it's expected that some users may (un)willingly do some XSS injection: we avoid flooding the production logs.
213
- !isProduction) {
214
- const msgVal = picocolors_1.default.cyan(String(templateVar));
215
- const msg = `${msgVal} which seems to be HTML code. Did you forget to wrap the value with dangerouslySkipEscape()?`;
216
- (0, utils_js_1.assertWarning)(false, getErrMsg(msg), { onlyOnce: false });
217
- }
218
- }
219
- // Escape untrusted template variable
220
- addHtmlPart((0, utils_js_1.escapeHtml)(templateVar));
221
- }
222
- (0, utils_js_1.assert)(templateStrings.length === templateVariables.length + 1);
223
- addHtmlPart(templateStrings[templateStrings.length - 1]);
224
- if (htmlStream === null) {
225
- (0, utils_js_1.assert)(htmlPartsEnd.length === 0);
226
- return {
227
- htmlPartsAll: htmlPartsBegin,
228
- };
229
- }
230
- return {
231
- htmlStream,
232
- htmlPartsBegin,
233
- htmlPartsEnd,
234
- };
235
- }
236
- async function getHtmlString(htmlRender) {
237
- if (typeof htmlRender === 'string') {
238
- return htmlRender;
239
- }
240
- if ((0, stream_js_1.isStream)(htmlRender)) {
241
- return (0, stream_js_1.streamToString)(htmlRender);
242
- }
243
- (0, utils_js_1.checkType)(htmlRender);
244
- (0, utils_js_1.assert)(false);
245
- }