houdini-react 1.2.0-react.1 → 1.2.6

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 (127) 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 +1 -0
  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 +4 -2
  13. package/build/plugin/vite.d.ts +19 -0
  14. package/build/plugin-cjs/index.js +32672 -1115
  15. package/build/plugin-esm/index.js +32666 -1111
  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 +29 -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 +52 -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 +24 -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 +0 -1
  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 +13 -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/useQuery.d.ts +3 -3
  52. package/build/runtime-cjs/hooks/useQueryHandle.d.ts +3 -3
  53. package/build/runtime-cjs/hooks/useQueryHandle.js +4 -4
  54. package/build/runtime-cjs/hooks/useSubscription.d.ts +2 -2
  55. package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +3 -3
  56. package/build/runtime-cjs/index.d.ts +29 -1
  57. package/build/runtime-cjs/index.js +87 -3
  58. package/build/runtime-cjs/manifest.d.ts +3 -0
  59. package/build/runtime-cjs/manifest.js +27 -0
  60. package/build/runtime-cjs/routing/components/Link.d.ts +5 -0
  61. package/build/runtime-cjs/{hooks/useHoudiniClient.js → routing/components/Link.js} +22 -13
  62. package/build/runtime-cjs/routing/components/Router.d.ts +52 -0
  63. package/build/runtime-cjs/routing/components/Router.js +267 -0
  64. package/build/runtime-cjs/routing/components/index.d.ts +2 -0
  65. package/build/runtime-cjs/{context.js → routing/components/index.js} +13 -19
  66. package/build/runtime-cjs/routing/index.d.ts +3 -0
  67. package/build/runtime-cjs/routing/index.js +30 -0
  68. package/build/runtime-cjs/routing/lib/cache.d.ts +7 -0
  69. package/build/runtime-cjs/{lib → routing/lib}/cache.js +23 -40
  70. package/build/runtime-cjs/routing/lib/match.d.ts +38 -0
  71. package/build/runtime-cjs/routing/lib/match.js +149 -0
  72. package/build/runtime-cjs/routing/lib/types.d.ts +24 -0
  73. package/build/runtime-cjs/routing/lib/types.js +16 -0
  74. package/build/runtime-esm/client.d.ts +3 -0
  75. package/build/runtime-esm/client.js +4 -0
  76. package/build/runtime-esm/clientPlugin.d.ts +3 -0
  77. package/build/runtime-esm/clientPlugin.js +17 -0
  78. package/build/runtime-esm/hooks/useDocumentHandle.d.ts +4 -4
  79. package/build/runtime-esm/hooks/useDocumentHandle.js +1 -4
  80. package/build/runtime-esm/hooks/useDocumentStore.d.ts +6 -5
  81. package/build/runtime-esm/hooks/useDocumentStore.js +9 -4
  82. package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +4 -3
  83. package/build/runtime-esm/hooks/useDocumentSubscription.js +13 -8
  84. package/build/runtime-esm/hooks/useFragment.d.ts +3 -2
  85. package/build/runtime-esm/hooks/useFragment.js +9 -7
  86. package/build/runtime-esm/hooks/useFragmentHandle.d.ts +2 -3
  87. package/build/runtime-esm/hooks/useMutation.d.ts +2 -2
  88. package/build/runtime-esm/hooks/useQuery.d.ts +3 -3
  89. package/build/runtime-esm/hooks/useQueryHandle.d.ts +3 -3
  90. package/build/runtime-esm/hooks/useQueryHandle.js +4 -4
  91. package/build/runtime-esm/hooks/useSubscription.d.ts +2 -2
  92. package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +3 -3
  93. package/build/runtime-esm/index.d.ts +29 -1
  94. package/build/runtime-esm/index.js +79 -2
  95. package/build/runtime-esm/manifest.d.ts +3 -0
  96. package/build/runtime-esm/manifest.js +5 -0
  97. package/build/runtime-esm/routing/components/Link.d.ts +5 -0
  98. package/build/runtime-esm/routing/components/Link.js +21 -0
  99. package/build/runtime-esm/routing/components/Router.d.ts +52 -0
  100. package/build/runtime-esm/routing/components/Router.js +230 -0
  101. package/build/runtime-esm/routing/components/index.d.ts +2 -0
  102. package/build/runtime-esm/routing/components/index.js +8 -0
  103. package/build/runtime-esm/routing/index.d.ts +3 -0
  104. package/build/runtime-esm/routing/index.js +5 -0
  105. package/build/runtime-esm/routing/lib/cache.d.ts +7 -0
  106. package/build/runtime-esm/routing/lib/cache.js +29 -0
  107. package/build/runtime-esm/routing/lib/match.d.ts +38 -0
  108. package/build/runtime-esm/routing/lib/match.js +122 -0
  109. package/build/runtime-esm/routing/lib/types.d.ts +24 -0
  110. package/build/runtime-esm/routing/lib/types.js +0 -0
  111. package/package.json +7 -11
  112. package/build/next/index.d.ts +0 -2
  113. package/build/next-cjs/package.json +0 -1
  114. package/build/next-esm/index.js +0 -26
  115. package/build/next-esm/package.json +0 -1
  116. package/build/runtime/context.d.ts +0 -7
  117. package/build/runtime/hooks/useHoudiniClient.d.ts +0 -2
  118. package/build/runtime/lib/cache.d.ts +0 -62
  119. package/build/runtime-cjs/context.d.ts +0 -7
  120. package/build/runtime-cjs/hooks/useHoudiniClient.d.ts +0 -2
  121. package/build/runtime-cjs/lib/cache.d.ts +0 -62
  122. package/build/runtime-esm/context.d.ts +0 -7
  123. package/build/runtime-esm/context.js +0 -10
  124. package/build/runtime-esm/hooks/useHoudiniClient.d.ts +0 -2
  125. package/build/runtime-esm/hooks/useHoudiniClient.js +0 -12
  126. package/build/runtime-esm/lib/cache.d.ts +0 -62
  127. package/build/runtime-esm/lib/cache.js +0 -47
