vike 0.4.228-commit-0e9e0f2 → 0.4.228-commit-1bb55f1

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 (60) hide show
  1. package/dist/cjs/__internal/index.js +1 -1
  2. package/dist/cjs/client/client-routing-runtime/globalContext.js +4 -4
  3. package/dist/cjs/client/server-routing-runtime/globalContext.js +4 -4
  4. package/dist/cjs/client/shared/{createGetGlobalContext.js → createGetGlobalContextClient.js} +23 -3
  5. package/dist/cjs/client/shared/utils.js +1 -0
  6. package/dist/cjs/node/plugin/plugins/commonConfig.js +5 -2
  7. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +0 -1
  8. package/dist/cjs/node/prerender/runPrerender.js +1 -1
  9. package/dist/cjs/node/runtime/globalContext.js +6 -5
  10. package/dist/cjs/node/runtime/index-deprecated.js +9 -38
  11. package/dist/cjs/node/runtime/index.js +56 -2
  12. package/dist/cjs/node/runtime/renderPage.js +1 -1
  13. package/dist/cjs/shared/createGlobalContextShared.js +3 -0
  14. package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
  15. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  16. package/dist/esm/__internal/index.js +2 -2
  17. package/dist/esm/client/client-routing-runtime/createPageContext.js +2 -2
  18. package/dist/esm/client/client-routing-runtime/globalContext.d.ts +3 -3
  19. package/dist/esm/client/client-routing-runtime/globalContext.js +3 -3
  20. package/dist/esm/client/index.d.ts +1 -0
  21. package/dist/esm/client/index.js +4 -0
  22. package/dist/esm/client/node.js +1 -3
  23. package/dist/esm/client/server-routing-runtime/createPageContextClientSide.js +2 -2
  24. package/dist/esm/client/server-routing-runtime/globalContext.d.ts +4 -3
  25. package/dist/esm/client/server-routing-runtime/globalContext.js +3 -3
  26. package/dist/esm/client/shared/{createGetGlobalContext.d.ts → createGetGlobalContextClient.d.ts} +6 -2
  27. package/dist/esm/client/shared/{createGetGlobalContext.js → createGetGlobalContextClient.js} +27 -5
  28. package/dist/esm/client/shared/utils.d.ts +1 -0
  29. package/dist/esm/client/shared/utils.js +1 -0
  30. package/dist/esm/node/plugin/plugins/commonConfig.js +5 -2
  31. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +0 -1
  32. package/dist/esm/node/prerender/runPrerender.d.ts +2 -2
  33. package/dist/esm/node/prerender/runPrerender.js +2 -2
  34. package/dist/esm/node/runtime/globalContext.d.ts +7 -6
  35. package/dist/esm/node/runtime/globalContext.js +7 -6
  36. package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
  37. package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
  38. package/dist/esm/node/runtime/index-deprecated.d.ts +1 -16
  39. package/dist/esm/node/runtime/index-deprecated.js +9 -36
  40. package/dist/esm/node/runtime/index.d.ts +23 -1
  41. package/dist/esm/node/runtime/index.js +38 -3
  42. package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
  43. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +2 -2
  44. package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
  45. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
  46. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -2
  47. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  48. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
  49. package/dist/esm/node/runtime/renderPage.d.ts +2 -2
  50. package/dist/esm/node/runtime/renderPage.js +2 -2
  51. package/dist/esm/shared/createGlobalContextShared.d.ts +2 -0
  52. package/dist/esm/shared/createGlobalContextShared.js +2 -0
  53. package/dist/esm/shared/route/loadPageRoutes.js +1 -1
  54. package/dist/esm/shared/types.d.ts +29 -12
  55. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  56. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  57. package/package.json +10 -9
  58. package/dist/cjs/node/runtime/index-common.js +0 -27
  59. package/dist/esm/node/runtime/index-common.d.ts +0 -8
  60. package/dist/esm/node/runtime/index-common.js +0 -10
@@ -1,7 +1,7 @@
1
1
  export { getGlobalContext };
2
2
  export { getGlobalContextSync };
3
3
  export { getGlobalContextAsync };
4
- export { getGlobalContextInternal };
4
+ export { getGlobalContextServerInternal };
5
5
  export { getViteDevServer };
6
6
  export { getViteConfig };
