vike 0.4.177 → 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 (50) hide show
  1. package/dist/cjs/node/plugin/plugins/envVars.js +11 -3
  2. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +131 -20
  3. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +6 -9
  4. package/dist/cjs/node/runtime/html/injectAssets/{getViteDevScripts.js → getViteDevScript.js} +5 -5
  5. package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +20 -18
  6. package/dist/cjs/node/runtime/html/injectAssets.js +13 -10
  7. package/dist/cjs/node/runtime/html/renderHtml.js +4 -4
  8. package/dist/cjs/node/runtime/html/stream/react-streaming.js +11 -10
  9. package/dist/cjs/node/runtime/html/stream.js +18 -10
  10. package/dist/cjs/node/runtime/utils.js +1 -0
  11. package/dist/cjs/utils/assert.js +1 -1
  12. package/dist/cjs/utils/assertSingleInstance.js +7 -7
  13. package/dist/cjs/utils/isVikeReactApp.js +9 -0
  14. package/dist/cjs/utils/parseUrl.js +17 -12
  15. package/dist/cjs/utils/projectInfo.js +1 -1
  16. package/dist/esm/client/client-routing-runtime/entry.js +5 -2
  17. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -0
  18. package/dist/esm/client/server-routing-runtime/entry.js +5 -2
  19. package/dist/esm/client/shared/removeFoucBuster.d.ts +2 -0
  20. package/dist/esm/client/shared/removeFoucBuster.js +39 -0
  21. package/dist/esm/client/shared/utils.d.ts +1 -0
  22. package/dist/esm/client/shared/utils.js +1 -0
  23. package/dist/esm/node/plugin/plugins/envVars.js +11 -3
  24. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +132 -21
  25. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.d.ts +2 -2
  26. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +6 -9
  27. package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -0
  28. package/dist/esm/node/runtime/html/injectAssets/{getViteDevScripts.js → getViteDevScript.js} +4 -4
  29. package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.d.ts +5 -2
  30. package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +19 -17
  31. package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
  32. package/dist/esm/node/runtime/html/injectAssets.js +14 -11
  33. package/dist/esm/node/runtime/html/renderHtml.js +5 -5
  34. package/dist/esm/node/runtime/html/stream/react-streaming.d.ts +16 -23
  35. package/dist/esm/node/runtime/html/stream/react-streaming.js +11 -10
  36. package/dist/esm/node/runtime/html/stream.d.ts +2 -2
  37. package/dist/esm/node/runtime/html/stream.js +19 -11
  38. package/dist/esm/node/runtime/utils.d.ts +1 -0
  39. package/dist/esm/node/runtime/utils.js +1 -0
  40. package/dist/esm/utils/assert.js +2 -2
  41. package/dist/esm/utils/assertSingleInstance.d.ts +6 -6
  42. package/dist/esm/utils/assertSingleInstance.js +6 -6
  43. package/dist/esm/utils/isVikeReactApp.d.ts +1 -0
  44. package/dist/esm/utils/isVikeReactApp.js +5 -0
  45. package/dist/esm/utils/parseUrl.d.ts +1 -1
  46. package/dist/esm/utils/parseUrl.js +17 -12
  47. package/dist/esm/utils/projectInfo.d.ts +2 -2
  48. package/dist/esm/utils/projectInfo.js +1 -1
  49. package/package.json +3 -3
  50. package/dist/esm/node/runtime/html/injectAssets/getViteDevScripts.d.ts +0 -2
@@ -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,27 +2,32 @@ 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
+ import { getViteDevScript } from './injectAssets/getViteDevScript.js';
7
8
  async function injectHtmlTagsToString(htmlParts, pageContext, injectFilter) {
8
- const htmlTags = await getHtmlTags(pageContext, null, injectFilter);
9
9
  const pageAssets = await pageContext.__getPageAssets();
10
+ const viteDevScript = await getViteDevScript();
11
+ const htmlTags = getHtmlTags(pageContext, null, injectFilter, pageAssets, viteDevScript);
10
12
  let htmlString = htmlPartsToString(htmlParts, pageAssets);
11
- htmlString = injectToHtmlBegin(htmlString, htmlTags, null);
13
+ htmlString = injectToHtmlBegin(htmlString, htmlTags);
12
14
  htmlString = injectToHtmlEnd(htmlString, htmlTags);
15
+ assert(htmlTags.filter((snippet) => snippet.position === 'STREAM').length === 0);
13
16
  return htmlString;
14
17
  }
