houdini-react 2.0.0-next.23 → 2.0.0-next.25
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/package.json +7 -7
- package/postInstall.js +1 -1
- package/runtime/hooks/index.ts +8 -8
- package/runtime/hooks/useDocumentHandle.ts +2 -2
- package/runtime/hooks/useDocumentStore.ts +2 -2
- package/runtime/hooks/useDocumentSubscription.ts +3 -3
- package/runtime/hooks/useFragment.ts +2 -2
- package/runtime/hooks/useFragmentHandle.ts +3 -3
- package/runtime/hooks/useMutation.ts +2 -2
- package/runtime/hooks/useQuery.ts +2 -2
- package/runtime/hooks/useQueryHandle.ts +6 -8
- package/runtime/hooks/useSubscription.ts +1 -1
- package/runtime/hooks/useSubscriptionHandle.ts +1 -1
- package/runtime/hydration.tsx +3 -3
- package/runtime/index.tsx +5 -5
- package/runtime/routing/Router.tsx +6 -7
- package/runtime/routing/index.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.25",
|
|
4
4
|
"description": "The React plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"houdini-react-darwin-x64": "2.0.0-next.
|
|
85
|
-
"houdini-react-darwin-arm64": "2.0.0-next.
|
|
86
|
-
"houdini-react-linux-x64": "2.0.0-next.
|
|
87
|
-
"houdini-react-linux-arm64": "2.0.0-next.
|
|
88
|
-
"houdini-react-win32-x64": "2.0.0-next.
|
|
89
|
-
"houdini-react-win32-arm64": "2.0.0-next.
|
|
84
|
+
"houdini-react-darwin-x64": "2.0.0-next.25",
|
|
85
|
+
"houdini-react-darwin-arm64": "2.0.0-next.25",
|
|
86
|
+
"houdini-react-linux-x64": "2.0.0-next.25",
|
|
87
|
+
"houdini-react-linux-arm64": "2.0.0-next.25",
|
|
88
|
+
"houdini-react-win32-x64": "2.0.0-next.25",
|
|
89
|
+
"houdini-react-win32-arm64": "2.0.0-next.25"
|
|
90
90
|
},
|
|
91
91
|
"bin": "bin/houdini-react",
|
|
92
92
|
"scripts": {
|
package/postInstall.js
CHANGED
|
@@ -5,7 +5,7 @@ const https = require('https')
|
|
|
5
5
|
const child_process = require('child_process')
|
|
6
6
|
|
|
7
7
|
// Adjust the version you want to install. You can also make this dynamic.
|
|
8
|
-
const BINARY_DISTRIBUTION_VERSION = '2.0.0-next.
|
|
8
|
+
const BINARY_DISTRIBUTION_VERSION = '2.0.0-next.25'
|
|
9
9
|
|
|
10
10
|
// Windows binaries end with .exe so we need to special case them.
|
|
11
11
|
const binaryName = process.platform === 'win32' ? 'houdini-react.exe' : 'houdini-react'
|
package/runtime/hooks/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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'
|
|
1
|
+
export { useQuery } from './useQuery.js'
|
|
2
|
+
export { useQueryHandle } from './useQueryHandle.js'
|
|
3
|
+
export { useFragment } from './useFragment.js'
|
|
4
|
+
export { useFragmentHandle } from './useFragmentHandle.js'
|
|
5
|
+
export { useMutation } from './useMutation.js'
|
|
6
|
+
export { useSubscription } from './useSubscription.js'
|
|
7
7
|
|
|
8
|
-
export type { DocumentHandle } from './useDocumentHandle'
|
|
9
|
-
export type { UseQueryConfig } from './useQueryHandle'
|
|
8
|
+
export type { DocumentHandle } from './useDocumentHandle.js'
|
|
9
|
+
export type { UseQueryConfig } from './useQueryHandle.js'
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
import type { DocumentStore } from 'houdini/runtime/client'
|
|
16
16
|
import React from 'react'
|
|
17
17
|
|
|
18
|
-
import { useClient, useLocation, useSession } from '../routing/Router'
|
|
18
|
+
import { useClient, useLocation, useSession } from '../routing/Router.js'
|
|
19
19
|
|
|
20
20
|
export function useDocumentHandle<
|
|
21
21
|
_Artifact extends QueryArtifact,
|
|
@@ -192,7 +192,7 @@ export function useDocumentHandle<
|
|
|
192
192
|
storeValue,
|
|
193
193
|
backwardPending,
|
|
194
194
|
forwardPending,
|
|
195
|
-
paginationObserver
|
|
195
|
+
paginationObserver,
|
|
196
196
|
location.params,
|
|
197
197
|
])
|
|
198
198
|
}
|
|
@@ -7,8 +7,8 @@ import type {
|
|
|
7
7
|
import type { DocumentStore, ObserveParams } from 'houdini/runtime/client'
|
|
8
8
|
import * as React from 'react'
|
|
9
9
|
|
|
10
|
-
import { useClient } from '../routing'
|
|
11
|
-
import { useIsMountedRef } from './useIsMounted'
|
|
10
|
+
import { useClient } from '../routing/index.js'
|
|
11
|
+
import { useIsMountedRef } from './useIsMounted.js'
|
|
12
12
|
|
|
13
13
|
export type UseDocumentStoreParams<
|
|
14
14
|
_Artifact extends DocumentArtifact,
|
|
@@ -6,9 +6,9 @@ import type {
|
|
|
6
6
|
} from 'houdini/runtime'
|
|
7
7
|
import type { DocumentStore, SendParams } from 'houdini/runtime/client'
|
|
8
8
|
|
|
9
|
-
import { useSession } from '../routing/Router'
|
|
10
|
-
import useDeepCompareEffect from './useDeepCompareEffect'
|
|
11
|
-
import { useDocumentStore, type UseDocumentStoreParams } from './useDocumentStore'
|
|
9
|
+
import { useSession } from '../routing/Router.js'
|
|
10
|
+
import useDeepCompareEffect from './useDeepCompareEffect.js'
|
|
11
|
+
import { useDocumentStore, type UseDocumentStoreParams } from './useDocumentStore.js'
|
|
12
12
|
|
|
13
13
|
export function useDocumentSubscription<
|
|
14
14
|
_Artifact extends DocumentArtifact = DocumentArtifact,
|
|
@@ -3,8 +3,8 @@ import { fragmentKey } from 'houdini/runtime'
|
|
|
3
3
|
import type { GraphQLObject, GraphQLVariables, FragmentArtifact } from 'houdini/runtime'
|
|
4
4
|
import * as React from 'react'
|
|
5
5
|
|
|
6
|
-
import { useRouterContext } from '../routing'
|
|
7
|
-
import { useDocumentSubscription } from './useDocumentSubscription'
|
|
6
|
+
import { useRouterContext } from '../routing/index.js'
|
|
7
|
+
import { useDocumentSubscription } from './useDocumentSubscription.js'
|
|
8
8
|
|
|
9
9
|
export function useFragment<
|
|
10
10
|
_Data extends GraphQLObject,
|
|
@@ -5,9 +5,9 @@ import type {
|
|
|
5
5
|
GraphQLVariables,
|
|
6
6
|
} from 'houdini/runtime'
|
|
7
7
|
|
|
8
|
-
import { useDocumentHandle } from './useDocumentHandle'
|
|
9
|
-
import { useDocumentStore } from './useDocumentStore'
|
|
10
|
-
import { fragmentReference, useFragment } from './useFragment'
|
|
8
|
+
import { useDocumentHandle } from './useDocumentHandle.js'
|
|
9
|
+
import { useDocumentStore } from './useDocumentStore.js'
|
|
10
|
+
import { fragmentReference, useFragment } from './useFragment.js'
|
|
11
11
|
|
|
12
12
|
// useFragmentHandle is just like useFragment except it also returns an imperative handle
|
|
13
13
|
// that users can use to interact with the fragment
|
|
@@ -5,8 +5,8 @@ import type {
|
|
|
5
5
|
GraphQLVariables,
|
|
6
6
|
} from 'houdini/runtime'
|
|
7
7
|
|
|
8
|
-
import { useSession } from '../routing/Router'
|
|
9
|
-
import { useDocumentStore } from './useDocumentStore'
|
|
8
|
+
import { useSession } from '../routing/Router.js'
|
|
9
|
+
import { useDocumentStore } from './useDocumentStore.js'
|
|
10
10
|
|
|
11
11
|
export type MutationHandler<_Result, _Input, _Optimistic extends GraphQLObject> = (args: {
|
|
12
12
|
variables: _Input
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GraphQLObject, QueryArtifact } from 'houdini/runtime'
|
|
2
2
|
|
|
3
|
-
import type { UseQueryConfig } from './useQueryHandle'
|
|
4
|
-
import { useQueryHandle } from './useQueryHandle'
|
|
3
|
+
import type { UseQueryConfig } from './useQueryHandle.js'
|
|
4
|
+
import { useQueryHandle } from './useQueryHandle.js'
|
|
5
5
|
|
|
6
6
|
export function useQuery<
|
|
7
7
|
_Artifact extends QueryArtifact,
|
|
@@ -2,10 +2,10 @@ import { createLRUCache } from 'houdini/runtime'
|
|
|
2
2
|
import type { GraphQLObject, CachePolicies, QueryArtifact, GraphQLVariables } from 'houdini/runtime'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
|
|
5
|
-
import { useClient } from '../routing'
|
|
6
|
-
import type { DocumentHandle } from './useDocumentHandle'
|
|
7
|
-
import { useDocumentHandle } from './useDocumentHandle'
|
|
8
|
-
import { useIsMountedRef } from './useIsMounted'
|
|
5
|
+
import { useClient } from '../routing/index.js'
|
|
6
|
+
import type { DocumentHandle } from './useDocumentHandle.js'
|
|
7
|
+
import { useDocumentHandle } from './useDocumentHandle.js'
|
|
8
|
+
import { useIsMountedRef } from './useIsMounted.js'
|
|
9
9
|
|
|
10
10
|
// Suspense requires a way to throw a promise that resolves to a place
|
|
11
11
|
// we can put when we go back on a susequent render. This means that we have to have
|
|
@@ -110,11 +110,10 @@ export function useQueryHandle<
|
|
|
110
110
|
// biome-ignore lint/suspicious/noThenProperty: suspense protocol requires a thenable
|
|
111
111
|
then: loadPromise.then.bind(loadPromise),
|
|
112
112
|
resolve,
|
|
113
|
-
// @ts-
|
|
113
|
+
// @ts-expect-error
|
|
114
114
|
variables,
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
// @ts-ignore
|
|
118
117
|
promiseCache.set(identifier, suspenseUnit)
|
|
119
118
|
|
|
120
119
|
// the suspense unit gives react something to hold onto
|
|
@@ -123,13 +122,12 @@ export function useQueryHandle<
|
|
|
123
122
|
handle
|
|
124
123
|
.fetch({
|
|
125
124
|
variables,
|
|
126
|
-
// @ts-
|
|
125
|
+
// @ts-expect-error: this is actually allowed... 🤫
|
|
127
126
|
stuff: {
|
|
128
127
|
silenceLoading: true,
|
|
129
128
|
},
|
|
130
129
|
})
|
|
131
130
|
.then((value) => {
|
|
132
|
-
// @ts-ignore
|
|
133
131
|
// the final value
|
|
134
132
|
suspenseUnit.resolved = {
|
|
135
133
|
...handle,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SubscriptionArtifact, GraphQLObject, GraphQLVariables } from 'houdini/runtime'
|
|
2
2
|
|
|
3
|
-
import { useSubscriptionHandle } from './useSubscriptionHandle'
|
|
3
|
+
import { useSubscriptionHandle } from './useSubscriptionHandle.js'
|
|
4
4
|
|
|
5
5
|
// a hook to subscribe to a subscription artifact
|
|
6
6
|
export function useSubscription<_Result extends GraphQLObject, _Input extends GraphQLVariables>(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SubscriptionArtifact, GraphQLObject, GraphQLVariables } from 'houdini/runtime'
|
|
2
2
|
|
|
3
|
-
import { useDocumentSubscription } from './useDocumentSubscription'
|
|
3
|
+
import { useDocumentSubscription } from './useDocumentSubscription.js'
|
|
4
4
|
|
|
5
5
|
export type SubscriptionHandle<_Result extends GraphQLObject, _Input extends GraphQLVariables> = {
|
|
6
6
|
data: _Result | null
|
package/runtime/hydration.tsx
CHANGED
|
@@ -5,9 +5,9 @@ import type { Cache } from '$houdini/runtime/cache'
|
|
|
5
5
|
import type { HoudiniClient } from '$houdini/runtime/client'
|
|
6
6
|
import cacheRef from '$houdini/runtime/cache'
|
|
7
7
|
|
|
8
|
-
import { injectComponents } from './componentFields'
|
|
9
|
-
import { router_cache, type RouterCache } from './routing'
|
|
10
|
-
import clientFactory from './client'
|
|
8
|
+
import { injectComponents } from './componentFields.js'
|
|
9
|
+
import { router_cache, type RouterCache } from './routing/index.js'
|
|
10
|
+
import clientFactory from './client.js'
|
|
11
11
|
|
|
12
12
|
declare global {
|
|
13
13
|
interface Window {
|
package/runtime/index.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { GraphQLObject } from 'houdini/runtime'
|
|
2
2
|
import type { Cache } from 'houdini/runtime/cache'
|
|
3
3
|
|
|
4
|
-
import client from './client'
|
|
5
|
-
import manifest from './manifest'
|
|
6
|
-
import { Router as RouterImpl, type RouterCache, RouterContextProvider } from './routing'
|
|
4
|
+
import client from './client.js'
|
|
5
|
+
import manifest from './manifest.js'
|
|
6
|
+
import { Router as RouterImpl, type RouterCache, RouterContextProvider } from './routing/index.js'
|
|
7
7
|
|
|
8
|
-
export * from './hooks'
|
|
9
|
-
export { router_cache, useSession, useLocation, useRoute } from './routing'
|
|
8
|
+
export * from './hooks/index.js'
|
|
9
|
+
export { router_cache, useSession, useLocation, useRoute } from './routing/index.js'
|
|
10
10
|
|
|
11
11
|
export function Router({
|
|
12
12
|
cache,
|
|
@@ -12,9 +12,9 @@ import type { RouterManifest, RouterPageManifest } from 'houdini/router/types'
|
|
|
12
12
|
import React from 'react'
|
|
13
13
|
import { useContext } from 'react'
|
|
14
14
|
|
|
15
|
-
import { type DocumentHandle, useDocumentHandle } from '../hooks/useDocumentHandle'
|
|
16
|
-
import { useDocumentStore } from '../hooks/useDocumentStore'
|
|
17
|
-
import { type SuspenseCache, suspense_cache } from './cache'
|
|
15
|
+
import { type DocumentHandle, useDocumentHandle } from '../hooks/useDocumentHandle.js'
|
|
16
|
+
import { useDocumentStore } from '../hooks/useDocumentStore.js'
|
|
17
|
+
import { type SuspenseCache, suspense_cache } from './cache.js'
|
|
18
18
|
|
|
19
19
|
type PageComponent = React.ComponentType<{ url: string }>
|
|
20
20
|
|
|
@@ -222,6 +222,8 @@ function usePageData({
|
|
|
222
222
|
? data_cache.get(artifact.name)!
|
|
223
223
|
: client.observe({ artifact, cache })
|
|
224
224
|
|
|
225
|
+
// store the observer immediately so useQueryResult can access it
|
|
226
|
+
// during SSR rendering before the fetch resolves
|
|
225
227
|
let resolve: () => void = () => {}
|
|
226
228
|
let reject: (message: string) => void = () => {}
|
|
227
229
|
const promise = new Promise<void>((res, rej) => {
|
|
@@ -234,7 +236,6 @@ function usePageData({
|
|
|
234
236
|
session,
|
|
235
237
|
})
|
|
236
238
|
.then(async () => {
|
|
237
|
-
data_cache.set(id, observer)
|
|
238
239
|
|
|
239
240
|
// if there is an error, we need to reject the promise
|
|
240
241
|
if (observer.state.errors && observer.state.errors.length > 0) {
|
|
@@ -484,12 +485,10 @@ export function RouterContextProvider({
|
|
|
484
485
|
}, [])
|
|
485
486
|
|
|
486
487
|
React.useEffect(() => {
|
|
487
|
-
// @ts-ignore
|
|
488
488
|
window.addEventListener('_houdini_session_', handleNewSession)
|
|
489
489
|
|
|
490
490
|
// cleanup this component
|
|
491
491
|
return () => {
|
|
492
|
-
// @ts-ignore
|
|
493
492
|
window.removeEventListener('_houdini_session_', handleNewSession)
|
|
494
493
|
}
|
|
495
494
|
}, [handleNewSession])
|
|
@@ -670,7 +669,7 @@ function useLinkBehavior({
|
|
|
670
669
|
// only use the preload handler if the browser hasn't chosen to reduce data usage
|
|
671
670
|
// this doesn't break the rule of hooks because it will only ever have one value
|
|
672
671
|
// in the lifetime of the app
|
|
673
|
-
// @ts-
|
|
672
|
+
// @ts-expect-error
|
|
674
673
|
if (!globalThis.navigator?.connection?.saveData) {
|
|
675
674
|
// biome-ignore lint/correctness/useHookAtTopLevel: value is constant for the lifetime of the app
|
|
676
675
|
usePreload({ preload })
|
package/runtime/routing/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Router'
|
|
2
|
-
export { type SuspenseCache, suspense_cache } from './cache'
|
|
1
|
+
export * from './Router.js'
|
|
2
|
+
export { type SuspenseCache, suspense_cache } from './cache.js'
|