7
7
  export { initGlobalContext_renderPage };
@@ -16,14 +16,15 @@ export { clearGlobalContext };
16
16
  export { assertBuildInfo };
17
17
  export { updateUserFiles };
18
18
  export type { BuildInfo };
19
- export type { GlobalContextServerInternal as GlobalContextInternal };
19
+ export type { GlobalContextServerInternal as GlobalContextServerInternal };
20
20
  export type { GlobalContextServer };
21
21
  import type { ViteManifest } from '../shared/ViteManifest.js';
22
22
  import type { ResolvedConfig, ViteDevServer } from 'vite';
23
23
  import type { ViteConfigRuntime } from '../plugin/shared/getViteConfigRuntime.js';
24
+ import type { GlobalContext } from '../../shared/types.js';
24
25
  type GlobalContextServer = ReturnType<typeof makePublic> & Vike.GlobalContext & Vike.GlobalContextServer;
25
26
  type GlobalContextServerInternal = Awaited<ReturnType<typeof setGlobalContext>>;
26
- declare function getGlobalContextInternal(): Promise<{
27
+ declare function getGlobalContextServerInternal(): Promise<{
27
28
  globalContext: (Record<string, unknown> & {
28
29
  isGlobalContext: true;
29
30
  _virtualFileExports: unknown;
@@ -246,13 +247,13 @@ declare function getGlobalContextInternal(): Promise<{
246
247
  *
247
248
  * https://vike.dev/getGlobalContext
248
249
  */
249
- declare function getGlobalContext(): Promise<GlobalContextServer>;
250
+ declare function getGlobalContext(): Promise<GlobalContext>;
250
251
  /**
251
252
  * Get runtime information about your app.
252
253
  *
253
254
  * https://vike.dev/getGlobalContext
254
255
  */
255
- declare function getGlobalContextAsync(isProduction: boolean): Promise<GlobalContextServer>;
256
+ declare function getGlobalContextAsync(isProduction: boolean): Promise<GlobalContext>;
256
257
  /**
257
258
  * Get runtime information about your app.
258
259
  *
@@ -260,7 +261,7 @@ declare function getGlobalContextAsync(isProduction: boolean): Promise<GlobalCon
260
261
  *
261
262
  * @deprecated
262
263
  */
263
- declare function getGlobalContextSync(): GlobalContextServer;
264
+ declare function getGlobalContextSync(): GlobalContext;
264
265
  declare function makePublic(globalContext: GlobalContextServerInternal): Pick<{
265
266
  isGlobalContext: true;
266
267
  _virtualFileExports: unknown;
@@ -3,7 +3,7 @@ export { getGlobalContext };
3
3
  export { getGlobalContextSync };
4
4
  export { getGlobalContextAsync };
5
5
  // Internal use
6
- export { getGlobalContextInternal };
6
+ export { getGlobalContextServerInternal };
7
7
  export { getViteDevServer };
8
8
  export { getViteConfig };
9
9
  export { initGlobalContext_renderPage };
@@ -32,14 +32,14 @@ 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 { resolveBase } from '../shared/resolveBase.js';
35
- import { createGlobalContextShared } from '../../shared/createGlobalContextShared.js';
35
+ import { createGlobalContextShared, getGlobalContextSyncErrMsg } from '../../shared/createGlobalContextShared.js';
36
36
  const debug = createDebugger('vike:globalContext');
37
37
  const globalObject = getGlobalObject('runtime/globalContext.ts', getInitialGlobalContext());
38
38
  // Trick to break down TypeScript circular dependency
39
39
  // https://chat.deepseek.com/a/chat/s/d7e9f90a-c7f3-4108-9cd5-4ad6caed3539
40
40
  const globalObjectTyped = globalObject;
41
- async function getGlobalContextInternal() {
42
- // getGlobalContextInternal() should always be called after initGlobalContext()
41
+ async function getGlobalContextServerInternal() {
42
+ // getGlobalContextServerInternal() should always be called after initGlobalContext()
43
43
  assert(globalObject.isInitialized);
44
44
  assertGlobalContextIsDefined();
45
45
  if (globalObject.isProduction !== true)
@@ -61,6 +61,7 @@ function assertGlobalContextIsDefined() {
61
61
  assert(globalObject.globalContext);
62
62
  assert(globalObject.globalContext_public);
63
63
  }
64
+ // We purposely return GlobalContext instead of GlobalContextServer because `import { getGlobalContext } from 'vike'` can resolve to the client-side implementation.
64
65
  /**
65
66
  * Get runtime information about your app.
66
67
  *
@@ -102,9 +103,9 @@ async function getGlobalContextAsync(isProduction) {
102
103
  function getGlobalContextSync() {
103
104
  debug('getGlobalContextSync()');
104
105
  const { globalContext_public } = globalObjectTyped;
105
- assertUsage(globalContext_public, "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.");
106
+ assertUsage(globalContext_public, getGlobalContextSyncErrMsg);
106
107
  assertWarning(false,
107
- // We discourage users from using it because using `pageContext.globalContext` is better: it doesn't have the race condition issue that `getGlobalContextSync()` would have when called inside React/Vue components.
108
+ // We discourage users from using it because `pageContext.globalContext` is safer: I ain't sure but there could be race conditions when using `getGlobalContextSync()` inside React/Vue components upon HMR.
108
109
  // We're lying about "is going to be deprecated in the next major release": let's keep it and see if users need it (so far I can't see a use case for it).
109
110
  'getGlobalContextSync() is going to be deprecated in the next major release, see https://vike.dev/getGlobalContext', { onlyOnce: true });
110
111
  return globalContext_public;
@@ -1,5 +1,5 @@
1
1
  export { getViteDevScript };
2
- import type { GlobalContextInternal } from '../../globalContext.js';
2
+ import type { GlobalContextServerInternal } from '../../globalContext.js';
3
3
  declare function getViteDevScript(pageContext: {
4
- _globalContext: GlobalContextInternal;
4
+ _globalContext: GlobalContextServerInternal;
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 './serializeContext.js';
11
- import type { GlobalContextInternal } from '../globalContext.js';
11
+ import type { GlobalContextServerInternal } 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: GlobalContextServerInternal;
26
26
  } & PageContextSerialization;
27
27
  declare function injectHtmlTagsToString(htmlParts: HtmlPart[], pageContext: PageContextInjectAssets & {
28
28
  _isStream: false;
@@ -1,16 +1 @@
1
- export * from './index-common.js';
2
- export * from '../../types/index-dreprecated.js';
3
- import { RenderErrorPage as RenderErrorPage_ } from '../../shared/route/abort.js';
4
- /** @deprecated
5
- * Replace:
6
- * ```
7
- * import { RenderErrorPage } from 'vike'
8
- * ```
9
- * With:
10
- * ```
11
- * import { render } from 'vike/abort'
12
- * ```
13
- *
14
- * See https://vike.dev/render
15
- */
16
- export declare const RenderErrorPage: (...args: Parameters<typeof RenderErrorPage_>) => Error;
1
+ export * from './index.js';
@@ -1,41 +1,14 @@
1
- // TODO/v1-release: replace this with:
2
- // assertUsage(false, "`import { something } from 'vike'` doesn't exist: instead import from 'vike/server', 'vike/client', 'vike/plugin', ...")
3
- import { isBrowser } from '../../utils/isBrowser.js';
4
- import { assertUsage } from '../../utils/assert.js';
5
- assertUsage(!isBrowser(), "It's forbidden to `import { something } from 'vike'` on the client-side: the module 'vike' is a server-only module.", { showStackTrace: true });
6
- export * from './index-common.js';
7
- export * from '../../types/index-dreprecated.js';
1
+ // TODO/soon: point package.json#exports['./server'] to this file.
2
+ // - Write migration guide, see comment below.
3
+ export * from './index.js';
8
4
  import { assertWarning } from './utils.js';
9
5
  import pc from '@brillout/picocolors';
10
- import { RenderErrorPage as RenderErrorPage_ } from '../../shared/route/abort.js';
11
- /** @deprecated
12
- * Replace:
13
- * ```
14
- * import { RenderErrorPage } from 'vike'
15
- * ```
16
- * With:
17
- * ```
18
- * import { render } from 'vike/abort'
19
- * ```
20
- *
21
- * See https://vike.dev/render
22
- */
23
- export const RenderErrorPage = (...args) => {
24
- assertWarning(false, [
25
- 'Replace:',
26
- pc.red(" import { RenderErrorPage } from 'vike'"),
27
- 'With:',
28
- pc.green(" import { render } from 'vike/abort'"),
29
- 'See https://vike.dev/render'
30
- ].join('\n'), { onlyOnce: true, showStackTrace: true });
31
- return RenderErrorPage_(...args);
32
- };
33
6
  assertWarning(false, [
34
- 'You have following imports which are outdated:',
35
- pc.red(" import { something } from 'vike'"),
7
+ 'You have outdated imports:',
8
+ pc.bold(pc.red(" import { something } from 'vike/server'")),
36
9
  'Replace them with:',
37
- pc.green(" import { something } from 'vike/server'"),
38
- `Or if ${pc.cyan('something')} is a type:`,
39
- pc.green(" import type { something } from 'vike/types'"),
40
- "Make sure to import renderPage(), escapeInject, html, dangerouslySkipEscape(), pipeWebStream(), pipeNodeStream(), pipeStream(), stampPipe() from 'vike/server'. (Or inspect the error stack below to find the import causing this warning.)"
10
+ pc.bold(pc.green(" import { something } from 'vike'"))
11
+ /* Add migration guide, with migration scritps such as `$ rename vike/server vike`
12
+ `See ${pc.underline('https://vike.dev/migration/0.4.xxx')}`
13
+ */
41
14
  ].join('\n'), { showStackTrace: true, onlyOnce: true });
@@ -1 +1,23 @@
1
- export * from './index-common.js';
1
+ export { renderPage } from './renderPage.js';
2
+ export { escapeInject, dangerouslySkipEscape } from './html/renderHtml.js';
3
+ export { pipeWebStream, pipeNodeStream, pipeStream, stampPipe } from './html/stream.js';
4
+ export { PROJECT_VERSION as version } from './utils.js';
5
+ export { getGlobalContext, getGlobalContextSync, getGlobalContextAsync } from './globalContext.js';
6
+ export { createDevMiddleware } from '../runtime-dev/index.js';
7
+ export * from '../../types/index-dreprecated.js';
8
+ export { injectAssets__public as _injectAssets } from './html/injectAssets/injectAssets__public.js';
9
+ export { createPageRenderer } from '../createPageRenderer.js';
10
+ import { RenderErrorPage as RenderErrorPage_ } from '../../shared/route/abort.js';
11
+ /** @deprecated
12
+ * Replace:
13
+ * ```
14
+ * import { RenderErrorPage } from 'vike'
15
+ * ```
16
+ * With:
17
+ * ```
18
+ * import { render } from 'vike/abort'
19
+ * ```
20
+ *
21
+ * See https://vike.dev/render
22
+ */
23
+ export declare const RenderErrorPage: (...args: Parameters<typeof RenderErrorPage_>) => Error;
@@ -1,4 +1,39 @@
1
1
  import { isBrowser } from '../../utils/isBrowser.js';
2
- import { assertUsage } from '../../utils/assert.js';
3
- assertUsage(!isBrowser(), "It's forbidden to `import { something } from 'vike/server'` on the client-side: the module 'vike/server' is a server-only module.", { showStackTrace: true });
4
- export * from './index-common.js';
2
+ import { assert } from '../../utils/assert.js';
3
+ assert(!isBrowser());
4
+ export { renderPage } from './renderPage.js';
5
+ export { escapeInject, dangerouslySkipEscape } from './html/renderHtml.js';
6
+ export { pipeWebStream, pipeNodeStream, pipeStream, stampPipe } from './html/stream.js';
7
+ export { PROJECT_VERSION as version } from './utils.js';
8
+ export { getGlobalContext, getGlobalContextSync, getGlobalContextAsync } from './globalContext.js';
9
+ export { createDevMiddleware } from '../runtime-dev/index.js';
10
+ // TODO/v1-release: remove
11
+ // Deprecated exports
12
+ export * from '../../types/index-dreprecated.js';
13
+ export { injectAssets__public as _injectAssets } from './html/injectAssets/injectAssets__public.js';
14
+ export { createPageRenderer } from '../createPageRenderer.js';
15
+ import { assertWarning } from './utils.js';
16
+ import pc from '@brillout/picocolors';
17
+ import { RenderErrorPage as RenderErrorPage_ } from '../../shared/route/abort.js';
18
+ /** @deprecated
19
+ * Replace:
20
+ * ```
21
+ * import { RenderErrorPage } from 'vike'
22
+ * ```
23
+ * With:
24
+ * ```
25
+ * import { render } from 'vike/abort'
26
+ * ```
27
+ *
28
+ * See https://vike.dev/render
29
+ */
30
+ export const RenderErrorPage = (...args) => {
31
+ assertWarning(false, [
32
+ 'Replace:',
33
+ pc.red(" import { RenderErrorPage } from 'vike'"),
34
+ 'With:',
35
+ pc.green(" import { render } from 'vike/abort'"),
36
+ 'See https://vike.dev/render'
37
+ ].join('\n'), { onlyOnce: true, showStackTrace: true });
38
+ return RenderErrorPage_(...args);
39
+ };
@@ -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 { GlobalContextServerInternal } from '../globalContext.js';
6
+ declare function analyzePage(pageFilesAll: PageFile[], pageConfig: null | PageConfigRuntime, pageId: string, globalContext: GlobalContextServerInternal): Promise<AnalysisResult>;
@@ -1,10 +1,10 @@
1
1
  export { createPageContextServerSide };
2
2
  export { createPageContextServerSideWithoutGlobalContext };
3
3
  export type { PageContextCreatedServerSide };
4
- import type { GlobalContextInternal, GlobalContextServer } from '../globalContext.js';
4
+ import type { GlobalContextServerInternal, GlobalContextServer } from '../globalContext.js';
5
5
  import type { PageContextInit } from '../renderPage.js';
6
6
  type PageContextCreatedServerSide = Awaited<ReturnType<typeof createPageContextServerSide>>;
7
- declare function createPageContextServerSide(pageContextInit: PageContextInit, globalContext: GlobalContextInternal, globalObject_public: GlobalContextServer, { isPrerendering, ssr: { urlHandler, isClientSideNavigation } }: {
7
+ declare function createPageContextServerSide(pageContextInit: PageContextInit, globalContext: GlobalContextServerInternal, globalObject_public: GlobalContextServer, { isPrerendering, ssr: { urlHandler, isClientSideNavigation } }: {
8
8
  isPrerendering: false;
9
9
  ssr: {
10
10
  urlHandler: null | ((url: string) => string);
@@ -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 { GlobalContextServerInternal } 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: GlobalContextServerInternal;
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 { GlobalContextServerInternal } 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: GlobalContextServerInternal;
14
14
  urlOriginal: string;
15
15
  }>(pageContext: PageContext): Promise<PageContext & PageContextAfterRender>;
@@ -6,12 +6,12 @@ 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 { GlobalContextServerInternal } 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: GlobalContextServerInternal;
15
15
  };
16
16
  type PageFiles = PromiseType<ReturnType<typeof loadUserFilesServerSide>>;
17
17
  declare function loadUserFilesServerSide(pageContext: {
@@ -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 { GlobalContextServerInternal } 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: GlobalContextServerInternal;
11
11
  }): Promise<void>;
12
12
  declare function getRoutesInfo(pageRoutes: PageRoutes): string | null;
@@ -4,7 +4,7 @@ import { PageContextUrlInternal } from '../../../shared/getPageContextUrlCompute
4
4
  import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
5
5
  import type { PageConfigUserFriendlyOld } from '../../../shared/page-configs/getPageConfigUserFriendly.js';
6
6
  import { PageContextBuiltInServerInternal } from '../../../shared/types.js';
7
- import type { GlobalContextInternal, GlobalContextServer } from '../globalContext.js';
7
+ import type { GlobalContextServerInternal, GlobalContextServer } from '../globalContext.js';
8
8
  type PageContextForUserConsumptionServerSide = PageContextBuiltInServerInternal & PageConfigUserFriendlyOld & {
9
9
  urlOriginal: string;
10
10
  /** @deprecated */
@@ -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: GlobalContextServerInternal;
22
22
  globalContext: GlobalContextServer;
23
23
  } & Record<string, unknown>;
24
24
  declare function preparePageContextForUserConsumptionServerSide(pageContext: PageContextForUserConsumptionServerSide): void;
@@ -2,7 +2,7 @@ export { renderPage };
2
2
  export { renderPage_addAsyncHookwrapper };
3
3
  export type { PageContextInit };
4
4
  export type { PageContextBegin };
5
- import { type GlobalContextServer, type GlobalContextInternal } from './globalContext.js';
5
+ import { type GlobalContextServer, type GlobalContextServerInternal } from './globalContext.js';
6
6
  import { type HttpResponse } from './renderPage/createHttpResponse.js';
7
7
  import type { PageContextServer } from '../../types/index.js';
8
8
  import type { PageContextBuiltInServerInternal } from '../../shared/types.js';
@@ -18,7 +18,7 @@ declare let asyncHookWrapper: <PageContext>(_httpRequestId: number, ret: () => P
18
18
  pageContextReturn: Awaited<PageContext>;
19
19
  }>;
20
20
  declare function renderPage_addAsyncHookwrapper(wrapper: typeof asyncHookWrapper): void;
21
- declare function getPageContextBegin(pageContextInit: PageContextInit, globalContext: GlobalContextInternal, globalContext_public: GlobalContextServer, httpRequestId: number): Promise<{
21
+ declare function getPageContextBegin(pageContextInit: PageContextInit, globalContext: GlobalContextServerInternal, globalContext_public: GlobalContextServer, httpRequestId: number): Promise<{
22
22
  isClientSide: boolean;
23
23
  isPrerendering: boolean;
24
24
  } & Pick<PageContextBuiltInServerInternal, "urlOriginal" | "headersOriginal"> & {
@@ -5,7 +5,7 @@ import { createPageContextServerSide, createPageContextServerSideWithoutGlobalCo
5
5
  import { route } from '../../shared/route/index.js';
6
6
  import { assert, hasProp, objectAssign, isUrl, parseUrl, onSetupRuntime, assertWarning, getGlobalObject, checkType, assertUsage, normalizeUrlPathname, removeBaseServer, modifyUrlPathname, prependBase, removeUrlOrigin, setUrlOrigin, isUri, getUrlPretty } from './utils.js';
7
7
  import { assertNoInfiniteAbortLoop, getPageContextFromAllRewrites, isAbortError, logAbortErrorHandled } from '../../shared/route/abort.js';
8
- import { getGlobalContextInternal, initGlobalContext_renderPage } from './globalContext.js';
8
+ import { getGlobalContextServerInternal, initGlobalContext_renderPage } from './globalContext.js';
9
9
  import { handlePageContextRequestUrl } from './renderPage/handlePageContextRequestUrl.js';
10
10
  import { createHttpResponseFavicon404, createHttpResponseRedirect, createHttpResponsePageContextJson, createHttpResponseError, createHttpResponseErrorWithoutGlobalContext, createHttpResponseBaseIsMissing } from './renderPage/createHttpResponse.js';
11
11
  import { logRuntimeError, logRuntimeInfo } from './renderPage/loggerRuntime.js';
@@ -76,7 +76,7 @@ async function renderPagePrepare(pageContextInit, httpRequestId) {
76
76
  else {
77
77
  // `globalContext` now contains the entire Vike config and getVikeConfig() isn't called anymore for this request.
78
78
  }
79
- const { globalContext, globalContext_public } = await getGlobalContextInternal();
79
+ const { globalContext, globalContext_public } = await getGlobalContextServerInternal();
80
80
  const pageContextBegin = await getPageContextBegin(pageContextInit, globalContext, globalContext_public, httpRequestId);
81
81
  // Check Base URL
82
82
  {
@@ -1,6 +1,8 @@
1
1
  export { createGlobalContextShared };
2
+ export { getGlobalContextSyncErrMsg };
2
3
  export type { GlobalContextShared };
3
4
  export type { GlobalContextSharedPublic };
5
+ declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
4
6
  declare function createGlobalContextShared<GlobalContextAddendum extends object>(virtualFileExports: unknown, globalObject: {
5
7
  globalContext?: Record<string, unknown>;
6
8
  }, addGlobalContext?: (globalContext: GlobalContextShared) => Promise<GlobalContextAddendum>): Promise<{
@@ -1,4 +1,6 @@
1
1
  export { createGlobalContextShared };
2
+ export { getGlobalContextSyncErrMsg };
3
+ const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
2
4
  import { getPageConfigsRuntime } from './getPageConfigsRuntime.js';
3
5
  import { executeHookGenericGlobalCumulative } from './hooks/executeHookGeneric.js';
4
6
  import { objectAssign } from './utils.js';
@@ -8,7 +8,7 @@ import { getDefinedAtString } from '../page-configs/getConfigDefinedAt.js';
8
8
  import { warnDeprecatedAllowKey } from './resolveRouteFunction.js';
9
9
  import { getHookFromPageConfigGlobal, getHookTimeoutDefault } from '../hooks/getHook.js';
10
10
  async function loadPageRoutes(
11
- // Remove all arguments and use GlobalContextInternal instead?
11
+ // Remove all arguments and use GlobalContextServerInternal instead?
12
12
  pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds) {
13
13
  // TODO/next-major: remove & make this function sync
14
14
  await Promise.all(pageFilesAll.filter((p) => p.fileType === '.page.route').map((p) => p.loadFile?.()));
@@ -35,21 +35,25 @@ type PageContextBuiltInCommon<Data> = {
35
35
  /** The `export { Page }` of your `.page.js` file.
36
36
  *
37
37
  * https://vike.dev/Page
38
+ * https://vike.dev/pageContext#Page
38
39
  */
39
40
  Page: Config['Page'];
40
41
  /** Route Parameters, e.g. `pageContext.routeParams.productId` for a Route String `/product/@productId`.
41
42
  *
42
43
  * https://vike.dev/route-string
44
+ * https://vike.dev/pageContext#routeParams
43
45
  */
44
46
  routeParams: Record<string, string>;
45
47
  /** The page's data which was fetched using the data() hook.
46
48
  *
47
49
  * https://vike.dev/data
50
+ * https://vike.dev/pageContext#data
48
51
  */
49
52
  data: Data;
50
53
  /** The page's configuration values.
51
54
  *
52
55
  * https://vike.dev/config
56
+ * https://vike.dev/pageContext#config
53
57
  */
54
58
  config: PageContextConfig;
55
59
  /** The page's configuration, including the configs origin and overriden configs.
@@ -78,9 +82,8 @@ type PageContextBuiltInCommon<Data> = {
78
82
  *
79
83
  * As a string object normalized by Vike.
80
84
  *
81
- * See also:
82
- * - https://vike.dev/headers
83
- * - `pageContext.headersOriginal`
85
+ * https://vike.dev/headers
86
+ * https://vike.dev/pageContext#headers
84
87
  */
85
88
  headers: Record<string, string> | null;
86
89
  /**
@@ -88,9 +91,8 @@ type PageContextBuiltInCommon<Data> = {
88
91
  *
89
92
  * The original object provided by the server.
90
93
  *
91
- * See also:
92
- * - https://vike.dev/headers
93
- * - `pageContext.headers`
94
+ * https://vike.dev/headers
95
+ * https://vike.dev/pageContext#headersOriginal
94
96
  */
95
97
  headersOriginal?: unknown;
96
98
  /** If an error occurs, whether the error is a `404 Page Not Found`.
@@ -101,25 +103,28 @@ type PageContextBuiltInCommon<Data> = {
101
103
  /**
102
104
  * Whether the page was navigated by the client-side router.
103
105
  *
104
- * https://vike.dev/pageContext
106
+ * https://vike.dev/pageContext#isClientSideNavigation
105
107
  */
106
108
  isClientSideNavigation: boolean;
107
109
  /**
108
110
  * The reason why the original page was aborted. Usually used for showing a custom message on the error page.
109
111
  *
110
112
  * https://vike.dev/render
113
+ * https://vike.dev/pageContext#abortReason
111
114
  */
112
115
  abortReason?: unknown;
113
116
  /**
114
117
  * The status code set by `throw render(abortStatusCode)`.
115
118
  *
116
119
  * https://vike.dev/render
120
+ * https://vike.dev/pageContext#abortStatusCode
117
121
  */
118
122
  abortStatusCode?: AbortStatusCode;
119
123
  /**
120
124
  * Error that occured while rendering.
121
125
  *
122
126
  * https://vike.dev/error-tracking
127
+ * https://vike.dev/pageContext#errorWhileRendering
123
128
  */
124
129
  errorWhileRendering?: unknown;
125
130
  /**
@@ -140,6 +145,7 @@ type PageContextBuiltInCommon<Data> = {
140
145
  * Whether the Base URL is missing in the URL of the HTTP request made to the SSR server.
141
146
  *
142
147
  * https://vike.dev/base-url#setup
148
+ * https://vike.dev/pageContext#isBaseMissing
143
149
  */
144
150
  isBaseMissing?: true;
145
151
  };
@@ -147,7 +153,9 @@ type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageConte
147
153
  /**
148
154
  * Whether the page is being rendered on the client-side or server-side / pre-rendered.
149
155
  *
150
- * We recommend using `import.meta.env.SSR` instead, see https://vike.dev/pageContext
156
+ * We recommend using `import.meta.env.SSR` instead, see https://vike.dev/pageContext#isClientSide
157
+ *
158
+ * https://vike.dev/pageContext#isClientSide
151
159
  */
152
160
  isClientSide: false;
153
161
  /**
@@ -156,13 +164,14 @@ type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageConte
156
164
  * The value is always `false` in development.
157
165
  *
158
166
  * https://vike.dev/pre-rendering
159
- * https://vike.dev/pageContext
167
+ * https://vike.dev/pageContext#isPrerendering
160
168
  */
161
169
  isPrerendering: boolean;
162
170
  /**
163
171
  * Runtime information about your app.
164
172
  *
165
173
  * https://vike.dev/getGlobalContext
174
+ * https://vike.dev/pageContext#globalContext
166
175
  */
167
176
  globalContext: GlobalContextServer;
168
177
  isHydration?: undefined;
@@ -176,12 +185,14 @@ type PageContextBuiltInClientWithClientRouting<Data> = Partial<PageContextBuiltI
176
185
  * Whether the user is navigating back in history.
177
186
  *
178
187
  * The value is `true` when the user clicks on his browser's backward navigation button, or when invoking `history.back()`.
188
+ *
189
+ * https://vike.dev/pageContext#isBackwardNavigation
179
190
  */
180
191
  isBackwardNavigation: boolean | null;
181
192
  /**
182
193
  * Upon client-side page navigation, you can use `pageContext.previousPageContext` to access the `pageContext` of the previous page.
183
194
  *
184
- * https://vike.dev/pageContext
195
+ * https://vike.dev/pageContext#previousPageContext
185
196
  */
186
197
  previousPageContext: PageContextClient<Data> | null;
187
198
  globalContext: GlobalContextClient;
@@ -191,12 +202,16 @@ type PageContextBuiltInClientWithServerRouting<Data> = Partial<PageContextBuiltI
191
202
  * Whether the current page is already rendered to HTML.
192
203
  *
193
204
  * The `isHydration` value is always `true` when using Server Routing.
205
+ *
206
+ * https://vike.dev/pageContext#isHydration
194
207
  */
195
208
  isHydration: true;
196
209
  /**
197
210
  * Whether the user is navigating back in history.
198
211
  *
199
212
  * The `isBackwardNavigation` property only works with Client Routing. (The value is always `null` when using Server Routing.)
213
+ *
214
+ * https://vike.dev/pageContext#isBackwardNavigation
200
215
  */
201
216
  isBackwardNavigation: null;
202
217
  globalContext: GlobalContextClientWithServerRouting;
@@ -205,7 +220,9 @@ type PageContextClientCommon = {
205
220
  /**
206
221
  * Whether the page is being rendered on the client-side, or rendered on the server-side / pre-rendered.
207
222
  *
208
- * In order to save client-side KBs, we recommend using `import.meta.env.SSR` whenever possible instead, see https://vike.dev/pageContext
223
+ * In order to save client-side KBs, we recommend using `import.meta.env.SSR` whenever possible instead, see https://vike.dev/pageContext#isClientSide
224
+ *
225
+ * https://vike.dev/pageContext#isClientSide
209
226
  */
210
227
  isClientSide: true;
211
228
  /**
@@ -214,7 +231,7 @@ type PageContextClientCommon = {
214
231
  * The value is always `false` in development.
215
232
  *
216
233
  * https://vike.dev/pre-rendering
217
- * https://vike.dev/pageContext
234
+ * https://vike.dev/pageContext#isPrerendering
218
235
  */
219
236
  isPrerendering: false;
220
237
  };
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.228-commit-0e9e0f2";
1
+ export declare const PROJECT_VERSION: "0.4.228-commit-1bb55f1";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.228-commit-0e9e0f2';
2
+ export const PROJECT_VERSION = '0.4.228-commit-1bb55f1';