15
- function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
18
+ function injectHtmlTagsToStream(pageContext, streamFromReactStreamingPackage, injectFilter) {
16
19
  let htmlTags;
17
20
  return {
18
21
  injectAtStreamBegin,
19
22
  injectAtStreamEnd
20
23
  };
21
24
  async function injectAtStreamBegin(htmlPartsBegin) {
22
- htmlTags = await getHtmlTags(pageContext, injectToStream, injectFilter);
23
25
  const pageAssets = await pageContext.__getPageAssets();
26
+ const viteDevScript = await getViteDevScript();
27
+ htmlTags = getHtmlTags(pageContext, streamFromReactStreamingPackage, injectFilter, pageAssets, viteDevScript);
24
28
  let htmlBegin = htmlPartsToString(htmlPartsBegin, pageAssets);
25
- htmlBegin = injectToHtmlBegin(htmlBegin, htmlTags, injectToStream);
29
+ htmlBegin = injectToHtmlBegin(htmlBegin, htmlTags);
30
+ await injectHtmlTagsUsingStream(htmlTags, streamFromReactStreamingPackage);
26
31
  return htmlBegin;
27
32
  }
28
33
  async function injectAtStreamEnd(htmlPartsEnd) {
@@ -34,16 +39,14 @@ function injectHtmlTagsToStream(pageContext, injectToStream, injectFilter) {
34
39
  return htmlEnd;
35
40
  }
36
41
  }
37
- function injectToHtmlBegin(htmlBegin, htmlTags, injectToStream) {
38
- const htmlTagsAtBegin = htmlTags.filter((snippet) => snippet.position !== 'HTML_END');
42
+ function injectToHtmlBegin(htmlBegin, htmlTags) {
39
43
  // Ensure existence of `<head>`
40
44
  htmlBegin = createHtmlHeadIfMissing(htmlBegin);
41
- htmlBegin = injectHtmlTags(htmlBegin, htmlTagsAtBegin, injectToStream);
45
+ htmlBegin = injectHtmlTags(htmlBegin, htmlTags, 'HTML_BEGIN');
42
46
  return htmlBegin;
43
47
  }
44
48
  function injectToHtmlEnd(htmlEnd, htmlTags) {
45
- const htmlTagsAtEnd = htmlTags.filter((snippet) => snippet.position === 'HTML_END');
46
- htmlEnd = injectHtmlTags(htmlEnd, htmlTagsAtEnd, null);
49
+ htmlEnd = injectHtmlTags(htmlEnd, htmlTags, 'HTML_END');
47
50
  return htmlEnd;
48
51
  }
49
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)) {
@@ -380,7 +380,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
380
380
  assert(writableOriginal);
381
381
  writableOriginal.write(chunk);
382
382
  if (debug.isActivated) {
383
- debug('data written (Node.js Writable)', String(chunk));
383
+ debug('data written (Node.js Writable)', getChunkAsString(chunk));
384
384
  }
385
385
  };
386
386
  // For libraries such as https://www.npmjs.com/package/compression
@@ -453,7 +453,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
453
453
  assert(writerOriginal);
454
454
  writerOriginal.write(encodeForWebStream(chunk));
455
455
  if (debug.isActivated) {
456
- debug('data written (Web Writable)', String(chunk));
456
+ debug('data written (Web Writable)', getChunkAsString(chunk));
457
457
  }
458
458
  };
459
459
  // Web Streams have compression built-in
@@ -546,12 +546,12 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
546
546
  !controllerProxyIsClosed) {
547
547
  controllerProxy.enqueue(encodeForWebStream(chunk));
548
548
  if (debug.isActivated) {
549
- debug('data written (Web Readable)', String(chunk));
549
+ debug('data written (Web Readable)', getChunkAsString(chunk));
550
550
  }
551
551
  }
552
552
  else {
553
553
  if (debug.isActivated) {
554
- debug('data emitted but not written (Web Readable)', String(chunk));
554
+ debug('data emitted but not written (Web Readable)', getChunkAsString(chunk));
555
555
  }
556
556
  }
557
557
  };
