vike 0.4.236-commit-eab75f6 → 0.4.237-commit-85e89b1
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/client/runtime-client-routing/globalContext.js +2 -2
- package/dist/cjs/client/runtime-server-routing/globalContext.js +2 -2
- package/dist/cjs/client/shared/createGetGlobalContextClient.js +5 -7
- package/dist/cjs/node/api/preview.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +4 -4
- package/dist/cjs/node/runtime/globalContext.js +21 -22
- package/dist/cjs/node/runtime/html/serializeContext.js +8 -47
- package/dist/cjs/node/runtime/html/stream.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +3 -3
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +4 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsDev.js → retrievePageAssetsDev.js} +21 -6
- package/dist/cjs/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +5 -34
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +50 -14
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +22 -9
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -3
- package/dist/cjs/node/runtime/renderPage.js +7 -6
- package/dist/cjs/node/shared/virtualFileId.js +110 -0
- package/dist/cjs/node/vite/index.js +3 -3
- package/dist/cjs/node/vite/onLoad.js +5 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +10 -10
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +20 -11
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -10
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +46 -44
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +5 -12
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +5 -5
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +5 -1
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +2 -6
- package/dist/cjs/node/vite/plugins/pluginPreview.js +11 -4
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +5 -12
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +7 -9
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFileEntry.js → generateVirtualFileGlobalEntryWithOldDesign.js} +11 -11
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -12
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +67 -0
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +14 -12
- package/dist/cjs/node/vite/shared/findPageFiles.js +1 -1
- package/dist/cjs/node/vite/shared/{resolveClientEntriesDev.js → getClientEntrySrcDev.js} +2 -2
- package/dist/cjs/node/vite/shared/getMagicString.js +1 -1
- package/dist/cjs/node/vite/shared/getOutDirs.js +18 -12
- package/dist/cjs/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/cjs/node/vite/shared/isViteServerBuild.js +54 -31
- package/dist/cjs/node/vite/shared/loggerVite.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +8 -19
- package/dist/cjs/shared/createGlobalContextShared.js +23 -10
- package/dist/cjs/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -26
- package/dist/cjs/shared/modifyUrlSameOrigin.js +9 -4
- package/dist/cjs/shared/page-configs/loadPageEntry.js +25 -0
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +4 -4
- package/dist/cjs/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js} +2 -2
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +15 -16
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/cast.js +1 -1
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +12 -12
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +35 -48
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/globalContext.js +2 -2
- package/dist/esm/client/runtime-client-routing/history.d.ts +3 -5
- package/dist/esm/client/runtime-client-routing/history.js +39 -22
- package/dist/esm/client/runtime-client-routing/initClientRouter.js +2 -3
- package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
- package/dist/esm/client/runtime-client-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +4 -4
- package/dist/esm/client/runtime-client-routing/utils.d.ts +2 -0
- package/dist/esm/client/runtime-client-routing/utils.js +2 -0
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +3 -3
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +2 -2
- package/dist/esm/client/runtime-server-routing/globalContext.js +2 -2
- package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +3 -3
- package/dist/esm/client/shared/createGetGlobalContextClient.js +5 -7
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +1 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +4 -4
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
- package/dist/esm/node/api/preview.js +1 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +9 -9
- package/dist/esm/node/prerender/runPrerender.js +4 -4
- package/dist/esm/node/runtime/globalContext.d.ts +10 -10
- package/dist/esm/node/runtime/globalContext.js +21 -22
- package/dist/esm/node/runtime/html/serializeContext.d.ts +8 -3
- package/dist/esm/node/runtime/html/serializeContext.js +8 -47
- package/dist/esm/node/runtime/html/stream.js +1 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.js +3 -3
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +4 -7
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrievePageAssetsDev.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/{retrieveAssetsDev.js → retrievePageAssetsDev.js} +22 -7
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrievePageAssetsProd.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/{retrieveAssetsProd.js → retrievePageAssetsProd.js} +19 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +0 -6
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -33
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.js +51 -15
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +25 -12
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -3
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +10 -11
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -3
- package/dist/esm/node/runtime/renderPage.d.ts +3 -2
- package/dist/esm/node/runtime/renderPage.js +7 -6
- package/dist/esm/node/shared/virtualFileId.d.ts +28 -0
- package/dist/esm/node/shared/virtualFileId.js +107 -0
- package/dist/esm/node/vite/index.js +3 -3
- package/dist/esm/node/vite/onLoad.js +5 -3
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +11 -11
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +1 -0
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +21 -12
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildEntry.js +4 -4
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +5 -8
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +47 -45
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +6 -10
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +4 -4
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +6 -2
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +2 -6
- package/dist/esm/node/vite/plugins/pluginPreview.js +13 -6
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +6 -10
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntry.d.ts +2 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigsEager.js → generateVirtualFileGlobalEntry.js} +7 -9
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.d.ts +6 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFileEntry.js → generateVirtualFileGlobalEntryWithOldDesign.js} +11 -11
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFilePageEntry.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/{getVirtualFilePageConfigLazy.js → generateVirtualFilePageEntry.js} +10 -12
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +14 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +65 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +14 -12
- package/dist/esm/node/vite/shared/findPageFiles.js +1 -1
- package/dist/esm/node/vite/shared/getClientEntrySrcDev.d.ts +4 -0
- package/dist/esm/node/vite/shared/{resolveClientEntriesDev.js → getClientEntrySrcDev.js} +2 -2
- package/dist/esm/node/vite/shared/getMagicString.js +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +6 -3
- package/dist/esm/node/vite/shared/getOutDirs.js +19 -13
- package/dist/esm/node/vite/shared/getViteConfigRuntime.js +1 -1
- package/dist/esm/node/vite/shared/isViteServerBuild.d.ts +14 -11
- package/dist/esm/node/vite/shared/isViteServerBuild.js +55 -31
- package/dist/esm/node/vite/shared/loggerVite.js +1 -1
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +3 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +10 -21
- package/dist/esm/shared/createGlobalContextShared.d.ts +6 -6
- package/dist/esm/shared/createGlobalContextShared.js +25 -12
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.d.ts → parseVirtualFileExportsGlobalEntry.d.ts} +2 -2
- package/dist/esm/shared/getPageFiles/{parseVirtualFileExports.js → parseVirtualFileExportsGlobalEntry.js} +20 -26
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/execHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/modifyUrlSameOrigin.d.ts +1 -1
- package/dist/esm/shared/modifyUrlSameOrigin.js +9 -4
- package/dist/esm/shared/page-configs/loadPageEntry.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadPageEntry.js +23 -0
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +9 -9
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +4 -4
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +1 -1
- package/dist/esm/shared/page-configs/serialize/{parsePageConfigs.d.ts → parsePageConfigsSerialized.d.ts} +2 -2
- package/dist/esm/shared/page-configs/serialize/{parsePageConfigs.js → parsePageConfigsSerialized.js} +2 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +15 -16
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/Config.d.ts +33 -98
- package/dist/esm/types/PageConfig.d.ts +9 -7
- package/dist/esm/types/VikeNamespace.d.ts +13 -0
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/cast.d.ts +2 -2
- package/dist/esm/utils/cast.js +1 -1
- package/dist/esm/utils/objectFilter.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +0 -31
- package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -45
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -23
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +0 -11
- package/dist/cjs/shared/page-configs/loadConfigValues.js +0 -21
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.d.ts +0 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +0 -4
- package/dist/esm/node/shared/virtualFiles/virtualFileEntry.d.ts +0 -11
- package/dist/esm/node/shared/virtualFiles/virtualFileEntry.js +0 -28
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.d.ts +0 -9
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +0 -43
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFileEntry.d.ts +0 -5
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigsEager.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.d.ts +0 -7
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -21
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.d.ts +0 -3
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +0 -9
- package/dist/esm/node/vite/shared/resolveClientEntriesDev.d.ts +0 -4
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadConfigValues.js +0 -19
|
@@ -1,30 +1,66 @@
|
|
|
1
1
|
export { handlePageContextRequestUrl };
|
|
2
2
|
import { pageContextJsonFileExtension, doNotCreateExtraDirectory } from '../../../shared/getPageContextRequestUrl.js';
|
|
3
|
-
import {
|
|
3
|
+
import { modifyUrl } from '../../../shared/modifyUrl.js';
|
|
4
|
+
import { baseServer, parseUrl, assert, slice, isObject, hasProp } from '../utils.js';
|
|
4
5
|
// See also shared/getPageContextRequestUrl.ts
|
|
5
6
|
function handlePageContextRequestUrl(url) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const urlParsed = parseUrl(url, baseServer);
|
|
8
|
+
if (!isMatch(urlParsed)) {
|
|
9
|
+
return {
|
|
10
|
+
isPageContextJsonRequest: false,
|
|
11
|
+
urlWithoutPageContextRequestSuffix: url,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const { urlWithoutPageContextRequestSuffix, searchVikeArgs } = processUrl(urlParsed, url);
|
|
16
|
+
const previousUrl = parseSearchVikeArgs(searchVikeArgs);
|
|
17
|
+
return {
|
|
18
|
+
/* TO-DO/soon/once: pass & use previousUrl
|
|
19
|
+
isPageContextJsonRequest: { previousUrl },
|
|
20
|
+
/*/
|
|
21
|
+
isPageContextJsonRequest: true,
|
|
22
|
+
//*/
|
|
23
|
+
urlWithoutPageContextRequestSuffix,
|
|
24
|
+
};
|
|
8
25
|
}
|
|
9
|
-
return { urlWithoutPageContextRequestSuffix: removePageContextUrlSuffix(url), isPageContextRequest: true };
|
|
10
26
|
}
|
|
11
|
-
function
|
|
12
|
-
const { pathnameOriginal, pathname } =
|
|
13
|
-
assert(
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
return pathnameOriginal.endsWith(pageContextJsonFileExtension);
|
|
27
|
+
function isMatch(urlParsed) {
|
|
28
|
+
const { pathnameOriginal, pathname } = urlParsed;
|
|
29
|
+
assert(pathname.endsWith(pageContextJsonFileExtension) === pathnameOriginal.endsWith(pageContextJsonFileExtension));
|
|
30
|
+
return pathname.endsWith(pageContextJsonFileExtension);
|
|
17
31
|
}
|
|
18
|
-
function
|
|
19
|
-
const urlParsed = parseUrl(url, baseServer);
|
|
32
|
+
function processUrl(urlParsed, url) {
|
|
20
33
|
// We cannot use `urlParsed.pathname` because it would break the `urlParsed.pathnameOriginal` value of subsequent `parseUrl()` calls.
|
|
21
|
-
const {
|
|
34
|
+
const { pathnameOriginal, search } = urlParsed;
|
|
22
35
|
assert(doNotCreateExtraDirectory === false);
|
|
23
36
|
const urlSuffix = `/index${pageContextJsonFileExtension}`;
|
|
24
37
|
assert(pathnameOriginal.endsWith(urlSuffix), { url });
|
|
25
38
|
let pathnameModified = slice(pathnameOriginal, 0, -1 * urlSuffix.length);
|
|
26
39
|
if (pathnameModified === '')
|
|
27
40
|
pathnameModified = '/';
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
const searchVikeArgs = search?._vike;
|
|
42
|
+
const urlWithoutPageContextRequestSuffix = modifyUrl(url, {
|
|
43
|
+
pathname: pathnameModified,
|
|
44
|
+
search: {
|
|
45
|
+
_vike: searchVikeArgs ? null : undefined,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
searchVikeArgs,
|
|
50
|
+
urlWithoutPageContextRequestSuffix,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function parseSearchVikeArgs(searchVikeArgs) {
|
|
54
|
+
const args = {
|
|
55
|
+
previousUrl: null,
|
|
56
|
+
};
|
|
57
|
+
if (searchVikeArgs) {
|
|
58
|
+
const parsed = JSON.parse(searchVikeArgs);
|
|
59
|
+
assert(isObject(parsed));
|
|
60
|
+
if ('previousUrl' in parsed) {
|
|
61
|
+
assert(hasProp(parsed, 'previousUrl', 'string'));
|
|
62
|
+
args.previousUrl = parsed.previousUrl;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return args;
|
|
30
66
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { loadPageConfigsLazyServerSideAndExecHook };
|
|
2
2
|
export type { PageContext_loadPageConfigsLazyServerSide };
|
|
3
3
|
export type { PageConfigsLazy };
|
|
4
|
-
import { type
|
|
4
|
+
import { type VikeConfigPublicPageLazyLoaded } from '../../../shared/getPageFiles.js';
|
|
5
5
|
import { PromiseType } from '../utils.js';
|
|
6
6
|
import { PageContextGetPageAssets, type PageAsset } from './getPageAssets.js';
|
|
7
7
|
import { type PageContextDebugRouteMatches } from './debugPageFiles.js';
|
|
@@ -15,7 +15,7 @@ type PageContext_loadPageConfigsLazyServerSide = PageContextGetPageAssets & Page
|
|
|
15
15
|
_globalContext: GlobalContextServerInternal;
|
|
16
16
|
};
|
|
17
17
|
type PageConfigsLazy = PromiseType<ReturnType<typeof loadPageConfigsLazyServerSide>>;
|
|
18
|
-
declare function loadPageConfigsLazyServerSideAndExecHook<PageContext extends PageContext_loadPageConfigsLazyServerSide & PageContextExecuteHook>(pageContext: PageContext): Promise<PageContext &
|
|
18
|
+
declare function loadPageConfigsLazyServerSideAndExecHook<PageContext extends PageContext_loadPageConfigsLazyServerSide & PageContextExecuteHook>(pageContext: PageContext): Promise<PageContext & VikeConfigPublicPageLazyLoaded & {
|
|
19
19
|
Page: unknown;
|
|
20
20
|
_isHtmlOnly: boolean;
|
|
21
21
|
_passToClient: PassToClient;
|
|
@@ -24,7 +24,7 @@ declare function loadPageConfigsLazyServerSideAndExecHook<PageContext extends Pa
|
|
|
24
24
|
} & {
|
|
25
25
|
__getPageAssets: () => Promise<PageAsset[]>;
|
|
26
26
|
}>;
|
|
27
|
-
declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPageConfigsLazyServerSide): Promise<
|
|
27
|
+
declare function loadPageConfigsLazyServerSide(pageContext: PageContext_loadPageConfigsLazyServerSide): Promise<VikeConfigPublicPageLazyLoaded & {
|
|
28
28
|
Page: unknown;
|
|
29
29
|
_isHtmlOnly: boolean;
|
|
30
30
|
_passToClient: PassToClient;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { loadPageConfigsLazyServerSideAndExecHook };
|
|
2
|
-
import { getPageFilesServerSide } from '../../../shared/getPageFiles.js';
|
|
3
|
-
import {
|
|
2
|
+
import { getPageFilesServerSide, } from '../../../shared/getPageFiles.js';
|
|
3
|
+
import { resolveVikeConfigPublicPageLazyLoaded } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
4
4
|
import { analyzePageClientSideInit } from '../../../shared/getPageFiles/analyzePageClientSide.js';
|
|
5
|
-
import { assertUsage, assertWarning, hasProp, objectAssign } from '../utils.js';
|
|
5
|
+
import { assertUsage, assertWarning, hasProp, isArray, isObject, objectAssign } from '../utils.js';
|
|
6
6
|
import { getPageAssets } from './getPageAssets.js';
|
|
7
7
|
import { debugPageFiles } from './debugPageFiles.js';
|
|
8
8
|
import { findPageConfig } from '../../../shared/page-configs/findPageConfig.js';
|
|
9
9
|
import { analyzePage } from './analyzePage.js';
|
|
10
|
-
import {
|
|
10
|
+
import { loadPageEntry } from '../../../shared/page-configs/loadPageEntry.js';
|
|
11
11
|
import { execHookServer } from './execHookServer.js';
|
|
12
12
|
import { getCacheControl } from './getCacheControl.js';
|
|
13
13
|
async function loadPageConfigsLazyServerSideAndExecHook(pageContext) {
|
|
@@ -29,19 +29,32 @@ async function loadPageConfigsLazyServerSide(pageContext) {
|
|
|
29
29
|
const { isHtmlOnly, isClientRouting, clientEntries, clientDependencies, pageFilesClientSide, pageFilesServerSide } = await analyzePage(pageContext._globalContext._pageFilesAll, pageConfig, pageContext.pageId, globalContext);
|
|
30
30
|
const isV1Design = !!pageConfig;
|
|
31
31
|
const passToClient = [];
|
|
32
|
-
const
|
|
32
|
+
const errMsgSuffix = ' should be an array of strings.';
|
|
33
33
|
if (!isV1Design) {
|
|
34
34
|
configPublicPageLazy.exportsAll.passToClient?.forEach((e) => {
|
|
35
|
-
assertUsage(hasProp(e, 'exportValue', 'string[]'), `${e.exportSource}${
|
|
35
|
+
assertUsage(hasProp(e, 'exportValue', 'string[]'), `${e.exportSource}${errMsgSuffix}`);
|
|
36
36
|
passToClient.push(...e.exportValue);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
configPublicPageLazy.from.configsCumulative.passToClient?.values.forEach((v) => {
|
|
41
|
-
const { value } = v;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const { value, definedAt } = v;
|
|
42
|
+
const errMsg = `+passToClient value defined at ${definedAt}${errMsgSuffix}`;
|
|
43
|
+
//*/ TO-DO/next-major-release: remove the passToClient once setting from the public API
|
|
44
|
+
assertUsage(isArray(value), `+passToClient value defined at ${definedAt} should be an array`);
|
|
45
|
+
const valS = value.map((el) => {
|
|
46
|
+
if (isObject(el)) {
|
|
47
|
+
assertWarning(!('once' in el), 'The passToClient once setting is deprecated and no longer has any effect. Instead, see the upcoming .once.js suffix (see https://github.com/vikejs/vike/issues/2566 for more information).', { onlyOnce: true });
|
|
48
|
+
assertUsage(hasProp(el, 'prop', 'string'), errMsg);
|
|
49
|
+
return el.prop;
|
|
50
|
+
}
|
|
51
|
+
assertUsage(typeof el === 'string', errMsg);
|
|
52
|
+
return el;
|
|
53
|
+
});
|
|
54
|
+
/*/
|
|
55
|
+
assertUsage(isArrayOfStrings(value), errMsg)
|
|
56
|
+
//*/
|
|
57
|
+
passToClient.push(...valS);
|
|
45
58
|
});
|
|
46
59
|
}
|
|
47
60
|
const pageContextAddendum = {};
|
|
@@ -106,9 +119,9 @@ async function loadPageConfigsLazyServerSide(pageContext) {
|
|
|
106
119
|
}
|
|
107
120
|
async function loadPageConfigFiles(pageFilesAll, pageConfig, pageConfigGlobal, pageId, isDev) {
|
|
108
121
|
const pageFilesServerSide = getPageFilesServerSide(pageFilesAll, pageId);
|
|
109
|
-
const pageConfigLoaded = !pageConfig ? null : await
|
|
122
|
+
const pageConfigLoaded = !pageConfig ? null : await loadPageEntry(pageConfig, isDev);
|
|
110
123
|
await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
|
|
111
|
-
const configPublicPageLazy =
|
|
124
|
+
const configPublicPageLazy = resolveVikeConfigPublicPageLazyLoaded(pageFilesServerSide, pageConfigLoaded, pageConfigGlobal);
|
|
112
125
|
return {
|
|
113
126
|
configPublicPageLazy,
|
|
114
127
|
pageFilesLoaded: pageFilesServerSide,
|
|
@@ -2,10 +2,10 @@ export { log404 };
|
|
|
2
2
|
export { getRoutesInfo };
|
|
3
3
|
import type { PageRoutes } from '../../../../shared/route/index.js';
|
|
4
4
|
import type { GlobalContextServerInternal } from '../../globalContext.js';
|
|
5
|
-
|
|
5
|
+
import type { PageContextCreated } from '../createPageContextServerSide.js';
|
|
6
|
+
declare function log404(pageContext: PageContextCreated & {
|
|
6
7
|
urlPathname: string;
|
|
7
8
|
errorWhileRendering: null | Error;
|
|
8
|
-
isClientSideNavigation: boolean;
|
|
9
9
|
_globalContext: GlobalContextServerInternal;
|
|
10
10
|
}): Promise<void>;
|
|
11
11
|
declare function getRoutesInfo(pageRoutes: PageRoutes): string | null;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { preparePageContextForPublicUsageServer };
|
|
2
2
|
export type { PageContextForPublicUsageServer };
|
|
3
3
|
import type { PageContextUrlInternal } from '../../../shared/getPageContextUrlComputed.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { VikeConfigPublicPageLazyLoaded } from '../../../shared/page-configs/resolveVikeConfigPublic.js';
|
|
5
5
|
import type { PageContextInternalServer } from '../../../types/PageContext.js';
|
|
6
6
|
import type { GlobalContextServerInternal } from '../globalContext.js';
|
|
7
|
-
type PageContextForPublicUsageServer = PageContextInternalServer &
|
|
7
|
+
type PageContextForPublicUsageServer = PageContextInternalServer & VikeConfigPublicPageLazyLoaded & {
|
|
8
8
|
urlOriginal: string;
|
|
9
9
|
/** @deprecated */
|
|
10
10
|
url: string;
|
|
@@ -14,7 +14,6 @@ type PageContextForPublicUsageServer = PageContextInternalServer & VikeConfigPub
|
|
|
14
14
|
Page: unknown;
|
|
15
15
|
pageId: string;
|
|
16
16
|
is404: null | boolean;
|
|
17
|
-
isClientSideNavigation: boolean;
|
|
18
17
|
_globalContext: GlobalContextServerInternal;
|
|
19
18
|
};
|
|
20
19
|
declare function preparePageContextForPublicUsageServer<PageContext extends PageContextForPublicUsageServer>(pageContext: PageContext): PageContext;
|
|
@@ -5,6 +5,7 @@ import { type PageContextUrlInternal } from '../../../shared/getPageContextUrlCo
|
|
|
5
5
|
import { HttpResponse } from './createHttpResponse.js';
|
|
6
6
|
import { PageContext_loadPageConfigsLazyServerSide, type PageConfigsLazy } from './loadPageConfigsLazyServerSide.js';
|
|
7
7
|
import type { PageContextCreated } from './createPageContextServerSide.js';
|
|
8
|
+
import type { PageContextBegin } from '../renderPage.js';
|
|
8
9
|
type PageContextAfterRender = {
|
|
9
10
|
httpResponse: HttpResponse;
|
|
10
11
|
errorWhileRendering: null | Error;
|
|
@@ -16,7 +17,7 @@ declare function renderPageAlreadyRouted<PageContext extends {
|
|
|
16
17
|
routeParams: Record<string, string>;
|
|
17
18
|
errorWhileRendering: null | Error;
|
|
18
19
|
_httpRequestId: number;
|
|
19
|
-
} & PageContextCreated & PageContextUrlInternal & PageContext_loadPageConfigsLazyServerSide>(pageContext: PageContext): Promise<PageContext & PageContextAfterRender>;
|
|
20
|
+
} & PageContextCreated & PageContextBegin & PageContextUrlInternal & PageContext_loadPageConfigsLazyServerSide>(pageContext: PageContext): Promise<PageContext & PageContextAfterRender>;
|
|
20
21
|
declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy & {
|
|
21
22
|
routeParams: Record<string, string>;
|
|
22
23
|
pageId: string;
|
|
@@ -41,7 +42,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
41
42
|
_globalContext: {
|
|
42
43
|
isGlobalContext: true;
|
|
43
44
|
_isOriginalObject: true;
|
|
44
|
-
|
|
45
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
45
46
|
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
46
47
|
_pageConfigs: import("../../../types/PageConfig.js").PageConfigRuntime[];
|
|
47
48
|
_pageConfigGlobal: import("../../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -54,7 +55,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
54
55
|
};
|
|
55
56
|
config: import("../../../types/index.js").ConfigResolved;
|
|
56
57
|
pages: {
|
|
57
|
-
[k: string]: import("../../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
58
|
+
[k: string]: import("../../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
58
59
|
};
|
|
59
60
|
} & (({
|
|
60
61
|
_isProduction: false;
|
|
@@ -117,7 +118,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
117
118
|
url: string;
|
|
118
119
|
} & {
|
|
119
120
|
headers: Record<string, string> | null;
|
|
120
|
-
} & import("../../../shared/getPageFiles.js").
|
|
121
|
+
} & import("../../../shared/getPageFiles.js").VikeConfigPublicPageLazyLoaded & {
|
|
121
122
|
Page: unknown;
|
|
122
123
|
_isHtmlOnly: boolean;
|
|
123
124
|
_passToClient: import("../html/serializeContext.js").PassToClient;
|
|
@@ -134,8 +135,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
134
135
|
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
135
136
|
is404: boolean;
|
|
136
137
|
} & {
|
|
137
|
-
|
|
138
|
-
_urlHandler: null;
|
|
138
|
+
_isPageContextJsonRequest: null;
|
|
139
139
|
};
|
|
140
140
|
} | {
|
|
141
141
|
documentHtml: string;
|
|
@@ -153,7 +153,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
153
153
|
_globalContext: {
|
|
154
154
|
isGlobalContext: true;
|
|
155
155
|
_isOriginalObject: true;
|
|
156
|
-
|
|
156
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
157
157
|
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
158
158
|
_pageConfigs: import("../../../types/PageConfig.js").PageConfigRuntime[];
|
|
159
159
|
_pageConfigGlobal: import("../../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -166,7 +166,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
166
166
|
};
|
|
167
167
|
config: import("../../../types/index.js").ConfigResolved;
|
|
168
168
|
pages: {
|
|
169
|
-
[k: string]: import("../../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
169
|
+
[k: string]: import("../../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
170
170
|
};
|
|
171
171
|
} & (({
|
|
172
172
|
_isProduction: false;
|
|
@@ -229,7 +229,7 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
229
229
|
url: string;
|
|
230
230
|
} & {
|
|
231
231
|
headers: Record<string, string> | null;
|
|
232
|
-
} & import("../../../shared/getPageFiles.js").
|
|
232
|
+
} & import("../../../shared/getPageFiles.js").VikeConfigPublicPageLazyLoaded & {
|
|
233
233
|
Page: unknown;
|
|
234
234
|
_isHtmlOnly: boolean;
|
|
235
235
|
_passToClient: import("../html/serializeContext.js").PassToClient;
|
|
@@ -246,7 +246,6 @@ declare function prerenderPage(pageContext: PageContextCreated & PageConfigsLazy
|
|
|
246
246
|
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
247
247
|
is404: boolean;
|
|
248
248
|
} & {
|
|
249
|
-
|
|
250
|
-
_urlHandler: null;
|
|
249
|
+
_isPageContextJsonRequest: null;
|
|
251
250
|
};
|
|
252
251
|
}>;
|
|
@@ -58,8 +58,7 @@ async function renderPageAlreadyRouted(pageContext) {
|
|
|
58
58
|
}
|
|
59
59
|
async function prerenderPage(pageContext) {
|
|
60
60
|
objectAssign(pageContext, {
|
|
61
|
-
|
|
62
|
-
_urlHandler: null,
|
|
61
|
+
_isPageContextJsonRequest: null,
|
|
63
62
|
});
|
|
64
63
|
/* Should we execute the guard() hook upon pre-rendering? Is there a use case for this?
|
|
65
64
|
* - It isn't trivial to implement, as it requires to duplicate / factor out the isAbortError() handling
|
|
@@ -68,7 +67,6 @@ async function prerenderPage(pageContext) {
|
|
|
68
67
|
await execHookDataAndOnBeforeRender(pageContext);
|
|
69
68
|
const { htmlRender, renderHook } = await execHookOnRenderHtml(pageContext);
|
|
70
69
|
assertUsage(htmlRender !== null, `Cannot pre-render ${pc.cyan(pageContext.urlOriginal)} because the ${renderHook.hookName}() hook defined by ${renderHook.hookFilePath} didn't return an HTML string.`);
|
|
71
|
-
assert(pageContext.isClientSideNavigation === false);
|
|
72
70
|
const documentHtml = await getHtmlString(htmlRender);
|
|
73
71
|
assert(typeof documentHtml === 'string');
|
|
74
72
|
if (!pageContext._usesClientRouter) {
|
|
@@ -31,7 +31,7 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
31
31
|
_globalContext: {
|
|
32
32
|
isGlobalContext: true;
|
|
33
33
|
_isOriginalObject: true;
|
|
34
|
-
|
|
34
|
+
_virtualFileExportsGlobalEntry: unknown;
|
|
35
35
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
36
36
|
_pageConfigs: import("../../types/PageConfig.js").PageConfigRuntime[];
|
|
37
37
|
_pageConfigGlobal: import("../../types/PageConfig.js").PageConfigGlobalRuntime;
|
|
@@ -44,7 +44,7 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
44
44
|
};
|
|
45
45
|
config: import("../../types/index.js").ConfigResolved;
|
|
46
46
|
pages: {
|
|
47
|
-
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").
|
|
47
|
+
[k: string]: import("../../shared/page-configs/resolveVikeConfigPublic.js").VikeConfigPublicPageEagerLoaded;
|
|
48
48
|
};
|
|
49
49
|
} & (({
|
|
50
50
|
_isProduction: false;
|
|
@@ -109,4 +109,5 @@ declare function getPageContextBegin(pageContextInit: PageContextInit, globalCon
|
|
|
109
109
|
headers: Record<string, string> | null;
|
|
110
110
|
} & {
|
|
111
111
|
_httpRequestId: number;
|
|
112
|
+
_isPageContextJsonRequest: boolean;
|
|
112
113
|
};
|
|
@@ -307,7 +307,7 @@ async function getPageContextErrorPageInit(pageContextBegin, errNominalPage, pag
|
|
|
307
307
|
return pageContext;
|
|
308
308
|
}
|
|
309
309
|
function getPageContextBegin(pageContextInit, globalContext, httpRequestId) {
|
|
310
|
-
const { isClientSideNavigation, _urlHandler } = handlePageContextUrl(pageContextInit.urlOriginal);
|
|
310
|
+
const { isClientSideNavigation, _urlHandler, _isPageContextJsonRequest } = handlePageContextUrl(pageContextInit.urlOriginal);
|
|
311
311
|
const pageContextBegin = createPageContextServerSide(pageContextInit, globalContext, {
|
|
312
312
|
isPrerendering: false,
|
|
313
313
|
ssr: {
|
|
@@ -315,13 +315,14 @@ function getPageContextBegin(pageContextInit, globalContext, httpRequestId) {
|
|
|
315
315
|
isClientSideNavigation,
|
|
316
316
|
},
|
|
317
317
|
});
|
|
318
|
-
objectAssign(pageContextBegin, { _httpRequestId: httpRequestId });
|
|
318
|
+
objectAssign(pageContextBegin, { _httpRequestId: httpRequestId, _isPageContextJsonRequest });
|
|
319
319
|
return pageContextBegin;
|
|
320
320
|
}
|
|
321
321
|
function handlePageContextUrl(urlOriginal) {
|
|
322
|
-
const {
|
|
322
|
+
const { isPageContextJsonRequest } = handlePageContextRequestUrl(urlOriginal);
|
|
323
323
|
return {
|
|
324
|
-
isClientSideNavigation:
|
|
324
|
+
isClientSideNavigation: !!isPageContextJsonRequest,
|
|
325
|
+
_isPageContextJsonRequest: isPageContextJsonRequest,
|
|
325
326
|
_urlHandler: (url) => handlePageContextRequestUrl(url).urlWithoutPageContextRequestSuffix,
|
|
326
327
|
};
|
|
327
328
|
}
|
|
@@ -345,8 +346,8 @@ async function normalizeUrl(pageContextBegin, globalContext, httpRequestId) {
|
|
|
345
346
|
if (disableUrlNormalization)
|
|
346
347
|
return null;
|
|
347
348
|
const { urlOriginal } = pageContext;
|
|
348
|
-
const {
|
|
349
|
-
if (
|
|
349
|
+
const { isPageContextJsonRequest } = handlePageContextRequestUrl(urlOriginal);
|
|
350
|
+
if (isPageContextJsonRequest)
|
|
350
351
|
return null;
|
|
351
352
|
const urlNormalized = normalizeUrlPathname(urlOriginal, trailingSlash ?? false, globalContext.baseServer);
|
|
352
353
|
if (!urlNormalized)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { parseVirtualFileId };
|
|
2
|
+
export { generateVirtualFileId };
|
|
3
|
+
export { virtualFileIdGlobalEntryServer };
|
|
4
|
+
export { virtualFileIdGlobalEntryClientSR };
|
|
5
|
+
export { virtualFileIdGlobalEntryClientCR };
|
|
6
|
+
declare const virtualFileIdGlobalEntryServer = "virtual:vike:global-entry:server";
|
|
7
|
+
declare const virtualFileIdGlobalEntryClientSR = "virtual:vike:global-entry:client:server-routing";
|
|
8
|
+
declare const virtualFileIdGlobalEntryClientCR = "virtual:vike:global-entry:client:client-routing";
|
|
9
|
+
type VirtualFileIdEntryParsed = {
|
|
10
|
+
type: 'global-entry';
|
|
11
|
+
isForClientSide: boolean;
|
|
12
|
+
isClientRouting: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'page-entry';
|
|
15
|
+
isForClientSide: boolean;
|
|
16
|
+
pageId: string;
|
|
17
|
+
isExtractAssets: boolean;
|
|
18
|
+
};
|
|
19
|
+
declare function parseVirtualFileId(id: string): false | VirtualFileIdEntryParsed;
|
|
20
|
+
declare function generateVirtualFileId(args: {
|
|
21
|
+
type: 'global-entry';
|
|
22
|
+
isForClientSide: boolean;
|
|
23
|
+
isClientRouting: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'page-entry';
|
|
26
|
+
pageId: string;
|
|
27
|
+
isForClientSide: boolean;
|
|
28
|
+
}): string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export { parseVirtualFileId };
|
|
2
|
+
export { generateVirtualFileId };
|
|
3
|
+
export { virtualFileIdGlobalEntryServer };
|
|
4
|
+
export { virtualFileIdGlobalEntryClientSR };
|
|
5
|
+
export { virtualFileIdGlobalEntryClientCR };
|
|
6
|
+
import { extractAssetsRemoveQuery } from './extractAssetsQuery.js';
|
|
7
|
+
import { assert, assertIsNotBrowser, removeVirtualFileIdPrefix } from './utils.js';
|
|
8
|
+
assertIsNotBrowser();
|
|
9
|
+
// Global entries
|
|
10
|
+
const virtualFileIdGlobalEntryServer =
|
|
11
|
+
//
|
|
12
|
+
'virtual:vike:global-entry:server';
|
|
13
|
+
const virtualFileIdGlobalEntryClientSR =
|
|
14
|
+
//
|
|
15
|
+
'virtual:vike:global-entry:client:server-routing';
|
|
16
|
+
const virtualFileIdGlobalEntryClientCR =
|
|
17
|
+
//
|
|
18
|
+
'virtual:vike:global-entry:client:client-routing';
|
|
19
|
+
// Page entries
|
|
20
|
+
const virtualFileIdPageEntryClient =
|
|
21
|
+
//
|
|
22
|
+
'virtual:vike:page-entry:client:'; // ${pageId}
|
|
23
|
+
const virtualFileIdPageEntryServer =
|
|
24
|
+
//
|
|
25
|
+
'virtual:vike:page-entry:server:'; // ${pageId}
|
|
26
|
+
// Virtual ID prefixes
|
|
27
|
+
const virtualFileIdPageEntryPrefix =
|
|
28
|
+
//
|
|
29
|
+
'virtual:vike:page-entry:';
|
|
30
|
+
const virtualFileIdGlobalEntryPrefix =
|
|
31
|
+
//
|
|
32
|
+
'virtual:vike:global-entry:';
|
|
33
|
+
const virtualFileIdGlobalEntries = [
|
|
34
|
+
virtualFileIdGlobalEntryServer,
|
|
35
|
+
virtualFileIdGlobalEntryClientCR,
|
|
36
|
+
virtualFileIdGlobalEntryClientSR,
|
|
37
|
+
];
|
|
38
|
+
assert(virtualFileIdGlobalEntries.every((v) =>
|
|
39
|
+
//
|
|
40
|
+
v.startsWith(virtualFileIdGlobalEntryPrefix)));
|
|
41
|
+
assert([virtualFileIdPageEntryClient, virtualFileIdPageEntryServer].every((v) =>
|
|
42
|
+
//
|
|
43
|
+
v.startsWith(virtualFileIdPageEntryPrefix)));
|
|
44
|
+
function parseVirtualFileId(id) {
|
|
45
|
+
id = removeVirtualFileIdPrefix(id);
|
|
46
|
+
if (!id.startsWith(virtualFileIdGlobalEntryPrefix) && !id.startsWith(virtualFileIdPageEntryPrefix))
|
|
47
|
+
return false;
|
|
48
|
+
// Global entry
|
|
49
|
+
if (id.includes(virtualFileIdGlobalEntryPrefix)) {
|
|
50
|
+
assert(virtualFileIdGlobalEntries.includes(id));
|
|
51
|
+
const isForClientSide = id !== virtualFileIdGlobalEntryServer;
|
|
52
|
+
const isClientRouting = id === virtualFileIdGlobalEntryClientCR;
|
|
53
|
+
return {
|
|
54
|
+
type: 'global-entry',
|
|
55
|
+
isForClientSide,
|
|
56
|
+
isClientRouting,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Page entry
|
|
60
|
+
if (id.includes(virtualFileIdPageEntryPrefix)) {
|
|
61
|
+
assert(id.startsWith(virtualFileIdPageEntryPrefix));
|
|
62
|
+
const idOriginal = id;
|
|
63
|
+
id = extractAssetsRemoveQuery(id);
|
|
64
|
+
const isExtractAssets = idOriginal !== id;
|
|
65
|
+
if (id.startsWith(virtualFileIdPageEntryClient)) {
|
|
66
|
+
assert(isExtractAssets === false);
|
|
67
|
+
return {
|
|
68
|
+
type: 'page-entry',
|
|
69
|
+
pageId: id.slice(virtualFileIdPageEntryClient.length),
|
|
70
|
+
isForClientSide: true,
|
|
71
|
+
isExtractAssets,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (id.startsWith(virtualFileIdPageEntryServer)) {
|
|
75
|
+
return {
|
|
76
|
+
type: 'page-entry',
|
|
77
|
+
pageId: id.slice(virtualFileIdPageEntryServer.length),
|
|
78
|
+
isForClientSide: false,
|
|
79
|
+
isExtractAssets,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
assert(false);
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
function generateVirtualFileId(args) {
|
|
87
|
+
if (args.type === 'global-entry') {
|
|
88
|
+
const { isForClientSide, isClientRouting } = args;
|
|
89
|
+
assert(typeof isClientRouting === 'boolean');
|
|
90
|
+
if (!isForClientSide) {
|
|
91
|
+
return virtualFileIdGlobalEntryServer;
|
|
92
|
+
}
|
|
93
|
+
else if (isClientRouting) {
|
|
94
|
+
return virtualFileIdGlobalEntryClientCR;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return virtualFileIdGlobalEntryClientSR;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (args.type === 'page-entry') {
|
|
101
|
+
const { pageId, isForClientSide } = args;
|
|
102
|
+
assert(typeof pageId === 'string');
|
|
103
|
+
const id = `${isForClientSide ? virtualFileIdPageEntryClient : virtualFileIdPageEntryServer}${pageId}`;
|
|
104
|
+
return id;
|
|
105
|
+
}
|
|
106
|
+
assert(false);
|
|
107
|
+
}
|
|
@@ -17,14 +17,14 @@ import { pluginBaseUrls } from './plugins/pluginBaseUrls.js';
|
|
|
17
17
|
import { pluginEnvVars } from './plugins/pluginEnvVars.js';
|
|
18
18
|
import pc from '@brillout/picocolors';
|
|
19
19
|
import { pluginFileEnv } from './plugins/pluginFileEnv.js';
|
|
20
|
-
import {
|
|
21
|
-
import { resolveClientEntriesDev } from './shared/resolveClientEntriesDev.js';
|
|
20
|
+
import { getClientEntrySrcDev } from './shared/getClientEntrySrcDev.js';
|
|
22
21
|
import { pluginWorkaroundCssModuleHmr } from './plugins/pluginWorkaroundCssModuleHmr.js';
|
|
23
22
|
import { pluginWorkaroundVite6HmrRegression } from './plugins/pluginWorkaroundVite6HmrRegression.js';
|
|
24
23
|
import { pluginReplaceConstants } from './plugins/pluginReplaceConstants.js';
|
|
25
24
|
import { pluginNonRunnableDev } from './plugins/pluginNonRunnableDev.js';
|
|
25
|
+
import { setGetClientEntrySrcDev } from '../runtime/renderPage/getPageAssets/retrievePageAssetsDev.js';
|
|
26
26
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
27
|
-
|
|
27
|
+
setGetClientEntrySrcDev(getClientEntrySrcDev);
|
|
28
28
|
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
29
29
|
function plugin(vikeVitePluginOptions = {}) {
|
|
30
30
|
const plugins = [
|
|
@@ -9,9 +9,11 @@ function onLoad() {
|
|
|
9
9
|
assertIsNotBrowser();
|
|
10
10
|
assertNodeVersion();
|
|
11
11
|
// package.json#peerDependencies isn't enough as users often ignore it
|
|
12
|
-
// This assertion isn't reliable: the user may still use a Vite version older than
|
|
13
|
-
// TO-DO/eventually: let's also use this.meta.viteVersion
|
|
14
|
-
|
|
12
|
+
// This assertion isn't reliable: the user may still use a Vite version older than 6.0.0 — see https://github.com/vitejs/vite/pull/19355
|
|
13
|
+
// TO-DO/eventually: let's also use this.meta.viteVersion
|
|
14
|
+
// - https://github.com/vitejs/vite/pull/20088
|
|
15
|
+
// - https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#700-2025-06-24
|
|
16
|
+
assertVersion('Vite', version, '6.0.0');
|
|
15
17
|
// Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
|
|
16
18
|
assertIsNotProductionRuntime();
|
|
17
19
|
}
|
|
@@ -7,13 +7,13 @@ import type { Environment, ResolvedConfig, Rollup, UserConfig } from 'vite';
|
|
|
7
7
|
type Bundle = Rollup.OutputBundle;
|
|
8
8
|
declare function handleAssetsManifest_isFixEnabled(config: ResolvedConfig | UserConfig): boolean;
|
|
9
9
|
declare function handleAssetsManifest_assertUsageCssCodeSplit(config: ResolvedConfig): void;
|
|
10
|
-
declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfig): void;
|
|
10
|
+
declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfig, env: Environment): void;
|
|
11
11
|
declare function handleAssetsManifest_getBuildConfig(config: UserConfig): Promise<{
|
|
12
12
|
readonly ssrEmitAssets: true | undefined;
|
|
13
13
|
readonly cssMinify: "esbuild" | undefined;
|
|
14
14
|
readonly manifest: true;
|
|
15
15
|
readonly copyPublicDir: boolean | undefined;
|
|
16
16
|
}>;
|
|
17
|
-
declare function handleAssetsManifest(config: ResolvedConfig, viteEnv: Environment
|
|
17
|
+
declare function handleAssetsManifest(config: ResolvedConfig, viteEnv: Environment, options: {
|
|
18
18
|
dir: string | undefined;
|
|
19
19
|
}, bundle: Bundle): Promise<void>;
|
|
@@ -8,12 +8,12 @@ import fs_sync from 'node:fs';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { existsSync } from 'node:fs';
|
|
10
10
|
import { assert, assertIsSingleModuleInstance, assertWarning, isEqualStringList, isObject, pLimit, unique, } from '../../utils.js';
|
|
11
|
-
import {
|
|
11
|
+
import { parseVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
12
12
|
import { getAssetsDir } from '../../shared/getAssetsDir.js';
|
|
13
13
|
import pc from '@brillout/picocolors';
|
|
14
14
|
import { getVikeConfigInternal, isV1Design } from '../../shared/resolveVikeConfigInternal.js';
|
|
15
15
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
16
|
-
import { isViteServerBuild_onlySsrEnv, isViteServerBuild } from '../../shared/isViteServerBuild.js';
|
|
16
|
+
import { isViteServerBuild_onlySsrEnv, isViteServerBuild, isViteServerBuild_withoutEnv, } from '../../shared/isViteServerBuild.js';
|
|
17
17
|
import { set_macro_ASSETS_MANIFEST } from './pluginBuildEntry.js';
|
|
18
18
|
import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
|
|
19
19
|
assertIsSingleModuleInstance('build/handleAssetsManifest.ts');
|
|
@@ -33,7 +33,7 @@ async function fixServerAssets(config) {
|
|
|
33
33
|
return { clientManifestMod, serverManifestMod };
|
|
34
34
|
}
|
|
35
35
|
async function copyAssets(filesToMove, filesToRemove, config) {
|
|
36
|
-
const { outDirClient, outDirServer } = getOutDirs(config);
|
|
36
|
+
const { outDirClient, outDirServer } = getOutDirs(config, undefined);
|
|
37
37
|
const assetsDir = getAssetsDir(config);
|
|
38
38
|
const assetsDirServer = path.posix.join(outDirServer, assetsDir);
|
|
39
39
|
if (!filesToMove.length && !filesToRemove.length && !existsSync(assetsDirServer))
|
|
@@ -165,13 +165,13 @@ function addServerAssets(clientManifest, serverManifest) {
|
|
|
165
165
|
}
|
|
166
166
|
function getPageId(key) {
|
|
167
167
|
// Normalize from:
|
|
168
|
-
// ../../virtual:vike:
|
|
168
|
+
// ../../virtual:vike:page-entry:client:/pages/index
|
|
169
169
|
// to:
|
|
170
|
-
// virtual:vike:
|
|
170
|
+
// virtual:vike:page-entry:client:/pages/index
|
|
171
171
|
// (This seems to be needed only for vitest tests that use Vite's build() API with an inline config.)
|
|
172
172
|
key = key.substring(key.indexOf('virtual:vike'));
|
|
173
|
-
const result =
|
|
174
|
-
return result && result.pageId;
|
|
173
|
+
const result = parseVirtualFileId(key);
|
|
174
|
+
return result && result.type === 'page-entry' ? result.pageId : null;
|
|
175
175
|
}
|
|
176
176
|
function collectResources(entryRoot, manifest) {
|
|
177
177
|
const css = [];
|
|
@@ -216,10 +216,10 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
|
|
|
216
216
|
assertWarning(config.build.cssCodeSplit, `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
217
217
|
}
|
|
218
218
|
const targets = [];
|
|
219
|
-
function handleAssetsManifest_assertUsageCssTarget(config) {
|
|
219
|
+
function handleAssetsManifest_assertUsageCssTarget(config, env) {
|
|
220
220
|
if (!handleAssetsManifest_isFixEnabled(config))
|
|
221
221
|
return;
|
|
222
|
-
const isServerSide = isViteServerBuild(config);
|
|
222
|
+
const isServerSide = isViteServerBuild(config, env);
|
|
223
223
|
assert(typeof isServerSide === 'boolean');
|
|
224
224
|
assert(config.build.target !== undefined);
|
|
225
225
|
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
@@ -290,7 +290,7 @@ async function handleAssetsManifest_getBuildConfig(config) {
|
|
|
290
290
|
copyPublicDir: vikeConfig.config.vite6BuilderApp
|
|
291
291
|
? // Already set by vike:build:pluginBuildApp
|
|
292
292
|
undefined
|
|
293
|
-
: !
|
|
293
|
+
: !isViteServerBuild_withoutEnv(config),
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
296
|
async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
@@ -328,7 +328,7 @@ async function writeAssetsManifestFile(assetsJsonFilePath, config) {
|
|
|
328
328
|
await fs.rm(serverManifestFilePath);
|
|
329
329
|
}
|
|
330
330
|
function getManifestFilePath(config, client) {
|
|
331
|
-
const outDirs = getOutDirs(config);
|
|
331
|
+
const outDirs = getOutDirs(config, undefined);
|
|
332
332
|
const outDir = client ? outDirs.outDirClient : outDirs.outDirServer;
|
|
333
333
|
const env = client ? config.environments.client : config.environments.ssr;
|
|
334
334
|
assert(env);
|