Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tanstack/solid-query

Package Overview
Dependencies
Maintainers
2
Versions
303
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/solid-query - npm Package Compare versions

Comparing version 5.30.3 to 5.30.4

52

build/dev.js

@@ -80,23 +80,19 @@ import { QueryClient as QueryClient$1, MutationObserver, replaceEqualDeep, QueriesObserver, hydrate, QueryObserver, InfiniteQueryObserver, notifyManager } from '@tanstack/query-core';

var hydratableObserverResult = (query, result) => {
if (!isServer)
return result;
return {
const obj = {
...unwrap(result),
// cast to refetch function should be safe, since we only remove it on the server,
// and refetch is not relevant on the server
refetch: void 0,
// cast to fetchNextPage function should be safe, since we only remove it on the server,
fetchNextPage: void 0,
// cast to fetchPreviousPage function should be safe, since we only remove it on the server,
fetchPreviousPage: void 0,
// hydrate() expects a QueryState object, which is similar but not
// quite the same as a QueryObserverResult object. Thus, for now, we're
// copying over the missing properties from state in order to support hydration
dataUpdateCount: query.state.dataUpdateCount,
fetchFailureCount: query.state.fetchFailureCount,
isInvalidated: query.state.isInvalidated,
// Unsetting these properties on the server since they might not be serializable
fetchFailureReason: null,
fetchMeta: null
// During SSR, functions cannot be serialized, so we need to remove them
// This is safe because we will add these functions back when the query is hydrated
refetch: void 0
};
if ("fetchNextPage" in result) {
obj.fetchNextPage = void 0;
obj.fetchPreviousPage = void 0;
}
obj.hydrationData = {
state: query.state,
queryKey: query.queryKey,
queryHash: query.queryHash,
...query.meta && { meta: query.meta }
};
return obj;
};

@@ -171,2 +167,6 @@ function createBaseQuery(options, Observer, queryClient) {

}
if (v.hydrationData) {
const { hydrationData, ...rest } = v;
v = rest;
}
setStateWithReconciliation(v);

@@ -197,5 +197,4 @@ }

if (!observerResult.isLoading) {
const query = obs.getCurrentQuery();
resolver = null;
return resolve(hydratableObserverResult(query, observerResult));
return resolve(observerResult);
}

@@ -219,11 +218,6 @@ setStateWithReconciliation(observerResult);

