houdini-react 1.2.25 → 1.2.26

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 (128) hide show
  1. package/build/plugin-cjs/index.js +2 -3
  2. package/build/plugin-esm/index.js +2 -3
  3. package/build/runtime/index.d.ts +2 -1
  4. package/build/runtime/routing/Router.d.ts +2 -1
  5. package/build/runtime/server/index.d.ts +17 -0
  6. package/build/runtime/server/renderToStream/createBuffer.d.ts +17 -0
  7. package/build/runtime/server/renderToStream/createPipeWrapper.d.ts +12 -0
  8. package/build/runtime/server/renderToStream/createReadableWrapper.d.ts +6 -0
  9. package/build/runtime/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
  10. package/build/runtime/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
  11. package/build/runtime/server/renderToStream.d.ts +28 -0
  12. package/build/runtime/server/shared/initData.d.ts +8 -0
  13. package/build/runtime/server/shared/key.d.ts +4 -0
  14. package/build/runtime/server/shared/utils.d.ts +3 -0
  15. package/build/runtime/server/useStream.d.ts +9 -0
  16. package/build/runtime/server/utils/assert.d.ts +15 -0
  17. package/build/runtime/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
  18. package/build/runtime/server/utils/debug.d.ts +14 -0
  19. package/build/runtime/server/utils/getGlobalVariable.d.ts +4 -0
  20. package/build/runtime/server/utils/isBrowser.d.ts +2 -0
  21. package/build/runtime/server/utils/isCallable.d.ts +2 -0
  22. package/build/runtime/server/utils/isClientSide.d.ts +2 -0
  23. package/build/runtime/server/utils/isPromise.d.ts +1 -0
  24. package/build/runtime/server/utils/isServerSide.d.ts +2 -0
  25. package/build/runtime/server/utils/objectAssign.d.ts +2 -0
  26. package/build/runtime/server/utils/projectInfo.d.ts +10 -0
  27. package/build/runtime/server/utils.d.ts +4 -0
  28. package/build/runtime-cjs/index.d.ts +2 -1
  29. package/build/runtime-cjs/index.js +11 -2
  30. package/build/runtime-cjs/routing/Router.d.ts +2 -1
  31. package/build/runtime-cjs/routing/Router.js +8 -7
  32. package/build/runtime-cjs/server/index.d.ts +17 -0
  33. package/build/runtime-cjs/server/index.js +28 -0
  34. package/build/runtime-cjs/server/renderToStream/createBuffer.d.ts +17 -0
  35. package/build/runtime-cjs/server/renderToStream/createBuffer.js +101 -0
  36. package/build/runtime-cjs/server/renderToStream/createPipeWrapper.d.ts +12 -0
  37. package/build/runtime-cjs/server/renderToStream/createPipeWrapper.js +90 -0
  38. package/build/runtime-cjs/server/renderToStream/createReadableWrapper.d.ts +6 -0
  39. package/build/runtime-cjs/server/renderToStream/createReadableWrapper.js +85 -0
  40. package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
  41. package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.js +51 -0
  42. package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
  43. package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.js +44 -0
  44. package/build/runtime-cjs/server/renderToStream.d.ts +28 -0
  45. package/build/runtime-cjs/server/renderToStream.js +183 -0
  46. package/build/runtime-cjs/server/shared/initData.d.ts +8 -0
  47. package/build/runtime-cjs/server/shared/initData.js +28 -0
  48. package/build/runtime-cjs/server/shared/key.d.ts +4 -0
  49. package/build/runtime-cjs/server/shared/key.js +45 -0
  50. package/build/runtime-cjs/server/shared/utils.d.ts +3 -0
  51. package/build/runtime-cjs/server/shared/utils.js +20 -0
  52. package/build/runtime-cjs/server/useStream.d.ts +9 -0
  53. package/build/runtime-cjs/server/useStream.js +44 -0
  54. package/build/runtime-cjs/server/utils/assert.d.ts +15 -0
  55. package/build/runtime-cjs/server/utils/assert.js +119 -0
  56. package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
  57. package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.js +62 -0
  58. package/build/runtime-cjs/server/utils/debug.d.ts +14 -0
  59. package/build/runtime-cjs/server/utils/debug.js +112 -0
  60. package/build/runtime-cjs/server/utils/getGlobalVariable.d.ts +4 -0
  61. package/build/runtime-cjs/server/utils/getGlobalVariable.js +32 -0
  62. package/build/runtime-cjs/server/utils/isBrowser.d.ts +2 -0
  63. package/build/runtime-cjs/server/utils/isBrowser.js +30 -0
  64. package/build/runtime-cjs/server/utils/isCallable.d.ts +2 -0
  65. package/build/runtime-cjs/server/utils/isCallable.js +30 -0
  66. package/build/runtime-cjs/server/utils/isClientSide.d.ts +2 -0
  67. package/build/runtime-cjs/server/utils/isClientSide.js +30 -0
  68. package/build/runtime-cjs/server/utils/isPromise.d.ts +1 -0
  69. package/build/runtime-cjs/server/utils/isPromise.js +31 -0
  70. package/build/runtime-cjs/server/utils/isServerSide.d.ts +2 -0
  71. package/build/runtime-cjs/server/utils/isServerSide.js +31 -0
  72. package/build/runtime-cjs/server/utils/objectAssign.d.ts +2 -0
  73. package/build/runtime-cjs/server/utils/objectAssign.js +30 -0
  74. package/build/runtime-cjs/server/utils/projectInfo.d.ts +10 -0
  75. package/build/runtime-cjs/server/utils/projectInfo.js +37 -0
  76. package/build/runtime-cjs/server/utils.d.ts +4 -0
  77. package/build/runtime-cjs/server/utils.js +21 -0
  78. package/build/runtime-esm/index.d.ts +2 -1
  79. package/build/runtime-esm/index.js +11 -2
  80. package/build/runtime-esm/routing/Router.d.ts +2 -1
  81. package/build/runtime-esm/routing/Router.js +8 -7
  82. package/build/runtime-esm/server/index.d.ts +17 -0
  83. package/build/runtime-esm/server/index.js +4 -0
  84. package/build/runtime-esm/server/renderToStream/createBuffer.d.ts +17 -0
  85. package/build/runtime-esm/server/renderToStream/createBuffer.js +77 -0
  86. package/build/runtime-esm/server/renderToStream/createPipeWrapper.d.ts +12 -0
  87. package/build/runtime-esm/server/renderToStream/createPipeWrapper.js +66 -0
  88. package/build/runtime-esm/server/renderToStream/createReadableWrapper.d.ts +6 -0
  89. package/build/runtime-esm/server/renderToStream/createReadableWrapper.js +61 -0
  90. package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
  91. package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.js +20 -0
  92. package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
  93. package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.js +20 -0
  94. package/build/runtime-esm/server/renderToStream.d.ts +28 -0
  95. package/build/runtime-esm/server/renderToStream.js +152 -0
  96. package/build/runtime-esm/server/shared/initData.d.ts +8 -0
  97. package/build/runtime-esm/server/shared/initData.js +4 -0
  98. package/build/runtime-esm/server/shared/key.d.ts +4 -0
  99. package/build/runtime-esm/server/shared/key.js +20 -0
  100. package/build/runtime-esm/server/shared/utils.d.ts +3 -0
  101. package/build/runtime-esm/server/shared/utils.js +3 -0
  102. package/build/runtime-esm/server/useStream.d.ts +9 -0
  103. package/build/runtime-esm/server/useStream.js +13 -0
  104. package/build/runtime-esm/server/utils/assert.d.ts +15 -0
  105. package/build/runtime-esm/server/utils/assert.js +91 -0
  106. package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
  107. package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.js +38 -0
  108. package/build/runtime-esm/server/utils/debug.d.ts +14 -0
  109. package/build/runtime-esm/server/utils/debug.js +87 -0
  110. package/build/runtime-esm/server/utils/getGlobalVariable.d.ts +4 -0
  111. package/build/runtime-esm/server/utils/getGlobalVariable.js +8 -0
  112. package/build/runtime-esm/server/utils/isBrowser.d.ts +2 -0
  113. package/build/runtime-esm/server/utils/isBrowser.js +6 -0
  114. package/build/runtime-esm/server/utils/isCallable.d.ts +2 -0
  115. package/build/runtime-esm/server/utils/isCallable.js +6 -0
  116. package/build/runtime-esm/server/utils/isClientSide.d.ts +2 -0
  117. package/build/runtime-esm/server/utils/isClientSide.js +6 -0
  118. package/build/runtime-esm/server/utils/isPromise.d.ts +1 -0
  119. package/build/runtime-esm/server/utils/isPromise.js +7 -0
  120. package/build/runtime-esm/server/utils/isServerSide.d.ts +2 -0
  121. package/build/runtime-esm/server/utils/isServerSide.js +7 -0
  122. package/build/runtime-esm/server/utils/objectAssign.d.ts +2 -0
  123. package/build/runtime-esm/server/utils/objectAssign.js +6 -0
  124. package/build/runtime-esm/server/utils/projectInfo.d.ts +10 -0
  125. package/build/runtime-esm/server/utils/projectInfo.js +13 -0
  126. package/build/runtime-esm/server/utils.d.ts +4 -0
  127. package/build/runtime-esm/server/utils.js +4 -0
  128. package/package.json +4 -4
