houdini-react 1.2.0-react.1 → 1.2.7
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/README.md +1 -1
- package/build/plugin/codegen/entries.d.ts +6 -0
- package/build/plugin/codegen/index.d.ts +14 -0
- package/build/plugin/codegen/manifest.d.ts +42 -0
- package/build/plugin/codegen/render.d.ts +2 -0
- package/build/plugin/codegen/router.d.ts +8 -0
- package/build/plugin/codegen/typeRoot.d.ts +6 -0
- package/build/plugin/config.d.ts +2 -1
- package/build/plugin/conventions.d.ts +24 -0
- package/build/plugin/dedent.d.ts +1 -0
- package/build/plugin/extract.d.ts +1 -1
- package/build/plugin/index.d.ts +16 -3
- package/build/plugin/vite.d.ts +19 -0
- package/build/plugin-cjs/index.js +132171 -43771
- package/build/plugin-esm/index.js +132162 -43765
- package/build/runtime/client.d.ts +3 -0
- package/build/runtime/clientPlugin.d.ts +3 -0
- package/build/runtime/hooks/useDocumentHandle.d.ts +4 -4
- package/build/runtime/hooks/useDocumentStore.d.ts +6 -5
- package/build/runtime/hooks/useDocumentSubscription.d.ts +4 -3
- package/build/runtime/hooks/useFragment.d.ts +3 -2
- package/build/runtime/hooks/useFragmentHandle.d.ts +2 -3
- package/build/runtime/hooks/useMutation.d.ts +2 -2
- package/build/runtime/hooks/useQuery.d.ts +3 -3
- package/build/runtime/hooks/useQueryHandle.d.ts +3 -3
- package/build/runtime/hooks/useSubscription.d.ts +2 -2
- package/build/runtime/hooks/useSubscriptionHandle.d.ts +3 -3
- package/build/runtime/index.d.ts +30 -1
- package/build/runtime/manifest.d.ts +3 -0
- package/build/runtime/routing/components/Link.d.ts +5 -0
- package/build/runtime/routing/components/Router.d.ts +56 -0
- package/build/runtime/routing/components/index.d.ts +2 -0
- package/build/runtime/routing/index.d.ts +3 -0
- package/build/runtime/routing/lib/cache.d.ts +7 -0
- package/build/runtime/routing/lib/match.d.ts +38 -0
- package/build/runtime/routing/lib/types.d.ts +23 -0
- package/build/runtime-cjs/client.d.ts +3 -0
- package/build/runtime-cjs/client.js +26 -0
- package/build/runtime-cjs/clientPlugin.d.ts +3 -0
- package/build/{next-cjs/index.js → runtime-cjs/clientPlugin.js} +15 -26
- package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +4 -4
- package/build/runtime-cjs/hooks/useDocumentHandle.js +11 -7
- package/build/runtime-cjs/hooks/useDocumentStore.d.ts +6 -5
- package/build/runtime-cjs/hooks/useDocumentStore.js +9 -4
- package/build/runtime-cjs/hooks/useDocumentSubscription.d.ts +4 -3
- package/build/runtime-cjs/hooks/useDocumentSubscription.js +15 -8
- package/build/runtime-cjs/hooks/useFragment.d.ts +3 -2
- package/build/runtime-cjs/hooks/useFragment.js +9 -7
- package/build/runtime-cjs/hooks/useFragmentHandle.d.ts +2 -3
- package/build/runtime-cjs/hooks/useMutation.d.ts +2 -2
- package/build/runtime-cjs/hooks/useMutation.js +3 -1
- package/build/runtime-cjs/hooks/useQuery.d.ts +3 -3
- package/build/runtime-cjs/hooks/useQueryHandle.d.ts +3 -3
- package/build/runtime-cjs/hooks/useQueryHandle.js +4 -4
- package/build/runtime-cjs/hooks/useSubscription.d.ts +2 -2
- package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +3 -3
- package/build/runtime-cjs/index.d.ts +30 -1
- package/build/runtime-cjs/index.js +89 -3
- package/build/runtime-cjs/manifest.d.ts +3 -0
- package/build/runtime-cjs/manifest.js +27 -0
- package/build/runtime-cjs/routing/components/Link.d.ts +5 -0
- package/build/runtime-cjs/{hooks/useHoudiniClient.js → routing/components/Link.js} +22 -13
- package/build/runtime-cjs/routing/components/Router.d.ts +56 -0
- package/build/runtime-cjs/routing/components/Router.js +296 -0
- package/build/runtime-cjs/routing/components/index.d.ts +2 -0
- package/build/runtime-cjs/{context.js → routing/components/index.js} +15 -19
- package/build/runtime-cjs/routing/index.d.ts +3 -0
- package/build/runtime-cjs/routing/index.js +30 -0
- package/build/runtime-cjs/routing/lib/cache.d.ts +7 -0
- package/build/runtime-cjs/{lib → routing/lib}/cache.js +23 -40
- package/build/runtime-cjs/routing/lib/match.d.ts +38 -0
- package/build/runtime-cjs/routing/lib/match.js +149 -0
- package/build/runtime-cjs/routing/lib/types.d.ts +23 -0
- package/build/runtime-cjs/routing/lib/types.js +16 -0
- package/build/runtime-esm/client.d.ts +3 -0
- package/build/runtime-esm/client.js +4 -0
- package/build/runtime-esm/clientPlugin.d.ts +3 -0
- package/build/runtime-esm/clientPlugin.js +17 -0
- package/build/runtime-esm/hooks/useDocumentHandle.d.ts +4 -4
- package/build/runtime-esm/hooks/useDocumentHandle.js +12 -10
- package/build/runtime-esm/hooks/useDocumentStore.d.ts +6 -5
- package/build/runtime-esm/hooks/useDocumentStore.js +9 -4
- package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +4 -3
- package/build/runtime-esm/hooks/useDocumentSubscription.js +15 -8
- package/build/runtime-esm/hooks/useFragment.d.ts +3 -2
- package/build/runtime-esm/hooks/useFragment.js +9 -7
- package/build/runtime-esm/hooks/useFragmentHandle.d.ts +2 -3
- package/build/runtime-esm/hooks/useMutation.d.ts +2 -2
- package/build/runtime-esm/hooks/useMutation.js +3 -1
- package/build/runtime-esm/hooks/useQuery.d.ts +3 -3
- package/build/runtime-esm/hooks/useQueryHandle.d.ts +3 -3
- package/build/runtime-esm/hooks/useQueryHandle.js +4 -4
- package/build/runtime-esm/hooks/useSubscription.d.ts +2 -2
- package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +3 -3
- package/build/runtime-esm/index.d.ts +30 -1
- package/build/runtime-esm/index.js +81 -2
- package/build/runtime-esm/manifest.d.ts +3 -0
- package/build/runtime-esm/manifest.js +5 -0
- package/build/runtime-esm/routing/components/Link.d.ts +5 -0
- package/build/runtime-esm/routing/components/Link.js +21 -0
- package/build/runtime-esm/routing/components/Router.d.ts +56 -0
- package/build/runtime-esm/routing/components/Router.js +257 -0
- package/build/runtime-esm/routing/components/index.d.ts +2 -0
- package/build/runtime-esm/routing/components/index.js +9 -0
- package/build/runtime-esm/routing/index.d.ts +3 -0
- package/build/runtime-esm/routing/index.js +5 -0
- package/build/runtime-esm/routing/lib/cache.d.ts +7 -0
- package/build/runtime-esm/routing/lib/cache.js +29 -0
- package/build/runtime-esm/routing/lib/match.d.ts +38 -0
- package/build/runtime-esm/routing/lib/match.js +122 -0
- package/build/runtime-esm/routing/lib/types.d.ts +23 -0
- package/build/runtime-esm/routing/lib/types.js +0 -0
- package/build/server/compat.d.ts +7 -0
- package/build/server/index.d.ts +17 -0
- package/build/server/session.d.ts +3 -0
- package/build/server-cjs/index.js +166712 -0
- package/build/server-esm/index.js +166703 -0
- package/package.json +21 -10
- package/build/next/index.d.ts +0 -2
- package/build/next-esm/index.js +0 -26
- package/build/runtime/context.d.ts +0 -7
- package/build/runtime/hooks/useHoudiniClient.d.ts +0 -2
- package/build/runtime/lib/cache.d.ts +0 -62
- package/build/runtime-cjs/context.d.ts +0 -7
- package/build/runtime-cjs/hooks/useHoudiniClient.d.ts +0 -2
- package/build/runtime-cjs/lib/cache.d.ts +0 -62
- package/build/runtime-esm/context.d.ts +0 -7
- package/build/runtime-esm/context.js +0 -10
- package/build/runtime-esm/hooks/useHoudiniClient.d.ts +0 -2
- package/build/runtime-esm/hooks/useHoudiniClient.js +0 -12
- package/build/runtime-esm/lib/cache.d.ts +0 -62
- package/build/runtime-esm/lib/cache.js +0 -47
- /package/build/{next-cjs → server-cjs}/package.json +0 -0
- /package/build/{next-esm → server-esm}/package.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fragmentKey } from '$houdini/runtime/lib/types';
|
|
2
|
-
import type { GraphQLObject, FragmentArtifact } from '$houdini/runtime/lib/types';
|
|
3
|
-
export declare function useFragment<_Data extends GraphQLObject, _ReferenceType extends {}, _Input extends
|
|
2
|
+
import type { GraphQLObject, GraphQLVariables, FragmentArtifact } from '$houdini/runtime/lib/types';
|
|
3
|
+
export declare function useFragment<_Data extends GraphQLObject, _ReferenceType extends {}, _Input extends GraphQLVariables = GraphQLVariables>(reference: _Data | {
|
|
4
4
|
[fragmentKey]: _ReferenceType;
|
|
5
5
|
} | null, document: {
|
|
6
6
|
artifact: FragmentArtifact;
|
|
@@ -12,4 +12,5 @@ export declare function fragmentReference<_Data extends GraphQLObject, _Input, _
|
|
|
12
12
|
}): {
|
|
13
13
|
variables: _Input;
|
|
14
14
|
parent: string;
|
|
15
|
+
loading: boolean;
|
|
15
16
|
};
|
|
@@ -35,7 +35,7 @@ var React = __toESM(require("react"));
|
|
|
35
35
|
var import_useDeepCompareEffect = require("./useDeepCompareEffect");
|
|
36
36
|
var import_useDocumentSubscription = require("./useDocumentSubscription");
|
|
37
37
|
function useFragment(reference, document) {
|
|
38
|
-
const { parent, variables } = fragmentReference(
|
|
38
|
+
const { parent, variables, loading } = fragmentReference(
|
|
39
39
|
reference,
|
|
40
40
|
document
|
|
41
41
|
);
|
|
@@ -44,20 +44,21 @@ function useFragment(reference, document) {
|
|
|
44
44
|
cachedValue = import_cache.default.read({
|
|
45
45
|
selection: document.artifact.selection,
|
|
46
46
|
parent,
|
|
47
|
-
variables
|
|
47
|
+
variables,
|
|
48
|
+
loading
|
|
48
49
|
}).data;
|
|
49
50
|
}
|
|
50
|
-
const
|
|
51
|
+
const [storeValue] = (0, import_useDocumentSubscription.useDocumentSubscription)({
|
|
51
52
|
artifact: document.artifact,
|
|
52
53
|
variables,
|
|
53
54
|
initialValue: cachedValue,
|
|
55
|
+
disabled: loading,
|
|
54
56
|
send: {
|
|
55
57
|
stuff: {
|
|
56
58
|
parentID: parent
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
|
-
};
|
|
60
|
-
const [storeValue] = (0, import_useDocumentSubscription.useDocumentSubscription)(observeParams);
|
|
61
|
+
});
|
|
61
62
|
const lastReference = React.useRef(null);
|
|
62
63
|
return React.useMemo(() => {
|
|
63
64
|
const parentChange = storeValue.parent !== parent || !(0, import_deepEquals.deepEquals)({ parent, variables }, lastReference.current);
|
|
@@ -77,14 +78,15 @@ function useFragment(reference, document) {
|
|
|
77
78
|
]);
|
|
78
79
|
}
|
|
79
80
|
function fragmentReference(reference, document) {
|
|
80
|
-
const { variables, parent } = reference?.[import_types.fragmentKey]?.[document.artifact.name] ?? {};
|
|
81
|
+
const { variables, parent } = reference?.[import_types.fragmentKey]?.values?.[document.artifact.name] ?? {};
|
|
81
82
|
if (reference && import_types.fragmentKey in reference && (!variables || !parent)) {
|
|
82
83
|
console.warn(
|
|
83
84
|
`\u26A0\uFE0F Parent does not contain the information for this fragment. Something is wrong.
|
|
84
85
|
Please ensure that you have passed a record that has ${document.artifact.name} mixed into it.`
|
|
85
86
|
);
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
const loading = Boolean(reference?.[import_types.fragmentKey]?.loading);
|
|
89
|
+
return { variables, parent, loading };
|
|
88
90
|
}
|
|
89
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
90
92
|
0 && (module.exports = {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { GraphQLObject, FragmentArtifact, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
2
|
-
import { fragmentKey } from '$houdini/runtime/lib/types';
|
|
1
|
+
import type { GraphQLObject, FragmentArtifact, QueryArtifact, fragmentKey, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
3
2
|
import { type DocumentHandle } from './useDocumentHandle';
|
|
4
|
-
export declare function useFragmentHandle<_Artifact extends FragmentArtifact, _Data extends GraphQLObject, _ReferenceType extends {}, _PaginationArtifact extends QueryArtifact, _Input extends
|
|
3
|
+
export declare function useFragmentHandle<_Artifact extends FragmentArtifact, _Data extends GraphQLObject, _ReferenceType extends {}, _PaginationArtifact extends QueryArtifact, _Input extends GraphQLVariables = GraphQLVariables>(reference: _Data | {
|
|
5
4
|
[fragmentKey]: _ReferenceType;
|
|
6
5
|
} | null, document: {
|
|
7
6
|
artifact: FragmentArtifact;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
|
|
1
|
+
import type { MutationArtifact, GraphQLObject, QueryResult, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
2
|
export type MutationHandler<_Result, _Input, _Optimistic extends GraphQLObject> = (args: {
|
|
3
3
|
variables: _Input;
|
|
4
4
|
metadata?: App.Metadata;
|
|
5
5
|
fetch?: typeof globalThis.fetch;
|
|
6
6
|
optimisticResponse?: _Optimistic;
|
|
7
7
|
}) => Promise<QueryResult<_Result, _Input>>;
|
|
8
|
-
export declare function useMutation<_Result extends GraphQLObject, _Input extends
|
|
8
|
+
export declare function useMutation<_Result extends GraphQLObject, _Input extends GraphQLVariables, _Optimistic extends GraphQLObject>({ artifact, }: {
|
|
9
9
|
artifact: MutationArtifact;
|
|
10
10
|
}): [boolean, MutationHandler<_Result, _Input, _Optimistic>];
|
|
@@ -21,12 +21,14 @@ __export(useMutation_exports, {
|
|
|
21
21
|
useMutation: () => useMutation
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useMutation_exports);
|
|
24
|
+
var import_Router = require("../routing/components/Router");
|
|
24
25
|
var import_useDocumentStore = require("./useDocumentStore");
|
|
25
26
|
function useMutation({
|
|
26
27
|
artifact
|
|
27
28
|
}) {
|
|
28
29
|
const [storeValue, observer] = (0, import_useDocumentStore.useDocumentStore)({ artifact });
|
|
29
30
|
const pending = storeValue.fetching;
|
|
31
|
+
const session = (0, import_Router.useSession)();
|
|
30
32
|
const mutate = ({
|
|
31
33
|
metadata,
|
|
32
34
|
fetch,
|
|
@@ -35,7 +37,7 @@ function useMutation({
|
|
|
35
37
|
}) => observer.send({
|
|
36
38
|
variables,
|
|
37
39
|
metadata,
|
|
38
|
-
session
|
|
40
|
+
session,
|
|
39
41
|
stuff: {
|
|
40
42
|
...mutationConfig
|
|
41
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UseQueryConfig } from './useQueryHandle';
|
|
3
|
-
export declare function useQuery<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends
|
|
1
|
+
import type { GraphQLVariables, GraphQLObject, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { UseQueryConfig } from './useQueryHandle';
|
|
3
|
+
export declare function useQuery<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables>(document: {
|
|
4
4
|
artifact: QueryArtifact;
|
|
5
5
|
}, variables?: any, config?: UseQueryConfig): _Data;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DocumentHandle } from './useDocumentHandle';
|
|
3
|
-
export declare function useQueryHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends
|
|
1
|
+
import type { GraphQLObject, CachePolicies, QueryArtifact, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { DocumentHandle } from './useDocumentHandle';
|
|
3
|
+
export declare function useQueryHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables>({ artifact }: {
|
|
4
4
|
artifact: QueryArtifact;
|
|
5
5
|
}, variables?: any, config?: UseQueryConfig): DocumentHandle<_Artifact, _Data, _Input>;
|
|
6
6
|
export type UseQueryConfig = {
|
|
@@ -27,16 +27,16 @@ __export(useQueryHandle_exports, {
|
|
|
27
27
|
useQueryHandle: () => useQueryHandle
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(useQueryHandle_exports);
|
|
30
|
+
var import_lru = require("$houdini/runtime/lib/lru");
|
|
30
31
|
var import_react = __toESM(require("react"));
|
|
31
|
-
var
|
|
32
|
+
var import_routing = require("../routing");
|
|
32
33
|
var import_useDocumentHandle = require("./useDocumentHandle");
|
|
33
|
-
var import_useHoudiniClient = require("./useHoudiniClient");
|
|
34
34
|
var import_useIsMounted = require("./useIsMounted");
|
|
35
|
-
const promiseCache = (0,
|
|
35
|
+
const promiseCache = (0, import_lru.createLRUCache)();
|
|
36
36
|
function useQueryHandle({ artifact }, variables = null, config = {}) {
|
|
37
37
|
const identifier = queryIdentifier({ artifact, variables, config });
|
|
38
38
|
const suspenseValue = promiseCache.get(identifier);
|
|
39
|
-
const client = (0,
|
|
39
|
+
const client = (0, import_routing.useClient)();
|
|
40
40
|
const isMountedRef = (0, import_useIsMounted.useIsMountedRef)();
|
|
41
41
|
let [observer] = import_react.default.useState(
|
|
42
42
|
client.observe({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubscriptionArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
|
|
2
|
-
export declare function useSubscription<_Result extends GraphQLObject, _Input extends
|
|
1
|
+
import type { SubscriptionArtifact, GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
|
+
export declare function useSubscription<_Result extends GraphQLObject, _Input extends GraphQLVariables>(document: {
|
|
3
3
|
artifact: SubscriptionArtifact;
|
|
4
4
|
}, variables: _Input): import("houdini").GraphQLObject | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SubscriptionArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
|
|
2
|
-
export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends
|
|
1
|
+
import type { SubscriptionArtifact, GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
|
+
export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends GraphQLVariables> = {
|
|
3
3
|
data: _Result | null;
|
|
4
4
|
errors: {
|
|
5
5
|
message: string;
|
|
@@ -11,7 +11,7 @@ export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends {}
|
|
|
11
11
|
unlisten: () => void;
|
|
12
12
|
fetching: boolean;
|
|
13
13
|
};
|
|
14
|
-
export declare function useSubscriptionHandle<_Result extends GraphQLObject, _Input extends
|
|
14
|
+
export declare function useSubscriptionHandle<_Result extends GraphQLObject, _Input extends GraphQLVariables>({ artifact }: {
|
|
15
15
|
artifact: SubscriptionArtifact;
|
|
16
16
|
}, variables: _Input): {
|
|
17
17
|
data: import("houdini").GraphQLObject | null;
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
+
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
+
import { DocumentStore } from '$houdini/runtime/client';
|
|
3
|
+
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
+
import { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { PendingCache } from './routing/components/Router';
|
|
7
|
+
import { SuspenseCache } from './routing/lib/cache';
|
|
1
8
|
export * from './hooks';
|
|
2
|
-
export
|
|
9
|
+
export * from './routing';
|
|
10
|
+
export declare function Router({ cache, intialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, loaded_queries, loaded_artifacts, session, }: {
|
|
11
|
+
intialURL: string;
|
|
12
|
+
cache: Cache;
|
|
13
|
+
loaded_queries?: Record<string, {
|
|
14
|
+
data: GraphQLObject;
|
|
15
|
+
variables: GraphQLVariables;
|
|
16
|
+
}>;
|
|
17
|
+
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
18
|
+
session?: App.Session;
|
|
19
|
+
} & RouterCache): JSX.Element;
|
|
20
|
+
type RouterCache = {
|
|
21
|
+
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
22
|
+
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
23
|
+
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
24
|
+
last_variables: LRUCache<GraphQLVariables>;
|
|
25
|
+
pending_cache: PendingCache;
|
|
26
|
+
};
|
|
27
|
+
export declare function router_cache({ pending_queries, artifacts, components, }?: {
|
|
28
|
+
pending_queries?: string[];
|
|
29
|
+
artifacts?: Record<string, QueryArtifact>;
|
|
30
|
+
components?: Record<string, (props: any) => React.ReactElement>;
|
|
31
|
+
}): RouterCache;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -16,15 +18,99 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
18
20
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
19
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
26
|
var runtime_exports = {};
|
|
21
27
|
__export(runtime_exports, {
|
|
22
|
-
|
|
28
|
+
Router: () => Router,
|
|
29
|
+
router_cache: () => router_cache
|
|
23
30
|
});
|
|
24
31
|
module.exports = __toCommonJS(runtime_exports);
|
|
32
|
+
var import_react = __toESM(require("react"));
|
|
33
|
+
var import_client2 = __toESM(require("./client"));
|
|
34
|
+
var import_manifest = __toESM(require("./manifest"));
|
|
35
|
+
var import_routing = require("./routing");
|
|
36
|
+
var import_cache = require("./routing/lib/cache");
|
|
25
37
|
__reExport(runtime_exports, require("./hooks"), module.exports);
|
|
26
|
-
|
|
38
|
+
__reExport(runtime_exports, require("./routing"), module.exports);
|
|
39
|
+
function Router({
|
|
40
|
+
cache,
|
|
41
|
+
intialURL,
|
|
42
|
+
artifact_cache,
|
|
43
|
+
component_cache,
|
|
44
|
+
data_cache,
|
|
45
|
+
pending_cache,
|
|
46
|
+
last_variables,
|
|
47
|
+
loaded_queries,
|
|
48
|
+
loaded_artifacts,
|
|
49
|
+
session
|
|
50
|
+
}) {
|
|
51
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
52
|
+
import_routing.RouterContextProvider,
|
|
53
|
+
{
|
|
54
|
+
client: import_client2.default,
|
|
55
|
+
cache,
|
|
56
|
+
artifact_cache,
|
|
57
|
+
component_cache,
|
|
58
|
+
data_cache,
|
|
59
|
+
pending_cache,
|
|
60
|
+
last_variables,
|
|
61
|
+
session
|
|
62
|
+
},
|
|
63
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
64
|
+
import_routing.Router,
|
|
65
|
+
{
|
|
66
|
+
intialURL,
|
|
67
|
+
manifest: import_manifest.default,
|
|
68
|
+
loaded_queries,
|
|
69
|
+
loaded_artifacts
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function router_cache({
|
|
75
|
+
pending_queries = [],
|
|
76
|
+
artifacts = {},
|
|
77
|
+
components = {}
|
|
78
|
+
} = {}) {
|
|
79
|
+
const result = {
|
|
80
|
+
artifact_cache: (0, import_cache.suspense_cache)(),
|
|
81
|
+
component_cache: (0, import_cache.suspense_cache)(),
|
|
82
|
+
data_cache: (0, import_cache.suspense_cache)(),
|
|
83
|
+
pending_cache: (0, import_cache.suspense_cache)(),
|
|
84
|
+
last_variables: (0, import_cache.suspense_cache)()
|
|
85
|
+
};
|
|
86
|
+
for (const query of pending_queries) {
|
|
87
|
+
result.pending_cache.set(query, signal_promise());
|
|
88
|
+
}
|
|
89
|
+
for (const [name, artifact] of Object.entries(artifacts)) {
|
|
90
|
+
result.artifact_cache.set(name, artifact);
|
|
91
|
+
}
|
|
92
|
+
for (const [name, component] of Object.entries(components)) {
|
|
93
|
+
result.component_cache.set(name, component);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
function signal_promise() {
|
|
98
|
+
let resolve = () => {
|
|
99
|
+
};
|
|
100
|
+
let reject = () => {
|
|
101
|
+
};
|
|
102
|
+
const promise = new Promise((res, rej) => {
|
|
103
|
+
resolve = res;
|
|
104
|
+
reject = rej;
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
...promise,
|
|
108
|
+
resolve,
|
|
109
|
+
reject
|
|
110
|
+
};
|
|
111
|
+
}
|
|
27
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
113
|
0 && (module.exports = {
|
|
29
|
-
|
|
114
|
+
Router,
|
|
115
|
+
router_cache
|
|
30
116
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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 manifest_exports = {};
|
|
20
|
+
__export(manifest_exports, {
|
|
21
|
+
default: () => manifest_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(manifest_exports);
|
|
24
|
+
const manifest = {};
|
|
25
|
+
var manifest_default = manifest;
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {});
|
|
@@ -22,21 +22,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var
|
|
26
|
-
__export(
|
|
27
|
-
|
|
25
|
+
var Link_exports = {};
|
|
26
|
+
__export(Link_exports, {
|
|
27
|
+
Link: () => Link
|
|
28
28
|
});
|
|
29
|
-
module.exports = __toCommonJS(
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
module.exports = __toCommonJS(Link_exports);
|
|
30
|
+
var import_react = __toESM(require("react"));
|
|
31
|
+
var import_Router = require("./Router");
|
|
32
|
+
function Link({
|
|
33
|
+
href,
|
|
34
|
+
children,
|
|
35
|
+
style,
|
|
36
|
+
...props
|
|
37
|
+
}) {
|
|
38
|
+
const { goto } = (0, import_Router.useNavigationContext)();
|
|
39
|
+
const [pending, startTransition] = (0, import_react.useTransition)();
|
|
40
|
+
const click = (e) => {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
startTransition(() => {
|
|
43
|
+
goto(href);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ import_react.default.createElement("a", { href, onClick: click, style, ...props }, children);
|
|
38
47
|
}
|
|
39
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
49
|
0 && (module.exports = {
|
|
41
|
-
|
|
50
|
+
Link
|
|
42
51
|
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
+
import { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
|
|
3
|
+
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
+
import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
|
+
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { SuspenseCache } from '../lib/cache';
|
|
8
|
+
import type { NavigationContext, RouterManifest } from '../lib/types';
|
|
9
|
+
/**
|
|
10
|
+
* Router is the top level entry point for the filesystem-based router.
|
|
11
|
+
* It is responsible for loading various page sources (including API fetches) and
|
|
12
|
+
* then rendering when appropriate.
|
|
13
|
+
*/
|
|
14
|
+
export declare function Router({ manifest, intialURL, loaded_queries, loaded_artifacts, }: {
|
|
15
|
+
manifest: RouterManifest;
|
|
16
|
+
intialURL?: string;
|
|
17
|
+
loaded_queries?: Record<string, {
|
|
18
|
+
data: GraphQLObject;
|
|
19
|
+
variables: GraphQLVariables;
|
|
20
|
+
}>;
|
|
21
|
+
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
22
|
+
}): JSX.Element;
|
|
23
|
+
export declare function useNavigationContext(): NavigationContext;
|
|
24
|
+
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
|
|
25
|
+
children: React.ReactElement;
|
|
26
|
+
client: HoudiniClient;
|
|
27
|
+
cache: Cache;
|
|
28
|
+
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
29
|
+
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
30
|
+
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
31
|
+
pending_cache: PendingCache;
|
|
32
|
+
last_variables: LRUCache<GraphQLVariables>;
|
|
33
|
+
session?: App.Session;
|
|
34
|
+
}): JSX.Element;
|
|
35
|
+
type RouterContext = {
|
|
36
|
+
client: HoudiniClient;
|
|
37
|
+
cache: Cache;
|
|
38
|
+
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
39
|
+
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
40
|
+
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
41
|
+
pending_cache: PendingCache;
|
|
42
|
+
last_variables: LRUCache<GraphQLVariables>;
|
|
43
|
+
session: App.Session;
|
|
44
|
+
};
|
|
45
|
+
export type PendingCache = SuspenseCache<Promise<void> & {
|
|
46
|
+
resolve: () => void;
|
|
47
|
+
reject: () => void;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const useRouterContext: () => RouterContext;
|
|
50
|
+
export declare function useClient(): HoudiniClient;
|
|
51
|
+
export declare function useCache(): Cache;
|
|
52
|
+
export declare function updateLocalSession(session: App.Session): void;
|
|
53
|
+
export declare function useSession(): App.Session;
|
|
54
|
+
export declare function useCurrentVariables(): GraphQLVariables;
|
|
55
|
+
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
|
|
56
|
+
export {};
|