@tanstack/angular-query-experimental 5.87.5 → 5.88.0
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/devtools/index.d.ts +2 -0
- package/devtools/index.mjs +5 -0
- package/devtools/index.mjs.map +1 -0
- package/devtools/production/index.d.ts +1 -0
- package/devtools/stub.d.ts +2 -0
- package/devtools/stub.mjs +8 -0
- package/devtools/stub.mjs.map +1 -0
- package/devtools/types.d.ts +95 -0
- package/devtools/with-devtools.d.ts +25 -0
- package/devtools/with-devtools.mjs +104 -0
- package/devtools/with-devtools.mjs.map +1 -0
- package/devtools-panel/index.d.ts +2 -0
- package/devtools-panel/index.mjs +5 -0
- package/devtools-panel/index.mjs.map +1 -0
- package/devtools-panel/inject-devtools-panel.d.ts +14 -0
- package/devtools-panel/inject-devtools-panel.mjs +72 -0
- package/devtools-panel/inject-devtools-panel.mjs.map +1 -0
- package/devtools-panel/production/index.d.ts +1 -0
- package/devtools-panel/stub.d.ts +2 -0
- package/devtools-panel/stub.mjs +8 -0
- package/devtools-panel/stub.mjs.map +1 -0
- package/devtools-panel/types.d.ts +48 -0
- package/index.d.ts +2 -2
- package/index.mjs +3 -4
- package/infinite-query-options.d.ts +0 -3
- package/infinite-query-options.mjs.map +1 -1
- package/inject-infinite-query.d.ts +0 -3
- package/inject-infinite-query.mjs.map +1 -1
- package/inject-is-mutating.d.ts +0 -1
- package/inject-is-mutating.mjs.map +1 -1
- package/inject-is-restoring.d.ts +6 -8
- package/inject-is-restoring.mjs +4 -7
- package/inject-is-restoring.mjs.map +1 -1
- package/inject-mutation-state.d.ts +0 -4
- package/inject-mutation-state.mjs.map +1 -1
- package/inject-mutation.d.ts +0 -1
- package/inject-mutation.mjs.map +1 -1
- package/inject-queries.d.ts +0 -4
- package/inject-queries.mjs.map +1 -1
- package/inject-query-client.d.ts +0 -1
- package/inject-query-client.mjs.map +1 -1
- package/inject-query.d.ts +0 -3
- package/inject-query.mjs.map +1 -1
- package/mutation-options.d.ts +5 -4
- package/mutation-options.mjs.map +1 -1
- package/package.json +23 -3
- package/providers.d.ts +8 -95
- package/providers.mjs +7 -84
- package/providers.mjs.map +1 -1
- package/query-options.d.ts +0 -3
- package/query-options.mjs.map +1 -1
- package/types.d.ts +0 -48
- package/util/is-dev-mode/is-dev-mode.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '..';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stub.mjs","sources":["../../src/devtools/stub.ts"],"sourcesContent":["import type { WithDevtools } from './types'\n\n// Stub which replaces `withDevtools` in production builds\nexport const withDevtools: WithDevtools = () => ({\n ɵkind: 'Devtools',\n ɵproviders: [],\n})\n"],"names":[],"mappings":"AAGO,MAAM,eAA6B,OAAO;AAAA,EAC/C,OAAO;AAAA,EACP,YAAY,CAAA;AACd;"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/query-core';
|
|
2
|
+
import { DevtoolsButtonPosition, DevtoolsErrorType, DevtoolsPosition } from '@tanstack/query-devtools';
|
|
3
|
+
import { DeveloperToolsFeature } from '../providers.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring withDevtools.
|
|
6
|
+
*/
|
|
7
|
+
export interface WithDevtoolsOptions {
|
|
8
|
+
/**
|
|
9
|
+
* An array of dependencies to be injected and passed to the `withDevtoolsFn` function.
|
|
10
|
+
*
|
|
11
|
+
* **Example**
|
|
12
|
+
* ```ts
|
|
13
|
+
* export const appConfig: ApplicationConfig = {
|
|
14
|
+
* providers: [
|
|
15
|
+
* provideTanStackQuery(
|
|
16
|
+
* new QueryClient(),
|
|
17
|
+
* withDevtools(
|
|
18
|
+
* (devToolsOptionsManager: DevtoolsOptionsManager) => ({
|
|
19
|
+
* loadDevtools: devToolsOptionsManager.loadDevtools(),
|
|
20
|
+
* }),
|
|
21
|
+
* {
|
|
22
|
+
* deps: [DevtoolsOptionsManager],
|
|
23
|
+
* },
|
|
24
|
+
* ),
|
|
25
|
+
* ),
|
|
26
|
+
* ],
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
deps?: Array<any>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Options for configuring the TanStack Query devtools.
|
|
34
|
+
*/
|
|
35
|
+
export interface DevtoolsOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Set this true if you want the devtools to default to being open
|
|
38
|
+
*/
|
|
39
|
+
initialIsOpen?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The position of the TanStack logo to open and close the devtools panel.
|
|
42
|
+
* `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`
|
|
43
|
+
* Defaults to `bottom-right`.
|
|
44
|
+
*/
|
|
45
|
+
buttonPosition?: DevtoolsButtonPosition;
|
|
46
|
+
/**
|
|
47
|
+
* The position of the TanStack Query devtools panel.
|
|
48
|
+
* `top` | `bottom` | `left` | `right`
|
|
49
|
+
* Defaults to `bottom`.
|
|
50
|
+
*/
|
|
51
|
+
position?: DevtoolsPosition;
|
|
52
|
+
/**
|
|
53
|
+
* Custom instance of QueryClient
|
|
54
|
+
*/
|
|
55
|
+
client?: QueryClient;
|
|
56
|
+
/**
|
|
57
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
58
|
+
*/
|
|
59
|
+
errorTypes?: Array<DevtoolsErrorType>;
|
|
60
|
+
/**
|
|
61
|
+
* Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.
|
|
62
|
+
*/
|
|
63
|
+
styleNonce?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Use this so you can attach the devtool's styles to a specific element in the DOM.
|
|
66
|
+
*/
|
|
67
|
+
shadowDOMTarget?: ShadowRoot;
|
|
68
|
+
/**
|
|
69
|
+
* Set this to true to hide disabled queries from the devtools panel.
|
|
70
|
+
*/
|
|
71
|
+
hideDisabledQueries?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the developer tools should load.
|
|
74
|
+
* - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.
|
|
75
|
+
* - `true`- Always load the devtools, regardless of the environment.
|
|
76
|
+
* - `false`- Never load the devtools, regardless of the environment.
|
|
77
|
+
*
|
|
78
|
+
* You can use `true` and `false` to override loading developer tools from an environment file.
|
|
79
|
+
* For example, a test environment might run in production mode but you may want to load developer tools.
|
|
80
|
+
*
|
|
81
|
+
* Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,
|
|
82
|
+
* a signal created from a RxJS observable that listens for a keyboard shortcut.
|
|
83
|
+
*
|
|
84
|
+
* **Example**
|
|
85
|
+
* ```ts
|
|
86
|
+
* withDevtools(() => ({
|
|
87
|
+
* initialIsOpen: true,
|
|
88
|
+
* loadDevtools: inject(ExampleService).loadDevtools()
|
|
89
|
+
* }))
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
loadDevtools?: 'auto' | boolean;
|
|
93
|
+
}
|
|
94
|
+
export type WithDevtoolsFn = (...deps: Array<any>) => DevtoolsOptions;
|
|
95
|
+
export type WithDevtools = (withDevtoolsFn?: WithDevtoolsFn, options?: WithDevtoolsOptions) => DeveloperToolsFeature;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WithDevtools } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enables developer tools in Angular development builds.
|
|
4
|
+
*
|
|
5
|
+
* **Example**
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* export const appConfig: ApplicationConfig = {
|
|
9
|
+
* providers: [
|
|
10
|
+
* provideTanStackQuery(new QueryClient(), withDevtools())
|
|
11
|
+
* ]
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
* The devtools will be rendered in `<body>`.
|
|
15
|
+
*
|
|
16
|
+
* If you need more control over when devtools are loaded, you can use the `loadDevtools` option.
|
|
17
|
+
*
|
|
18
|
+
* If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.
|
|
19
|
+
* @param withDevtoolsFn - A function that returns `DevtoolsOptions`.
|
|
20
|
+
* @param options - Additional options for configuring `withDevtools`.
|
|
21
|
+
* @returns A set of providers for use with `provideTanStackQuery`.
|
|
22
|
+
* @see {@link provideTanStackQuery}
|
|
23
|
+
* @see {@link DevtoolsOptions}
|
|
24
|
+
*/
|
|
25
|
+
export declare const withDevtools: WithDevtools;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
2
|
+
import { computed, InjectionToken, ENVIRONMENT_INITIALIZER, inject, PLATFORM_ID, DestroyRef, Injector, isDevMode, effect } from "@angular/core";
|
|
3
|
+
import { noop, QueryClient, onlineManager } from "@tanstack/query-core";
|
|
4
|
+
import { queryFeature } from "../providers.mjs";
|
|
5
|
+
const DEVTOOLS_PROVIDED = new InjectionToken("", {
|
|
6
|
+
factory: () => ({
|
|
7
|
+
isProvided: false
|
|
8
|
+
})
|
|
9
|
+
});
|
|
10
|
+
const DEVTOOLS_OPTIONS_SIGNAL = new InjectionToken("");
|
|
11
|
+
const withDevtools = (withDevtoolsFn, options = {}) => queryFeature("Devtools", [
|
|
12
|
+
{
|
|
13
|
+
provide: DEVTOOLS_OPTIONS_SIGNAL,
|
|
14
|
+
useFactory: (...deps) => computed(() => (withDevtoolsFn == null ? void 0 : withDevtoolsFn(...deps)) ?? {}),
|
|
15
|
+
deps: options.deps || []
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
// Do not use provideEnvironmentInitializer while Angular < v19 is supported
|
|
19
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
20
|
+
multi: true,
|
|
21
|
+
useFactory: () => {
|
|
22
|
+
const devtoolsProvided = inject(DEVTOOLS_PROVIDED);
|
|
23
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID)) || devtoolsProvided.isProvided)
|
|
24
|
+
return noop;
|
|
25
|
+
devtoolsProvided.isProvided = true;
|
|
26
|
+
let injectorIsDestroyed = false;
|
|
27
|
+
inject(DestroyRef).onDestroy(() => injectorIsDestroyed = true);
|
|
28
|
+
return () => {
|
|
29
|
+
const injectedClient = inject(QueryClient, {
|
|
30
|
+
optional: true
|
|
31
|
+
});
|
|
32
|
+
const destroyRef = inject(DestroyRef);
|
|
33
|
+
const devtoolsOptions = inject(DEVTOOLS_OPTIONS_SIGNAL);
|
|
34
|
+
const injector = inject(Injector);
|
|
35
|
+
let devtools = null;
|
|
36
|
+
let el = null;
|
|
37
|
+
const shouldLoadToolsSignal = computed(() => {
|
|
38
|
+
const { loadDevtools } = devtoolsOptions();
|
|
39
|
+
return typeof loadDevtools === "boolean" ? loadDevtools : isDevMode();
|
|
40
|
+
});
|
|
41
|
+
const getResolvedQueryClient = () => {
|
|
42
|
+
const client = devtoolsOptions().client ?? injectedClient;
|
|
43
|
+
if (!client) {
|
|
44
|
+
throw new Error("No QueryClient found");
|
|
45
|
+
}
|
|
46
|
+
return client;
|
|
47
|
+
};
|
|
48
|
+
const destroyDevtools = () => {
|
|
49
|
+
devtools == null ? void 0 : devtools.unmount();
|
|
50
|
+
el == null ? void 0 : el.remove();
|
|
51
|
+
devtools = null;
|
|
52
|
+
};
|
|
53
|
+
effect(
|
|
54
|
+
() => {
|
|
55
|
+
const shouldLoadTools = shouldLoadToolsSignal();
|
|
56
|
+
const {
|
|
57
|
+
client,
|
|
58
|
+
position,
|
|
59
|
+
errorTypes,
|
|
60
|
+
buttonPosition,
|
|
61
|
+
initialIsOpen
|
|
62
|
+
} = devtoolsOptions();
|
|
63
|
+
if (!shouldLoadTools) {
|
|
64
|
+
devtools && destroyDevtools();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (devtools) {
|
|
68
|
+
client && devtools.setClient(client);
|
|
69
|
+
position && devtools.setPosition(position);
|
|
70
|
+
errorTypes && devtools.setErrorTypes(errorTypes);
|
|
71
|
+
buttonPosition && devtools.setButtonPosition(buttonPosition);
|
|
72
|
+
typeof initialIsOpen === "boolean" && devtools.setInitialIsOpen(initialIsOpen);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
import("@tanstack/query-devtools").then((queryDevtools) => {
|
|
76
|
+
if (injectorIsDestroyed) return;
|
|
77
|
+
devtools = new queryDevtools.TanstackQueryDevtools({
|
|
78
|
+
...devtoolsOptions(),
|
|
79
|
+
client: getResolvedQueryClient(),
|
|
80
|
+
queryFlavor: "Angular Query",
|
|
81
|
+
version: "5",
|
|
82
|
+
onlineManager
|
|
83
|
+
});
|
|
84
|
+
el = document.body.appendChild(document.createElement("div"));
|
|
85
|
+
el.classList.add("tsqd-parent-container");
|
|
86
|
+
devtools.mount(el);
|
|
87
|
+
destroyRef.onDestroy(destroyDevtools);
|
|
88
|
+
}).catch((error) => {
|
|
89
|
+
console.error(
|
|
90
|
+
"Install @tanstack/query-devtools or reinstall without --omit=optional.",
|
|
91
|
+
error
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
{ injector }
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]);
|
|
101
|
+
export {
|
|
102
|
+
withDevtools
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=with-devtools.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-devtools.mjs","sources":["../../src/devtools/with-devtools.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common'\nimport {\n DestroyRef,\n ENVIRONMENT_INITIALIZER,\n InjectionToken,\n Injector,\n PLATFORM_ID,\n computed,\n effect,\n inject,\n isDevMode,\n} from '@angular/core'\nimport { QueryClient, noop, onlineManager } from '@tanstack/query-core'\nimport { queryFeature } from '../providers'\nimport type { Signal } from '@angular/core'\nimport type {\n DevtoolsOptions,\n WithDevtools,\n WithDevtoolsFn,\n WithDevtoolsOptions,\n} from './types'\nimport type { TanstackQueryDevtools } from '@tanstack/query-devtools'\n\n/**\n * Internal token used to prevent double providing of devtools in child injectors\n */\nconst DEVTOOLS_PROVIDED = new InjectionToken('', {\n factory: () => ({\n isProvided: false,\n }),\n})\n\n/**\n * Internal token for providing devtools options\n */\nconst DEVTOOLS_OPTIONS_SIGNAL = new InjectionToken<Signal<DevtoolsOptions>>('')\n\n/**\n * Enables developer tools in Angular development builds.\n *\n * **Example**\n *\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideTanStackQuery(new QueryClient(), withDevtools())\n * ]\n * }\n * ```\n * The devtools will be rendered in `<body>`.\n *\n * If you need more control over when devtools are loaded, you can use the `loadDevtools` option.\n *\n * If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.\n * @param withDevtoolsFn - A function that returns `DevtoolsOptions`.\n * @param options - Additional options for configuring `withDevtools`.\n * @returns A set of providers for use with `provideTanStackQuery`.\n * @see {@link provideTanStackQuery}\n * @see {@link DevtoolsOptions}\n */\nexport const withDevtools: WithDevtools = (\n withDevtoolsFn?: WithDevtoolsFn,\n options: WithDevtoolsOptions = {},\n) =>\n queryFeature('Devtools', [\n {\n provide: DEVTOOLS_OPTIONS_SIGNAL,\n useFactory: (...deps: Array<any>) =>\n computed(() => withDevtoolsFn?.(...deps) ?? {}),\n deps: options.deps || [],\n },\n {\n // Do not use provideEnvironmentInitializer while Angular < v19 is supported\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: () => {\n const devtoolsProvided = inject(DEVTOOLS_PROVIDED)\n if (\n !isPlatformBrowser(inject(PLATFORM_ID)) ||\n devtoolsProvided.isProvided\n )\n return noop\n\n devtoolsProvided.isProvided = true\n let injectorIsDestroyed = false\n inject(DestroyRef).onDestroy(() => (injectorIsDestroyed = true))\n\n return () => {\n const injectedClient = inject(QueryClient, {\n optional: true,\n })\n const destroyRef = inject(DestroyRef)\n const devtoolsOptions = inject(DEVTOOLS_OPTIONS_SIGNAL)\n const injector = inject(Injector)\n\n let devtools: TanstackQueryDevtools | null = null\n let el: HTMLElement | null = null\n\n const shouldLoadToolsSignal = computed(() => {\n const { loadDevtools } = devtoolsOptions()\n return typeof loadDevtools === 'boolean'\n ? loadDevtools\n : isDevMode()\n })\n\n const getResolvedQueryClient = () => {\n const client = devtoolsOptions().client ?? injectedClient\n if (!client) {\n throw new Error('No QueryClient found')\n }\n return client\n }\n\n const destroyDevtools = () => {\n devtools?.unmount()\n el?.remove()\n devtools = null\n }\n\n effect(\n () => {\n const shouldLoadTools = shouldLoadToolsSignal()\n const {\n client,\n position,\n errorTypes,\n buttonPosition,\n initialIsOpen,\n } = devtoolsOptions()\n\n if (!shouldLoadTools) {\n // Destroy or do nothing\n devtools && destroyDevtools()\n return\n }\n\n if (devtools) {\n // Update existing devtools config\n client && devtools.setClient(client)\n position && devtools.setPosition(position)\n errorTypes && devtools.setErrorTypes(errorTypes)\n buttonPosition && devtools.setButtonPosition(buttonPosition)\n typeof initialIsOpen === 'boolean' &&\n devtools.setInitialIsOpen(initialIsOpen)\n return\n }\n\n // Create devtools\n import('@tanstack/query-devtools')\n .then((queryDevtools) => {\n // As this code runs async, the injector could have been destroyed\n if (injectorIsDestroyed) return\n\n devtools = new queryDevtools.TanstackQueryDevtools({\n ...devtoolsOptions(),\n client: getResolvedQueryClient(),\n queryFlavor: 'Angular Query',\n version: '5',\n onlineManager,\n })\n\n el = document.body.appendChild(document.createElement('div'))\n el.classList.add('tsqd-parent-container')\n devtools.mount(el)\n\n destroyRef.onDestroy(destroyDevtools)\n })\n .catch((error) => {\n console.error(\n 'Install @tanstack/query-devtools or reinstall without --omit=optional.',\n error,\n )\n })\n },\n { injector },\n )\n }\n },\n },\n ])\n"],"names":[],"mappings":";;;;AA0BA,MAAM,oBAAoB,IAAI,eAAe,IAAI;AAAA,EAC/C,SAAS,OAAO;AAAA,IACd,YAAY;AAAA,EACd;AACF,CAAC;AAKD,MAAM,0BAA0B,IAAI,eAAwC,EAAE;AAyBvE,MAAM,eAA6B,CACxC,gBACA,UAA+B,CAAA,MAE/B,aAAa,YAAY;AAAA,EACvB;AAAA,IACE,SAAS;AAAA,IACT,YAAY,IAAI,SACd,SAAS,OAAM,iDAAiB,GAAG,UAAS,EAAE;AAAA,IAChD,MAAM,QAAQ,QAAQ,CAAA;AAAA,EACxB;AAAA,EACA;AAAA;AAAA,IAEE,SAAS;AAAA,IACT,OAAO;AAAA,IACP,YAAY,MAAM;AACV,YAAA,mBAAmB,OAAO,iBAAiB;AACjD,UACE,CAAC,kBAAkB,OAAO,WAAW,CAAC,KACtC,iBAAiB;AAEV,eAAA;AAET,uBAAiB,aAAa;AAC9B,UAAI,sBAAsB;AAC1B,aAAO,UAAU,EAAE,UAAU,MAAO,sBAAsB,IAAK;AAE/D,aAAO,MAAM;AACL,cAAA,iBAAiB,OAAO,aAAa;AAAA,UACzC,UAAU;AAAA,QAAA,CACX;AACK,cAAA,aAAa,OAAO,UAAU;AAC9B,cAAA,kBAAkB,OAAO,uBAAuB;AAChD,cAAA,WAAW,OAAO,QAAQ;AAEhC,YAAI,WAAyC;AAC7C,YAAI,KAAyB;AAEvB,cAAA,wBAAwB,SAAS,MAAM;AACrC,gBAAA,EAAE,aAAa,IAAI,gBAAgB;AACzC,iBAAO,OAAO,iBAAiB,YAC3B,eACA,UAAU;AAAA,QAAA,CACf;AAED,cAAM,yBAAyB,MAAM;AAC7B,gBAAA,SAAS,kBAAkB,UAAU;AAC3C,cAAI,CAAC,QAAQ;AACL,kBAAA,IAAI,MAAM,sBAAsB;AAAA,UAAA;AAEjC,iBAAA;AAAA,QACT;AAEA,cAAM,kBAAkB,MAAM;AAC5B,+CAAU;AACV,mCAAI;AACO,qBAAA;AAAA,QACb;AAEA;AAAA,UACE,MAAM;AACJ,kBAAM,kBAAkB,sBAAsB;AACxC,kBAAA;AAAA,cACJ;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,gBACE,gBAAgB;AAEpB,gBAAI,CAAC,iBAAiB;AAEpB,0BAAY,gBAAgB;AAC5B;AAAA,YAAA;AAGF,gBAAI,UAAU;AAEF,wBAAA,SAAS,UAAU,MAAM;AACvB,0BAAA,SAAS,YAAY,QAAQ;AAC3B,4BAAA,SAAS,cAAc,UAAU;AAC7B,gCAAA,SAAS,kBAAkB,cAAc;AAC3D,qBAAO,kBAAkB,aACvB,SAAS,iBAAiB,aAAa;AACzC;AAAA,YAAA;AAIF,mBAAO,0BAA0B,EAC9B,KAAK,CAAC,kBAAkB;AAEvB,kBAAI,oBAAqB;AAEd,yBAAA,IAAI,cAAc,sBAAsB;AAAA,gBACjD,GAAG,gBAAgB;AAAA,gBACnB,QAAQ,uBAAuB;AAAA,gBAC/B,aAAa;AAAA,gBACb,SAAS;AAAA,gBACT;AAAA,cAAA,CACD;AAED,mBAAK,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC;AACzD,iBAAA,UAAU,IAAI,uBAAuB;AACxC,uBAAS,MAAM,EAAE;AAEjB,yBAAW,UAAU,eAAe;AAAA,YAAA,CACrC,EACA,MAAM,CAAC,UAAU;AACR,sBAAA;AAAA,gBACN;AAAA,gBACA;AAAA,cACF;AAAA,YAAA,CACD;AAAA,UACL;AAAA,UACA,EAAE,SAAS;AAAA,QACb;AAAA,MACF;AAAA,IAAA;AAAA,EACF;AAEJ,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InjectDevtoolsPanel } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Inject a TanStack Query devtools panel and render it in the DOM.
|
|
4
|
+
*
|
|
5
|
+
* Devtools panel allows programmatic control over the devtools, for example if you want to render
|
|
6
|
+
* the devtools as part of your own devtools.
|
|
7
|
+
*
|
|
8
|
+
* Consider `withDevtools` instead if you don't need this.
|
|
9
|
+
* @param injectDevtoolsPanelFn - A function that returns devtools panel options.
|
|
10
|
+
* @param options - Additional configuration
|
|
11
|
+
* @returns DevtoolsPanelRef
|
|
12
|
+
* @see https://tanstack.com/query/v5/docs/framework/angular/devtools
|
|
13
|
+
*/
|
|
14
|
+
export declare const injectDevtoolsPanel: InjectDevtoolsPanel;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { assertInInjectionContext, inject, Injector, runInInjectionContext, DestroyRef, PLATFORM_ID, computed, effect, untracked } from "@angular/core";
|
|
2
|
+
import { QueryClient, onlineManager } from "@tanstack/query-core";
|
|
3
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
4
|
+
const injectDevtoolsPanel = (injectDevtoolsPanelFn, options) => {
|
|
5
|
+
!(options == null ? void 0 : options.injector) && assertInInjectionContext(injectDevtoolsPanel);
|
|
6
|
+
const currentInjector = (options == null ? void 0 : options.injector) ?? inject(Injector);
|
|
7
|
+
return runInInjectionContext(currentInjector, () => {
|
|
8
|
+
const destroyRef = inject(DestroyRef);
|
|
9
|
+
const isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
10
|
+
const injectedClient = inject(QueryClient, { optional: true });
|
|
11
|
+
const queryOptions = computed(injectDevtoolsPanelFn);
|
|
12
|
+
let devtools = null;
|
|
13
|
+
const destroy = () => {
|
|
14
|
+
devtools == null ? void 0 : devtools.unmount();
|
|
15
|
+
devtools = null;
|
|
16
|
+
};
|
|
17
|
+
if (!isBrowser)
|
|
18
|
+
return {
|
|
19
|
+
destroy
|
|
20
|
+
};
|
|
21
|
+
effect(() => {
|
|
22
|
+
const {
|
|
23
|
+
client = injectedClient,
|
|
24
|
+
errorTypes = [],
|
|
25
|
+
styleNonce,
|
|
26
|
+
shadowDOMTarget,
|
|
27
|
+
onClose,
|
|
28
|
+
hostElement
|
|
29
|
+
} = queryOptions();
|
|
30
|
+
untracked(() => {
|
|
31
|
+
if (!client) throw new Error("No QueryClient found");
|
|
32
|
+
if (!devtools && hostElement) {
|
|
33
|
+
import("@tanstack/query-devtools").then((queryDevtools) => {
|
|
34
|
+
devtools = new queryDevtools.TanstackQueryDevtoolsPanel({
|
|
35
|
+
client,
|
|
36
|
+
queryFlavor: "Angular Query",
|
|
37
|
+
version: "5",
|
|
38
|
+
buttonPosition: "bottom-left",
|
|
39
|
+
position: "bottom",
|
|
40
|
+
initialIsOpen: true,
|
|
41
|
+
errorTypes,
|
|
42
|
+
styleNonce,
|
|
43
|
+
shadowDOMTarget,
|
|
44
|
+
onClose,
|
|
45
|
+
onlineManager
|
|
46
|
+
});
|
|
47
|
+
devtools.mount(hostElement.nativeElement);
|
|
48
|
+
}).catch((error) => {
|
|
49
|
+
console.error(
|
|
50
|
+
"Install @tanstack/query-devtools or reinstall without --omit=optional.",
|
|
51
|
+
error
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
} else if (devtools && hostElement) {
|
|
55
|
+
devtools.setClient(client);
|
|
56
|
+
devtools.setErrorTypes(errorTypes);
|
|
57
|
+
onClose && devtools.setOnClose(onClose);
|
|
58
|
+
} else if (devtools && !hostElement) {
|
|
59
|
+
destroy();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
destroyRef.onDestroy(destroy);
|
|
64
|
+
return {
|
|
65
|
+
destroy
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
injectDevtoolsPanel
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=inject-devtools-panel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-devtools-panel.mjs","sources":["../../src/devtools-panel/inject-devtools-panel.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n PLATFORM_ID,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n runInInjectionContext,\n untracked,\n} from '@angular/core'\nimport { QueryClient, onlineManager } from '@tanstack/query-core'\nimport { isPlatformBrowser } from '@angular/common'\nimport type { TanstackQueryDevtoolsPanel } from '@tanstack/query-devtools'\nimport type {\n DevtoolsPanelOptions,\n InjectDevtoolsPanel,\n InjectDevtoolsPanelOptions,\n} from './types'\n\n/**\n * Inject a TanStack Query devtools panel and render it in the DOM.\n *\n * Devtools panel allows programmatic control over the devtools, for example if you want to render\n * the devtools as part of your own devtools.\n *\n * Consider `withDevtools` instead if you don't need this.\n * @param injectDevtoolsPanelFn - A function that returns devtools panel options.\n * @param options - Additional configuration\n * @returns DevtoolsPanelRef\n * @see https://tanstack.com/query/v5/docs/framework/angular/devtools\n */\nexport const injectDevtoolsPanel: InjectDevtoolsPanel = (\n injectDevtoolsPanelFn: () => DevtoolsPanelOptions,\n options?: InjectDevtoolsPanelOptions,\n) => {\n !options?.injector && assertInInjectionContext(injectDevtoolsPanel)\n const currentInjector = options?.injector ?? inject(Injector)\n\n return runInInjectionContext(currentInjector, () => {\n const destroyRef = inject(DestroyRef)\n const isBrowser = isPlatformBrowser(inject(PLATFORM_ID))\n const injectedClient = inject(QueryClient, { optional: true })\n\n const queryOptions = computed(injectDevtoolsPanelFn)\n let devtools: TanstackQueryDevtoolsPanel | null = null\n\n const destroy = () => {\n devtools?.unmount()\n devtools = null\n }\n\n if (!isBrowser)\n return {\n destroy,\n }\n\n effect(() => {\n const {\n client = injectedClient,\n errorTypes = [],\n styleNonce,\n shadowDOMTarget,\n onClose,\n hostElement,\n } = queryOptions()\n\n untracked(() => {\n if (!client) throw new Error('No QueryClient found')\n if (!devtools && hostElement) {\n import('@tanstack/query-devtools')\n .then((queryDevtools) => {\n devtools = new queryDevtools.TanstackQueryDevtoolsPanel({\n client,\n queryFlavor: 'Angular Query',\n version: '5',\n buttonPosition: 'bottom-left',\n position: 'bottom',\n initialIsOpen: true,\n errorTypes,\n styleNonce,\n shadowDOMTarget,\n onClose,\n onlineManager,\n })\n devtools.mount(hostElement.nativeElement)\n })\n .catch((error) => {\n console.error(\n 'Install @tanstack/query-devtools or reinstall without --omit=optional.',\n error,\n )\n })\n } else if (devtools && hostElement) {\n devtools.setClient(client)\n devtools.setErrorTypes(errorTypes)\n onClose && devtools.setOnClose(onClose)\n } else if (devtools && !hostElement) {\n destroy()\n }\n })\n })\n\n destroyRef.onDestroy(destroy)\n\n return {\n destroy,\n }\n })\n}\n"],"names":[],"mappings":";;;AAgCa,MAAA,sBAA2C,CACtD,uBACA,YACG;AACF,IAAA,mCAAS,aAAY,yBAAyB,mBAAmB;AAClE,QAAM,mBAAkB,mCAAS,aAAY,OAAO,QAAQ;AAErD,SAAA,sBAAsB,iBAAiB,MAAM;AAC5C,UAAA,aAAa,OAAO,UAAU;AACpC,UAAM,YAAY,kBAAkB,OAAO,WAAW,CAAC;AACvD,UAAM,iBAAiB,OAAO,aAAa,EAAE,UAAU,MAAM;AAEvD,UAAA,eAAe,SAAS,qBAAqB;AACnD,QAAI,WAA8C;AAElD,UAAM,UAAU,MAAM;AACpB,2CAAU;AACC,iBAAA;AAAA,IACb;AAEA,QAAI,CAAC;AACI,aAAA;AAAA,QACL;AAAA,MACF;AAEF,WAAO,MAAM;AACL,YAAA;AAAA,QACJ,SAAS;AAAA,QACT,aAAa,CAAC;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,UACE,aAAa;AAEjB,gBAAU,MAAM;AACd,YAAI,CAAC,OAAc,OAAA,IAAI,MAAM,sBAAsB;AAC/C,YAAA,CAAC,YAAY,aAAa;AAC5B,iBAAO,0BAA0B,EAC9B,KAAK,CAAC,kBAAkB;AACZ,uBAAA,IAAI,cAAc,2BAA2B;AAAA,cACtD;AAAA,cACA,aAAa;AAAA,cACb,SAAS;AAAA,cACT,gBAAgB;AAAA,cAChB,UAAU;AAAA,cACV,eAAe;AAAA,cACf;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YAAA,CACD;AACQ,qBAAA,MAAM,YAAY,aAAa;AAAA,UAAA,CACzC,EACA,MAAM,CAAC,UAAU;AACR,oBAAA;AAAA,cACN;AAAA,cACA;AAAA,YACF;AAAA,UAAA,CACD;AAAA,QAAA,WACM,YAAY,aAAa;AAClC,mBAAS,UAAU,MAAM;AACzB,mBAAS,cAAc,UAAU;AACtB,qBAAA,SAAS,WAAW,OAAO;AAAA,QAAA,WAC7B,YAAY,CAAC,aAAa;AAC3B,kBAAA;AAAA,QAAA;AAAA,MACV,CACD;AAAA,IAAA,CACF;AAED,eAAW,UAAU,OAAO;AAErB,WAAA;AAAA,MACL;AAAA,IACF;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '..';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stub.mjs","sources":["../../src/devtools-panel/stub.ts"],"sourcesContent":["import { noop } from '@tanstack/query-core'\nimport type { InjectDevtoolsPanel } from './types'\n\n// Stub which replaces `injectDevtoolsPanel` in production builds\nexport const injectDevtoolsPanel: InjectDevtoolsPanel = () => ({\n destroy: noop,\n})\n"],"names":[],"mappings":";AAIO,MAAM,sBAA2C,OAAO;AAAA,EAC7D,SAAS;AACX;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DevtoolsErrorType } from '@tanstack/query-devtools';
|
|
2
|
+
import { ElementRef, Injector } from '@angular/core';
|
|
3
|
+
import { QueryClient } from '@tanstack/query-core';
|
|
4
|
+
export interface InjectDevtoolsPanelOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The `Injector` in which to create the devtools panel.
|
|
7
|
+
*
|
|
8
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
9
|
+
*/
|
|
10
|
+
injector?: Injector;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A devtools panel, which can be manually destroyed.
|
|
14
|
+
*/
|
|
15
|
+
export interface DevtoolsPanelRef {
|
|
16
|
+
/**
|
|
17
|
+
* Destroy the panel, removing it from the DOM and stops listening to signal changes.
|
|
18
|
+
*/
|
|
19
|
+
destroy: () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface DevtoolsPanelOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Custom instance of QueryClient
|
|
24
|
+
*/
|
|
25
|
+
client?: QueryClient;
|
|
26
|
+
/**
|
|
27
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
28
|
+
*/
|
|
29
|
+
errorTypes?: Array<DevtoolsErrorType>;
|
|
30
|
+
/**
|
|
31
|
+
* Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.
|
|
32
|
+
*/
|
|
33
|
+
styleNonce?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Use this so you can attach the devtool's styles to specific element in the DOM.
|
|
36
|
+
*/
|
|
37
|
+
shadowDOMTarget?: ShadowRoot;
|
|
38
|
+
/**
|
|
39
|
+
* Callback function that is called when the devtools panel is closed
|
|
40
|
+
*/
|
|
41
|
+
onClose?: () => unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Element where to render the devtools panel. When set to undefined or null, the devtools panel will not be created, or destroyed if existing.
|
|
44
|
+
* If changed from undefined to a ElementRef, the devtools panel will be created.
|
|
45
|
+
*/
|
|
46
|
+
hostElement?: ElementRef;
|
|
47
|
+
}
|
|
48
|
+
export type InjectDevtoolsPanel = (injectDevtoolsPanelFn: () => DevtoolsPanelOptions, options?: InjectDevtoolsPanelOptions) => DevtoolsPanelRef;
|
package/index.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export type { QueriesOptions, QueriesResults } from './inject-queries.js';
|
|
|
21
21
|
export type { InjectQueryOptions } from './inject-query.js';
|
|
22
22
|
export { injectQuery } from './inject-query.js';
|
|
23
23
|
export { injectQueryClient } from './inject-query-client.js';
|
|
24
|
-
export type { DeveloperToolsFeature,
|
|
25
|
-
export { provideQueryClient, provideTanStackQuery, queryFeature,
|
|
24
|
+
export type { DeveloperToolsFeature, PersistQueryClientFeature, QueryFeature, QueryFeatures, } from './providers.js';
|
|
25
|
+
export { provideAngularQuery, provideQueryClient, provideTanStackQuery, queryFeature, } from './providers.js';
|
package/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { injectMutation } from "./inject-mutation.mjs";
|
|
|
10
10
|
import { injectMutationState } from "./inject-mutation-state.mjs";
|
|
11
11
|
import { injectQuery } from "./inject-query.mjs";
|
|
12
12
|
import { injectQueryClient } from "./inject-query-client.mjs";
|
|
13
|
-
import { provideQueryClient, provideTanStackQuery, queryFeature
|
|
13
|
+
import { provideAngularQuery, provideQueryClient, provideTanStackQuery, queryFeature } from "./providers.mjs";
|
|
14
14
|
export {
|
|
15
15
|
infiniteQueryOptions,
|
|
16
16
|
injectInfiniteQuery,
|
|
@@ -22,12 +22,11 @@ export {
|
|
|
22
22
|
injectQuery,
|
|
23
23
|
injectQueryClient,
|
|
24
24
|
mutationOptions,
|
|
25
|
+
provideAngularQuery,
|
|
25
26
|
provideIsRestoring,
|
|
26
27
|
provideQueryClient,
|
|
27
28
|
provideTanStackQuery,
|
|
28
29
|
queryFeature,
|
|
29
|
-
|
|
30
|
-
queryOptions,
|
|
31
|
-
withDevtools
|
|
30
|
+
queryOptions
|
|
32
31
|
};
|
|
33
32
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -15,7 +15,6 @@ export type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultErro
|
|
|
15
15
|
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
16
16
|
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
17
17
|
* @returns The tagged infinite query options.
|
|
18
|
-
* @public
|
|
19
18
|
*/
|
|
20
19
|
export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
21
20
|
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
@@ -26,7 +25,6 @@ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError
|
|
|
26
25
|
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
27
26
|
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
28
27
|
* @returns The tagged infinite query options.
|
|
29
|
-
* @public
|
|
30
28
|
*/
|
|
31
29
|
export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
32
30
|
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
@@ -37,7 +35,6 @@ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError
|
|
|
37
35
|
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
38
36
|
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
39
37
|
* @returns The tagged infinite query options.
|
|
40
|
-
* @public
|
|
41
38
|
*/
|
|
42
39
|
export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
43
40
|
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infinite-query-options.mjs","sources":["../src/infinite-query-options.ts"],"sourcesContent":["import type {\n DataTag,\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { CreateInfiniteQueryOptions } from './types'\n\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n | undefined\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n
|
|
1
|
+
{"version":3,"file":"infinite-query-options.mjs","sources":["../src/infinite-query-options.ts"],"sourcesContent":["import type {\n DataTag,\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { CreateInfiniteQueryOptions } from './types'\n\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n 'queryFn'\n> & {\n queryFn?: Exclude<\n CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n | undefined\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n */\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"names":[],"mappings":"AAoLO,SAAS,qBAAqB,SAAkB;AAC9C,SAAA;AACT;"}
|
|
@@ -16,7 +16,6 @@ export interface InjectInfiniteQueryOptions {
|
|
|
16
16
|
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
17
17
|
* @param options - Additional configuration.
|
|
18
18
|
* @returns The infinite query result.
|
|
19
|
-
* @public
|
|
20
19
|
*/
|
|
21
20
|
export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): DefinedCreateInfiniteQueryResult<TData, TError>;
|
|
22
21
|
/**
|
|
@@ -25,7 +24,6 @@ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError,
|
|
|
25
24
|
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
26
25
|
* @param options - Additional configuration.
|
|
27
26
|
* @returns The infinite query result.
|
|
28
|
-
* @public
|
|
29
27
|
*/
|
|
30
28
|
export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
|
|
31
29
|
/**
|
|
@@ -34,6 +32,5 @@ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError,
|
|
|
34
32
|
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
35
33
|
* @param options - Additional configuration.
|
|
36
34
|
* @returns The infinite query result.
|
|
37
|
-
* @public
|
|
38
35
|
*/
|
|
39
36
|
export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-infinite-query.mjs","sources":["../src/inject-infinite-query.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport {\n Injector,\n assertInInjectionContext,\n inject,\n runInInjectionContext,\n} from '@angular/core'\nimport { createBaseQuery } from './create-base-query'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type {\n CreateInfiniteQueryOptions,\n CreateInfiniteQueryResult,\n DefinedCreateInfiniteQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infinite-query-options'\n\nexport interface InjectInfiniteQueryOptions {\n /**\n * The `Injector` in which to create the infinite query.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param injectInfiniteQueryFn - A function that returns infinite query options.\n * @param options - Additional configuration.\n * @returns The infinite query result.\n
|
|
1
|
+
{"version":3,"file":"inject-infinite-query.mjs","sources":["../src/inject-infinite-query.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport {\n Injector,\n assertInInjectionContext,\n inject,\n runInInjectionContext,\n} from '@angular/core'\nimport { createBaseQuery } from './create-base-query'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type {\n CreateInfiniteQueryOptions,\n CreateInfiniteQueryResult,\n DefinedCreateInfiniteQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infinite-query-options'\n\nexport interface InjectInfiniteQueryOptions {\n /**\n * The `Injector` in which to create the infinite query.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param injectInfiniteQueryFn - A function that returns infinite query options.\n * @param options - Additional configuration.\n * @returns The infinite query result.\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n injectInfiniteQueryFn: () => DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n options?: InjectInfiniteQueryOptions,\n): DefinedCreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param injectInfiniteQueryFn - A function that returns infinite query options.\n * @param options - Additional configuration.\n * @returns The infinite query result.\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n injectInfiniteQueryFn: () => UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n options?: InjectInfiniteQueryOptions,\n): CreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param injectInfiniteQueryFn - A function that returns infinite query options.\n * @param options - Additional configuration.\n * @returns The infinite query result.\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n injectInfiniteQueryFn: () => CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n options?: InjectInfiniteQueryOptions,\n): CreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param injectInfiniteQueryFn - A function that returns infinite query options.\n * @param options - Additional configuration.\n * @returns The infinite query result.\n */\nexport function injectInfiniteQuery(\n injectInfiniteQueryFn: () => CreateInfiniteQueryOptions,\n options?: InjectInfiniteQueryOptions,\n) {\n !options?.injector && assertInInjectionContext(injectInfiniteQuery)\n const injector = options?.injector ?? inject(Injector)\n return runInInjectionContext(injector, () =>\n createBaseQuery(\n injectInfiniteQueryFn,\n InfiniteQueryObserver as typeof QueryObserver,\n ),\n )\n}\n"],"names":[],"mappings":";;;AAgHgB,SAAA,oBACd,uBACA,SACA;AACC,IAAA,mCAAS,aAAY,yBAAyB,mBAAmB;AAClE,QAAM,YAAW,mCAAS,aAAY,OAAO,QAAQ;AAC9C,SAAA;AAAA,IAAsB;AAAA,IAAU,MACrC;AAAA,MACE;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF;"}
|
package/inject-is-mutating.d.ts
CHANGED
|
@@ -15,6 +15,5 @@ export interface InjectIsMutatingOptions {
|
|
|
15
15
|
* @param filters - The filters to apply to the query.
|
|
16
16
|
* @param options - Additional configuration
|
|
17
17
|
* @returns signal with number of fetching mutations.
|
|
18
|
-
* @public
|
|
19
18
|
*/
|
|
20
19
|
export declare function injectIsMutating(filters?: MutationFilters, options?: InjectIsMutatingOptions): Signal<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-is-mutating.mjs","sources":["../src/inject-is-mutating.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { Signal } from '@angular/core'\n\nexport interface InjectIsMutatingOptions {\n /**\n * The `Injector` in which to create the isMutating signal.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a signal that tracks the number of mutations that your application is fetching.\n *\n * Can be used for app-wide loading indicators\n * @param filters - The filters to apply to the query.\n * @param options - Additional configuration\n * @returns signal with number of fetching mutations.\n
|
|
1
|
+
{"version":3,"file":"inject-is-mutating.mjs","sources":["../src/inject-is-mutating.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { Signal } from '@angular/core'\n\nexport interface InjectIsMutatingOptions {\n /**\n * The `Injector` in which to create the isMutating signal.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a signal that tracks the number of mutations that your application is fetching.\n *\n * Can be used for app-wide loading indicators\n * @param filters - The filters to apply to the query.\n * @param options - Additional configuration\n * @returns signal with number of fetching mutations.\n */\nexport function injectIsMutating(\n filters?: MutationFilters,\n options?: InjectIsMutatingOptions,\n): Signal<number> {\n !options?.injector && assertInInjectionContext(injectIsMutating)\n const injector = options?.injector ?? inject(Injector)\n const destroyRef = injector.get(DestroyRef)\n const ngZone = injector.get(NgZone)\n const queryClient = injector.get(QueryClient)\n\n const cache = queryClient.getMutationCache()\n // isMutating is the prev value initialized on mount *\n let isMutating = queryClient.isMutating(filters)\n\n const result = signal(isMutating)\n\n const unsubscribe = ngZone.runOutsideAngular(() =>\n cache.subscribe(\n notifyManager.batchCalls(() => {\n const newIsMutating = queryClient.isMutating(filters)\n if (isMutating !== newIsMutating) {\n // * and update with each change\n isMutating = newIsMutating\n ngZone.run(() => {\n result.set(isMutating)\n })\n }\n }),\n ),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return result\n}\n"],"names":[],"mappings":";;AA6BgB,SAAA,iBACd,SACA,SACgB;AACf,IAAA,mCAAS,aAAY,yBAAyB,gBAAgB;AAC/D,QAAM,YAAW,mCAAS,aAAY,OAAO,QAAQ;AAC/C,QAAA,aAAa,SAAS,IAAI,UAAU;AACpC,QAAA,SAAS,SAAS,IAAI,MAAM;AAC5B,QAAA,cAAc,SAAS,IAAI,WAAW;AAEtC,QAAA,QAAQ,YAAY,iBAAiB;AAEvC,MAAA,aAAa,YAAY,WAAW,OAAO;AAEzC,QAAA,SAAS,OAAO,UAAU;AAEhC,QAAM,cAAc,OAAO;AAAA,IAAkB,MAC3C,MAAM;AAAA,MACJ,cAAc,WAAW,MAAM;AACvB,cAAA,gBAAgB,YAAY,WAAW,OAAO;AACpD,YAAI,eAAe,eAAe;AAEnB,uBAAA;AACb,iBAAO,IAAI,MAAM;AACf,mBAAO,IAAI,UAAU;AAAA,UAAA,CACtB;AAAA,QAAA;AAAA,MAEJ,CAAA;AAAA,IAAA;AAAA,EAEL;AAEA,aAAW,UAAU,WAAW;AAEzB,SAAA;AACT;"}
|