vike 0.4.222-commit-6647d1e → 0.4.222

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 (64) hide show
  1. package/dist/cjs/node/plugin/index.js +1 -1
  2. package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -6
  3. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +14 -7
  4. package/dist/cjs/node/runtime/globalContext.js +6 -17
  5. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  6. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -2
  7. package/dist/cjs/node/runtime/renderPage.js +8 -4
  8. package/dist/cjs/node/shared/resolveBase.js +13 -0
  9. package/dist/cjs/shared/getPageConfigsRuntime.js +8 -2
  10. package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +12 -44
  11. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +8 -2
  12. package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
  13. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  14. package/dist/cjs/utils/assertSingleInstance.js +1 -1
  15. package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
  16. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
  17. package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
  18. package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
  19. package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
  20. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +1 -1
  21. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
  22. package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
  23. package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
  24. package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
  25. package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
  26. package/dist/esm/node/plugin/index.d.ts +1 -4
  27. package/dist/esm/node/plugin/index.js +1 -1
  28. package/dist/esm/node/plugin/plugins/baseUrls.js +1 -6
  29. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -2
  30. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +15 -8
  31. package/dist/esm/node/runtime/globalContext.d.ts +8 -9
  32. package/dist/esm/node/runtime/globalContext.js +6 -17
  33. package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
  34. package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
  35. package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
  36. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
  37. package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
  38. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
  39. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +3 -3
  40. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
  41. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  42. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +4 -4
  43. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +12 -12
  44. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -2
  45. package/dist/esm/node/runtime/renderPage.js +8 -4
  46. package/dist/esm/node/shared/resolveBase.d.ts +9 -1
  47. package/dist/esm/node/shared/resolveBase.js +13 -0
  48. package/dist/esm/shared/getPageConfigsRuntime.d.ts +2 -2
  49. package/dist/esm/shared/getPageConfigsRuntime.js +9 -3
  50. package/dist/esm/shared/getPageFiles.d.ts +1 -1
  51. package/dist/esm/shared/hooks/getHook.d.ts +3 -3
  52. package/dist/esm/shared/page-configs/Config.d.ts +1 -3
  53. package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -9
  54. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +16 -24
  55. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +12 -44
  56. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +2 -3
  57. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +8 -2
  58. package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
  59. package/dist/esm/shared/route/loadPageRoutes.js +1 -1
  60. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  61. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  62. package/dist/esm/utils/assertSingleInstance.js +1 -1
  63. package/dist/esm/utils/projectInfo.d.ts +1 -1
  64. package/package.json +1 -1
@@ -9,12 +9,12 @@ export type { VikeConfigObject };
9
9
  import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
10
10
  import { type ConfigDefinitions, type ConfigDefinitionInternal } from './getVikeConfig/configDefinitionsBuiltIn.js';
11
11
  import type { ResolvedConfig } from 'vite';
12
- import { type PageConfigUserFriendly, type PageConfigsUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
12
+ import { type ConfigUserFriendly, type PageConfigsUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
13
13
  import { type PlusFile } from './getVikeConfig/getPlusFilesAll.js';
14
14
  type VikeConfigObject = {
15
15
  pageConfigs: PageConfigBuildTime[];
16
16
  pageConfigGlobal: PageConfigGlobalBuildTime;
17
- global: PageConfigUserFriendly;
17
+ global: ConfigUserFriendly;
18
18
  pages: PageConfigsUserFriendly;
19
19
  };
20
20
  declare const vikeConfigDependencies: Set<string>;
@@ -19,7 +19,7 @@ import { resolvePointerImport } from './getVikeConfig/resolvePointerImport.js';
19
19
  import { getFilePathResolved } from '../../../shared/getFilePath.js';
20
20
  import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
21
21
  import { assertExtensionsRequire } from './getVikeConfig/assertExtensions.js';
22
- import { getPageConfigGlobalUserFriendly, getPageConfigUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
22
+ import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
23
23
  import { getConfigValuesBase } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
24
24
  import { getPlusFilesAll } from './getVikeConfig/getPlusFilesAll.js';
25
25
  assertIsNotProductionRuntime();
@@ -127,7 +127,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
127
127
  configDefinitions: {},
128
128
  configValueSources: {}
129
129
  },
130
- global: getPageConfigGlobalUserFriendly({ pageConfigGlobalValues: {} }),
130
+ global: getPageConfigUserFriendlyNew({ configValues: {} }),
131
131
  pages: {}
132
132
  };
133
133
  return dummyData;
@@ -143,12 +143,18 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
143
143
  // interop vike(options) in vite.config.js
144
144
  temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
145
145
  // global
146
- const pageConfigGlobalValues = getConfigValues(pageConfigGlobal);
147
- const global = getPageConfigGlobalUserFriendly({ pageConfigGlobalValues });
146
+ const configValuesGlobal = getConfigValues(pageConfigGlobal);
147
+ const global = getPageConfigUserFriendlyNew({ configValues: configValuesGlobal });
148
+ // TODO/now DEDUPE
148
149
  // pages
149
150
  const pages = objectFromEntries(pageConfigs.map((pageConfig) => {
150
- const pageConfigValues = getConfigValues(pageConfig, true);
151
- return getPageConfigUserFriendly(pageConfigGlobalValues, pageConfig, pageConfigValues);
151
+ const configValuesLocal = getConfigValues(pageConfig, true);
152
+ const configValues = { ...configValuesGlobal, ...configValuesLocal };
153
+ const page = {
154
+ ...getPageConfigUserFriendlyNew({ configValues }),
155
+ route: pageConfig.routeFilesystem?.routeString ?? null
156
+ };
157
+ return [pageConfig.pageId, page];
152
158
  }));
153
159
  return { pageConfigs, pageConfigGlobal, global, pages };
154
160
  }
