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.
Files changed (134) hide show
  1. package/README.md +1 -1
  2. package/build/plugin/codegen/entries.d.ts +6 -0
  3. package/build/plugin/codegen/index.d.ts +14 -0
  4. package/build/plugin/codegen/manifest.d.ts +42 -0
  5. package/build/plugin/codegen/render.d.ts +2 -0
  6. package/build/plugin/codegen/router.d.ts +8 -0
  7. package/build/plugin/codegen/typeRoot.d.ts +6 -0
  8. package/build/plugin/config.d.ts +2 -1
  9. package/build/plugin/conventions.d.ts +24 -0
  10. package/build/plugin/dedent.d.ts +1 -0
  11. package/build/plugin/extract.d.ts +1 -1
  12. package/build/plugin/index.d.ts +16 -3
  13. package/build/plugin/vite.d.ts +19 -0
  14. package/build/plugin-cjs/index.js +132171 -43771
  15. package/build/plugin-esm/index.js +132162 -43765
  16. package/build/runtime/client.d.ts +3 -0
  17. package/build/runtime/clientPlugin.d.ts +3 -0
  18. package/build/runtime/hooks/useDocumentHandle.d.ts +4 -4
  19. package/build/runtime/hooks/useDocumentStore.d.ts +6 -5
  20. package/build/runtime/hooks/useDocumentSubscription.d.ts +4 -3
  21. package/build/runtime/hooks/useFragment.d.ts +3 -2
  22. package/build/runtime/hooks/useFragmentHandle.d.ts +2 -3
  23. package/build/runtime/hooks/useMutation.d.ts +2 -2
  24. package/build/runtime/hooks/useQuery.d.ts +3 -3
  25. package/build/runtime/hooks/useQueryHandle.d.ts +3 -3
  26. package/build/runtime/hooks/useSubscription.d.ts +2 -2
  27. package/build/runtime/hooks/useSubscriptionHandle.d.ts +3 -3
  28. package/build/runtime/index.d.ts +30 -1
  29. package/build/runtime/manifest.d.ts +3 -0
  30. package/build/runtime/routing/components/Link.d.ts +5 -0
  31. package/build/runtime/routing/components/Router.d.ts +56 -0
  32. package/build/runtime/routing/components/index.d.ts +2 -0
  33. package/build/runtime/routing/index.d.ts +3 -0
  34. package/build/runtime/routing/lib/cache.d.ts +7 -0
  35. package/build/runtime/routing/lib/match.d.ts +38 -0
  36. package/build/runtime/routing/lib/types.d.ts +23 -0
  37. package/build/runtime-cjs/client.d.ts +3 -0
  38. package/build/runtime-cjs/client.js +26 -0
  39. package/build/runtime-cjs/clientPlugin.d.ts +3 -0
  40. package/build/{next-cjs/index.js → runtime-cjs/clientPlugin.js} +15 -26
  41. package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +4 -4
  42. package/build/runtime-cjs/hooks/useDocumentHandle.js +11 -7
  43. package/build/runtime-cjs/hooks/useDocumentStore.d.ts +6 -5
  44. package/build/runtime-cjs/hooks/useDocumentStore.js +9 -4
  45. package/build/runtime-cjs/hooks/useDocumentSubscription.d.ts +4 -3
  46. package/build/runtime-cjs/hooks/useDocumentSubscription.js +15 -8
  47. package/build/runtime-cjs/hooks/useFragment.d.ts +3 -2
  48. package/build/runtime-cjs/hooks/useFragment.js +9 -7
  49. package/build/runtime-cjs/hooks/useFragmentHandle.d.ts +2 -3
  50. package/build/runtime-cjs/hooks/useMutation.d.ts +2 -2
  51. package/build/runtime-cjs/hooks/useMutation.js +3 -1
  52. package/build/runtime-cjs/hooks/useQuery.d.ts +3 -3
  53. package/build/runtime-cjs/hooks/useQueryHandle.d.ts +3 -3
  54. package/build/runtime-cjs/hooks/useQueryHandle.js +4 -4
  55. package/build/runtime-cjs/hooks/useSubscription.d.ts +2 -2
  56. package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +3 -3
  57. package/build/runtime-cjs/index.d.ts +30 -1
  58. package/build/runtime-cjs/index.js +89 -3
  59. package/build/runtime-cjs/manifest.d.ts +3 -0
  60. package/build/runtime-cjs/manifest.js +27 -0
  61. package/build/runtime-cjs/routing/components/Link.d.ts +5 -0
  62. package/build/runtime-cjs/{hooks/useHoudiniClient.js → routing/components/Link.js} +22 -13
  63. package/build/runtime-cjs/routing/components/Router.d.ts +56 -0
  64. package/build/runtime-cjs/routing/components/Router.js +296 -0
  65. package/build/runtime-cjs/routing/components/index.d.ts +2 -0
  66. package/build/runtime-cjs/{context.js → routing/components/index.js} +15 -19
  67. package/build/runtime-cjs/routing/index.d.ts +3 -0
  68. package/build/runtime-cjs/routing/index.js +30 -0
  69. package/build/runtime-cjs/routing/lib/cache.d.ts +7 -0
  70. package/build/runtime-cjs/{lib → routing/lib}/cache.js +23 -40
  71. package/build/runtime-cjs/routing/lib/match.d.ts +38 -0
  72. package/build/runtime-cjs/routing/lib/match.js +149 -0
  73. package/build/runtime-cjs/routing/lib/types.d.ts +23 -0
  74. package/build/runtime-cjs/routing/lib/types.js +16 -0
  75. package/build/runtime-esm/client.d.ts +3 -0
  76. package/build/runtime-esm/client.js +4 -0
  77. package/build/runtime-esm/clientPlugin.d.ts +3 -0
  78. package/build/runtime-esm/clientPlugin.js +17 -0
  79. package/build/runtime-esm/hooks/useDocumentHandle.d.ts +4 -4
  80. package/build/runtime-esm/hooks/useDocumentHandle.js +12 -10
  81. package/build/runtime-esm/hooks/useDocumentStore.d.ts +6 -5
  82. package/build/runtime-esm/hooks/useDocumentStore.js +9 -4
  83. package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +4 -3
  84. package/build/runtime-esm/hooks/useDocumentSubscription.js +15 -8
  85. package/build/runtime-esm/hooks/useFragment.d.ts +3 -2
  86. package/build/runtime-esm/hooks/useFragment.js +9 -7
  87. package/build/runtime-esm/hooks/useFragmentHandle.d.ts +2 -3
  88. package/build/runtime-esm/hooks/useMutation.d.ts +2 -2
  89. package/build/runtime-esm/hooks/useMutation.js +3 -1
  90. package/build/runtime-esm/hooks/useQuery.d.ts +3 -3
  91. package/build/runtime-esm/hooks/useQueryHandle.d.ts +3 -3
  92. package/build/runtime-esm/hooks/useQueryHandle.js +4 -4
  93. package/build/runtime-esm/hooks/useSubscription.d.ts +2 -2
  94. package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +3 -3
  95. package/build/runtime-esm/index.d.ts +30 -1
  96. package/build/runtime-esm/index.js +81 -2
  97. package/build/runtime-esm/manifest.d.ts +3 -0
  98. package/build/runtime-esm/manifest.js +5 -0
  99. package/build/runtime-esm/routing/components/Link.d.ts +5 -0
  100. package/build/runtime-esm/routing/components/Link.js +21 -0
  101. package/build/runtime-esm/routing/components/Router.d.ts +56 -0
  102. package/build/runtime-esm/routing/components/Router.js +257 -0
  103. package/build/runtime-esm/routing/components/index.d.ts +2 -0
  104. package/build/runtime-esm/routing/components/index.js +9 -0
  105. package/build/runtime-esm/routing/index.d.ts +3 -0
  106. package/build/runtime-esm/routing/index.js +5 -0
  107. package/build/runtime-esm/routing/lib/cache.d.ts +7 -0
  108. package/build/runtime-esm/routing/lib/cache.js +29 -0
  109. package/build/runtime-esm/routing/lib/match.d.ts +38 -0
  110. package/build/runtime-esm/routing/lib/match.js +122 -0
  111. package/build/runtime-esm/routing/lib/types.d.ts +23 -0
  112. package/build/runtime-esm/routing/lib/types.js +0 -0
  113. package/build/server/compat.d.ts +7 -0
  114. package/build/server/index.d.ts +17 -0
  115. package/build/server/session.d.ts +3 -0
  116. package/build/server-cjs/index.js +166712 -0
  117. package/build/server-esm/index.js +166703 -0
  118. package/package.json +21 -10
  119. package/build/next/index.d.ts +0 -2
  120. package/build/next-esm/index.js +0 -26
  121. package/build/runtime/context.d.ts +0 -7
  122. package/build/runtime/hooks/useHoudiniClient.d.ts +0 -2
  123. package/build/runtime/lib/cache.d.ts +0 -62
  124. package/build/runtime-cjs/context.d.ts +0 -7
  125. package/build/runtime-cjs/hooks/useHoudiniClient.d.ts +0 -2
  126. package/build/runtime-cjs/lib/cache.d.ts +0 -62
  127. package/build/runtime-esm/context.d.ts +0 -7
  128. package/build/runtime-esm/context.js +0 -10
  129. package/build/runtime-esm/hooks/useHoudiniClient.d.ts +0 -2
  130. package/build/runtime-esm/hooks/useHoudiniClient.js +0 -12
  131. package/build/runtime-esm/lib/cache.d.ts +0 -62
  132. package/build/runtime-esm/lib/cache.js +0 -47
  133. /package/build/{next-cjs → server-cjs}/package.json +0 -0
  134. /package/build/{next-esm → server-esm}/package.json +0 -0
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,3 @@
1
+ import type { HoudiniClient } from '$houdini/runtime/client';
2
+ declare const _default: HoudiniClient;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ var client_default = {};
2
+ export {
3
+ client_default as default
4
+ };
@@ -0,0 +1,3 @@
1
+ import type { ClientPlugin } from 'houdini';
2
+ declare const plugin: () => ClientPlugin;
3
+ export default plugin;
@@ -0,0 +1,17 @@
1
+ const plugin = () => () => {
2
+ return {
3
+ beforeNetwork(ctx, { next }) {
4
+ next({
5
+ ...ctx,
6
+ cacheParams: {
7
+ ...ctx.fetchParams,
8
+ serverSideFallback: false
9
+ }
10
+ });
11
+ }
12
+ };
13
+ };
14
+ var clientPlugin_default = plugin;
15
+ export {
16
+ clientPlugin_default as default
17
+ };
@@ -1,13 +1,13 @@
1
- import { DocumentStore } from '$houdini/runtime/client';
2
- import { type QueryArtifact, GraphQLObject, CursorHandlers, OffsetHandlers, PageInfo, FetchFn, QueryResult, DocumentArtifact } from '$houdini/runtime/lib/types';
3
- export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, observer, storeValue, }: {
1
+ import type { DocumentStore } from '$houdini/runtime/client';
2
+ import type { GraphQLObject, GraphQLVariables, CursorHandlers, OffsetHandlers, PageInfo, FetchFn, QueryResult, DocumentArtifact, QueryArtifact } from '$houdini/runtime/lib/types';
3
+ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input extends GraphQLVariables>({ artifact, observer, storeValue, }: {
4
4
  artifact: DocumentArtifact;
5
5
  observer: DocumentStore<_Data, _Input>;
6
6
  storeValue: QueryResult<_Data, _Input>;
7
7
  }): DocumentHandle<_Artifact, _Data, _Input> & {
8
8
  fetch: FetchFn<_Data, _Input>;
9
9
  };
10
- export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []> = {
10
+ export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
11
11
  data: _Data;
12
12
  partial: boolean;
13
13
  } & RefetchHandlers<_Artifact, _Data, _Input>;
@@ -1,9 +1,8 @@
1
1
  import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
2
2
  import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
3
- import {
4
- ArtifactKind
5
- } from "$houdini/runtime/lib/types";
3
+ import { ArtifactKind } from "$houdini/runtime/lib/types";
6
4
  import React from "react";
5
+ import { useSession } from "../routing/components/Router";
7
6
  function useDocumentHandle({
8
7
  artifact,
9
8
  observer,
@@ -11,6 +10,7 @@ function useDocumentHandle({
11
10
  }) {
12
11
  const [forwardPending, setForwardPending] = React.useState(false);
13
12
  const [backwardPending, setBackwardPending] = React.useState(false);
13
+ const session = useSession();
14
14
  return React.useMemo(() => {
15
15
  const wrapLoad = (setLoading, fn) => {
16
16
  return async (value) => {
@@ -20,7 +20,10 @@ function useDocumentHandle({
20
20
  return result;
21
21
  };
22
22
  };
23
- const fetchQuery = (args) => observer.send(args);
23
+ const fetchQuery = (args) => observer.send({
24
+ ...args,
25
+ session
26
+ });
24
27
  if (artifact.kind !== ArtifactKind.Query || !artifact.refetch?.paginated) {
25
28
  return {
26
29
  data: storeValue.data,
@@ -28,13 +31,11 @@ function useDocumentHandle({
28
31
  partial: storeValue.partial
29
32
  };
30
33
  }
31
- const getSession = async () => ({});
32
34
  if (artifact.refetch.method === "cursor") {
33
35
  const handlers = cursorHandlers({
34
36
  artifact,
35
37
  getState: () => storeValue.data,
36
38
  getVariables: () => storeValue.variables,
37
- storeName: artifact.name,
38
39
  fetch: fetchQuery,
39
40
  fetchUpdate: (args, updates) => {
40
41
  return observer.send({
@@ -43,10 +44,11 @@ function useDocumentHandle({
43
44
  disableSubscriptions: true,
44
45
  applyUpdates: updates,
45
46
  ...args?.cacheParams
46
- }
47
+ },
48
+ session
47
49
  });
48
50
  },
49
- getSession
51
+ getSession: async () => session
50
52
  });
51
53
  return {
52
54
  data: storeValue.data,
@@ -76,7 +78,7 @@ function useDocumentHandle({
76
78
  }
77
79
  });
78
80
  },
79
- getSession: async () => ({})
81
+ getSession: async () => session
80
82
  });
81
83
  return {
82
84
  data: storeValue.data,
@@ -92,7 +94,7 @@ function useDocumentHandle({
92
94
  refetch: fetchQuery,
93
95
  partial: storeValue.partial
94
96
  };
95
- }, [artifact, observer, storeValue, true, true]);
97
+ }, [artifact, observer, session, storeValue, true, true]);
96
98
  }
97
99
  export {
98
100
  useDocumentHandle
@@ -1,10 +1,11 @@
1
- import type { DocumentArtifact, QueryResult } from '$houdini/lib/types';
1
+ import type { DocumentArtifact, GraphQLVariables, QueryResult } from '$houdini/lib/types';
2
2
  import type { DocumentStore, ObserveParams } from '$houdini/runtime/client';
3
- import { GraphQLObject } from 'houdini';
4
- export type UseDocumentStoreParams<_Artifact extends DocumentArtifact, _Data extends GraphQLObject> = {
3
+ import type { GraphQLObject } from 'houdini';
4
+ export type UseDocumentStoreParams<_Artifact extends DocumentArtifact, _Data extends GraphQLObject, _Input extends GraphQLVariables> = {
5
5
  artifact: _Artifact;
6
- } & Partial<ObserveParams<_Data>>;
7
- export declare function useDocumentStore<_Data extends GraphQLObject = GraphQLObject, _Input extends {} = {}, _Artifact extends DocumentArtifact = DocumentArtifact>({ artifact, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data>): [
6
+ observer?: DocumentStore<_Data, _Input>;
7
+ } & Partial<ObserveParams<_Data, DocumentArtifact, _Input>>;
8
+ export declare function useDocumentStore<_Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables, _Artifact extends DocumentArtifact = DocumentArtifact>({ artifact, observer: obs, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data, _Input>): [
8
9
  QueryResult<_Data, _Input>,
9
10
  DocumentStore<_Data, _Input>,
10
11
  (store: DocumentStore<_Data, _Input>) => void
@@ -1,14 +1,15 @@
1
1
  import * as React from "react";
2
- import { useHoudiniClient } from "./useHoudiniClient";
2
+ import { useClient } from "../routing";
3
3
  import { useIsMountedRef } from "./useIsMounted";
4
4
  function useDocumentStore({
5
5
  artifact,
6
+ observer: obs,
6
7
  ...observeParams
7
8
  }) {
8
- const client = useHoudiniClient();
9
+ const client = useClient();
9
10
  const isMountedRef = useIsMountedRef();
10
11
  let [observer, setObserver] = React.useState(
11
- () => client.observe({
12
+ () => obs ?? client.observe({
12
13
  artifact,
13
14
  ...observeParams
14
15
  })
@@ -25,7 +26,11 @@ function useDocumentStore({
25
26
  },
26
27
  [observer]
27
28
  );
28
- const storeValue = React.useSyncExternalStore(subscribe, () => box.current);
29
+ const storeValue = React.useSyncExternalStore(
30
+ subscribe,
31
+ () => box.current,
32
+ () => box.current
33
+ );
29
34
  return [storeValue, observer, setObserver];
30
35
  }
31
36
  export {
@@ -1,9 +1,10 @@
1
- import type { DocumentArtifact, QueryResult } from '$houdini/lib/types';
1
+ import type { DocumentArtifact, GraphQLVariables, QueryResult } from '$houdini/lib/types';
2
2
  import type { DocumentStore, SendParams } from '$houdini/runtime/client';
3
- import { GraphQLObject } from 'houdini';
3
+ import type { GraphQLObject } from 'houdini';
4
4
  import { type UseDocumentStoreParams } from './useDocumentStore';
5
- export declare function useDocumentSubscription<_Artifact extends DocumentArtifact = DocumentArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = {}>({ artifact, variables, send, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data> & {
5
+ export declare function useDocumentSubscription<_Artifact extends DocumentArtifact = DocumentArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables>({ artifact, variables, send, disabled, ...observeParams }: UseDocumentStoreParams<_Artifact, _Data, _Input> & {
6
6
  variables: _Input;
7
+ disabled?: boolean;
7
8
  send?: Partial<SendParams>;
8
9
  }): [
9
10
  QueryResult<_Data, _Input> & {
@@ -1,26 +1,33 @@
1
+ import { useSession } from "../routing/components/Router";
1
2
  import useDeepCompareEffect from "./useDeepCompareEffect";
2
3
  import { useDocumentStore } from "./useDocumentStore";
3
4
  function useDocumentSubscription({
4
5
  artifact,
5
6
  variables,
6
7
  send,
8
+ disabled,
7
9
  ...observeParams
8
10
  }) {
9
11
  const [storeValue, observer, setObserver] = useDocumentStore({
10
12
  artifact,
11
13
  ...observeParams
12
14
  });
15
+ const session = useSession();
13
16
  useDeepCompareEffect(() => {
14
- observer.send({
15
- variables,
16
- session: {},
17
- metadata: {},
18
- ...send
19
- });
17
+ if (!disabled) {
18
+ observer.send({
19
+ variables,
20
+ session,
21
+ metadata: {},
22
+ ...send
23
+ });
24
+ }
20
25
  return () => {
21
- observer.cleanup();
26
+ if (!disabled) {
27
+ observer.cleanup();
28
+ }
22
29
  };
23
- }, [observer, variables ?? {}, send ?? {}]);
30
+ }, [disabled, session, observer, variables ?? {}, send ?? {}]);
24
31
  return [
25
32
  {
26
33
  parent: send?.stuff?.parentID,
@@ -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 {} = {}>(reference: _Data | {
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
  };
@@ -5,7 +5,7 @@ import * as React from "react";
5
5
  import { useDeepCompareMemoize } from "./useDeepCompareEffect";
6
6
  import { useDocumentSubscription } from "./useDocumentSubscription";
7
7
  function useFragment(reference, document) {
8
- const { parent, variables } = fragmentReference(
8
+ const { parent, variables, loading } = fragmentReference(
9
9
  reference,
10
10
  document
11
11
  );
@@ -14,20 +14,21 @@ function useFragment(reference, document) {
14
14
  cachedValue = cache.read({
15
15
  selection: document.artifact.selection,
16
16
  parent,
17
- variables
17
+ variables,
18
+ loading
18
19
  }).data;
19
20
  }
20
- const observeParams = {
21
+ const [storeValue] = useDocumentSubscription({
21
22
  artifact: document.artifact,
22
23
  variables,
23
24
  initialValue: cachedValue,
25
+ disabled: loading,
24
26
  send: {
25
27
  stuff: {
26
28
  parentID: parent
27
29
  }
28
30
  }
29
- };
30
- const [storeValue] = useDocumentSubscription(observeParams);
31
+ });
31
32
  const lastReference = React.useRef(null);
32
33
  return React.useMemo(() => {
33
34
  const parentChange = storeValue.parent !== parent || !deepEquals({ parent, variables }, lastReference.current);
@@ -47,14 +48,15 @@ function useFragment(reference, document) {
47
48
  ]);
48
49
  }
49
50
  function fragmentReference(reference, document) {
50
- const { variables, parent } = reference?.[fragmentKey]?.[document.artifact.name] ?? {};
51
+ const { variables, parent } = reference?.[fragmentKey]?.values?.[document.artifact.name] ?? {};
51
52
  if (reference && fragmentKey in reference && (!variables || !parent)) {
52
53
  console.warn(
53
54
  `\u26A0\uFE0F Parent does not contain the information for this fragment. Something is wrong.
54
55
  Please ensure that you have passed a record that has ${document.artifact.name} mixed into it.`
55
56
  );
56
57
  }
57
- return { variables, parent };
58
+ const loading = Boolean(reference?.[fragmentKey]?.loading);
59
+ return { variables, parent, loading };
58
60
  }
59
61
  export {
60
62
  fragmentReference,
@@ -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 {} = {}>(reference: _Data | {
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 {}, _Optimistic extends GraphQLObject>({ artifact, }: {
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>];
@@ -1,9 +1,11 @@
1
+ import { useSession } from "../routing/components/Router";
1
2
  import { useDocumentStore } from "./useDocumentStore";
2
3
  function useMutation({
3
4
  artifact
4
5
  }) {
5
6
  const [storeValue, observer] = useDocumentStore({ artifact });
6
7
  const pending = storeValue.fetching;
8
+ const session = useSession();
7
9
  const mutate = ({
8
10
  metadata,
9
11
  fetch,
@@ -12,7 +14,7 @@ function useMutation({
12
14
  }) => observer.send({
13
15
  variables,
14
16
  metadata,
15
- session: {},
17
+ session,
16
18
  stuff: {
17
19
  ...mutationConfig
18
20
  }
@@ -1,5 +1,5 @@
1
- import { type QueryArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
2
- import { UseQueryConfig } from './useQueryHandle';
3
- export declare function useQuery<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []>(document: {
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 { type QueryArtifact, GraphQLObject, CachePolicies } from '$houdini/runtime/lib/types';
2
- import { DocumentHandle } from './useDocumentHandle';
3
- export declare function useQueryHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []>({ artifact }: {
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 = {
@@ -1,13 +1,13 @@
1
+ import { createLRUCache } from "$houdini/runtime/lib/lru";
1
2
  import React from "react";
2
- import { createCache } from "../lib/cache";
3
+ import { useClient } from "../routing";
3
4
  import { useDocumentHandle } from "./useDocumentHandle";
4
- import { useHoudiniClient } from "./useHoudiniClient";
5
5
  import { useIsMountedRef } from "./useIsMounted";
6
- const promiseCache = createCache();
6
+ const promiseCache = createLRUCache();
7
7
  function useQueryHandle({ artifact }, variables = null, config = {}) {
8
8
  const identifier = queryIdentifier({ artifact, variables, config });
9
9
  const suspenseValue = promiseCache.get(identifier);
10
- const client = useHoudiniClient();
10
+ const client = useClient();
11
11
  const isMountedRef = useIsMountedRef();
12
12
  let [observer] = React.useState(
13
13
  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 {}>(document: {
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 {} | null> = {
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 {}>({ artifact }: {
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 { HoudiniProvider } from './context';
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,5 +1,84 @@
1
+ import React from "react";
2
+ import client from "./client";
3
+ import manifest from "./manifest";
4
+ import { Router as RouterImpl, RouterContextProvider } from "./routing";
5
+ import { suspense_cache } from "./routing/lib/cache";
1
6
  export * from "./hooks";
2
- import { HoudiniProvider } from "./context";
7
+ export * from "./routing";
8
+ function Router({
9
+ cache,
10
+ intialURL,
11
+ artifact_cache,
12
+ component_cache,
13
+ data_cache,
14
+ pending_cache,
15
+ last_variables,
16
+ loaded_queries,
17
+ loaded_artifacts,
18
+ session
19
+ }) {
20
+ return /* @__PURE__ */ React.createElement(
21
+ RouterContextProvider,
22
+ {
23
+ client,
24
+ cache,
25
+ artifact_cache,
26
+ component_cache,
27
+ data_cache,
28
+ pending_cache,
29
+ last_variables,
30
+ session
31
+ },
32
+ /* @__PURE__ */ React.createElement(
33
+ RouterImpl,
34
+ {
35
+ intialURL,
36
+ manifest,
37
+ loaded_queries,
38
+ loaded_artifacts
39
+ }
40
+ )
41
+ );
42
+ }
43
+ function router_cache({
44
+ pending_queries = [],
45
+ artifacts = {},
46
+ components = {}
47
+ } = {}) {
48
+ const result = {
49
+ artifact_cache: suspense_cache(),
50
+ component_cache: suspense_cache(),
51
+ data_cache: suspense_cache(),
52
+ pending_cache: suspense_cache(),
53
+ last_variables: suspense_cache()
54
+ };
55
+ for (const query of pending_queries) {
56
+ result.pending_cache.set(query, signal_promise());
57
+ }
58
+ for (const [name, artifact] of Object.entries(artifacts)) {
59
+ result.artifact_cache.set(name, artifact);
60
+ }
61
+ for (const [name, component] of Object.entries(components)) {
62
+ result.component_cache.set(name, component);
63
+ }
64
+ return result;
65
+ }
66
+ function signal_promise() {
67
+ let resolve = () => {
68
+ };
69
+ let reject = () => {
70
+ };
71
+ const promise = new Promise((res, rej) => {
72
+ resolve = res;
73
+ reject = rej;
74
+ });
75
+ return {
76
+ ...promise,
77
+ resolve,
78
+ reject
79
+ };
80
+ }
3
81
  export {
4
- HoudiniProvider
82
+ Router,
83
+ router_cache
5
84
  };
@@ -0,0 +1,3 @@
1
+ import type { RouterManifest } from './routing';
2
+ declare const manifest: RouterManifest;
3
+ export default manifest;
@@ -0,0 +1,5 @@
1
+ const manifest = {};
2
+ var manifest_default = manifest;
3
+ export {
4
+ manifest_default as default
5
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare function Link({ href, children, style, ...props }: {
3
+ href: string;
4
+ children: React.ReactNode;
5
+ } & React.AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element;
@@ -0,0 +1,21 @@
1
+ import React, { useTransition } from "react";
2
+ import { useNavigationContext } from "./Router";
3
+ function Link({
4
+ href,
5
+ children,
6
+ style,
7
+ ...props
8
+ }) {
9
+ const { goto } = useNavigationContext();
10
+ const [pending, startTransition] = useTransition();
11
+ const click = (e) => {
12
+ e.preventDefault();
13
+ startTransition(() => {
14
+ goto(href);
15
+ });
16
+ };
17
+ return /* @__PURE__ */ React.createElement("a", { href, onClick: click, style, ...props }, children);
18
+ }
19
+ export {
20
+ Link
21
+ };