vike 0.4.222 → 0.4.223

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 (131) hide show
  1. package/dist/cjs/client/shared/getPageContextProxyForUser.js +1 -1
  2. package/dist/cjs/node/api/prepareViteApiCall.js +1 -1
  3. package/dist/cjs/node/plugin/index.js +1 -1
  4. package/dist/cjs/node/plugin/plugins/baseUrls.js +6 -1
  5. package/dist/cjs/node/plugin/plugins/buildApp.js +9 -5
  6. package/dist/cjs/node/plugin/plugins/buildConfig.js +3 -0
  7. package/dist/cjs/node/plugin/plugins/envVars.js +2 -18
  8. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +2 -2
  9. package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +1 -1
  10. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +16 -41
  12. package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +1 -1
  13. package/dist/cjs/node/plugin/shared/viteIsSSR.js +19 -10
  14. package/dist/cjs/node/runtime/globalContext.js +19 -8
  15. package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +1 -1
  16. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +24 -0
  17. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
  18. package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +1 -1
  19. package/dist/cjs/node/runtime/renderPage/isNewError.js +1 -1
  20. package/dist/cjs/node/runtime/renderPage/isVikeConfigInvalid.js +10 -0
  21. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  22. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
  23. package/dist/cjs/node/runtime/renderPage.js +63 -49
  24. package/dist/cjs/node/runtime/universal-middleware.js +14 -0
  25. package/dist/cjs/node/shared/resolveBase.js +0 -13
  26. package/dist/cjs/shared/getPageConfigsRuntime.js +2 -8
  27. package/dist/cjs/shared/getPageContextRequestUrl.js +1 -1
  28. package/dist/cjs/shared/getPageContextUrlComputed.js +12 -9
  29. package/dist/cjs/shared/hooks/getHook.js +1 -1
  30. package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +44 -12
  31. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -8
  32. package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
  33. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  34. package/dist/cjs/utils/assert.js +1 -1
  35. package/dist/cjs/utils/assertSetup.js +1 -1
  36. package/dist/cjs/utils/assertSingleInstance.js +2 -2
  37. package/dist/cjs/utils/getGlobalObject.js +2 -6
  38. package/dist/cjs/utils/parseUrl-extras.js +2 -2
  39. package/dist/cjs/utils/parseUrl.js +5 -5
  40. package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
  41. package/dist/esm/client/client-routing-runtime/getPageContextCurrent.js +1 -1
  42. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
  43. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
  44. package/dist/esm/client/client-routing-runtime/history.js +1 -1
  45. package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
  46. package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
  47. package/dist/esm/client/client-routing-runtime/prefetch.js +3 -3
  48. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +2 -2
  49. package/dist/esm/client/client-routing-runtime/scrollRestoration.js +1 -1
  50. package/dist/esm/client/client-routing-runtime/skipLink.js +2 -2
  51. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
  52. package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
  53. package/dist/esm/client/shared/getPageContextProxyForUser.js +1 -1
  54. package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
  55. package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
  56. package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
  57. package/dist/esm/node/api/prepareViteApiCall.js +1 -1
  58. package/dist/esm/node/plugin/index.d.ts +4 -1
  59. package/dist/esm/node/plugin/index.js +1 -1
  60. package/dist/esm/node/plugin/plugins/baseUrls.js +6 -1
  61. package/dist/esm/node/plugin/plugins/buildApp.js +9 -5
  62. package/dist/esm/node/plugin/plugins/buildConfig.js +3 -0
  63. package/dist/esm/node/plugin/plugins/envVars.js +2 -18
  64. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +3 -3
  65. package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +1 -1
  66. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -1
  67. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -2
  68. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +17 -42
  69. package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +2 -2
  70. package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +7 -4
  71. package/dist/esm/node/plugin/shared/viteIsSSR.js +20 -11
  72. package/dist/esm/node/runtime/globalContext.d.ts +9 -8
  73. package/dist/esm/node/runtime/globalContext.js +19 -8
  74. package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
  75. package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
  76. package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
  77. package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +1 -1
  78. package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +2 -0
  79. package/dist/esm/node/runtime/renderPage/createHttpResponse.js +24 -0
  80. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
  81. package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
  82. package/dist/esm/node/runtime/renderPage/getPageAssets.js +1 -1
  83. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
  84. package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.js +1 -1
  85. package/dist/esm/node/runtime/renderPage/isNewError.js +1 -1
  86. package/dist/esm/node/runtime/renderPage/isVikeConfigInvalid.d.ts +6 -0
  87. package/dist/esm/node/runtime/renderPage/isVikeConfigInvalid.js +8 -0
  88. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +3 -3
  89. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
  90. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  91. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +4 -4
  92. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +12 -12
  93. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
  94. package/dist/esm/node/runtime/renderPage.d.ts +5 -5
  95. package/dist/esm/node/runtime/renderPage.js +64 -49
  96. package/dist/esm/node/runtime/universal-middleware.d.ts +1 -0
  97. package/dist/esm/node/runtime/universal-middleware.js +11 -0
  98. package/dist/esm/node/shared/resolveBase.d.ts +1 -9
  99. package/dist/esm/node/shared/resolveBase.js +0 -13
  100. package/dist/esm/shared/getPageConfigsRuntime.d.ts +2 -2
  101. package/dist/esm/shared/getPageConfigsRuntime.js +3 -9
  102. package/dist/esm/shared/getPageContextRequestUrl.js +1 -1
  103. package/dist/esm/shared/getPageContextUrlComputed.js +12 -9
  104. package/dist/esm/shared/getPageFiles.d.ts +1 -1
  105. package/dist/esm/shared/hooks/getHook.d.ts +3 -3
  106. package/dist/esm/shared/hooks/getHook.js +1 -1
  107. package/dist/esm/shared/page-configs/Config.d.ts +3 -1
  108. package/dist/esm/shared/page-configs/PageConfig.d.ts +9 -2
  109. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +24 -16
  110. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +44 -12
  111. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +3 -2
  112. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -8
  113. package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
  114. package/dist/esm/shared/route/loadPageRoutes.js +1 -1
  115. package/dist/esm/shared/types.d.ts +6 -0
  116. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  117. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  118. package/dist/esm/utils/assert.js +1 -1
  119. package/dist/esm/utils/assertSetup.js +1 -1
  120. package/dist/esm/utils/assertSingleInstance.js +2 -2
  121. package/dist/esm/utils/getGlobalObject.d.ts +3 -2
  122. package/dist/esm/utils/getGlobalObject.js +2 -6
  123. package/dist/esm/utils/parseUrl-extras.js +2 -2
  124. package/dist/esm/utils/parseUrl.d.ts +3 -4
  125. package/dist/esm/utils/parseUrl.js +5 -5
  126. package/dist/esm/utils/projectInfo.d.ts +1 -1
  127. package/package.json +15 -2
  128. package/universal-middleware.js +3 -0
  129. package/dist/cjs/node/runtime/renderPage/isConfigInvalid.js +0 -10
  130. package/dist/esm/node/runtime/renderPage/isConfigInvalid.d.ts +0 -6
  131. package/dist/esm/node/runtime/renderPage/isConfigInvalid.js +0 -8
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.renderPage_addWrapper = void 0;
7
6
  exports.renderPage = renderPage;
