vike 0.4.243 → 0.4.244-commit-a8703f7
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.
- package/dist/esm/client/runtime-client-routing/getGlobalContextClientInternal.d.ts +0 -3
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +149 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +4 -4
- package/dist/esm/client/runtime-server-routing/getGlobalContextClientInternal.d.ts +0 -3
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +4 -1
- package/dist/esm/node/api/preview.d.ts +3 -0
- package/dist/esm/node/api/preview.js +18 -2
- package/dist/esm/node/api/utils.d.ts +1 -0
- package/dist/esm/node/api/utils.js +1 -0
- package/dist/esm/node/runtime/globalContext.d.ts +2 -4
- package/dist/esm/node/runtime/renderPage.d.ts +283 -0
- package/dist/esm/node/vite/plugins/build/handleAssetsManifest.js +4 -3
- package/dist/esm/node/vite/plugins/build/pluginBuildApp.js +1 -1
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +4 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +5 -1
- package/dist/esm/shared/getProxyForPublicUsage.d.ts +8 -1
- package/dist/esm/shared/getProxyForPublicUsage.js +24 -24
- package/dist/esm/shared/prepareGlobalContextForPublicUsage.d.ts +4 -1
- package/dist/esm/shared/preparePageContextForPublicUsage.d.ts +4 -1
- package/dist/esm/types/Config.d.ts +7 -1
- package/dist/esm/types/GlobalContext.d.ts +18 -0
- package/dist/esm/types/GlobalContext.js +1 -0
- package/dist/esm/types/PageContext.d.ts +12 -10
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { getGlobalContextClientInternal };
|
|
2
|
-
export type { GlobalContextClient };
|
|
3
2
|
export type { GlobalContextClientInternal };
|
|
4
|
-
import type { GlobalContextBasePublic } from '../../shared/createGlobalContextShared.js';
|
|
5
|
-
type GlobalContextClient = GlobalContextBasePublic & Pick<GlobalContextClientInternal, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
6
3
|
type GlobalContextClientInternal = Awaited<ReturnType<typeof getGlobalContextClientInternal>>;
|
|
7
4
|
declare function getGlobalContextClientInternal(): Promise<{
|
|
8
5
|
_globalConfigPublic: {
|
|
@@ -145,7 +145,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
145
145
|
isHydration: boolean;
|
|
146
146
|
isBackwardNavigation: boolean | null;
|
|
147
147
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
148
|
-
globalContext: import("
|
|
148
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
149
149
|
} & {
|
|
150
150
|
urlOriginal: string;
|
|
151
151
|
} & {
|
|
@@ -210,7 +210,7 @@ declare function getPageContextFromHooks_isHydration(pageContext: PageContextSer
|
|
|
210
210
|
isHydration: boolean;
|
|
211
211
|
isBackwardNavigation: boolean | null;
|
|
212
212
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
213
|
-
globalContext: import("
|
|
213
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
214
214
|
} & {
|
|
215
215
|
urlOriginal: string;
|
|
216
216
|
} & {
|
|
@@ -366,7 +366,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
366
366
|
isHydration: boolean;
|
|
367
367
|
isBackwardNavigation: boolean | null;
|
|
368
368
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
369
|
-
globalContext: import("
|
|
369
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
370
370
|
} & {
|
|
371
371
|
urlOriginal: string;
|
|
372
372
|
} & {
|
|
@@ -429,7 +429,7 @@ declare function getPageContextFromClientHooks(pageContext: {
|
|
|
429
429
|
isHydration: boolean;
|
|
430
430
|
isBackwardNavigation: boolean | null;
|
|
431
431
|
previousPageContext: import("../../types/PageContext.js").PageContextClient<unknown> | null;
|
|
432
|
-
globalContext: import("
|
|
432
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
433
433
|
} & {
|
|
434
434
|
urlOriginal: string;
|
|
435
435
|
} & {
|
|
@@ -4,11 +4,13 @@ export { disableClientRouting };
|
|
|
4
4
|
export { firstRenderStartPromise };
|
|
5
5
|
export { getPageContextClient };
|
|
6
6
|
export type { PageContextBegin };
|
|
7
|
+
export type { PageContextInternalClientAfterRender };
|
|
7
8
|
import { type PageContextFromRewrite } from '../../shared/route/abort.js';
|
|
8
9
|
import { type ScrollTarget } from './setScrollPosition.js';
|
|
9
10
|
import type { PageContextConfig } from '../../shared/getPageFiles.js';
|
|
10
11
|
import type { PageContextClient, PageContextInternalClient } from '../../types/PageContext.js';
|
|
11
12
|
import type { VikeGlobalInternal } from '../../types/VikeGlobalInternal.js';
|
|
13
|
+
type PageContextInternalClientAfterRender = NonNullable<Awaited<ReturnType<typeof renderPageClientSide>>>;
|
|
12
14
|
declare const firstRenderStartPromise: Promise<void>;
|
|
13
15
|
type PageContextRouted = {
|
|
14
16
|
pageId: string;
|
|
@@ -26,7 +28,152 @@ type RenderArgs = {
|
|
|
26
28
|
isClientSideNavigation?: boolean;
|
|
27
29
|
pageContextInitClient?: Record<string, unknown>;
|
|
28
30
|
};
|
|
29
|
-
declare function renderPageClientSide(renderArgs: RenderArgs): Promise<
|
|
31
|
+
declare function renderPageClientSide(renderArgs: RenderArgs): Promise<({
|
|
32
|
+
_pageFilesLoaded: import("../../shared/getPageFiles.js").PageFile[];
|
|
33
|
+
urlOriginal?: string;
|
|
34
|
+
urlPathname?: string;
|
|
35
|
+
pageId: string;
|
|
36
|
+
_globalContext: import("../shared/getGlobalContextClientInternalShared.js").GlobalContextClientInternalShared;
|
|
37
|
+
} & PageContextConfig & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & PageContextInternalClient & {
|
|
38
|
+
_isOriginalObject: true;
|
|
39
|
+
isPageContext: true;
|
|
40
|
+
} & {
|
|
41
|
+
isClientSide: true;
|
|
42
|
+
isPrerendering: false;
|
|
43
|
+
urlOriginal: string;
|
|
44
|
+
_globalContext: {
|
|
45
|
+
_globalConfigPublic: {
|
|
46
|
+
pages: {
|
|
47
|
+
[k: string]: {
|
|
48
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
49
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
50
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
51
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
52
|
+
} & ({
|
|
53
|
+
route: import("../../types/Config.js").Route;
|
|
54
|
+
isErrorPage?: undefined;
|
|
55
|
+
} | {
|
|
56
|
+
route?: undefined;
|
|
57
|
+
isErrorPage: true;
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
61
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
62
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
63
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
64
|
+
};
|
|
65
|
+
pages: {
|
|
66
|
+
[k: string]: {
|
|
67
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
68
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
69
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
70
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
71
|
+
} & ({
|
|
72
|
+
route: import("../../types/Config.js").Route;
|
|
73
|
+
isErrorPage?: undefined;
|
|
74
|
+
} | {
|
|
75
|
+
route?: undefined;
|
|
76
|
+
isErrorPage: true;
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
80
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
81
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
82
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
83
|
+
isGlobalContext: true;
|
|
84
|
+
_isOriginalObject: true;
|
|
85
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
86
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
87
|
+
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
88
|
+
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
89
|
+
_allPageIds: string[];
|
|
90
|
+
} & {
|
|
91
|
+
isClientSide: true;
|
|
92
|
+
} & {
|
|
93
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
94
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
95
|
+
};
|
|
96
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
97
|
+
_urlHandler: null;
|
|
98
|
+
_urlRewrite: null | string;
|
|
99
|
+
_baseServer: string;
|
|
100
|
+
} & {
|
|
101
|
+
urlParsed: import("./utils.js").UrlPublic;
|
|
102
|
+
urlPathname: string;
|
|
103
|
+
url: string;
|
|
104
|
+
} & import("../../shared/page-configs/resolveVikeConfigPublic.js").GlobalConfigPublic & {
|
|
105
|
+
isBackwardNavigation: boolean | null;
|
|
106
|
+
isClientSideNavigation: boolean;
|
|
107
|
+
isHydration: boolean;
|
|
108
|
+
previousPageContext: ({
|
|
109
|
+
pageId: string;
|
|
110
|
+
} & PageContextConfig & PageContextRouted & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & PageContextInternalClient & Omit<Partial<PageContextConfig & {
|
|
111
|
+
isPageContext: true;
|
|
112
|
+
Page: import("../../types/Config.js").Config["Page"];
|
|
113
|
+
routeParams: Record<string, string>;
|
|
114
|
+
data: unknown;
|
|
115
|
+
urlOriginal: string;
|
|
116
|
+
headers: Record<string, string> | null;
|
|
117
|
+
headersOriginal?: unknown;
|
|
118
|
+
headersResponse: Headers;
|
|
119
|
+
is404: boolean | null;
|
|
120
|
+
isClientSideNavigation: boolean;
|
|
121
|
+
abortReason?: unknown;
|
|
122
|
+
abortStatusCode?: import("../../shared/route/abort.js").AbortStatusCode;
|
|
123
|
+
errorWhileRendering?: unknown;
|
|
124
|
+
pageId: string | null;
|
|
125
|
+
from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
126
|
+
source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
127
|
+
sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
128
|
+
url: string;
|
|
129
|
+
pageExports: Record<string, unknown>;
|
|
130
|
+
isBaseMissing?: true;
|
|
131
|
+
}> & Pick<PageContextConfig & {
|
|
132
|
+
isPageContext: true;
|
|
133
|
+
Page: import("../../types/Config.js").Config["Page"];
|
|
134
|
+
routeParams: Record<string, string>;
|
|
135
|
+
data: unknown;
|
|
136
|
+
urlOriginal: string;
|
|
137
|
+
headers: Record<string, string> | null;
|
|
138
|
+
headersOriginal?: unknown;
|
|
139
|
+
headersResponse: Headers;
|
|
140
|
+
is404: boolean | null;
|
|
141
|
+
isClientSideNavigation: boolean;
|
|
142
|
+
abortReason?: unknown;
|
|
143
|
+
abortStatusCode?: import("../../shared/route/abort.js").AbortStatusCode;
|
|
144
|
+
errorWhileRendering?: unknown;
|
|
145
|
+
pageId: string | null;
|
|
146
|
+
from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
147
|
+
source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
148
|
+
sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
149
|
+
url: string;
|
|
150
|
+
pageExports: Record<string, unknown>;
|
|
151
|
+
isBaseMissing?: true;
|
|
152
|
+
}, "exports" | "pageId" | "pageExports" | "config" | "Page" | "data" | "source" | "sources" | "from" | "configEntries" | "exportsAll" | "routeParams" | "abortReason"> & {
|
|
153
|
+
isClientSide: true;
|
|
154
|
+
isPrerendering: false;
|
|
155
|
+
} & {
|
|
156
|
+
isHydration: boolean;
|
|
157
|
+
isBackwardNavigation: boolean | null;
|
|
158
|
+
previousPageContext: PageContextClient<unknown> | null;
|
|
159
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
160
|
+
} & {
|
|
161
|
+
urlOriginal: string;
|
|
162
|
+
} & {
|
|
163
|
+
urlParsed: import("./utils.js").UrlPublic;
|
|
164
|
+
urlPathname: string;
|
|
165
|
+
url: string;
|
|
166
|
+
}, ("globalContext" | "Page" | "data") | "previousPageContext"> & {
|
|
167
|
+
previousPageContext: {
|
|
168
|
+
pageId: string;
|
|
169
|
+
} | null;
|
|
170
|
+
} & {
|
|
171
|
+
urlOriginal: string;
|
|
172
|
+
}) | null;
|
|
173
|
+
} & {
|
|
174
|
+
urlPathname: string;
|
|
175
|
+
_hasPageContextFromServer: boolean;
|
|
176
|
+
} & PageContextRouted) | undefined>;
|
|
30
177
|
declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isBackwardNavigation, pageContextsFromRewrite, isClientSideNavigation, pageContextInitClient, isFirstRender, }: {
|
|
31
178
|
urlOriginal: string;
|
|
32
179
|
isBackwardNavigation: boolean | null;
|
|
@@ -156,7 +303,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
|
|
|
156
303
|
isHydration: boolean;
|
|
157
304
|
isBackwardNavigation: boolean | null;
|
|
158
305
|
previousPageContext: PageContextClient<unknown> | null;
|
|
159
|
-
globalContext: import("
|
|
306
|
+
globalContext: import("../../types/GlobalContext.js").GlobalContextClient;
|
|
160
307
|
} & {
|
|
161
308
|
urlOriginal: string;
|
|
162
309
|
} & {
|
|
@@ -57,8 +57,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
57
57
|
globalObject.firstRenderStartPromiseResolve();
|
|
58
58
|
if (isRenderOutdated())
|
|
59
59
|
return;
|
|
60
|
-
await renderPageNominal();
|
|
61
|
-
return;
|
|
60
|
+
return await renderPageNominal();
|
|
62
61
|
async function renderPageNominal() {
|
|
63
62
|
const onError = async (err) => {
|
|
64
63
|
await handleError({ err });
|
|
@@ -187,7 +186,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
187
186
|
return;
|
|
188
187
|
updateType(pageContext, pageContextAugmented);
|
|
189
188
|
// Render page view
|
|
190
|
-
await renderPageView(pageContext);
|
|
189
|
+
return await renderPageView(pageContext);
|
|
191
190
|
}
|
|
192
191
|
else {
|
|
193
192
|
// Fetch pageContext from server-side hooks
|
|
@@ -227,7 +226,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
227
226
|
if (isRenderOutdated())
|
|
228
227
|
return;
|
|
229
228
|
updateType(pageContext, pageContextFromClientHooks);
|
|
230
|
-
await renderPageView(pageContext);
|
|
229
|
+
return await renderPageView(pageContext);
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
232
|
// When the normal page threw an error:
|
|
@@ -474,6 +473,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
474
473
|
addLinkPrefetchHandlers();
|
|
475
474
|
globalObject.renderedPageContext = pageContext;
|
|
476
475
|
stampFinished(urlOriginal);
|
|
476
|
+
return pageContext;
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
async function getPageContextBegin(isForErrorPage, { urlOriginal, isBackwardNavigation, pageContextsFromRewrite, isClientSideNavigation, pageContextInitClient, isFirstRender, }) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { getGlobalContextClientInternal };
|
|
2
|
-
export type { GlobalContextClientWithServerRouting };
|
|
3
2
|
export type { GlobalContextClientInternalWithServerRouting };
|
|
4
|
-
import type { GlobalContextBasePublic } from '../../shared/createGlobalContextShared.js';
|
|
5
|
-
type GlobalContextClientWithServerRouting = GlobalContextBasePublic & Pick<GlobalContextClientInternalWithServerRouting, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
6
3
|
type GlobalContextClientInternalWithServerRouting = Awaited<ReturnType<typeof getGlobalContextClientInternal>>;
|
|
7
4
|
declare function getGlobalContextClientInternal(): Promise<{
|
|
8
5
|
_globalConfigPublic: {
|
|
@@ -8,4 +8,7 @@ type PageContextForPublicUsageClientShared = PageContextPrepareMinimum & PageCon
|
|
|
8
8
|
declare function preparePageContextForPublicUsageClientShared<PageContext extends PageContextForPublicUsageClientShared>(pageContext: PageContext): PageContext & {
|
|
9
9
|
Page: unknown;
|
|
10
10
|
};
|
|
11
|
-
declare function preparePageContextForPublicUsageClientMinimal<PageContext extends PageContextPrepareMinimum>(pageContext: PageContext): PageContext
|
|
11
|
+
declare function preparePageContextForPublicUsageClientMinimal<PageContext extends PageContextPrepareMinimum>(pageContext: PageContext): PageContext & {
|
|
12
|
+
_isProxyObject: true;
|
|
13
|
+
dangerouslyUseInternals: PageContext;
|
|
14
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { preview };
|
|
2
|
+
export type { CliPreviewConfig };
|
|
2
3
|
import { type ResolvedConfig, type PreviewServer } from 'vite';
|
|
3
4
|
import type { ApiOptions } from './types.js';
|
|
4
5
|
/**
|
|
@@ -10,3 +11,5 @@ declare function preview(options?: ApiOptions): Promise<{
|
|
|
10
11
|
viteServer?: PreviewServer;
|
|
11
12
|
viteConfig: ResolvedConfig;
|
|
12
13
|
}>;
|
|
14
|
+
type CliPreviewValue = boolean | 'vite' | undefined;
|
|
15
|
+
type CliPreviewConfig = CliPreviewValue | (() => CliPreviewValue | Promise<CliPreviewValue>);
|
|
@@ -3,9 +3,10 @@ import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
|
3
3
|
import { preview as previewVite } from 'vite';
|
|
4
4
|
import { importServerProductionIndex } from '@brillout/vite-plugin-server-entry/runtime';
|
|
5
5
|
import { getOutDirs } from '../vite/shared/getOutDirs.js';
|
|
6
|
-
import { assertWarning, onSetupPreview } from './utils.js';
|
|
6
|
+
import { assertUsage, assertWarning, onSetupPreview, isCallable } from './utils.js';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
+
import { getVikeConfigInternal } from '../vite/shared/resolveVikeConfigInternal.js';
|
|
9
10
|
/**
|
|
10
11
|
* Programmatically trigger `$ vike preview`
|
|
11
12
|
*
|
|
@@ -14,7 +15,11 @@ import path from 'node:path';
|
|
|
14
15
|
async function preview(options = {}) {
|
|
15
16
|
onSetupPreview();
|
|
16
17
|
const { viteConfigFromUserResolved, viteConfigResolved } = await prepareViteApiCall(options, 'preview');
|
|
17
|
-
|
|
18
|
+
const cliPreview = await resolveCliPreviewConfig();
|
|
19
|
+
assertUsage(cliPreview !== false, `${pc.cyan('$ vike preview')} isn't supported`);
|
|
20
|
+
const useVite = cliPreview === 'vite' || (cliPreview === undefined && !viteConfigResolved.vitePluginServerEntry?.inject);
|
|
21
|
+
if (!useVite) {
|
|
22
|
+
// Dynamically import() server production entry dist/server/index.js
|
|
18
23
|
const outDir = getOutDirs(viteConfigResolved, undefined).outDirRoot;
|
|
19
24
|
const { outServerIndex } = await importServerProductionIndex({ outDir });
|
|
20
25
|
const outServerIndexRelative = path.relative(viteConfigResolved.root, outServerIndex);
|
|
@@ -24,6 +29,7 @@ async function preview(options = {}) {
|
|
|
24
29
|
};
|
|
25
30
|
}
|
|
26
31
|
else {
|
|
32
|
+
// Use Vite's preview server
|
|
27
33
|
const server = await previewVite(viteConfigFromUserResolved);
|
|
28
34
|
return {
|
|
29
35
|
viteServer: server,
|
|
@@ -31,3 +37,13 @@ async function preview(options = {}) {
|
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
}
|
|
40
|
+
async function resolveCliPreviewConfig() {
|
|
41
|
+
const vikeConfig = await getVikeConfigInternal();
|
|
42
|
+
const val = vikeConfig.config.cli?.preview;
|
|
43
|
+
if (!isCallable(val)) {
|
|
44
|
+
return val;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return await val();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -20,17 +20,15 @@ export { updateUserFiles };
|
|
|
20
20
|
export { isRunnable };
|
|
21
21
|
export { vikeConfigErrorRecoverMsg };
|
|
22
22
|
export type { BuildInfo };
|
|
23
|
-
export type { GlobalContextServerInternal
|
|
24
|
-
export type { GlobalContextServer };
|
|
23
|
+
export type { GlobalContextServerInternal };
|
|
25
24
|
import type { ViteManifest } from '../../types/ViteManifest.js';
|
|
26
25
|
import type { ResolvedConfig, ViteDevServer } from 'vite';
|
|
27
26
|
import { type PageRoutes } from '../../shared/route/loadPageRoutes.js';
|
|
28
27
|
import type { ViteConfigRuntime } from '../vite/shared/getViteConfigRuntime.js';
|
|
29
|
-
import type { GlobalContext } from '../../types/
|
|
28
|
+
import type { GlobalContext } from '../../types/GlobalContext.js';
|
|
30
29
|
import type { Hook } from '../../shared/hooks/getHook.js';
|
|
31
30
|
import type { PrerenderContext } from '../../types/index.js';
|
|
32
31
|
declare const vikeConfigErrorRecoverMsg: "Vike config loaded";
|
|
33
|
-
type GlobalContextServer = Pick<GlobalContextServerInternal, 'assetsManifest' | 'config' | 'viteConfig' | 'viteConfigRuntime' | 'pages' | 'baseServer' | 'baseAssets' | 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextServer;
|
|
34
32
|
type GlobalContextServerInternal = Awaited<ReturnType<typeof createGlobalContext>>;
|
|
35
33
|
declare function getGlobalContextServerInternal(): Promise<{
|
|
36
34
|
globalContext: (Record<string, unknown> & {
|
|
@@ -2,6 +2,7 @@ export { renderPage };
|
|
|
2
2
|
export { renderPage_addAsyncHookwrapper };
|
|
3
3
|
export type { PageContextInit };
|
|
4
4
|
export type { PageContextBegin };
|
|
5
|
+
export type { PageContextInternalServerAfterRender };
|
|
5
6
|
import { type GlobalContextServerInternal } from './globalContext.js';
|
|
6
7
|
import { type HttpResponse } from './renderPage/createHttpResponse.js';
|
|
7
8
|
import type { PageContextServer } from '../../types/index.js';
|
|
@@ -21,6 +22,288 @@ declare function renderPage<PageContextUserAdded extends {}, PageContextInitUser
|
|
|
21
22
|
httpResponse: HttpResponse;
|
|
22
23
|
} & Partial<PageContextServer & PageContextUserAdded>>;
|
|
23
24
|
declare function renderPage_addAsyncHookwrapper(wrapper: typeof globalObject.asyncHookWrapper): void;
|
|
25
|
+
type PageContextInternalServerAfterRender = Awaited<ReturnType<typeof renderPageNominal>>;
|
|
26
|
+
declare function renderPageNominal(pageContext: PageContextBegin): Promise<({
|
|
27
|
+
_isOriginalObject: true;
|
|
28
|
+
isPageContext: true;
|
|
29
|
+
} & {
|
|
30
|
+
isClientSide: false;
|
|
31
|
+
isPrerendering: boolean;
|
|
32
|
+
} & Pick<PageContextInternalServer, "urlOriginal" | "headersOriginal"> & {
|
|
33
|
+
/** @deprecated Set `pageContextInit.urlOriginal` instead */ url?: string;
|
|
34
|
+
/** @deprecated Set pageContextInit.headersOriginal instead */ headers?: Record<string, string>;
|
|
35
|
+
} & {
|
|
36
|
+
_globalContext: ({
|
|
37
|
+
_globalConfigPublic: {
|
|
38
|
+
pages: {
|
|
39
|
+
[k: string]: {
|
|
40
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
41
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
42
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
43
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
44
|
+
} & ({
|
|
45
|
+
route: import("../../types/Config.js").Route;
|
|
46
|
+
isErrorPage?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
route?: undefined;
|
|
49
|
+
isErrorPage: true;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
53
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
54
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
55
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
56
|
+
};
|
|
57
|
+
pages: {
|
|
58
|
+
[k: string]: {
|
|
59
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
60
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
61
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
62
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
63
|
+
} & ({
|
|
64
|
+
route: import("../../types/Config.js").Route;
|
|
65
|
+
isErrorPage?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
route?: undefined;
|
|
68
|
+
isErrorPage: true;
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
72
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
73
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
74
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
75
|
+
isGlobalContext: true;
|
|
76
|
+
_isOriginalObject: true;
|
|
77
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
78
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
79
|
+
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
80
|
+
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
81
|
+
_allPageIds: string[];
|
|
82
|
+
} & (({
|
|
83
|
+
_isProduction: false;
|
|
84
|
+
_isPrerendering: false;
|
|
85
|
+
assetsManifest: null;
|
|
86
|
+
_viteDevServer: import("vite").ViteDevServer | undefined;
|
|
87
|
+
viteConfig: import("vite").ResolvedConfig | undefined;
|
|
88
|
+
isClientSide: false;
|
|
89
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
90
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
91
|
+
} | {
|
|
92
|
+
_isPrerendering: true;
|
|
93
|
+
viteConfig: import("vite").ResolvedConfig;
|
|
94
|
+
_isProduction: true;
|
|
95
|
+
assetsManifest: import("../../types/ViteManifest.js").ViteManifest;
|
|
96
|
+
_viteDevServer: null;
|
|
97
|
+
_usesClientRouter: boolean;
|
|
98
|
+
isClientSide: false;
|
|
99
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
100
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
101
|
+
} | {
|
|
102
|
+
_isPrerendering: false;
|
|
103
|
+
viteConfig: null;
|
|
104
|
+
_isProduction: true;
|
|
105
|
+
assetsManifest: import("../../types/ViteManifest.js").ViteManifest;
|
|
106
|
+
_viteDevServer: null;
|
|
107
|
+
_usesClientRouter: boolean;
|
|
108
|
+
isClientSide: false;
|
|
109
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
110
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
111
|
+
}) & {
|
|
112
|
+
baseServer: string;
|
|
113
|
+
baseAssets: string;
|
|
114
|
+
viteConfigRuntime: {
|
|
115
|
+
root: string;
|
|
116
|
+
build: {
|
|
117
|
+
outDir: string;
|
|
118
|
+
};
|
|
119
|
+
_baseViteOriginal: string;
|
|
120
|
+
vitePluginServerEntry: {
|
|
121
|
+
inject: boolean | undefined;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
})) & {
|
|
125
|
+
prerenderContext: import("../prerender/runPrerender.js").PrerenderContextPublic | undefined;
|
|
126
|
+
};
|
|
127
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
128
|
+
_baseServer: string;
|
|
129
|
+
_baseAssets: string;
|
|
130
|
+
_pageContextInit: PageContextInit;
|
|
131
|
+
_urlRewrite: null;
|
|
132
|
+
_urlHandler: ((url: string) => string) | null;
|
|
133
|
+
isClientSideNavigation: boolean;
|
|
134
|
+
} & {
|
|
135
|
+
pages: {
|
|
136
|
+
[k: string]: {
|
|
137
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
138
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
139
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
140
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
141
|
+
} & ({
|
|
142
|
+
route: import("../../types/Config.js").Route;
|
|
143
|
+
isErrorPage?: undefined;
|
|
144
|
+
} | {
|
|
145
|
+
route?: undefined;
|
|
146
|
+
isErrorPage: true;
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
150
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
151
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
152
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
153
|
+
} & {
|
|
154
|
+
urlParsed: import("./utils.js").UrlPublic;
|
|
155
|
+
urlPathname: string;
|
|
156
|
+
url: string;
|
|
157
|
+
} & {
|
|
158
|
+
headers: Record<string, string> | null;
|
|
159
|
+
} & {
|
|
160
|
+
_httpRequestId: number;
|
|
161
|
+
_isPageContextJsonRequest: boolean;
|
|
162
|
+
} & {
|
|
163
|
+
errorWhileRendering: null;
|
|
164
|
+
} & import("../../shared/route/index.js").PageContextAfterRoute & {
|
|
165
|
+
is404: boolean | null;
|
|
166
|
+
} & Record<"pageId", null> & import("./renderPage/renderPageAfterRoute.js").PageContextAfterRender) | ({
|
|
167
|
+
_isOriginalObject: true;
|
|
168
|
+
isPageContext: true;
|
|
169
|
+
} & {
|
|
170
|
+
isClientSide: false;
|
|
171
|
+
isPrerendering: boolean;
|
|
172
|
+
} & Pick<PageContextInternalServer, "urlOriginal" | "headersOriginal"> & {
|
|
173
|
+
/** @deprecated Set `pageContextInit.urlOriginal` instead */ url?: string;
|
|
174
|
+
/** @deprecated Set pageContextInit.headersOriginal instead */ headers?: Record<string, string>;
|
|
175
|
+
} & {
|
|
176
|
+
_globalContext: ({
|
|
177
|
+
_globalConfigPublic: {
|
|
178
|
+
pages: {
|
|
179
|
+
[k: string]: {
|
|
180
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
181
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
182
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
183
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
184
|
+
} & ({
|
|
185
|
+
route: import("../../types/Config.js").Route;
|
|
186
|
+
isErrorPage?: undefined;
|
|
187
|
+
} | {
|
|
188
|
+
route?: undefined;
|
|
189
|
+
isErrorPage: true;
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
193
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
194
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
195
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
196
|
+
};
|
|
197
|
+
pages: {
|
|
198
|
+
[k: string]: {
|
|
199
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
200
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
201
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
202
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
203
|
+
} & ({
|
|
204
|
+
route: import("../../types/Config.js").Route;
|
|
205
|
+
isErrorPage?: undefined;
|
|
206
|
+
} | {
|
|
207
|
+
route?: undefined;
|
|
208
|
+
isErrorPage: true;
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
212
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
213
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
214
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
215
|
+
isGlobalContext: true;
|
|
216
|
+
_isOriginalObject: true;
|
|
217
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
218
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
219
|
+
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
220
|
+
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
221
|
+
_allPageIds: string[];
|
|
222
|
+
} & (({
|
|
223
|
+
_isProduction: false;
|
|
224
|
+
_isPrerendering: false;
|
|
225
|
+
assetsManifest: null;
|
|
226
|
+
_viteDevServer: import("vite").ViteDevServer | undefined;
|
|
227
|
+
viteConfig: import("vite").ResolvedConfig | undefined;
|
|
228
|
+
isClientSide: false;
|
|
229
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
230
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
231
|
+
} | {
|
|
232
|
+
_isPrerendering: true;
|
|
233
|
+
viteConfig: import("vite").ResolvedConfig;
|
|
234
|
+
_isProduction: true;
|
|
235
|
+
assetsManifest: import("../../types/ViteManifest.js").ViteManifest;
|
|
236
|
+
_viteDevServer: null;
|
|
237
|
+
_usesClientRouter: boolean;
|
|
238
|
+
isClientSide: false;
|
|
239
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
240
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
241
|
+
} | {
|
|
242
|
+
_isPrerendering: false;
|
|
243
|
+
viteConfig: null;
|
|
244
|
+
_isProduction: true;
|
|
245
|
+
assetsManifest: import("../../types/ViteManifest.js").ViteManifest;
|
|
246
|
+
_viteDevServer: null;
|
|
247
|
+
_usesClientRouter: boolean;
|
|
248
|
+
isClientSide: false;
|
|
249
|
+
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
250
|
+
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
251
|
+
}) & {
|
|
252
|
+
baseServer: string;
|
|
253
|
+
baseAssets: string;
|
|
254
|
+
viteConfigRuntime: {
|
|
255
|
+
root: string;
|
|
256
|
+
build: {
|
|
257
|
+
outDir: string;
|
|
258
|
+
};
|
|
259
|
+
_baseViteOriginal: string;
|
|
260
|
+
vitePluginServerEntry: {
|
|
261
|
+
inject: boolean | undefined;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
})) & {
|
|
265
|
+
prerenderContext: import("../prerender/runPrerender.js").PrerenderContextPublic | undefined;
|
|
266
|
+
};
|
|
267
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
268
|
+
_baseServer: string;
|
|
269
|
+
_baseAssets: string;
|
|
270
|
+
_pageContextInit: PageContextInit;
|
|
271
|
+
_urlRewrite: null;
|
|
272
|
+
_urlHandler: ((url: string) => string) | null;
|
|
273
|
+
isClientSideNavigation: boolean;
|
|
274
|
+
} & {
|
|
275
|
+
pages: {
|
|
276
|
+
[k: string]: {
|
|
277
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
278
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
279
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
280
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
281
|
+
} & ({
|
|
282
|
+
route: import("../../types/Config.js").Route;
|
|
283
|
+
isErrorPage?: undefined;
|
|
284
|
+
} | {
|
|
285
|
+
route?: undefined;
|
|
286
|
+
isErrorPage: true;
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
config: import("../../types/index.js").ConfigResolved;
|
|
290
|
+
_source: import("../../shared/page-configs/resolveVikeConfigPublic.js").Source;
|
|
291
|
+
_sources: import("../../shared/page-configs/resolveVikeConfigPublic.js").Sources;
|
|
292
|
+
_from: import("../../shared/page-configs/resolveVikeConfigPublic.js").From;
|
|
293
|
+
} & {
|
|
294
|
+
urlParsed: import("./utils.js").UrlPublic;
|
|
295
|
+
urlPathname: string;
|
|
296
|
+
url: string;
|
|
297
|
+
} & {
|
|
298
|
+
headers: Record<string, string> | null;
|
|
299
|
+
} & {
|
|
300
|
+
_httpRequestId: number;
|
|
301
|
+
_isPageContextJsonRequest: boolean;
|
|
302
|
+
} & {
|
|
303
|
+
errorWhileRendering: null;
|
|
304
|
+
} & import("../../shared/route/index.js").PageContextAfterRoute & {
|
|
305
|
+
is404: boolean | null;
|
|
306
|
+
} & Record<"pageId", string> & import("./renderPage/renderPageAfterRoute.js").PageContextAfterRender)>;
|
|
24
307
|
declare function getPageContextBegin(pageContextInit: PageContextInit, globalContext: GlobalContextServerInternal, httpRequestId: number): {
|
|
25
308
|
_isOriginalObject: true;
|
|
26
309
|
isPageContext: true;
|
|
@@ -221,9 +221,10 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
|
221
221
|
}
|
|
222
222
|
function handleAssetsManifest_alignCssTarget(config) {
|
|
223
223
|
globalObject.configsAll.push(config);
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
const clientSideConfigs = globalObject.configsAll.filter((c) => !isViteServerSide_viteEnvOptional(c, undefined));
|
|
225
|
+
if (clientSideConfigs.length === 0)
|
|
226
|
+
return;
|
|
227
|
+
const { cssTarget } = clientSideConfigs.at(-1).build;
|
|
227
228
|
assert(cssTarget);
|
|
228
229
|
globalObject.configsAll.forEach((c) => (c.build.cssTarget = cssTarget));
|
|
229
230
|
}
|
|
@@ -89,6 +89,7 @@ function pluginBuildApp() {
|
|
|
89
89
|
*/
|
|
90
90
|
async handler(options, bundle) {
|
|
91
91
|
try {
|
|
92
|
+
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
92
93
|
await handleAssetsManifest(config, this.environment, options, bundle);
|
|
93
94
|
await triggerPrerendering(config, this.environment, bundle);
|
|
94
95
|
}
|
|
@@ -112,7 +113,6 @@ function pluginBuildApp() {
|
|
|
112
113
|
order: 'post',
|
|
113
114
|
handler() {
|
|
114
115
|
onSetupBuild();
|
|
115
|
-
handleAssetsManifest_assertUsageCssTarget(config, this.environment);
|
|
116
116
|
},
|
|
117
117
|
},
|
|
118
118
|
},
|
|
@@ -196,6 +196,10 @@ const configDefinitionsBuiltIn = {
|
|
|
196
196
|
env: { client: true },
|
|
197
197
|
},
|
|
198
198
|
middleware: { env: { server: true }, cumulative: true, eager: true, global: true },
|
|
199
|
+
cli: {
|
|
200
|
+
env: { config: true },
|
|
201
|
+
global: true,
|
|
202
|
+
},
|
|
199
203
|
onPrerenderStart: {
|
|
200
204
|
env: { server: true, production: true },
|
|
201
205
|
eager: true,
|
|
@@ -18,6 +18,7 @@ import { type GlobalConfigPublic } from '../../../shared/page-configs/resolveVik
|
|
|
18
18
|
import { type PlusFile } from './resolveVikeConfigInternal/getPlusFilesAll.js';
|
|
19
19
|
import type { PrerenderContextPublic } from '../../prerender/runPrerender.js';
|
|
20
20
|
import type { ResolvedConfig, UserConfig } from 'vite';
|
|
21
|
+
import { type DangerouslyUseInternals } from '../../../shared/getProxyForPublicUsage.js';
|
|
21
22
|
type VikeConfigContext = {
|
|
22
23
|
userRootDir: string;
|
|
23
24
|
isDev: boolean;
|
|
@@ -44,7 +45,10 @@ declare function getVikeConfigInternalSync(): VikeConfigInternal;
|
|
|
44
45
|
* https://vike.dev/getVikeConfig
|
|
45
46
|
*/
|
|
46
47
|
declare function getVikeConfig(config: ResolvedConfig | UserConfig): VikeConfig;
|
|
47
|
-
type VikeConfig = Pick<VikeConfigInternal, 'config' | 'pages' | 'prerenderContext'
|
|
48
|
+
type VikeConfig = Pick<VikeConfigInternal, 'config' | 'pages' | 'prerenderContext'> & {
|
|
49
|
+
/** https://vike.dev/warning/internals */
|
|
50
|
+
dangerouslyUseInternals: DangerouslyUseInternals<VikeConfigInternal>;
|
|
51
|
+
};
|
|
48
52
|
declare function setVikeConfigContext(vikeConfigCtx_: VikeConfigContext): void;
|
|
49
53
|
declare function isVikeConfigContextSet(): boolean;
|
|
50
54
|
declare function getVikeConfigInternalOptional(): Promise<null | VikeConfigInternal>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export { getProxyForPublicUsage };
|
|
2
|
+
export type { DangerouslyUseInternals };
|
|
2
3
|
type Target = Record<string, unknown>;
|
|
3
4
|
type Fallback = (prop: string | symbol) => unknown;
|
|
4
|
-
declare function getProxyForPublicUsage<Obj extends Target>(obj: Obj, objName: 'pageContext' | 'globalContext' | 'prerenderContext' | 'vikeConfig', skipOnInternalProp?: true, fallback?: Fallback): Obj
|
|
5
|
+
declare function getProxyForPublicUsage<Obj extends Target>(obj: Obj, objName: 'pageContext' | 'globalContext' | 'prerenderContext' | 'vikeConfig', skipOnInternalProp?: true, fallback?: Fallback): Obj & {
|
|
6
|
+
_isProxyObject: true;
|
|
7
|
+
/** https://vike.dev/warning/internals */
|
|
8
|
+
dangerouslyUseInternals: DangerouslyUseInternals<Obj>;
|
|
9
|
+
};
|
|
10
|
+
/** https://vike.dev/warning/internals */
|
|
11
|
+
type DangerouslyUseInternals<Obj> = Obj;
|
|
@@ -10,25 +10,27 @@ import { NOT_SERIALIZABLE } from './NOT_SERIALIZABLE.js';
|
|
|
10
10
|
import { assert, assertUsage, assertWarning, getPropAccessNotation, isBrowser } from './utils.js';
|
|
11
11
|
function getProxyForPublicUsage(obj, objName, skipOnInternalProp, fallback) {
|
|
12
12
|
return new Proxy(obj, {
|
|
13
|
-
get:
|
|
13
|
+
get: (_, prop) => getProp(prop, obj, objName, skipOnInternalProp, fallback),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
function getProp(prop, obj, objName, skipOnInternalProp, fallback) {
|
|
17
|
+
const propStr = String(prop);
|
|
18
|
+
if (prop === '_isProxyObject')
|
|
19
|
+
return true;
|
|
20
|
+
if (prop === 'dangerouslyUseInternals')
|
|
21
|
+
return obj;
|
|
22
|
+
if (!skipOnInternalProp) {
|
|
23
|
+
if (!globalThis.__VIKE__IS_CLIENT)
|
|
22
24
|
onInternalProp(propStr, objName);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
}
|
|
26
|
+
if (fallback && !(prop in obj)) {
|
|
27
|
+
// Rudimentary flat pageContext implementation https://github.com/vikejs/vike/issues/1268
|
|
28
|
+
// Failed full-fledged implementation: https://github.com/vikejs/vike/pull/2458
|
|
29
|
+
return fallback(prop);
|
|
30
|
+
}
|
|
31
|
+
const val = obj[prop];
|
|
32
|
+
onNotSerializable(propStr, val, objName);
|
|
33
|
+
return val;
|
|
32
34
|
}
|
|
33
35
|
function onNotSerializable(propStr, val, objName) {
|
|
34
36
|
if (val !== NOT_SERIALIZABLE)
|
|
@@ -38,17 +40,15 @@ function onNotSerializable(propStr, val, objName) {
|
|
|
38
40
|
assertUsage(false, `Can't access ${objName}${propName} on the client side. Because it can't be serialized, see server logs.`);
|
|
39
41
|
}
|
|
40
42
|
function onInternalProp(propStr, objName) {
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
// - Where import.meta.CLIENT is defined by Vike
|
|
44
|
-
// - Using import.meta.env.CLIENT (note `.env.`) doesn't seem possible: https://github.com/brillout/playground_node_import.meta.env
|
|
45
|
-
// - If Rolldown Vite + Rolldowns always transpiles node_modules/ then we can simply use import.meta.env.SSR
|
|
46
|
-
if (isBrowser())
|
|
47
|
-
return;
|
|
43
|
+
// We must skip it on the client-side because of the reactivity mechanism of UI frameworks like Solid.
|
|
44
|
+
assert(!isBrowser());
|
|
48
45
|
// TO-DO/soon/proxy: remove this and only warn on built-in access instead
|
|
49
46
|
if (propStr === '_configFromHook')
|
|
50
47
|
return;
|
|
51
48
|
if (propStr.startsWith('_')) {
|
|
52
|
-
assertWarning(false, `Using internal ${objName}.${propStr}
|
|
49
|
+
assertWarning(false, `Using internal ${objName}.${propStr} — https://vike.dev/warning/internals`, {
|
|
50
|
+
onlyOnce: true,
|
|
51
|
+
showStackTrace: true,
|
|
52
|
+
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -4,4 +4,7 @@ type GlobalContextPrepareMinimum = {
|
|
|
4
4
|
_isOriginalObject: true;
|
|
5
5
|
isGlobalContext: true;
|
|
6
6
|
};
|
|
7
|
-
declare function prepareGlobalContextForPublicUsage<GlobalContext extends GlobalContextPrepareMinimum>(globalContext: GlobalContext): GlobalContext
|
|
7
|
+
declare function prepareGlobalContextForPublicUsage<GlobalContext extends GlobalContextPrepareMinimum>(globalContext: GlobalContext): GlobalContext & {
|
|
8
|
+
_isProxyObject: true;
|
|
9
|
+
dangerouslyUseInternals: GlobalContext;
|
|
10
|
+
};
|
|
@@ -7,5 +7,8 @@ type PageContextPrepareMinimum = {
|
|
|
7
7
|
isPageContext: true;
|
|
8
8
|
_globalContext: GlobalContextPrepareMinimum;
|
|
9
9
|
};
|
|
10
|
-
declare function preparePageContextForPublicUsage<PageContext extends PageContextPrepareMinimum>(pageContext: PageContext): PageContext
|
|
10
|
+
declare function preparePageContextForPublicUsage<PageContext extends PageContextPrepareMinimum>(pageContext: PageContext): PageContext & {
|
|
11
|
+
_isProxyObject: true;
|
|
12
|
+
dangerouslyUseInternals: PageContext;
|
|
13
|
+
};
|
|
11
14
|
declare function assertPropertyGetters(pageContext: Record<string, unknown>): void;
|
|
@@ -42,9 +42,11 @@ import type { InjectFilterEntry } from './index.js';
|
|
|
42
42
|
import type { VikeVitePluginOptions } from '../node/vite/index.js';
|
|
43
43
|
import type { Vike } from './VikeNamespace.js';
|
|
44
44
|
import type { HooksTimeoutProvidedByUser } from '../shared/hooks/getHook.js';
|
|
45
|
-
import type {
|
|
45
|
+
import type { PageContextClient, PageContextServer } from './PageContext.js';
|
|
46
|
+
import type { GlobalContext } from './GlobalContext.js';
|
|
46
47
|
import type { InlineConfig } from 'vite';
|
|
47
48
|
import type { PassToClientPublic } from '../node/runtime/renderPage/html/serializeContext.js';
|
|
49
|
+
import type { CliPreviewConfig } from '../node/api/preview.js';
|
|
48
50
|
type HookNameOld = HookName | HookNameOldDesign;
|
|
49
51
|
type HookName = HookNamePage | HookNameGlobal;
|
|
50
52
|
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data' | 'onData' | 'route';
|
|
@@ -512,6 +514,10 @@ type ConfigBuiltIn = {
|
|
|
512
514
|
keepScrollPosition?: KeepScrollPosition;
|
|
513
515
|
/** @experimental */
|
|
514
516
|
middleware?: Function;
|
|
517
|
+
/** @experimental */
|
|
518
|
+
cli?: {
|
|
519
|
+
preview?: CliPreviewConfig;
|
|
520
|
+
};
|
|
515
521
|
};
|
|
516
522
|
type ConfigBuiltInResolved = {
|
|
517
523
|
passToClient?: string[][];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type { GlobalContext };
|
|
2
|
+
export type { GlobalContextServer };
|
|
3
|
+
export type { GlobalContextClient };
|
|
4
|
+
export type { GlobalContextClientWithServerRouting };
|
|
5
|
+
import type { GlobalContextServerInternal } from '../node/runtime/globalContext.js';
|
|
6
|
+
import type { GlobalContextClientInternalWithServerRouting } from '../client/runtime-server-routing/getGlobalContextClientInternal.js';
|
|
7
|
+
import type { GlobalContextBasePublic } from '../shared/createGlobalContextShared.js';
|
|
8
|
+
import type { GlobalContextClientInternal } from '../client/runtime-client-routing/getGlobalContextClientInternal.js';
|
|
9
|
+
type GlobalContext = GlobalContextServer | GlobalContextClient;
|
|
10
|
+
type GlobalContextServer = Pick<GlobalContextServerInternal, 'assetsManifest' | 'config' | 'viteConfig' | 'viteConfigRuntime' | 'pages' | 'baseServer' | 'baseAssets' | 'isClientSide'> & {
|
|
11
|
+
/** https://vike.dev/warning/internals */
|
|
12
|
+
dangerouslyUseInternals: GlobalContextServerInternal;
|
|
13
|
+
} & Vike.GlobalContext & Vike.GlobalContextServer;
|
|
14
|
+
type GlobalContextClient = GlobalContextBasePublic & {
|
|
15
|
+
/** https://vike.dev/warning/internals */
|
|
16
|
+
dangerouslyUseInternals: GlobalContextClientInternal;
|
|
17
|
+
} & Pick<GlobalContextClientInternal, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
18
|
+
type GlobalContextClientWithServerRouting = GlobalContextBasePublic & Pick<GlobalContextClientInternalWithServerRouting, 'isClientSide'> & Vike.GlobalContext & Vike.GlobalContextClient & {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
export type { PageContext };
|
|
2
2
|
export type { PageContextServer };
|
|
3
3
|
export type { PageContextClient };
|
|
4
|
-
export type { GlobalContext };
|
|
5
|
-
export type { GlobalContextServer };
|
|
6
|
-
export type { GlobalContextClient };
|
|
7
4
|
export type { PageContextWithServerRouting };
|
|
8
5
|
export type { PageContextClientWithServerRouting };
|
|
9
|
-
export type { GlobalContextClientWithServerRouting };
|
|
10
6
|
export type { PageContextInternalServer };
|
|
11
7
|
export type { PageContextInternalClient };
|
|
12
8
|
export type { PageContextInternalClient_ServerRouting };
|
|
@@ -18,13 +14,19 @@ import type { PageContextUrlInternal, PageContextUrlClient, PageContextUrlServer
|
|
|
18
14
|
import type { From, PageContextConfig, Source, Sources } from '../shared/page-configs/resolveVikeConfigPublic.js';
|
|
19
15
|
import type { Config } from './Config.js';
|
|
20
16
|
import type { AbortStatusCode } from '../shared/route/abort.js';
|
|
21
|
-
import type { GlobalContextServer } from '
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
24
|
-
type
|
|
17
|
+
import type { GlobalContextClient, GlobalContextServer, GlobalContextClientWithServerRouting } from './GlobalContext.js';
|
|
18
|
+
import type { DangerouslyUseInternals } from '../shared/getProxyForPublicUsage.js';
|
|
19
|
+
import type { PageContextInternalServerAfterRender } from '../node/runtime/renderPage.js';
|
|
20
|
+
import type { PageContextInternalClientAfterRender } from '../client/runtime-client-routing/renderPageClientSide.js';
|
|
21
|
+
type PageContextServer<Data = unknown> = PageContextBuiltInServer<Data> & {
|
|
22
|
+
/** https://vike.dev/warning/internals */
|
|
23
|
+
dangerouslyUseInternals: DangerouslyUseInternals<PageContextInternalServer & PageContextInternalServerAfterRender>;
|
|
24
|
+
} & Vike.PageContext & Vike.PageContextServer;
|
|
25
25
|
type PageContext<Data = unknown> = PageContextClient<Data> | PageContextServer<Data>;
|
|
26
|
-
type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> &
|
|
27
|
-
|
|
26
|
+
type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> & {
|
|
27
|
+
/** https://vike.dev/warning/internals */
|
|
28
|
+
dangerouslyUseInternals: DangerouslyUseInternals<PageContextInternalClient_ClientRouting & PageContextInternalClientAfterRender>;
|
|
29
|
+
} & Vike.PageContext & Vike.PageContextClient;
|
|
28
30
|
type PageContextWithServerRouting<Data = unknown> = PageContextClientWithServerRouting<Data> | PageContextServer<Data>;
|
|
29
31
|
type PageContextClientWithServerRouting<Data = unknown> = PageContextBuiltInClientWithServerRouting<Data> & Vike.PageContext & Vike.PageContextClient;
|
|
30
32
|
type PageContextBuiltInCommon<Data> = PageContextConfig & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { PageContext, PageContextServer, PageContextClient,
|
|
1
|
+
export type { PageContext, PageContextServer, PageContextClient, PageContextWithServerRouting, PageContextClientWithServerRouting, } from './PageContext.js';
|
|
2
|
+
export type { GlobalContext, GlobalContextServer, GlobalContextClient, GlobalContextClientWithServerRouting, } from './GlobalContext.js';
|
|
2
3
|
export type { PrerenderContextPublic as PrerenderContext } from '../node/prerender/runPrerender.js';
|
|
3
4
|
export type { PageContextBuiltInServer } from './PageContext.js';
|
|
4
5
|
export type { PageContextBuiltInClientWithClientRouting } from './PageContext.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.244-commit-a8703f7";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.244-commit-a8703f7';
|