houdini-react 1.2.0-react.1

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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/build/next/index.d.ts +2 -0
  4. package/build/next-cjs/index.js +50 -0
  5. package/build/next-cjs/package.json +1 -0
  6. package/build/next-esm/index.js +26 -0
  7. package/build/next-esm/package.json +1 -0
  8. package/build/plugin/config.d.ts +3 -0
  9. package/build/plugin/extract.d.ts +6 -0
  10. package/build/plugin/index.d.ts +3 -0
  11. package/build/plugin/transform.d.ts +6 -0
  12. package/build/plugin-cjs/index.js +78313 -0
  13. package/build/plugin-cjs/package.json +1 -0
  14. package/build/plugin-esm/index.js +78307 -0
  15. package/build/plugin-esm/package.json +1 -0
  16. package/build/runtime/context.d.ts +7 -0
  17. package/build/runtime/hooks/index.d.ts +8 -0
  18. package/build/runtime/hooks/useDeepCompareEffect.d.ts +35 -0
  19. package/build/runtime/hooks/useDocumentHandle.d.ts +34 -0
  20. package/build/runtime/hooks/useDocumentStore.d.ts +11 -0
  21. package/build/runtime/hooks/useDocumentSubscription.d.ts +14 -0
  22. package/build/runtime/hooks/useFragment.d.ts +15 -0
  23. package/build/runtime/hooks/useFragmentHandle.d.ts +9 -0
  24. package/build/runtime/hooks/useHoudiniClient.d.ts +2 -0
  25. package/build/runtime/hooks/useIsMounted.d.ts +3 -0
  26. package/build/runtime/hooks/useMutation.d.ts +10 -0
  27. package/build/runtime/hooks/useQuery.d.ts +5 -0
  28. package/build/runtime/hooks/useQueryHandle.d.ts +10 -0
  29. package/build/runtime/hooks/useSubscription.d.ts +4 -0
  30. package/build/runtime/hooks/useSubscriptionHandle.d.ts +25 -0
  31. package/build/runtime/index.d.ts +2 -0
  32. package/build/runtime/lib/cache.d.ts +62 -0
  33. package/build/runtime-cjs/context.d.ts +7 -0
  34. package/build/runtime-cjs/context.js +41 -0
  35. package/build/runtime-cjs/hooks/index.d.ts +8 -0
  36. package/build/runtime-cjs/hooks/index.js +45 -0
  37. package/build/runtime-cjs/hooks/useDeepCompareEffect.d.ts +35 -0
  38. package/build/runtime-cjs/hooks/useDeepCompareEffect.js +72 -0
  39. package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +34 -0
  40. package/build/runtime-cjs/hooks/useDocumentHandle.js +127 -0
  41. package/build/runtime-cjs/hooks/useDocumentStore.d.ts +11 -0
  42. package/build/runtime-cjs/hooks/useDocumentStore.js +63 -0
  43. package/build/runtime-cjs/hooks/useDocumentSubscription.d.ts +14 -0
  44. package/build/runtime-cjs/hooks/useDocumentSubscription.js +65 -0
  45. package/build/runtime-cjs/hooks/useFragment.d.ts +15 -0
  46. package/build/runtime-cjs/hooks/useFragment.js +93 -0
  47. package/build/runtime-cjs/hooks/useFragmentHandle.d.ts +9 -0
  48. package/build/runtime-cjs/hooks/useFragmentHandle.js +47 -0
  49. package/build/runtime-cjs/hooks/useHoudiniClient.d.ts +2 -0
  50. package/build/runtime-cjs/hooks/useHoudiniClient.js +42 -0
  51. package/build/runtime-cjs/hooks/useIsMounted.d.ts +3 -0
  52. package/build/runtime-cjs/hooks/useIsMounted.js +38 -0
  53. package/build/runtime-cjs/hooks/useMutation.d.ts +10 -0
  54. package/build/runtime-cjs/hooks/useMutation.js +48 -0
  55. package/build/runtime-cjs/hooks/useQuery.d.ts +5 -0
  56. package/build/runtime-cjs/hooks/useQuery.js +32 -0
  57. package/build/runtime-cjs/hooks/useQueryHandle.d.ts +10 -0
  58. package/build/runtime-cjs/hooks/useQueryHandle.js +125 -0
  59. package/build/runtime-cjs/hooks/useSubscription.d.ts +4 -0
  60. package/build/runtime-cjs/hooks/useSubscription.js +32 -0
  61. package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +25 -0
  62. package/build/runtime-cjs/hooks/useSubscriptionHandle.js +42 -0
  63. package/build/runtime-cjs/index.d.ts +2 -0
  64. package/build/runtime-cjs/index.js +30 -0
  65. package/build/runtime-cjs/lib/cache.d.ts +62 -0
  66. package/build/runtime-cjs/lib/cache.js +71 -0
  67. package/build/runtime-cjs/package.json +1 -0
  68. package/build/runtime-esm/context.d.ts +7 -0
  69. package/build/runtime-esm/context.js +10 -0
  70. package/build/runtime-esm/hooks/index.d.ts +8 -0
  71. package/build/runtime-esm/hooks/index.js +16 -0
  72. package/build/runtime-esm/hooks/useDeepCompareEffect.d.ts +35 -0
  73. package/build/runtime-esm/hooks/useDeepCompareEffect.js +41 -0
  74. package/build/runtime-esm/hooks/useDocumentHandle.d.ts +34 -0
  75. package/build/runtime-esm/hooks/useDocumentHandle.js +99 -0
  76. package/build/runtime-esm/hooks/useDocumentStore.d.ts +11 -0
  77. package/build/runtime-esm/hooks/useDocumentStore.js +33 -0
  78. package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +14 -0
  79. package/build/runtime-esm/hooks/useDocumentSubscription.js +35 -0
  80. package/build/runtime-esm/hooks/useFragment.d.ts +15 -0
  81. package/build/runtime-esm/hooks/useFragment.js +62 -0
  82. package/build/runtime-esm/hooks/useFragmentHandle.d.ts +9 -0
  83. package/build/runtime-esm/hooks/useFragmentHandle.js +23 -0
  84. package/build/runtime-esm/hooks/useHoudiniClient.d.ts +2 -0
  85. package/build/runtime-esm/hooks/useHoudiniClient.js +12 -0
  86. package/build/runtime-esm/hooks/useIsMounted.d.ts +3 -0
  87. package/build/runtime-esm/hooks/useIsMounted.js +14 -0
  88. package/build/runtime-esm/hooks/useMutation.d.ts +10 -0
  89. package/build/runtime-esm/hooks/useMutation.js +24 -0
  90. package/build/runtime-esm/hooks/useQuery.d.ts +5 -0
  91. package/build/runtime-esm/hooks/useQuery.js +8 -0
  92. package/build/runtime-esm/hooks/useQueryHandle.d.ts +10 -0
  93. package/build/runtime-esm/hooks/useQueryHandle.js +95 -0
  94. package/build/runtime-esm/hooks/useSubscription.d.ts +4 -0
  95. package/build/runtime-esm/hooks/useSubscription.js +8 -0
  96. package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +25 -0
  97. package/build/runtime-esm/hooks/useSubscriptionHandle.js +18 -0
  98. package/build/runtime-esm/index.d.ts +2 -0
  99. package/build/runtime-esm/index.js +5 -0
  100. package/build/runtime-esm/lib/cache.d.ts +62 -0
  101. package/build/runtime-esm/lib/cache.js +47 -0
  102. package/build/runtime-esm/package.json +1 -0
  103. package/package.json +63 -0
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,7 @@
1
+ import { HoudiniClient } from '$houdini/runtime';
2
+ import * as React from 'react';
3
+ export declare const HoudiniContext: React.Context<HoudiniClient | null>;
4
+ export declare const HoudiniProvider: ({ client, children, }: {
5
+ client: HoudiniClient;
6
+ children: React.ReactNode;
7
+ }) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ export { useQuery } from './useQuery';
2
+ export { useQueryHandle } from './useQueryHandle';
3
+ export { useFragment } from './useFragment';
4
+ export { useFragmentHandle } from './useFragmentHandle';
5
+ export { useMutation } from './useMutation';
6
+ export { useSubscription } from './useSubscription';
7
+ export { type DocumentHandle } from './useDocumentHandle';
8
+ export { type UseQueryConfig } from './useQueryHandle';
@@ -0,0 +1,35 @@
1
+ import * as React from 'react';
2
+ type UseEffectParams = Parameters<typeof React.useEffect>;
3
+ type EffectCallback = UseEffectParams[0];
4
+ type DependencyList = UseEffectParams[1];
5
+ type UseEffectReturn = ReturnType<typeof React.useEffect>;
6
+ /**
7
+ * @param value the value to be memoized (usually a dependency list)
8
+ * @returns a memoized version of the value as long as it remains deeply equal
9
+ */
10
+ export declare function useDeepCompareMemoize<T>(value: T): T;
11
+ declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): UseEffectReturn;
12
+ export declare function useDeepCompareEffectNoCheck(callback: EffectCallback, dependencies: DependencyList): UseEffectReturn;
13
+ export default useDeepCompareEffect;
14
+ /**
15
+ The MIT License (MIT)
16
+ Copyright (c) 2020 Kent C. Dodds
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining a copy
19
+ of this software and associated documentation files (the "Software"), to deal
20
+ in the Software without restriction, including without limitation the rights
21
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
+ copies of the Software, and to permit persons to whom the Software is
23
+ furnished to do so, subject to the following conditions:
24
+
25
+ The above copyright notice and this permission notice shall be included in all
26
+ copies or substantial portions of the Software.
27
+
28
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
+ SOFTWARE.
35
+ */
@@ -0,0 +1,34 @@
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, }: {
4
+ artifact: DocumentArtifact;
5
+ observer: DocumentStore<_Data, _Input>;
6
+ storeValue: QueryResult<_Data, _Input>;
7
+ }): DocumentHandle<_Artifact, _Data, _Input> & {
8
+ fetch: FetchFn<_Data, _Input>;
9
+ };
10
+ export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []> = {
11
+ data: _Data;
12
+ partial: boolean;
13
+ } & RefetchHandlers<_Artifact, _Data, _Input>;
14
+ type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
15
+ refetch: {
16
+ paginated: true;
17
+ method: 'cursor';
18
+ };
19
+ } ? {
20
+ loadNext: CursorHandlers<_Data, _Input>['loadNextPage'];
21
+ loadNextPending: boolean;
22
+ loadPrevious: CursorHandlers<_Data, _Input>['loadPreviousPage'];
23
+ loadPreviousPending: boolean;
24
+ pageInfo: PageInfo;
25
+ } : _Artifact extends {
26
+ refetch: {
27
+ paginated: true;
28
+ method: 'offset';
29
+ };
30
+ } ? {
31
+ loadNext: OffsetHandlers<_Data, _Input>['loadNextPage'];
32
+ loadNextPending: boolean;
33
+ } : {};
34
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { DocumentArtifact, QueryResult } from '$houdini/lib/types';
2
+ import type { DocumentStore, ObserveParams } from '$houdini/runtime/client';
3
+ import { GraphQLObject } from 'houdini';
4
+ export type UseDocumentStoreParams<_Artifact extends DocumentArtifact, _Data extends GraphQLObject> = {
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>): [
8
+ QueryResult<_Data, _Input>,
9
+ DocumentStore<_Data, _Input>,
10
+ (store: DocumentStore<_Data, _Input>) => void
11
+ ];
@@ -0,0 +1,14 @@
1
+ import type { DocumentArtifact, QueryResult } from '$houdini/lib/types';
2
+ import type { DocumentStore, SendParams } from '$houdini/runtime/client';
3
+ import { GraphQLObject } from 'houdini';
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> & {
6
+ variables: _Input;
7
+ send?: Partial<SendParams>;
8
+ }): [
9
+ QueryResult<_Data, _Input> & {
10
+ parent?: string | null;
11
+ },
12
+ DocumentStore<_Data, _Input>,
13
+ (store: DocumentStore<_Data, _Input>) => void
14
+ ];
@@ -0,0 +1,15 @@
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 | {
4
+ [fragmentKey]: _ReferenceType;
5
+ } | null, document: {
6
+ artifact: FragmentArtifact;
7
+ }): _Data | null;
8
+ export declare function fragmentReference<_Data extends GraphQLObject, _Input, _ReferenceType extends {}>(reference: _Data | {
9
+ [fragmentKey]: _ReferenceType;
10
+ } | null, document: {
11
+ artifact: FragmentArtifact;
12
+ }): {
13
+ variables: _Input;
14
+ parent: string;
15
+ };
@@ -0,0 +1,9 @@
1
+ import type { GraphQLObject, FragmentArtifact, QueryArtifact } from '$houdini/runtime/lib/types';
2
+ import { fragmentKey } from '$houdini/runtime/lib/types';
3
+ 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 | {
5
+ [fragmentKey]: _ReferenceType;
6
+ } | null, document: {
7
+ artifact: FragmentArtifact;
8
+ refetchArtifact?: QueryArtifact;
9
+ }): DocumentHandle<_PaginationArtifact, _Data, _Input>;
@@ -0,0 +1,2 @@
1
+ import type { HoudiniClient } from '$houdini/runtime/client';
2
+ export declare function useHoudiniClient(): HoudiniClient;
@@ -0,0 +1,3 @@
1
+ export declare function useIsMountedRef(): {
2
+ current: boolean;
3
+ };
@@ -0,0 +1,10 @@
1
+ import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
2
+ export type MutationHandler<_Result, _Input, _Optimistic extends GraphQLObject> = (args: {
3
+ variables: _Input;
4
+ metadata?: App.Metadata;
5
+ fetch?: typeof globalThis.fetch;
6
+ optimisticResponse?: _Optimistic;
7
+ }) => Promise<QueryResult<_Result, _Input>>;
8
+ export declare function useMutation<_Result extends GraphQLObject, _Input extends {}, _Optimistic extends GraphQLObject>({ artifact, }: {
9
+ artifact: MutationArtifact;
10
+ }): [boolean, MutationHandler<_Result, _Input, _Optimistic>];
@@ -0,0 +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: {
4
+ artifact: QueryArtifact;
5
+ }, variables?: any, config?: UseQueryConfig): _Data;
@@ -0,0 +1,10 @@
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 }: {
4
+ artifact: QueryArtifact;
5
+ }, variables?: any, config?: UseQueryConfig): DocumentHandle<_Artifact, _Data, _Input>;
6
+ export type UseQueryConfig = {
7
+ policy?: CachePolicies;
8
+ metadata?: App.Metadata;
9
+ fetchKey?: any;
10
+ };
@@ -0,0 +1,4 @@
1
+ import { SubscriptionArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
2
+ export declare function useSubscription<_Result extends GraphQLObject, _Input extends {}>(document: {
3
+ artifact: SubscriptionArtifact;
4
+ }, variables: _Input): import("houdini").GraphQLObject | null;
@@ -0,0 +1,25 @@
1
+ import { SubscriptionArtifact, GraphQLObject } from '$houdini/runtime/lib/types';
2
+ export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends {} | null> = {
3
+ data: _Result | null;
4
+ errors: {
5
+ message: string;
6
+ }[] | null;
7
+ variables: _Input;
8
+ listen: (args: {
9
+ variables?: _Input;
10
+ }) => void;
11
+ unlisten: () => void;
12
+ fetching: boolean;
13
+ };
14
+ export declare function useSubscriptionHandle<_Result extends GraphQLObject, _Input extends {}>({ artifact }: {
15
+ artifact: SubscriptionArtifact;
16
+ }, variables: _Input): {
17
+ data: import("houdini").GraphQLObject | null;
18
+ errors: {
19
+ message: string;
20
+ }[] | null;
21
+ fetching: boolean;
22
+ variables: _Input;
23
+ unlisten: () => Promise<void>;
24
+ listen: ({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: import("$houdini/lib").SendParams) => Promise<import("$houdini/runtime/lib/types").QueryResult<import("houdini").GraphQLObject, _Input>>;
25
+ };
@@ -0,0 +1,2 @@
1
+ export * from './hooks';
2
+ export { HoudiniProvider } from './context';
@@ -0,0 +1,62 @@
1
+ /**
2
+ * This file is a copy and paste of a very simple and effective LRU cache
3
+ * using javascript maps. It was copied under the MIT license found at the
4
+ * bottom of the page.
5
+ */
6
+ export interface Cache<T> {
7
+ get(key: string): T | null;
8
+ set(key: string, value: T): void;
9
+ has(key: string): boolean;
10
+ delete(key: string): void;
11
+ size(): number;
12
+ capacity(): number;
13
+ clear(): void;
14
+ }
15
+ /**
16
+ * JS maps (both plain objects and Map) maintain key insertion
17
+ * order, which means there is an easy way to simulate LRU behavior
18
+ * that should also perform quite well:
19
+ *
20
+ * To insert a new value, first delete the key from the inner _map,
21
+ * then _map.set(k, v). By deleting and reinserting, you ensure that the
22
+ * map sees the key as the last inserted key.
23
+ *
24
+ * Get does the same: if the key is present, delete and reinsert it.
25
+ */
26
+ declare class LRUCache<T> implements Cache<T> {
27
+ _capacity: number;
28
+ _map: Map<string, T>;
29
+ constructor(capacity?: number);
30
+ set(key: string, value: T): void;
31
+ get(key: string): T | null;
32
+ has(key: string): boolean;
33
+ delete(key: string): void;
34
+ size(): number;
35
+ capacity(): number;
36
+ clear(): void;
37
+ }
38
+ export declare function createCache<T>(capacity?: number): LRUCache<T>;
39
+ export {};
40
+ /**
41
+ MIT License
42
+
43
+ Copyright (c) Meta Platforms, Inc. and affiliates.
44
+
45
+ Permission is hereby granted, free of charge, to any person obtaining a copy
46
+ of this software and associated documentation files (the "Software"), to deal
47
+ in the Software without restriction, including without limitation the rights
48
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49
+ copies of the Software, and to permit persons to whom the Software is
50
+ furnished to do so, subject to the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be included in all
53
+ copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61
+ SOFTWARE.
62
+ */
@@ -0,0 +1,7 @@
1
+ import { HoudiniClient } from '$houdini/runtime';
2
+ import * as React from 'react';
3
+ export declare const HoudiniContext: React.Context<HoudiniClient | null>;
4
+ export declare const HoudiniProvider: ({ client, children, }: {
5
+ client: HoudiniClient;
6
+ children: React.ReactNode;
7
+ }) => JSX.Element;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var context_exports = {};
26
+ __export(context_exports, {
27
+ HoudiniContext: () => HoudiniContext,
28
+ HoudiniProvider: () => HoudiniProvider
29
+ });
30
+ module.exports = __toCommonJS(context_exports);
31
+ var React = __toESM(require("react"));
32
+ const HoudiniContext = React.createContext(null);
33
+ const HoudiniProvider = ({
34
+ client,
35
+ children
36
+ }) => /* @__PURE__ */ React.createElement(HoudiniContext.Provider, { value: client }, children);
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ HoudiniContext,
40
+ HoudiniProvider
41
+ });
@@ -0,0 +1,8 @@
1
+ export { useQuery } from './useQuery';
2
+ export { useQueryHandle } from './useQueryHandle';
3
+ export { useFragment } from './useFragment';
4
+ export { useFragmentHandle } from './useFragmentHandle';
5
+ export { useMutation } from './useMutation';
6
+ export { useSubscription } from './useSubscription';
7
+ export { type DocumentHandle } from './useDocumentHandle';
8
+ export { type UseQueryConfig } from './useQueryHandle';
@@ -0,0 +1,45 @@
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 hooks_exports = {};
20
+ __export(hooks_exports, {
21
+ useFragment: () => import_useFragment.useFragment,
22
+ useFragmentHandle: () => import_useFragmentHandle.useFragmentHandle,
23
+ useMutation: () => import_useMutation.useMutation,
24
+ useQuery: () => import_useQuery.useQuery,
25
+ useQueryHandle: () => import_useQueryHandle.useQueryHandle,
26
+ useSubscription: () => import_useSubscription.useSubscription
27
+ });
28
+ module.exports = __toCommonJS(hooks_exports);
29
+ var import_useQuery = require("./useQuery");
30
+ var import_useQueryHandle = require("./useQueryHandle");
31
+ var import_useFragment = require("./useFragment");
32
+ var import_useFragmentHandle = require("./useFragmentHandle");
33
+ var import_useMutation = require("./useMutation");
34
+ var import_useSubscription = require("./useSubscription");
35
+ var import_useDocumentHandle = require("./useDocumentHandle");
36
+ var import_useQueryHandle2 = require("./useQueryHandle");
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ useFragment,
40
+ useFragmentHandle,
41
+ useMutation,
42
+ useQuery,
43
+ useQueryHandle,
44
+ useSubscription
45
+ });
@@ -0,0 +1,35 @@
1
+ import * as React from 'react';
2
+ type UseEffectParams = Parameters<typeof React.useEffect>;
3
+ type EffectCallback = UseEffectParams[0];
4
+ type DependencyList = UseEffectParams[1];
5
+ type UseEffectReturn = ReturnType<typeof React.useEffect>;
6
+ /**
7
+ * @param value the value to be memoized (usually a dependency list)
8
+ * @returns a memoized version of the value as long as it remains deeply equal
9
+ */
10
+ export declare function useDeepCompareMemoize<T>(value: T): T;
11
+ declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): UseEffectReturn;
12
+ export declare function useDeepCompareEffectNoCheck(callback: EffectCallback, dependencies: DependencyList): UseEffectReturn;
13
+ export default useDeepCompareEffect;
14
+ /**
15
+ The MIT License (MIT)
16
+ Copyright (c) 2020 Kent C. Dodds
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining a copy
19
+ of this software and associated documentation files (the "Software"), to deal
20
+ in the Software without restriction, including without limitation the rights
21
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
+ copies of the Software, and to permit persons to whom the Software is
23
+ furnished to do so, subject to the following conditions:
24
+
25
+ The above copyright notice and this permission notice shall be included in all
26
+ copies or substantial portions of the Software.
27
+
28
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
+ SOFTWARE.
35
+ */
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var useDeepCompareEffect_exports = {};
26
+ __export(useDeepCompareEffect_exports, {
27
+ default: () => useDeepCompareEffect_default,
28
+ useDeepCompareEffectNoCheck: () => useDeepCompareEffectNoCheck,
29
+ useDeepCompareMemoize: () => useDeepCompareMemoize
30
+ });
31
+ module.exports = __toCommonJS(useDeepCompareEffect_exports);
32
+ var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
33
+ var React = __toESM(require("react"));
34
+ function checkDeps(deps) {
35
+ if (!deps || !deps.length) {
36
+ throw new Error(
37
+ "useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead."
38
+ );
39
+ }
40
+ if (deps.every(isPrimitive)) {
41
+ throw new Error(
42
+ "useDeepCompareEffect should not be used with dependencies that are all primitive values. Use React.useEffect instead."
43
+ );
44
+ }
45
+ }
46
+ function isPrimitive(val) {
47
+ return val == null || /^[sbn]/.test(typeof val);
48
+ }
49
+ function useDeepCompareMemoize(value) {
50
+ const ref = React.useRef(value);
51
+ const signalRef = React.useRef(0);
52
+ if (!(0, import_deepEquals.deepEquals)(value, ref.current)) {
53
+ ref.current = value;
54
+ signalRef.current += 1;
55
+ }
56
+ return React.useMemo(() => ref.current, [signalRef.current]);
57
+ }
58
+ function useDeepCompareEffect(callback, dependencies) {
59
+ if (process.env.NODE_ENV !== "production") {
60
+ checkDeps(dependencies);
61
+ }
62
+ return React.useEffect(callback, useDeepCompareMemoize(dependencies));
63
+ }
64
+ function useDeepCompareEffectNoCheck(callback, dependencies) {
65
+ return React.useEffect(callback, useDeepCompareMemoize(dependencies));
66
+ }
67
+ var useDeepCompareEffect_default = useDeepCompareEffect;
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ useDeepCompareEffectNoCheck,
71
+ useDeepCompareMemoize
72
+ });
@@ -0,0 +1,34 @@
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, }: {
4
+ artifact: DocumentArtifact;
5
+ observer: DocumentStore<_Data, _Input>;
6
+ storeValue: QueryResult<_Data, _Input>;
7
+ }): DocumentHandle<_Artifact, _Data, _Input> & {
8
+ fetch: FetchFn<_Data, _Input>;
9
+ };
10
+ export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends {} = []> = {
11
+ data: _Data;
12
+ partial: boolean;
13
+ } & RefetchHandlers<_Artifact, _Data, _Input>;
14
+ type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
15
+ refetch: {
16
+ paginated: true;
17
+ method: 'cursor';
18
+ };
19
+ } ? {
20
+ loadNext: CursorHandlers<_Data, _Input>['loadNextPage'];
21
+ loadNextPending: boolean;
22
+ loadPrevious: CursorHandlers<_Data, _Input>['loadPreviousPage'];
23
+ loadPreviousPending: boolean;
24
+ pageInfo: PageInfo;
25
+ } : _Artifact extends {
26
+ refetch: {
27
+ paginated: true;
28
+ method: 'offset';
29
+ };
30
+ } ? {
31
+ loadNext: OffsetHandlers<_Data, _Input>['loadNextPage'];
32
+ loadNextPending: boolean;
33
+ } : {};
34
+ export {};