houdini-react 1.2.26 → 1.2.28
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/codegen/entries/documentWrappers.d.ts +6 -0
- package/build/plugin/codegen/{entries.d.ts → entries/fallbacks.d.ts} +2 -2
- package/build/plugin/codegen/entries/index.d.ts +16 -0
- package/build/plugin/codegen/entries/pages.d.ts +2 -0
- package/build/plugin/codegen/index.d.ts +6 -2
- package/build/plugin/codegen/render.d.ts +3 -1
- package/build/plugin/vite.d.ts +3 -2
- package/build/plugin-cjs/index.js +1629 -970
- package/build/plugin-esm/index.js +1629 -970
- package/build/runtime/componentFields.d.ts +9 -0
- package/build/runtime/index.d.ts +3 -1
- package/build/runtime/routing/Router.d.ts +6 -5
- package/build/runtime-cjs/componentFields.d.ts +9 -0
- package/build/runtime-cjs/componentFields.js +83 -0
- package/build/runtime-cjs/index.d.ts +3 -1
- package/build/runtime-cjs/index.js +2 -2
- package/build/runtime-cjs/routing/Router.d.ts +6 -5
- package/build/runtime-cjs/routing/Router.js +113 -68
- package/build/runtime-esm/componentFields.d.ts +9 -0
- package/build/runtime-esm/componentFields.js +59 -0
- package/build/runtime-esm/index.d.ts +3 -1
- package/build/runtime-esm/index.js +2 -2
- package/build/runtime-esm/routing/Router.d.ts +6 -5
- package/build/runtime-esm/routing/Router.js +113 -68
- package/build/server/index.d.ts +1 -0
- package/build/{runtime-cjs/server → server-cjs}/index.js +2 -2
- package/build/server-cjs/package.json +1 -0
- package/build/server-esm/index.js +4 -0
- package/build/server-esm/package.json +1 -0
- package/package.json +17 -7
- package/build/runtime/server/index.d.ts +0 -17
- package/build/runtime/server/renderToStream/createBuffer.d.ts +0 -17
- package/build/runtime/server/renderToStream/createPipeWrapper.d.ts +0 -12
- package/build/runtime/server/renderToStream/createReadableWrapper.d.ts +0 -6
- package/build/runtime/server/renderToStream/loadNodeStreamModule.d.ts +0 -10
- package/build/runtime/server/renderToStream/resolveSeoStrategy.d.ts +0 -9
- package/build/runtime/server/renderToStream.d.ts +0 -28
- package/build/runtime/server/shared/initData.d.ts +0 -8
- package/build/runtime/server/shared/key.d.ts +0 -4
- package/build/runtime/server/shared/utils.d.ts +0 -3
- package/build/runtime/server/useStream.d.ts +0 -9
- package/build/runtime/server/utils/assert.d.ts +0 -15
- package/build/runtime/server/utils/createErrorWithCleanStackTrace.d.ts +0 -2
- package/build/runtime/server/utils/debug.d.ts +0 -14
- package/build/runtime/server/utils/getGlobalVariable.d.ts +0 -4
- package/build/runtime/server/utils/isBrowser.d.ts +0 -2
- package/build/runtime/server/utils/isCallable.d.ts +0 -2
- package/build/runtime/server/utils/isClientSide.d.ts +0 -2
- package/build/runtime/server/utils/isPromise.d.ts +0 -1
- package/build/runtime/server/utils/isServerSide.d.ts +0 -2
- package/build/runtime/server/utils/objectAssign.d.ts +0 -2
- package/build/runtime/server/utils/projectInfo.d.ts +0 -10
- package/build/runtime/server/utils.d.ts +0 -4
- package/build/runtime-cjs/server/index.d.ts +0 -17
- package/build/runtime-cjs/server/renderToStream/createBuffer.d.ts +0 -17
- package/build/runtime-cjs/server/renderToStream/createBuffer.js +0 -101
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.d.ts +0 -12
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.js +0 -90
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.d.ts +0 -6
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.js +0 -85
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.d.ts +0 -10
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.js +0 -51
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.d.ts +0 -9
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.js +0 -44
- package/build/runtime-cjs/server/renderToStream.d.ts +0 -28
- package/build/runtime-cjs/server/renderToStream.js +0 -183
- package/build/runtime-cjs/server/shared/initData.d.ts +0 -8
- package/build/runtime-cjs/server/shared/initData.js +0 -28
- package/build/runtime-cjs/server/shared/key.d.ts +0 -4
- package/build/runtime-cjs/server/shared/key.js +0 -45
- package/build/runtime-cjs/server/shared/utils.d.ts +0 -3
- package/build/runtime-cjs/server/shared/utils.js +0 -20
- package/build/runtime-cjs/server/useStream.d.ts +0 -9
- package/build/runtime-cjs/server/useStream.js +0 -44
- package/build/runtime-cjs/server/utils/assert.d.ts +0 -15
- package/build/runtime-cjs/server/utils/assert.js +0 -119
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.d.ts +0 -2
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.js +0 -62
- package/build/runtime-cjs/server/utils/debug.d.ts +0 -14
- package/build/runtime-cjs/server/utils/debug.js +0 -112
- package/build/runtime-cjs/server/utils/getGlobalVariable.d.ts +0 -4
- package/build/runtime-cjs/server/utils/getGlobalVariable.js +0 -32
- package/build/runtime-cjs/server/utils/isBrowser.d.ts +0 -2
- package/build/runtime-cjs/server/utils/isBrowser.js +0 -30
- package/build/runtime-cjs/server/utils/isCallable.d.ts +0 -2
- package/build/runtime-cjs/server/utils/isCallable.js +0 -30
- package/build/runtime-cjs/server/utils/isClientSide.d.ts +0 -2
- package/build/runtime-cjs/server/utils/isClientSide.js +0 -30
- package/build/runtime-cjs/server/utils/isPromise.d.ts +0 -1
- package/build/runtime-cjs/server/utils/isPromise.js +0 -31
- package/build/runtime-cjs/server/utils/isServerSide.d.ts +0 -2
- package/build/runtime-cjs/server/utils/isServerSide.js +0 -31
- package/build/runtime-cjs/server/utils/objectAssign.d.ts +0 -2
- package/build/runtime-cjs/server/utils/objectAssign.js +0 -30
- package/build/runtime-cjs/server/utils/projectInfo.d.ts +0 -10
- package/build/runtime-cjs/server/utils/projectInfo.js +0 -37
- package/build/runtime-cjs/server/utils.d.ts +0 -4
- package/build/runtime-cjs/server/utils.js +0 -21
- package/build/runtime-esm/server/index.d.ts +0 -17
- package/build/runtime-esm/server/index.js +0 -4
- package/build/runtime-esm/server/renderToStream/createBuffer.d.ts +0 -17
- package/build/runtime-esm/server/renderToStream/createBuffer.js +0 -77
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.d.ts +0 -12
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.js +0 -66
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.d.ts +0 -6
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.js +0 -61
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.d.ts +0 -10
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.js +0 -20
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.d.ts +0 -9
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.js +0 -20
- package/build/runtime-esm/server/renderToStream.d.ts +0 -28
- package/build/runtime-esm/server/renderToStream.js +0 -152
- package/build/runtime-esm/server/shared/initData.d.ts +0 -8
- package/build/runtime-esm/server/shared/initData.js +0 -4
- package/build/runtime-esm/server/shared/key.d.ts +0 -4
- package/build/runtime-esm/server/shared/key.js +0 -20
- package/build/runtime-esm/server/shared/utils.d.ts +0 -3
- package/build/runtime-esm/server/shared/utils.js +0 -3
- package/build/runtime-esm/server/useStream.d.ts +0 -9
- package/build/runtime-esm/server/useStream.js +0 -13
- package/build/runtime-esm/server/utils/assert.d.ts +0 -15
- package/build/runtime-esm/server/utils/assert.js +0 -91
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.d.ts +0 -2
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.js +0 -38
- package/build/runtime-esm/server/utils/debug.d.ts +0 -14
- package/build/runtime-esm/server/utils/debug.js +0 -87
- package/build/runtime-esm/server/utils/getGlobalVariable.d.ts +0 -4
- package/build/runtime-esm/server/utils/getGlobalVariable.js +0 -8
- package/build/runtime-esm/server/utils/isBrowser.d.ts +0 -2
- package/build/runtime-esm/server/utils/isBrowser.js +0 -6
- package/build/runtime-esm/server/utils/isCallable.d.ts +0 -2
- package/build/runtime-esm/server/utils/isCallable.js +0 -6
- package/build/runtime-esm/server/utils/isClientSide.d.ts +0 -2
- package/build/runtime-esm/server/utils/isClientSide.js +0 -6
- package/build/runtime-esm/server/utils/isPromise.d.ts +0 -1
- package/build/runtime-esm/server/utils/isPromise.js +0 -7
- package/build/runtime-esm/server/utils/isServerSide.d.ts +0 -2
- package/build/runtime-esm/server/utils/isServerSide.js +0 -7
- package/build/runtime-esm/server/utils/objectAssign.d.ts +0 -2
- package/build/runtime-esm/server/utils/objectAssign.js +0 -6
- package/build/runtime-esm/server/utils/projectInfo.d.ts +0 -10
- package/build/runtime-esm/server/utils/projectInfo.js +0 -13
- package/build/runtime-esm/server/utils.d.ts +0 -4
- package/build/runtime-esm/server/utils.js +0 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
+
import type { DocumentArtifact, GraphQLValue } from 'houdini';
|
|
3
|
+
export declare function injectComponents({ cache, selection, data, variables, parentType, }: {
|
|
4
|
+
cache: Cache;
|
|
5
|
+
selection: DocumentArtifact['selection'];
|
|
6
|
+
data: GraphQLValue | null;
|
|
7
|
+
variables: Record<string, GraphQLValue> | undefined | null;
|
|
8
|
+
parentType?: string;
|
|
9
|
+
}): void;
|
package/build/runtime/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { GraphQLObject } from '$houdini/lib/types';
|
|
1
2
|
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
3
|
import { RouterCache } from './routing';
|
|
3
4
|
export * from './hooks';
|
|
4
5
|
export { router_cache } from './routing';
|
|
5
|
-
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache,
|
|
6
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, ssr_signals, last_variables, session, assetPrefix, injectToStream, }: {
|
|
6
7
|
initialURL: string;
|
|
8
|
+
initialVariables: GraphQLObject;
|
|
7
9
|
cache: Cache;
|
|
8
10
|
session?: App.Session;
|
|
9
11
|
assetPrefix: string;
|
|
@@ -18,14 +18,14 @@ export declare function Router({ manifest, initialURL, assetPrefix, injectToStre
|
|
|
18
18
|
assetPrefix: string;
|
|
19
19
|
injectToStream?: undefined | ((chunk: string) => void);
|
|
20
20
|
}): JSX.Element;
|
|
21
|
-
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache,
|
|
21
|
+
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, ssr_signals, last_variables, session: ssrSession, }: {
|
|
22
22
|
children: React.ReactElement;
|
|
23
23
|
client: HoudiniClient;
|
|
24
24
|
cache: Cache;
|
|
25
25
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
26
26
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
27
27
|
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
28
|
-
|
|
28
|
+
ssr_signals: PendingCache;
|
|
29
29
|
last_variables: LRUCache<GraphQLVariables>;
|
|
30
30
|
session?: App.Session;
|
|
31
31
|
}): JSX.Element;
|
|
@@ -35,7 +35,7 @@ type RouterContext = {
|
|
|
35
35
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
36
36
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
37
37
|
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
38
|
-
|
|
38
|
+
ssr_signals: PendingCache;
|
|
39
39
|
last_variables: LRUCache<GraphQLVariables>;
|
|
40
40
|
session: App.Session;
|
|
41
41
|
};
|
|
@@ -55,13 +55,14 @@ export type RouterCache = {
|
|
|
55
55
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
56
56
|
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
57
57
|
last_variables: LRUCache<GraphQLVariables>;
|
|
58
|
-
|
|
58
|
+
ssr_signals: PendingCache;
|
|
59
59
|
};
|
|
60
|
-
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
|
|
60
|
+
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialVariables, initialArtifacts, }?: {
|
|
61
61
|
pending_queries?: string[];
|
|
62
62
|
artifacts?: Record<string, QueryArtifact>;
|
|
63
63
|
components?: Record<string, (props: any) => React.ReactElement>;
|
|
64
64
|
initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
65
|
+
initialVariables?: Record<string, GraphQLVariables>;
|
|
65
66
|
initialArtifacts?: Record<string, QueryArtifact>;
|
|
66
67
|
}): RouterCache;
|
|
67
68
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
+
import type { DocumentArtifact, GraphQLValue } from 'houdini';
|
|
3
|
+
export declare function injectComponents({ cache, selection, data, variables, parentType, }: {
|
|
4
|
+
cache: Cache;
|
|
5
|
+
selection: DocumentArtifact['selection'];
|
|
6
|
+
data: GraphQLValue | null;
|
|
7
|
+
variables: Record<string, GraphQLValue> | undefined | null;
|
|
8
|
+
parentType?: string;
|
|
9
|
+
}): void;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 componentFields_exports = {};
|
|
20
|
+
__export(componentFields_exports, {
|
|
21
|
+
injectComponents: () => injectComponents
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(componentFields_exports);
|
|
24
|
+
var import_cache = require("$houdini/runtime/cache/cache");
|
|
25
|
+
var import_selection = require("$houdini/runtime/lib/selection");
|
|
26
|
+
function injectComponents({
|
|
27
|
+
cache,
|
|
28
|
+
selection,
|
|
29
|
+
data,
|
|
30
|
+
variables,
|
|
31
|
+
parentType = "Query"
|
|
32
|
+
}) {
|
|
33
|
+
if (data === null) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (typeof data !== "object") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(data)) {
|
|
40
|
+
data.forEach(
|
|
41
|
+
(item) => injectComponents({
|
|
42
|
+
cache,
|
|
43
|
+
selection,
|
|
44
|
+
data: item,
|
|
45
|
+
variables,
|
|
46
|
+
parentType
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const typename = data["__typename"];
|
|
52
|
+
const fields = (0, import_selection.getFieldsForType)(selection, typename, false);
|
|
53
|
+
if (!fields) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const [field, subSelection] of Object.entries(fields)) {
|
|
57
|
+
if (subSelection.component) {
|
|
58
|
+
if (!cache._internal_unstable.componentCache[subSelection.component.key]) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
data[field] = (0, import_cache.defaultComponentField)({
|
|
62
|
+
variables,
|
|
63
|
+
parent: cache._internal_unstable.id(parentType, data) ?? "",
|
|
64
|
+
cache,
|
|
65
|
+
component: subSelection.component
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const dataValue = data[field];
|
|
69
|
+
if (subSelection.selection) {
|
|
70
|
+
injectComponents({
|
|
71
|
+
cache,
|
|
72
|
+
selection: subSelection.selection,
|
|
73
|
+
data: dataValue,
|
|
74
|
+
variables,
|
|
75
|
+
parentType: subSelection.type
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
injectComponents
|
|
83
|
+
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { GraphQLObject } from '$houdini/lib/types';
|
|
1
2
|
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
3
|
import { RouterCache } from './routing';
|
|
3
4
|
export * from './hooks';
|
|
4
5
|
export { router_cache } from './routing';
|
|
5
|
-
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache,
|
|
6
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, ssr_signals, last_variables, session, assetPrefix, injectToStream, }: {
|
|
6
7
|
initialURL: string;
|
|
8
|
+
initialVariables: GraphQLObject;
|
|
7
9
|
cache: Cache;
|
|
8
10
|
session?: App.Session;
|
|
9
11
|
assetPrefix: string;
|
|
@@ -41,7 +41,7 @@ function Router({
|
|
|
41
41
|
artifact_cache,
|
|
42
42
|
component_cache,
|
|
43
43
|
data_cache,
|
|
44
|
-
|
|
44
|
+
ssr_signals,
|
|
45
45
|
last_variables,
|
|
46
46
|
session,
|
|
47
47
|
assetPrefix,
|
|
@@ -55,7 +55,7 @@ function Router({
|
|
|
55
55
|
artifact_cache,
|
|
56
56
|
component_cache,
|
|
57
57
|
data_cache,
|
|
58
|
-
|
|
58
|
+
ssr_signals,
|
|
59
59
|
last_variables,
|
|
60
60
|
session,
|
|
61
61
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -18,14 +18,14 @@ export declare function Router({ manifest, initialURL, assetPrefix, injectToStre
|
|
|
18
18
|
assetPrefix: string;
|
|
19
19
|
injectToStream?: undefined | ((chunk: string) => void);
|
|
20
20
|
}): JSX.Element;
|
|
21
|
-
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache,
|
|
21
|
+
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, ssr_signals, last_variables, session: ssrSession, }: {
|
|
22
22
|
children: React.ReactElement;
|
|
23
23
|
client: HoudiniClient;
|
|
24
24
|
cache: Cache;
|
|
25
25
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
26
26
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
27
27
|
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
28
|
-
|
|
28
|
+
ssr_signals: PendingCache;
|
|
29
29
|
last_variables: LRUCache<GraphQLVariables>;
|
|
30
30
|
session?: App.Session;
|
|
31
31
|
}): JSX.Element;
|
|
@@ -35,7 +35,7 @@ type RouterContext = {
|
|
|
35
35
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
36
36
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
37
37
|
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
38
|
-
|
|
38
|
+
ssr_signals: PendingCache;
|
|
39
39
|
last_variables: LRUCache<GraphQLVariables>;
|
|
40
40
|
session: App.Session;
|
|
41
41
|
};
|
|
@@ -55,13 +55,14 @@ export type RouterCache = {
|
|
|
55
55
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
56
56
|
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
57
57
|
last_variables: LRUCache<GraphQLVariables>;
|
|
58
|
-
|
|
58
|
+
ssr_signals: PendingCache;
|
|
59
59
|
};
|
|
60
|
-
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
|
|
60
|
+
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialVariables, initialArtifacts, }?: {
|
|
61
61
|
pending_queries?: string[];
|
|
62
62
|
artifacts?: Record<string, QueryArtifact>;
|
|
63
63
|
components?: Record<string, (props: any) => React.ReactElement>;
|
|
64
64
|
initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
65
|
+
initialVariables?: Record<string, GraphQLVariables>;
|
|
65
66
|
initialArtifacts?: Record<string, QueryArtifact>;
|
|
66
67
|
}): RouterCache;
|
|
67
68
|
export {};
|
|
@@ -53,10 +53,10 @@ function Router({
|
|
|
53
53
|
assetPrefix,
|
|
54
54
|
injectToStream
|
|
55
55
|
}) {
|
|
56
|
-
const [
|
|
56
|
+
const [currentURL, setCurrentURL] = import_react.default.useState(() => {
|
|
57
57
|
return initialURL || window.location.pathname;
|
|
58
58
|
});
|
|
59
|
-
const [page, variables] = (0, import_match.find_match)(manifest,
|
|
59
|
+
const [page, variables] = (0, import_match.find_match)(manifest, currentURL);
|
|
60
60
|
const { loadData, loadComponent } = usePageData({
|
|
61
61
|
page,
|
|
62
62
|
variables,
|
|
@@ -66,16 +66,16 @@ function Router({
|
|
|
66
66
|
const { component_cache } = useRouterContext();
|
|
67
67
|
const PageComponent = component_cache.get(page.id);
|
|
68
68
|
import_react.default.useEffect(() => {
|
|
69
|
-
if (globalThis.window && window.location.pathname !==
|
|
70
|
-
window.history.pushState({}, "",
|
|
69
|
+
if (globalThis.window && window.location.pathname !== currentURL) {
|
|
70
|
+
window.history.pushState({}, "", currentURL);
|
|
71
71
|
}
|
|
72
|
-
}, [
|
|
72
|
+
}, [currentURL]);
|
|
73
73
|
import_react.default.useEffect(() => {
|
|
74
74
|
if (!globalThis.window) {
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
const onChange = (evt) => {
|
|
78
|
-
|
|
78
|
+
setCurrentURL(window.location.pathname);
|
|
79
79
|
};
|
|
80
80
|
window.addEventListener("popstate", onChange);
|
|
81
81
|
return () => {
|
|
@@ -83,7 +83,9 @@ function Router({
|
|
|
83
83
|
};
|
|
84
84
|
}, []);
|
|
85
85
|
useLinkBehavior({
|
|
86
|
-
goto:
|
|
86
|
+
goto: (val) => {
|
|
87
|
+
setCurrentURL(val);
|
|
88
|
+
},
|
|
87
89
|
preload(url, which) {
|
|
88
90
|
const [page2, variables2] = (0, import_match.find_match)(manifest, url);
|
|
89
91
|
if (["both", "component"].includes(which)) {
|
|
@@ -94,7 +96,7 @@ function Router({
|
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VariableContext.Provider, { value: variables, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageComponent, { url:
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VariableContext.Provider, { value: variables, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageComponent, { url: currentURL }, page.id) });
|
|
98
100
|
}
|
|
99
101
|
function usePageData({
|
|
100
102
|
page,
|
|
@@ -108,14 +110,18 @@ function usePageData({
|
|
|
108
110
|
data_cache,
|
|
109
111
|
component_cache,
|
|
110
112
|
artifact_cache,
|
|
111
|
-
|
|
113
|
+
ssr_signals,
|
|
112
114
|
last_variables
|
|
113
115
|
} = useRouterContext();
|
|
114
116
|
const session = useSession();
|
|
115
117
|
function load_query({ id, artifact }) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
for (const artifact2 of Object.keys(page.documents)) {
|
|
119
|
+
last_variables.set(artifact2, variables);
|
|
120
|
+
}
|
|
121
|
+
console.log("loading query", artifact.name);
|
|
122
|
+
if (ssr_signals.has(id)) {
|
|
123
|
+
console.log("using ssr signal", id);
|
|
124
|
+
return ssr_signals.get(id);
|
|
119
125
|
}
|
|
120
126
|
const observer = client.observe({ artifact, cache });
|
|
121
127
|
let resolve = () => {
|
|
@@ -125,71 +131,102 @@ function usePageData({
|
|
|
125
131
|
const promise = new Promise((res, rej) => {
|
|
126
132
|
resolve = res;
|
|
127
133
|
reject = rej;
|
|
134
|
+
console.log("sending query", id, variables);
|
|
128
135
|
observer.send({
|
|
129
136
|
variables,
|
|
130
137
|
cacheParams: { disableSubscriptions: true },
|
|
131
138
|
session
|
|
132
139
|
}).then(() => {
|
|
140
|
+
console.log("resolved query", id, variables);
|
|
133
141
|
data_cache.set(id, observer);
|
|
134
142
|
injectToStream?.(`
|
|
135
143
|
<script>
|
|
136
|
-
|
|
144
|
+
{
|
|
145
|
+
window.__houdini__cache__?.hydrate(${cache.serialize()}, window.__houdini__hydration__layer)
|
|
137
146
|
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
const artifactName = "${artifact.name}"
|
|
148
|
+
const value = ${JSON.stringify(observer.state.data)}
|
|
140
149
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
// if the data is pending, we need to resolve it
|
|
151
|
+
if (window.__houdini__nav_caches__?.data_cache.has(artifactName)) {
|
|
152
|
+
// before we resolve the pending signals,
|
|
153
|
+
// fill the data cache with values we got on the server
|
|
154
|
+
const new_store = window.__houdini__client__.observe({
|
|
155
|
+
artifact: window.__houdini__nav_caches__.artifact_cache.get(artifactName),
|
|
156
|
+
cache: window.__houdini__cache__,
|
|
157
|
+
initialValue: value,
|
|
158
|
+
})
|
|
150
159
|
|
|
151
|
-
|
|
152
|
-
|
|
160
|
+
window.__houdini__nav_caches__?.data_cache.set(artifactName, new_store)
|
|
161
|
+
}
|
|
153
162
|
|
|
154
163
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
// if there are no data caches available we need to populate the pending one instead
|
|
165
|
+
if (!window.__houdini__nav_caches__) {
|
|
166
|
+
if (!window.__houdini__pending_data__) {
|
|
167
|
+
window.__houdini__pending_data__ = {}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!window.__houdini__pending_variables__) {
|
|
171
|
+
window.__houdini__pending_variables__ = {}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!window.__houdini__pending_artifacts__) {
|
|
175
|
+
window.__houdini__pending_artifacts__ = {}
|
|
176
|
+
}
|
|
160
177
|
|
|
161
|
-
|
|
162
|
-
window.
|
|
178
|
+
window.__houdini__pending_variables__[artifactName] = ${JSON.stringify(variables)}
|
|
179
|
+
window.__houdini__pending_data__[artifactName] = value
|
|
180
|
+
window.__houdini__pending_artifacts__[artifactName] = ${JSON.stringify(artifact)}
|
|
163
181
|
}
|
|
164
182
|
|
|
165
|
-
|
|
166
|
-
window.
|
|
167
|
-
|
|
183
|
+
// if this payload finishes off an ssr request, we need to resolve the signal
|
|
184
|
+
if (window.__houdini__nav_caches__?.ssr_signals.has(artifactName)) {
|
|
185
|
+
|
|
186
|
+
// if the data showed up on the client before
|
|
187
|
+
if (window.__houdini__nav_caches__.data_cache.has(artifactName)) {
|
|
188
|
+
// we're pushing this store onto the client, it should be initialized
|
|
189
|
+
window.__houdini__nav_caches__.data_cache.get(artifactName).send({
|
|
190
|
+
setup: true,
|
|
191
|
+
variables: ${JSON.stringify(variables)}
|
|
192
|
+
})
|
|
193
|
+
}
|
|
168
194
|
|
|
169
|
-
if (window.__houdini__nav_caches__?.pending_cache.has(artifactName)) {
|
|
170
|
-
// we're pushing this store onto the client, it should be initialized
|
|
171
|
-
new_store.send({
|
|
172
|
-
setup: true,
|
|
173
|
-
variables: ${JSON.stringify(variables)}
|
|
174
|
-
})
|
|
175
195
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
196
|
+
console.log('clearing ssr signal', artifactName)
|
|
197
|
+
// trigger the signal
|
|
198
|
+
window.__houdini__nav_caches__.ssr_signals.get(artifactName).resolve()
|
|
199
|
+
window.__houdini__nav_caches__.ssr_signals.delete(artifactName)
|
|
200
|
+
}
|
|
179
201
|
}
|
|
180
202
|
<\/script>
|
|
181
203
|
`);
|
|
182
204
|
resolve();
|
|
183
|
-
}).catch(reject)
|
|
184
|
-
pending_cache.delete(id);
|
|
185
|
-
});
|
|
205
|
+
}).catch(reject);
|
|
186
206
|
});
|
|
187
|
-
|
|
188
|
-
|
|
207
|
+
const resolvable = { ...promise, resolve, reject };
|
|
208
|
+
if (!globalThis.window) {
|
|
209
|
+
console.log("setting ssr signal");
|
|
210
|
+
ssr_signals.set(id, resolvable);
|
|
211
|
+
}
|
|
212
|
+
return resolvable;
|
|
189
213
|
}
|
|
190
214
|
function loadData(targetPage, variables2) {
|
|
191
|
-
|
|
192
|
-
|
|
215
|
+
for (const [artifact, { variables: pageVariables }] of Object.entries(
|
|
216
|
+
targetPage.documents
|
|
217
|
+
)) {
|
|
218
|
+
if (!last_variables.has(artifact)) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
let last = {};
|
|
222
|
+
let usedVariables = {};
|
|
223
|
+
for (const variable of pageVariables) {
|
|
224
|
+
last[variable] = last_variables.get(artifact)[variable];
|
|
225
|
+
usedVariables[variable] = (variables2 ?? {})[variable];
|
|
226
|
+
}
|
|
227
|
+
if (Object.keys(usedVariables ?? {}).length > 0 && !(0, import_deepEquals.deepEquals)(last, usedVariables)) {
|
|
228
|
+
data_cache.delete(artifact);
|
|
229
|
+
}
|
|
193
230
|
}
|
|
194
231
|
const missing_artifacts = [];
|
|
195
232
|
const found_artifacts = {};
|
|
@@ -241,7 +278,7 @@ function RouterContextProvider({
|
|
|
241
278
|
artifact_cache,
|
|
242
279
|
component_cache,
|
|
243
280
|
data_cache,
|
|
244
|
-
|
|
281
|
+
ssr_signals,
|
|
245
282
|
last_variables,
|
|
246
283
|
session: ssrSession = {}
|
|
247
284
|
}) {
|
|
@@ -264,7 +301,7 @@ function RouterContextProvider({
|
|
|
264
301
|
artifact_cache,
|
|
265
302
|
component_cache,
|
|
266
303
|
data_cache,
|
|
267
|
-
|
|
304
|
+
ssr_signals,
|
|
268
305
|
last_variables,
|
|
269
306
|
session
|
|
270
307
|
},
|
|
@@ -276,7 +313,6 @@ const Context = import_react.default.createContext(null);
|
|
|
276
313
|
const useRouterContext = () => {
|
|
277
314
|
const ctx = import_react.default.useContext(Context);
|
|
278
315
|
if (!ctx) {
|
|
279
|
-
console.log(ctx);
|
|
280
316
|
throw new Error("Could not find router context");
|
|
281
317
|
}
|
|
282
318
|
return ctx;
|
|
@@ -323,21 +359,26 @@ function useLinkNavigation({ goto }) {
|
|
|
323
359
|
const [pending, startTransition] = import_react.default.useTransition();
|
|
324
360
|
import_react.default.useEffect(() => {
|
|
325
361
|
const onClick = (e) => {
|
|
362
|
+
if (!e.target) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
326
365
|
const link = e.target?.closest("a");
|
|
327
|
-
if (link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.defaultPrevented) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
startTransition(() => {
|
|
334
|
-
goto(target);
|
|
335
|
-
});
|
|
366
|
+
if (!(link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.defaultPrevented)) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const target = link.attributes.getNamedItem("href")?.value;
|
|
370
|
+
if (!target || !target.startsWith("/")) {
|
|
371
|
+
return;
|
|
336
372
|
}
|
|
373
|
+
e.preventDefault();
|
|
374
|
+
e.stopPropagation();
|
|
375
|
+
startTransition(() => {
|
|
376
|
+
goto(target);
|
|
377
|
+
});
|
|
337
378
|
};
|
|
338
|
-
|
|
379
|
+
window.addEventListener("click", onClick);
|
|
339
380
|
return () => {
|
|
340
|
-
|
|
381
|
+
window.removeEventListener("click", onClick);
|
|
341
382
|
};
|
|
342
383
|
}, []);
|
|
343
384
|
}
|
|
@@ -379,17 +420,18 @@ function router_cache({
|
|
|
379
420
|
artifacts = {},
|
|
380
421
|
components = {},
|
|
381
422
|
initialData = {},
|
|
423
|
+
initialVariables = {},
|
|
382
424
|
initialArtifacts = {}
|
|
383
425
|
} = {}) {
|
|
384
426
|
const result = {
|
|
385
427
|
artifact_cache: (0, import_cache.suspense_cache)(initialArtifacts),
|
|
386
428
|
component_cache: (0, import_cache.suspense_cache)(),
|
|
387
429
|
data_cache: (0, import_cache.suspense_cache)(initialData),
|
|
388
|
-
|
|
430
|
+
ssr_signals: (0, import_cache.suspense_cache)(),
|
|
389
431
|
last_variables: (0, import_cache.suspense_cache)()
|
|
390
432
|
};
|
|
391
433
|
for (const query of pending_queries) {
|
|
392
|
-
result.
|
|
434
|
+
result.ssr_signals.set(query, signal_promise());
|
|
393
435
|
}
|
|
394
436
|
for (const [name, artifact] of Object.entries(artifacts)) {
|
|
395
437
|
result.artifact_cache.set(name, artifact);
|
|
@@ -397,6 +439,9 @@ function router_cache({
|
|
|
397
439
|
for (const [name, component] of Object.entries(components)) {
|
|
398
440
|
result.component_cache.set(name, component);
|
|
399
441
|
}
|
|
442
|
+
for (const [name, variables] of Object.entries(initialVariables)) {
|
|
443
|
+
result.last_variables.set(name, variables);
|
|
444
|
+
}
|
|
400
445
|
return result;
|
|
401
446
|
}
|
|
402
447
|
function signal_promise() {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
+
import type { DocumentArtifact, GraphQLValue } from 'houdini';
|
|
3
|
+
export declare function injectComponents({ cache, selection, data, variables, parentType, }: {
|
|
4
|
+
cache: Cache;
|
|
5
|
+
selection: DocumentArtifact['selection'];
|
|
6
|
+
data: GraphQLValue | null;
|
|
7
|
+
variables: Record<string, GraphQLValue> | undefined | null;
|
|
8
|
+
parentType?: string;
|
|
9
|
+
}): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defaultComponentField } from "$houdini/runtime/cache/cache";
|
|
2
|
+
import { getFieldsForType } from "$houdini/runtime/lib/selection";
|
|
3
|
+
function injectComponents({
|
|
4
|
+
cache,
|
|
5
|
+
selection,
|
|
6
|
+
data,
|
|
7
|
+
variables,
|
|
8
|
+
parentType = "Query"
|
|
9
|
+
}) {
|
|
10
|
+
if (data === null) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (typeof data !== "object") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(data)) {
|
|
17
|
+
data.forEach(
|
|
18
|
+
(item) => injectComponents({
|
|
19
|
+
cache,
|
|
20
|
+
selection,
|
|
21
|
+
data: item,
|
|
22
|
+
variables,
|
|
23
|
+
parentType
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const typename = data["__typename"];
|
|
29
|
+
const fields = getFieldsForType(selection, typename, false);
|
|
30
|
+
if (!fields) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for (const [field, subSelection] of Object.entries(fields)) {
|
|
34
|
+
if (subSelection.component) {
|
|
35
|
+
if (!cache._internal_unstable.componentCache[subSelection.component.key]) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
data[field] = defaultComponentField({
|
|
39
|
+
variables,
|
|
40
|
+
parent: cache._internal_unstable.id(parentType, data) ?? "",
|
|
41
|
+
cache,
|
|
42
|
+
component: subSelection.component
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const dataValue = data[field];
|
|
46
|
+
if (subSelection.selection) {
|
|
47
|
+
injectComponents({
|
|
48
|
+
cache,
|
|
49
|
+
selection: subSelection.selection,
|
|
50
|
+
data: dataValue,
|
|
51
|
+
variables,
|
|
52
|
+
parentType: subSelection.type
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
injectComponents
|
|
59
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { GraphQLObject } from '$houdini/lib/types';
|
|
1
2
|
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
3
|
import { RouterCache } from './routing';
|
|
3
4
|
export * from './hooks';
|
|
4
5
|
export { router_cache } from './routing';
|
|
5
|
-
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache,
|
|
6
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, ssr_signals, last_variables, session, assetPrefix, injectToStream, }: {
|
|
6
7
|
initialURL: string;
|
|
8
|
+
initialVariables: GraphQLObject;
|
|
7
9
|
cache: Cache;
|
|
8
10
|
session?: App.Session;
|
|
9
11
|
assetPrefix: string;
|
|
@@ -10,7 +10,7 @@ function Router({
|
|
|
10
10
|
artifact_cache,
|
|
11
11
|
component_cache,
|
|
12
12
|
data_cache,
|
|
13
|
-
|
|
13
|
+
ssr_signals,
|
|
14
14
|
last_variables,
|
|
15
15
|
session,
|
|
16
16
|
assetPrefix,
|
|
@@ -24,7 +24,7 @@ function Router({
|
|
|
24
24
|
artifact_cache,
|
|
25
25
|
component_cache,
|
|
26
26
|
data_cache,
|
|
27
|
-
|
|
27
|
+
ssr_signals,
|
|
28
28
|
last_variables,
|
|
29
29
|
session,
|
|
30
30
|
children: /* @__PURE__ */ jsx(
|