vike 0.4.191-commit-7e0cd43 → 0.4.191-commit-349a3eb

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.
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPageFilesAllSafe = exports.getPagesAndRoutes = exports.route = void 0;
3
+ exports.getPagesAndRoutes = exports.route = void 0;
4
4
  const index_js_1 = require("../shared/route/index.js");
5
- const getPageFiles_js_1 = require("../shared/getPageFiles.js");
6
5
  const globalContext_js_1 = require("../node/runtime/globalContext.js");
7
6
  const assertNodeEnv_js_1 = require("../utils/assertNodeEnv.js");
8
7
  const assert_js_1 = require("../utils/assert.js");
@@ -28,15 +27,6 @@ async function getPagesAndRoutes() {
28
27
  };
29
28
  }
30
29
  exports.getPagesAndRoutes = getPagesAndRoutes;
31
- // TODO: make it cleaner once the internal refactoring about global configs is done
32
- async function getPageFilesAllSafe() {
33
- await (0, globalContext_js_1.initGlobalContext)(false);
34
- await (0, globalContext_js_1.getGlobalContextAsync)();
35
- const globalContext = (0, globalContext_js_1.getGlobalContext)();
36
- const pageFilesAll = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
37
- return pageFilesAll;
38
- }
39
- exports.getPageFilesAllSafe = getPageFilesAllSafe;
40
30
  async function route(pageContext) {
41
31
  const pageContextFromRoute = await (0, index_js_1.route)(pageContext);
42
32
  // Old interface
@@ -94,7 +94,7 @@ async function triggerFullBuild(config, configVike, bundle) {
94
94
  (0, logErrorHint_js_1.logErrorHint)(err);
95
95
  process.exit(1);
96
96
  }
97
- if (configVike.prerender && !configVike.prerender.disableAutoRun) {
97
+ if (configVike.prerender && !configVike.prerender.disableAutoRun && configVike.disableAutoFullBuild !== 'prerender') {
98
98
  await (0, runPrerender_js_1.runPrerenderFromAutoFullBuild)({ viteConfig: configInline });
99
99
  forceExit = true;
100
100
  }
@@ -106,11 +106,12 @@ function abortViteBuildSsr(configVike) {
106
106
  }
107
107
  }
108
108
  function isDisabled(configVike) {
109
- if (configVike.disableAutoFullBuild === null) {
109
+ const { disableAutoFullBuild } = configVike;
110
+ if (disableAutoFullBuild === null || disableAutoFullBuild === 'prerender') {
110
111
  // TODO/v1-release: also enable autoFullBuild when running Vite's build() API
111
112
  return !(0, isViteCliCall_js_1.isViteCliCall)();
112
113
  }
113
114
  else {
114
- return configVike.disableAutoFullBuild;
115
+ return disableAutoFullBuild;
115
116
  }
116
117
  }
@@ -30,8 +30,10 @@ function checkConfigVike(configVike) {
30
30
  }
31
31
  {
32
32
  const prop = 'disableAutoFullBuild';
33
- if (!(0, utils_js_1.hasProp)(configVike, prop, 'boolean') && !(0, utils_js_1.hasProp)(configVike, prop, 'undefined'))
34
- return { prop, errMsg: 'should be a boolean' };
33
+ if (!(0, utils_js_1.hasProp)(configVike, prop, 'boolean') &&
34
+ !(0, utils_js_1.hasProp)(configVike, prop, 'undefined') &&
35
+ !(configVike[prop] === 'prerender'))
36
+ return { prop, errMsg: "should be a boolean or 'prerender'" };
35
37
  }
36
38
  {
37
39
  const prop = 'includeAssetsImportedByServer';
@@ -44,16 +44,15 @@ async function streamReadableNodeToString(readableNode) {
44
44
  }
45
45
  async function streamReadableWebToString(readableWeb) {
46
46
  const reader = readableWeb.getReader();
47
- const decoder = new TextDecoder();
47
+ const { decode, getClosingChunk } = decodeChunks();
48
48
  let str = '';
49
49
  while (true) {
50
50
  const { done, value } = await reader.read();
51
51
  if (done)
52
52
  break;
53
- str += decoder.decode(value, { stream: true });
53
+ str += decode(value);
54
54
  }
55
- // https://github.com/vikejs/vike/pull/1799#discussion_r1713554096
56
- str += decoder.decode();
55
+ str += getClosingChunk();
57
56
  return str;
58
57
  }
59
58
  exports.streamReadableWebToString = streamReadableWebToString;
@@ -119,15 +118,16 @@ async function streamPipeNodeToString(streamPipeNode) {
119
118
  }
120
119
  exports.streamPipeNodeToString = streamPipeNodeToString;
121
120
  function streamPipeWebToString(streamPipeWeb) {
121
+ const { decode, getClosingChunk } = decodeChunks();
122
122
  let str = '';
123
123
  let resolve;
124
124
  const promise = new Promise((r) => (resolve = r));
125
125
  const writable = new WritableStream({
126
126
  write(chunk) {
127
- (0, utils_js_1.assert)(typeof chunk === 'string');
128
- str += chunk;
127
+ str += decode(chunk);
129
128
  },
130
129
  close() {
130
+ str += getClosingChunk();
131
131
  resolve(str);
132
132
  }
133
133
  });
@@ -384,9 +384,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
384
384
  const writeChunk = (chunk) => {
385
385
  (0, utils_js_1.assert)(writableOriginal);
386
386
  writableOriginal.write(chunk);
387
- if (debug.isActivated) {
388
- debug('data written (Node.js Writable)', getChunkAsString(chunk));
389
- }
387
+ debugWithChunk('data written (Node.js Writable)', chunk);
390
388
  };
391
389
  // For libraries such as https://www.npmjs.com/package/compression
392
390
  // - React calls writable.flush() when available
@@ -457,9 +455,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
457
455
  const writeChunk = (chunk) => {
458
456
  (0, utils_js_1.assert)(writerOriginal);
459
457
  writerOriginal.write(encodeForWebStream(chunk));
460
- if (debug.isActivated) {
461
- debug('data written (Web Writable)', getChunkAsString(chunk));
462
- }
458
+ debugWithChunk('data written (Web Writable)', chunk);
463
459
  };
464
460
  // Web Streams have compression built-in
465
461
  // - https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API
@@ -550,14 +546,10 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
550
546
  // If readableOriginal doesn't implement readableOriginal.cancel() then it may still emit data after we close the stream. We therefore need to check whether we closed `controllerProxy`.
551
547
  !controllerProxyIsClosed) {
552
548
  controllerProxy.enqueue(encodeForWebStream(chunk));
553
- if (debug.isActivated) {
554
- debug('data written (Web Readable)', getChunkAsString(chunk));
555
- }
549
+ debugWithChunk('data written (Web Readable)', chunk);
556
550
  }
557
551
  else {
558
- if (debug.isActivated) {
559
- debug('data emitted but not written (Web Readable)', getChunkAsString(chunk));
560
- }
552
+ debugWithChunk('data emitted but not written (Web Readable)', chunk);
561
553
  }
562
554
  };
563
555
  // Readables don't have the notion of flushing
@@ -577,9 +569,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
577
569
  }
578
570
  const writeChunk = (chunk) => {
579
571
  readableProxy.push(chunk);
580
- if (debug.isActivated) {
581
- debug('data written (Node.js Readable)', getChunkAsString(chunk));
582
- }
572
+ debugWithChunk('data written (Node.js Readable)', chunk);
583
573
  };
584
574
  // Readables don't have the notion of flushing
585
575
  const flushStream = null;
@@ -802,11 +792,34 @@ function inferStreamName(stream) {
802
792
  (0, utils_js_1.assert)(false);
803
793
  }
804
794
  exports.inferStreamName = inferStreamName;
805
- function getChunkAsString(chunk) {
795
+ function decodeChunks() {
796
+ const decoder = new TextDecoder();
797
+ const decode = (chunk) => {
798
+ if (typeof chunk === 'string') {
799
+ return chunk;
800
+ }
801
+ else if (chunk instanceof Uint8Array) {
802
+ return decoder.decode(chunk, { stream: true });
803
+ }
804
+ else {
805
+ (0, utils_js_1.assert)(false);
806
+ }
807
+ };
808
+ // https://github.com/vikejs/vike/pull/1799#discussion_r1713554096
809
+ const getClosingChunk = () => {
810
+ return decoder.decode();
811
+ };
812
+ return { decode, getClosingChunk };
813
+ }
814
+ function debugWithChunk(msg, chunk) {
815
+ if (!debug.isActivated)
816
+ return;
817
+ let chunkStr;
806
818
  try {
807
- return new TextDecoder().decode(chunk);
819
+ chunkStr = new TextDecoder().decode(chunk);
808
820
  }
809
821
  catch (err) {
810
- return String(chunk);
822
+ chunkStr = String(chunk);
811
823
  }
824
+ debug(msg, chunkStr);
812
825
  }
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.191-commit-7e0cd43';
5
+ exports.PROJECT_VERSION = '0.4.191-commit-349a3eb';
@@ -1,6 +1,5 @@
1
1
  export { route, getPagesAndRoutes };
2
2
  export type { PageRoutes, PageFile, PageConfigRuntime as PageConfig };
3
- export { getPageFilesAllSafe };
4
3
  import { route as routeInternal, type PageRoutes } from '../shared/route/index.js';
5
4
  import { type PageFile } from '../shared/getPageFiles.js';
6
5
  import { PageConfigRuntime } from '../shared/page-configs/PageConfig.js';
@@ -16,12 +15,6 @@ declare function getPagesAndRoutes(): Promise<{
16
15
  pageConfigs: PageConfigRuntime[];
17
16
  allPageIds: string[];
18
17
  }>;
19
- declare function getPageFilesAllSafe(): Promise<{
20
- pageFilesAll: PageFile[];
21
- allPageIds: string[];
22
- pageConfigs: PageConfigRuntime[];
23
- pageConfigGlobal: import("../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
24
- }>;
25
18
  declare function route(pageContext: Parameters<typeof routeInternal>[0]): Promise<{
26
19
  pageContextAddendum: import("../shared/route/index.js").PageContextFromRoute;
27
20
  }>;
@@ -1,10 +1,7 @@
1
1
  // Internals needed by vite-plugin-vercel
2
2
  export { route, getPagesAndRoutes };
3
- // Internals needed by nitedani's experimental implementation of vike-telefunc
4
- export { getPageFilesAllSafe };
5
3
  import { route as routeInternal } from '../shared/route/index.js';
6
- import { getPageFilesAll } from '../shared/getPageFiles.js';
7
- import { getGlobalContext, getGlobalContextAsync, initGlobalContext } from '../node/runtime/globalContext.js';
4
+ import { getGlobalContext, initGlobalContext } from '../node/runtime/globalContext.js';
8
5
  import { handleNodeEnv_vitePluginVercel } from '../utils/assertNodeEnv.js';
9
6
  import { assert } from '../utils/assert.js';
10
7
  import { getRenderContext } from '../node/runtime/renderPage/renderPageAlreadyRouted.js';
@@ -28,14 +25,6 @@ async function getPagesAndRoutes() {
28
25
  allPageIds
29
26
  };
30
27
  }
31
- // TODO: make it cleaner once the internal refactoring about global configs is done
32
- async function getPageFilesAllSafe() {
33
- await initGlobalContext(false);
34
- await getGlobalContextAsync();
35
- const globalContext = getGlobalContext();
36
- const pageFilesAll = await getPageFilesAll(false, globalContext.isProduction);
37
- return pageFilesAll;
38
- }
39
28
  async function route(pageContext) {
40
29
  const pageContextFromRoute = await routeInternal(pageContext);
41
30
  // Old interface
@@ -88,7 +88,7 @@ async function triggerFullBuild(config, configVike, bundle) {
88
88
  logErrorHint(err);
89
89
  process.exit(1);
90
90
  }
91
- if (configVike.prerender && !configVike.prerender.disableAutoRun) {
91
+ if (configVike.prerender && !configVike.prerender.disableAutoRun && configVike.disableAutoFullBuild !== 'prerender') {
92
92
  await runPrerenderFromAutoFullBuild({ viteConfig: configInline });
93
93
  forceExit = true;
94
94
  }
@@ -100,11 +100,12 @@ function abortViteBuildSsr(configVike) {
100
100
  }
101
101
  }
102
102
  function isDisabled(configVike) {
103
- if (configVike.disableAutoFullBuild === null) {
103
+ const { disableAutoFullBuild } = configVike;
104
+ if (disableAutoFullBuild === null || disableAutoFullBuild === 'prerender') {
104
105
  // TODO/v1-release: also enable autoFullBuild when running Vite's build() API
105
106
  return !isViteCliCall();
106
107
  }
107
108
  else {
108
- return configVike.disableAutoFullBuild;
109
+ return disableAutoFullBuild;
109
110
  }
110
111
  }
@@ -27,8 +27,10 @@ function checkConfigVike(configVike) {
27
27
  }
28
28
  {
29
29
  const prop = 'disableAutoFullBuild';
30
- if (!hasProp(configVike, prop, 'boolean') && !hasProp(configVike, prop, 'undefined'))
31
- return { prop, errMsg: 'should be a boolean' };
30
+ if (!hasProp(configVike, prop, 'boolean') &&
31
+ !hasProp(configVike, prop, 'undefined') &&
32
+ !(configVike[prop] === 'prerender'))
33
+ return { prop, errMsg: "should be a boolean or 'prerender'" };
32
34
  }
33
35
  {
34
36
  const prop = 'includeAssetsImportedByServer';
@@ -55,16 +55,15 @@ async function streamReadableNodeToString(readableNode) {
55
55
  }
56
56
  async function streamReadableWebToString(readableWeb) {
57
57
  const reader = readableWeb.getReader();
58
- const decoder = new TextDecoder();
58
+ const { decode, getClosingChunk } = decodeChunks();
59
59
  let str = '';
60
60
  while (true) {
61
61
  const { done, value } = await reader.read();
62
62
  if (done)
63
63
  break;
64
- str += decoder.decode(value, { stream: true });
64
+ str += decode(value);
65
65
  }
66
- // https://github.com/vikejs/vike/pull/1799#discussion_r1713554096
67
- str += decoder.decode();
66
+ str += getClosingChunk();
68
67
  return str;
69
68
  }
70
69
  async function stringToStreamReadableNode(str) {
@@ -128,15 +127,16 @@ async function streamPipeNodeToString(streamPipeNode) {
128
127
  return promise;
129
128
  }
130
129
  function streamPipeWebToString(streamPipeWeb) {
130
+ const { decode, getClosingChunk } = decodeChunks();
131
131
  let str = '';
132
132
  let resolve;
133
133
  const promise = new Promise((r) => (resolve = r));
134
134
  const writable = new WritableStream({
135
135
  write(chunk) {
136
- assert(typeof chunk === 'string');
137
- str += chunk;
136
+ str += decode(chunk);
138
137
  },
139
138
  close() {
139
+ str += getClosingChunk();
140
140
  resolve(str);
141
141
  }
142
142
  });
@@ -388,9 +388,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
388
388
  const writeChunk = (chunk) => {
389
389
  assert(writableOriginal);
390
390
  writableOriginal.write(chunk);
391
- if (debug.isActivated) {
392
- debug('data written (Node.js Writable)', getChunkAsString(chunk));
393
- }
391
+ debugWithChunk('data written (Node.js Writable)', chunk);
394
392
  };
395
393
  // For libraries such as https://www.npmjs.com/package/compression
396
394
  // - React calls writable.flush() when available
@@ -461,9 +459,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
461
459
  const writeChunk = (chunk) => {
462
460
  assert(writerOriginal);
463
461
  writerOriginal.write(encodeForWebStream(chunk));
464
- if (debug.isActivated) {
465
- debug('data written (Web Writable)', getChunkAsString(chunk));
466
- }
462
+ debugWithChunk('data written (Web Writable)', chunk);
467
463
  };
468
464
  // Web Streams have compression built-in
469
465
  // - https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API
@@ -554,14 +550,10 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
554
550
  // If readableOriginal doesn't implement readableOriginal.cancel() then it may still emit data after we close the stream. We therefore need to check whether we closed `controllerProxy`.
555
551
  !controllerProxyIsClosed) {
556
552
  controllerProxy.enqueue(encodeForWebStream(chunk));
557
- if (debug.isActivated) {
558
- debug('data written (Web Readable)', getChunkAsString(chunk));
559
- }
553
+ debugWithChunk('data written (Web Readable)', chunk);
560
554
  }
561
555
  else {
562
- if (debug.isActivated) {
563
- debug('data emitted but not written (Web Readable)', getChunkAsString(chunk));
564
- }
556
+ debugWithChunk('data emitted but not written (Web Readable)', chunk);
565
557
  }
566
558
  };
567
559
  // Readables don't have the notion of flushing
@@ -581,9 +573,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
581
573
  }
582
574
  const writeChunk = (chunk) => {
583
575
  readableProxy.push(chunk);
584
- if (debug.isActivated) {
585
- debug('data written (Node.js Readable)', getChunkAsString(chunk));
586
- }
576
+ debugWithChunk('data written (Node.js Readable)', chunk);
587
577
  };
588
578
  // Readables don't have the notion of flushing
589
579
  const flushStream = null;
@@ -796,11 +786,34 @@ function inferStreamName(stream) {
796
786
  }
797
787
  assert(false);
798
788
  }
799
- function getChunkAsString(chunk) {
789
+ function decodeChunks() {
790
+ const decoder = new TextDecoder();
791
+ const decode = (chunk) => {
792
+ if (typeof chunk === 'string') {
793
+ return chunk;
794
+ }
795
+ else if (chunk instanceof Uint8Array) {
796
+ return decoder.decode(chunk, { stream: true });
797
+ }
798
+ else {
799
+ assert(false);
800
+ }
801
+ };
802
+ // https://github.com/vikejs/vike/pull/1799#discussion_r1713554096
803
+ const getClosingChunk = () => {
804
+ return decoder.decode();
805
+ };
806
+ return { decode, getClosingChunk };
807
+ }
808
+ function debugWithChunk(msg, chunk) {
809
+ if (!debug.isActivated)
810
+ return;
811
+ let chunkStr;
800
812
  try {
801
- return new TextDecoder().decode(chunk);
813
+ chunkStr = new TextDecoder().decode(chunk);
802
814
  }
803
815
  catch (err) {
804
- return String(chunk);
816
+ chunkStr = String(chunk);
805
817
  }
818
+ debug(msg, chunkStr);
806
819
  }
@@ -7,7 +7,7 @@ type ConfigVikeResolved = {
7
7
  partial: boolean;
8
8
  disableAutoRun: boolean;
9
9
  };
10
- disableAutoFullBuild: boolean | null;
10
+ disableAutoFullBuild: boolean | 'prerender' | null;
11
11
  includeAssetsImportedByServer: boolean;
12
12
  baseAssets: string;
13
13
  baseServer: string;
@@ -63,13 +63,13 @@ type ConfigVikeUserProvided = {
63
63
  disableAutoRun?: boolean;
64
64
  };
65
65
  /**
66
- * Set to `true` to disable the automatic chaining of all the build steps.
66
+ * Disable the automatic chaining of build steps.
67
67
  *
68
68
  * https://vike.dev/disableAutoFullBuild
69
69
  *
70
70
  * @default false
71
71
  */
72
- disableAutoFullBuild?: boolean;
72
+ disableAutoFullBuild?: boolean | 'prerender';
73
73
  /** The Base URL of your server.
74
74
  *
75
75
  * https://vike.dev/base-url
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.191-commit-7e0cd43";
1
+ export declare const PROJECT_VERSION: "0.4.191-commit-349a3eb";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.191-commit-7e0cd43';
2
+ export const PROJECT_VERSION = '0.4.191-commit-349a3eb';
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.191-commit-7e0cd43";
3
+ projectVersion: "0.4.191-commit-349a3eb";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.191-commit-7e0cd43",
3
+ "version": "0.4.191-commit-349a3eb",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",