@tanstack/angular-query-persist-client 5.0.0 → 5.108.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/build/index.d.ts CHANGED
@@ -25,13 +25,22 @@ type WithPersistQueryClientFn = () => PersistQueryClientUserOptions;
25
25
  * browser APIs such as `localStorage`.
26
26
  *
27
27
  * ```ts
28
- * withPersistQueryClient(() => ({
29
- * persistOptions: {
30
- * persister: createAsyncStoragePersister({ storage: localStorage }),
31
- * },
32
- * }))
28
+ * export const appConfig: ApplicationConfig = {
29
+ * providers: [
30
+ * provideTanStackQuery(
31
+ * () => new QueryClient(),
32
+ * withPersistQueryClient(() => ({
33
+ * persistOptions: {
34
+ * persister: createAsyncStoragePersister({ storage: localStorage }),
35
+ * },
36
+ * onSuccess: () => console.log('Restoration completed successfully.'),
37
+ * })),
38
+ * ),
39
+ * ],
40
+ * }
33
41
  * ```
34
- * @param optionsFactory - Creates the persistence options in the browser.
42
+ * @param optionsFactory - Creates the persistence options in the browser, and optional `onSuccess` and
43
+ * `onError` callbacks which get called when the restoration process is complete.
35
44
  * @returns A set of providers for use with `provideTanStackQuery`.
36
45
  * @public
37
46
  */
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;wBCqC7B,uBACd,gBAAgB,2BACf"}
package/build/index.mjs CHANGED
@@ -12,13 +12,22 @@ const RESTORING_STATE = new InjectionToken("Query restoration state");
12
12
  * browser APIs such as `localStorage`.
13
13
  *
14
14
  * ```ts
15
- * withPersistQueryClient(() => ({
16
- * persistOptions: {
17
- * persister: createAsyncStoragePersister({ storage: localStorage }),
18
- * },
19
- * }))
15
+ * export const appConfig: ApplicationConfig = {
16
+ * providers: [
17
+ * provideTanStackQuery(
18
+ * () => new QueryClient(),
19
+ * withPersistQueryClient(() => ({
20
+ * persistOptions: {
21
+ * persister: createAsyncStoragePersister({ storage: localStorage }),
22
+ * },
23
+ * onSuccess: () => console.log('Restoration completed successfully.'),
24
+ * })),
25
+ * ),
26
+ * ],
27
+ * }
20
28
  * ```
21
- * @param optionsFactory - Creates the persistence options in the browser.
29
+ * @param optionsFactory - Creates the persistence options in the browser, and optional `onSuccess` and
30
+ * `onError` callbacks which get called when the restoration process is complete.
22
31
  * @returns A set of providers for use with `provideTanStackQuery`.
23
32
  * @public
24
33
  */
@@ -1 +1 @@
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"}
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 * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideTanStackQuery(\n * () => new QueryClient(),\n * withPersistQueryClient(() => ({\n * persistOptions: {\n * persister: createAsyncStoragePersister({ storage: localStorage }),\n * },\n * onSuccess: () => console.log('Restoration completed successfully.'),\n * })),\n * ),\n * ],\n * }\n * ```\n * @param optionsFactory - Creates the persistence options in the browser, and optional `onSuccess` and\n * `onError` callbacks which get called when the restoration process is complete.\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;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,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",
3
+ "version": "5.108.0",
4
4
  "description": "Angular bindings to work with persisters in TanStack/angular-query",
5
5
  "author": "Omer Gronich",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "!src/__tests__"
34
34
  ],
35
35
  "dependencies": {
36
- "@tanstack/query-persist-client-core": "5.107.2"
36
+ "@tanstack/query-persist-client-core": "5.108.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@analogjs/vite-plugin-angular": "^2.7.5",
@@ -43,7 +43,7 @@
43
43
  "@angular/platform-browser": "^22.2.4",
44
44
  "@angular/router": "^22.2.4",
45
45
  "@oxc-project/runtime": "^0.151.0",
46
- "@tanstack/angular-query": "5.0.0",
46
+ "@tanstack/angular-query": "5.108.0",
47
47
  "@tanstack/query-test-utils": "0.0.0",
48
48
  "@testing-library/angular": "^19.6.0",
49
49
  "@testing-library/dom": "^10.4.0",
@@ -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"
57
+ "@tanstack/angular-query": "^5.108.0"
58
58
  },
59
59
  "scripts": {
60
60
  "clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
@@ -36,13 +36,22 @@ export type {
36
36
  * browser APIs such as `localStorage`.
37
37
  *
38
38
  * ```ts
39
- * withPersistQueryClient(() => ({
40
- * persistOptions: {
41
- * persister: createAsyncStoragePersister({ storage: localStorage }),
42
- * },
43
- * }))
39
+ * export const appConfig: ApplicationConfig = {
40
+ * providers: [
41
+ * provideTanStackQuery(
42
+ * () => new QueryClient(),
43
+ * withPersistQueryClient(() => ({
44
+ * persistOptions: {
45
+ * persister: createAsyncStoragePersister({ storage: localStorage }),
46
+ * },
47
+ * onSuccess: () => console.log('Restoration completed successfully.'),
48
+ * })),
49
+ * ),
50
+ * ],
51
+ * }
44
52
  * ```
45
- * @param optionsFactory - Creates the persistence options in the browser.
53
+ * @param optionsFactory - Creates the persistence options in the browser, and optional `onSuccess` and
54
+ * `onError` callbacks which get called when the restoration process is complete.
46
55
  * @returns A set of providers for use with `provideTanStackQuery`.
47
56
  * @public
48
57
  */