houdini-react 0.0.0-20231008055552
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/build/plugin/codegen/entries.d.ts +5 -0
- package/build/plugin/codegen/index.d.ts +13 -0
- package/build/plugin/codegen/manifest.d.ts +5 -0
- package/build/plugin/codegen/render.d.ts +5 -0
- package/build/plugin/codegen/router.d.ts +7 -0
- package/build/plugin/codegen/typeRoot.d.ts +6 -0
- package/build/plugin/config.d.ts +4 -0
- package/build/plugin/dedent.d.ts +1 -0
- package/build/plugin/extract.d.ts +6 -0
- package/build/plugin/index.d.ts +7 -0
- package/build/plugin/transform.d.ts +6 -0
- package/build/plugin/vite.d.ts +54 -0
- package/build/plugin-cjs/index.js +79966 -0
- package/build/plugin-cjs/package.json +1 -0
- package/build/plugin-esm/index.js +79956 -0
- package/build/plugin-esm/package.json +1 -0
- package/build/runtime/client.d.ts +3 -0
- package/build/runtime/clientPlugin.d.ts +3 -0
- package/build/runtime/hooks/index.d.ts +8 -0
- package/build/runtime/hooks/useDeepCompareEffect.d.ts +35 -0
- package/build/runtime/hooks/useDocumentHandle.d.ts +34 -0
- package/build/runtime/hooks/useDocumentStore.d.ts +12 -0
- package/build/runtime/hooks/useDocumentSubscription.d.ts +15 -0
- package/build/runtime/hooks/useFragment.d.ts +16 -0
- package/build/runtime/hooks/useFragmentHandle.d.ts +8 -0
- package/build/runtime/hooks/useIsMounted.d.ts +3 -0
- package/build/runtime/hooks/useMutation.d.ts +10 -0
- package/build/runtime/hooks/useQuery.d.ts +5 -0
- package/build/runtime/hooks/useQueryHandle.d.ts +10 -0
- package/build/runtime/hooks/useSubscription.d.ts +4 -0
- package/build/runtime/hooks/useSubscriptionHandle.d.ts +25 -0
- package/build/runtime/index.d.ts +11 -0
- package/build/runtime/manifest.d.ts +3 -0
- package/build/runtime/routing/Router.d.ts +67 -0
- package/build/runtime/routing/cache.d.ts +7 -0
- package/build/runtime/routing/index.d.ts +2 -0
- package/build/runtime/server/index.d.ts +17 -0
- package/build/runtime/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime/server/renderToStream.d.ts +28 -0
- package/build/runtime/server/shared/initData.d.ts +8 -0
- package/build/runtime/server/shared/key.d.ts +4 -0
- package/build/runtime/server/shared/utils.d.ts +3 -0
- package/build/runtime/server/useStream.d.ts +9 -0
- package/build/runtime/server/utils/assert.d.ts +15 -0
- package/build/runtime/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime/server/utils/debug.d.ts +14 -0
- package/build/runtime/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime/server/utils/isCallable.d.ts +2 -0
- package/build/runtime/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime/server/utils/isPromise.d.ts +1 -0
- package/build/runtime/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime/server/utils.d.ts +4 -0
- package/build/runtime-cjs/client.d.ts +3 -0
- package/build/runtime-cjs/client.js +27 -0
- package/build/runtime-cjs/clientPlugin.d.ts +3 -0
- package/build/runtime-cjs/clientPlugin.js +39 -0
- package/build/runtime-cjs/hooks/index.d.ts +8 -0
- package/build/runtime-cjs/hooks/index.js +45 -0
- package/build/runtime-cjs/hooks/useDeepCompareEffect.d.ts +35 -0
- package/build/runtime-cjs/hooks/useDeepCompareEffect.js +72 -0
- package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +34 -0
- package/build/runtime-cjs/hooks/useDocumentHandle.js +131 -0
- package/build/runtime-cjs/hooks/useDocumentStore.d.ts +12 -0
- package/build/runtime-cjs/hooks/useDocumentStore.js +68 -0
- package/build/runtime-cjs/hooks/useDocumentSubscription.d.ts +15 -0
- package/build/runtime-cjs/hooks/useDocumentSubscription.js +72 -0
- package/build/runtime-cjs/hooks/useFragment.d.ts +16 -0
- package/build/runtime-cjs/hooks/useFragment.js +97 -0
- package/build/runtime-cjs/hooks/useFragmentHandle.d.ts +8 -0
- package/build/runtime-cjs/hooks/useFragmentHandle.js +47 -0
- package/build/runtime-cjs/hooks/useIsMounted.d.ts +3 -0
- package/build/runtime-cjs/hooks/useIsMounted.js +38 -0
- package/build/runtime-cjs/hooks/useMutation.d.ts +10 -0
- package/build/runtime-cjs/hooks/useMutation.js +50 -0
- package/build/runtime-cjs/hooks/useQuery.d.ts +5 -0
- package/build/runtime-cjs/hooks/useQuery.js +32 -0
- package/build/runtime-cjs/hooks/useQueryHandle.d.ts +10 -0
- package/build/runtime-cjs/hooks/useQueryHandle.js +125 -0
- package/build/runtime-cjs/hooks/useSubscription.d.ts +4 -0
- package/build/runtime-cjs/hooks/useSubscription.js +32 -0
- package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +25 -0
- package/build/runtime-cjs/hooks/useSubscriptionHandle.js +42 -0
- package/build/runtime-cjs/index.d.ts +11 -0
- package/build/runtime-cjs/index.js +77 -0
- package/build/runtime-cjs/manifest.d.ts +3 -0
- package/build/runtime-cjs/manifest.js +27 -0
- package/build/runtime-cjs/package.json +1 -0
- package/build/runtime-cjs/routing/Router.d.ts +67 -0
- package/build/runtime-cjs/routing/Router.js +429 -0
- package/build/runtime-cjs/routing/cache.d.ts +7 -0
- package/build/runtime-cjs/routing/cache.js +58 -0
- package/build/runtime-cjs/routing/index.d.ts +2 -0
- package/build/runtime-cjs/routing/index.js +30 -0
- package/build/runtime-cjs/server/index.d.ts +17 -0
- package/build/runtime-cjs/server/index.js +28 -0
- package/build/runtime-cjs/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime-cjs/server/renderToStream/createBuffer.js +101 -0
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime-cjs/server/renderToStream/createPipeWrapper.js +90 -0
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime-cjs/server/renderToStream/createReadableWrapper.js +85 -0
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime-cjs/server/renderToStream/loadNodeStreamModule.js +51 -0
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime-cjs/server/renderToStream/resolveSeoStrategy.js +44 -0
- package/build/runtime-cjs/server/renderToStream.d.ts +28 -0
- package/build/runtime-cjs/server/renderToStream.js +183 -0
- package/build/runtime-cjs/server/shared/initData.d.ts +8 -0
- package/build/runtime-cjs/server/shared/initData.js +28 -0
- package/build/runtime-cjs/server/shared/key.d.ts +4 -0
- package/build/runtime-cjs/server/shared/key.js +45 -0
- package/build/runtime-cjs/server/shared/utils.d.ts +3 -0
- package/build/runtime-cjs/server/shared/utils.js +20 -0
- package/build/runtime-cjs/server/useStream.d.ts +9 -0
- package/build/runtime-cjs/server/useStream.js +44 -0
- package/build/runtime-cjs/server/utils/assert.d.ts +15 -0
- package/build/runtime-cjs/server/utils/assert.js +119 -0
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime-cjs/server/utils/createErrorWithCleanStackTrace.js +62 -0
- package/build/runtime-cjs/server/utils/debug.d.ts +14 -0
- package/build/runtime-cjs/server/utils/debug.js +112 -0
- package/build/runtime-cjs/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime-cjs/server/utils/getGlobalVariable.js +32 -0
- package/build/runtime-cjs/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isBrowser.js +30 -0
- package/build/runtime-cjs/server/utils/isCallable.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isCallable.js +30 -0
- package/build/runtime-cjs/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isClientSide.js +30 -0
- package/build/runtime-cjs/server/utils/isPromise.d.ts +1 -0
- package/build/runtime-cjs/server/utils/isPromise.js +31 -0
- package/build/runtime-cjs/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime-cjs/server/utils/isServerSide.js +31 -0
- package/build/runtime-cjs/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime-cjs/server/utils/objectAssign.js +30 -0
- package/build/runtime-cjs/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime-cjs/server/utils/projectInfo.js +37 -0
- package/build/runtime-cjs/server/utils.d.ts +4 -0
- package/build/runtime-cjs/server/utils.js +21 -0
- package/build/runtime-esm/client.d.ts +3 -0
- package/build/runtime-esm/client.js +5 -0
- package/build/runtime-esm/clientPlugin.d.ts +3 -0
- package/build/runtime-esm/clientPlugin.js +17 -0
- package/build/runtime-esm/hooks/index.d.ts +8 -0
- package/build/runtime-esm/hooks/index.js +16 -0
- package/build/runtime-esm/hooks/useDeepCompareEffect.d.ts +35 -0
- package/build/runtime-esm/hooks/useDeepCompareEffect.js +41 -0
- package/build/runtime-esm/hooks/useDocumentHandle.d.ts +34 -0
- package/build/runtime-esm/hooks/useDocumentHandle.js +101 -0
- package/build/runtime-esm/hooks/useDocumentStore.d.ts +12 -0
- package/build/runtime-esm/hooks/useDocumentStore.js +38 -0
- package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +15 -0
- package/build/runtime-esm/hooks/useDocumentSubscription.js +42 -0
- package/build/runtime-esm/hooks/useFragment.d.ts +16 -0
- package/build/runtime-esm/hooks/useFragment.js +66 -0
- package/build/runtime-esm/hooks/useFragmentHandle.d.ts +8 -0
- package/build/runtime-esm/hooks/useFragmentHandle.js +23 -0
- package/build/runtime-esm/hooks/useIsMounted.d.ts +3 -0
- package/build/runtime-esm/hooks/useIsMounted.js +14 -0
- package/build/runtime-esm/hooks/useMutation.d.ts +10 -0
- package/build/runtime-esm/hooks/useMutation.js +26 -0
- package/build/runtime-esm/hooks/useQuery.d.ts +5 -0
- package/build/runtime-esm/hooks/useQuery.js +8 -0
- package/build/runtime-esm/hooks/useQueryHandle.d.ts +10 -0
- package/build/runtime-esm/hooks/useQueryHandle.js +95 -0
- package/build/runtime-esm/hooks/useSubscription.d.ts +4 -0
- package/build/runtime-esm/hooks/useSubscription.js +8 -0
- package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +25 -0
- package/build/runtime-esm/hooks/useSubscriptionHandle.js +18 -0
- package/build/runtime-esm/index.d.ts +11 -0
- package/build/runtime-esm/index.js +45 -0
- package/build/runtime-esm/manifest.d.ts +3 -0
- package/build/runtime-esm/manifest.js +5 -0
- package/build/runtime-esm/package.json +1 -0
- package/build/runtime-esm/routing/Router.d.ts +67 -0
- package/build/runtime-esm/routing/Router.js +390 -0
- package/build/runtime-esm/routing/cache.d.ts +7 -0
- package/build/runtime-esm/routing/cache.js +33 -0
- package/build/runtime-esm/routing/index.d.ts +2 -0
- package/build/runtime-esm/routing/index.js +5 -0
- package/build/runtime-esm/server/index.d.ts +17 -0
- package/build/runtime-esm/server/index.js +4 -0
- package/build/runtime-esm/server/renderToStream/createBuffer.d.ts +17 -0
- package/build/runtime-esm/server/renderToStream/createBuffer.js +77 -0
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.d.ts +12 -0
- package/build/runtime-esm/server/renderToStream/createPipeWrapper.js +66 -0
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.d.ts +6 -0
- package/build/runtime-esm/server/renderToStream/createReadableWrapper.js +61 -0
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.d.ts +10 -0
- package/build/runtime-esm/server/renderToStream/loadNodeStreamModule.js +20 -0
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.d.ts +9 -0
- package/build/runtime-esm/server/renderToStream/resolveSeoStrategy.js +20 -0
- package/build/runtime-esm/server/renderToStream.d.ts +28 -0
- package/build/runtime-esm/server/renderToStream.js +152 -0
- package/build/runtime-esm/server/shared/initData.d.ts +8 -0
- package/build/runtime-esm/server/shared/initData.js +4 -0
- package/build/runtime-esm/server/shared/key.d.ts +4 -0
- package/build/runtime-esm/server/shared/key.js +20 -0
- package/build/runtime-esm/server/shared/utils.d.ts +3 -0
- package/build/runtime-esm/server/shared/utils.js +3 -0
- package/build/runtime-esm/server/useStream.d.ts +9 -0
- package/build/runtime-esm/server/useStream.js +13 -0
- package/build/runtime-esm/server/utils/assert.d.ts +15 -0
- package/build/runtime-esm/server/utils/assert.js +91 -0
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.d.ts +2 -0
- package/build/runtime-esm/server/utils/createErrorWithCleanStackTrace.js +38 -0
- package/build/runtime-esm/server/utils/debug.d.ts +14 -0
- package/build/runtime-esm/server/utils/debug.js +87 -0
- package/build/runtime-esm/server/utils/getGlobalVariable.d.ts +4 -0
- package/build/runtime-esm/server/utils/getGlobalVariable.js +8 -0
- package/build/runtime-esm/server/utils/isBrowser.d.ts +2 -0
- package/build/runtime-esm/server/utils/isBrowser.js +6 -0
- package/build/runtime-esm/server/utils/isCallable.d.ts +2 -0
- package/build/runtime-esm/server/utils/isCallable.js +6 -0
- package/build/runtime-esm/server/utils/isClientSide.d.ts +2 -0
- package/build/runtime-esm/server/utils/isClientSide.js +6 -0
- package/build/runtime-esm/server/utils/isPromise.d.ts +1 -0
- package/build/runtime-esm/server/utils/isPromise.js +7 -0
- package/build/runtime-esm/server/utils/isServerSide.d.ts +2 -0
- package/build/runtime-esm/server/utils/isServerSide.js +7 -0
- package/build/runtime-esm/server/utils/objectAssign.d.ts +2 -0
- package/build/runtime-esm/server/utils/objectAssign.js +6 -0
- package/build/runtime-esm/server/utils/projectInfo.d.ts +10 -0
- package/build/runtime-esm/server/utils/projectInfo.js +13 -0
- package/build/runtime-esm/server/utils.d.ts +4 -0
- package/build/runtime-esm/server/utils.js +4 -0
- package/package.json +67 -0
|
@@ -0,0 +1,37 @@
|
|
|
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 projectInfo_exports = {};
|
|
20
|
+
__export(projectInfo_exports, {
|
|
21
|
+
projectInfo: () => projectInfo
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(projectInfo_exports);
|
|
24
|
+
const PROJECT_VERSION = "0.3.14";
|
|
25
|
+
const projectInfo = {
|
|
26
|
+
projectName: "react-streaming",
|
|
27
|
+
projectVersion: PROJECT_VERSION,
|
|
28
|
+
npmPackageName: "react-streaming",
|
|
29
|
+
githubRepository: "https://github.com/brillout/react-streaming",
|
|
30
|
+
discordInviteToolChannel: "https://discord.com/invite/H23tjRxFvx"
|
|
31
|
+
};
|
|
32
|
+
globalThis.__vite_plugin_ssr__instances = globalThis.__vite_plugin_ssr__instances || [];
|
|
33
|
+
globalThis.__vite_plugin_ssr__instances.push(projectInfo.projectVersion);
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
projectInfo
|
|
37
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var utils_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(utils_exports);
|
|
18
|
+
__reExport(utils_exports, require("./utils/assert"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./utils/debug"), module.exports);
|
|
20
|
+
__reExport(utils_exports, require("./utils/isPromise"), module.exports);
|
|
21
|
+
__reExport(utils_exports, require("./utils/isBrowser"), module.exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const plugin = () => () => {
|
|
2
|
+
return {
|
|
3
|
+
beforeNetwork(ctx, { next }) {
|
|
4
|
+
next({
|
|
5
|
+
...ctx,
|
|
6
|
+
cacheParams: {
|
|
7
|
+
...ctx.fetchParams,
|
|
8
|
+
serverSideFallback: false
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
var clientPlugin_default = plugin;
|
|
15
|
+
export {
|
|
16
|
+
clientPlugin_default as default
|
|
17
|
+
};
|
|
@@ -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,16 @@
|
|
|
1
|
+
import { useQuery } from "./useQuery";
|
|
2
|
+
import { useQueryHandle } from "./useQueryHandle";
|
|
3
|
+
import { useFragment } from "./useFragment";
|
|
4
|
+
import { useFragmentHandle } from "./useFragmentHandle";
|
|
5
|
+
import { useMutation } from "./useMutation";
|
|
6
|
+
import { useSubscription } from "./useSubscription";
|
|
7
|
+
import {} from "./useDocumentHandle";
|
|
8
|
+
import {} from "./useQueryHandle";
|
|
9
|
+
export {
|
|
10
|
+
useFragment,
|
|
11
|
+
useFragmentHandle,
|
|
12
|
+
useMutation,
|
|
13
|
+
useQuery,
|
|
14
|
+
useQueryHandle,
|
|
15
|
+
useSubscription
|
|
16
|
+
};
|
|
@@ -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,41 @@
|
|
|
1
|
+
import { deepEquals } from "$houdini/runtime/lib/deepEquals";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
function checkDeps(deps) {
|
|
4
|
+
if (!deps || !deps.length) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
"useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead."
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
if (deps.every(isPrimitive)) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
"useDeepCompareEffect should not be used with dependencies that are all primitive values. Use React.useEffect instead."
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isPrimitive(val) {
|
|
16
|
+
return val == null || /^[sbn]/.test(typeof val);
|
|
17
|
+
}
|
|
18
|
+
function useDeepCompareMemoize(value) {
|
|
19
|
+
const ref = React.useRef(value);
|
|
20
|
+
const signalRef = React.useRef(0);
|
|
21
|
+
if (!deepEquals(value, ref.current)) {
|
|
22
|
+
ref.current = value;
|
|
23
|
+
signalRef.current += 1;
|
|
24
|
+
}
|
|
25
|
+
return React.useMemo(() => ref.current, [signalRef.current]);
|
|
26
|
+
}
|
|
27
|
+
function useDeepCompareEffect(callback, dependencies) {
|
|
28
|
+
if (process.env.NODE_ENV !== "production") {
|
|
29
|
+
checkDeps(dependencies);
|
|
30
|
+
}
|
|
31
|
+
return React.useEffect(callback, useDeepCompareMemoize(dependencies));
|
|
32
|
+
}
|
|
33
|
+
function useDeepCompareEffectNoCheck(callback, dependencies) {
|
|
34
|
+
return React.useEffect(callback, useDeepCompareMemoize(dependencies));
|
|
35
|
+
}
|
|
36
|
+
var useDeepCompareEffect_default = useDeepCompareEffect;
|
|
37
|
+
export {
|
|
38
|
+
useDeepCompareEffect_default as default,
|
|
39
|
+
useDeepCompareEffectNoCheck,
|
|
40
|
+
useDeepCompareMemoize
|
|
41
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
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 GraphQLVariables = GraphQLVariables> = {
|
|
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,101 @@
|
|
|
1
|
+
import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
2
|
+
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
3
|
+
import { ArtifactKind } from "$houdini/runtime/lib/types";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { useSession } from "../routing/Router";
|
|
6
|
+
function useDocumentHandle({
|
|
7
|
+
artifact,
|
|
8
|
+
observer,
|
|
9
|
+
storeValue
|
|
10
|
+
}) {
|
|
11
|
+
const [forwardPending, setForwardPending] = React.useState(false);
|
|
12
|
+
const [backwardPending, setBackwardPending] = React.useState(false);
|
|
13
|
+
const session = useSession();
|
|
14
|
+
return React.useMemo(() => {
|
|
15
|
+
const wrapLoad = (setLoading, fn) => {
|
|
16
|
+
return async (value) => {
|
|
17
|
+
setLoading(true);
|
|
18
|
+
const result = await fn(value);
|
|
19
|
+
setLoading(false);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const fetchQuery = (args) => observer.send({
|
|
24
|
+
...args,
|
|
25
|
+
session
|
|
26
|
+
});
|
|
27
|
+
if (artifact.kind !== ArtifactKind.Query || !artifact.refetch?.paginated) {
|
|
28
|
+
return {
|
|
29
|
+
data: storeValue.data,
|
|
30
|
+
fetch: fetchQuery,
|
|
31
|
+
partial: storeValue.partial
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (artifact.refetch.method === "cursor") {
|
|
35
|
+
const handlers = cursorHandlers({
|
|
36
|
+
artifact,
|
|
37
|
+
getState: () => storeValue.data,
|
|
38
|
+
getVariables: () => storeValue.variables,
|
|
39
|
+
fetch: fetchQuery,
|
|
40
|
+
fetchUpdate: (args, updates) => {
|
|
41
|
+
return observer.send({
|
|
42
|
+
...args,
|
|
43
|
+
cacheParams: {
|
|
44
|
+
disableSubscriptions: true,
|
|
45
|
+
applyUpdates: updates,
|
|
46
|
+
...args?.cacheParams
|
|
47
|
+
},
|
|
48
|
+
session
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
getSession: async () => session
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
data: storeValue.data,
|
|
55
|
+
fetch: handlers.fetch,
|
|
56
|
+
partial: storeValue.partial,
|
|
57
|
+
loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
|
|
58
|
+
loadNextPending: forwardPending,
|
|
59
|
+
loadPrevious: wrapLoad(setBackwardPending, handlers.loadPreviousPage),
|
|
60
|
+
loadPreviousPending: backwardPending,
|
|
61
|
+
pageInfo: extractPageInfo(storeValue.data, artifact.refetch.path)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (artifact.refetch.method === "offset") {
|
|
65
|
+
const handlers = offsetHandlers({
|
|
66
|
+
artifact,
|
|
67
|
+
getState: () => storeValue.data,
|
|
68
|
+
getVariables: () => storeValue.variables,
|
|
69
|
+
storeName: artifact.name,
|
|
70
|
+
fetch: fetchQuery,
|
|
71
|
+
fetchUpdate: async (args, updates = ["append"]) => {
|
|
72
|
+
return observer.send({
|
|
73
|
+
...args,
|
|
74
|
+
cacheParams: {
|
|
75
|
+
disableSubscriptions: true,
|
|
76
|
+
applyUpdates: updates,
|
|
77
|
+
...args?.cacheParams
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
getSession: async () => session
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
data: storeValue.data,
|
|
85
|
+
fetch: handlers.fetch,
|
|
86
|
+
partial: storeValue.partial,
|
|
87
|
+
loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
|
|
88
|
+
loadNextPending: forwardPending
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
data: storeValue.data,
|
|
93
|
+
fetch: fetchQuery,
|
|
94
|
+
refetch: fetchQuery,
|
|
95
|
+
partial: storeValue.partial
|
|
96
|
+
};
|
|
97
|
+
}, [artifact, observer, session, storeValue, true, true]);
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
useDocumentHandle
|
|
101
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DocumentArtifact, GraphQLVariables, QueryResult } from '$houdini/lib/types';
|
|
2
|
+
import type { DocumentStore, ObserveParams } from '$houdini/runtime/client';
|
|
3
|
+
import type { GraphQLObject } from 'houdini';
|
|
4
|
+
export type UseDocumentStoreParams<_Artifact extends DocumentArtifact, _Data extends GraphQLObject, _Input extends GraphQLVariables> = {
|
|
5
|
+
artifact: _Artifact;
|
|
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>): [
|
|
9
|
+
QueryResult<_Data, _Input>,
|
|
10
|
+
DocumentStore<_Data, _Input>,
|
|
11
|
+
(store: DocumentStore<_Data, _Input>) => void
|
|
12
|
+
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useClient } from "../routing";
|
|
3
|
+
import { useIsMountedRef } from "./useIsMounted";
|
|
4
|
+
function useDocumentStore({
|
|
5
|
+
artifact,
|
|
6
|
+
observer: obs,
|
|
7
|
+
...observeParams
|
|
8
|
+
}) {
|
|
9
|
+
const client = useClient();
|
|
10
|
+
const isMountedRef = useIsMountedRef();
|
|
11
|
+
let [observer, setObserver] = React.useState(
|
|
12
|
+
() => obs ?? client.observe({
|
|
13
|
+
artifact,
|
|
14
|
+
...observeParams
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
const box = React.useRef(observer.state);
|
|
18
|
+
const subscribe = React.useCallback(
|
|
19
|
+
(fn) => {
|
|
20
|
+
return observer.subscribe((val) => {
|
|
21
|
+
box.current = val;
|
|
22
|
+
if (isMountedRef.current) {
|
|
23
|
+
fn();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
[observer]
|
|
28
|
+
);
|
|
29
|
+
const storeValue = React.useSyncExternalStore(
|
|
30
|
+
subscribe,
|
|
31
|
+
() => box.current,
|
|
32
|
+
() => box.current
|
|
33
|
+
);
|
|
34
|
+
return [storeValue, observer, setObserver];
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
useDocumentStore
|
|
38
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DocumentArtifact, GraphQLVariables, QueryResult } from '$houdini/lib/types';
|
|
2
|
+
import type { DocumentStore, SendParams } from '$houdini/runtime/client';
|
|
3
|
+
import type { GraphQLObject } from 'houdini';
|
|
4
|
+
import { type UseDocumentStoreParams } from './useDocumentStore';
|
|
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
|
+
variables: _Input;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
send?: Partial<SendParams>;
|
|
9
|
+
}): [
|
|
10
|
+
QueryResult<_Data, _Input> & {
|
|
11
|
+
parent?: string | null;
|
|
12
|
+
},
|
|
13
|
+
DocumentStore<_Data, _Input>,
|
|
14
|
+
(store: DocumentStore<_Data, _Input>) => void
|
|
15
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useSession } from "../routing/Router";
|
|
2
|
+
import useDeepCompareEffect from "./useDeepCompareEffect";
|
|
3
|
+
import { useDocumentStore } from "./useDocumentStore";
|
|
4
|
+
function useDocumentSubscription({
|
|
5
|
+
artifact,
|
|
6
|
+
variables,
|
|
7
|
+
send,
|
|
8
|
+
disabled,
|
|
9
|
+
...observeParams
|
|
10
|
+
}) {
|
|
11
|
+
const [storeValue, observer, setObserver] = useDocumentStore({
|
|
12
|
+
artifact,
|
|
13
|
+
...observeParams
|
|
14
|
+
});
|
|
15
|
+
const session = useSession();
|
|
16
|
+
useDeepCompareEffect(() => {
|
|
17
|
+
if (!disabled) {
|
|
18
|
+
observer.send({
|
|
19
|
+
variables,
|
|
20
|
+
session,
|
|
21
|
+
metadata: {},
|
|
22
|
+
...send
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return () => {
|
|
26
|
+
if (!disabled) {
|
|
27
|
+
observer.cleanup();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}, [disabled, session, observer, variables ?? {}, send ?? {}]);
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
parent: send?.stuff?.parentID,
|
|
34
|
+
...storeValue
|
|
35
|
+
},
|
|
36
|
+
observer,
|
|
37
|
+
setObserver
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
useDocumentSubscription
|
|
42
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fragmentKey } from '$houdini/runtime/lib/types';
|
|
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
|
+
[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
|
+
loading: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { deepEquals } from "$houdini/runtime/lib/deepEquals";
|
|
2
|
+
import { fragmentKey } from "$houdini/runtime/lib/types";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useRouterContext } from "../routing";
|
|
5
|
+
import { useDeepCompareMemoize } from "./useDeepCompareEffect";
|
|
6
|
+
import { useDocumentSubscription } from "./useDocumentSubscription";
|
|
7
|
+
function useFragment(reference, document) {
|
|
8
|
+
const { cache } = useRouterContext();
|
|
9
|
+
const { parent, variables, loading } = fragmentReference(
|
|
10
|
+
reference,
|
|
11
|
+
document
|
|
12
|
+
);
|
|
13
|
+
let cachedValue = reference;
|
|
14
|
+
if (reference && parent) {
|
|
15
|
+
cachedValue = cache.read({
|
|
16
|
+
selection: document.artifact.selection,
|
|
17
|
+
parent,
|
|
18
|
+
variables,
|
|
19
|
+
loading
|
|
20
|
+
}).data;
|
|
21
|
+
}
|
|
22
|
+
const [storeValue] = useDocumentSubscription({
|
|
23
|
+
artifact: document.artifact,
|
|
24
|
+
variables,
|
|
25
|
+
initialValue: cachedValue,
|
|
26
|
+
disabled: loading,
|
|
27
|
+
send: {
|
|
28
|
+
stuff: {
|
|
29
|
+
parentID: parent
|
|
30
|
+
},
|
|
31
|
+
setup: true
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const lastReference = React.useRef(null);
|
|
35
|
+
return React.useMemo(() => {
|
|
36
|
+
const parentChange = storeValue.parent !== parent || !deepEquals({ parent, variables }, lastReference.current);
|
|
37
|
+
if (parentChange) {
|
|
38
|
+
lastReference.current = { parent, variables: { ...variables } };
|
|
39
|
+
return cachedValue;
|
|
40
|
+
}
|
|
41
|
+
return storeValue.data;
|
|
42
|
+
}, [
|
|
43
|
+
useDeepCompareMemoize({
|
|
44
|
+
parent,
|
|
45
|
+
variables,
|
|
46
|
+
cachedValue,
|
|
47
|
+
storeValue: storeValue.data,
|
|
48
|
+
storeParent: storeValue.parent
|
|
49
|
+
})
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
function fragmentReference(reference, document) {
|
|
53
|
+
const { variables, parent } = reference?.[fragmentKey]?.values?.[document.artifact.name] ?? {};
|
|
54
|
+
if (reference && fragmentKey in reference && (!variables || !parent)) {
|
|
55
|
+
console.warn(
|
|
56
|
+
`\u26A0\uFE0F Parent does not contain the information for this fragment. Something is wrong.
|
|
57
|
+
Please ensure that you have passed a record that has ${document.artifact.name} mixed into it.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
const loading = Boolean(reference?.[fragmentKey]?.loading);
|
|
61
|
+
return { variables, parent, loading };
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
fragmentReference,
|
|
65
|
+
useFragment
|
|
66
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GraphQLObject, FragmentArtifact, QueryArtifact, fragmentKey, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
|
+
import { type DocumentHandle } from './useDocumentHandle';
|
|
3
|
+
export declare function useFragmentHandle<_Artifact extends FragmentArtifact, _Data extends GraphQLObject, _ReferenceType extends {}, _PaginationArtifact extends QueryArtifact, _Input extends GraphQLVariables = GraphQLVariables>(reference: _Data | {
|
|
4
|
+
[fragmentKey]: _ReferenceType;
|
|
5
|
+
} | null, document: {
|
|
6
|
+
artifact: FragmentArtifact;
|
|
7
|
+
refetchArtifact?: QueryArtifact;
|
|
8
|
+
}): DocumentHandle<_PaginationArtifact, _Data, _Input>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useDocumentHandle } from "./useDocumentHandle";
|
|
2
|
+
import { useDocumentStore } from "./useDocumentStore";
|
|
3
|
+
import { fragmentReference, useFragment } from "./useFragment";
|
|
4
|
+
function useFragmentHandle(reference, document) {
|
|
5
|
+
const data = useFragment(reference, document);
|
|
6
|
+
const { variables } = fragmentReference(reference, document);
|
|
7
|
+
const [handleValue, handleObserver] = useDocumentStore({
|
|
8
|
+
artifact: document.refetchArtifact ?? document.artifact
|
|
9
|
+
});
|
|
10
|
+
const handle = useDocumentHandle({
|
|
11
|
+
observer: handleObserver,
|
|
12
|
+
storeValue: handleValue,
|
|
13
|
+
artifact: document.refetchArtifact ?? document.artifact
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
...handle,
|
|
17
|
+
variables,
|
|
18
|
+
data
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
useFragmentHandle
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRef, useEffect } from "react";
|
|
2
|
+
function useIsMountedRef() {
|
|
3
|
+
const isMountedRef = useRef(true);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
isMountedRef.current = true;
|
|
6
|
+
return () => {
|
|
7
|
+
isMountedRef.current = false;
|
|
8
|
+
};
|
|
9
|
+
}, []);
|
|
10
|
+
return isMountedRef;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useIsMountedRef
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MutationArtifact, GraphQLObject, QueryResult, GraphQLVariables } 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 GraphQLVariables, _Optimistic extends GraphQLObject>({ artifact, }: {
|
|
9
|
+
artifact: MutationArtifact;
|
|
10
|
+
}): [boolean, MutationHandler<_Result, _Input, _Optimistic>];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useSession } from "../routing/Router";
|
|
2
|
+
import { useDocumentStore } from "./useDocumentStore";
|
|
3
|
+
function useMutation({
|
|
4
|
+
artifact
|
|
5
|
+
}) {
|
|
6
|
+
const [storeValue, observer] = useDocumentStore({ artifact });
|
|
7
|
+
const pending = storeValue.fetching;
|
|
8
|
+
const session = useSession();
|
|
9
|
+
const mutate = ({
|
|
10
|
+
metadata,
|
|
11
|
+
fetch,
|
|
12
|
+
variables,
|
|
13
|
+
...mutationConfig
|
|
14
|
+
}) => observer.send({
|
|
15
|
+
variables,
|
|
16
|
+
metadata,
|
|
17
|
+
session,
|
|
18
|
+
stuff: {
|
|
19
|
+
...mutationConfig
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return [pending, mutate];
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
useMutation
|
|
26
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
artifact: QueryArtifact;
|
|
5
|
+
}, variables?: any, config?: UseQueryConfig): _Data;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
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
|
+
};
|