vike 0.4.177-commit-51d612a → 0.4.178-commit-fae90a1

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 (40) hide show
  1. package/dist/cjs/node/plugin/plugins/envVars.js +4 -0
  2. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
  3. package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +20 -18
  4. package/dist/cjs/node/runtime/html/injectAssets.js +9 -9
  5. package/dist/cjs/node/runtime/html/renderHtml.js +4 -4
  6. package/dist/cjs/node/runtime/html/stream/react-streaming.js +11 -10
  7. package/dist/cjs/node/runtime/html/stream.js +5 -5
  8. package/dist/cjs/node/runtime/utils.js +1 -0
  9. package/dist/cjs/utils/assert.js +1 -1
  10. package/dist/cjs/utils/assertSingleInstance.js +7 -7
  11. package/dist/cjs/utils/isVikeReactApp.js +9 -0
  12. package/dist/cjs/utils/projectInfo.js +1 -1
  13. package/dist/esm/client/client-routing-runtime/entry.js +5 -2
  14. package/dist/esm/client/server-routing-runtime/entry.js +5 -2
  15. package/dist/esm/client/shared/removeFoucBuster.d.ts +2 -0
  16. package/dist/esm/client/shared/removeFoucBuster.js +39 -0
  17. package/dist/esm/client/shared/utils.d.ts +1 -0
  18. package/dist/esm/client/shared/utils.js +1 -0
  19. package/dist/esm/node/plugin/plugins/envVars.js +4 -0
  20. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +2 -2
  21. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +3 -3
  22. package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.d.ts +5 -2
  23. package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +19 -17
  24. package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
  25. package/dist/esm/node/runtime/html/injectAssets.js +10 -10
  26. package/dist/esm/node/runtime/html/renderHtml.js +5 -5
  27. package/dist/esm/node/runtime/html/stream/react-streaming.d.ts +16 -23
  28. package/dist/esm/node/runtime/html/stream/react-streaming.js +11 -10
  29. package/dist/esm/node/runtime/html/stream.d.ts +2 -2
  30. package/dist/esm/node/runtime/html/stream.js +6 -6
  31. package/dist/esm/node/runtime/utils.d.ts +1 -0
  32. package/dist/esm/node/runtime/utils.js +1 -0
  33. package/dist/esm/utils/assert.js +2 -2
  34. package/dist/esm/utils/assertSingleInstance.d.ts +6 -6
  35. package/dist/esm/utils/assertSingleInstance.js +6 -6
  36. package/dist/esm/utils/isVikeReactApp.d.ts +1 -0
  37. package/dist/esm/utils/isVikeReactApp.js +5 -0
  38. package/dist/esm/utils/projectInfo.d.ts +2 -2
  39. package/dist/esm/utils/projectInfo.js +1 -1
  40. package/package.json +3 -3
@@ -5,6 +5,10 @@ const vite_1 = require("vite");
5
5
  const utils_js_1 = require("../utils.js");
6
6
  const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
7
7
  const getFilePath_js_1 = require("../shared/getFilePath.js");
8
+ // TODO/enventually: (after we implemented vike.config.js)
9
+ // - Make import.meta.env work inside +config.js
10
+ // - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
11
+ // - Or stop using Vite's `mode` implemention and have Vike implement its own `mode` feature? (So that the only dependencies are `$ vike build --mode staging` and `$ MODE=staging vike build`.)
8
12
  const PUBLIC_ENV_PREFIX = 'PUBLIC_ENV__';
