houdini-react 1.2.13 → 1.2.14
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/render.d.ts +5 -2
- package/build/plugin/vite.d.ts +8 -10
- package/build/plugin-cjs/index.js +263 -523
- package/build/plugin-esm/index.js +263 -523
- package/build/runtime/client.d.ts +1 -1
- package/build/runtime/index.d.ts +2 -9
- package/build/runtime/manifest.d.ts +1 -1
- package/build/runtime/routing/{components/Router.d.ts → Router.d.ts} +5 -9
- package/build/runtime/routing/index.d.ts +2 -3
- package/build/runtime-cjs/client.d.ts +1 -1
- package/build/runtime-cjs/client.js +2 -1
- package/build/runtime-cjs/hooks/useDocumentHandle.js +1 -1
- package/build/runtime-cjs/hooks/useDocumentSubscription.js +1 -1
- package/build/runtime-cjs/hooks/useFragment.js +5 -3
- package/build/runtime-cjs/hooks/useMutation.js +1 -1
- package/build/runtime-cjs/index.d.ts +2 -9
- package/build/runtime-cjs/index.js +7 -20
- package/build/runtime-cjs/manifest.d.ts +1 -1
- package/build/runtime-cjs/routing/{components/Router.d.ts → Router.d.ts} +5 -9
- package/build/runtime-cjs/routing/{components/Router.js → Router.js} +3 -17
- package/build/runtime-cjs/routing/index.d.ts +2 -3
- package/build/runtime-cjs/routing/index.js +2 -2
- package/build/runtime-esm/client.d.ts +1 -1
- package/build/runtime-esm/client.js +2 -1
- package/build/runtime-esm/hooks/useDocumentHandle.js +1 -1
- package/build/runtime-esm/hooks/useDocumentSubscription.js +1 -1
- package/build/runtime-esm/hooks/useFragment.js +4 -2
- package/build/runtime-esm/hooks/useMutation.js +1 -1
- package/build/runtime-esm/index.d.ts +2 -9
- package/build/runtime-esm/index.js +7 -16
- package/build/runtime-esm/manifest.d.ts +1 -1
- package/build/runtime-esm/routing/{components/Router.d.ts → Router.d.ts} +5 -9
- package/build/runtime-esm/routing/{components/Router.js → Router.js} +3 -17
- package/build/runtime-esm/routing/index.d.ts +2 -3
- package/build/runtime-esm/routing/index.js +2 -2
- package/package.json +3 -2
- package/build/runtime/routing/components/index.d.ts +0 -1
- package/build/runtime/routing/lib/match.d.ts +0 -38
- package/build/runtime/routing/lib/types.d.ts +0 -19
- package/build/runtime-cjs/routing/components/index.d.ts +0 -1
- package/build/runtime-cjs/routing/components/index.js +0 -34
- package/build/runtime-cjs/routing/lib/match.d.ts +0 -38
- package/build/runtime-cjs/routing/lib/match.js +0 -149
- package/build/runtime-cjs/routing/lib/types.d.ts +0 -19
- package/build/runtime-cjs/routing/lib/types.js +0 -16
- package/build/runtime-esm/routing/components/index.d.ts +0 -1
- package/build/runtime-esm/routing/components/index.js +0 -7
- package/build/runtime-esm/routing/lib/match.d.ts +0 -38
- package/build/runtime-esm/routing/lib/match.js +0 -122
- package/build/runtime-esm/routing/lib/types.d.ts +0 -19
- package/build/runtime-esm/routing/lib/types.js +0 -0
- /package/build/runtime/routing/{lib/cache.d.ts → cache.d.ts} +0 -0
- /package/build/runtime-cjs/routing/{lib/cache.d.ts → cache.d.ts} +0 -0
- /package/build/runtime-cjs/routing/{lib/cache.js → cache.js} +0 -0
- /package/build/runtime-esm/routing/{lib/cache.d.ts → cache.d.ts} +0 -0
- /package/build/runtime-esm/routing/{lib/cache.js → cache.js} +0 -0
package/build/runtime/index.d.ts
CHANGED
|
@@ -3,18 +3,11 @@ import { DocumentStore } from '$houdini/runtime/client';
|
|
|
3
3
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
4
|
import { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { PendingCache } from './routing
|
|
7
|
-
import { SuspenseCache } from './routing/lib/cache';
|
|
6
|
+
import { SuspenseCache, type PendingCache } from './routing';
|
|
8
7
|
export * from './hooks';
|
|
9
|
-
export
|
|
10
|
-
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, loaded_queries, loaded_artifacts, session, assetPrefix, }: {
|
|
8
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
|
|
11
9
|
initialURL: string;
|
|
12
10
|
cache: Cache;
|
|
13
|
-
loaded_queries?: Record<string, {
|
|
14
|
-
data: GraphQLObject;
|
|
15
|
-
variables: GraphQLVariables;
|
|
16
|
-
}>;
|
|
17
|
-
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
18
11
|
session?: App.Session;
|
|
19
12
|
assetPrefix: string;
|
|
20
13
|
} & RouterCache): JSX.Element;
|
|
@@ -3,22 +3,18 @@ import { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
|
|
|
3
3
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
4
|
import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
|
+
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
6
7
|
import React from 'react';
|
|
7
|
-
import { SuspenseCache } from '
|
|
8
|
-
|
|
8
|
+
import { SuspenseCache } from './cache';
|
|
9
|
+
type ComponentType = any;
|
|
9
10
|
/**
|
|
10
11
|
* Router is the top level entry point for the filesystem-based router.
|
|
11
12
|
* It is responsible for loading various page sources (including API fetches) and
|
|
12
13
|
* then rendering when appropriate.
|
|
13
14
|
*/
|
|
14
|
-
export declare function Router({ manifest, initialURL,
|
|
15
|
-
manifest: RouterManifest
|
|
15
|
+
export declare function Router({ manifest, initialURL, assetPrefix, }: {
|
|
16
|
+
manifest: RouterManifest<ComponentType>;
|
|
16
17
|
initialURL?: string;
|
|
17
|
-
loaded_queries?: Record<string, {
|
|
18
|
-
data: GraphQLObject;
|
|
19
|
-
variables: GraphQLVariables;
|
|
20
|
-
}>;
|
|
21
|
-
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
22
18
|
assetPrefix: string;
|
|
23
19
|
}): JSX.Element;
|
|
24
20
|
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export { suspense_cache } from './
|
|
3
|
-
export type { RouterManifest, RouterPageManifest } from './lib/types';
|
|
1
|
+
export * from './Router';
|
|
2
|
+
export { type SuspenseCache, suspense_cache } from './cache';
|
|
@@ -21,6 +21,7 @@ __export(client_exports, {
|
|
|
21
21
|
default: () => client_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(client_exports);
|
|
24
|
-
var client_default = {
|
|
24
|
+
var client_default = () => {
|
|
25
|
+
};
|
|
25
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
27
|
0 && (module.exports = {});
|
|
@@ -31,7 +31,7 @@ var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
|
|
|
31
31
|
var import_pagination = require("$houdini/runtime/lib/pagination");
|
|
32
32
|
var import_types = require("$houdini/runtime/lib/types");
|
|
33
33
|
var import_react = __toESM(require("react"));
|
|
34
|
-
var import_Router = require("../routing/
|
|
34
|
+
var import_Router = require("../routing/Router");
|
|
35
35
|
function useDocumentHandle({
|
|
36
36
|
artifact,
|
|
37
37
|
observer,
|
|
@@ -27,7 +27,7 @@ __export(useDocumentSubscription_exports, {
|
|
|
27
27
|
useDocumentSubscription: () => useDocumentSubscription
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(useDocumentSubscription_exports);
|
|
30
|
-
var import_Router = require("../routing/
|
|
30
|
+
var import_Router = require("../routing/Router");
|
|
31
31
|
var import_useDeepCompareEffect = __toESM(require("./useDeepCompareEffect"));
|
|
32
32
|
var import_useDocumentStore = require("./useDocumentStore");
|
|
33
33
|
function useDocumentSubscription({
|
|
@@ -28,20 +28,21 @@ __export(useFragment_exports, {
|
|
|
28
28
|
useFragment: () => useFragment
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(useFragment_exports);
|
|
31
|
-
var import_cache = __toESM(require("$houdini/runtime/cache"));
|
|
32
31
|
var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
|
|
33
32
|
var import_types = require("$houdini/runtime/lib/types");
|
|
34
33
|
var React = __toESM(require("react"));
|
|
34
|
+
var import_routing = require("../routing");
|
|
35
35
|
var import_useDeepCompareEffect = require("./useDeepCompareEffect");
|
|
36
36
|
var import_useDocumentSubscription = require("./useDocumentSubscription");
|
|
37
37
|
function useFragment(reference, document) {
|
|
38
|
+
const { cache } = (0, import_routing.useRouterContext)();
|
|
38
39
|
const { parent, variables, loading } = fragmentReference(
|
|
39
40
|
reference,
|
|
40
41
|
document
|
|
41
42
|
);
|
|
42
43
|
let cachedValue = reference;
|
|
43
44
|
if (reference && parent) {
|
|
44
|
-
cachedValue =
|
|
45
|
+
cachedValue = cache.read({
|
|
45
46
|
selection: document.artifact.selection,
|
|
46
47
|
parent,
|
|
47
48
|
variables,
|
|
@@ -56,7 +57,8 @@ function useFragment(reference, document) {
|
|
|
56
57
|
send: {
|
|
57
58
|
stuff: {
|
|
58
59
|
parentID: parent
|
|
59
|
-
}
|
|
60
|
+
},
|
|
61
|
+
setup: true
|
|
60
62
|
}
|
|
61
63
|
});
|
|
62
64
|
const lastReference = React.useRef(null);
|
|
@@ -21,7 +21,7 @@ __export(useMutation_exports, {
|
|
|
21
21
|
useMutation: () => useMutation
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useMutation_exports);
|
|
24
|
-
var import_Router = require("../routing/
|
|
24
|
+
var import_Router = require("../routing/Router");
|
|
25
25
|
var import_useDocumentStore = require("./useDocumentStore");
|
|
26
26
|
function useMutation({
|
|
27
27
|
artifact
|
|
@@ -3,18 +3,11 @@ import { DocumentStore } from '$houdini/runtime/client';
|
|
|
3
3
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
4
|
import { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { PendingCache } from './routing
|
|
7
|
-
import { SuspenseCache } from './routing/lib/cache';
|
|
6
|
+
import { SuspenseCache, type PendingCache } from './routing';
|
|
8
7
|
export * from './hooks';
|
|
9
|
-
export
|
|
10
|
-
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, loaded_queries, loaded_artifacts, session, assetPrefix, }: {
|
|
8
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
|
|
11
9
|
initialURL: string;
|
|
12
10
|
cache: Cache;
|
|
13
|
-
loaded_queries?: Record<string, {
|
|
14
|
-
data: GraphQLObject;
|
|
15
|
-
variables: GraphQLVariables;
|
|
16
|
-
}>;
|
|
17
|
-
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
18
11
|
session?: App.Session;
|
|
19
12
|
assetPrefix: string;
|
|
20
13
|
} & RouterCache): JSX.Element;
|
|
@@ -33,9 +33,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
33
33
|
var import_client2 = __toESM(require("./client"));
|
|
34
34
|
var import_manifest = __toESM(require("./manifest"));
|
|
35
35
|
var import_routing = require("./routing");
|
|
36
|
-
var import_cache = require("./routing/lib/cache");
|
|
37
36
|
__reExport(runtime_exports, require("./hooks"), module.exports);
|
|
38
|
-
__reExport(runtime_exports, require("./routing"), module.exports);
|
|
39
37
|
function Router({
|
|
40
38
|
cache,
|
|
41
39
|
initialURL,
|
|
@@ -44,15 +42,13 @@ function Router({
|
|
|
44
42
|
data_cache,
|
|
45
43
|
pending_cache,
|
|
46
44
|
last_variables,
|
|
47
|
-
loaded_queries,
|
|
48
|
-
loaded_artifacts,
|
|
49
45
|
session,
|
|
50
46
|
assetPrefix
|
|
51
47
|
}) {
|
|
52
48
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
53
49
|
import_routing.RouterContextProvider,
|
|
54
50
|
{
|
|
55
|
-
client: import_client2.default,
|
|
51
|
+
client: (0, import_client2.default)(),
|
|
56
52
|
cache,
|
|
57
53
|
artifact_cache,
|
|
58
54
|
component_cache,
|
|
@@ -60,16 +56,7 @@ function Router({
|
|
|
60
56
|
pending_cache,
|
|
61
57
|
last_variables,
|
|
62
58
|
session,
|
|
63
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
-
import_routing.Router,
|
|
65
|
-
{
|
|
66
|
-
initialURL,
|
|
67
|
-
manifest: import_manifest.default,
|
|
68
|
-
loaded_queries,
|
|
69
|
-
loaded_artifacts,
|
|
70
|
-
assetPrefix
|
|
71
|
-
}
|
|
72
|
-
)
|
|
59
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_routing.Router, { initialURL, manifest: import_manifest.default, assetPrefix })
|
|
73
60
|
}
|
|
74
61
|
);
|
|
75
62
|
}
|
|
@@ -81,11 +68,11 @@ function router_cache({
|
|
|
81
68
|
initialArtifacts = {}
|
|
82
69
|
} = {}) {
|
|
83
70
|
const result = {
|
|
84
|
-
artifact_cache: (0,
|
|
85
|
-
component_cache: (0,
|
|
86
|
-
data_cache: (0,
|
|
87
|
-
pending_cache: (0,
|
|
88
|
-
last_variables: (0,
|
|
71
|
+
artifact_cache: (0, import_routing.suspense_cache)(initialArtifacts),
|
|
72
|
+
component_cache: (0, import_routing.suspense_cache)(),
|
|
73
|
+
data_cache: (0, import_routing.suspense_cache)(initialData),
|
|
74
|
+
pending_cache: (0, import_routing.suspense_cache)(),
|
|
75
|
+
last_variables: (0, import_routing.suspense_cache)()
|
|
89
76
|
};
|
|
90
77
|
for (const query of pending_queries) {
|
|
91
78
|
result.pending_cache.set(query, signal_promise());
|
|
@@ -3,22 +3,18 @@ import { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
|
|
|
3
3
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
4
|
import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
|
+
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
6
7
|
import React from 'react';
|
|
7
|
-
import { SuspenseCache } from '
|
|
8
|
-
|
|
8
|
+
import { SuspenseCache } from './cache';
|
|
9
|
+
type ComponentType = any;
|
|
9
10
|
/**
|
|
10
11
|
* Router is the top level entry point for the filesystem-based router.
|
|
11
12
|
* It is responsible for loading various page sources (including API fetches) and
|
|
12
13
|
* then rendering when appropriate.
|
|
13
14
|
*/
|
|
14
|
-
export declare function Router({ manifest, initialURL,
|
|
15
|
-
manifest: RouterManifest
|
|
15
|
+
export declare function Router({ manifest, initialURL, assetPrefix, }: {
|
|
16
|
+
manifest: RouterManifest<ComponentType>;
|
|
16
17
|
initialURL?: string;
|
|
17
|
-
loaded_queries?: Record<string, {
|
|
18
|
-
data: GraphQLObject;
|
|
19
|
-
variables: GraphQLVariables;
|
|
20
|
-
}>;
|
|
21
|
-
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
22
18
|
assetPrefix: string;
|
|
23
19
|
}): JSX.Element;
|
|
24
20
|
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
|
|
@@ -37,10 +37,10 @@ __export(Router_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(Router_exports);
|
|
38
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
39
|
var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
|
|
40
|
+
var import_match = require("$houdini/runtime/router/match");
|
|
40
41
|
var import_react = __toESM(require("react"));
|
|
41
42
|
var import_react_streaming = require("react-streaming");
|
|
42
|
-
var import_useDocumentStore = require("
|
|
43
|
-
var import_match = require("../lib/match");
|
|
43
|
+
var import_useDocumentStore = require("../hooks/useDocumentStore");
|
|
44
44
|
const PreloadWhich = {
|
|
45
45
|
component: "component",
|
|
46
46
|
data: "data",
|
|
@@ -49,8 +49,6 @@ const PreloadWhich = {
|
|
|
49
49
|
function Router({
|
|
50
50
|
manifest,
|
|
51
51
|
initialURL,
|
|
52
|
-
loaded_queries,
|
|
53
|
-
loaded_artifacts,
|
|
54
52
|
assetPrefix
|
|
55
53
|
}) {
|
|
56
54
|
const [current, setCurrent] = import_react.default.useState(() => {
|
|
@@ -60,8 +58,6 @@ function Router({
|
|
|
60
58
|
const { loadData, loadComponent } = usePageData({
|
|
61
59
|
page,
|
|
62
60
|
variables,
|
|
63
|
-
loaded_queries,
|
|
64
|
-
loaded_artifacts,
|
|
65
61
|
assetPrefix
|
|
66
62
|
});
|
|
67
63
|
const { component_cache } = useRouterContext();
|
|
@@ -100,8 +96,6 @@ function Router({
|
|
|
100
96
|
function usePageData({
|
|
101
97
|
page,
|
|
102
98
|
variables,
|
|
103
|
-
loaded_queries,
|
|
104
|
-
loaded_artifacts,
|
|
105
99
|
assetPrefix
|
|
106
100
|
}) {
|
|
107
101
|
const {
|
|
@@ -134,12 +128,6 @@ function usePageData({
|
|
|
134
128
|
session
|
|
135
129
|
}).then(() => {
|
|
136
130
|
data_cache.set(id, observer);
|
|
137
|
-
if (loaded_queries) {
|
|
138
|
-
loaded_queries[artifact.name] = {
|
|
139
|
-
data: observer.state.data,
|
|
140
|
-
variables
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
131
|
stream?.injectToStream(`
|
|
144
132
|
<script>
|
|
145
133
|
window.__houdini__cache__?.hydrate(${cache.serialize()}, window.__houdini__hydration__layer)
|
|
@@ -213,9 +201,6 @@ function usePageData({
|
|
|
213
201
|
targetPage.documents[artifact_id].artifact().then((mod) => {
|
|
214
202
|
const artifact = mod.default;
|
|
215
203
|
artifact_cache.set(artifact_id, artifact);
|
|
216
|
-
if (loaded_artifacts) {
|
|
217
|
-
loaded_artifacts[artifact.name] = artifact;
|
|
218
|
-
}
|
|
219
204
|
stream?.injectToStream(`
|
|
220
205
|
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""><\/script>
|
|
221
206
|
`);
|
|
@@ -288,6 +273,7 @@ const Context = import_react.default.createContext(null);
|
|
|
288
273
|
const useRouterContext = () => {
|
|
289
274
|
const ctx = import_react.default.useContext(Context);
|
|
290
275
|
if (!ctx) {
|
|
276
|
+
console.log(ctx);
|
|
291
277
|
throw new Error("Could not find router context");
|
|
292
278
|
}
|
|
293
279
|
return ctx;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export { suspense_cache } from './
|
|
3
|
-
export type { RouterManifest, RouterPageManifest } from './lib/types';
|
|
1
|
+
export * from './Router';
|
|
2
|
+
export { type SuspenseCache, suspense_cache } from './cache';
|
|
@@ -22,8 +22,8 @@ __export(routing_exports, {
|
|
|
22
22
|
suspense_cache: () => import_cache.suspense_cache
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(routing_exports);
|
|
25
|
-
__reExport(routing_exports, require("./
|
|
26
|
-
var import_cache = require("./
|
|
25
|
+
__reExport(routing_exports, require("./Router"), module.exports);
|
|
26
|
+
var import_cache = require("./cache");
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
|
29
29
|
suspense_cache
|
|
@@ -2,7 +2,7 @@ import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
|
2
2
|
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
3
3
|
import { ArtifactKind } from "$houdini/runtime/lib/types";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { useSession } from "../routing/
|
|
5
|
+
import { useSession } from "../routing/Router";
|
|
6
6
|
function useDocumentHandle({
|
|
7
7
|
artifact,
|
|
8
8
|
observer,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import cache from "$houdini/runtime/cache";
|
|
2
1
|
import { deepEquals } from "$houdini/runtime/lib/deepEquals";
|
|
3
2
|
import { fragmentKey } from "$houdini/runtime/lib/types";
|
|
4
3
|
import * as React from "react";
|
|
4
|
+
import { useRouterContext } from "../routing";
|
|
5
5
|
import { useDeepCompareMemoize } from "./useDeepCompareEffect";
|
|
6
6
|
import { useDocumentSubscription } from "./useDocumentSubscription";
|
|
7
7
|
function useFragment(reference, document) {
|
|
8
|
+
const { cache } = useRouterContext();
|
|
8
9
|
const { parent, variables, loading } = fragmentReference(
|
|
9
10
|
reference,
|
|
10
11
|
document
|
|
@@ -26,7 +27,8 @@ function useFragment(reference, document) {
|
|
|
26
27
|
send: {
|
|
27
28
|
stuff: {
|
|
28
29
|
parentID: parent
|
|
29
|
-
}
|
|
30
|
+
},
|
|
31
|
+
setup: true
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
const lastReference = React.useRef(null);
|
|
@@ -3,18 +3,11 @@ import { DocumentStore } from '$houdini/runtime/client';
|
|
|
3
3
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
4
|
import { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { PendingCache } from './routing
|
|
7
|
-
import { SuspenseCache } from './routing/lib/cache';
|
|
6
|
+
import { SuspenseCache, type PendingCache } from './routing';
|
|
8
7
|
export * from './hooks';
|
|
9
|
-
export
|
|
10
|
-
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, loaded_queries, loaded_artifacts, session, assetPrefix, }: {
|
|
8
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
|
|
11
9
|
initialURL: string;
|
|
12
10
|
cache: Cache;
|
|
13
|
-
loaded_queries?: Record<string, {
|
|
14
|
-
data: GraphQLObject;
|
|
15
|
-
variables: GraphQLVariables;
|
|
16
|
-
}>;
|
|
17
|
-
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
18
11
|
session?: App.Session;
|
|
19
12
|
assetPrefix: string;
|
|
20
13
|
} & RouterCache): JSX.Element;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import client from "./client";
|
|
3
3
|
import manifest from "./manifest";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
suspense_cache,
|
|
6
|
+
Router as RouterImpl,
|
|
7
|
+
RouterContextProvider
|
|
8
|
+
} from "./routing";
|
|
6
9
|
export * from "./hooks";
|
|
7
|
-
export * from "./routing";
|
|
8
10
|
function Router({
|
|
9
11
|
cache,
|
|
10
12
|
initialURL,
|
|
@@ -13,15 +15,13 @@ function Router({
|
|
|
13
15
|
data_cache,
|
|
14
16
|
pending_cache,
|
|
15
17
|
last_variables,
|
|
16
|
-
loaded_queries,
|
|
17
|
-
loaded_artifacts,
|
|
18
18
|
session,
|
|
19
19
|
assetPrefix
|
|
20
20
|
}) {
|
|
21
21
|
return /* @__PURE__ */ jsx(
|
|
22
22
|
RouterContextProvider,
|
|
23
23
|
{
|
|
24
|
-
client,
|
|
24
|
+
client: client(),
|
|
25
25
|
cache,
|
|
26
26
|
artifact_cache,
|
|
27
27
|
component_cache,
|
|
@@ -29,16 +29,7 @@ function Router({
|
|
|
29
29
|
pending_cache,
|
|
30
30
|
last_variables,
|
|
31
31
|
session,
|
|
32
|
-
children: /* @__PURE__ */ jsx(
|
|
33
|
-
RouterImpl,
|
|
34
|
-
{
|
|
35
|
-
initialURL,
|
|
36
|
-
manifest,
|
|
37
|
-
loaded_queries,
|
|
38
|
-
loaded_artifacts,
|
|
39
|
-
assetPrefix
|
|
40
|
-
}
|
|
41
|
-
)
|
|
32
|
+
children: /* @__PURE__ */ jsx(RouterImpl, { initialURL, manifest, assetPrefix })
|
|
42
33
|
}
|
|
43
34
|
);
|
|
44
35
|
}
|
|
@@ -3,22 +3,18 @@ import { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
|
|
|
3
3
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
4
|
import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
|
+
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
6
7
|
import React from 'react';
|
|
7
|
-
import { SuspenseCache } from '
|
|
8
|
-
|
|
8
|
+
import { SuspenseCache } from './cache';
|
|
9
|
+
type ComponentType = any;
|
|
9
10
|
/**
|
|
10
11
|
* Router is the top level entry point for the filesystem-based router.
|
|
11
12
|
* It is responsible for loading various page sources (including API fetches) and
|
|
12
13
|
* then rendering when appropriate.
|
|
13
14
|
*/
|
|
14
|
-
export declare function Router({ manifest, initialURL,
|
|
15
|
-
manifest: RouterManifest
|
|
15
|
+
export declare function Router({ manifest, initialURL, assetPrefix, }: {
|
|
16
|
+
manifest: RouterManifest<ComponentType>;
|
|
16
17
|
initialURL?: string;
|
|
17
|
-
loaded_queries?: Record<string, {
|
|
18
|
-
data: GraphQLObject;
|
|
19
|
-
variables: GraphQLVariables;
|
|
20
|
-
}>;
|
|
21
|
-
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
22
18
|
assetPrefix: string;
|
|
23
19
|
}): JSX.Element;
|
|
24
20
|
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { deepEquals } from "$houdini/runtime/lib/deepEquals";
|
|
3
|
+
import { find_match } from "$houdini/runtime/router/match";
|
|
3
4
|
import React from "react";
|
|
4
5
|
import { useStream } from "react-streaming";
|
|
5
|
-
import { useDocumentStore } from "
|
|
6
|
-
import { find_match } from "../lib/match";
|
|
6
|
+
import { useDocumentStore } from "../hooks/useDocumentStore";
|
|
7
7
|
const PreloadWhich = {
|
|
8
8
|
component: "component",
|
|
9
9
|
data: "data",
|
|
@@ -12,8 +12,6 @@ const PreloadWhich = {
|
|
|
12
12
|
function Router({
|
|
13
13
|
manifest,
|
|
14
14
|
initialURL,
|
|
15
|
-
loaded_queries,
|
|
16
|
-
loaded_artifacts,
|
|
17
15
|
assetPrefix
|
|
18
16
|
}) {
|
|
19
17
|
const [current, setCurrent] = React.useState(() => {
|
|
@@ -23,8 +21,6 @@ function Router({
|
|
|
23
21
|
const { loadData, loadComponent } = usePageData({
|
|
24
22
|
page,
|
|
25
23
|
variables,
|
|
26
|
-
loaded_queries,
|
|
27
|
-
loaded_artifacts,
|
|
28
24
|
assetPrefix
|
|
29
25
|
});
|
|
30
26
|
const { component_cache } = useRouterContext();
|
|
@@ -63,8 +59,6 @@ function Router({
|
|
|
63
59
|
function usePageData({
|
|
64
60
|
page,
|
|
65
61
|
variables,
|
|
66
|
-
loaded_queries,
|
|
67
|
-
loaded_artifacts,
|
|
68
62
|
assetPrefix
|
|
69
63
|
}) {
|
|
70
64
|
const {
|
|
@@ -97,12 +91,6 @@ function usePageData({
|
|
|
97
91
|
session
|
|
98
92
|
}).then(() => {
|
|
99
93
|
data_cache.set(id, observer);
|
|
100
|
-
if (loaded_queries) {
|
|
101
|
-
loaded_queries[artifact.name] = {
|
|
102
|
-
data: observer.state.data,
|
|
103
|
-
variables
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
94
|
stream?.injectToStream(`
|
|
107
95
|
<script>
|
|
108
96
|
window.__houdini__cache__?.hydrate(${cache.serialize()}, window.__houdini__hydration__layer)
|
|
@@ -176,9 +164,6 @@ function usePageData({
|
|
|
176
164
|
targetPage.documents[artifact_id].artifact().then((mod) => {
|
|
177
165
|
const artifact = mod.default;
|
|
178
166
|
artifact_cache.set(artifact_id, artifact);
|
|
179
|
-
if (loaded_artifacts) {
|
|
180
|
-
loaded_artifacts[artifact.name] = artifact;
|
|
181
|
-
}
|
|
182
167
|
stream?.injectToStream(`
|
|
183
168
|
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""><\/script>
|
|
184
169
|
`);
|
|
@@ -251,6 +236,7 @@ const Context = React.createContext(null);
|
|
|
251
236
|
const useRouterContext = () => {
|
|
252
237
|
const ctx = React.useContext(Context);
|
|
253
238
|
if (!ctx) {
|
|
239
|
+
console.log(ctx);
|
|
254
240
|
throw new Error("Could not find router context");
|
|
255
241
|
}
|
|
256
242
|
return ctx;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export { suspense_cache } from './
|
|
3
|
-
export type { RouterManifest, RouterPageManifest } from './lib/types';
|
|
1
|
+
export * from './Router';
|
|
2
|
+
export { type SuspenseCache, suspense_cache } from './cache';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
4
4
|
"description": "The React plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@babel/parser": "^7.19.3",
|
|
30
30
|
"@babel/types": "^7.21.4",
|
|
31
31
|
"@types/react": "^18.0.28",
|
|
32
|
+
"@whatwg-node/server": "^0.9.14",
|
|
32
33
|
"cookie-parser": "^1.4.6",
|
|
33
34
|
"cookie-session": "^2.0.0",
|
|
34
35
|
"cookies": "^0.8.0",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"recast": "^0.23.1",
|
|
42
43
|
"rollup": "^3.7.4",
|
|
43
44
|
"use-deep-compare-effect": "^1.8.1",
|
|
44
|
-
"houdini": "^1.2.
|
|
45
|
+
"houdini": "^1.2.14"
|
|
45
46
|
},
|
|
46
47
|
"files": [
|
|
47
48
|
"build"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Router, RouterContextProvider, useClient, updateLocalSession } from './Router';
|