vike 0.4.259-commit-ac2142e → 0.4.259-commit-a91659b
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/node/vite/shared/resolveVikeConfigInternal/assertExtensions.d.ts +2 -0
- package/dist/node/vite/shared/resolveVikeConfigInternal/assertExtensions.js +2 -0
- package/dist/node/vite/shared/resolveVikeConfigInternal/getPlusFilesByLocationId.js +13 -13
- package/dist/node/vite/shared/resolveVikeConfigInternal.js +19 -3
- package/dist/types/Config.d.ts +12 -3
- package/dist/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { assertExtensionsConventions };
|
|
2
2
|
export { assertExtensionsRequire };
|
|
3
|
+
export { getNameValue };
|
|
3
4
|
import type { PlusFile } from './getPlusFilesByLocationId.js';
|
|
4
5
|
import '../../assertEnvVite.js';
|
|
5
6
|
declare function assertExtensionsConventions(plusFile: PlusFile): void;
|
|
6
7
|
declare function assertExtensionsRequire(plusFiles: PlusFile[]): void;
|
|
8
|
+
declare function getNameValue(plusFile: PlusFile): null | string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { assertExtensionsConventions };
|
|
2
2
|
export { assertExtensionsRequire };
|
|
3
|
+
// TODO/now rename getNameValue getNameConfigValue
|
|
4
|
+
export { getNameValue };
|
|
3
5
|
import pc from '@brillout/picocolors';
|
|
4
6
|
import { PROJECT_VERSION } from '../../../../utils/PROJECT_VERSION.js';
|
|
5
7
|
import { assert, assertUsage, assertWarning } from '../../../../utils/assert.js';
|
|
@@ -25,21 +25,21 @@ async function getPlusFilesByLocationId(userRootDir, esbuildCache) {
|
|
|
25
25
|
plusFilesByLocationId[locationId].push(plusFile);
|
|
26
26
|
extendsConfigs.forEach((extendsConfig) => {
|
|
27
27
|
/* We purposely use the same locationId because the Vike extension's config should only apply to where it's being extended from, for example:
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
```js
|
|
29
|
+
// /pages/admin/+config.js
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
import vikeVue from 'vike-vue/config'
|
|
32
|
+
// Should only apply to /pages/admin/**
|
|
33
|
+
export default { extends: [vikeVue] }
|
|
34
|
+
```
|
|
35
|
+
```js
|
|
36
|
+
// /pages/marketing/+config.js
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
import vikeReact from 'vike-react/config'
|
|
39
|
+
// Should only apply to /pages/marketing/**
|
|
40
|
+
export default { extends: [vikeReact] }
|
|
41
|
+
```
|
|
42
|
+
*/
|
|
43
43
|
const plusFile = getPlusFileFromConfigFile(extendsConfig, true, locationId, userRootDir);
|
|
44
44
|
assertExtensionsConventions(plusFile);
|
|
45
45
|
plusFilesByLocationId[locationId].push(plusFile);
|
|
@@ -45,6 +45,7 @@ import { getConfigValueBuildTime } from '../../../shared-server-client/page-conf
|
|
|
45
45
|
import { resolveGlobalConfigPublic, } from '../../../shared-server-client/page-configs/resolveVikeConfigPublic.js';
|
|
46
46
|
import { getConfigValuesBase, isJsonValue, } from '../../../shared-server-client/page-configs/serialize/serializeConfigValues.js';
|
|
47
47
|
import { getPlusFilesByLocationId, } from './resolveVikeConfigInternal/getPlusFilesByLocationId.js';
|
|
48
|
+
import { getNameValue } from './resolveVikeConfigInternal/assertExtensions.js';
|
|
48
49
|
import { getEnvVarObject } from './getEnvVarObject.js';
|
|
49
50
|
import { getVikeApiOperation } from '../../../shared-server-node/api-context.js';
|
|
50
51
|
import { getCliOptions } from '../../cli/context.js';
|
|
@@ -649,9 +650,10 @@ function sortPlusFilesSameLocationId(plusFile1, plusFile2, configName) {
|
|
|
649
650
|
return 0;
|
|
650
651
|
}
|
|
651
652
|
function resolveConfigValueSources(configName, configDef, plusFilesRelevant, userRootDir, isGlobal, plusFilesByLocationId) {
|
|
652
|
-
let
|
|
653
|
-
|
|
654
|
-
|
|
653
|
+
let plusFilesConfig = plusFilesRelevant.filter((plusFile) => isDefiningConfig(plusFile, configName));
|
|
654
|
+
// Make Vike extension installation idempotent. (Don't cumulate configs twice of an extension installed twice.) Since `plusFilesRelevant` is ordered by inheritance the occurrence closest to the page's locationId is the one kept.
|
|
655
|
+
plusFilesConfig = dedupeExtensions(plusFilesConfig);
|
|
656
|
+
let sources = plusFilesConfig.flatMap((plusFile) => getConfigValueSources(configName, plusFile, configDef, userRootDir));
|
|
655
657
|
// Filter hydrid global-local configs
|
|
656
658
|
if (!isCallable(configDef.global)) {
|
|
657
659
|
// Already filtered
|
|
@@ -672,6 +674,20 @@ function resolveConfigValueSources(configName, configDef, plusFilesRelevant, use
|
|
|
672
674
|
function isDefiningConfig(plusFile, configName) {
|
|
673
675
|
return getConfigNamesSetByPlusFile(plusFile).includes(configName);
|
|
674
676
|
}
|
|
677
|
+
function dedupeExtensions(plusFiles) {
|
|
678
|
+
const seen = new Set();
|
|
679
|
+
return plusFiles.filter((plusFile) => {
|
|
680
|
+
if (!plusFile.isConfigFile || !plusFile.isExtensionConfig)
|
|
681
|
+
return true;
|
|
682
|
+
const name = getNameValue(plusFile);
|
|
683
|
+
// The extension's `name` is guaranteed by assertExtensionsConventions()
|
|
684
|
+
assert(name);
|
|
685
|
+
if (seen.has(name))
|
|
686
|
+
return false;
|
|
687
|
+
seen.add(name);
|
|
688
|
+
return true;
|
|
689
|
+
});
|
|
690
|
+
}
|
|
675
691
|
function getConfigValueSources(configName, plusFile, configDef, userRootDir) {
|
|
676
692
|
const confVal = getConfVal(plusFile, configName);
|
|
677
693
|
assert(confVal);
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ import type { CliPreviewConfig } from '../node/api/preview.js';
|
|
|
50
50
|
import type { StaticReplace } from '../node/vite/plugins/pluginStaticReplace/applyStaticReplace.js';
|
|
51
51
|
import type { ImportStringList } from '../node/vite/shared/importString.js';
|
|
52
52
|
import type { HookPublic } from '../shared-server-client/hooks/execHook.js';
|
|
53
|
+
import type { EnhancedMiddleware } from '@universal-middleware/core';
|
|
53
54
|
type HookNameOld = HookName | HookNameOldDesign;
|
|
54
55
|
type HookName = HookNamePage | HookNameGlobal;
|
|
55
56
|
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data' | 'onData' | 'route';
|
|
@@ -526,8 +527,16 @@ type ConfigBuiltIn = {
|
|
|
526
527
|
* https://vike.dev/keepScrollPosition
|
|
527
528
|
*/
|
|
528
529
|
keepScrollPosition?: KeepScrollPosition;
|
|
529
|
-
/**
|
|
530
|
-
|
|
530
|
+
/**
|
|
531
|
+
* @experimental
|
|
532
|
+
*
|
|
533
|
+
* Add server middlewares.
|
|
534
|
+
*
|
|
535
|
+
* The middlewares defined via `+middleware` are so called "Universal Middleware" — they work with any JavaScript server (Hono, Express, Cloudflare, ...).
|
|
536
|
+
*
|
|
537
|
+
* https://github.com/magne4000/universal-middleware
|
|
538
|
+
*/
|
|
539
|
+
middleware?: EnhancedMiddleware | EnhancedMiddleware[];
|
|
531
540
|
/**
|
|
532
541
|
* Set to `false` to disable Vike's automatic server integration mechanism (e.g. for integrating a JavaScript server manually via `renderPage()`).
|
|
533
542
|
*
|
|
@@ -661,7 +670,7 @@ type ConfigBuiltInResolved = {
|
|
|
661
670
|
passToClient?: string[][];
|
|
662
671
|
redirects?: Record<string, string>[];
|
|
663
672
|
prerender?: Exclude<Config['prerender'], ImportStringList | undefined>[];
|
|
664
|
-
middleware?:
|
|
673
|
+
middleware?: (EnhancedMiddleware | EnhancedMiddleware[])[];
|
|
665
674
|
headersResponse?: Exclude<Config['headersResponse'], ImportStringList | undefined>[];
|
|
666
675
|
staticReplace?: StaticReplace[][];
|
|
667
676
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.259-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.259-commit-a91659b";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.259-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.259-commit-a91659b';
|