@@ -79168,7 +79168,7 @@ export default (props) => (
79168
79168
  import { Cache } from '$houdini/runtime/cache/cache'
79169
79169
  import { serverAdapterFactory, _serverHandler } from '$houdini/runtime/router/server'
79170
79170
  import { HoudiniClient } from '$houdini/runtime/client'
79171
- import { renderToStream } from 'react-streaming/server'
79171
+ import { renderToStream } from '$houdini/plugins/houdini-react/runtime/server'
79172
79172
  import React from 'react'
79173
79173
 
79174
79174
  import { router_cache } from '../../runtime/routing'
@@ -79556,8 +79556,7 @@ var vite_default = {
79556
79556
  output: {
79557
79557
  assetFileNames: "assets/[name].js",
79558
79558
  entryFileNames: "[name].js"
79559
- },
79560
- external: ["react-streaming/server"]
79559
+ }
79561
79560
  }
79562
79561
  };
79563
79562
  await fs_exports.mkdirp(config.compiledAssetsDir);
@@ -79158,7 +79158,7 @@ export default (props) => (
79158
79158
  import { Cache } from '$houdini/runtime/cache/cache'
79159
79159
  import { serverAdapterFactory, _serverHandler } from '$houdini/runtime/router/server'
79160
79160
  import { HoudiniClient } from '$houdini/runtime/client'
79161
- import { renderToStream } from 'react-streaming/server'
79161
+ import { renderToStream } from '$houdini/plugins/houdini-react/runtime/server'
79162
79162
  import React from 'react'
79163
79163
 
79164
79164
  import { router_cache } from '../../runtime/routing'
@@ -79546,8 +79546,7 @@ var vite_default = {
79546
79546
  output: {
79547
79547
  assetFileNames: "assets/[name].js",
79548
79548
  entryFileNames: "[name].js"
79549
- },
79550
- external: ["react-streaming/server"]
79549
+ }
79551
79550
  }
