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.
- package/build/plugin-cjs/index.js +2 -3
- package/build/plugin-esm/index.js +2 -3
- package/build/runtime/index.d.ts +2 -1
- package/build/runtime/routing/Router.d.ts +2 -1
- package/build/runtime/server/index.d.ts +17 -0
- package/build/runtime/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime/server/renderToStream.d.ts +28 -0
- package/build/runtime/server/shared/initData.d.ts +8 -0
- package/build/runtime/server/shared/key.d.ts +4 -0
- package/build/runtime/server/shared/utils.d.ts +3 -0
- package/build/runtime/server/useStream.d.ts +9 -0
- package/build/runtime/server/utils/assert.d.ts +15 -0
- package/build/runtime/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime/server/utils/debug.d.ts +14 -0
- package/build/runtime/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime/server/utils/isCallable.d.ts +2 -0
- package/build/runtime/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime/server/utils/isPromise.d.ts +1 -0
- package/build/runtime/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime/server/utils.d.ts +4 -0
- package/build/runtime-cjs/index.d.ts +2 -1
- package/build/runtime-cjs/index.js +11 -2
- package/build/runtime-cjs/routing/Router.d.ts +2 -1
- package/build/runtime-cjs/routing/Router.js +8 -7
- package/build/runtime-cjs/server/index.d.ts +17 -0
- package/build/runtime-cjs/server/index.js +28 -0
- package/build/runtime-cjs/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime-cjs/server/renderToStream/createBuffer.js +101 -0
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.js +90 -0
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.js +85 -0
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.js +51 -0
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.js +44 -0
- package/build/runtime-cjs/server/renderToStream.d.ts +28 -0
- package/build/runtime-cjs/server/renderToStream.js +183 -0
- package/build/runtime-cjs/server/shared/initData.d.ts +8 -0
- package/build/runtime-cjs/server/shared/initData.js +28 -0
- package/build/runtime-cjs/server/shared/key.d.ts +4 -0
- package/build/runtime-cjs/server/shared/key.js +45 -0
- package/build/runtime-cjs/server/shared/utils.d.ts +3 -0
- package/build/runtime-cjs/server/shared/utils.js +20 -0
- package/build/runtime-cjs/server/useStream.d.ts +9 -0
- package/build/runtime-cjs/server/useStream.js +44 -0
- package/build/runtime-cjs/server/utils/assert.d.ts +15 -0
- package/build/runtime-cjs/server/utils/assert.js +119 -0
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.js +62 -0
- package/build/runtime-cjs/server/utils/debug.d.ts +14 -0
- package/build/runtime-cjs/server/utils/debug.js +112 -0
- package/build/runtime-cjs/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime-cjs/server/utils/getGlobalVariable.js +32 -0
- package/build/runtime-cjs/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isBrowser.js +30 -0
- package/build/runtime-cjs/server/utils/isCallable.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isCallable.js +30 -0
- package/build/runtime-cjs/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isClientSide.js +30 -0
- package/build/runtime-cjs/server/utils/isPromise.d.ts +1 -0
- package/build/runtime-cjs/server/utils/isPromise.js +31 -0
- package/build/runtime-cjs/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isServerSide.js +31 -0
- package/build/runtime-cjs/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime-cjs/server/utils/objectAssign.js +30 -0
- package/build/runtime-cjs/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime-cjs/server/utils/projectInfo.js +37 -0
- package/build/runtime-cjs/server/utils.d.ts +4 -0
- package/build/runtime-cjs/server/utils.js +21 -0
- package/build/runtime-esm/index.d.ts +2 -1
- package/build/runtime-esm/index.js +11 -2
- package/build/runtime-esm/routing/Router.d.ts +2 -1
- package/build/runtime-esm/routing/Router.js +8 -7
- package/build/runtime-esm/server/index.d.ts +17 -0
- package/build/runtime-esm/server/index.js +4 -0
- package/build/runtime-esm/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime-esm/server/renderToStream/createBuffer.js +77 -0
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.js +66 -0
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.js +61 -0
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.js +20 -0
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.js +20 -0
- package/build/runtime-esm/server/renderToStream.d.ts +28 -0
- package/build/runtime-esm/server/renderToStream.js +152 -0
- package/build/runtime-esm/server/shared/initData.d.ts +8 -0
- package/build/runtime-esm/server/shared/initData.js +4 -0
- package/build/runtime-esm/server/shared/key.d.ts +4 -0
- package/build/runtime-esm/server/shared/key.js +20 -0
- package/build/runtime-esm/server/shared/utils.d.ts +3 -0
- package/build/runtime-esm/server/shared/utils.js +3 -0
- package/build/runtime-esm/server/useStream.d.ts +9 -0
- package/build/runtime-esm/server/useStream.js +13 -0
- package/build/runtime-esm/server/utils/assert.d.ts +15 -0
- package/build/runtime-esm/server/utils/assert.js +91 -0
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.js +38 -0
- package/build/runtime-esm/server/utils/debug.d.ts +14 -0
- package/build/runtime-esm/server/utils/debug.js +87 -0
- package/build/runtime-esm/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime-esm/server/utils/getGlobalVariable.js +8 -0
- package/build/runtime-esm/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime-esm/server/utils/isBrowser.js +6 -0
- package/build/runtime-esm/server/utils/isCallable.d.ts +2 -0
- package/build/runtime-esm/server/utils/isCallable.js +6 -0
- package/build/runtime-esm/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime-esm/server/utils/isClientSide.js +6 -0
- package/build/runtime-esm/server/utils/isPromise.d.ts +1 -0
- package/build/runtime-esm/server/utils/isPromise.js +7 -0
- package/build/runtime-esm/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime-esm/server/utils/isServerSide.js +7 -0
- package/build/runtime-esm/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime-esm/server/utils/objectAssign.js +6 -0
- package/build/runtime-esm/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime-esm/server/utils/projectInfo.js +13 -0
- package/build/runtime-esm/server/utils.d.ts +4 -0
- package/build/runtime-esm/server/utils.js +4 -0
- 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
|
|
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
|
|
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);
|
package/build/runtime/index.d.ts
CHANGED
|
@@ -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,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,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,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,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 @@
|
|
|
1
|
+
export declare function isPromise(val: unknown): val is Promise<unknown>;
|
|
@@ -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
|
+
}
|
|
@@ -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)(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}>;
|