@@ -573,7 +573,7 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
573
573
  const writeChunk = (chunk) => {
574
574
  readableProxy.push(chunk);
575
575
  if (debug.isActivated) {
576
- debug('data written (Node.js Readable)', String(chunk));
576
+ debug('data written (Node.js Readable)', getChunkAsString(chunk));
577
577
  }
578
578
  };
579
579
  // Readables don't have the notion of flushing
@@ -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
  }
@@ -787,3 +787,11 @@ function inferStreamName(stream) {
787
787
  }
788
788
  assert(false);
789
789
  }
790
+ function getChunkAsString(chunk) {
791
+ try {
792
+ return new TextDecoder().decode(chunk);
793
+ }
794
+ catch (err) {
795
+ return String(chunk);
796
+ }
797
+ }
@@ -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
+ }
@@ -21,4 +21,4 @@ declare function parseUrl(url: string, baseServer: string): {
21
21
  declare function isBaseServer(baseServer: string): boolean;
22
22
  declare function assertUrlComponents(url: string, origin: string | null, pathname: string, searchOriginal: string | null, hashOriginal: string | null): void;
23
23
  declare function createUrlFromComponents(origin: string | null, pathname: string, searchOriginal: string | null, hashOriginal: string | null): string;
24
- declare function isUriWithProtocol(uri: string): boolean;
24
+ declare function isUriWithProtocol(str: string): boolean;
@@ -12,17 +12,9 @@ export { isUriWithProtocol };
12
12
  import { slice } from './slice.js';
13
13
  import { assert, assertUsage } from './assert.js';
14
14
  import pc from '@brillout/picocolors';
15
- const PROTOCOLS = [
16
- 'http://',
17
- 'https://',
18
- // For [Tauri](https://tauri.app/)
19
- 'tauri://',
20
- // For Electron: https://github.com/vikejs/vike/issues/1557
21
- 'file://'
22
- ];
23
15
  function isParsable(url) {
24
16
  // `parseUrl()` works with these URLs
25
- return (PROTOCOLS.some((p) => url.startsWith(p)) ||
17
+ return (isUrlWithProtocol(url) ||
26
18
  url.startsWith('/') ||
27
19
  url.startsWith('.') ||
28
20
  url.startsWith('?') ||
@@ -137,7 +129,8 @@ function getPathname(url, baseServer) {
137
129
  }
138
130
  }
139
131
  function parseOrigin(url) {
140
- if (!PROTOCOLS.some((protocol) => url.startsWith(protocol))) {
132
+ if (!isUrlWithProtocol(url)) {
133
+ assert(!isUriWithProtocol(url));
141
134
  return { pathname: url, origin: null };
142
135
  }
143
136
  else {
@@ -235,7 +228,19 @@ function createUrlFromComponents(origin, pathname, searchOriginal, hashOriginal)
235
228
  const urlRecreated = `${origin || ''}${pathname}${searchOriginal || ''}${hashOriginal || ''}`;
236
229
  return urlRecreated;
237
230
  }
238
- function isUriWithProtocol(uri) {
231
+ function isUriWithProtocol(str) {
239
232
  // https://en.wikipedia.org/wiki/List_of_URI_schemes
240
- return /^[a-z0-9][a-z0-9\.\+\-]*:/i.test(uri);
233
+ // https://www.rfc-editor.org/rfc/rfc7595
234
+ // https://github.com/vikejs/vike/commit/886a99ff21e86a8ca699a25cee7edc184aa058e4#r143308934
235
+ // Examples:
236
+ // http://
237
+ // https://
238
+ // tauri:// # [Tauri](https://tauri.app)
239
+ // file:// # [Electron](https://github.com/vikejs/vike/issues/1557)
240
+ // capacitor:// # [Capacitor](https://github.com/vikejs/vike/issues/1706)
241
+ return /^[a-z][a-z0-9\+\-]*:/i.test(str);
242
+ }
243
+ // Same as isUriWithProtocol() but with trailing :// which is needed for parseOrigin()
244
+ function isUrlWithProtocol(str) {
245
+ return /^[a-z][a-z0-9\+\-]*:\/\//i.test(str);
241
246
  }
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.177";
3
+ declare const PROJECT_VERSION: "0.4.178-commit-fae90a1";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.177";
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';
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",
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",
@@ -1,2 +0,0 @@
1
- export { getViteDevScripts };
2
- declare function getViteDevScripts(): Promise<string>;