@@ -0,0 +1,3 @@
1
+ import type { HoudiniClient } from '$houdini/runtime/client';
2
+ declare const _default: HoudiniClient;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { ClientPlugin } from 'houdini';
2
+ declare const plugin: () => ClientPlugin;
3
+ export default plugin;
@@ -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,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,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,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
  };
@@ -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,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,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,30 @@
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, }: {
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
+ } & RouterCache): JSX.Element;
19
+ type RouterCache = {
20
+ artifact_cache: SuspenseCache<QueryArtifact>;
21
+ component_cache: SuspenseCache<(props: any) => React.ReactElement>;
22
+ data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
23
+ last_variables: LRUCache<GraphQLVariables>;
24
+ pending_cache: PendingCache;
25
+ };
26
+ export declare function router_cache({ pending_queries, artifacts, components, }?: {
27
+ pending_queries?: string[];
28
+ artifacts?: Record<string, QueryArtifact>;
29
+ components?: Record<string, (props: any) => React.ReactElement>;
30
+ }): RouterCache;
@@ -0,0 +1,3 @@
1
+ import type { RouterManifest } from './routing';
2
+ declare const manifest: RouterManifest;
3
+ export default manifest;
@@ -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,52 @@
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, }: {
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
+ }): JSX.Element;
34
+ type RouterContext = {
35
+ client: HoudiniClient;
36
+ cache: Cache;
37
+ artifact_cache: SuspenseCache<QueryArtifact>;
38
+ component_cache: SuspenseCache<(props: any) => React.ReactElement>;
39
+ data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
40
+ pending_cache: PendingCache;
41
+ last_variables: LRUCache<GraphQLVariables>;
42
+ };
43
+ export type PendingCache = SuspenseCache<Promise<void> & {
44
+ resolve: () => void;
45
+ reject: () => void;
46
+ }>;
47
+ export declare const useRouterContext: () => RouterContext;
48
+ export declare function useClient(): HoudiniClient;
49
+ export declare function useCache(): Cache;
50
+ export declare function useCurrentVariables(): GraphQLVariables;
51
+ export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
52
+ export {};
@@ -0,0 +1,2 @@
1
+ export { Link } from './Link';
2
+ export { Router, RouterContextProvider, useClient } from './Router';
@@ -0,0 +1,3 @@
1
+ export * from './components';
2
+ export { suspense_cache } from './lib/cache';
3
+ export type { RouterManifest, RouterPageManifest } from './lib/types';
@@ -0,0 +1,7 @@
1
+ import { LRUCache } from '$houdini/runtime/lib/lru';
2
+ export declare function suspense_cache<T>(): SuspenseCache<T>;
3
+ export declare class SuspenseCache<_Data> extends LRUCache<_Data> {
4
+ #private;
5
+ get(key: string): _Data;
6
+ set(key: string, value: _Data): void;
7
+ }
@@ -0,0 +1,38 @@
1
+ import type { GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ import type { RouterManifest, RouterPageManifest } from './types';
3
+ export type RouteParam = {
4
+ name: string;
5
+ matcher: string;
6
+ optional: boolean;
7
+ rest: boolean;
8
+ chained: boolean;
9
+ };
10
+ export interface ParamMatcher {
11
+ (param: string): boolean;
12
+ }
13
+ export declare function find_match(manifest: RouterManifest, current: string, allowNull: true): [RouterPageManifest | null, GraphQLVariables];
14
+ export declare function find_match(manifest: RouterManifest, current: string, allowNull?: false): [RouterPageManifest, GraphQLVariables];
15
+ /**
16
+ * Creates the regex pattern, extracts parameter names, and generates types for a route
17
+ */
18
+ export declare function parse_page_pattern(id: string): {
19
+ pattern: RegExp;
20
+ params: RouteParam[];
21
+ page_id: string;
22
+ };
23
+ /**
24
+ * Splits a route id into its segments, removing segments that
25
+ * don't affect the path (i.e. groups). The root route is represented by `/`
26
+ * and will be returned as `['']`.
27
+ */
28
+ export declare function get_route_segments(route: string): string[];
29
+ export declare function exec(match: RegExpMatchArray, params: RouteParam[]): Record<string, string> | undefined;
30
+ /**
31
+ Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
34
+
35
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
+ */
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { QueryArtifact } from '$houdini/runtime/lib/types';
3
+ import type { RouteParam } from './match';
4
+ export type RouterManifest = {
5
+ pages: Record<string, RouterPageManifest>;
6
+ };
7
+ export type RouterPageManifest = {
8
+ id: string;
9
+ pattern: RegExp;
10
+ params: RouteParam[];
11
+ documents: Record<string, {
12
+ artifact: () => Promise<{
13
+ default: QueryArtifact;
14
+ }>;
15
+ loading: boolean;
16
+ }>;
17
+ component: () => Promise<{
18
+ default: (props: any) => React.ReactElement;
19
+ }>;
20
+ };
21
+ export type NavigationContext = {
22
+ currentRoute: string;
23
+ goto: (route: string) => void;
24
+ };
@@ -0,0 +1,3 @@
1
+ import type { HoudiniClient } from '$houdini/runtime/client';
2
+ declare const _default: HoudiniClient;
3
+ export default _default;
@@ -0,0 +1,26 @@
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 client_exports = {};
20
+ __export(client_exports, {
21
+ default: () => client_default
22
+ });
23
+ module.exports = __toCommonJS(client_exports);
24
+ var client_default = {};
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {});
@@ -0,0 +1,3 @@
1
+ import type { ClientPlugin } from 'houdini';
2
+ declare const plugin: () => ClientPlugin;
3
+ export default plugin;
@@ -1,4 +1,3 @@
1
- const require = conflict_free(import.meta.url);
2
1
  "use strict";
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -17,34 +16,24 @@ var __copyProps = (to, from, except, desc) => {
17
16
  return to;
18
17
  };
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/next/index.ts
22
- var next_exports = {};
23
- __export(next_exports, {
24
- withHoudini: () => withHoudini
19
+ var clientPlugin_exports = {};
20
+ __export(clientPlugin_exports, {
21
+ default: () => clientPlugin_default
25
22
  });
26
- module.exports = __toCommonJS(next_exports);
27
- function withHoudini(nextConfig) {
23
+ module.exports = __toCommonJS(clientPlugin_exports);
24
+ const plugin = () => () => {
28
25
  return {
29
- ...nextConfig,
30
- webpack(config, options) {
31
- config.module.rules.push({
32
- test: /\.(jsx|tsx)$/,
33
- use: [
34
- options.defaultLoaders.babel,
35
- {
36
- loader: "houdini/webpack"
37
- }
38
- ]
26
+ beforeNetwork(ctx, { next }) {
27
+ next({
28
+ ...ctx,
29
+ cacheParams: {
30
+ ...ctx.fetchParams,
31
+ serverSideFallback: false
32
+ }
39
33
  });
40
- if (nextConfig && typeof nextConfig.webpack === "function") {
41
- return nextConfig.webpack(config, options);
42
- }
43
- return config;
44
34
  }
45
35
  };
46
- }
36
+ };
37
+ var clientPlugin_default = plugin;
47
38
  // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- withHoudini
50
- });
39
+ 0 && (module.exports = {});
@@ -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>;
@@ -61,7 +61,6 @@ function useDocumentHandle({
61
61
  artifact,
62
62
  getState: () => storeValue.data,
63
63
  getVariables: () => storeValue.variables,
64
- storeName: artifact.name,
65
64
  fetch: fetchQuery,
66
65
  fetchUpdate: (args, updates) => {
67
66
  return observer.send({
@@ -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
@@ -28,16 +28,17 @@ __export(useDocumentStore_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(useDocumentStore_exports);
30
30
  var React = __toESM(require("react"));
31
- var import_useHoudiniClient = require("./useHoudiniClient");
31
+ var import_routing = require("../routing");
32
32
  var import_useIsMounted = require("./useIsMounted");
33
33
  function useDocumentStore({
34
34
  artifact,
35
+ observer: obs,
35
36
  ...observeParams
36
37
  }) {
37
- const client = (0, import_useHoudiniClient.useHoudiniClient)();
38
+ const client = (0, import_routing.useClient)();
38
39
  const isMountedRef = (0, import_useIsMounted.useIsMountedRef)();
39
40
  let [observer, setObserver] = React.useState(
40
- () => client.observe({
41
+ () => obs ?? client.observe({
41
42
  artifact,
42
43
  ...observeParams
43
44
  })
@@ -54,7 +55,11 @@ function useDocumentStore({
54
55
  },
55
56
  [observer]
56
57
  );
57
- const storeValue = React.useSyncExternalStore(subscribe, () => box.current);
58
+ const storeValue = React.useSyncExternalStore(
59
+ subscribe,
60
+ () => box.current,
61
+ () => box.current
62
+ );
58
63
  return [storeValue, observer, setObserver];
59
64
  }
60
65
  // Annotate the CommonJS export names for ESM import in node:
@@ -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> & {
@@ -33,6 +33,7 @@ function useDocumentSubscription({
33
33
  artifact,
34
34
  variables,
35
35
  send,
36
+ disabled,
36
37
  ...observeParams
37
38
  }) {
38
39
  const [storeValue, observer, setObserver] = (0, import_useDocumentStore.useDocumentStore)({
@@ -40,16 +41,20 @@ function useDocumentSubscription({
40
41
  ...observeParams
41
42
  });
42
43
  (0, import_useDeepCompareEffect.default)(() => {
43
- observer.send({
44
- variables,
45
- session: {},
46
- metadata: {},
47
- ...send
48
- });
44
+ if (!disabled) {
45
+ observer.send({
46
+ variables,
47
+ session: {},
48
+ metadata: {},
49
+ ...send
50
+ });
51
+ }
49
52
  return () => {
50
- observer.cleanup();
53
+ if (!disabled) {
54
+ observer.cleanup();
55
+ }
51
56
  };
52
- }, [observer, variables ?? {}, send ?? {}]);
57
+ }, [disabled, observer, variables ?? {}, send ?? {}]);
53
58
  return [
54
59
  {
55
60
  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
  };
@@ -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 observeParams = {
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
- return { variables, parent };
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 = {