79552
79551
  };
79553
79552
  await fs_exports.mkdirp(config.compiledAssetsDir);
@@ -2,9 +2,10 @@ import type { Cache } from '$houdini/runtime/cache/cache';
2
2
  import { RouterCache } from './routing';
3
3
  export * from './hooks';
4
4
  export { router_cache } from './routing';
5
- export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
5
+ export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, injectToStream, }: {
6
6
  initialURL: string;
7
7
  cache: Cache;
8
8
  session?: App.Session;
9
9
  assetPrefix: string;
10
+ injectToStream?: (chunk: string) => void;
10
11
  } & RouterCache): JSX.Element;
@@ -12,10 +12,11 @@ type ComponentType = any;
12
12
  * It is responsible for loading various page sources (including API fetches) and
13
13
  * then rendering when appropriate.
14
14
  */
15
- export declare function Router({ manifest, initialURL, assetPrefix, }: {
15
+ export declare function Router({ manifest, initialURL, assetPrefix, injectToStream, }: {
16
16
  manifest: RouterManifest<ComponentType>;
17
17
  initialURL?: string;
18
18
  assetPrefix: string;
19
+ injectToStream?: undefined | ((chunk: string) => void);
19
20
  }): JSX.Element;
20
21
  export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
21
22
  children: React.ReactElement;
@@ -0,0 +1,17 @@
1
+ /**
2
+ This directory is largely copied from https://github.com/brillout/react-streaming and adapted to fit the needs of this project. It is subject to the MIT license, found [here](https://github.com/brillout/react-streaming/blob/main/LICENSE.md). Duplicated below for reference:
3
+
4
+ MIT License
5
+
6
+ Copyright (c) 2022-present Romuald Brillout
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ */
14
+ import { renderToStream } from './renderToStream';
15
+ import type { InjectToStream } from './renderToStream/createBuffer';
16
+ export { renderToStream };
17
+ export type { InjectToStream };
@@ -0,0 +1,17 @@
1
+ export { createBuffer };
2
+ export type { InjectToStream };
3
+ export type { StreamOperations };
4
+ type InjectToStream = (chunk: unknown, options?: {
5
+ flush?: boolean;
6
+ }) => void;
7
+ type StreamOperations = {
8
+ operations: null | {
9
+ writeChunk: (chunk: unknown) => void;
10
+ flush: null | (() => void);
11
+ };
12
+ };
13
+ declare function createBuffer(streamOperations: StreamOperations): {
14
+ injectToStream: InjectToStream;
15
+ onBeforeWrite: (chunk: unknown) => void;
16
+ onBeforeEnd: () => void;
17
+ };
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import type { Writable as StreamNodeWritable } from 'stream';
3
+ export { createPipeWrapper };
4
+ export type { Pipe };
5
+ type Pipe = (writable: StreamNodeWritable) => void;
6
+ declare function createPipeWrapper(pipeFromReact: Pipe, { onReactBug }: {
7
+ onReactBug: (err: unknown) => void;
8
+ }): Promise<{
9
+ pipeForUser: Pipe;
10
+ streamEnd: Promise<void>;
11
+ injectToStream: import("./createBuffer").InjectToStream;
12
+ }>;
@@ -0,0 +1,6 @@
1
+ export { createReadableWrapper };
2
+ declare function createReadableWrapper(readableFromReact: ReadableStream): {
3
+ readableForUser: ReadableStream<any>;
4
+ streamEnd: Promise<void>;
5
+ injectToStream: import("./createBuffer").InjectToStream;
6
+ };
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import type { Readable as StreamNodeReadable, Writable as StreamNodeWritable } from 'stream';
3
+ export { loadNodeStreamModule };
4
+ export { nodeStreamModuleIsAvailable };
5
+ type StreamModule = {
6
+ Readable: typeof StreamNodeReadable;
7
+ Writable: typeof StreamNodeWritable;
8
+ };
9
+ declare function loadNodeStreamModule(): Promise<StreamModule>;
10
+ declare function nodeStreamModuleIsAvailable(): Promise<boolean>;
@@ -0,0 +1,9 @@
1
+ export { resolveSeoStrategy };
2
+ export type { SeoStrategy };
3
+ type SeoStrategy = 'conservative' | 'google-speed';
4
+ declare function resolveSeoStrategy(options?: {
5
+ seoStrategy?: SeoStrategy;
6
+ userAgent?: string;
7
+ }): {
8
+ disableStream: boolean;
9
+ };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import type { renderToPipeableStream as RenderToPipeableStream, renderToReadableStream as RenderToReadableStream } from 'react-dom/server';
3
+ import { Pipe } from './renderToStream/createPipeWrapper';
4
+ import { SeoStrategy } from './renderToStream/resolveSeoStrategy';
5
+ export { renderToStream };
6
+ export { disable };
7
+ type Options = {
8
+ webStream?: boolean;
9
+ disable?: boolean;
10
+ seoStrategy?: SeoStrategy;
11
+ userAgent?: string;
12
+ onBoundaryError?: (err: unknown) => void;
13
+ renderToReadableStream?: typeof RenderToReadableStream;
14
+ renderToPipeableStream?: typeof RenderToPipeableStream;
15
+ };
16
+ type Result = ({
17
+ pipe: Pipe;
18
+ readable: null;
19
+ } | {
20
+ pipe: null;
21
+ readable: ReadableStream;
22
+ }) & {
23
+ streamEnd: Promise<boolean>;
24
+ disabled: boolean;
25
+ injectToStream: (chunk: unknown) => void;
26
+ };
27
+ declare function disable(): void;
28
+ declare function renderToStream(element: React.ReactNode, options?: Options): Promise<Result>;
@@ -0,0 +1,8 @@
1
+ export type { InitData };
2
+ export { initDataHtmlClass };
3
+ type InitData = {
4
+ value: unknown;
5
+ key: string;
6
+ elementId: string;
7
+ };
8
+ declare const initDataHtmlClass = "react-streaming_initData";
@@ -0,0 +1,4 @@
1
+ export { stringifyKey };
2
+ export { assertKey };
3
+ declare function stringifyKey(key: unknown): string;
4
+ declare function assertKey(keyValue: unknown): void;
@@ -0,0 +1,3 @@
1
+ export * from '../utils/assert';
2
+ export * from '../utils/getGlobalVariable';
3
+ export * from '../utils/isPromise';
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export { useStream };
3
+ export { StreamProvider };
4
+ export type { StreamUtils };
5
+ type StreamUtils = {
6
+ injectToStream: (htmlChunk: string) => void;
7
+ };
8
+ declare const StreamProvider: React.Provider<StreamUtils | null>;
9
+ declare function useStream(): StreamUtils | null;
@@ -0,0 +1,15 @@
1
+ export { assert };
2
+ export { assertUsage };
3
+ export { assertWarning };
4
+ export { assertInfo };
5
+ export { getProjectError };
6
+ declare function assert(condition: unknown, debugInfo?: unknown): asserts condition;
7
+ declare function assertUsage(condition: unknown, errorMessage: string): asserts condition;
8
+ declare function getProjectError(errorMessage: string): Error;
9
+ declare function assertWarning(condition: unknown, errorMessage: string, { onlyOnce, showStackTrace }: {
10
+ onlyOnce: boolean | string;
11
+ showStackTrace?: true;
12
+ }): void;
13
+ declare function assertInfo(condition: unknown, errorMessage: string, { onlyOnce }: {
14
+ onlyOnce: boolean;
15
+ }): void;
@@ -0,0 +1,2 @@
1
+ export { createErrorWithCleanStackTrace };
2
+ declare function createErrorWithCleanStackTrace(errorMessage: string, numberOfStackTraceLinesToRemove: number): Error;
@@ -0,0 +1,14 @@
1
+ export { createDebugger };
2
+ export { isDebugEnabled };
3
+ export type { Debug };
4
+ type Debug = ReturnType<typeof createDebugger>;
5
+ type Options = {
6
+ serialization?: {
7
+ emptyArray?: string;
8
+ };
9
+ };
10
+ declare function createDebugger(namespace: string, optionsGlobal?: Options): ((msg: string, info?: unknown) => void) & {
11
+ options: (options: Options) => (msg: string, info?: unknown) => void;
12
+ isEnabled: boolean;
13
+ };
14
+ declare function isDebugEnabled(namespace: string): boolean;
@@ -0,0 +1,4 @@
1
+ export declare function getGlobalVariable<T>(key: string, defaultValue: T): T;
2
+ declare global {
3
+ var __react_streaming: Record<string, any>;
4
+ }
@@ -0,0 +1,2 @@
1
+ export { isBrowser };
2
+ declare function isBrowser(): boolean;
@@ -0,0 +1,2 @@
1
+ export { isCallable };
2
+ declare function isCallable<T extends (...args: unknown[]) => unknown>(thing: T | unknown): thing is T;
@@ -0,0 +1,2 @@
1
+ export { isClientSide };
2
+ declare function isClientSide(): boolean;
@@ -0,0 +1 @@
1
+ export declare function isPromise(val: unknown): val is Promise<unknown>;
@@ -0,0 +1,2 @@
1
+ export { isServerSide };
2
+ declare function isServerSide(): boolean;
@@ -0,0 +1,2 @@
1
+ export { objectAssign };
2
+ declare function objectAssign<Obj extends object, ObjAddendum>(obj: Obj, objAddendum: ObjAddendum): asserts obj is Obj & ObjAddendum;
@@ -0,0 +1,10 @@
1
+ export declare const projectInfo: {
2
+ projectName: "react-streaming";
3
+ projectVersion: string;
4
+ npmPackageName: "react-streaming";
5
+ githubRepository: "https://github.com/brillout/react-streaming";
6
+ discordInviteToolChannel: "https://discord.com/invite/H23tjRxFvx";
7
+ };
8
+ declare global {
9
+ var __vite_plugin_ssr__instances: undefined | string[];
10
+ }
@@ -0,0 +1,4 @@
1
+ export * from './utils/assert';
2
+ export * from './utils/debug';
3
+ export * from './utils/isPromise';
4
+ export * from './utils/isBrowser';
@@ -2,9 +2,10 @@ import type { Cache } from '$houdini/runtime/cache/cache';
2
2
  import { RouterCache } from './routing';
3
3
  export * from './hooks';
4
4
  export { router_cache } from './routing';
5
- export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
5
+ export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, injectToStream, }: {
6
6
  initialURL: string;
7
7
  cache: Cache;
8
8
  session?: App.Session;
9
9
  assetPrefix: string;
10
+ injectToStream?: (chunk: string) => void;
10
11
  } & RouterCache): JSX.Element;
