vike 0.4.254 → 0.4.255-commit-05a7b95

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.
Files changed (59) hide show
  1. package/dist/client/runtime-client-routing/createPageContextClient.d.ts +2 -24
  2. package/dist/client/runtime-client-routing/getGlobalContextClientInternal.d.ts +2 -24
  3. package/dist/client/runtime-client-routing/getPageContextFromHooks.d.ts +8 -96
  4. package/dist/client/runtime-client-routing/renderPageClient.d.ts +8 -96
  5. package/dist/client/runtime-server-routing/createPageContextClient.d.ts +2 -24
  6. package/dist/client/runtime-server-routing/getGlobalContextClientInternal.d.ts +2 -24
  7. package/dist/client/shared/getGlobalContextClientInternalShared.d.ts +2 -24
  8. package/dist/node/prerender/runPrerender.d.ts +9 -36
  9. package/dist/node/vite/index.js +2 -0
  10. package/dist/node/vite/plugins/build/pluginBuildConfig.js +2 -2
  11. package/dist/node/vite/plugins/pluginCommon/assertResolveAlias.js +2 -2
  12. package/dist/node/vite/plugins/pluginDev/optimizeDeps.js +2 -2
  13. package/dist/node/vite/plugins/pluginReplaceConstantsGlobalThis.js +2 -0
  14. package/dist/node/vite/plugins/pluginStripPointerImportAttribute.js +3 -3
  15. package/dist/node/vite/plugins/pluginUniversalDeploy/getDeployConfigs.d.ts +12 -0
  16. package/dist/node/vite/plugins/pluginUniversalDeploy/getDeployConfigs.js +73 -0
  17. package/dist/node/vite/plugins/pluginUniversalDeploy.d.ts +5 -0
  18. package/dist/node/vite/plugins/pluginUniversalDeploy.js +155 -0
  19. package/dist/node/vite/shared/addSsrMiddleware.js +1 -0
  20. package/dist/node/vite/shared/getClientEntrySrcDev.js +2 -2
  21. package/dist/node/vite/shared/getFilePath.js +3 -3
  22. package/dist/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +18 -0
  23. package/dist/node/vite/shared/resolveVikeConfigInternal/pointerImports.d.ts +0 -2
  24. package/dist/node/vite/shared/resolveVikeConfigInternal/pointerImports.js +16 -6
  25. package/dist/node/vite/shared/resolveVikeConfigInternal/resolvePointerImport.js +2 -2
  26. package/dist/node/vite/shared/resolveVikeConfigInternal/transpileAndExecuteFile.js +16 -34
  27. package/dist/server/assertEnvServer.js +1 -1
  28. package/dist/server/runtime/fetch.d.ts +10 -0
  29. package/dist/server/runtime/fetch.js +5 -0
  30. package/dist/server/runtime/globalContext.d.ts +10 -120
  31. package/dist/server/runtime/renderPageServer/createHttpResponse.d.ts +5 -3
  32. package/dist/server/runtime/renderPageServer/createHttpResponse.js +13 -1
  33. package/dist/server/runtime/renderPageServer/createPageContextServer.d.ts +15 -39
  34. package/dist/server/runtime/renderPageServer/getPageAssets/getManifestEntry.js +2 -2
  35. package/dist/server/runtime/renderPageServer/getPageAssets/retrievePageAssetsProd.js +2 -2
  36. package/dist/server/runtime/renderPageServer/loadPageConfigsLazyServerSide.d.ts +9 -36
  37. package/dist/server/runtime/renderPageServer/renderPageServerAfterRoute.d.ts +36 -144
  38. package/dist/server/runtime/renderPageServer.d.ts +13 -39
  39. package/dist/server/runtime/renderPageServer.js +51 -3
  40. package/dist/server/runtime/universal-middleware.d.ts +9 -2
  41. package/dist/server/runtime/universal-middleware.js +9 -1
  42. package/dist/shared-server-client/createGlobalContextShared.d.ts +4 -48
  43. package/dist/shared-server-client/getPageFiles/fileTypes.js +1 -1
  44. package/dist/shared-server-client/page-configs/resolveVikeConfigPublic.d.ts +1 -0
  45. package/dist/types/Config.d.ts +28 -1
  46. package/dist/types/PageContext.d.ts +6 -0
  47. package/dist/utils/PROJECT_VERSION.d.ts +1 -1
  48. package/dist/utils/PROJECT_VERSION.js +1 -1
  49. package/dist/utils/asyncFlatten.d.ts +4 -0
  50. package/dist/utils/asyncFlatten.js +7 -0
  51. package/dist/utils/isImportPath.js +2 -2
  52. package/dist/utils/isScriptFile.d.ts +2 -0
  53. package/dist/utils/isScriptFile.js +4 -0
  54. package/dist/utils/parseNpmPackage.d.ts +8 -8
  55. package/dist/utils/parseNpmPackage.js +13 -13
  56. package/dist/utils/path.js +1 -1
  57. package/dist/utils/requireResolve.js +3 -3
  58. package/fetch.js +3 -0
  59. package/package.json +21 -4