7
+ exports.renderPage_addAsyncHookwrapper = renderPage_addAsyncHookwrapper;
8
8
  const renderPageAlreadyRouted_js_1 = require("./renderPage/renderPageAlreadyRouted.js");
9
9
  const index_js_1 = require("../../shared/route/index.js");
10
10
  const utils_js_1 = require("./utils.js");
@@ -16,54 +16,48 @@ const loggerRuntime_js_1 = require("./renderPage/loggerRuntime.js");
16
16
  const isNewError_js_1 = require("./renderPage/isNewError.js");
17
17
  const assertArguments_js_1 = require("./renderPage/assertArguments.js");
18
18
  const index_js_2 = require("./renderPage/log404/index.js");
19
- const isConfigInvalid_js_1 = require("./renderPage/isConfigInvalid.js");
19
+ const isVikeConfigInvalid_js_1 = require("./renderPage/isVikeConfigInvalid.js");
20
20
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
21
21
  const serializePageContextClientSide_js_1 = require("./html/serializePageContextClientSide.js");
22
22
  const error_page_js_1 = require("../../shared/error-page.js");
23
23
  const handleErrorWithoutErrorPage_js_1 = require("./renderPage/handleErrorWithoutErrorPage.js");
24
24
  const loadUserFilesServerSide_js_1 = require("./renderPage/loadUserFilesServerSide.js");
25
25
  const resolveRedirects_js_1 = require("./renderPage/resolveRedirects.js");
26
- const resolveBase_js_1 = require("../shared/resolveBase.js");
27
26
  const globalObject = (0, utils_js_1.getGlobalObject)('runtime/renderPage.ts', {
28
27
  httpRequestsCount: 0
29
28
  });
30
- let renderPage_wrapper = async (_httpRequestId, ret) => ({
31
- pageContextReturn: await ret()
32
- });
33
- const renderPage_addWrapper = (wrapper) => {
34
- renderPage_wrapper = wrapper;
35
- };
36
- exports.renderPage_addWrapper = renderPage_addWrapper;
37
29
  // `renderPage()` calls `renderPageNominal()` while ensuring that errors are `console.error(err)` instead of `throw err`, so that Vike never triggers a server shut down. (Throwing an error in an Express.js middleware shuts down the whole Express.js server.)
38
30
  async function renderPage(pageContextInit) {
39
31
  (0, assertArguments_js_1.assertArguments)(...arguments);
40
32
  (0, utils_js_1.assert)((0, utils_js_1.hasProp)(pageContextInit, 'urlOriginal', 'string')); // assertUsage() already implemented at assertArguments()
41
- (0, utils_js_1.onSetupRuntime)();
42
33
  assertIsUrl(pageContextInit.urlOriginal);
43
- const urlPathnameWithBase = (0, utils_js_1.parseUrl)(pageContextInit.urlOriginal, '/').pathname;
44
- assertIsNotViteRequest(urlPathnameWithBase, pageContextInit.urlOriginal);
45
- if (urlPathnameWithBase.endsWith('/favicon.ico'))
46
- return getPageContextHttpResponseFavicon404(pageContextInit);
34
+ (0, utils_js_1.onSetupRuntime)();
35
+ const pageContextInvalidRequest = renderInvalidRequest(pageContextInit);
36
+ if (pageContextInvalidRequest)
37
+ return pageContextInvalidRequest;
47
38
  const httpRequestId = getRequestId();
48
39
  const urlOriginalPretty = (0, utils_js_1.getUrlPretty)(pageContextInit.urlOriginal);
49
40
  logHttpRequest(urlOriginalPretty, httpRequestId);
50
- const { pageContextReturn } = await renderPage_wrapper(httpRequestId, () => renderPageAndPrepare(pageContextInit, httpRequestId));
41
+ const { pageContextReturn } = await asyncHookWrapper(httpRequestId, () => renderPageAndPrepare(pageContextInit, httpRequestId));
51
42
  logHttpResponse(urlOriginalPretty, httpRequestId, pageContextReturn);
52
43
  (0, utils_js_1.checkType)(pageContextReturn);
53
44
  (0, utils_js_1.assert)(pageContextReturn.httpResponse);
54
45
  return pageContextReturn;
55
46
  }
