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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (420) hide show
  1. package/dist/esm/client/runtime-client-routing/entry.js +5 -0
  2. package/dist/esm/client/runtime-client-routing/globalContext.d.ts +1 -1
  3. package/dist/esm/client/runtime-client-routing/globalContext.js +9 -3
  4. package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +2 -2
  5. package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +15 -1
  6. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
  7. package/dist/esm/client/runtime-server-routing/entry.js +5 -0
  8. package/dist/esm/client/runtime-server-routing/globalContext.d.ts +2 -2
  9. package/dist/esm/client/runtime-server-routing/globalContext.js +7 -3
  10. package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +4 -3
  11. package/dist/esm/client/shared/createGetGlobalContextClient.js +38 -34
  12. package/dist/esm/node/vite/index.js +34 -15
  13. package/dist/esm/node/vite/plugins/pluginBaseUrls.d.ts +1 -1
  14. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +37 -35
  15. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +4 -0
  16. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +21 -6
  17. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +16 -4
  18. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.d.ts +1 -1
  19. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +82 -80
  20. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.d.ts +1 -1
  21. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +23 -21
  22. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.d.ts +1 -1
  23. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +38 -36
  24. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.d.ts +1 -1
  25. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +26 -24
  26. package/dist/esm/node/vite/plugins/pluginCommon.js +1 -1
  27. package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -1
  28. package/dist/esm/node/vite/plugins/pluginEnvVars.d.ts +1 -1
  29. package/dist/esm/node/vite/plugins/pluginEnvVars.js +87 -65
  30. package/dist/esm/node/vite/plugins/pluginExtractExportNames.d.ts +1 -1
  31. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +29 -27
  32. package/dist/esm/node/vite/plugins/pluginFileEnv.d.ts +1 -1
  33. package/dist/esm/node/vite/plugins/pluginFileEnv.js +75 -73
  34. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +1 -1
  35. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +30 -28
  36. package/dist/esm/node/vite/plugins/pluginPreview.d.ts +1 -1
  37. package/dist/esm/node/vite/plugins/pluginPreview.js +35 -33
  38. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.d.ts +9 -0
  39. package/dist/esm/node/vite/plugins/pluginReplaceGlobalThisConstants.js +45 -0
  40. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.d.ts +3 -0
  41. package/dist/esm/node/vite/plugins/pluginReplaceIsClientSide.js +89 -0
  42. package/dist/esm/node/vite/plugins/pluginVirtualFiles.d.ts +1 -1
  43. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +50 -48
  44. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.d.ts +1 -1
  45. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +12 -10
  46. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.d.ts +1 -1
  47. package/dist/esm/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +26 -24
  48. package/dist/esm/shared/createGlobalContextShared.js +1 -0
  49. package/dist/esm/shared/route/abort.d.ts +22 -11
  50. package/dist/esm/shared/route/abort.js +37 -5
  51. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  52. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  53. package/dist/esm/utils/findPackageJson.js +0 -1
  54. package/dist/esm/utils/getViteRPC.js +0 -2
  55. package/dist/esm/utils/requireResolve.js +0 -1
  56. package/package.json +3 -22
  57. package/dist/cjs/__internal/index.js +0 -35
  58. package/dist/cjs/client/runtime-client-routing/globalContext.js +0 -49
  59. package/dist/cjs/client/runtime-client-routing/prefetch/PrefetchSetting.js +0 -2
  60. package/dist/cjs/client/runtime-server-routing/globalContext.js +0 -41
  61. package/dist/cjs/client/runtime-server-routing/onLoad.js +0 -7
  62. package/dist/cjs/client/runtime-server-routing/utils.js +0 -34
  63. package/dist/cjs/client/shared/createGetGlobalContextClient.js +0 -65
  64. package/dist/cjs/client/shared/getJsonSerializedInHtml.js +0 -40
  65. package/dist/cjs/client/shared/preparePageContextForPublicUsageClientShared.js +0 -41
  66. package/dist/cjs/client/shared/utils.js +0 -23
  67. package/dist/cjs/node/api/build.js +0 -24
  68. package/dist/cjs/node/api/context.js +0 -23
  69. package/dist/cjs/node/api/dev.js +0 -18
  70. package/dist/cjs/node/api/index.js +0 -44
  71. package/dist/cjs/node/api/onLoad.js +0 -9
  72. package/dist/cjs/node/api/prepareViteApiCall.js +0 -206
  73. package/dist/cjs/node/api/prerender.js +0 -18
  74. package/dist/cjs/node/api/preview.js +0 -38
  75. package/dist/cjs/node/api/types.js +0 -2
  76. package/dist/cjs/node/api/utils.js +0 -27
  77. package/dist/cjs/node/cli/context.js +0 -17
  78. package/dist/cjs/node/cli/entry.js +0 -121
  79. package/dist/cjs/node/cli/index.js +0 -12
  80. package/dist/cjs/node/cli/onLoad.js +0 -9
  81. package/dist/cjs/node/cli/parseCli.js +0 -95
  82. package/dist/cjs/node/cli/utils.js +0 -24
  83. package/dist/cjs/node/client/router.js +0 -19
  84. package/dist/cjs/node/createPageRenderer.js +0 -132
  85. package/dist/cjs/node/importBuild.js +0 -3
  86. package/dist/cjs/node/prerender/context.js +0 -26
  87. package/dist/cjs/node/prerender/index.js +0 -12
  88. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +0 -66
  89. package/dist/cjs/node/prerender/runPrerender.js +0 -778
  90. package/dist/cjs/node/prerender/runPrerenderEntry.js +0 -55
  91. package/dist/cjs/node/prerender/utils.js +0 -37
  92. package/dist/cjs/node/runtime/globalContext.js +0 -582
  93. package/dist/cjs/node/runtime/index-deprecated.js +0 -33
  94. package/dist/cjs/node/runtime/index.js +0 -74
  95. package/dist/cjs/node/runtime/loggerRuntime.js +0 -17
  96. package/dist/cjs/node/runtime/onLoad.js +0 -29
  97. package/dist/cjs/node/runtime/page-files/setup.js +0 -5
  98. package/dist/cjs/node/runtime/renderPage/analyzePage.js +0 -71
  99. package/dist/cjs/node/runtime/renderPage/assertArguments.js +0 -42
  100. package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +0 -51
  101. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +0 -114
  102. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +0 -59
  103. package/dist/cjs/node/runtime/renderPage/csp.js +0 -47
  104. package/dist/cjs/node/runtime/renderPage/execHookDataAndOnBeforeRender.js +0 -31
  105. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +0 -120
  106. package/dist/cjs/node/runtime/renderPage/execHookServer.js +0 -8
  107. package/dist/cjs/node/runtime/renderPage/getCacheControl.js +0 -24
  108. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +0 -20
  109. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +0 -137
  110. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +0 -125
  111. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.js +0 -86
  112. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.js +0 -77
  113. package/dist/cjs/node/runtime/renderPage/getPageAssets/sortPageAssetsForEarlyHintsHeader.js +0 -36
  114. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +0 -50
  115. package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +0 -41
  116. package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +0 -68
  117. package/dist/cjs/node/runtime/renderPage/headersResponse.js +0 -48
  118. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getHtmlTags.js +0 -269
  119. package/dist/cjs/node/runtime/renderPage/html/injectAssets/getViteDevScript.js +0 -32
  120. package/dist/cjs/node/runtime/renderPage/html/injectAssets/inferHtmlTags.js +0 -55
  121. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectAssets__public.js +0 -31
  122. package/dist/cjs/node/runtime/renderPage/html/injectAssets/injectHtmlTags.js +0 -161
  123. package/dist/cjs/node/runtime/renderPage/html/injectAssets/mergeScriptTags.js +0 -73
  124. package/dist/cjs/node/runtime/renderPage/html/injectAssets/sanitizeJson.js +0 -8
  125. package/dist/cjs/node/runtime/renderPage/html/injectAssets.js +0 -93
  126. package/dist/cjs/node/runtime/renderPage/html/propKeys.js +0 -47
  127. package/dist/cjs/node/runtime/renderPage/html/renderHtml.js +0 -245
  128. package/dist/cjs/node/runtime/renderPage/html/serializeContext.js +0 -189
  129. package/dist/cjs/node/runtime/renderPage/html/stream/react-streaming.js +0 -36
  130. package/dist/cjs/node/runtime/renderPage/html/stream.js +0 -829
  131. package/dist/cjs/node/runtime/renderPage/inferMediaType.js +0 -81
  132. package/dist/cjs/node/runtime/renderPage/isFontFallback.js +0 -29
  133. package/dist/cjs/node/runtime/renderPage/isNewError.js +0 -25
  134. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +0 -124
  135. package/dist/cjs/node/runtime/renderPage/log404/index.js +0 -154
  136. package/dist/cjs/node/runtime/renderPage/logErrorHint/errors.js +0 -20
  137. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +0 -200
  138. package/dist/cjs/node/runtime/renderPage/loggerProd.js +0 -34
  139. package/dist/cjs/node/runtime/renderPage/preparePageContextForPublicUsageServer.js +0 -10
  140. package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +0 -83
  141. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +0 -71
  142. package/dist/cjs/node/runtime/renderPage.js +0 -502
  143. package/dist/cjs/node/runtime/universal-middleware.js +0 -20
  144. package/dist/cjs/node/runtime/utils.js +0 -83
  145. package/dist/cjs/node/runtime-dev/createDevMiddleware.js +0 -27
  146. package/dist/cjs/node/runtime-dev/index.js +0 -42
  147. package/dist/cjs/node/shared/assertV1Design.js +0 -30
  148. package/dist/cjs/node/shared/extractAssetsQuery.js +0 -29
  149. package/dist/cjs/node/shared/getVikeConfigError.js +0 -22
  150. package/dist/cjs/node/shared/isErrorDebug.js +0 -7
  151. package/dist/cjs/node/shared/prependEntriesDir.js +0 -13
  152. package/dist/cjs/node/shared/resolveBase.js +0 -35
  153. package/dist/cjs/node/shared/utils.js +0 -35
  154. package/dist/cjs/node/shared/virtualFileId.js +0 -110
  155. package/dist/cjs/node/vite/index.js +0 -69
  156. package/dist/cjs/node/vite/onLoad.js +0 -21
  157. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +0 -52
  158. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +0 -342
  159. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +0 -183
  160. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -222
  161. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +0 -256
  162. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +0 -40
  163. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +0 -49
  164. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +0 -111
  165. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +0 -65
  166. package/dist/cjs/node/vite/plugins/pluginBuild.js +0 -21
  167. package/dist/cjs/node/vite/plugins/pluginCommon/assertResolveAlias.js +0 -88
  168. package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -183
  169. package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +0 -28
  170. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +0 -163
  171. package/dist/cjs/node/vite/plugins/pluginDev.js +0 -111
  172. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +0 -92
  173. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +0 -241
  174. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +0 -113
  175. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +0 -172
  176. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +0 -70
  177. package/dist/cjs/node/vite/plugins/pluginPreview.js +0 -82
  178. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +0 -95
  179. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +0 -51
  180. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/debug.js +0 -5
  181. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.js +0 -56
  182. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +0 -190
  183. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.js +0 -54
  184. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +0 -97
  185. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +0 -233
  186. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +0 -17
  187. package/dist/cjs/node/vite/plugins/pluginWorkaroundVite6HmrRegression.js +0 -35
  188. package/dist/cjs/node/vite/shared/addSsrMiddleware.js +0 -60
  189. package/dist/cjs/node/vite/shared/findPageFiles.js +0 -25
  190. package/dist/cjs/node/vite/shared/getAssetsDir.js +0 -10
  191. package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +0 -42
  192. package/dist/cjs/node/vite/shared/getEnvVarObject.js +0 -37
  193. package/dist/cjs/node/vite/shared/getFilePath.js +0 -172
  194. package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +0 -125
  195. package/dist/cjs/node/vite/shared/getMagicString.js +0 -18
  196. package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +0 -10
  197. package/dist/cjs/node/vite/shared/getOutDirs.js +0 -146
  198. package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +0 -21
  199. package/dist/cjs/node/vite/shared/isAsset.js +0 -40
  200. package/dist/cjs/node/vite/shared/isViteCliCall.js +0 -83
  201. package/dist/cjs/node/vite/shared/isViteServerSide.js +0 -68
  202. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +0 -15
  203. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelSolid.js +0 -15
  204. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +0 -38
  205. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx1.js +0 -26
  206. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errMdx2.js +0 -85
  207. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errPostcss.js +0 -30
  208. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwc.js +0 -19
  209. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errSwcBig.js +0 -19
  210. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +0 -29
  211. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueHtml.js +0 -13
  212. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueJavascript.js +0 -15
  213. package/dist/cjs/node/vite/shared/loggerNotProd/errorWithCodeSnippet.js +0 -162
  214. package/dist/cjs/node/vite/shared/loggerNotProd/log.js +0 -102
  215. package/dist/cjs/node/vite/shared/loggerNotProd.js +0 -208
  216. package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +0 -26
  217. package/dist/cjs/node/vite/shared/loggerVite.js +0 -54
  218. package/dist/cjs/node/vite/shared/normalizeId.js +0 -9
  219. package/dist/cjs/node/vite/shared/parseEsModule.js +0 -33
  220. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +0 -136
  221. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +0 -262
  222. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles/ignorePatternsBuiltIn.js +0 -18
  223. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +0 -252
  224. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/filesystemRouting.js +0 -190
  225. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getConfigFileExport.js +0 -17
  226. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/getPlusFilesAll.js +0 -127
  227. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/loadFileAtConfigTime.js +0 -129
  228. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +0 -195
  229. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +0 -102
  230. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +0 -425
  231. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +0 -1151
  232. package/dist/cjs/node/vite/shared/rollupIsEsm.js +0 -15
  233. package/dist/cjs/node/vite/utils.js +0 -45
  234. package/dist/cjs/package.json +0 -1
  235. package/dist/cjs/shared/NOT_SERIALIZABLE.js +0 -4
  236. package/dist/cjs/shared/RenderErrorPage.js +0 -6
  237. package/dist/cjs/shared/abort.js +0 -16
  238. package/dist/cjs/shared/addIs404ToPageProps.js +0 -18
  239. package/dist/cjs/shared/assertHookReturnedObject.js +0 -21
  240. package/dist/cjs/shared/assertOnBeforeRenderHookReturn.js +0 -21
  241. package/dist/cjs/shared/assertPageContextProvidedByUser.js +0 -20
  242. package/dist/cjs/shared/createGlobalContextShared.js +0 -109
  243. package/dist/cjs/shared/createPageContextShared.js +0 -17
  244. package/dist/cjs/shared/determinePageIdOld.js +0 -11
  245. package/dist/cjs/shared/error-page.js +0 -40
  246. package/dist/cjs/shared/getPageContext.js +0 -6
  247. package/dist/cjs/shared/getPageContextRequestUrl.js +0 -16
  248. package/dist/cjs/shared/getPageContextUrlComputed.js +0 -132
  249. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +0 -19
  250. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/ClientDependency.js +0 -2
  251. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/analyzeExports.js +0 -50
  252. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/determineClientEntry.js +0 -30
  253. package/dist/cjs/shared/getPageFiles/analyzePageClientSide/getExportNames.js +0 -15
  254. package/dist/cjs/shared/getPageFiles/analyzePageClientSide.js +0 -59
  255. package/dist/cjs/shared/getPageFiles/analyzePageServerSide.js +0 -22
  256. package/dist/cjs/shared/getPageFiles/assert_exports_old_design.js +0 -24
  257. package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -52
  258. package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -102
  259. package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -56
  260. package/dist/cjs/shared/getPageFiles/parseVirtualFileExportsGlobalEntry.js +0 -100
  261. package/dist/cjs/shared/getPageFiles.js +0 -7
  262. package/dist/cjs/shared/getProxyForPublicUsage.js +0 -56
  263. package/dist/cjs/shared/hooks/execHook.js +0 -147
  264. package/dist/cjs/shared/hooks/getHook.js +0 -173
  265. package/dist/cjs/shared/htmlElementIds.js +0 -5
  266. package/dist/cjs/shared/misc/isServerSideError.js +0 -4
  267. package/dist/cjs/shared/misc/pageContextInitIsPassedToClient.js +0 -4
  268. package/dist/cjs/shared/modifyUrl.js +0 -28
  269. package/dist/cjs/shared/modifyUrlSameOrigin.js +0 -47
  270. package/dist/cjs/shared/page-configs/assertPlusFileExport.js +0 -42
  271. package/dist/cjs/shared/page-configs/findPageConfig.js +0 -10
  272. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +0 -65
  273. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -68
  274. package/dist/cjs/shared/page-configs/getConfigValueRuntime.js +0 -10
  275. package/dist/cjs/shared/page-configs/getConfigValueTyped.js +0 -32
  276. package/dist/cjs/shared/page-configs/getExportPath.js +0 -29
  277. package/dist/cjs/shared/page-configs/helpers.js +0 -27
  278. package/dist/cjs/shared/page-configs/loadAndParseVirtualFilePageEntry.js +0 -25
  279. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +0 -287
  280. package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +0 -2
  281. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -1
  282. package/dist/cjs/shared/page-configs/serialize/parsePageConfigsSerialized.js +0 -145
  283. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +0 -290
  284. package/dist/cjs/shared/prepareGlobalContextForPublicUsage.js +0 -10
  285. package/dist/cjs/shared/preparePageContextForPublicUsage.js +0 -80
  286. package/dist/cjs/shared/route/abort.js +0 -178
  287. package/dist/cjs/shared/route/debug.js +0 -23
  288. package/dist/cjs/shared/route/deduceRouteStringFromFilesystemPath.js +0 -52
  289. package/dist/cjs/shared/route/execHookGuard.js +0 -37
  290. package/dist/cjs/shared/route/execHookOnBeforeRoute.js +0 -84
  291. package/dist/cjs/shared/route/index.js +0 -107
  292. package/dist/cjs/shared/route/loadPageRoutes.js +0 -197
  293. package/dist/cjs/shared/route/noRouteMatch.js +0 -4
  294. package/dist/cjs/shared/route/resolvePrecedence.js +0 -93
  295. package/dist/cjs/shared/route/resolveRoute.js +0 -20
  296. package/dist/cjs/shared/route/resolveRouteFunction.js +0 -73
  297. package/dist/cjs/shared/route/resolveRouteString.js +0 -153
  298. package/dist/cjs/shared/route/resolveUrlPathname.js +0 -47
  299. package/dist/cjs/shared/route/routing.js +0 -9
  300. package/dist/cjs/shared/route/utils.js +0 -40
  301. package/dist/cjs/shared/utils.js +0 -49
  302. package/dist/cjs/types/Config/ConfigResolved.js +0 -2
  303. package/dist/cjs/types/Config.js +0 -2
  304. package/dist/cjs/types/FilePath.js +0 -2
  305. package/dist/cjs/types/PageConfig.js +0 -2
  306. package/dist/cjs/types/PageContext.js +0 -2
  307. package/dist/cjs/types/VikeGlobalInternal.js +0 -2
  308. package/dist/cjs/types/VikeNamespace.js +0 -2
  309. package/dist/cjs/types/ViteManifest.js +0 -2
  310. package/dist/cjs/types/defineConfig.js +0 -6
  311. package/dist/cjs/types/index-dreprecated.js +0 -3
  312. package/dist/cjs/types/index.js +0 -5
  313. package/dist/cjs/utils/PROJECT_VERSION.js +0 -5
  314. package/dist/cjs/utils/PromiseType.js +0 -2
  315. package/dist/cjs/utils/assert.js +0 -211
  316. package/dist/cjs/utils/assertIsBrowser.js +0 -8
  317. package/dist/cjs/utils/assertIsNotBrowser.js +0 -9
  318. package/dist/cjs/utils/assertKeys.js +0 -27
  319. package/dist/cjs/utils/assertNodeVersion.js +0 -14
  320. package/dist/cjs/utils/assertRoutingType.js +0 -29
  321. package/dist/cjs/utils/assertSetup.js +0 -171
  322. package/dist/cjs/utils/assertSingleInstance.js +0 -110
  323. package/dist/cjs/utils/assertVersion.js +0 -60
  324. package/dist/cjs/utils/capitalizeFirstLetter.js +0 -9
  325. package/dist/cjs/utils/cast.js +0 -6
  326. package/dist/cjs/utils/catchInfiniteLoop.js +0 -34
  327. package/dist/cjs/utils/changeEnumerable.js +0 -8
  328. package/dist/cjs/utils/checkType.js +0 -6
  329. package/dist/cjs/utils/compareString.js +0 -10
  330. package/dist/cjs/utils/createErrorWithCleanStackTrace.js +0 -39
  331. package/dist/cjs/utils/debug.js +0 -178
  332. package/dist/cjs/utils/debugGlob.js +0 -6
  333. package/dist/cjs/utils/deepEqual.js +0 -10
  334. package/dist/cjs/utils/escapeHtml.js +0 -13
  335. package/dist/cjs/utils/escapeRegex.js +0 -7
  336. package/dist/cjs/utils/findFile.js +0 -30
  337. package/dist/cjs/utils/findPackageJson.js +0 -18
  338. package/dist/cjs/utils/formatHintLog.js +0 -17
  339. package/dist/cjs/utils/freezePartial.js +0 -35
  340. package/dist/cjs/utils/genPromise.js +0 -51
  341. package/dist/cjs/utils/getFileExtension.js +0 -16
  342. package/dist/cjs/utils/getGlobalObject.js +0 -15
  343. package/dist/cjs/utils/getMostSimilar.js +0 -68
  344. package/dist/cjs/utils/getPropAccessNotation.js +0 -9
  345. package/dist/cjs/utils/getRandomId.js +0 -14
  346. package/dist/cjs/utils/getTerminalWidth.js +0 -7
  347. package/dist/cjs/utils/getValuePrintable.js +0 -10
  348. package/dist/cjs/utils/getViteRPC.js +0 -79
  349. package/dist/cjs/utils/hasProp.js +0 -50
  350. package/dist/cjs/utils/humanizeTime.js +0 -24
  351. package/dist/cjs/utils/includes.js +0 -13
  352. package/dist/cjs/utils/injectRollupInputs.js +0 -29
  353. package/dist/cjs/utils/isArray.js +0 -7
  354. package/dist/cjs/utils/isArrayOfStrings.js +0 -7
  355. package/dist/cjs/utils/isBrowser.js +0 -8
  356. package/dist/cjs/utils/isCallable.js +0 -6
  357. package/dist/cjs/utils/isDev.js +0 -20
  358. package/dist/cjs/utils/isDocker.js +0 -45
  359. package/dist/cjs/utils/isEqualStringList.js +0 -13
  360. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +0 -66
  361. package/dist/cjs/utils/isHtml.js +0 -9
  362. package/dist/cjs/utils/isImportPath.js +0 -21
  363. package/dist/cjs/utils/isNodeJS.js +0 -16
  364. package/dist/cjs/utils/isNonRunnableDev.js +0 -12
  365. package/dist/cjs/utils/isNullish.js +0 -16
  366. package/dist/cjs/utils/isObject.js +0 -6
  367. package/dist/cjs/utils/isObjectOfStrings.js +0 -7
  368. package/dist/cjs/utils/isObjectWithKeys.js +0 -15
  369. package/dist/cjs/utils/isPlainObject.js +0 -19
  370. package/dist/cjs/utils/isPromise.js +0 -7
  371. package/dist/cjs/utils/isPropertyGetter.js +0 -7
  372. package/dist/cjs/utils/isReact.js +0 -23
  373. package/dist/cjs/utils/isRunnableDevEnvironment.js +0 -9
  374. package/dist/cjs/utils/isSameErrorMessage.js +0 -9
  375. package/dist/cjs/utils/isScriptFile.js +0 -67
  376. package/dist/cjs/utils/isVikeReactApp.js +0 -8
  377. package/dist/cjs/utils/isVitest.js +0 -6
  378. package/dist/cjs/utils/joinEnglish.js +0 -14
  379. package/dist/cjs/utils/normalizeHeaders.js +0 -17
  380. package/dist/cjs/utils/objectAssign.js +0 -14
  381. package/dist/cjs/utils/objectAssignSafe.js +0 -7
  382. package/dist/cjs/utils/objectDefineProperty.js +0 -7
  383. package/dist/cjs/utils/objectEntries.js +0 -8
  384. package/dist/cjs/utils/objectEntriesForEach.js +0 -7
  385. package/dist/cjs/utils/objectFilter.js +0 -10
  386. package/dist/cjs/utils/objectFromEntries.js +0 -7
  387. package/dist/cjs/utils/objectKeys.js +0 -9
  388. package/dist/cjs/utils/objectReplace.js +0 -9
  389. package/dist/cjs/utils/onPageVisibilityChange.js +0 -18
  390. package/dist/cjs/utils/pLimit.js +0 -134
  391. package/dist/cjs/utils/parseNpmPackage.js +0 -106
  392. package/dist/cjs/utils/parseUrl-extras.js +0 -110
  393. package/dist/cjs/utils/parseUrl.js +0 -338
  394. package/dist/cjs/utils/path.js +0 -59
  395. package/dist/cjs/utils/pick.js +0 -12
  396. package/dist/cjs/utils/preservePropertyGetters.js +0 -30
  397. package/dist/cjs/utils/redirectHard.js +0 -6
  398. package/dist/cjs/utils/removeEmptyLines.js +0 -9
  399. package/dist/cjs/utils/removeFileExtension.js +0 -6
  400. package/dist/cjs/utils/requireResolve.js +0 -214
  401. package/dist/cjs/utils/rollupSourceMap.js +0 -19
  402. package/dist/cjs/utils/sleep.js +0 -6
  403. package/dist/cjs/utils/slice.js +0 -35
  404. package/dist/cjs/utils/sorter.js +0 -117
  405. package/dist/cjs/utils/stringifyStringArray.js +0 -6
  406. package/dist/cjs/utils/stripAnsi.js +0 -21
  407. package/dist/cjs/utils/styleFileRE.js +0 -6
  408. package/dist/cjs/utils/throttle.js +0 -15
  409. package/dist/cjs/utils/trackLogs.js +0 -31
  410. package/dist/cjs/utils/trimWithAnsi.js +0 -40
  411. package/dist/cjs/utils/truncateString.js +0 -23
  412. package/dist/cjs/utils/unique.js +0 -6
  413. package/dist/cjs/utils/updateType.js +0 -9
  414. package/dist/cjs/utils/urlToFile.js +0 -36
  415. package/dist/cjs/utils/virtualFileId.js +0 -43
  416. package/dist/cjs/utils/warnIfErrorIsNotObject.js +0 -23
  417. package/dist/esm/node/vite/plugins/pluginBuild.d.ts +0 -3
  418. package/dist/esm/node/vite/plugins/pluginBuild.js +0 -19
  419. package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +0 -14
  420. package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +0 -92
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isImportPathNpmPackage = isImportPathNpmPackage;
4
- exports.isImportPathNpmPackageOrPathAlias = isImportPathNpmPackageOrPathAlias;
5
- exports.assertIsImportPathNpmPackage = assertIsImportPathNpmPackage;
6
- exports.isPathAliasRecommended = isPathAliasRecommended;
7
- exports.getNpmPackageName = getNpmPackageName;
8
- exports.parseNpmPackage = parseNpmPackage;
9
- exports.isDistinguishable = isDistinguishable;
10
- const assert_js_1 = require("./assert.js");
11
- const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
12
- (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
13
- function isImportPathNpmPackage(str, { cannotBePathAlias }) {
14
- (0, assert_js_1.assert)(cannotBePathAlias);
15
- return isImportPathNpmPackageOrPathAlias(str);
16
- }
17
- // We cannot distinguish path aliases that look like npm package imports
18
- function isImportPathNpmPackageOrPathAlias(str) {
19
- const res = parseNpmPackage(str);
20
- return res !== null;
21
- }
22
- function assertIsImportPathNpmPackage(str) {
23
- (0, assert_js_1.assert)(isImportPathNpmPackage(str, {
24
- // If `str` is a path alias that looks like an npm package => assertIsImportPathNpmPackage() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
25
- cannotBePathAlias: true,
26
- }), str);
27
- }
28
- function isNpmPackageName(str) {
29
- const res = parseNpmPackage(str);
30
- return res !== null && res.importPath === null;
31
- }
32
- function getNpmPackageName(str) {
33
- const res = parseNpmPackage(str);
34
- if (!res)
35
- return null;
36
- return res.pkgName;
37
- }
38
- function getNpmPackageImportPath(str) {
39
- const res = parseNpmPackage(str);
40
- if (!res)
41
- return null;
42
- return res.importPath;
43
- }
44
- function isPathAliasRecommended(alias) {
45
- // Cannot be distinguished from npm package names
46
- if (!isDistinguishable(alias))
47
- return false;
48
- // Ensure path alias starts with a special character.
49
- // - In principle, we could allow path aliases that don't start with special character as long as they can be distinguished from npm package names.
50
- // - But we still enforce path aliases to start with a special character because it's a much simpler rule to follow.
51
- if (alias.startsWith('@/'))
52
- return true; // Needed by contra.com and https://github.com/vikejs/vike/issues/1567#issuecomment-3076374243
53
- const firstLetter = alias[0];
54
- (0, assert_js_1.assert)(firstLetter);
55
- if (firstLetter === '@' || /[0-9a-z]/.test(firstLetter.toLowerCase()))
56
- return false;
57
- return true;
58
- }
59
- function isDistinguishable(alias) {
60
- return (parseNpmPackage(alias) === null &&
61
- parseNpmPackage(`${alias}fake-path`) === null &&
62
- parseNpmPackage(`${alias}/fake-path`) === null &&
63
- parseNpmPackage(`${alias}fake/deep/path`) === null &&
64
- parseNpmPackage(`${alias}/fake/deep/path`) === null &&
65
- // See note about '-' in ./isNpmPackageName.spec.ts
66
- // ```ts
67
- // expect(parseNpmPackage('-')).toBe(null) // actually wrong: https://www.npmjs.com/package/-
68
- // ```
69
- !alias.startsWith('-'));
70
- }
71
- // The logic down below is wrong, for example:
72
- // - https://www.npmjs.com/package/-
73
- // The correct logic is complex, see https://github.com/npm/validate-npm-package-name
74
- // We don't need to be accurate: are there npm packages with weird names that are actually being used?
75
- function parseNpmPackage(str) {
76
- if (!str)
77
- return null;
78
- let scope = null;
79
- if (str.startsWith('@')) {
80
- if (!str.includes('/'))
81
- return null;
82
- const [scope_, ...rest] = str.split('/');
83
- scope = scope_;
84
- str = rest.join('/');
85
- if (!str)
86
- return null;
87
- if (scope === '@' || invalid(scope.slice(1)))
88
- return null;
89
- }
90
- const [name, ...importPathParts] = str.split('/');
91
- if (!name || invalid(name))
92
- return null;
93
- const importPath = importPathParts.length === 0 ? null : importPathParts.join('/');
94
- return {
95
- pkgName: scope ? `${scope}/${name}` : name,
96
- importPath,
97
- };
98
- }
99
- function invalid(s) {
100
- const firstLetter = s[0];
101
- if (!firstLetter || !/[a-z0-9]/.test(firstLetter))
102
- return true;
103
- if (/[^a-z0-9_\-\.]/.test(s))
104
- return true;
105
- return false;
106
- }
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prependBase = prependBase;
4
- exports.isBaseAssets = isBaseAssets;
5
- exports.normalizeUrlPathname = normalizeUrlPathname;
6
- exports.removeBaseServer = removeBaseServer;
7
- exports.modifyUrlPathname = modifyUrlPathname;
8
- exports.removeUrlOrigin = removeUrlOrigin;
9
- exports.setUrlOrigin = setUrlOrigin;
10
- exports.getUrlPretty = getUrlPretty;
11
- const parseUrl_js_1 = require("./parseUrl.js");
12
- const assert_js_1 = require("./assert.js");
13
- const slice_js_1 = require("./slice.js");
14
- const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
15
- (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
16
- function prependBase(url, baseServer) {
17
- if (baseServer.startsWith('http')) {
18
- const baseAssets = baseServer;
19
- const baseAssetsNormalized = normalizeBaseAssets(baseAssets);
20
- (0, assert_js_1.assert)(!baseAssetsNormalized.endsWith('/'));
21
- (0, assert_js_1.assert)(url.startsWith('/'));
22
- return `${baseAssetsNormalized}${url}`;
23
- }
24
- (0, assert_js_1.assert)((0, parseUrl_js_1.isBaseServer)(baseServer));
25
- const baseServerNormalized = normalizeBaseServer(baseServer);
26
- if (baseServerNormalized === '/')
27
- return url;
28
- (0, assert_js_1.assert)(!baseServerNormalized.endsWith('/'));
29
- (0, assert_js_1.assert)(url.startsWith('/'));
30
- return `${baseServerNormalized}${url}`;
31
- }
32
- function removeBaseServer(url, baseServer) {
33
- const { isBaseMissing, origin, pathname, pathnameOriginal, searchOriginal, hashOriginal } = (0, parseUrl_js_1.parseUrl)(url, baseServer);
34
- (0, assert_js_1.assert)(!isBaseMissing);
35
- (0, parseUrl_js_1.assertUrlComponents)(url, origin, pathnameOriginal, searchOriginal, hashOriginal);
36
- const urlWithoutBase = (0, parseUrl_js_1.createUrlFromComponents)(origin, pathname, searchOriginal, hashOriginal);
37
- return urlWithoutBase;
38
- }
39
- function normalizeBaseAssets(baseAssets) {
40
- let baseAssetsNormalized = baseAssets;
41
- if (baseAssetsNormalized.endsWith('/')) {
42
- baseAssetsNormalized = (0, slice_js_1.slice)(baseAssetsNormalized, 0, -1);
43
- }
44
- (0, assert_js_1.assert)(!baseAssetsNormalized.endsWith('/'));
45
- return baseAssetsNormalized;
46
- }
47
- function normalizeBaseServer(baseServer) {
48
- let baseServerNormalized = baseServer;
49
- if (baseServerNormalized.endsWith('/') && baseServerNormalized !== '/') {
50
- baseServerNormalized = (0, slice_js_1.slice)(baseServerNormalized, 0, -1);
51
- }
52
- // We can and should expect `baseServer` to not contain `/` doublets.
53
- (0, assert_js_1.assert)(!baseServerNormalized.endsWith('/') || baseServerNormalized === '/');
54
- return baseServerNormalized;
55
- }
56
- function isBaseAssets(base) {
57
- return base.startsWith('/') || base.startsWith('http://') || base.startsWith('https://');
58
- }
59
- function normalizeUrlPathname(urlOriginal, trailingSlash, baseServer) {
60
- const urlNormalized = modifyUrlPathname(urlOriginal, (urlPathname) => {
61
- (0, assert_js_1.assert)(urlPathname.startsWith('/'));
62
- let urlPathnameNormalized = normalize(urlPathname);
63
- if (urlPathnameNormalized === '/') {
64
- return urlPathnameNormalized;
65
- }
66
- // If the Base URL has a trailing slash, then Vite (as of vite@5.0.0-beta.19) expects the root URL to also have a trailing slash, see https://github.com/vikejs/vike/issues/1258#issuecomment-1812226260
67
- if (baseServer.endsWith('/') && baseServer !== '/' && normalize(baseServer) === urlPathnameNormalized) {
68
- trailingSlash = true;
69
- }
70
- (0, assert_js_1.assert)(!urlPathnameNormalized.endsWith('/'));
71
- if (trailingSlash) {
72
- urlPathnameNormalized = urlPathnameNormalized + '/';
73
- }
74
- return urlPathnameNormalized;
75
- });
76
- if (urlNormalized === urlOriginal)
77
- return null;
78
- return urlNormalized;
79
- }
80
- function normalize(urlPathname) {
81
- (0, assert_js_1.assert)(urlPathname.startsWith('/'));
82
- return '/' + urlPathname.split('/').filter(Boolean).join('/');
83
- }
84
- function modifyUrlPathname(url, modifier) {
85
- const { origin, pathnameOriginal, searchOriginal, hashOriginal } = (0, parseUrl_js_1.parseUrl)(url, '/');
86
- const pathnameModified = modifier(pathnameOriginal);
87
- if (pathnameModified === null)
88
- return url;
89
- (0, parseUrl_js_1.assertUrlComponents)(url, origin, pathnameOriginal, searchOriginal, hashOriginal);
90
- const urlModified = (0, parseUrl_js_1.createUrlFromComponents)(origin, pathnameModified, searchOriginal, hashOriginal);
91
- (0, assert_js_1.assert)((pathnameOriginal === pathnameModified) === (url === urlModified));
92
- return urlModified;
93
- }
94
- function removeUrlOrigin(url) {
95
- const { origin, pathnameOriginal, searchOriginal, hashOriginal } = (0, parseUrl_js_1.parseUrl)(url, '/');
96
- const urlModified = (0, parseUrl_js_1.createUrlFromComponents)(null, pathnameOriginal, searchOriginal, hashOriginal);
97
- return { urlModified, origin };
98
- }
99
- function setUrlOrigin(url, origin) {
100
- const { origin: originCurrent, pathnameOriginal, searchOriginal, hashOriginal } = (0, parseUrl_js_1.parseUrl)(url, '/');
101
- if (origin === originCurrent)
102
- return false;
103
- (0, assert_js_1.assert)(origin === null || origin.startsWith('http'));
104
- const urlModified = (0, parseUrl_js_1.createUrlFromComponents)(origin, pathnameOriginal, searchOriginal, hashOriginal);
105
- return urlModified;
106
- }
107
- function getUrlPretty(url) {
108
- const { urlModified } = removeUrlOrigin(url);
109
- return urlModified;
110
- }
@@ -1,338 +0,0 @@
1
- "use strict";
2
- // We don't use new URL() as it doesn't exactly do what we need, for example:
3
- // - It loses the original URL parts (which we need to manipulate and recreate URLs)
4
- // - It doesn't support the tauri:// protocol
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.parseUrl = parseUrl;
10
- exports.assertUsageUrlPathnameAbsolute = assertUsageUrlPathnameAbsolute;
11
- exports.assertUsageUrlRedirectTarget = assertUsageUrlRedirectTarget;
12
- exports.isUrl = isUrl;
13
- exports.isUri = isUri;
14
- exports.isUrlRedirectTarget = isUrlRedirectTarget;
15
- exports.isUrlRelative = isUrlRelative;
16
- exports.isUrlExternal = isUrlExternal;
17
- exports.isBaseServer = isBaseServer;
18
- exports.assertUrlComponents = assertUrlComponents;
19
- exports.createUrlFromComponents = createUrlFromComponents;
20
- const slice_js_1 = require("./slice.js");
21
- const assert_js_1 = require("./assert.js");
22
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
23
- function parseUrl(url, baseServer) {
24
- (0, assert_js_1.assert)(isUrl(url), url);
25
- (0, assert_js_1.assert)(baseServer.startsWith('/'));
26
- // Hash
27
- const { hashString: hashOriginal, withoutHash: urlWithoutHash } = extractHash(url);
28
- (0, assert_js_1.assert)(hashOriginal === null || hashOriginal.startsWith('#'));
29
- const hash = hashOriginal === null ? '' : decodeSafe(hashOriginal.slice(1));
30
- // Search
31
- const { searchString: searchOriginal, withoutSearch: urlWithoutHashNorSearch } = extractSearch(urlWithoutHash);
32
- (0, assert_js_1.assert)(searchOriginal === null || searchOriginal.startsWith('?'));
33
- let searchString = '';
34
- if (searchOriginal !== null) {
35
- searchString = searchOriginal;
36
- }
37
- else if (url.startsWith('#')) {
38
- const baseURI = getBaseURI();
39
- searchString = (baseURI && extractSearch(baseURI).searchString) || '';
40
- }
41
- const search = {};
42
- const searchAll = {};
43
- Array.from(new URLSearchParams(searchString)).forEach(([key, val]) => {
44
- search[key] = val;
45
- searchAll[key] = [...(searchAll.hasOwnProperty(key) ? searchAll[key] : []), val];
46
- });
47
- // Origin + pathname
48
- let { protocol, origin, pathnameAbsoluteWithBase } = getPathnameAbsoluteWithBase(urlWithoutHashNorSearch, baseServer);
49
- const pathnameOriginal = urlWithoutHashNorSearch.slice((origin || '').length);
50
- assertUrlComponents(url, origin, pathnameOriginal, searchOriginal, hashOriginal);
51
- // Base URL
52
- let { pathname, isBaseMissing } = removeBaseServer(pathnameAbsoluteWithBase, baseServer);
53
- // pageContext.urlParsed.href
54
- const href = createUrlFromComponents(origin, pathname, searchOriginal, hashOriginal);
55
- // pageContext.urlParsed.{hostname, port}
56
- const host = !origin ? null : origin.slice(protocol.length);
57
- const { hostname, port } = parseHost(host, url);
58
- // decode after setting href
59
- pathname = decodePathname(pathname);
60
- (0, assert_js_1.assert)(pathname.startsWith('/'));
61
- return {
62
- href,
63
- protocol,
64
- hostname,
65
- port,
66
- origin,
67
- pathname,
68
- pathnameOriginal: pathnameOriginal,
69
- isBaseMissing,
70
- search,
71
- searchAll,
72
- searchOriginal,
73
- hash,
74
- hashOriginal,
75
- };
76
- }
77
- function extractHash(url) {
78
- const [withoutHash, ...parts] = url.split('#');
79
- const hashString = ['', ...parts].join('#') || null;
80
- return { hashString, withoutHash: withoutHash };
81
- }
82
- function extractSearch(url) {
83
- const [withoutSearch, ...parts] = url.split('?');
84
- const searchString = ['', ...parts].join('?') || null;
85
- return { searchString, withoutSearch: withoutSearch };
86
- }
87
- function decodeSafe(urlComponent) {
88
- try {
89
- return decodeURIComponent(urlComponent);
90
- }
91
- catch { }
92
- try {
93
- return decodeURI(urlComponent);
94
- }
95
- catch { }
96
- return urlComponent;
97
- }
98
- function decodePathname(urlPathname) {
99
- urlPathname = urlPathname.replace(/\s+$/, '');
100
- urlPathname = urlPathname
101
- .split('/')
102
- .map((dir) => decodeSafe(dir).split('/').join('%2F'))
103
- .join('/');
104
- return urlPathname;
105
- }
106
- function getPathnameAbsoluteWithBase(url, baseServer) {
107
- // Search and hash already extracted
108
- (0, assert_js_1.assert)(!url.includes('?') && !url.includes('#'));
109
- // url has origin
110
- {
111
- const { protocol, origin, pathname } = parseOrigin(url);
112
- if (origin) {
113
- return { protocol, origin, pathnameAbsoluteWithBase: pathname };
114
- }
115
- (0, assert_js_1.assert)(pathname === url);
116
- }
117
- // url doesn't have origin
118
- if (url.startsWith('/')) {
119
- return { protocol: null, origin: null, pathnameAbsoluteWithBase: url };
120
- }
121
- else {
122
- // url is a relative path
123
- const baseURI = getBaseURI();
124
- let base;
125
- if (baseURI) {
126
- base = parseOrigin(baseURI.split('?')[0].split('#')[0]).pathname;
127
- }
128
- else {
129
- base = baseServer;
130
- }
131
- const pathnameAbsoluteWithBase = resolveUrlPathnameRelative(url, base);
132
- return { protocol: null, origin: null, pathnameAbsoluteWithBase };
133
- }
134
- }
135
- function getBaseURI() {
136
- // In the browser, this is the Base URL of the current URL.
137
- // Safe access `window?.document?.baseURI` for users who shim `window` in Node.js
138
- const baseURI = typeof window !== 'undefined' ? window?.document?.baseURI : undefined;
139
- return baseURI;
140
- }
141
- function parseOrigin(url) {
142
- if (!isUrlWithProtocol(url)) {
143
- return { pathname: url, origin: null, protocol: null };
144
- }
145
- else {
146
- const { protocol, uriWithoutProtocol } = parseProtocol(url);
147
- (0, assert_js_1.assert)(protocol);
148
- const [host, ...rest] = uriWithoutProtocol.split('/');
149
- const origin = protocol + host;
150
- const pathname = '/' + rest.join('/');
151
- return { pathname, origin, protocol };
152
- }
153
- }
154
- function parseHost(host, url) {
155
- const ret = { hostname: null, port: null };
156
- if (!host)
157
- return ret;
158
- // port
159
- const parts = host.split(':');
160
- if (parts.length > 1) {
161
- const port = parseInt(parts.pop(), 10);
162
- (0, assert_js_1.assert)(port || port === 0, url);
163
- ret.port = port;
164
- }
165
- // hostname
166
- ret.hostname = parts.join(':');
167
- return ret;
168
- }
169
- function parseProtocol(uri) {
170
- const SEP = ':';
171
- const [before, ...after] = uri.split(SEP);
172
- if (after.length === 0 ||
173
- // https://github.com/vikejs/vike/commit/886a99ff21e86a8ca699a25cee7edc184aa058e4#r143308934
174
- // https://en.wikipedia.org/wiki/List_of_URI_schemes
175
- // https://www.rfc-editor.org/rfc/rfc7595
176
- !/^[a-z][a-z0-9\+\-]*$/i.test(before)) {
177
- return { protocol: null, uriWithoutProtocol: uri };
178
- }
179
- let protocol = before + SEP;
180
- let uriWithoutProtocol = after.join(SEP);
181
- const SEP2 = '//';
182
- if (uriWithoutProtocol.startsWith(SEP2)) {
183
- protocol = protocol + SEP2;
184
- uriWithoutProtocol = uriWithoutProtocol.slice(SEP2.length);
185
- }
186
- return { protocol, uriWithoutProtocol };
187
- }
188
- function isUrlProtocol(protocol) {
189
- // Is there an alternative to having a blocklist?
190
- // - If the blocklist becomes too big, maybe use a allowlist instead ['tauri://', 'file://', 'capacitor://', 'http://', 'https://']
191
- const blocklist = [
192
- // https://docs.ipfs.tech/how-to/address-ipfs-on-web
193
- 'ipfs://',
194
- 'ipns://',
195
- ];
196
- if (blocklist.includes(protocol))
197
- return false;
198
- return protocol.endsWith('://');
199
- }
200
- // Adapted from https://stackoverflow.com/questions/14780350/convert-relative-path-to-absolute-using-javascript/14780463#14780463
201
- function resolveUrlPathnameRelative(pathnameRelative, base) {
202
- const stack = base.split('/');
203
- const parts = pathnameRelative.split('/');
204
- let baseRestoreTrailingSlash = base.endsWith('/');
205
- if (pathnameRelative.startsWith('.')) {
206
- // remove current file name
207
- stack.pop();
208
- }
209
- for (const i in parts) {
210
- const p = parts[i];
211
- if (p == '' && i === '0')
212
- continue;
213
- if (p == '.')
214
- continue;
215
- if (p == '..')
216
- stack.pop();
217
- else {
218
- baseRestoreTrailingSlash = false;
219
- stack.push(p);
220
- }
221
- }
222
- let pathnameAbsolute = stack.join('/');
223
- if (baseRestoreTrailingSlash && !pathnameAbsolute.endsWith('/'))
224
- pathnameAbsolute += '/';
225
- if (!pathnameAbsolute.startsWith('/'))
226
- pathnameAbsolute = '/' + pathnameAbsolute;
227
- return pathnameAbsolute;
228
- }
229
- function removeBaseServer(pathnameAbsoluteWithBase, baseServer) {
230
- (0, assert_js_1.assert)(pathnameAbsoluteWithBase.startsWith('/'));
231
- (0, assert_js_1.assert)(isBaseServer(baseServer));
232
- // Mutable
233
- let urlPathname = pathnameAbsoluteWithBase;
234
- (0, assert_js_1.assert)(urlPathname.startsWith('/'));
235
- (0, assert_js_1.assert)(baseServer.startsWith('/'));
236
- if (baseServer === '/') {
237
- const pathname = pathnameAbsoluteWithBase;
238
- return { pathname, isBaseMissing: false };
239
- }
240
- // Support `url === '/some-base-url' && baseServer === '/some-base-url/'`
241
- let baseServerNormalized = baseServer;
242
- if (baseServer.endsWith('/') && urlPathname === (0, slice_js_1.slice)(baseServer, 0, -1)) {
243
- baseServerNormalized = (0, slice_js_1.slice)(baseServer, 0, -1);
244
- (0, assert_js_1.assert)(urlPathname === baseServerNormalized);
245
- }
246
- if (!urlPathname.startsWith(baseServerNormalized)) {
247
- const pathname = pathnameAbsoluteWithBase;
248
- return { pathname, isBaseMissing: true };
249
- }
250
- (0, assert_js_1.assert)(urlPathname.startsWith('/') || urlPathname.startsWith('http'));
251
- (0, assert_js_1.assert)(urlPathname.startsWith(baseServerNormalized));
252
- urlPathname = urlPathname.slice(baseServerNormalized.length);
253
- if (!urlPathname.startsWith('/'))
254
- urlPathname = '/' + urlPathname;
255
- (0, assert_js_1.assert)(urlPathname.startsWith('/'));
256
- return { pathname: urlPathname, isBaseMissing: false };
257
- }
258
- function isBaseServer(baseServer) {
259
- return baseServer.startsWith('/');
260
- }
261
- function assertUrlComponents(url, origin, pathnameOriginal, searchOriginal, hashOriginal) {
262
- const urlRecreated = createUrlFromComponents(origin, pathnameOriginal, searchOriginal, hashOriginal);
263
- (0, assert_js_1.assert)(url === urlRecreated);
264
- }
265
- function createUrlFromComponents(origin, pathname, search, hash) {
266
- const urlRecreated = `${origin || ''}${pathname}${search || ''}${hash || ''}`;
267
- return urlRecreated;
268
- }
269
- function isUrl(url) {
270
- // parseUrl() works with these URLs
271
- return isUrlWithProtocol(url) || url.startsWith('/') || isUrlRelative(url);
272
- }
273
- function isUrlRedirectTarget(url) {
274
- return url.startsWith('/') || isUri(url) || isUrlWithProtocol(url);
275
- }
276
- function isUrlRelative(url) {
277
- return ['.', '?', '#'].some((c) => url.startsWith(c)) || url === '';
278
- }
279
- function isUrlExternal(url) {
280
- return !url.startsWith('/') && !isUrlRelative(url);
281
- }
282
- /*
283
- URL with protocol.
284
-
285
- http://example.com
286
- https://example.com
287
- tauri://localhost
288
- file://example.com
289
- capacitor://localhost/assets/chunks/chunk-DJBYDrsP.js
290
-
291
- [Tauri](https://github.com/vikejs/vike/issues/808)
292
- [Electron (`file://`)](https://github.com/vikejs/vike/issues/1557)
293
- [Capacitor](https://github.com/vikejs/vike/issues/1706)
294
- */
295
- function isUrlWithProtocol(url) {
296
- const { protocol } = parseProtocol(url);
297
- return !!protocol && isUrlProtocol(protocol);
298
- }
299
- /*
300
- URIs that aren't URLs.
301
-
302
- mailto:john@example.com
303
-
304
- ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html
305
-
306
- magnet:?xt=urn:btih:3a15e1ac49683d91b20c2ffc252ea612a6c01bd7&dn=The.Empire.Strikes.Back.1980.Remastered.1080p.BluRay.DDP.7.1.x265-EDGE2020.mkv&xl=3225443573&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://tracker.torrent.eu.org:451&tr=udp://open.stealth.si:80/announce&tr=udp://tracker.openbittorrent.com:6969&tr=udp://tracker.tiny-vps.com:6969/announce&tr=udp://open.demonii.com:1337
307
-
308
- We need to treat URIs differently than URLs.
309
- - For example, we cannot parse URIs (their structure is unknown e.g. a `magnet:` URI is completely different than a `http://` URL).
310
- - The protocols tauri:// file:// capacitor:// follow the same structure as http:// and https:// URLs.
311
- - Thus we can parse them like http:// and https:// URLs.
312
- */
313
- function isUri(uri) {
314
- const { protocol } = parseProtocol(uri);
315
- return !!protocol && !isUrlProtocol(uri);
316
- }
317
- function assertUsageUrlPathnameAbsolute(url, errPrefix) {
318
- assertUsageUrl(url, errPrefix);
319
- }
320
- function assertUsageUrlRedirectTarget(url, errPrefix, isUnresolved) {
321
- assertUsageUrl(url, errPrefix, { isRedirectTarget: isUnresolved ? 'unresolved' : true });
322
- }
323
- function assertUsageUrl(url, errPrefix, { isRedirectTarget } = {}) {
324
- if (url.startsWith('/'))
325
- return;
326
- let errMsg = `${errPrefix} is ${picocolors_1.default.string(url)} but it should start with ${picocolors_1.default.string('/')}`;
327
- if (isRedirectTarget) {
328
- if (isUrlRedirectTarget(url))
329
- return;
330
- errMsg += ` or a protocol (${picocolors_1.default.string('http://')}, ${picocolors_1.default.string('mailto:')}, ...)`;
331
- if (isRedirectTarget === 'unresolved') {
332
- if (url === '*')
333
- return;
334
- errMsg += `, or be ${picocolors_1.default.string('*')}`;
335
- }
336
- }
337
- (0, assert_js_1.assertUsage)(false, errMsg);
338
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pathJoin = pathJoin;
4
- exports.pathIsRelative = pathIsRelative;
5
- exports.pathIsAbsolute = pathIsAbsolute;
6
- exports.toPosixPath = toPosixPath;
7
- exports.assertPosixPath = assertPosixPath;
8
- // Utilities for handling file paths.
9
- // - Shims `import * from "node:path"` for server runtime.
10
- // - Robust shim reference: https://github.com/unjs/pathe
11
- const assert_js_1 = require("./assert.js");
12
- const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
13
- // While this path shim also works on the client-side, let's try to not use it on the client-side in order to minimize KBs sent to the browser.
14
- (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
15
- /**********************/
16
- /****** SHIMS *********/
17
- /**********************/
18
- function pathJoin(path1, path2) {
19
- (0, assert_js_1.assert)(!path1.includes('\\'));
20
- (0, assert_js_1.assert)(!path2.includes('\\'));
21
- let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/');
22
- if (path1.startsWith('/'))
23
- joined = '/' + joined;
24
- return joined;
25
- }
26
- // https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
27
- const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
28
- function pathIsAbsolute(filePath) {
29
- return IS_ABSOLUTE_RE.test(filePath);
30
- }
31
- /**********************/
32
- /****** UTILS *********/
33
- /**********************/
34
- function toPosixPath(path) {
35
- const pathPosix = path.split('\\').join('/');
36
- assertPosixPath(pathPosix);
37
- return pathPosix;
38
- }
39
- function assertPosixPath(path) {
40
- const errMsg = (msg) => `Not a posix path: ${msg}`;
41
- (0, assert_js_1.assert)(path !== null, errMsg('null'));
42
- (0, assert_js_1.assert)(typeof path === 'string', errMsg(`typeof path === ${JSON.stringify(typeof path)}`));
43
- (0, assert_js_1.assert)(path !== '', errMsg('(empty string)'));
44
- (0, assert_js_1.assert)(path);
45
- (0, assert_js_1.assert)(!path.includes('\\'), errMsg(path));
46
- }
47
- // See also `import { isImportPathRelative } from './isImportPath.js'`
48
- function pathIsRelative(path) {
49
- assertPosixPath(path);
50
- if (path.startsWith('./') || path.startsWith('../')) {
51
- return true;
52
- }
53
- else {
54
- /* Not true if `path` starts with a hidden directory (i.e. a directory with a name that starts with `.`)
55
- assert(!path.startsWith('.'))
56
- */
57
- return false;
58
- }
59
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pick = pick;
4
- function pick(obj, keys) {
5
- const result = {};
6
- for (const key of keys) {
7
- if (key in obj) {
8
- result[key] = obj[key];
9
- }
10
- }
11
- return result;
12
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preservePropertyGetters = preservePropertyGetters;
4
- const assert_js_1 = require("./assert.js");
5
- function preservePropertyGetters(objOriginal) {
6
- // Store original getter descriptors
7
- const getters = Object.fromEntries(Object.entries(Object.getOwnPropertyDescriptors(objOriginal)).filter(([_, desc]) => 'get' in desc));
8
- // Make getters non-enumerable
9
- for (const [key, desc] of Object.entries(getters)) {
10
- Object.defineProperty(objOriginal, key, { ...desc, enumerable: false });
11
- }
12
- const restorePropertyGetters = function () {
13
- const objCopy = this;
14
- delete objOriginal._restorePropertyGetters;
15
- delete objCopy._restorePropertyGetters;
16
- for (const [key, desc] of Object.entries(getters)) {
17
- if (objCopy !== objOriginal) {
18
- (0, assert_js_1.assert)(!(key in objCopy));
19
- Object.defineProperty(objCopy, key, desc); // Add property getters to copy
20
- }
21
- (0, assert_js_1.assert)(key in objOriginal);
22
- Object.defineProperty(objOriginal, key, desc); // Restore original `enumerable` value
23
- }
24
- };
25
- Object.defineProperty(objOriginal, '_restorePropertyGetters', {
26
- value: restorePropertyGetters,
27
- enumerable: true,
28
- configurable: true,
29
- });
30
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.redirectHard = redirectHard;
4
- function redirectHard(url) {
5
- window.location.href = url;
6
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeEmptyLines = removeEmptyLines;
4
- function removeEmptyLines(msg) {
5
- return msg
6
- .split('\n')
7
- .filter((line) => line.trim() !== '')
8
- .join('\n');
9
- }