9
13
  const PUBLIC_ENV_WHITELIST = [
10
14
  // https://github.com/vikejs/vike/issues/1724
@@ -12,7 +12,7 @@ const mergeScriptTags_js_1 = require("./mergeScriptTags.js");
12
12
  const globalContext_js_1 = require("../../globalContext.js");
13
13
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
14
14
  const stamp = '__injectFilterEntry';
15
- function getHtmlTags(pageContext, injectToStream, injectFilter, pageAssets, viteDevScript) {
15
+ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript) {
16
16
  (0, utils_js_1.assert)([true, false].includes(pageContext._isHtmlOnly));
17
17
  const isHtmlOnly = pageContext._isHtmlOnly;
18
18
  const { isProduction } = (0, globalContext_js_1.getGlobalContext)();
@@ -88,11 +88,11 @@ function getHtmlTags(pageContext, injectToStream, injectFilter, pageAssets, vite
88
88
  // See https://github.com/vikejs/vike/pull/1271
89
89
  const positionJavaScriptEntry = (() => {
90
90
  if (pageContext._pageContextPromise) {
91
- (0, utils_js_1.assertWarning)(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time, because progressive hydration won't work.", { onlyOnce: true });
91
+ (0, utils_js_1.assertWarning)(!streamFromReactStreamingPackage, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time, because progressive hydration won't work.", { onlyOnce: true });
92
92
  // If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/streaming#initial-data-after-stream-end
93
93
  return 'HTML_END';
94
94
  }
95
- if (injectToStream) {
95
+ if (streamFromReactStreamingPackage && !streamFromReactStreamingPackage.hasStreamEnded()) {
96
96
  // If there is a stream then, in order to support progressive hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary
97
97
  return 'STREAM';
98
98
  }
@@ -1,23 +1,30 @@
1
1
  "use strict";
2
2
  // Unit tests at ./injectHtmlTags.spec.ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.injectAtClosingTag = exports.injectAtOpeningTag = exports.createHtmlHeadIfMissing = exports.injectHtmlTags = void 0;
4
+ exports.injectAtClosingTag = exports.injectAtOpeningTag = exports.createHtmlHeadIfMissing = exports.injectHtmlTagsUsingStream = exports.injectHtmlTags = void 0;
5
5
  const utils_js_1 = require("../../utils.js");
6
- const POSITIONS = ['HTML_BEGIN', 'HTML_END', 'STREAM'];
7
- function injectHtmlTags(htmlString, htmlTags, injectToStream) {
8
- POSITIONS.forEach((position) => {
9
- const htmlFragment = htmlTags
10
- .filter((h) => h.position === position)
11
- .map((h) => resolveHtmlTag(h.htmlTag))
12
- .join('');
13
- if (htmlFragment) {
14
- htmlString = injectHtmlFragment(position, htmlFragment, htmlString, injectToStream);
15
- }
16
- });
6
+ function injectHtmlTags(htmlString, htmlTags, position) {
7
+ const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === position));
8
+ if (htmlFragment) {
9
+ htmlString = injectHtmlFragment(position, htmlFragment, htmlString);
10
+ }
17
11
  return htmlString;
18
12
  }
19
13
  exports.injectHtmlTags = injectHtmlTags;
20
- function injectHtmlFragment(position, htmlFragment, htmlString, injectToStream) {
14
+ async function injectHtmlTagsUsingStream(htmlTags, streamFromReactStreamingPackage) {
15
+ const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === 'STREAM'));
16
+ if (htmlFragment) {
17
+ (0, utils_js_1.assert)(streamFromReactStreamingPackage);
18
+ (0, utils_js_1.assert)(!streamFromReactStreamingPackage.hasStreamEnded());
19
+ await streamFromReactStreamingPackage.injectToStream(htmlFragment, { flush: true });
20
+ }
21
+ }
22
+ exports.injectHtmlTagsUsingStream = injectHtmlTagsUsingStream;
23
+ function joinHtmlTags(htmlTags) {
24
+ const htmlFragment = htmlTags.map((h) => resolveHtmlTag(h.htmlTag)).join('');
25
+ return htmlFragment;
26
+ }
27
+ function injectHtmlFragment(position, htmlFragment, htmlString) {
21
28
  if (position === 'HTML_BEGIN') {
22
29
  {
23
30
  const res = injectAtPaceholder(htmlFragment, htmlString, true);
@@ -42,11 +49,6 @@ function injectHtmlFragment(position, htmlFragment, htmlString, injectToStream)
42
49
  }
43
50
  return htmlString + '\n' + htmlFragment;
44
51
  }
45
- if (position === 'STREAM') {
46
- (0, utils_js_1.assert)(injectToStream);
47
- injectToStream(htmlFragment, { flush: true });
48
- return htmlString;
49
- }
50
52
  (0, utils_js_1.assert)(false);
51
53
  }
52
54
  function resolveHtmlTag(htmlTag) {
@@ -11,12 +11,13 @@ async function injectHtmlTagsToString(htmlParts, pageContext, injectFilter) {
11
11
  const viteDevScript = await (0, getViteDevScript_js_1.getViteDevScript)();
12
12
  const htmlTags = (0, getHtmlTags_js_1.getHtmlTags)(pageContext, null, injectFilter, pageAssets, viteDevScript);
13
13
  let htmlString = htmlPartsToString(htmlParts, pageAssets);
14
- htmlString = injectToHtmlBegin(htmlString, htmlTags, null);
14
+ htmlString = injectToHtmlBegin(htmlString, htmlTags);
15
15
  htmlString = injectToHtmlEnd(htmlString, htmlTags);
16
+ (0, utils_js_1.assert)(htmlTags.filter((snippet) => snippet.position === 'STREAM').length === 0);
16
17
  return htmlString;
17
18
  }
18
19
  exports.injectHtmlTagsToString = injectHtmlTagsToString;
19
- function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
20
+ function injectHtmlTagsToStream(pageContext, streamFromReactStreamingPackage, injectFilter) {
20
21
  let htmlTags;
21
22
  return {
22
23
  injectAtStreamBegin,
@@ -25,9 +26,10 @@ function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
25
26
  async function injectAtStreamBegin(htmlPartsBegin) {
26
27
  const pageAssets = await pageContext.__getPageAssets();
27
28
  const viteDevScript = await (0, getViteDevScript_js_1.getViteDevScript)();
28
- htmlTags = (0, getHtmlTags_js_1.getHtmlTags)(pageContext, injectToStream, injectFilter, pageAssets, viteDevScript);
29
+ htmlTags = (0, getHtmlTags_js_1.getHtmlTags)(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript);
29
30
  let htmlBegin = htmlPartsToString(htmlPartsBegin, pageAssets);
30
- htmlBegin = injectToHtmlBegin(htmlBegin, htmlTags, injectToStream);
31
+ htmlBegin = injectToHtmlBegin(htmlBegin, htmlTags);
32
+ await (0, injectHtmlTags_js_1.injectHtmlTagsUsingStream)(htmlTags, streamFromReactStreamingPackage);
31
33
  return htmlBegin;
32
34
  }
33
35
  async function injectAtStreamEnd(htmlPartsEnd) {
@@ -40,16 +42,14 @@ function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
40
42
  }
41
43
  }
42
44
  exports.injectHtmlTagsToStream = injectHtmlTagsToStream;
43
- function injectToHtmlBegin(htmlBegin, htmlTags, injectToStream) {
44
- const htmlTagsAtBegin = htmlTags.filter((snippet) => snippet.position !== 'HTML_END');
45
+ function injectToHtmlBegin(htmlBegin, htmlTags) {
45
46
  // Ensure existence of `<head>`
46
47
  htmlBegin = (0, injectHtmlTags_js_1.createHtmlHeadIfMissing)(htmlBegin);
47
- htmlBegin = (0, injectHtmlTags_js_1.injectHtmlTags)(htmlBegin, htmlTagsAtBegin, injectToStream);
48
+ htmlBegin = (0, injectHtmlTags_js_1.injectHtmlTags)(htmlBegin, htmlTags, 'HTML_BEGIN');
48
49
  return htmlBegin;
49
50
  }
50
51
  function injectToHtmlEnd(htmlEnd, htmlTags) {
51
- const htmlTagsAtEnd = htmlTags.filter((snippet) => snippet.position === 'HTML_END');
52
- htmlEnd = (0, injectHtmlTags_js_1.injectHtmlTags)(htmlEnd, htmlTagsAtEnd, null);
52
+ htmlEnd = (0, injectHtmlTags_js_1.injectHtmlTags)(htmlEnd, htmlTags, 'HTML_END');
53
53
  return htmlEnd;
54
54
  }
55
55
  async function resolvePageContextPromise(pageContext) {
@@ -60,11 +60,11 @@ async function renderHtmlStream(streamOriginal, injectString, pageContext, onErr
60
60
  enableEagerStreaming: pageContext.enableEagerStreaming
61
61
  };
62
62
  if (injectString) {
63
- let injectToStream = null;
64
- if ((0, react_streaming_js_1.isStreamReactStreaming)(streamOriginal) && !streamOriginal.disabled) {
65
- injectToStream = streamOriginal.injectToStream;
63
+ let streamFromReactStreamingPackage = null;
64
+ if ((0, react_streaming_js_1.isStreamFromReactStreamingPackage)(streamOriginal) && !streamOriginal.disabled) {
65
+ streamFromReactStreamingPackage = streamOriginal;
66
66
  }
67
- const { injectAtStreamBegin, injectAtStreamEnd } = (0, injectAssets_js_1.injectHtmlTagsToStream)(pageContext, injectToStream, injectFilter);
67
+ const { injectAtStreamBegin, injectAtStreamEnd } = (0, injectAssets_js_1.injectHtmlTagsToStream)(pageContext, streamFromReactStreamingPackage, injectFilter);
68
68
  (0, utils_js_1.objectAssign)(opts, {
69
69
  injectStringAtBegin: async () => {
70
70
  return await injectAtStreamBegin(injectString.htmlPartsBegin);
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // Zero-config support for https://www.npmjs.com/package/react-streaming
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getStreamFromReactStreaming = exports.streamReactStreamingToString = exports.isStreamReactStreaming = void 0;
4
+ exports.getStreamOfReactStreamingPackage = exports.streamFromReactStreamingPackageToString = exports.isStreamFromReactStreamingPackage = void 0;
5
5
  const utils_js_1 = require("../../utils.js");
6
6
  const stream_js_1 = require("../stream.js");
7
- function streamReactStreamingToString(stream) {
7
+ function streamFromReactStreamingPackageToString(stream) {
8
8
  if (stream.pipe) {
9
9
  return (0, stream_js_1.streamPipeNodeToString)(stream.pipe);
10
10
  }
@@ -13,19 +13,20 @@ function streamReactStreamingToString(stream) {
13
13
  }
14
14
  (0, utils_js_1.assert)(false);
15
15
  }
16
- exports.streamReactStreamingToString = streamReactStreamingToString;
17
- function isStreamReactStreaming(thing) {
16
+ exports.streamFromReactStreamingPackageToString = streamFromReactStreamingPackageToString;
17
+ function isStreamFromReactStreamingPackage(thing) {
18
18
  if ((0, utils_js_1.hasProp)(thing, 'injectToStream', 'function')) {
19
+ (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(thing, 'hasStreamEnded', 'function'), (0, utils_js_1.isVikeReactApp)()
20
+ ? //
21
+ 'Update vike-react to its latest version'
22
+ : 'Update react-streaming to its latest version');
19
23
  return true;
20
24
  }
21
- // TODO
22
- //if( isStreamPipeNode
23
25
  return false;
24
26
  }
25
- exports.isStreamReactStreaming = isStreamReactStreaming;
26
- function getStreamFromReactStreaming(stream) {
27
+ exports.isStreamFromReactStreamingPackage = isStreamFromReactStreamingPackage;
28
+ function getStreamOfReactStreamingPackage(stream) {
27
29
  if (stream.pipe) {
28
- // TODO
29
30
  return { __streamPipeNode: stream.pipe };
30
31
  }
31
32
  if (stream.readable) {
@@ -33,4 +34,4 @@ function getStreamFromReactStreaming(stream) {
33
34
  }
34
35
  (0, utils_js_1.assert)(false);
35
36
  }
36
- exports.getStreamFromReactStreaming = getStreamFromReactStreaming;
37
+ exports.getStreamOfReactStreamingPackage = getStreamOfReactStreamingPackage;
@@ -354,9 +354,9 @@ async function processStream(streamOriginal, { injectStringAtBegin, injectString
354
354
  }
355
355
  exports.processStream = processStream;
356
356
  async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onFlush, onReadyToWrite }) {
357
- if ((0, react_streaming_js_1.isStreamReactStreaming)(streamOriginal)) {
357
+ if ((0, react_streaming_js_1.isStreamFromReactStreamingPackage)(streamOriginal)) {
358
358
  debug(`onRenderHtml() hook returned ${picocolors_1.default.cyan('react-streaming')} result`);
359
- const stream = (0, react_streaming_js_1.getStreamFromReactStreaming)(streamOriginal);
359
+ const stream = (0, react_streaming_js_1.getStreamOfReactStreamingPackage)(streamOriginal);
360
360
  streamOriginal = stream;
361
361
  }
362
362
  if (isStreamPipeNode(streamOriginal)) {
@@ -621,7 +621,7 @@ function isStream(something) {
621
621
  isStreamReadableNode(something) ||
622
622
  isStreamPipeNode(something) ||
623
623
  isStreamPipeWeb(something) ||
624
- (0, react_streaming_js_1.isStreamReactStreaming)(something)) {
624
+ (0, react_streaming_js_1.isStreamFromReactStreamingPackage)(something)) {
625
625
  (0, utils_js_1.checkType)(something);
626
626
  return true;
627
627
  }
@@ -733,8 +733,8 @@ async function streamToString(stream) {
733
733
  if (isStreamPipeWeb(stream)) {
734
734
  return await streamPipeWebToString(getStreamPipeWeb(stream));
735
735
  }
736
- if ((0, react_streaming_js_1.isStreamReactStreaming)(stream)) {
737
- return await (0, react_streaming_js_1.streamReactStreamingToString)(stream);
736
+ if ((0, react_streaming_js_1.isStreamFromReactStreamingPackage)(stream)) {
737
+ return await (0, react_streaming_js_1.streamFromReactStreamingPackageToString)(stream);
738
738
  }
739
739
  (0, utils_js_1.assert)(false);
740
740
  }
@@ -70,3 +70,4 @@ __exportStar(require("../../utils/joinEnglish.js"), exports);
70
70
  __exportStar(require("../../utils/isArrayOfStrings.js"), exports);
71
71
  __exportStar(require("../../utils/escapeHtml.js"), exports);
72
72
  __exportStar(require("../../utils/normalizeHeaders.js"), exports);
73
+ __exportStar(require("../../utils/isVikeReactApp.js"), exports);
@@ -23,7 +23,7 @@ const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/assert.ts'
23
23
  },
24
24
  showStackTraceList: new WeakSet()
25
25
  });
26
- (0, assertSingleInstance_js_1.onAssertModuleLoad)();
26
+ (0, assertSingleInstance_js_1.assertSingleInstance_onAssertModuleLoad)();
27
27
  const projectTag = `[vike]`;
28
28
  const projectTagWithVersion = `[vike@${projectInfo_js_1.projectInfo.projectVersion}]`;
29
29
  const numberOfStackTraceLinesToRemove = 2;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.onAssertModuleLoad = exports.onClientEntry_ClientRouting = exports.onClientEntry_ServerRouting = void 0;
6
+ exports.assertSingleInstance_onAssertModuleLoad = exports.assertSingleInstance_onClientEntryClientRouting = exports.assertSingleInstance_onClientEntryServerRouting = void 0;
7
7
  // - Throw error if there are two different versions of vike loaded
8
8
  // - Show warning if entry of Client Routing and entry of Server Routing are both loaded
9
9
  // - Show warning if vike is loaded twice
@@ -35,7 +35,7 @@ function assertSingleInstance() {
35
35
  //*/
36
36
  }
37
37
  }
38
- function onClientEntry_ServerRouting(isProduction) {
38
+ function assertSingleInstance_onClientEntryServerRouting(isProduction) {
39
39
  assertWarning(globalObject.isClientRouting !== true, clientRuntimesClonflict, {
40
40
  onlyOnce: true,
41
41
  showStackTrace: true
@@ -49,8 +49,8 @@ function onClientEntry_ServerRouting(isProduction) {
49
49
  globalObject.checkSingleInstance = true;
50
50
  assertSingleInstance();
51
51
  }
52
- exports.onClientEntry_ServerRouting = onClientEntry_ServerRouting;
53
- function onClientEntry_ClientRouting(isProduction) {
52
+ exports.assertSingleInstance_onClientEntryServerRouting = assertSingleInstance_onClientEntryServerRouting;
53
+ function assertSingleInstance_onClientEntryClientRouting(isProduction) {
54
54
  assertWarning(globalObject.isClientRouting !== false, clientRuntimesClonflict, {
55
55
  onlyOnce: true,
56
56
  showStackTrace: true
@@ -64,13 +64,13 @@ function onClientEntry_ClientRouting(isProduction) {
64
64
  globalObject.checkSingleInstance = true;
65
65
  assertSingleInstance();
66
66
  }
67
- exports.onClientEntry_ClientRouting = onClientEntry_ClientRouting;
67
+ exports.assertSingleInstance_onClientEntryClientRouting = assertSingleInstance_onClientEntryClientRouting;
68
68
  // Called by utils/assert.ts which is (most certainly) loaded by all entries. That way we don't have to call a callback for every entry. (There are a lot of entries: `client/router/`, `client/`, `node/runtime/`, `node/plugin/`, `node/cli`.)
69
- function onAssertModuleLoad() {
69
+ function assertSingleInstance_onAssertModuleLoad() {
70
70
  globalObject.instances.push(projectInfo_js_1.projectInfo.projectVersion);
71
71
  assertSingleInstance();
72
72
  }
73
- exports.onAssertModuleLoad = onAssertModuleLoad;
73
+ exports.assertSingleInstance_onAssertModuleLoad = assertSingleInstance_onAssertModuleLoad;
74
74
  function assertUsage(condition, errorMessage) {
75
75
  if (condition) {
76
76
  return;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVikeReactApp = void 0;
4
+ function isVikeReactApp() {
5
+ const g = globalThis;
6
+ // Set by vike-react https://github.com/vikejs/vike-react/blob/23e92434424f10e7e742b6bf587edee5aa8832df/packages/vike-react/src/renderer/onRenderHtml.tsx#L75
7
+ return !!g._isVikeReactApp;
8
+ }
9
+ exports.isVikeReactApp = isVikeReactApp;
@@ -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.177-commit-51d612a';
4
+ const PROJECT_VERSION = '0.4.178-commit-fae90a1';
5
5
  exports.PROJECT_VERSION = PROJECT_VERSION;
6
6
  const projectInfo = {
7
7
  projectName: 'Vike',
@@ -2,8 +2,11 @@ import { assertClientRouting } from '../../utils/assertRoutingType.js';
2
2
  assertClientRouting();
3
3
  import './pageFiles';
4
4
  import { installClientRouter } from './installClientRouter.js';
5
- import { onClientEntry_ClientRouting } from './utils.js';
5
+ import { assertSingleInstance_onClientEntryClientRouting } from './utils.js';
6
+ import { removeFoucBuster } from '../shared/removeFoucBuster.js';
6
7
  // @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
7
8
  const isProd = import.meta.env.PROD;
8
- onClientEntry_ClientRouting(isProd);
9
+ assertSingleInstance_onClientEntryClientRouting(isProd);
10
+ if (import.meta.env.DEV)
11
+ removeFoucBuster();
9
12
  installClientRouter();
@@ -4,10 +4,13 @@ import './pageFiles';
4
4
  import { getPageContext } from './getPageContext.js';
5
5
  import { executeOnRenderClientHook } from '../shared/executeOnRenderClientHook.js';
6
6
  import { assertHook } from '../../shared/hooks/getHook.js';
7
- import { onClientEntry_ServerRouting } from './utils.js';
7
+ import { assertSingleInstance_onClientEntryServerRouting } from './utils.js';
8
+ import { removeFoucBuster } from '../shared/removeFoucBuster.js';
8
9
  // @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
9
10
  const isProd = import.meta.env.PROD;
10
- onClientEntry_ServerRouting(isProd);
11
+ assertSingleInstance_onClientEntryServerRouting(isProd);
12
+ if (import.meta.env.DEV)
13
+ removeFoucBuster();
11
14
  hydrate();
12
15
  async function hydrate() {
13
16
  const pageContext = await getPageContext();
@@ -0,0 +1,2 @@
1
+ export { removeFoucBuster };
2
+ declare function removeFoucBuster(): void;
@@ -0,0 +1,39 @@
1
+ export { removeFoucBuster };
2
+ import { assert } from './utils.js';
3
+ function removeFoucBuster() {
4
+ assert(import.meta.env.DEV);
5
+ let sleep = 2;
6
+ const runClean = () => {
7
+ if (sleep < 1000)
8
+ sleep = 2 * sleep;
9
+ const isClean = clean();
10
+ if (!isClean) {
11
+ setTimeout(runClean, sleep);
12
+ }
13
+ };
14
+ setTimeout(runClean, sleep);
15
+ }
16
+ function clean() {
17
+ const VITE_ID = 'data-vite-dev-id';
18
+ const injectedByVite = [...document.querySelectorAll(`style[${VITE_ID}]`)].map((style) => style.getAttribute(VITE_ID));
19
+ // ```
20
+ // <link rel="stylesheet" type="text/css" href="/renderer/css/index.css?direct">
21
+ // <link rel="stylesheet" type="text/css" href="/renderer/Layout.css?direct">
22
+ // ```
23
+ const suffix = '?direct';
24
+ const injectedByVike = [...document.querySelectorAll(`link[rel="stylesheet"][type="text/css"][href$="${suffix}"]`)];
25
+ if (injectedByVike.length === 0) {
26
+ // clearInterval(interval)
27
+ }
28
+ let isClean = true;
29
+ injectedByVike.forEach((link) => {
30
+ const filePathAbsoluteUserRootDir = link.getAttribute('href').slice(0, -suffix.length);
31
+ if (injectedByVite.some((filePathAbsoluteFilesystem) => filePathAbsoluteFilesystem.endsWith(filePathAbsoluteUserRootDir))) {
32
+ link.remove();
33
+ }
34
+ else {
35
+ isClean = false;
36
+ }
37
+ });
38
+ return isClean;
39
+ }
@@ -0,0 +1 @@
1
+ export * from '../../utils/assert.js';
@@ -0,0 +1 @@
1
+ export * from '../../utils/assert.js';
@@ -5,6 +5,10 @@ import { loadEnv } from 'vite';
5
5
  import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, lowerFirst } from '../utils.js';
6
6
  import { sourceMapPassthrough } from '../shared/rollupSourceMap.js';
7
7
  import { getModuleFilePath } from '../shared/getFilePath.js';
8
+ // TODO/enventually: (after we implemented vike.config.js)
9
+ // - Make import.meta.env work inside +config.js
10
+ // - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
11
+ // - Or stop using Vite's `mode` implemention and have Vike implement its own `mode` feature? (So that the only dependencies are `$ vike build --mode staging` and `$ MODE=staging vike build`.)
8
12
  const PUBLIC_ENV_PREFIX = 'PUBLIC_ENV__';
9
13
  const PUBLIC_ENV_WHITELIST = [
10
14
  // https://github.com/vikejs/vike/issues/1724
@@ -3,7 +3,7 @@ export type { HtmlTag };
3
3
  export type { PreloadFilter };
4
4
  export type { InjectFilterEntry };
5
5
  import type { PageContextInjectAssets } from '../injectAssets.js';
6
- import type { InjectToStream } from '../stream/react-streaming.js';
6
+ import type { StreamFromReactStreamingPackage } from '../stream/react-streaming.js';
7
7
  import type { PageAsset } from '../../renderPage/getPageAssets.js';
8
8
  type PreloadFilter = null | ((assets: InjectFilterEntry[]) => InjectFilterEntry[]);
9
9
  type PreloadFilterInject = false | 'HTML_BEGIN' | 'HTML_END';
@@ -28,4 +28,4 @@ type HtmlTag = {
28
28
  };
29
29
  declare function getHtmlTags(pageContext: {
30
30
  _isStream: boolean;
31
- } & PageContextInjectAssets, injectToStream: null | InjectToStream, injectFilter: PreloadFilter, pageAssets: PageAsset[], viteDevScript: string): HtmlTag[];
31
+ } & PageContextInjectAssets, streamFromReactStreamingPackage: null | StreamFromReactStreamingPackage, injectFilter: PreloadFilter, pageAssets: PageAsset[], viteDevScript: string): HtmlTag[];
@@ -7,7 +7,7 @@ import { mergeScriptTags } from './mergeScriptTags.js';
7
7
  import { getGlobalContext } from '../../globalContext.js';
8
8
  import pc from '@brillout/picocolors';
9
9
  const stamp = '__injectFilterEntry';
10
- function getHtmlTags(pageContext, injectToStream, injectFilter, pageAssets, viteDevScript) {
10
+ function getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript) {
11
11
  assert([true, false].includes(pageContext._isHtmlOnly));
12
12
  const isHtmlOnly = pageContext._isHtmlOnly;
13
13
  const { isProduction } = getGlobalContext();
@@ -83,11 +83,11 @@ function getHtmlTags(pageContext, injectToStream, injectFilter, pageAssets, vite
83
83
  // See https://github.com/vikejs/vike/pull/1271
84
84
  const positionJavaScriptEntry = (() => {
85
85
  if (pageContext._pageContextPromise) {
86
- assertWarning(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time, because progressive hydration won't work.", { onlyOnce: true });
86
+ assertWarning(!streamFromReactStreamingPackage, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time, because progressive hydration won't work.", { onlyOnce: true });
87
87
  // If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/streaming#initial-data-after-stream-end
88
88
  return 'HTML_END';
89
89
  }
90
- if (injectToStream) {
90
+ if (streamFromReactStreamingPackage && !streamFromReactStreamingPackage.hasStreamEnded()) {
91
91
  // If there is a stream then, in order to support progressive hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary
92
92
  return 'STREAM';
93
93
  }
@@ -1,10 +1,13 @@
1
1
  export { injectHtmlTags };
2
+ export { injectHtmlTagsUsingStream };
2
3
  export { createHtmlHeadIfMissing };
3
4
  export { injectAtOpeningTag };
4
5
  export { injectAtClosingTag };
6
+ import type { StreamFromReactStreamingPackage } from '../stream/react-streaming.js';
5
7
  import type { HtmlTag } from './getHtmlTags.js';
6
- import type { InjectToStream } from '../stream/react-streaming.js';
7
- declare function injectHtmlTags(htmlString: string, htmlTags: HtmlTag[], injectToStream: null | InjectToStream): string;
8
+ type Position = 'HTML_BEGIN' | 'HTML_END';
9
+ declare function injectHtmlTags(htmlString: string, htmlTags: HtmlTag[], position: Position): string;
10
+ declare function injectHtmlTagsUsingStream(htmlTags: HtmlTag[], streamFromReactStreamingPackage: null | StreamFromReactStreamingPackage): Promise<void>;
8
11
  declare function injectAtOpeningTag(tag: 'head' | 'html' | '!doctype', htmlString: string, htmlFragment: string): string;
9
12
  declare function injectAtClosingTag(tag: 'body' | 'html', htmlString: string, htmlFragment: string): string;
10
13
  declare function createHtmlHeadIfMissing(htmlString: string): string;
@@ -1,24 +1,31 @@
1
1
  // Unit tests at ./injectHtmlTags.spec.ts
2
2
  export { injectHtmlTags };
3
+ export { injectHtmlTagsUsingStream };
3
4
  export { createHtmlHeadIfMissing };
4
5
  // Only needed for unit tests
5
6
  export { injectAtOpeningTag };
6
7
  export { injectAtClosingTag };
7
8
  import { assert, assertUsage, slice } from '../../utils.js';
8
- const POSITIONS = ['HTML_BEGIN', 'HTML_END', 'STREAM'];
9
- function injectHtmlTags(htmlString, htmlTags, injectToStream) {
10
- POSITIONS.forEach((position) => {
11
- const htmlFragment = htmlTags
12
- .filter((h) => h.position === position)
13
- .map((h) => resolveHtmlTag(h.htmlTag))
14
- .join('');
15
- if (htmlFragment) {
16
- htmlString = injectHtmlFragment(position, htmlFragment, htmlString, injectToStream);
17
- }
18
- });
9
+ function injectHtmlTags(htmlString, htmlTags, position) {
10
+ const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === position));
11
+ if (htmlFragment) {
12
+ htmlString = injectHtmlFragment(position, htmlFragment, htmlString);
13
+ }
19
14
  return htmlString;
20
15
  }
21
- function injectHtmlFragment(position, htmlFragment, htmlString, injectToStream) {
16
+ async function injectHtmlTagsUsingStream(htmlTags, streamFromReactStreamingPackage) {
17
+ const htmlFragment = joinHtmlTags(htmlTags.filter((h) => h.position === 'STREAM'));
18
+ if (htmlFragment) {
19
+ assert(streamFromReactStreamingPackage);
20
+ assert(!streamFromReactStreamingPackage.hasStreamEnded());
21
+ await streamFromReactStreamingPackage.injectToStream(htmlFragment, { flush: true });
22
+ }
23
+ }
24
+ function joinHtmlTags(htmlTags) {
25
+ const htmlFragment = htmlTags.map((h) => resolveHtmlTag(h.htmlTag)).join('');
26
+ return htmlFragment;
27
+ }
28
+ function injectHtmlFragment(position, htmlFragment, htmlString) {
22
29
  if (position === 'HTML_BEGIN') {
23
30
  {
24
31
  const res = injectAtPaceholder(htmlFragment, htmlString, true);
@@ -43,11 +50,6 @@ function injectHtmlFragment(position, htmlFragment, htmlString, injectToStream)
43
50
  }
44
51
  return htmlString + '\n' + htmlFragment;
45
52
  }
46
- if (position === 'STREAM') {
47
- assert(injectToStream);
48
- injectToStream(htmlFragment, { flush: true });
49
- return htmlString;
50
- }
51
53
  assert(false);
52
54
  }
53
55
  function resolveHtmlTag(htmlTag) {
@@ -5,7 +5,7 @@ export type { PageContextPromise };
5
5
  import type { PageAsset } from '../renderPage/getPageAssets.js';
6
6
  import type { HtmlPart } from './renderHtml.js';
7
7
  import { type PreloadFilter } from './injectAssets/getHtmlTags.js';
8
- import type { InjectToStream } from './stream/react-streaming.js';
8
+ import type { StreamFromReactStreamingPackage } from './stream/react-streaming.js';
9
9
  import type { PageConfigRuntime } from '../../../shared/page-configs/PageConfig.js';
10
10
  import type { PageContextSerialization } from './serializePageContextClientSide.js';
11
11
  type PageContextInjectAssets = {
@@ -27,7 +27,7 @@ declare function injectHtmlTagsToString(htmlParts: HtmlPart[], pageContext: Page
27
27
  }, injectFilter: PreloadFilter): Promise<string>;
28
28
  declare function injectHtmlTagsToStream(pageContext: PageContextInjectAssets & {
29
29
  _isStream: true;
30
- }, injectToStream: null | InjectToStream, injectFilter: PreloadFilter): {
30
+ }, streamFromReactStreamingPackage: null | StreamFromReactStreamingPackage, injectFilter: PreloadFilter): {
31
31
  injectAtStreamBegin: (htmlPartsBegin: HtmlPart[]) => Promise<string>;
32
32
  injectAtStreamEnd: (htmlPartsEnd: HtmlPart[]) => Promise<string>;
33
33
  };
@@ -2,7 +2,7 @@ export { injectHtmlTagsToString };
2
2
  export { injectHtmlTagsToStream };
3
3
  import { assert, isCallable, isPromise } from '../utils.js';
4
4
  import { assertPageContextProvidedByUser } from '../../../shared/assertPageContextProvidedByUser.js';
5
- import { injectHtmlTags, createHtmlHeadIfMissing } from './injectAssets/injectHtmlTags.js';
5
+ import { injectHtmlTags, createHtmlHeadIfMissing, injectHtmlTagsUsingStream } from './injectAssets/injectHtmlTags.js';
6
6
  import { getHtmlTags } from './injectAssets/getHtmlTags.js';
7
7
  import { getViteDevScript } from './injectAssets/getViteDevScript.js';
8
8
  async function injectHtmlTagsToString(htmlParts, pageContext, injectFilter) {
@@ -10,11 +10,12 @@ async function injectHtmlTagsToString(htmlParts, pageContext, injectFilter) {
10
10
  const viteDevScript = await getViteDevScript();
11
11
  const htmlTags = getHtmlTags(pageContext, null, injectFilter, pageAssets, viteDevScript);
12
12
  let htmlString = htmlPartsToString(htmlParts, pageAssets);
13
- htmlString = injectToHtmlBegin(htmlString, htmlTags, null);
13
+ htmlString = injectToHtmlBegin(htmlString, htmlTags);
14
14
  htmlString = injectToHtmlEnd(htmlString, htmlTags);
15
+ assert(htmlTags.filter((snippet) => snippet.position === 'STREAM').length === 0);
15
16
  return htmlString;
16
17
  }
17
- function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
18
+ function injectHtmlTagsToStream(pageContext, streamFromReactStreamingPackage, injectFilter) {
18
19
  let htmlTags;
19
20
  return {
20
21
  injectAtStreamBegin,
@@ -23,9 +24,10 @@ function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
23
24
  async function injectAtStreamBegin(htmlPartsBegin) {
24
25
  const pageAssets = await pageContext.__getPageAssets();
25
26
  const viteDevScript = await getViteDevScript();
26
- htmlTags = getHtmlTags(pageContext, injectToStream, injectFilter, pageAssets, viteDevScript);
27
+ htmlTags = getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript);
27
28
  let htmlBegin = htmlPartsToString(htmlPartsBegin, pageAssets);
28
- htmlBegin = injectToHtmlBegin(htmlBegin, htmlTags, injectToStream);
29
+ htmlBegin = injectToHtmlBegin(htmlBegin, htmlTags);
30
+ await injectHtmlTagsUsingStream(htmlTags, streamFromReactStreamingPackage);
29
31
  return htmlBegin;
30
32
  }
31
33
  async function injectAtStreamEnd(htmlPartsEnd) {
@@ -37,16 +39,14 @@ function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
37
39
  return htmlEnd;
38
40
  }
39
41
  }
40
- function injectToHtmlBegin(htmlBegin, htmlTags, injectToStream) {
41
- const htmlTagsAtBegin = htmlTags.filter((snippet) => snippet.position !== 'HTML_END');
42
+ function injectToHtmlBegin(htmlBegin, htmlTags) {
42
43
  // Ensure existence of `<head>`
43
44
  htmlBegin = createHtmlHeadIfMissing(htmlBegin);
44
- htmlBegin = injectHtmlTags(htmlBegin, htmlTagsAtBegin, injectToStream);
45
+ htmlBegin = injectHtmlTags(htmlBegin, htmlTags, 'HTML_BEGIN');
45
46
  return htmlBegin;
46
47
  }
47
48
  function injectToHtmlEnd(htmlEnd, htmlTags) {
48
- const htmlTagsAtEnd = htmlTags.filter((snippet) => snippet.position === 'HTML_END');
49
- htmlEnd = injectHtmlTags(htmlEnd, htmlTagsAtEnd, null);
49
+ htmlEnd = injectHtmlTags(htmlEnd, htmlTags, 'HTML_END');
50
50
  return htmlEnd;
51
51
  }
52
52
  async function resolvePageContextPromise(pageContext) {
@@ -6,7 +6,7 @@ export { getHtmlString };
6
6
  import { assert, assertUsage, assertWarning, checkType, escapeHtml, hasProp, isHtml, isPromise, objectAssign } from '../utils.js';
7
7
  import { injectHtmlTagsToString, injectHtmlTagsToStream } from './injectAssets.js';
8
8
  import { processStream, isStream, streamToString } from './stream.js';
9
- import { isStreamReactStreaming } from './stream/react-streaming.js';
9
+ import { isStreamFromReactStreamingPackage } from './stream/react-streaming.js';
10
10
  import { getGlobalContext } from '../globalContext.js';
11
11
  import pc from '@brillout/picocolors';
12
12
  function isDocumentHtml(something) {
@@ -57,11 +57,11 @@ async function renderHtmlStream(streamOriginal, injectString, pageContext, onErr
57
57
  enableEagerStreaming: pageContext.enableEagerStreaming
58
58
  };
59
59
  if (injectString) {
60
- let injectToStream = null;
61
- if (isStreamReactStreaming(streamOriginal) && !streamOriginal.disabled) {
62
- injectToStream = streamOriginal.injectToStream;
60
+ let streamFromReactStreamingPackage = null;
61
+ if (isStreamFromReactStreamingPackage(streamOriginal) && !streamOriginal.disabled) {
62
+ streamFromReactStreamingPackage = streamOriginal;
63
63
  }
64
- const { injectAtStreamBegin, injectAtStreamEnd } = injectHtmlTagsToStream(pageContext, injectToStream, injectFilter);
64
+ const { injectAtStreamBegin, injectAtStreamEnd } = injectHtmlTagsToStream(pageContext, streamFromReactStreamingPackage, injectFilter);
65
65
  objectAssign(opts, {
66
66
  injectStringAtBegin: async () => {
67
67
  return await injectAtStreamBegin(injectString.htmlPartsBegin);
@@ -1,25 +1,18 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- export { isStreamReactStreaming };
3
- export { streamReactStreamingToString };
4
- export { getStreamFromReactStreaming };
5
- export type { StreamReactStreaming };
6
- export type { InjectToStream };
1
+ export { isStreamFromReactStreamingPackage };
2
+ export { streamFromReactStreamingPackageToString };
3
+ export { getStreamOfReactStreamingPackage };
4
+ export type { StreamFromReactStreamingPackage };
5
+ export type { StreamFromReactStreamingPackagePublic };
6
+ import type { renderToStream } from 'react-streaming/server';
7
7
  import { StreamReadableWeb, StreamWritableNode } from '../stream.js';
8
- type InjectToStream = (chunk: unknown, options?: {
9
- flush?: boolean;
10
- }) => void;
11
- type StreamReactStreaming = {
12
- injectToStream: InjectToStream;
13
- disabled?: boolean;
14
- } & ({
15
- pipe: (writable: StreamWritableNode) => void;
16
- readable: null;
17
- } | {
18
- pipe: null;
19
- readable: StreamReadableWeb;
20
- });
21
- declare function streamReactStreamingToString(stream: StreamReactStreaming): Promise<string>;
22
- declare function isStreamReactStreaming(thing: unknown): thing is StreamReactStreaming;
23
- declare function getStreamFromReactStreaming(stream: StreamReactStreaming): StreamReadableWeb | {
24
- __streamPipeNode: (writable: import("stream").Writable) => void;
8
+ type StreamFromReactStreamingPackagePublic = {
9
+ injectToStream: Function;
25
10
  };
11
+ type StreamFromReactStreamingPackage = Awaited<ReturnType<typeof renderToStream>>;
12
+ declare function streamFromReactStreamingPackageToString(stream: StreamFromReactStreamingPackage): Promise<string>;
13
+ declare function isStreamFromReactStreamingPackage(thing: unknown): thing is StreamFromReactStreamingPackage;
14
+ type Pipe = {
15
+ __streamPipeNode: (writable: StreamWritableNode) => void;
16
+ };
17
+ type Readable = StreamReadableWeb;
18
+ declare function getStreamOfReactStreamingPackage(stream: StreamFromReactStreamingPackage): Pipe | Readable;
@@ -1,10 +1,10 @@
1
1
  // Zero-config support for https://www.npmjs.com/package/react-streaming
2
- export { isStreamReactStreaming };
3
- export { streamReactStreamingToString };
4
- export { getStreamFromReactStreaming };
5
- import { assert, hasProp } from '../../utils.js';
2
+ export { isStreamFromReactStreamingPackage };
3
+ export { streamFromReactStreamingPackageToString };
4
+ export { getStreamOfReactStreamingPackage };
5
+ import { assert, assertUsage, hasProp, isVikeReactApp } from '../../utils.js';
6
6
  import { streamPipeNodeToString, streamReadableWebToString } from '../stream.js';
7
- function streamReactStreamingToString(stream) {
7
+ function streamFromReactStreamingPackageToString(stream) {
8
8
  if (stream.pipe) {
9
9
  return streamPipeNodeToString(stream.pipe);
10
10
  }
@@ -13,17 +13,18 @@ function streamReactStreamingToString(stream) {
13
13
  }
14
14
  assert(false);
15
15
  }
16
- function isStreamReactStreaming(thing) {
16
+ function isStreamFromReactStreamingPackage(thing) {
17
17
  if (hasProp(thing, 'injectToStream', 'function')) {
18
+ assertUsage(hasProp(thing, 'hasStreamEnded', 'function'), isVikeReactApp()
19
+ ? //
20
+ 'Update vike-react to its latest version'
21
+ : 'Update react-streaming to its latest version');
18
22
  return true;
19
23
  }
20
- // TODO
21
- //if( isStreamPipeNode
22
24
  return false;
23
25
  }
24
- function getStreamFromReactStreaming(stream) {
26
+ function getStreamOfReactStreamingPackage(stream) {
25
27
  if (stream.pipe) {
26
- // TODO
27
28
  return { __streamPipeNode: stream.pipe };
28
29
  }
29
30
  if (stream.readable) {
@@ -30,7 +30,7 @@ export type { StreamWritableNode };
30
30
  export type { StreamPipeWeb };
31
31
  export type { StreamPipeNode };
32
32
  import { HtmlRender } from './renderHtml.js';
33
- import { StreamReactStreaming } from './stream/react-streaming.js';
33
+ import { StreamFromReactStreamingPackagePublic } from './stream/react-streaming.js';
34
34
  import type { Readable as Readable_, Writable as Writable_ } from 'node:stream';
35
35
  type StreamReadableWeb = ReadableStream;
36
36
  type StreamReadableNode = Readable_;
@@ -39,7 +39,7 @@ type StreamWritableNode = Writable_;
39
39
  type StreamPipeWeb = (writable: StreamWritableWeb) => void;
40
40
  type StreamPipeNode = (writable: StreamWritableNode) => void;
41
41
  type StreamProviderNormalized = StreamReadableWeb | StreamReadableNode | StreamPipeWeb | StreamPipeNode;
42
- type StreamProviderAny = StreamProviderNormalized | StreamReactStreaming | StreamPipeWebWrapped | StreamPipeNodeWrapped;
42
+ type StreamProviderAny = StreamProviderNormalized | StreamFromReactStreamingPackagePublic | StreamPipeWebWrapped | StreamPipeNodeWrapped;
43
43
  type StreamTypePatch = NodeJS.ReadableStream;
44
44
  declare function isStreamReadableWeb(thing: unknown): thing is StreamReadableWeb;
45
45
  declare function isStreamWritableWeb(thing: unknown): thing is StreamWritableWeb;
@@ -20,7 +20,7 @@ export { streamPipeNodeToString };
20
20
  export { isStreamWritableWeb };
21
21
  export { isStreamWritableNode };
22
22
  import { assert, assertUsage, checkType, isObject, hasProp, objectAssign, capitalizeFirstLetter, assertWarning, isCallable, createDebugger, isBug } from '../utils.js';
23
- import { getStreamFromReactStreaming, isStreamReactStreaming, streamReactStreamingToString } from './stream/react-streaming.js';
23
+ import { getStreamOfReactStreamingPackage, isStreamFromReactStreamingPackage, streamFromReactStreamingPackageToString } from './stream/react-streaming.js';
24
24
  import { import_ } from '@brillout/import';
25
25
  import pc from '@brillout/picocolors';
26
26
  const debug = createDebugger('vike:stream');
@@ -358,9 +358,9 @@ async function processStream(streamOriginal, { injectStringAtBegin, injectString
358
358
  }
359
359
  }
360
360
  async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onFlush, onReadyToWrite }) {
361
- if (isStreamReactStreaming(streamOriginal)) {
361
+ if (isStreamFromReactStreamingPackage(streamOriginal)) {
362
362
  debug(`onRenderHtml() hook returned ${pc.cyan('react-streaming')} result`);
363
- const stream = getStreamFromReactStreaming(streamOriginal);
363
+ const stream = getStreamOfReactStreamingPackage(streamOriginal);
364
364
  streamOriginal = stream;
365
365
  }
366
366
  if (isStreamPipeNode(streamOriginal)) {
@@ -625,7 +625,7 @@ function isStream(something) {
625
625
  isStreamReadableNode(something) ||
626
626
  isStreamPipeNode(something) ||
627
627
  isStreamPipeWeb(something) ||
628
- isStreamReactStreaming(something)) {
628
+ isStreamFromReactStreamingPackage(something)) {
629
629
  checkType(something);
630
630
  return true;
631
631
  }
@@ -730,8 +730,8 @@ async function streamToString(stream) {
730
730
  if (isStreamPipeWeb(stream)) {
731
731
  return await streamPipeWebToString(getStreamPipeWeb(stream));
732
732
  }
733
- if (isStreamReactStreaming(stream)) {
734
- return await streamReactStreamingToString(stream);
733
+ if (isStreamFromReactStreamingPackage(stream)) {
734
+ return await streamFromReactStreamingPackageToString(stream);
735
735
  }
736
736
  assert(false);
737
737
  }
@@ -51,3 +51,4 @@ export * from '../../utils/joinEnglish.js';
51
51
  export * from '../../utils/isArrayOfStrings.js';
52
52
  export * from '../../utils/escapeHtml.js';
53
53
  export * from '../../utils/normalizeHeaders.js';
54
+ export * from '../../utils/isVikeReactApp.js';
@@ -54,3 +54,4 @@ export * from '../../utils/joinEnglish.js';
54
54
  export * from '../../utils/isArrayOfStrings.js';
55
55
  export * from '../../utils/escapeHtml.js';
56
56
  export * from '../../utils/normalizeHeaders.js';
57
+ export * from '../../utils/isVikeReactApp.js';
@@ -8,7 +8,7 @@ export { getAssertErrMsg };
8
8
  export { overwriteAssertProductionLogger };
9
9
  export { isBug };
10
10
  export { setAlwaysShowStackTrace };
11
- import { onAssertModuleLoad } from './assertSingleInstance.js';
11
+ import { assertSingleInstance_onAssertModuleLoad } from './assertSingleInstance.js';
12
12
  import { createErrorWithCleanStackTrace } from './createErrorWithCleanStackTrace.js';
13
13
  import { getGlobalObject } from './getGlobalObject.js';
14
14
  import { isObject } from './isObject.js';
@@ -27,7 +27,7 @@ const globalObject = getGlobalObject('utils/assert.ts', {
27
27
  },
28
28
  showStackTraceList: new WeakSet()
29
29
  });
30
- onAssertModuleLoad();
30
+ assertSingleInstance_onAssertModuleLoad();
31
31
  const projectTag = `[vike]`;
32
32
  const projectTagWithVersion = `[vike@${projectInfo.projectVersion}]`;
33
33
  const numberOfStackTraceLinesToRemove = 2;
@@ -1,6 +1,6 @@
1
- export { onClientEntry_ServerRouting };
2
- export { onClientEntry_ClientRouting };
3
- export { onAssertModuleLoad };
4
- declare function onClientEntry_ServerRouting(isProduction: boolean): void;
5
- declare function onClientEntry_ClientRouting(isProduction: boolean): void;
6
- declare function onAssertModuleLoad(): void;
1
+ export { assertSingleInstance_onClientEntryServerRouting };
2
+ export { assertSingleInstance_onClientEntryClientRouting };
3
+ export { assertSingleInstance_onAssertModuleLoad };
4
+ declare function assertSingleInstance_onClientEntryServerRouting(isProduction: boolean): void;
5
+ declare function assertSingleInstance_onClientEntryClientRouting(isProduction: boolean): void;
6
+ declare function assertSingleInstance_onAssertModuleLoad(): void;
@@ -1,6 +1,6 @@
1
- export { onClientEntry_ServerRouting };
2
- export { onClientEntry_ClientRouting };
3
- export { onAssertModuleLoad };
1
+ export { assertSingleInstance_onClientEntryServerRouting };
2
+ export { assertSingleInstance_onClientEntryClientRouting };
3
+ export { assertSingleInstance_onAssertModuleLoad };
4
4
  // - Throw error if there are two different versions of vike loaded
5
5
  // - Show warning if entry of Client Routing and entry of Server Routing are both loaded
6
6
  // - Show warning if vike is loaded twice
@@ -32,7 +32,7 @@ function assertSingleInstance() {
32
32
  //*/
33
33
  }
34
34
  }
35
- function onClientEntry_ServerRouting(isProduction) {
35
+ function assertSingleInstance_onClientEntryServerRouting(isProduction) {
36
36
  assertWarning(globalObject.isClientRouting !== true, clientRuntimesClonflict, {
37
37
  onlyOnce: true,
38
38
  showStackTrace: true
@@ -46,7 +46,7 @@ function onClientEntry_ServerRouting(isProduction) {
46
46
  globalObject.checkSingleInstance = true;
47
47
  assertSingleInstance();
48
48
  }
49
- function onClientEntry_ClientRouting(isProduction) {
49
+ function assertSingleInstance_onClientEntryClientRouting(isProduction) {
50
50
  assertWarning(globalObject.isClientRouting !== false, clientRuntimesClonflict, {
51
51
  onlyOnce: true,
52
52
  showStackTrace: true
@@ -61,7 +61,7 @@ function onClientEntry_ClientRouting(isProduction) {
61
61
  assertSingleInstance();
62
62
  }
63
63
  // Called by utils/assert.ts which is (most certainly) loaded by all entries. That way we don't have to call a callback for every entry. (There are a lot of entries: `client/router/`, `client/`, `node/runtime/`, `node/plugin/`, `node/cli`.)
64
- function onAssertModuleLoad() {
64
+ function assertSingleInstance_onAssertModuleLoad() {
65
65
  globalObject.instances.push(projectInfo.projectVersion);
66
66
  assertSingleInstance();
67
67
  }
@@ -0,0 +1 @@
1
+ export declare function isVikeReactApp(): boolean;
@@ -0,0 +1,5 @@
1
+ export function isVikeReactApp() {
2
+ const g = globalThis;
3
+ // Set by vike-react https://github.com/vikejs/vike-react/blob/23e92434424f10e7e742b6bf587edee5aa8832df/packages/vike-react/src/renderer/onRenderHtml.tsx#L75
4
+ return !!g._isVikeReactApp;
5
+ }
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.177-commit-51d612a";
3
+ declare const PROJECT_VERSION: "0.4.178-commit-fae90a1";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.177-commit-51d612a";
6
+ projectVersion: "0.4.178-commit-fae90a1";
7
7
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- const PROJECT_VERSION = '0.4.177-commit-51d612a';
3
+ const PROJECT_VERSION = '0.4.178-commit-fae90a1';
4
4
  const projectInfo = {
5
5
  projectName: 'Vike',
6
6
  projectVersion: PROJECT_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.177-commit-51d612a",
3
+ "version": "0.4.178-commit-fae90a1",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -138,7 +138,7 @@
138
138
  }
139
139
  },
140
140
  "peerDependencies": {
141
- "react-streaming": ">=0.3.5",
141
+ "react-streaming": ">=0.3.40",
142
142
  "vite": ">=4.4.0"
143
143
  },
144
144
  "peerDependenciesMeta": {
@@ -209,7 +209,7 @@
209
209
  "es-module-lexer": "^1.4.1",
210
210
  "esbuild": "^0.19.10",
211
211
  "fast-glob": "^3.3.2",
212
- "react-streaming": "^0.3.24",
212
+ "react-streaming": "^0.3.40",
213
213
  "rimraf": "^5.0.5",
214
214
  "sirv": "^2.0.4",
215
215
  "source-map-support": "^0.5.21",