47
+ // Fallback wrapper if node:async_hooks isn't available
48
+ let asyncHookWrapper = async (_httpRequestId, ret) => ({
49
+ pageContextReturn: await ret()
50
+ });
51
+ // Add node:async_hooks wrapper
52
+ function renderPage_addAsyncHookwrapper(wrapper) {
53
+ asyncHookWrapper = wrapper;
54
+ }
56
55
  async function renderPageAndPrepare(pageContextInit, httpRequestId) {
57
56
  // Invalid config
58
- const handleInvalidConfig = (err) => {
59
- (0, loggerRuntime_js_1.logRuntimeInfo)?.(picocolors_1.default.bold(picocolors_1.default.red('Error while loading a Vike config file, see error above.')), httpRequestId, 'error');
60
- const pageContextWithError = getPageContextHttpResponseError(err, pageContextInit, null);
61
- return pageContextWithError;
62
- };
63
- if (isConfigInvalid_js_1.isConfigInvalid) {
57
+ if (isVikeConfigInvalid_js_1.isVikeConfigInvalid) {
64
58
  if (1 < 2 // Make TS happy
65
59
  ) {
66
- return handleInvalidConfig(isConfigInvalid_js_1.isConfigInvalid.err);
60
+ return renderInvalidVikeConfig(isVikeConfigInvalid_js_1.isVikeConfigInvalid.err, pageContextInit, httpRequestId);
67
61
  }
68
62
  }
69
63
  // Prepare context
@@ -71,22 +65,29 @@ async function renderPageAndPrepare(pageContextInit, httpRequestId) {
71
65
  await (0, globalContext_js_1.initGlobalContext_renderPage)();
72
66
  }
73
67
  catch (err) {
74
- // Errors are expected since assertUsage() is used in both initGlobalContext_renderPage() and getRenderContext().
75
- // initGlobalContext_renderPage() and getRenderContext() don't call any user hooks => err isn't thrown from user code.
68
+ // Errors are expected since assertUsage() is used in initGlobalContext_renderPage() such as:
69
+ // ```bash
70
+ // Re-build your app (you're using 1.2.3 but your app was built with 1.2.2)
71
+ // ```
72
+ // initGlobalContext_renderPage() doens't call any user hook => err isn't thrown from user code.
76
73
  (0, utils_js_1.assert)(!(0, abort_js_1.isAbortError)(err));
77
74
  (0, loggerRuntime_js_1.logRuntimeError)(err, httpRequestId);
78
75
  const pageContextWithError = getPageContextHttpResponseError(err, pageContextInit, null);
79
76
  return pageContextWithError;
80
77
  }
81
- if (isConfigInvalid_js_1.isConfigInvalid) {
82
- return handleInvalidConfig(isConfigInvalid_js_1.isConfigInvalid.err);
78
+ if (isVikeConfigInvalid_js_1.isVikeConfigInvalid) {
79
+ return renderInvalidVikeConfig(isVikeConfigInvalid_js_1.isVikeConfigInvalid.err, pageContextInit, httpRequestId);
83
80
  }
84
81
  else {
85
- // From now on, globalContext contains all the configuration data; getVikeConfig() isn't called anymore for this request
82
+ // `globalContext` now contains the entire Vike config and getVikeConfig() isn't called anymore for this request.
86
83
  }
87
84
  const globalContext = await (0, globalContext_js_1.getGlobalContextInternal)();
88
85
  // Check Base URL
89
- await assertBaseUrl(pageContextInit, globalContext);
86
+ {
87
+ const pageContextHttpResponse = await checkBaseUrl(pageContextInit, globalContext);
88
+ if (pageContextHttpResponse)
89
+ return pageContextHttpResponse;
90
+ }
90
91
  // Normalize URL
91
92
  {
92
93
  const pageContextHttpResponse = await normalizeUrl(pageContextInit, globalContext, httpRequestId);
@@ -254,15 +255,6 @@ function getPageContextHttpResponseError(err, pageContextInit, pageContext) {
254
255
  });
255
256
  return pageContextWithError;
256
257
  }
257
- function getPageContextHttpResponseFavicon404(pageContextInit) {
258
- const pageContext = createPageContext(pageContextInit);
259
- const httpResponse = (0, createHttpResponse_js_1.createHttpResponseFavicon404)();
260
- (0, utils_js_1.objectAssign)(pageContext, {
261
- httpResponse
262
- });
263
- (0, utils_js_1.checkType)(pageContext);
264
- return pageContext;
265
- }
266
258
  function createPageContext(pageContextInit) {
267
259
  const pageContext = {
268
260
  _isPageContextObject: true
@@ -343,7 +335,6 @@ function assertIsNotViteRequest(urlPathname, urlOriginal) {
343
335
  (0, utils_js_1.assertUsage)(false, `${picocolors_1.default.code('renderPage(pageContextInit)')} called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which is unexpected because the URL ${picocolors_1.default.bold(urlOriginal)} should have already been handled by the development middleware: make sure the ${picocolors_1.default.cyan('createDevMiddleware()')} middleware is executed *before* the ${picocolors_1.default.cyan('renderPage()')} middleware, see ${picocolors_1.default.underline('https://vike.dev/renderPage')}`);
344
336
  }
345
337
  async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
346
- const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)(globalContext);
347
338
  const { trailingSlash, disableUrlNormalization } = globalContext.config;
348
339
  if (disableUrlNormalization)
349
340
  return null;
@@ -351,7 +342,7 @@ async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
351
342
  const { isPageContextRequest } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
352
343
  if (isPageContextRequest)
353
344
  return null;
354
- const urlNormalized = (0, utils_js_1.normalizeUrlPathname)(urlOriginal, trailingSlash ?? false, baseServer);
345
+ const urlNormalized = (0, utils_js_1.normalizeUrlPathname)(urlOriginal, trailingSlash ?? false, globalContext.baseServer);
355
346
  if (!urlNormalized)
356
347
  return null;
357
348
  (0, loggerRuntime_js_1.logRuntimeInfo)?.(`URL normalized from ${picocolors_1.default.cyan(urlOriginal)} to ${picocolors_1.default.cyan(urlNormalized)} (https://vike.dev/url-normalization)`, httpRequestId, 'info');
@@ -361,8 +352,7 @@ async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
361
352
  return pageContextHttpResponse;
362
353
  }
363
354
  async function getPermanentRedirect(pageContextInit, globalContext, httpRequestId) {
364
- const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)(globalContext);
365
- const urlWithoutBase = (0, utils_js_1.removeBaseServer)(pageContextInit.urlOriginal, baseServer);
355
+ const urlWithoutBase = (0, utils_js_1.removeBaseServer)(pageContextInit.urlOriginal, globalContext.baseServer);
366
356
  let origin = null;
367
357
  let urlTargetExternal = null;
368
358
  let urlTarget = (0, utils_js_1.modifyUrlPathname)(urlWithoutBase, (urlPathname) => {
@@ -393,9 +383,8 @@ async function getPermanentRedirect(pageContextInit, globalContext, httpRequestI
393
383
  }
394
384
  if (normalize(urlTarget) === normalize(urlWithoutBase))
395
385
  return null;
396
- const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)(globalContext);
397
386
  if (!originChanged)
398
- urlTarget = (0, utils_js_1.prependBase)(urlTarget, baseServer);
387
+ urlTarget = (0, utils_js_1.prependBase)(urlTarget, globalContext.baseServer);
399
388
  (0, utils_js_1.assert)(urlTarget !== pageContextInit.urlOriginal);
400
389
  }
401
390
  (0, loggerRuntime_js_1.logRuntimeInfo)?.(`Permanent redirection defined by config.redirects (https://vike.dev/redirects)`, httpRequestId, 'info');
@@ -458,10 +447,35 @@ pageContextNominalPageInit, httpRequestId, pageContextErrorPageInit, globalConte
458
447
  (0, utils_js_1.assert)(pageContextAbort.abortStatusCode);
459
448
  return { pageContextAbort };
460
449
  }
461
- async function assertBaseUrl(pageContextInit, globalContext) {
462
- const { baseServer } = (0, resolveBase_js_1.resolveBaseRuntime)(globalContext);
450
+ async function checkBaseUrl(pageContextInit, globalContext) {
451
+ const { baseServer } = globalContext;
463
452
  const { urlOriginal } = pageContextInit;
464
- const { urlWithoutPageContextRequestSuffix } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
465
- const { hasBaseServer } = (0, utils_js_1.parseUrl)(urlWithoutPageContextRequestSuffix, baseServer);
466
- (0, utils_js_1.assertUsage)(hasBaseServer, `${picocolors_1.default.code('renderPage(pageContextInit)')} (https://vike.dev/renderPage) called with ${picocolors_1.default.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which doesn't start with Base URL ${picocolors_1.default.code(baseServer)} (https://vike.dev/base-url)`);
453
+ const { isBaseMissing } = (0, utils_js_1.parseUrl)(urlOriginal, baseServer);
454
+ if (!isBaseMissing)
455
+ return;
456
+ const pageContext = createPageContext(pageContextInit);
457
+ const httpResponse = (0, createHttpResponse_js_1.createHttpResponseBaseIsMissing)(urlOriginal, baseServer);
458
+ (0, utils_js_1.objectAssign)(pageContext, {
459
+ httpResponse,
460
+ isBaseMissing: true
461
+ });
462
+ (0, utils_js_1.checkType)(pageContext);
463
+ return pageContext;
464
+ }
465
+ function renderInvalidRequest(pageContextInit) {
466
+ const urlPathnameWithBase = (0, utils_js_1.parseUrl)(pageContextInit.urlOriginal, '/').pathname;
467
+ assertIsNotViteRequest(urlPathnameWithBase, pageContextInit.urlOriginal);
468
+ if (urlPathnameWithBase.endsWith('/favicon.ico')) {
469
+ const pageContext = createPageContext(pageContextInit);
470
+ const httpResponse = (0, createHttpResponse_js_1.createHttpResponseFavicon404)();
471
+ (0, utils_js_1.objectAssign)(pageContext, { httpResponse });
472
+ (0, utils_js_1.checkType)(pageContext);
473
+ return pageContext;
474
+ }
475
+ return null;
476
+ }
477
+ function renderInvalidVikeConfig(err, pageContextInit, httpRequestId) {
478
+ (0, loggerRuntime_js_1.logRuntimeInfo)?.(picocolors_1.default.bold(picocolors_1.default.red('Error while loading a Vike config file, see error above.')), httpRequestId, 'error');
479
+ const pageContextWithError = getPageContextHttpResponseError(err, pageContextInit, null);
480
+ return pageContextWithError;
467
481
  }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = universalVikeHandler;
4
+ const index_js_1 = require("./index.js");
5
+ async function universalVikeHandler(request, context, runtime) {
6
+ const pageContextInit = { ...context, ...runtime, urlOriginal: request.url, headersOriginal: request.headers };
7
+ const pageContext = await (0, index_js_1.renderPage)(pageContextInit);
8
+ const response = pageContext.httpResponse;
9
+ const readable = response.getReadableWebStream();
10
+ return new Response(readable, {
11
+ status: response.statusCode,
12
+ headers: response.headers
13
+ });
14
+ }
@@ -4,21 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolveBase = resolveBase;
7
- exports.resolveBaseRuntime = resolveBaseRuntime;
8
- exports.resolveBaseFromResolvedConfig = resolveBaseFromResolvedConfig;
9
7
  const utils_js_1 = require("./utils.js");
10
8
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
11
- function resolveBaseFromResolvedConfig(baseServer, baseAssets, config) {
12
- let baseViteOriginal = config._baseViteOriginal;
13
- (0, utils_js_1.assert)(baseViteOriginal === null || typeof baseViteOriginal == 'string');
14
- return resolveBase(baseViteOriginal, baseServer, baseAssets);
15
- }
16
- function resolveBaseRuntime(globalContext) {
17
- const baseViteOriginal = globalContext.viteConfigRuntime._baseViteOriginal;
18
- const baseServerUnresolved = globalContext.config.baseServer ?? null;
19
- const baseAssetsUnresolved = globalContext.config.baseAssets ?? null;
20
- return resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
21
- }
22
9
  function resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved) {
23
10
  if (baseViteOriginal === '/__UNSET__')
24
11
  baseViteOriginal = null;
@@ -9,15 +9,9 @@ function getPageConfigsRuntime(virtualFileExports) {
9
9
  const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseGlobResults_js_1.parseGlobResults)(virtualFileExports);
10
10
  const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
11
11
  // TODO/now: re-use this call, instead of calling it twice
12
- const globalConfig = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)(pageConfigGlobal);
13
- // TODO/now DEDUPE
12
+ const globalConfig = (0, getPageConfigUserFriendly_js_1.getPageConfigGlobalUserFriendly)({ pageConfigGlobalValues: pageConfigGlobal.configValues });
14
13
  const pageConfigsUserFriendly = Object.fromEntries(pageConfigs.map((pageConfig) => {
15
- const configValues = { ...pageConfigGlobal.configValues, ...pageConfig.configValues };
16
- const page = {
17
- ...(0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyNew)({ configValues }),
18
- route: pageConfig.routeFilesystem?.routeString ?? null
19
- };
20
- return [pageConfig.pageId, page];
14
+ return (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendly)(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
21
15
  }));
22
16
  return { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig, pageConfigsUserFriendly };
23
17
  }
@@ -9,7 +9,7 @@ exports.pageContextJsonFileExtension = pageContextJsonFileExtension;
9
9
  // `/some-base-url/index.pageContext.json` instead of `/some-base-url.pageContext.json` in order to comply to common reverse proxy setups, see https://github.com/vikejs/vike/issues/443
10
10
  const doNotCreateExtraDirectory = false;
11
11
  exports.doNotCreateExtraDirectory = doNotCreateExtraDirectory;
12
- // See node/renderPage/handlePageContextRequestUrl.ts
12
+ // See also node/renderPage/handlePageContextRequestUrl.ts
13
13
  function getPageContextRequestUrl(url) {
14
14
  const pageContextRequestUrl = (0, urlToFile_js_1.urlToFile)(url, pageContextJsonFileExtension, doNotCreateExtraDirectory);
15
15
  return pageContextRequestUrl;
@@ -39,26 +39,29 @@ function getUrlParsed(pageContext) {
39
39
  // 6. The value of pageContext.urlPathname is now '/login': the pathname of `pageContext.urlLogical`. (While pageContext.urlOriginal is still '/fr-FR/admin'.)
40
40
  // Reproduction: https://github.com/vikejs/vike/discussions/1436#discussioncomment-8142023
41
41
  // Determine logical URL
42
- // TODO/soon: revert https://github.com/vikejs/vike/issues/2138#issuecomment-2631713411
43
- const assertUrlResolved = (src) => (0, utils_js_1.assert)(urlResolved && typeof urlResolved === 'string', { src, urlResolved });
42
+ const assertUrlResolved = (src) => (0, utils_js_1.assert)(urlResolved && typeof urlResolved === 'string',
43
+ // TODO/eventually: remove debug logs, see:
44
+ // - https://github.com/vikejs/vike/issues/2138#issuecomment-2631713411
45
+ // - https://github.com/vikejs/vike/commit/5c7810f3080ab62536950f26e019bb2a3a517082
46
+ { src, urlResolved });
44
47
  let urlResolved;
45
- let baseToBeRemoved;
48
+ let isBaseToBeRemoved;
46
49
  if (pageContext.urlLogical) {
47
50
  // Set by onBeforeRoute()
48
51
  urlResolved = pageContext.urlLogical;
49
- baseToBeRemoved = false;
52
+ isBaseToBeRemoved = false;
50
53
  assertUrlResolved(1);
51
54
  }
52
55
  else if (pageContext._urlRewrite) {
53
56
  // Set by `throw render()`
54
57
  urlResolved = pageContext._urlRewrite;
55
- baseToBeRemoved = false;
58
+ isBaseToBeRemoved = false;
56
59
  assertUrlResolved(2);
57
60
  }
58
61
  else {
59
62
  // Set by renderPage()
60
63
  urlResolved = pageContext.urlOriginal;
61
- baseToBeRemoved = true;
64
+ isBaseToBeRemoved = true;
62
65
  assertUrlResolved(3);
63
66
  }
64
67
  assertUrlResolved(4);
@@ -71,7 +74,7 @@ function getUrlParsed(pageContext) {
71
74
  // - We assume there isn't any Base URL to the URLs set by the user at `throw render()` and onBeforeRoute()
72
75
  // - This makes sense because the Base URL is merely a setting: ideally the user should write code that doesn't know anything about it (so that the user can remove/add/change Base URL without having to modify any code).
73
76
  // - pageContext.urlOriginal is the URL of the HTTP request and thus contains the Base URL.
74
- const baseServer = !baseToBeRemoved ? '/' : pageContext._baseServer;
77
+ const baseServer = !isBaseToBeRemoved ? '/' : pageContext._baseServer;
75
78
  // Parse URL
76
79
  return (0, utils_js_1.parseUrl)(urlResolved, baseServer);
77
80
  }
@@ -88,8 +91,8 @@ function urlGetter() {
88
91
  }
89
92
  function urlParsedGetter() {
90
93
  const {
91
- // remove hasBaseServer as it isn't part of UrlPublic
92
- hasBaseServer: _, ...urlParsed } = getUrlParsed(this);
94
+ // remove isBaseMissing as it isn't part of UrlPublic
95
+ isBaseMissing: _, ...urlParsed } = getUrlParsed(this);
93
96
  const hashIsAvailable = (0, utils_js_1.isBrowser)();
94
97
  const warnHashNotAvailable = (prop) => {
95
98
  (0, utils_js_1.assertWarning)(hashIsAvailable, `pageContext.urlParsed.${prop} isn't available on the server-side (HTTP requests don't include the URL hash)`, { onlyOnce: true, showStackTrace: true });
@@ -14,7 +14,7 @@ const helpers_js_1 = require("../page-configs/helpers.js");
14
14
  const getConfigValueRuntime_js_1 = require("../page-configs/getConfigValueRuntime.js");
15
15
  const utils_js_1 = require("../utils.js");
16
16
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
17
- const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('getHook.ts', {});
17
+ const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('hooks/getHook.ts', {});
18
18
  function getHook(pageContext, hookName) {
19
19
  if (!(hookName in pageContext.exports)) {
20
20
  return null;
@@ -3,23 +3,54 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPageConfigUserFriendlyOld = getPageConfigUserFriendlyOld;
7
- exports.getPageConfigUserFriendlyNew = getPageConfigUserFriendlyNew;
6
+ exports.getPageConfigUserFriendly = getPageConfigUserFriendly;
7
+ exports.getPageConfigUserFriendly_oldDesign = getPageConfigUserFriendly_oldDesign;
8
+ exports.getPageConfigGlobalUserFriendly = getPageConfigGlobalUserFriendly;
8
9
  const assert_exports_old_design_js_1 = require("../getPageFiles/assert_exports_old_design.js");
9
10
  const getConfigDefinedAt_js_1 = require("./getConfigDefinedAt.js");
10
11
  const helpers_js_1 = require("./helpers.js");
11
12
  const utils_js_1 = require("../utils.js");
12
13
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
13
- function getPageConfigUserFriendlyNew(pageConfig) {
14
- const res = getPageConfigUserFriendlyV1Desin(pageConfig);
14
+ function getPageConfigUserFriendly(pageConfigGlobalValues, pageConfig, pageConfigValues) {
15
+ const pageConfigUserFriendly = getPageConfigUserFriendly_public({ pageConfigGlobalValues, pageConfigValues });
16
+ let page;
17
+ if (!pageConfig.isErrorPage) {
18
+ const route = pageConfigUserFriendly.config.route ?? pageConfig.routeFilesystem.routeString;
19
+ page = {
20
+ ...pageConfigUserFriendly,
21
+ route
22
+ };
23
+ }
24
+ else {
25
+ page = {
26
+ ...pageConfigUserFriendly,
27
+ isErrorPage: true
28
+ };
29
+ }
30
+ return [pageConfig.pageId, page];
31
+ }
32
+ function getPageConfigUserFriendly_public({ pageConfigGlobalValues, pageConfigValues }) {
33
+ const pageConfigUserFriendly = getPageConfigUserFriendly_base({ pageConfigGlobalValues, pageConfigValues });
34
+ return getPublicCopy(pageConfigUserFriendly);
35
+ }
36
+ function getPublicCopy(pageConfigUserFriendly) {
37
+ const p = pageConfigUserFriendly;
15
38
  return {
16
- config: res.config,
17
- _source: res.source,
18
- _sources: res.sources,
19
- _from: res.from
39
+ config: p.config,
40
+ _source: p.source,
41
+ _sources: p.sources,
42
+ _from: p.from
20
43
  };
21
44
  }
22
- function getPageConfigUserFriendlyOld(pageFiles, pageConfig, pageConfigGlobal) {
45
+ function getPageConfigUserFriendly_base({ pageConfigGlobalValues, pageConfigValues }) {
46
+ const configValues = { ...pageConfigGlobalValues, ...pageConfigValues };
47
+ return getPageConfigUserFriendly_V1Design({ configValues });
48
+ }
49
+ function getPageConfigGlobalUserFriendly({ pageConfigGlobalValues }) {
50
+ const pageConfigGlobalUserFriendly = getPageConfigUserFriendly_V1Design({ configValues: pageConfigGlobalValues });
51
+ return getPublicCopy(pageConfigGlobalUserFriendly);
52
+ }
53
+ function getPageConfigUserFriendly_oldDesign(pageFiles, pageConfig, pageConfigGlobal) {
23
54
  const config = {};
24
55
  const configEntries = {}; // TODO/v1-release: remove
25
56
  const exportsAll = {}; // TODO/v1-release: remove
@@ -44,8 +75,9 @@ function getPageConfigUserFriendlyOld(pageFiles, pageConfig, pageConfigGlobal) {
44
75
  let sources;
45
76
  let from;
46
77
  if (pageConfig) {
47
- const res = getPageConfigUserFriendlyV1Desin({
48
- configValues: { ...pageConfigGlobal.configValues, ...pageConfig.configValues }
78
+ const res = getPageConfigUserFriendly_base({
79
+ pageConfigGlobalValues: pageConfigGlobal.configValues,
80
+ pageConfigValues: pageConfig.configValues
49
81
  });
50
82
  source = res.source;
51
83
  sources = res.sources;
@@ -92,7 +124,7 @@ function getPageConfigUserFriendlyOld(pageFiles, pageConfig, pageConfigGlobal) {
92
124
  return pageContextExports;
93
125
  }
94
126
  // V1 design
95
- function getPageConfigUserFriendlyV1Desin(pageConfig) {
127
+ function getPageConfigUserFriendly_V1Design(pageConfig) {
96
128
  const config = {};
97
129
  const configEntries = {};
98
130
  const exportsAll = {};
@@ -14,15 +14,9 @@ function parsePageConfigs(pageConfigsSerialized, pageConfigGlobalSerialized) {
14
14
  // pageConfigs
15
15
  const pageConfigs = pageConfigsSerialized.map((pageConfigSerialized) => {
16
16
  const configValues = parseConfigValuesSerialized(pageConfigSerialized.configValuesSerialized);
17
- const { pageId, isErrorPage, routeFilesystem, loadConfigValuesAll } = pageConfigSerialized;
18
17
  assertRouteConfigValue(configValues);
19
- return {
20
- pageId,
21
- isErrorPage,
22
- routeFilesystem,
23
- configValues,
24
- loadConfigValuesAll
25
- };
18
+ const pageConfig = { ...pageConfigSerialized, configValues };
19
+ return pageConfig;
26
20
  });
27
21
  // pageConfigsGlobal
28
22
  const pageConfigGlobal = { configValues: {} };
@@ -10,7 +10,7 @@ const getConfigDefinedAt_js_1 = require("../page-configs/getConfigDefinedAt.js")
10
10
  const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
11
11
  const getHook_js_1 = require("../hooks/getHook.js");
12
12
  async function loadPageRoutes(
13
- // Remove all arguments and use GlobalContext instead?
13
+ // Remove all arguments and use GlobalContextInternal instead?
14
14
  pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
15
15
  // TODO/next-major: remove & make this function sync
16
16
  await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.222';
5
+ exports.PROJECT_VERSION = '0.4.223';
@@ -47,7 +47,7 @@ function assert(condition, debugInfo) {
47
47
  const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
48
48
  return picocolors_1.default.dim(`Debug info (for Vike maintainers; you can ignore this): ${debugInfoSerialized}`);
49
49
  })();
50
- const link = picocolors_1.default.blue('https://github.com/vikejs/vike/issues/new');
50
+ const link = picocolors_1.default.blue('https://github.com/vikejs/vike/issues/new?template=bug.yml');
51
51
  let errMsg = [
52
52
  `You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).`,
53
53
  debugStr
@@ -21,7 +21,7 @@ const isVitest_js_1 = require("./isVitest.js");
21
21
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
22
22
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
23
23
  const debug = (0, debug_js_1.createDebugger)('vike:setup');
24
- const setup = (0, getGlobalObject_js_1.getGlobalObject)('utils/assertIsNotProductionRuntime.ts', {});
24
+ const setup = (0, getGlobalObject_js_1.getGlobalObject)('utils/assertSetup.ts', {});
25
25
  // Called by Vike modules that want to ensure that they aren't loaded by the server runtime in production
26
26
  function assertIsNotProductionRuntime() {
27
27
  if (debug.isActivated)
@@ -16,7 +16,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
16
16
  /* Use original assertUsage() & assertWarning() after all CJS is removed from node_modules/vike/dist/
17
17
  import { assertUsage, assertWarning } from './assert.js'
18
18
  */
19
- const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('assertSingleInstance.ts', {
19
+ const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/assertSingleInstance.ts', {
20
20
  instances: [],
21
21
  alreadyLogged: new Set()
22
22
  });
@@ -27,7 +27,7 @@ function assertSingleInstance() {
27
27
  const versions = (0, unique_js_1.unique)(globalObject.instances);
28
28
  assertUsage(versions.length <= 1,
29
29
  // DO *NOT* patch vike to remove this error: because of multiple conflicting versions, you *will* eventually encounter insidious issues that hard to debug and potentially a security hazard, see for example https://github.com/vikejs/vike/issues/1108
30
- `vike@${picocolors_1.default.bold(versions[0])} and vike@${picocolors_1.default.bold(versions[1])} loaded but only one version should be loaded`);
30
+ `vike@${picocolors_1.default.bold(versions[0])} and vike@${picocolors_1.default.bold(versions[1])} loaded but it's forbidden to load different versions`);
31
31
  }
32
32
  if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
33
33
  /*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
@@ -4,17 +4,13 @@ exports.getGlobalObject = getGlobalObject;
4
4
  exports.assertIsSingleModuleInstance = assertIsSingleModuleInstance;
5
5
  const assert_js_1 = require("./assert.js");
6
6
  /** Share information across module instances. */
7
- function getGlobalObject(
8
- // We use the filename (or file path) as key. There should be only one getGlobalObject() usage per file. Thus the key should be unique, assuming the filename (or file path) is unique.
9
- key, defaultValue) {
7
+ function getGlobalObject(key, defaultValue) {
10
8
  const globalObjects = getGlobalObjects();
11
9
  const globalObject = (globalObjects[key] = globalObjects[key] || defaultValue);
12
10
  return globalObject;
13
11
  }
14
12
  /** Assert that the module is instantiated only once. */
15
- function assertIsSingleModuleInstance(
16
- // We use the filename (or file path) as key.
17
- key) {
13
+ function assertIsSingleModuleInstance(key) {
18
14
  const globalObjects = getGlobalObjects();
19
15
  (0, assert_js_1.assert)(!(key in globalObjects));
20
16
  }
@@ -30,8 +30,8 @@ function prependBase(url, baseServer) {
30
30
  return `${baseServerNormalized}${url}`;
31
31
  }
32
32
  function removeBaseServer(url, baseServer) {
33
- const { hasBaseServer, origin, pathname, pathnameOriginal, searchOriginal, hashOriginal } = (0, parseUrl_js_1.parseUrl)(url, baseServer);
34
- (0, assert_js_1.assert)(hasBaseServer);
33
+ const { isBaseMissing, origin, pathname, pathnameOriginal, searchOriginal, hashOriginal } = (0, parseUrl_js_1.parseUrl)(url, baseServer);
34
+ (0, assert_js_1.assert)(!isBaseMissing);
35
35
  (0, parseUrl_js_1.assertUrlComponents)(url, origin, pathnameOriginal, searchOriginal, hashOriginal);
36
36
  const urlWithoutBase = (0, parseUrl_js_1.createUrlFromComponents)(origin, pathname, searchOriginal, hashOriginal);
37
37
  return urlWithoutBase;
@@ -49,7 +49,7 @@ function parseUrl(url, baseServer) {
49
49
  const pathnameOriginal = urlWithoutHashNorSearch.slice((origin || '').length);
50
50
  assertUrlComponents(url, origin, pathnameOriginal, searchOriginal, hashOriginal);
51
51
  // Base URL
52
- let { pathname, hasBaseServer } = removeBaseServer(pathnameAbsoluteWithBase, baseServer);
52
+ let { pathname, isBaseMissing } = removeBaseServer(pathnameAbsoluteWithBase, baseServer);
53
53
  // pageContext.urlParsed.href
54
54
  const href = createUrlFromComponents(origin, pathname, searchOriginal, hashOriginal);
55
55
  // pageContext.urlParsed.{hostname, port}
@@ -66,7 +66,7 @@ function parseUrl(url, baseServer) {
66
66
  origin,
67
67
  pathname,
68
68
  pathnameOriginal: pathnameOriginal,
69
- hasBaseServer,
69
+ isBaseMissing,
70
70
  search,
71
71
  searchAll,
72
72
  searchOriginal,
@@ -235,7 +235,7 @@ function removeBaseServer(pathnameAbsoluteWithBase, baseServer) {
235
235
  (0, assert_js_1.assert)(baseServer.startsWith('/'));
236
236
  if (baseServer === '/') {
237
237
  const pathname = pathnameAbsoluteWithBase;
238
- return { pathname, hasBaseServer: true };
238
+ return { pathname, isBaseMissing: false };
239
239
  }
240
240
  // Support `url === '/some-base-url' && baseServer === '/some-base-url/'`
241
241
  let baseServerNormalized = baseServer;
@@ -245,7 +245,7 @@ function removeBaseServer(pathnameAbsoluteWithBase, baseServer) {
245
245
  }
246
246
  if (!urlPathname.startsWith(baseServerNormalized)) {
247
247
  const pathname = pathnameAbsoluteWithBase;
248
- return { pathname, hasBaseServer: false };
248
+ return { pathname, isBaseMissing: true };
249
249
  }
250
250
  (0, assert_js_1.assert)(urlPathname.startsWith('/') || urlPathname.startsWith('http'));
251
251
  (0, assert_js_1.assert)(urlPathname.startsWith(baseServerNormalized));
@@ -253,7 +253,7 @@ function removeBaseServer(pathnameAbsoluteWithBase, baseServer) {
253
253
  if (!urlPathname.startsWith('/'))
254
254
  urlPathname = '/' + urlPathname;
255
255
  (0, assert_js_1.assert)(urlPathname.startsWith('/'));
256
- return { pathname: urlPathname, hasBaseServer: true };
256
+ return { pathname: urlPathname, isBaseMissing: false };
257
257
  }
258
258
  function isBaseServer(baseServer) {
259
259
  return baseServer.startsWith('/');
@@ -1,7 +1,7 @@
1
1
  export { setPageContextCurrent };
2
2
  export { getPageContextCurrent };
3
- import type { PageConfigUserFriendly } from '../../shared/getPageFiles.js';
4
- type PageContextCurrent = PageConfigUserFriendly & {
3
+ import type { PageConfigUserFriendlyOld } from '../../shared/getPageFiles.js';
4
+ type PageContextCurrent = PageConfigUserFriendlyOld & {
5
5
  urlPathname: string;
6
6
  };
7
7
  declare function getPageContextCurrent(): null | PageContextCurrent;
@@ -1,7 +1,7 @@
1
1
  export { setPageContextCurrent };
2
2
  export { getPageContextCurrent };
3
3
  import { getGlobalObject } from './utils.js';
4
- const globalObject = getGlobalObject('getPageContextCurrent.ts', {
4
+ const globalObject = getGlobalObject('client-routing-runtime/getPageContextCurrent.ts', {
5
5
  pageContextCurrent: null
6
6
  });
7
7
  function getPageContextCurrent() {
@@ -5,7 +5,7 @@ export { getPageContextFromClientHooks };
5
5
  export { setPageContextInitIsPassedToClient };
6
6
  export type { PageContextFromServerHooks };
7
7
  export type { PageContextFromClientHooks };
8
- import type { PageConfigUserFriendly, PageFile } from '../../shared/getPageFiles.js';
8
+ import type { PageConfigUserFriendlyOld, PageFile } from '../../shared/getPageFiles.js';
9
9
  import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
10
10
  type PageContext = {
11
11
  urlOriginal: string;
@@ -21,9 +21,9 @@ declare function getPageContextFromHooks_serialized(): PageContextSerialized & {
21
21
  routeParams: Record<string, string>;
22
22
  _hasPageContextFromServer: true;
23
23
  };
24
- declare function getPageContextFromHooks_isHydration(pageContext: PageContextSerialized & PageContext & PageConfigUserFriendly & {
24
+ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSerialized & PageContext & PageConfigUserFriendlyOld & {
25
25
  _hasPageContextFromServer: true;
26
- }): Promise<PageContextSerialized & PageContext & PageConfigUserFriendly & {
26
+ }): Promise<PageContextSerialized & PageContext & PageConfigUserFriendlyOld & {
27
27
  _hasPageContextFromServer: true;
28
28
  } & {
29
29
  _hasPageContextFromClient: boolean;
@@ -45,5 +45,5 @@ type PageContextFromClientHooks = {
45
45
  declare function getPageContextFromClientHooks(pageContext: {
46
46
  pageId: string;
47
47
  _hasPageContextFromServer: boolean;
48
- } & PageContext & PageConfigUserFriendly, isErrorPage: boolean): Promise<PageContextFromClientHooks>;
48
+ } & PageContext & PageConfigUserFriendlyOld, isErrorPage: boolean): Promise<PageContextFromClientHooks>;
49
49
  declare function setPageContextInitIsPassedToClient(pageContext: Record<string, unknown>): void;