@@ -44,7 +44,8 @@ function Router({
44
44
  pending_cache,
45
45
  last_variables,
46
46
  session,
47
- assetPrefix
47
+ assetPrefix,
48
+ injectToStream
48
49
  }) {
49
50
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
50
51
  import_routing.RouterContextProvider,
@@ -57,7 +58,15 @@ function Router({
57
58
  pending_cache,
58
59
  last_variables,
59
60
  session,
60
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_routing.Router, { initialURL, manifest: import_manifest.default, assetPrefix })
61
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
62
+ import_routing.Router,
63
+ {
64
+ initialURL,
65
+ manifest: import_manifest.default,
66
+ assetPrefix,
67
+ injectToStream
68
+ }
69
+ )
61
70
  }
62
71
  );
63
72
  }
@@ -12,10 +12,11 @@ type ComponentType = any;
12
12
  * It is responsible for loading various page sources (including API fetches) and
13
13
  * then rendering when appropriate.
14
14
  */
15
- export declare function Router({ manifest, initialURL, assetPrefix, }: {
15
+ export declare function Router({ manifest, initialURL, assetPrefix, injectToStream, }: {
16
16
  manifest: RouterManifest<ComponentType>;
17
17
  initialURL?: string;
18
18
  assetPrefix: string;
19
+ injectToStream?: undefined | ((chunk: string) => void);
19
20
  }): JSX.Element;
20
21
  export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
21
22
  children: React.ReactElement;
@@ -40,7 +40,6 @@ var import_jsx_runtime = require("react/jsx-runtime");
40
40
  var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
41
41
  var import_match = require("$houdini/runtime/router/match");
42
42
  var import_react = __toESM(require("react"));
43
- var import_react_streaming = require("react-streaming");
44
43
  var import_useDocumentStore = require("../hooks/useDocumentStore");
45
44
  var import_cache = require("./cache");
46
45
  const PreloadWhich = {
@@ -51,7 +50,8 @@ const PreloadWhich = {
51
50
  function Router({
52
51
  manifest,
53
52
  initialURL,
54
- assetPrefix
53
+ assetPrefix,
54
+ injectToStream
55
55
  }) {
56
56
  const [current, setCurrent] = import_react.default.useState(() => {
57
57
  return initialURL || window.location.pathname;
@@ -60,7 +60,8 @@ function Router({
60
60
  const { loadData, loadComponent } = usePageData({
61
61
  page,
62
62
  variables,
63
- assetPrefix
63
+ assetPrefix,
64
+ injectToStream
64
65
  });
65
66
  const { component_cache } = useRouterContext();
66
67
  const PageComponent = component_cache.get(page.id);
@@ -98,7 +99,8 @@ function Router({
98
99
  function usePageData({
99
100
  page,
100
101
  variables,
101
- assetPrefix
102
+ assetPrefix,
103
+ injectToStream
102
104
  }) {
103
105
  const {
104
106
  client,
@@ -109,7 +111,6 @@ function usePageData({
109
111
  pending_cache,
110
112
  last_variables
111
113
  } = useRouterContext();
112
- const stream = (0, import_react_streaming.useStream)();
113
114
  const session = useSession();
114
115
  function load_query({ id, artifact }) {
115
116
  last_variables.set(page.id, variables);
@@ -130,7 +131,7 @@ function usePageData({
130
131
  session
131
132
  }).then(() => {
132
133
  data_cache.set(id, observer);
133
- stream?.injectToStream(`
134
+ injectToStream?.(`
134
135
  <script>
135
136
  window.__houdini__cache__?.hydrate(${cache.serialize()}, window.__houdini__hydration__layer)
136
137
 
@@ -203,7 +204,7 @@ function usePageData({
203
204
  targetPage.documents[artifact_id].artifact().then((mod) => {
204
205
  const artifact = mod.default;
205
206
  artifact_cache.set(artifact_id, artifact);
206
- stream?.injectToStream(`
207
+ injectToStream?.(`
207
208
  <script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""><\/script>
208
209
  `);
209
210
  load_query({ id: artifact.name, artifact });
@@ -0,0 +1,17 @@
1
+ /**
2
+ This directory is largely copied from https://github.com/brillout/react-streaming and adapted to fit the needs of this project. It is subject to the MIT license, found [here](https://github.com/brillout/react-streaming/blob/main/LICENSE.md). Duplicated below for reference:
3
+
4
+ MIT License
5
+
6
+ Copyright (c) 2022-present Romuald Brillout
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ */
14
+ import { renderToStream } from './renderToStream';
15
+ import type { InjectToStream } from './renderToStream/createBuffer';
16
+ export { renderToStream };
17
+ export type { InjectToStream };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var server_exports = {};
20
+ __export(server_exports, {
21
+ renderToStream: () => import_renderToStream.renderToStream
22
+ });
23
+ module.exports = __toCommonJS(server_exports);
24
+ var import_renderToStream = require("./renderToStream");
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ renderToStream
28
+ });
@@ -0,0 +1,17 @@
1
+ export { createBuffer };
2
+ export type { InjectToStream };
3
+ export type { StreamOperations };
4
+ type InjectToStream = (chunk: unknown, options?: {
5
+ flush?: boolean;
6
+ }) => void;
7
+ type StreamOperations = {
8
+ operations: null | {
9
+ writeChunk: (chunk: unknown) => void;
10
+ flush: null | (() => void);
11
+ };
12
+ };
13
+ declare function createBuffer(streamOperations: StreamOperations): {
14
+ injectToStream: InjectToStream;
15
+ onBeforeWrite: (chunk: unknown) => void;
16
+ onBeforeEnd: () => void;
17
+ };
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createBuffer_exports = {};
20
+ __export(createBuffer_exports, {
21
+ createBuffer: () => createBuffer
22
+ });
23
+ module.exports = __toCommonJS(createBuffer_exports);
24
+ var import_utils = require("../utils");
25
+ const debug = (0, import_utils.createDebugger)("react-streaming:buffer");
26
+ function createBuffer(streamOperations) {
27
+ const buffer = [];
28
+ let state = "UNSTARTED";
29
+ let writePermission = null;
30
+ return { injectToStream, onBeforeWrite, onBeforeEnd };
31
+ function injectToStream(chunk, options) {
32
+ (0, import_utils.assertUsage)(
33
+ state !== "ENDED",
34
+ `Cannot inject following chunk after stream has ended: \`${chunk}\``
35
+ );
36
+ if (debug.isEnabled) {
37
+ debug("injectToStream()", String(chunk));
38
+ }
39
+ buffer.push({ chunk, flush: options?.flush });
40
+ flushBuffer();
41
+ }
42
+ function flushBuffer() {
43
+ if (!writePermission) {
44
+ return;
45
+ }
46
+ if (buffer.length === 0) {
47
+ return;
48
+ }
49
+ if (state !== "STREAMING") {
50
+ (0, import_utils.assert)(state === "UNSTARTED");
51
+ return;
52
+ }
53
+ let flushStream = false;
54
+ buffer.forEach((bufferEntry) => {
55
+ (0, import_utils.assert)(streamOperations.operations);
56
+ const { writeChunk } = streamOperations.operations;
57
+ writeChunk(bufferEntry.chunk);
58
+ if (bufferEntry.flush) {
59
+ flushStream = true;
60
+ }
61
+ });
62
+ buffer.length = 0;
63
+ (0, import_utils.assert)(streamOperations.operations);
64
+ if (flushStream && streamOperations.operations.flush !== null) {
65
+ streamOperations.operations.flush();
66
+ debug("stream flushed");
67
+ }
68
+ }
69
+ function onBeforeWrite(chunk) {
70
+ state === "UNSTARTED" && debug(">>> START");
71
+ if (debug.isEnabled) {
72
+ debug(`react write${!writePermission ? "" : " (allowed)"}`, String(chunk));
73
+ }
74
+ state = "STREAMING";
75
+ if (writePermission) {
76
+ flushBuffer();
77
+ }
78
+ if (writePermission == true || writePermission === null) {
79
+ writePermission = false;
80
+ debug("writePermission =", writePermission);
81
+ setTimeout(() => {
82
+ debug(">>> setTimeout()");
83
+ writePermission = true;
84
+ debug("writePermission =", writePermission);
85
+ flushBuffer();
86
+ });
87
+ }
88
+ }
89
+ function onBeforeEnd() {
90
+ writePermission = true;
91
+ debug("writePermission =", writePermission);
92
+ flushBuffer();
93
+ (0, import_utils.assert)(buffer.length === 0);
94
+ state = "ENDED";
95
+ debug(">>> END");
96
+ }
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ createBuffer
101
+ });
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import type { Writable as StreamNodeWritable } from 'stream';
3
+ export { createPipeWrapper };
4
+ export type { Pipe };
5
+ type Pipe = (writable: StreamNodeWritable) => void;
6
+ declare function createPipeWrapper(pipeFromReact: Pipe, { onReactBug }: {
7
+ onReactBug: (err: unknown) => void;
8
+ }): Promise<{
9
+ pipeForUser: Pipe;
10
+ streamEnd: Promise<void>;
11
+ injectToStream: import("./createBuffer").InjectToStream;
12
+ }>;