@@ -54,7 +54,7 @@ type HookName = HookNamePage | HookNameGlobal;
54
54
  type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data' | 'onData' | 'route';
55
55
  type HookNameGlobal = 'onBeforeRoute' | 'onPrerenderStart' | 'onCreatePageContext' | 'onCreateGlobalContext' | 'onError' | 'onHookCall';
56
56
  type HookNameOldDesign = 'render' | 'prerender' | 'onBeforePrerender';
57
- type ConfigNameBuiltIn = Exclude<keyof ConfigBuiltIn, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | 'hasServerOnlyHook' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'guardEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware';
57
+ type ConfigNameBuiltIn = Exclude<keyof ConfigBuiltIn, keyof VikeVitePluginOptions | 'onBeforeRoute' | 'onPrerenderStart' | 'vite' | 'redirects'> | 'prerender' | 'hasServerOnlyHook' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'guardEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware' | 'server' | 'isr' | 'edge';
58
58
  type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
59
59
  type Config = ConfigBuiltIn & Vike.Config;
60
60
  /** @deprecated This type is deprecated, see:
@@ -521,6 +521,14 @@ type ConfigBuiltIn = {
521
521
  keepScrollPosition?: KeepScrollPosition;
522
522
  /** @experimental */
523
523
  middleware?: Function;
524
+ /**
525
+ * Set to `false` to disable Vike's automatic server integration mechanism (e.g. for integrating a JavaScript server manually via `renderPage()`).
526
+ *
527
+ * Set to `true` to use Vike's built-in server (no need to define `+server.js`).
528
+ *
529
+ * https://vike.dev/server
530
+ */
531
+ server?: boolean;
524
532
  cli?: {
525
533
  /** @experimental
526
534
  *
@@ -540,6 +548,25 @@ type ConfigBuiltIn = {
540
548
  * @experimental
541
549
  */
542
550
  staticReplace?: StaticReplace[];
551
+ /**
552
+ * The license key for larger teams.
553
+ *
554
+ * https://vike.dev/license
555
+ * https://vike.dev/pricing
556
+ */
557
+ license?: string;
558
+ /** Incremental Static Regeneration (ISR).
559
+ *
560
+ * https://vike.dev/vercel#isr
561
+ */
562
+ isr?: {
563
+ expiration: number;
564
+ };
565
+ /** Deploy on Vercel Edge.
566
+ *
567
+ * https://vike.dev/vercel
568
+ */
569
+ edge?: boolean;
543
570
  };
544
571
  type PrerenderSetting = boolean | {
545
572
  /**
@@ -1,3 +1,4 @@
1
+ import type { IncomingMessage } from 'node:http';
1
2
  export type { PageContext };
2
3
  export type { PageContextServer };
3
4
  export type { PageContextClient };
@@ -7,6 +8,7 @@ export type { PageContextInternalServer };
7
8
  export type { PageContextInternalClient };
8
9
  export type { PageContextInternalClient_ServerRouting };
9
10
  export type { PageContextInternalClient_ClientRouting };
11
+ export type { PageContextInternalInit };
10
12
  export type { PageContextInit };
11
13
  export type { PageContextBuiltInServer_deprecated as PageContextBuiltInServer };
12
14
  export type { PageContextBuiltInClientWithClientRouting_deprecated as PageContextBuiltInClientWithClientRouting };
@@ -132,6 +134,10 @@ type PageContextInit = {
132
134
  headersOriginal?: unknown;
133
135
  /** @deprecated Set `pageContextInit.urlOriginal` instead */ url?: string;
134
136
  };