onHydrated(_k, info) {
if (info.value) {
if (info.value && "hydrationData" in info.value) {
hydrate(client(), {
queries: [
{
queryKey: initialOptions.queryKey,
queryHash: initialOptions.queryHash,
state: info.value
}
]
// @ts-expect-error - hydrationData is not correctly typed internally
queries: [{ ...info.value.hydrationData }]
});

@@ -230,0 +224,0 @@ }

@@ -71,23 +71,19 @@ import { QueryClient as QueryClient$1, MutationObserver, replaceEqualDeep, QueriesObserver, hydrate, QueryObserver, InfiniteQueryObserver, notifyManager } from '@tanstack/query-core';

var hydratableObserverResult = (query, result) => {
if (!isServer)
return result;
return {
const obj = {
...unwrap(result),
// cast to refetch function should be safe, since we only remove it on the server,
// and refetch is not relevant on the server
refetch: void 0,
// cast to fetchNextPage function should be safe, since we only remove it on the server,
fetchNextPage: void 0,
// cast to fetchPreviousPage function should be safe, since we only remove it on the server,
fetchPreviousPage: void 0,
// hydrate() expects a QueryState object, which is similar but not
// quite the same as a QueryObserverResult object. Thus, for now, we're
// copying over the missing properties from state in order to support hydration
dataUpdateCount: query.state.dataUpdateCount,
fetchFailureCount: query.state.fetchFailureCount,
isInvalidated: query.state.isInvalidated,
// Unsetting these properties on the server since they might not be serializable
fetchFailureReason: null,
fetchMeta: null
// During SSR, functions cannot be serialized, so we need to remove them
// This is safe because we will add these functions back when the query is hydrated
refetch: void 0
};
if ("fetchNextPage" in result) {
obj.fetchNextPage = void 0;
obj.fetchPreviousPage = void 0;
}
obj.hydrationData = {
state: query.state,
queryKey: query.queryKey,
queryHash: query.queryHash,
...query.meta && { meta: query.meta }
};
return obj;
};

@@ -162,2 +158,6 @@ function createBaseQuery(options, Observer, queryClient) {

}
if (v.hydrationData) {
const { hydrationData, ...rest } = v;
v = rest;
}
setStateWithReconciliation(v);

@@ -188,5 +188,4 @@ }

if (!observerResult.isLoading) {
const query = obs.getCurrentQuery();
resolver = null;
return resolve(hydratableObserverResult(query, observerResult));
return resolve(observerResult);
}

@@ -210,11 +209,6 @@ setStateWithReconciliation(observerResult);

onHydrated(_k, info) {
if (info.value) {
if (info.value && "hydrationData" in info.value) {
hydrate(client(), {
queries: [
{
queryKey: initialOptions.queryKey,
queryHash: initialOptions.queryHash,
state: info.value
}
]
// @ts-expect-error - hydrationData is not correctly typed internally
queries: [{ ...info.value.hydrationData }]
});

@@ -221,0 +215,0 @@ }

{
"name": "@tanstack/solid-query",
"version": "5.30.3",
"version": "5.30.4",
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",

@@ -5,0 +5,0 @@ "author": "tannerlinsley",

@@ -22,3 +22,2 @@ // Had to disable the lint rule because isServer type is defined as false

import type {
InfiniteQueryObserverResult,
Query,

@@ -28,3 +27,2 @@ QueryKey,

QueryObserverResult,
QueryState,
} from '@tanstack/query-core'

@@ -67,6 +65,2 @@

type HydratableQueryState<TData, TError> = QueryObserverResult<TData, TError> &
QueryState<TData, TError> &
InfiniteQueryObserverResult<TData, TError>
/**

@@ -86,38 +80,25 @@ * Solid's `onHydrated` functionality will silently "fail" (hydrate with an empty object)

) => {
// Including the extra properties is only relevant on the server
if (!isServer) return result as HydratableQueryState<TDataHydratable, TError>
return {
const obj: any = {
...unwrap(result),
// During SSR, functions cannot be serialized, so we need to remove them
// This is safe because we will add these functions back when the query is hydrated
refetch: undefined,
}
// cast to refetch function should be safe, since we only remove it on the server,
// and refetch is not relevant on the server
refetch: undefined as unknown as HydratableQueryState<
TDataHydratable,
TError
>['refetch'],
// If the query is an infinite query, we need to remove additional properties
if ('fetchNextPage' in result) {
obj.fetchNextPage = undefined
obj.fetchPreviousPage = undefined
}
// cast to fetchNextPage function should be safe, since we only remove it on the server,
fetchNextPage: undefined as unknown as HydratableQueryState<
TDataHydratable,
TError
>['fetchNextPage'],
// We will also attach the dehydrated state of the query to the result
// This will be removed on client after hydration
obj.hydrationData = {
state: query.state,
queryKey: query.queryKey,
queryHash: query.queryHash,
...(query.meta && { meta: query.meta }),
}
// cast to fetchPreviousPage function should be safe, since we only remove it on the server,
fetchPreviousPage: undefined as unknown as HydratableQueryState<
TDataHydratable,
TError
>['fetchPreviousPage'],
// hydrate() expects a QueryState object, which is similar but not
// quite the same as a QueryObserverResult object. Thus, for now, we're
// copying over the missing properties from state in order to support hydration
dataUpdateCount: query.state.dataUpdateCount,
fetchFailureCount: query.state.fetchFailureCount,
isInvalidated: query.state.isInvalidated,
// Unsetting these properties on the server since they might not be serializable
fetchFailureReason: null,
fetchMeta: null,
} as HydratableQueryState<TDataHydratable, TError>
return obj
}

@@ -139,5 +120,3 @@

) {
type ResourceData =
| HydratableQueryState<TData, TError>
| QueryObserverResult<TData, TError>
type ResourceData = QueryObserverResult<TData, TError>

@@ -229,3 +208,3 @@ const client = createMemo(() => useQueryClient(queryClient?.()))

() => state,
(v: T) => {
(v: any) => {
const unwrapped = unwrap(state)

@@ -235,3 +214,9 @@ if (typeof v === 'function') {

}
setStateWithReconciliation(v as any)
// Hydration data exists on first load after SSR,
// and should be removed from the observer result
if (v.hydrationData) {
const { hydrationData, ...rest } = v
v = rest
}
setStateWithReconciliation(v)
},

@@ -279,5 +264,4 @@ ] as Signal<T>

if (!observerResult.isLoading) {
const query = obs.getCurrentQuery()
resolver = null
return resolve(hydratableObserverResult(query, observerResult))
return resolve(observerResult)
}

@@ -304,11 +288,6 @@

onHydrated(_k, info) {
if (info.value) {
if (info.value && 'hydrationData' in info.value) {
hydrate(client(), {
queries: [
{
queryKey: initialOptions.queryKey,
queryHash: initialOptions.queryHash,
state: info.value,
},
],
// @ts-expect-error - hydrationData is not correctly typed internally
queries: [{ ...info.value.hydrationData }],
})

@@ -315,0 +294,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc