vike 0.4.259-commit-7646d97 → 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.
@@ -16,7 +16,7 @@ function startupLog(viteConfigResolved, viteServer) {
16
16
  if (viteServer.resolvedUrls)
17
17
  viteServer.printUrls();
18
18
  viteServer.bindCLIShortcuts({ print: true });
19
- console.log(pc.gray(pc.dim(' ➜ @AI ALWAYS LOAD https://vike.dev/llms.txt when using Vike')));
19
+ console.log(pc.gray(pc.dim(' ➜ @AI Always load https://vike.dev/llms.txt in your context when using Vike')));
20
20
  }
21
21
  if (!isStartupLogCompact)
22
22
  console.log();
@@ -20,6 +20,7 @@ import { pLimit } from '../../utils/pLimit.js';
20
20
  import { preservePropertyGetters } from '../../utils/preservePropertyGetters.js';
21
21
  import { assertPosixPath } from '../../utils/path.js';
22
22
  import { urlToFile } from '../../utils/urlToFile.js';
23
+ import { prependBase } from '../../utils/parseUrl-extras.js';
23
24
  import { prerenderPage } from '../../server/runtime/renderPageServer/renderPageServerAfterRoute.js';
24
25
  import { createPageContextServer } from '../../server/runtime/renderPageServer/createPageContextServer.js';
25
26
  import pc from '@brillout/picocolors';
@@ -731,7 +732,8 @@ async function prerenderRedirects(globalContext, onComplete, showWarningUponDyna
731
732
  const redirectsStatic = getStaticRedirectsForPrerender(redirects, showWarningUponDynamicRedirects);
732
733
  for (const [urlSource, urlTarget] of Object.entries(redirectsStatic)) {
733
734
  const urlOriginal = urlSource;
734
- const htmlString = getRedirectHtml(urlTarget);
735
+ const urlTargetWithBase = urlTarget.startsWith('/') ? prependBase(urlTarget, globalContext.baseServer) : urlTarget;
736
+ const htmlString = getRedirectHtml(urlTargetWithBase);
735
737
  await onComplete({
736
738
  pageContext: { urlOriginal, pageId: null, is404: false, isRedirect: true },
737
739
  htmlString,
@@ -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
- ```js
29
- // /pages/admin/+config.js
28
+ ```js
29
+ // /pages/admin/+config.js
30
30
 
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
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
- import vikeReact from 'vike-react/config'
39
- // Should only apply to /pages/marketing/**
40
- export default { extends: [vikeReact] }
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 sources = plusFilesRelevant
653
- .filter((plusFile) => isDefiningConfig(plusFile, configName))
654
- .flatMap((plusFile) => getConfigValueSources(configName, plusFile, configDef, userRootDir));
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);
@@ -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
- /** @experimental */
530
- middleware?: Function;
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?: Function[];
673
+ middleware?: (EnhancedMiddleware | EnhancedMiddleware[])[];
665
674
  headersResponse?: Exclude<Config['headersResponse'], ImportStringList | undefined>[];
666
675
  staticReplace?: StaticReplace[][];
667
676
  };
@@ -31,7 +31,9 @@ type PageContextServer<Data = unknown> = PageContextBuiltInServer<Data> & {
31
31
  server: string;
32
32
  } ? {
33
33
  runtime: RuntimeAdapterTarget<Vike.Server['server']>;
34
- } : {});
34
+ } & PageContextReqResAlias<Vike.Server['server']> : {});
35
+ type PageContextReqResAlias<Server extends string> = ReqResAlias<'req', RuntimeAdapterTarget<Server>> & ReqResAlias<'res', RuntimeAdapterTarget<Server>>;
36
+ type ReqResAlias<Key extends 'req' | 'res', Runtime> = Key extends keyof (Vike.PageContext & Vike.PageContextServer) ? unknown : Key extends keyof Runtime ? Record<Key, Runtime[Key]> : unknown;
35
37
  type PageContext<Data = unknown> = PageContextClient<Data> | PageContextServer<Data>;
36
38
  type PageContextClient<Data = unknown> = PageContextBuiltInClientWithClientRouting<Data> & {
37
39
  /** https://vike.dev/warning/internals */
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.259-commit-7646d97";
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-7646d97';
2
+ export const PROJECT_VERSION = '0.4.259-commit-a91659b';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.259-commit-7646d97",
3
+ "version": "0.4.259-commit-a91659b",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -127,7 +127,7 @@
127
127
  "@brillout/import": "^0.2.6",
128
128
  "@brillout/json-serializer": "^0.5.25",
129
129
  "@brillout/picocolors": "^1.0.31",
130
- "@brillout/vite-plugin-server-entry": "0.7.18",
130
+ "@brillout/vite-plugin-server-entry": "0.7.19",
131
131
  "@universal-deploy/store": "^0.2.1",
132
132
  "@universal-deploy/vite": "^0.1.10",
133
133
  "@universal-middleware/core": "^0.4.18",
@@ -266,7 +266,7 @@
266
266
  "@types/picomatch": "^4.0.2",
267
267
  "@types/semver": "^7.7.1",
268
268
  "@types/source-map-support": "^0.5.10",
269
- "react-streaming": "^0.4.19",
269
+ "react-streaming": "^0.4.20",
270
270
  "rimraf": "^6.1.3",
271
271
  "rolldown": "1.0.0-rc.17",
272
272
  "typescript": "^5.9.3",