vike 0.4.171 → 0.4.172-commit-c1b0884
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/plugin/index.js +3 -0
- package/dist/cjs/node/plugin/plugins/buildConfig.js +3 -4
- package/dist/cjs/node/plugin/plugins/config/index.js +9 -5
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -1
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +8 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +19 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +43 -85
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +5 -44
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +10 -51
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/cjs/node/plugin/resolveClientEntriesDev.js +59 -0
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +17 -2
- package/dist/cjs/node/prerender/runPrerender.js +35 -15
- package/dist/cjs/node/prerender/utils.js +1 -0
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScripts.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/cjs/node/runtime/html/renderHtml.js +19 -20
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/cjs/node/runtime/html/stream.js +9 -9
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +91 -282
- package/dist/cjs/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +30 -10
- package/dist/cjs/node/runtime/renderPage.js +24 -17
- package/dist/cjs/node/runtime/utils.js +2 -0
- package/dist/cjs/node/shared/assertV1Design.js +3 -4
- package/dist/cjs/shared/getPageContext.js +5 -0
- package/dist/cjs/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +2 -2
- package/dist/cjs/shared/getPageFiles/getExports.js +49 -1
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +15 -8
- package/dist/cjs/shared/hooks/executeHook.js +22 -3
- package/dist/cjs/shared/hooks/getHook.js +2 -2
- package/dist/cjs/shared/page-configs/getConfigValue.js +14 -17
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +70 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +0 -18
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +110 -16
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +198 -0
- package/dist/cjs/shared/route/executeGuardHook.js +1 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/shared/route/index.js +2 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +2 -2
- package/dist/cjs/shared/route/resolveRouteFunction.js +2 -2
- package/dist/cjs/shared/sortPageContext.js +4 -8
- package/dist/cjs/shared/utils.js +2 -0
- package/dist/cjs/utils/assert.js +3 -3
- package/dist/cjs/utils/assertNodeVersion.js +1 -1
- package/dist/cjs/utils/changeEnumerable.js +9 -0
- package/dist/cjs/utils/escapeHtml.js +14 -0
- package/dist/cjs/utils/getPropAccessNotation.js +1 -4
- package/dist/cjs/utils/hasProp.js +5 -7
- package/dist/cjs/utils/normalizeHeaders.js +13 -0
- package/dist/cjs/utils/objectAssign.js +1 -1
- package/dist/cjs/utils/objectDefineProperty.js +8 -0
- package/dist/cjs/utils/objectKeys.js +8 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +6 -4
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -3
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +16 -12
- package/dist/esm/client/client-routing-runtime/installClientRouter.js +18 -10
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +3 -3
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +4 -4
- package/dist/esm/client/server-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/utils.js +1 -0
- package/dist/esm/client/shared/executeOnRenderClientHook.js +1 -1
- package/dist/esm/client/shared/getPageContextProxyForUser.d.ts +3 -2
- package/dist/esm/client/shared/getPageContextProxyForUser.js +35 -48
- package/dist/esm/client/shared/loadUserFilesClientSide.js +4 -4
- package/dist/esm/node/plugin/index.js +3 -0
- package/dist/esm/node/plugin/plugins/buildConfig.js +3 -4
- package/dist/esm/node/plugin/plugins/config/index.js +9 -5
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -15
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -1
- package/dist/esm/node/plugin/plugins/envVars.js +2 -1
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +14 -0
- package/dist/esm/node/plugin/plugins/importUserCode/{generateEagerImport.js → addImportStatement.js} +7 -9
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +20 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +4 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +43 -85
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +5 -44
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +10 -51
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +6 -0
- package/dist/esm/node/plugin/resolveClientEntriesDev.d.ts +4 -0
- package/dist/esm/node/plugin/resolveClientEntriesDev.js +56 -0
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +14 -2
- package/dist/esm/node/prerender/runPrerender.js +37 -17
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScripts.js +3 -2
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +1 -1
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.js +2 -8
- package/dist/esm/node/runtime/html/renderHtml.js +19 -20
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/esm/node/runtime/html/stream.d.ts +1 -1
- package/dist/esm/node/runtime/html/stream.js +9 -9
- package/dist/esm/node/runtime/renderPage/analyzePage.js +9 -7
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +8 -8
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -6
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +4 -5
- package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +2 -6
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +92 -283
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +65 -39
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +31 -11
- package/dist/esm/node/runtime/renderPage.js +24 -17
- package/dist/esm/node/runtime/utils.d.ts +2 -0
- package/dist/esm/node/runtime/utils.js +2 -0
- package/dist/esm/node/shared/assertV1Design.d.ts +2 -2
- package/dist/esm/node/shared/assertV1Design.js +3 -4
- package/dist/esm/shared/ConfigVike.d.ts +7 -0
- package/dist/esm/shared/VikeNamespace.d.ts +9 -0
- package/dist/esm/shared/getPageContext.d.ts +1 -0
- package/dist/esm/shared/getPageContext.js +1 -0
- package/dist/esm/shared/{addUrlComputedProps.d.ts → getPageContextUrlComputed.d.ts} +23 -21
- package/dist/esm/shared/{addUrlComputedProps.js → getPageContextUrlComputed.js} +52 -42
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/getPageFiles/getExports.d.ts +36 -0
- package/dist/esm/shared/getPageFiles/getExports.js +50 -2
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +14 -7
- package/dist/esm/shared/hooks/executeHook.d.ts +10 -1
- package/dist/esm/shared/hooks/executeHook.js +21 -2
- package/dist/esm/shared/hooks/getHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.js +3 -3
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +14 -8
- package/dist/esm/shared/page-configs/getConfigValue.d.ts +12 -12
- package/dist/esm/shared/page-configs/getConfigValue.js +13 -16
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.d.ts +9 -0
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +67 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +3 -12
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +17 -21
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.d.ts +1 -5
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -16
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +4 -1
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +109 -15
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +192 -0
- package/dist/esm/shared/route/executeGuardHook.js +1 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +3 -3
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +2 -2
- package/dist/esm/shared/route/resolveRouteFunction.js +2 -2
- package/dist/esm/shared/sortPageContext.js +4 -8
- package/dist/esm/shared/types.d.ts +32 -6
- package/dist/esm/shared/utils.d.ts +2 -0
- package/dist/esm/shared/utils.js +2 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/assert.js +3 -3
- package/dist/esm/utils/assertNodeVersion.js +1 -1
- package/dist/esm/utils/changeEnumerable.d.ts +2 -0
- package/dist/esm/utils/changeEnumerable.js +5 -0
- package/dist/esm/utils/escapeHtml.d.ts +1 -0
- package/dist/esm/utils/escapeHtml.js +10 -0
- package/dist/esm/utils/getPropAccessNotation.d.ts +1 -2
- package/dist/esm/utils/getPropAccessNotation.js +2 -6
- package/dist/esm/utils/hasProp.d.ts +4 -13
- package/dist/esm/utils/hasProp.js +5 -7
- package/dist/esm/utils/normalizeHeaders.d.ts +1 -0
- package/dist/esm/utils/normalizeHeaders.js +9 -0
- package/dist/esm/utils/objectAssign.js +1 -1
- package/dist/esm/utils/objectDefineProperty.d.ts +4 -0
- package/dist/esm/utils/objectDefineProperty.js +4 -0
- package/dist/esm/utils/objectKeys.d.ts +1 -3
- package/dist/esm/utils/objectKeys.js +8 -4
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +23 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -76
- package/dist/cjs/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -14
- package/dist/cjs/node/shared/getClientEntry.js +0 -12
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +0 -85
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -24
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +0 -50
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +0 -16
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +0 -70
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.d.ts +0 -5
- package/dist/esm/node/plugin/shared/getConfigValueSourcesNotOverriden.js +0 -11
- package/dist/esm/node/shared/getClientEntry.d.ts +0 -3
- package/dist/esm/node/shared/getClientEntry.js +0 -9
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +0 -82
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.d.ts +0 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +0 -21
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +0 -8
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +0 -47
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasProp = void 0;
|
|
4
|
-
// - https://2ality.com/2020/06/type-guards-assertion-functions-typescript.html
|
|
5
|
-
// - https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABDAzgFQJ4AcCmdgAUAbgIYA2IOAXIiWBgDSJTbWIDkARnHGTnewCUNUhRzIUibr35gA3AFgAUKEiwEEzLnzFylGnUbNWNdmBABbTjgBOQkXvGpE5q7cUrw0eElRa8hKL6tPRMLLimKFA2MGAA5vaIQU6SUTHxHqreGn6sOskGocYRHOAA1mBwAO5gickSiOWVNZle6r7oeYGOhUbhbGmxcYgAvKVgFdW1wlI8fHSIAN7KiMiExeIjW+OTNeyIgksrq4g2OFAgNkjRlMcAvsdnF1cb+EmOo9v9Hg9KyhAIKK0GhNKajRAAFgATMplCQUChbFACLltIQSEwzJZrHZBIJ-oCZAA6MhwOIEEj4v6eNQ+WgIpEEAFgAAmMHaIImzTAM3hiJsUEkzLZ7SOShOa0QTIQIp8hyelzAx1WUAAFjZqi4cFVEABRGwamwEdgAQQZArpADESDAyEJlHcgA
|
|
6
4
|
const isCallable_js_1 = require("./isCallable.js");
|
|
7
5
|
const isObject_js_1 = require("./isObject.js");
|
|
8
6
|
const isArrayOfStrings_js_1 = require("./isArrayOfStrings.js");
|
|
9
7
|
const isObjectOfStrings_js_1 = require("./isObjectOfStrings.js");
|
|
10
8
|
const isArray_js_1 = require("./isArray.js");
|
|
11
|
-
function hasProp(obj, prop, type
|
|
9
|
+
function hasProp(obj, prop, type) {
|
|
12
10
|
if (!(0, isObject_js_1.isObject)(obj))
|
|
13
11
|
return false;
|
|
14
12
|
if (!(prop in obj)) {
|
|
15
13
|
return type === 'undefined';
|
|
16
14
|
}
|
|
17
|
-
if (type ===
|
|
15
|
+
if (type === undefined) {
|
|
18
16
|
return true;
|
|
19
17
|
}
|
|
20
18
|
const propValue = obj[prop];
|
|
19
|
+
if (type === 'undefined') {
|
|
20
|
+
return propValue === undefined;
|
|
21
|
+
}
|
|
21
22
|
if (type === 'array') {
|
|
22
23
|
return (0, isArray_js_1.isArray)(propValue);
|
|
23
24
|
}
|
|
@@ -39,9 +40,6 @@ function hasProp(obj, prop, type = 'unknown') {
|
|
|
39
40
|
if (type === 'null') {
|
|
40
41
|
return propValue === null;
|
|
41
42
|
}
|
|
42
|
-
if (type === 'undefined') {
|
|
43
|
-
return propValue === undefined;
|
|
44
|
-
}
|
|
45
43
|
if (type === 'true') {
|
|
46
44
|
return propValue === true;
|
|
47
45
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeHeaders = void 0;
|
|
4
|
+
function normalizeHeaders(
|
|
5
|
+
/* This type is precise, too precise which can be annoying: e.g. cannot pass a string[][] argument because it doesn't match the more precise [string,string][] type.
|
|
6
|
+
headersOriginal ConstructorParameters<typeof Headers>[0]
|
|
7
|
+
*/
|
|
8
|
+
headersOriginal) {
|
|
9
|
+
const headersStandard = new Headers(headersOriginal);
|
|
10
|
+
const headers = Object.fromEntries(headersStandard.entries());
|
|
11
|
+
return headers;
|
|
12
|
+
}
|
|
13
|
+
exports.normalizeHeaders = normalizeHeaders;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.objectAssign = void 0;
|
|
4
4
|
// Same as Object.assign() but:
|
|
5
5
|
// - With type inference
|
|
6
|
-
// - Preserves property descriptors, which we need for preserving the getters added by
|
|
6
|
+
// - Preserves property descriptors, which we need for preserving the getters added by getPageContextUrlComputed()
|
|
7
7
|
function objectAssign(obj, objAddendum) {
|
|
8
8
|
if (objAddendum) {
|
|
9
9
|
Object.defineProperties(obj, Object.getOwnPropertyDescriptors(objAddendum));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectDefineProperty = void 0;
|
|
4
|
+
/** Like Object.defineProperty() but with type inference */
|
|
5
|
+
function objectDefineProperty(obj, prop, { get, ...args }) {
|
|
6
|
+
Object.defineProperty(obj, prop, { ...args, get });
|
|
7
|
+
}
|
|
8
|
+
exports.objectDefineProperty = objectDefineProperty;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.objectKeys = exports.objectFromEntries = exports.objectEntries = void 0;
|
|
4
|
+
// export { forEach }
|
|
4
5
|
// https://stackoverflow.com/questions/60141960/typescript-key-value-relation-preserving-object-entries-type/75337277#75337277
|
|
5
6
|
/** Same as Object.entries() but with type inference */
|
|
6
7
|
function objectEntries(obj) {
|
|
@@ -19,8 +20,11 @@ function objectKeys(obj) {
|
|
|
19
20
|
return Object.keys(obj);
|
|
20
21
|
}
|
|
21
22
|
exports.objectKeys = objectKeys;
|
|
22
|
-
/*
|
|
23
|
-
function
|
|
24
|
-
|
|
23
|
+
/* Not used yet, but can be quite useful.
|
|
24
|
+
function forEach<Obj extends object>(
|
|
25
|
+
obj: Obj,
|
|
26
|
+
iterator: <Key extends keyof Obj>(key: Key, val: Obj[Key]) => void
|
|
27
|
+
): void {
|
|
28
|
+
Object.entries(obj).forEach(([key, val]) => iterator(key as keyof Obj, val))
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
//*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.
|
|
4
|
+
const PROJECT_VERSION = '0.4.172-commit-c1b0884';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -5,12 +5,14 @@ declare function createPageContext(urlOriginal: string): Promise<{
|
|
|
5
5
|
_urlHandler: null;
|
|
6
6
|
_urlRewrite: null;
|
|
7
7
|
_baseServer: string;
|
|
8
|
-
_pageFilesAll: import("../../shared/getPageFiles
|
|
9
|
-
_pageConfigs: import("../../
|
|
8
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
9
|
+
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
10
10
|
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
11
11
|
_allPageIds: string[];
|
|
12
12
|
_pageRoutes: import("../../shared/route/loadPageRoutes.js").PageRoutes;
|
|
13
13
|
_onBeforeRouteHook: import("../../shared/hooks/getHook.js").Hook | null;
|
|
14
|
-
} &
|
|
15
|
-
|
|
14
|
+
} & {
|
|
15
|
+
urlParsed: import("../../shared/getPageContextUrlComputed.js").Url;
|
|
16
|
+
urlPathname: string;
|
|
17
|
+
url: string;
|
|
16
18
|
}>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { createPageContext };
|
|
2
|
-
import {
|
|
2
|
+
import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js';
|
|
3
3
|
import { getPageFilesAll } from '../../shared/getPageFiles.js';
|
|
4
4
|
import { loadPageRoutes } from '../../shared/route/loadPageRoutes.js';
|
|
5
5
|
import { getBaseServer } from './getBaseServer.js';
|
|
6
|
-
import { assert, isBaseServer, getGlobalObject } from './utils.js';
|
|
6
|
+
import { assert, isBaseServer, getGlobalObject, objectAssign } from './utils.js';
|
|
7
7
|
const globalObject = getGlobalObject('createPageContext.ts', {});
|
|
8
8
|
async function createPageContext(urlOriginal) {
|
|
9
9
|
if (!globalObject.pageFilesData) {
|
|
@@ -26,6 +26,7 @@ async function createPageContext(urlOriginal) {
|
|
|
26
26
|
_pageRoutes: pageRoutes,
|
|
27
27
|
_onBeforeRouteHook: onBeforeRouteHook
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
const pageContextUrlComputed = getPageContextUrlComputed(pageContext);
|
|
30
|
+
objectAssign(pageContext, pageContextUrlComputed);
|
|
30
31
|
return pageContext;
|
|
31
32
|
}
|
|
@@ -10,7 +10,7 @@ import { preparePageContextForUserConsumptionClientSide } from '../shared/prepar
|
|
|
10
10
|
import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides.js';
|
|
11
11
|
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
|
|
12
12
|
import { getPageConfig } from '../../shared/page-configs/helpers.js';
|
|
13
|
-
import {
|
|
13
|
+
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValue.js';
|
|
14
14
|
import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn.js';
|
|
15
15
|
import { executeGuardHook } from '../../shared/route/executeGuardHook.js';
|
|
16
16
|
import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js';
|
|
@@ -32,7 +32,9 @@ async function getPageContextFromHooks_isHydration(pageContext) {
|
|
|
32
32
|
_hasPageContextFromServer: true
|
|
33
33
|
};
|
|
34
34
|
for (const hookName of ['data', 'onBeforeRender']) {
|
|
35
|
-
const pageContextForHook = {
|
|
35
|
+
const pageContextForHook = {};
|
|
36
|
+
objectAssign(pageContextForHook, pageContext);
|
|
37
|
+
objectAssign(pageContextForHook, pageContextFromHooks);
|
|
36
38
|
if (hookClientOnlyExists(hookName, pageContextForHook)) {
|
|
37
39
|
const pageContextFromHook = await executeHookClientSide(hookName, pageContextForHook);
|
|
38
40
|
Object.assign(pageContextFromHooks, pageContextFromHook);
|
|
@@ -45,6 +47,9 @@ async function getPageContextFromHooks_isNotHydration(pageContext, isErrorPage)
|
|
|
45
47
|
isHydration: false,
|
|
46
48
|
_hasPageContextFromClient: false
|
|
47
49
|
};
|
|
50
|
+
const pageContextForCondition = {};
|
|
51
|
+
objectAssign(pageContextForCondition, pageContext);
|
|
52
|
+
objectAssign(pageContextForCondition, pageContextFromHooks);
|
|
48
53
|
let hasPageContextFromServer = false;
|
|
49
54
|
// If pageContextInit has some client data or if one of the hooks guard(), data() or onBeforeRender() is server-side
|
|
50
55
|
// only, then we need to fetch pageContext from the server.
|
|
@@ -53,7 +58,7 @@ async function getPageContextFromHooks_isNotHydration(pageContext, isErrorPage)
|
|
|
53
58
|
// For the error page, we cannot fetch pageContext from the server because the pageContext JSON request is based on the URL
|
|
54
59
|
!isErrorPage &&
|
|
55
60
|
// true if pageContextInit has some client data or at least one of the data() and onBeforeRender() hooks is server-side only:
|
|
56
|
-
(await hasPageContextServer(
|
|
61
|
+
(await hasPageContextServer(pageContextForCondition))) {
|
|
57
62
|
const res = await fetchPageContextFromServer(pageContext);
|
|
58
63
|
if ('is404ServerSideRouted' in res)
|
|
59
64
|
return { is404ServerSideRouted: true };
|
|
@@ -70,11 +75,10 @@ async function getPageContextFromHooks_isNotHydration(pageContext, isErrorPage)
|
|
|
70
75
|
// Note: for the error page, we also execute the client-side data() and onBeforeRender() hooks, but maybe we
|
|
71
76
|
// shouldn't? The server-side does it as well (but maybe it shouldn't).
|
|
72
77
|
for (const hookName of ['guard', 'data', 'onBeforeRender']) {
|
|
73
|
-
const pageContextForHook = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
+
const pageContextForHook = {};
|
|
79
|
+
objectAssign(pageContextForHook, { _hasPageContextFromServer: hasPageContextFromServer });
|
|
80
|
+
objectAssign(pageContextForHook, pageContext);
|
|
81
|
+
objectAssign(pageContextForHook, pageContextFromHooks);
|
|
78
82
|
if (hookName === 'guard') {
|
|
79
83
|
if (!isErrorPage &&
|
|
80
84
|
// We don't need to call guard() on the client-side if we fetch pageContext from the server side. (Because the `${url}.pageContext.json` HTTP request will already trigger the routing and guard() hook on the server-side.)
|
|
@@ -108,7 +112,7 @@ async function executeHookClientSide(hookName, pageContext) {
|
|
|
108
112
|
return null;
|
|
109
113
|
}
|
|
110
114
|
const pageContextForUserConsumption = preparePageContextForUserConsumptionClientSide(pageContext, true);
|
|
111
|
-
const hookResult = await executeHook(() => hook.hookFn(pageContextForUserConsumption), hook);
|
|
115
|
+
const hookResult = await executeHook(() => hook.hookFn(pageContextForUserConsumption), hook, pageContext);
|
|
112
116
|
const pageContextFromHook = {};
|
|
113
117
|
if (hookName === 'onBeforeRender') {
|
|
114
118
|
assertOnBeforeRenderHookReturn(hookResult, hook.hookFilePath);
|
|
@@ -165,7 +169,7 @@ async function hookServerOnlyExists(hookName, pageContext) {
|
|
|
165
169
|
if (pageContext._pageConfigs.length > 0) {
|
|
166
170
|
// V1
|
|
167
171
|
const pageConfig = getPageConfig(pageContext._pageId, pageContext._pageConfigs);
|
|
168
|
-
const hookEnv =
|
|
172
|
+
const hookEnv = getConfigValueRuntime(pageConfig, `${hookName}Env`)?.value ?? {};
|
|
169
173
|
assert(isObject(hookEnv));
|
|
170
174
|
return !!hookEnv.server && !hookEnv.client;
|
|
171
175
|
}
|
|
@@ -189,7 +193,7 @@ function hookClientOnlyExists(hookName, pageContext) {
|
|
|
189
193
|
if (pageContext._pageConfigs.length > 0) {
|
|
190
194
|
// V1
|
|
191
195
|
const pageConfig = getPageConfig(pageContext._pageId, pageContext._pageConfigs);
|
|
192
|
-
const hookEnv =
|
|
196
|
+
const hookEnv = getConfigValueRuntime(pageConfig, `${hookName}Env`)?.value ?? {};
|
|
193
197
|
assert(isObject(hookEnv));
|
|
194
198
|
return !!hookEnv.client && !hookEnv.server;
|
|
195
199
|
}
|
|
@@ -221,7 +225,7 @@ async function fetchPageContextFromServer(pageContext) {
|
|
|
221
225
|
}
|
|
222
226
|
// Is there a reason for having two different properties? Can't we use only one property? I guess/think the isServerSideError property was an attempt (a bad idea really) for rendering the error page even though an error occured on the server-side (which is a bad idea because the added complexity is non-negligible while the added value is minuscule since the error page usually doesn't have any (meaningful / server-side) hooks).
|
|
223
227
|
if ('serverSideError' in pageContextFromServer || isServerSideError in pageContextFromServer) {
|
|
224
|
-
throw getProjectError(`
|
|
228
|
+
throw getProjectError(`pageContext couldn't be fetched from server: an error occurred on the server-side (see your server logs)`);
|
|
225
229
|
}
|
|
226
230
|
assert(hasProp(pageContextFromServer, '_pageId', 'string'));
|
|
227
231
|
processPageContextFromServer(pageContextFromServer);
|
|
@@ -7,22 +7,30 @@ import { onLinkClick } from './onLinkClick.js';
|
|
|
7
7
|
import { setupNativeScrollRestoration } from './scrollRestoration.js';
|
|
8
8
|
import { autoSaveScrollPosition } from './setScrollPosition.js';
|
|
9
9
|
async function installClientRouter() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
10
|
+
// Init navigation history and scroll restoration
|
|
11
|
+
initHistoryAndScroll();
|
|
12
|
+
// Render initial page
|
|
13
|
+
const renderPromise = render();
|
|
14
|
+
// Intercept <a> clicks
|
|
15
|
+
onLinkClick();
|
|
16
|
+
// Preserve stack track
|
|
17
|
+
await renderPromise;
|
|
18
|
+
}
|
|
19
|
+
function render() {
|
|
15
20
|
assert(getRenderCount() === 0);
|
|
16
|
-
const
|
|
21
|
+
const renderPromise = renderPageClientSide({
|
|
17
22
|
scrollTarget: 'preserve-scroll',
|
|
18
23
|
isBackwardNavigation: null,
|
|
19
24
|
isClientSideNavigation: false
|
|
20
25
|
});
|
|
21
26
|
assert(getRenderCount() === 1);
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
return renderPromise;
|
|
28
|
+
}
|
|
29
|
+
function initHistoryAndScroll() {
|
|
30
|
+
setupNativeScrollRestoration();
|
|
31
|
+
initHistoryState();
|
|
32
|
+
autoSaveScrollPosition();
|
|
33
|
+
monkeyPatchHistoryPushState();
|
|
24
34
|
// Handle back-/forward navigation
|
|
25
35
|
onBrowserHistoryNavigation();
|
|
26
|
-
// Only for full stack straces
|
|
27
|
-
await promise;
|
|
28
36
|
}
|
|
@@ -51,7 +51,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
51
51
|
const hook = onPageTransitionStartHook;
|
|
52
52
|
const { hookFn } = hook;
|
|
53
53
|
try {
|
|
54
|
-
await executeHook(() => hookFn(pageContext), hook);
|
|
54
|
+
await executeHook(() => hookFn(pageContext), hook, pageContext);
|
|
55
55
|
}
|
|
56
56
|
catch (err) {
|
|
57
57
|
await onError(err);
|
|
@@ -353,7 +353,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
353
353
|
if (hook) {
|
|
354
354
|
const { hookFn } = hook;
|
|
355
355
|
try {
|
|
356
|
-
await executeHook(() => hookFn(pageContext), hook);
|
|
356
|
+
await executeHook(() => hookFn(pageContext), hook, pageContext);
|
|
357
357
|
}
|
|
358
358
|
catch (err) {
|
|
359
359
|
await onError(err);
|
|
@@ -377,7 +377,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
377
377
|
if (hook) {
|
|
378
378
|
const { hookFn } = hook;
|
|
379
379
|
try {
|
|
380
|
-
await executeHook(() => hookFn(pageContext), hook);
|
|
380
|
+
await executeHook(() => hookFn(pageContext), hook, pageContext);
|
|
381
381
|
}
|
|
382
382
|
catch (err) {
|
|
383
383
|
await onError(err);
|
|
@@ -8,8 +8,8 @@ declare function getPageContext(): Promise<{
|
|
|
8
8
|
_hasPageContextFromServer: true;
|
|
9
9
|
_hasPageContextFromClient: false;
|
|
10
10
|
} & {
|
|
11
|
-
_pageFilesAll: import("../../shared/getPageFiles
|
|
12
|
-
_pageConfigs: import("../../
|
|
13
|
-
} & import("../../shared/getPageFiles
|
|
14
|
-
_pageFilesLoaded: import("../../shared/getPageFiles
|
|
11
|
+
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
12
|
+
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
13
|
+
} & import("../../shared/getPageFiles.js").PageContextExports & {
|
|
14
|
+
_pageFilesLoaded: import("../../shared/getPageFiles.js").PageFile[];
|
|
15
15
|
}>;
|
|
@@ -16,3 +16,4 @@ export * from '../../utils/parseUrl.js';
|
|
|
16
16
|
export * from '../../utils/projectInfo.js';
|
|
17
17
|
export * from '../../utils/slice.js';
|
|
18
18
|
export * from '../../utils/unique.js'; // Only used by Server Routing (not needed for Client Routing)
|
|
19
|
+
export * from '../../utils/getPropAccessNotation.js';
|
|
@@ -45,7 +45,7 @@ async function executeOnRenderClientHook(pageContext, isClientRouting) {
|
|
|
45
45
|
const renderHook = hook.hookFn;
|
|
46
46
|
assert(hookName);
|
|
47
47
|
// We don't use a try-catch wrapper because rendering errors are usually handled by the UI framework. (E.g. React's Error Boundaries.)
|
|
48
|
-
const hookResult = await executeHook(() => renderHook(pageContextForUserConsumption), hook);
|
|
48
|
+
const hookResult = await executeHook(() => renderHook(pageContextForUserConsumption), hook, pageContext);
|
|
49
49
|
assertUsage(hookResult === undefined, `The ${hookName}() hook defined by ${hook.hookFilePath} isn't allowed to return a value`);
|
|
50
50
|
}
|
|
51
51
|
function getUrlToShowToUser(pageContext) {
|
|
@@ -5,7 +5,8 @@ type PageContextForPassToClientWarning = {
|
|
|
5
5
|
_hasPageContextFromClient: boolean;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
8
|
+
* Throw error when pageContext value isn't:
|
|
9
|
+
* - serializable, or
|
|
10
|
+
* - defined.
|
|
10
11
|
*/
|
|
11
12
|
declare function getPageContextProxyForUser<PageContext extends Record<string, unknown> & PageContextForPassToClientWarning>(pageContext: PageContext): PageContext;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { getPageContextProxyForUser };
|
|
2
|
-
import { assert, assertUsage, assertWarning, getGlobalObject } from '../server-routing-runtime/utils.js';
|
|
2
|
+
import { assert, assertUsage, assertWarning, getGlobalObject, getPropAccessNotation } from '../server-routing-runtime/utils.js';
|
|
3
3
|
import { notSerializable } from '../../shared/notSerializable.js';
|
|
4
4
|
const globalObject = getGlobalObject('getPageContextProxyForUser.ts', {});
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
6
|
+
* Throw error when pageContext value isn't:
|
|
7
|
+
* - serializable, or
|
|
8
|
+
* - defined.
|
|
8
9
|
*/
|
|
9
10
|
function getPageContextProxyForUser(pageContext) {
|
|
10
11
|
assert([true, false].includes(pageContext._hasPageContextFromServer));
|
|
@@ -12,66 +13,45 @@ function getPageContextProxyForUser(pageContext) {
|
|
|
12
13
|
return new Proxy(pageContext, {
|
|
13
14
|
get(_, prop) {
|
|
14
15
|
const val = pageContext[prop];
|
|
15
|
-
const propName =
|
|
16
|
-
assertUsage(val !== notSerializable, `pageContext
|
|
17
|
-
|
|
16
|
+
const propName = getPropAccessNotation(prop);
|
|
17
|
+
assertUsage(val !== notSerializable, `pageContext${propName} couldn't be serialized and, therefore, is missing on the client-side. Check the server logs for more information.`);
|
|
18
|
+
passToClientHint(pageContext, prop, propName);
|
|
18
19
|
return val;
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
// - Vue tries to read its old value first. This triggers a `assertIsDefined()` failure if e.g. `pageContextOldReactive.routeParams = pageContextNew.routeParams` and `pageContextOldReactive` has no `routeParams`.
|
|
25
|
-
// - Vue seems to read __v_raw before reading the property
|
|
26
|
-
if (globalObject.prev === prop || globalObject.prev === '__v_raw')
|
|
23
|
+
function passToClientHint(pageContext, prop, propName) {
|
|
24
|
+
if (handleVueReactivity(prop))
|
|
27
25
|
return;
|
|
28
|
-
|
|
26
|
+
// `prop in pageContext` is the trick we use to know the passToClient value on the client-side, as we set a value to all passToClient props, even `undefined` ones:
|
|
27
|
+
// ```html
|
|
28
|
+
// <script id="vike_pageContext" type="application/json">{"pageProps":"!undefined"}</script>
|
|
29
|
+
// ```
|
|
29
30
|
if (prop in pageContext)
|
|
30
31
|
return;
|
|
31
|
-
if (
|
|
32
|
+
if (isWhitelisted(prop))
|
|
32
33
|
return;
|
|
33
|
-
//
|
|
34
|
-
// -
|
|
34
|
+
// The trick described above (`prop in pageContext`) doesn't work if Vike doesn't fetch any pageContext from the server.
|
|
35
|
+
// - There would still be some value to show a warning, but it isn't worth it because of the confusion that the first recommendation (adding `prop` to `passToClient`) wouldn't actually remove the warning, and only the second recommendation (using `prop in pageContext` instead of `pageContext[prop]`) would work.
|
|
35
36
|
if (!pageContext._hasPageContextFromServer)
|
|
36
37
|
return;
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*/
|
|
44
|
-
if (!pageContext._hasPageContextFromClient) {
|
|
45
|
-
// We can safely assume that the property is missing in passToClient, because the server-side defines all passToClient properties even if they have an undefined value:
|
|
46
|
-
// ```
|
|
47
|
-
// <script id="vike_pageContext" type="application/json">{"_pageId":"/pages/admin","user":"!undefined","pageProps":"!undefined","title":"!undefined","abortReason":"!undefined","_urlRewrite":null}</script>
|
|
48
|
-
// ```
|
|
49
|
-
// Note how properties have "!undefined" values => we can tell whether an undefined pageContext value exists in passToClient.
|
|
50
|
-
assertUsage(false, `pageContext[${propName}] isn't available on the client-side because ${propName} is missing in passToClient, see https://vike.dev/passToClient`);
|
|
38
|
+
const errMsg = `pageContext${propName} isn't defined on the client-side, see https://vike.dev/passToClient#error`;
|
|
39
|
+
if (
|
|
40
|
+
// TODO/next-major-release always make it an error.
|
|
41
|
+
// - Remove pageContext._hasPageContextFromClient logic (IIRC this is its only use case).
|
|
42
|
+
pageContext._hasPageContextFromClient) {
|
|
43
|
+
assertWarning(false, errMsg, { onlyOnce: false, showStackTrace: true });
|
|
51
44
|
}
|
|
52
45
|
else {
|
|
53
|
-
|
|
54
|
-
// TODO/next-major-release make it an assertUsage()
|
|
55
|
-
assertWarning(false, [
|
|
56
|
-
`pageContext[${propName}] isn't defined on the client-side:`,
|
|
57
|
-
`1. if it's defined by the server-side then add ${propName} to passToClient (https://vike.dev/passToClient), or`,
|
|
58
|
-
`2. if it's expected that it may not be defined:`,
|
|
59
|
-
' ```js',
|
|
60
|
-
' // ❌ Replace code like this:',
|
|
61
|
-
` const val = pageContext[${propName}] ?? someDefaultValue`,
|
|
62
|
-
' // ✅ With that:',
|
|
63
|
-
` const val = ${propName} in pageContext ? pageContext[${propName}] : someDefaultValue`,
|
|
64
|
-
' ```',
|
|
65
|
-
`See stack track below to find where pageContext[${propName}] is being accessed.`
|
|
66
|
-
].join('\n'), { showStackTrace: true, onlyOnce: false });
|
|
46
|
+
assertUsage(false, errMsg);
|
|
67
47
|
}
|
|
68
48
|
}
|
|
69
|
-
const
|
|
49
|
+
const WHITELIST = [
|
|
70
50
|
'then',
|
|
71
|
-
'toJSON' // Vue
|
|
51
|
+
'toJSON' // Vue triggers `toJSON`
|
|
72
52
|
];
|
|
73
|
-
function
|
|
74
|
-
if (
|
|
53
|
+
function isWhitelisted(prop) {
|
|
54
|
+
if (WHITELIST.includes(prop))
|
|
75
55
|
return true;
|
|
76
56
|
if (typeof prop === 'symbol')
|
|
77
57
|
return true; // Vue tries to access some symbols
|
|
@@ -81,9 +61,16 @@ function isExpected(prop) {
|
|
|
81
61
|
return true; // Vue internals upon `reactive(pageContext)`
|
|
82
62
|
return false;
|
|
83
63
|
}
|
|
84
|
-
|
|
64
|
+
// Handle Vue's reactivity.
|
|
65
|
+
// When changing a reactive object:
|
|
66
|
+
// - Vue tries to read its old value first. This triggers a `assertIsDefined()` failure if e.g. `pageContextReactive.routeParams = pageContextNew.routeParams` and `pageContextReactive` has no `routeParams`.
|
|
67
|
+
// - Vue seems to read __v_raw before reading the property.
|
|
68
|
+
function handleVueReactivity(prop) {
|
|
69
|
+
if (globalObject.prev === prop || globalObject.prev === '__v_raw')
|
|
70
|
+
return true;
|
|
85
71
|
globalObject.prev = prop;
|
|
86
72
|
window.setTimeout(() => {
|
|
87
73
|
globalObject.prev = undefined;
|
|
88
74
|
}, 0);
|
|
75
|
+
return false;
|
|
89
76
|
}
|
|
@@ -3,6 +3,7 @@ export { isErrorFetchingStaticAssets };
|
|
|
3
3
|
import { getPageFilesClientSide, getPageContextExports } from '../../shared/getPageFiles.js';
|
|
4
4
|
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
5
5
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
6
|
+
import { objectAssign } from '../server-routing-runtime/utils.js';
|
|
6
7
|
const stamp = '__whileFetchingAssets';
|
|
7
8
|
async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
8
9
|
const pageFilesClientSide = getPageFilesClientSide(pageFilesAll, pageId);
|
|
@@ -29,10 +30,9 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
|
29
30
|
throw err;
|
|
30
31
|
}
|
|
31
32
|
const pageContextExports = getPageContextExports(pageFilesClientSide, pageConfigLoaded);
|
|
32
|
-
const pageContextAddendum = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
33
|
+
const pageContextAddendum = {};
|
|
34
|
+
objectAssign(pageContextAddendum, pageContextExports);
|
|
35
|
+
objectAssign(pageContextAddendum, { _pageFilesLoaded: pageFilesClientSide });
|
|
36
36
|
return pageContextAddendum;
|
|
37
37
|
}
|
|
38
38
|
function isErrorFetchingStaticAssets(err) {
|
|
@@ -24,9 +24,12 @@ import { baseUrls } from './plugins/baseUrls.js';
|
|
|
24
24
|
import { envVarsPlugin } from './plugins/envVars.js';
|
|
25
25
|
import pc from '@brillout/picocolors';
|
|
26
26
|
import { fileEnv } from './plugins/fileEnv.js';
|
|
27
|
+
import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.js';
|
|
28
|
+
import { resolveClientEntriesDev } from './resolveClientEntriesDev.js';
|
|
27
29
|
assertNodeEnv_onVikePluginLoad();
|
|
28
30
|
markEnvAsVikePluginLoaded();
|
|
29
31
|
assertViteVersion();
|
|
32
|
+
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
30
33
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
31
34
|
function plugin(vikeConfig) {
|
|
32
35
|
const plugins = [
|
|
@@ -4,19 +4,18 @@ export { analyzeClientEntries };
|
|
|
4
4
|
export { manifestTempFile };
|
|
5
5
|
import { assert, resolveOutDir, viteIsSSR, addOnBeforeLogHook, removeFileExtention, unique, assertUsage, injectRollupInputs, normalizeRollupInput, getOutDirs, assertNodeEnv_build, assertIsNpmPackageImport } from '../utils.js';
|
|
6
6
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
|
-
import { getConfigValue } from '../../../shared/page-configs/getConfigValue.js';
|
|
8
7
|
import { findPageFiles } from '../shared/findPageFiles.js';
|
|
9
8
|
import { getConfigVike } from '../../shared/getConfigVike.js';
|
|
10
9
|
import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
11
10
|
import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
|
|
12
11
|
import { createRequire } from 'module';
|
|
13
|
-
import { getClientEntry } from '../../shared/getClientEntry.js';
|
|
14
12
|
import fs from 'fs/promises';
|
|
15
13
|
import path from 'path';
|
|
16
14
|
import { fixServerAssets, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
17
15
|
import { set_constant_ASSETS_MAP } from './importBuild/index.js';
|
|
18
16
|
import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
|
|
19
17
|
import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
18
|
+
import { getConfigValueBuildTime } from '../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
20
19
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
21
20
|
const importMetaUrl = import.meta.url;
|
|
22
21
|
const require_ = createRequire(importMetaUrl);
|
|
@@ -152,7 +151,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
152
151
|
let clientEntries = {};
|
|
153
152
|
let clientEntryList = [];
|
|
154
153
|
pageConfigs.forEach((pageConfig) => {
|
|
155
|
-
const configValue =
|
|
154
|
+
const configValue = getConfigValueBuildTime(pageConfig, 'clientRouting', 'boolean');
|
|
156
155
|
if (configValue?.value) {
|
|
157
156
|
hasClientRouting = true;
|
|
158
157
|
}
|
|
@@ -165,7 +164,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
165
164
|
clientEntries[entryName] = entryTarget;
|
|
166
165
|
}
|
|
167
166
|
{
|
|
168
|
-
const clientEntry =
|
|
167
|
+
const clientEntry = getConfigValueBuildTime(pageConfig, 'client', 'string')?.value ?? null;
|
|
169
168
|
if (clientEntry) {
|
|
170
169
|
clientEntryList.push(clientEntry);
|
|
171
170
|
}
|
|
@@ -20,15 +20,16 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
20
20
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
21
21
|
const fromViteConfig = (config.vike ?? {});
|
|
22
22
|
const configs = [fromPluginOptions, fromViteConfig];
|
|
23
|
-
|
|
23
|
+
assertVikeConfig(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
24
|
+
// TODO/v1-release: deprecate this
|
|
25
|
+
assertVikeConfig(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
26
|
+
const crawlWithGit = fromPluginOptions.crawl?.git ?? null;
|
|
27
|
+
const { globalVikeConfig: fromPlusConfigFile } = await getVikeConfig(config, isDev2(config), { crawlWithGit });
|
|
24
28
|
configs.push(fromPlusConfigFile);
|
|
25
29
|
assertVikeConfig(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
26
30
|
// TODO: add config file path ?
|
|
27
31
|
return `config ${pc.cyan(prop)} ${errMsg}`;
|
|
28
32
|
});
|
|
29
|
-
assertVikeConfig(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
30
|
-
// TODO/v1-release: deprecate this
|
|
31
|
-
assertVikeConfig(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
32
33
|
const { baseServer, baseAssets } = resolveBase(configs, config);
|
|
33
34
|
const configVike = {
|
|
34
35
|
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
@@ -38,7 +39,10 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
38
39
|
baseAssets,
|
|
39
40
|
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
40
41
|
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
41
|
-
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
|
|
42
|
+
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false,
|
|
43
|
+
crawl: {
|
|
44
|
+
git: crawlWithGit
|
|
45
|
+
}
|
|
42
46
|
};
|
|
43
47
|
return configVike;
|
|
44
48
|
}
|