@@ -213,12 +219,13 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
213
219
  return;
214
220
  configValueSources[configName] = sources;
215
221
  });
216
- const pageConfigRoute = determineRouteFilesystem(locationId, configValueSources);
222
+ const { routeFilesystem, isErrorPage } = determineRouteFilesystem(locationId, configValueSources);
217
223
  applyEffectsAll(configValueSources, configDefinitionsLocal);
218
224
  const configValuesComputed = getComputed(configValueSources, configDefinitionsLocal);
219
225
  const pageConfig = {
220
226
  pageId: locationId,
221
- ...pageConfigRoute,
227
+ isErrorPage,
228
+ routeFilesystem,
222
229
  configDefinitions: configDefinitionsLocal,
223
230
  plusFiles: plusFilesRelevant,
224
231
  configValueSources,
@@ -16,25 +16,24 @@ export { assertBuildInfo };
16
16
  export { getViteConfigRuntime };
17
17
  export { updateUserFiles };
18
18
  export type { BuildInfo };
19
- export type { GlobalContextInternal };
19
+ export type { GlobalContext };
20
20
  export type { GlobalContextPublic };
21
21
  import type { ViteManifest } from '../shared/ViteManifest.js';
22
22
  import type { ResolvedConfig, ViteDevServer } from 'vite';
23
- import type { PageConfigUserFriendly, PageConfigsUserFriendly } from '../../shared/page-configs/getPageConfigUserFriendly.js';
23
+ import type { ConfigUserFriendly, PageConfigsUserFriendly } from '../../shared/page-configs/getPageConfigUserFriendly.js';
24
24
  import type { ConfigVitePluginServerEntry } from '@brillout/vite-plugin-server-entry/plugin';
25
- import { type BaseUrlsResolved } from '../shared/resolveBase.js';
26
- type GlobalContextPublic = Pick<GlobalContext, 'assetsManifest' | 'config' | 'viteConfig' | 'pages' | 'baseAssets' | 'baseServer'>;
25
+ type GlobalContextPublic = Pick<GlobalContext, 'assetsManifest' | 'config' | 'viteConfig' | 'pages'>;
27
26
  type PageRuntimeInfo = Awaited<ReturnType<typeof getUserFiles>>;
28
- type GlobalContextInternal = GlobalContext & {
27
+ type GlobalContext = GlobalContextWithoutPublicCopy & {
29
28
  globalContext_public: GlobalContextPublic;
30
29
  };
31
- type GlobalContext = {
30
+ type GlobalContextWithoutPublicCopy = {
32
31
  viteConfigRuntime: {
33
32
  _baseViteOriginal: null | string;
34
33
  };
35
- config: PageConfigUserFriendly['config'];
34
+ config: ConfigUserFriendly['config'];
36
35
  pages: PageConfigsUserFriendly;
37
- } & BaseUrlsResolved & PageRuntimeInfo & ({
36
+ } & PageRuntimeInfo & ({
38
37
  isProduction: false;
39
38
  isPrerendering: false;
40
39
  viteConfig: ResolvedConfig;
@@ -52,7 +51,7 @@ type GlobalContext = {
52
51
  usesClientRouter: boolean;
53
52
  viteConfig: ResolvedConfig;
54
53
  })));
55
- declare function getGlobalContextInternal(): Promise<GlobalContextInternal>;
54
+ declare function getGlobalContextInternal(): Promise<GlobalContext>;
56
55
  /** @experimental https://vike.dev/getGlobalContext */
57
56
  declare function getGlobalContextSync(): GlobalContextPublic;
58
57
  /** @experimental https://vike.dev/getGlobalContext */
@@ -18,7 +18,7 @@ export { assertBuildInfo };
18
18
  export { getViteConfigRuntime };
19
19
  export { updateUserFiles };
20
20
  // The core logic revolves around:
21
- // - globalObject.userFiles which is the main requirement for resolveGlobalContext()
21
+ // - globalObject.userFiles which is the main requirement for assembleGlobalContext()
22
22
  // - In production: globalObject.buildEntry which is the production entry set by @brillout/vite-plugin-server-entry
23
23
  // - loadBuildEntry() sets globalObject.buildEntry and then sets globalObject.userFiles
24
24
  // - With vike-server it's set at server start: @brillout/vite-plugin-server-entry injects `import './entry.mjs'` (the production entry generated by @brillout/vite-plugin-server-entry) as first line of code of dist/server/index.mjs while dist/server/entry.mjs calls setGlobalContext_buildEntry()
@@ -32,7 +32,6 @@ import pc from '@brillout/picocolors';
32
32
  import { loadPageRoutes } from '../../shared/route/loadPageRoutes.js';
33
33
  import { assertV1Design } from '../shared/assertV1Design.js';
34
34
  import { getPageConfigsRuntime } from '../../shared/getPageConfigsRuntime.js';
35
- import { resolveBase } from '../shared/resolveBase.js';
36
35
  const debug = createDebugger('vike:globalContext');
37
36
  const globalObject = getGlobalObject('globalContext.ts', getInitialGlobalContext());
38
37
  async function getGlobalContextInternal() {
@@ -80,9 +79,7 @@ function makePublic(globalContext) {
80
79
  'assetsManifest',
81
80
  'config',
82
81
  'viteConfig',
83
- 'pages',
84
- 'baseServer',
85
- 'baseAssets'
82
+ 'pages'
86
83
  ]);
87
84
  return globalContextPublic;
88
85
  }
@@ -187,7 +184,7 @@ function setIsProduction(isProduction) {
187
184
  globalObject.isProduction = isProduction;
188
185
  }
189
186
  function defineGlobalContext() {
190
- const globalContext = resolveGlobalContext();
187
+ const globalContext = assembleGlobalContext();
191
188
  assertIsDefined(globalContext);
192
189
  const globalContext_public = makePublic(globalContext);
193
190
  objectAssign(globalContext, { globalContext_public });
@@ -196,7 +193,7 @@ function defineGlobalContext() {
196
193
  assertGlobalContextIsDefined();
197
194
  onSetupRuntime();
198
195
  }
199
- function resolveGlobalContext() {
196
+ function assembleGlobalContext() {
200
197
  const { viteDevServer, viteConfig, isPrerendering, isProduction, userFiles } = globalObject;
201
198
  assert(typeof isProduction === 'boolean');
202
199
  let globalContext;
@@ -215,8 +212,7 @@ function resolveGlobalContext() {
215
212
  viteDevServer,
216
213
  viteConfig,
217
214
  ...userFiles,
218
- viteConfigRuntime,
219
- ...resolveBaseRuntime(viteConfigRuntime, userFiles.config)
215
+ viteConfigRuntime
220
216
  };
221
217
  }
222
218
  else {
@@ -233,8 +229,7 @@ function resolveGlobalContext() {
233
229
  ...userFiles,
234
230
  viteDevServer: null,
235
231
  viteConfigRuntime: buildInfo.viteConfigRuntime,
236
- usesClientRouter: buildInfo.usesClientRouter,
237
- ...resolveBaseRuntime(buildInfo.viteConfigRuntime, userFiles.config)
232
+ usesClientRouter: buildInfo.usesClientRouter
238
233
  };
239
234
  if (isPrerendering) {
240
235
  assert(viteConfig);
@@ -403,9 +398,3 @@ function getInitialGlobalContext() {
403
398
  viteDevServerPromiseResolve
404
399
  };
405
400
  }
406
- function resolveBaseRuntime(viteConfigRuntime, config) {
407
- const baseViteOriginal = viteConfigRuntime._baseViteOriginal;
408
- const baseServerUnresolved = config.baseServer ?? null;
409
- const baseAssetsUnresolved = config.baseAssets ?? null;
410
- return resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
411
- }
@@ -1,5 +1,5 @@
1
1
  export { getViteDevScript };
2
- import type { GlobalContextInternal } from '../../globalContext.js';
2
+ import type { GlobalContext } from '../../globalContext.js';
3
3
  declare function getViteDevScript(pageContext: {
4
- _globalContext: GlobalContextInternal;
4
+ _globalContext: GlobalContext;
5
5
  }): Promise<string>;
@@ -8,7 +8,7 @@ import { type PreloadFilter } from './injectAssets/getHtmlTags.js';
8
8
  import type { StreamFromReactStreamingPackage } from './stream/react-streaming.js';
9
9
  import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
10
10
  import type { PageContextSerialization } from './serializePageContextClientSide.js';
11
- import type { GlobalContextInternal } from '../globalContext.js';
11
+ import type { GlobalContext } from '../globalContext.js';
12
12
  type PageContextInjectAssets = {
13
13
  urlPathname: string;
14
14
  __getPageAssets: () => Promise<PageAsset[]>;
@@ -22,7 +22,7 @@ type PageContextInjectAssets = {
22
22
  _baseServer: string;
23
23
  _pageConfigs: PageConfigRuntime[];
24
24
  is404: null | boolean;
25
- _globalContext: GlobalContextInternal;
25
+ _globalContext: GlobalContext;
26
26
  } & PageContextSerialization;
27
27
  declare function injectHtmlTagsToString(htmlParts: HtmlPart[], pageContext: PageContextInjectAssets & {
28
28
  _isStream: false;
@@ -2,5 +2,5 @@ export { analyzePage };
2
2
  import type { PageFile } from '../../../shared/getPageFiles/getPageFileObject.js';
3
3
  import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
4
4
  import { type AnalysisResult } from '../../../shared/getPageFiles/analyzePageClientSide.js';
5
- import type { GlobalContextInternal } from '../globalContext.js';
6
- declare function analyzePage(pageFilesAll: PageFile[], pageConfig: null | PageConfigRuntime, pageId: string, globalContext: GlobalContextInternal): Promise<AnalysisResult>;
5
+ import type { GlobalContext } from '../globalContext.js';
6
+ declare function analyzePage(pageFilesAll: PageFile[], pageConfig: null | PageConfigRuntime, pageId: string, globalContext: GlobalContext): Promise<AnalysisResult>;
@@ -1,7 +1,7 @@
1
1
  export { executeOnBeforeRenderAndDataHooks };
2
- import { type PageConfigUserFriendlyOld } from '../../../shared/getPageFiles.js';
2
+ import { type PageConfigUserFriendly } from '../../../shared/getPageFiles.js';
3
3
  import { type PageContextForUserConsumptionServerSide } from './preparePageContextForUserConsumptionServerSide.js';
4
4
  declare function executeOnBeforeRenderAndDataHooks(pageContext: {
5
5
  pageId: string;
6
6
  _pageContextAlreadyProvidedByOnPrerenderHook?: true;
7
- } & PageConfigUserFriendlyOld & PageContextForUserConsumptionServerSide): Promise<void>;
7
+ } & PageConfigUserFriendly & PageContextForUserConsumptionServerSide): Promise<void>;
@@ -5,7 +5,7 @@ export type { GetPageAssets };
5
5
  export type { PageContextGetPageAssets };
6
6
  import { type MediaType } from './inferMediaType.js';
7
7
  import type { ClientDependency } from '../../../shared/getPageFiles/analyzePageClientSide/ClientDependency.js';
8
- import type { GlobalContextInternal } from '../globalContext.js';
8
+ import type { GlobalContext } from '../globalContext.js';
9
9
  import type { ResolveClientEntriesDev } from '../../plugin/shared/resolveClientEntriesDev.js';
10
10
  type PageAsset = {
11
11
  src: string;
@@ -18,7 +18,7 @@ type PageContextGetPageAssets = {
18
18
  _baseServer: string;
19
19
  _baseAssets: string | null;
20
20
  _includeAssetsImportedByServer: boolean;
21
- _globalContext: GlobalContextInternal;
21
+ _globalContext: GlobalContext;
22
22
  };
23
23
  declare function getPageAssets(pageContext: PageContextGetPageAssets, clientDependencies: ClientDependency[], clientEntries: string[]): Promise<PageAsset[]>;
24
24
  declare function setResolveClientEntriesDev(resolveClientEntriesDev: ResolveClientEntriesDev): void;
@@ -1,5 +1,5 @@
1
1
  export { handleErrorWithoutErrorPage };
2
- import type { GlobalContextInternal } from '../globalContext.js';
2
+ import type { GlobalContext } from '../globalContext.js';
3
3
  import type { PageContextAfterRender } from './renderPageAlreadyRouted.js';
4
4
  import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
5
5
  import type { PageFile } from '../../../shared/getPageFiles.js';
@@ -10,6 +10,6 @@ declare function handleErrorWithoutErrorPage<PageContext extends {
10
10
  pageId: null;
11
11
  _pageFilesAll: PageFile[];
12
12
  _pageConfigs: PageConfigRuntime[];
13
- _globalContext: GlobalContextInternal;
13
+ _globalContext: GlobalContext;
14
14
  urlOriginal: string;
15
15
  }>(pageContext: PageContext): Promise<PageContext & PageContextAfterRender>;
@@ -6,17 +6,17 @@ import { PromiseType } from '../utils.js';
6
6
  import { PageContextGetPageAssets, type PageAsset } from './getPageAssets.js';
7
7
  import { type PageContextDebugRouteMatches } from './debugPageFiles.js';
8
8
  import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
9
- import type { GlobalContextInternal } from '../globalContext.js';
9
+ import type { GlobalContext } from '../globalContext.js';
10
10
  type PageContext_loadUserFilesServerSide = PageContextGetPageAssets & PageContextDebugRouteMatches & {
11
11
  urlOriginal: string;
12
12
  _pageFilesAll: PageFile[];
13
13
  _pageConfigs: PageConfigRuntime[];
14
- _globalContext: GlobalContextInternal;
14
+ _globalContext: GlobalContext;
15
15
  };
16
16
  type PageFiles = PromiseType<ReturnType<typeof loadUserFilesServerSide>>;
17
17
  declare function loadUserFilesServerSide(pageContext: {
18
18
  pageId: string;
19
- } & PageContext_loadUserFilesServerSide): Promise<import("../../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
19
+ } & PageContext_loadUserFilesServerSide): Promise<import("../../../shared/getPageFiles.js").PageConfigUserFriendly & {
20
20
  Page: unknown;
21
21
  _isHtmlOnly: boolean;
22
22
  _passToClient: string[];
@@ -1,6 +1,6 @@
1
1
  export { loadUserFilesServerSide };
2
2
  import { getPageFilesServerSide } from '../../../shared/getPageFiles.js';
3
- import { getPageConfigUserFriendly_oldDesign } from '../../../shared/page-configs/getPageConfigUserFriendly.js';
3
+ import { getPageConfigUserFriendlyOld } from '../../../shared/page-configs/getPageConfigUserFriendly.js';
4
4
  import { analyzePageClientSideInit } from '../../../shared/getPageFiles/analyzePageClientSide.js';
5
5
  import { assert, assertUsage, assertWarning, hasProp, isArrayOfStrings, objectAssign, isArray } from '../utils.js';
6
6
  import { getPageAssets } from './getPageAssets.js';
@@ -100,7 +100,7 @@ async function loadPageUserFiles(pageFilesAll, pageConfig, pageConfigGlobal, pag
100
100
  const pageFilesServerSide = getPageFilesServerSide(pageFilesAll, pageId);
101
101
  const pageConfigLoaded = !pageConfig ? null : await loadConfigValues(pageConfig, isDev);
102
102
  await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
103
- const pageContextExports = getPageConfigUserFriendly_oldDesign(pageFilesServerSide, pageConfigLoaded, pageConfigGlobal);
103
+ const pageContextExports = getPageConfigUserFriendlyOld(pageFilesServerSide, pageConfigLoaded, pageConfigGlobal);
104
104
  return {
105
105
  pageContextExports,
106
106
  pageFilesLoaded: pageFilesServerSide
@@ -1,12 +1,12 @@
1
1
  export { log404 };
2
2
  export { getRoutesInfo };
3
3
  import type { PageRoutes } from '../../../../shared/route/index.js';
4
- import type { GlobalContextInternal } from '../../globalContext.js';
4
+ import type { GlobalContext } from '../../globalContext.js';
5
5
  declare function log404(pageContext: {
6
6
  urlPathname: string;
7
7
  errorWhileRendering: null | Error;
8
8
  isClientSideNavigation: boolean;
9
9
  _pageRoutes: PageRoutes;
10
- _globalContext: GlobalContextInternal;
10
+ _globalContext: GlobalContext;
11
11
  }): Promise<void>;
12
12
  declare function getRoutesInfo(pageRoutes: PageRoutes): string | null;
@@ -2,10 +2,10 @@ export { preparePageContextForUserConsumptionServerSide };
2
2
  export type { PageContextForUserConsumptionServerSide };
3
3
  import { PageContextUrlInternal } from '../../../shared/getPageContextUrlComputed.js';
4
4
  import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
5
- import type { PageConfigUserFriendlyOld } from '../../../shared/page-configs/getPageConfigUserFriendly.js';
5
+ import type { PageConfigUserFriendly } from '../../../shared/page-configs/getPageConfigUserFriendly.js';
6
6
  import { PageContextBuiltInServerInternal } from '../../../shared/types.js';
7
- import type { GlobalContextInternal, GlobalContextPublic } from '../globalContext.js';
8
- type PageContextForUserConsumptionServerSide = PageContextBuiltInServerInternal & PageConfigUserFriendlyOld & {
7
+ import type { GlobalContext, GlobalContextPublic } from '../globalContext.js';
8
+ type PageContextForUserConsumptionServerSide = PageContextBuiltInServerInternal & PageConfigUserFriendly & {
9
9
  urlOriginal: string;
10
10
  /** @deprecated */
11
11
  url: string;
@@ -18,7 +18,7 @@ type PageContextForUserConsumptionServerSide = PageContextBuiltInServerInternal
18
18
  is404: null | boolean;
19
19
  isClientSideNavigation: boolean;
20
20
  pageProps?: Record<string, unknown>;
21
- _globalContext: GlobalContextInternal;
21
+ _globalContext: GlobalContext;
22
22
  globalContext: GlobalContextPublic;
23
23
  } & Record<string, unknown>;
24
24
  declare function preparePageContextForUserConsumptionServerSide(pageContext: PageContextForUserConsumptionServerSide): void;
@@ -5,7 +5,7 @@ export { getPageContextInitEnhanced };
5
5
  export type { PageContextAfterRender };
6
6
  export type { PageContextInitEnhanced };
7
7
  import { type PageContextUrlInternal } from '../../../shared/getPageContextUrlComputed.js';
8
- import type { GlobalContextInternal } from '../globalContext.js';
8
+ import type { GlobalContext } from '../globalContext.js';
9
9
  import { HttpResponse } from './createHttpResponse.js';
10
10
  import { PageContext_loadUserFilesServerSide, type PageFiles } from './loadUserFilesServerSide.js';
11
11
  type PageContextAfterRender = {
@@ -46,7 +46,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
46
46
  _allPageIds: string[];
47
47
  _pageRoutes: import("../../../__internal/index.js").PageRoutes;
48
48
  _onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
49
- _globalContext: GlobalContextInternal;
49
+ _globalContext: GlobalContext;
50
50
  /** @experimental This is a beta feature https://vike.dev/getGlobalContext */
51
51
  globalContext: import("../globalContext.js").GlobalContextPublic;
52
52
  _pageContextInit: {
@@ -63,7 +63,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
63
63
  url: string;
64
64
  } & {
65
65
  headers: Record<string, string> | null;
66
- } & import("../../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
66
+ } & import("../../../shared/getPageFiles.js").PageConfigUserFriendly & {
67
67
  Page: unknown;
68
68
  _isHtmlOnly: boolean;
69
69
  _passToClient: string[];
@@ -100,7 +100,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
100
100
  _allPageIds: string[];
101
101
  _pageRoutes: import("../../../__internal/index.js").PageRoutes;
102
102
  _onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
103
- _globalContext: GlobalContextInternal;
103
+ _globalContext: GlobalContext;
104
104
  /** @experimental This is a beta feature https://vike.dev/getGlobalContext */
105
105
  globalContext: import("../globalContext.js").GlobalContextPublic;
106
106
  _pageContextInit: {
@@ -117,7 +117,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
117
117
  url: string;
118
118
  } & {
119
119
  headers: Record<string, string> | null;
120
- } & import("../../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
120
+ } & import("../../../shared/getPageFiles.js").PageConfigUserFriendly & {
121
121
  Page: unknown;
122
122
  _isHtmlOnly: boolean;
123
123
  _passToClient: string[];
@@ -137,7 +137,7 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
137
137
  _urlHandler: null;
138
138
  };
139
139
  }>;
140
- declare function prerender404Page(pageContextInit_: Record<string, unknown> | null, globalContext: GlobalContextInternal): Promise<{
140
+ declare function prerender404Page(pageContextInit_: Record<string, unknown> | null, globalContext: GlobalContext): Promise<{
141
141
  documentHtml: string;
142
142
  pageContextSerialized: null;
143
143
  pageContext: {
@@ -155,7 +155,7 @@ declare function prerender404Page(pageContextInit_: Record<string, unknown> | nu
155
155
  _allPageIds: string[];
156
156
  _pageRoutes: import("../../../__internal/index.js").PageRoutes;
157
157
  _onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
158
- _globalContext: GlobalContextInternal;
158
+ _globalContext: GlobalContext;
159
159
  /** @experimental This is a beta feature https://vike.dev/getGlobalContext */
160
160
  globalContext: import("../globalContext.js").GlobalContextPublic;
161
161
  _pageContextInit: {
@@ -172,7 +172,7 @@ declare function prerender404Page(pageContextInit_: Record<string, unknown> | nu
172
172
  url: string;
173
173
  } & {
174
174
  headers: Record<string, string> | null;
175
- } & import("../../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
175
+ } & import("../../../shared/getPageFiles.js").PageConfigUserFriendly & {
176
176
  Page: unknown;
177
177
  _isHtmlOnly: boolean;
178
178
  _passToClient: string[];
@@ -209,7 +209,7 @@ declare function prerender404Page(pageContextInit_: Record<string, unknown> | nu
209
209
  _allPageIds: string[];
210
210
  _pageRoutes: import("../../../__internal/index.js").PageRoutes;
211
211
  _onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
212
- _globalContext: GlobalContextInternal;
212
+ _globalContext: GlobalContext;
213
213
  /** @experimental This is a beta feature https://vike.dev/getGlobalContext */
214
214
  globalContext: import("../globalContext.js").GlobalContextPublic;
215
215
  _pageContextInit: {
@@ -226,7 +226,7 @@ declare function prerender404Page(pageContextInit_: Record<string, unknown> | nu
226
226
  url: string;
227
227
  } & {
228
228
  headers: Record<string, string> | null;
229
- } & import("../../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
229
+ } & import("../../../shared/getPageFiles.js").PageConfigUserFriendly & {
230
230
  Page: unknown;
231
231
  _isHtmlOnly: boolean;
232
232
  _passToClient: string[];
@@ -251,7 +251,7 @@ declare function getPageContextInitEnhanced(pageContextInit: {
251
251
  urlOriginal: string;
252
252
  headersOriginal?: unknown;
253
253
  headers?: unknown;
254
- }, globalContext: GlobalContextInternal, { ssr: { urlRewrite, urlHandler, isClientSideNavigation } }?: {
254
+ }, globalContext: GlobalContext, { ssr: { urlRewrite, urlHandler, isClientSideNavigation } }?: {
255
255
  ssr?: {
256
256
  urlRewrite: null | string;
257
257
  urlHandler: null | ((url: string) => string);
@@ -272,7 +272,7 @@ declare function getPageContextInitEnhanced(pageContextInit: {
272
272
  _allPageIds: string[];
273
273
  _pageRoutes: import("../../../__internal/index.js").PageRoutes;
274
274
  _onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
275
- _globalContext: GlobalContextInternal;
275
+ _globalContext: GlobalContext;
276
276
  /** @experimental This is a beta feature https://vike.dev/getGlobalContext */
277
277
  globalContext: import("../globalContext.js").GlobalContextPublic;
278
278
  _pageContextInit: {
@@ -17,6 +17,7 @@ import { preparePageContextForUserConsumptionServerSide } from './preparePageCon
17
17
  import { executeGuardHook } from '../../../shared/route/executeGuardHook.js';
18
18
  import pc from '@brillout/picocolors';
19
19
  import { isServerSideError } from '../../../shared/misc/isServerSideError.js';
20
+ import { resolveBaseRuntime } from '../../shared/resolveBase.js';
20
21
  async function renderPageAlreadyRouted(pageContext) {
21
22
  // pageContext.pageId can either be the:
22
23
  // - ID of the page matching the routing, or the
@@ -111,13 +112,14 @@ async function getPageContextInitEnhanced(pageContextInit, globalContext, { ssr:
111
112
  isClientSideNavigation: false
112
113
  } } = {}) {
113
114
  assert(pageContextInit.urlOriginal);
115
+ const { baseServer, baseAssets } = resolveBaseRuntime(globalContext);
114
116
  const pageContextInitEnhanced = {};
115
117
  objectAssign(pageContextInitEnhanced, pageContextInit);
116
118
  objectAssign(pageContextInitEnhanced, {
117
119
  _objectCreatedByVike: true,
118
120
  // The following is defined on `pageContext` because we can eventually make these non-global
119
- _baseServer: globalContext.baseServer,
120
- _baseAssets: globalContext.baseAssets,
121
+ _baseServer: baseServer,
122
+ _baseAssets: baseAssets,
121
123
  // TODO/now: add meta.default
122
124
  _includeAssetsImportedByServer: globalContext.config.includeAssetsImportedByServer ?? true,
123
125
  // TODO/soon: use GloablContext instead
@@ -18,6 +18,7 @@ import { getErrorPageId } from '../../shared/error-page.js';
18
18
  import { handleErrorWithoutErrorPage } from './renderPage/handleErrorWithoutErrorPage.js';
19
19
  import { loadUserFilesServerSide } from './renderPage/loadUserFilesServerSide.js';
20
20
  import { resolveRedirects } from './renderPage/resolveRedirects.js';
21
+ import { resolveBaseRuntime } from '../shared/resolveBase.js';
21
22
  const globalObject = getGlobalObject('runtime/renderPage.ts', {
22
23
  httpRequestsCount: 0
23
24
  });
@@ -336,6 +337,7 @@ function assertIsNotViteRequest(urlPathname, urlOriginal) {
336
337
  assertUsage(false, `${pc.code('renderPage(pageContextInit)')} called with ${pc.code(`pageContextInit.urlOriginal===${JSON.stringify(urlOriginal)}`)} which is unexpected because the URL ${pc.bold(urlOriginal)} should have already been handled by the development middleware: make sure the ${pc.cyan('createDevMiddleware()')} middleware is executed *before* the ${pc.cyan('renderPage()')} middleware, see ${pc.underline('https://vike.dev/renderPage')}`);
337
338
  }
338
339
  async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
340
+ const { baseServer } = resolveBaseRuntime(globalContext);
339
341
  const { trailingSlash, disableUrlNormalization } = globalContext.config;
340
342
  if (disableUrlNormalization)
341
343
  return null;
@@ -343,7 +345,7 @@ async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
343
345
  const { isPageContextRequest } = handlePageContextRequestUrl(urlOriginal);
344
346
  if (isPageContextRequest)
345
347
  return null;
346
- const urlNormalized = normalizeUrlPathname(urlOriginal, trailingSlash ?? false, globalContext.baseServer);
348
+ const urlNormalized = normalizeUrlPathname(urlOriginal, trailingSlash ?? false, baseServer);
347
349
  if (!urlNormalized)
348
350
  return null;
349
351
  logRuntimeInfo?.(`URL normalized from ${pc.cyan(urlOriginal)} to ${pc.cyan(urlNormalized)} (https://vike.dev/url-normalization)`, httpRequestId, 'info');
@@ -353,7 +355,8 @@ async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
353
355
  return pageContextHttpResponse;
354
356
  }
355
357
  async function getPermanentRedirect(pageContextInit, globalContext, httpRequestId) {
356
- const urlWithoutBase = removeBaseServer(pageContextInit.urlOriginal, globalContext.baseServer);
358
+ const { baseServer } = resolveBaseRuntime(globalContext);
359
+ const urlWithoutBase = removeBaseServer(pageContextInit.urlOriginal, baseServer);
357
360
  let origin = null;
358
361
  let urlTargetExternal = null;
359
362
  let urlTarget = modifyUrlPathname(urlWithoutBase, (urlPathname) => {
@@ -384,8 +387,9 @@ async function getPermanentRedirect(pageContextInit, globalContext, httpRequestI
384
387
  }
385
388
  if (normalize(urlTarget) === normalize(urlWithoutBase))
386
389
  return null;
390
+ const { baseServer } = resolveBaseRuntime(globalContext);
387
391
  if (!originChanged)
388
- urlTarget = prependBase(urlTarget, globalContext.baseServer);
392
+ urlTarget = prependBase(urlTarget, baseServer);
389
393
  assert(urlTarget !== pageContextInit.urlOriginal);
390
394
  }
391
395
  logRuntimeInfo?.(`Permanent redirection defined by config.redirects (https://vike.dev/redirects)`, httpRequestId, 'info');
@@ -449,7 +453,7 @@ pageContextNominalPageInit, httpRequestId, pageContextErrorPageInit, globalConte
449
453
  return { pageContextAbort };
450
454
  }
451
455
  async function assertBaseUrl(pageContextInit, globalContext) {
452
- const { baseServer } = globalContext;
456
+ const { baseServer } = resolveBaseRuntime(globalContext);
453
457
  const { urlOriginal } = pageContextInit;
454
458
  const { urlWithoutPageContextRequestSuffix } = handlePageContextRequestUrl(urlOriginal);
455
459
  const { hasBaseServer } = parseUrl(urlWithoutPageContextRequestSuffix, baseServer);
@@ -1,7 +1,15 @@
1
1
  export { resolveBase };
2
- export type { BaseUrlsResolved };
2
+ export { resolveBaseRuntime };
3
+ export { resolveBaseFromResolvedConfig };
4
+ import type { ResolvedConfig } from 'vite';
5
+ import type { GlobalContext } from '../runtime/globalContext.js';
6
+ declare function resolveBaseFromResolvedConfig(baseServer: string | null, baseAssets: string | null, config: ResolvedConfig): {
7
+ baseServer: string;
8
+ baseAssets: string;
9
+ };
3
10
  type BaseUrlsResolved = {
4
11
  baseServer: string;
5
12
  baseAssets: string;
6
13
  };
14
+ declare function resolveBaseRuntime(globalContext: GlobalContext): BaseUrlsResolved;
7
15
  declare function resolveBase(baseViteOriginal: string | null, baseServerUnresolved: string | null, baseAssetsUnresolved: string | null): BaseUrlsResolved;
@@ -1,6 +1,19 @@
1
1
  export { resolveBase };
2
+ export { resolveBaseRuntime };
3
+ export { resolveBaseFromResolvedConfig };
2
4
  import { assert, assertUsage, isBaseServer, isBaseAssets } from './utils.js';
3
5
  import pc from '@brillout/picocolors';
6
+ function resolveBaseFromResolvedConfig(baseServer, baseAssets, config) {
7
+ let baseViteOriginal = config._baseViteOriginal;
8
+ assert(baseViteOriginal === null || typeof baseViteOriginal == 'string');
9
+ return resolveBase(baseViteOriginal, baseServer, baseAssets);
10
+ }
11
+ function resolveBaseRuntime(globalContext) {
12
+ const baseViteOriginal = globalContext.viteConfigRuntime._baseViteOriginal;
13
+ const baseServerUnresolved = globalContext.config.baseServer ?? null;
14
+ const baseAssetsUnresolved = globalContext.config.baseAssets ?? null;
15
+ return resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
16
+ }
4
17
  function resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved) {
5
18
  if (baseViteOriginal === '/__UNSET__')
6
19
  baseViteOriginal = null;
@@ -1,14 +1,14 @@
1
1
  export { getPageConfigsRuntime };
2
2
  export { getAllPageIds };
3
3
  import type { PageFile } from './getPageFiles.js';
4
- import { type PageConfigUserFriendly, type PageConfigsUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
4
+ import { type ConfigUserFriendly, type PageConfigsUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
5
5
  import type { PageConfigGlobalRuntime, PageConfigRuntime } from './page-configs/PageConfig.js';
6
6
  declare function getPageConfigsRuntime(virtualFileExports: unknown): {
7
7
  pageFilesAll: PageFile[];
8
8
  allPageIds: string[];
9
9
  pageConfigs: PageConfigRuntime[];
10
10
  pageConfigGlobal: PageConfigGlobalRuntime;
11
- globalConfig: PageConfigUserFriendly;
11
+ globalConfig: ConfigUserFriendly;
12
12
  pageConfigsUserFriendly: PageConfigsUserFriendly;
13
13
  };
14
14
  declare function getAllPageIds(pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[]): string[];
@@ -1,15 +1,21 @@
1
1
  export { getPageConfigsRuntime };
2
2
  export { getAllPageIds };
3
3
  import { parseGlobResults } from './getPageFiles/parseGlobResults.js';
4
- import { getPageConfigGlobalUserFriendly, getPageConfigUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
4
+ import { getPageConfigUserFriendlyNew } from './page-configs/getPageConfigUserFriendly.js';
5
5
  import { unique } from './utils.js';
6
6
  function getPageConfigsRuntime(virtualFileExports) {
7
7
  const { pageFilesAll, pageConfigs, pageConfigGlobal } = parseGlobResults(virtualFileExports);
8
8
  const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
9
9
  // TODO/now: re-use this call, instead of calling it twice
10
- const globalConfig = getPageConfigGlobalUserFriendly({ pageConfigGlobalValues: pageConfigGlobal.configValues });
10
+ const globalConfig = getPageConfigUserFriendlyNew(pageConfigGlobal);
11
+ // TODO/now DEDUPE
11
12
  const pageConfigsUserFriendly = Object.fromEntries(pageConfigs.map((pageConfig) => {
12
- return getPageConfigUserFriendly(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
13
+ const configValues = { ...pageConfigGlobal.configValues, ...pageConfig.configValues };
14
+ const page = {
15
+ ...getPageConfigUserFriendlyNew({ configValues }),
16
+ route: pageConfig.routeFilesystem?.routeString ?? null
17
+ };
18
+ return [pageConfig.pageId, page];
13
19
  }));
14
20
  return { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig, pageConfigsUserFriendly };
15
21
  }
@@ -1,4 +1,4 @@
1
1
  export type { PageFile } from './getPageFiles/getPageFileObject.js';
2
- export type { ExportsAll, PageConfigUserFriendlyOld } from './page-configs/getPageConfigUserFriendly.js';
2
+ export type { ExportsAll, PageConfigUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
3
3
  export { getPageFilesClientSide } from './getPageFiles/getAllPageIdFiles.js';
4
4
  export { getPageFilesServerSide } from './getPageFiles/getAllPageIdFiles.js';