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,127 @@
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 useDocumentHandle_exports = {};
26
+ __export(useDocumentHandle_exports, {
27
+ useDocumentHandle: () => useDocumentHandle
28
+ });
29
+ module.exports = __toCommonJS(useDocumentHandle_exports);
30
+ var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
31
+ var import_pagination = require("$houdini/runtime/lib/pagination");
32
+ var import_types = require("$houdini/runtime/lib/types");
33
+ var import_react = __toESM(require("react"));
34
+ function useDocumentHandle({
35
+ artifact,
36
+ observer,
37
+ storeValue
38
+ }) {
39
+ const [forwardPending, setForwardPending] = import_react.default.useState(false);
40
+ const [backwardPending, setBackwardPending] = import_react.default.useState(false);
41
+ return import_react.default.useMemo(() => {
42
+ const wrapLoad = (setLoading, fn) => {
43
+ return async (value) => {
44
+ setLoading(true);
45
+ const result = await fn(value);
46
+ setLoading(false);
47
+ return result;
48
+ };
49
+ };
50
+ const fetchQuery = (args) => observer.send(args);
51
+ if (artifact.kind !== import_types.ArtifactKind.Query || !artifact.refetch?.paginated) {
52
+ return {
53
+ data: storeValue.data,
54
+ fetch: fetchQuery,
55
+ partial: storeValue.partial
56
+ };
57
+ }
58
+ const getSession = async () => ({});
59
+ if (artifact.refetch.method === "cursor") {
60
+ const handlers = (0, import_pagination.cursorHandlers)({
61
+ artifact,
62
+ getState: () => storeValue.data,
63
+ getVariables: () => storeValue.variables,
64
+ storeName: artifact.name,
65
+ fetch: fetchQuery,
66
+ fetchUpdate: (args, updates) => {
67
+ return observer.send({
68
+ ...args,
69
+ cacheParams: {
70
+ disableSubscriptions: true,
71
+ applyUpdates: updates,
72
+ ...args?.cacheParams
73
+ }
74
+ });
75
+ },
76
+ getSession
77
+ });
78
+ return {
79
+ data: storeValue.data,
80
+ fetch: handlers.fetch,
81
+ partial: storeValue.partial,
82
+ loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
83
+ loadNextPending: forwardPending,
84
+ loadPrevious: wrapLoad(setBackwardPending, handlers.loadPreviousPage),
85
+ loadPreviousPending: backwardPending,
86
+ pageInfo: (0, import_pageInfo.extractPageInfo)(storeValue.data, artifact.refetch.path)
87
+ };
88
+ }
89
+ if (artifact.refetch.method === "offset") {
90
+ const handlers = (0, import_pagination.offsetHandlers)({
91
+ artifact,
92
+ getState: () => storeValue.data,
93
+ getVariables: () => storeValue.variables,
94
+ storeName: artifact.name,
95
+ fetch: fetchQuery,
96
+ fetchUpdate: async (args, updates = ["append"]) => {
97
+ return observer.send({
98
+ ...args,
99
+ cacheParams: {
100
+ disableSubscriptions: true,
101
+ applyUpdates: updates,
102
+ ...args?.cacheParams
103
+ }
104
+ });
105
+ },
106
+ getSession: async () => ({})
107
+ });
108
+ return {
109
+ data: storeValue.data,
110
+ fetch: handlers.fetch,
111
+ partial: storeValue.partial,
112
+ loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
113
+ loadNextPending: forwardPending
114
+ };
115
+ }
116
+ return {
117
+ data: storeValue.data,
118
+ fetch: fetchQuery,
119
+ refetch: fetchQuery,
120
+ partial: storeValue.partial
121
+ };
122
+ }, [artifact, observer, storeValue, true, true]);
123
+ }
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ useDocumentHandle
127
+ });
@@ -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,63 @@
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 useDocumentStore_exports = {};
26
+ __export(useDocumentStore_exports, {
27
+ useDocumentStore: () => useDocumentStore
28
+ });
29
+ module.exports = __toCommonJS(useDocumentStore_exports);
30
+ var React = __toESM(require("react"));
31
+ var import_useHoudiniClient = require("./useHoudiniClient");
32
+ var import_useIsMounted = require("./useIsMounted");
33
+ function useDocumentStore({
34
+ artifact,
35
+ ...observeParams
36
+ }) {
37
+ const client = (0, import_useHoudiniClient.useHoudiniClient)();
38
+ const isMountedRef = (0, import_useIsMounted.useIsMountedRef)();
39
+ let [observer, setObserver] = React.useState(
40
+ () => client.observe({
41
+ artifact,
42
+ ...observeParams
43
+ })
44
+ );
45
+ const box = React.useRef(observer.state);
46
+ const subscribe = React.useCallback(
47
+ (fn) => {
48
+ return observer.subscribe((val) => {
49
+ box.current = val;
50
+ if (isMountedRef.current) {
51
+ fn();
52
+ }
53
+ });
54
+ },
55
+ [observer]
56
+ );
57
+ const storeValue = React.useSyncExternalStore(subscribe, () => box.current);
58
+ return [storeValue, observer, setObserver];
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ useDocumentStore
63
+ });
@@ -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,65 @@
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 useDocumentSubscription_exports = {};
26
+ __export(useDocumentSubscription_exports, {
27
+ useDocumentSubscription: () => useDocumentSubscription
28
+ });
29
+ module.exports = __toCommonJS(useDocumentSubscription_exports);
30
+ var import_useDeepCompareEffect = __toESM(require("./useDeepCompareEffect"));
31
+ var import_useDocumentStore = require("./useDocumentStore");
32
+ function useDocumentSubscription({
33
+ artifact,
34
+ variables,
35
+ send,
36
+ ...observeParams
37
+ }) {
38
+ const [storeValue, observer, setObserver] = (0, import_useDocumentStore.useDocumentStore)({
39
+ artifact,
40
+ ...observeParams
41
+ });
42
+ (0, import_useDeepCompareEffect.default)(() => {
43
+ observer.send({
44
+ variables,
45
+ session: {},
46
+ metadata: {},
47
+ ...send
48
+ });
49
+ return () => {
50
+ observer.cleanup();
51
+ };
52
+ }, [observer, variables ?? {}, send ?? {}]);
53
+ return [
54
+ {
55
+ parent: send?.stuff?.parentID,
56
+ ...storeValue
57
+ },
58
+ observer,
59
+ setObserver
60
+ ];
61
+ }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ useDocumentSubscription
65
+ });
@@ -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,93 @@
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 useFragment_exports = {};
26
+ __export(useFragment_exports, {
27
+ fragmentReference: () => fragmentReference,
28
+ useFragment: () => useFragment
29
+ });
30
+ module.exports = __toCommonJS(useFragment_exports);
31
+ var import_cache = __toESM(require("$houdini/runtime/cache"));
32
+ var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
33
+ var import_types = require("$houdini/runtime/lib/types");
34
+ var React = __toESM(require("react"));
35
+ var import_useDeepCompareEffect = require("./useDeepCompareEffect");
36
+ var import_useDocumentSubscription = require("./useDocumentSubscription");
37
+ function useFragment(reference, document) {
38
+ const { parent, variables } = fragmentReference(
39
+ reference,
40
+ document
41
+ );
42
+ let cachedValue = reference;
43
+ if (reference && parent) {
44
+ cachedValue = import_cache.default.read({
45
+ selection: document.artifact.selection,
46
+ parent,
47
+ variables
48
+ }).data;
49
+ }
50
+ const observeParams = {
51
+ artifact: document.artifact,
52
+ variables,
53
+ initialValue: cachedValue,
54
+ send: {
55
+ stuff: {
56
+ parentID: parent
57
+ }
58
+ }
59
+ };
60
+ const [storeValue] = (0, import_useDocumentSubscription.useDocumentSubscription)(observeParams);
61
+ const lastReference = React.useRef(null);
62
+ return React.useMemo(() => {
63
+ const parentChange = storeValue.parent !== parent || !(0, import_deepEquals.deepEquals)({ parent, variables }, lastReference.current);
64
+ if (parentChange) {
65
+ lastReference.current = { parent, variables: { ...variables } };
66
+ return cachedValue;
67
+ }
68
+ return storeValue.data;
69
+ }, [
70
+ (0, import_useDeepCompareEffect.useDeepCompareMemoize)({
71
+ parent,
72
+ variables,
73
+ cachedValue,
74
+ storeValue: storeValue.data,
75
+ storeParent: storeValue.parent
76
+ })
77
+ ]);
78
+ }
79
+ function fragmentReference(reference, document) {
80
+ const { variables, parent } = reference?.[import_types.fragmentKey]?.[document.artifact.name] ?? {};
81
+ if (reference && import_types.fragmentKey in reference && (!variables || !parent)) {
82
+ console.warn(
83
+ `\u26A0\uFE0F Parent does not contain the information for this fragment. Something is wrong.
84
+ Please ensure that you have passed a record that has ${document.artifact.name} mixed into it.`
85
+ );
86
+ }
87
+ return { variables, parent };
88
+ }
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ fragmentReference,
92
+ useFragment
93
+ });
@@ -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,47 @@
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 useFragmentHandle_exports = {};
20
+ __export(useFragmentHandle_exports, {
21
+ useFragmentHandle: () => useFragmentHandle
22
+ });
23
+ module.exports = __toCommonJS(useFragmentHandle_exports);
24
+ var import_useDocumentHandle = require("./useDocumentHandle");
25
+ var import_useDocumentStore = require("./useDocumentStore");
26
+ var import_useFragment = require("./useFragment");
27
+ function useFragmentHandle(reference, document) {
28
+ const data = (0, import_useFragment.useFragment)(reference, document);
29
+ const { variables } = (0, import_useFragment.fragmentReference)(reference, document);
30
+ const [handleValue, handleObserver] = (0, import_useDocumentStore.useDocumentStore)({
31
+ artifact: document.refetchArtifact ?? document.artifact
32
+ });
33
+ const handle = (0, import_useDocumentHandle.useDocumentHandle)({
34
+ observer: handleObserver,
35
+ storeValue: handleValue,
36
+ artifact: document.refetchArtifact ?? document.artifact
37
+ });
38
+ return {
39
+ ...handle,
40
+ variables,
41
+ data
42
+ };
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ useFragmentHandle
47
+ });
@@ -0,0 +1,2 @@
1
+ import type { HoudiniClient } from '$houdini/runtime/client';
2
+ export declare function useHoudiniClient(): HoudiniClient;
@@ -0,0 +1,42 @@
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 useHoudiniClient_exports = {};
26
+ __export(useHoudiniClient_exports, {
27
+ useHoudiniClient: () => useHoudiniClient
28
+ });
29
+ module.exports = __toCommonJS(useHoudiniClient_exports);
30
+ var React = __toESM(require("react"));
31
+ var import_context = require("../context");
32
+ function useHoudiniClient() {
33
+ const client = React.useContext(import_context.HoudiniContext);
34
+ if (!client) {
35
+ throw new Error("Could not find client");
36
+ }
37
+ return client;
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ useHoudiniClient
42
+ });
@@ -0,0 +1,3 @@
1
+ export declare function useIsMountedRef(): {
2
+ current: boolean;
3
+ };
@@ -0,0 +1,38 @@
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 useIsMounted_exports = {};
20
+ __export(useIsMounted_exports, {
21
+ useIsMountedRef: () => useIsMountedRef
22
+ });
23
+ module.exports = __toCommonJS(useIsMounted_exports);
24
+ var import_react = require("react");
25
+ function useIsMountedRef() {
26
+ const isMountedRef = (0, import_react.useRef)(true);
27
+ (0, import_react.useEffect)(() => {
28
+ isMountedRef.current = true;
29
+ return () => {
30
+ isMountedRef.current = false;
31
+ };
32
+ }, []);
33
+ return isMountedRef;
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ useIsMountedRef
38
+ });
@@ -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,48 @@
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 useMutation_exports = {};
20
+ __export(useMutation_exports, {
21
+ useMutation: () => useMutation
22
+ });
23
+ module.exports = __toCommonJS(useMutation_exports);
24
+ var import_useDocumentStore = require("./useDocumentStore");
25
+ function useMutation({
26
+ artifact
27
+ }) {
28
+ const [storeValue, observer] = (0, import_useDocumentStore.useDocumentStore)({ artifact });
29
+ const pending = storeValue.fetching;
30
+ const mutate = ({
31
+ metadata,
32
+ fetch,
33
+ variables,
34
+ ...mutationConfig
35
+ }) => observer.send({
36
+ variables,
37
+ metadata,
38
+ session: {},
39
+ stuff: {
40
+ ...mutationConfig
41
+ }
42
+ });
43
+ return [pending, mutate];
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ useMutation
48
+ });
@@ -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,32 @@
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 useQuery_exports = {};
20
+ __export(useQuery_exports, {
21
+ useQuery: () => useQuery
22
+ });
23
+ module.exports = __toCommonJS(useQuery_exports);
24
+ var import_useQueryHandle = require("./useQueryHandle");
25
+ function useQuery(document, variables = null, config = {}) {
26
+ const { data } = (0, import_useQueryHandle.useQueryHandle)(document, variables, config);
27
+ return data;
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ useQuery
32
+ });
@@ -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
+ };