@tanstack/angular-query-persist-client 5.0.0-rc.5 → 5.0.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/README.md CHANGED
@@ -5,14 +5,19 @@ Persistence integration for `@tanstack/angular-query`.
5
5
  ## Installation
6
6
 
7
7
  ```sh
8
- pnpm add @tanstack/angular-query-persist-client @tanstack/query-persist-client-core
8
+ pnpm add @tanstack/angular-query-persist-client @tanstack/query-async-storage-persister
9
9
  ```
10
10
 
11
+ `@tanstack/query-async-storage-persister` provides the persister used below. Any
12
+ other persister works as well.
13
+
11
14
  ## Usage
12
15
 
13
16
  ```ts
14
17
  import { QueryClient, provideTanStackQuery } from '@tanstack/angular-query'
15
18
  import { withPersistQueryClient } from '@tanstack/angular-query-persist-client'
19
+ import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
20
+ import type { ApplicationConfig } from '@angular/core'
16
21
 
17
22
  export const appConfig: ApplicationConfig = {
18
23
  providers: [
package/build/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { PersistQueryClientOptions } from "@tanstack/query-persist-client-core";
2
2
  import { QueryFeature } from "@tanstack/angular-query";
3
3
  export * from "@tanstack/query-persist-client-core";
4
- //#region src/with-persist-query-client.types.d.ts
5
4
  /**
6
5
  * Configures cache persistence and callbacks for completion of the initial restoration.
7
6
  */
@@ -20,8 +19,6 @@ type PersistQueryClientUserOptions = {
20
19
  * context in the browser, so it can call `inject()` and touch browser APIs.
21
20
  */
22
21
  type WithPersistQueryClientFn = () => PersistQueryClientUserOptions;
23
- //#endregion
24
- //#region src/with-persist-query-client.d.ts
25
22
  /**
26
23
  * Enables persistence. The options factory runs once per injector, only in the
27
24
  * browser, in an Angular injection context. It can call `inject()` and use
@@ -39,6 +36,5 @@ type WithPersistQueryClientFn = () => PersistQueryClientUserOptions;
39
36
  * @public
40
37
  */
41
38
  export declare function withPersistQueryClient(optionsFactory: WithPersistQueryClientFn): QueryFeature;
42
- //#endregion
43
39
  export type { PersistQueryClientUserOptions, WithPersistQueryClientFn };
44
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["PersistQueryClientOptionsCore"],"sources":["../src/with-persist-query-client.types.ts","../src/with-persist-query-client.ts"],"mappings":";;;;;;;KAKY;;;;EAIV,gBAAgB,KAAKA;;EAErB;;EAEA;;;;;;KAOU,iCAAiC;;;;;;;;;;;;;;;;;;;wBC4B7B,uBACd,gBAAgB,2BACf"}
1
+ {"version":3,"file":"index.d.ts","names":["PersistQueryClientOptionsCore"],"sources":["../src/with-persist-query-client.types.ts","../src/with-persist-query-client.ts"],"mappings":";;;;;;KAKY;;;;EAIV,gBAAgB,KAAKA;;EAErB;;EAEA;;;;;;KAOU,iCAAiC;;;;;;;;;;;;;;;;;wBC4B7B,uBACd,gBAAgB,2BACf"}
package/build/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { persistQueryClientRestore, persistQueryClientSubscribe } from "@tanstack/query-persist-client-core";
2
- import { QueryClient } from "@tanstack/angular-query";
2
+ import { isPlatformBrowser } from "@angular/common";
3
3
  import { DestroyRef, InjectionToken, PLATFORM_ID, inject, makeEnvironmentProviders, provideEnvironmentInitializer, signal } from "@angular/core";
4
+ import { QueryClient } from "@tanstack/angular-query";
4
5
  import { provideIsRestoring, queryFeature } from "@tanstack/angular-query/internal";
5
- import { isPlatformBrowser } from "@angular/common";
6
6
  export * from "@tanstack/query-persist-client-core";
7
- //#region src/with-persist-query-client.ts
7
+ // src/with-persist-query-client.ts
8
8
  const RESTORING_STATE = new InjectionToken("Query restoration state");
9
9
  /**
10
10
  * Enables persistence. The options factory runs once per injector, only in the
@@ -55,7 +55,6 @@ function withPersistQueryClient(optionsFactory) {
55
55
  })
56
56
  ]));
57
57
  }
58
- //#endregion
59
58
  export { withPersistQueryClient };
60
59
 
61
60
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/with-persist-query-client.ts"],"sourcesContent":["import { QueryClient } from '@tanstack/angular-query'\nimport {\n DestroyRef,\n InjectionToken,\n PLATFORM_ID,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n signal,\n} from '@angular/core'\nimport {\n provideIsRestoring,\n queryFeature,\n} from '@tanstack/angular-query/internal'\nimport { isPlatformBrowser } from '@angular/common'\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport type { WritableSignal } from '@angular/core'\nimport type { QueryFeature } from '@tanstack/angular-query'\nimport type { WithPersistQueryClientFn } from './with-persist-query-client.types'\n\nconst RESTORING_STATE = new InjectionToken<WritableSignal<boolean>>(\n 'Query restoration state',\n)\n\nexport type {\n PersistQueryClientUserOptions,\n WithPersistQueryClientFn,\n} from './with-persist-query-client.types'\n\n/**\n * Enables persistence. The options factory runs once per injector, only in the\n * browser, in an Angular injection context. It can call `inject()` and use\n * browser APIs such as `localStorage`.\n *\n * ```ts\n * withPersistQueryClient(() => ({\n * persistOptions: {\n * persister: createAsyncStoragePersister({ storage: localStorage }),\n * },\n * }))\n * ```\n * @param optionsFactory - Creates the persistence options in the browser.\n * @returns A set of providers for use with `provideTanStackQuery`.\n * @public\n */\nexport function withPersistQueryClient(\n optionsFactory: WithPersistQueryClientFn,\n): QueryFeature {\n return queryFeature(\n makeEnvironmentProviders([\n { provide: RESTORING_STATE, useFactory: () => signal(true) },\n provideIsRestoring(() => inject(RESTORING_STATE).asReadonly()),\n provideEnvironmentInitializer(() => {\n const isRestoring = inject(RESTORING_STATE)\n if (!isPlatformBrowser(inject(PLATFORM_ID))) {\n isRestoring.set(false)\n return\n }\n const destroyRef = inject(DestroyRef)\n const queryClient = inject(QueryClient)\n\n const { onSuccess, onError, persistOptions } = optionsFactory()\n const options = { queryClient, ...persistOptions }\n void persistQueryClientRestore(options)\n .then(() => {\n return onSuccess?.()\n })\n .catch(() => {\n return onError?.()\n })\n .finally(() => {\n if (destroyRef.destroyed) return\n isRestoring.set(false)\n const cleanup = persistQueryClientSubscribe(options)\n destroyRef.onDestroy(cleanup)\n })\n }),\n ]),\n )\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,kBAAkB,IAAI,eAC1B,yBACF;;;;;;;;;;;;;;;;;AAuBA,SAAgB,uBACd,gBACc;CACd,OAAO,aACL,yBAAyB;EACvB;GAAE,SAAS;GAAiB,kBAAkB,OAAO,IAAI;EAAE;EAC3D,yBAAyB,OAAO,eAAe,CAAC,CAAC,WAAW,CAAC;EAC7D,oCAAoC;GAClC,MAAM,cAAc,OAAO,eAAe;GAC1C,IAAI,CAAC,kBAAkB,OAAO,WAAW,CAAC,GAAG;IAC3C,YAAY,IAAI,KAAK;IACrB;GACF;GACA,MAAM,aAAa,OAAO,UAAU;GACpC,MAAM,cAAc,OAAO,WAAW;GAEtC,MAAM,EAAE,WAAW,SAAS,mBAAmB,eAAe;GAC9D,MAAM,UAAU;IAAE;IAAa,GAAG;GAAe;GACjD,0BAA+B,OAAO,CAAC,CACpC,WAAW;IACV,OAAO,YAAY;GACrB,CAAC,CAAC,CACD,YAAY;IACX,OAAO,UAAU;GACnB,CAAC,CAAC,CACD,cAAc;IACb,IAAI,WAAW,WAAW;IAC1B,YAAY,IAAI,KAAK;IACrB,MAAM,UAAU,4BAA4B,OAAO;IACnD,WAAW,UAAU,OAAO;GAC9B,CAAC;EACL,CAAC;CACH,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/with-persist-query-client.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common'\nimport {\n DestroyRef,\n InjectionToken,\n PLATFORM_ID,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n signal,\n} from '@angular/core'\nimport { QueryClient } from '@tanstack/angular-query'\nimport {\n provideIsRestoring,\n queryFeature,\n} from '@tanstack/angular-query/internal'\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport type { WritableSignal } from '@angular/core'\nimport type { QueryFeature } from '@tanstack/angular-query'\nimport type { WithPersistQueryClientFn } from './with-persist-query-client.types'\n\nconst RESTORING_STATE = new InjectionToken<WritableSignal<boolean>>(\n 'Query restoration state',\n)\n\nexport type {\n PersistQueryClientUserOptions,\n WithPersistQueryClientFn,\n} from './with-persist-query-client.types'\n\n/**\n * Enables persistence. The options factory runs once per injector, only in the\n * browser, in an Angular injection context. It can call `inject()` and use\n * browser APIs such as `localStorage`.\n *\n * ```ts\n * withPersistQueryClient(() => ({\n * persistOptions: {\n * persister: createAsyncStoragePersister({ storage: localStorage }),\n * },\n * }))\n * ```\n * @param optionsFactory - Creates the persistence options in the browser.\n * @returns A set of providers for use with `provideTanStackQuery`.\n * @public\n */\nexport function withPersistQueryClient(\n optionsFactory: WithPersistQueryClientFn,\n): QueryFeature {\n return queryFeature(\n makeEnvironmentProviders([\n { provide: RESTORING_STATE, useFactory: () => signal(true) },\n provideIsRestoring(() => inject(RESTORING_STATE).asReadonly()),\n provideEnvironmentInitializer(() => {\n const isRestoring = inject(RESTORING_STATE)\n if (!isPlatformBrowser(inject(PLATFORM_ID))) {\n isRestoring.set(false)\n return\n }\n const destroyRef = inject(DestroyRef)\n const queryClient = inject(QueryClient)\n\n const { onSuccess, onError, persistOptions } = optionsFactory()\n const options = { queryClient, ...persistOptions }\n void persistQueryClientRestore(options)\n .then(() => {\n return onSuccess?.()\n })\n .catch(() => {\n return onError?.()\n })\n .finally(() => {\n if (destroyRef.destroyed) return\n isRestoring.set(false)\n const cleanup = persistQueryClientSubscribe(options)\n destroyRef.onDestroy(cleanup)\n })\n }),\n ]),\n )\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,kBAAkB,IAAI,eAC1B,yBACF;;;;;;;;;;;;;;;;;AAuBA,SAAgB,uBACd,gBACc;CACd,OAAO,aACL,yBAAyB;EACvB;GAAE,SAAS;GAAiB,kBAAkB,OAAO,IAAI;EAAE;EAC3D,yBAAyB,OAAO,eAAe,CAAC,CAAC,WAAW,CAAC;EAC7D,oCAAoC;GAClC,MAAM,cAAc,OAAO,eAAe;GAC1C,IAAI,CAAC,kBAAkB,OAAO,WAAW,CAAC,GAAG;IAC3C,YAAY,IAAI,KAAK;IACrB;GACF;GACA,MAAM,aAAa,OAAO,UAAU;GACpC,MAAM,cAAc,OAAO,WAAW;GAEtC,MAAM,EAAE,WAAW,SAAS,mBAAmB,eAAe;GAC9D,MAAM,UAAU;IAAE;IAAa,GAAG;GAAe;GACjD,0BAA+B,OAAO,CAAC,CACpC,WAAW;IACV,OAAO,YAAY;GACrB,CAAC,CAAC,CACD,YAAY;IACX,OAAO,UAAU;GACnB,CAAC,CAAC,CACD,cAAc;IACb,IAAI,WAAW,WAAW;IAC1B,YAAY,IAAI,KAAK;IACrB,MAAM,UAAU,4BAA4B,OAAO;IACnD,WAAW,UAAU,OAAO;GAC9B,CAAC;EACL,CAAC;CACH,CAAC,CACH;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/angular-query-persist-client",
3
- "version": "5.0.0-rc.5",
3
+ "version": "5.0.0",
4
4
  "description": "Angular bindings to work with persisters in TanStack/angular-query",
5
5
  "author": "Omer Gronich",
6
6
  "license": "MIT",
@@ -33,19 +33,19 @@
33
33
  "!src/__tests__"
34
34
  ],
35
35
  "dependencies": {
36
- "@tanstack/query-persist-client-core": "5.104.3"
36
+ "@tanstack/query-persist-client-core": "5.107.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@analogjs/vite-plugin-angular": "^2.3.1",
40
- "@angular/common": "^22.0.0",
41
- "@angular/compiler": "^22.0.0",
42
- "@angular/core": "^22.0.0",
43
- "@angular/platform-browser": "^22.0.0",
44
- "@angular/router": "^22.0.0",
39
+ "@analogjs/vite-plugin-angular": "^2.7.5",
40
+ "@angular/common": "^22.2.4",
41
+ "@angular/compiler": "^22.2.4",
42
+ "@angular/core": "^22.2.4",
43
+ "@angular/platform-browser": "^22.2.4",
44
+ "@angular/router": "^22.2.4",
45
45
  "@oxc-project/runtime": "^0.151.0",
46
- "@tanstack/angular-query": "5.0.0-rc.5",
46
+ "@tanstack/angular-query": "5.0.0",
47
47
  "@tanstack/query-test-utils": "0.0.0",
48
- "@testing-library/angular": "^18.1.1",
48
+ "@testing-library/angular": "^19.6.0",
49
49
  "@testing-library/dom": "^10.4.0",
50
50
  "npm-run-all2": "^9.0.3",
51
51
  "typescript": "6.0.3",
@@ -54,7 +54,7 @@
54
54
  "peerDependencies": {
55
55
  "@angular/common": ">=20.1.0",
56
56
  "@angular/core": ">=20.1.0",
57
- "@tanstack/angular-query": "^5.0.0-rc.5"
57
+ "@tanstack/angular-query": "^5.0.0"
58
58
  },
59
59
  "scripts": {
60
60
  "clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
package/src/index.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  // Re-export core
2
+ // oxlint-disable-next-line tanstack-query/no-restricted-syntax
2
3
  export * from '@tanstack/query-persist-client-core'
3
4
 
4
- export * from './with-persist-query-client'
5
+ export type {
6
+ PersistQueryClientUserOptions,
7
+ WithPersistQueryClientFn,
8
+ } from './with-persist-query-client'
9
+ export { withPersistQueryClient } from './with-persist-query-client'
@@ -1,4 +1,4 @@
1
- import { QueryClient } from '@tanstack/angular-query'
1
+ import { isPlatformBrowser } from '@angular/common'
2
2
  import {
3
3
  DestroyRef,
4
4
  InjectionToken,
@@ -8,11 +8,11 @@ import {
8
8
  provideEnvironmentInitializer,
9
9
  signal,
10
10
  } from '@angular/core'
11
+ import { QueryClient } from '@tanstack/angular-query'
11
12
  import {
12
13
  provideIsRestoring,
13
14
  queryFeature,
14
15
  } from '@tanstack/angular-query/internal'
15
- import { isPlatformBrowser } from '@angular/common'
16
16
  import {
17
17
  persistQueryClientRestore,
18
18
  persistQueryClientSubscribe,