vike 0.4.221 → 0.4.222-commit-207e079
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/cjs/node/api/prepareViteApiCall.js +18 -16
- package/dist/cjs/node/plugin/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/baseUrls.js +6 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/cjs/node/plugin/plugins/buildConfig.js +0 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +73 -39
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +64 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +0 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +2 -40
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +49 -18
- package/dist/cjs/node/runtime/globalContext.js +24 -8
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +3 -3
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/cjs/node/runtime/renderPage.js +4 -8
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +3 -3
- package/dist/cjs/node/shared/resolveBase.js +0 -13
- package/dist/cjs/shared/getPageConfigsRuntime.js +10 -1
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +4 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSingleInstance.js +1 -1
- package/dist/cjs/utils/debug.js +9 -6
- package/dist/esm/client/client-routing-runtime/prefetch.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +5 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +9 -2
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/getPageContext.js +4 -3
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +3 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +2 -2
- package/dist/esm/node/api/prepareViteApiCall.js +18 -16
- package/dist/esm/node/plugin/index.d.ts +4 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +6 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -2
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +4 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +73 -39
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +4 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +65 -15
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +2 -37
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +6 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +50 -19
- package/dist/esm/node/runtime/globalContext.d.ts +10 -7
- package/dist/esm/node/runtime/globalContext.js +24 -8
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +3 -3
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +8 -8
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/esm/node/runtime/renderPage.js +4 -8
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +3 -3
- package/dist/esm/node/shared/resolveBase.d.ts +1 -9
- package/dist/esm/node/shared/resolveBase.js +0 -13
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +2 -1
- package/dist/esm/shared/getPageConfigsRuntime.js +10 -1
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +8 -2
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +4 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +9 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSingleInstance.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +9 -6
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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 {
|
|
8
|
+
import type { GlobalContextInternal } 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:
|
|
49
|
+
_globalContext: GlobalContextInternal;
|
|
50
50
|
/** @experimental This is a beta feature https://vike.dev/getGlobalContext */
|
|
51
51
|
globalContext: import("../globalContext.js").GlobalContextPublic;
|
|
52
52
|
_pageContextInit: {
|
|
@@ -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:
|
|
103
|
+
_globalContext: GlobalContextInternal;
|
|
104
104
|
/** @experimental This is a beta feature https://vike.dev/getGlobalContext */
|
|
105
105
|
globalContext: import("../globalContext.js").GlobalContextPublic;
|
|
106
106
|
_pageContextInit: {
|
|
@@ -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:
|
|
140
|
+
declare function prerender404Page(pageContextInit_: Record<string, unknown> | null, globalContext: GlobalContextInternal): 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:
|
|
158
|
+
_globalContext: GlobalContextInternal;
|
|
159
159
|
/** @experimental This is a beta feature https://vike.dev/getGlobalContext */
|
|
160
160
|
globalContext: import("../globalContext.js").GlobalContextPublic;
|
|
161
161
|
_pageContextInit: {
|
|
@@ -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:
|
|
212
|
+
_globalContext: GlobalContextInternal;
|
|
213
213
|
/** @experimental This is a beta feature https://vike.dev/getGlobalContext */
|
|
214
214
|
globalContext: import("../globalContext.js").GlobalContextPublic;
|
|
215
215
|
_pageContextInit: {
|
|
@@ -251,7 +251,7 @@ declare function getPageContextInitEnhanced(pageContextInit: {
|
|
|
251
251
|
urlOriginal: string;
|
|
252
252
|
headersOriginal?: unknown;
|
|
253
253
|
headers?: unknown;
|
|
254
|
-
}, globalContext:
|
|
254
|
+
}, globalContext: GlobalContextInternal, { 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:
|
|
275
|
+
_globalContext: GlobalContextInternal;
|
|
276
276
|
/** @experimental This is a beta feature https://vike.dev/getGlobalContext */
|
|
277
277
|
globalContext: import("../globalContext.js").GlobalContextPublic;
|
|
278
278
|
_pageContextInit: {
|
|
@@ -17,7 +17,6 @@ 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';
|
|
21
20
|
async function renderPageAlreadyRouted(pageContext) {
|
|
22
21
|
// pageContext.pageId can either be the:
|
|
23
22
|
// - ID of the page matching the routing, or the
|
|
@@ -112,14 +111,13 @@ async function getPageContextInitEnhanced(pageContextInit, globalContext, { ssr:
|
|
|
112
111
|
isClientSideNavigation: false
|
|
113
112
|
} } = {}) {
|
|
114
113
|
assert(pageContextInit.urlOriginal);
|
|
115
|
-
const { baseServer, baseAssets } = resolveBaseRuntime(globalContext);
|
|
116
114
|
const pageContextInitEnhanced = {};
|
|
117
115
|
objectAssign(pageContextInitEnhanced, pageContextInit);
|
|
118
116
|
objectAssign(pageContextInitEnhanced, {
|
|
119
117
|
_objectCreatedByVike: true,
|
|
120
118
|
// The following is defined on `pageContext` because we can eventually make these non-global
|
|
121
|
-
_baseServer: baseServer,
|
|
122
|
-
_baseAssets: baseAssets,
|
|
119
|
+
_baseServer: globalContext.baseServer,
|
|
120
|
+
_baseAssets: globalContext.baseAssets,
|
|
123
121
|
// TODO/now: add meta.default
|
|
124
122
|
_includeAssetsImportedByServer: globalContext.config.includeAssetsImportedByServer ?? true,
|
|
125
123
|
// TODO/soon: use GloablContext instead
|
|
@@ -18,7 +18,6 @@ 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';
|
|
22
21
|
const globalObject = getGlobalObject('runtime/renderPage.ts', {
|
|
23
22
|
httpRequestsCount: 0
|
|
24
23
|
});
|
|
@@ -337,7 +336,6 @@ function assertIsNotViteRequest(urlPathname, urlOriginal) {
|
|
|
337
336
|
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')}`);
|
|
338
337
|
}
|
|
339
338
|
async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
|
|
340
|
-
const { baseServer } = resolveBaseRuntime(globalContext);
|
|
341
339
|
const { trailingSlash, disableUrlNormalization } = globalContext.config;
|
|
342
340
|
if (disableUrlNormalization)
|
|
343
341
|
return null;
|
|
@@ -345,7 +343,7 @@ async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
|
|
|
345
343
|
const { isPageContextRequest } = handlePageContextRequestUrl(urlOriginal);
|
|
346
344
|
if (isPageContextRequest)
|
|
347
345
|
return null;
|
|
348
|
-
const urlNormalized = normalizeUrlPathname(urlOriginal, trailingSlash ?? false, baseServer);
|
|
346
|
+
const urlNormalized = normalizeUrlPathname(urlOriginal, trailingSlash ?? false, globalContext.baseServer);
|
|
349
347
|
if (!urlNormalized)
|
|
350
348
|
return null;
|
|
351
349
|
logRuntimeInfo?.(`URL normalized from ${pc.cyan(urlOriginal)} to ${pc.cyan(urlNormalized)} (https://vike.dev/url-normalization)`, httpRequestId, 'info');
|
|
@@ -355,8 +353,7 @@ async function normalizeUrl(pageContextInit, globalContext, httpRequestId) {
|
|
|
355
353
|
return pageContextHttpResponse;
|
|
356
354
|
}
|
|
357
355
|
async function getPermanentRedirect(pageContextInit, globalContext, httpRequestId) {
|
|
358
|
-
const
|
|
359
|
-
const urlWithoutBase = removeBaseServer(pageContextInit.urlOriginal, baseServer);
|
|
356
|
+
const urlWithoutBase = removeBaseServer(pageContextInit.urlOriginal, globalContext.baseServer);
|
|
360
357
|
let origin = null;
|
|
361
358
|
let urlTargetExternal = null;
|
|
362
359
|
let urlTarget = modifyUrlPathname(urlWithoutBase, (urlPathname) => {
|
|
@@ -387,9 +384,8 @@ async function getPermanentRedirect(pageContextInit, globalContext, httpRequestI
|
|
|
387
384
|
}
|
|
388
385
|
if (normalize(urlTarget) === normalize(urlWithoutBase))
|
|
389
386
|
return null;
|
|
390
|
-
const { baseServer } = resolveBaseRuntime(globalContext);
|
|
391
387
|
if (!originChanged)
|
|
392
|
-
urlTarget = prependBase(urlTarget, baseServer);
|
|
388
|
+
urlTarget = prependBase(urlTarget, globalContext.baseServer);
|
|
393
389
|
assert(urlTarget !== pageContextInit.urlOriginal);
|
|
394
390
|
}
|
|
395
391
|
logRuntimeInfo?.(`Permanent redirection defined by config.redirects (https://vike.dev/redirects)`, httpRequestId, 'info');
|
|
@@ -453,7 +449,7 @@ pageContextNominalPageInit, httpRequestId, pageContextErrorPageInit, globalConte
|
|
|
453
449
|
return { pageContextAbort };
|
|
454
450
|
}
|
|
455
451
|
async function assertBaseUrl(pageContextInit, globalContext) {
|
|
456
|
-
const { baseServer } =
|
|
452
|
+
const { baseServer } = globalContext;
|
|
457
453
|
const { urlOriginal } = pageContextInit;
|
|
458
454
|
const { urlWithoutPageContextRequestSuffix } = handlePageContextRequestUrl(urlOriginal);
|
|
459
455
|
const { hasBaseServer } = parseUrl(urlWithoutPageContextRequestSuffix, baseServer);
|
|
@@ -9,7 +9,7 @@ import { setGlobalContext_isProduction } from '../runtime/globalContext.js';
|
|
|
9
9
|
*/
|
|
10
10
|
async function createDevMiddleware(options = {}) {
|
|
11
11
|
setGlobalContext_isProduction(false);
|
|
12
|
-
const
|
|
12
|
+
const viteConfigFromOptions = {
|
|
13
13
|
...options.viteConfig,
|
|
14
14
|
server: {
|
|
15
15
|
...options.viteConfig?.server,
|
|
@@ -17,8 +17,8 @@ async function createDevMiddleware(options = {}) {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
if (options.root)
|
|
20
|
-
|
|
21
|
-
const { viteConfigEnhanced } = await prepareViteApiCall(
|
|
20
|
+
viteConfigFromOptions.root = options.root;
|
|
21
|
+
const { viteConfigEnhanced } = await prepareViteApiCall(viteConfigFromOptions, 'dev');
|
|
22
22
|
const server = await createServer(viteConfigEnhanced);
|
|
23
23
|
const devMiddleware = server.middlewares;
|
|
24
24
|
return { devMiddleware, viteServer: server, viteConfig: server.config };
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
export { resolveBase };
|
|
2
|
-
export {
|
|
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
|
-
};
|
|
2
|
+
export type { BaseUrlsResolved };
|
|
10
3
|
type BaseUrlsResolved = {
|
|
11
4
|
baseServer: string;
|
|
12
5
|
baseAssets: string;
|
|
13
6
|
};
|
|
14
|
-
declare function resolveBaseRuntime(globalContext: GlobalContext): BaseUrlsResolved;
|
|
15
7
|
declare function resolveBase(baseViteOriginal: string | null, baseServerUnresolved: string | null, baseAssetsUnresolved: string | null): BaseUrlsResolved;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
export { resolveBase };
|
|
2
|
-
export { resolveBaseRuntime };
|
|
3
|
-
export { resolveBaseFromResolvedConfig };
|
|
4
2
|
import { assert, assertUsage, isBaseServer, isBaseAssets } from './utils.js';
|
|
5
3
|
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
|
-
}
|
|
17
4
|
function resolveBase(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved) {
|
|
18
5
|
if (baseViteOriginal === '/__UNSET__')
|
|
19
6
|
baseViteOriginal = null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getPageConfigsRuntime };
|
|
2
2
|
export { getAllPageIds };
|
|
3
3
|
import type { PageFile } from './getPageFiles.js';
|
|
4
|
-
import { type ConfigUserFriendly } 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[];
|
|
@@ -9,5 +9,6 @@ declare function getPageConfigsRuntime(virtualFileExports: unknown): {
|
|
|
9
9
|
pageConfigs: PageConfigRuntime[];
|
|
10
10
|
pageConfigGlobal: PageConfigGlobalRuntime;
|
|
11
11
|
globalConfig: ConfigUserFriendly;
|
|
12
|
+
pageConfigsUserFriendly: PageConfigsUserFriendly;
|
|
12
13
|
};
|
|
13
14
|
declare function getAllPageIds(pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[]): string[];
|
|
@@ -8,7 +8,16 @@ function getPageConfigsRuntime(virtualFileExports) {
|
|
|
8
8
|
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
|
|
9
9
|
// TODO/now: re-use this call, instead of calling it twice
|
|
10
10
|
const globalConfig = getPageConfigUserFriendlyNew(pageConfigGlobal);
|
|
11
|
-
|
|
11
|
+
// TODO/now DEDUPE
|
|
12
|
+
const pageConfigsUserFriendly = Object.fromEntries(pageConfigs.map((pageConfig) => {
|
|
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];
|
|
19
|
+
}));
|
|
20
|
+
return { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig, pageConfigsUserFriendly };
|
|
12
21
|
}
|
|
13
22
|
function getAllPageIds(pageFilesAll, pageConfigs) {
|
|
14
23
|
const fileIds = pageFilesAll.filter(({ isDefaultPageFile }) => !isDefaultPageFile).map(({ pageId }) => pageId);
|
|
@@ -2,6 +2,7 @@ export { getPageConfigUserFriendlyOld };
|
|
|
2
2
|
export { getPageConfigUserFriendlyNew };
|
|
3
3
|
export type { ConfigUserFriendly };
|
|
4
4
|
export type { PageConfigUserFriendly };
|
|
5
|
+
export type { PageConfigsUserFriendly };
|
|
5
6
|
export type { Source };
|
|
6
7
|
export type { Sources };
|
|
7
8
|
export type { From };
|
|
@@ -9,7 +10,7 @@ export type { ExportsAll };
|
|
|
9
10
|
export type { ConfigEntries };
|
|
10
11
|
import type { FileType } from '../getPageFiles/fileTypes.js';
|
|
11
12
|
import type { PageFile } from '../getPageFiles/getPageFileObject.js';
|
|
12
|
-
import type { ConfigValues, PageConfigRuntimeLoaded } from './PageConfig.js';
|
|
13
|
+
import type { ConfigValues, PageConfigGlobalRuntime, PageConfigRuntimeLoaded } from './PageConfig.js';
|
|
13
14
|
import { type ConfigDefinedAtOptional } from './getConfigDefinedAt.js';
|
|
14
15
|
import type { ConfigResolved } from './Config/PageContextConfig.js';
|
|
15
16
|
type ExportsAll = Record<string, {
|
|
@@ -73,6 +74,11 @@ type SourceConfigsComputed = {
|
|
|
73
74
|
type: 'configsComputed';
|
|
74
75
|
value: unknown;
|
|
75
76
|
};
|
|
77
|
+
type PageConfigsUserFriendly = Record<string, // pageId
|
|
78
|
+
// pageId
|
|
79
|
+
ConfigUserFriendly & {
|
|
80
|
+
route: string | null;
|
|
81
|
+
}>;
|
|
76
82
|
type ConfigUserFriendly = {
|
|
77
83
|
config: ConfigResolved;
|
|
78
84
|
_source: Source;
|
|
@@ -82,4 +88,4 @@ type ConfigUserFriendly = {
|
|
|
82
88
|
declare function getPageConfigUserFriendlyNew(pageConfig: {
|
|
83
89
|
configValues: ConfigValues;
|
|
84
90
|
}): ConfigUserFriendly;
|
|
85
|
-
declare function getPageConfigUserFriendlyOld(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null): PageConfigUserFriendly;
|
|
91
|
+
declare function getPageConfigUserFriendlyOld(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null, pageConfigGlobal: PageConfigGlobalRuntime): PageConfigUserFriendly;
|
|
@@ -14,7 +14,7 @@ function getPageConfigUserFriendlyNew(pageConfig) {
|
|
|
14
14
|
_from: res.from
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
17
|
+
function getPageConfigUserFriendlyOld(pageFiles, pageConfig, pageConfigGlobal) {
|
|
18
18
|
const config = {};
|
|
19
19
|
const configEntries = {}; // TODO/v1-release: remove
|
|
20
20
|
const exportsAll = {}; // TODO/v1-release: remove
|
|
@@ -39,7 +39,9 @@ function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
|
39
39
|
let sources;
|
|
40
40
|
let from;
|
|
41
41
|
if (pageConfig) {
|
|
42
|
-
const res = getPageConfigUserFriendlyV1Desin(
|
|
42
|
+
const res = getPageConfigUserFriendlyV1Desin({
|
|
43
|
+
configValues: { ...pageConfigGlobal.configValues, ...pageConfig.configValues }
|
|
44
|
+
});
|
|
43
45
|
source = res.source;
|
|
44
46
|
sources = res.sources;
|
|
45
47
|
from = res.from;
|
|
@@ -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
|
|
11
|
+
// Remove all arguments and use GlobalContextInternal 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?.()));
|
|
@@ -12,6 +12,7 @@ import type { ConfigEntries, ExportsAll, From, Source, Sources } from './page-co
|
|
|
12
12
|
import type { Config } from './page-configs/Config.js';
|
|
13
13
|
import type { PageContextConfig } from './page-configs/Config/PageContextConfig.js';
|
|
14
14
|
import type { AbortStatusCode } from './route/abort.js';
|
|
15
|
+
import type { GlobalContextPublic } from '../node/runtime/globalContext.js';
|
|
15
16
|
type PageContextServer<Data = unknown> = PageContextBuiltInServer<Data> & Vike.PageContext;
|
|
16
17
|
type PageContext<Data = unknown> = PageContextClient<Data> | PageContextServer<Data>;
|
|
17
18
|
type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> & Vike.PageContext;
|
|
@@ -118,6 +119,14 @@ type PageContextBuiltInCommon<Data> = {
|
|
|
118
119
|
source: Source;
|
|
119
120
|
/** @experimental https://github.com/vikejs/vike/issues/1268 */
|
|
120
121
|
sources: Sources;
|
|
122
|
+
/**
|
|
123
|
+
* Information shared by all pages.
|
|
124
|
+
*
|
|
125
|
+
* https://vike.dev/getGlobalContext
|
|
126
|
+
*
|
|
127
|
+
* @experimental
|
|
128
|
+
*/
|
|
129
|
+
globalContext: GlobalContextPublic;
|
|
121
130
|
/** @deprecated */
|
|
122
131
|
url: string;
|
|
123
132
|
/** @deprecated */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.222-commit-207e079";
|
|
@@ -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.222-commit-207e079';
|
|
@@ -22,7 +22,7 @@ function assertSingleInstance() {
|
|
|
22
22
|
const versions = unique(globalObject.instances);
|
|
23
23
|
assertUsage(versions.length <= 1,
|
|
24
24
|
// DO *NOT* patch vike to remove this error: because of multiple conflicting versions, you *will* eventually encounter insidious issues that hard to debug and potentially a security hazard, see for example https://github.com/vikejs/vike/issues/1108
|
|
25
|
-
`vike@${pc.bold(versions[0])} and vike@${pc.bold(versions[1])} loaded but
|
|
25
|
+
`vike@${pc.bold(versions[0])} and vike@${pc.bold(versions[1])} loaded but it's forbidden to load different versions`);
|
|
26
26
|
}
|
|
27
27
|
if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
|
|
28
28
|
/*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugActivated };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
declare const flags: readonly ["vike:error", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"
|
|
4
|
+
declare const flags: readonly ["vike:crawl", "vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
5
5
|
type Flag = (typeof flags)[number];
|
|
6
6
|
type Debug = ReturnType<typeof createDebugger>;
|
|
7
7
|
type Options = {
|
package/dist/esm/utils/debug.js
CHANGED
|
@@ -12,7 +12,9 @@ import { isArray } from './isArray.js';
|
|
|
12
12
|
assert(!isBrowser());
|
|
13
13
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
14
14
|
const flags = [
|
|
15
|
+
'vike:crawl',
|
|
15
16
|
'vike:error',
|
|
17
|
+
'vike:esbuild-resolve',
|
|
16
18
|
'vike:extractAssets',
|
|
17
19
|
'vike:extractExportNames',
|
|
18
20
|
'vike:glob',
|
|
@@ -25,9 +27,9 @@ const flags = [
|
|
|
25
27
|
'vike:routing',
|
|
26
28
|
'vike:setup',
|
|
27
29
|
'vike:stream',
|
|
28
|
-
'vike:virtual-files'
|
|
29
|
-
'vike:esbuild-resolve'
|
|
30
|
+
'vike:virtual-files'
|
|
30
31
|
];
|
|
32
|
+
const flagsSkipWildcard = ['vike:log'];
|
|
31
33
|
const flagRegex = /\bvike:[a-zA-Z-]+/g;
|
|
32
34
|
assertFlagsActivated();
|
|
33
35
|
function createDebugger(flag, optionsGlobal) {
|
|
@@ -72,8 +74,8 @@ function debug_(flag, options, ...msgs) {
|
|
|
72
74
|
function isDebugActivated(flag) {
|
|
73
75
|
checkType(flag);
|
|
74
76
|
assert(flags.includes(flag));
|
|
75
|
-
const flagsActivated = getFlagsActivated();
|
|
76
|
-
const isActivated = flagsActivated.includes(flag);
|
|
77
|
+
const { flagsActivated, all } = getFlagsActivated();
|
|
78
|
+
const isActivated = flagsActivated.includes(flag) || (all && !flagsSkipWildcard.includes(flag));
|
|
77
79
|
return isActivated;
|
|
78
80
|
}
|
|
79
81
|
function formatMsg(info, options, padding, position) {
|
|
@@ -137,7 +139,7 @@ function replaceFunctionSerializer(_key, value) {
|
|
|
137
139
|
return value;
|
|
138
140
|
}
|
|
139
141
|
function assertFlagsActivated() {
|
|
140
|
-
const flagsActivated = getFlagsActivated();
|
|
142
|
+
const { flagsActivated } = getFlagsActivated();
|
|
141
143
|
flagsActivated.forEach((flag) => {
|
|
142
144
|
assertUsage(flags.includes(flag), `Unknown DEBUG flag ${pc.cyan(flag)}. Valid flags:\n${flags.map((f) => ` ${pc.cyan(f)}`).join('\n')}`);
|
|
143
145
|
});
|
|
@@ -145,7 +147,8 @@ function assertFlagsActivated() {
|
|
|
145
147
|
function getFlagsActivated() {
|
|
146
148
|
const DEBUG = getDEBUG() ?? '';
|
|
147
149
|
const flagsActivated = DEBUG.match(flagRegex) ?? [];
|
|
148
|
-
|
|
150
|
+
const all = DEBUG.includes('vike:*');
|
|
151
|
+
return { flagsActivated, all };
|
|
149
152
|
}
|
|
150
153
|
function getDEBUG() {
|
|
151
154
|
let DEBUG;
|