@tanstack/angular-query-persist-client 5.0.0-rc.4 → 5.0.0-rc.5
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
|
@@ -2,7 +2,13 @@ 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
4
|
//#region src/with-persist-query-client.types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Configures cache persistence and callbacks for completion of the initial restoration.
|
|
7
|
+
*/
|
|
5
8
|
type PersistQueryClientUserOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Persistence storage and lifecycle settings; the client is supplied by the Query provider.
|
|
11
|
+
*/
|
|
6
12
|
persistOptions: Omit<PersistQueryClientOptions, 'queryClient'>;
|
|
7
13
|
/** Called after restoration succeeds. A returned promise is awaited. */
|
|
8
14
|
onSuccess?: () => unknown;
|
|
@@ -28,12 +34,11 @@ type WithPersistQueryClientFn = () => PersistQueryClientUserOptions;
|
|
|
28
34
|
* },
|
|
29
35
|
* }))
|
|
30
36
|
* ```
|
|
31
|
-
*
|
|
32
37
|
* @param optionsFactory - Creates the persistence options in the browser.
|
|
33
38
|
* @returns A set of providers for use with `provideTanStackQuery`.
|
|
34
39
|
* @public
|
|
35
40
|
*/
|
|
36
|
-
declare function withPersistQueryClient(optionsFactory: WithPersistQueryClientFn): QueryFeature;
|
|
41
|
+
export declare function withPersistQueryClient(optionsFactory: WithPersistQueryClientFn): QueryFeature;
|
|
37
42
|
//#endregion
|
|
38
|
-
export {
|
|
43
|
+
export type { PersistQueryClientUserOptions, WithPersistQueryClientFn };
|
|
39
44
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/with-persist-query-client.types.ts","../src/with-persist-query-client.ts"],"mappings":";;;;
|
|
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
package/build/index.mjs.map
CHANGED
|
@@ -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
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/angular-query-persist-client",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.5",
|
|
4
4
|
"description": "Angular bindings to work with persisters in TanStack/angular-query",
|
|
5
5
|
"author": "Omer Gronich",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,43 +33,39 @@
|
|
|
33
33
|
"!src/__tests__"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tanstack/query-persist-client-core": "5.
|
|
36
|
+
"@tanstack/query-persist-client-core": "5.104.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@analogjs/vite-plugin-angular": "^2.3.1",
|
|
39
40
|
"@angular/common": "^22.0.0",
|
|
40
41
|
"@angular/compiler": "^22.0.0",
|
|
41
42
|
"@angular/core": "^22.0.0",
|
|
42
43
|
"@angular/platform-browser": "^22.0.0",
|
|
43
44
|
"@angular/router": "^22.0.0",
|
|
45
|
+
"@oxc-project/runtime": "^0.151.0",
|
|
46
|
+
"@tanstack/angular-query": "5.0.0-rc.5",
|
|
47
|
+
"@tanstack/query-test-utils": "0.0.0",
|
|
44
48
|
"@testing-library/angular": "^18.1.1",
|
|
45
49
|
"@testing-library/dom": "^10.4.0",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"zone.js": "^0.16.0",
|
|
50
|
-
"@tanstack/angular-query": "5.0.0-rc.4",
|
|
51
|
-
"@tanstack/query-test-utils": "0.0.0"
|
|
50
|
+
"npm-run-all2": "^9.0.3",
|
|
51
|
+
"typescript": "6.0.3",
|
|
52
|
+
"zone.js": "^0.16.0"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"@angular/common": ">=20.1.0",
|
|
55
56
|
"@angular/core": ">=20.1.0",
|
|
56
|
-
"@tanstack/angular-query": "^5.0.0-rc.
|
|
57
|
+
"@tanstack/angular-query": "^5.0.0-rc.5"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
|
|
60
61
|
"compile": "tsc --project tsconfig.json",
|
|
61
|
-
"test:eslint": "eslint --concurrency=auto ./src",
|
|
62
62
|
"test:types": "npm-run-all --serial test:types:*",
|
|
63
|
-
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts56 --tsBuildInfoFile .cache/test-types/ts56.tsbuildinfo",
|
|
64
|
-
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts57 --tsBuildInfoFile .cache/test-types/ts57.tsbuildinfo",
|
|
65
|
-
"test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts58 --tsBuildInfoFile .cache/test-types/ts58.tsbuildinfo",
|
|
66
|
-
"test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts59 --tsBuildInfoFile .cache/test-types/ts59.tsbuildinfo",
|
|
67
63
|
"test:types:tscurrent": "tsc --project tsconfig.json --outDir .cache/test-types/tscurrent --tsBuildInfoFile .cache/test-types/tscurrent.tsbuildinfo",
|
|
68
|
-
"test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --project tsconfig.json --outDir .cache/test-types/ts70 --tsBuildInfoFile .cache/test-types/ts70.tsbuildinfo",
|
|
69
64
|
"test:lib": "vitest",
|
|
70
65
|
"test:lib:dev": "pnpm run test:lib --watch",
|
|
71
66
|
"test:build": "publint --strict && attw --pack",
|
|
72
67
|
"build": "pnpm build:tsdown",
|
|
73
|
-
"build:tsdown": "tsdown --tsconfig tsconfig.prod.json"
|
|
68
|
+
"build:tsdown": "tsdown --tsconfig tsconfig.prod.json",
|
|
69
|
+
"test:oxlint": "oxlint ./src"
|
|
74
70
|
}
|
|
75
71
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { PersistQueryClientOptions as PersistQueryClientOptionsCore } from '@tanstack/query-persist-client-core'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Configures cache persistence and callbacks for completion of the initial restoration.
|
|
5
|
+
*/
|
|
3
6
|
export type PersistQueryClientUserOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Persistence storage and lifecycle settings; the client is supplied by the Query provider.
|
|
9
|
+
*/
|
|
4
10
|
persistOptions: Omit<PersistQueryClientOptionsCore, 'queryClient'>
|
|
5
11
|
/** Called after restoration succeeds. A returned promise is awaited. */
|
|
6
12
|
onSuccess?: () => unknown
|