137
+ type PageContextInternalInit = PageContextInit & {
138
+ _reqDev?: IncomingMessage;
139
+ _reqWeb?: Request;
140
+ };
135
141
  type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> & PageContextInit & PageContextUrlServer & {
136
142
  /**
137
143
  * The HTTP request headers.
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.254";
1
+ export declare const PROJECT_VERSION: "0.4.255-commit-05a7b95";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.254';
2
+ export const PROJECT_VERSION = '0.4.255-commit-05a7b95';
@@ -0,0 +1,4 @@
1
+ export { asyncFlatten };
2
+ export type { AsyncFlatten };
3
+ type AsyncFlatten<T extends unknown[]> = T extends (infer U)[] ? Exclude<Awaited<U>, U[]>[] : never;
4
+ declare function asyncFlatten<T extends unknown[]>(arr: T): Promise<AsyncFlatten<T>>;
@@ -0,0 +1,7 @@
1
+ export { asyncFlatten };
2
+ async function asyncFlatten(arr) {
3
+ do {
4
+ arr = (await Promise.all(arr)).flat(Infinity);
5
+ } while (arr.some((v) => v?.then));
6
+ return arr;
7
+ }
@@ -2,9 +2,9 @@ export { isImportPath };
2
2
  export { isImportPathRelative };
3
3
  import { assertPosixPath } from './path.js';
4
4
  import { assert } from './assert.js';
5
- import { isImportPathNpmPackageOrPathAlias } from './parseNpmPackage.js';
5
+ import { isImportNpmPackageOrPathAlias } from './parseNpmPackage.js';
6
6
  function isImportPath(importPath) {
7
- return isImportPathRelative(importPath) || isImportPathNpmPackageOrPathAlias(importPath);
7
+ return isImportPathRelative(importPath) || isImportNpmPackageOrPathAlias(importPath);
8
8
  }
9
9
  // See also `import { pathIsRelative } from './path'`
10
10
  function isImportPathRelative(importPath) {
@@ -1,5 +1,6 @@
1
1
  export { isScriptFile };
2
2
  export { isPlainScriptFile };
3
+ export { isPlainJavaScriptFile };
3
4
  export { isTemplateFile };
4
5
  export { scriptFileExtensionList };
5
6
  export { scriptFileExtensionPattern };
@@ -7,4 +8,5 @@ declare const scriptFileExtensionList: readonly ["js", "cjs", "mjs", "ts", "cts"
7
8
  declare const scriptFileExtensionPattern: string;
8
9
  declare function isScriptFile(filePath: string): boolean;
9
10
  declare function isPlainScriptFile(filePath: string): boolean;
11
+ declare function isPlainJavaScriptFile(filePath: string): boolean;
10
12
  declare function isTemplateFile(filePath: string): boolean;
@@ -1,5 +1,6 @@
1
1
  export { isScriptFile };
2
2
  export { isPlainScriptFile };
3
+ export { isPlainJavaScriptFile };
3
4
  export { isTemplateFile };
4
5
  export { scriptFileExtensionList };
5
6
  export { scriptFileExtensionPattern };
@@ -59,6 +60,9 @@ function isScriptFile(filePath) {
59
60
  function isPlainScriptFile(filePath) {
60
61
  return extJsOrTs.some((ext) => filePath.endsWith('.' + ext));
61
62
  }
63
+ function isPlainJavaScriptFile(filePath) {
64
+ return extJs.some((ext) => filePath.endsWith('.' + ext));
65
+ }
62
66
  function isTemplateFile(filePath) {
63
67
  return extTemplates.some((ext) => filePath.endsWith('.' + ext));
64
68
  }
@@ -1,17 +1,17 @@
1
- export { isImportPathNpmPackage };
2
- export { isImportPathNpmPackageOrPathAlias };
3
- export { assertIsImportPathNpmPackage };
4
- export { isPathAliasRecommended };
1
+ export { isImportNpmPackage };
2
+ export { isImportNpmPackageOrPathAlias };
3
+ export { assertImportIsNpmPackage };
4
+ export { isPathAliasRecommendation };
5
5
  export { getNpmPackageName };
6
6
  export { parseNpmPackage };
7
7
  export { isDistinguishable };
8
8
  declare function getNpmPackageName(str: string): null | string;
9
- declare function isImportPathNpmPackage(str: string, { cannotBePathAlias }: {
9
+ declare function isImportNpmPackage(str: string, { cannotBePathAlias }: {
10
10
  cannotBePathAlias: true;
11
11
  }): boolean;
12
- declare function isImportPathNpmPackageOrPathAlias(str: string): boolean;
13
- declare function assertIsImportPathNpmPackage(str: string): void;
14
- declare function isPathAliasRecommended(alias: string): boolean;
12
+ declare function isImportNpmPackageOrPathAlias(str: string): boolean;
13
+ declare function assertImportIsNpmPackage(str: string): void;
14
+ declare function isPathAliasRecommendation(alias: string): boolean;
15
15
  declare function isDistinguishable(alias: string): boolean;
16
16
  declare function parseNpmPackage(str: string | undefined): null | {
17
17
  pkgName: string;
@@ -1,7 +1,7 @@
1
- export { isImportPathNpmPackage };
2
- export { isImportPathNpmPackageOrPathAlias };
3
- export { assertIsImportPathNpmPackage };
4
- export { isPathAliasRecommended };
1
+ export { isImportNpmPackage };
2
+ export { isImportNpmPackageOrPathAlias };
3
+ export { assertImportIsNpmPackage };
4
+ export { isPathAliasRecommendation };
5
5
  export { getNpmPackageName };
6
6
  // For ./isNpmPackage.spec.ts
7
7
  export { parseNpmPackage };
@@ -16,7 +16,7 @@ function getNpmPackageName(str) {
16
16
  return res.pkgName;
17
17
  }
18
18
  /* Currently not used
19
- export function isNpmPackageName(str: string | undefined): boolean {
19
+ export function isValidNpmPackageName(str: string | undefined): boolean {
20
20
  const res = parseNpmPackage(str)
21
21
  return res !== null && res.importPath === null
22
22
  }
@@ -28,22 +28,22 @@ export function getNpmPackageImportPath(str: string): null | string {
28
28
  return res.importPath
29
29
  }
30
30
  //*/
31
- function isImportPathNpmPackage(str, { cannotBePathAlias }) {
31
+ function isImportNpmPackage(str, { cannotBePathAlias }) {
32
32
  assert(cannotBePathAlias);
33
- return isImportPathNpmPackageOrPathAlias(str);
33
+ return isImportNpmPackageOrPathAlias(str);
34
34
  }
35
35
  // We cannot distinguish path aliases that look like npm package imports
36
- function isImportPathNpmPackageOrPathAlias(str) {
36
+ function isImportNpmPackageOrPathAlias(str) {
37
37
  const res = parseNpmPackage(str);
38
38
  return res !== null;
39
39
  }
40
- function assertIsImportPathNpmPackage(str) {
41
- assert(isImportPathNpmPackage(str, {
42
- // If `str` is a path alias that looks like an npm package => assertIsImportPathNpmPackage() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
40
+ function assertImportIsNpmPackage(str) {
41
+ assert(isImportNpmPackage(str, {
42
+ // If `str` is a path alias that looks like an npm package => assertImportIsNpmPackage() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
43
43
  cannotBePathAlias: true,
44
44
  }), str);
45
45
  }
46
- function isPathAliasRecommended(alias) {
46
+ function isPathAliasRecommendation(alias) {
47
47
  // Cannot be distinguished from npm package names
48
48
  if (!isDistinguishable(alias))
49
49
  return false;
@@ -64,7 +64,7 @@ function isDistinguishable(alias) {
64
64
  parseNpmPackage(`${alias}/fake-path`) === null &&
65
65
  parseNpmPackage(`${alias}fake/deep/path`) === null &&
66
66
  parseNpmPackage(`${alias}/fake/deep/path`) === null &&
67
- // See note about '-' in ./isNpmPackageName.spec.ts
67
+ // See note about '-' in ./parseNpmPackage.spec.ts
68
68
  // ```ts
69
69
  // expect(parseNpmPackage('-')).toBe(null) // actually wrong: https://www.npmjs.com/package/-
70
70
  // ```
@@ -21,7 +21,7 @@ function pathJoin(path1, path2) {
21
21
  joined = '/' + joined;
22
22
  return joined;
23
23
  }
24
- // https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
24
+ // https://github.com/telefunc/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
25
25
  const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
26
26
  function pathIsAbsolute(filePath) {
27
27
  return IS_ABSOLUTE_RE.test(filePath);
@@ -10,7 +10,7 @@ import { assertPosixPath, toPosixPath } from './path.js';
10
10
  import { scriptFileExtensionList } from './isScriptFile.js';
11
11
  import { createRequire } from 'node:module';
12
12
  import path from 'node:path';
13
- import { assertIsImportPathNpmPackage, isImportPathNpmPackageOrPathAlias } from './parseNpmPackage.js';
13
+ import { assertImportIsNpmPackage, isImportNpmPackageOrPathAlias } from './parseNpmPackage.js';
14
14
  import { isNotNullish } from './isNullish.js';
15
15
  import { createDebug } from './debug.js';
16
16
  const importMetaUrl = import.meta.url;
@@ -96,7 +96,7 @@ function requireResolveOptionalDir({ importPath, importerDir, userRootDir, }) {
96
96
  return res.importPathResolvedFilePath;
97
97
  }
98
98
  function requireResolveNpmPackage({ importPathNpmPackage, userRootDir, }) {
99
- assertIsImportPathNpmPackage(importPathNpmPackage);
99
+ assertImportIsNpmPackage(importPathNpmPackage);
100
100
  const importerFilePath = getFakeImporterFile(userRootDir);
101
101
  const res = requireResolve_(importPathNpmPackage, importerFilePath, userRootDir);
102
102
  if (res.hasFailed)
@@ -121,7 +121,7 @@ function requireResolveDistFile(distFile) {
121
121
  }
122
122
  function addExtraContextForNpmPackageImport(contexts, importPath, userRootDir) {
123
123
  // We should add extra context only for npm packages, but unfortunately we cannot always disambiguate between npm package imports and path aliases.
124
- if (!isImportPathNpmPackageOrPathAlias(importPath))
124
+ if (!isImportNpmPackageOrPathAlias(importPath))
125
125
  return;
126
126
  const userRootDirFakeFile = userRootDir && getFakeImporterFile(userRootDir);
127
127
  [
package/fetch.js ADDED
@@ -0,0 +1,3 @@
1
+ // Some tools still need this as of January 2025
2
+ export * from './dist/server/runtime/fetch.js'
3
+ export { default } from './dist/server/runtime/fetch.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.254",
3
+ "version": "0.4.255-commit-05a7b95",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -94,6 +94,14 @@
94
94
  "browser": "./dist/client/node.js",
95
95
  "default": "./dist/server/runtime/universal-middleware.js"
96
96
  },
97
+ "./fetch": {
98
+ "types": "./dist/server/runtime/fetch.d.ts",
99
+ "worker": "./dist/server/runtime/fetch.js",
100
+ "workerd": "./dist/server/runtime/fetch.js",
101
+ "node": "./dist/server/runtime/fetch.js",
102
+ "browser": "./dist/client/node.js",
103
+ "default": "./dist/server/runtime/fetch.js"
104
+ },
97
105
  "./__internal": {
98
106
  "types": "./dist/server/__internal/index.d.ts",
99
107
  "node": "./dist/server/__internal/index.js",
@@ -124,7 +132,12 @@
124
132
  "@brillout/json-serializer": "^0.5.22",
125
133
  "@brillout/picocolors": "^1.0.30",
126
134
  "@brillout/vite-plugin-server-entry": "0.7.18",
135
+ "@universal-deploy/node": "^0.1.2",
136
+ "@universal-deploy/store": "^0.1.4",
137
+ "@universal-middleware/core": "^0.4.17",
138
+ "@universal-middleware/node": "^0.1.0",
127
139
  "cac": "^6.0.0",
140
+ "convert-route": "^1.1.1",
128
141
  "es-module-lexer": "^1.0.0",
129
142
  "esbuild": ">=0.19.0",
130
143
  "json5": "^2.0.0",
@@ -208,6 +221,9 @@
208
221
  "universal-middleware": [
209
222
  "./dist/server/runtime/universal-middleware.d.ts"
210
223
  ],
224
+ "fetch": [
225
+ "./dist/server/runtime/fetch.d.ts"
226
+ ],
211
227
  "__internal": [
212
228
  "./dist/server/__internal/index.d.ts"
213
229
  ],
@@ -241,17 +257,18 @@
241
257
  "./routing.js",
242
258
  "./server.js",
243
259
  "./types.js",
244
- "./universal-middleware.js"
260
+ "./universal-middleware.js",
261
+ "./fetch.js"
245
262
  ],
246
263
  "devDependencies": {
247
- "@brillout/release-me": "^0.4.12",
264
+ "@brillout/release-me": "^0.4.13",
248
265
  "@types/babel__core": "^7.20.5",
249
266
  "@types/estree": "^1.0.5",
250
267
  "@types/node": "^20.10.5",
251
268
  "@types/picomatch": "^3.0.2",
252
269
  "@types/semver": "^7.5.8",
253
270
  "@types/source-map-support": "^0.5.10",
254
- "react-streaming": "^0.4.15",
271
+ "react-streaming": "^0.4.16",
255
272
  "rimraf": "^5.0.5",
256
273
  "typescript": "^5.9.3",
257
274
  "vite": "^7.2.6"