@analogjs/router 3.0.0-beta.42 → 3.0.0-beta.43
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/fesm2022/analogjs-router-tanstack-query-server.mjs +4 -23
- package/fesm2022/analogjs-router-tanstack-query-server.mjs.map +1 -1
- package/fesm2022/analogjs-router-tanstack-query.mjs +7 -36
- package/fesm2022/analogjs-router-tanstack-query.mjs.map +1 -1
- package/package.json +6 -6
- package/types/tanstack-query/server/src/define-page-load-queries.d.ts +13 -10
- package/types/tanstack-query/server/src/index.d.ts +1 -2
- package/types/tanstack-query/src/index.d.ts +1 -1
- package/types/tanstack-query/src/provide-analog-query.d.ts +1 -3
- package/types/tanstack-query/src/server-query.d.ts +1 -1
- package/types/tanstack-query/server/src/provide-server-analog-query.d.ts +0 -2
- package/types/tanstack-query/src/provide-server-analog-query.d.ts +0 -2
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { filter, skipWhile, take } from "rxjs/operators";
|
|
3
|
-
import { QueryClient, dehydrate } from "@tanstack/angular-query-experimental";
|
|
4
|
-
import { ANALOG_QUERIES_KEY, ANALOG_QUERIES_KEY as ANALOG_QUERIES_KEY$1, ANALOG_QUERY_STATE_KEY } from "@analogjs/router/tanstack-query";
|
|
1
|
+
import { QueryClient, dehydrate } from "@tanstack/angular-query";
|
|
5
2
|
import { definePageLoad } from "@analogjs/router/server/actions";
|
|
6
|
-
|
|
7
|
-
function provideServerAnalogQuery() {
|
|
8
|
-
return makeEnvironmentProviders([{
|
|
9
|
-
provide: ENVIRONMENT_INITIALIZER,
|
|
10
|
-
multi: true,
|
|
11
|
-
useValue() {
|
|
12
|
-
const appRef = inject(ApplicationRef);
|
|
13
|
-
const queryClient = inject(QueryClient);
|
|
14
|
-
const transferState = inject(TransferState);
|
|
15
|
-
const subscription = appRef.isStable.pipe(skipWhile((stable) => stable), filter((stable) => stable), take(1)).subscribe(() => {
|
|
16
|
-
transferState.set(ANALOG_QUERY_STATE_KEY, dehydrate(queryClient));
|
|
17
|
-
});
|
|
18
|
-
appRef.onDestroy(() => subscription.unsubscribe());
|
|
19
|
-
}
|
|
20
|
-
}]);
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
3
|
+
import { ANALOG_QUERIES_KEY, ANALOG_QUERIES_KEY as ANALOG_QUERIES_KEY$1 } from "@analogjs/router/tanstack-query";
|
|
23
4
|
//#region packages/router/tanstack-query/server/src/define-page-load-queries.ts
|
|
24
5
|
function getRequestSignal(event) {
|
|
25
6
|
const { web, req } = event;
|
|
@@ -37,7 +18,7 @@ function getRequestSignal(event) {
|
|
|
37
18
|
* ```ts
|
|
38
19
|
* // src/app/pages/posts.server.ts
|
|
39
20
|
* import { definePageLoadQueries } from '@analogjs/router/tanstack-query/server';
|
|
40
|
-
* import { queryOptions } from '@tanstack/angular-query
|
|
21
|
+
* import { queryOptions } from '@tanstack/angular-query';
|
|
41
22
|
*
|
|
42
23
|
* export const postsQuery = queryOptions({
|
|
43
24
|
* queryKey: ['posts'],
|
|
@@ -78,6 +59,6 @@ function definePageLoadQueries(options) {
|
|
|
78
59
|
});
|
|
79
60
|
}
|
|
80
61
|
//#endregion
|
|
81
|
-
export { ANALOG_QUERIES_KEY, definePageLoadQueries
|
|
62
|
+
export { ANALOG_QUERIES_KEY, definePageLoadQueries };
|
|
82
63
|
|
|
83
64
|
//# sourceMappingURL=analogjs-router-tanstack-query-server.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analogjs-router-tanstack-query-server.mjs","names":[],"sources":["../../tanstack-query/server/src/
|
|
1
|
+
{"version":3,"file":"analogjs-router-tanstack-query-server.mjs","names":[],"sources":["../../tanstack-query/server/src/define-page-load-queries.ts"],"sourcesContent":["import { QueryClient, dehydrate } from '@tanstack/angular-query';\nimport type { DehydratedState } from '@tanstack/angular-query';\nimport type { H3Event, H3EventContext } from 'h3';\nimport type { $Fetch } from 'ofetch';\n\nimport {\n definePageLoad,\n type PageLoadContext,\n type StandardSchemaV1,\n} from '@analogjs/router/server/actions';\nimport { ANALOG_QUERIES_KEY } from '@analogjs/router/tanstack-query';\n\nexport { ANALOG_QUERIES_KEY } from '@analogjs/router/tanstack-query';\n\ntype OptionalSchema = StandardSchemaV1 | undefined;\n\n// h3 v2 exposes the web Request as `event.req`; h3 v1 as `event.web.request`.\nfunction getRequestSignal(event: H3Event): AbortSignal | undefined {\n const { web, req } = event as unknown as {\n web?: { request?: Request };\n req?: unknown;\n };\n return (web?.request ?? (req instanceof Request ? req : undefined))?.signal;\n}\n\nexport interface PageLoadQueriesResult<TData> {\n __analogQueries: DehydratedState;\n data: TData;\n}\n\nexport interface PageLoadQueries<TData> {\n (ctx: {\n params: H3EventContext['params'];\n req: H3Event['node']['req'];\n res: H3Event['node']['res'];\n fetch: $Fetch;\n event: H3Event;\n }): Promise<PageLoadQueriesResult<TData> | Response>;\n}\n\nexport interface DefinePageLoadQueriesOptions<\n TParamsSchema extends OptionalSchema,\n TQuerySchema extends OptionalSchema,\n TData,\n> {\n params?: TParamsSchema;\n query?: TQuerySchema;\n /**\n * Optional QueryClient factory. Defaults to `new QueryClient()`.\n * Override to set `defaultOptions` (e.g. `queries: { staleTime: Infinity }`).\n */\n client?: () => QueryClient;\n /**\n * Handler receives the standard PageLoadContext plus a per-request\n * QueryClient. Use `client.prefetchQuery` / `ensureQueryData` /\n * `prefetchInfiniteQuery` to warm the cache; the dehydrated client\n * is returned as `__analogQueries` on the load result. Anything you\n * return from the handler becomes `data` on the same result.\n */\n handler: (\n ctx: PageLoadContext<TParamsSchema, TQuerySchema> & { client: QueryClient },\n ) => Promise<TData> | TData;\n}\n\n/**\n * Page load helper that prefetches TanStack Query queries inside the\n * `.server.ts` handler and ships the dehydrated cache alongside any\n * additional data. The router-side hydrator in `provideAnalogQuery()`\n * merges the dehydrated payload into the active `QueryClient` on\n * `ResolveEnd`, so components reading the same query options see a\n * warm cache on first render.\n *\n * @example\n * ```ts\n * // src/app/pages/posts.server.ts\n * import { definePageLoadQueries } from '@analogjs/router/tanstack-query/server';\n * import { queryOptions } from '@tanstack/angular-query';\n *\n * export const postsQuery = queryOptions({\n * queryKey: ['posts'],\n * queryFn: async ({ signal }) =>\n * fetch('https://api.example.com/posts', { signal }).then((r) => r.json()),\n * });\n *\n * export const load = definePageLoadQueries({\n * handler: async ({ client }) => {\n * await client.prefetchQuery(postsQuery);\n * },\n * });\n * ```\n */\nexport function definePageLoadQueries<\n TParamsSchema extends OptionalSchema = undefined,\n TQuerySchema extends OptionalSchema = undefined,\n TData = void,\n>(\n options: DefinePageLoadQueriesOptions<TParamsSchema, TQuerySchema, TData>,\n): PageLoadQueries<TData> {\n return definePageLoad({\n params: options.params,\n query: options.query,\n handler: async (ctx): Promise<PageLoadQueriesResult<TData>> => {\n const signal = getRequestSignal(ctx.event);\n signal?.throwIfAborted();\n const client = options.client?.() ?? new QueryClient();\n const cancel = () => void client.cancelQueries();\n signal?.addEventListener('abort', cancel, { once: true });\n try {\n const data = await options.handler({ ...ctx, client });\n return {\n [ANALOG_QUERIES_KEY]: dehydrate(client),\n data,\n };\n } finally {\n signal?.removeEventListener('abort', cancel);\n }\n },\n });\n}\n"],"mappings":";;;;AAiBA,SAAS,iBAAiB,OAAc;CACtC,MAAM,EAAE,KAAK,QAAQ;CAIrB,QAAQ,KAAK,YAAY,eAAe,UAAU,MAAM,KAAA,GAAA,EAAa;AACvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgB,sBAKd,SAAyE;CAEzE,OAAO,eAAe;EACpB,QAAQ,QAAQ;EAChB,OAAO,QAAQ;EACf,SAAS,OAAO,QAA8C;GAC5D,MAAM,SAAS,iBAAiB,IAAI,KAAK;GACzC,QAAQ,eAAc;GACtB,MAAM,SAAS,QAAQ,SAAQ,KAAM,IAAI,YAAW;GACpD,MAAM,eAAe,KAAK,OAAO,cAAa;GAC9C,QAAQ,iBAAiB,SAAS,QAAQ,EAAE,MAAM,KAAI,CAAE;GACxD,IAAI;IACF,MAAM,OAAO,MAAM,QAAQ,QAAQ;KAAE,GAAG;KAAK;IAAM,CAAE;IACrD,OAAO;MACJ,uBAAqB,UAAU,MAAM;KACtC;IACD;GACH,UAAU;IACR,QAAQ,oBAAoB,SAAS,MAAM;GAC7C;EACF;CACD,CAAA;AACH"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ResolveEnd, Router } from "@angular/router";
|
|
2
|
-
import { DestroyRef, ENVIRONMENT_INITIALIZER,
|
|
2
|
+
import { DestroyRef, ENVIRONMENT_INITIALIZER, inject, makeEnvironmentProviders } from "@angular/core";
|
|
3
3
|
import { fromEvent, lastValueFrom, takeUntil } from "rxjs";
|
|
4
|
-
import {
|
|
5
|
-
import { QueryClient, hydrate } from "@tanstack/angular-query-experimental";
|
|
4
|
+
import { QueryClient, hydrate } from "@tanstack/angular-query";
|
|
6
5
|
//#region packages/router/tanstack-query/src/constants.ts
|
|
7
6
|
/**
|
|
8
7
|
* Route-data key under `ActivatedRoute.data['load']` that holds the
|
|
@@ -15,21 +14,8 @@ import { QueryClient, hydrate } from "@tanstack/angular-query-experimental";
|
|
|
15
14
|
var ANALOG_QUERIES_KEY = "__analogQueries";
|
|
16
15
|
//#endregion
|
|
17
16
|
//#region packages/router/tanstack-query/src/provide-analog-query.ts
|
|
18
|
-
var ANALOG_QUERY_STATE_KEY = makeStateKey("analog_query_state");
|
|
19
17
|
function provideAnalogQuery() {
|
|
20
18
|
return makeEnvironmentProviders([{
|
|
21
|
-
provide: ENVIRONMENT_INITIALIZER,
|
|
22
|
-
multi: true,
|
|
23
|
-
useValue() {
|
|
24
|
-
const transferState = inject(TransferState);
|
|
25
|
-
const client = inject(QueryClient);
|
|
26
|
-
const dehydratedState = transferState.get(ANALOG_QUERY_STATE_KEY, null);
|
|
27
|
-
if (dehydratedState) {
|
|
28
|
-
hydrate(client, dehydratedState);
|
|
29
|
-
transferState.remove(ANALOG_QUERY_STATE_KEY);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}, {
|
|
33
19
|
provide: ENVIRONMENT_INITIALIZER,
|
|
34
20
|
multi: true,
|
|
35
21
|
useValue() {
|
|
@@ -37,35 +23,20 @@ function provideAnalogQuery() {
|
|
|
37
23
|
if (!router) return;
|
|
38
24
|
const client = inject(QueryClient);
|
|
39
25
|
const destroyRef = inject(DestroyRef);
|
|
40
|
-
const transferState = isPlatformServer(inject(PLATFORM_ID)) ? inject(TransferState) : null;
|
|
41
26
|
const subscription = router.events.subscribe((event) => {
|
|
42
|
-
if (event instanceof ResolveEnd) mergeRouteSnapshot(event.state.root, client
|
|
27
|
+
if (event instanceof ResolveEnd) mergeRouteSnapshot(event.state.root, client);
|
|
43
28
|
});
|
|
44
29
|
destroyRef.onDestroy(() => subscription.unsubscribe());
|
|
45
30
|
}
|
|
46
31
|
}]);
|
|
47
32
|
}
|
|
48
|
-
function mergeRouteSnapshot(snapshot, client
|
|
33
|
+
function mergeRouteSnapshot(snapshot, client) {
|
|
49
34
|
const load = snapshot.data?.["load"];
|
|
50
35
|
if (load && typeof load === "object" && "__analogQueries" in load) {
|
|
51
36
|
const dehydrated = load[ANALOG_QUERIES_KEY];
|
|
52
|
-
if (dehydrated)
|
|
53
|
-
hydrate(client, dehydrated);
|
|
54
|
-
if (transferState) {
|
|
55
|
-
const existing = transferState.get(ANALOG_QUERY_STATE_KEY, null);
|
|
56
|
-
transferState.set(ANALOG_QUERY_STATE_KEY, existing ? mergeDehydrated(existing, dehydrated) : dehydrated);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
37
|
+
if (dehydrated) hydrate(client, dehydrated);
|
|
59
38
|
}
|
|
60
|
-
for (const child of snapshot.children) mergeRouteSnapshot(child, client
|
|
61
|
-
}
|
|
62
|
-
function mergeDehydrated(base, next) {
|
|
63
|
-
const queriesByHash = new Map(base.queries.map((query) => [query.queryHash, query]));
|
|
64
|
-
for (const query of next.queries) queriesByHash.set(query.queryHash, query);
|
|
65
|
-
return {
|
|
66
|
-
mutations: [...base.mutations, ...next.mutations],
|
|
67
|
-
queries: [...queriesByHash.values()]
|
|
68
|
-
};
|
|
39
|
+
for (const child of snapshot.children) mergeRouteSnapshot(child, client);
|
|
69
40
|
}
|
|
70
41
|
//#endregion
|
|
71
42
|
//#region packages/router/tanstack-query/src/server-query.ts
|
|
@@ -105,6 +76,6 @@ function serverInfiniteQueryOptions(http, url, options) {
|
|
|
105
76
|
};
|
|
106
77
|
}
|
|
107
78
|
//#endregion
|
|
108
|
-
export { ANALOG_QUERIES_KEY,
|
|
79
|
+
export { ANALOG_QUERIES_KEY, provideAnalogQuery, serverInfiniteQueryOptions, serverMutationOptions, serverQueryOptions };
|
|
109
80
|
|
|
110
81
|
//# sourceMappingURL=analogjs-router-tanstack-query.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analogjs-router-tanstack-query.mjs","names":[],"sources":["../../tanstack-query/src/constants.ts","../../tanstack-query/src/provide-analog-query.ts","../../tanstack-query/src/server-query.ts"],"sourcesContent":["/**\n * Route-data key under `ActivatedRoute.data['load']` that holds the\n * `DehydratedState` produced by `definePageLoadQueries`. The Router-\n * events hydrator in `provideAnalogQuery()` looks for this key on\n * `ResolveEnd` and merges the dehydrated payload into the active\n * `QueryClient`, so component-issued queries hit a warm cache on\n * first render.\n */\nexport const ANALOG_QUERIES_KEY: '__analogQueries' = '__analogQueries';\n","import {\n DestroyRef,\n ENVIRONMENT_INITIALIZER,\n PLATFORM_ID,\n TransferState,\n inject,\n makeEnvironmentProviders,\n makeStateKey,\n} from '@angular/core';\nimport type { EnvironmentProviders, StateKey } from '@angular/core';\nimport { isPlatformServer } from '@angular/common';\nimport { ResolveEnd, Router } from '@angular/router';\nimport type { ActivatedRouteSnapshot } from '@angular/router';\nimport { QueryClient, hydrate } from '@tanstack/angular-query-experimental';\nimport type { DehydratedState } from '@tanstack/angular-query-experimental';\n\nimport { ANALOG_QUERIES_KEY } from './constants';\n\nexport const ANALOG_QUERY_STATE_KEY: StateKey<DehydratedState> =\n makeStateKey<DehydratedState>('analog_query_state');\n\nexport function provideAnalogQuery(): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue() {\n if (import.meta.env.SSR) {\n return;\n }\n\n const transferState = inject(TransferState);\n const client = inject(QueryClient);\n const dehydratedState = transferState.get<DehydratedState | null>(\n ANALOG_QUERY_STATE_KEY,\n null,\n );\n\n if (dehydratedState) {\n hydrate(client, dehydratedState);\n transferState.remove(ANALOG_QUERY_STATE_KEY);\n }\n },\n },\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue() {\n const router = inject(Router, { optional: true });\n if (!router) {\n return;\n }\n\n const client = inject(QueryClient);\n const destroyRef = inject(DestroyRef);\n // On the server, also mirror any dehydrated load payloads into\n // `TransferState` so Angular's own serializer can include them in\n // the `ng-state` script — we can't rely on\n // `provideServerAnalogQuery()`'s `BEFORE_APP_SERIALIZED` running\n // before Angular's `TRANSFER_STATE_SERIALIZATION_PROVIDERS`.\n const transferState = isPlatformServer(inject(PLATFORM_ID))\n ? inject(TransferState)\n : null;\n\n const subscription = router.events.subscribe((event) => {\n if (event instanceof ResolveEnd) {\n mergeRouteSnapshot(event.state.root, client, transferState);\n }\n });\n\n destroyRef.onDestroy(() => subscription.unsubscribe());\n },\n },\n ]);\n}\n\nfunction mergeRouteSnapshot(\n snapshot: ActivatedRouteSnapshot,\n client: QueryClient,\n transferState: TransferState | null,\n): void {\n const load = snapshot.data?.['load'];\n if (load && typeof load === 'object' && ANALOG_QUERIES_KEY in load) {\n const dehydrated = (load as Record<string, unknown>)[ANALOG_QUERIES_KEY] as\n | DehydratedState\n | undefined;\n if (dehydrated) {\n hydrate(client, dehydrated);\n if (transferState) {\n const existing = transferState.get<DehydratedState | null>(\n ANALOG_QUERY_STATE_KEY,\n null,\n );\n transferState.set(\n ANALOG_QUERY_STATE_KEY,\n existing ? mergeDehydrated(existing, dehydrated) : dehydrated,\n );\n }\n }\n }\n for (const child of snapshot.children) {\n mergeRouteSnapshot(child, client, transferState);\n }\n}\n\nfunction mergeDehydrated(\n base: DehydratedState,\n next: DehydratedState,\n): DehydratedState {\n // Last-writer-wins on duplicate `queryHash`: child route resolves run\n // after parent resolves, so the later entry is the fresher one and\n // matches `hydrate()`'s own newer-wins semantics for the QueryClient.\n const queriesByHash = new Map(\n base.queries.map((query) => [query.queryHash, query]),\n );\n for (const query of next.queries) {\n queriesByHash.set(query.queryHash, query);\n }\n return {\n mutations: [...base.mutations, ...next.mutations],\n queries: [...queriesByHash.values()],\n };\n}\n","import type { HttpClient } from '@angular/common/http';\nimport { fromEvent, lastValueFrom, takeUntil, type Observable } from 'rxjs';\nimport type {\n CreateQueryOptions,\n CreateMutationOptions,\n CreateInfiniteQueryOptions,\n DefaultError,\n InfiniteData,\n QueryKey,\n} from '@tanstack/angular-query-experimental';\nimport type {\n ApiRouteHandler,\n InferRouteQuery,\n InferRouteBody,\n InferRouteResult,\n} from '@analogjs/router/server/actions';\n\nfunction buildUrl(base: string, params?: Record<string, unknown>): string {\n if (!params) return base;\n const parts: string[] = [];\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n const k = encodeURIComponent(key);\n if (Array.isArray(value)) {\n for (const item of value) {\n parts.push(`${k}=${encodeURIComponent(String(item))}`);\n }\n } else {\n parts.push(`${k}=${encodeURIComponent(String(value))}`);\n }\n }\n if (parts.length === 0) return base;\n const separator = base.includes('?') ? '&' : '?';\n return `${base}${separator}${parts.join('&')}`;\n}\n\nfunction fetchUntilAborted<T>(\n request: Observable<T>,\n signal: AbortSignal,\n): Promise<T> {\n return lastValueFrom(request.pipe(takeUntil(fromEvent(signal, 'abort'))));\n}\n\nexport function serverQueryOptions<\n TRoute extends ApiRouteHandler<any, any, any>,\n TError = DefaultError,\n TData = InferRouteResult<TRoute>,\n TQueryKey extends QueryKey = QueryKey,\n>(\n http: HttpClient,\n url: string,\n options: { queryKey: TQueryKey; query?: InferRouteQuery<TRoute> } & Omit<\n CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>,\n 'queryKey' | 'queryFn'\n >,\n): CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey> {\n const { query, ...rest } = options;\n return {\n ...rest,\n queryFn: ({ signal }: { signal: AbortSignal }) =>\n fetchUntilAborted(\n http.get<InferRouteResult<TRoute>>(\n buildUrl(url, query as Record<string, any>),\n { transferCache: false },\n ),\n signal,\n ),\n } as CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>;\n}\n\nexport function serverMutationOptions<\n TRoute extends ApiRouteHandler<any, any, any>,\n TError = DefaultError,\n TOnMutateResult = unknown,\n>(\n http: HttpClient,\n url: string,\n options?: Omit<\n CreateMutationOptions<\n InferRouteResult<TRoute>,\n TError,\n InferRouteBody<TRoute>,\n TOnMutateResult\n >,\n 'mutationFn'\n >,\n): CreateMutationOptions<\n InferRouteResult<TRoute>,\n TError,\n InferRouteBody<TRoute>,\n TOnMutateResult\n> {\n return {\n mutationFn: (body: InferRouteBody<TRoute>) =>\n lastValueFrom(\n http.post<InferRouteResult<TRoute>>(\n url,\n body === undefined ? null : JSON.stringify(body),\n { headers: { 'content-type': 'application/json' } },\n ),\n ),\n ...options,\n } as CreateMutationOptions<\n InferRouteResult<TRoute>,\n TError,\n InferRouteBody<TRoute>,\n TOnMutateResult\n >;\n}\n\nexport function serverInfiniteQueryOptions<\n TRoute extends ApiRouteHandler<any, any, any>,\n TError = DefaultError,\n TData = InfiniteData<InferRouteResult<TRoute>>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n http: HttpClient,\n url: string,\n options: {\n queryKey: TQueryKey;\n query: (context: { pageParam: TPageParam }) => InferRouteQuery<TRoute>;\n initialPageParam: TPageParam;\n getNextPageParam: (\n lastPage: InferRouteResult<TRoute>,\n allPages: InferRouteResult<TRoute>[],\n ) => TPageParam | undefined | null;\n } & Omit<\n CreateInfiniteQueryOptions<\n InferRouteResult<TRoute>,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'\n >,\n): CreateInfiniteQueryOptions<\n InferRouteResult<TRoute>,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> {\n const { query: buildQuery, ...rest } = options;\n return {\n ...rest,\n queryFn: (context: { pageParam: TPageParam; signal: AbortSignal }) =>\n fetchUntilAborted(\n http.get<InferRouteResult<TRoute>>(\n buildUrl(url, buildQuery(context) as Record<string, any>),\n { transferCache: false },\n ),\n context.signal,\n ),\n } as CreateInfiniteQueryOptions<\n InferRouteResult<TRoute>,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"analogjs-router-tanstack-query.mjs","names":[],"sources":["../../tanstack-query/src/constants.ts","../../tanstack-query/src/provide-analog-query.ts","../../tanstack-query/src/server-query.ts"],"sourcesContent":["/**\n * Route-data key under `ActivatedRoute.data['load']` that holds the\n * `DehydratedState` produced by `definePageLoadQueries`. The Router-\n * events hydrator in `provideAnalogQuery()` looks for this key on\n * `ResolveEnd` and merges the dehydrated payload into the active\n * `QueryClient`, so component-issued queries hit a warm cache on\n * first render.\n */\nexport const ANALOG_QUERIES_KEY: '__analogQueries' = '__analogQueries';\n","import {\n DestroyRef,\n ENVIRONMENT_INITIALIZER,\n inject,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport type { EnvironmentProviders } from '@angular/core';\nimport { ResolveEnd, Router } from '@angular/router';\nimport type { ActivatedRouteSnapshot } from '@angular/router';\nimport { QueryClient, hydrate } from '@tanstack/angular-query';\nimport type { DehydratedState } from '@tanstack/angular-query';\n\nimport { ANALOG_QUERIES_KEY } from './constants';\n\nexport function provideAnalogQuery(): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue() {\n const router = inject(Router, { optional: true });\n if (!router) {\n return;\n }\n\n const client = inject(QueryClient);\n const destroyRef = inject(DestroyRef);\n const subscription = router.events.subscribe((event) => {\n if (event instanceof ResolveEnd) {\n mergeRouteSnapshot(event.state.root, client);\n }\n });\n\n destroyRef.onDestroy(() => subscription.unsubscribe());\n },\n },\n ]);\n}\n\nfunction mergeRouteSnapshot(\n snapshot: ActivatedRouteSnapshot,\n client: QueryClient,\n): void {\n const load = snapshot.data?.['load'];\n if (load && typeof load === 'object' && ANALOG_QUERIES_KEY in load) {\n const dehydrated = (load as Record<string, unknown>)[ANALOG_QUERIES_KEY] as\n | DehydratedState\n | undefined;\n if (dehydrated) {\n hydrate(client, dehydrated);\n }\n }\n for (const child of snapshot.children) {\n mergeRouteSnapshot(child, client);\n }\n}\n","import type { HttpClient } from '@angular/common/http';\nimport { fromEvent, lastValueFrom, takeUntil, type Observable } from 'rxjs';\nimport type {\n CreateQueryOptions,\n CreateMutationOptions,\n CreateInfiniteQueryOptions,\n DefaultError,\n InfiniteData,\n QueryKey,\n} from '@tanstack/angular-query';\nimport type {\n ApiRouteHandler,\n InferRouteQuery,\n InferRouteBody,\n InferRouteResult,\n} from '@analogjs/router/server/actions';\n\nfunction buildUrl(base: string, params?: Record<string, unknown>): string {\n if (!params) return base;\n const parts: string[] = [];\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n const k = encodeURIComponent(key);\n if (Array.isArray(value)) {\n for (const item of value) {\n parts.push(`${k}=${encodeURIComponent(String(item))}`);\n }\n } else {\n parts.push(`${k}=${encodeURIComponent(String(value))}`);\n }\n }\n if (parts.length === 0) return base;\n const separator = base.includes('?') ? '&' : '?';\n return `${base}${separator}${parts.join('&')}`;\n}\n\nfunction fetchUntilAborted<T>(\n request: Observable<T>,\n signal: AbortSignal,\n): Promise<T> {\n return lastValueFrom(request.pipe(takeUntil(fromEvent(signal, 'abort'))));\n}\n\nexport function serverQueryOptions<\n TRoute extends ApiRouteHandler<any, any, any>,\n TError = DefaultError,\n TData = InferRouteResult<TRoute>,\n TQueryKey extends QueryKey = QueryKey,\n>(\n http: HttpClient,\n url: string,\n options: { queryKey: TQueryKey; query?: InferRouteQuery<TRoute> } & Omit<\n CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>,\n 'queryKey' | 'queryFn'\n >,\n): CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey> {\n const { query, ...rest } = options;\n return {\n ...rest,\n queryFn: ({ signal }: { signal: AbortSignal }) =>\n fetchUntilAborted(\n http.get<InferRouteResult<TRoute>>(\n buildUrl(url, query as Record<string, any>),\n { transferCache: false },\n ),\n signal,\n ),\n } as CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>;\n}\n\nexport function serverMutationOptions<\n TRoute extends ApiRouteHandler<any, any, any>,\n TError = DefaultError,\n TOnMutateResult = unknown,\n>(\n http: HttpClient,\n url: string,\n options?: Omit<\n CreateMutationOptions<\n InferRouteResult<TRoute>,\n TError,\n InferRouteBody<TRoute>,\n TOnMutateResult\n >,\n 'mutationFn'\n >,\n): CreateMutationOptions<\n InferRouteResult<TRoute>,\n TError,\n InferRouteBody<TRoute>,\n TOnMutateResult\n> {\n return {\n mutationFn: (body: InferRouteBody<TRoute>) =>\n lastValueFrom(\n http.post<InferRouteResult<TRoute>>(\n url,\n body === undefined ? null : JSON.stringify(body),\n { headers: { 'content-type': 'application/json' } },\n ),\n ),\n ...options,\n } as CreateMutationOptions<\n InferRouteResult<TRoute>,\n TError,\n InferRouteBody<TRoute>,\n TOnMutateResult\n >;\n}\n\nexport function serverInfiniteQueryOptions<\n TRoute extends ApiRouteHandler<any, any, any>,\n TError = DefaultError,\n TData = InfiniteData<InferRouteResult<TRoute>>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n http: HttpClient,\n url: string,\n options: {\n queryKey: TQueryKey;\n query: (context: { pageParam: TPageParam }) => InferRouteQuery<TRoute>;\n initialPageParam: TPageParam;\n getNextPageParam: (\n lastPage: InferRouteResult<TRoute>,\n allPages: InferRouteResult<TRoute>[],\n ) => TPageParam | undefined | null;\n } & Omit<\n CreateInfiniteQueryOptions<\n InferRouteResult<TRoute>,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'\n >,\n): CreateInfiniteQueryOptions<\n InferRouteResult<TRoute>,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> {\n const { query: buildQuery, ...rest } = options;\n return {\n ...rest,\n queryFn: (context: { pageParam: TPageParam; signal: AbortSignal }) =>\n fetchUntilAborted(\n http.get<InferRouteResult<TRoute>>(\n buildUrl(url, buildQuery(context) as Record<string, any>),\n { transferCache: false },\n ),\n context.signal,\n ),\n } as CreateInfiniteQueryOptions<\n InferRouteResult<TRoute>,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >;\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,IAAa,qBAAwC;;;ACMrD,SAAgB,qBAAkB;CAChC,OAAO,yBAAyB,CAC9B;EACE,SAAS;EACT,OAAO;EACP,WAAQ;GACN,MAAM,SAAS,OAAO,QAAQ,EAAE,UAAU,KAAI,CAAE;GAChD,IAAI,CAAC,QACH;GAGF,MAAM,SAAS,OAAO,WAAW;GACjC,MAAM,aAAa,OAAO,UAAU;GACpC,MAAM,eAAe,OAAO,OAAO,WAAW,UAAS;IACrD,IAAI,iBAAiB,YACnB,mBAAmB,MAAM,MAAM,MAAM,MAAM;GAE/C,CAAC;GAED,WAAW,gBAAgB,aAAa,YAAW,CAAE;EACvD;CACD,CACF,CAAA;AACH;AAEA,SAAS,mBACP,UACA,QAAmB;CAEnB,MAAM,OAAO,SAAS,OAAO;CAC7B,IAAI,QAAQ,OAAO,SAAS,YAAA,qBAAkC,MAAM;EAClE,MAAM,aAAc,KAAiC;EAGrD,IAAI,YACF,QAAQ,QAAQ,UAAU;CAE9B;CACA,KAAK,MAAM,SAAS,SAAS,UAC3B,mBAAmB,OAAO,MAAM;AAEpC;;;ACtCA,SAAS,SAAS,MAAc,QAAgC;CAC9D,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QAAkB,CAAA;CACxB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;EACjD,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAC3C,MAAM,IAAI,mBAAmB,GAAG;EAChC,IAAI,MAAM,QAAQ,KAAK,GACrB,KAAK,MAAM,QAAQ,OACjB,MAAM,KAAK,GAAG,EAAC,GAAI,mBAAmB,OAAO,IAAI,CAAC,GAAG;OAGvD,MAAM,KAAK,GAAG,EAAC,GAAI,mBAAmB,OAAO,KAAK,CAAC,GAAG;CAE1D;CACA,IAAI,MAAM,WAAW,GAAG,OAAO;CAE/B,OAAO,GAAG,OADQ,KAAK,SAAS,GAAG,IAAI,MAAM,MAChB,MAAM,KAAK,GAAG;AAC7C;AAEA,SAAS,kBACP,SACA,QAAmB;CAEnB,OAAO,cAAc,QAAQ,KAAK,UAAU,UAAU,QAAQ,OAAO,CAAC,CAAC,CAAC;AAC1E;AAEA,SAAgB,mBAMd,MACA,KACA,SAGC;CAED,MAAM,EAAE,OAAO,GAAG,SAAS;CAC3B,OAAO;EACL,GAAG;EACH,UAAU,EAAE,aACV,kBACE,KAAK,IACH,SAAS,KAAK,KAA4B,GAC1C,EAAE,eAAe,MAAK,CAAE,GAE1B,MAAM;CAE+D;AAC7E;AAEA,SAAgB,sBAKd,MACA,KACA,SAQC;CAOD,OAAO;EACL,aAAa,SACX,cACE,KAAK,KACH,KACA,SAAS,KAAA,IAAY,OAAO,KAAK,UAAU,IAAI,GAC/C,EAAE,SAAS,EAAE,gBAAgB,mBAAkB,EAAE,CAAE,CACpD;EAEL,GAAG;CAMJ;AACH;AAEA,SAAgB,2BAOd,MACA,KACA,SAiBC;CAQD,MAAM,EAAE,OAAO,YAAY,GAAG,SAAS;CACvC,OAAO;EACL,GAAG;EACH,UAAU,YACR,kBACE,KAAK,IACH,SAAS,KAAK,WAAW,OAAO,CAAwB,GACxD,EAAE,eAAe,MAAK,CAAE,GAE1B,QAAQ,MAAM;CAQnB;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/router",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.43",
|
|
4
4
|
"description": "Filesystem-based routing for Angular",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Brandon Roberts <robertsbt@gmail.com>",
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"url": "https://github.com/sponsors/brandonroberts"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@analogjs/content": "3.0.0-beta.
|
|
72
|
+
"@analogjs/content": "3.0.0-beta.43",
|
|
73
73
|
"@angular/core": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
74
74
|
"@angular/platform-server": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
75
75
|
"@angular/router": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
76
76
|
"@standard-schema/spec": "^1.1.0",
|
|
77
|
-
"@tanstack/angular-query
|
|
77
|
+
"@tanstack/angular-query": "^5.108.0",
|
|
78
78
|
"h3": "^1.13.0 || ^2.0.0-rc.0",
|
|
79
79
|
"schema-dts": "^2.0.0"
|
|
80
80
|
},
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@standard-schema/spec": {
|
|
89
89
|
"optional": true
|
|
90
90
|
},
|
|
91
|
-
"@tanstack/angular-query
|
|
91
|
+
"@tanstack/angular-query": {
|
|
92
92
|
"optional": true
|
|
93
93
|
},
|
|
94
94
|
"h3": {
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"tslib": "^2.3.0"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@analogjs/vite-plugin-angular": "3.0.0-beta.
|
|
110
|
-
"@analogjs/vitest-angular": "3.0.0-beta.
|
|
109
|
+
"@analogjs/vite-plugin-angular": "3.0.0-beta.43",
|
|
110
|
+
"@analogjs/vitest-angular": "3.0.0-beta.43"
|
|
111
111
|
},
|
|
112
112
|
"ng-update": {
|
|
113
113
|
"packageGroup": [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryClient } from '@tanstack/angular-query
|
|
2
|
-
import type { DehydratedState } from '@tanstack/angular-query
|
|
1
|
+
import { QueryClient } from '@tanstack/angular-query';
|
|
2
|
+
import type { DehydratedState } from '@tanstack/angular-query';
|
|
3
3
|
import type { H3Event, H3EventContext } from 'h3';
|
|
4
4
|
import type { $Fetch } from 'ofetch';
|
|
5
5
|
import { type PageLoadContext, type StandardSchemaV1 } from '@analogjs/router/server/actions';
|
|
@@ -9,6 +9,15 @@ export interface PageLoadQueriesResult<TData> {
|
|
|
9
9
|
__analogQueries: DehydratedState;
|
|
10
10
|
data: TData;
|
|
11
11
|
}
|
|
12
|
+
export interface PageLoadQueries<TData> {
|
|
13
|
+
(ctx: {
|
|
14
|
+
params: H3EventContext['params'];
|
|
15
|
+
req: H3Event['node']['req'];
|
|
16
|
+
res: H3Event['node']['res'];
|
|
17
|
+
fetch: $Fetch;
|
|
18
|
+
event: H3Event;
|
|
19
|
+
}): Promise<PageLoadQueriesResult<TData> | Response>;
|
|
20
|
+
}
|
|
12
21
|
export interface DefinePageLoadQueriesOptions<TParamsSchema extends OptionalSchema, TQuerySchema extends OptionalSchema, TData> {
|
|
13
22
|
params?: TParamsSchema;
|
|
14
23
|
query?: TQuerySchema;
|
|
@@ -40,7 +49,7 @@ export interface DefinePageLoadQueriesOptions<TParamsSchema extends OptionalSche
|
|
|
40
49
|
* ```ts
|
|
41
50
|
* // src/app/pages/posts.server.ts
|
|
42
51
|
* import { definePageLoadQueries } from '@analogjs/router/tanstack-query/server';
|
|
43
|
-
* import { queryOptions } from '@tanstack/angular-query
|
|
52
|
+
* import { queryOptions } from '@tanstack/angular-query';
|
|
44
53
|
*
|
|
45
54
|
* export const postsQuery = queryOptions({
|
|
46
55
|
* queryKey: ['posts'],
|
|
@@ -55,10 +64,4 @@ export interface DefinePageLoadQueriesOptions<TParamsSchema extends OptionalSche
|
|
|
55
64
|
* });
|
|
56
65
|
* ```
|
|
57
66
|
*/
|
|
58
|
-
export declare function definePageLoadQueries<TParamsSchema extends OptionalSchema = undefined, TQuerySchema extends OptionalSchema = undefined, TData = void>(options: DefinePageLoadQueriesOptions<TParamsSchema, TQuerySchema, TData>):
|
|
59
|
-
params: H3EventContext['params'];
|
|
60
|
-
req: H3Event['node']['req'];
|
|
61
|
-
res: H3Event['node']['res'];
|
|
62
|
-
fetch: $Fetch;
|
|
63
|
-
event: H3Event;
|
|
64
|
-
}) => Promise<PageLoadQueriesResult<TData> | Response>;
|
|
67
|
+
export declare function definePageLoadQueries<TParamsSchema extends OptionalSchema = undefined, TQuerySchema extends OptionalSchema = undefined, TData = void>(options: DefinePageLoadQueriesOptions<TParamsSchema, TQuerySchema, TData>): PageLoadQueries<TData>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { provideServerAnalogQuery } from './provide-server-analog-query';
|
|
2
1
|
export { definePageLoadQueries, ANALOG_QUERIES_KEY, } from './define-page-load-queries';
|
|
3
|
-
export type { PageLoadQueriesResult, DefinePageLoadQueriesOptions, } from './define-page-load-queries';
|
|
2
|
+
export type { PageLoadQueries, PageLoadQueriesResult, DefinePageLoadQueriesOptions, } from './define-page-load-queries';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ANALOG_QUERIES_KEY } from './constants';
|
|
2
|
-
export {
|
|
2
|
+
export { provideAnalogQuery } from './provide-analog-query';
|
|
3
3
|
export { serverQueryOptions, serverMutationOptions, serverInfiniteQueryOptions, } from './server-query';
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import type { EnvironmentProviders
|
|
2
|
-
import type { DehydratedState } from '@tanstack/angular-query-experimental';
|
|
3
|
-
export declare const ANALOG_QUERY_STATE_KEY: StateKey<DehydratedState>;
|
|
1
|
+
import type { EnvironmentProviders } from '@angular/core';
|
|
4
2
|
export declare function provideAnalogQuery(): EnvironmentProviders;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '@angular/common/http';
|
|
2
|
-
import type { CreateQueryOptions, CreateMutationOptions, CreateInfiniteQueryOptions, DefaultError, InfiniteData, QueryKey } from '@tanstack/angular-query
|
|
2
|
+
import type { CreateQueryOptions, CreateMutationOptions, CreateInfiniteQueryOptions, DefaultError, InfiniteData, QueryKey } from '@tanstack/angular-query';
|
|
3
3
|
import type { ApiRouteHandler, InferRouteQuery, InferRouteBody, InferRouteResult } from '@analogjs/router/server/actions';
|
|
4
4
|
export declare function serverQueryOptions<TRoute extends ApiRouteHandler<any, any, any>, TError = DefaultError, TData = InferRouteResult<TRoute>, TQueryKey extends QueryKey = QueryKey>(http: HttpClient, url: string, options: {
|
|
5
5
|
queryKey: TQueryKey;
|